1c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c45d927aSAndrew Rist  * distributed with this work for additional information
6c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c45d927aSAndrew Rist  *
11c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c45d927aSAndrew Rist  *
13c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17c45d927aSAndrew Rist  * specific language governing permissions and limitations
18c45d927aSAndrew Rist  * under the License.
19c45d927aSAndrew Rist  *
20c45d927aSAndrew Rist  *************************************************************/
21c45d927aSAndrew Rist 
22c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_FRAMEWORK_FRAMEWORK_HELPER_HXX
25cdf0e10cSrcweir #define SD_FRAMEWORK_FRAMEWORK_HELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "ViewShell.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "tools/SdGlobalResourceContainer.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
36cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
37cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp>
38cdf0e10cSrcweir #include <boost/function.hpp>
39cdf0e10cSrcweir #include <map>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace sd {
42cdf0e10cSrcweir class ViewShell;
43cdf0e10cSrcweir class ViewShellBase;
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace rtl {
47cdf0e10cSrcweir class OUString;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace css = ::com::sun::star;
51*7a32b0c8SAndre Fischer namespace cssu = ::com::sun::star::uno;
52*7a32b0c8SAndre Fischer namespace cssdf = ::com::sun::star::drawing::framework;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace sd { namespace framework {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir /** The FrameworkHelper is a convenience class that simplifies the
57cdf0e10cSrcweir     access to the drawing framework.
58cdf0e10cSrcweir     It has three main tasks:
59cdf0e10cSrcweir     1. Provide frequently used strings of resource URLs and event names.
60cdf0e10cSrcweir     2. Provide shortcuts for accessing the sd framework.
61*7a32b0c8SAndre Fischer     3. Ease the migration to the drawing framwork.
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     Note that a FrameworkHelper disposes itself when one of the resource
64*7a32b0c8SAndre Fischer     controllers called by it throws a DisposedException.
65cdf0e10cSrcweir */
66cdf0e10cSrcweir class FrameworkHelper
67cdf0e10cSrcweir     : public ::boost::enable_shared_from_this<FrameworkHelper>,
68cdf0e10cSrcweir       public SdGlobalResource
69cdf0e10cSrcweir {
70cdf0e10cSrcweir public:
71cdf0e10cSrcweir     // URLs of frequently used panes.
72cdf0e10cSrcweir     static const ::rtl::OUString msPaneURLPrefix;
73cdf0e10cSrcweir     static const ::rtl::OUString msCenterPaneURL;
74cdf0e10cSrcweir     static const ::rtl::OUString msFullScreenPaneURL;
75cdf0e10cSrcweir     static const ::rtl::OUString msLeftImpressPaneURL;
76cdf0e10cSrcweir     static const ::rtl::OUString msLeftDrawPaneURL;
77*7a32b0c8SAndre Fischer     static const ::rtl::OUString msSidebarPaneURL;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     // URLs of frequently used views.
80cdf0e10cSrcweir     static const ::rtl::OUString msViewURLPrefix;
81cdf0e10cSrcweir     static const ::rtl::OUString msImpressViewURL;
82cdf0e10cSrcweir     static const ::rtl::OUString msDrawViewURL;
83cdf0e10cSrcweir     static const ::rtl::OUString msOutlineViewURL;
84cdf0e10cSrcweir     static const ::rtl::OUString msNotesViewURL;
85cdf0e10cSrcweir     static const ::rtl::OUString msHandoutViewURL;
86cdf0e10cSrcweir     static const ::rtl::OUString msSlideSorterURL;
87cdf0e10cSrcweir     static const ::rtl::OUString msPresentationViewURL;
88*7a32b0c8SAndre Fischer     static const ::rtl::OUString msSidebarViewURL;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     // URLs of frequently used tool bars.
91cdf0e10cSrcweir     static const ::rtl::OUString msToolBarURLPrefix;
92cdf0e10cSrcweir     static const ::rtl::OUString msViewTabBarURL;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     // URLs of task panels.
95cdf0e10cSrcweir     static const ::rtl::OUString msTaskPanelURLPrefix;
96*7a32b0c8SAndre Fischer     static const ::rtl::OUString msAllMasterPagesTaskPanelURL;
97*7a32b0c8SAndre Fischer     static const ::rtl::OUString msRecentMasterPagesTaskPanelURL;
98*7a32b0c8SAndre Fischer     static const ::rtl::OUString msUsedMasterPagesTaskPanelURL;
99cdf0e10cSrcweir     static const ::rtl::OUString msLayoutTaskPanelURL;
100cdf0e10cSrcweir     static const ::rtl::OUString msTableDesignPanelURL;
101cdf0e10cSrcweir     static const ::rtl::OUString msCustomAnimationTaskPanelURL;
102cdf0e10cSrcweir     static const ::rtl::OUString msSlideTransitionTaskPanelURL;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     // Names of frequently used events.
105cdf0e10cSrcweir     static const ::rtl::OUString msResourceActivationRequestEvent;
106cdf0e10cSrcweir     static const ::rtl::OUString msResourceDeactivationRequestEvent;
107cdf0e10cSrcweir     static const ::rtl::OUString msResourceActivationEvent;
108cdf0e10cSrcweir     static const ::rtl::OUString msResourceDeactivationEvent;
109*7a32b0c8SAndre Fischer     static const ::rtl::OUString msResourceDeactivationEndEvent;
110cdf0e10cSrcweir     static const ::rtl::OUString msConfigurationUpdateStartEvent;
111cdf0e10cSrcweir     static const ::rtl::OUString msConfigurationUpdateEndEvent;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     // Service names of the common controllers.
114cdf0e10cSrcweir     static const ::rtl::OUString msModuleControllerService;
115cdf0e10cSrcweir     static const ::rtl::OUString msConfigurationControllerService;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     /** Return the FrameworkHelper object that is associated with the given
118cdf0e10cSrcweir         ViewShellBase.  If such an object does not yet exist, a new one is
119cdf0e10cSrcweir         created.
120cdf0e10cSrcweir     */
121cdf0e10cSrcweir     static ::boost::shared_ptr<FrameworkHelper> Instance (ViewShellBase& rBase);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     static ::boost::shared_ptr<FrameworkHelper> Instance (
124*7a32b0c8SAndre Fischer         const cssu::Reference<css::frame::XController>& rxController);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /** Mark the FrameworkHelper object for the given ViewShellBase as
127cdf0e10cSrcweir         disposed.  A following ReleaseInstance() call will destroy the
128cdf0e10cSrcweir         FrameworkHelper object.
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         Do not call this method.  It is an internally used method that can
131cdf0e10cSrcweir         not be made private.
132cdf0e10cSrcweir     */
133cdf0e10cSrcweir     static void DisposeInstance (ViewShellBase& rBase);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     /** Destroy the FrameworkHelper object for the given ViewShellBase.
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         Do not call this method.  It is an internally used method that can
138cdf0e10cSrcweir         not be made private.
139cdf0e10cSrcweir     */
140cdf0e10cSrcweir     static void ReleaseInstance (ViewShellBase& rBase);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /** Return an identifier for the given view URL.  This identifier can be
143cdf0e10cSrcweir         used in a switch statement.  See GetViewURL() for a mapping in the
144cdf0e10cSrcweir         opposite direction.
145cdf0e10cSrcweir     */
146cdf0e10cSrcweir     static ViewShell::ShellType GetViewId (const rtl::OUString& rsViewURL);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     /** Return a view URL for the given identifier.  See GetViewId() for a
149cdf0e10cSrcweir         mapping in the opposite direction.
150cdf0e10cSrcweir     */
151cdf0e10cSrcweir     static ::rtl::OUString GetViewURL (ViewShell::ShellType eType);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     /** Return a ViewShell pointer for the given XView reference.  This
154cdf0e10cSrcweir         assumes that the given reference is implemented by the
155cdf0e10cSrcweir         ViewShellWrapper class that supports the XTunnel interface.
156cdf0e10cSrcweir         @return
157cdf0e10cSrcweir             When the ViewShell pointer can not be inferred from the given
158cdf0e10cSrcweir             reference then an empty pointer is returned.
159cdf0e10cSrcweir     */
160cdf0e10cSrcweir     static ::boost::shared_ptr<ViewShell> GetViewShell (
161*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XView>& rxView);
162cdf0e10cSrcweir 
163*7a32b0c8SAndre Fischer     typedef ::boost::function<bool(const cssdf::ConfigurationChangeEvent&)>
164cdf0e10cSrcweir         ConfigurationChangeEventFilter;
165cdf0e10cSrcweir     typedef ::boost::function<void(bool bEventSeen)> Callback;
166cdf0e10cSrcweir     typedef ::boost::function<
167cdf0e10cSrcweir         void(
168*7a32b0c8SAndre Fischer             const cssu::Reference<
169*7a32b0c8SAndre Fischer                 cssdf::XResourceId>&)
170cdf0e10cSrcweir         > ResourceFunctor;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     /** Test whether the called FrameworkHelper object is valid.
173cdf0e10cSrcweir         @return
174cdf0e10cSrcweir             When the object has already been disposed then <FALSE/> is returned.
175cdf0e10cSrcweir     */
176cdf0e10cSrcweir     bool IsValid (void);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     /** Return a pointer to the view shell that is displayed in the
179cdf0e10cSrcweir         specified pane.  See GetView() for a variant that returns a
180cdf0e10cSrcweir         reference to XView instead of a ViewShell pointer.
181cdf0e10cSrcweir         @return
182cdf0e10cSrcweir             An empty pointer is returned when for example the specified pane
183cdf0e10cSrcweir             does not exist or is not visible or does not show a view or one
184cdf0e10cSrcweir             of the involved objects does not support XUnoTunnel (where
185cdf0e10cSrcweir             necessary).
186cdf0e10cSrcweir     */
187cdf0e10cSrcweir     ::boost::shared_ptr<ViewShell> GetViewShell (const ::rtl::OUString& rsPaneURL);
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     /** Return a reference to the view that is displayed in the specified
190cdf0e10cSrcweir         pane.  See GetViewShell () for a variant that returns a ViewShell
191cdf0e10cSrcweir         pointer instead of a reference to XView.
192cdf0e10cSrcweir         @param rxPaneOrViewId
193cdf0e10cSrcweir             When this ResourceId specifies a view then that view is
194cdf0e10cSrcweir             returned.  When it belongs to a pane then one view in that pane
195cdf0e10cSrcweir             is returned.
196cdf0e10cSrcweir         @return
197cdf0e10cSrcweir             An empty reference is returned when for example the specified pane
198cdf0e10cSrcweir             does not exist or is not visible or does not show a view or one
199cdf0e10cSrcweir             of the involved objects does not support XTunnel (where
200cdf0e10cSrcweir             necessary).
201cdf0e10cSrcweir     */
202*7a32b0c8SAndre Fischer     cssu::Reference<cssdf::XView> GetView (
203*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxPaneOrViewId);
204*7a32b0c8SAndre Fischer 
205*7a32b0c8SAndre Fischer     /** Return the XWindow that is represented by the pane with the
206*7a32b0c8SAndre Fischer         given resource id.
207*7a32b0c8SAndre Fischer     */
208*7a32b0c8SAndre Fischer     cssu::Reference<css::awt::XWindow> GetPaneWindow (
209*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxPaneId);
210*7a32b0c8SAndre Fischer 
211*7a32b0c8SAndre Fischer     /** Return the XResource object with the given resource id.
212*7a32b0c8SAndre Fischer     */
213*7a32b0c8SAndre Fischer     cssu::Reference<cssdf::XResource> GetResource (
214*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxResourceId);
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     /** Request the specified view to be displayed in the specified pane.
217cdf0e10cSrcweir         When the pane is not visible its creation is also requested.  The
218cdf0e10cSrcweir         update that creates the actual view object is done asynchronously.
219cdf0e10cSrcweir         @param rsResourceURL
220cdf0e10cSrcweir             The resource URL of the view to show.
221cdf0e10cSrcweir         @param rsAnchorURL
222cdf0e10cSrcweir             The URL of the pane in which to show the view.
223cdf0e10cSrcweir         @return
224cdf0e10cSrcweir             The resource id of the requested view is returned.  With that
225cdf0e10cSrcweir             the caller can, for example, call RunOnResourceActivation() to
226cdf0e10cSrcweir             do some initialization after the requested view becomes active.
227cdf0e10cSrcweir     */
228*7a32b0c8SAndre Fischer     cssu::Reference<cssdf::XResourceId> RequestView (
229cdf0e10cSrcweir         const ::rtl::OUString& rsResourceURL,
230cdf0e10cSrcweir         const ::rtl::OUString& rsAnchorURL);
231cdf0e10cSrcweir 
232*7a32b0c8SAndre Fischer     /** Request the deactivation of the specified resource.
233*7a32b0c8SAndre Fischer     */
234*7a32b0c8SAndre Fischer     void RequestResourceDeactivation (
235*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxResourceId);
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     /** Process a slot call that requests a view shell change.
238cdf0e10cSrcweir     */
239cdf0e10cSrcweir     void HandleModeChangeSlot (
240cdf0e10cSrcweir         sal_uLong nSlotId,
241cdf0e10cSrcweir         SfxRequest& rRequest);
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     /** Run the given callback when the specified event is notified by the
244cdf0e10cSrcweir         ConfigurationManager.  When there are no pending requests and
245cdf0e10cSrcweir         therefore no events would be notified (in the foreseeable future)
246cdf0e10cSrcweir         then the callback is called immediately.
247cdf0e10cSrcweir         The callback is called with a flag that tells the callback whether
248cdf0e10cSrcweir         the event it waits for has been sent.
249cdf0e10cSrcweir     */
250cdf0e10cSrcweir     void RunOnConfigurationEvent(
251cdf0e10cSrcweir         const ::rtl::OUString& rsEventType,
252cdf0e10cSrcweir         const Callback& rCallback);
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     /** Run the given callback when the specified resource has been
255cdf0e10cSrcweir         activated.  When the resource is active already when this method is
256cdf0e10cSrcweir         called then rCallback is called before this method returns.
257cdf0e10cSrcweir         @param rxResourceId
258cdf0e10cSrcweir             Wait for the activation of this resource before calling
259cdf0e10cSrcweir             rCallback.
260cdf0e10cSrcweir         @param rCallback
261cdf0e10cSrcweir             The callback to be called when the resource is activated.
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     */
264cdf0e10cSrcweir     void RunOnResourceActivation(
265*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxResourceId,
266cdf0e10cSrcweir         const Callback& rCallback);
267cdf0e10cSrcweir 
268*7a32b0c8SAndre Fischer     /** Run the given callback when the specified resource has been
269*7a32b0c8SAndre Fischer         deactivated.  When the resource is not active already when
270*7a32b0c8SAndre Fischer         this method is called then rCallback is called before this
271*7a32b0c8SAndre Fischer         method returns.
272*7a32b0c8SAndre Fischer         @param rxResourceId
273*7a32b0c8SAndre Fischer             Wait for the deactivation of this resource before calling
274*7a32b0c8SAndre Fischer             rCallback.
275*7a32b0c8SAndre Fischer         @param rCallback
276*7a32b0c8SAndre Fischer             The callback to be called when the resource is
277*7a32b0c8SAndre Fischer             deactivated.
278*7a32b0c8SAndre Fischer         @param bRunOnDeactivationEnd
279*7a32b0c8SAndre Fischer             The callback is run either when the deactivation starts
280*7a32b0c8SAndre Fischer             and the callback can still access the resource or when the
281*7a32b0c8SAndre Fischer             deactivatio is complete and the resource is no longer available.
282*7a32b0c8SAndre Fischer 
283*7a32b0c8SAndre Fischer     */
284*7a32b0c8SAndre Fischer     void RunOnResourceDeactivation(
285*7a32b0c8SAndre Fischer         const cssu::Reference<cssdf::XResourceId>& rxResourceId,
286*7a32b0c8SAndre Fischer         const Callback& rCallback,
287*7a32b0c8SAndre Fischer         const bool bRunOnDeactivationEnd);
288*7a32b0c8SAndre Fischer 
289cdf0e10cSrcweir     /** Normally the requested changes of the configuration are executed
290cdf0e10cSrcweir         asynchronously.  However, there is at least one situation (searching
291cdf0e10cSrcweir         with the Outliner) where the surrounding code does not cope with
292cdf0e10cSrcweir         this.  So, instead of calling Reschedule until the global event loop
293cdf0e10cSrcweir         executes the configuration update, this method does (almost) the
294cdf0e10cSrcweir         same without the reschedules.
295cdf0e10cSrcweir 
296cdf0e10cSrcweir         Do not use this method until there is absolutely no other way.
297cdf0e10cSrcweir     */
298cdf0e10cSrcweir     void RequestSynchronousUpdate (void);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     /** Block until the specified event is notified by the configuration
301cdf0e10cSrcweir         controller.  When the configuration controller is not processing any
302cdf0e10cSrcweir         requests the method returns immediately.
303cdf0e10cSrcweir     */
304cdf0e10cSrcweir     void WaitForEvent (const ::rtl::OUString& rsEventName) const;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     /** This is a short cut for WaitForEvent(msConfigurationUpdateEndEvent).
307cdf0e10cSrcweir         Call this method to execute the pending requests.
308cdf0e10cSrcweir     */
309cdf0e10cSrcweir     void WaitForUpdate (void) const;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     /** Explicit request for an update of the current configuration.  Call
312cdf0e10cSrcweir         this method when one of the resources managed by the sd framework
313cdf0e10cSrcweir         has been activated or deactivated from the outside, i.e. not by the
314cdf0e10cSrcweir         framework itself.  An example for this is a click on the closer
315cdf0e10cSrcweir         button of one of the side panes.
316cdf0e10cSrcweir     */
317cdf0e10cSrcweir     void UpdateConfiguration (void);
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     /** Return a string representation of the given XResourceId object.
320cdf0e10cSrcweir     */
321cdf0e10cSrcweir     static ::rtl::OUString ResourceIdToString (
322*7a32b0c8SAndre Fischer         const cssu::Reference<
323*7a32b0c8SAndre Fischer             cssdf::XResourceId>& rxResourceId);
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     /** Create a new XResourceId object for the given resource URL.
326cdf0e10cSrcweir     */
327*7a32b0c8SAndre Fischer     static cssu::Reference<
328*7a32b0c8SAndre Fischer         cssdf::XResourceId>
329cdf0e10cSrcweir             CreateResourceId (
330cdf0e10cSrcweir                 const ::rtl::OUString& rsResourceURL);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     /** Create a new XResourceId object for the given resource URL and a
333cdf0e10cSrcweir         single anchor URL.
334cdf0e10cSrcweir     */
335*7a32b0c8SAndre Fischer     static cssu::Reference<
336*7a32b0c8SAndre Fischer         cssdf::XResourceId>
337cdf0e10cSrcweir             CreateResourceId (
338cdf0e10cSrcweir                 const ::rtl::OUString& rsResourceURL,
339cdf0e10cSrcweir                 const ::rtl::OUString& rsAnchorURL);
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     /** Create a new XResourceId object for the given resource URL and the
342cdf0e10cSrcweir         two given anchor URLs.
343cdf0e10cSrcweir     */
344*7a32b0c8SAndre Fischer     static cssu::Reference<
345*7a32b0c8SAndre Fischer         cssdf::XResourceId>
346cdf0e10cSrcweir             CreateResourceId (
347cdf0e10cSrcweir                 const ::rtl::OUString& rsResourceURL,
348cdf0e10cSrcweir                 const ::rtl::OUString& rsFirstAnchorURL,
349cdf0e10cSrcweir                 const ::rtl::OUString& rsSecondAnchorURL);
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     /** Create a new XResourceId object for the given resource URL.
352cdf0e10cSrcweir     */
353*7a32b0c8SAndre Fischer     static cssu::Reference<
354*7a32b0c8SAndre Fischer         cssdf::XResourceId>
355cdf0e10cSrcweir             CreateResourceId (
356cdf0e10cSrcweir                 const ::rtl::OUString& rsResourceURL,
357*7a32b0c8SAndre Fischer                 const cssu::Reference<
358*7a32b0c8SAndre Fischer                     cssdf::XResourceId>& rxAnchor);
359cdf0e10cSrcweir 
360*7a32b0c8SAndre Fischer     cssu::Reference<cssdf::XConfigurationController>
361cdf0e10cSrcweir         GetConfigurationController (void) const;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 
364cdf0e10cSrcweir private:
365cdf0e10cSrcweir     typedef ::std::map<
366cdf0e10cSrcweir         ViewShellBase*,
367cdf0e10cSrcweir         ::boost::shared_ptr<FrameworkHelper> > InstanceMap;
368cdf0e10cSrcweir     /** The instance map holds (at least) one FrameworkHelper instance for
369cdf0e10cSrcweir         every ViewShellBase object.
370cdf0e10cSrcweir     */
371cdf0e10cSrcweir     static InstanceMap maInstanceMap;
372cdf0e10cSrcweir     class ViewURLMap;
373cdf0e10cSrcweir     static ::boost::scoped_ptr<ViewURLMap> mpViewURLMap;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     ViewShellBase& mrBase;
376*7a32b0c8SAndre Fischer     cssu::Reference<cssdf::XConfigurationController>
377cdf0e10cSrcweir         mxConfigurationController;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     class DisposeListener;
380cdf0e10cSrcweir     friend class DisposeListener;
381*7a32b0c8SAndre Fischer     cssu::Reference<css::lang::XComponent>
382cdf0e10cSrcweir         mxDisposeListener;
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     FrameworkHelper (ViewShellBase& rBase);
385cdf0e10cSrcweir     FrameworkHelper (const FrameworkHelper& rHelper); // Not implemented.
386*7a32b0c8SAndre Fischer     ~FrameworkHelper (void);
387*7a32b0c8SAndre Fischer     class Deleter; friend class Deleter;
388cdf0e10cSrcweir     FrameworkHelper& operator= (const FrameworkHelper& rHelper); // Not implemented.
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     void Initialize (void);
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     void Dispose (void);
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     /** Run the given callback when an event of the specified type is
395cdf0e10cSrcweir         received from the ConfigurationController or when the
396cdf0e10cSrcweir         ConfigurationController has no pending change requests.
397cdf0e10cSrcweir         @param rsEventType
398cdf0e10cSrcweir             Run rCallback only on this event.
399cdf0e10cSrcweir         @param rFilter
400cdf0e10cSrcweir             This filter has to return <TRUE/> in order for rCallback to be
401cdf0e10cSrcweir             called.
402cdf0e10cSrcweir         @param rCallback
403cdf0e10cSrcweir             The callback functor to be called.
404cdf0e10cSrcweir     */
405cdf0e10cSrcweir     void RunOnEvent(
406cdf0e10cSrcweir         const ::rtl::OUString& rsEventType,
407cdf0e10cSrcweir         const ConfigurationChangeEventFilter& rFilter,
408cdf0e10cSrcweir         const Callback& rCallback) const;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     /** This disposing method is forwarded from the inner DisposeListener class.
411cdf0e10cSrcweir     */
412cdf0e10cSrcweir     void disposing (const css::lang::EventObject& rEventObject);
413cdf0e10cSrcweir };
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 
416cdf0e10cSrcweir } } // end of namespace sd::framework
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 
420cdf0e10cSrcweir namespace sd { namespace framework {
421cdf0e10cSrcweir 
422cdf0e10cSrcweir namespace {
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     class FrameworkHelperAllPassFilter
425cdf0e10cSrcweir     {
426cdf0e10cSrcweir     public:
operator ()(const cssdf::ConfigurationChangeEvent &)427*7a32b0c8SAndre Fischer         bool operator() (const cssdf::ConfigurationChangeEvent&) { return true; }
428cdf0e10cSrcweir     };
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     class FrameworkHelperResourceIdFilter
432cdf0e10cSrcweir     {
433cdf0e10cSrcweir     public:
434cdf0e10cSrcweir         FrameworkHelperResourceIdFilter (
435*7a32b0c8SAndre Fischer             const cssu::Reference<cssdf::XResourceId>& rxResourceId);
operator ()(const cssdf::ConfigurationChangeEvent & rEvent)436*7a32b0c8SAndre Fischer         bool operator() (const cssdf::ConfigurationChangeEvent& rEvent)
437cdf0e10cSrcweir         { return mxResourceId.is() && rEvent.ResourceId.is()
438cdf0e10cSrcweir                 && mxResourceId->compareTo(rEvent.ResourceId) == 0; }
439cdf0e10cSrcweir     private:
440*7a32b0c8SAndre Fischer         cssu::Reference<cssdf::XResourceId> mxResourceId;
441cdf0e10cSrcweir     };
442cdf0e10cSrcweir 
443cdf0e10cSrcweir } // end of anonymous namespace
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 
448cdf0e10cSrcweir } } // end of namespace sd::framework
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 
451cdf0e10cSrcweir #endif
452