From 81fac0e0892167a5dd198360dbd9d35b0cef4f65 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 6 Nov 2008 22:56:12 +0000 Subject: removed unused headers --- automation/source/server/statemnt.cxx | 9 --------- 1 file changed, 9 deletions(-) (limited to 'automation') diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 9b1d747a0ec7..8d93ae46633e 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -91,16 +91,7 @@ #include #include #include -#ifndef _PRINT_HXX //autogen -#include -#endif -#ifndef _PRNDLG_HXX //autogen -#include -#endif #include -#ifndef _SV_DRAG_HXX //autogen -//#include -#endif #include #include #include -- cgit v1.2.3 From 5b16a85b74f89bd4a57304b00bb0ac084d61d67b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 20 Apr 2009 16:57:13 +0000 Subject: CWS-TOOLING: rebase CWS printerpullpages to trunk@270723 (milestone: DEV300:m46) --- automation/prj/d.lst | 1 + automation/util/manually_added_ids.hid | 15 + embedserv/source/embed/docholder.cxx | 12 + embedserv/source/embed/ed_ioleobject.cxx | 10 +- embedserv/source/inprocserv/advisesink.cxx | 15 + embedserv/source/inprocserv/advisesink.hxx | 1 + embedserv/source/inprocserv/dllentry.cxx | 65 +- embedserv/source/inprocserv/inprocembobj.cxx | 432 +++++++---- embedserv/source/inprocserv/inprocembobj.h | 3 +- embedserv/source/inprocserv/makefile.mk | 2 + embedserv/source/inprocserv/smartpointer.hxx | 16 + extensions/source/oooimprovecore/core.cxx | 19 +- extensions/source/oooimprovecore/makefile.mk | 6 +- extensions/source/plugin/aqua/macmgr.cxx | 658 ++++++++++++---- extensions/source/plugin/aqua/sysplug.cxx | 828 ++++++++++++++++++--- extensions/source/plugin/base/nfuncs.cxx | 116 ++- extensions/source/plugin/base/plcom.cxx | 11 + extensions/source/plugin/base/xplugin.cxx | 53 +- .../source/plugin/inc/plugin/aqua/sysplug.hxx | 160 ++-- extensions/source/plugin/inc/plugin/impl.hxx | 101 +-- extensions/source/plugin/inc/plugin/plcom.hxx | 5 + .../source/plugin/inc/plugin/unx/sysplug.hxx | 3 + .../source/plugin/inc/plugin/win/sysplug.hxx | 3 + extensions/source/plugin/util/makefile.pmk | 5 + .../setup/Controller/InstallationOngoingCtrl.java | 28 + .../Controller/UninstallationPrologueCtrl.java | 2 + .../org/openoffice/setup/InstallData.java | 63 ++ .../openoffice/setup/Installer/LinuxInstaller.java | 24 +- .../setup/Installer/SolarisInstaller.java | 48 +- .../setup/InstallerHelper/LinuxHelper.java | 17 + .../setup/InstallerHelper/SolarisHelper.java | 49 +- .../setup/SetupData/PackageDescription.java | 48 ++ .../setup/SetupData/ProductDescription.java | 12 +- .../org/openoffice/setup/Util/Dumper.java | 2 + .../org/openoffice/setup/Util/InfoDir.java | 29 + .../openoffice/setup/Util/InstallChangeCtrl.java | 7 + .../org/openoffice/setup/Util/ModuleCtrl.java | 84 ++- .../openoffice/setup/Util/PackageCollector.java | 57 ++ package/qa/storages/StorageUnitTest.java | 7 + package/qa/storages/Test17.java | 142 ++++ package/qa/storages/makefile.mk | 1 + package/source/xstor/owriteablestream.cxx | 71 +- package/source/zippackage/ZipPackageFolder.cxx | 4 +- setup_native/source/java/javaversion.dat | 26 +- setup_native/source/java/javaversion2.dat | 26 +- .../customactions/shellextensions/checkpatches.cxx | 1 + .../shellextensions/checkrunningoffice.cxx | 28 +- .../customactions/shellextensions/vistaspecial.cxx | 4 +- .../xmlsec/nss/securityenvironment_nssimpl.cxx | 33 +- 49 files changed, 2654 insertions(+), 699 deletions(-) create mode 100755 automation/util/manually_added_ids.hid create mode 100644 package/qa/storages/Test17.java (limited to 'automation') diff --git a/automation/prj/d.lst b/automation/prj/d.lst index 6e99d47f420c..c83a2284e34b 100644 --- a/automation/prj/d.lst +++ b/automation/prj/d.lst @@ -2,6 +2,7 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid mkdir: %_DEST%\inc%_EXT%\automation #..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid +..\util\manually_added_ids.hid %COMMON_DEST%\bin%_EXT%\hid\manually_added_ids.hid ..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll ..\%__SRC%\lib\lib* %_DEST%\lib%_EXT%\* ..\%__SRC%\lib\ists.lib %_DEST%\lib%_EXT%\ists.lib diff --git a/automation/util/manually_added_ids.hid b/automation/util/manually_added_ids.hid new file mode 100755 index 000000000000..e9fdb24f9793 --- /dev/null +++ b/automation/util/manually_added_ids.hid @@ -0,0 +1,15 @@ + +HDE_PDF_EXPORT_DLG 33375 + +MSC_Super_ID 123456 +MSC_Super_ID2 1234567 +MSC_Super_ID3 12345678 + +HID_OPTIONS_JAVA_LIST 39997 + +PDF1TBO 867876864 +PDF2TBO 867860480 + +FontWork1TBO 40026 +FontWork2TBO 40027 + diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index 1f7fe0a0500e..2e214a9c8a79 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -502,7 +502,17 @@ void DocumentHolder::InPlaceDeactivate(void) m_xLayoutManager->setVisible(false); if (NULL!=m_pIOleIPSite) + { + // The following workaround should let the object be stored in case of inplace editing +// CComPtr< IOleClientSite > pClientSite; +// +// m_pIOleIPSite->QueryInterface( +// IID_IOleClientSite, (void**)&pClientSite ); +// if ( pClientSite ) +// pClientSite->SaveObject(); + m_pIOleIPSite->OnInPlaceDeactivate(); + } if(m_pIOleIPFrame) m_pIOleIPFrame->Release(); m_pIOleIPFrame = 0; if(m_pIOleIPUIWindow) m_pIOleIPUIWindow->Release(); m_pIOleIPUIWindow = 0; @@ -512,7 +522,9 @@ void DocumentHolder::InPlaceDeactivate(void) { LockedEmbedDocument_Impl aDocLock = m_xOleAccess->GetEmbedDocument(); if ( aDocLock.GetEmbedDocument() ) + { aDocLock.GetEmbedDocument()->SaveObject(); + } } return; diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx index e17127d8adc6..07d172ef7173 100755 --- a/embedserv/source/embed/ed_ioleobject.cxx +++ b/embedserv/source/embed/ed_ioleobject.cxx @@ -159,6 +159,11 @@ STDMETHODIMP EmbedDocument_Impl::DoVerb( if ( m_bIsInVerbHandling ) return OLEOBJ_S_CANNOT_DOVERB_NOW; + // an object can not handle any Verbs in Hands off mode + if ( m_pMasterStorage == NULL || m_pOwnStream == NULL ) + return OLE_E_CANT_BINDTOSOURCE; + + BooleanGuard_Impl aGuard( m_bIsInVerbHandling ); if ( iVerb == OLEIVERB_PRIMARY ) @@ -260,8 +265,9 @@ STDMETHODIMP EmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** /*ppEnumOleVerb*/ ) STDMETHODIMP EmbedDocument_Impl::Update() { - HRESULT hr = CACHE_E_NOCACHE_UPDATED; - return hr; + return S_OK; +// HRESULT hr = CACHE_E_NOCACHE_UPDATED; +// return hr; } STDMETHODIMP EmbedDocument_Impl::IsUpToDate() diff --git a/embedserv/source/inprocserv/advisesink.cxx b/embedserv/source/inprocserv/advisesink.cxx index c65ba4dbe40e..ea61f866c372 100644 --- a/embedserv/source/inprocserv/advisesink.cxx +++ b/embedserv/source/inprocserv/advisesink.cxx @@ -146,31 +146,46 @@ STDMETHODIMP_(ULONG) OleWrapperAdviseSink::Release() STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( LPFORMATETC pFetc, LPSTGMEDIUM pMedium ) { if ( m_pListener ) + { + WRITEDEBUGINFO( "OleWrapperAdviseSink::OnDataChange():" ); m_pListener->OnDataChange( pFetc, pMedium ); + } } STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect, LONG lindex ) { if ( m_pListener ) + { + WRITEDEBUGINFO( "OleWrapperAdviseSink::OnViewChange():" ); m_pListener->OnViewChange( dwAspect, lindex ); + } } STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( LPMONIKER pMoniker ) { if ( m_pListener ) + { + WRITEDEBUGINFO( "OleWrapperAdviseSink::OnRename():" ); m_pListener->OnRename( pMoniker ); + } } STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave(void) { if ( m_pListener ) + { + WRITEDEBUGINFO( "OleWrapperAdviseSink::OnSave():" ); m_pListener->OnSave(); + } } STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose(void) { if ( m_pListener ) + { + WRITEDEBUGINFO( "OleWrapperAdviseSink::OnClose():" ); m_pListener->OnClose(); + } if ( m_bHandleClosed ) m_bClosed = TRUE; diff --git a/embedserv/source/inprocserv/advisesink.hxx b/embedserv/source/inprocserv/advisesink.hxx index 0f7ebbf25401..c7ef75d0c028 100644 --- a/embedserv/source/inprocserv/advisesink.hxx +++ b/embedserv/source/inprocserv/advisesink.hxx @@ -82,6 +82,7 @@ public: FORMATETC* GetFormatEtc() { return m_pFormatEtc; } DWORD GetAspect() { return m_nAspect; } ComSmart< IAdviseSink >& GetOrigAdvise() { return m_pListener; } + void DisconnectOrigAdvise() { m_pListener = NULL; } void SetClosed() { m_bClosed = TRUE; } void UnsetClosed() { m_bClosed = FALSE; } diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx index 1da88444e841..e8d327bc9e84 100644 --- a/embedserv/source/inprocserv/dllentry.cxx +++ b/embedserv/source/inprocserv/dllentry.cxx @@ -59,29 +59,44 @@ static ULONG g_nLock = 0; namespace { + void FillCharFromInt( int nValue, char* pBuf, int nLen ) + { + int nInd = 0; + while( nInd < nLen ) + { + char nSign = ( nValue / ( 1 << ( ( nLen - nInd ) * 4 ) ) ) % 16; + if ( nSign >= 0 && nSign <= 9 ) + pBuf[nInd] = nSign + '0'; + else if ( nSign >= 10 && nSign <= 15 ) + pBuf[nInd] = nSign - 10 + 'a'; + + nInd++; + } + } + int GetStringFromClassID( const GUID& guid, char* pBuf, int nLen ) { - if ( nLen < 27 ) + // is not allowed to insert + if ( nLen < 38 ) return 0; - int nResult = sprintf( pBuf, - "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - guid.Data1, - guid.Data2, - guid.Data3, - guid.Data4[0], - guid.Data4[1], - guid.Data4[2], - guid.Data4[3], - guid.Data4[4], - guid.Data4[5], - guid.Data4[6], - guid.Data4[7] ); - - if ( nResult && nResult < nLen ) - return ++nResult; - - return 0; + pBuf[0] = '{'; + FillCharFromInt( guid.Data1, &pBuf[1], 8 ); + pBuf[9] = '-'; + FillCharFromInt( guid.Data2, &pBuf[10], 4 ); + pBuf[14] = '-'; + FillCharFromInt( guid.Data3, &pBuf[15], 4 ); + pBuf[19] = '-'; + + int nInd = 0; + for ( nInd = 0; nInd < 2 ; nInd++ ) + FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 2*nInd], 2 ); + pBuf[24] = '-'; + for ( nInd = 2; nInd < 8 ; nInd++ ) + FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 1 + 2*nInd], 2 ); + pBuf[37] = '}'; + + return 38; } HRESULT WriteLibraryToRegistry( char* pLibrary, DWORD nLen ) @@ -90,21 +105,17 @@ namespace { if ( pLibrary && nLen ) { HKEY hKey = NULL; - char* pPrefix = "Software\\Classes\\CLSID\\"; - char* pPostfix = "\\InprocHandler32"; hRes = S_OK; for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ ) { - char pSubKey[513]; - char pCLSID[64]; - int nGuidLen = GetStringFromClassID( *guidList[nInd], pCLSID, 64 ); + char* pSubKey = "Software\\Classes\\CLSID\\.....................................\\InprocHandler32"; + + int nGuidLen = GetStringFromClassID( *guidList[nInd], &pSubKey[23], 38 ); BOOL bLocalSuccess = FALSE; - if ( nGuidLen && nGuidLen < 64 ) + if ( nGuidLen && nGuidLen == 38 ) { - pCLSID[nGuidLen] = 0; - sprintf( pSubKey, "%s%s%s", pPrefix, pCLSID, pPostfix ); if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) { if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, (const BYTE*)pLibrary, nLen ) ) diff --git a/embedserv/source/inprocserv/inprocembobj.cxx b/embedserv/source/inprocserv/inprocembobj.cxx index 6f18bfc8e57f..895427e1646c 100644 --- a/embedserv/source/inprocserv/inprocembobj.cxx +++ b/embedserv/source/inprocserv/inprocembobj.cxx @@ -33,35 +33,61 @@ * ************************************************************************/ -#include - #include #include "inprocembobj.h" -// #define OWNDEBUG - -#ifdef OWNDEBUG -#define WRITEDEBUGINFO( x ) WriteDebugInfo( x ) -#else -#define WRITEDEBUGINFO( x ) -#endif - namespace inprocserv { -//------------------------------------------------------------------------------- #ifdef OWNDEBUG -void WriteDebugInfo( char* pString ) +//------------------------------------------------------------------------------- +void WriteDebugInfo( DWORD pThis, char* pString, DWORD nToWrite ) { - FILE* pFile = fopen( "c:\\inproc.log", "aw" ); - if ( pFile ) + if ( nToWrite ) { - fprintf( pFile, pString ); - fclose( pFile ); + char pNumber[12]; + pNumber[0] = '0'; + pNumber[1] = 'x'; + for ( int nInd = 0; nInd < 8; nInd++ ) + pNumber[nInd+2] = (char)( ( pThis / ( 1 << ( 7 - nInd ) ) ) % 16 ) + 48; + pNumber[10] = ' '; + pNumber[11] = 0; + + HANDLE pFile = CreateFileA( "h:\\inproc.log", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL ); + if ( pFile ) + { + DWORD dwWritten = 0; + SetFilePointer( pFile, 0, 0, FILE_END ); + WriteFile( pFile, pNumber, 11, &dwWritten, NULL ); + WriteFile( pFile, pString, nToWrite - 1, &dwWritten, NULL ); + CloseHandle( pFile ); + } } } #endif +//------------------------------------------------------------------------------- +BOOL StringsEqual( LPCOLESTR pszNameFromOutside, wchar_t* pOwnName ) +{ + BOOL bResult = TRUE; + + if ( pszNameFromOutside && pOwnName ) + { + for ( int nInd = 0; pszNameFromOutside[nInd] != 0 || pOwnName[nInd] != 0; nInd++ ) + { + if ( pszNameFromOutside[nInd] != pOwnName[nInd] ) + { + bResult = FALSE; + break; + } + } + } + else if ( pszNameFromOutside || pOwnName ) + bResult = FALSE; + + return bResult; +} + //------------------------------------------------------------------------------- HRESULT InprocEmbedDocument_Impl::Init() { @@ -69,40 +95,54 @@ HRESULT InprocEmbedDocument_Impl::Init() } //------------------------------------------------------------------------------- -void InprocEmbedDocument_Impl::SetFileName( LPCOLESTR pszFileName ) +void InprocEmbedDocument_Impl::SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName ) { + if ( !pszNameFromOutside ) + return; + // copy the string - size_t nLen = wcslen( pszFileName ); - if ( m_pFileName ) + size_t nLen = 0; + while( pszNameFromOutside[nLen] != 0 ) + nLen++; + + if ( pOwnName ) { - delete[] m_pFileName; - m_pFileName = NULL; + delete[] pOwnName; + pOwnName = NULL; } - m_pFileName = new wchar_t[nLen+1]; - wcsncpy( m_pFileName, pszFileName, nLen ); - m_pFileName[nLen] = 0; + + pOwnName = new wchar_t[nLen+1]; + for ( size_t nInd = 0; nInd < nLen; nInd++ ) + pOwnName[nInd] = pszNameFromOutside[nInd]; + pOwnName[nLen] = 0; } //------------------------------------------------------------------------------- BOOL InprocEmbedDocument_Impl::CheckDefHandler() { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); // set the own listener if ( m_pOleAdvises[0] == NULL ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); m_pOleAdvises[0] = new OleWrapperAdviseSink(); } else { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( m_pOleAdvises[0]->IsClosed() ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( m_pDefHandler ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); // deregister all the listeners ComSmart< IOleObject > pOleObject; HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); if ( SUCCEEDED( hr ) && pOleObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) if ( m_pOleAdvises[nInd] ) { @@ -110,12 +150,16 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() pOleObject->Unadvise( nID ); m_pOleAdvises[nInd]->SetRegID( 0 ); } + + pOleObject->SetClientSite( NULL ); } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IDataObject > pIDataObject; hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); if ( SUCCEEDED( hr ) && pIDataObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) if ( m_pDataAdvises[nInd] ) { @@ -125,17 +169,31 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IViewObject > pIViewObject; hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); if ( SUCCEEDED( hr ) && pIViewObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( m_pViewAdvise ) pIViewObject->SetAdvise( m_pViewAdvise->GetAspect(), m_pViewAdvise->GetViewAdviseFlag(), NULL ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); + } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); + + ComSmart< IPersistStorage > pPersist; + hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + if ( SUCCEEDED( hr ) && pPersist ) + { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); + // disconnect the old wrapper from the storage + pPersist->HandsOffStorage(); } m_pDefHandler = NULL; } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); m_pOleAdvises[0]->UnsetClosed(); } } @@ -143,12 +201,15 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() if ( m_nCallsOnStack ) return FALSE; + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( !m_pDefHandler ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); // create a new default inprocess handler HRESULT hr = OleCreateDefaultHandler( m_guid, NULL, IID_IUnknown, (void**)&m_pDefHandler ); if ( SUCCEEDED( hr ) ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); // // reinit the handler // ComSmart< IRunnableObject > pIRunObj; // hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); @@ -164,6 +225,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() { if ( m_nInitMode == INIT_FROM_STORAGE ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IPersistStorage > pPersist; hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); @@ -173,6 +235,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } else if ( m_nInitMode == LOAD_FROM_STORAGE ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IPersistStorage > pPersist; hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); @@ -182,6 +245,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } else if ( m_nInitMode == LOAD_FROM_FILE ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IPersistFile > pPersistFile; hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersistFile ); @@ -189,12 +253,15 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() if ( SUCCEEDED( hr ) && pPersistFile && m_pFileName ) hr = pPersistFile->Load( m_pFileName, m_nFileOpenMode ); } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); } } } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( !SUCCEEDED( hr ) || !m_pDefHandler ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); m_pDefHandler = NULL; return FALSE; } @@ -205,9 +272,11 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); if ( SUCCEEDED( hr ) && pOleObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( m_pClientSite ) pOleObject->SetClientSite( m_pClientSite ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) if ( m_pOleAdvises[nInd] ) { @@ -217,28 +286,37 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IDataObject > pIDataObject; hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); if ( SUCCEEDED( hr ) && pIDataObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) if ( m_pDataAdvises[nInd] ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); DWORD nRegID = 0; if ( SUCCEEDED( pIDataObject->DAdvise( m_pDataAdvises[nInd]->GetFormatEtc(), m_pDataAdvises[nInd]->GetDataAdviseFlag(), m_pDataAdvises[nInd], &nRegID ) ) && nRegID > 0 ) m_pDataAdvises[nInd]->SetRegID( nRegID ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); } } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); ComSmart< IViewObject > pIViewObject; hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); if ( SUCCEEDED( hr ) && pIViewObject ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); if ( m_pViewAdvise ) pIViewObject->SetAdvise( m_pViewAdvise->GetAspect(), m_pViewAdvise->GetViewAdviseFlag(), m_pViewAdvise ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); } } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::CheckDefHandler()" ); + return TRUE; } @@ -272,23 +350,33 @@ void InprocEmbedDocument_Impl::Clean() { m_pDefHandler = (IUnknown*)NULL; + // no DisconnectOrigAdvise() call here, since it is no explicit disconnection for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) { if ( m_pOleAdvises[nInd] ) { - ComSmart< OleWrapperAdviseSink > pAdvice = m_pOleAdvises[nInd]; + ComSmart< OleWrapperAdviseSink > pAdvise = m_pOleAdvises[nInd]; m_pOleAdvises[nInd] = NULL; } if ( m_pDataAdvises[nInd] ) { - ComSmart< OleWrapperAdviseSink > pAdvice = m_pDataAdvises[nInd]; + ComSmart< OleWrapperAdviseSink > pAdvise = m_pDataAdvises[nInd]; m_pDataAdvises[nInd] = NULL; } } + m_pViewAdvise = NULL; + m_nInitMode = NOINIT; m_pStorage = NULL; + + if ( m_pOleContainer ) + { + m_pOleContainer->LockContainer( FALSE ); + m_pOleContainer = NULL; + } + m_pClientSite = NULL; m_nFileOpenMode = 0; @@ -426,11 +514,11 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetClassID( CLSID* pClassId ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::IsDirty() { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsDirty()1\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsDirty()1" ); if ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) return S_FALSE; - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsDirty()2\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsDirty()2" ); if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; @@ -447,7 +535,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::IsDirty() //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InitNew( IStorage *pStg ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InitNew( IStorage *pStg )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InitNew( IStorage *pStg )" ); if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; @@ -480,24 +568,28 @@ STDMETHODIMP InprocEmbedDocument_Impl::InitNew( IStorage *pStg ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Load( IStorage *pStg ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )" ); if ( CheckDefHandler() ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )" ); ComSmart< IPersistStorage > pPersist; HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )" ); hr = pPersist->Load( pStg ); if ( SUCCEEDED( hr ) ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )" ); m_nInitMode = LOAD_FROM_STORAGE; m_pStorage = pStg; m_nFileOpenMode = 0; if ( m_pFileName ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( IStorage *pStg )" ); delete[] m_pFileName; m_pFileName = NULL; } @@ -513,11 +605,11 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( IStorage *pStg ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )1\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )" ); if ( fSameAsLoad && ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) ) return S_OK; - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )2\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )" ); if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; @@ -534,7 +626,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoa //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )1\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )" ); if ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) { if ( pStgNew ) @@ -543,7 +635,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) return S_OK; } - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )2\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )" ); if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; @@ -555,9 +647,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) hr = pPersist->SaveCompleted( pStgNew ); if ( SUCCEEDED( hr ) ) { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )" ); m_nInitMode = LOAD_FROM_STORAGE; if ( pStgNew ) + { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )" ); m_pStorage = pStgNew; + } m_nFileOpenMode = 0; if ( m_pFileName ) @@ -577,7 +673,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::HandsOffStorage() { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::HandsOffStorage()\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::HandsOffStorage()" ); if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; @@ -585,7 +681,16 @@ STDMETHODIMP InprocEmbedDocument_Impl::HandsOffStorage() ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) - return pPersist->HandsOffStorage(); + { + hr = pPersist->HandsOffStorage(); + if ( SUCCEEDED( hr ) ) + { + m_pStorage = NULL; + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::HandsOffStorage()" ); + } + + return hr; + } } return E_FAIL; @@ -595,7 +700,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::HandsOffStorage() //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode )" ); if ( CheckDefHandler() && pszFileName ) { ComSmart< IPersistFile > pPersist; @@ -613,7 +718,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode m_nFileOpenMode = dwMode; // copy the string - SetFileName( pszFileName ); + SetName( pszFileName, m_pFileName ); } return hr; @@ -626,7 +731,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember )" ); if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; @@ -643,7 +748,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRememb //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName )" ); if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; @@ -661,7 +766,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) m_nFileOpenMode = STGM_READWRITE; // was just written // copy the string - SetFileName( pszFileName ); + SetName( pszFileName, m_pFileName ); } } @@ -673,7 +778,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName )" ); if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; @@ -691,7 +796,20 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite )" ); + if ( pSite == m_pClientSite ) + return S_OK; + + if ( !pSite ) + { + m_pClientSite = NULL; + if ( m_pOleContainer ) + { + m_pOleContainer->LockContainer( FALSE ); + m_pOleContainer = NULL; + } + } + if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -702,8 +820,20 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite ) { HRESULT hr = pOleObject->SetClientSite( pSite ); if ( SUCCEEDED( hr ) ) + { m_pClientSite = pSite; + if ( m_pOleContainer ) + { + m_pOleContainer->LockContainer( FALSE ); + m_pOleContainer = NULL; + } + + m_pClientSite->GetContainer( &m_pOleContainer ); + if ( m_pOleContainer ) + m_pOleContainer->LockContainer( TRUE ); + } + return hr; } } @@ -714,7 +844,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetClientSite( IOleClientSite** pSite ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetClientSite( IOleClientSite** pSite )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetClientSite( IOleClientSite** pSite )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -731,7 +861,9 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetClientSite( IOleClientSite** pSite ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj )" ); + + HRESULT hr = S_OK; if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -739,18 +871,22 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, L ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) - return pOleObject->SetHostNames( szContainerApp, szContainerObj ); + { + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj )" ); + hr = pOleObject->SetHostNames( szContainerApp, szContainerObj ); + } } - return E_FAIL; + return hr; } //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Close( DWORD dwSaveOption ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Close( DWORD dwSaveOption )\n" ); - if ( CheckDefHandler() ) + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Close( DWORD dwSaveOption )" ); + if ( m_pDefHandler && CheckDefHandler() ) { + // no need to close if there is no default handler. ComSmart< IOleObject > pOleObject; HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); @@ -759,21 +895,19 @@ STDMETHODIMP InprocEmbedDocument_Impl::Close( DWORD dwSaveOption ) { hr = pOleObject->Close( dwSaveOption ); hr = CoDisconnectObject( (IUnknown*)(IPersistStorage*)this, 0 ); - - // if the object is closed from outside that means that it should go to uninitialized state - Clean(); - - return S_OK; } } - return E_FAIL; + // if the object is closed from outside that means that it should go to uninitialized state + Clean(); + + return S_OK; } //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMoniker * pmk ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMoniker * pmk )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMoniker * pmk )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -790,7 +924,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMonike //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker ** ppmk ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker ** ppmk )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker ** ppmk )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -807,7 +941,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhich //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InitFromData( IDataObject * pDataObject, BOOL fCreation, DWORD dwReserved ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InitFromData( IDataObject * pDataObject, BOOL fCreation, DWORD dwReserved )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InitFromData( IDataObject * pDataObject, BOOL fCreation, DWORD dwReserved )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -824,7 +958,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InitFromData( IDataObject * pDataObject, //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IDataObject ** ppDataObject ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IDataObject ** ppDataObject )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IDataObject ** ppDataObject )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -847,15 +981,29 @@ STDMETHODIMP InprocEmbedDocument_Impl::DoVerb( HWND hWin, LPCRECT pRect ) { - WRITEDEBUGINFO( "DoVerb\n" ); + WRITEDEBUGINFO( "DoVerb" ); if ( CheckDefHandler() ) { + WRITEDEBUGINFO( "DoVerb" MY_STRING_LINE "n" ); ComSmart< IOleObject > pOleObject; HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + WRITEDEBUGINFO( "DoVerb" ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem + WRITEDEBUGINFO( "DoVerb" ); if ( SUCCEEDED( hr ) && pOleObject ) - return pOleObject->DoVerb( iVerb, pMsg, pActiveSite, nLong, hWin, pRect ); + { + WRITEDEBUGINFO( "DoVerb" ); + hr = pOleObject->DoVerb( iVerb, pMsg, pActiveSite, nLong, hWin, pRect ); + if ( SUCCEEDED( hr ) ) + { + WRITEDEBUGINFO( "DoVerb" ); + } + + return hr; + } + + WRITEDEBUGINFO( "DoVerb" ); } return E_FAIL; @@ -864,7 +1012,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::DoVerb( //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** ppEnumOleVerb ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** ppEnumOleVerb )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** ppEnumOleVerb )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -881,8 +1029,9 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** ppEnumOleVerb //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Update() { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Update()\n" ); - if ( CheckDefHandler() ) + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Update()" ); + + if ( m_pDefHandler && CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); @@ -892,13 +1041,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::Update() return pOleObject->Update(); } - return E_FAIL; + return S_OK; } //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::IsUpToDate() { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsUpToDate()\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsUpToDate()" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -915,24 +1064,17 @@ STDMETHODIMP InprocEmbedDocument_Impl::IsUpToDate() //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetUserClassID( CLSID *pClsid ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetUserClassID( CLSID *pClsid )\n" ); - if ( CheckDefHandler() ) - { - ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); - - ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem - if ( SUCCEEDED( hr ) && pOleObject ) - return pOleObject->GetUserClassID( pClsid ); - } + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetUserClassID( CLSID *pClsid )" ); + if ( pClsid ) + *pClsid = m_guid; - return E_FAIL; + return S_OK; } //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR * pszUserType ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR * pszUserType )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR * pszUserType )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -949,7 +1091,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psizel ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psizel )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psizel )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -966,7 +1108,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psi //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL * psizel ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL * psizel )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL * psizel )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -983,7 +1125,18 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL * ps //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdwConnection ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdwConnection )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdwConnection )" ); + + if ( !pdwConnection ) + return E_FAIL; + + // CheckDefHandler will set the listener, avoid reusing of old listener + if ( DEFAULT_ARRAY_LEN > *pdwConnection && *pdwConnection > 0 && m_pOleAdvises[*pdwConnection] ) + { + m_pOleAdvises[*pdwConnection]->DisconnectOrigAdvise(); + m_pOleAdvises[*pdwConnection] = NULL; + } + if ( pAdvSink && CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -1007,7 +1160,8 @@ STDMETHODIMP InprocEmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdw } } - return E_FAIL; + // return success always for now + return S_OK; } //------------------------------------------------------------------------------- @@ -1024,11 +1178,14 @@ STDMETHODIMP InprocEmbedDocument_Impl::Unadvise( DWORD dwConnection ) if ( SUCCEEDED( hr ) && pOleObject ) { DWORD nID = m_pOleAdvises[dwConnection]->GetRegID(); - return pOleObject->Unadvise( nID ); + pOleObject->Unadvise( nID ); } } + m_pOleAdvises[dwConnection]->DisconnectOrigAdvise(); m_pOleAdvises[dwConnection] = NULL; + + return S_OK; } return E_FAIL; @@ -1055,7 +1212,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumAdvise( IEnumSTATDATA ** /*ppenumAdvi //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD * pdwStatus ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD * pdwStatus )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD * pdwStatus )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -1072,7 +1229,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD * pd //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE * pLogpal ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE * pLogpal )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE * pLogpal )" ); if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; @@ -1090,7 +1247,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE * pLogpal ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1107,7 +1264,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIU //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM * pMedium )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM * pMedium )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1124,7 +1281,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGM //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1141,7 +1298,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1158,7 +1315,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pForma //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1175,7 +1332,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIU //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1192,7 +1349,18 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFO //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection )" ); + + if ( !pdwConnection ) + return E_FAIL; + + // avoid reusing of the old listener + if ( m_pDefHandler && DEFAULT_ARRAY_LEN > *pdwConnection && *pdwConnection > 0 && m_pDataAdvises[*pdwConnection] ) + { + m_pDataAdvises[*pdwConnection]->DisconnectOrigAdvise(); + m_pDataAdvises[*pdwConnection] = NULL; + } + if ( pAdvSink && CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1216,13 +1384,14 @@ STDMETHODIMP InprocEmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD ad } } - return E_FAIL; + // return success always for now + return S_OK; } //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection )" ); if ( m_pDefHandler && DEFAULT_ARRAY_LEN > dwConnection && dwConnection > 0 && m_pDataAdvises[dwConnection] ) { if ( CheckDefHandler() ) @@ -1234,11 +1403,14 @@ STDMETHODIMP InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection ) if ( SUCCEEDED( hr ) && pIDataObject ) { DWORD nID = m_pDataAdvises[dwConnection]->GetRegID(); - return pIDataObject->DUnadvise( nID ); + pIDataObject->DUnadvise( nID ); } } + m_pDataAdvises[dwConnection]->DisconnectOrigAdvise(); m_pDataAdvises[dwConnection] = NULL; + + return S_OK; } return E_FAIL; @@ -1247,7 +1419,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvise ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvise )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvise )" ); if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; @@ -1265,7 +1437,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvis //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid )" ); if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; @@ -1282,7 +1454,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Run( LPBINDCTX pbc ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Run( LPBINDCTX pbc )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Run( LPBINDCTX pbc )" ); if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; @@ -1299,7 +1471,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Run( LPBINDCTX pbc ) //------------------------------------------------------------------------------- BOOL STDMETHODCALLTYPE InprocEmbedDocument_Impl::IsRunning() { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsRunning()\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::IsRunning()" ); if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; @@ -1317,7 +1489,7 @@ BOOL STDMETHODCALLTYPE InprocEmbedDocument_Impl::IsRunning() //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::LockRunning( BOOL fLock, BOOL fLastUnlockCloses ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::LockRunning( BOOL fLock, BOOL fLastUnlockCloses )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::LockRunning( BOOL fLock, BOOL fLastUnlockCloses )" ); if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; @@ -1334,7 +1506,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::LockRunning( BOOL fLock, BOOL fLastUnlock //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained)\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained)" ); if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; @@ -1353,7 +1525,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Draw( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Draw( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Draw( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue )" ); if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; @@ -1370,7 +1542,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Draw( DWORD dwDrawAspect, LONG lindex, vo //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet )" ); if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; @@ -1387,7 +1559,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect, LONG lin //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze )" ); if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; @@ -1404,7 +1576,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect, LONG lindex, //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze )" ); if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; @@ -1421,8 +1593,16 @@ STDMETHODIMP InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetAdvise( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetAdvise( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink )\n" ); - if ( CheckDefHandler() ) + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetAdvise( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink )" ); + + // CheckDefHandler will set the listener, avoid reusing of old listener + if ( m_pViewAdvise ) + { + m_pViewAdvise->DisconnectOrigAdvise(); + m_pViewAdvise = NULL; + } + + if ( pAdvSink && CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); @@ -1440,7 +1620,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetAdvise( DWORD aspects, DWORD advf, IAd } } - return E_FAIL; + return S_OK; } //------------------------------------------------------------------------------- @@ -1471,7 +1651,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetAdvise( DWORD *pAspects, DWORD *pAdvf, //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel )" ); if ( CheckDefHandler() ) { ComSmart< IViewObject2 > pIViewObject2; @@ -1491,7 +1671,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, LONG linde //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetWindow( HWND *phwnd ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetWindow( HWND *phwnd )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetWindow( HWND *phwnd )" ); if ( CheckDefHandler() ) { ComSmart< IOleWindow > pIOleWindow; @@ -1508,7 +1688,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetWindow( HWND *phwnd ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode )" ); if ( CheckDefHandler() ) { ComSmart< IOleWindow > pIOleWindow; @@ -1527,7 +1707,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InPlaceDeactivate( void ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InPlaceDeactivate( void )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InPlaceDeactivate( void )" ); if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; @@ -1544,7 +1724,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InPlaceDeactivate( void ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::UIDeactivate( void ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::UIDeactivate( void )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::UIDeactivate( void )" ); if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; @@ -1561,7 +1741,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::UIDeactivate( void ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect, LPCRECT lprcClipRect ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect, LPCRECT lprcClipRect )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect, LPCRECT lprcClipRect )" ); if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; @@ -1578,7 +1758,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect, LPCR //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::ReactivateAndUndo( void ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::ReactivateAndUndo( void )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::ReactivateAndUndo( void )" ); if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; @@ -1597,7 +1777,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::ReactivateAndUndo( void ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfoCount( UINT *pctinfo ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetTypeInfoCount( UINT *pctinfo )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetTypeInfoCount( UINT *pctinfo )" ); if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; @@ -1614,7 +1794,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfoCount( UINT *pctinfo ) //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo )" ); if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; @@ -1631,7 +1811,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo, LCID lcid, ITyp //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId )" ); if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; @@ -1648,7 +1828,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid, LPOLESTR *rgs //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr )" ); if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; @@ -1690,7 +1870,7 @@ STDMETHODIMP_(ULONG) InprocEmbedDocument_Impl::InternalCacheWrapper::Release() //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; @@ -1707,7 +1887,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC *p //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwConnection ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwConnection )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwConnection )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; @@ -1724,7 +1904,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwCo //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTATDATA **ppenumSTATDATA ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTATDATA **ppenumSTATDATA )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTATDATA **ppenumSTATDATA )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; @@ -1741,7 +1921,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTA //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObject *pDataObject ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObject *pDataObject )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObject *pDataObject )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; @@ -1758,7 +1938,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObj //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; @@ -1776,7 +1956,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache2 > pIOleCache2; @@ -1793,7 +1973,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATA //------------------------------------------------------------------------------- STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::DiscardCache( DWORD dwDiscardOptions ) { - WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::DiscardCache( DWORD dwDiscardOptions )\n" ); + WRITEDEBUGINFO( "InprocEmbedDocument_Impl::InternalCacheWrapper::DiscardCache( DWORD dwDiscardOptions )" ); if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache2 > pIOleCache2; diff --git a/embedserv/source/inprocserv/inprocembobj.h b/embedserv/source/inprocserv/inprocembobj.h index 178040ea6ea4..97e789dfbcd4 100644 --- a/embedserv/source/inprocserv/inprocembobj.h +++ b/embedserv/source/inprocserv/inprocembobj.h @@ -93,6 +93,7 @@ class InprocEmbedDocument_Impl : public InprocCountedObject_Impl ComSmart< IStorage > m_pStorage; ComSmart< IOleClientSite > m_pClientSite; + ComSmart< IOleContainer > m_pOleContainer; ULONG m_nCallsOnStack; @@ -148,7 +149,7 @@ public: {} HRESULT Init(); - void SetFileName( LPCOLESTR pszFileName ); + void SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName ); BOOL CheckDefHandler(); ComSmart< IUnknown >& GetDefHandler() { return m_pDefHandler; } diff --git a/embedserv/source/inprocserv/makefile.mk b/embedserv/source/inprocserv/makefile.mk index ca49d2f0210f..0f81dcc8bd0d 100644 --- a/embedserv/source/inprocserv/makefile.mk +++ b/embedserv/source/inprocserv/makefile.mk @@ -46,6 +46,8 @@ use_shl_versions= LIBTARGET=NO USE_DEFFILE=YES +LIBCMT=libcmt.lib +UWINAPILIB= # --- Files ------------------------------------- diff --git a/embedserv/source/inprocserv/smartpointer.hxx b/embedserv/source/inprocserv/smartpointer.hxx index 2d6487d0b3d4..ff40cedc30bf 100644 --- a/embedserv/source/inprocserv/smartpointer.hxx +++ b/embedserv/source/inprocserv/smartpointer.hxx @@ -36,8 +36,24 @@ #ifndef _INPROCSERV_SMARTPOINTER_HXX_ #define _INPROCSERV_SMARTPOINTER_HXX_ +// #define OWNDEBUG + +#ifdef OWNDEBUG +#define WRITEDEBUGINFOINTERN( x ) WriteDebugInfo( (DWORD)this, x, sizeof( x ) ) +#define WRITEDEBUGINFO( x ) WRITEDEBUGINFOINTERN( x ":" MY_STRING_LINE "\n" ) +#define TO_STRING( x ) #x +#define MACRO_VALUE_TO_STRING( x ) TO_STRING( x ) +#define MY_STRING_LINE MACRO_VALUE_TO_STRING( __LINE__ ) +#else +#define WRITEDEBUGINFO( x ) void() +#define MY_STRING_LINE +#endif + + namespace inprocserv{ +void WriteDebugInfo( DWORD pThis, char* pString, DWORD nToWrite ); + template< class T > class ComSmart { T* m_pInterface; diff --git a/extensions/source/oooimprovecore/core.cxx b/extensions/source/oooimprovecore/core.cxx index 398cc282f10b..adf3a49bf9a1 100644 --- a/extensions/source/oooimprovecore/core.cxx +++ b/extensions/source/oooimprovecore/core.cxx @@ -43,9 +43,14 @@ #include #include #include -#include +#include #include #include +#include +#include +#include +#include +#include using namespace ::com::sun::star::oooimprovement; using ::com::sun::star::frame::XTerminateListener; @@ -129,11 +134,17 @@ namespace oooimprovecore ::comphelper::ConfigurationHelper::E_READONLY) >>= help_url; else help_url = OUString::createFromAscii("http://www.openoffice.org"); - { ::vos::OGuard aGuard( Application::GetSolarMutex() ); - SvxImprovementDialog dlg(NULL, help_url); - dlg.Execute(); + SfxAllItemSet aSet( SFX_APP()->GetPool() ); + aSet.Put( SfxStringItem( SID_CURRENT_URL, help_url ) ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + AbstractSfxSingleTabDialog *pDlg = pFact->CreateSfxSingleTabDialog( NULL, aSet, 0, RID_SVXPAGE_IMPROVEMENT ); + pDlg->Execute(); + delete pDlg; + } } } diff --git a/extensions/source/oooimprovecore/makefile.mk b/extensions/source/oooimprovecore/makefile.mk index 0547be93b8c0..53de4e333994 100644 --- a/extensions/source/oooimprovecore/makefile.mk +++ b/extensions/source/oooimprovecore/makefile.mk @@ -58,10 +58,12 @@ SHL1STDLIBS= \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) \ - $(SVXLIB) \ $(VCLLIB) \ + $(SVLLIB) \ + $(SVTOOLLIB) \ $(SFXLIB) \ - $(TOOLSLIB) \ + $(SVXLIB) \ + $(TOOLSLIB) SHL1LIBS=$(LIB1TARGET) diff --git a/extensions/source/plugin/aqua/macmgr.cxx b/extensions/source/plugin/aqua/macmgr.cxx index a80bac015b27..26df705a1d97 100644 --- a/extensions/source/plugin/aqua/macmgr.cxx +++ b/extensions/source/plugin/aqua/macmgr.cxx @@ -28,236 +28,572 @@ * ************************************************************************/ -#include -#include -#include -#include -#include -#include +#include "rtl/ustrbuf.hxx" +#include "rtl/strbuf.hxx" -#include -#include +#include "plugin/impl.hxx" +#include "osl/file.h" +#include "osl/module.hxx" using namespace rtl; using namespace std; using namespace com::sun::star::uno; using namespace com::sun::star::plugin; -// Unix specific implementation -static bool CheckPlugin( const ByteString& rPath, list< PluginDescription* >& rDescriptions ) +namespace plugstringhelper { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Trying plugin %s ... ", rPath.GetBuffer() ); -#endif - xub_StrLen nPos = rPath.SearchBackward( '/' ); - if( nPos == STRING_NOTFOUND ) +rtl::OUString getString( CFStringRef i_xString ) +{ + rtl::OUStringBuffer aBuf; + if( i_xString ) { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "no absolute path to plugin\n" ); -#endif - return false; + CFIndex nChars = CFStringGetLength( i_xString ); + CFRange aRange = { 0, nChars }; + aBuf.setLength( nChars ); + CFStringGetCharacters( i_xString, aRange, static_cast< UniChar* >(const_cast(aBuf.getStr())) ); } + return aBuf.makeStringAndClear(); +} + +rtl::OUString getString( CFURLRef i_xURL ) +{ + CFStringRef xString = CFURLGetString( i_xURL ); + return getString( xString ); +} + +CFMutableStringRef createString( const rtl::OUString& i_rString ) +{ + CFMutableStringRef xString = CFStringCreateMutable( NULL, 0 ); + if( xString ) + CFStringAppendCharacters( xString, i_rString.getStr(), i_rString.getLength() ); + return xString; +} + +CFURLRef createURL( const rtl::OUString& i_rString ) +{ + + CFMutableStringRef xMutableString = createString( i_rString ); + CFURLRef xURL = CFURLCreateWithString( NULL, xMutableString, NULL ); + CFRelease( xMutableString ); + return xURL; +} - ByteString aBaseName = rPath.Copy( nPos+1 ); - if( aBaseName.Equals( "libnullplugin.so" ) ) +rtl::OUString getURLFromPath( const rtl::OUString& i_rPath ) +{ + CFMutableStringRef xMutableString = createString( i_rPath ); + CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); + CFRelease( xMutableString ); + CFStringRef xString = CFURLGetString( xURL ); + rtl::OUString aRet = getString( xString ); + CFRelease( xURL ); + return aRet; +} + +CFURLRef createURLFromPath( const rtl::OUString& i_rPath ) +{ + CFMutableStringRef xMutableString = createString( i_rPath ); + CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); + return xURL; +} + +rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL ) +{ + // make URL absolute + CFURLRef xAbsURL = CFURLCopyAbsoluteURL( i_xURL ); + // copy system path + CFStringRef xSysPath = CFURLCopyFileSystemPath( xAbsURL ? xAbsURL : i_xURL, kCFURLPOSIXPathStyle ); + if( xAbsURL ) + CFRelease( xAbsURL ); + rtl::OUString aSysPath( getString( xSysPath ) ); + CFRelease( xSysPath ); + rtl::OUString aFileURL; + osl_getFileURLFromSystemPath( aSysPath.pData, &aFileURL.pData ); + return aFileURL; +} + +} + +using namespace plugstringhelper; + +static int parsePlist( CFBundleRef i_xBundle, const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions ) +{ + CFTypeRef xMimeDict = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginMIMETypes")); + int nMimetypes = 0; + if( xMimeDict == 0 || + CFGetTypeID(xMimeDict) != CFDictionaryGetTypeID() || + (nMimetypes = CFDictionaryGetCount( static_cast(xMimeDict))) <= 0 ) { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "don't like %s\n", aBaseName.GetBuffer() ); -#endif - return false; + return 0; } - struct stat aStat; - if( stat( rPath.GetBuffer(), &aStat ) || ! S_ISREG( aStat.st_mode ) ) + // prepare an array of key and value refs + std::vector< CFTypeRef > aKeys( nMimetypes, CFTypeRef(NULL) ); + std::vector< CFTypeRef > aValues( nMimetypes, CFTypeRef(NULL) ); + CFDictionaryGetKeysAndValues(static_cast(xMimeDict), &aKeys[0], &aValues[0] ); + + int nAdded = 0; + for( int i = 0; i < nMimetypes; i++ ) { + // get the mimetype + CFTypeRef xKey = aKeys[i]; + if( ! xKey || CFGetTypeID(xKey) != CFStringGetTypeID() ) + continue; + rtl::OUString aMimetype = getString( (CFStringRef)xKey ); + + // the correspoding value should be a dictionary + CFTypeRef xDict = aValues[i]; + if( ! xDict || CFGetTypeID( xDict ) != CFDictionaryGetTypeID() ) + continue; + + // get the extension list + CFTypeRef xExtArray = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginExtensions" ) ); + if( !xExtArray || CFGetTypeID( xExtArray ) != CFArrayGetTypeID() ) + continue; + + OUStringBuffer aExtBuf; + int nExtensions = CFArrayGetCount( (CFArrayRef)xExtArray ); + for( int n = 0; n < nExtensions; n++ ) + { + CFTypeRef xExt = CFArrayGetValueAtIndex( (CFArrayRef)xExtArray, n ); + if( xExt && CFGetTypeID( xExt ) == CFStringGetTypeID() ) + { + if( aExtBuf.getLength() > 0 ) + aExtBuf.append( sal_Unicode(';') ); + OUString aExt( getString( (CFStringRef)xExt ) ); + if( aExt.indexOfAsciiL( "*.", 2 ) != 0 ) + aExtBuf.appendAscii( "*." ); + aExtBuf.append( aExt ); + } + } + + // get the description string + CFTypeRef xDescString = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginTypeDescription" ) ); + if( !xDescString || CFGetTypeID( xDescString ) != CFStringGetTypeID() ) + continue; + rtl::OUString aDescription = getString( (CFStringRef)xDescString ); + + PluginDescription* pNew = new PluginDescription; + // set plugin name (path to library) + pNew->PluginName = i_rBundleURL; + // set mimetype + pNew->Mimetype = aMimetype; + // set extension line + pNew->Extension = aExtBuf.makeStringAndClear(); + // set description + pNew->Description= aDescription; + + io_rDescriptions.push_back( pNew ); + nAdded++; + #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "%s is not a regular file\n", rPath.GetBuffer() ); + fprintf( stderr, + "Inserting from PList:\n" + " Mimetype: %s\n" + " Extension: %s\n" + " Description: %s\n", + OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(), + OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(), + OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr() + ); #endif - return false; + } + return nAdded; +} + +static int parseMimeString( const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions, const char* i_pMime ) +{ + if( ! i_pMime ) + return 0; rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - ByteString aCommand( "pluginapp.bin \"" ); - aCommand.Append( rPath ); - aCommand.Append( '"' ); + OStringBuffer aMIME; + aMIME.append( i_pMime ); - FILE* pResult = popen( aCommand.GetBuffer(), "r" ); - int nDescriptions = 0; - if( pResult ) + if( aMIME.getLength() < 1 ) + return 0; + + OString aLine = aMIME.makeStringAndClear(); + + int nAdded = 0; + sal_Int32 nIndex = 0; + while( nIndex != -1 ) { - OStringBuffer aMIME; - char buf[256]; - while( fgets( buf, sizeof( buf ), pResult ) ) + OString aType = aLine.getToken( 0, ';', nIndex ); + + sal_Int32 nTypeIndex = 0; + OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); + OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); + if( nTypeIndex < 0 ) // ensure at least three tokens + continue; + OString aDesc = aType.getToken( 0, ':', nTypeIndex ); + + // create extension list string + sal_Int32 nExtIndex = 0; + OStringBuffer aExtension; + while( nExtIndex != -1 ) { - for( size_t i = 0; i < sizeof(buf) && buf[i]; ++i ) + OString aExt = aExtLine.getToken( 0, ',', nExtIndex); + if( aExt.indexOf( "*." ) != 0 ) + aExtension.append( "*." ); + aExtension.append( aExt ); + if( nExtIndex != -1 ) + aExtension.append( ';' ); + } + + PluginDescription* pNew = new PluginDescription; + // set plugin name (path to library) + pNew->PluginName = i_rBundleURL; + // set mimetype + pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); + // set extension line + pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); + // set description + pNew->Description= OStringToOUString( aDesc, aEncoding ); + io_rDescriptions.push_back( pNew ); + nAdded++; + +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, + "Inserting from mime string:\n" + " Mimetype: %s\n" + " Extension: %s\n" + " Description: %s\n", + OUStringToOString( pNew->Mimetype, aEncoding ).getStr(), + OUStringToOString( pNew->Extension, aEncoding ).getStr(), + OUStringToOString( pNew->Description, aEncoding ).getStr() + ); +#endif + } + return nAdded; +} + +// this is so ugly it you want to tear your eyes out +static rtl::OUString GetNextPluginStringFromHandle(Handle h, short *index) +{ + char* pPascalBytes = (*h + *index); + sal_uInt32 nLen = (unsigned char)pPascalBytes[0]; + rtl::OStringBuffer aBuf( nLen ); + aBuf.append( pPascalBytes+1, nLen ); + *index += nLen + 1; + return rtl::OStringToOUString( aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); +} + +static int parseMimeResource( CFBundleRef i_xBundle, + oslModule& i_rMod, + const rtl::OUString& i_rBundleURL, + list< PluginDescription* >& io_rDescriptions ) +{ + int nAdded = 0; + // just to hurt our eyes more there is an alternative mimetype function plus the possibility + // of a resource fork. Must be a case of think different. + #if __LP64__ + int + #else + SInt16 + #endif + xRes = 0; + BPSupportedMIMETypes aMIMETypesStrangeStruct = {kBPSupportedMIMETypesStructVers_1, NULL, NULL}; + + BP_GetSupportedMIMETypesUPP pBPGetSupp = (BP_GetSupportedMIMETypesUPP)osl_getAsciiFunctionSymbol( i_rMod, "BP_GetSupportedMIMETypes" ); + if( pBPGetSupp && + noErr == pBPGetSupp( &aMIMETypesStrangeStruct, 0 ) && + aMIMETypesStrangeStruct.typeStrings ) + { + HLock( aMIMETypesStrangeStruct.typeStrings ); + if( aMIMETypesStrangeStruct.infoStrings ) // it's possible some plugins have infoStrings missing + HLock( aMIMETypesStrangeStruct.infoStrings ); + } + else // Try to get data from the resource fork + { + xRes = CFBundleOpenBundleResourceMap( i_xBundle ); + if( xRes > 0 ) + { + aMIMETypesStrangeStruct.typeStrings = Get1Resource('STR#', 128); + if( aMIMETypesStrangeStruct.typeStrings ) { - if( buf[i] == '\n' ) - buf[i] = ';'; + DetachResource( aMIMETypesStrangeStruct.typeStrings ); + HLock( aMIMETypesStrangeStruct.typeStrings ); + aMIMETypesStrangeStruct.infoStrings = Get1Resource('STR#', 127); + if( aMIMETypesStrangeStruct.infoStrings ) + { + DetachResource( aMIMETypesStrangeStruct.infoStrings ); + HLock( aMIMETypesStrangeStruct.infoStrings ); + } } - aMIME.append( buf ); } - pclose( pResult ); + } - if( aMIME.getLength() > 0 ) + if( aMIMETypesStrangeStruct.typeStrings && aMIMETypesStrangeStruct.infoStrings ) + { + short nVariantCount = (**(short**)aMIMETypesStrangeStruct.typeStrings) / 2; + // Fill in the info struct based on the data in the BPSupportedMIMETypes struct + // this is an array of pascal string of unknown (!) encoding + // whoever thought of this deserves a fair beating + short mimeIndex = 2; + short descriptionIndex = 2; + for( int i = 0; i < nVariantCount; i++ ) { - OString aLine = aMIME.makeStringAndClear(); + rtl::OUString aMimetype = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex ); + rtl::OUString aExtLine = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex ); + rtl::OUString aDescription; + if( aMIMETypesStrangeStruct.infoStrings ) + aDescription = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.infoStrings, &descriptionIndex ); - sal_Int32 nIndex = 0; - while( nIndex != -1 ) + // create extension list string + sal_Int32 nExtIndex = 0; + OUStringBuffer aExtension; + while( nExtIndex != -1 ) { - OString aType = aLine.getToken( 0, ';', nIndex ); - - sal_Int32 nTypeIndex = 0; - OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); - OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); - if( nTypeIndex < 0 ) // ensure at least three tokens - continue; - OString aDesc = aType.getToken( 0, ':', nTypeIndex ); - - // create extension list string - sal_Int32 nExtIndex = 0; - OStringBuffer aExtension; - while( nExtIndex != -1 ) - { - OString aExt = aExtLine.getToken( 0, ',', nExtIndex); - if( aExt.indexOf( "*." ) != 0 ) - aExtension.append( "*." ); - aExtension.append( aExt ); - if( nExtIndex != -1 ) - aExtension.append( ';' ); - } + OUString aExt = aExtLine.getToken( 0, ',', nExtIndex); + if( aExt.indexOfAsciiL( "*.", 2 ) != 0 ) + aExtension.appendAscii( "*." ); + aExtension.append( aExt ); + if( nExtIndex != -1 ) + aExtension.append( sal_Unicode(';') ); + } - PluginDescription* pNew = new PluginDescription; - // set plugin name (path to library) - pNew->PluginName = OStringToOUString( rPath, aEncoding ); - // set mimetype - pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); - // set extension line - pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); - // set description - pNew->Description= OStringToOUString( aDesc, aEncoding ); - rDescriptions.push_back( pNew ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Mimetype: %s\nExtension: %s\n" - "Description: %s\n", - OUStringToOString( pNew->Mimetype, aEncoding ).getStr(), - OUStringToOString( pNew->Extension, aEncoding ).getStr(), - OUStringToOString( pNew->Description, aEncoding ).getStr() - ); -#endif + PluginDescription* pNew = new PluginDescription; + // set plugin name (path to library) + pNew->PluginName = i_rBundleURL; + // set mimetype + pNew->Mimetype = aMimetype; + // set extension line + pNew->Extension = aExtension.makeStringAndClear(); + // set description + pNew->Description= aDescription; + io_rDescriptions.push_back( pNew ); + nAdded++; + + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, + "Inserting from resource:\n" + " Mimetype: %s\n" + " Extension: %s\n" + " Description: %s\n", + OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(), + OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(), + OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr() + ); + #endif + } + } + + + // clean up + if( aMIMETypesStrangeStruct.typeStrings ) + { + HUnlock( aMIMETypesStrangeStruct.typeStrings ); + DisposeHandle( aMIMETypesStrangeStruct.typeStrings ); + } + if( aMIMETypesStrangeStruct.infoStrings ) + { + HUnlock( aMIMETypesStrangeStruct.infoStrings ); + DisposeHandle( aMIMETypesStrangeStruct.infoStrings ); + } + if( xRes ) + CFBundleCloseBundleResourceMap( i_xBundle, xRes ); + + return nAdded; +} + +static int getPluginDescriptions( CFBundleRef i_xBundle , list< PluginDescription* >& io_rDescriptions ) +{ + int nDescriptions = 0; + if( ! i_xBundle ) + return nDescriptions; + + rtl::OUString aPlugURL; + CFURLRef xURL = CFBundleCopyBundleURL( i_xBundle ); + aPlugURL = getString( xURL ); + CFRelease( xURL ); + + #if OSL_DEBUG_LEVEL > 1 + rtl::OUString aPlugName, aPlugDescription; + CFTypeRef name = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginName")); + if( name && CFGetTypeID(name) == CFStringGetTypeID() ) + aPlugName = getString( static_cast(name) ); + + CFTypeRef description = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginDescription")); + if( description && CFGetTypeID(description) == CFStringGetTypeID() ) + aPlugDescription = getString( static_cast(description) ); + + fprintf( stderr, "URL: %s\nname: %s\ndescription: %s\n", + rtl::OUStringToOString( aPlugURL, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( aPlugName, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( aPlugDescription, RTL_TEXTENCODING_UTF8 ).getStr() ); + #endif + + + // get location of plugin library + CFURLRef xLibURL = CFBundleCopyExecutableURL( i_xBundle ); + if( ! xLibURL ) + return 0; + // get the file system path + rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) ); + CFRelease( xLibURL ); + + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "exec URL = %s\n", rtl::OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() ); + #endif + + /* TODO: originally the C++ wrapper for oslModule was used here, but that led to + mysterious crashes in the event loop (pointing to heap corruption). Why using + the C style oslModule should fix this is completely unknown. It may be that + we have just hidden the heap corruption a little more. + */ + oslModule aMod = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT ); + if( ! aMod ) + return 0; + + // check for at least the init function of a plugin + if( ! osl_getAsciiFunctionSymbol( aMod, "NP_Initialize") && + ! osl_getAsciiFunctionSymbol( aMod, "NP_GetEntryPoints" ) ) + { + return 0; + } + + // ask the plist of the bundle for mimetypes + nDescriptions = parsePlist( i_xBundle, aPlugURL, io_rDescriptions ); + if( nDescriptions ) + { + osl_unloadModule( aMod ); + return nDescriptions; + } + + // resolve the symbol that might get us the mimetypes + const char* (*pGetMimeDescription)() = (const char*(*)())osl_getAsciiFunctionSymbol( aMod, "_NP_GetMIMEDescription" ); + if( pGetMimeDescription ) + { + const char* pMime = pGetMimeDescription(); + if( pMime ) + { + nDescriptions = parseMimeString( aPlugURL, io_rDescriptions, pMime ); + if( nDescriptions ) + { + osl_unloadModule( aMod ); + return nDescriptions; } } + } + + // and as last resort check the resource of the bundle + nDescriptions = parseMimeResource( i_xBundle, aMod, aPlugURL, io_rDescriptions ); + osl_unloadModule( aMod ); + + return nDescriptions; +} + +// Unix specific implementation +static bool CheckPlugin( const rtl::OUString& rPath, list< PluginDescription* >& rDescriptions ) +{ #if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "result of \"%s\" contains no mimtype\n", - aCommand.GetBuffer() ); + fprintf( stderr, "Trying path %s ... ", rtl::OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getStr() ); #endif - } + CFURLRef xURL = createURL( rPath ); + + CFArrayRef xBundles = CFBundleCreateBundlesFromDirectory( NULL, xURL, CFSTR("plugin") ); + if( ! xBundles ) + return false; + + CFIndex nBundles = CFArrayGetCount( xBundles ); + #if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "command \"%s\" failed\n", aCommand.GetBuffer() ); + fprintf( stderr, "got %d bundles\n", (int)nBundles ); #endif + + int nDescriptions = 0; + for( CFIndex i = 0; i < nBundles; i++ ) + { + CFBundleRef xBundle = (CFBundleRef)CFArrayGetValueAtIndex( xBundles, i ); + nDescriptions += getPluginDescriptions( xBundle, rDescriptions ); + + CFRelease( xBundle ); + } + CFRelease( xBundles ); + + return nDescriptions > 0; } +static rtl::OUString FindFolderURL( FSVolumeRefNum vRefNum, OSType folderType ) +{ + rtl::OUString aRet; + + FSRef aFSRef; + OSErr err = FSFindFolder( vRefNum, folderType, kDontCreateFolder, &aFSRef ); + if( err == noErr ) + { + CFURLRef xURL = CFURLCreateFromFSRef( NULL, &aFSRef ); + aRet = getString( xURL ); + CFRelease( xURL ); + } + + return aRet; +} + Sequence XPluginManager_Impl::getPluginDescriptions() throw() { static Sequence aDescriptions; static BOOL bHavePlugins = FALSE; if( ! bHavePlugins ) { - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - list aPlugins; - int i; - - // unix: search for plugins in /usr/lib/netscape/plugins, - // ~/.netscape/plugins und NPX_PLUGIN_PATH - // additionally: search in PluginsPath - static const char* pHome = getenv( "HOME" ); - static const char* pNPXPluginPath = getenv( "NPX_PLUGIN_PATH" ); - - ByteString aSearchPath( "/usr/lib/netscape/plugins" ); - if( pHome ) - { - aSearchPath.Append( ':' ); - aSearchPath.Append( pHome ); - aSearchPath += "/.netscape/plugins"; - } + std::list aPlugins; + + static const char* pNPXPluginPath = getenv( "MOZ_PLUGIN_PATH" ); + + // get directories + std::list< rtl::OUString > aPaths; if( pNPXPluginPath ) { - aSearchPath.Append( ':' ); - aSearchPath += pNPXPluginPath; + CFMutableStringRef xMutableString = CFStringCreateMutable( NULL, 0 ); + CFStringAppendCString( xMutableString, pNPXPluginPath, kCFStringEncodingUTF8 ); + CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); + CFRelease( xMutableString ); + aPaths.push_back( getString( xURL ) ); + CFRelease( xURL ); } - const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() ); - for( i = 0; i < rPaths.getLength(); i++ ) - { - aSearchPath += ":"; - aSearchPath += ByteString( String( rPaths.getConstArray()[i] ), aEncoding ); - } + rtl::OUString aPath = FindFolderURL( kUserDomain, kInternetPlugInFolderType ); + if( aPath.getLength() ) + aPaths.push_back( aPath ); + aPath = FindFolderURL( kLocalDomain, kInternetPlugInFolderType ); + if( aPath.getLength() ) + aPaths.push_back( aPath ); + aPath = FindFolderURL( kOnAppropriateDisk, kInternetPlugInFolderType ); + if( aPath.getLength() ) + aPaths.push_back( aPath ); - long aBuffer[ sizeof( struct dirent ) + _PC_NAME_MAX +1 ]; - int nPaths = aSearchPath.GetTokenCount( ':' ); - for( i = 0; i < nPaths; i++ ) + const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() ); + for( sal_Int32 i = 0; i < rPaths.getLength(); i++ ) { - ByteString aPath( aSearchPath.GetToken( i, ':' ) ); - if( aPath.Len() ) - { - DIR* pDIR = opendir( aPath.GetBuffer() ); - struct dirent* pDirEnt = NULL; - while( pDIR && ! readdir_r( pDIR, (struct dirent*)aBuffer, &pDirEnt ) && pDirEnt ) - { - char* pBaseName = ((struct dirent*)aBuffer)->d_name; - if( pBaseName[0] != '.' || - pBaseName[1] != '.' || - pBaseName[2] != 0 ) - { - ByteString aFileName( aPath ); - aFileName += "/"; - aFileName += pBaseName; - CheckPlugin( aFileName, aPlugins ); - } - } - if( pDIR ) - closedir( pDIR ); - } + aPaths.push_back( getURLFromPath( rPaths.getConstArray()[i] ) ); } - // try ~/.mozilla/pluginreg.dat - ByteString aMozPluginreg( pHome ); - aMozPluginreg.Append( "/.mozilla/pluginreg.dat" ); - FILE* fp = fopen( aMozPluginreg.GetBuffer(), "r" ); - if( fp ) + for( std::list< rtl::OUString >::const_iterator it = aPaths.begin(); it != aPaths.end(); ++it ) { + rtl::OUString aPath( *it ); #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "parsing %s\n", aMozPluginreg.GetBuffer() ); + fprintf( stderr, "check path %s\n", rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() ); #endif - char aLine[1024]; - while( fgets( aLine, sizeof( aLine ), fp ) ) - { - int nLineLen = strlen( aLine ); - int nDotPos; - for( nDotPos = nLineLen-1; nDotPos > 0 && aLine[nDotPos] != ':'; nDotPos-- ) - ; - if( aLine[0] == '/' && aLine[nDotPos] == ':' && aLine[nDotPos+1] == '$' ) - CheckPlugin( ByteString( aLine, nDotPos ), aPlugins ); - } - fclose( fp ); + CheckPlugin( aPath, aPlugins ); } + // create return value aDescriptions = Sequence( aPlugins.size() ); #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "found %d plugins\n", aPlugins.size() ); + fprintf( stderr, "found %d plugins\n", (int)aPlugins.size() ); #endif list::iterator iter; - for( iter = aPlugins.begin(), i=0; iter != aPlugins.end(); ++iter ,i++ ) + sal_Int32 nPlug = 0; + for( iter = aPlugins.begin(); iter != aPlugins.end(); ++iter ) { - aDescriptions.getArray()[ i ] = **iter; + aDescriptions.getArray()[ nPlug++ ] = **iter; delete *iter; } aPlugins.clear(); diff --git a/extensions/source/plugin/aqua/sysplug.cxx b/extensions/source/plugin/aqua/sysplug.cxx index 46d0f8a2746c..5c1ac8ad093b 100644 --- a/extensions/source/plugin/aqua/sysplug.cxx +++ b/extensions/source/plugin/aqua/sysplug.cxx @@ -36,182 +36,776 @@ #include -int MacPluginComm::nConnCounter = 0; - -MacPluginComm::MacPluginComm( - const String& mimetype, - const String& library, - NSView* aParent, - int nDescriptor1, - int nDescriptor2 - ) : -PluginComm( ::rtl::OUStringToOString( library, osl_getThreadTextEncoding() ) )/*, -PluginConnector( nDescriptor2 )*/ -{ - //char pDesc[32]; -// char pWindow[32]; -// sprintf( pWindow, "%d", aParent ); -// sprintf( pDesc, "%d", nDescriptor1 ); -// ByteString aLib( library, osl_getThreadTextEncoding() ); -// -// char* pArgs[5]; -// pArgs[0] = "pluginapp.bin"; -// pArgs[1] = pDesc; -// pArgs[2] = const_cast(aLib.GetBuffer()); -// pArgs[3] = pWindow; -// pArgs[4] = NULL; -// -//#if OSL_DEBUG_LEVEL > 1 -// m_nCommPID = 10; -// fprintf( stderr, "Try to launch: %s %s %s %s, descriptors are %d, %d\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3], nDescriptor1, nDescriptor2 ); -//#endif -// -// if( ! ( m_nCommPID = fork() ) ) -// { -// execvp( pArgs[0], pArgs ); -// fprintf( stderr, "Error: could not exec %s\n", pArgs[0] ); -// _exit(255); -// } -// -// if( m_nCommPID != -1 ) -// { -// // wait for pluginapp.bin to start up -// if( ! WaitForMessage( 5000 ) ) -// { -// fprintf( stderr, "Timeout on command: %s %s %s %s\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3] ); -// invalidate(); -// } -// else -// { -// MediatorMessage* pMessage = GetNextMessage( TRUE ); -// Respond( pMessage->m_nID, -// "init ack",8, -// NULL ); -// delete pMessage; -// NPP_Initialize(); -// } -// } +extern NPNetscapeFuncs aNPNFuncs; + +#include + +using namespace rtl; +using namespace plugstringhelper; + +#if OSL_DEBUG_LEVEL > 1 +void TRACE( char const * s ); +void TRACEN( char const * s, long n ); +#else +#define TRACE(x) +#define TRACEN(x,n) +#endif + +struct FakeEventRecord : public EventRecord +{ + FakeEventRecord() + { + memset( this, 0, sizeof(EventRecord) ); + ::GetGlobalMouse( &where ); + when = ::TickCount(); + modifiers = ::GetCurrentEventKeyModifiers(); + } +}; + + +@interface OOoPluginView : NSView +{ + XPlugin_Impl* m_pImpl; + MacPluginComm* m_pCom; +} +-(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect)i_aRect; +-(void)drawRect: (NSRect)i_aRect; +-(MacOSBOOL)isOpaque; +-(MacOSBOOL)isFlipped; + +// NSResponder +-(void)mouseMoved: (NSEvent*)i_pEvent; +-(void)mouseDown: (NSEvent*)i_pEvent; +-(void)mouseDragged: (NSEvent*)i_pEvent; +-(void)mouseUp: (NSEvent*)i_pEvent; +-(void)rightMouseDown: (NSEvent*)i_pEvent; +-(void)rightMouseDragged: (NSEvent*)i_pEvent; +-(void)rightMouseUp: (NSEvent*)i_pEvent; +-(void)otherMouseDown: (NSEvent*)i_pEvent; +-(void)otherMouseDragged: (NSEvent*)i_pEvent; +-(void)otherMouseUp: (NSEvent*)i_pEvent; +-(void)mouseEntered: (NSEvent*)i_pEvent; +-(void)mouseExited: (NSEvent*)i_pEvent; +@end + +@implementation OOoPluginView +-(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect) i_aRect +{ + if( (self = [super initWithFrame: i_aRect]) ) + { + m_pImpl = i_pImpl; + m_pCom = i_pCom; + } + return self; +} + +-(void)drawRect: (NSRect) i_aRect +{ + m_pCom->drawView( m_pImpl ); +} + +-(MacOSBOOL)isOpaque +{ + return NO; +} + +-(MacOSBOOL)isFlipped +{ + return YES; +} + +// NSResponder +-(void)mouseMoved: (NSEvent*)i_pEvent +{ + FakeEventRecord aRec; + aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)mouseDown: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseDown; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)mouseDragged: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)mouseUp: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseUp; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)rightMouseDown: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseDown; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)rightMouseDragged: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)rightMouseUp: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseUp; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)otherMouseDown: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseDown; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)otherMouseDragged: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)otherMouseUp: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = mouseUp; + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)mouseEntered: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); +} + +-(void)mouseExited: (NSEvent*)i_pEvent; +{ + FakeEventRecord aRec; + aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent + m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec ); } +@end + +//-------------------------------------------------------------------------------------------------- +MacPluginComm::MacPluginComm( const rtl::OUString& i_rMimetype, const rtl::OUString& i_rBundle, NSView* i_pParent ) + : PluginComm( OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ) ), + m_xBundle( NULL ), + m_hPlugLib( NULL ), + m_pNullTimer( NULL ) +{ + // initialize plugin function table + memset( &m_aNPPfuncs, 0, sizeof( m_aNPPfuncs ) ); + + // load the bundle + CFURLRef xURL = createURL( i_rBundle ); + m_xBundle = CFBundleCreate( NULL, xURL ); + CFRelease( xURL ); + if( m_xBundle ) + { + // ask the plugin library + // first get its location + CFURLRef xLibURL = CFBundleCopyExecutableURL( m_xBundle ); + if( xLibURL ) + { + // get the file system path + rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) ); + CFRelease( xLibURL ); + m_hPlugLib = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT ); + #if OSL_DEBUG_LEVEL > 1 + if( ! m_hPlugLib ) + fprintf( stderr, "module %s could not be loaded\n", OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() ); + #endif + } + #if OSL_DEBUG_LEVEL > 1 + else + fprintf( stderr, "bundle %s has no exectutable URL\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() ); + #endif + } + else + { + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "bundle %s could not be loaded\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() ); + #endif + } + + DBG_ASSERT( m_xBundle && m_hPlugLib, "loading plugin bundle failed!" ); + + + m_aNPPfuncs.size = sizeof( m_aNPPfuncs ); + m_aNPPfuncs.version = 0; + + + m_eCall = eNP_Initialize; + execute(); +} + +//-------------------------------------------------------------------------------------------------- MacPluginComm::~MacPluginComm() { - NPP_Shutdown(); - if( m_nCommPID != -1 && m_nCommPID != 0 ) + if( m_hPlugLib ) { - int status = 16777216; -#if OSL_DEBUG_LEVEL > 1 - pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED ); - fprintf( stderr, "child %d (plugin app child %d) exited with status %d\n", nExit, m_nCommPID, WEXITSTATUS(status) ); -#else - waitpid( m_nCommPID, &status, WUNTRACED ); -#endif + // NPP_Shutdown(); + NPError (*pShutdown)(); + if( retrieveFunction( "NP_Shutdown", (void**)&pShutdown ) ) + { + NPError nErr = (*pShutdown)(); (void)nErr; + DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_Shutdown() failed!" ); + } + osl_unloadModule( m_hPlugLib ); } + if( m_xBundle ) + CFRelease( m_xBundle ); } -NPError MacPluginComm::NPP_Destroy( NPP instance, - NPSavedData** save ) +//-------------------------------------------------------------------------------------------------- +BOOL MacPluginComm::retrieveFunction( const char* i_pName, void** o_ppFunc ) const { - return 0; + if( ! m_hPlugLib || ! o_ppFunc ) + return FALSE; + + *o_ppFunc = (void*)osl_getAsciiFunctionSymbol( m_hPlugLib, i_pName ); + + if( ! *o_ppFunc && m_xBundle ) + { + rtl::OUString aName( OUString::createFromAscii( *i_pName == '_' ? i_pName+1 : i_pName ) ); + CFStringRef xName = createString( aName ); + if( xName ) + { + *o_ppFunc = CFBundleGetFunctionPointerForName( m_xBundle, xName ); + CFRelease( xName ); + } + } + + return (*o_ppFunc != NULL); } -NPError MacPluginComm::NPP_DestroyStream( NPP instance, - NPStream* stream, - NPError reason ) +IMPL_LINK( MacPluginComm, NullTimerHdl, void*, EMPTYARG ) { + // note: this is a Timer handler, we are already protected by the SolarMutex + + FakeEventRecord aRec; + aRec.what = nullEvent; + aRec.where.h = aRec.where.v = 20000; + + for( std::list< XPlugin_Impl* >::iterator it = m_aNullEventClients.begin(); + it != m_aNullEventClients.end(); ++it ) + { + SysPlugData& rPlugData( (*it)->getSysPlugData() ); + if( rPlugData.m_pPlugView ) // for safety do not dispatch null events before first NPP_SetWindow + (*m_aNPPfuncs.event)( (*it)->getNPPInstance(), &aRec ); + } + return 0; } -void* MacPluginComm::NPP_GetJavaClass() +//-------------------------------------------------------------------------------------------------- + +long MacPluginComm::doIt() { - return 0; + long nRet = 0; + switch( m_eCall ) + { + case eNP_Initialize: + { + TRACE( "eNP_Initialize" ); + NPError (*pInit)( NPNetscapeFuncs* ); + if( retrieveFunction( "NP_Initialize", (void**)&pInit ) ) + { + nRet = (*pInit)( &aNPNFuncs ); + + NPError nErr = NPERR_NO_ERROR; + NPError (*pEntry)( NPPluginFuncs* ); + retrieveFunction( "NP_GetEntryPoints", (void**)&pEntry ); + nErr = (*pEntry)( &m_aNPPfuncs ); + + DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_GetEntryPoints() failed!" ); + } + else + { + nRet = NPERR_GENERIC_ERROR; + } + DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" ); + } + break; + case eNPP_Destroy: + if( m_aNullEventClients.empty() ) + delete m_pNullTimer, m_pNullTimer = NULL; + + TRACE( "eNPP_Destroy" ); + nRet = (m_aNPPfuncs.destroy + ? (*m_aNPPfuncs.destroy)( + (NPP)m_aArgs[0], + (NPSavedData**)m_aArgs[1] ) + : NPERR_GENERIC_ERROR); + break; + case eNPP_DestroyStream: + TRACE( "eNPP_DestroyStream" ); + nRet = (m_aNPPfuncs.destroystream + ? (*m_aNPPfuncs.destroystream)( + (NPP)m_aArgs[0], + (NPStream*)m_aArgs[1], + (NPError)(sal_IntPtr)m_aArgs[2] ) + : NPERR_GENERIC_ERROR); + break; + case eNPP_New: + TRACE( "eNPP_New" ); + nRet = (m_aNPPfuncs.newp + ? (*m_aNPPfuncs.newp)( + (NPMIMEType)m_aArgs[0], + (NPP)m_aArgs[1], + (uint16)(sal_IntPtr)m_aArgs[2], + (int16)(sal_IntPtr)m_aArgs[3], + (char**)m_aArgs[4], + (char**)m_aArgs[5], + (NPSavedData*)m_aArgs[6] ) + : NPERR_GENERIC_ERROR); + + if( ! m_pNullTimer && m_aNPPfuncs.event ) + { + m_pNullTimer = new AutoTimer(); + m_pNullTimer->SetTimeout( 50 ); + m_pNullTimer->SetTimeoutHdl( LINK( this, MacPluginComm, NullTimerHdl ) ); + m_pNullTimer->Start(); + } + + break; + case eNPP_NewStream: + TRACE( "eNPP_NewStream" ); + nRet = (m_aNPPfuncs.newstream + ? (*m_aNPPfuncs.newstream)( + (NPP)m_aArgs[0], + (NPMIMEType)m_aArgs[1], + (NPStream*)m_aArgs[2], + (NPBool)(sal_IntPtr)m_aArgs[3], + (uint16*)m_aArgs[4] ) + : NPERR_GENERIC_ERROR); + break; + case eNPP_Print: + TRACE( "eNPP_Print" ); + if (m_aNPPfuncs.print) + (*m_aNPPfuncs.print)( + (NPP)m_aArgs[0], + (NPPrint*)m_aArgs[1] ); + break; + case eNPP_SetWindow: + { + TRACE( "eNPP_SetWindow" ); + nRet = (m_aNPPfuncs.setwindow + ? (*m_aNPPfuncs.setwindow)( + (NPP)m_aArgs[0], + (NPWindow*)m_aArgs[1] ) + : NPERR_GENERIC_ERROR); + + break; + } + case eNPP_HandleEvent: + { + TRACE( "eNPP_HandleEvent" ); + nRet = (m_aNPPfuncs.event + ? (*m_aNPPfuncs.event)( + (NPP)m_aArgs[0], + m_aArgs[1] ) + : NPERR_GENERIC_ERROR); + + break; + } + case eNPP_StreamAsFile: + TRACE( "eNPP_StreamAsFile" ); + if (m_aNPPfuncs.asfile) + (*m_aNPPfuncs.asfile)( + (NPP)m_aArgs[0], + (NPStream*)m_aArgs[1], + (char*)m_aArgs[2] ); + break; + case eNPP_URLNotify: + TRACE( "eNPP_URLNotify" ); + if (m_aNPPfuncs.urlnotify) + (*m_aNPPfuncs.urlnotify)( + (NPP)m_aArgs[0], + (char*)m_aArgs[1], + (NPReason)(sal_IntPtr)m_aArgs[2], + m_aArgs[3] ); + break; + case eNPP_Write: + TRACEN( "eNPP_Write n=", (int32)m_aArgs[3] ); + nRet = (m_aNPPfuncs.write + ? (*m_aNPPfuncs.write)( + (NPP)m_aArgs[0], + (NPStream*)m_aArgs[1], + (int32)m_aArgs[2], + (int32)m_aArgs[3], + m_aArgs[4] ) + : 0); + break; + case eNPP_WriteReady: + TRACE( "eNPP_WriteReady" ); + nRet = (m_aNPPfuncs.writeready + ? (*m_aNPPfuncs.writeready)( + (NPP)m_aArgs[0], + (NPStream*)m_aArgs[1] ) + : 0); + break; + case eNPP_GetValue: + TRACE( "eNPP_GetValue" ); + nRet = (m_aNPPfuncs.getvalue + ? (*m_aNPPfuncs.getvalue)( + (NPP)m_aArgs[0], + (NPPVariable)(int)m_aArgs[1], + m_aArgs[2] ) + : NPERR_GENERIC_ERROR); + break; + case eNPP_SetValue: + TRACE( "eNPP_SetValue" ); + nRet = (m_aNPPfuncs.setvalue + ? (*m_aNPPfuncs.setvalue)( + (NPP)m_aArgs[0], + (NPNVariable)(int)m_aArgs[1], + m_aArgs[2] ) + : NPERR_GENERIC_ERROR); + break; + case eNPP_Shutdown: + { + TRACE( "eNPP_Shutdown" ); + NPP_ShutdownUPP pFunc; + if (retrieveFunction( "NPP_Shutdown", (void**)&pFunc )) + (*pFunc)(); + } + break; + case eNPP_Initialize: + TRACE( "eNPP_Initialize" ); + OSL_ENSURE( false, "NPP_Initialize: not implemented!" ); + break; + case eNPP_GetJavaClass: + TRACE( "eNPP_GetJavaClass" ); + OSL_ENSURE( false, "NPP_GetJavaClass: not implemented!" ); + break; + } + return nRet; } -NPError MacPluginComm::NPP_Initialize() +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save ) { - return 0; + // remove from NullEvent timer + m_aNullEventClients.remove( i_pImpl ); + + NPError nErr = NPP_Destroy( i_pImpl->getNPPInstance(), save ); + + // release plugin view + SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); + if( rPlugData.m_pPlugView ) + { + [rPlugData.m_pPlugView removeFromSuperview]; + [rPlugData.m_pPlugView release]; + rPlugData.m_pPlugView = nil; + } + + return nErr; } -NPError MacPluginComm::NPP_New( NPMIMEType pluginType, - NPP instance, - uint16 mode, - int16 argc, - char* argn[], - char* argv[], - NPSavedData *saved ) + +NPError MacPluginComm::NPP_Destroy( NPP instance, NPSavedData** save ) { - return 0; + DBG_ASSERT( m_aNPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" ); + m_eCall = eNPP_Destroy; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)save; + return (NPError)execute(); } -NPError MacPluginComm::NPP_NewStream( NPP instance, - NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype ) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) { - return 0; + DBG_ASSERT( m_aNPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" ); + m_eCall = eNPP_DestroyStream; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)stream; + m_aArgs[2] = (void*)reason; + return (NPError)execute(); } -void MacPluginComm::NPP_Print( NPP instance, - NPPrint* platformPrint ) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ) { + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + DBG_ASSERT( pImpl, "no instance found" ); + if( pImpl ) // sanity check + m_aNullEventClients.push_back( pImpl ); + + DBG_ASSERT( m_aNPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" ); + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "NPP_New( %s. %p, %d, %d", + pluginType, instance, (int)mode, (int)argc ); + for( int16 i = 0; i < argc; i++ ) + fprintf( stderr, "\n%s = %s", argn[i], argv[i] ); + fprintf( stderr, ", %p )\n", saved ); + #endif + m_eCall = eNPP_New; + m_aArgs[0] = (void*)pluginType; + m_aArgs[1] = (void*)instance; + m_aArgs[2] = (void*)mode; + m_aArgs[3] = (void*)argc; + m_aArgs[4] = (void*)argn; + m_aArgs[5] = (void*)argv; + m_aArgs[6] = (void*)saved; + + return (NPError)execute(); } -NPError MacPluginComm::NPP_SetWindow( NPP instance, - NPWindow* window ) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ) { - return 0; + DBG_ASSERT( m_aNPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" ); + m_eCall = eNPP_NewStream; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)type; + m_aArgs[2] = (void*)stream; + m_aArgs[3] = (void*)seekable; + m_aArgs[4] = (void*)stype; + return (NPError)execute(); } -void MacPluginComm::NPP_Shutdown() +//-------------------------------------------------------------------------------------------------- +void MacPluginComm::NPP_Print( NPP instance, NPPrint* platformPrint ) { + DBG_ASSERT( m_aNPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" ); + m_eCall = eNPP_Print; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)platformPrint; + execute(); +} +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_SetWindow( NPP instance, NPWindow* window ) +{ + DBG_ASSERT( m_aNPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" ); + m_eCall = eNPP_SetWindow; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)window; + return (NPError)execute(); } -void MacPluginComm::NPP_StreamAsFile( NPP instance, - NPStream* stream, - const char* fname ) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_HandleEvent( NPP instance, void* event ) { + DBG_ASSERT( m_aNPPfuncs.event, "### NPP_HandleEvent(): null pointer in NPP functions table!" ); + m_eCall = eNPP_HandleEvent; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = event; + return (NPError)execute(); +} +//-------------------------------------------------------------------------------------------------- +void MacPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) +{ + DBG_ASSERT( m_aNPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" ); + m_eCall = eNPP_StreamAsFile; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)stream; + m_aArgs[2] = (void*)fname; + execute(); } -void MacPluginComm::NPP_URLNotify( NPP instance, - const char* url, - NPReason reason, - void* notifyData ) +//-------------------------------------------------------------------------------------------------- +void MacPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) { + DBG_ASSERT( m_aNPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" ); + m_eCall = eNPP_URLNotify; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)url; + m_aArgs[2] = (void*)reason; + m_aArgs[3] = notifyData; + execute(); +} +//-------------------------------------------------------------------------------------------------- +int32 MacPluginComm::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer ) +{ + DBG_ASSERT( m_aNPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" ); + m_eCall = eNPP_Write; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)stream; + m_aArgs[2] = (void*)offset; + m_aArgs[3] = (void*)len; + m_aArgs[4] = buffer; + return (NPError)execute(); } -int32 MacPluginComm::NPP_Write( NPP instance, - NPStream* stream, - int32 offset, - int32 len, - void* buffer ) +//-------------------------------------------------------------------------------------------------- +int32 MacPluginComm::NPP_WriteReady( NPP instance, NPStream* stream ) { - return 0; + DBG_ASSERT( m_aNPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" ); + m_eCall = eNPP_WriteReady; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)stream; + return execute(); } -int32 MacPluginComm::NPP_WriteReady( NPP instance, - NPStream* stream ) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ) { - return 0; + DBG_ASSERT( m_aNPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" ); + m_eCall = eNPP_GetValue; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)variable; + m_aArgs[2] = ret_value; + return (NPError)execute(); } -char* MacPluginComm::NPP_GetMIMEDescription() +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_SetValue( NPP instance, NPNVariable variable, void *set_value ) { - return ""; + DBG_ASSERT( m_aNPPfuncs.setvalue, "### NPP_SetValue(): null pointer in NPP functions table!" ); + m_eCall = eNPP_SetValue; + m_aArgs[0] = (void*)instance; + m_aArgs[1] = (void*)variable; + m_aArgs[2] = set_value; + return (NPError)execute(); } -NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void* value ) +//-------------------------------------------------------------------------------------------------- +void * MacPluginComm::NPP_GetJavaClass() { + DBG_ERROR( "no java class available!" ); return 0; } -NPError MacPluginComm::NPP_SetValue( NPP instance, - NPNVariable variable, - void *value) +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_Initialize() { - return 0; + return NPERR_NO_ERROR; +} + +//-------------------------------------------------------------------------------------------------- +void MacPluginComm::NPP_Shutdown() +{ + m_eCall = eNPP_Shutdown; + execute(); +} + +//-------------------------------------------------------------------------------------------------- +NPError MacPluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl ) +{ + // update window NPWindow from view + SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); + + // update plug view + NSRect aPlugRect = [rPlugData.m_pParentView frame]; + aPlugRect.origin.x = aPlugRect.origin.y = 0; + if( ! rPlugData.m_pPlugView ) + { + rPlugData.m_pPlugView = [[OOoPluginView alloc] initWithInstance: i_pImpl pluginComm: this frame: aPlugRect]; + [rPlugData.m_pParentView addSubview: rPlugData.m_pPlugView]; + } + else + [rPlugData.m_pPlugView setFrame: aPlugRect]; + + NPWindow* pNPWin = i_pImpl->getNPWindow(); + NSWindow* pWin = [rPlugData.m_pPlugView window]; + NSRect aWinRect = [pWin frame]; + NSRect aBounds = [rPlugData.m_pPlugView frame]; + NSRect aVisibleBounds = [rPlugData.m_pPlugView visibleRect]; + + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "visible bounds = %d+%d+%dx%d\n", + (int)aVisibleBounds.origin.x, (int)aVisibleBounds.origin.y, + (int)aVisibleBounds.size.width, (int)aVisibleBounds.size.height ); + #endif + + NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil]; + // save view origin so we can notice movement of the view in drawView + // in case of a moved view we need to reset the port/context + rPlugData.m_aLastPlugViewOrigin = aViewOrigin; + + // convert view origin to topdown coordinates + aViewOrigin.y = aWinRect.size.height - aViewOrigin.y; + + // same for clipping + NSPoint aClipOrigin = [rPlugData.m_pPlugView convertPoint: aVisibleBounds.origin toView: nil]; + aClipOrigin.y = aWinRect.size.height - aClipOrigin.y; + + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "view origin: %d+%d, clip origin = %d+%d\n", + (int)aViewOrigin.x, (int)aViewOrigin.y, + (int)aClipOrigin.x, (int)aClipOrigin.y ); + #endif + + pNPWin->x = aViewOrigin.x; + pNPWin->y = aViewOrigin.y; + pNPWin->width = aBounds.size.width; + pNPWin->height = aBounds.size.height; + pNPWin->clipRect.left = aClipOrigin.x; + pNPWin->clipRect.top = aClipOrigin.y; + pNPWin->clipRect.right = aClipOrigin.x + aVisibleBounds.size.width; + pNPWin->clipRect.bottom = aClipOrigin.y + aVisibleBounds.size.height; + + if( rPlugData.m_nDrawingModel == 1 ) + { + rPlugData.m_aCGContext.window = reinterpret_cast([pWin windowRef]); + pNPWin->window = &rPlugData.m_aCGContext; + rPlugData.m_aCGContext.context = reinterpret_cast([[pWin graphicsContext] graphicsPort]); + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "window is %p, context is %p\n", + rPlugData.m_aCGContext.window, rPlugData.m_aCGContext.context ); + #endif + } + else + { + rPlugData.m_aNPPort.port = GetWindowPort( reinterpret_cast([pWin windowRef]) ); + rPlugData.m_aNPPort.portx = aClipOrigin.x; + rPlugData.m_aNPPort.porty = aClipOrigin.y; + pNPWin->window = &rPlugData.m_aNPPort; + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "port is %p at (%d,%d)\n", + rPlugData.m_aNPPort.port, (int)rPlugData.m_aNPPort.portx, (int)rPlugData.m_aNPPort.porty ); + #endif + } + + if( pNPWin->width == 0 || pNPWin->height == 0 || [rPlugData.m_pPlugView isHiddenOrHasHiddenAncestor] ) + rPlugData.m_bSetWindowOnDraw = true; + + NPError nErr = NPP_SetWindow( i_pImpl->getNPPInstance(), i_pImpl->getNPWindow() ); + + return nErr; +} + +void MacPluginComm::drawView( XPlugin_Impl* i_pImpl ) +{ + SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); + + // check if the view was moved since the last SetWindow + NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil]; + if( rPlugData.m_bSetWindowOnDraw || + aViewOrigin.x != rPlugData.m_aLastPlugViewOrigin.x || + aViewOrigin.y != rPlugData.m_aLastPlugViewOrigin.y ) + { + NPP_SetWindow( i_pImpl ); + rPlugData.m_bSetWindowOnDraw = false; + } + + // send a paint event + NSWindow* pWin = [rPlugData.m_pPlugView window]; + FakeEventRecord aRec; + aRec.what = updateEvt; + aRec.message = (UInt32)[pWin windowRef]; + this->NPP_HandleEvent( i_pImpl->getNPPInstance(), &aRec ); } diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx index ef19a9944c51..73cf259aeccd 100644 --- a/extensions/source/plugin/base/nfuncs.cxx +++ b/extensions/source/plugin/base/nfuncs.cxx @@ -51,7 +51,7 @@ void TRACE( char const * s ) if (s_file) { oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%d]: %s\n", t, s ); + fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s\n", t, s ); fflush( s_file ); } } @@ -62,7 +62,7 @@ void TRACEN( char const * s, long n ) if (s_file) { oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%d]: %s%d\n", t, s, n ); + fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s%ld\n", t, s, n ); fflush( s_file ); } } @@ -73,7 +73,7 @@ void TRACES( char const* s, char const* s2 ) if (s_file) { oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%d]: %s %s\n", t, s, s2 ); + fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s %s\n", t, s, s2 ); fflush( s_file ); } } @@ -477,30 +477,29 @@ extern "C" { const char* SAL_CALL NP_LOADDS NPN_UserAgent( NPP instance ) { - TRACE( "NPN_UserAgent" ); - static char* pAgent = strdup( "Mozilla" ); + static char* pAgent = strdup( "Mozilla 3.0" ); XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return pAgent; - - ::rtl::OUString UserAgent; - try + if( pImpl ) { - pImpl->enterPluginCallback(); - UserAgent = pImpl->getPluginContext()-> - getUserAgent( pImpl ); - pImpl->leavePluginCallback(); - } - catch( ::com::sun::star::plugin::PluginException& ) - { - pImpl->leavePluginCallback(); - return pAgent; + rtl::OUString UserAgent; + try + { + pImpl->enterPluginCallback(); + UserAgent = pImpl->getPluginContext()-> + getUserAgent( pImpl ); + pImpl->leavePluginCallback(); + if( pAgent ) + free( pAgent ); + pAgent = strdup( ::rtl::OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() ); + } + catch( ::com::sun::star::plugin::PluginException& ) + { + pImpl->leavePluginCallback(); + } } - if( pAgent ) - free( pAgent ); - pAgent = strdup( ::rtl::OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() ); + TRACES( "NPN_UserAgent: returning", pAgent ); return pAgent; } @@ -537,7 +536,7 @@ int32 SAL_CALL NP_LOADDS NPN_Write( NPP instance, NPStream* stream, int32 len, NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, void* value ) { - TRACE( "NPN_GetValue" ); + TRACEN( "NPN_GetValue: ", variable ); XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); if( ! pImpl ) @@ -554,6 +553,14 @@ NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, vo default: aResult = NPERR_INVALID_PARAM; break; + #ifdef QUARTZ + case 2000: // NPNVsupportsQuickDrawBool + *(NPBool*)value = false; + break; + case 2001: // NPNVsupportsCoreGraphicsBool + *(NPBool*)value = true; + break; + #endif case NPNVjavascriptEnabledBool: // no javascript *(NPBool*)value = false; @@ -594,26 +601,75 @@ void SAL_CALL NP_LOADDS NPN_ReloadPlugins(NPBool /*reloadPages*/) } -NPError SAL_CALL NP_LOADDS NPN_SetValue(NPP /*instance*/, NPPVariable /*variable*/, - void* /*value*/) +NPError SAL_CALL NP_LOADDS NPN_SetValue( NPP instance, + NPPVariable variable, + void* value ) { - TRACE( "NPN_SetValue" ); - return 0; + NPError nError = NPERR_NO_ERROR; + TRACEN( "NPN_SetValue ", variable ); + switch( variable ) + { + #ifdef QUARTZ + case (NPPVariable)1000: // NPNVpluginDrawingModel + { + int nDrawingModel = (int)value; // ugly, but that's the way we need to do it + + TRACEN( "drawing model: ", nDrawingModel ); + + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( pImpl ) + pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel; + } + break; + #endif + case NPPVpluginNameString: // make the windows compiler happy, it needs at least one case statement + break; + default: + break; + } + #ifndef QUARTZ + (void)instance; + (void)value; + #endif + return nError; } -void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP /*instance*/, NPRect* /*invalidRect*/) +void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect* /*invalidRect*/) { TRACE( "NPN_InvalidateRect" ); + + #ifdef QUARTZ + NPN_ForceRedraw( instance ); + #else + (void)instance; + #endif } -void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP /*instance*/, NPRegion /*invalidRegion*/) +void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion /*invalidRegion*/) { TRACE( "NPN_InvalidateRegion" ); + + #ifdef QUARTZ + NPN_ForceRedraw( instance ); + #else + (void)instance; + #endif } -void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP /*instance*/) +void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP instance) { TRACE( "NPN_ForceRedraw" ); + #ifdef QUARTZ + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( pImpl ) + { + SysPlugData& rPlugData( pImpl->getSysPlugData() ); + if( rPlugData.m_pPlugView ) + [rPlugData.m_pPlugView setNeedsDisplay: YES]; + } + #else + (void)instance; + #endif } } diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx index bc836a6fe73e..1d3566bd2873 100644 --- a/extensions/source/plugin/base/plcom.cxx +++ b/extensions/source/plugin/base/plcom.cxx @@ -60,3 +60,14 @@ PluginComm::~PluginComm() aEntry.Kill(); } } + +NPError PluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl ) +{ + return NPP_SetWindow( i_pImpl->getNPPInstance(), i_pImpl->getNPWindow() ); +} + +NPError PluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save ) +{ + return NPP_Destroy( i_pImpl->getNPPInstance(), save ); +} + diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx index 2833cf78bdee..61d860f6977c 100644 --- a/extensions/source/plugin/base/xplugin.cxx +++ b/extensions/source/plugin/base/xplugin.cxx @@ -121,6 +121,7 @@ XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiSe { memset( &m_aInstance, 0, sizeof( m_aInstance ) ); memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) ); + memset( &m_aSysPlugData, 0, sizeof( m_aSysPlugData ) ); m_xModel = new PluginModel(); uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); @@ -139,8 +140,7 @@ void XPlugin_Impl::destroyInstance() destroyStreams(); if( getPluginComm() ) { - getPluginComm()->NPP_Destroy( getNPPInstance(), - &pSavedData ); + getPluginComm()->NPP_Destroy( this, &pSavedData ); getPluginComm()->decRef(); m_pPluginComm = NULL; } @@ -218,8 +218,7 @@ IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, /*pThis*/ ) m_aNPWindow.window = NULL; #ifndef UNX // acrobat does an unconditional XtParent on the windows widget - getPluginComm()-> - NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); + getPluginComm()->NPP_SetWindow( this ); #endif destroyInstance(); PluginControl_Impl::dispose(); @@ -520,26 +519,21 @@ void XPlugin_Impl::loadPlugin() { if( m_aDescription.PluginName.getLength() ) { -#ifdef UNX +#if defined QUARTZ + PluginComm* pComm = new MacPluginComm( m_aDescription.Mimetype, + m_aDescription.PluginName, + pEnvData->pView ); +#elif defined UNX // need a new PluginComm PluginComm* pComm = NULL; int sv[2]; if( !socketpair( AF_UNIX, SOCK_STREAM, 0, sv ) ) -#ifdef QUARTZ - pComm = new MacPluginComm( m_aDescription.Mimetype, - m_aDescription.PluginName, - pEnvData->pView, - sv[0], - sv[1] - ); -#else pComm = new UnxPluginComm( m_aDescription.Mimetype, m_aDescription.PluginName, (XLIB_Window)pEnvData->aWindow, sv[0], sv[1] ); -#endif //QUARTZ #elif (defined WNT || defined OS2) PluginComm* pComm = new PluginComm_Impl( m_aDescription.Mimetype, m_aDescription.PluginName, @@ -560,19 +554,13 @@ void XPlugin_Impl::loadPlugin() (char**)(m_nArgs ? m_pArgn : NULL), (char**)(m_nArgs ? m_pArgv : NULL), NULL ); - -#if defined( UNX ) && !defined(QUARTZ) +#ifdef QUARTZ + // m_aNPWindow is set up in the MacPluginComm from the view + m_aSysPlugData.m_pParentView = pEnvData->pView; +#elif defined( UNX ) XSync( (Display*)pEnvData->pDisplay, False ); -#endif -#ifdef UNX -#if !defined(QUARTZ) m_aNPWindow.window = (void*)pEnvData->aWindow; m_aNPWindow.ws_info = NULL; -#else - // FIXME: this is untested and possiblz wrong - m_aNPWindow.window = (void*)pEnvData->pView; - m_aNPWindow.type = NPWindowTypeWindow; -#endif //QUARTZ #else m_aNPWindow.window = (void*)pEnvData->hWnd; #endif @@ -604,8 +592,7 @@ void XPlugin_Impl::loadPlugin() m_aNPWindow.width = aPosSize.Width ? aPosSize.Width : 600; m_aNPWindow.height = aPosSize.Height ? aPosSize.Height : 600; - aError = getPluginComm()-> - NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); + aError = getPluginComm()->NPP_SetWindow( this ); } void XPlugin_Impl::destroyStreams() @@ -768,7 +755,7 @@ sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype, fprintf( stderr, "new stream \"%s\" of MIMEType \"%s\"\n" "for plugin \"%s\"\n" - "seekable = %s, length = %d\n", + "seekable = %s, length = %"SAL_PRIdINT32"\n", aURL.getStr(), aMIME.getStr(), getPluginComm()->getLibName().getStr(), isfile ? "true" : "false", length ); @@ -879,7 +866,7 @@ void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, Guard< Mutex > aGuard( m_aMutex ); #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "XPlugin_Impl::setPosSize( %d, %d, %d, %d, %d )\n", + fprintf( stderr, "XPlugin_Impl::setPosSize( %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %d )\n", nX_, nY_, nWidth_, nHeight_, nFlags ); #endif @@ -894,8 +881,8 @@ void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16, sal_Int32 >( nWidth_ ); m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16, sal_Int32 >( nHeight_ ); - if(getPluginComm()) - getPluginComm()->NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); + if( getPluginComm() ) + getPluginComm()->NPP_SetWindow( this ); } PluginDescription XPlugin_Impl::fitDescription( const OUString& rURL ) @@ -959,8 +946,7 @@ PluginStream::~PluginStream() m_pPlugin->getPluginComm()->NPP_DestroyStream( m_pPlugin->getNPPInstance(), &m_aNPStream, NPRES_DONE ); m_pPlugin->checkListeners( m_aNPStream.url ); - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin->getNPPInstance(), - m_pPlugin->getNPWindow()); + m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); } ::free( (void*)m_aNPStream.url ); } @@ -1018,8 +1004,7 @@ PluginInputStream::~PluginInputStream() &m_aNPStream, aFileName.GetBuffer() ); } - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin->getNPPInstance(), - m_pPlugin->getNPWindow()); + m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); m_pPlugin->getInputStreams().remove( this ); } else diff --git a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx index 2cb70ff90d91..3987b0f6f4e0 100644 --- a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx +++ b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx @@ -35,65 +35,135 @@ #include #include #include -#include +#include "premac.h" #include #include -#include +#include "postmac.h" #undef uint32 -#include -#include -#include -#include +#define XP_MAC +#include "npsdk/npapi.h" +#include "npsdk/npupp.h" + +#include "plugin/plcom.hxx" +#include "premac.h" #include -#include +#include "postmac.h" + +#include "vcl/sysdata.hxx" +#include "vcl/threadex.hxx" +#include "vcl/timer.hxx" +#include "osl/module.h" -#include +class XPlugin_Impl; +namespace plugstringhelper +{ +rtl::OUString getString( CFStringRef i_xString ); +rtl::OUString getString( CFURLRef i_xURL ); +CFMutableStringRef createString( const rtl::OUString& i_rString ); +CFURLRef createURL( const rtl::OUString& i_rString ); +rtl::OUString getURLFromPath( const rtl::OUString& i_rPath ); +CFURLRef createURLFromPath( const rtl::OUString& i_rPath ); +rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL ); +} //================================================================================================== -class MacPluginComm : public PluginComm +class MacPluginComm : + public PluginComm, + public ::vcl::SolarThreadExecutor + { -private: - static int nConnCounter; + enum CallType { + eNPP_Destroy, + eNPP_DestroyStream, + eNPP_GetJavaClass, + eNPP_Initialize, + eNPP_New, + eNPP_NewStream, + eNPP_Print, + eNPP_SetWindow, + eNPP_Shutdown, + eNPP_StreamAsFile, + eNPP_URLNotify, + eNPP_Write, + eNPP_WriteReady, + eNPP_GetValue, + eNPP_SetValue, + eNPP_HandleEvent, + eNP_Initialize + }; - pid_t m_nCommPID; + void* m_aArgs[ 8 ]; + CallType m_eCall; + + virtual long doIt(); public: - MacPluginComm( const String& mimetype, - const String& library, - NSView* pParent, - int nDescriptor1, - int nDescriptor2 - ); - virtual ~MacPluginComm(); - - virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); - virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, - NPError reason ); - virtual void* NPP_GetJavaClass(); - virtual NPError NPP_Initialize(); - virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, - uint16 mode, int16 argc, - char* argn[], char* argv[], NPSavedData *saved ); - virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, - NPStream* stream, - NPBool seekable, uint16* stype ); - virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); - virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); - virtual void NPP_Shutdown(); - virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, - const char* fname ); - virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason, - void* notifyData ); - virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, - int32 len, void* buffer ); - virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); - virtual char* NPP_GetMIMEDescription(); - virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ); - virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, - void *value); + MacPluginComm( const rtl::OUString& rMIME, const rtl::OUString& rName, NSView* pView ); + virtual ~MacPluginComm(); + + // FIXME: + // this actually should be from the NP headers + // but currently we have too old a version + // changes this when we have updated our headers + typedef struct NP_CGContext + { + CGContextRef context; + WindowRef window; + } NP_CGContext; + +public: + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); + virtual void * NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_value ); + virtual int16 NPP_HandleEvent( NPP instance, void* event ); + + virtual NPError NPP_SetWindow( XPlugin_Impl* ); + virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); + + void drawView( XPlugin_Impl* ); +private: + BOOL retrieveFunction( const char* i_pName, void** i_ppFunc ) const; + DECL_LINK( NullTimerHdl, void* ); + +private: + CFBundleRef m_xBundle; + oslModule m_hPlugLib; + NPPluginFuncs m_aNPPfuncs; + + // timer for sending nullEvents + AutoTimer* m_pNullTimer; + std::list< XPlugin_Impl* > m_aNullEventClients; }; +struct SysPlugData +{ + MacPluginComm::NP_CGContext m_aCGContext; + NP_Port m_aNPPort; + NSView* m_pParentView; + NSView* m_pPlugView; + int m_nDrawingModel; + NSPoint m_aLastPlugViewOrigin; + bool m_bSetWindowOnDraw; +}; + + #endif diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx index 8c67892aefb5..d3d583476686 100644 --- a/extensions/source/plugin/inc/plugin/impl.hxx +++ b/extensions/source/plugin/inc/plugin/impl.hxx @@ -34,64 +34,73 @@ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "cppuhelper/weak.hxx" + +#include "com/sun/star/awt/Key.hpp" +#include "com/sun/star/awt/KeyFunction.hpp" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/plugin/PluginMode.hpp" +#include "com/sun/star/plugin/PluginDescription.hpp" +#include "com/sun/star/plugin/PluginException.hpp" +#include "com/sun/star/plugin/PluginVariable.hpp" +#include "com/sun/star/plugin/XPlugin.hpp" +#include "com/sun/star/plugin/XPluginManager.hpp" +#include "com/sun/star/plugin/XPluginContext.hpp" +#include "com/sun/star/io/XConnectable.hpp" +#include "com/sun/star/io/XOutputStream.hpp" +#include "com/sun/star/io/XDataOutputStream.hpp" +#include "com/sun/star/io/XActiveDataControl.hpp" +#include "com/sun/star/io/XDataInputStream.hpp" +#include "com/sun/star/io/XMarkableStream.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "com/sun/star/io/XStreamListener.hpp" +#include "com/sun/star/io/XActiveDataSink.hpp" +#include "com/sun/star/io/XActiveDataSource.hpp" +#include "com/sun/star/lang/XServiceName.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/awt/GradientStyle.hpp" +#include "com/sun/star/awt/RasterOperation.hpp" +#include "com/sun/star/awt/Gradient.hpp" +#include "com/sun/star/awt/XGraphics.hpp" + +#include "cppuhelper/implbase3.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implbase1.hxx" -#ifdef WNT -#include -#else #include + +#ifdef WNT +#include "plugin/win/sysplug.hxx" #endif #ifdef OS2 -#include +#include "plugin/os2/sysplug.hxx" #endif #if defined(UNX) #if defined(QUARTZ) -#include +#include "plugin/aqua/sysplug.hxx" #else -#include +#include "plugin/unx/sysplug.hxx" #endif #endif -#include -#include -#include -#include -#include -#include +#if ! defined (QUARTZ) +// the QUARTZ implementation needs special instance data +typedef int SysPlugData; +#endif + +#include "plugin/plctrl.hxx" +#include "plugin/model.hxx" + +#include "vcl/sysdata.hxx" +#include "vcl/syschild.hxx" + +#include "tools/link.hxx" +#include "tools/stream.hxx" + using namespace com::sun::star::uno; @@ -120,6 +129,7 @@ private: PluginComm* m_pPluginComm; NPP_t m_aInstance; NPWindow m_aNPWindow; + SysPlugData m_aSysPlugData; rtl_TextEncoding m_aEncoding; const char** m_pArgv; @@ -182,6 +192,7 @@ public: rtl_TextEncoding getTextEncoding() { return m_aEncoding; } NPP getNPPInstance() { return &m_aInstance; } NPWindow* getNPWindow() { return &m_aNPWindow; } + SysPlugData& getSysPlugData() { return m_aSysPlugData; } void enterPluginCallback() { m_nCalledFromPlugin++; } void leavePluginCallback() { m_nCalledFromPlugin--; } diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx index 8ea7e80226ea..1ea42d933467 100644 --- a/extensions/source/plugin/inc/plugin/plcom.hxx +++ b/extensions/source/plugin/inc/plugin/plcom.hxx @@ -33,6 +33,8 @@ #include #include +class XPlugin_Impl; + class PluginComm { protected: @@ -78,6 +80,9 @@ public: virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ) = 0; virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value) = 0; + + virtual NPError NPP_SetWindow( XPlugin_Impl* ); + virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); }; #endif diff --git a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx index 5566c9aef6d1..910c9e9ac6ca 100644 --- a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx +++ b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx @@ -51,6 +51,7 @@ public: ); virtual ~UnxPluginComm(); + using PluginComm::NPP_Destroy; virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); @@ -63,6 +64,8 @@ public: NPStream* stream, NPBool seekable, uint16* stype ); virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + + using PluginComm::NPP_SetWindow; virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); virtual void NPP_Shutdown(); virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, diff --git a/extensions/source/plugin/inc/plugin/win/sysplug.hxx b/extensions/source/plugin/inc/plugin/win/sysplug.hxx index ec5bc12fa73d..a0f8249b4c00 100644 --- a/extensions/source/plugin/inc/plugin/win/sysplug.hxx +++ b/extensions/source/plugin/inc/plugin/win/sysplug.hxx @@ -90,6 +90,7 @@ public: virtual ~PluginComm_Impl(); public: + using PluginComm::NPP_Destroy; virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); virtual void * NPP_GetJavaClass(); @@ -99,6 +100,8 @@ public: virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype ); virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + + using PluginComm::NPP_SetWindow; virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); virtual void NPP_Shutdown(); virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); diff --git a/extensions/source/plugin/util/makefile.pmk b/extensions/source/plugin/util/makefile.pmk index e5ad905cb8d3..f081a85c2565 100644 --- a/extensions/source/plugin/util/makefile.pmk +++ b/extensions/source/plugin/util/makefile.pmk @@ -42,6 +42,11 @@ CDEFS+=-DENABLE_GTK PKGCONFIG_MODULES+=gtk+-2.0 gthread-2.0 .ENDIF +.IF "$(GUIBASE)" == "aqua" +CFLAGS += -I$(FRAMEWORKSHOME)/ApplicationServices.framework/Versions/Current/Frameworks/QD.framework/Headers\ + -I$(FRAMEWORKSHOME)/Carbon.framework/Versions/Current/Frameworks/HIToolbox.framework/Versions/Current/Headers +.ENDIF + .IF "$(PKGCONFIG_MODULES)" != "" .INCLUDE : pkg_config.mk .ENDIF diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/InstallationOngoingCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/InstallationOngoingCtrl.java index cb08fb41bbe8..412eae3fdabf 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/InstallationOngoingCtrl.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/InstallationOngoingCtrl.java @@ -85,6 +85,14 @@ public class InstallationOngoingCtrl extends PanelController { PackageCollector.sortPackages(installPackages, sortedPackages, "install"); installData.setInstallPackages(sortedPackages); + if ( installData.isMajorUpgrade() ) { + // PackageCollector.findOldPackages(installData); + // Sorting for correct order of uninstallation + Vector sortedUninstallPackages = new Vector(); + PackageCollector.sortPackages(installData.getOldPackages(), sortedUninstallPackages, "uninstall"); + installData.setOldPackages(sortedUninstallPackages); + } + Installer installer = InstallerFactory.getInstance(); installer.preInstallationOngoing(); } @@ -96,6 +104,7 @@ public class InstallationOngoingCtrl extends PanelController { InstallData installData = InstallData.getInstance(); InstallationOngoing panel = (InstallationOngoing)getPanel(); Vector installPackages = installData.getInstallPackages(); + Vector removePackages = installData.getOldPackages(); private Vector installedPackages = new Vector(); public void run() { @@ -110,6 +119,18 @@ public class InstallationOngoingCtrl extends PanelController { panel.setProgressValue(progress); panel.setProgressText(packageData.getPackageName()); + // Creating an upgrade process for Solaris packages + if ( installData.getOSType().equalsIgnoreCase("SunOS") ) { + if ( installer.isPackageInstalled(packageData, installData) ) { + if ( installer.isInstalledPackageOlder(packageData, installData) ) { + packageData.setIgnoreDependsForUninstall(true); + installer.uninstallPackage(packageData); + } else { + continue; // no downgrading + } + } + } + installer.installPackage(packageData); installedPackages.add(packageData); @@ -118,6 +139,13 @@ public class InstallationOngoingCtrl extends PanelController { } } + if ( installData.isMajorUpgrade() ) { + for (int i = 0; i < removePackages.size(); i++) { + PackageDescription packageData = (PackageDescription) removePackages.get(i); + installer.uninstallPackage(packageData); + } + } + if ( installData.isAbortedInstallation() ) { // undoing the installation LogManager.setCommandsHeaderLine("Installation aborted!"); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/UninstallationPrologueCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/UninstallationPrologueCtrl.java index 2b5773171298..b006e4671abc 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/UninstallationPrologueCtrl.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/UninstallationPrologueCtrl.java @@ -95,7 +95,9 @@ public class UninstallationPrologueCtrl extends PanelController { // adding information to installData data.setPackagePath((String)map.get("PackagePath")); data.setAdminFileNameReloc((String)map.get("AdminFileReloc")); + data.setAdminFileNameRelocNoDepends((String)map.get("AdminFileRelocNoDepends")); data.setAdminFileNameNoReloc((String)map.get("AdminFileNoReloc")); + data.setAdminFileNameNoRelocNoDepends((String)map.get("AdminFileNoRelocNoDepends")); data.setDatabasePath((String)map.get("DatabasePath")); data.setInstallDir((String)map.get("InstallationDir")); data.setStoredInstallationPrivileges((String)map.get("InstallationPrivileges")); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java index 56c21620a6d5..476669c0617f 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java @@ -71,11 +71,13 @@ public class InstallData static private boolean olderVersionExists = false; static private boolean sameVersionExists = false; static private boolean newerVersionExists = false; + static private boolean majorUpgrade = false; static private boolean isMultiLingual = false; static private boolean dontUpdate = false; static private boolean hideEula = false; static private boolean databaseQueried = false; static private boolean useRtl = false; + static private boolean installedProductMinorSet = false; static private String installType; /* custom or typical installation */ static private String osType; /* Linux, SunOS, ... */ static private String installDir = null; @@ -87,7 +89,9 @@ public class InstallData static private String packagePath = null; static private String packageSubdir = "packages"; static private String adminFileNameReloc = null; + static private String adminFileNameRelocNoDepends = null; static private String adminFileNameNoReloc = null; + static private String adminFileNameNoRelocNoDepends = null; static private String databasePath = null; static private String getUidPath = null; static private String installationPrivileges = null; @@ -97,6 +101,8 @@ public class InstallData static private String uninstallDirName = "uninstalldata"; static private int availableDiscSpace = 0; static private int preselectedLanguages = 0; + static private int productMinor = 0; + static private int installedProductMinor = 0; static private File jarFilePath = null; static private File resourceRoot; static private File infoRoot; @@ -105,6 +111,7 @@ public class InstallData static private PackageDescription updatePackage = null; static private Vector removeFiles = new Vector(); /* Files to remove, if installation is aborted */ static private Vector installPackages = new Vector(); + static private Vector oldPackages = new Vector(); static private Vector systemLanguages = new Vector(); public static InstallData getInstance() @@ -290,6 +297,22 @@ public class InstallData productDir = dir; } + public int getProductMinor() { + return productMinor; + } + + public void setProductMinor(int minor) { + productMinor = minor; + } + + public int getInstalledProductMinor() { + return installedProductMinor; + } + + public void setInstalledProductMinor(int minor) { + installedProductMinor = minor; + } + public String getInstallDirName() { return installDirName; } @@ -389,6 +412,14 @@ public class InstallData adminFileNameReloc = fileName; } + public String getAdminFileNameRelocNoDepends() { + return adminFileNameRelocNoDepends; + } + + public void setAdminFileNameRelocNoDepends(String fileName) { + adminFileNameRelocNoDepends = fileName; + } + public String getAdminFileNameNoReloc() { return adminFileNameNoReloc; } @@ -397,6 +428,14 @@ public class InstallData adminFileNameNoReloc = fileName; } + public String getAdminFileNameNoRelocNoDepends() { + return adminFileNameNoRelocNoDepends; + } + + public void setAdminFileNameNoRelocNoDepends(String fileName) { + adminFileNameNoRelocNoDepends = fileName; + } + public String getGetUidPath() { return getUidPath; } @@ -565,6 +604,14 @@ public class InstallData olderVersionExists = exists; } + public boolean isMajorUpgrade() { + return majorUpgrade; + } + + public void setMajorUpgrade(boolean upgrade) { + majorUpgrade = upgrade; + } + public boolean sameVersionExists() { return sameVersionExists; } @@ -597,6 +644,14 @@ public class InstallData hideEula = value; } + public boolean installedProductMinorSet() { + return installedProductMinorSet; + } + + public void setInstalledProductMinorSet(boolean value) { + installedProductMinorSet = value; + } + public boolean databaseQueried() { return databaseQueried; } @@ -637,6 +692,14 @@ public class InstallData installPackages = packages; } + public Vector getOldPackages() { + return oldPackages; + } + + public void setOldPackages(Vector packages) { + oldPackages = packages; + } + public Vector getSystemLanguages() { return systemLanguages; } diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java index fc4104cbdc7c..b4a9ffbe7506 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java @@ -409,12 +409,17 @@ public class LinuxInstaller extends Installer { log = rpmCommand + "
Returns: " + returnValue + " Successful uninstallation
"; LogManager.addCommandsLogfileComment(log); } else { // an error occured during installation - log = rpmCommand + "
Returns: " + returnValue + " Error during uninstallation
"; - LogManager.addCommandsLogfileComment(log); - for (int i = 0; i < returnErrorVector.size(); i++) { - LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i)); + if ( packageData.uninstallCanFail() ) { + log = rpmCommand + "
Returns: " + returnValue + " Problem during uninstallation. Can be ignored.
"; + LogManager.addCommandsLogfileComment(log); + } else { + log = rpmCommand + "
Returns: " + returnValue + " Error during uninstallation
"; + LogManager.addCommandsLogfileComment(log); + for (int i = 0; i < returnErrorVector.size(); i++) { + LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i)); + } + data.setIsErrorInstallation(true); } - data.setIsErrorInstallation(true); } } } @@ -538,7 +543,8 @@ public class LinuxInstaller extends Installer { String onePackage = (String)returnVector.get(i); int pos1 = onePackage.lastIndexOf("-"); int pos2 = onePackage.substring(0, pos1).lastIndexOf("-"); - map.put(onePackage.substring(0, pos2), value); + String key = onePackage.substring(0, pos2); + map.put(key, value); } } @@ -667,6 +673,12 @@ public class LinuxInstaller extends Installer { log = rpmCommand + "
Returns: " + version + "
"; LogManager.addCommandsLogfileComment(log); + if ( ! installData.installedProductMinorSet() ) { + int productMinor = helper.getInstalledMinor(version); + installData.setInstalledProductMinor(productMinor); + installData.setInstalledProductMinorSet(true); + } + if (useLocalDatabase) { rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " -q --queryformat %{RELEASE}\\n " + packageName; rpmCommandArray[5] = "%{RELEASE}\\n"; diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/SolarisInstaller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/SolarisInstaller.java index d696f0f9ac54..2da5006e9022 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/SolarisInstaller.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/SolarisInstaller.java @@ -81,8 +81,11 @@ public class SolarisInstaller extends Installer { if ( data.isInstallationMode()) { boolean makeRelocatableAdminFile = true; - helper.createAdminFile(makeRelocatableAdminFile); - helper.createAdminFile(! makeRelocatableAdminFile); + boolean removeDepends = true; + helper.createAdminFile(makeRelocatableAdminFile, removeDepends); + helper.createAdminFile(makeRelocatableAdminFile, ! removeDepends); + helper.createAdminFile(! makeRelocatableAdminFile, removeDepends); + helper.createAdminFile(! makeRelocatableAdminFile, ! removeDepends); } if ( data.isUserInstallation() ) { @@ -259,9 +262,17 @@ public class SolarisInstaller extends Installer { // is package relocatable or not? if ( packageData.isRelocatable() ) { - adminFileName = data.getAdminFileNameReloc(); + if ( packageData.ignoreDependsForUninstall() ) { // Force removal of older packages during installation + adminFileName = data.getAdminFileNameRelocNoDepends(); + } else { + adminFileName = data.getAdminFileNameReloc(); + } } else { - adminFileName = data.getAdminFileNameNoReloc(); + if ( packageData.ignoreDependsForUninstall() ) { // Force removal of older packages during installation + adminFileName = data.getAdminFileNameNoRelocNoDepends(); + } else { + adminFileName = data.getAdminFileNameNoReloc(); + } } String pkgCommand = ""; @@ -300,16 +311,20 @@ public class SolarisInstaller extends Installer { log = pkgCommand + "
Returns: " + returnValue + " Successful uninstallation
"; LogManager.addCommandsLogfileComment(log); } else { // an error occured during installation - log = pkgCommand + "
Returns: " + returnValue + " Error during uninstallation
"; - LogManager.addCommandsLogfileComment(log); - System.err.println("Error during uninstallation:"); - for (int i = 0; i < returnErrorVector.size(); i++) { - LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i)); - System.err.println(returnErrorVector.get(i)); + if ( packageData.uninstallCanFail() ) { + log = pkgCommand + "
Returns: " + returnValue + " Problem during uninstallation. Can be ignored.
"; + LogManager.addCommandsLogfileComment(log); + } else { + log = pkgCommand + "
Returns: " + returnValue + " Error during uninstallation
"; + LogManager.addCommandsLogfileComment(log); + System.err.println("Error during uninstallation:"); + for (int i = 0; i < returnErrorVector.size(); i++) { + LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i)); + System.err.println(returnErrorVector.get(i)); + } + data.setIsErrorInstallation(true); } - data.setIsErrorInstallation(true); } - } public boolean isPackageNameInstalledClassic(String packageName, InstallData installData) { @@ -402,7 +417,8 @@ public class SolarisInstaller extends Installer { for (int i = 0; i < returnVector.size(); i++) { String onePackage = (String)returnVector.get(i); int pos1 = onePackage.indexOf(" "); - map.put(onePackage.substring(0, pos1), value); + String key = onePackage.substring(0, pos1); + map.put(key, value); } } @@ -522,6 +538,12 @@ public class SolarisInstaller extends Installer { String installedPackageVersion = helper.getVersionString(returnVector); String newPackageVersion = packageData.getPkgVersion(); + if ( ! installData.installedProductMinorSet() ) { + int productMinor = helper.getInstalledMinor(installedPackageVersion); + installData.setInstalledProductMinor(productMinor); + installData.setInstalledProductMinorSet(true); + } + if (( installedPackageVersion != null ) && ( newPackageVersion != null )) { if ( checkIfInstalledIsOlder ) { firstPackageIsOlder = helper.comparePackageVersions(installedPackageVersion, newPackageVersion); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java index 88280b94fb1f..5ef4252808c1 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java @@ -241,6 +241,23 @@ import java.util.Vector;public class LinuxHelper { return hashRpm; } + public int getInstalledMinor(String version) { + + int minor = 0; + int pos = version.indexOf("."); + if ( pos > -1 ) { + String reduced = version.substring(pos + 1, version.length()); + + pos = reduced.indexOf("."); + if ( pos > -1 ) { + reduced = reduced.substring(0, pos); + minor = Integer.parseInt(reduced); + } + } + + return minor; + } + private boolean compareTwoRpms(HashMap hash1, HashMap hash2) { boolean hash1IsOlder = false; diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/SolarisHelper.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/SolarisHelper.java index 61dc02ca97f4..7d582f0a03d2 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/SolarisHelper.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/SolarisHelper.java @@ -108,7 +108,7 @@ public class SolarisHelper { } } - private Vector getAdminFileContent(boolean relocatable) { + private Vector getAdminFileContent(boolean relocatable, boolean rdepends) { Vector adminFile = new Vector(); InstallData data = InstallData.getInstance(); @@ -151,6 +151,7 @@ public class SolarisHelper { // String rdependLine = "rdepend=nocheck"; String rdependLine = "rdepend=quit"; + if ( ! rdepends ) { rdependLine = "rdepend=nocheck"; } if ( data.isUserInstallation() ) { rdependLine = "rdepend=nocheck"; } adminFile.add(rdependLine); @@ -268,25 +269,41 @@ public class SolarisHelper { return databasePath; } - public void createAdminFile(boolean relocatable) { + public void createAdminFile(boolean relocatable, boolean rdepends) { InstallData data = InstallData.getInstance(); Vector removeFiles = data.getRemoveFiles(); String adminFileName = ""; if ( relocatable ) { - adminFileName = "adminFileReloc"; + if ( rdepends ) { + adminFileName = "adminFileReloc"; + } else { + adminFileName = "adminFileRelocNoDepends"; + } } else { - adminFileName = "adminFileNoReloc"; + if ( rdepends ) { + adminFileName = "adminFileNoReloc"; + } else { + adminFileName = "adminFileNoRelocNoDepends"; + } } - Vector fileContent = getAdminFileContent(relocatable); + Vector fileContent = getAdminFileContent(relocatable, rdepends); File adminFile = new File(data.getInstallDir(), adminFileName); String completeAdminFileName = adminFile.getPath(); if ( relocatable ) { - data.setAdminFileNameReloc(completeAdminFileName); + if ( rdepends ) { + data.setAdminFileNameReloc(completeAdminFileName); + } else { + data.setAdminFileNameRelocNoDepends(completeAdminFileName); + } } else { - data.setAdminFileNameNoReloc(completeAdminFileName); + if ( rdepends ) { + data.setAdminFileNameNoReloc(completeAdminFileName); + } else { + data.setAdminFileNameNoRelocNoDepends(completeAdminFileName); + } } if ( ! adminFile.exists() ) { @@ -331,6 +348,24 @@ public class SolarisHelper { return versionString; } + public int getInstalledMinor(String version) { + + int minor = 0; + + int pos = version.indexOf("."); + if ( pos > -1 ) { + String reduced = version.substring(pos + 1, version.length()); + + pos = reduced.indexOf("."); + if ( pos > -1 ) { + reduced = reduced.substring(0, pos); + minor = Integer.parseInt(reduced); + } + } + + return minor; + } + public boolean comparePackageVersions(String firstPackageVersion, String secondPackageVersion) { // Analyzing strings: version, 2.0.0,REV=106.2005.05.26 diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java index 0c10c960aa0a..69aba3c19a93 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java @@ -103,9 +103,12 @@ public class PackageDescription implements TreeNode { private boolean isApplicationPackage = false; private boolean isJavaPackage = false; private boolean installCanFail = false; + private boolean uninstallCanFail = false; + private boolean forceIntoUpdate = false; private boolean useForce = false; private boolean isNewInstalled = false; private boolean wasAlreadyInstalled = false; + private boolean ignoreDependsForUninstall = false; /* Saving the default selection state. This is necessary, if the user chooses * the custom installation type, makes changes, and then changes into @@ -118,6 +121,8 @@ public class PackageDescription implements TreeNode { private int customSelectionState = DONT_KNOW; // Saving settings for custom installation private int startSelectionState = DONT_KNOW; // Saving settings at start of installation + public PackageDescription() {} + /** * construct only with package information to wrap */ @@ -143,6 +148,10 @@ public class PackageDescription implements TreeNode { return dpyName; } + public void setName(String name) { + dpyName = name; + } + public String getDescription() { return dpyDescription; } @@ -163,6 +172,10 @@ public class PackageDescription implements TreeNode { return pkgOrder; } + public void setOrder(int order) { + pkgOrder = order; + } + // public int getAccumulatedSize() { // int size = getSize(); // @@ -215,6 +228,18 @@ public class PackageDescription implements TreeNode { return installCanFail; } + public boolean uninstallCanFail() { + return uninstallCanFail; + } + + public void setUninstallCanFail(boolean canFail) { + uninstallCanFail = canFail; + } + + public boolean forceIntoUpdate() { + return forceIntoUpdate; + } + public boolean useForce() { return useForce; } @@ -235,6 +260,14 @@ public class PackageDescription implements TreeNode { return wasAlreadyInstalled; } + public void setIgnoreDependsForUninstall(boolean ignore) { + ignoreDependsForUninstall = ignore; + } + + public boolean ignoreDependsForUninstall() { + return ignoreDependsForUninstall; + } + public boolean isDefault() { return isDefault; } @@ -247,10 +280,19 @@ public class PackageDescription implements TreeNode { return isRelocatable; } + public void setIsRelocatable(boolean relocatable) { + isRelocatable = relocatable; + } + public String getPackageName() { return pkgFileName; } + public void setPackageName(String name) { + pkgFileName = name; + } + + public String getFullPackageName() { return pkgFullName; } @@ -468,6 +510,12 @@ public class PackageDescription implements TreeNode { installCanFail = Parser.parseBoolean(installCanFailValue); } + subSection = section.getElement("forceintoupdate"); + if (subSection != null) { + String forceIntoUpdateValue = subSection.getValue(); + forceIntoUpdate = Parser.parseBoolean(forceIntoUpdateValue); + } + subSection = section.getElement("useforce"); if (subSection != null) { String useForceValue = subSection.getValue(); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java index 3aba24855f99..f4bc983162a2 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java @@ -239,7 +239,17 @@ public class ProductDescription { installData.setDontUpdate(dontupdate); } - section = data.getElement("hideeula"); + /* check for the Product Minor of this installation set */ + section = data.getElement("productminor"); + if (section != null) { + String value = section.getValue(); + if (value != null) { + int intValue = Integer.parseInt(value); + installData.setProductMinor(intValue); + } + } + + section = data.getElement("hideeula"); if (section != null) { String value = section.getValue(); if ((value != null) && (! value.equals(""))) { diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java index d72eb8d65489..da252f6d0a39 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java @@ -179,7 +179,9 @@ public class Dumper { InstallData data = InstallData.getInstance(); System.err.println("PackagePath: " + data.getPackagePath()); System.err.println("AdminFileReloc: " + data.getAdminFileNameReloc()); + System.err.println("AdminFileRelocNoDepends: " + data.getAdminFileNameRelocNoDepends()); System.err.println("AdminFileNoReloc: " + data.getAdminFileNameNoReloc()); + System.err.println("AdminFileNoRelocNoDepends: " + data.getAdminFileNameNoRelocNoDepends()); System.err.println("DatabasePath: " + data.getDatabasePath()); System.err.println("InstallDir: " + data.getInstallDir()); System.err.println("Original privileges: " + data.getStoredInstallationPrivileges()); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java index cc1cc6a641db..55e80d52cd52 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java @@ -158,6 +158,15 @@ public class InfoDir { sourceFile.delete(); } + if ( data.getAdminFileNameRelocNoDepends() != null ) { + File sourceFile = new File(data.getAdminFileNameRelocNoDepends()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameRelocNoDepends(destFile.getPath()); + sourceFile.delete(); + } + if ( data.getAdminFileNameNoReloc() != null ) { File sourceFile = new File(data.getAdminFileNameNoReloc()); String fileName = sourceFile.getName(); @@ -167,6 +176,14 @@ public class InfoDir { sourceFile.delete(); } + if ( data.getAdminFileNameNoRelocNoDepends() != null ) { + File sourceFile = new File(data.getAdminFileNameNoRelocNoDepends()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameNoRelocNoDepends(destFile.getPath()); + sourceFile.delete(); + } } static private void createInfoFile(File dir) { @@ -180,8 +197,12 @@ public class InfoDir { fileContent.add(line); line = "AdminFileReloc=" + data.getAdminFileNameReloc(); fileContent.add(line); + line = "AdminFileRelocNoDepends=" + data.getAdminFileNameRelocNoDepends(); + fileContent.add(line); line = "AdminFileNoReloc=" + data.getAdminFileNameNoReloc(); fileContent.add(line); + line = "AdminFileNoRelocNoDepends=" + data.getAdminFileNameNoRelocNoDepends(); + fileContent.add(line); line = "InstallationDir=" + data.getInstallDir(); fileContent.add(line); line = "DatabasePath=" + data.getDatabasePath(); @@ -207,10 +228,18 @@ public class InfoDir { SystemManager.deleteFile(new File(data.getAdminFileNameReloc())); } + if ( ! data.getAdminFileNameRelocNoDepends().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameRelocNoDepends())); + } + if ( ! data.getAdminFileNameNoReloc().equals("null") ) { SystemManager.deleteFile(new File(data.getAdminFileNameNoReloc())); } + if ( ! data.getAdminFileNameNoRelocNoDepends().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameNoRelocNoDepends())); + } + if ( ! data.getGetUidPath().equals("null") ) { SystemManager.deleteFile(new File(data.getGetUidPath())); } diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java index 8cd96537e5da..2bd57123a6aa 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java @@ -98,6 +98,13 @@ public class InstallChangeCtrl { data.setOlderVersionExists(true); // All installed packages will be updated -> determining which packages are installed System.err.println("An older product is installed"); + // But if this is a kind of Major Upgrade with different Minor and therefore different package names, + // it is necessary to remove the old product. + if ( data.getProductMinor() > data.getInstalledProductMinor() ) + { + data.setMajorUpgrade(true); + System.err.println("Major Upgrade"); + } } else if ( installer.isInstallSetPackageOlder(data.getUpdatePackage(), data) ) { data.setNewerVersionExists(true); System.err.println("A newer product is installed"); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java index e70fd63b58c8..354b64d78420 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java @@ -180,10 +180,16 @@ public class ModuleCtrl { // System.err.println("Setting allChildrenHidden for module " + packageData.getName() ); } - // System.err.println("Setting " + packageData.getName() + " to " + packageData.getSelectionState() ); - packageData.setSelectionState(state); + // If older version exist, only modules without packages shall be updated, + // because all packages are already determined by querying the database. + if ( installdata.olderVersionExists() ) { + if ( packageData.getPackageName().equals("") ) { + packageData.setSelectionState(state); + } + } else { + packageData.setSelectionState(state); + } } - } static public void setHiddenModuleSettingsInstall(PackageDescription packageData) { @@ -409,6 +415,18 @@ public class ModuleCtrl { } } + static public void setForcedUpdateProductSettings(PackageDescription packageData) { + + if ( packageData.forceIntoUpdate() ) { + packageData.setSelectionState(PackageDescription.INSTALL); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setForcedUpdateProductSettings(child); + } + } + static public void setShowInUserInstallOnlyFlags(PackageDescription packageData) { // This function is not needed during deinstallation, because a @@ -721,6 +739,50 @@ public class ModuleCtrl { } } else { packageData.setSelectionState(PackageDescription.DONT_INSTALL); + // Special handling for Major Upgrade + if ( data.isMajorUpgrade() ) { + String basis = "ooobasis3"; + if ( data.getOSType().equalsIgnoreCase("Linux") ) { basis = basis + "."; } + String search = basis + data.getProductMinor(); + String replacestring = basis + data.getInstalledProductMinor(); + int pos = packageData.getPackageName().indexOf(search); + if ( pos > -1 ) { + // Check if this package is installed with a lower product minor + // Creating new package for removal, very simple PackageDescription + PackageDescription localPackage = new PackageDescription(); + localPackage.setUninstallCanFail(true); + localPackage.setIsRelocatable(packageData.isRelocatable()); + String localName = packageData.getPackageName(); + localName = localName.replace(search, replacestring); + localPackage.setPackageName(localName); + + if ( ( packageData.getPkgRealName() != null ) && ( ! packageData.getPkgRealName().equals("") )) { + localName = packageData.getPkgRealName(); + localName = localName.replace(search, replacestring); + localPackage.setPkgRealName(localName); + } + + if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + localName = packageData.getName(); + localName = localName.replace(search, replacestring); + localPackage.setName(localName); + } + + // saving also the order, needed for order of uninstallation + localPackage.setOrder(packageData.getOrder()); + + // If the old package is installed, the new package can be installed, too, + // and the old package can be marked for removal (with dependency check). + if ( installer.isPackageInstalled(localPackage, data) ) { + packageData.setSelectionState(PackageDescription.INSTALL); + + // Collecting all installed older packages for uninstallation + Vector oldPackages = data.getOldPackages(); + oldPackages.add(localPackage); + data.setOldPackages(oldPackages); + } + } + } } } @@ -841,6 +903,13 @@ public class ModuleCtrl { Dumper.logModuleStates(packageData, "ChooseDirectory: After setUpdateOlderProductSettings"); } + // Setting packages that are forced into update, because they did not exist in older version. + ModuleCtrl.setForcedUpdateProductSettings(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setForcedUpdateProductSettings"); + } + // Setting required root module packages (that are new in the update product). ModuleCtrl.setRequiredNewCoreModules(packageData, data); @@ -871,6 +940,13 @@ public class ModuleCtrl { } } + // Setting parent module settings. Only required for displaying correct module settings before starting installation. + ModuleCtrl.setParentDefaultModuleSettings(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setParentDefaultModuleSettings"); + } + // Collecting packages to install // This has to be done here, because "ChooseInstallationType" and "ChooseComponents" // are not called. @@ -903,7 +979,7 @@ public class ModuleCtrl { Dumper.logModuleStates(packageData, "ChooseDirectory: After disableNonExistingPackages"); } - // disable packages, that are not valid in user installation + // disable packages, that are not valid in user installation if ( data.isUserInstallation() ) { ModuleCtrl.setShowInUserInstallFlags(packageData); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java index 4c2ad128b57c..efa15c0212ae 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java @@ -30,6 +30,7 @@ package org.openoffice.setup.Util; +import org.openoffice.setup.InstallData; import org.openoffice.setup.SetupData.PackageDescription; import java.util.Enumeration; import java.util.Vector; @@ -82,6 +83,62 @@ public class PackageCollector { } } + // Special handling for packages, that change their name, and therefore need to be uninstalled + + // static public void findOldPackages( InstallData installData ) { + // + // String basis = "ooobasis3"; + // if ( installData.getOSType().equalsIgnoreCase("Linux") ) { basis = basis + "."; } + // String search = basis + installData.getProductMinor(); + + // Vector allPackages = installData.getInstallPackages(); + // Vector oldPackages = new Vector(); + + // for (int i = 0; i < allPackages.size(); i++) { + // PackageDescription packageData = (PackageDescription) allPackages.get(i); + // int pos = packageData.getPackageName().indexOf(search); + + // if ( pos > -1 ) { + // String substring = packageData.getPackageName().substring(pos, pos + 1); + // for (int j = 0; j < installData.getProductMinor(); j++) { + // String replace = basis + j; + // // Creating new package for removal, very simple PackageDescription + // PackageDescription localPackage = new PackageDescription(); + // localPackage.setUninstallCanFail(true); + // localPackage.setIsRelocatable(packageData.isRelocatable()); + // String localName = packageData.getPackageName(); + // localName = localName.replace(search, replace); + // localPackage.setPackageName(localName); + + // if ( ( packageData.getPkgRealName() != null ) && ( ! packageData.getPkgRealName().equals("") )) { + // localName = packageData.getPkgRealName(); + // localName = localName.replace(search, replace); + // localPackage.setPkgRealName(localName); + // } + + // if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + // localName = packageData.getName(); + // localName = localName.replace(search, replace); + // localPackage.setName(localName); + // } + + // oldPackages.add(localPackage); + // } + // } + // } + + // // reverse order for uninstallation + // int number = oldPackages.size(); + // for (int i = 0; i < number; i++) { + // if ( i > 0 ) { + // PackageDescription oldPackageData = (PackageDescription) oldPackages.remove(i); + // oldPackages.add(0,oldPackageData); + // } + // } + + // installData.setOldPackages(oldPackages); + // } + static public void sortPackages(Vector allPackages, Vector sortedPackages, String mode) { for (int i = 0; i < allPackages.size(); i++) { boolean integrated = false; diff --git a/package/qa/storages/StorageUnitTest.java b/package/qa/storages/StorageUnitTest.java index 83bfd79358e7..7e8caa314e96 100644 --- a/package/qa/storages/StorageUnitTest.java +++ b/package/qa/storages/StorageUnitTest.java @@ -83,6 +83,7 @@ public class StorageUnitTest extends ComplexTestCase "ExecuteTest14", "ExecuteTest15", "ExecuteTest16", + "ExecuteTest17", "ExecuteRegressionTest_114358", "ExecuteRegressionTest_i29169", "ExecuteRegressionTest_i30400", @@ -227,6 +228,12 @@ public class StorageUnitTest extends ComplexTestCase assure( "Test16 failed!", aTest.test() ); } + public void ExecuteTest17() + { + StorageTest aTest = new Test17( m_xMSF, m_xStorageFactory, log ); + assure( "Test17 failed!", aTest.test() ); + } + public void ExecuteRegressionTest_114358() { diff --git a/package/qa/storages/Test17.java b/package/qa/storages/Test17.java new file mode 100644 index 000000000000..009344cefbc4 --- /dev/null +++ b/package/qa/storages/Test17.java @@ -0,0 +1,142 @@ +package complex.storages; + +import com.sun.star.uno.XInterface; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; + +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.io.XStream; +import com.sun.star.io.XInputStream; + +import com.sun.star.embed.*; + +import share.LogWriter; +import complex.storages.TestHelper; +import complex.storages.StorageTest; + +public class Test17 implements StorageTest { + + XMultiServiceFactory m_xMSF; + XSingleServiceFactory m_xStorageFactory; + TestHelper m_aTestHelper; + + public Test17( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory, LogWriter aLogWriter ) + { + m_xMSF = xMSF; + m_xStorageFactory = xStorageFactory; + m_aTestHelper = new TestHelper( aLogWriter, "Test17: " ); + } + + public boolean test() + { + try + { + XStream xTempFileStream = m_aTestHelper.CreateTempFileStream( m_xMSF ); + if ( xTempFileStream == null ) + return false; + + // create storage based on the temporary stream + Object pArgs[] = new Object[2]; + pArgs[0] = (Object) xTempFileStream; + pArgs[1] = new Integer( ElementModes.WRITE ); + + Object oTempStorage = m_xStorageFactory.createInstanceWithArguments( pArgs ); + XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage ); + if ( xTempStorage == null ) + { + m_aTestHelper.Error( "Can't create temporary storage representation!" ); + return false; + } + + + byte pBytes1[] = { 1, 1, 1, 1, 1 }; + String pNames[] = { "SubStream1", "SubStream2", "SubStream3", "SubStream4", "SubStream5", "SubStream6", "SubStream7" }; + + for ( int nInd = 0; nInd < pNames.length; nInd++ ) + { + // open a new substorage + XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, + "SubStorage1", + ElementModes.WRITE ); + if ( xTempSubStorage == null ) + { + m_aTestHelper.Error( "Can't create substorage!" ); + return false; + } + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, pNames[nInd], "MediaType1", true, pBytes1 ) ) + return false; + + // commit substorage first + if ( !m_aTestHelper.commitStorage( xTempSubStorage ) ) + return false; + + // dispose used storage to free resources + if ( !m_aTestHelper.disposeStorage( xTempSubStorage ) ) + return false; + } + + // commit the root storage so the contents must be stored now + if ( !m_aTestHelper.commitStorage( xTempStorage ) ) + return false; + + // dispose used storage to free resources + if ( !m_aTestHelper.disposeStorage( xTempStorage ) ) + return false; + + + // ================================================ + // now check all the written information + // ================================================ + + // close the output part of the temporary stream + // the output part must present since we already wrote to the stream + if ( !m_aTestHelper.closeOutput( xTempFileStream ) ) + return false; + + XInputStream xTempInStream = m_aTestHelper.getInputStream( xTempFileStream ); + if ( xTempInStream == null ) + return false; + + + // open input stream + // since no mode is provided the result storage must be opened readonly + Object pOneArg[] = new Object[1]; + pOneArg[0] = (Object) xTempInStream; + + Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pOneArg ); + XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage ); + if ( xResultStorage == null ) + { + m_aTestHelper.Error( "Can't open storage based on input stream!" ); + return false; + } + + // open existing substorage + XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage, + "SubStorage1", + ElementModes.READ ); + if ( xResultSubStorage == null ) + { + m_aTestHelper.Error( "Can't open existing substorage!" ); + return false; + } + + for ( int nInd = 0; nInd < pNames.length; nInd++ ) + if ( !m_aTestHelper.checkStream( xResultSubStorage, pNames[nInd], "MediaType1", true, pBytes1 ) ) + return false; + + return true; + } + catch( Exception e ) + { + m_aTestHelper.Error( "Exception: " + e ); + return false; + } + } + +} + diff --git a/package/qa/storages/makefile.mk b/package/qa/storages/makefile.mk index 7caa832a543d..a8a5bbf8219e 100644 --- a/package/qa/storages/makefile.mk +++ b/package/qa/storages/makefile.mk @@ -63,6 +63,7 @@ JAVAFILES =\ Test14.java\ Test15.java\ Test16.java\ + Test17.java\ RegressionTest_114358.java\ RegressionTest_i29169.java\ RegressionTest_i30400.java\ diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 111eaa357d31..b3b9ec6affa2 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -2249,52 +2249,57 @@ void SAL_CALL OWriteStream::dispose() throw ( uno::RuntimeException ) { // should be an internal method since it can be called only from parent storage + { + ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() ); - ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() ); - - if ( !m_pImpl ) - throw lang::DisposedException(); - - if ( m_xOutStream.is() ) - CloseOutput_Impl(); + if ( !m_pImpl ) + throw lang::DisposedException(); - if ( m_xInStream.is() ) - { - m_xInStream->closeInput(); - m_xInStream = uno::Reference< io::XInputStream >(); - } + if ( m_xOutStream.is() ) + CloseOutput_Impl(); - lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) ); - m_pData->m_aListenersContainer.disposeAndClear( aSource ); + if ( m_xInStream.is() ) + { + m_xInStream->closeInput(); + m_xInStream = uno::Reference< io::XInputStream >(); + } - m_pImpl->m_pAntiImpl = NULL; + m_pImpl->m_pAntiImpl = NULL; - if ( !m_bInitOnDemand ) - { - try + if ( !m_bInitOnDemand ) { - if ( !m_bTransacted ) + try { - m_pImpl->Commit(); + if ( !m_bTransacted ) + { + m_pImpl->Commit(); + } + else + { + // throw away all the changes + m_pImpl->Revert(); + } } - else + catch( uno::Exception& ) { - // throw away all the changes - m_pImpl->Revert(); + uno::Any aCaught( ::cppu::getCaughtException() ); + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii( "Can not commit/revert the storage!\n" ), + uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), + uno::UNO_QUERY ), + aCaught ); } } - catch( uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - throw lang::WrappedTargetRuntimeException( - ::rtl::OUString::createFromAscii( "Can not commit/revert the storage!\n" ), - uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), - uno::UNO_QUERY ), - aCaught ); - } + + m_pImpl = NULL; } - m_pImpl = NULL; + // the listener might try to get rid of parent storage, and the storage would delete this object; + // for now the listener is just notified at the end of the method to workaround the problem + // in future a more elegant way should be found + + lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) ); + m_pData->m_aListenersContainer.disposeAndClear( aSource ); } //----------------------------------------------- diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index d6f115a3a09b..1d5e900e28fe 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -271,7 +271,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr // it is an empty subfolder, use workaround to store it ZipEntry* pTempEntry = new ZipEntry(); ZipPackageFolder::copyZipEntry ( *pTempEntry, aEntry ); - pTempEntry->nNameLen = (sal_Int16)rPath.getLength(); + pTempEntry->nNameLen = (sal_Int16)( ::rtl::OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getLength() ); pTempEntry->nExtraLen = -1; pTempEntry->sName = rPath; @@ -333,7 +333,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr ZipPackageFolder::copyZipEntry ( *pTempEntry, pStream->aEntry ); pTempEntry->sName = rPath + rShortName; - pTempEntry->nNameLen = (sal_Int16)( pTempEntry->sName.getLength() ); + pTempEntry->nNameLen = (sal_Int16)( ::rtl::OUStringToOString( pTempEntry->sName, RTL_TEXTENCODING_UTF8 ).getLength() ); sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && (bHaveEncryptionKey || pStream->HasOwnKey()); sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : pStream->IsToBeCompressed(); diff --git a/setup_native/source/java/javaversion.dat b/setup_native/source/java/javaversion.dat index 93ef7a7bee78..120bed23d7bf 100755 --- a/setup_native/source/java/javaversion.dat +++ b/setup_native/source/java/javaversion.dat @@ -30,30 +30,30 @@ #************************************************************************* # GUI String in the installer ("Java Runtime Environment (${JAVAVERSION})") -JAVAVERSION=Java 6 Update 12 -WINDOWSJAVAVERSION=Java 6 Update 12 +JAVAVERSION=Java 6 Update 13 +WINDOWSJAVAVERSION=Java 6 Update 13 # Windows (scp2 and downloadtemplate.nsi) -WINDOWSJAVAFILENAME=jre-6u12-windows-i586-p.exe -WINDOWSJAVAREGISTRYENTRY=1.6.0_12 +WINDOWSJAVAFILENAME=jre-6u13-windows-i586-p.exe +WINDOWSJAVAREGISTRYENTRY=1.6.0_13 # Linux (scp2) -LINUXJAVAFILENAME=jre-6u12-linux-i586.rpm +LINUXJAVAFILENAME=jre-6u13-linux-i586.rpm # Linux (rpmUnit.xml, rpm -qp ) -LINUXJAVANAME=jre-1.6.0_12-fcs +LINUXJAVANAME=jre-1.6.0_13-fcs # Linux-x64 (scp2) -LINUXX64JAVAFILENAME=jre-6u12-linux-amd64.rpm +LINUXX64JAVAFILENAME=jre-6u13-linux-amd64.rpm # Solaris Sparc (scp2) -SOLSJAVARTPACKED=SUNWj6rt_1_6_0_12_sparc.tar.gz -SOLSJAVACFGPACKED=SUNWj6cfg_1_6_0_12_sparc.tar.gz -SOLSJAVAMANPACKED=SUNWj6man_1_6_0_12_sparc.tar.gz +SOLSJAVARTPACKED=SUNWj6rt_1_6_0_13_sparc.tar.gz +SOLSJAVACFGPACKED=SUNWj6cfg_1_6_0_13_sparc.tar.gz +SOLSJAVAMANPACKED=SUNWj6man_1_6_0_13_sparc.tar.gz # Solaris x86 (scp2) -SOLIJAVARTPACKED=SUNWj6rt_1_6_0_12_x86.tar.gz -SOLIJAVACFGPACKED=SUNWj6cfg_1_6_0_12_x86.tar.gz -SOLIJAVAMANPACKED=SUNWj6man_1_6_0_12_x86.tar.gz +SOLIJAVARTPACKED=SUNWj6rt_1_6_0_13_x86.tar.gz +SOLIJAVACFGPACKED=SUNWj6cfg_1_6_0_13_x86.tar.gz +SOLIJAVAMANPACKED=SUNWj6man_1_6_0_13_x86.tar.gz # Solaris (pkgUnit.xml, needs only to be changed in major changes) SOLARISJAVART=SUNWj6rt diff --git a/setup_native/source/java/javaversion2.dat b/setup_native/source/java/javaversion2.dat index 93ef7a7bee78..120bed23d7bf 100644 --- a/setup_native/source/java/javaversion2.dat +++ b/setup_native/source/java/javaversion2.dat @@ -30,30 +30,30 @@ #************************************************************************* # GUI String in the installer ("Java Runtime Environment (${JAVAVERSION})") -JAVAVERSION=Java 6 Update 12 -WINDOWSJAVAVERSION=Java 6 Update 12 +JAVAVERSION=Java 6 Update 13 +WINDOWSJAVAVERSION=Java 6 Update 13 # Windows (scp2 and downloadtemplate.nsi) -WINDOWSJAVAFILENAME=jre-6u12-windows-i586-p.exe -WINDOWSJAVAREGISTRYENTRY=1.6.0_12 +WINDOWSJAVAFILENAME=jre-6u13-windows-i586-p.exe +WINDOWSJAVAREGISTRYENTRY=1.6.0_13 # Linux (scp2) -LINUXJAVAFILENAME=jre-6u12-linux-i586.rpm +LINUXJAVAFILENAME=jre-6u13-linux-i586.rpm # Linux (rpmUnit.xml, rpm -qp ) -LINUXJAVANAME=jre-1.6.0_12-fcs +LINUXJAVANAME=jre-1.6.0_13-fcs # Linux-x64 (scp2) -LINUXX64JAVAFILENAME=jre-6u12-linux-amd64.rpm +LINUXX64JAVAFILENAME=jre-6u13-linux-amd64.rpm # Solaris Sparc (scp2) -SOLSJAVARTPACKED=SUNWj6rt_1_6_0_12_sparc.tar.gz -SOLSJAVACFGPACKED=SUNWj6cfg_1_6_0_12_sparc.tar.gz -SOLSJAVAMANPACKED=SUNWj6man_1_6_0_12_sparc.tar.gz +SOLSJAVARTPACKED=SUNWj6rt_1_6_0_13_sparc.tar.gz +SOLSJAVACFGPACKED=SUNWj6cfg_1_6_0_13_sparc.tar.gz +SOLSJAVAMANPACKED=SUNWj6man_1_6_0_13_sparc.tar.gz # Solaris x86 (scp2) -SOLIJAVARTPACKED=SUNWj6rt_1_6_0_12_x86.tar.gz -SOLIJAVACFGPACKED=SUNWj6cfg_1_6_0_12_x86.tar.gz -SOLIJAVAMANPACKED=SUNWj6man_1_6_0_12_x86.tar.gz +SOLIJAVARTPACKED=SUNWj6rt_1_6_0_13_x86.tar.gz +SOLIJAVACFGPACKED=SUNWj6cfg_1_6_0_13_x86.tar.gz +SOLIJAVAMANPACKED=SUNWj6man_1_6_0_13_x86.tar.gz # Solaris (pkgUnit.xml, needs only to be changed in major changes) SOLARISJAVART=SUNWj6rt diff --git a/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx b/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx index 4541aca7e9ef..8490b1d5682e 100644 --- a/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx +++ b/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include diff --git a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx index 63f5e8cc521f..1fe1d2335b88 100755 --- a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx +++ b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx @@ -242,7 +242,7 @@ extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) return ERROR_SUCCESS; std::_tstring sRenameSrc = sOfficeInstallPath + TEXT("program"); - std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_1"); + std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_test"); bool bSuccess = MoveFile( sRenameSrc.c_str(), sRenameDst.c_str() ); @@ -252,6 +252,32 @@ extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) } else { + DWORD dwError = GetLastError(); + LPVOID lpMsgBuf; + // When there is no program folder, there could be no running office + if ( dwError == ERROR_FILE_NOT_FOUND ) + return ERROR_SUCCESS; + // The destination folder should never exist, don't know what to do here + if ( dwError == ERROR_ALREADY_EXISTS ) + return ERROR_SUCCESS; + + if ( FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL )) + { + OutputDebugStringFormat( TEXT("Error Code %d: %s"), dwError, lpMsgBuf ); + LocalFree( lpMsgBuf ); + } + else + OutputDebugStringFormat( TEXT("Error Code %d: Unknown"), dwError ); + MsiSetProperty( handle, TEXT("OFFICERUNS"), TEXT("1") ); SetMsiErrorCode( MSI_ERROR_OFFICE_IS_RUNNING ); } diff --git a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx index 016103812bec..5b5d649ea334 100644 --- a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx +++ b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx @@ -189,7 +189,7 @@ extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle ) std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); std::_tstring sRenameSrc = sOfficeInstallPath + TEXT("program"); - std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_1"); + std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_old"); // MessageBox(NULL, sRenameSrc.c_str(), "OFFICEINSTALLLOCATION", MB_OK); @@ -208,7 +208,7 @@ extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle ) extern "C" UINT __stdcall RemovePrgFolder( MSIHANDLE handle ) { std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); - std::_tstring sRemoveDir = sOfficeInstallPath + TEXT("program_1"); + std::_tstring sRemoveDir = sOfficeInstallPath + TEXT("program_old"); // MessageBox(NULL, sRemoveDir.c_str(), "REMOVING OLD DIR", MB_OK); diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx index 6aa6f009212a..d0e6670fd2ff 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -448,21 +448,34 @@ void SecurityEnvironment_NssImpl::updateSlots() if(pSlot != NULL) { RTL_LOGFILE_TRACE2( "XMLSEC: Found a slot: SlotName=%s, TokenName=%s", PK11_GetSlotName(pSlot), PK11_GetTokenName(pSlot) ); - pSymKey = PK11_KeyGen( pSlot , CKM_DES3_CBC, NULL, 128, NULL ) ; - if( pSymKey == NULL ) - { - PK11_FreeSlot( pSlot ) ; - RTL_LOGFILE_TRACE( "XMLSEC: Error - pSymKey is NULL" ); - continue; - } +//The following code which is commented out checks if a slot, that is a smart card for example, is +// able to generate a symmetric key of type CKM_DES3_CBC. If this fails then this token +// will not be used. This key is possibly used for the encryption service. However, all +// interfaces and services used for public key signature and encryption are not published +// and the encryption is not used in OOo. Therefore it does not do any harm to remove +// this code, hence allowing smart cards which cannot generate this type of key. +// +// By doing this, the encryption may fail if a smart card is being used which does not +// support this key generation. +// + pSymKey = PK11_KeyGen( pSlot , CKM_DES3_CBC, NULL, 128, NULL ) ; +// if( pSymKey == NULL ) +// { +// PK11_FreeSlot( pSlot ) ; +// RTL_LOGFILE_TRACE( "XMLSEC: Error - pSymKey is NULL" ); +// continue; +// } addCryptoSlot(pSlot); PK11_FreeSlot( pSlot ) ; pSlot = NULL; - adoptSymKey( pSymKey ) ; - PK11_FreeSymKey( pSymKey ) ; - pSymKey = NULL; + if (pSymKey != NULL) + { + adoptSymKey( pSymKey ) ; + PK11_FreeSymKey( pSymKey ) ; + pSymKey = NULL; + } }// end of if(pSlot != NULL) }// end of for -- cgit v1.2.3 From d13e45bbade0a247f0ec8880dc891f4abafe372a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 15 Aug 2009 16:26:40 +0000 Subject: #i92516# move solar.hrc to vcl --- automation/source/server/statemnt.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'automation') diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 1d0eb9d85eaf..318a60a7259a 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -4811,37 +4811,49 @@ BOOL StatementControl::Execute() } break; case M_GetPage: - pRet->GenReturn ( RET_Value, aUId, static_cast(((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit + pRet->GenReturn ( RET_Value, aUId, ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetText()); break; case M_SetPage : { // Wegen lokaler Variablen TabControl *pTControl = ((TabControl*)pControl); USHORT nActive = pTControl->GetCurPageId(); USHORT i,anz; - ULONG nID = 0; + SmartId aID; + SmartId aWantedID; + if ( (nParams & PARAM_ULONG_1) ) + { + aWantedID = SmartId( nLNr1 ); + } + else if ( (nParams & PARAM_STR_1) ) + { + aWantedID = SmartId( aString1 ); + } + else + ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + i = pTControl->GetPagePos( pTControl->GetCurPageId() ); - for ( anz=0 ; anz < pTControl->GetPageCount() && nID != nLNr1 ; anz++ ) + for ( anz=0 ; anz < pTControl->GetPageCount() && !aID.Matches( aWantedID ) ; anz++ ) { pTControl->SelectTabPage( pTControl->GetPageId(i) ); /*if (pTControl->GetCurPageId()) pTControl->DeactivatePage(); pTControl->SetCurPageId( pTControl->GetPageId(i) ); pTControl->ActivatePage();*/ - nID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum(); + aID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId(); i++; if ( i >= pTControl->GetPageCount() ) i = 0; if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen break; } - if ( nID != nLNr1 ) + if ( !aID.Matches( aWantedID ) ) { pTControl->SelectTabPage( nActive ); /*if (pTControl->GetCurPageId()) pTControl->DeactivatePage(); pTControl->SetCurPageId( nActive ); pTControl->ActivatePage();*/ - ReportError( SmartId( nLNr1 ), GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) ); + ReportError( aWantedID, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) ); } } break; -- cgit v1.2.3