LibreOffice Module embeddedobj (master) 1
olewrapclient.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <osl/diagnose.h>
21
22#include "olewrapclient.hxx"
23#include "olecomponent.hxx"
24
25// TODO: May be a mutex must be introduced
26
28: m_nRefCount( 0 )
29, m_pOleComp( pOleComp )
30{
31 OSL_ENSURE( m_pOleComp, "No ole component is provided!" );
32}
33
35{
36}
37
38STDMETHODIMP OleWrapperClientSite::QueryInterface( REFIID riid , void** ppv )
39{
40 *ppv=nullptr;
41
42 if ( riid == IID_IUnknown )
43 *ppv = static_cast<IUnknown*>(this);
44
45 if ( riid == IID_IOleClientSite )
46 *ppv = static_cast<IOleClientSite*>(this);
47
48 if ( *ppv != nullptr )
49 {
50 static_cast<IUnknown*>(*ppv)->AddRef();
51 return S_OK;
52 }
53
54 return E_NOINTERFACE;
55}
56
57STDMETHODIMP_(ULONG) OleWrapperClientSite::AddRef()
58{
59 return osl_atomic_increment( &m_nRefCount);
60}
61
62STDMETHODIMP_(ULONG) OleWrapperClientSite::Release()
63{
64 ULONG nReturn = --m_nRefCount;
65 if ( m_nRefCount == 0 )
66 delete this;
67
68 return nReturn;
69}
70
72{
73 // must not be called from the descructor of OleComponent!!!
74 osl::MutexGuard aGuard( m_aMutex );
75 m_pOleComp = nullptr;
76}
77
79{
80 OleComponent* pLockComponent = nullptr;
81 HRESULT hResult = E_FAIL;
82
83 {
84 osl::MutexGuard aGuard( m_aMutex );
85 if ( m_pOleComp )
86 {
87 pLockComponent = m_pOleComp;
88 pLockComponent->acquire();
89 }
90 }
91
92 if ( pLockComponent )
93 {
94 if ( pLockComponent->SaveObject_Impl() )
95 hResult = S_OK;
96
97 pLockComponent->release();
98 }
99
100 return hResult;
101}
102
103STDMETHODIMP OleWrapperClientSite::GetMoniker( DWORD, DWORD, IMoniker **ppmk )
104{
105 *ppmk = nullptr;
106 return E_NOTIMPL;
107}
108
109STDMETHODIMP OleWrapperClientSite::GetContainer( IOleContainer** ppContainer )
110{
111 *ppContainer = nullptr;
112 return E_NOTIMPL;
113}
114
116{
117 return S_OK;
118}
119
121{
122 OleComponent* pLockComponent = nullptr;
123
124 // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
125 {
126 osl::MutexGuard aGuard( m_aMutex );
127 if ( m_pOleComp )
128 {
129 pLockComponent = m_pOleComp;
130 pLockComponent->acquire();
131 }
132 }
133
134 if ( pLockComponent )
135 {
136 pLockComponent->OnShowWindow_Impl( bShow ); // the result is not interesting
137 pLockComponent->release();
138 }
139
140 return S_OK;
141}
142
144{
145 return E_NOTIMPL;
146}
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool SaveObject_Impl()
bool OnShowWindow_Impl(bool bShow)
STDMETHODIMP ShowObject() override
STDMETHODIMP RequestNewObjectLayout() override
STDMETHODIMP GetContainer(IOleContainer **) override
virtual ~OleWrapperClientSite()
STDMETHODIMP SaveObject() override
oslInterlockedCount m_nRefCount
STDMETHODIMP OnShowWindow(BOOL) override
STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker **) override
STDMETHODIMP QueryInterface(REFIID, void **) override
OleWrapperClientSite(OleComponent *pOleComp)
OleComponent * m_pOleComp
STDMETHODIMP_(ULONG) OleWrapperClientSite
const wchar_t *typedef BOOL