summaryrefslogtreecommitdiff
path: root/framework/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-08 20:19:57 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-08 22:07:01 +0100
commite693261fbb96acb52567bd1e36228e93c4622630 (patch)
treedb775fd93f07b0cc5e5dbbc318dde00ea5564be0 /framework/source
parent045a98c9ee0a0b9f1366064f3e57bdce977cb056 (diff)
tdf#144407 save the current window state on new document
so a new window of the same type will open with the same settings Change-Id: I7ee4b476d207d1dbd538ce6c054d83f7281f0309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178119 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'framework/source')
-rw-r--r--framework/source/helper/persistentwindowstate.cxx25
-rw-r--r--framework/source/uielement/newmenucontroller.cxx5
-rw-r--r--framework/source/uielement/popuptoolbarcontroller.cxx5
3 files changed, 35 insertions, 0 deletions
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) };