summaryrefslogtreecommitdiffstats
path: root/include/framework
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /include/framework
parentInitial commit. (diff)
downloadlibreoffice-upstream/4%7.4.7.tar.xz
libreoffice-upstream/4%7.4.7.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--include/framework/ContextChangeEventMultiplexerTunnel.hxx30
-rw-r--r--include/framework/actiontriggerhelper.hxx65
-rw-r--r--include/framework/addonsoptions.hxx264
-rw-r--r--include/framework/configimporter.hxx49
-rw-r--r--include/framework/desktop.hxx455
-rw-r--r--include/framework/dispatchhelper.hxx111
-rw-r--r--include/framework/documentundoguard.hxx61
-rw-r--r--include/framework/framecontainer.hxx91
-rw-r--r--include/framework/framelistanalyzer.hxx204
-rw-r--r--include/framework/fwkdllapi.h22
-rw-r--r--include/framework/gate.hxx146
-rw-r--r--include/framework/generictoolbarcontroller.hxx73
-rw-r--r--include/framework/imutex.hxx43
-rw-r--r--include/framework/interaction.hxx105
-rw-r--r--include/framework/sfxhelperfunctions.hxx107
-rw-r--r--include/framework/titlehelper.hxx181
-rw-r--r--include/framework/transactionmanager.hxx123
-rw-r--r--include/framework/undomanagerhelper.hxx162
18 files changed, 2292 insertions, 0 deletions
diff --git a/include/framework/ContextChangeEventMultiplexerTunnel.hxx b/include/framework/ContextChangeEventMultiplexerTunnel.hxx
new file mode 100644
index 000000000..d2ff18bbe
--- /dev/null
+++ b/include/framework/ContextChangeEventMultiplexerTunnel.hxx
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#include <framework/fwkdllapi.h>
+#include <functional>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+namespace com::sun::star::ui { class XContextChangeEventListener; }
+namespace com::sun::star::uno { class XInterface; }
+namespace com::sun::star::uno { class XComponentContext; }
+
+namespace framework {
+
+// this is pretty horrible, don't use it!
+FWK_DLLPUBLIC css::uno::Reference<css::ui::XContextChangeEventListener>
+GetFirstListenerWith(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
+ css::uno::Reference<css::uno::XInterface> const& xEventFocus,
+ std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/actiontriggerhelper.hxx b/include/framework/actiontriggerhelper.hxx
new file mode 100644
index 000000000..d0efa7a3a
--- /dev/null
+++ b/include/framework/actiontriggerhelper.hxx
@@ -0,0 +1,65 @@
+/* -*- 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 <framework/fwkdllapi.h>
+#include <com/sun/star/uno/Reference.hxx>
+
+namespace com::sun::star::awt { class XPopupMenu; }
+namespace com::sun::star::container { class XIndexContainer; }
+
+namespace framework
+{
+ class FWK_DLLPUBLIC ActionTriggerHelper
+ {
+ public:
+ // Fills the submitted menu with the structure contained in the second
+ // parameter rActionTriggerContainer
+ // @param pNewMenu = must be a valid and empty menu
+ // @param rActionTriggerContainer = must be an instance of service "com.sun.star.ui.ActionTriggerContainer"
+ static void
+ CreateMenuFromActionTriggerContainer(
+ const css::uno::Reference<css::awt::XPopupMenu>& rNewMenu,
+ const css::uno::Reference<css::container::XIndexContainer>& rActionTriggerContainer);
+
+ // Creates a "css::ui::ActionTriggerContainer" with the structure of the menu
+ // provided as a parameter. The implementation class stores the menu pointer
+ // to optimize the time of creation of a menu from an actiontrigger structure.
+ // IMPORTANT: The caller must ensure that the menu pointer is valid through the
+ // life time of the XIndexContainer object!!!
+ // @param rMenu = Must be a valid menu. Please be aware that this implementation is based on
+ // the above mentioned restriction!!!
+
+ static css::uno::Reference< css::container::XIndexContainer > CreateActionTriggerContainerFromMenu(
+ const css::uno::Reference<css::awt::XPopupMenu>& rMenu, const OUString* pMenuIdentifier );
+
+ // Fills the submitted rActionTriggerContainer with the structure of the menu
+ // provided as the second parameter
+ // @param rActionTriggerContainer = must be an instance of service "com.sun.star.ui.ActionTriggerContainer"
+ // @param rMenu = must be a valid menu
+ static void
+ FillActionTriggerContainerFromMenu(
+ css::uno::Reference< css::container::XIndexContainer > const & rActionTriggerContainer,
+ const css::uno::Reference<css::awt::XPopupMenu>& rMenu);
+
+ };
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/addonsoptions.hxx b/include/framework/addonsoptions.hxx
new file mode 100644
index 000000000..0e97f7a24
--- /dev/null
+++ b/include/framework/addonsoptions.hxx
@@ -0,0 +1,264 @@
+/* -*- 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 .
+ */
+#ifndef INCLUDED_FRAMEWORK_ADDONSOPTIONS_HXX
+#define INCLUDED_FRAMEWORK_ADDONSOPTIONS_HXX
+
+#include <config_options.h>
+#include <sal/types.h>
+#include <vcl/bitmapex.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <framework/fwkdllapi.h>
+#include <memory>
+
+namespace osl { class Mutex; }
+
+/*-************************************************************************************************************
+ @descr The method GetAddonsMenu() returns a list of property values.
+ Use follow defines to separate values by names.
+*//*-*************************************************************************************************************/
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_URL = u"URL";
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_TITLE = u"Title";
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_TARGET = u"Target";
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_IMAGEIDENTIFIER = u"ImageIdentifier";
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_CONTEXT = u"Context";
+inline constexpr OUStringLiteral ADDONSMENUITEM_STRING_SUBMENU = u"Submenu";
+
+inline constexpr OUStringLiteral ADDONSPOPUPMENU_URL_PREFIX_STR = u"private:menu/Addon";
+
+namespace framework
+{
+
+struct FWK_DLLPUBLIC MergeMenuInstruction
+{
+ OUString aMergePoint;
+ OUString aMergeCommand;
+ OUString aMergeCommandParameter;
+ OUString aMergeFallback;
+ OUString aMergeContext;
+ css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aMergeMenu;
+};
+typedef ::std::vector< MergeMenuInstruction > MergeMenuInstructionContainer;
+
+struct FWK_DLLPUBLIC MergeToolbarInstruction
+{
+ OUString aMergeToolbar;
+ OUString aMergePoint;
+ OUString aMergeCommand;
+ OUString aMergeCommandParameter;
+ OUString aMergeFallback;
+ OUString aMergeContext;
+ css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aMergeToolbarItems;
+};
+
+typedef ::std::vector< MergeToolbarInstruction > MergeToolbarInstructionContainer;
+
+struct FWK_DLLPUBLIC MergeNotebookBarInstruction
+{
+ OUString aMergeNotebookBar;
+ OUString aMergePoint;
+ OUString aMergeCommand;
+ OUString aMergeCommandParameter;
+ OUString aMergeFallback;
+ OUString aMergeContext;
+ css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aMergeNotebookBarItems;
+};
+
+typedef ::std::vector< MergeNotebookBarInstruction > MergeNotebookBarInstructionContainer;
+
+struct FWK_DLLPUBLIC MergeStatusbarInstruction
+{
+ OUString aMergePoint;
+ OUString aMergeCommand;
+ OUString aMergeCommandParameter;
+ OUString aMergeContext;
+ css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aMergeStatusbarItems;
+};
+
+typedef ::std::vector< MergeStatusbarInstruction > MergeStatusbarInstructionContainer;
+
+/*-************************************************************************************************************
+ @short forward declaration to our private date container implementation
+ @descr We use these class as internal member to support small memory requirements.
+ You can create the container if it is necessary. The class which use these mechanism
+ is faster and smaller then a complete implementation!
+*//*-*************************************************************************************************************/
+
+class AddonsOptions_Impl;
+
+/*-************************************************************************************************************
+ @short collect information about menu features
+ @devstatus ready to use
+*//*-*************************************************************************************************************/
+
+class UNLESS_MERGELIBS(FWK_DLLPUBLIC) AddonsOptions
+{
+ public:
+ AddonsOptions();
+ ~AddonsOptions();
+
+ /*-****************************************************************************************************
+ @short returns if an addons menu is available
+ @descr Call to retrieve if an addons menu is available
+
+ @return true if there is a menu otherwise false
+ *//*-*****************************************************************************************************/
+
+ bool HasAddonsMenu() const;
+
+ /*-****************************************************************************************************
+ @short returns number of addons toolbars
+ @descr Call to retrieve the number of addons toolbars
+
+ @return number of addons toolbars
+ *//*-*****************************************************************************************************/
+ sal_Int32 GetAddonsToolBarCount() const ;
+
+ /*-****************************************************************************************************
+ @short returns number of addons notebookbar
+ @descr Call to retrieve the number of addons notebookbar
+
+ @return number of addons notebookar
+ *//*-*****************************************************************************************************/
+ sal_Int32 GetAddonsNotebookBarCount() const ;
+
+ /*-****************************************************************************************************
+ @short returns the complete addons menu
+ @descr Call it to get all entries of the addon menu.
+ We return a list of all nodes with its names and properties.
+ @return A list of menu items is returned.
+
+ @onerror We return an empty list.
+ *//*-*****************************************************************************************************/
+
+ const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& GetAddonsMenu() const;
+
+ /*-****************************************************************************************************
+ @short Gets the menu bar part of all addon components registered
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& GetAddonsMenuBarPart() const;
+
+ /*-****************************************************************************************************
+ @short Gets a toolbar part of a single addon
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& GetAddonsToolBarPart( sal_uInt32 nIndex ) const;
+
+ /*-****************************************************************************************************
+ @short Gets a unique toolbar resource name of a single addon
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
+
+ /*-****************************************************************************************************
+ @short Gets a NotebookBar part of a single addon
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& GetAddonsNotebookBarPart( sal_uInt32 nIndex ) const;
+
+ /*-****************************************************************************************************
+ @short Gets a unique NotebookBar resource name of a single addon
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ OUString GetAddonsNotebookBarResourceName( sal_uInt32 ) const;
+
+ /*-****************************************************************************************************
+ @short Retrieves all available merge instructions for the Office menu bar
+ @return The filled MergeMenuDefinitionContainer
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+
+ const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
+
+ /*-****************************************************************************************************
+ @short Retrieves all available merge instructions for a single toolbar
+ @return The filled
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+ bool GetMergeToolbarInstructions( const OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbar ) const;
+
+ /*-****************************************************************************************************
+ @short Retrieves all available merge instructions for Notebookbar
+ @return The filled
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+ bool GetMergeNotebookBarInstructions( const OUString& rNotebookBarName, MergeNotebookBarInstructionContainer& rNotebookBar ) const;
+
+ /*-****************************************************************************************************
+ @short Gets the Add-On help menu part of all addon components registered
+ @return A complete
+
+ @onerror We return sal_False
+ *//*-*****************************************************************************************************/
+ const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& GetAddonsHelpMenu() const;
+
+ const MergeStatusbarInstructionContainer& GetMergeStatusbarInstructions() const;
+
+ /*-****************************************************************************************************
+ @short Retrieve an image for a command URL which is defined inside the addon menu configuration
+ @descr Call it to retrieve an image for a command URL which is defined inside the addon menu configuration
+ @return An image which was defined in the configuration for the menu item. The image can be empty
+ no bitmap was defined for the request image properties.
+
+ @onerror An empty image
+ *//*-*****************************************************************************************************/
+
+ BitmapEx GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const;
+ BitmapEx GetImageFromURL( const OUString& aURL, bool bBig ) const;
+
+ // private methods
+
+ /*-****************************************************************************************************
+ @short return a reference to a static mutex
+ @descr These class is partially threadsafe (for de-/initialization only).
+ All access methods aren't safe!
+ We create a static mutex only for one ime and use at different times.
+ @return A reference to a static mutex member.
+ *//*-*****************************************************************************************************/
+
+ static ::osl::Mutex& GetOwnStaticMutex();
+
+ private:
+ std::shared_ptr<AddonsOptions_Impl> m_pImpl;
+};
+
+}
+
+#endif // INCLUDED_FRAMEWORK_ADDONSOPTIONS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/configimporter.hxx b/include/framework/configimporter.hxx
new file mode 100644
index 000000000..eca312719
--- /dev/null
+++ b/include/framework/configimporter.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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_CONFIGIMPORTER_HXX
+#define INCLUDED_FRAMEWORK_CONFIGIMPORTER_HXX
+
+#include <config_options.h>
+#include <framework/fwkdllapi.h>
+#include <vector>
+
+namespace com::sun::star::container { class XIndexContainer; }
+namespace com::sun::star::embed { class XStorage; }
+namespace com::sun::star::ui { class XUIConfigurationManager2; }
+namespace com::sun::star::uno { class XComponentContext; }
+namespace com::sun::star::uno { template <typename > class Reference; }
+
+namespace framework
+{
+ class UNLESS_MERGELIBS(FWK_DLLPUBLIC) UIConfigurationImporterOOo1x
+ {
+ public:
+ static bool ImportCustomToolbars(
+ const css::uno::Reference< css::ui::XUIConfigurationManager2 >& rContainerFactory,
+ std::vector< css::uno::Reference< css::container::XIndexContainer > >& rSeqContainer,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::embed::XStorage >& rToolbarStorage );
+ };
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_CONFIGIMPORTER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/desktop.hxx b/include/framework/desktop.hxx
new file mode 100644
index 000000000..3d525eb54
--- /dev/null
+++ b/include/framework/desktop.hxx
@@ -0,0 +1,455 @@
+/* -*- 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 <sal/config.h>
+
+#include <memory>
+#include <vector>
+
+#include "framecontainer.hxx"
+#include "fwkdllapi.h"
+#include "transactionmanager.hxx"
+
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XDesktop2.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/frame/XTask.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XTasksSupplier.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/frame/XDispatchResultListener.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <comphelper/multicontainer2.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <rtl/ref.hxx>
+#include <unotools/cmdoptions.hxx>
+
+namespace framework{
+
+enum ELoadState
+{
+ E_NOTSET ,
+ E_SUCCESSFUL ,
+ E_FAILED ,
+ E_INTERACTION
+};
+
+/*-************************************************************************************************************
+ @short implement the topframe of frame tree
+ @descr This is the root of the frame tree. The desktop has no window, is not visible but he is the logical
+ "masternode" to build the hierarchy.
+
+ @implements XInterface
+ XTypeProvider
+ XServiceInfo
+ XDesktop
+ XComponentLoader
+ XTasksSupplier
+ XDispatchProvider
+ XFramesSupplier
+ XFrame
+ XComponent
+ XPropertySet
+ XFastPropertySet
+ XMultiPropertySet
+ XDispatchResultListener
+ XEventListener
+ XInteractionHandler
+
+ @devstatus ready to use
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+typedef cppu::WeakComponentImplHelper<
+ css::lang::XServiceInfo ,
+ css::frame::XDesktop2 ,
+ css::frame::XTasksSupplier ,
+ css::frame::XDispatchResultListener , // => XEventListener
+ css::task::XInteractionHandler ,
+ css::frame::XUntitledNumbers > Desktop_BASE;
+
+class FWK_DLLPUBLIC Desktop final : private cppu::BaseMutex,
+ public Desktop_BASE,
+ public cppu::OPropertySetHelper
+{
+ // internal used types, const etcpp.
+ private:
+
+ /** used temporary to know which listener was already called or not. */
+ typedef ::std::vector< css::uno::Reference< css::frame::XTerminateListener > > TTerminateListenerList;
+
+ // public methods
+ public:
+
+ // constructor / destructor
+ Desktop( css::uno::Reference< css::uno::XComponentContext > xContext );
+ virtual ~Desktop( ) override;
+
+ void constructorInit();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XInterface
+ virtual void SAL_CALL acquire() noexcept override
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() noexcept override
+ { OWeakObject::release(); }
+ virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override;
+
+ // XTypeProvider
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
+
+ /**
+ @interface XDesktop
+
+ @short try to shutdown these desktop environment.
+
+ @descr Will try to close all frames. If at least one frame could
+ not be closed successfully termination will be stopped.
+
+ Registered termination listener will be taken into account
+ also. As special feature some of our registered listener
+ are well known by its UNO implementation name. They are handled
+ different to all other listener.
+
+ Btw: Desktop.terminate() was designed in the past to be used
+ within an UI based environment. So it's allowed e.g. to
+ call XController.suspend() here. If UI isn't an option ... please
+ use XCloseable.close() at these desktop implementation.
+ ... if it will be supported in the future .-))
+
+ @seealso XTerminateListener
+ @seealso XTerminateListener2
+
+ @return true if all open frames could be closed and no listener threw
+ a veto exception; false otherwise.
+
+ @onerror False will be returned.
+ @threadsafe yes
+ */
+ virtual sal_Bool SAL_CALL terminate() override;
+
+ /**
+ @interface XDesktop
+
+ @short add a listener for termination events
+
+ @descr Additional to adding normal listener these method was implemented special.
+ Every listener will be asked for its uno implementation name.
+ Some of them are well known... and the corresponding listener won't be added
+ to the container of "normal listener". Those listener will be set as special
+ member.
+ see e.g. member m_xSfxTerminator
+
+ @seealso terminate()
+
+ @param xListener
+ the listener for registration.
+
+ @threadsafe yes
+ */
+ virtual void SAL_CALL addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override;
+
+ /**
+ @interface XDesktop
+
+ @short remove a listener from this container.
+
+ @descr Additional to removing normal listener these method was implemented special.
+ Every listener will be asked for its uno implementation name.
+ Some of them are well known... and the corresponding listener was set as special member.
+ Now those special member will be reset also.
+ see e.g. member m_xSfxTerminator
+
+ @seealso terminate()
+
+ @param xListener
+ the listener for deregistration.
+
+ @threadsafe yes
+ */
+ virtual void SAL_CALL removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override;
+
+ virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getComponents ( ) override;
+ virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getCurrentComponent ( ) override;
+ virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getCurrentFrame ( ) override;
+
+ // XComponentLoader
+ virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponentFromURL ( const OUString& sURL ,
+ const OUString& sTargetFrameName ,
+ sal_Int32 nSearchFlags ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
+
+ // XTasksSupplier
+ virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTasks ( ) override;
+ virtual css::uno::Reference< css::frame::XTask > SAL_CALL getActiveTask ( ) override;
+
+ // XDispatchProvider
+ virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL ,
+ const OUString& sTargetFrameName ,
+ sal_Int32 nSearchFlags ) override;
+ virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches ( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) override;
+
+ // XDispatchProviderInterception
+ virtual void SAL_CALL registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override;
+ virtual void SAL_CALL releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override;
+
+ // XFramesSupplier
+ virtual css::uno::Reference< css::frame::XFrames > SAL_CALL getFrames ( ) override;
+ virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getActiveFrame ( ) override;
+ virtual void SAL_CALL setActiveFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame ) override;
+
+ // XFrame
+ // Attention: findFrame() is implemented only! Other methods make no sense for our desktop!
+ virtual css::uno::Reference< css::frame::XFrame > SAL_CALL findFrame ( const OUString& sTargetFrameName ,
+ sal_Int32 nSearchFlags ) override;
+ virtual void SAL_CALL initialize ( const css::uno::Reference< css::awt::XWindow >& xWindow ) override;
+ virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getContainerWindow ( ) override;
+ virtual void SAL_CALL setCreator ( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) override;
+ virtual css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL getCreator ( ) override;
+ virtual OUString SAL_CALL getName ( ) override;
+ virtual void SAL_CALL setName ( const OUString& sName ) override;
+ virtual sal_Bool SAL_CALL isTop ( ) override;
+ virtual void SAL_CALL activate ( ) override;
+ virtual void SAL_CALL deactivate ( ) override;
+ virtual sal_Bool SAL_CALL isActive ( ) override;
+ virtual sal_Bool SAL_CALL setComponent ( const css::uno::Reference< css::awt::XWindow >& xComponentWindow ,
+ const css::uno::Reference< css::frame::XController >& xController ) override;
+ virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getComponentWindow ( ) override;
+ virtual css::uno::Reference< css::frame::XController > SAL_CALL getController ( ) override;
+ virtual void SAL_CALL contextChanged ( ) override;
+ virtual void SAL_CALL addFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override;
+ virtual void SAL_CALL removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override;
+
+ // XComponent
+ virtual void SAL_CALL disposing() override;
+ virtual void SAL_CALL addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+
+ // XDispatchResultListener
+ virtual void SAL_CALL dispatchFinished ( const css::frame::DispatchResultEvent& aEvent ) override;
+
+ // XEventListener
+ virtual void SAL_CALL disposing ( const css::lang::EventObject& aSource ) override;
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle ( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) override;
+
+ // css.frame.XUntitledNumbers
+ virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
+
+ // css.frame.XUntitledNumbers
+ virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override;
+
+ // css.frame.XUntitledNumbers
+ virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
+
+ // css.frame.XUntitledNumbers
+ virtual OUString SAL_CALL getUntitledPrefix() override;
+
+ // we need this wrapped terminate()-call to terminate even the QuickStarter
+ // non-virtual and non-UNO for now
+ /// @throws css::uno::RuntimeException
+ bool terminateQuickstarterToo();
+
+ void shutdown();
+
+ private:
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue ,
+ css::uno::Any& aOldValue ,
+ sal_Int32 nHandle ,
+ const css::uno::Any& aValue ) override;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
+ const css::uno::Any& aValue ) override;
+ using cppu::OPropertySetHelper::getFastPropertyValue;
+ virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue ,
+ sal_Int32 nHandle ) const override;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( ) override;
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo ( ) override;
+
+ css::uno::Reference< css::lang::XComponent > impl_getFrameComponent ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const;
+
+ /** calls queryTermination() on every registered termination listener.
+ *
+ * Note: Only normal termination listener (registered in list m_aListenerContainer
+ * will be recognized here. Special listener like quick starter, pipe or others
+ * has to be handled explicitly !
+ *
+ * @param [out] lCalledListener
+ * every called listener will be returned here.
+ * Those list will be used to inform all called listener
+ * about cancel this termination request.
+ *
+ * @return true if no one vetoed the termination.
+ *
+ * @see impl_sendCancelTerminationEvent()
+ */
+ bool impl_sendQueryTerminationEvent(TTerminateListenerList& lCalledListener);
+
+ /** calls cancelTermination() on every termination listener
+ * where queryTermination() was called before.
+ *
+ * Note: Only normal termination listener (registered in list m_aListenerContainer
+ * will be recognized here. Special listener like quick starter, pipe or others
+ * has to be handled explicitly !
+ *
+ * @param [in] lCalledListener
+ * every listener in this list was called within its method
+ * queryTermination() before.
+ *
+ * @see impl_sendQueryTerminationEvent()
+ */
+ void impl_sendCancelTerminationEvent(const TTerminateListenerList& lCalledListener);
+
+ /** calls notifyTermination() on the clipboard listener
+ *
+ * The system clipboard may decide that it wants copies
+ * in several formats of the clipboard content requiring
+ * nearly all the services
+ *
+ */
+ void impl_sendTerminateToClipboard();
+
+ /** calls notifyTermination() on every registered termination listener.
+ *
+ * Note: Only normal termination listener (registered in list m_aListenerContainer
+ * will be recognized here. Special listener like quick starter, pipe or others
+ * has to be handled explicitly !
+ */
+ void impl_sendNotifyTerminationEvent();
+
+ /** try to close all open frames.
+ *
+ * Iterates over all child frames and try to close them.
+ * Given parameter bAllowUI enable/disable showing any UI
+ * (which mostly occur on calling XController->suspend()).
+ *
+ * This method doesn't stop if one frame could not be closed.
+ * It will ignore such frames and try all other ones.
+ * But it returns false in such case - true otherwise.
+ *
+ * @param bAllowUI
+ * enable/disable showing of UI.
+ *
+ * @return true if all frames could be closed; false otherwise.
+ */
+ bool impl_closeFrames(bool bAllowUI);
+
+ private:
+
+ mutable TransactionManager m_aTransactionManager;
+
+ /** check flag to protect against multiple terminate runs
+ */
+ bool m_bIsTerminated;
+
+ /** check flag to protect us against dispose before terminate!
+ * see dispose() for further information!
+ */
+ bool m_bIsShutdown;
+
+ /** when true, the call came from session manager
+ * the method is Desktop::terminateQuickstarterToo()
+ * this the only one place where set this to true
+ * In this case, when one frame break, not make
+ * question for other, the break of shutdown or logout
+ * can be only once.
+ * In Desktop::impl_closeFrames would be test and break
+ * the loop and reset to false
+ */
+ bool m_bSession;
+
+ css::uno::Reference< css::uno::XComponentContext > m_xContext; /// reference to factory, which has create this instance
+ FrameContainer m_aChildTaskContainer; /// array of child tasks (children of desktop are tasks; and tasks are also frames - But pure frames are not accepted!)
+ comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; /// container for ALL Listener
+ css::uno::Reference< css::frame::XFrames > m_xFramesHelper; /// helper for XFrames, XIndexAccess, XElementAccess and implementation of a childcontainer!
+ css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper; /// helper to dispatch something for new tasks, created by "_blank"!
+ ELoadState m_eLoadState; /// hold information about state of asynchron loading of component for loadComponentFromURL()!
+ bool m_bSuspendQuickstartVeto; /// don't ask quickstart for a veto
+ std::unique_ptr<SvtCommandOptions> m_xCommandOptions; /// ref counted class to support disabling commands defined by configuration file
+ OUString m_sName;
+ OUString m_sTitle;
+ css::uno::Reference< css::frame::XDispatchRecorderSupplier > m_xDispatchRecorderSupplier;
+
+ /** special terminate listener to close pipe and block external requests
+ * during/after termination process is/was running
+ */
+ css::uno::Reference< css::frame::XTerminateListener > m_xPipeTerminator;
+
+ /** special terminate listener shown inside system tray (quick starter)
+ * Will hinder the office on shutdown ... but wish to allow closing
+ * of open documents. And because that's different to a normal terminate listener
+ * it has to be handled special .-)
+ */
+ css::uno::Reference< css::frame::XTerminateListener > m_xQuickLauncher;
+
+ /** special terminate listener which loads images asynchronous for current open documents.
+ * Because internally it uses blocking system APIs... it can't be guaranteed that
+ * running jobs can be cancelled successfully if the corresponding document will be closed...
+ * it will not hinder those documents on closing. Instead it let all jobs running...
+ * but at least on terminate we have to wait for all those blocked requests.
+ * So these implementation must be a special terminate listener too .-(
+ */
+ css::uno::Reference< css::frame::XTerminateListener > m_xSWThreadManager;
+
+ /** special terminate listener shutting down the SfxApplication.
+ * Because these desktop instance closes documents and informs listener
+ * only... it does not really shutdown the whole application.
+ *
+ * Btw: that wouldn't be possible by design... because Desktop.terminate()
+ * has to return a boolean value about success... it can't really shutdown the
+ * process .-)
+ *
+ * So we uses a trick: a special listener (exactly these one here) listen for notifyTermination()
+ * and shutdown the process asynchronous. But desktop has to make this special
+ * notification as really last one ... Otherwise it can happen that asynchronous
+ * shutdown will be faster then all other code around Desktop.terminate() .-))
+ */
+ css::uno::Reference< css::frame::XTerminateListener > m_xSfxTerminator;
+
+ css::uno::Reference< css::frame::XUntitledNumbers > m_xTitleNumberGenerator;
+
+ std::vector<css::uno::Reference<css::frame::XTerminateListener>> m_xComponentDllListeners;
+
+}; // class Desktop
+
+FWK_DLLPUBLIC const rtl::Reference<Desktop> & getDesktop(
+ css::uno::Reference<css::uno::XComponentContext> const & context);
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/dispatchhelper.hxx b/include/framework/dispatchhelper.hxx
new file mode 100644
index 000000000..399d3f0ec
--- /dev/null
+++ b/include/framework/dispatchhelper.hxx
@@ -0,0 +1,111 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCHHELPER_HXX
+#define INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCHHELPER_HXX
+
+#include <config_options.h>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+#include <com/sun/star/frame/XDispatchResultListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <framework/fwkdllapi.h>
+#include <condition_variable>
+#include <mutex>
+
+namespace com::sun::star::lang
+{
+class XMultiServiceFactory;
+}
+namespace com::sun::star::lang
+{
+class XSingleServiceFactory;
+}
+namespace com::sun::star::uno
+{
+class XComponentContext;
+}
+
+namespace framework
+{
+/**
+ @short implements an easy way for dispatches
+ @descr Dispatches are split into different parts:
+ - parsing of the URL
+ - searching for a dispatch object
+ - dispatching of the URL
+ All these steps are done inside one method call here.
+*/
+class UNLESS_MERGELIBS(FWK_DLLPUBLIC) DispatchHelper final
+ : public ::cppu::WeakImplHelper<css::lang::XServiceInfo, css::frame::XDispatchHelper,
+ css::frame::XDispatchResultListener>
+{
+ std::mutex m_mutex;
+
+ /** global uno service manager.
+ Can be used to create own needed services. */
+ css::uno::Reference<css::uno::XComponentContext> m_xContext;
+
+ /** used to wait for asynchronous listener callbacks. */
+ std::condition_variable m_aBlock;
+ bool m_aBlockFlag;
+
+ css::uno::Any m_aResult;
+
+ css::uno::Reference<css::uno::XInterface> m_xBroadcaster;
+
+ // interface
+
+public:
+ // ctor/dtor
+
+ DispatchHelper(css::uno::Reference<css::uno::XComponentContext> xContext);
+ virtual ~DispatchHelper() override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XDispatchHelper
+ virtual css::uno::Any SAL_CALL
+ executeDispatch(const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider,
+ const OUString& sURL, const OUString& sTargetFrameName, sal_Int32 nSearchFlags,
+ const css::uno::Sequence<css::beans::PropertyValue>& lArguments) override;
+
+ // not a public XDispatchHelper-method, need in sfx2/source/control/statcach.cxx for extensions
+ /// @throws css::uno::RuntimeException
+ const css::uno::Any&
+ executeDispatch(const css::uno::Reference<css::frame::XDispatch>& xDispatch,
+ const css::util::URL& aURL, bool SyncronFlag,
+ const css::uno::Sequence<css::beans::PropertyValue>& lArguments);
+
+ // XDispatchResultListener
+ virtual void SAL_CALL dispatchFinished(const css::frame::DispatchResultEvent& aResult) override;
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+};
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/documentundoguard.hxx b/include/framework/documentundoguard.hxx
new file mode 100644
index 000000000..ec1a5951b
--- /dev/null
+++ b/include/framework/documentundoguard.hxx
@@ -0,0 +1,61 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_DOCUMENTUNDOGUARD_HXX
+#define INCLUDED_FRAMEWORK_DOCUMENTUNDOGUARD_HXX
+
+#include <framework/fwkdllapi.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <memory>
+
+namespace com::sun::star::uno { class XInterface; }
+
+namespace framework
+{
+ //= DocumentUndoGuard
+
+ struct DocumentUndoGuard_Data;
+ /** a helper class guarding the Undo manager of a document
+
+ This class guards, within a given scope, the Undo Manager of a document (or another component supporting
+ the XUndoManagerSupplier interface). When entering the scope (i.e. when the <code>DocumentUndoGuard</code>
+ instances is constructed), the current state of the undo contexts of the undo manager is examined.
+ Upon leaving the scope (i.e. when the <code>DocumentUndoGuard</code> is destructed), the guard will execute
+ as many calls to <member scope="css::document">XUndoManager::leaveUndoContext</member> as are
+ necessary to restore the manager's initial state.
+ */
+ class FWK_DLLPUBLIC DocumentUndoGuard
+ {
+ public:
+ DocumentUndoGuard( const css::uno::Reference< css::uno::XInterface >& i_undoSupplierComponent );
+ ~DocumentUndoGuard();
+
+ private:
+ std::unique_ptr< DocumentUndoGuard_Data > m_xData;
+ };
+
+
+} // namespace framework
+
+
+#endif // INCLUDED_FRAMEWORK_DOCUMENTUNDOGUARD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/framecontainer.hxx b/include/framework/framecontainer.hxx
new file mode 100644
index 000000000..1678a8670
--- /dev/null
+++ b/include/framework/framecontainer.hxx
@@ -0,0 +1,91 @@
+/* -*- 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 <sal/config.h>
+
+#include <vector>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <rtl/ustring.hxx>
+
+namespace framework{
+
+typedef ::std::vector< css::uno::Reference< css::frame::XFrame > > TFrameContainer;
+
+/*-************************************************************************************************************
+ @short implement a container to hold children of frame, task or desktop
+ @descr Every object of frame, task or desktop hold reference to its children. These container is used as helper
+ to do this. Some helper-classes like OFrames or OTasksAccess use it to. They hold a pointer to an instance
+ of this class, which is a member of a frame, task or desktop! You can append and remove frames.
+ It's possible to set one of these frames as active or deactivate. You could have full index-access to
+ container-items.
+
+ @devstatus ready to use
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+class FrameContainer final
+{
+
+ // member
+
+ private:
+
+ /// list to hold all frames
+ TFrameContainer m_aContainer;
+ /// one container item can be the current active frame. It's necessary for Desktop or Frame implementation.
+ css::uno::Reference< css::frame::XFrame > m_xActiveFrame;
+
+ // interface
+
+ public:
+
+ /// constructor / destructor
+ FrameContainer();
+ ~FrameContainer();
+
+ /// add/remove/mark container items
+ void append ( const css::uno::Reference< css::frame::XFrame >& xFrame );
+ void remove ( const css::uno::Reference< css::frame::XFrame >& xFrame );
+ void setActive ( const css::uno::Reference< css::frame::XFrame >& xFrame );
+ css::uno::Reference< css::frame::XFrame > getActive ( ) const;
+
+ /// checks and free memory
+ bool exist ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const;
+ void clear ( );
+
+ /// deprecated IndexAccess!
+ sal_uInt32 getCount ( ) const;
+ css::uno::Reference< css::frame::XFrame > operator[]( sal_uInt32 nIndex ) const;
+
+ /// replacement for deprecated index access
+ css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > getAllElements() const;
+
+ /// special helper for Frame::findFrame()
+ css::uno::Reference< css::frame::XFrame > searchOnAllChildrens ( const OUString& sName ) const;
+ css::uno::Reference< css::frame::XFrame > searchOnDirectChildrens( std::u16string_view sName ) const;
+
+}; // class FrameContainer
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/framelistanalyzer.hxx b/include/framework/framelistanalyzer.hxx
new file mode 100644
index 000000000..df47f90b2
--- /dev/null
+++ b/include/framework/framelistanalyzer.hxx
@@ -0,0 +1,204 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_FRAMELISTANALYZER_HXX
+#define INCLUDED_FRAMEWORK_FRAMELISTANALYZER_HXX
+
+#include <config_options.h>
+#include <framework/fwkdllapi.h>
+#include <o3tl/typed_flags_set.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <vector>
+
+namespace com::sun::star::frame { class XFrame; }
+namespace com::sun::star::frame { class XFramesSupplier; }
+
+/** These enums can be combined as flags to enable/disable
+ special search algorithm during analyze phase.
+ see impl_analyze() for further information.
+ But note: To be usable as flags, these enums
+ must be values of range [2^n]! */
+enum class FrameAnalyzerFlags
+{
+ Model = 1,
+ Help = 2,
+ BackingComponent = 4,
+ Hidden = 8,
+ All = 15,
+ Zombie = 32768 // use it for special test scenarios only!!!
+};
+namespace o3tl {
+ template<> struct typed_flags<FrameAnalyzerFlags> : is_typed_flags<FrameAnalyzerFlags, 32768+15> {};
+}
+
+
+namespace framework{
+
+/** analyze and split the current available frame list of a given frames supplier
+ into different parts.
+
+ These analyzed information can be used e.g. to decide if it's necessary
+ to switch into the backing mode, close the current active frame only or
+ exit the whole application explicitly or implicitly.
+ */
+class UNLESS_MERGELIBS(FWK_DLLPUBLIC) FrameListAnalyzer final
+{
+
+ // types
+
+ public:
+
+ // member
+
+ public:
+
+ /** provides access to the frame container, which should be analyzed. */
+ const css::uno::Reference< css::frame::XFramesSupplier >& m_xSupplier;
+
+ /** hold the reference frame, which is used e.g. to detect other frames with the same model. */
+ const css::uno::Reference< css::frame::XFrame >& m_xReferenceFrame;
+
+ /** enable/disable some special analyzing steps.
+ see impl_analyze() for further information. */
+ FrameAnalyzerFlags m_eDetectMode;
+
+ /** contains all frames, which uses the same model like the reference frame.
+ Will be filled only if m_eDetectMode has set the flag FrameAnalyzerFlags::Model.
+ The reference frame is never part of this list! */
+ std::vector< css::uno::Reference< css::frame::XFrame > > m_lModelFrames;
+
+ /** contains all frames, which does not contain the same model like the reference frame.
+ Filling of it can't be suppressed by m_eDetectMode.
+ The reference frame is never part of this list!
+ All frames inside this list are visible ones. */
+ std::vector< css::uno::Reference< css::frame::XFrame > > m_lOtherVisibleFrames;
+
+ /** contains all frames, which does not contain the same model like the reference frame.
+ Filling of it can't be suppressed by m_eDetectMode.
+ The reference frame is never part of this list!
+ All frames inside this list are hidden ones. */
+ std::vector< css::uno::Reference< css::frame::XFrame > > m_lOtherHiddenFrames;
+
+ /** points to the help frame.
+ Will be set only, if any other frame (means different from the reference frame)
+ contains the help component. If the reference frame itself includes the help module
+ it's not set ... but another member m_bIsHelp is used to safe this information.
+ See following example code:
+
+ <listing>
+ if (m_xReferenceFrame == help)
+ {
+ m_xHelp = NULL;
+ m_bIsHelp = sal_True;
+ }
+ else
+ if (xOtherFrame == help)
+ {
+ m_xHelp = xOtherFrame;
+ m_bIsHelp = sal_False;
+ }
+ </listing>
+
+ Analyzing of the help frame ignores the visible state of any frame.
+ But note: a hidden help frame indicates a wrong state!
+ */
+ css::uno::Reference< css::frame::XFrame > m_xHelp;
+
+ /** points to the frame, which contains the backing component.
+ Will be set only, if any other frame (means different from the reference frame)
+ contains the backing component. If the reference frame itself includes the
+ backing component it's not set ... but another member m_bIsBackingComponent
+ will used to safe this information.
+ See following example code:
+
+ <listing>
+ if (m_xReferenceFrame == backing)
+ {
+ m_xBackingComponent = NULL;
+ m_bIsBackingComponent = sal_True;
+ }
+ else
+ if (xOtherFrame == backing)
+ {
+ m_xBackingComponent = xOtherFrame;
+ m_bIsBackingComponent = sal_False ;
+ }
+ </listing>
+
+ Analyzing of the help frame ignores the visible state of any frame.
+ But note: a hidden backing mode frame indicates a wrong state!
+ */
+ css::uno::Reference< css::frame::XFrame > m_xBackingComponent;
+
+ /** is set to true only, if the reference frame is a hidden one.
+ This value is undefined if m_eDetectMode doesn't have set the flag FrameAnalyzerFlags::Hidden! */
+ bool m_bReferenceIsHidden;
+
+ /** is set to true only, if the reference frame contains the help component.
+ In this case the member m_xHelp is set to NULL every time.
+ This value is undefined if m_eDetectMode doesn't have set the flag FrameAnalyzerFlags::Help! */
+ bool m_bReferenceIsHelp;
+
+ /** is set to true only, if the reference frame contains the backing component.
+ In this case the member m_xBackingComponent is set to NULL every time.
+ This value is undefined if m_eDetectMode doesn't have set the flag FrameAnalyzerFlags::BackingComponent! */
+ bool m_bReferenceIsBacking;
+
+
+ // interface
+
+ public:
+
+ /** starts analyze phase and fill all members with valid information.
+
+ @param xSupplier
+ Must be a valid reference to a frames supplier, which provides
+ access to the frame list for analyzing.
+
+ @param xReferenceFrame
+ This frame must(!) exist inside the analyzed frame list and
+ is used for some comparing functions. Further some member states
+ depends from the current state of this frame.
+
+ @param eDetectMode
+ It represent a flag field, which can enable/disable special
+ analyze steps. Note: Some member values will be undefined, if
+ an analyze step will be disabled.
+ */
+ FrameListAnalyzer( const css::uno::Reference< css::frame::XFramesSupplier >& xSupplier ,
+ const css::uno::Reference< css::frame::XFrame >& xReferenceFrame ,
+ FrameAnalyzerFlags eDetectMode );
+ ~FrameListAnalyzer();
+
+
+ // helper
+
+ private:
+
+ void impl_analyze();
+
+
+}; // class FrameListAnalyzer
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_FRAMELISTANALYZER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/fwkdllapi.h b/include/framework/fwkdllapi.h
new file mode 100644
index 000000000..dc580c1bb
--- /dev/null
+++ b/include/framework/fwkdllapi.h
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <sal/config.h>
+
+#include <sal/types.h>
+
+#if defined FWK_DLLIMPLEMENTATION
+#define FWK_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define FWK_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/framework/gate.hxx b/include/framework/gate.hxx
new file mode 100644
index 000000000..ab9f81c24
--- /dev/null
+++ b/include/framework/gate.hxx
@@ -0,0 +1,146 @@
+/* -*- 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 <mutex>
+#include <osl/conditn.hxx>
+
+namespace framework{
+
+/*-************************************************************************************************************
+ @short implement a gate to block multiple threads at the same time or unblock all
+ @descr A gate can be used as a negative-condition! You can open a "door" - wait() will not block ...
+ or you can close it - wait() blocks till open() is called again.
+ Then all currently waiting threads are running immediately - but new ones are blocked!
+
+ @attention To prevent us against wrong using, the default ctor, copy ctor and the =operator are marked private!
+
+ @devstatus ready to use
+*//*-*************************************************************************************************************/
+class Gate
+{
+
+ // public methods
+
+ public:
+
+ /*-****************************************************************************************************
+ @short ctor
+ @descr These initialize the object right as an open gate.
+ *//*-*****************************************************************************************************/
+ Gate()
+ : m_bClosed ( false )
+ {
+ open();
+ }
+
+ /*-****************************************************************************************************
+ @short dtor
+ @descr Is user forget it - we open the gate ...
+ blocked threads can running ... but I don't know
+ if it's right - we are destroyed yet!?
+ *//*-*****************************************************************************************************/
+ ~Gate()
+ {
+ open();
+ }
+ /*-****************************************************************************************************
+ @short copy-ctor
+ @descr Forbid copy construction
+ *//*-*****************************************************************************************************/
+ Gate(const Gate&) = delete;
+ /*-****************************************************************************************************
+ @short copy-assignment
+ @descr Forbid copy assigning
+ *//*-*****************************************************************************************************/
+ Gate& operator=(const Gate&) = delete;
+
+ /*-****************************************************************************************************
+ @short open the gate
+ @descr A wait() call will not block then.
+
+ @seealso method close()
+ *//*-*****************************************************************************************************/
+ void open()
+ {
+ // We must safe access to our internal member!
+ std::unique_lock aLock( m_aAccessLock );
+ // Set condition -> wait don't block any longer -> gate is open
+ m_aPassage.set();
+ // Check if operation was successful!
+ // Check returns false if condition isn't set => m_bClosed will be true then => we must return false; opening failed
+ m_bClosed = !m_aPassage.check();
+ }
+
+ /*-****************************************************************************************************
+ @short close the gate
+ @descr A wait() call will block then.
+
+ @seealso method open()
+ *//*-*****************************************************************************************************/
+ void close()
+ {
+ // We must safe access to our internal member!
+ std::unique_lock aLock( m_aAccessLock );
+ // Reset condition -> wait blocks now -> gate is closed
+ m_aPassage.reset();
+ // Check if operation was successful!
+ // Check returns false if condition was reset => m_bClosed will be true then => we can return true; closing ok
+ m_bClosed = !m_aPassage.check();
+ }
+
+ /*-****************************************************************************************************
+ @short must be called to pass the gate
+ @descr If gate "open" => wait() will not block.
+ If gate "closed" => wait() will block till somewhere open it again.
+
+ @seealso method wait()
+ @seealso method open()
+
+ *//*-*****************************************************************************************************/
+ void wait()
+ {
+ // We must safe access to our internal member!
+ std::unique_lock aLock( m_aAccessLock );
+ // If gate not closed - caller can pass it.
+ if( m_bClosed )
+ {
+ // Then we must release used access lock -
+ // because next call will block...
+ // and if we hold the access lock nobody else can use this object without a deadlock!
+ aLock.unlock();
+ // Wait for opening gate...
+ m_aPassage.wait();
+ }
+ }
+
+ // private member
+
+ private:
+
+ std::mutex m_aAccessLock;
+ ::osl::Condition m_aPassage;
+ bool m_bClosed;
+
+}; // class Gate
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/generictoolbarcontroller.hxx b/include/framework/generictoolbarcontroller.hxx
new file mode 100644
index 000000000..e177ea5f0
--- /dev/null
+++ b/include/framework/generictoolbarcontroller.hxx
@@ -0,0 +1,73 @@
+/* -*- 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 <framework/fwkdllapi.h>
+#include <svtools/toolboxcontroller.hxx>
+#include <vcl/vclptr.hxx>
+
+class ToolBox;
+
+namespace framework
+{
+
+class FWK_DLLPUBLIC GenericToolbarController final : public svt::ToolboxController
+{
+ public:
+ GenericToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ ToolBox* pToolBar,
+ ToolBoxItemId nID,
+ const OUString& aCommand );
+ GenericToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ weld::Toolbar& rToolBar,
+ const OUString& aCommand );
+ virtual ~GenericToolbarController() override;
+
+ // XComponent
+ virtual void SAL_CALL dispose() override;
+
+ // XToolbarController
+ virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override;
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
+
+ DECL_DLLPRIVATE_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, void*, void );
+
+ struct ExecuteInfo
+ {
+ css::uno::Reference< css::frame::XDispatch > xDispatch;
+ css::util::URL aTargetURL;
+ css::uno::Sequence< css::beans::PropertyValue > aArgs;
+ };
+
+ private:
+ VclPtr<ToolBox> m_xToolbar;
+ ToolBoxItemId m_nID;
+ bool m_bEnumCommand : 1,
+ m_bMadeInvisible : 1;
+ OUString m_aEnumCommand;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/imutex.hxx b/include/framework/imutex.hxx
new file mode 100644
index 000000000..4b4668f8e
--- /dev/null
+++ b/include/framework/imutex.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_IMUTEX_HXX
+#define INCLUDED_FRAMEWORK_IMUTEX_HXX
+
+#include <sal/types.h>
+
+namespace framework{
+
+/// Interface to support different mutex implementations in a generic way.
+class SAL_NO_VTABLE IMutex
+{
+ public:
+ /// try to register thread
+ virtual void acquire() = 0;
+ /// unregister thread
+ virtual void release() = 0;
+
+ protected:
+ ~IMutex() {}
+};
+}
+
+#endif // INCLUDED_FRAMEWORK_IMUTEX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/interaction.hxx b/include/framework/interaction.hxx
new file mode 100644
index 000000000..4700d1920
--- /dev/null
+++ b/include/framework/interaction.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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_INTERACTION_HXX
+#define INCLUDED_FRAMEWORK_INTERACTION_HXX
+
+#include <config_options.h>
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <framework/fwkdllapi.h>
+
+namespace com::sun::star::task
+{
+class XInteractionContinuation;
+}
+namespace com::sun::star::task
+{
+class XInteractionRequest;
+}
+namespace com::sun::star::uno
+{
+template <class E> class Sequence;
+}
+
+namespace framework
+{
+/*-************************************************************************************************************
+ @short special request for interaction to ask user for right filter
+ @descr These helper can be used to ask user for right filter, if filter detection failed.
+ It capsulate communication with any interaction handler and supports an easy
+ access on interaction results for user of these class.
+ Use it and forget complex mechanism of interaction ...
+
+ @example RequestFilterSelect* pRequest = new RequestFilterSelect;
+ Reference< XInteractionRequest > xRequest ( pRequest );
+ xInteractionHandler->handle( xRequest );
+ if( ! pRequest.isAbort() )
+ {
+ OUString sFilter = pRequest->getFilter();
+ }
+
+ @implements XInteractionRequest
+
+ @devstatus ready to use
+ @threadsafe no (used on once position only!)
+*/ /*-*************************************************************************************************************/
+class RequestFilterSelect_Impl;
+class UNLESS_MERGELIBS(FWK_DLLPUBLIC) RequestFilterSelect
+{
+ rtl::Reference<RequestFilterSelect_Impl> mxImpl;
+
+public:
+ RequestFilterSelect(const OUString& sURL);
+ ~RequestFilterSelect();
+
+ RequestFilterSelect& operator=(RequestFilterSelect const&) = delete; // MSVC2019 workaround
+ RequestFilterSelect(RequestFilterSelect const&) = delete; // MSVC2019 workaround
+
+ bool isAbort() const;
+ OUString getFilter() const;
+ css::uno::Reference<css::task::XInteractionRequest> GetRequest() const;
+};
+
+/*-************************************************************************************************************
+ @short special request for interaction
+ @descr User must decide between a preselected and another detected filter.
+ It capsulate communication with any interaction handler and supports an easy
+ access on interaction results for user of these class.
+
+ @implements XInteractionRequest
+
+ @devstatus ready to use
+ @threadsafe no (used on once position only!)
+*/ /*-*************************************************************************************************************/
+class FWK_DLLPUBLIC InteractionRequest
+{
+public:
+ static css::uno::Reference<css::task::XInteractionRequest> CreateRequest(
+ const css::uno::Any& aRequest,
+ const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>>&
+ lContinuations);
+};
+
+} // namespace framework
+
+#endif // #define INCLUDED_FRAMEWORK_INTERACTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/sfxhelperfunctions.hxx b/include/framework/sfxhelperfunctions.hxx
new file mode 100644
index 000000000..36de22f54
--- /dev/null
+++ b/include/framework/sfxhelperfunctions.hxx
@@ -0,0 +1,107 @@
+/* -*- 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 <framework/fwkdllapi.h>
+#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
+#include <vcl/toolboxid.hxx>
+
+namespace com::sun::star::frame { class XFrame; class XToolbarController; }
+namespace com::sun::star::uno { template <typename > class Reference; }
+namespace svt { class StatusbarController; }
+namespace svt { class ToolboxController; }
+
+class StatusBar;
+class ToolBox;
+namespace weld {
+ class Toolbar;
+ class Builder;
+};
+
+typedef rtl::Reference<svt::ToolboxController> ( *pfunc_setToolBoxControllerCreator)(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ ToolBox* pToolbox,
+ ToolBoxItemId nID,
+ const OUString& aCommandURL );
+
+typedef css::uno::Reference<css::frame::XToolbarController> ( *pfunc_setWeldToolBoxControllerCreator)(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ weld::Toolbar* pToolbar,
+ weld::Builder* pBuilder,
+ const OUString& aCommandURL );
+
+typedef rtl::Reference<svt::StatusbarController> ( *pfunc_setStatusBarControllerCreator)(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ StatusBar* pStatusBar,
+ unsigned short nID,
+ const OUString& aCommandURL );
+
+typedef void ( *pfunc_getRefreshToolbars)(
+ css::uno::Reference< css::frame::XFrame > const & rFrame );
+
+typedef void ( *pfunc_createDockingWindow)(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ std::u16string_view rResourceURL );
+
+typedef bool ( *pfunc_isDockingWindowVisible)(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ std::u16string_view rResourceURL );
+
+
+namespace framework
+{
+FWK_DLLPUBLIC pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator );
+FWK_DLLPUBLIC rtl::Reference<svt::ToolboxController> CreateToolBoxController(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ ToolBox* pToolbox,
+ ToolBoxItemId nID,
+ const OUString& aCommandURL );
+
+FWK_DLLPUBLIC pfunc_setWeldToolBoxControllerCreator SetWeldToolBoxControllerCreator( pfunc_setWeldToolBoxControllerCreator pSetToolBoxControllerCreator );
+FWK_DLLPUBLIC css::uno::Reference<css::frame::XToolbarController> CreateWeldToolBoxController(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ weld::Toolbar* pToolbar,
+ weld::Builder* pBuilder,
+ const OUString& aCommandURL );
+
+FWK_DLLPUBLIC pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator );
+FWK_DLLPUBLIC rtl::Reference<svt::StatusbarController> CreateStatusBarController(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ StatusBar* pStatusBar,
+ unsigned short nID,
+ const OUString& aCommandURL );
+
+FWK_DLLPUBLIC pfunc_getRefreshToolbars SetRefreshToolbars( pfunc_getRefreshToolbars pRefreshToolbarsFunc );
+FWK_DLLPUBLIC void RefreshToolbars(
+ css::uno::Reference< css::frame::XFrame > const & rFrame );
+
+FWK_DLLPUBLIC pfunc_createDockingWindow SetDockingWindowCreator( pfunc_createDockingWindow pCreateDockingWindow );
+FWK_DLLPUBLIC void CreateDockingWindow(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ std::u16string_view rResourceURL );
+
+FWK_DLLPUBLIC pfunc_isDockingWindowVisible SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pIsDockingWindowVisible );
+FWK_DLLPUBLIC bool IsDockingWindowVisible(
+ const css::uno::Reference< css::frame::XFrame >& rFrame,
+ std::u16string_view rResourceURL );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/titlehelper.hxx b/include/framework/titlehelper.hxx
new file mode 100644
index 000000000..2b6e251d3
--- /dev/null
+++ b/include/framework/titlehelper.hxx
@@ -0,0 +1,181 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_TITLEHELPER_HXX
+#define INCLUDED_FRAMEWORK_TITLEHELPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
+#include <com/sun/star/frame/XFrameActionListener.hpp>
+#include <com/sun/star/document/XDocumentEventListener.hpp>
+
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/multicontainer2.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <framework/fwkdllapi.h>
+
+namespace com::sun::star::frame { class XController; }
+namespace com::sun::star::frame { class XFrame; }
+namespace com::sun::star::frame { class XModel3; }
+namespace com::sun::star::frame { class XUntitledNumbers; }
+namespace com::sun::star::uno { class XComponentContext; }
+namespace com::sun::star::uno { class XInterface; }
+
+
+namespace framework{
+
+
+/** @short can be used as implementation helper of interface css.frame.XTitle
+
+ @threadsafe
+ */
+class FWK_DLLPUBLIC TitleHelper final : private ::cppu::BaseMutex
+ , public ::cppu::WeakImplHelper< css::frame::XTitle ,
+ css::frame::XTitleChangeBroadcaster,
+ css::frame::XTitleChangeListener ,
+ css::frame::XFrameActionListener ,
+ css::document::XDocumentEventListener >
+{
+
+ // interface
+ public:
+
+
+ /** set an outside component which uses this container and must be set
+ as source of all broadcasted messages, exceptions.
+
+ It's holded weak only so we do not need any complex dispose sessions.
+
+ Note: Passing NULL as parameter will be allowed. It will reset the internal
+ member reference only.
+
+ @param xOwner
+ the new owner of this collection.
+ @param xNumbers
+ provides the right string and number for an untitled component.
+ */
+ TitleHelper(css::uno::Reference< css::uno::XComponentContext > xContext,
+ const css::uno::Reference< css::uno::XInterface >& xOwner,
+ const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers);
+
+ /** @short free all internally used resources.
+ */
+ virtual ~TitleHelper() override;
+
+
+ /** @see XTitle */
+ virtual OUString SAL_CALL getTitle() override;
+
+
+ /** @see XTitle */
+ virtual void SAL_CALL setTitle(const OUString& sTitle) override;
+
+
+ /** @see XTitleChangeBroadcaster */
+ virtual void SAL_CALL addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) override;
+
+
+ /** @see XTitleChangeBroadcaster */
+ virtual void SAL_CALL removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) override;
+
+
+ /** @see XTitleChangeListener */
+ virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent) override;
+
+
+ /** @see css.document.XDocumentEventListener */
+ virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& aEvent) override;
+
+
+ /** @see css.lang.XEventListener */
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+
+
+ /** @see css.frame.XFrameActionListener */
+ virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
+
+
+ // internal
+ private:
+
+ void impl_sendTitleChangedEvent ();
+
+ void impl_updateTitle (bool init = false);
+ void impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel3 >& xModel, bool init);
+ void impl_updateTitleForController (const css::uno::Reference< css::frame::XController >& xController, bool init);
+ void impl_updateTitleForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame, bool init);
+
+ void impl_startListeningForModel (const css::uno::Reference< css::frame::XModel >& xModel);
+ void impl_startListeningForController (const css::uno::Reference< css::frame::XController >& xController);
+ void impl_startListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame);
+ void impl_updateListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame);
+
+ void impl_appendComponentTitle ( OUStringBuffer& sTitle ,
+ const css::uno::Reference< css::uno::XInterface >& xComponent);
+ void impl_appendProductName (OUStringBuffer& sTitle);
+ void impl_appendModuleName (OUStringBuffer& sTitle);
+ void impl_appendDebugVersion (OUStringBuffer& sTitle);
+ void impl_appendSafeMode (OUStringBuffer& sTitle);
+
+ void impl_setSubTitle (const css::uno::Reference< css::frame::XTitle >& xSubTitle);
+
+ OUString impl_convertURL2Title(std::u16string_view sURL);
+
+
+ // member
+ private:
+
+ /** points to the global uno service manager. */
+ css::uno::Reference< css::uno::XComponentContext> m_xContext;
+
+ /** reference to the outside UNO class using this helper. */
+ css::uno::WeakReference< css::uno::XInterface > m_xOwner;
+
+ /** used to know how an "Untitled X" string can be created right :-) */
+ css::uno::WeakReference< css::frame::XUntitledNumbers > m_xUntitledNumbers;
+
+ /** provides parts of our own title and we listen there for changes too. */
+ css::uno::WeakReference< css::frame::XTitle > m_xSubTitle;
+
+ /** if it's set to sal_True the member m_sTitle has not to be changed internally.
+ It was set from outside and so outside code has to make sure it will be
+ updated.
+ */
+ bool m_bExternalTitle;
+
+ /** the actual title value */
+ OUString m_sTitle;
+
+ /** knows the leased number which must be used for untitled components. */
+ ::sal_Int32 m_nLeasedNumber;
+
+ /** contains all title change listener */
+ comphelper::OMultiTypeInterfaceContainerHelper2 m_aListener;
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_TITLEHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/transactionmanager.hxx b/include/framework/transactionmanager.hxx
new file mode 100644
index 000000000..fe011968c
--- /dev/null
+++ b/include/framework/transactionmanager.hxx
@@ -0,0 +1,123 @@
+/* -*- 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 <mutex>
+
+#include "gate.hxx"
+
+namespace framework{
+
+/*-************************************************************************************************************
+ @descr Describe different states of a feature of following implementation.
+ During lifetime of an object different working states occur:
+ initialization - working - closing - closed
+ If you wish to implement thread safe classes you should use this feature to protect
+ your code against calls at wrong time. e.g. you are not full initialized but somewhere
+ call an interface method (initialize phase means startup time from creating object till
+ calling specified first method e.g. XInitialization::initialize()!) then you should refuse
+ this call. The same for closing/disposing the object!
+*//*-*************************************************************************************************************/
+enum EWorkingMode
+{
+ E_INIT , // We stand in an init method -> some calls are accepted - some ones are rejected
+ E_WORK , // Object is ready for working -> all calls are accepted
+ E_BEFORECLOSE, // We stand in a close method -> some calls are accepted - some ones are rejected
+ E_CLOSE // Object is dead! -> all calls are rejected!
+};
+
+/*-************************************************************************************************************
+ @descr A transaction object should support throwing exceptions if user used it at wrong working mode.
+ e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE!
+ But sometimes he doesn't need this feature - will handle it by himself.
+ Then we must differ between some exception-modi:
+ E_HARDEXCEPTIONS We throw exceptions for all working modes different from E_WORK!
+ E_SOFTEXCEPTIONS We throw exceptions for all working modes different from E_WORK AND E_INCLOSE!
+ This mode is useful for impl-methods which should be callable from dispose() method!
+
+ e.g. void dispose()
+ {
+ m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );
+ ...
+ impl_setA( 0 );
+ ...
+ m_aTransactionManager.setWorkingMode( E_CLOSE );
+ }
+
+ void impl_setA( int nA )
+ {
+ ERejectReason EReason;
+ TransactionGuard aTransactionGuard( m_aTransactionManager, E_SOFTEXCEPTIONS, eReason );
+
+ m_nA = nA;
+ }
+
+ Normally (if E_HARDEXCEPTIONS was used!) creation of guard
+ will throw an exception ... but using of E_SOFTEXCEPTIONS suppress it
+ and member "A" can be set.
+*//*-*************************************************************************************************************/
+enum EExceptionMode
+{
+ E_HARDEXCEPTIONS,
+ E_SOFTEXCEPTIONS
+};
+
+/*-************************************************************************************************************
+ @short implement a transaction manager to support non breakable interface methods
+ @descr Use it to support non breakable interface methods without using any thread
+ synchronization like e.g. mutex, rw-lock!
+ That protect your code against wrong calls at wrong time ... e.g. calls after disposing an object!
+ Use combination of EExceptionMode and ERejectReason to detect rejected requests
+ and react for it. You can enable automatically throwing of exceptions too.
+
+ @devstatus draft
+*//*-*************************************************************************************************************/
+class TransactionManager
+{
+
+ // public methods
+
+ public:
+
+ TransactionManager ( );
+ ~TransactionManager ( );
+ TransactionManager(const TransactionManager&) = delete;
+ TransactionManager& operator=(const TransactionManager&) = delete;
+ void setWorkingMode ( EWorkingMode eMode );
+ EWorkingMode getWorkingMode ( ) const;
+ /// @throws css::uno::RuntimeException
+ /// @throws css::lang::DisposedException
+ void registerTransaction ( EExceptionMode eMode );
+ /// @throws css::uno::RuntimeException
+ /// @throws css::lang::DisposedException
+ void unregisterTransaction ( );
+
+ private:
+
+ mutable std::mutex m_aAccessLock; /// regulate access on internal member of this instance
+ Gate m_aBarrier; /// used to block transactions requests during change or work mode
+ EWorkingMode m_eWorkingMode; /// current working mode of object which use this manager (used to reject calls at wrong time)
+ sal_Int32 m_nTransactionCount; /// every transaction request is registered by this counter
+
+}; // class TransactionManager
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/undomanagerhelper.hxx b/include/framework/undomanagerhelper.hxx
new file mode 100644
index 000000000..eb9986919
--- /dev/null
+++ b/include/framework/undomanagerhelper.hxx
@@ -0,0 +1,162 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
+#define INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
+
+#include <framework/fwkdllapi.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <memory>
+
+namespace com::sun::star::document { class XUndoAction; }
+namespace com::sun::star::document { class XUndoManager; }
+namespace com::sun::star::document { class XUndoManagerListener; }
+namespace com::sun::star::util { class XModifyListener; }
+namespace framework { class IMutex; }
+
+class SfxUndoManager;
+
+
+namespace framework
+{
+
+
+ //= IMutexGuard
+
+ class SAL_NO_VTABLE IMutexGuard
+ {
+ public:
+ /** clears the lock. If the guard does not currently hold the lock, nothing happens.
+ */
+ virtual void clear() = 0;
+
+ /** returns the mutex guarded by the instance.
+
+ Even if the guard currently has not a lock on the mutex, this method must succeed.
+ */
+ virtual IMutex& getGuardedMutex() = 0;
+
+ protected:
+ ~IMutexGuard() {}
+ };
+
+
+ //= IUndoManagerImplementation
+
+ class SAL_NO_VTABLE IUndoManagerImplementation
+ {
+ public:
+ /** returns the SfxUndoManager interface to the actual Undo stack
+
+ @throws css::lang::DisposedException
+ when the instance is already disposed, and no SfxUndoManager can be provided
+
+ @throws css::lang::NotInitializedException
+ when the instance is not initialized, yet, and no SfxUndoManager can be provided
+ */
+ virtual SfxUndoManager& getImplUndoManager() = 0;
+
+ /** provides access to a UNO interface for the XUndoManager implementation. Used when throwing exceptions.
+ */
+ virtual css::uno::Reference< css::document::XUndoManager >
+ getThis() = 0;
+
+ protected:
+ ~IUndoManagerImplementation() {}
+ };
+
+
+ //= UndoManagerHelper
+
+ class UndoManagerHelper_Impl;
+ /** helper class for implementing an XUndoManager
+
+ Several of the methods of the class take an IMutexGuard instance. It is assumed that this guard has a lock on
+ its mutex at the moment the method is entered. The lock will be released before any notifications to the
+ registered XUndoManagerListeners happen.
+
+ The following locking strategy is used for this mutex:
+ <ul><li>Any notifications to the registered XUndoManagerListeners are after the guard has been cleared. i.e.
+ without the mutex being locked.</p>
+ <li>Any calls into the <code>SfxUndoManager</code> implementation is made without the mutex being locked.
+ Note that this implies that the <code>SfxUndoManager</code> implementation must be thread-safe in itself
+ (which is true for the default implementation, SfxUndoManager).</li>
+ <li>An exception to the previous item are the <member>SfxUndoManager::Undo</member> and
+ <member>SfxUndoManager::Redo</member> methods: They're called with the given external mutex being
+ locked.</li>
+ </ul>
+
+ The reason for the exception for SfxUndoManager::Undo and SfxUndoManager::Redo is that those are expected to
+ modify the actual document which the UndoManager works for. And as long as our documents are not thread-safe,
+ and as long as we do not re-fit <strong>all</strong> existing SfxUndoImplementations to <em>not</em> expect
+ the dreaded SolarMutex being locked when they're called, the above behavior is a compromise between "how it should
+ be" and "how it can realistically be".
+ */
+ class FWK_DLLPUBLIC UndoManagerHelper
+ {
+ public:
+ UndoManagerHelper( IUndoManagerImplementation& i_undoManagerImpl );
+ ~UndoManagerHelper();
+
+ // life time control
+ void disposing();
+
+ // XUndoManager equivalents
+ void enterUndoContext( const OUString& i_title, IMutexGuard& i_instanceLock );
+ void enterHiddenUndoContext( IMutexGuard& i_instanceLock );
+ void leaveUndoContext( IMutexGuard& i_instanceLock );
+ void addUndoAction( const css::uno::Reference< css::document::XUndoAction >& i_action, IMutexGuard& i_instanceLock );
+ void undo( IMutexGuard& i_instanceLock );
+ void redo( IMutexGuard& i_instanceLock );
+ bool isUndoPossible() const;
+ bool isRedoPossible() const;
+ OUString getCurrentUndoActionTitle() const;
+ OUString getCurrentRedoActionTitle() const;
+ css::uno::Sequence< OUString >
+ getAllUndoActionTitles() const;
+ css::uno::Sequence< OUString >
+ getAllRedoActionTitles() const;
+ void clear( IMutexGuard& i_instanceLock );
+ void clearRedo( IMutexGuard& i_instanceLock );
+ void reset( IMutexGuard& i_instanceLock );
+ void addUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener );
+ void removeUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener );
+
+ // XLockable, base of XUndoManager, equivalents
+ void lock();
+ void unlock();
+ bool isLocked();
+
+ // XModifyBroadcaster equivalents
+ void addModifyListener( const css::uno::Reference< css::util::XModifyListener >& i_listener );
+ void removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& i_listener );
+
+ private:
+ std::unique_ptr< UndoManagerHelper_Impl > m_xImpl;
+ };
+
+
+} // namespace framework
+
+
+#endif // INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */