1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <osl/diagnose.h>
31 #include "olewrapclient.hxx"
32 #include "olecomponent.hxx"
34 // TODO: May be a mutex must be introduced
36 OleWrapperClientSite::OleWrapperClientSite( OleComponent
* pOleComp
)
38 , m_pOleComp( pOleComp
)
40 OSL_ENSURE( m_pOleComp
, "No ole component is provided!\n" );
43 OleWrapperClientSite::~OleWrapperClientSite()
47 STDMETHODIMP
OleWrapperClientSite::QueryInterface( REFIID riid
, void** ppv
)
51 if ( riid
== IID_IUnknown
)
52 *ppv
= (IUnknown
*)this;
54 if ( riid
== IID_IOleClientSite
)
55 *ppv
= (IOleClientSite
*)this;
59 ((IUnknown
*)*ppv
)->AddRef();
66 STDMETHODIMP_(ULONG
) OleWrapperClientSite::AddRef()
68 return osl_incrementInterlockedCount( &m_nRefCount
);
71 STDMETHODIMP_(ULONG
) OleWrapperClientSite::Release()
73 ULONG nReturn
= --m_nRefCount
;
74 if ( m_nRefCount
== 0 )
80 void OleWrapperClientSite::disconnectOleComponent()
82 // must not be called from the descructor of OleComponent!!!
83 osl::MutexGuard
aGuard( m_aMutex
);
87 STDMETHODIMP
OleWrapperClientSite::SaveObject()
89 OleComponent
* pLockComponent
= NULL
;
90 HRESULT hResult
= E_FAIL
;
93 osl::MutexGuard
aGuard( m_aMutex
);
96 pLockComponent
= m_pOleComp
;
97 pLockComponent
->acquire();
101 if ( pLockComponent
)
103 if ( pLockComponent
->SaveObject_Impl() )
106 pLockComponent
->release();
112 STDMETHODIMP
OleWrapperClientSite::GetMoniker( DWORD
, DWORD
, LPMONIKER
*ppmk
)
118 STDMETHODIMP
OleWrapperClientSite::GetContainer( LPOLECONTAINER
* ppContainer
)
124 STDMETHODIMP
OleWrapperClientSite::ShowObject(void)
129 STDMETHODIMP
OleWrapperClientSite::OnShowWindow( BOOL bShow
)
131 OleComponent
* pLockComponent
= NULL
;
133 // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
135 osl::MutexGuard
aGuard( m_aMutex
);
138 pLockComponent
= m_pOleComp
;
139 pLockComponent
->acquire();
143 if ( pLockComponent
)
145 pLockComponent
->OnShowWindow_Impl( bShow
); // the result is not interesting
146 pLockComponent
->release();
152 STDMETHODIMP
OleWrapperClientSite::RequestNewObjectLayout(void)
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */