Commits

vg  committed 6db5728

CWS-TOOLING: integrate CWS fwk123
2009-10-14 10:18:49 +0200 cd r276885 : #i99971# Use AttachThreadInput to force SetForegroundWindow
2009-10-14 08:56:20 +0200 mav r276881 : #i105476# let the allocated memory live long anough
2009-10-14 08:53:51 +0200 mav r276880 : #i105476# let ZipFile use mutex while creating the requested stream
2009-10-14 08:51:52 +0200 mav r276879 : #i105476# let buffered IO use mutex ( patch from MHU )
2009-10-09 12:20:22 +0200 cd r276803 : #i99971# Use configuration to control window to front/focus handling
2009-10-09 12:19:22 +0200 cd r276802 : #i99971# New configuration item to force set focus and window to front for new document windows
2009-10-09 12:18:23 +0200 cd r276801 : #i99971# Introduction of a new show flag to force window to front
2009-10-06 11:04:16 +0200 ab r276695 : #i105386# Call xmlInitParser() before registering input callbacks

  • Participants
  • Parent commits a33ee9e

Comments (0)

Files changed (14)

File framework/source/helper/statusindicatorfactory.cxx

 // includes of other projects
 #include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/mediadescriptor.hxx>
+#include <comphelper/configurationhelper.hxx>
 #include <vcl/svapp.hxx>
 #include <vos/mutex.hxx>
 
 
     css::uno::Reference< css::frame::XFrame > xFrame      (m_xFrame.get()      , css::uno::UNO_QUERY);
     css::uno::Reference< css::awt::XWindow >  xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
+    css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR.get(), css::uno::UNO_QUERY);
 
     aReadLock.unlock();
     // <- SAFE ----------------------------------
     // is visible too.
     impl_showProgress();
 
-    if (xParentWindow.is())
-        xParentWindow->setVisible(sal_True);
+    ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex());
+    Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow);
+    if ( pWindow )
+    {
+        bool bForceFrontAndFocus(false);
+        ::comphelper::ConfigurationHelper::readDirectKey(
+            xSMGR,
+            ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/View"),
+            ::rtl::OUString::createFromAscii("NewDocumentHandling"),
+            ::rtl::OUString::createFromAscii("ForceFocusAndToFront"),
+            ::comphelper::ConfigurationHelper::E_READONLY) >>= bForceFrontAndFocus;
+
+        pWindow->Show(sal_True, bForceFrontAndFocus ? SHOW_FOREGROUNDTASK : 0 );
+    }
+
     /*
     #i75167# dont disturb window manager handling .-)
     css::uno::Reference< css::awt::XTopWindow > xParentWindowTop(xParentWindow, css::uno::UNO_QUERY);

File framework/source/loadenv/loadenv.cxx

 void LoadEnv::impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow      ,
                                                 sal_Bool bForceToFront)            
 {
-    css::uno::Reference< css::awt::XTopWindow > xTopWindow(xWindow, css::uno::UNO_QUERY);
+    // SAFE -> ----------------------------------
+    ReadGuard aReadLock(m_aLock);
+    css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR.get(), css::uno::UNO_QUERY );
+    aReadLock.unlock();
+    // <- SAFE ----------------------------------
 
-    if (xWindow.is())
-        xWindow->setVisible(sal_True);
+    ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex());
+    Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
+    if ( pWindow )
+    {
+        bool bForceFrontAndFocus(false);
+        css::uno::Any a = ::comphelper::ConfigurationHelper::readDirectKey(
+            xSMGR,
+            ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/View"),
+            ::rtl::OUString::createFromAscii("NewDocumentHandling"),
+            ::rtl::OUString::createFromAscii("ForceFocusAndToFront"),
+            ::comphelper::ConfigurationHelper::E_READONLY);
+        a >>= bForceFrontAndFocus;
 
-    if (xTopWindow.is() && bForceToFront)
-        xTopWindow->toFront();
-
+        pWindow->Show(sal_True, (bForceFrontAndFocus || bForceToFront) ? SHOW_FOREGROUNDTASK : 0 );
+    }
+    
 /* #i19976#
     We tried to prevent a toFront() call in case the user putted the
     loading document into the background ..

File officecfg/registry/schema/org/openoffice/Office/Common.xcs

 				</info>
 			</set>
 		</group>
-        <group oor:name="Save">
+    <group oor:name="Save">
 			<info>
 				<author>MBA</author>
 				<desc>Contains general settings about the saving process.</desc>
 				</constraints>
 				<value>0</value>
 			</prop>
+			<group oor:name="NewDocumentHandling">
+				<info>
+					<author>CD</author>
+					<desc>Contains settings to change new document window behavior.</desc>
+				</info>
+				<prop oor:name="ForceFocusAndToFront" oor:type="xs:boolean">
+					<info>
+						<author>CD</author>
+						<desc>Every new document window will be forced to front and grabs the focus.</desc>
+					</info>
+					<value>true</value>
+				</prop>
+			</group>
 			<group oor:name="AppWindow">
 				<info>
 					<author>MBA</author>

File package/inc/ByteGrabber.hxx

 #include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 
+#include <osl/mutex.hxx>
+
 namespace com { namespace sun { namespace star {
 	namespace io { class XSeekable; class XInputStream; }
 } } }
 class ByteGrabber 
 {
 protected:
+    ::osl::Mutex m_aMutex;
+
 	com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
 	com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
 	com::sun::star::uno::Sequence < sal_Int8 > aSequence;

File package/inc/ZipFile.hxx

 class ZipFile
 {
 protected:
+    ::osl::Mutex    m_aMutex;
+
     ::rtl::OUString	sComment; 	  	/* zip file comment */
 	EntryHash		aEntries;
 	ByteGrabber 	aGrabber;

File package/source/zipapi/ByteGrabber.cxx

 ByteGrabber::~ByteGrabber()
 {
 }
+
 void ByteGrabber::setInputStream (uno::Reference < io::XInputStream > xNewStream)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	xStream = xNewStream;
 	xSeek = uno::Reference < io::XSeekable > (xNewStream, uno::UNO_QUERY);
 }
 										sal_Int32 nBytesToRead ) 
 	throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	return xStream->readBytes(aData, nBytesToRead );
 }
 
 sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location ) 
 	throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	if (xSeek.is() )
 	{
 		sal_Int64 nLen = xSeek->getLength();
 	else
 		throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
 }
+
 sal_Int64 SAL_CALL ByteGrabber::getPosition(  ) 
 		throw(io::IOException, uno::RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	if (xSeek.is() )
 		return xSeek->getPosition();
 	else
 		throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
 }
+
 sal_Int64 SAL_CALL ByteGrabber::getLength(  )
 		throw(io::IOException, uno::RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	if (xSeek.is() )
 		return xSeek->getLength();
 	else
 		throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
 }
+
 ByteGrabber& ByteGrabber::operator >> (sal_Int8& rInt8)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	if (xStream->readBytes(aSequence,1) != 1)
 		rInt8 = 0;
 	else
 		rInt8 = aSequence[0] & 0xFF;
 	return *this;
 }
+
 ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
 	if (xStream->readBytes ( aSequence, 2) != 2)
 		rInt16 = 0;
 	else
 	}
 	return *this;
 }
+
 ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if (xStream->readBytes(aSequence, 4) != 4)
 		rInt32 = 0;
 	else
 
 ByteGrabber& ByteGrabber::operator >> (sal_uInt8& rInt8)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if (xStream->readBytes(aSequence,1) != 1)
 		rInt8 = 0;
 	else
 }
 ByteGrabber& ByteGrabber::operator >> (sal_uInt16& rInt16)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if (xStream->readBytes(aSequence, 2) != 2)
 		rInt16 = 0;
 	else
 }
 ByteGrabber& ByteGrabber::operator >> (sal_uInt32& ruInt32)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if (xStream->readBytes(aSequence, 4) != 4)
 		ruInt32 = 0;
 	else

File package/source/zipapi/ZipFile.cxx

 
 void ZipFile::setInputStream ( Reference < XInputStream > xNewStream )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	xStream = xNewStream;
 	xSeek = Reference < XSeekable > ( xStream, UNO_QUERY );
 	aGrabber.setInputStream ( xStream );
 
 sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ORef < EncryptionData > &rData )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	sal_Bool bRet = sal_False;
 	if ( rData->aKey.getLength() )
 	{
 			sal_Bool bIsEncrypted,
 			::rtl::OUString aMediaType )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	return new XUnbufferedStream ( aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
 }
 
         SotMutexHolderRef aMutexHolder )
 	throw(IOException, ZipException, RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if ( rEntry.nOffset <= 0 )
 		readLOC( rEntry );
 
 			ZipException,
 			RuntimeException )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if ( rEntry.nOffset <= 0 )
 		readLOC( rEntry );
 
         SotMutexHolderRef aMutexHolder )
 	throw(IOException, ZipException, RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if ( rEntry.nOffset <= 0 )
 		readLOC( rEntry );
 
 			ZipException,
 			RuntimeException )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	if ( rData.isEmpty() )
 		throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
 
 sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
 	throw(IOException, ZipException, RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	sal_Int32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
 	sal_Int16 nVersion, nFlag, nHow, nPathLen, nExtraLen;
 	sal_Int32 nPos = -rEntry.nOffset;
 sal_Int32 ZipFile::findEND( )
 	throw(IOException, ZipException, RuntimeException)
 {
+    // this method is called in constructor only, no need for mutex
 	sal_Int32 nLength, nPos, nEnd;
 	Sequence < sal_Int8 > aBuffer;
 	try
 sal_Int32 ZipFile::readCEN()
 	throw(IOException, ZipException, RuntimeException)
 {
+    // this method is called in constructor only, no need for mutex
 	sal_Int32 nCenLen, nCenPos = -1, nCenOff, nEndPos, nLocPos;
 	sal_uInt16 nCount, nTotal;
 
 sal_Int32 ZipFile::recover()
 	throw(IOException, ZipException, RuntimeException)
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	sal_Int32 nLength;
 	Sequence < sal_Int8 > aBuffer;
 	Sequence < sal_Int32 > aHeaderOffsets;
 
 sal_Bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	sal_Int32 nSize = 0, nCRC = 0;
 
 	if( aEntry.nMethod == STORED )
 
 sal_Int32 ZipFile::getCRC( sal_Int32 nOffset, sal_Int32 nSize )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	Sequence < sal_Int8 > aBuffer;
 	CRC32 aCRC;
 	sal_Int32 nBlockSize = ::std::min( nSize, static_cast< sal_Int32 >( 32000 ) );
 
 void ZipFile::getSizeAndCRC( sal_Int32 nOffset, sal_Int32 nCompressedSize, sal_Int32 *nSize, sal_Int32 *nCRC )
 {
+    ::osl::MutexGuard aGuard( m_aMutex );
+
 	Sequence < sal_Int8 > aBuffer;
 	CRC32 aCRC;
 	sal_Int32 nRealSize = 0;

File sal/osl/unx/file.cxx

 #include <limits>
 
 #include <string.h>
+#include <pthread.h>
 #include <sys/mman.h>
 
 #if defined(MACOSX)
  ******************************************************************/
 struct FileHandle_Impl
 {
-    rtl_String * m_strFilePath; /* holds native file path */
-    int          m_fd;
+    pthread_mutex_t m_mutex;
+    rtl_String *    m_strFilePath; /* holds native file path */
+    int             m_fd;
 
     /** State
      */
         Allocator();
         ~Allocator();
     };
+
+    /** Guard.
+     */
+    class Guard
+    {
+        pthread_mutex_t * m_mutex;
+
+    public:
+        explicit Guard(pthread_mutex_t * pMutex);
+        ~Guard();
+    };
 };
 
 /*******************************************************************
         rtl_cache_free (m_cache, pBuffer);
 }
 
+FileHandle_Impl::Guard::Guard(pthread_mutex_t * pMutex)
+    : m_mutex (pMutex)
+{
+    OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer.");
+    (void) pthread_mutex_lock (m_mutex); // ignoring EINVAL ...
+}
+FileHandle_Impl::Guard::~Guard()
+{
+    OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer.");
+    (void) pthread_mutex_unlock (m_mutex);
+}
+
 FileHandle_Impl::FileHandle_Impl (int fd, char const * path)
     : m_strFilePath (0),
       m_fd      (fd),
       m_bufsiz  (0),
       m_buffer  (0)
 {
+    (void) pthread_mutex_init(&m_mutex, 0);
     rtl_string_newFromStr (&m_strFilePath, path);
     Allocator::get().allocate (&m_buffer, &m_bufsiz);
     if (0 != m_buffer)
 {
     Allocator::get().deallocate (m_buffer), m_buffer = 0;
     rtl_string_release (m_strFilePath), m_strFilePath = 0;
+    (void) pthread_mutex_destroy(&m_mutex); // ignoring EBUSY ...
 }
 
 void* FileHandle_Impl::operator new (size_t n)
     if ((pImpl == 0) || (pImpl->m_fd < 0))
         return osl_File_E_INVAL;
 
+    (void) pthread_mutex_lock (&(pImpl->m_mutex));
+
     /* close(2) implicitly (and unconditionally) unlocks */
     OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath));
     oslFileError result = pImpl->syncFile();
         result = oslTranslateFileError (OSL_FET_ERROR, errno);
     }
 
+    (void) pthread_mutex_unlock (&(pImpl->m_mutex));
     delete pImpl;
     return (result);
 }
     if ((0 == pImpl) || (-1 == pImpl->m_fd))
         return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
+
     OSL_FILE_TRACE("osl_syncFile(%d)", pImpl->m_fd);
     oslFileError result = pImpl->syncFile();
     if (result != osl_File_E_None)
     sal_uInt64 uBytesRead = 0;
 
     // read at current fileptr; fileptr += uBytesRead;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     oslFileError result = pImpl->readLineAt (
         pImpl->m_fileptr, ppSequence, &uBytesRead);
     if (result == osl_File_E_None)
 	size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested);
 
     // read at current fileptr; fileptr += *pBytesRead;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     oslFileError result = pImpl->readFileAt (
         pImpl->m_fileptr, pBuffer, nBytesRequested, pBytesRead);
     if (result == osl_File_E_None)
 	size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite);
 
     // write at current fileptr; fileptr += *pBytesWritten;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     oslFileError result = pImpl->writeFileAt (
         pImpl->m_fileptr, pBuffer, nBytesToWrite, pBytesWritten);
     if (result == osl_File_E_None)
 	size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested);
 
     // read at specified fileptr
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     return pImpl->readFileAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
 }
 
 	size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite);
 
     // write at specified fileptr
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     return pImpl->writeFileAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten);
 }
 
     if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pIsEOF))
         return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     *pIsEOF = (pImpl->getPos() == pImpl->getSize());
     return osl_File_E_None;
 }
     if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pPos))
         return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     *pPos = pImpl->getPos();
     return osl_File_E_None;
 }
 		return osl_File_E_OVERFLOW;
 	off_t nPos = 0, nOffset = sal::static_int_cast< off_t >(uOffset);
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     switch(uHow)
     {
         case osl_Pos_Absolut:
     if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pSize))
         return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     *pSize = pImpl->getSize();
     return osl_File_E_None;
 }

File sal/osl/w32/file.cxx

 //##################################################################
 struct FileHandle_Impl
 {
-    HANDLE m_hFile;
+    CRITICAL_SECTION m_mutex;
+    HANDLE           m_hFile;
 
 	/** State
 	 */
 		Allocator();
 		~Allocator();
 	};
+
+    /** Guard.
+     */
+    class Guard
+    {
+        LPCRITICAL_SECTION m_mutex;
+
+    public:
+        explicit Guard(LPCRITICAL_SECTION pMutex);
+        ~Guard();
+    };
 };
 
 FileHandle_Impl::Allocator &
 		rtl_cache_free (m_cache, pBuffer);
 }
 
+FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex)
+    : m_mutex (pMutex)
+{
+    OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer.");
+    ::EnterCriticalSection (m_mutex);
+}
+FileHandle_Impl::Guard::~Guard()
+{
+    OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer.");
+    ::LeaveCriticalSection (m_mutex);
+}
+
 FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
 	: m_hFile   (hFile),
 	  m_state   (STATE_READABLE | STATE_WRITEABLE),
 	  m_bufsiz  (0),
 	  m_buffer  (0)
 {
+    ::InitializeCriticalSection (&m_mutex);
 	Allocator::get().allocate (&m_buffer, &m_bufsiz);
 	if (m_buffer != 0)
 		memset (m_buffer, 0, m_bufsiz);
 FileHandle_Impl::~FileHandle_Impl()
 {
 	Allocator::get().deallocate (m_buffer), m_buffer = 0;
+    ::DeleteCriticalSection (&m_mutex);
 }
 
 void * FileHandle_Impl::operator new(size_t n)
 	if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
 		return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
+
 	oslFileError result = pImpl->syncFile();
 	if (result != osl_File_E_None)
 		return result;
 	if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
 		return osl_File_E_INVAL;
 
+    ::EnterCriticalSection (&(pImpl->m_mutex));
+
 	oslFileError result = pImpl->syncFile();
 	if (result != osl_File_E_None)
 	{
 		result = oslTranslateFileError( GetLastError() );
 	}
 
+    ::LeaveCriticalSection (&(pImpl->m_mutex));
 	delete pImpl;
 	return (result);
 }
 	sal_uInt64 uBytesRead = 0;
 
 	// read at current filepos; filepos += uBytesRead;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	oslFileError result = pImpl->readLineAt (
 		pImpl->m_filepos, ppSequence, &uBytesRead);
 	if (result == osl_File_E_None)
 		return osl_File_E_INVAL;
 
 	// read at current filepos; filepos += *pBytesRead;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	oslFileError result = pImpl->readFileAt (
 		pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead);
 	if (result == osl_File_E_None)
 		return osl_File_E_INVAL;
 
 	// write at current filepos; filepos += *pBytesWritten;
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	oslFileError result = pImpl->writeFileAt (
 		pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten);
 	if (result == osl_File_E_None)
 	LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset);
 
 	// read at specified fileptr
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	return pImpl->readFileAt (nOffset, pBuffer, uBytesRequested, pBytesRead);
 }
 
 	LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset);
 
 	// write at specified fileptr
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	return pImpl->writeFileAt (nOffset, pBuffer, uBytesToWrite, pBytesWritten);
 }
 
 	if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF))
 		return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	*pIsEOF = (pImpl->getPos() == pImpl->getSize());
 	return osl_File_E_None;
 }
 	if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos))
 		return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	*pPos = pImpl->getPos();
 	return osl_File_E_None;
 }
 		return osl_File_E_OVERFLOW;
 	LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset);
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	switch (uHow)
 	{
 		case osl_Pos_Absolut:
 	if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize))
 		return osl_File_E_INVAL;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
     *pSize = pImpl->getSize();
     return osl_File_E_None;
 }
 	if (g_limit_longlong < uSize)
 		return osl_File_E_OVERFLOW;
 
+    FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
 	oslFileError result = pImpl->syncFile();
 	if (result != osl_File_E_None)
 		return (result);

File vcl/inc/vcl/window.hxx

 #define SHOW_NOPARENTUPDATE             ((USHORT)0x0001)
 #define SHOW_NOFOCUSCHANGE              ((USHORT)0x0002)
 #define SHOW_NOACTIVATE                 ((USHORT)0x0004)
+#define SHOW_FOREGROUNDTASK             ((USHORT)0x0008)
 
 // Flags for SetZOrder()
 #define WINDOW_ZORDER_BEFOR             ((USHORT)0x0001)

File vcl/source/window/window.cxx

             // nach vorne, wenn es gewuenscht ist
             if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) )
             {
-                ImplStartToTop( 0 );
+                ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 );
                 ImplFocusToTop( 0, FALSE );
             }
 

File vcl/win/source/window/salframe.cxx

         BringWindowToTop( hWnd );
     
     if ( nFlags & SAL_FRAME_TOTOP_FOREGROUNDTASK )
-        SetForegroundWindow( hWnd );
+    {
+        // This magic code is necessary to connect the input focus of the
+        // current window thread and the thread which owns the window that
+        // should be the new foreground window.
+        HWND   hCurrWnd     = GetForegroundWindow();
+        DWORD  myThreadID   = GetCurrentThreadId();
+        DWORD  currThreadID = GetWindowThreadProcessId(hCurrWnd,NULL);
+        AttachThreadInput(myThreadID, currThreadID,TRUE);
+        SetForegroundWindow(hWnd);
+        AttachThreadInput(myThreadID,currThreadID,FALSE);
+    }
 
     if ( nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN )
     {

File xmlhelp/source/cxxhelp/provider/databases.cxx

 
 	for( sal_uInt32 i = 0; i < id.size(); ++i )
 	{
+        // the following object must live longer than the
+        // pointer returned by aDBData.getData()
+        DBData aDBData;
+
 		listId[i] = id[i];
 		listAnchor[i] = anchor[i];
 
 			DBHelp* pDBHelp = pDb->getDBHelp();
 			if( pDBHelp != NULL )
 			{
-				DBData aDBData;
 				bool bSuccess = pDBHelp->getValueForKey( idi, aDBData );
 				if( bSuccess )
 				{

File xmlhelp/source/cxxhelp/provider/urlparameter.cxx

 
         ugblData = &userData;
 
+        xmlInitParser();
         xmlRegisterInputCallbacks(zipMatch, zipOpen, zipRead, uriClose);
         xmlRegisterInputCallbacks(helpMatch, helpOpen, helpRead, uriClose);
 		xmlRegisterInputCallbacks(fileMatch, fileOpen, fileRead, fileClose);