LibreOffice Module sd (master) 1
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
sd::framework::ConfigurationUpdater Class Reference

This is a helper class for the ConfigurationController. More...

#include <ConfigurationUpdater.hxx>

Collaboration diagram for sd::framework::ConfigurationUpdater:
[legend]

Public Member Functions

 ConfigurationUpdater (std::shared_ptr< ConfigurationControllerBroadcaster > pBroadcaster, std::shared_ptr< ConfigurationControllerResourceManager > pResourceManager, const rtl::Reference<::sd::DrawController > &xControllerManager)
 Create a new ConfigurationUpdater object that notifies configuration changes and the start and end of updates via the given broadcaster. More...
 
 ~ConfigurationUpdater ()
 
void RequestUpdate (const css::uno::Reference< css::drawing::framework::XConfiguration > &rxRequestedConfiguration)
 Request an update of the current configuration so that it looks like the given requested configuration. More...
 
const css::uno::Reference< css::drawing::framework::XConfiguration > & GetCurrentConfiguration () const
 
std::shared_ptr< ConfigurationUpdaterLockGetLock ()
 Return a lock of the called ConfigurationUpdater. More...
 

Private Member Functions

void UpdateConfiguration ()
 This method does the main work of an update. More...
 
void UpdateCore (const ConfigurationClassifier &rClassifier)
 Basically calls UpdaterStart() andUpdateEnd() and makes some debug output. More...
 
void CheckPureAnchors (const css::uno::Reference< css::drawing::framework::XConfiguration > &rxConfiguration, ::std::vector< css::uno::Reference< css::drawing::framework::XResourceId > > &rResourcesToDeactivate)
 Check for all pure anchors if they have at least one child. More...
 
void CleanRequestedConfiguration ()
 Remove from the requested configuration all pure anchors that have no child. More...
 
void CheckUpdateSuccess ()
 Check the success of a recently executed configuration update. More...
 
void SetUpdateBeingProcessed (bool bValue)
 This method sets the mbUpdateBeingProcessed member that is used to prevent reentrance problems. More...
 
bool IsUpdatePossible () const
 Return whether it is possible to do an update of the configuration. More...
 
void LockUpdates ()
 Lock updates of the current configuration. More...
 
void UnlockUpdates ()
 When an update was requested since the last LockUpdates() call then RequestUpdate() is called. More...
 
 DECL_LINK (TimeoutHandler, Timer *, void)
 

Private Attributes

rtl::Reference<::sd::DrawControllermxControllerManager
 A reference to the XControllerManager is kept so that UpdateConfiguration() has access to the other sub controllers. More...
 
std::shared_ptr< ConfigurationControllerBroadcastermpBroadcaster
 
css::uno::Reference< css::drawing::framework::XConfiguration > mxCurrentConfiguration
 The current configuration holds the resources that are currently active. More...
 
css::uno::Reference< css::drawing::framework::XConfiguration > mxRequestedConfiguration
 The requested configuration holds the resources that have been requested to activate or to deactivate since the last update. More...
 
bool mbUpdatePending
 This flag is set to </sal_True> when an update of the current configuration was requested (because the last request in the queue was processed) but could not be executed because the ConfigurationController was locked. More...
 
bool mbUpdateBeingProcessed
 This flag is set to </sal_True> while the UpdateConfiguration() method is running. More...
 
sal_Int32 mnLockCount
 The ConfigurationController is locked when this count has a value larger then zero. More...
 
Timer maUpdateTimer
 This timer is used to check from time to time whether the requested configuration and the current configuration are identical and request an update when they are not. More...
 
sal_Int32 mnFailedUpdateCount
 The number of failed updates (those after which the current configuration is not equivalent to the requested configuration) is used to determine how long to wait before another update is made. More...
 
std::shared_ptr< ConfigurationControllerResourceManagermpResourceManager
 

Friends

class ConfigurationUpdaterLock
 

Detailed Description

This is a helper class for the ConfigurationController.

It handles the update of the current configuration so that it looks like a requested configuration. An update is made by activating or deactivating drawing framework resources.

When an update is not successful, i.e. after the update the current configuration is not equivalent to the requested configuration, then a timer is started to repeat the update after a short time.

Definition at line 61 of file ConfigurationUpdater.hxx.

Constructor & Destructor Documentation

◆ ConfigurationUpdater()

sd::framework::ConfigurationUpdater::ConfigurationUpdater ( std::shared_ptr< ConfigurationControllerBroadcaster pBroadcaster,
std::shared_ptr< ConfigurationControllerResourceManager pResourceManager,
const rtl::Reference<::sd::DrawController > &  xControllerManager 
)

Create a new ConfigurationUpdater object that notifies configuration changes and the start and end of updates via the given broadcaster.

Definition at line 66 of file ConfigurationUpdater.cxx.

References LINK, maUpdateTimer, mxControllerManager, Reference, Timer::SetInvokeHandler(), and Timer::SetTimeout().

◆ ~ConfigurationUpdater()

sd::framework::ConfigurationUpdater::~ConfigurationUpdater ( )

Definition at line 87 of file ConfigurationUpdater.cxx.

References maUpdateTimer, and Task::Stop().

Member Function Documentation

◆ CheckPureAnchors()

void sd::framework::ConfigurationUpdater::CheckPureAnchors ( const css::uno::Reference< css::drawing::framework::XConfiguration > &  rxConfiguration,
::std::vector< css::uno::Reference< css::drawing::framework::XResourceId > > &  rResourcesToDeactivate 
)
private

Check for all pure anchors if they have at least one child.

Childless pure anchors are deactivated. This affects only the current configuration.

Definition at line 271 of file ConfigurationUpdater.cxx.

References mpResourceManager, nCount, nIndex, sd::framework::FrameworkHelper::ResourceIdToString(), and SAL_INFO.

Referenced by CleanRequestedConfiguration(), and UpdateCore().

◆ CheckUpdateSuccess()

void sd::framework::ConfigurationUpdater::CheckUpdateSuccess ( )
private

Check the success of a recently executed configuration update.

When the update failed then start the timer.

Definition at line 209 of file ConfigurationUpdater.cxx.

References sd::framework::AreConfigurationsEquivalent(), maUpdateTimer, mnFailedUpdateCount, mxCurrentConfiguration, mxRequestedConfiguration, Timer::SetTimeout(), and Timer::Start().

Referenced by UpdateConfiguration().

◆ CleanRequestedConfiguration()

void sd::framework::ConfigurationUpdater::CleanRequestedConfiguration ( )
private

Remove from the requested configuration all pure anchors that have no child.

Requested but not yet activated anchors can not be removed because without the actual resource the 'pureness' of an anchor can not be determined.

Definition at line 191 of file ConfigurationUpdater.cxx.

References CheckPureAnchors(), mxControllerManager, and mxRequestedConfiguration.

Referenced by UpdateConfiguration().

◆ DECL_LINK()

sd::framework::ConfigurationUpdater::DECL_LINK ( TimeoutHandler  ,
Timer ,
void   
)
private

◆ GetCurrentConfiguration()

const css::uno::Reference< css::drawing::framework::XConfiguration > & sd::framework::ConfigurationUpdater::GetCurrentConfiguration ( ) const
inline

Definition at line 82 of file ConfigurationUpdater.hxx.

References mxCurrentConfiguration.

◆ GetLock()

std::shared_ptr< ConfigurationUpdaterLock > sd::framework::ConfigurationUpdater::GetLock ( )

Return a lock of the called ConfigurationUpdater.

While the returned object exists no update of the current configuration is made.

Definition at line 353 of file ConfigurationUpdater.cxx.

◆ IsUpdatePossible()

bool sd::framework::ConfigurationUpdater::IsUpdatePossible ( ) const
private

Return whether it is possible to do an update of the configuration.

This takes into account whether another update is currently being executed, the lock count, and whether the configuration controller is still valid.

Definition at line 117 of file ConfigurationUpdater.cxx.

References mbUpdateBeingProcessed, mnLockCount, mxControllerManager, mxCurrentConfiguration, and mxRequestedConfiguration.

Referenced by RequestUpdate().

◆ LockUpdates()

void sd::framework::ConfigurationUpdater::LockUpdates ( )
private

Lock updates of the current configuration.

For intermediate requests for updates mbUpdatePending is set to <TRUE>.

Definition at line 339 of file ConfigurationUpdater.cxx.

References mnLockCount.

Referenced by sd::framework::ConfigurationUpdaterLock::ConfigurationUpdaterLock().

◆ RequestUpdate()

void sd::framework::ConfigurationUpdater::RequestUpdate ( const css::uno::Reference< css::drawing::framework::XConfiguration > &  rxRequestedConfiguration)

Request an update of the current configuration so that it looks like the given requested configuration.

It checks whether an update of the current configuration can be done. Calls UpdateConfiguration() if that is the case. Otherwise it schedules a later call to UpdateConfiguration().

Definition at line 92 of file ConfigurationUpdater.cxx.

References IsUpdatePossible(), mbUpdatePending, mxRequestedConfiguration, SAL_INFO, and UpdateConfiguration().

Referenced by UnlockUpdates().

◆ SetUpdateBeingProcessed()

void sd::framework::ConfigurationUpdater::SetUpdateBeingProcessed ( bool  bValue)
private

This method sets the mbUpdateBeingProcessed member that is used to prevent reentrance problems.

This method allows function objects easily and safely to modify the variable.

Definition at line 358 of file ConfigurationUpdater.cxx.

References mbUpdateBeingProcessed.

Referenced by UpdateConfiguration().

◆ UnlockUpdates()

void sd::framework::ConfigurationUpdater::UnlockUpdates ( )
private

When an update was requested since the last LockUpdates() call then RequestUpdate() is called.

Definition at line 344 of file ConfigurationUpdater.cxx.

References mbUpdatePending, mnLockCount, mxRequestedConfiguration, and RequestUpdate().

Referenced by sd::framework::ConfigurationUpdaterLock::~ConfigurationUpdaterLock().

◆ UpdateConfiguration()

void sd::framework::ConfigurationUpdater::UpdateConfiguration ( )
private

This method does the main work of an update.

It calls the sub controllers that are responsible for the various types of resources and tells them to update their active resources. It notifies listeners about the start and end of the configuration update.

Definition at line 126 of file ConfigurationUpdater.cxx.

References aEvent, CheckUpdateSuccess(), CleanRequestedConfiguration(), DBG_UNHANDLED_EXCEPTION, mbUpdatePending, mnLockCount, mpBroadcaster, sd::framework::FrameworkHelper::msConfigurationUpdateEndEvent, sd::framework::FrameworkHelper::msConfigurationUpdateStartEvent, mxCurrentConfiguration, mxRequestedConfiguration, sd::framework::ConfigurationClassifier::Partition(), SAL_INFO, SetUpdateBeingProcessed(), sd::framework::ConfigurationTracer::TraceConfiguration(), and UpdateCore().

Referenced by RequestUpdate().

◆ UpdateCore()

void sd::framework::ConfigurationUpdater::UpdateCore ( const ConfigurationClassifier rClassifier)
private

Friends And Related Function Documentation

◆ ConfigurationUpdaterLock

friend class ConfigurationUpdaterLock
friend

Definition at line 87 of file ConfigurationUpdater.hxx.

Member Data Documentation

◆ maUpdateTimer

Timer sd::framework::ConfigurationUpdater::maUpdateTimer
private

This timer is used to check from time to time whether the requested configuration and the current configuration are identical and request an update when they are not.

This is used to overcome problems with resources that become available asynchronously.

Definition at line 141 of file ConfigurationUpdater.hxx.

Referenced by CheckUpdateSuccess(), ConfigurationUpdater(), and ~ConfigurationUpdater().

◆ mbUpdateBeingProcessed

bool sd::framework::ConfigurationUpdater::mbUpdateBeingProcessed
private

This flag is set to </sal_True> while the UpdateConfiguration() method is running.

It is used to prevent reentrance problems with this method.

Definition at line 127 of file ConfigurationUpdater.hxx.

Referenced by IsUpdatePossible(), and SetUpdateBeingProcessed().

◆ mbUpdatePending

bool sd::framework::ConfigurationUpdater::mbUpdatePending
private

This flag is set to </sal_True> when an update of the current configuration was requested (because the last request in the queue was processed) but could not be executed because the ConfigurationController was locked.

A call to UpdateConfiguration() resets the flag to </sal_False>.

Definition at line 121 of file ConfigurationUpdater.hxx.

Referenced by RequestUpdate(), UnlockUpdates(), and UpdateConfiguration().

◆ mnFailedUpdateCount

sal_Int32 sd::framework::ConfigurationUpdater::mnFailedUpdateCount
private

The number of failed updates (those after which the current configuration is not equivalent to the requested configuration) is used to determine how long to wait before another update is made.

Definition at line 147 of file ConfigurationUpdater.hxx.

Referenced by CheckUpdateSuccess().

◆ mnLockCount

sal_Int32 sd::framework::ConfigurationUpdater::mnLockCount
private

The ConfigurationController is locked when this count has a value larger then zero.

If the controller is locked then updates of the current configuration are not made.

Definition at line 133 of file ConfigurationUpdater.hxx.

Referenced by IsUpdatePossible(), LockUpdates(), UnlockUpdates(), and UpdateConfiguration().

◆ mpBroadcaster

std::shared_ptr<ConfigurationControllerBroadcaster> sd::framework::ConfigurationUpdater::mpBroadcaster
private

Definition at line 100 of file ConfigurationUpdater.hxx.

Referenced by UpdateConfiguration().

◆ mpResourceManager

std::shared_ptr<ConfigurationControllerResourceManager> sd::framework::ConfigurationUpdater::mpResourceManager
private

Definition at line 149 of file ConfigurationUpdater.hxx.

Referenced by CheckPureAnchors(), and UpdateCore().

◆ mxControllerManager

rtl::Reference<::sd::DrawController> sd::framework::ConfigurationUpdater::mxControllerManager
private

A reference to the XControllerManager is kept so that UpdateConfiguration() has access to the other sub controllers.

Definition at line 98 of file ConfigurationUpdater.hxx.

Referenced by CleanRequestedConfiguration(), ConfigurationUpdater(), and IsUpdatePossible().

◆ mxCurrentConfiguration

css::uno::Reference<css::drawing::framework::XConfiguration> sd::framework::ConfigurationUpdater::mxCurrentConfiguration
private

The current configuration holds the resources that are currently active.

It is modified during an update.

Definition at line 105 of file ConfigurationUpdater.hxx.

Referenced by CheckUpdateSuccess(), GetCurrentConfiguration(), IsUpdatePossible(), UpdateConfiguration(), and UpdateCore().

◆ mxRequestedConfiguration

css::uno::Reference<css::drawing::framework::XConfiguration> sd::framework::ConfigurationUpdater::mxRequestedConfiguration
private

The requested configuration holds the resources that have been requested to activate or to deactivate since the last update.

It is (usually) not modified during an update. This configuration is maintained by the ConfigurationController and given to the ConfigurationUpdater in the RequestUpdate() method.

Definition at line 113 of file ConfigurationUpdater.hxx.

Referenced by CheckUpdateSuccess(), CleanRequestedConfiguration(), IsUpdatePossible(), RequestUpdate(), UnlockUpdates(), UpdateConfiguration(), and UpdateCore().


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