LibreOffice Module sd (master) 1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
sd::framework::FrameworkHelper Class Referencefinal

The FrameworkHelper is a convenience class that simplifies the access to the drawing framework. More...

#include <FrameworkHelper.hxx>

Inheritance diagram for sd::framework::FrameworkHelper:
[legend]
Collaboration diagram for sd::framework::FrameworkHelper:
[legend]

Classes

class  Deleter
 
class  DisposeListener
 
class  ViewURLMap
 The ViewURLMap is used to translate between the view URLs used by the drawing framework and the enums defined in the ViewShell class. More...
 

Public Types

typedef ::std::function< bool(const css::drawing::framework::ConfigurationChangeEvent &)> ConfigurationChangeEventFilter
 
typedef ::std::function< void(bool bEventSeen)> Callback
 
typedef ::std::function< void(const css::uno::Reference< css::drawing::framework::XResourceId > &) > ResourceFunctor
 

Public Member Functions

static ::std::shared_ptr< FrameworkHelperInstance (ViewShellBase &rBase)
 Return the FrameworkHelper object that is associated with the given ViewShellBase. More...
 
static ::std::shared_ptr< ViewShellGetViewShell (const css::uno::Reference< css::drawing::framework::XView > &rxView)
 Return a ViewShell pointer for the given XView reference. More...
 
bool IsValid () const
 Test whether the called FrameworkHelper object is valid. More...
 
::std::shared_ptr< ViewShellGetViewShell (const OUString &rsPaneURL)
 Return a pointer to the view shell that is displayed in the specified pane. More...
 
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. More...
 
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. More...
 
void HandleModeChangeSlot (sal_uInt16 nSlotId, SfxRequest const &rRequest)
 Process a slot call that requests a view shell change. More...
 
void RunOnConfigurationEvent (const OUString &rsEventType, const Callback &rCallback)
 Run the given callback when the specified event is notified by the ConfigurationManager. More...
 
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. More...
 
void RequestSynchronousUpdate ()
 Normally the requested changes of the configuration are executed asynchronously. More...
 
void WaitForEvent (const OUString &rsEventName) const
 Block until the specified event is notified by the configuration controller. More...
 
void WaitForUpdate () const
 This is a short cut for WaitForEvent(msConfigurationUpdateEndEvent). More...
 
void UpdateConfiguration ()
 Explicit request for an update of the current configuration. More...
 
const css::uno::Reference< css::drawing::framework::XConfigurationController > & GetConfigurationController () const
 
- Public Member Functions inherited from sd::SdGlobalResource
virtual ~SdGlobalResource () COVERITY_NOEXCEPT_FALSE
 

Static Public Member Functions

static void DisposeInstance (const ViewShellBase &rBase)
 Mark the FrameworkHelper object for the given ViewShellBase as disposed. More...
 
static void ReleaseInstance (const ViewShellBase &rBase)
 Destroy the FrameworkHelper object for the given ViewShellBase. More...
 
static ViewShell::ShellType GetViewId (const OUString &rsViewURL)
 Return an identifier for the given view URL. More...
 
static OUString GetViewURL (ViewShell::ShellType eType)
 Return a view URL for the given identifier. More...
 
static OUString ResourceIdToString (const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId)
 Return a string representation of the given XResourceId object. More...
 
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId (const OUString &rsResourceURL)
 Create a new XResourceId object for the given resource URL. More...
 
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId (const OUString &rsResourceURL, const OUString &rsAnchorURL)
 Create a new XResourceId object for the given resource URL and a single anchor URL. More...
 
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. More...
 

Static Public Attributes

static constexpr OUStringLiteral msPaneURLPrefix = u"private:resource/pane/"
 
static const OUString msCenterPaneURL
 
static const OUString msFullScreenPaneURL
 
static const OUString msLeftImpressPaneURL
 
static const OUString msLeftDrawPaneURL
 
static constexpr OUStringLiteral msViewURLPrefix = u"private:resource/view/"
 
static const OUString msImpressViewURL
 
static const OUString msDrawViewURL
 
static const OUString msOutlineViewURL
 
static const OUString msNotesViewURL
 
static const OUString msHandoutViewURL
 
static const OUString msSlideSorterURL
 
static const OUString msPresentationViewURL
 
static const OUString msSidebarViewURL
 
static constexpr OUStringLiteral msToolBarURLPrefix = u"private:resource/toolbar/"
 
static const OUString msViewTabBarURL
 
static constexpr OUStringLiteral msResourceActivationRequestEvent = u"ResourceActivationRequested"
 
static constexpr OUStringLiteral msResourceDeactivationRequestEvent = u"ResourceDeactivationRequest"
 
static constexpr OUStringLiteral msResourceActivationEvent = u"ResourceActivation"
 
static constexpr OUStringLiteral msResourceDeactivationEvent = u"ResourceDeactivation"
 
static constexpr OUStringLiteral msResourceDeactivationEndEvent = u"ResourceDeactivationEnd"
 
static constexpr OUStringLiteral msConfigurationUpdateStartEvent = u"ConfigurationUpdateStart"
 
static constexpr OUStringLiteral msConfigurationUpdateEndEvent = u"ConfigurationUpdateEnd"
 

Private Types

typedef ::std::map< const ViewShellBase *, ::std::shared_ptr< FrameworkHelper > > InstanceMap
 

Private Member Functions

 FrameworkHelper (ViewShellBase &rBase)
 
 FrameworkHelper (const FrameworkHelper &rHelper)=delete
 
virtual ~FrameworkHelper () override
 
FrameworkHelperoperator= (const FrameworkHelper &rHelper)=delete
 
void Initialize ()
 
void Dispose ()
 
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 ConfigurationController or when the ConfigurationController has no pending change requests. More...
 
void disposing (const css::lang::EventObject &rEventObject)
 This disposing method is forwarded from the inner DisposeListener class. More...
 

Private Attributes

ViewShellBasemrBase
 
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
 
css::uno::Reference< css::lang::XComponent > mxDisposeListener
 

Static Private Attributes

static InstanceMap maInstanceMap
 The instance map holds (at least) one FrameworkHelper instance for every ViewShellBase object. More...
 
static ViewURLMap maViewURLMap
 
static std::mutex maInstanceMapMutex
 

Friends

class DisposeListener
 
class Deleter
 

Detailed Description

The FrameworkHelper is a convenience class that simplifies the access to the drawing framework.

It has three main tasks:

  1. Provide frequently used strings of resource URLs and event names.
  2. Provide shortcuts for accessing the sd framework.
  3. Ease the migration to the drawing framework.

Note that a FrameworkHelper disposes itself when one of the resource controllers called by it throws a DisposedException.

Definition at line 53 of file FrameworkHelper.hxx.

Member Typedef Documentation

◆ Callback

typedef ::std::function<void (bool bEventSeen)> sd::framework::FrameworkHelper::Callback

Definition at line 136 of file FrameworkHelper.hxx.

◆ ConfigurationChangeEventFilter

typedef ::std::function<bool (const css::drawing::framework::ConfigurationChangeEvent&)> sd::framework::FrameworkHelper::ConfigurationChangeEventFilter

Definition at line 135 of file FrameworkHelper.hxx.

◆ InstanceMap

Definition at line 290 of file FrameworkHelper.hxx.

◆ ResourceFunctor

typedef ::std::function< void ( const css::uno::Reference< css::drawing::framework::XResourceId>&) > sd::framework::FrameworkHelper::ResourceFunctor

Definition at line 141 of file FrameworkHelper.hxx.

Constructor & Destructor Documentation

◆ FrameworkHelper() [1/2]

sd::framework::FrameworkHelper::FrameworkHelper ( ViewShellBase rBase)
private

Definition at line 317 of file FrameworkHelper.cxx.

References SfxViewShell::GetController(), mrBase, and mxConfigurationController.

Referenced by Instance().

◆ FrameworkHelper() [2/2]

sd::framework::FrameworkHelper::FrameworkHelper ( const FrameworkHelper rHelper)
privatedelete

◆ ~FrameworkHelper()

sd::framework::FrameworkHelper::~FrameworkHelper ( )
overrideprivatevirtual

Definition at line 334 of file FrameworkHelper.cxx.

Member Function Documentation

◆ CreateResourceId() [1/3]

Reference< XResourceId > sd::framework::FrameworkHelper::CreateResourceId ( const OUString &  rsResourceURL)
static

◆ CreateResourceId() [2/3]

static css::uno::Reference< css::drawing::framework::XResourceId > sd::framework::FrameworkHelper::CreateResourceId ( const OUString &  rsResourceURL,
const css::uno::Reference< css::drawing::framework::XResourceId > &  rxAnchor 
)
static

Create a new XResourceId object for the given resource URL.

◆ CreateResourceId() [3/3]

Reference< XResourceId > sd::framework::FrameworkHelper::CreateResourceId ( const OUString &  rsResourceURL,
const OUString &  rsAnchorURL 
)
static

Create a new XResourceId object for the given resource URL and a single anchor URL.

Definition at line 726 of file FrameworkHelper.cxx.

◆ Dispose()

void sd::framework::FrameworkHelper::Dispose ( )
private

Definition at line 338 of file FrameworkHelper.cxx.

References mxConfigurationController, and mxDisposeListener.

Referenced by GetView(), RequestView(), and UpdateConfiguration().

◆ DisposeInstance()

void sd::framework::FrameworkHelper::DisposeInstance ( const ViewShellBase rBase)
static

Mark the FrameworkHelper object for the given ViewShellBase as disposed.

A following ReleaseInstance() call will destroy the FrameworkHelper object.

Do not call this method. It is an internally used method that can not be made private.

Definition at line 301 of file FrameworkHelper.cxx.

References maInstanceMap.

◆ disposing()

void sd::framework::FrameworkHelper::disposing ( const css::lang::EventObject &  rEventObject)
private

This disposing method is forwarded from the inner DisposeListener class.

Definition at line 677 of file FrameworkHelper.cxx.

References mxConfigurationController.

◆ GetConfigurationController()

const css::uno::Reference< css::drawing::framework::XConfigurationController > & sd::framework::FrameworkHelper::GetConfigurationController ( ) const
inline

Definition at line 285 of file FrameworkHelper.hxx.

References mxConfigurationController.

◆ GetView()

Reference< XView > sd::framework::FrameworkHelper::GetView ( const css::uno::Reference< css::drawing::framework::XResourceId > &  rxPaneOrViewId)

Return a reference to the view that is displayed in the specified pane.

See GetViewShell () for a variant that returns a ViewShell pointer instead of a reference to XView.

Parameters
rxPaneOrViewIdWhen this ResourceId specifies a view then that view is returned. When it belongs to a pane then one view in that pane is returned.
Returns
An empty reference is returned when for example the specified pane does not exist or is not visible or does not show a view or one of the involved objects does not support XTunnel (where necessary).

Definition at line 364 of file FrameworkHelper.cxx.

References Dispose(), msViewURLPrefix, and mxConfigurationController.

Referenced by HandleModeChangeSlot().

◆ GetViewId()

ViewShell::ShellType sd::framework::FrameworkHelper::GetViewId ( const OUString &  rsViewURL)
static

◆ GetViewShell() [1/2]

static ::std::shared_ptr< ViewShell > sd::framework::FrameworkHelper::GetViewShell ( const css::uno::Reference< css::drawing::framework::XView > &  rxView)

Return a ViewShell pointer for the given XView reference.

This assumes that the given reference is implemented by the ViewShellWrapper class that supports the XTunnel interface.

Returns
When the ViewShell pointer can not be inferred from the given reference then an empty pointer is returned.

◆ GetViewShell() [2/2]

std::shared_ptr< ViewShell > sd::framework::FrameworkHelper::GetViewShell ( const OUString &  rsPaneURL)

Return a pointer to the view shell that is displayed in the specified pane.

See GetView() for a variant that returns a reference to XView instead of a ViewShell pointer.

Returns
An empty pointer is returned when for example the specified pane does not exist or is not visible or does not show a view or one of the involved objects does not support XUnoTunnel (where necessary).

Definition at line 350 of file FrameworkHelper.cxx.

References CreateResourceId(), and mxConfigurationController.

◆ GetViewURL()

OUString sd::framework::FrameworkHelper::GetViewURL ( ViewShell::ShellType  eType)
static

◆ HandleModeChangeSlot()

void sd::framework::FrameworkHelper::HandleModeChangeSlot ( sal_uInt16  nSlotId,
SfxRequest const &  rRequest 
)

◆ Initialize()

void sd::framework::FrameworkHelper::Initialize ( )
private

Definition at line 329 of file FrameworkHelper.cxx.

References DisposeListener, and mxDisposeListener.

◆ Instance()

std::shared_ptr< FrameworkHelper > sd::framework::FrameworkHelper::Instance ( ViewShellBase rBase)

◆ IsValid()

bool sd::framework::FrameworkHelper::IsValid ( ) const

Test whether the called FrameworkHelper object is valid.

Returns
When the object has already been disposed then <FALSE> is returned.

Definition at line 345 of file FrameworkHelper.cxx.

References mxConfigurationController.

◆ operator=()

FrameworkHelper & sd::framework::FrameworkHelper::operator= ( const FrameworkHelper rHelper)
privatedelete

◆ ReleaseInstance()

void sd::framework::FrameworkHelper::ReleaseInstance ( const ViewShellBase rBase)
static

Destroy the FrameworkHelper object for the given ViewShellBase.

Do not call this method. It is an internally used method that can not be made private.

Definition at line 310 of file FrameworkHelper.cxx.

References maInstanceMap.

◆ RequestSynchronousUpdate()

void sd::framework::FrameworkHelper::RequestSynchronousUpdate ( )

Normally the requested changes of the configuration are executed asynchronously.

However, there is at least one situation (searching with the Outliner) where the surrounding code does not cope with this. So, instead of calling Reschedule until the global event loop executes the configuration update, this method does (almost) the same without the reschedules.

Do not use this method until there is absolutely no other way.

Definition at line 634 of file FrameworkHelper.cxx.

References mxConfigurationController.

◆ RequestView()

Reference< XResourceId > sd::framework::FrameworkHelper::RequestView ( const OUString &  rsResourceURL,
const OUString &  rsAnchorURL 
)

Request the specified view to be displayed in the specified pane.

When the pane is not visible its creation is also requested. The update that creates the actual view object is done asynchronously.

Parameters
rsResourceURLThe resource URL of the view to show.
rsAnchorURLThe URL of the pane in which to show the view.
Returns
The resource id of the requested view is returned. With that the caller can, for example, call RunOnResourceActivation() to do some initialization after the requested view becomes active.

Definition at line 393 of file FrameworkHelper.cxx.

References CreateResourceId(), Dispose(), and mxConfigurationController.

◆ ResourceIdToString()

OUString sd::framework::FrameworkHelper::ResourceIdToString ( const css::uno::Reference< css::drawing::framework::XResourceId > &  rxResourceId)
static

◆ RunOnConfigurationEvent()

void sd::framework::FrameworkHelper::RunOnConfigurationEvent ( const OUString &  rsEventType,
const Callback rCallback 
)

Run the given callback when the specified event is notified by the ConfigurationManager.

When there are no pending requests and therefore no events would be notified (in the foreseeable future) then the callback is called immediately. The callback is called with a flag that tells the callback whether the event it waits for has been sent.

Definition at line 590 of file FrameworkHelper.cxx.

References RunOnEvent().

◆ RunOnEvent()

void sd::framework::FrameworkHelper::RunOnEvent ( const OUString &  rsEventType,
const ConfigurationChangeEventFilter rFilter,
const Callback rCallback 
) const
private

Run the given callback when an event of the specified type is received from the ConfigurationController or when the ConfigurationController has no pending change requests.

Parameters
rsEventTypeRun rCallback only on this event.
rFilterThis filter has to return <TRUE> in order for rCallback to be called.
rCallbackThe callback functor to be called.

Definition at line 669 of file FrameworkHelper.cxx.

References mrBase.

Referenced by RunOnConfigurationEvent(), RunOnResourceActivation(), and WaitForEvent().

◆ RunOnResourceActivation()

void sd::framework::FrameworkHelper::RunOnResourceActivation ( const css::uno::Reference< css::drawing::framework::XResourceId > &  rxResourceId,
const Callback rCallback 
)

Run the given callback when the specified resource has been activated.

When the resource is active already when this method is called then rCallback is called before this method returns.

Parameters
rxResourceIdWait for the activation of this resource before calling rCallback.
rCallbackThe callback to be called when the resource is activated.

Definition at line 600 of file FrameworkHelper.cxx.

References msResourceActivationEvent, mxConfigurationController, and RunOnEvent().

Referenced by HandleModeChangeSlot().

◆ UpdateConfiguration()

void sd::framework::FrameworkHelper::UpdateConfiguration ( )

Explicit request for an update of the current configuration.

Call this method when one of the resources managed by the sd framework has been activated or deactivated from the outside, i.e. not by the framework itself. An example for this is a click on the closer button of one of the side panes.

Definition at line 683 of file FrameworkHelper.cxx.

References DBG_UNHANDLED_EXCEPTION, Dispose(), and mxConfigurationController.

◆ WaitForEvent()

void sd::framework::FrameworkHelper::WaitForEvent ( const OUString &  rsEventName) const

Block until the specified event is notified by the configuration controller.

When the configuration controller is not processing any requests the method returns immediately.

Definition at line 642 of file FrameworkHelper.cxx.

References Application::Reschedule(), and RunOnEvent().

Referenced by WaitForUpdate().

◆ WaitForUpdate()

void sd::framework::FrameworkHelper::WaitForUpdate ( ) const

This is a short cut for WaitForEvent(msConfigurationUpdateEndEvent).

Call this method to execute the pending requests.

Definition at line 664 of file FrameworkHelper.cxx.

References msConfigurationUpdateEndEvent, and WaitForEvent().

Friends And Related Function Documentation

◆ Deleter

friend class Deleter
friend

Definition at line 311 of file FrameworkHelper.hxx.

◆ DisposeListener

friend class DisposeListener
friend

Definition at line 304 of file FrameworkHelper.hxx.

Referenced by Initialize().

Member Data Documentation

◆ maInstanceMap

FrameworkHelper::InstanceMap sd::framework::FrameworkHelper::maInstanceMap
staticprivate

The instance map holds (at least) one FrameworkHelper instance for every ViewShellBase object.

Definition at line 294 of file FrameworkHelper.hxx.

Referenced by DisposeInstance(), Instance(), and ReleaseInstance().

◆ maInstanceMapMutex

std::mutex sd::framework::FrameworkHelper::maInstanceMapMutex
staticprivate

Definition at line 297 of file FrameworkHelper.hxx.

Referenced by Instance().

◆ maViewURLMap

FrameworkHelper::ViewURLMap sd::framework::FrameworkHelper::maViewURLMap
staticprivate

Definition at line 296 of file FrameworkHelper.hxx.

Referenced by GetViewId().

◆ mrBase

ViewShellBase& sd::framework::FrameworkHelper::mrBase
private

Definition at line 299 of file FrameworkHelper.hxx.

Referenced by FrameworkHelper(), and RunOnEvent().

◆ msCenterPaneURL

const OUString sd::framework::FrameworkHelper::msCenterPaneURL
static

◆ msConfigurationUpdateEndEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msConfigurationUpdateEndEvent = u"ConfigurationUpdateEnd"
staticconstexpr

◆ msConfigurationUpdateStartEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msConfigurationUpdateStartEvent = u"ConfigurationUpdateStart"
staticconstexpr

◆ msDrawViewURL

const OUString sd::framework::FrameworkHelper::msDrawViewURL
static

◆ msFullScreenPaneURL

const OUString sd::framework::FrameworkHelper::msFullScreenPaneURL
static

◆ msHandoutViewURL

const OUString sd::framework::FrameworkHelper::msHandoutViewURL
static

◆ msImpressViewURL

const OUString sd::framework::FrameworkHelper::msImpressViewURL
static

◆ msLeftDrawPaneURL

const OUString sd::framework::FrameworkHelper::msLeftDrawPaneURL
static

◆ msLeftImpressPaneURL

const OUString sd::framework::FrameworkHelper::msLeftImpressPaneURL
static

◆ msNotesViewURL

const OUString sd::framework::FrameworkHelper::msNotesViewURL
static

◆ msOutlineViewURL

const OUString sd::framework::FrameworkHelper::msOutlineViewURL
static

◆ msPaneURLPrefix

constexpr OUStringLiteral sd::framework::FrameworkHelper::msPaneURLPrefix = u"private:resource/pane/"
staticconstexpr

Definition at line 59 of file FrameworkHelper.hxx.

Referenced by sd::PaneHider::PaneHider().

◆ msPresentationViewURL

const OUString sd::framework::FrameworkHelper::msPresentationViewURL
static

◆ msResourceActivationEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msResourceActivationEvent = u"ResourceActivation"
staticconstexpr

◆ msResourceActivationRequestEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msResourceActivationRequestEvent = u"ResourceActivationRequested"
staticconstexpr

◆ msResourceDeactivationEndEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msResourceDeactivationEndEvent = u"ResourceDeactivationEnd"
staticconstexpr

◆ msResourceDeactivationEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msResourceDeactivationEvent = u"ResourceDeactivation"
staticconstexpr

◆ msResourceDeactivationRequestEvent

constexpr OUStringLiteral sd::framework::FrameworkHelper::msResourceDeactivationRequestEvent = u"ResourceDeactivationRequest"
staticconstexpr

◆ msSidebarViewURL

const OUString sd::framework::FrameworkHelper::msSidebarViewURL
static

Definition at line 74 of file FrameworkHelper.hxx.

Referenced by GetViewId(), and GetViewURL().

◆ msSlideSorterURL

const OUString sd::framework::FrameworkHelper::msSlideSorterURL
static

◆ msToolBarURLPrefix

constexpr OUStringLiteral sd::framework::FrameworkHelper::msToolBarURLPrefix = u"private:resource/toolbar/"
staticconstexpr

Definition at line 77 of file FrameworkHelper.hxx.

◆ msViewTabBarURL

const OUString sd::framework::FrameworkHelper::msViewTabBarURL
static

◆ msViewURLPrefix

constexpr OUStringLiteral sd::framework::FrameworkHelper::msViewURLPrefix = u"private:resource/view/"
staticconstexpr

◆ mxConfigurationController

css::uno::Reference<css::drawing::framework::XConfigurationController> sd::framework::FrameworkHelper::mxConfigurationController
private

◆ mxDisposeListener

css::uno::Reference<css::lang::XComponent> sd::framework::FrameworkHelper::mxDisposeListener
private

Definition at line 306 of file FrameworkHelper.hxx.

Referenced by Dispose(), and Initialize().


The documentation for this class was generated from the following files: