1*5116778eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5116778eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5116778eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5116778eSAndrew Rist * distributed with this work for additional information 6*5116778eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5116778eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5116778eSAndrew Rist * "License"); you may not use this file except in compliance 9*5116778eSAndrew Rist * with the License. You may obtain a copy of the License at 10*5116778eSAndrew Rist * 11*5116778eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5116778eSAndrew Rist * 13*5116778eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5116778eSAndrew Rist * software distributed under the License is distributed on an 15*5116778eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5116778eSAndrew Rist * KIND, either express or implied. See the License for the 17*5116778eSAndrew Rist * specific language governing permissions and limitations 18*5116778eSAndrew Rist * under the License. 19*5116778eSAndrew Rist * 20*5116778eSAndrew Rist *************************************************************/ 21*5116778eSAndrew Rist 22*5116778eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef FORMULA_MODULE_HELPER_RPT_HXX_ 25cdf0e10cSrcweir #define FORMULA_MODULE_HELPER_RPT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28cdf0e10cSrcweir #include <tools/resmgr.hxx> 29cdf0e10cSrcweir #include "formula/formuladllapi.h" 30cdf0e10cSrcweir //......................................................................... 31cdf0e10cSrcweir namespace formula 32cdf0e10cSrcweir { 33cdf0e10cSrcweir //......................................................................... 34cdf0e10cSrcweir //========================================================================= 35cdf0e10cSrcweir //= OModule 36cdf0e10cSrcweir //========================================================================= 37cdf0e10cSrcweir class OModuleImpl; 38cdf0e10cSrcweir class FORMULA_DLLPUBLIC OModule 39cdf0e10cSrcweir { 40cdf0e10cSrcweir friend class OModuleClient; 41cdf0e10cSrcweir 42cdf0e10cSrcweir private: 43cdf0e10cSrcweir OModule(); 44cdf0e10cSrcweir // not implemented. OModule is a static class 45cdf0e10cSrcweir 46cdf0e10cSrcweir protected: 47cdf0e10cSrcweir static ::osl::Mutex s_aMutex; /// access safety 48cdf0e10cSrcweir static sal_Int32 s_nClients; /// number of registered clients 49cdf0e10cSrcweir static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered 50cdf0e10cSrcweir 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir /// get the vcl res manager of the module 53cdf0e10cSrcweir static ResMgr* getResManager(); 54cdf0e10cSrcweir protected: 55cdf0e10cSrcweir /// register a client for the module 56cdf0e10cSrcweir static void registerClient(); 57cdf0e10cSrcweir /// revoke a client for the module 58cdf0e10cSrcweir static void revokeClient(); 59cdf0e10cSrcweir 60cdf0e10cSrcweir private: 61cdf0e10cSrcweir /** ensure that the impl class exists 62cdf0e10cSrcweir @precond m_aMutex is guarded when this method gets called 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir static void ensureImpl(); 65cdf0e10cSrcweir }; 66cdf0e10cSrcweir 67cdf0e10cSrcweir //========================================================================= 68cdf0e10cSrcweir //= OModuleClient 69cdf0e10cSrcweir //========================================================================= 70cdf0e10cSrcweir /** base class for objects which uses any global module-specific ressources 71cdf0e10cSrcweir */ 72cdf0e10cSrcweir class FORMULA_DLLPUBLIC OModuleClient 73cdf0e10cSrcweir { 74cdf0e10cSrcweir public: OModuleClient()75cdf0e10cSrcweir OModuleClient() { OModule::registerClient(); } ~OModuleClient()76cdf0e10cSrcweir ~OModuleClient() { OModule::revokeClient(); } 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir //========================================================================= 80cdf0e10cSrcweir //= ModuleRes 81cdf0e10cSrcweir //========================================================================= 82cdf0e10cSrcweir /** specialized ResId, using the ressource manager provided by the global module 83cdf0e10cSrcweir */ 84cdf0e10cSrcweir class FORMULA_DLLPUBLIC ModuleRes : public ::ResId 85cdf0e10cSrcweir { 86cdf0e10cSrcweir public: ModuleRes(sal_uInt16 _nId)87cdf0e10cSrcweir ModuleRes(sal_uInt16 _nId) : ResId(_nId, *OModule::getResManager()) { } 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir //......................................................................... 90cdf0e10cSrcweir } // namespace formula 91cdf0e10cSrcweir //......................................................................... 92cdf0e10cSrcweir 93cdf0e10cSrcweir #endif // FORMULA_MODULE_HELPER_RPT_HXX_ 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96