29#include <com/sun/star/drawing/framework/XControllerManager.hpp>
39using ::sd::framework::FrameworkHelper;
43const sal_Int32 snShortTimeout (100);
44const sal_Int32 snNormalTimeout (1000);
45const sal_Int32 snLongTimeout (10000);
46const sal_Int32 snShortTimeoutCountThreshold (1);
47const sal_Int32 snNormalTimeoutCountThreshold (5);
67 std::shared_ptr<ConfigurationControllerBroadcaster> pBroadcaster,
68 std::shared_ptr<ConfigurationControllerResourceManager> pResourceManager,
70 : mpBroadcaster(
std::move(pBroadcaster)),
72 mbUpdatePending(false),
73 mbUpdateBeingProcessed(false),
75 maUpdateTimer(
"sd::ConfigurationUpdater maUpdateTimer"),
76 mnFailedUpdateCount(0),
77 mpResourceManager(
std::move(pResourceManager))
93 const Reference<XConfiguration>& rxRequestedConfiguration)
100 SAL_INFO(
"sd.fwk", __func__ <<
": UpdateConfiguration start");
113 SAL_INFO(
"sd.fwk", __func__ <<
": scheduling update for later");
128 SAL_INFO(
"sd.fwk", __func__ <<
": UpdateConfiguration update");
141#if DEBUG_SD_CONFIGURATION_TRACE
142 SAL_INFO(
"sd.fwk", __func__ <<
": ConfigurationUpdater::UpdateConfiguration(");
149 ConfigurationChangeEvent
aEvent;
173 SAL_INFO(
"sd.fwk", __func__ <<
": nothing to do");
174#if DEBUG_SD_CONFIGURATION_TRACE
187 SAL_INFO(
"sd.fwk", __func__ <<
": ConfigurationUpdater::UpdateConfiguration)");
188 SAL_INFO(
"sd.fwk", __func__ <<
": UpdateConfiguration end");
197 vector<Reference<XResourceId> > aResourcesToDeactivate;
199 if (!aResourcesToDeactivate.empty())
201 Reference<XConfigurationController> xCC (
203 for (
const auto& rxId : aResourcesToDeactivate)
205 xCC->requestResourceDeactivation(rxId);
235#if DEBUG_SD_CONFIGURATION_TRACE
236 rClassifier.TraceResourceIdVector(
237 "requested but not current resources:", rClassifier.
GetC1minusC2());
238 rClassifier.TraceResourceIdVector(
239 "current but not requested resources:", rClassifier.
GetC2minusC1());
240 rClassifier.TraceResourceIdVector(
241 "requested and current resources:", rClassifier.GetC1andC2());
251#if DEBUG_SD_CONFIGURATION_TRACE
252 SAL_INFO(
"sd.fwk", __func__ <<
": ConfigurationController::UpdateConfiguration)");
260 vector<Reference<XResourceId> > aResourcesToDeactivate;
262 if (!aResourcesToDeactivate.empty())
272 const Reference<XConfiguration>& rxConfiguration,
273 vector<Reference<XResourceId> >& rResourcesToDeactivate)
275 if ( ! rxConfiguration.is())
279 Sequence<Reference<XResourceId> > aResources(
280 rxConfiguration->getResources(
281 nullptr, OUString(), AnchorBindingMode_INDIRECT));
282 auto aResourcesRange = asNonConstRange(aResources);
283 sal_Int32
nCount (aResources.getLength());
286 rResourcesToDeactivate.clear();
294 const Reference<XResourceId> xResourceId (aResources[
nIndex]);
295 const Reference<XResource> xResource (
297 bool bDeactiveCurrentResource (
false);
300 if (xResource.is() && xResource->isAnchorOnly())
308 bDeactiveCurrentResource =
true;
312 const Reference<XResourceId> xPrevResourceId (aResources[
nIndex+1]);
313 if ( ! xPrevResourceId.is()
314 || ! xPrevResourceId->isBoundTo(xResourceId, AnchorBindingMode_DIRECT))
318 bDeactiveCurrentResource =
true;
323 if (bDeactiveCurrentResource)
325 SAL_INFO(
"sd.fwk", __func__ <<
": deactivating pure anchor " <<
327 "because it has no children");
330 aResourcesRange[nI] = aResources[nI+1];
333 rResourcesToDeactivate.push_back(xResourceId);
355 return std::make_shared<ConfigurationUpdaterLock>(*
this);
365 if ( ! mbUpdateBeingProcessed
366 && mxCurrentConfiguration.is()
367 && mxRequestedConfiguration.is())
371 RequestUpdate(mxRequestedConfiguration);
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
A ConfigurationClassifier object compares two configurations of resources and gives access to the dif...
const ResourceIdVector & GetC2minusC1() const
Return the resources that belong to the configuration given as rxConfiguration2 to the constructor bu...
const ResourceIdVector & GetC1minusC2() const
Return the resources that belong to the configuration given as rxConfiguration1 to the constructor bu...
bool Partition()
Calculate three lists of resource ids.
static void TraceConfiguration(const css::uno::Reference< css::drawing::framework::XConfiguration > &rxConfiguration, const char *pMessage)
~ConfigurationUpdaterLock()
ConfigurationUpdaterLock(ConfigurationUpdater &rUpdater)
ConfigurationUpdater & mrUpdater
This is a helper class for the ConfigurationController.
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...
Timer maUpdateTimer
This timer is used to check from time to time whether the requested configuration and the current con...
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 configuratio...
void UnlockUpdates()
When an update was requested since the last LockUpdates() call then RequestUpdate() is called.
bool IsUpdatePossible() const
Return whether it is possible to do an update of the configuration.
std::shared_ptr< ConfigurationUpdaterLock > GetLock()
Return a lock of the called ConfigurationUpdater.
void UpdateCore(const ConfigurationClassifier &rClassifier)
Basically calls UpdaterStart() andUpdateEnd() and makes some debug output.
sal_Int32 mnLockCount
The ConfigurationController is locked when this count has a value larger then zero.
void UpdateConfiguration()
This method does the main work of an update.
bool mbUpdatePending
This flag is set to </sal_True> when an update of the current configuration was requested (because th...
rtl::Reference<::sd::DrawController > mxControllerManager
A reference to the XControllerManager is kept so that UpdateConfiguration() has access to the other s...
css::uno::Reference< css::drawing::framework::XConfiguration > mxRequestedConfiguration
The requested configuration holds the resources that have been requested to activate or to deactivate...
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.
std::shared_ptr< ConfigurationControllerResourceManager > mpResourceManager
bool mbUpdateBeingProcessed
This flag is set to </sal_True> while the UpdateConfiguration() method is running.
void LockUpdates()
Lock updates of the current configuration.
void SetUpdateBeingProcessed(bool bValue)
This method sets the mbUpdateBeingProcessed member that is used to prevent reentrance problems.
void CleanRequestedConfiguration()
Remove from the requested configuration all pure anchors that have no child.
css::uno::Reference< css::drawing::framework::XConfiguration > mxCurrentConfiguration
The current configuration holds the resources that are currently active.
sal_Int32 mnFailedUpdateCount
The number of failed updates (those after which the current configuration is not equivalent to the re...
std::shared_ptr< ConfigurationControllerBroadcaster > mpBroadcaster
void CheckUpdateSuccess()
Check the success of a recently executed configuration update.
A configuration describes the resources of an application like panes, views, and tool bars and their ...
static constexpr OUStringLiteral msConfigurationUpdateStartEvent
static constexpr OUStringLiteral msConfigurationUpdateEndEvent
static OUString ResourceIdToString(const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId)
Return a string representation of the given XResourceId object.
#define DBG_UNHANDLED_EXCEPTION(...)
#define LINK(Instance, Class, Member)
#define SAL_INFO(area, stream)
IMPL_LINK_NOARG(ChangeRequestQueueProcessor, ProcessEvent, void *, void)
bool AreConfigurationsEquivalent(const Reference< XConfiguration > &rxConfiguration1, const Reference< XConfiguration > &rxConfiguration2)