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