sc/source/ui/unoobj/docuno.cxx    |   16 ++++++++++++++++
 sd/source/ui/unoidl/unomodel.cxx  |   16 ++++++++++++++++
 sw/source/uibase/uno/unotxdoc.cxx |   15 +++++++++++++++
 3 files changed, 47 insertions(+)

New commits:
commit f64d8d879e78fd3fdf593d3f29c16e5bf270a8cd
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Feb 20 11:25:06 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Feb 21 14:33:11 2024 +0100

    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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163686
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index abb046ba1dd2..b59167efef3c 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>
@@ -1310,6 +1312,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>())
@@ -1318,6 +1322,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
@@ -1334,6 +1340,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 6e86e2a958f9..40a4a5c4b917 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -34,8 +34,10 @@
 
 #include <officecfg/Office/Common.hxx>
 #include <officecfg/Office/Impress.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>
@@ -2585,6 +2587,8 @@ void 
SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
 {
     SolarMutexGuard aGuard;
 
+    OUString sThemeName;
+
     if (DrawViewShell* pViewShell = GetViewShell())
     {
         DrawView* pDrawView = pViewShell->GetDrawView();
@@ -2596,6 +2600,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
@@ -2637,6 +2643,16 @@ void 
SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
     if (!getenv("LO_TESTNAME") || !comphelper::LibreOfficeKit::isActive())
         
officecfg::Office::Impress::MultiPaneGUI::SlideSorterBar::Visible::ImpressView::set(true,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);
+    }
 }
 
 void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 358cdbba532a..1b36c4f249e7 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>
@@ -3574,6 +3576,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;
 
@@ -3595,6 +3598,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)
@@ -3643,6 +3648,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)

Reply via email to