sw/inc/docsh.hxx                           |    3 +++
 sw/source/core/model/ThemeColorChanger.cxx |   17 +++++++++++++++++
 sw/source/uibase/app/docst.cxx             |   13 +++++++++++++
 3 files changed, 33 insertions(+)

New commits:
commit 76d63bb1f6385175238ab3a44f0aa3d877df4c79
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Jan 25 18:09:15 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Jan 27 06:06:54 2023 +0000

    sw: change or create the selected theme in SdrPage on theme change
    
    When the theme color changes (from the UI), also the theme that
    is set to the SdrPage needs to change. If there is no theme set
    yet, a new theme needs to be created (from a set of defaults).
    
    Change-Id: I5e3d6d9f973712ddb875a41adba1aff04395ca7a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146129
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 784ee6e9fad22560add4a0767828ef07b8567bc2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146153
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/source/core/model/ThemeColorChanger.cxx 
b/sw/source/core/model/ThemeColorChanger.cxx
index 4c739547685b..87f1901083c4 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -19,6 +19,7 @@
 #include <format.hxx>
 #include <charatr.hxx>
 #include <DocumentContentOperationsManager.hxx>
+#include <IDocumentDrawModelAccess.hxx>
 #include <IDocumentUndoRedo.hxx>
 
 #include <sal/config.h>
@@ -234,8 +235,24 @@ ThemeColorChanger::~ThemeColorChanger() {}
 void ThemeColorChanger::apply(svx::ColorSet const& rColorSet)
 {
     SwDoc* pDocument = mpDocSh->GetDoc();
+    if (!pDocument)
+        return;
+
     pDocument->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
 
+    SdrPage* pPage = 
pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+    if (pTheme)
+    {
+        pTheme->SetColorSet(std::make_unique<svx::ColorSet>(rColorSet));
+    }
+    else
+    {
+        
pPage->getSdrPageProperties().SetTheme(std::make_unique<svx::Theme>("Office"));
+        pTheme = pPage->getSdrPageProperties().GetTheme();
+        pTheme->SetColorSet(std::make_unique<svx::ColorSet>(rColorSet));
+    }
+
     SfxStyleSheetBasePool* pPool = mpDocSh->GetStyleSheetPool();
     SwDocStyleSheet* pStyle;
 
commit 4f50daccaa206058df53959875d13827af267364
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Jan 25 16:55:14 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Jan 27 06:06:47 2023 +0000

    sw: support theme colors in color picker in writer
    
    Implements SfxDocumentShell::GetThemeColors, which allows the
    color picker to use the theme colors and change them in Writer.
    
    Change-Id: Ic13d2086d4ff037b377b475630b02ed1509fdf3d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146120
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit cae93bc7a401cb6ddaf33b7a23e2ff3c3bfada40)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146152
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 8d051b4fb54a..74fa2225ae93 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -253,6 +253,9 @@ public:
                                    bool bTemplate = false ) const override;
 
     virtual std::set<Color> GetDocColors() override;
+
+    virtual std::vector<Color> GetThemeColors() override;
+
     sfx::AccessibilityIssueCollection runAccessibilityCheck() override;
 
     virtual void LoadStyles( SfxObjectShell& rSource ) override;
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index f13b90b70af6..e3cc7b0f6b6e 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -81,6 +81,8 @@
 #include <SwUndoFmt.hxx>
 #include <strings.hrc>
 #include <AccessibilityCheck.hxx>
+#include <svx/ColorSets.hxx>
+#include <svx/svdpage.hxx>
 
 using namespace ::com::sun::star;
 
@@ -1575,6 +1577,17 @@ std::set<Color> SwDocShell::GetDocColors()
     return m_xDoc->GetDocColors();
 }
 
+std::vector<Color> SwDocShell::GetThemeColors()
+{
+    SdrPage* pPage = 
m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    if (!pPage)
+        return {};
+    svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+    if (!pTheme)
+        return {};
+    return pTheme->GetColors();
+}
+
 void  SwDocShell::LoadStyles( SfxObjectShell& rSource )
 {
     LoadStyles_(rSource, false);

Reply via email to