xref: /AOO41X/main/sd/source/ui/inc/framework/ConfigurationController.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_FRAMEWORK_CONFIGURATION_CONTROLLER_HXX
29*cdf0e10cSrcweir #define SD_FRAMEWORK_CONFIGURATION_CONTROLLER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "MutexOwner.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfiguration.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ConfigurationChangeEvent.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
44*cdf0e10cSrcweir #include <tools/link.hxx>
45*cdf0e10cSrcweir #include <rtl/ref.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
48*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
49*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace css = ::com::sun::star;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2 <
56*cdf0e10cSrcweir     ::css::drawing::framework::XConfigurationController,
57*cdf0e10cSrcweir     ::css::lang::XInitialization
58*cdf0e10cSrcweir     > ConfigurationControllerInterfaceBase;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir } // end of anonymous namespace.
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir namespace sd { class ViewShellBase; }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir namespace sd { namespace framework {
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class ChangeRequestQueueProcessor;
69*cdf0e10cSrcweir class ConfigurationControllerBroadcaster;
70*cdf0e10cSrcweir class ConfigurationUpdater;
71*cdf0e10cSrcweir class ConfigurationUpdaterLock;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir /** The configuration controller is responsible for maintaining the current
74*cdf0e10cSrcweir     configuration.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     @see css::drawing::framework::XConfigurationController
77*cdf0e10cSrcweir         for an extended documentation.
78*cdf0e10cSrcweir */
79*cdf0e10cSrcweir class ConfigurationController
80*cdf0e10cSrcweir     : private sd::MutexOwner,
81*cdf0e10cSrcweir       private boost::noncopyable,
82*cdf0e10cSrcweir       public ConfigurationControllerInterfaceBase
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir public:
85*cdf0e10cSrcweir     ConfigurationController (void) throw();
86*cdf0e10cSrcweir     virtual ~ConfigurationController (void) throw();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     void ProcessEvent (void);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     /** Normally the requested changes of the configuration are executed
93*cdf0e10cSrcweir         asynchronously.  However, there is at least one situation (searching
94*cdf0e10cSrcweir         with the Outliner) where the surrounding code does not cope with
95*cdf0e10cSrcweir         this.  So, instead of calling Reschedule until the global event loop
96*cdf0e10cSrcweir         executes the configuration update, this method does (almost) the
97*cdf0e10cSrcweir         same without the reschedules.
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         Do not use this method until there is absolutely no other way.
100*cdf0e10cSrcweir     */
101*cdf0e10cSrcweir     void RequestSynchronousUpdate (void);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     // XConfigurationController
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     virtual void SAL_CALL lock (void)
106*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     virtual void SAL_CALL unlock (void)
109*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     virtual void SAL_CALL requestResourceActivation (
112*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
113*cdf0e10cSrcweir         css::drawing::framework::ResourceActivationMode eMode)
114*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     virtual void SAL_CALL requestResourceDeactivation (
117*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>&
118*cdf0e10cSrcweir             rxResourceId)
119*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResource>
122*cdf0e10cSrcweir         SAL_CALL getResource (
123*cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId)
124*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     virtual void SAL_CALL update (void)
127*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     virtual  css::uno::Reference<
130*cdf0e10cSrcweir         css::drawing::framework::XConfiguration>
131*cdf0e10cSrcweir         SAL_CALL getRequestedConfiguration (void)
132*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     virtual  css::uno::Reference<
135*cdf0e10cSrcweir         css::drawing::framework::XConfiguration>
136*cdf0e10cSrcweir         SAL_CALL getCurrentConfiguration (void)
137*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     virtual void SAL_CALL restoreConfiguration (
140*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XConfiguration>&
141*cdf0e10cSrcweir         rxConfiguration)
142*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     // XConfigurationControllerBroadcaster
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     virtual void SAL_CALL addConfigurationChangeListener (
148*cdf0e10cSrcweir         const css::uno::Reference<
149*cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeListener>& rxListener,
150*cdf0e10cSrcweir         const ::rtl::OUString& rsEventType,
151*cdf0e10cSrcweir         const css::uno::Any& rUserData)
152*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     virtual void SAL_CALL removeConfigurationChangeListener (
155*cdf0e10cSrcweir         const css::uno::Reference<
156*cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeListener>& rxListener)
157*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     virtual void SAL_CALL notifyEvent (
160*cdf0e10cSrcweir         const css::drawing::framework::ConfigurationChangeEvent& rEvent)
161*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     // XConfigurationRequestQueue
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPendingRequests (void)
167*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     virtual void SAL_CALL postChangeRequest (
170*cdf0e10cSrcweir         const css::uno::Reference<
171*cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeRequest>& rxRequest)
172*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     // XResourceFactoryManager
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     virtual void SAL_CALL addResourceFactory(
178*cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL,
179*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory)
180*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     virtual void SAL_CALL removeResourceFactoryForURL(
183*cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL)
184*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     virtual void SAL_CALL removeResourceFactoryForReference(
187*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory)
188*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResourceFactory>
191*cdf0e10cSrcweir         SAL_CALL getResourceFactory (
192*cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL)
193*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     // XInitialization
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     virtual void SAL_CALL initialize(
199*cdf0e10cSrcweir         const css::uno::Sequence<css::uno::Any>& rArguments)
200*cdf0e10cSrcweir         throw (css::uno::Exception, css::uno::RuntimeException);
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     /** Use this class instead of calling lock() and unlock() directly in
204*cdf0e10cSrcweir         order to be exception safe.
205*cdf0e10cSrcweir     */
206*cdf0e10cSrcweir     class Lock
207*cdf0e10cSrcweir     {
208*cdf0e10cSrcweir     public:
209*cdf0e10cSrcweir         Lock (const css::uno::Reference<
210*cdf0e10cSrcweir             css::drawing::framework::XConfigurationController>& rxController);
211*cdf0e10cSrcweir         ~Lock (void);
212*cdf0e10cSrcweir     private:
213*cdf0e10cSrcweir         css::uno::Reference<
214*cdf0e10cSrcweir             css::drawing::framework::XConfigurationController> mxController;
215*cdf0e10cSrcweir     };
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir private:
218*cdf0e10cSrcweir     class Implementation;
219*cdf0e10cSrcweir     ::boost::scoped_ptr<Implementation> mpImplementation;
220*cdf0e10cSrcweir     bool mbIsDisposed;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     /** When the called object has already been disposed this method throws
223*cdf0e10cSrcweir         an exception and does not return.
224*cdf0e10cSrcweir     */
225*cdf0e10cSrcweir     void ThrowIfDisposed (void) const
226*cdf0e10cSrcweir         throw (css::lang::DisposedException);
227*cdf0e10cSrcweir };
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir } } // end of namespace sd::framework
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir #endif
232