LibreOffice Module shell (master) 1
spsuppClassFactory.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
11#include <COMOpenDocuments.hpp>
12
15
17{
18 ::InterlockedIncrement(&m_nObjCount);
19};
20
22{
23 ::InterlockedDecrement(&m_nObjCount);
24};
25
26// IUnknown methods
27
29 REFIID riid,
30 void **ppvObject)
31{
32 *ppvObject = nullptr;
33 if (IsEqualIID(riid, __uuidof(IUnknown)) ||
34 IsEqualIID(riid, __uuidof(IClassFactory)))
35 {
36 *ppvObject = static_cast<IClassFactory*>(this);
37 AddRef();
38 return S_OK;
39 }
40 return E_NOINTERFACE;
41}
42
43// IClassFactory methods
44
46 IUnknown *pUnkOuter,
47 REFIID riid,
48 void **ppvObject)
49{
50 *ppvObject = nullptr;
51 if (pUnkOuter)
52 {
53 return CLASS_E_NOAGGREGATION;
54 }
55
56 COMOpenDocuments* pObj;
57 try {
58 pObj = new COMOpenDocuments;
59 }
60 catch (const COMOpenDocuments::Error& e) {
61 return e.val();
62 }
63 catch (...) {
64 return E_OUTOFMEMORY;
65 }
66
67 HRESULT hr = pObj->QueryInterface(riid, ppvObject);
68 pObj->Release();
69 return hr;
70}
71
72STDMETHODIMP ClassFactory::LockServer(BOOL fLock)
73{
74 if (fLock)
75 ::InterlockedIncrement(&m_nLockCount);
76 else
77 ::InterlockedDecrement(&m_nLockCount);
78 return S_OK;
79}
80
81/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override
ULONG STDMETHODCALLTYPE Release() override
ULONG STDMETHODCALLTYPE AddRef() override
virtual ~ClassFactory() override
static LONG m_nLockCount
static LONG m_nObjCount
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) override
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) override
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override
const wchar_t *typedef BOOL
LONG
return hr