fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / formula / source / ui / resource / ModuleHelper.cxx
blob4d4803e4cb57ea7675161a82859a1815f32db164
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 .
19 #include "ModuleHelper.hxx"
20 #include <comphelper/processfactory.hxx>
21 #include <osl/thread.h>
22 #include <com/sun/star/util/XMacroExpander.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <rtl/instance.hxx>
26 #include <rtl/uri.hxx>
27 #include <tools/debug.hxx>
28 #include <svl/solar.hrc>
30 #define ENTER_MOD_METHOD() \
31 ::osl::MutexGuard aGuard(theOModuleMutex::get()); \
32 ensureImpl()
35 namespace formula
38 using namespace ::com::sun::star;
40 //= OModuleImpl
42 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner
44 class OModuleImpl
46 ResMgr* m_pResources;
48 public:
49 /// ctor
50 OModuleImpl();
51 ~OModuleImpl();
53 /// get the manager for the resources of the module
54 ResMgr* getResManager();
57 OModuleImpl::OModuleImpl()
58 :m_pResources(NULL)
63 OModuleImpl::~OModuleImpl()
65 if (m_pResources)
66 delete m_pResources;
70 ResMgr* OModuleImpl::getResManager()
72 // note that this method is not threadsafe, which counts for the whole class !
74 if (!m_pResources)
76 // create a manager with a fixed prefix
77 m_pResources = ResMgr::CreateResMgr("forui");
79 return m_pResources;
83 //= OModule
85 namespace
87 // access safety
88 struct theOModuleMutex : public rtl::Static< osl::Mutex, theOModuleMutex > {};
90 sal_Int32 OModule::s_nClients = 0;
91 OModuleImpl* OModule::s_pImpl = NULL;
93 ResMgr* OModule::getResManager()
95 ENTER_MOD_METHOD();
96 return s_pImpl->getResManager();
100 void OModule::registerClient()
102 ::osl::MutexGuard aGuard(theOModuleMutex::get());
103 ++s_nClients;
107 void OModule::revokeClient()
109 ::osl::MutexGuard aGuard(theOModuleMutex::get());
110 if (!--s_nClients && s_pImpl)
112 delete s_pImpl;
113 s_pImpl = NULL;
118 void OModule::ensureImpl()
120 if (s_pImpl)
121 return;
122 s_pImpl = new OModuleImpl();
126 } // namespace formula
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */