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 .
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()); \
38 using namespace ::com::sun::star
;
42 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner
53 /// get the manager for the resources of the module
54 ResMgr
* getResManager();
58 OModuleImpl::OModuleImpl()
64 OModuleImpl::~OModuleImpl()
71 ResMgr
* OModuleImpl::getResManager()
73 // note that this method is not threadsafe, which counts for the whole class !
77 // create a manager with a fixed prefix
78 m_pResources
= ResMgr::CreateResMgr("rptui");
90 struct theOModuleMutex
: public rtl::Static
< osl::Mutex
, theOModuleMutex
> {};
93 sal_Int32
OModule::s_nClients
= 0;
94 OModuleImpl
* OModule::s_pImpl
= NULL
;
96 ResMgr
* OModule::getResManager()
99 return s_pImpl
->getResManager();
103 void OModule::registerClient()
105 ::osl::MutexGuard
aGuard(theOModuleMutex::get());
110 void OModule::revokeClient()
112 ::osl::MutexGuard
aGuard(theOModuleMutex::get());
113 if (!--s_nClients
&& s_pImpl
)
121 void OModule::ensureImpl()
125 s_pImpl
= new OModuleImpl();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */