1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef FORMULA_MODULE_HELPER_RPT_HXX_ 29 #define FORMULA_MODULE_HELPER_RPT_HXX_ 30 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 #include <tools/resmgr.hxx> 33 #include "formula/formuladllapi.h" 34 //......................................................................... 35 namespace formula 36 { 37 //......................................................................... 38 //========================================================================= 39 //= OModule 40 //========================================================================= 41 class OModuleImpl; 42 class FORMULA_DLLPUBLIC OModule 43 { 44 friend class OModuleClient; 45 46 private: 47 OModule(); 48 // not implemented. OModule is a static class 49 50 protected: 51 static ::osl::Mutex s_aMutex; /// access safety 52 static sal_Int32 s_nClients; /// number of registered clients 53 static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered 54 55 public: 56 /// get the vcl res manager of the module 57 static ResMgr* getResManager(); 58 protected: 59 /// register a client for the module 60 static void registerClient(); 61 /// revoke a client for the module 62 static void revokeClient(); 63 64 private: 65 /** ensure that the impl class exists 66 @precond m_aMutex is guarded when this method gets called 67 */ 68 static void ensureImpl(); 69 }; 70 71 //========================================================================= 72 //= OModuleClient 73 //========================================================================= 74 /** base class for objects which uses any global module-specific ressources 75 */ 76 class FORMULA_DLLPUBLIC OModuleClient 77 { 78 public: 79 OModuleClient() { OModule::registerClient(); } 80 ~OModuleClient() { OModule::revokeClient(); } 81 }; 82 83 //========================================================================= 84 //= ModuleRes 85 //========================================================================= 86 /** specialized ResId, using the ressource manager provided by the global module 87 */ 88 class FORMULA_DLLPUBLIC ModuleRes : public ::ResId 89 { 90 public: 91 ModuleRes(sal_uInt16 _nId) : ResId(_nId, *OModule::getResManager()) { } 92 }; 93 //......................................................................... 94 } // namespace formula 95 //......................................................................... 96 97 #endif // FORMULA_MODULE_HELPER_RPT_HXX_ 98 99 100