1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: olewrapclient.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_embeddedobj.hxx"
34 #include <osl/diagnose.h>
36 #include "olewrapclient.hxx"
37 #include "olecomponent.hxx"
39 // TODO: May be a mutex must be introduced
41 OleWrapperClientSite::OleWrapperClientSite( OleComponent
* pOleComp
)
43 , m_pOleComp( pOleComp
)
45 OSL_ENSURE( m_pOleComp
, "No ole component is provided!\n" );
48 OleWrapperClientSite::~OleWrapperClientSite()
52 STDMETHODIMP
OleWrapperClientSite::QueryInterface( REFIID riid
, void** ppv
)
56 if ( riid
== IID_IUnknown
)
57 *ppv
= (IUnknown
*)this;
59 if ( riid
== IID_IOleClientSite
)
60 *ppv
= (IOleClientSite
*)this;
64 ((IUnknown
*)*ppv
)->AddRef();
71 STDMETHODIMP_(ULONG
) OleWrapperClientSite::AddRef()
73 return osl_incrementInterlockedCount( &m_nRefCount
);
76 STDMETHODIMP_(ULONG
) OleWrapperClientSite::Release()
78 ULONG nReturn
= --m_nRefCount
;
79 if ( m_nRefCount
== 0 )
85 void OleWrapperClientSite::disconnectOleComponent()
87 // must not be called from the descructor of OleComponent!!!
88 osl::MutexGuard
aGuard( m_aMutex
);
92 STDMETHODIMP
OleWrapperClientSite::SaveObject()
94 OleComponent
* pLockComponent
= NULL
;
95 HRESULT hResult
= E_FAIL
;
98 osl::MutexGuard
aGuard( m_aMutex
);
101 pLockComponent
= m_pOleComp
;
102 pLockComponent
->acquire();
106 if ( pLockComponent
)
108 if ( pLockComponent
->SaveObject_Impl() )
111 pLockComponent
->release();
117 STDMETHODIMP
OleWrapperClientSite::GetMoniker( DWORD
, DWORD
, LPMONIKER
*ppmk
)
123 STDMETHODIMP
OleWrapperClientSite::GetContainer( LPOLECONTAINER
* ppContainer
)
129 STDMETHODIMP
OleWrapperClientSite::ShowObject(void)
134 STDMETHODIMP
OleWrapperClientSite::OnShowWindow( BOOL bShow
)
136 OleComponent
* pLockComponent
= NULL
;
138 // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
140 osl::MutexGuard
aGuard( m_aMutex
);
143 pLockComponent
= m_pOleComp
;
144 pLockComponent
->acquire();
148 if ( pLockComponent
)
150 pLockComponent
->OnShowWindow_Impl( bShow
); // the result is not interesting
151 pLockComponent
->release();
157 STDMETHODIMP
OleWrapperClientSite::RequestNewObjectLayout(void)