1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ModuleHelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "ModuleHelper.hxx"
31 #include <comphelper/configurationhelper.hxx>
32 #include <comphelper/processfactory.hxx>
33 #include <osl/thread.h>
34 #include <com/sun/star/util/XMacroExpander.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <rtl/uri.hxx>
38 #include <tools/debug.hxx>
40 #include <svtools/solar.hrc>
43 #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
44 #define ENTER_MOD_METHOD() \
45 ::osl::MutexGuard aGuard(s_aMutex); \
48 //.........................................................................
51 //.........................................................................
52 using namespace ::com::sun::star
;
53 //=========================================================================
55 //=========================================================================
56 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
60 ResMgr
* m_pRessources
;
67 /// get the manager for the ressources of the module
68 ResMgr
* getResManager();
71 DBG_NAME( rpt_OModuleImpl
)
72 //-------------------------------------------------------------------------
73 OModuleImpl::OModuleImpl()
76 DBG_CTOR( rpt_OModuleImpl
,NULL
);
80 //-------------------------------------------------------------------------
81 OModuleImpl::~OModuleImpl()
86 DBG_DTOR( rpt_OModuleImpl
,NULL
);
89 //-------------------------------------------------------------------------
90 ResMgr
* OModuleImpl::getResManager()
92 // note that this method is not threadsafe, which counts for the whole class !
96 // create a manager with a fixed prefix
97 rtl::OString sName
= rtl::OString( "forui" );
98 m_pRessources
= ResMgr::CreateResMgr(sName
);
100 return m_pRessources
;
103 //=========================================================================
105 //=========================================================================
106 ::osl::Mutex
OModule::s_aMutex
;
107 sal_Int32
OModule::s_nClients
= 0;
108 OModuleImpl
* OModule::s_pImpl
= NULL
;
109 //-------------------------------------------------------------------------
110 ResMgr
* OModule::getResManager()
113 return s_pImpl
->getResManager();
116 //-------------------------------------------------------------------------
117 void OModule::registerClient()
119 ::osl::MutexGuard
aGuard(s_aMutex
);
123 //-------------------------------------------------------------------------
124 void OModule::revokeClient()
126 ::osl::MutexGuard
aGuard(s_aMutex
);
127 if (!--s_nClients
&& s_pImpl
)
134 //-------------------------------------------------------------------------
135 void OModule::ensureImpl()
139 s_pImpl
= new OModuleImpl();
142 //.........................................................................
143 } // namespace formula
144 //.........................................................................