1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
22 #include <embservconst.h>
23 #include "inprocembobj.h"
35 explicit ULONGGuard( ULONG
& rValue
)
36 : m_rValue( ++rValue
)
40 ~ULONGGuard() { --m_rValue
; }
43 void SetName( LPCOLESTR pszNameFromOutside
, wchar_t*& pOwnName
)
45 if ( !pszNameFromOutside
)
50 while( pszNameFromOutside
[nLen
] != 0 )
59 pOwnName
= new wchar_t[nLen
+1];
60 for ( size_t nInd
= 0; nInd
< nLen
; nInd
++ )
61 pOwnName
[nInd
] = pszNameFromOutside
[nInd
];
65 DWORD
InsertAdviseLinkToList( const sal::systools::COMReference
<OleWrapperAdviseSink
>& pOwnAdvise
, sal::systools::COMReference
< OleWrapperAdviseSink
> pAdvises
[] )
67 // the result should start from 1 in case of success, the element 0 can be used for own needs
72 for ( DWORD nInd
= 1; nInd
< DEFAULT_ARRAY_LEN
&& nResult
== 0; nInd
++ )
74 if ( pAdvises
[nInd
].get() == pOwnAdvise
.get() )
78 else if ( pAdvises
[nInd
] == nullptr )
80 pAdvises
[nInd
] = pOwnAdvise
;
91 BOOL
InprocEmbedDocument_Impl::CheckDefHandler()
93 // set the own listener
94 if ( m_pOleAdvises
[0] == nullptr )
96 m_pOleAdvises
[0] = new OleWrapperAdviseSink();
100 if ( m_pOleAdvises
[0]->IsClosed() )
104 // deregister all the listeners
106 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
109 for ( DWORD nInd
= 0; nInd
< DEFAULT_ARRAY_LEN
; nInd
++ )
110 if ( m_pOleAdvises
[nInd
] )
112 DWORD nID
= m_pOleAdvises
[nInd
]->GetRegID();
113 pOleObject
->Unadvise( nID
);
114 m_pOleAdvises
[nInd
]->SetRegID( 0 );
117 pOleObject
->SetClientSite( nullptr );
120 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
123 for ( DWORD nInd
= 0; nInd
< DEFAULT_ARRAY_LEN
; nInd
++ )
124 if ( m_pDataAdvises
[nInd
] )
126 DWORD nID
= m_pDataAdvises
[nInd
]->GetRegID();
127 pIDataObject
->DUnadvise( nID
);
128 m_pDataAdvises
[nInd
]->SetRegID( 0 );
132 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
136 pIViewObject
->SetAdvise( m_pViewAdvise
->GetAspect(), m_pViewAdvise
->GetViewAdviseFlag(), nullptr );
139 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
142 // disconnect the old wrapper from the storage
143 pPersist
->HandsOffStorage();
146 m_pDefHandler
= nullptr;
149 m_pOleAdvises
[0]->UnsetClosed();
153 if ( m_nCallsOnStack
)
156 if ( !m_pDefHandler
)
158 // create a new default inprocess handler
159 HRESULT hr
= OleCreateDefaultHandler( m_guid
, nullptr, IID_IUnknown
, reinterpret_cast<void**>(&m_pDefHandler
) );
160 if ( SUCCEEDED( hr
) )
162 if ( m_nInitMode
== INIT_FROM_STORAGE
)
164 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
166 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
167 if ( pPersist
&& m_pStorage
)
168 hr
= pPersist
->InitNew( m_pStorage
.get() );
170 else if ( m_nInitMode
== LOAD_FROM_STORAGE
)
172 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
174 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
175 if ( pPersist
&& m_pStorage
)
176 hr
= pPersist
->Load( m_pStorage
.get() );
178 else if ( m_nInitMode
== LOAD_FROM_FILE
)
180 sal::systools::COMReference
< IPersistFile
> pPersistFile(m_pDefHandler
, sal::systools::COM_QUERY
);
182 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
183 if ( pPersistFile
&& m_pFileName
)
184 hr
= pPersistFile
->Load( m_pFileName
, m_nFileOpenMode
);
188 if ( !SUCCEEDED( hr
) || !m_pDefHandler
)
190 m_pDefHandler
= nullptr;
194 // register all the listeners new
196 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
200 pOleObject
->SetClientSite( m_pClientSite
.get() );
202 for ( DWORD nInd
= 0; nInd
< DEFAULT_ARRAY_LEN
; nInd
++ )
203 if ( m_pOleAdvises
[nInd
] )
206 if ( SUCCEEDED( pOleObject
->Advise( m_pOleAdvises
[nInd
].get(), &nRegID
) ) && nRegID
> 0 )
207 m_pOleAdvises
[nInd
]->SetRegID( nRegID
);
211 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
214 for ( DWORD nInd
= 0; nInd
< DEFAULT_ARRAY_LEN
; nInd
++ )
215 if ( m_pDataAdvises
[nInd
] )
218 if ( SUCCEEDED( pIDataObject
->DAdvise( m_pDataAdvises
[nInd
]->GetFormatEtc(), m_pDataAdvises
[nInd
]->GetDataAdviseFlag(), m_pDataAdvises
[nInd
].get(), &nRegID
) ) && nRegID
> 0 )
219 m_pDataAdvises
[nInd
]->SetRegID( nRegID
);
223 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
227 pIViewObject
->SetAdvise( m_pViewAdvise
->GetAspect(), m_pViewAdvise
->GetViewAdviseFlag(), m_pViewAdvise
.get() );
235 void InprocEmbedDocument_Impl::Clean()
237 m_pDefHandler
= nullptr;
239 // no DisconnectOrigAdvise() call here, since it is no explicit disconnection
240 for ( DWORD nInd
= 0; nInd
< DEFAULT_ARRAY_LEN
; nInd
++ )
242 m_pOleAdvises
[nInd
].clear();
243 m_pDataAdvises
[nInd
].clear();
246 m_pViewAdvise
= nullptr;
248 m_nInitMode
= NOINIT
;
249 m_pStorage
= nullptr;
251 if ( m_pOleContainer
)
253 m_pOleContainer
->LockContainer( FALSE
);
254 m_pOleContainer
= nullptr;
257 m_pClientSite
= nullptr;
263 m_pFileName
= nullptr;
269 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::QueryInterface(REFIID riid
, void** ppv
)
271 if(IsEqualIID(riid
, IID_IUnknown
))
274 *ppv
= static_cast<IUnknown
*>(static_cast<IPersistStorage
*>(this));
277 else if (IsEqualIID(riid
, IID_IPersist
))
280 *ppv
= static_cast<IPersist
*>(static_cast<IPersistStorage
*>(this));
283 else if (IsEqualIID(riid
, IID_IPersistStorage
))
286 *ppv
= static_cast<IPersistStorage
*>(this);
289 else if (IsEqualIID(riid
, IID_IDataObject
))
292 *ppv
= static_cast<IDataObject
*>(this);
295 else if (IsEqualIID(riid
, IID_IOleObject
))
298 *ppv
= static_cast<IOleObject
*>(this);
301 else if (IsEqualIID(riid
, IID_IPersistFile
))
304 *ppv
= static_cast<IPersistFile
*>(this);
307 else if (IsEqualIID(riid
, IID_IRunnableObject
))
310 *ppv
= static_cast<IRunnableObject
*>(this);
313 else if (IsEqualIID(riid
, IID_IViewObject
))
316 *ppv
= static_cast<IViewObject
*>(this);
319 else if (IsEqualIID(riid
, IID_IViewObject2
))
322 *ppv
= static_cast<IViewObject2
*>(this);
325 else if (IsEqualIID(riid
, IID_IOleCache
))
328 *ppv
= static_cast<IOleCache
*>(&m_aInternalCache
);
331 else if (IsEqualIID(riid
, IID_IOleCache2
))
334 *ppv
= static_cast<IOleCache2
*>(&m_aInternalCache
);
337 else if (IsEqualIID(riid
, IID_IOleWindow
))
340 *ppv
= static_cast<IOleWindow
*>(this);
343 else if (IsEqualIID(riid
, IID_IOleInPlaceObject
))
346 *ppv
= static_cast<IOleInPlaceObject
*>(this);
349 else if (IsEqualIID(riid
, IID_IDispatch
))
352 *ppv
= static_cast<IDispatch
*>(this);
357 return ResultFromScode(E_NOINTERFACE
);
361 COM_DECLSPEC_NOTHROW
STDMETHODIMP_(ULONG
) InprocEmbedDocument_Impl::AddRef()
367 COM_DECLSPEC_NOTHROW
STDMETHODIMP_(ULONG
) InprocEmbedDocument_Impl::Release()
369 // unfortunately there are reentrance problems in mfc that have to be workarounded
370 sal_Int32 nCount
= m_refCount
> 0 ? --m_refCount
: 0;
371 if ( nCount
== 0 && !m_bDeleted
)
373 // deleting of this object can trigger deleting of mfc objects that will try to delete this object one more time
384 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetClassID( CLSID
* pClassId
)
392 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::IsDirty()
394 if ( m_pDefHandler
== nullptr || m_pOleAdvises
[0] == nullptr || m_pOleAdvises
[0]->IsClosed() )
397 if ( CheckDefHandler() )
399 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
401 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
403 return pPersist
->IsDirty();
410 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InitNew( IStorage
*pStg
)
412 if ( CheckDefHandler() )
414 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
416 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
419 HRESULT hr
= pPersist
->InitNew( pStg
);
420 if ( SUCCEEDED( hr
) )
422 m_nInitMode
= INIT_FROM_STORAGE
;
428 delete[] m_pFileName
;
429 m_pFileName
= nullptr;
441 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Load( IStorage
*pStg
)
443 if ( CheckDefHandler() )
445 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
447 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
450 HRESULT hr
= pPersist
->Load( pStg
);
451 if ( SUCCEEDED( hr
) )
453 m_nInitMode
= LOAD_FROM_STORAGE
;
459 delete[] m_pFileName
;
460 m_pFileName
= nullptr;
472 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Save( IStorage
*pStgSave
, BOOL fSameAsLoad
)
474 if ( fSameAsLoad
&& ( m_pDefHandler
== nullptr || m_pOleAdvises
[0] == nullptr || m_pOleAdvises
[0]->IsClosed() ) )
477 if ( CheckDefHandler() )
479 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
481 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
483 return pPersist
->Save( pStgSave
, fSameAsLoad
);
490 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SaveCompleted( IStorage
*pStgNew
)
492 if ( m_pDefHandler
== nullptr || m_pOleAdvises
[0] == nullptr || m_pOleAdvises
[0]->IsClosed() )
495 m_pStorage
= pStgNew
;
500 if ( CheckDefHandler() )
502 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
504 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
507 HRESULT hr
= pPersist
->SaveCompleted( pStgNew
);
508 if ( SUCCEEDED( hr
) )
510 m_nInitMode
= LOAD_FROM_STORAGE
;
513 m_pStorage
= pStgNew
;
519 delete[] m_pFileName
;
520 m_pFileName
= nullptr;
532 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::HandsOffStorage()
534 if ( CheckDefHandler() )
536 sal::systools::COMReference
< IPersistStorage
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
538 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
541 HRESULT hr
= pPersist
->HandsOffStorage();
542 if ( SUCCEEDED( hr
) )
544 m_pStorage
= nullptr;
556 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName
, DWORD dwMode
)
558 if ( CheckDefHandler() && pszFileName
)
560 sal::systools::COMReference
< IPersistFile
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
562 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
565 HRESULT hr
= pPersist
->Load( pszFileName
, dwMode
);
566 if ( SUCCEEDED( hr
) )
568 m_nInitMode
= LOAD_FROM_FILE
;
570 m_pStorage
= nullptr;
572 m_nFileOpenMode
= dwMode
;
574 SetName( pszFileName
, m_pFileName
);
585 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName
, BOOL fRemember
)
587 if ( CheckDefHandler() )
589 sal::systools::COMReference
< IPersistFile
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
591 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
593 return pPersist
->Save( pszFileName
, fRemember
);
600 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName
)
602 if ( CheckDefHandler() )
604 sal::systools::COMReference
< IPersistFile
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
606 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
609 HRESULT hr
= pPersist
->SaveCompleted( pszFileName
);
610 if ( SUCCEEDED( hr
) )
612 m_nInitMode
= LOAD_FROM_STORAGE
;
614 m_pStorage
= nullptr;
616 m_nFileOpenMode
= STGM_READWRITE
; // was just written
618 SetName( pszFileName
, m_pFileName
);
628 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetCurFile( LPOLESTR
*ppszFileName
)
630 if ( CheckDefHandler() )
632 sal::systools::COMReference
< IPersistFile
> pPersist(m_pDefHandler
, sal::systools::COM_QUERY
);
634 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
636 return pPersist
->GetCurFile( ppszFileName
);
644 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetClientSite( IOleClientSite
* pSite
)
646 if ( pSite
== m_pClientSite
.get() )
651 m_pClientSite
= nullptr;
652 if ( m_pOleContainer
)
654 m_pOleContainer
->LockContainer( FALSE
);
655 m_pOleContainer
= nullptr;
659 if ( CheckDefHandler() )
661 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
663 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
666 HRESULT hr2
= pOleObject
->SetClientSite( pSite
);
667 if ( SUCCEEDED( hr2
) )
669 m_pClientSite
= pSite
;
671 if ( m_pOleContainer
)
673 m_pOleContainer
->LockContainer( FALSE
);
674 m_pOleContainer
= nullptr;
677 m_pClientSite
->GetContainer( &m_pOleContainer
);
678 if ( m_pOleContainer
)
679 m_pOleContainer
->LockContainer( TRUE
);
690 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetClientSite( IOleClientSite
** pSite
)
692 if ( CheckDefHandler() )
694 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
696 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
698 return pOleObject
->GetClientSite( pSite
);
705 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
)
708 if ( CheckDefHandler() )
710 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
712 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
715 pOleObject
->SetHostNames( szContainerApp
, szContainerObj
);
723 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Close( DWORD dwSaveOption
)
726 if ( m_pDefHandler
&& CheckDefHandler() )
728 // no need to close if there is no default handler.
729 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
731 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
734 HRESULT hr
= pOleObject
->Close( dwSaveOption
);
737 hr
= CoDisconnectObject( static_cast<IUnknown
*>(static_cast<IPersistStorage
*>(this)), 0 );
738 if (!SUCCEEDED(hr
) && SUCCEEDED(ret
))
743 // if the object is closed from outside that means that it should go to uninitialized state
750 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker
, IMoniker
* pmk
)
752 if ( CheckDefHandler() )
754 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
756 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
758 return pOleObject
->SetMoniker( dwWhichMoniker
, pmk
);
765 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
** ppmk
)
767 if ( CheckDefHandler() )
769 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
771 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
773 return pOleObject
->GetMoniker( dwAssign
, dwWhichMoniker
, ppmk
);
780 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InitFromData( IDataObject
* pDataObject
, BOOL fCreation
, DWORD dwReserved
)
782 if ( CheckDefHandler() )
784 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
786 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
788 return pOleObject
->InitFromData( pDataObject
, fCreation
, dwReserved
);
795 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetClipboardData( DWORD dwReserved
, IDataObject
** ppDataObject
)
797 if ( CheckDefHandler() )
799 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
801 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
803 return pOleObject
->GetClipboardData( dwReserved
, ppDataObject
);
810 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::DoVerb(
813 IOleClientSite
*pActiveSite
,
818 if ( CheckDefHandler() )
820 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
822 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
825 return pOleObject
->DoVerb( iVerb
, pMsg
, pActiveSite
, nLong
, hWin
, pRect
);
834 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB
** ppEnumOleVerb
)
836 if ( CheckDefHandler() )
838 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
840 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
842 return pOleObject
->EnumVerbs( ppEnumOleVerb
);
849 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Update()
852 if ( m_pDefHandler
&& CheckDefHandler() )
854 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
856 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
858 return pOleObject
->Update();
865 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::IsUpToDate()
867 if ( CheckDefHandler() )
869 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
871 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
873 return pOleObject
->IsUpToDate();
880 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetUserClassID( CLSID
*pClsid
)
889 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType
, LPOLESTR
* pszUserType
)
891 if ( CheckDefHandler() )
893 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
895 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
897 return pOleObject
->GetUserType( dwFormOfType
, pszUserType
);
904 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect
, SIZEL
*psizel
)
906 if ( CheckDefHandler() )
908 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
910 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
912 return pOleObject
->SetExtent( dwDrawAspect
, psizel
);
919 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect
, SIZEL
* psizel
)
921 if ( CheckDefHandler() )
923 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
925 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
927 return pOleObject
->GetExtent( dwDrawAspect
, psizel
);
934 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Advise( IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
)
937 if ( !pdwConnection
)
940 // CheckDefHandler will set the listener, avoid reusing of old listener
941 if ( DEFAULT_ARRAY_LEN
> *pdwConnection
&& *pdwConnection
> 0 && m_pOleAdvises
[*pdwConnection
] )
943 m_pOleAdvises
[*pdwConnection
]->DisconnectOrigAdvise();
944 m_pOleAdvises
[*pdwConnection
] = nullptr;
947 if ( pAdvSink
&& CheckDefHandler() )
949 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
951 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
954 sal::systools::COMReference
pOwnAdvise(new OleWrapperAdviseSink(pAdvSink
));
957 if ( SUCCEEDED( pOleObject
->Advise( pOwnAdvise
.get(), &nRegID
) ) && nRegID
> 0 )
959 pOwnAdvise
->SetRegID( nRegID
);
960 *pdwConnection
= InsertAdviseLinkToList( pOwnAdvise
, m_pOleAdvises
);
961 if ( *pdwConnection
)
964 pOleObject
->Unadvise( nRegID
);
969 // return success always for now
974 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Unadvise( DWORD dwConnection
)
976 if ( DEFAULT_ARRAY_LEN
> dwConnection
&& dwConnection
> 0 && m_pOleAdvises
[dwConnection
] )
980 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
982 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
985 DWORD nID
= m_pOleAdvises
[dwConnection
]->GetRegID();
986 pOleObject
->Unadvise( nID
);
990 m_pOleAdvises
[dwConnection
]->DisconnectOrigAdvise();
991 m_pOleAdvises
[dwConnection
] = nullptr;
1000 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::EnumAdvise( IEnumSTATDATA
** /*ppenumAdvise*/ )
1006 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect
, DWORD
* pdwStatus
)
1008 if ( CheckDefHandler() )
1010 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1012 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1014 return pOleObject
->GetMiscStatus( dwAspect
, pdwStatus
);
1021 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE
* pLogpal
)
1023 if ( CheckDefHandler() )
1025 sal::systools::COMReference
< IOleObject
> pOleObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1027 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1029 return pOleObject
->SetColorScheme( pLogpal
);
1037 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetData( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
)
1039 if ( CheckDefHandler() )
1041 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1043 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1045 return pIDataObject
->GetData( pFormatetc
, pMedium
);
1052 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetDataHere( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
)
1054 if ( CheckDefHandler() )
1056 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1058 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1060 return pIDataObject
->GetDataHere( pFormatetc
, pMedium
);
1067 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::QueryGetData( FORMATETC
* pFormatetc
)
1069 if ( CheckDefHandler() )
1071 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1073 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1075 return pIDataObject
->QueryGetData( pFormatetc
);
1082 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC
* pFormatetcIn
, FORMATETC
* pFormatetcOut
)
1084 if ( CheckDefHandler() )
1086 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1088 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1090 return pIDataObject
->GetCanonicalFormatEtc( pFormatetcIn
, pFormatetcOut
);
1097 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetData( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
, BOOL fRelease
)
1099 if ( CheckDefHandler() )
1101 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1103 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1105 return pIDataObject
->SetData( pFormatetc
, pMedium
, fRelease
);
1112 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection
, IEnumFORMATETC
** ppFormatetc
)
1114 if ( CheckDefHandler() )
1116 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1118 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1120 return pIDataObject
->EnumFormatEtc( dwDirection
, ppFormatetc
);
1127 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::DAdvise( FORMATETC
* pFormatetc
, DWORD advf
, IAdviseSink
* pAdvSink
, DWORD
* pdwConnection
)
1130 if ( !pdwConnection
)
1133 // avoid reusing of the old listener
1134 if ( m_pDefHandler
&& DEFAULT_ARRAY_LEN
> *pdwConnection
&& *pdwConnection
> 0 && m_pDataAdvises
[*pdwConnection
] )
1136 m_pDataAdvises
[*pdwConnection
]->DisconnectOrigAdvise();
1137 m_pDataAdvises
[*pdwConnection
] = nullptr;
1140 if ( pAdvSink
&& CheckDefHandler() )
1142 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1144 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1147 sal::systools::COMReference
pOwnAdvise( new OleWrapperAdviseSink( pAdvSink
, pFormatetc
, advf
) );
1150 if ( SUCCEEDED( pIDataObject
->DAdvise( pFormatetc
, advf
, pOwnAdvise
.get(), &nRegID
) ) && nRegID
> 0 )
1152 pOwnAdvise
->SetRegID( nRegID
);
1153 *pdwConnection
= InsertAdviseLinkToList( pOwnAdvise
, m_pDataAdvises
);
1154 if ( *pdwConnection
)
1157 pIDataObject
->DUnadvise( nRegID
);
1162 // return success always for now
1167 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection
)
1169 if ( m_pDefHandler
&& DEFAULT_ARRAY_LEN
> dwConnection
&& dwConnection
> 0 && m_pDataAdvises
[dwConnection
] )
1171 if ( CheckDefHandler() )
1173 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1175 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1178 DWORD nID
= m_pDataAdvises
[dwConnection
]->GetRegID();
1179 pIDataObject
->DUnadvise( nID
);
1183 m_pDataAdvises
[dwConnection
]->DisconnectOrigAdvise();
1184 m_pDataAdvises
[dwConnection
] = nullptr;
1193 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA
** ppenumAdvise
)
1195 if ( CheckDefHandler() )
1197 sal::systools::COMReference
< IDataObject
> pIDataObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1199 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1201 return pIDataObject
->EnumDAdvise( ppenumAdvise
);
1209 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid
)
1211 if ( CheckDefHandler() )
1213 sal::systools::COMReference
< IRunnableObject
> pIRunObj(m_pDefHandler
, sal::systools::COM_QUERY
);
1215 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1217 return pIRunObj
->GetRunningClass( lpClsid
);
1224 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Run( LPBINDCTX pbc
)
1226 if ( CheckDefHandler() )
1228 sal::systools::COMReference
< IRunnableObject
> pIRunObj(m_pDefHandler
, sal::systools::COM_QUERY
);
1230 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1232 return pIRunObj
->Run( pbc
);
1238 BOOL STDMETHODCALLTYPE
InprocEmbedDocument_Impl::IsRunning()
1240 if (CheckDefHandler())
1242 sal::systools::COMReference
< IRunnableObject
> pIRunObj(m_pDefHandler
, sal::systools::COM_QUERY
);
1244 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1246 return pIRunObj
->IsRunning();
1252 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::LockRunning( BOOL fLock
, BOOL fLastUnlockCloses
)
1254 if ( CheckDefHandler() )
1256 sal::systools::COMReference
< IRunnableObject
> pIRunObj(m_pDefHandler
, sal::systools::COM_QUERY
);
1258 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1260 return pIRunObj
->LockRunning( fLock
, fLastUnlockCloses
);
1267 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained
)
1269 if ( CheckDefHandler() )
1271 sal::systools::COMReference
< IRunnableObject
> pIRunObj(m_pDefHandler
, sal::systools::COM_QUERY
);
1273 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1275 return pIRunObj
->SetContainedObject( fContained
);
1282 // IViewObject methods
1284 COM_DECLSPEC_NOTHROW 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
)
1286 if ( CheckDefHandler() )
1288 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1290 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1292 return pIViewObject
->Draw( dwDrawAspect
, lindex
, pvAspect
, ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
1299 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
1301 if ( CheckDefHandler() )
1303 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1305 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1307 return pIViewObject
->GetColorSet( dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
1314 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DWORD
*pdwFreeze
)
1316 if ( CheckDefHandler() )
1318 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1320 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1322 return pIViewObject
->Freeze( dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
1329 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze
)
1331 if ( CheckDefHandler() )
1333 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1335 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1337 return pIViewObject
->Unfreeze( dwFreeze
);
1344 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetAdvise( DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
1347 // CheckDefHandler will set the listener, avoid reusing of old listener
1348 if ( m_pViewAdvise
)
1350 m_pViewAdvise
->DisconnectOrigAdvise();
1351 m_pViewAdvise
= nullptr;
1354 if ( pAdvSink
&& CheckDefHandler() )
1356 sal::systools::COMReference
< IViewObject
> pIViewObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1358 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1361 sal::systools::COMReference
pOwnAdvise(new OleWrapperAdviseSink(pAdvSink
, aspects
, advf
));
1363 if ( SUCCEEDED( pIViewObject
->SetAdvise( aspects
, advf
, pOwnAdvise
.get() ) ) )
1365 m_pViewAdvise
= pOwnAdvise
;
1375 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetAdvise( DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
1378 return E_INVALIDARG
;
1380 if ( m_pViewAdvise
)
1383 *pAspects
= m_pViewAdvise
->GetAspect();
1386 *pAdvf
= m_pViewAdvise
->GetViewAdviseFlag();
1388 *ppAdvSink
= m_pViewAdvise
->GetOrigAdvise().get();
1390 (*ppAdvSink
)->AddRef();
1393 *ppAdvSink
= nullptr;
1398 // IViewObject2 methods
1400 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect
, LONG lindex
, DVTARGETDEVICE
*ptd
, LPSIZEL lpsizel
)
1402 if ( CheckDefHandler() )
1404 sal::systools::COMReference
< IViewObject2
> pIViewObject2(m_pDefHandler
, sal::systools::COM_QUERY
);
1406 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1407 if ( pIViewObject2
)
1408 return pIViewObject2
->GetExtent( dwDrawAspect
, lindex
, ptd
, lpsizel
);
1415 // IOleWindow methods
1417 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetWindow( HWND
*phwnd
)
1419 if ( CheckDefHandler() )
1421 sal::systools::COMReference
< IOleWindow
> pIOleWindow(m_pDefHandler
, sal::systools::COM_QUERY
);
1423 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1425 return pIOleWindow
->GetWindow( phwnd
);
1432 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode
)
1434 if ( CheckDefHandler() )
1436 sal::systools::COMReference
< IOleWindow
> pIOleWindow(m_pDefHandler
, sal::systools::COM_QUERY
);
1438 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1440 return pIOleWindow
->ContextSensitiveHelp( fEnterMode
);
1447 // IOleInPlaceObject methods
1449 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InPlaceDeactivate()
1451 if ( CheckDefHandler() )
1453 sal::systools::COMReference
< IOleInPlaceObject
> pIOleInPlaceObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1455 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1456 if ( pIOleInPlaceObject
)
1457 return pIOleInPlaceObject
->InPlaceDeactivate();
1464 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::UIDeactivate()
1466 if ( CheckDefHandler() )
1468 sal::systools::COMReference
< IOleInPlaceObject
> pIOleInPlaceObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1470 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1471 if ( pIOleInPlaceObject
)
1472 return pIOleInPlaceObject
->UIDeactivate();
1479 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
1481 if ( CheckDefHandler() )
1483 sal::systools::COMReference
< IOleInPlaceObject
> pIOleInPlaceObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1485 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1486 if ( pIOleInPlaceObject
)
1487 return pIOleInPlaceObject
->SetObjectRects( lprcPosRect
, lprcClipRect
);
1494 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::ReactivateAndUndo()
1496 if ( CheckDefHandler() )
1498 sal::systools::COMReference
< IOleInPlaceObject
> pIOleInPlaceObject(m_pDefHandler
, sal::systools::COM_QUERY
);
1500 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1501 if ( pIOleInPlaceObject
)
1502 return pIOleInPlaceObject
->ReactivateAndUndo();
1509 // IDispatch methods
1511 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetTypeInfoCount( UINT
*pctinfo
)
1513 if ( CheckDefHandler() )
1515 sal::systools::COMReference
< IDispatch
> pIDispatch(m_pDefHandler
, sal::systools::COM_QUERY
);
1517 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1519 return pIDispatch
->GetTypeInfoCount( pctinfo
);
1526 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1528 if ( CheckDefHandler() )
1530 sal::systools::COMReference
< IDispatch
> pIDispatch(m_pDefHandler
, sal::systools::COM_QUERY
);
1532 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1534 return pIDispatch
->GetTypeInfo( iTInfo
, lcid
, ppTInfo
);
1541 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1543 if ( CheckDefHandler() )
1545 sal::systools::COMReference
< IDispatch
> pIDispatch(m_pDefHandler
, sal::systools::COM_QUERY
);
1547 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1549 return pIDispatch
->GetIDsOfNames( riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1556 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::Invoke( DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1558 if ( CheckDefHandler() )
1560 sal::systools::COMReference
< IDispatch
> pIDispatch(m_pDefHandler
, sal::systools::COM_QUERY
);
1562 ULONGGuard
aGuard( m_nCallsOnStack
); // avoid reentrance problem
1564 return pIDispatch
->Invoke( dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1571 // InternalCacheWrapper
1576 COM_DECLSPEC_NOTHROW STDMETHODIMP
1577 InprocEmbedDocument_Impl::InternalCacheWrapper::QueryInterface(REFIID riid
, void** ppv
)
1579 return m_rOwnDocument
.QueryInterface( riid
, ppv
);
1583 COM_DECLSPEC_NOTHROW
STDMETHODIMP_(ULONG
) InprocEmbedDocument_Impl::InternalCacheWrapper::AddRef()
1585 return m_rOwnDocument
.AddRef();
1589 COM_DECLSPEC_NOTHROW
STDMETHODIMP_(ULONG
) InprocEmbedDocument_Impl::InternalCacheWrapper::Release()
1591 return m_rOwnDocument
.Release();
1594 // IOleCache methods
1596 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC
*pformatetc
, DWORD advf
, DWORD
*pdwConnection
)
1598 if ( m_rOwnDocument
.CheckDefHandler() )
1600 sal::systools::COMReference
< IOleCache
> pIOleCache(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1602 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1604 return pIOleCache
->Cache( pformatetc
, advf
, pdwConnection
);
1611 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwConnection
)
1613 if ( m_rOwnDocument
.CheckDefHandler() )
1615 sal::systools::COMReference
< IOleCache
> pIOleCache(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1617 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1619 return pIOleCache
->Uncache( dwConnection
);
1626 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTATDATA
**ppenumSTATDATA
)
1628 if ( m_rOwnDocument
.CheckDefHandler() )
1630 sal::systools::COMReference
< IOleCache
> pIOleCache(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1632 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1634 return pIOleCache
->EnumCache( ppenumSTATDATA
);
1641 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObject
*pDataObject
)
1643 if ( m_rOwnDocument
.CheckDefHandler() )
1645 sal::systools::COMReference
< IOleCache
> pIOleCache(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1647 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1649 return pIOleCache
->InitCache( pDataObject
);
1656 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC
*pformatetc
, STGMEDIUM
*pmedium
, BOOL fRelease
)
1658 if ( m_rOwnDocument
.CheckDefHandler() )
1660 sal::systools::COMReference
< IOleCache
> pIOleCache(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1662 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1664 return pIOleCache
->SetData( pformatetc
, pmedium
, fRelease
);
1670 // IOleCache2 methods
1672 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATAOBJECT pDataObject
, DWORD grfUpdf
, LPVOID pReserved
)
1674 if ( m_rOwnDocument
.CheckDefHandler() )
1676 sal::systools::COMReference
< IOleCache2
> pIOleCache2(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1678 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1680 return pIOleCache2
->UpdateCache( pDataObject
, grfUpdf
, pReserved
);
1687 COM_DECLSPEC_NOTHROW STDMETHODIMP
InprocEmbedDocument_Impl::InternalCacheWrapper::DiscardCache( DWORD dwDiscardOptions
)
1689 if ( m_rOwnDocument
.CheckDefHandler() )
1691 sal::systools::COMReference
< IOleCache2
> pIOleCache2(m_rOwnDocument
.GetDefHandler(), sal::systools::COM_QUERY
);
1693 ULONGGuard
aGuard( m_rOwnDocument
.m_nCallsOnStack
); // avoid reentrance problem
1695 return pIOleCache2
->DiscardCache( dwDiscardOptions
);
1701 }; // namespace inprocserv
1703 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */