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>
This commit is contained in:
Caolán McNamara 2024-12-08 20:19:57 +00:00
parent 045a98c9ee
commit e693261fbb
4 changed files with 39 additions and 0 deletions

View file

@ -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:

View file

@ -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: */

View file

@ -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) };

View file

@ -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) };