a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent
[LibreOffice.git] / embeddedobj / source / msole / olewrapclient.cxx
blob15d5f16632fa85398c7927b320470320f57e51d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 )
28 : m_nRefCount( 0 )
29 , m_pOleComp( pOleComp )
31 OSL_ENSURE( m_pOleComp, "No ole component is provided!" );
34 OleWrapperClientSite::~OleWrapperClientSite()
38 STDMETHODIMP OleWrapperClientSite::QueryInterface( REFIID riid , void** ppv )
40 *ppv=nullptr;
42 if ( riid == IID_IUnknown )
43 *ppv = static_cast<IUnknown*>(this);
45 if ( riid == IID_IOleClientSite )
46 *ppv = static_cast<IOleClientSite*>(this);
48 if ( *ppv != nullptr )
50 static_cast<IUnknown*>(*ppv)->AddRef();
51 return S_OK;
54 return E_NOINTERFACE;
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 )
66 delete this;
68 return nReturn;
71 void OleWrapperClientSite::disconnectOleComponent()
73 // must not be called from the descructor of OleComponent!!!
74 osl::MutexGuard aGuard( m_aMutex );
75 m_pOleComp = nullptr;
78 STDMETHODIMP OleWrapperClientSite::SaveObject()
80 OleComponent* pLockComponent = nullptr;
81 HRESULT hResult = E_FAIL;
84 osl::MutexGuard aGuard( m_aMutex );
85 if ( m_pOleComp )
87 pLockComponent = m_pOleComp;
88 pLockComponent->acquire();
92 if ( pLockComponent )
94 if ( pLockComponent->SaveObject_Impl() )
95 hResult = S_OK;
97 pLockComponent->release();
100 return hResult;
103 STDMETHODIMP OleWrapperClientSite::GetMoniker( DWORD, DWORD, IMoniker **ppmk )
105 *ppmk = nullptr;
106 return E_NOTIMPL;
109 STDMETHODIMP OleWrapperClientSite::GetContainer( IOleContainer** ppContainer )
111 *ppContainer = nullptr;
112 return E_NOTIMPL;
115 STDMETHODIMP OleWrapperClientSite::ShowObject()
117 return S_OK;
120 STDMETHODIMP OleWrapperClientSite::OnShowWindow( BOOL bShow )
122 OleComponent* pLockComponent = nullptr;
124 // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
126 osl::MutexGuard aGuard( m_aMutex );
127 if ( m_pOleComp )
129 pLockComponent = m_pOleComp;
130 pLockComponent->acquire();
134 if ( pLockComponent )
136 pLockComponent->OnShowWindow_Impl( bShow ); // the result is not interesting
137 pLockComponent->release();
140 return S_OK;
143 STDMETHODIMP OleWrapperClientSite::RequestNewObjectLayout()
145 return E_NOTIMPL;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */