desktop/source/lib/init.cxx | 3 +-- include/sfx2/lokhelper.hxx | 2 -- sc/source/ui/unoobj/docuno.cxx | 16 ++++++++++++++++ sd/source/ui/unoidl/unomodel.cxx | 16 ++++++++++++++++ sfx2/source/view/frmload.cxx | 30 ------------------------------ sfx2/source/view/lokhelper.cxx | 15 --------------- sw/source/uibase/uno/unotxdoc.cxx | 15 +++++++++++++++ 7 files changed, 48 insertions(+), 49 deletions(-)
New commits: commit a0a4309c718143a60ac8702fa6f15c1b7c6c2788 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Apr 2 11:16:43 2024 +0100 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Apr 19 15:46:10 2024 +0200 support possibility to set Theme early during initializeForTiledRendering so we are already in the desired theme from the start Change-Id: Ibaaf647612a0a61ce74fa4e4272d7084868a6ea3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163650 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> (cherry picked from commit e2ca1c82dbce30d625d33c0bd8c3c080294f93b8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165672 Reviewed-by: Henry Castro <hcas...@collabora.com> Tested-by: Henry Castro <hcas...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a81b0410d81e..e602d2725b6d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2784,8 +2784,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, comphelper::makePropertyValue("InteractionHandler", xInteraction), comphelper::makePropertyValue("MacroExecutionMode", nMacroExecMode), comphelper::makePropertyValue("AsTemplate", false), - comphelper::makePropertyValue("Silent", !aBatch.isEmpty()), - comphelper::makePropertyValue("Theme", extractParameter(aOptions, u"Theme")) + comphelper::makePropertyValue("Silent", !aBatch.isEmpty()) }; /* TODO diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 35ed5109f5c0..e8904d013f75 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -131,8 +131,6 @@ public: static LOKDeviceFormFactor getDeviceFormFactor(); /// Set the device form factor that should be used for a new view. static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor); - /// Get the document type - static OUString getDocumentType(const OUString& sDocumentService); /// Set timezone of the given view. /// @isSet true to use @rTimezone, even if it's empty. Otherwise, no timezone. diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 1520b183beb9..8e67eab09413 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -21,6 +21,8 @@ #include <scitems.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <editeng/brushitem.hxx> @@ -1311,6 +1313,8 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans aAppOptions.SetAutoComplete(true); SC_MOD()->SetAppOptions(aAppOptions); + OUString sThemeName; + for (const beans::PropertyValue& rValue : rArguments) { if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>()) @@ -1319,6 +1323,8 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans options.SetAutoSpell(rValue.Value.get<bool>()); GetDocument()->SetDocOptions(options); } + else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) + sThemeName = rValue.Value.get<OUString>(); } // show us the text exactly @@ -1335,6 +1341,16 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans auto xChanges = comphelper::ConfigurationChanges::create(); officecfg::Office::Common::Save::Document::WarnAlienFormat::set(false, xChanges); xChanges->commit(); + + // if we know what theme the user wants, then we can dispatch that now early + if (!sThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sThemeName) } + })); + comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); + } } uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index c9b69575ff49..5d535707eed3 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -33,8 +33,10 @@ #include <com/sun/star/embed/Aspects.hpp> #include <officecfg/Office/Common.hxx> +#include <comphelper/dispatchcommand.hxx> #include <comphelper/indexedpropertyvalues.hxx> #include <comphelper/lok.hxx> +#include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <comphelper/servicehelper.hxx> @@ -2578,6 +2580,8 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs { SolarMutexGuard aGuard; + OUString sThemeName; + if (DrawViewShell* pViewShell = GetViewShell()) { DrawView* pDrawView = pViewShell->GetDrawView(); @@ -2589,6 +2593,8 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs pDrawView->SetAuthor(rValue.Value.get<OUString>()); else if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>()) mpDoc->SetOnlineSpell(rValue.Value.get<bool>()); + else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) + sThemeName = rValue.Value.get<OUString>(); } // Disable comments if requested @@ -2630,6 +2636,16 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs if (!getenv("LO_TESTNAME")) SvtSlideSorterBarOptions().SetVisibleImpressView(true); + + // if we know what theme the user wants, then we can dispatch that now early + if (!sThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sThemeName) } + })); + comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); + } } void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode) diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index e4acd00ffa37..f03b08fe5886 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -26,7 +26,6 @@ #include <sfx2/doctempl.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/frame.hxx> -#include <sfx2/lokhelper.hxx> #include <sfx2/objsh.hxx> #include <sfx2/request.hxx> #include <sfx2/sfxsids.hrc> @@ -49,7 +48,6 @@ #include <com/sun/star/util/XCloseable.hpp> #include <comphelper/interaction.hxx> -#include <comphelper/lok.hxx> #include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase.hxx> @@ -59,7 +57,6 @@ #include <sal/log.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> -#include <svtools/colorcfg.hxx> #include <unotools/fcm.hxx> #include <unotools/moduleoptions.hxx> #include <comphelper/diagnose_ex.hxx> @@ -711,7 +708,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA const OUString sServiceName = aDescriptor.getOrDefault( "DocumentService", OUString() ); xModel.set( m_aContext->getServiceManager()->createInstanceWithContext(sServiceName, m_aContext), UNO_QUERY_THROW ); - // load resp. init it const Reference< XLoadable > xLoadable( xModel, UNO_QUERY_THROW ); if ( bInitNewModel ) @@ -770,32 +766,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA } bLoadSuccess = true; - - const OUString sThemes = aDescriptor.getOrDefault("Theme", OUString()); - if (comphelper::LibreOfficeKit::isActive() && !sThemes.isEmpty()) - { - const OUString sServiceName = aDescriptor.getOrDefault("DocumentService", OUString()); - OUString sTheme, sType, sName; - sal_Int32 nTheme = 0, nIndex = 0; - do - { - sTheme = sThemes.getToken(0, ';', nTheme); - sType = sTheme.getToken(0, ':', nIndex); - sName = sTheme.getToken(0, ':', nIndex); - if (sType == SfxLokHelper::getDocumentType(sServiceName)) - { - svtools::EditableColorConfig aConfig; - if (aConfig.GetCurrentSchemeName() != sName) - { - aConfig.LoadScheme(sName); - break; - } - } - nIndex = 0; - - } - while ( nTheme >= 0 ); - } } catch ( Exception& ) { diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index b22d1e488283..e6fc7e8c7114 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -388,21 +388,6 @@ void SfxLokHelper::setDeviceFormFactor(std::u16string_view rDeviceFormFactor) g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; } -OUString SfxLokHelper::getDocumentType(const OUString& sDocumentService) -{ - if (sDocumentService == "com.sun.star.sheet.SpreadsheetDocument") - return "spreadsheet"; - else if (sDocumentService == "com.sun.star.presentation.PresentationDocument") - return "presentation"; - else if (sDocumentService == "com.sun.star.drawing.DrawingDocument") - return "drawing"; - else if (sDocumentService == "com.sun.star.text.TextDocument" || - sDocumentService == "com.sun.star.text.WebDocument") - return "text"; - - return OUString(); -} - void SfxLokHelper::setDefaultTimezone(bool isSet, const OUString& rTimezone) { g_isDefaultTimezoneSet = isSet; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 9ed0f762a782..99c26e6f39dc 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -19,6 +19,8 @@ #include <sal/config.h> #include <officecfg/Office/Common.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertysequence.hxx> #include <comphelper/string.hxx> #include <AnnotationWin.hxx> #include <o3tl/any.hxx> @@ -3641,6 +3643,7 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: // the case of clicking in the header area of a document with no headers aViewOption.SetUseHeaderFooterMenu(false); + OUString sThemeName; OUString sOrigAuthor = SW_MOD()->GetRedlineAuthor(SW_MOD()->GetRedlineAuthor()); OUString sAuthor; @@ -3662,6 +3665,8 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: } else if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>()) aViewOption.SetOnlineSpell(rValue.Value.get<bool>()); + else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) + sThemeName = rValue.Value.get<OUString>(); } if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor) @@ -3710,6 +3715,16 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: // don't change the whitespace at the beginning of paragraphs, this is // annoying when taking minutes without further formatting SwEditShell::GetAutoFormatFlags()->bAFormatByInpDelSpacesAtSttEnd = false; + + // if we know what theme the user wants, then we can dispatch that now early + if (!sThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sThemeName) } + })); + comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); + } } void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)