diff options
author | Aung <wildgugu2020@gmail.com> | 2025-05-12 01:29:55 +0700 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2025-09-24 06:44:43 +0200 |
commit | 8ce2cf3973ecd428eb8d0290930791ee1c771626 (patch) | |
tree | 9f0b878cb18c35bea69e3ce854c39b90a1cd0f76 | |
parent | 6f68c46d0aa5fe872de0dec8777d35ff91886043 (diff) |
tdf#41777 Add window size and position for each document
-Extend ViewDataSupplier to work with window state for supported
applications like sw, sc, sd
-Extend sm DocumentPropertySupplier to work with window state
-Add OldWindowState string member to SfxViewShell inherited
classes for sw, sc and sd
-Add OldWindowState string member to SmDocShell class for sm
Imported window state is stored in the model shells
or the ViewShells if available. This data is accessed by services
like ViewDataSupplier and DocumentPropertySupplier used by
persistentwindowstate.cxx. It is needed to store the window state
data since frame is not available to get to resize
and reposition by the time importing document has finished.
-Add windowstatehelper header and source files in the framework
module for getting/exporting the size and position of
windows. Also add associated file and library to make files for
exporting/using these helper methods across different modules.
-Modify impl_searchRecycleTarget method in loadenv.cxx
New frames are created for saved documents when launched from
the start center. This is to apply their own window state
separately from the backing window.
New docs and templates still recycle the backing window frame.
-Make the backing window close afterwards after the new frame has
been created and the document gets loaded successfully
(modified in loadenv.cxx)
Change-Id: Ia5ad606e744621f267dae6cd468b0c430b2ebf1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185189
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
24 files changed, 267 insertions, 8 deletions
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index cb893808900e..aa09b95bfd4d 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -125,6 +125,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ framework/source/fwe/helper/titlehelper \ framework/source/fwe/helper/documentundoguard \ framework/source/fwe/helper/undomanagerhelper \ + framework/source/fwe/helper/windowstatehelper \ framework/source/fwe/xml/menuconfiguration \ framework/source/fwe/xml/menudocumenthandler \ framework/source/fwe/xml/saxnamespacefilter \ diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx index 3dc70985423f..a84a74a104eb 100644 --- a/framework/inc/helper/persistentwindowstate.hxx +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> @@ -163,6 +164,13 @@ class PersistentWindowState final : public ::cppu::WeakImplHelper< static void implst_setWindowStateOnWindow(const css::uno::Reference< css::awt::XWindow >& xWindow , std::u16string_view sWindowState); + /** @short retrieve the window state from the model if exported. + + @return [string] + contains the information about position and size. + */ + static OUString implst_getWindowStateFromModel(const css::uno::Reference<css::frame::XModel>& xModel); + }; // class PersistentWindowState } // namespace framework diff --git a/framework/source/fwe/helper/windowstatehelper.cxx b/framework/source/fwe/helper/windowstatehelper.cxx new file mode 100644 index 000000000000..2d110a69612e --- /dev/null +++ b/framework/source/fwe/helper/windowstatehelper.cxx @@ -0,0 +1,82 @@ +/* -*- 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/. + * + * 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 . + */ + +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <framework/windowstatehelper.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/syswin.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/window.hxx> + +namespace framework +{ +// for use from SfxViewShell inherited classes +OUString WindowStateHelper::GetFromWindow(vcl::Window* pWin) +{ + // SOLAR SAFE -> ------------------------ + SolarMutexGuard aSolarGuard; + + // getting to system window here is necessary + while (pWin && !pWin->IsSystemWindow()) + { + pWin = pWin->GetParent(); + } + if (pWin) + { + vcl::WindowDataMask const nMask + = vcl::WindowDataMask::All & ~vcl::WindowDataMask::Minimized; + return static_cast<SystemWindow*>(pWin)->GetWindowState(nMask); + } + + return {}; + // <- SOLAR SAFE ------------------------ +} + +// for use from application exports +OUString WindowStateHelper::GetFromModel(const css::uno::Reference<css::frame::XModel>& xModel) +{ + if (!xModel) + return {}; + + auto xController = xModel->getCurrentController(); + if (!xController) + return {}; + + auto xFrame = xController->getFrame(); + if (!xFrame) + return {}; + + if (auto xWindow = xFrame->getContainerWindow()) + { + // SOLAR SAFE FOR VCL HELPER -> ------------------------ + SolarMutexGuard aSolarGuard; + return WindowStateHelper::GetFromWindow(VCLUnoHelper::GetWindow(xWindow)); + // <- SOLAR SAFE ------------------------ + } + + return {}; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index d7967d7457df..5d7c1d6014dc 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -22,6 +22,10 @@ #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/frame/ModuleManager.hpp> +#include <com/sun/star/document/XViewDataSupplier.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <comphelper/lok.hxx> #include <comphelper/configurationhelper.hxx> @@ -101,13 +105,19 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv if (sModuleName.isEmpty()) return; + css::uno::Reference<css::frame::XModel> xModel; + if (auto xController = xFrame->getController()) + xModel = xController->getModel(); + switch(aEvent.Action) { case css::frame::FrameAction_COMPONENT_ATTACHED : { if (bRestoreWindowState) { - OUString sWindowState = PersistentWindowState::implst_getWindowStateFromConfig(xContext, sModuleName); + OUString sWindowState = PersistentWindowState::implst_getWindowStateFromModel(xModel); + if (sWindowState.isEmpty()) + sWindowState = PersistentWindowState::implst_getWindowStateFromConfig(xContext, sModuleName); PersistentWindowState::implst_setWindowStateOnWindow(xWindow,sWindowState); SolarMutexGuard g; m_bWindowStateAlreadySet = true; @@ -284,6 +294,50 @@ void PersistentWindowState::SaveWindowStateToConfig(const css::uno::Reference<cs PersistentWindowState::implst_setWindowStateOnConfig(rContext, sModuleName, sWindowState); } +OUString PersistentWindowState::implst_getWindowStateFromModel(const css::uno::Reference<css::frame::XModel>& xModel) +{ + if (!xModel) + return {}; + + OUString sWindowState; + + if (auto xViewDataSupplier = xModel.query<css::document::XViewDataSupplier>()) + { + css::uno::Reference<css::container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData()); + if (xIndexAccess && xIndexAccess->getCount() > 0) + { + css::uno::Sequence<css::beans::PropertyValue> aSeq; + if (xIndexAccess->getByIndex(0) >>= aSeq) + { + for (const auto& rProp : aSeq) + { + OUString sName(rProp.Name); + if (sName == "WindowState") + { + rProp.Value >>= sWindowState; + if (!sWindowState.isEmpty()) + { + return sWindowState; + } + } + } + } + } + } + // no view supplier or empty window state + if (auto xProps = xModel.query<css::beans::XPropertySet>()) + { + if (auto xInfo = xProps->getPropertySetInfo(); + xInfo && xInfo->hasPropertyByName(u"WindowState"_ustr)) + { + css::uno::Any any = xProps->getPropertyValue(u"WindowState"_ustr); + any >>= sWindowState; + } + } + + return sWindowState; +} + } // namespace framework diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index db81c5ce4f3a..36c26f961194 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -22,6 +22,7 @@ #include <loadenv/loadenvexception.hxx> #include <loadenv/targethelper.hxx> #include <framework/framelistanalyzer.hxx> +#include <pattern/frame.hxx> #include <interaction/quietinteraction.hxx> #include <properties.h> @@ -1466,12 +1467,24 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget() css::uno::Reference< css::frame::XFramesSupplier > xSupplier = css::frame::Desktop::create( m_xContext ); FrameListAnalyzer aTasksAnalyzer(xSupplier, css::uno::Reference< css::frame::XFrame >(), FrameAnalyzerFlags::BackingComponent); + if (aTasksAnalyzer.m_xBackingComponent.is()) { - if (!impl_isFrameAlreadyUsedForLoading(aTasksAnalyzer.m_xBackingComponent)) + // new docs should recycle the backing window + if (ProtocolCheck::isProtocol(m_aURL.Complete, EProtocol::PrivateFactory) + || m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE, + false)) + { + if (!impl_isFrameAlreadyUsedForLoading(aTasksAnalyzer.m_xBackingComponent)) + { + m_bReactivateControllerOnError = true; + return aTasksAnalyzer.m_xBackingComponent; + } + } + // for docs with saved window state, let's create a new frame for their own size/pos + else { - m_bReactivateControllerOnError = true; - return aTasksAnalyzer.m_xBackingComponent; + return {}; } } @@ -1634,6 +1647,13 @@ void LoadEnv::impl_reactForLoadingState() if (TargetHelper::isValidNameForFrame(sFrameName)) m_xTargetFrame->setName(sFrameName); } + // if a new frame is created without reusing backing window, close the backing window afterwards + FrameListAnalyzer aTasksAnalyzer(css::frame::Desktop::create(m_xContext), m_xTargetFrame, + FrameAnalyzerFlags::BackingComponent); + if (aTasksAnalyzer.m_xBackingComponent.is()) + { + framework::pattern::frame::closeIt(aTasksAnalyzer.m_xBackingComponent); + } } else if (m_bReactivateControllerOnError) { diff --git a/include/framework/windowstatehelper.hxx b/include/framework/windowstatehelper.hxx new file mode 100644 index 000000000000..86c1feee864a --- /dev/null +++ b/include/framework/windowstatehelper.hxx @@ -0,0 +1,37 @@ +/* -*- 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/. + * + * 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 <com/sun/star/frame/XModel.hpp> + +#include <framework/fwkdllapi.h> +#include <vcl/window.hxx> + +namespace framework::WindowStateHelper +{ +// for use from SfxViewShell inherited classes +FWK_DLLPUBLIC OUString GetFromWindow(vcl::Window* pWindow); +// for use from application exports +FWK_DLLPUBLIC OUString GetFromModel(const css::uno::Reference<css::frame::XModel>& xModel); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index efe89a34bd08..b716acae1068 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -77,6 +77,7 @@ $(eval $(call gb_Library_use_libraries,sc,\ editeng \ for \ forui \ + fwk \ i18nlangtag \ i18nutil \ $(call gb_Helper_optional,OPENCL, \ diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx b/sc/inc/ViewSettingsSequenceDefines.hxx index 42bdac0e2df2..95ce98278322 100644 --- a/sc/inc/ViewSettingsSequenceDefines.hxx +++ b/sc/inc/ViewSettingsSequenceDefines.hxx @@ -24,7 +24,7 @@ // this are the defines for the position of the settings in the // ViewSettingsSequence -#define SC_VIEWSETTINGS_COUNT 27 +#define SC_VIEWSETTINGS_COUNT 28 #define SC_VIEW_ID 0 #define SC_TABLE_VIEWSETTINGS 1 @@ -53,6 +53,7 @@ #define SC_RASTERSUBY 24 #define SC_RASTERSYNC 25 #define SC_FORMULA_BAR_HEIGHT 26 +#define SC_WINDOW_STATE 27 // this are the defines for the position of the settings in the // TableViewSettingsSequence @@ -102,4 +103,6 @@ inline constexpr OUString SC_FORMULABARHEIGHT = u"FormulaBarHeight"_ustr; inline constexpr OUString SC_VIEWID = u"ViewId"_ustr; #define SC_VIEW "view" +inline constexpr OUString SC_WINDOWSTATE = u"WindowState"_ustr; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 86021bf92bf0..e6e5c1b56559 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -271,6 +271,7 @@ class ScViewData { private: double nPPTX, nPPTY; // Scaling factors + OUString msOldWindowState; // imported window size ::std::vector<std::unique_ptr<ScViewDataTable>> maTabData; ScDocShell& mrDocShell; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 4ff40391ca6e..4185f2e96b17 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -19,6 +19,7 @@ #include <scitems.hxx> #include <editeng/eeitem.hxx> +#include <framework/windowstatehelper.hxx> #include <o3tl/safeint.hxx> #include <o3tl/unit_conversion.hxx> #include <o3tl/string_view.hxx> @@ -825,8 +826,8 @@ ScViewData::ScViewData(ScDocShell& rDocSh, ScTabViewShell* pViewSh) : { ++mnTabNumber; maTabData.emplace_back(nullptr); + maTabData[mnTabNumber].reset( new ScViewDataTable(mrDoc) ); } - maTabData[mnTabNumber].reset( new ScViewDataTable(mrDoc) ); pThisTab = maTabData[mnTabNumber].get(); } @@ -3844,6 +3845,8 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDivisionY()); pSettings[SC_RASTERSYNC].Name = SC_UNO_RASTERSYNC; pSettings[SC_RASTERSYNC].Value <<= aGridOpt.GetSynchronize(); + pSettings[SC_WINDOW_STATE].Name = SC_WINDOWSTATE; + pSettings[SC_WINDOW_STATE].Value <<= ::framework::WindowStateHelper::GetFromWindow( pView->GetWindow() ); // Common SdrModel processing GetDocument().GetDrawLayer()->WriteUserDataSequence(rSettings); @@ -3994,6 +3997,10 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue> } else if ( sName == SC_UNO_VALUEHIGH && !comphelper::LibreOfficeKit::isActive() ) maOptions.SetOption(sc::ViewOption::SYNTAX, ScUnoHelpFunctions::GetBoolFromAny(rSetting.Value)); + else if (sName == SC_WINDOWSTATE) + { + rSetting.Value >>= msOldWindowState; + } else { ScGridOptions aGridOpt(maOptions.GetGridOptions()); diff --git a/sc/ucalc_setup.mk b/sc/ucalc_setup.mk index 4a4918d0dcf6..41fd99e49ff0 100644 --- a/sc/ucalc_setup.mk +++ b/sc/ucalc_setup.mk @@ -52,6 +52,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc$(1), \ editeng \ for \ forui \ + fwk \ i18nlangtag \ i18nutil \ $(call gb_Helper_optional,OPENCL, \ diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk index 4577e4b4ee4c..538f28623a37 100644 --- a/sd/CppunitTest_sd_uimpress.mk +++ b/sd/CppunitTest_sd_uimpress.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\ drawinglayer \ drawinglayercore \ editeng \ + fwk \ i18nlangtag \ i18nutil \ icg \ diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 2244355494e5..78797e73bd69 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Library_use_libraries,sd,\ drawinglayercore \ drawinglayer \ editeng \ + fwk \ i18nlangtag \ i18nutil \ icg \ diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index ae0ff4af609f..579728bbfc21 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -549,6 +549,8 @@ protected: void doShow(); private: + OUString msOldWindowState; // imported window state + VclPtr<vcl::Window> mpParentWindow; /** This window updater is used to keep all relevant windows up to date with reference to the digit language used to display digits in text diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 0017fa3eca60..c02e8f16f9d0 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -56,6 +56,7 @@ #include <Window.hxx> +#include <framework/windowstatehelper.hxx> #include <sfx2/viewfrm.hxx> #include <svtools/soerr.hxx> #include <svx/charthelper.hxx> @@ -943,7 +944,7 @@ sal_Int8 ViewShell::ExecuteDrop ( void ViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rSequence ) { const sal_Int32 nIndex = rSequence.getLength(); - rSequence.realloc( nIndex + 1 ); + rSequence.realloc( nIndex + 2 ); auto pSequence = rSequence.getArray(); OSL_ASSERT (GetViewShell()!=nullptr); @@ -956,11 +957,19 @@ void ViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::Propert pSequence[nIndex].Name = sUNO_View_ViewId; pSequence[nIndex].Value <<= "view" + OUString::number( static_cast<sal_uInt16>(nViewID)); + pSequence[nIndex].Name = u"WindowState"_ustr; + pSequence[nIndex].Value <<= ::framework::WindowStateHelper::GetFromWindow(GetViewShellBase().GetWindow()); + mpFrameView->WriteUserDataSequence( rSequence ); } void ViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence ) { + for (const css::beans::PropertyValue& rValue : rSequence) + { + if (rValue.Name == "WindowState") + rValue.Value >>= msOldWindowState; + } mpFrameView->ReadUserDataSequence( rSequence ); } diff --git a/starmath/CppunitTest_starmath_qa_cppunit.mk b/starmath/CppunitTest_starmath_qa_cppunit.mk index 87ebe58083dd..b79aa71a0e0e 100644 --- a/starmath/CppunitTest_starmath_qa_cppunit.mk +++ b/starmath/CppunitTest_starmath_qa_cppunit.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,starmath_qa_cppunit,\ cppu \ cppuhelper \ editeng \ + fwk \ i18nlangtag \ i18nutil \ msfilter \ diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index 9791ffdd5b97..57a19e1bcf4f 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -44,6 +44,7 @@ $(eval $(call gb_Library_use_libraries,sm,\ cppu \ cppuhelper \ editeng \ + fwk \ i18nutil \ i18nlangtag \ msfilter \ diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx index cdb916bccffc..e2edbfa651a3 100644 --- a/starmath/inc/unomodel.hxx +++ b/starmath/inc/unomodel.hxx @@ -93,6 +93,7 @@ public: virtual Size getFormulaSize() const override; private: + OUString msOldWindowState; // imported window state SmDocShell* GetSmDocShell() const; }; diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 95d141f7060b..1f219d49b3e7 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/uno/Any.h> #include <officecfg/Office/Common.hxx> +#include <framework/windowstatehelper.hxx> #include <rtl/math.hxx> #include <sfx2/frame.hxx> #include <sfx2/docfile.hxx> @@ -514,6 +515,10 @@ void SmXMLExport::GetConfigurationSettings(Sequence<PropertyValue>& rProps) if (!xProps.is()) return; + // update window state value + OUString sWindowState = ::framework::WindowStateHelper::GetFromModel(GetModel()); + xProps->setPropertyValue(u"WindowState"_ustr, css::uno::Any(sWindowState)); + Reference<XPropertySetInfo> xPropertySetInfo = xProps->getPropertySetInfo(); if (!xPropertySetInfo.is()) return; diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 14e39542f432..49a794bb6ecd 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -226,7 +226,8 @@ enum SmModelPropertyHandles HANDLE_DIALOG_LIBRARIES, // #i73329# HANDLE_BASELINE, HANDLE_INTEROP_GRAB_BAG, - HANDLE_STARMATH_VERSION + HANDLE_STARMATH_VERSION, + HANDLE_WINDOWSTATE }; } @@ -309,6 +310,7 @@ static const rtl::Reference<PropertySetInfo> & lcl_createModelPropertyInfo () { u"BaseLine"_ustr , HANDLE_BASELINE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 }, { u"InteropGrabBag"_ustr , HANDLE_INTEROP_GRAB_BAG , cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), PROPERTY_NONE, 0 }, { u"SyntaxVersion"_ustr , HANDLE_STARMATH_VERSION , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 }, + { u"WindowState"_ustr , HANDLE_WINDOWSTATE , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, }; static const rtl::Reference<PropertySetInfo> PROPS_INFO = new PropertySetInfo ( aModelPropertyInfoMap ); return PROPS_INFO; @@ -664,6 +666,11 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* case HANDLE_STARMATH_VERSION: pDocSh->SetSmSyntaxVersion(pValues->get<sal_Int16>()); break; + case HANDLE_WINDOWSTATE: + { + *pValues >>= msOldWindowState; + } + break; } } @@ -931,6 +938,10 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu case HANDLE_STARMATH_VERSION: *pValue <<= pDocSh->GetSmSyntaxVersion(); break; + case HANDLE_WINDOWSTATE: + { + *pValue <<= msOldWindowState; + } } } } diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk index b2e7526b722e..325fe3412bcf 100644 --- a/sw/CppunitTest_sw_uwriter.mk +++ b/sw/CppunitTest_sw_uwriter.mk @@ -39,6 +39,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \ drawinglayer \ drawinglayercore \ editeng \ + fwk \ i18nlangtag \ i18nutil \ lng \ diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 606d85d51114..f887b4fa24e9 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -62,6 +62,7 @@ $(eval $(call gb_Library_use_libraries,sw,\ drawinglayercore \ drawinglayer \ editeng \ + fwk \ i18nlangtag \ i18nutil \ lng \ diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 843536a5026d..d20b0ed85866 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -186,6 +186,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell sal_uInt16 m_nOldPageNum; UIName m_sOldSectionName; + OUString m_sOldWindowState; // imported window state + Point m_aTabColFromDocPos; // moving table columns out of the document SwTextNode * m_pNumRuleNodeFromDoc; // Moving indent of numrule #i23726# diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 856e12a29f53..279de499c6c8 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -109,6 +109,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/servicehelper.hxx> +#include <framework/windowstatehelper.hxx> #include <sfx2/lokhelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <svtools/embedhlp.hxx> @@ -1508,6 +1509,10 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue > rValue.Value >>= bKeepRatio; bGotKeepRatio = true; } + else if (rValue.Name == "WindowState") + { + rValue.Value >>= m_sOldWindowState; + } // Fallback to common SdrModel processing else GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(&rValue); @@ -1688,6 +1693,9 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe aVector.push_back( comphelper::makePropertyValue(u"KeepRatio"_ustr, m_pWrtShell->GetViewOptions()->IsKeepRatio())); + // get the current window state for export + aVector.push_back(comphelper::makePropertyValue(u"WindowState"_ustr, ::framework::WindowStateHelper::GetFromWindow(GetWindow()))); + rSequence = comphelper::containerToSequence(aVector); // Common SdrModel processing |