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