summaryrefslogtreecommitdiff
path: root/embedserv
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2009-04-02 16:41:21 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2009-04-02 16:41:21 +0000
commit02ff95fc2d70379b7b239e775f60b199f1da90a4 (patch)
tree435f16202272378323b04741c3959ca6a167a83d /embedserv
parent7bd3cbaa383f61f54a5f8cb94f8372e091ad4116 (diff)
CWS-TOOLING: integrate CWS hb21_DEV300
2009-03-24 17:48:22 +0100 hbrinkm r269985 : #i100449# OutWW8TableDefinition: nSz sums the widths of columns. nTblOffset is added to the current width for every cellx. 2009-03-24 16:28:31 +0100 mav r269966 : #i100505# fix the wrapper ole-handler
Diffstat (limited to 'embedserv')
-rw-r--r--embedserv/source/embed/docholder.cxx12
-rwxr-xr-xembedserv/source/embed/ed_ioleobject.cxx10
-rw-r--r--embedserv/source/inprocserv/advisesink.cxx15
-rw-r--r--embedserv/source/inprocserv/advisesink.hxx1
-rw-r--r--embedserv/source/inprocserv/dllentry.cxx65
-rw-r--r--embedserv/source/inprocserv/inprocembobj.cxx432
-rw-r--r--embedserv/source/inprocserv/inprocembobj.h3
-rw-r--r--embedserv/source/inprocserv/makefile.mk2
-rw-r--r--embedserv/source/inprocserv/smartpointer.hxx16
9 files changed, 400 insertions, 156 deletions
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,76 +33,116 @@
*
************************************************************************/
-#include <stdio.h>
-
#include <embservconst.h>
#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()
{
return S_OK;
}
//-------------------------------------------------------------------------------
-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;