LibreOffice Module sd (master) 1
FrameworkHelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <ViewShell.hxx>
23
25
26#include <functional>
27#include <map>
28#include <memory>
29#include <mutex>
30
31namespace com::sun::star::drawing::framework { class XConfigurationController; }
32namespace com::sun::star::drawing::framework { class XResourceId; }
33namespace com::sun::star::drawing::framework { class XView; }
34namespace com::sun::star::drawing::framework { struct ConfigurationChangeEvent; }
35
36namespace sd {
37class ViewShellBase;
38}
39
40
41namespace sd::framework {
42
53class FrameworkHelper final
54 : public std::enable_shared_from_this<FrameworkHelper>,
55 public SdGlobalResource
56{
57public:
58 // URLs of frequently used panes.
59 static constexpr OUStringLiteral msPaneURLPrefix = u"private:resource/pane/";
60 static const OUString msCenterPaneURL;
61 static const OUString msFullScreenPaneURL;
62 static const OUString msLeftImpressPaneURL;
63 static const OUString msLeftDrawPaneURL;
64
65 // URLs of frequently used views.
66 static constexpr OUStringLiteral msViewURLPrefix = u"private:resource/view/";
67 static const OUString msImpressViewURL;
68 static const OUString msDrawViewURL;
69 static const OUString msOutlineViewURL;
70 static const OUString msNotesViewURL;
71 static const OUString msHandoutViewURL;
72 static const OUString msSlideSorterURL;
73 static const OUString msPresentationViewURL;
74 static const OUString msSidebarViewURL;
75
76 // URLs of frequently used tool bars.
77 static constexpr OUStringLiteral msToolBarURLPrefix = u"private:resource/toolbar/";
78 static const OUString msViewTabBarURL;
79
80 // Names of frequently used events.
81 static constexpr OUStringLiteral msResourceActivationRequestEvent
82 = u"ResourceActivationRequested";
83 static constexpr OUStringLiteral msResourceDeactivationRequestEvent
84 = u"ResourceDeactivationRequest";
85 static constexpr OUStringLiteral msResourceActivationEvent = u"ResourceActivation";
86 static constexpr OUStringLiteral msResourceDeactivationEvent = u"ResourceDeactivation";
87 static constexpr OUStringLiteral msResourceDeactivationEndEvent = u"ResourceDeactivationEnd";
88 static constexpr OUStringLiteral msConfigurationUpdateStartEvent = u"ConfigurationUpdateStart";
89 static constexpr OUStringLiteral msConfigurationUpdateEndEvent = u"ConfigurationUpdateEnd";
90
95 static ::std::shared_ptr<FrameworkHelper> Instance (ViewShellBase& rBase);
96
104 static void DisposeInstance (const ViewShellBase& rBase);
105
111 static void ReleaseInstance (const ViewShellBase& rBase);
112
117 static ViewShell::ShellType GetViewId (const OUString& rsViewURL);
118
122 static OUString GetViewURL (ViewShell::ShellType eType);
123
131 static ::std::shared_ptr<ViewShell> GetViewShell (
132 const css::uno::Reference<css::drawing::framework::XView>& rxView);
133
134 typedef ::std::function<bool (const css::drawing::framework::ConfigurationChangeEvent&)>
136 typedef ::std::function<void (bool bEventSeen)> Callback;
137 typedef ::std::function<
138 void (
139 const css::uno::Reference<
140 css::drawing::framework::XResourceId>&)
142
147 bool IsValid() const;
148
158 ::std::shared_ptr<ViewShell> GetViewShell (const OUString& rsPaneURL);
159
173 css::uno::Reference<css::drawing::framework::XView> GetView (
174 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneOrViewId);
175
188 css::uno::Reference<css::drawing::framework::XResourceId> RequestView (
189 const OUString& rsResourceURL,
190 const OUString& rsAnchorURL);
191
195 sal_uInt16 nSlotId,
196 SfxRequest const & rRequest);
197
206 const OUString& rsEventType,
207 const Callback& rCallback);
208
220 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
221 const Callback& rCallback);
222
233
238 void WaitForEvent (const OUString& rsEventName) const;
239
243 void WaitForUpdate() const;
244
251 void UpdateConfiguration();
252
255 static OUString ResourceIdToString (
256 const css::uno::Reference<
257 css::drawing::framework::XResourceId>& rxResourceId);
258
261 static css::uno::Reference<
262 css::drawing::framework::XResourceId>
264 const OUString& rsResourceURL);
265
269 static css::uno::Reference<
270 css::drawing::framework::XResourceId>
272 const OUString& rsResourceURL,
273 const OUString& rsAnchorURL);
274
277 static css::uno::Reference<
278 css::drawing::framework::XResourceId>
280 const OUString& rsResourceURL,
281 const css::uno::Reference<
282 css::drawing::framework::XResourceId>& rxAnchor);
283
284 const css::uno::Reference<css::drawing::framework::XConfigurationController>&
286
287private:
288 typedef ::std::map<
289 const ViewShellBase*,
290 ::std::shared_ptr<FrameworkHelper> > InstanceMap;
295 class ViewURLMap;
297 static std::mutex maInstanceMapMutex;
298
300 css::uno::Reference<css::drawing::framework::XConfigurationController>
302
303 class DisposeListener;
304 friend class DisposeListener;
305 css::uno::Reference<css::lang::XComponent>
307
309 FrameworkHelper (const FrameworkHelper& rHelper) = delete;
310 virtual ~FrameworkHelper() override;
311 class Deleter; friend class Deleter;
312 FrameworkHelper& operator= (const FrameworkHelper& rHelper) = delete;
313
314 void Initialize();
315
316 void Dispose();
317
329 void RunOnEvent(
330 const OUString& rsEventType,
331 const ConfigurationChangeEventFilter& rFilter,
332 const Callback& rCallback) const;
333
336 void disposing (const css::lang::EventObject& rEventObject);
337};
338
339} // end of namespace sd::framework
340
341
342/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
The ViewURLMap is used to translate between the view URLs used by the drawing framework and the enums...
The FrameworkHelper is a convenience class that simplifies the access to the drawing framework.
FrameworkHelper(ViewShellBase &rBase)
void disposing(const css::lang::EventObject &rEventObject)
This disposing method is forwarded from the inner DisposeListener class.
FrameworkHelper & operator=(const FrameworkHelper &rHelper)=delete
static ::std::shared_ptr< ViewShell > GetViewShell(const css::uno::Reference< css::drawing::framework::XView > &rxView)
Return a ViewShell pointer for the given XView reference.
css::uno::Reference< css::drawing::framework::XResourceId > RequestView(const OUString &rsResourceURL, const OUString &rsAnchorURL)
Request the specified view to be displayed in the specified pane.
void UpdateConfiguration()
Explicit request for an update of the current configuration.
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId(const OUString &rsResourceURL)
Create a new XResourceId object for the given resource URL.
static InstanceMap maInstanceMap
The instance map holds (at least) one FrameworkHelper instance for every ViewShellBase object.
::std::map< const ViewShellBase *, ::std::shared_ptr< FrameworkHelper > > InstanceMap
static const OUString msHandoutViewURL
static OUString GetViewURL(ViewShell::ShellType eType)
Return a view URL for the given identifier.
static constexpr OUStringLiteral msPaneURLPrefix
static const OUString msCenterPaneURL
static constexpr OUStringLiteral msResourceDeactivationEvent
void RunOnEvent(const OUString &rsEventType, const ConfigurationChangeEventFilter &rFilter, const Callback &rCallback) const
Run the given callback when an event of the specified type is received from the ConfigurationControll...
static constexpr OUStringLiteral msResourceDeactivationEndEvent
static const OUString msLeftDrawPaneURL
void HandleModeChangeSlot(sal_uInt16 nSlotId, SfxRequest const &rRequest)
Process a slot call that requests a view shell change.
static constexpr OUStringLiteral msConfigurationUpdateStartEvent
void RunOnResourceActivation(const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId, const Callback &rCallback)
Run the given callback when the specified resource has been activated.
static constexpr OUStringLiteral msResourceActivationRequestEvent
static constexpr OUStringLiteral msToolBarURLPrefix
static const OUString msNotesViewURL
static ViewShell::ShellType GetViewId(const OUString &rsViewURL)
Return an identifier for the given view URL.
static const OUString msOutlineViewURL
static constexpr OUStringLiteral msConfigurationUpdateEndEvent
void RunOnConfigurationEvent(const OUString &rsEventType, const Callback &rCallback)
Run the given callback when the specified event is notified by the ConfigurationManager.
void RequestSynchronousUpdate()
Normally the requested changes of the configuration are executed asynchronously.
::std::function< void(bool bEventSeen)> Callback
static const OUString msPresentationViewURL
static const OUString msSlideSorterURL
css::uno::Reference< css::drawing::framework::XView > GetView(const css::uno::Reference< css::drawing::framework::XResourceId > &rxPaneOrViewId)
Return a reference to the view that is displayed in the specified pane.
css::uno::Reference< css::lang::XComponent > mxDisposeListener
static const OUString msSidebarViewURL
static OUString ResourceIdToString(const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId)
Return a string representation of the given XResourceId object.
static constexpr OUStringLiteral msResourceDeactivationRequestEvent
static ::std::shared_ptr< FrameworkHelper > Instance(ViewShellBase &rBase)
Return the FrameworkHelper object that is associated with the given ViewShellBase.
FrameworkHelper(const FrameworkHelper &rHelper)=delete
::std::function< void(const css::uno::Reference< css::drawing::framework::XResourceId > &) > ResourceFunctor
static const OUString msLeftImpressPaneURL
void WaitForUpdate() const
This is a short cut for WaitForEvent(msConfigurationUpdateEndEvent).
const css::uno::Reference< css::drawing::framework::XConfigurationController > & GetConfigurationController() const
static void ReleaseInstance(const ViewShellBase &rBase)
Destroy the FrameworkHelper object for the given ViewShellBase.
static const OUString msDrawViewURL
static constexpr OUStringLiteral msResourceActivationEvent
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
::std::function< bool(const css::drawing::framework::ConfigurationChangeEvent &)> ConfigurationChangeEventFilter
static constexpr OUStringLiteral msViewURLPrefix
static const OUString msImpressViewURL
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId(const OUString &rsResourceURL, const css::uno::Reference< css::drawing::framework::XResourceId > &rxAnchor)
Create a new XResourceId object for the given resource URL.
static const OUString msViewTabBarURL
static const OUString msFullScreenPaneURL
void WaitForEvent(const OUString &rsEventName) const
Block until the specified event is notified by the configuration controller.
static void DisposeInstance(const ViewShellBase &rBase)
Mark the FrameworkHelper object for the given ViewShellBase as disposed.
bool IsValid() const
Test whether the called FrameworkHelper object is valid.
float u