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 <osl/diagnose.h>
22 #include "olewrapclient.hxx"
23 #include "olecomponent.hxx"
25 // TODO: May be a mutex must be introduced
27 OleWrapperClientSite::OleWrapperClientSite( OleComponent
* pOleComp
)
29 , m_pOleComp( pOleComp
)
31 OSL_ENSURE( m_pOleComp
, "No ole component is provided!\n" );
34 OleWrapperClientSite::~OleWrapperClientSite()
38 STDMETHODIMP
OleWrapperClientSite::QueryInterface( REFIID riid
, void** ppv
)
42 if ( riid
== IID_IUnknown
)
43 *ppv
= (IUnknown
*)this;
45 if ( riid
== IID_IOleClientSite
)
46 *ppv
= (IOleClientSite
*)this;
50 ((IUnknown
*)*ppv
)->AddRef();
57 STDMETHODIMP_(ULONG
) OleWrapperClientSite::AddRef()
59 return osl_atomic_increment( &m_nRefCount
);
62 STDMETHODIMP_(ULONG
) OleWrapperClientSite::Release()
64 ULONG nReturn
= --m_nRefCount
;
65 if ( m_nRefCount
== 0 )
71 void OleWrapperClientSite::disconnectOleComponent()
73 // must not be called from the descructor of OleComponent!!!
74 osl::MutexGuard
aGuard( m_aMutex
);
78 STDMETHODIMP
OleWrapperClientSite::SaveObject()
80 OleComponent
* pLockComponent
= NULL
;
81 HRESULT hResult
= E_FAIL
;
84 osl::MutexGuard
aGuard( m_aMutex
);
87 pLockComponent
= m_pOleComp
;
88 pLockComponent
->acquire();
94 if ( pLockComponent
->SaveObject_Impl() )
97 pLockComponent
->release();
103 STDMETHODIMP
OleWrapperClientSite::GetMoniker( DWORD
, DWORD
, LPMONIKER
*ppmk
)
109 STDMETHODIMP
OleWrapperClientSite::GetContainer( LPOLECONTAINER
* ppContainer
)
115 STDMETHODIMP
OleWrapperClientSite::ShowObject(void)
120 STDMETHODIMP
OleWrapperClientSite::OnShowWindow( BOOL bShow
)
122 OleComponent
* pLockComponent
= NULL
;
124 // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
126 osl::MutexGuard
aGuard( m_aMutex
);
129 pLockComponent
= m_pOleComp
;
130 pLockComponent
->acquire();
134 if ( pLockComponent
)
136 pLockComponent
->OnShowWindow_Impl( bShow
); // the result is not interesting
137 pLockComponent
->release();
143 STDMETHODIMP
OleWrapperClientSite::RequestNewObjectLayout(void)
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */