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& rContext, + const css::uno::Reference& 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& rContext, + const css::uno::Reference& 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 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 #include +#include #include #include #include @@ -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 #include #include +#include #include #include #include @@ -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) };