summaryrefslogtreecommitdiffstats
path: root/sd/source/ui/inc/tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sd/source/ui/inc/tools/AsynchronousCall.hxx77
-rw-r--r--sd/source/ui/inc/tools/AsynchronousTask.hxx49
-rw-r--r--sd/source/ui/inc/tools/ConfigurationAccess.hxx144
-rw-r--r--sd/source/ui/inc/tools/GraphicSizeCheck.hxx116
-rw-r--r--sd/source/ui/inc/tools/IconCache.hxx70
-rw-r--r--sd/source/ui/inc/tools/IdleDetection.hxx89
-rw-r--r--sd/source/ui/inc/tools/PropertySet.hxx114
-rw-r--r--sd/source/ui/inc/tools/SdGlobalResourceContainer.hxx105
-rw-r--r--sd/source/ui/inc/tools/SlotStateListener.hxx138
-rw-r--r--sd/source/ui/inc/tools/TimerBasedTaskExecution.hxx89
10 files changed, 991 insertions, 0 deletions
diff --git a/sd/source/ui/inc/tools/AsynchronousCall.hxx b/sd/source/ui/inc/tools/AsynchronousCall.hxx
new file mode 100644
index 000000000..fa4c18020
--- /dev/null
+++ b/sd/source/ui/inc/tools/AsynchronousCall.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <vcl/timer.hxx>
+
+#include <memory>
+#include <functional>
+
+namespace sd::tools
+{
+/** Store a function object and execute it asynchronous.
+
+ The features of this class are:
+ a) It provides a wrapper around a VCL Timer so that generic function
+ objects can be used.
+ b) When more than one function objects are posted to be executed later
+ then the pending ones are erased and only the last one will actually be
+ executed.
+
+ Use this class like this:
+ aInstanceOfAsynchronousCall.Post(
+ ::std::bind(
+ ::std::mem_fun(&DrawViewShell::SwitchPage),
+ pDrawViewShell,
+ 11));
+*/
+class AsynchronousCall
+{
+public:
+ /** Create a new asynchronous call. Each object of this class processes
+ one (semantical) type of call.
+ */
+ AsynchronousCall();
+
+ ~AsynchronousCall();
+
+ /** Post a function object that is to be executed asynchronously. When
+ this method is called while the current function object has not been
+ executed then the latter is destroyed and only the given function
+ object will be executed.
+ @param rFunction
+ The function object that may be called asynchronously in the
+ near future.
+ */
+ typedef ::std::function<void()> AsynchronousFunction;
+ void Post(const AsynchronousFunction& rFunction);
+
+private:
+ Timer maTimer;
+ /** The function object that will be executed when the TimerCallback
+ function is called the next time. This pointer may be NULL.
+ */
+ ::std::unique_ptr<AsynchronousFunction> mpFunction;
+ DECL_LINK(TimerCallback, Timer*, void);
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/AsynchronousTask.hxx b/sd/source/ui/inc/tools/AsynchronousTask.hxx
new file mode 100644
index 000000000..696423439
--- /dev/null
+++ b/sd/source/ui/inc/tools/AsynchronousTask.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+namespace sd::tools
+{
+/** Interface for the asynchronous execution of a task. This interface
+ allows a controller to run the task either timer based with a fixed
+ amount of time between the steps or thread based one step right after
+ the other.
+*/
+class AsynchronousTask
+{
+public:
+ /** Run the next step of the task. After HasNextStep() returns false
+ this method should ignore further calls.
+ */
+ virtual void RunNextStep() = 0;
+
+ /** Return <TRUE/> when there is at least one more step to execute.
+ When the task has been executed completely then <FALSE/> is
+ returned.
+ */
+ virtual bool HasNextStep() = 0;
+
+protected:
+ ~AsynchronousTask() {}
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/ConfigurationAccess.hxx b/sd/source/ui/inc/tools/ConfigurationAccess.hxx
new file mode 100644
index 000000000..b86a30fff
--- /dev/null
+++ b/sd/source/ui/inc/tools/ConfigurationAccess.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <vector>
+#include <functional>
+
+namespace com::sun::star::container { class XHierarchicalNameAccess; }
+namespace com::sun::star::container { class XNameAccess; }
+namespace com::sun::star::lang { class XMultiServiceFactory; }
+namespace com::sun::star::uno { class XComponentContext; }
+
+namespace sd::tools {
+
+/** This class gives access to the configuration. Create an object of this
+ class for one node of the configuration. This will be the root node.
+ Its children are then accessible through the new ConfigurationAccess
+ object.
+*/
+class ConfigurationAccess
+{
+public:
+ enum WriteMode { READ_WRITE, READ_ONLY };
+
+ /** Create a new object to access the configuration entries below the
+ given root.
+ @param rsRootName
+ Name of the root.
+ @param eMode
+ This flag specifies whether to give read-write or read-only
+ access.
+ */
+ ConfigurationAccess(
+ const OUString& rsRootName,
+ const WriteMode eMode);
+
+ ConfigurationAccess(
+ const css::uno::Reference<css::uno::XComponentContext>& rxContext,
+ const OUString& rsRootName,
+ const WriteMode eMode);
+
+ /** Return a configuration node below the root of the called object.
+ @param rsPathToNode
+ The relative path from the root (as given the constructor) to
+ the node.
+ @return
+ The type of the returned node varies with the requested node.
+ It is empty when the node was not found.
+ */
+ css::uno::Any GetConfigurationNode (
+ const OUString& rsPathToNode);
+
+ /** Return a configuration node below the given node.
+ @param rxNode
+ The node that acts as root to the given relative path.
+ @param rsPathToNode
+ The relative path from the given node to the requested node.
+ @return
+ The type of the returned node varies with the requested node.
+ It is empty when the node was not found.
+ */
+ static css::uno::Any GetConfigurationNode (
+ const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
+ const OUString& rsPathToNode);
+
+ /** Write any changes that have been made back to the configuration.
+ This call is ignored when the called ConfigurationAccess object was
+ not create with read-write mode.
+ */
+ void CommitChanges();
+
+ /** This functor is typically called for every item in a set. Its two
+ parameters are the name of key item (often of no further interest)
+ and the value of the item.
+ */
+ typedef ::std::function<void (
+ const OUString&,
+ const std::vector<css::uno::Any>&) > Functor;
+
+ /** Execute a functor for all elements of the given container.
+ @param rxContainer
+ The container is a XNameAccess to a list of the configuration.
+ This can be a node returned by GetConfigurationNode().
+ @param rArguments
+ The functor is called with arguments that are children of each
+ element of the container. The set of children is specified in this
+ list.
+ @param rFunctor
+ The functor to be executed for some or all of the elements in
+ the given container.
+ */
+ static void ForAll (
+ const css::uno::Reference<css::container::XNameAccess>& rxContainer,
+ const ::std::vector<OUString>& rArguments,
+ const Functor& rFunctor);
+
+ /** Fill a list with the string contents of all sub-elements in the given container.
+ @param rxContainer
+ The container is a XNameAccess to a list of the configuration.
+ This can be a node returned by GetConfigurationNode().
+ @param rsArgument
+ This specifies which string children of the elements in the
+ container are to be inserted into the list. The specified child
+ has to be of type string.
+ @param rList
+ The list to be filled.
+ */
+ static void FillList(
+ const css::uno::Reference<css::container::XNameAccess>& rxContainer,
+ const OUString& rsArgument,
+ ::std::vector<OUString>& rList);
+
+private:
+ css::uno::Reference<css::uno::XInterface> mxRoot;
+
+ void Initialize (
+ const css::uno::Reference<css::lang::XMultiServiceFactory>& rxProvider,
+ const OUString& rsRootName,
+ const WriteMode eMode);
+};
+
+} // end of namespace sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/GraphicSizeCheck.hxx b/sd/source/ui/inc/tools/GraphicSizeCheck.hxx
new file mode 100644
index 000000000..44f78e4eb
--- /dev/null
+++ b/sd/source/ui/inc/tools/GraphicSizeCheck.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+#include <drawdoc.hxx>
+#include <svx/GenericCheckDialog.hxx>
+#include <svx/svdograf.hxx>
+
+namespace sd
+{
+/**
+ * Class responsible to check if a graphic object violates the size
+ * constraints and store the results.
+ */
+class GraphicSizeViolation final
+{
+private:
+ SdrGrafObj* m_pGraphicObject;
+
+ sal_Int32 m_nLowDPILimit = 0;
+ sal_Int32 m_nHighDPILimit = 0;
+
+ sal_Int32 m_nDPIX = 0;
+ sal_Int32 m_nDPIY = 0;
+
+public:
+ GraphicSizeViolation(sal_Int32 nDPI, SdrGrafObj* pGraphicObject);
+ bool check();
+
+ const OUString& getGraphicName();
+
+ SdrGrafObj* getObject() const { return m_pGraphicObject; }
+
+ bool isDPITooLow() { return m_nDPIX < m_nLowDPILimit || m_nDPIY < m_nLowDPILimit; }
+
+ bool isDPITooHigh() { return m_nDPIX > m_nHighDPILimit || m_nDPIY > m_nHighDPILimit; }
+
+ sal_Int32 getDPIX() { return m_nDPIX; }
+
+ sal_Int32 getDPIY() { return m_nDPIY; }
+};
+
+/**
+ * Run the graphic size checks for all the graphic objects in the DOM
+ * and store a list of violations.
+ */
+class GraphicSizeCheck final
+{
+private:
+ SdDrawDocument* m_pDocument;
+ std::vector<std::unique_ptr<GraphicSizeViolation>> m_aGraphicSizeViolationList;
+
+public:
+ GraphicSizeCheck(SdDrawDocument* pDocument)
+ : m_pDocument(pDocument)
+ {
+ }
+
+ void check();
+
+ std::vector<std::unique_ptr<GraphicSizeViolation>>& getViolationList()
+ {
+ return m_aGraphicSizeViolationList;
+ }
+};
+
+/** The UI part of the GraphicSizeViolation used by GenericCheckDialog */
+class GraphicSizeCheckGUIEntry : public svx::CheckData
+{
+private:
+ SdDrawDocument* m_pDocument;
+ std::unique_ptr<GraphicSizeViolation> m_pViolation;
+
+public:
+ GraphicSizeCheckGUIEntry(SdDrawDocument* pDocument,
+ std::unique_ptr<GraphicSizeViolation>&& pViolation)
+ : m_pDocument(pDocument)
+ , m_pViolation(std::move(pViolation))
+ {
+ }
+
+ OUString getText() override;
+
+ bool canMarkObject() override { return true; }
+
+ void markObject() override;
+
+ bool hasProperties() override { return true; }
+
+ void runProperties() override;
+};
+
+/**
+ * The UI part presenting the graphic size check results, which is
+ * used by GenericCheckDialog
+ */
+class GraphicSizeCheckGUIResult : public svx::CheckDataCollection
+{
+public:
+ GraphicSizeCheckGUIResult(SdDrawDocument* m_pDocument);
+
+ OUString getTitle() override;
+};
+
+} // end of namespace sd
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/IconCache.hxx b/sd/source/ui/inc/tools/IconCache.hxx
new file mode 100644
index 000000000..fef994764
--- /dev/null
+++ b/sd/source/ui/inc/tools/IconCache.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <memory>
+#include <tools/SdGlobalResourceContainer.hxx>
+#include <vcl/image.hxx>
+
+namespace sd
+{
+/** This simple class stores frequently used icons so that the classes that
+ use the icons do not have to store them in every one of their
+ instances.
+
+ Icons are addressed over their resource id and are loaded on demand.
+
+ This cache acts like a singleton with a lifetime equal to that of the sd
+ module.
+*/
+class IconCache final : public SdGlobalResource
+{
+public:
+ /** The lifetime of the returned reference is limited to that of the sd
+ module.
+ */
+ static IconCache& Instance();
+
+ /** Return the icon with the given resource id.
+ @return
+ The returned Image may be empty when there is no icon for the
+ given id or an error occurred. Should not happen under normal
+ circumstances.
+ */
+ Image GetIcon(const OUString& rResourceId);
+
+private:
+ class Implementation;
+ ::std::unique_ptr<Implementation> mpImpl;
+
+ /** The constructor creates the one instance of the cache and registers
+ it at the SdGlobalResourceContainer to limit is lifetime to that of
+ the sd module.
+ */
+ IconCache();
+
+ /** This destructor is called by SdGlobalResourceContainer.
+ */
+ virtual ~IconCache() override;
+};
+
+} // end of namespace sd
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/IdleDetection.hxx b/sd/source/ui/inc/tools/IdleDetection.hxx
new file mode 100644
index 000000000..decf5ff26
--- /dev/null
+++ b/sd/source/ui/inc/tools/IdleDetection.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <o3tl/typed_flags_set.hxx>
+
+namespace vcl { class Window; }
+
+namespace sd::tools {
+ enum class IdleState {
+ /** When GetIdleState() returns this value, then the system is idle.
+ */
+ Idle = 0x0000,
+
+ /** There are system event pending.
+ */
+ SystemEventPending = 0x0001,
+
+ /** A full screen slide show is running and is active. In contrast
+ there may be a full screen show be running in an inactive window,
+ i.e. in the background.
+ */
+ FullScreenShowActive = 0x0002,
+
+ /** A slide show is running in a window.
+ */
+ WindowShowActive = 0x0004,
+
+ /** A window is being painted.
+ */
+ WindowPainting = 0x0008,
+ };
+} // end of namespace ::sd::tools
+namespace o3tl {
+ template<> struct typed_flags<::sd::tools::IdleState> : is_typed_flags<::sd::tools::IdleState, 0x0f> {};
+}
+
+namespace sd::tools {
+
+/** Detect whether the system is idle and some time consuming operation may
+ be carried out. This class distinguishes between different states of
+ idle-ness.
+*/
+class IdleDetection
+{
+public:
+ /** Determine whether the system is idle.
+ @param pWindow
+ When a valid Window pointer is given then it is checked
+ whether the window is currently being painting.
+ @return
+ This method either returns IdleState::Idle or a combination of
+ IdleStates values or-ed together that describe what the system
+ is currently doing so that the caller can decide what to do.
+ */
+ static IdleState GetIdleState (const vcl::Window* pWindow);
+
+private:
+ /** Check whether there are input events pending.
+ */
+ static IdleState CheckInputPending();
+
+ /** Check whether a slide show is running full screen or in a window.
+ */
+ static IdleState CheckSlideShowRunning();
+
+ static IdleState CheckWindowPainting (const vcl::Window& rWindow);
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/PropertySet.hxx b/sd/source/ui/inc/tools/PropertySet.hxx
new file mode 100644
index 000000000..c432783da
--- /dev/null
+++ b/sd/source/ui/inc/tools/PropertySet.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <map>
+#include <memory>
+
+namespace sd::tools {
+
+typedef ::cppu::WeakComponentImplHelper <
+ css::beans::XPropertySet
+> PropertySetInterfaceBase;
+
+/** A very simple implementation of the XPropertySet interface. It does not
+ support constrained properties and thus does not support vetoable
+ listeners. It does not support the optional property set info.
+
+ In order to use it you have to derive from this class and implement the
+ GetPropertyValue() and SetPropertyValue() methods.
+*/
+class PropertySet
+ : protected ::cppu::BaseMutex,
+ public PropertySetInterfaceBase
+{
+public:
+ explicit PropertySet();
+ virtual ~PropertySet() override;
+
+ virtual void SAL_CALL disposing() override;
+
+ // XPropertySet
+
+ virtual css::uno::Reference<css::beans::XPropertySetInfo>
+ SAL_CALL getPropertySetInfo() override;
+
+ virtual void SAL_CALL setPropertyValue (
+ const OUString& rsPropertyName,
+ const css::uno::Any& rsPropertyValue) override;
+
+ virtual css::uno::Any SAL_CALL getPropertyValue (const OUString& rsPropertyName) override;
+
+ virtual void SAL_CALL addPropertyChangeListener (
+ const OUString& rsPropertyName,
+ const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override;
+
+ virtual void SAL_CALL removePropertyChangeListener (
+ const OUString& rsPropertyName,
+ const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override;
+
+ virtual void SAL_CALL addVetoableChangeListener (
+ const OUString& rsPropertyName,
+ const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override;
+
+ virtual void SAL_CALL removeVetoableChangeListener (
+ const OUString& rsPropertyName,
+ const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override;
+
+protected:
+ /** Return the requested property value.
+ @throw css::beans::UnknownPropertyException when the
+ property is not supported.
+ */
+ virtual css::uno::Any GetPropertyValue (const OUString& rsPropertyName) = 0;
+ /** Set the given property value.
+ @return the old value.
+ @throw css::beans::UnknownPropertyException when the
+ property is not supported.
+ */
+ virtual css::uno::Any SetPropertyValue (
+ const OUString& rsPropertyName,
+ const css::uno::Any& rValue) = 0;
+
+private:
+ typedef ::std::multimap<OUString,
+ css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer;
+ std::unique_ptr<ChangeListenerContainer> mpChangeListeners;
+
+ /** Call all listeners that are registered for the given property name.
+ Call this method with an empty property name to call listeners that
+ are registered for all properties.
+ */
+ void CallListeners (
+ const OUString& rsPropertyName,
+ const css::beans::PropertyChangeEvent& rEvent);
+
+ /** @throws css::lang::DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed();
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/SdGlobalResourceContainer.hxx b/sd/source/ui/inc/tools/SdGlobalResourceContainer.hxx
new file mode 100644
index 000000000..a582ffa72
--- /dev/null
+++ b/sd/source/ui/inc/tools/SdGlobalResourceContainer.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <memory>
+#include <sal/types.h>
+#include <o3tl/deleter.hxx>
+
+namespace com::sun::star::uno
+{
+template <class interface_type> class Reference;
+}
+namespace com::sun::star::uno
+{
+class XInterface;
+}
+
+namespace sd
+{
+class SdGlobalResource
+{
+public:
+ virtual ~SdGlobalResource() COVERITY_NOEXCEPT_FALSE{};
+};
+
+/** The purpose of this container is to hold references to resources that
+ are globally available to all interested objects and to destroy them
+ when the sd module is destroyed. Examples for resources can be
+ containers of bitmaps or the container of master pages used by the
+ MasterPagesSelector objects in the task panel.
+
+ It works like a singleton in that there is one instance per sd module.
+ Resources can be added (by themselves or their owners) to the
+ container. The main task of the container is the destruction of all
+ resources that have been added to it.
+
+ As you may note, there is no method to get a resource from the
+ container. It is the task of the resource to provide other means of
+ access to it.
+
+ The reason for this design is not to have to change the SdModule
+ destructor every time when there is a new resource. This is done by
+ reversing the dependency between module and resource: the resource knows
+ about the module--this container class to be more precisely--and tells
+ it to destroy the resource when the sd module is at the end of its
+ lifetime.
+*/
+class SdGlobalResourceContainer final
+{
+public:
+ static SdGlobalResourceContainer& Instance();
+
+ /** Add a resource to the container. The ownership of the resource is
+ transferred to the container. The resource is destroyed when the
+ container is destroyed, i.e. when the sd module is destroyed.
+
+ When in doubt, use the shared_ptr variant of this method.
+ */
+ void AddResource(::std::unique_ptr<SdGlobalResource> pResource);
+
+ /** Add a resource to the container. By using a shared_ptr and
+ releasing it only when the SgGlobalResourceContainer is destroyed
+ the given resource is kept alive at least that long. When at the
+ time of the destruction of SgGlobalResourceContainer no other
+ references exist the resource is destroyed as well.
+ */
+ void AddResource(const std::shared_ptr<SdGlobalResource>& pResource);
+
+ /** Add a resource that is implemented as UNO object. Destruction
+ (when the sd modules is unloaded) is done by a) calling dispose()
+ when the XComponent is supported and by b) releasing the reference.
+ */
+ void AddResource(const css::uno::Reference<css::uno::XInterface>& rxResource);
+
+private:
+ friend class SdGlobalResourceContainerInstance;
+ friend struct o3tl::default_delete<SdGlobalResourceContainer>;
+
+ class Implementation;
+ ::std::unique_ptr<Implementation> mpImpl;
+
+ SdGlobalResourceContainer();
+ ~SdGlobalResourceContainer();
+};
+
+} // end of namespace sd
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/SlotStateListener.hxx b/sd/source/ui/inc/tools/SlotStateListener.hxx
new file mode 100644
index 000000000..54a2e463d
--- /dev/null
+++ b/sd/source/ui/inc/tools/SlotStateListener.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <comphelper/compbase.hxx>
+#include <tools/link.hxx>
+#include <cppuhelper/weakref.hxx>
+
+namespace com::sun::star::frame { class XDispatch; }
+namespace com::sun::star::frame { class XDispatchProvider; }
+namespace com::sun::star::frame { class XStatusListener; }
+namespace com::sun::star::frame { struct FeatureStateEvent; }
+
+namespace sd::tools {
+
+typedef comphelper::WeakComponentImplHelper<
+ css::frame::XStatusListener
+ > SlotStateListenerInterfaceBase;
+
+/** Listen for state changes of slots. This class has been created in order
+ to be informed when the support for vertical writing changes but it can
+ be used to relay state changes of other slots as well.
+*/
+class SlotStateListener final
+ : public SlotStateListenerInterfaceBase
+{
+public:
+ /** This convenience version of the constructor takes all parameters
+ that are necessary to observe a single slot. See descriptions of
+ the SetCallback(), ConnectToFrame(), and ObserveSlot() methods for
+ explanations about the parameters.
+ */
+ SlotStateListener (
+ Link<const OUString&,void> const & rCallback,
+ const css::uno::Reference<css::frame::XDispatchProvider>& rxDispatchProvider,
+ const OUString& rSlotName);
+
+ /** The constructor de-registers all remaining listeners. Usually a prior
+ dispose() call should have done that already.
+ */
+ virtual ~SlotStateListener() override;
+
+ /** Set the callback to the given value. Whenever one of the observed
+ slots changes its state this callback is informed about it.
+ Changing the callback does not release the listeners.
+ @throws DisposedException
+ */
+ void SetCallback (const Link<const OUString&,void>& rCallback);
+
+ /** Set the frame whose slots shall be observed. When an object of this
+ class is already observing slots of another frame then these
+ listeners are released first.
+ @throws DisposedException
+ */
+ void ConnectToDispatchProvider (
+ const css::uno::Reference<css::frame::XDispatchProvider>& rxDispatchProvider);
+
+ /** Observe the slot specified by the given name. Note that
+ ConnectToFrame() has to have been called earlier.
+ @param rSlotName
+ The name of the slot to observe. An example is
+ ".uno:VerticalTextState".
+ @throws DisposedException
+ */
+ void ObserveSlot (const OUString& rSlotName);
+
+ //===== frame::XStatusListener ==========================================
+
+ /** Called by slot state change broadcasters. In turn the callback is
+ informed about the state change.
+ @throws DisposedException
+ */
+ virtual void SAL_CALL
+ statusChanged (
+ const css::frame::FeatureStateEvent& rState) override;
+
+ //===== lang::XEventListener ============================================
+
+ virtual void SAL_CALL
+ disposing(const css::lang::EventObject& rEvent) override;
+
+private:
+ /** This method is called by the WeakComponentImplHelper base class in
+ reaction to a XComponent::dispose() call. It releases all currently
+ active listeners.
+ */
+ virtual void disposing(std::unique_lock<std::mutex>&) override;
+
+ Link<const OUString&,void> maCallback;
+
+ /** Remember the URLs that describe slots whose state changes we are
+ listening to.
+ */
+ std::vector<css::util::URL> maRegisteredURLList;
+
+ css::uno::WeakReference<css::frame::XDispatchProvider> mxDispatchProviderWeak;
+
+ /** Deregister all currently active state change listeners.
+ */
+ void ReleaseListeners();
+
+ /** @throws css::lang::DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed();
+
+ /** Transform the given string into a URL object.
+ */
+ static css::util::URL MakeURL (const OUString& rSlotName);
+
+ /** Return an XDispatch object for the given URL.
+ */
+ css::uno::Reference<css::frame::XDispatch>
+ GetDispatch (
+ const css::util::URL& rURL) const;
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tools/TimerBasedTaskExecution.hxx b/sd/source/ui/inc/tools/TimerBasedTaskExecution.hxx
new file mode 100644
index 000000000..bbff549f1
--- /dev/null
+++ b/sd/source/ui/inc/tools/TimerBasedTaskExecution.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <vcl/timer.hxx>
+
+#include <memory>
+
+namespace sd::tools {
+
+class AsynchronousTask;
+
+/** Execute an AsynchronousTask timer based, i.e. every
+ nMillisecondsBetweenSteps milliseconds as much steps are executed as fit
+ into a nMaxTimePerStep millisecond interval.
+
+ When a task is executed completely, i.e. HasNextStep() returns <FALSE/>,
+ the TimerBasedTaskExecution destroys itself. This, of course, works
+ only if the creating instance does not hold a shared_ptr to that object.
+*/
+class TimerBasedTaskExecution
+{
+public:
+ /** Create a new object of this class.
+ @param rpTask
+ The AsynchronousTask that is to be executed.
+ @param nMillisecondsBetweenSteps
+ Wait at least this long between the execution of steps. Note
+ that more than one step may be executed in succession.
+ @param nMaxTimePerStep
+ The maximal time for executing steps without yielding control.
+ */
+ static std::shared_ptr<TimerBasedTaskExecution> Create (
+ const std::shared_ptr<AsynchronousTask>& rpTask,
+ sal_uInt32 nMillisecondsBetweenSteps,
+ sal_uInt32 nMaxTimePerStep);
+
+ /** Stop the execution of the task and release the shared pointer to
+ itself so that it will eventually be destroyed.
+ */
+ void Release();
+
+ /** Convenience method that calls Release() on the given task. It
+ checks the given weak_ptr for being expired and catches bad_weak_ptr
+ exceptions.
+ */
+ static void ReleaseTask (const std::weak_ptr<TimerBasedTaskExecution>& rpTask);
+
+private:
+ std::shared_ptr<AsynchronousTask> mpTask;
+ Timer maTimer;
+ /** This shared_ptr to this is used to destroy a TimerBasedTaskExecution
+ object when its task has been executed completely.
+ */
+ std::shared_ptr<TimerBasedTaskExecution> mpSelf;
+ sal_uInt32 mnMaxTimePerStep;
+
+ TimerBasedTaskExecution (
+ const std::shared_ptr<AsynchronousTask>& rpTask,
+ sal_uInt32 nMillisecondsBetweenSteps,
+ sal_uInt32 nMaxTimePerStep);
+ ~TimerBasedTaskExecution();
+
+ class Deleter;
+ friend class Deleter;
+
+ DECL_LINK(TimerCallback, Timer *, void);
+};
+
+} // end of namespace ::sd::tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */