summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/inc/helper/persistentwindowstate.hxx4
-rw-r--r--framework/source/helper/persistentwindowstate.cxx25
-rw-r--r--framework/source/uielement/newmenucontroller.cxx5
-rw-r--r--framework/source/uielement/popuptoolbarcontroller.cxx5
4 files changed, 39 insertions, 0 deletions
diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx
index 8d062488fe83..3dc70985423f 100644
--- a/framework/inc/helper/persistentwindowstate.hxx
+++ b/framework/inc/helper/persistentwindowstate.hxx
@@ -84,6 +84,10 @@ class PersistentWindowState final : public ::cppu::WeakImplHelper<
// XEventListener
virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+ // Helper to explicitly save the state of rFrame's window to the config
+ static void SaveWindowStateToConfig(const css::uno::Reference<css::uno::XComponentContext>& rContext,
+ const css::uno::Reference<css::frame::XFrame>& rFrame);
+
// helper
private:
diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx
index 8e90defb0711..d7967d7457df 100644
--- a/framework/source/helper/persistentwindowstate.cxx
+++ b/framework/source/helper/persistentwindowstate.cxx
@@ -260,6 +260,31 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere
// <- SOLAR SAFE ------------------------
}
+//static
+void PersistentWindowState::SaveWindowStateToConfig(const css::uno::Reference<css::uno::XComponentContext>& rContext,
+ const css::uno::Reference<css::frame::XFrame>& rFrame)
+{
+ // We don't want to do this stuff when being used through LibreOfficeKit
+ if (comphelper::LibreOfficeKit::isActive())
+ return;
+
+ if (!rFrame.is())
+ return;
+
+ css::uno::Reference<css::awt::XWindow> xWindow = rFrame->getContainerWindow();
+ if (!xWindow.is())
+ return;
+
+ // unknown module -> no configuration available!
+ OUString sModuleName = PersistentWindowState::implst_identifyModule(rContext, rFrame);
+ if (sModuleName.isEmpty())
+ return;
+
+ OUString sWindowState = PersistentWindowState::implst_getWindowStateFromWindow(xWindow);
+ PersistentWindowState::implst_setWindowStateOnConfig(rContext, sModuleName, sWindowState);
+}
+
+
} // namespace framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 0aa152028a38..9f773ff869d7 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <comphelper/propertyvalue.hxx>
+#include <helper/persistentwindowstate.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
@@ -383,6 +384,10 @@ void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent
aTargetFrame = pAttributes->aTargetFrame;
}
+ // tdf#144407 save the current window state so a new window of the same type will
+ // open with the same settings
+ PersistentWindowState::SaveWindowStateToConfig(m_xContext, m_xFrame);
+
Sequence< PropertyValue > aArgsList{ comphelper::makePropertyValue(u"Referer"_ustr,
u"private:user"_ustr) };
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index 4fbbf6839b07..81424825b2c2 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -22,6 +22,7 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <helper/persistentwindowstate.hxx>
#include <menuconfiguration.hxx>
#include <svtools/imagemgr.hxx>
#include <svtools/toolboxcontroller.hxx>
@@ -704,6 +705,10 @@ void SAL_CALL NewToolbarController::execute( sal_Int16 /*KeyModifier*/ )
else
aURL = m_aCommandURL;
+ // tdf#144407 save the current window state so a new window of the same type will
+ // open with the same settings
+ PersistentWindowState::SaveWindowStateToConfig(m_xContext, m_xFrame);
+
css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
u"Referer"_ustr, u"private:user"_ustr) };