1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_FRAMEWORK_CONFIGURATION_CONTROLLER_HXX
25cdf0e10cSrcweir #define SD_FRAMEWORK_CONFIGURATION_CONTROLLER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "MutexOwner.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfiguration.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ConfigurationChangeEvent.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
37cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
40cdf0e10cSrcweir #include <tools/link.hxx>
41cdf0e10cSrcweir #include <rtl/ref.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
44cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
45cdf0e10cSrcweir #include <boost/noncopyable.hpp>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace css = ::com::sun::star;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace {
50cdf0e10cSrcweir 
51cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2 <
52cdf0e10cSrcweir     ::css::drawing::framework::XConfigurationController,
53cdf0e10cSrcweir     ::css::lang::XInitialization
54cdf0e10cSrcweir     > ConfigurationControllerInterfaceBase;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir } // end of anonymous namespace.
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir namespace sd { class ViewShellBase; }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir namespace sd { namespace framework {
63cdf0e10cSrcweir 
64cdf0e10cSrcweir class ChangeRequestQueueProcessor;
65cdf0e10cSrcweir class ConfigurationControllerBroadcaster;
66cdf0e10cSrcweir class ConfigurationUpdater;
67cdf0e10cSrcweir class ConfigurationUpdaterLock;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir /** The configuration controller is responsible for maintaining the current
70cdf0e10cSrcweir     configuration.
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     @see css::drawing::framework::XConfigurationController
73cdf0e10cSrcweir         for an extended documentation.
74cdf0e10cSrcweir */
75cdf0e10cSrcweir class ConfigurationController
76cdf0e10cSrcweir     : private sd::MutexOwner,
77cdf0e10cSrcweir       private boost::noncopyable,
78cdf0e10cSrcweir       public ConfigurationControllerInterfaceBase
79cdf0e10cSrcweir {
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir     ConfigurationController (void) throw();
82cdf0e10cSrcweir     virtual ~ConfigurationController (void) throw();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     void ProcessEvent (void);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     /** Normally the requested changes of the configuration are executed
89cdf0e10cSrcweir         asynchronously.  However, there is at least one situation (searching
90cdf0e10cSrcweir         with the Outliner) where the surrounding code does not cope with
91cdf0e10cSrcweir         this.  So, instead of calling Reschedule until the global event loop
92cdf0e10cSrcweir         executes the configuration update, this method does (almost) the
93cdf0e10cSrcweir         same without the reschedules.
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         Do not use this method until there is absolutely no other way.
96cdf0e10cSrcweir     */
97cdf0e10cSrcweir     void RequestSynchronousUpdate (void);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // XConfigurationController
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     virtual void SAL_CALL lock (void)
102cdf0e10cSrcweir         throw (css::uno::RuntimeException);
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     virtual void SAL_CALL unlock (void)
105cdf0e10cSrcweir         throw (css::uno::RuntimeException);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     virtual void SAL_CALL requestResourceActivation (
108cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
109cdf0e10cSrcweir         css::drawing::framework::ResourceActivationMode eMode)
110cdf0e10cSrcweir         throw (css::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     virtual void SAL_CALL requestResourceDeactivation (
113cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>&
114cdf0e10cSrcweir             rxResourceId)
115cdf0e10cSrcweir         throw (css::uno::RuntimeException);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResource>
118cdf0e10cSrcweir         SAL_CALL getResource (
119cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId)
120cdf0e10cSrcweir         throw (css::uno::RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     virtual void SAL_CALL update (void)
123cdf0e10cSrcweir         throw (css::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     virtual  css::uno::Reference<
126cdf0e10cSrcweir         css::drawing::framework::XConfiguration>
127cdf0e10cSrcweir         SAL_CALL getRequestedConfiguration (void)
128cdf0e10cSrcweir         throw (css::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     virtual  css::uno::Reference<
131cdf0e10cSrcweir         css::drawing::framework::XConfiguration>
132cdf0e10cSrcweir         SAL_CALL getCurrentConfiguration (void)
133cdf0e10cSrcweir         throw (css::uno::RuntimeException);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     virtual void SAL_CALL restoreConfiguration (
136cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XConfiguration>&
137cdf0e10cSrcweir         rxConfiguration)
138cdf0e10cSrcweir         throw (css::uno::RuntimeException);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     // XConfigurationControllerBroadcaster
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     virtual void SAL_CALL addConfigurationChangeListener (
144cdf0e10cSrcweir         const css::uno::Reference<
145cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeListener>& rxListener,
146cdf0e10cSrcweir         const ::rtl::OUString& rsEventType,
147cdf0e10cSrcweir         const css::uno::Any& rUserData)
148cdf0e10cSrcweir         throw (css::uno::RuntimeException);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     virtual void SAL_CALL removeConfigurationChangeListener (
151cdf0e10cSrcweir         const css::uno::Reference<
152cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeListener>& rxListener)
153cdf0e10cSrcweir         throw (css::uno::RuntimeException);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     virtual void SAL_CALL notifyEvent (
156cdf0e10cSrcweir         const css::drawing::framework::ConfigurationChangeEvent& rEvent)
157cdf0e10cSrcweir         throw (css::uno::RuntimeException);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     // XConfigurationRequestQueue
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPendingRequests (void)
163cdf0e10cSrcweir         throw (css::uno::RuntimeException);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     virtual void SAL_CALL postChangeRequest (
166cdf0e10cSrcweir         const css::uno::Reference<
167cdf0e10cSrcweir             css::drawing::framework::XConfigurationChangeRequest>& rxRequest)
168cdf0e10cSrcweir         throw (css::uno::RuntimeException);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     // XResourceFactoryManager
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     virtual void SAL_CALL addResourceFactory(
174cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL,
175cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory)
176cdf0e10cSrcweir         throw (css::uno::RuntimeException);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     virtual void SAL_CALL removeResourceFactoryForURL(
179cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL)
180cdf0e10cSrcweir         throw (css::uno::RuntimeException);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     virtual void SAL_CALL removeResourceFactoryForReference(
183cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory)
184cdf0e10cSrcweir         throw (css::uno::RuntimeException);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResourceFactory>
187cdf0e10cSrcweir         SAL_CALL getResourceFactory (
188cdf0e10cSrcweir         const ::rtl::OUString& sResourceURL)
189cdf0e10cSrcweir         throw (css::uno::RuntimeException);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     // XInitialization
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     virtual void SAL_CALL initialize(
195cdf0e10cSrcweir         const css::uno::Sequence<css::uno::Any>& rArguments)
196cdf0e10cSrcweir         throw (css::uno::Exception, css::uno::RuntimeException);
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     /** Use this class instead of calling lock() and unlock() directly in
200cdf0e10cSrcweir         order to be exception safe.
201cdf0e10cSrcweir     */
202cdf0e10cSrcweir     class Lock
203cdf0e10cSrcweir     {
204cdf0e10cSrcweir     public:
205cdf0e10cSrcweir         Lock (const css::uno::Reference<
206cdf0e10cSrcweir             css::drawing::framework::XConfigurationController>& rxController);
207cdf0e10cSrcweir         ~Lock (void);
208cdf0e10cSrcweir     private:
209cdf0e10cSrcweir         css::uno::Reference<
210cdf0e10cSrcweir             css::drawing::framework::XConfigurationController> mxController;
211cdf0e10cSrcweir     };
212cdf0e10cSrcweir 
213cdf0e10cSrcweir private:
214cdf0e10cSrcweir     class Implementation;
215cdf0e10cSrcweir     ::boost::scoped_ptr<Implementation> mpImplementation;
216cdf0e10cSrcweir     bool mbIsDisposed;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     /** When the called object has already been disposed this method throws
219cdf0e10cSrcweir         an exception and does not return.
220cdf0e10cSrcweir     */
221cdf0e10cSrcweir     void ThrowIfDisposed (void) const
222cdf0e10cSrcweir         throw (css::lang::DisposedException);
223cdf0e10cSrcweir };
224cdf0e10cSrcweir 
225cdf0e10cSrcweir } } // end of namespace sd::framework
226cdf0e10cSrcweir 
227cdf0e10cSrcweir #endif
228