include/svx/dialog/ThemeDialog.hxx          |    7 -
 include/svx/theme/IThemeColorChanger.hxx    |    2 
 include/svx/theme/ThemeColorChanger.hxx     |    2 
 sc/source/ui/inc/ThemeColorChanger.hxx      |    2 
 sc/source/ui/theme/ThemeColorChanger.cxx    |    4 
 sc/source/ui/view/tabvwsh3.cxx              |    7 -
 svx/source/dialog/ThemeDialog.cxx           |   11 +-
 svx/source/svdraw/svdpage.cxx               |   17 ---
 svx/source/theme/ThemeColorChanger.cxx      |    6 -
 sw/inc/bitmaps.hlst                         |    2 
 sw/qa/core/theme/ThemeTest.cxx              |    6 -
 sw/qa/uitest/writer_tests/trackedChanges.py |   44 +++++++++
 sw/source/core/inc/ThemeColorChanger.hxx    |    2 
 sw/source/core/model/ThemeColorChanger.cxx  |   32 +++----
 sw/source/uibase/inc/redlndlg.hxx           |    3 
 sw/source/uibase/misc/redlndlg.cxx          |  128 +++++++++++++++++-----------
 sw/source/uibase/shells/basesh.cxx          |   16 ++-
 sw/source/uibase/sidebar/ThemePanel.cxx     |    2 
 18 files changed, 180 insertions(+), 113 deletions(-)

New commits:
commit cc52d895314dd7b67de916bd90ccbfa098e77419
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Wed Jun 7 16:53:42 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Thu Jun 8 16:31:51 2023 +0200

    tdf#155342 sw tracked table column: manage changes
    
    in Manage Changes dialog window, where deleted/inserted
    table columns were shown as multiple cell changes.
    Now deleted/inserted table columns are shown with a
    single tree item in the dialog window instead of
    showing multiple cell changes.
    
    Add new Action icons to the tracked table column
    insertion/deletion tree items (re-using table column
    deletion/insertion icons).
    
    Show cell changes as children of the single parent
    item tracked table column change.
    
    Accept/Reject and Accept/Reject All support
    1-click acceptance or rejection of table column changes,
    instead of clicking on all cell changes of a single
    table column deletion/insertion.
    
    Follow-up to commit commit eebe4747d2d13545004937bb0267ccfc8ab9d63f
    "tdf#144270 sw: manage tracked table (row) deletion/insertion" and
    commit ffd8d20d368a885d6d786749278fa438573227a7
    "tdf#150673 sw xmloff: import/export tracked table column".
    
    Change-Id: Ie9c9d8ef707ee2581cf6d0b066c10901555ca04c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152711
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index 6582b691d371..3d1e322af006 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -30,6 +30,8 @@ inline constexpr OUStringLiteral BMP_REDLINE_MOVED_INSERTION 
= u"cmd/sc_paste.pn
 inline constexpr OUStringLiteral BMP_REDLINE_MOVED_DELETION = 
u"cmd/sc_cut.png";
 inline constexpr OUStringLiteral BMP_REDLINE_ROW_INSERTION = 
u"cmd/sc_insertrows.png";
 inline constexpr OUStringLiteral BMP_REDLINE_ROW_DELETION = 
u"cmd/sc_deleterows.png";
+inline constexpr OUStringLiteral BMP_REDLINE_COL_INSERTION = 
u"cmd/sc_insertcolumns.png";
+inline constexpr OUStringLiteral BMP_REDLINE_COL_DELETION = 
u"cmd/sc_deletecolumns.png";
 inline constexpr OUStringLiteral BMP_REDLINE_COMMENT_INSERTION = 
u"cmd/sc_insertannotation.png";
 inline constexpr OUStringLiteral BMP_REDLINE_COMMENT_DELETION = 
u"cmd/sc_deleteannotation.png";
 
diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py 
b/sw/qa/uitest/writer_tests/trackedChanges.py
index a76cfe5dbe36..7e780ef61730 100644
--- a/sw/qa/uitest/writer_tests/trackedChanges.py
+++ b/sw/qa/uitest/writer_tests/trackedChanges.py
@@ -281,6 +281,9 @@ class trackedchanges(UITestCase):
                 # Now: 4 changes (2 deleted/inserted rows and 2 
deleted/inserted tables)
                 self.assertEqual(4, len(changesList.getChildren()))
 
+                # jump to the parent to allow rejecting the table change
+                changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"LEFT"}))
+
                 # Without the fix in place, it would have crashed here
                 for i in (3, 2, 1, 0):
                     xAccBtn = xTrackDlg.getChild("reject")
@@ -500,4 +503,45 @@ class trackedchanges(UITestCase):
                     # of the text "inserts": "Document text inserts 
document"...
                     
self.assertTrue(document.getText().getString().startswith('Document text 
document text'))
 
+    def test_tdf155342_tracked_table_colums(self):
+        with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
document:
+
+            # accept all changes and insert new columns with change tracking
+            self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+            tables = document.getTextTables()
+            self.assertEqual(2, len(tables))
+            self.assertEqual(len(tables[0].getColumns()), 3)
+            self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+            self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+            self.assertEqual(len(tables[0].getColumns()), 5)
+
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.processEventsToIdle()
+
+            # check and reject changes
+            with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
+                changesList = xTrackDlg.getChild("writerchanges")
+
+                # six changes, but only one visible in the Manage Changes 
dialog window
+                state = get_state_as_dict(changesList)
+                self.assertEqual(state['Children'], '6')
+                self.assertEqual(state['VisibleCount'], '1')
+
+                # This was 6 (every cell is a different change instead of 
counting column changes)
+                # Now: 1 changes (2 inserted columns)
+                self.assertEqual(1, len(changesList.getChildren()))
+
+                # reject column insertion
+
+                xAccBtn = xTrackDlg.getChild("reject")
+                xAccBtn.executeAction("CLICK", tuple())
+
+                # all inserted columns are removed
+
+                self.assertEqual(len(tables[0].getColumns()), 3)
+
+                # no changes in the dialog window
+
+                self.assertEqual(0, len(changesList.getChildren()))
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/uibase/inc/redlndlg.hxx 
b/sw/source/uibase/inc/redlndlg.hxx
index 36be9513a932..7337f1fadce4 100644
--- a/sw/source/uibase/inc/redlndlg.hxx
+++ b/sw/source/uibase/inc/redlndlg.hxx
@@ -97,7 +97,8 @@ class SW_DLLPUBLIC SwRedlineAcceptDlg final
     SAL_DLLPRIVATE void          RemoveParents(SwRedlineTable::size_type 
nStart, SwRedlineTable::size_type nEnd);
     SAL_DLLPRIVATE void          InitAuthors();
 
-    SAL_DLLPRIVATE static OUString GetActionImage(const SwRangeRedline& 
rRedln, sal_uInt16 nStack = 0, bool bRowChanges = false);
+    SAL_DLLPRIVATE static OUString GetActionImage(const SwRangeRedline& 
rRedln, sal_uInt16 nStack = 0,
+                                                  bool bTableChanges = false, 
bool bRowChanges = false);
     SAL_DLLPRIVATE OUString      GetActionText(const SwRangeRedline& rRedln, 
sal_uInt16 nStack = 0);
     SAL_DLLPRIVATE SwRedlineTable::size_type GetRedlinePos(const 
weld::TreeIter& rEntry);
 
diff --git a/sw/source/uibase/misc/redlndlg.cxx 
b/sw/source/uibase/misc/redlndlg.cxx
index 19374e5187a2..e583dc3af1a9 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -312,19 +312,24 @@ void SwRedlineAcceptDlg::InitAuthors()
                                 m_bOnlyFormatedRedlines );
 }
 
-OUString SwRedlineAcceptDlg::GetActionImage(const SwRangeRedline& rRedln, 
sal_uInt16 nStack, bool bRowChanges)
+OUString SwRedlineAcceptDlg::GetActionImage(const SwRangeRedline& rRedln, 
sal_uInt16 nStack,
+                                            bool bTableChanges, bool 
bRowChanges)
 {
     switch (rRedln.GetType(nStack))
     {
-        case RedlineType::Insert:  return bRowChanges
-            ? OUString(BMP_REDLINE_ROW_INSERTION)
+        case RedlineType::Insert:  return bTableChanges
+            ? bRowChanges
+                ? OUString(BMP_REDLINE_ROW_INSERTION)
+                : OUString(BMP_REDLINE_COL_INSERTION)
             : rRedln.IsMoved()
                 ? OUString(BMP_REDLINE_MOVED_INSERTION)
                 : rRedln.IsAnnotation()
                     ? OUString(BMP_REDLINE_COMMENT_INSERTION)
                     : OUString(BMP_REDLINE_INSERTED);
-        case RedlineType::Delete:  return bRowChanges
-            ? OUString(BMP_REDLINE_ROW_DELETION)
+        case RedlineType::Delete:  return bTableChanges
+            ? bRowChanges
+                 ? OUString(BMP_REDLINE_ROW_DELETION)
+                 : OUString(BMP_REDLINE_COL_DELETION)
             : rRedln.IsMoved()
                 ? OUString(BMP_REDLINE_MOVED_DELETION)
                 : rRedln.IsAnnotation()
@@ -790,25 +795,23 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
 
     bool bIsShowChangesInMargin = 
SW_MOD()->GetUsrPref(false)->IsShowChangesInMargin();
 
-    // collect redlines of tracked table or table row insertion/deletions 
under a single tree list
-    // item to accept/reject table (row) insertion/deletion with a single 
click on Accept/Reject
+    // collect redlines of tracked table/row/column insertion/deletions under 
a single tree list
+    // item to accept/reject the table change with a single click on 
Accept/Reject
     // Note: because update of the tree list depends on parent count, we don't 
modify
     // m_RedlineParents, only store the 2nd and more redlines as children of 
the tree list
     // item of the first redline
 
     // count of items stored as children (to adjust parent position)
-    sal_Int32 nSkipRedlines = 0;
-    // count of items of the actual table row (or joined table rows) stored as 
children =
-    // redlines of the row(s) - 1 (first redline is associated to the parent 
tree list item)
-    sal_Int32 nSkipRedline = 0;
-    // nSkipRedline of the previous table row (to join multiple table rows, if 
it's possible)
-    sal_Int32 nPrevSkipRedline = 0;
-
-    // last SwRangeRedline in the table row
+    SwRedlineTable::size_type nSkipRedlines = 0;
+    // count of items of the actual table change stored as children =
+    // redlines of the change - 1 (first redline is associated to the parent 
tree list item)
+    SwRedlineTable::size_type nSkipRedline = 0;
+
+    // last SwRangeRedline in the table row/column
     SwRedlineTable::size_type nLastChangeInRow = SwRedlineTable::npos;
-    // descriptor redline of the tracked table row
-    SwRedlineTable::size_type nRowChange = SwRedlineTable::npos;
-    // descriptor redline of the previous table row to join the table rows
+    // descriptor redline of the tracked table row/column
+    SwRedlineTable::size_type nRowChange = 0;
+    // descriptor redline of the previous table change to join with the next 
one
     SwRedlineTable::size_type nPrevRowChange = SwRedlineTable::npos;
 
     // show all redlines as tree list items,
@@ -825,42 +828,69 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
         // handle tracked table row changes
         const SwTableBox* pTableBox;
         const SwTableLine* pTableLine;
-        // first SwRangeRedline of the tracked table row(s), base of the 
parent tree list
-        // of the other SwRangeRedlines of the tracked table row(s)
+        bool bChange = false;
+        bool bRowChange = false;
+        // first SwRangeRedline of the tracked table rows/columns, base of the 
parent tree list
+        // of the other SwRangeRedlines of the tracked table rows or columns
         SwRedlineTable::size_type nNewTableParent = SwRedlineTable::npos;
         if ( // not recognized yet as tracked table row change
-             nLastChangeInRow == SwRedlineTable::npos &&
              nullptr != ( pTableBox = 
pSh->GetRedline(i).Start()->GetNode().GetTableBox() ) &&
              nullptr != ( pTableLine = pTableBox->GetUpper() ) &&
-             // it's a tracked row change based on the cached row data
-             RedlineType::None != pTableLine->GetRedlineType() )
+             // it's a tracked row (or column change) based on the cached row 
data
+             ( RedlineType::None != pTableLine->GetRedlineType() ||
+               RedlineType::None != pTableBox->GetRedlineType() ) )
         {
-            SwRedlineTable::size_type nRedline = i;
-            nRowChange = pTableLine->UpdateTextChangesOnly(nRedline);
+            // start redline search from the start from the tracked row/column 
change
+            SwRedlineTable::size_type nStartPos =
+                                        nRowChange > nSkipRedline ? nRowChange 
- nSkipRedline : 0;
+            bChange = true;
+            bRowChange = RedlineType::None != pTableLine->GetRedlineType();
+            nRowChange = bRowChange
+                            ? pTableLine->UpdateTextChangesOnly(nStartPos)
+                            : pTableBox->GetRedline();
             if ( SwRedlineTable::npos != nRowChange )
             {
-                nSkipRedline = nRedline - i - 1;
-                nLastChangeInRow = nRedline - 1;
-                // join the consecutive deleted/inserted rows under a single 
treebox item,
+                // redline is there in a tracked table change
+
+                // join the consecutive deleted/inserted rows/columns under a 
single treebox item,
                 // if they have the same redline data (equal type, author and 
time stamp)
-                if ( nPrevRowChange != SwRedlineTable::npos &&
-                    pSh->GetRedline(nRowChange).GetRedlineData() == 
pSh->GetRedline(nPrevRowChange).GetRedlineData() )
+                if ( nPrevRowChange != SwRedlineTable::npos )
                 {
-                    nSkipRedline += nPrevSkipRedline + 1;
-                    nPrevSkipRedline = 0;
-                    nPrevRowChange = SwRedlineTable::npos;
+                    // note: CanCombine() allows a time frame to join the 
changes within a short
+                    // time period: this avoid of falling apart of the tracked 
columns inserted
+                    // by several clicks
+                    if ( pSh->GetRedline(nRowChange).GetRedlineData()
+                             
.CanCombine(pSh->GetRedline(nPrevRowChange).GetRedlineData()) &&
+                         // in the same table?
+                         
pSh->GetRedline(nRowChange).Start()->GetNode().FindTableNode() ==
+                             
pSh->GetRedline(nPrevRowChange).Start()->GetNode().FindTableNode() )
+                    {
+                        nSkipRedline++;
+                    }
+                    else
+                    {
+                        nNewTableParent = i;
+                        nLastChangeInRow = i;
+                        nPrevRowChange = nRowChange;
+                    }
                 }
                 else
+                {
+                    nLastChangeInRow = i;
                     nNewTableParent = i;
+                }
             }
             else
+            {
+                // redline is not in a tracked table change
+                bChange = bRowChange = false;
                 nPrevRowChange = SwRedlineTable::npos;
+            }
         }
         else
+            // redline is not in a tracked table change
             nPrevRowChange = SwRedlineTable::npos;
 
-        bool bRowChange(SwRedlineTable::npos != nLastChangeInRow);
-
         bool bShowDeletedTextAsComment = bIsShowChangesInMargin &&
                 RedlineType::Delete == rRedln.GetType() && 
rRedln.GetComment().isEmpty();
         const OUString& sComment = bShowDeletedTextAsComment
@@ -876,9 +906,9 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
 
         // use descriptor SwRangeRedline of the changed row, if needed to show
         // the correct redline type, author and time stamp of the tracked row 
change
-        const SwRangeRedline& rChangeRedln = pSh->GetRedline(bRowChange ? 
nRowChange : i);
+        const SwRangeRedline& rChangeRedln = pSh->GetRedline(bChange ? 
nRowChange : i);
 
-        OUString sImage = GetActionImage(rChangeRedln, 0, bRowChange && 
nNewTableParent != SwRedlineTable::npos );
+        OUString sImage = GetActionImage(rChangeRedln, 0, bChange && 
nNewTableParent != SwRedlineTable::npos, bRowChange );
         OUString sAuthor = rChangeRedln.GetAuthorString(0);
         pData->aDateTime = rChangeRedln.GetTimeStamp(0);
         pData->eType = rChangeRedln.GetType(0);
@@ -887,12 +917,20 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
         OUString sId = weld::toId(pData.get());
         std::unique_ptr<weld::TreeIter> xParent(rTreeView.make_iterator());
 
-        if ( !bRowChange || nNewTableParent != SwRedlineTable::npos )
+        if ( !bChange || nNewTableParent != SwRedlineTable::npos )
+        {
             rTreeView.insert(nullptr, i - nSkipRedlines, nullptr, &sId, 
nullptr, nullptr, false, xParent.get());
+            // before this was a tracked table change with more than a single 
redline
+            if ( nSkipRedline > 0 )
+            {
+                nSkipRedlines += nSkipRedline;
+                nSkipRedline = 0;
+            }
+        }
         else
         {
             // put 2nd or more redlines of deleted/inserted rows as children 
of their first redline
-            SwRedlineDataParent *const pParent = 
m_RedlineParents[nLastChangeInRow - nSkipRedline].get();
+            SwRedlineDataParent *const pParent = 
m_RedlineParents[nLastChangeInRow].get();
             rTreeView.insert(pParent->xTLBParent.get(), -1, nullptr, &sId, 
nullptr, nullptr, false, xParent.get());
         }
 
@@ -916,16 +954,8 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
 
         InsertChildren(pRedlineParent, rRedln, bHasRedlineAutoFormat);
 
-        // end of a tracked deletion/insertion of a table row
-        if ( nLastChangeInRow != SwRedlineTable::npos && i == nLastChangeInRow 
)
-        {
-            nSkipRedlines += nSkipRedline;
-            nPrevSkipRedline = nSkipRedline;
-            nSkipRedline = 0;
-            nPrevRowChange = nRowChange;
-            nNewTableParent = SwRedlineTable::npos;
-            nLastChangeInRow = SwRedlineTable::npos;
-        }
+        nPrevRowChange = nRowChange;
+        nNewTableParent = SwRedlineTable::npos;
     }
     rTreeView.thaw();
     if (m_pTable->IsSorted())
commit c86622057c51622eca24b79d0644c3686299e829
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Jun 6 15:05:18 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Jun 8 16:31:41 2023 +0200

    lok: send theme palette after the change in ThemeDialog
    
    For some reason the SdrPage is constructed in Online after every
    change (cursor, selection) so can't use that to send theme change
    callback. Instead of that send it after the theme is changed with
    the ThemeDialog.
    
    in addition this requires that we transport model::ColorSet in a
    shared_ptr more, to prevent doing constant copies. This requires
    that the IThemeColorChanger interface is changed and the signature
    of apply() method.
    
    Change-Id: Iac951fce57a8e9dff467bd27b2f9c64ec65ea30c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152635
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 6c40e4d1796bcb6418dcb5ec17f46f576c171796)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152728
    Tested-by: Jenkins

diff --git a/include/svx/dialog/ThemeDialog.hxx 
b/include/svx/dialog/ThemeDialog.hxx
index d715894f027a..020240c97ca3 100644
--- a/include/svx/dialog/ThemeDialog.hxx
+++ b/include/svx/dialog/ThemeDialog.hxx
@@ -36,7 +36,7 @@ private:
     std::unique_ptr<weld::CustomWeld> mxValueSetThemeColorsWindow;
     std::unique_ptr<weld::Button> mxAdd;
 
-    std::optional<std::reference_wrapper<model::ColorSet>> moCurrentColorSet;
+    std::shared_ptr<model::ColorSet> mpCurrentColorSet;
 
     void runThemeColorEditDialog();
     void initColorSets();
@@ -49,10 +49,7 @@ public:
     DECL_LINK(SelectItem, ValueSet*, void);
     DECL_LINK(ButtonClicked, weld::Button&, void);
 
-    std::optional<std::reference_wrapper<model::ColorSet>> const& 
getCurrentColorSet()
-    {
-        return moCurrentColorSet;
-    }
+    std::shared_ptr<model::ColorSet> const& getCurrentColorSet() { return 
mpCurrentColorSet; }
 };
 
 } // end svx namespace
diff --git a/include/svx/theme/IThemeColorChanger.hxx 
b/include/svx/theme/IThemeColorChanger.hxx
index 4f10ad15120f..d9273238c712 100644
--- a/include/svx/theme/IThemeColorChanger.hxx
+++ b/include/svx/theme/IThemeColorChanger.hxx
@@ -18,7 +18,7 @@ class SVXCORE_DLLPUBLIC IThemeColorChanger
 {
 public:
     virtual ~IThemeColorChanger() = default;
-    virtual void apply(model::ColorSet const& rColorSet) = 0;
+    virtual void apply(std::shared_ptr<model::ColorSet> const& pColorSet) = 0;
 };
 
 } // end svx namespace
diff --git a/include/svx/theme/ThemeColorChanger.hxx 
b/include/svx/theme/ThemeColorChanger.hxx
index 708344fef2b3..8e942ea975ad 100644
--- a/include/svx/theme/ThemeColorChanger.hxx
+++ b/include/svx/theme/ThemeColorChanger.hxx
@@ -31,7 +31,7 @@ public:
     ThemeColorChanger(SdrPage* pPage);
     virtual ~ThemeColorChanger() override;
 
-    void apply(model::ColorSet const& rColorSet) override;
+    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end svx namespace
diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx 
b/sc/source/ui/inc/ThemeColorChanger.hxx
index 89d154aca7d9..888cf34f11ba 100644
--- a/sc/source/ui/inc/ThemeColorChanger.hxx
+++ b/sc/source/ui/inc/ThemeColorChanger.hxx
@@ -23,7 +23,7 @@ public:
     ThemeColorChanger(ScDocShell& rDocShell);
     virtual ~ThemeColorChanger() override;
 
-    void apply(model::ColorSet const& rColorSet) override;
+    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end sc namespace
diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx 
b/sc/source/ui/theme/ThemeColorChanger.cxx
index 1e8641f525a4..870ef5b15cb8 100644
--- a/sc/source/ui/theme/ThemeColorChanger.cxx
+++ b/sc/source/ui/theme/ThemeColorChanger.cxx
@@ -77,7 +77,7 @@ void paragraphStyleChange(ScStyleSheet* pStyle, 
model::ColorSet const& rColorSet
 }
 } // end anonymous ns
 
-void ThemeColorChanger::apply(model::ColorSet const& rColorSet)
+void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     auto& rDocument = m_rDocShell.GetDocument();
     ScStyleSheetPool* pPool = rDocument.GetStyleSheetPool();
@@ -87,7 +87,7 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
     pStyle = static_cast<ScStyleSheet*>(pPool->First(SfxStyleFamily::Para));
     while (pStyle)
     {
-        paragraphStyleChange(pStyle, rColorSet);
+        paragraphStyleChange(pStyle, *pColorSet);
         pStyle = static_cast<ScStyleSheet*>(pPool->Next());
     }
 }
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index bb03be4fd9cc..7395325f775c 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1356,12 +1356,11 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                     if (RET_OK != nResult)
                         return;
 
-                    auto oColorSet = pDialog->getCurrentColorSet();
-                    if (oColorSet)
+                    auto pColorSet = pDialog->getCurrentColorSet();
+                    if (pColorSet)
                     {
-                        auto& rColorSet = (*oColorSet).get();
                         sc::ThemeColorChanger 
aChanger(*GetViewData().GetDocShell());
-                        aChanger.apply(rColorSet);
+                        aChanger.apply(pColorSet);
                     }
                 });
             }
diff --git a/svx/source/dialog/ThemeDialog.cxx 
b/svx/source/dialog/ThemeDialog.cxx
index ce88b2ef4b79..8af6f5975df2 100644
--- a/svx/source/dialog/ThemeDialog.cxx
+++ b/svx/source/dialog/ThemeDialog.cxx
@@ -40,7 +40,7 @@ ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* 
pTheme)
     if (!maColorSets.empty())
     {
         mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0
-        moCurrentColorSet = std::ref(maColorSets[0]);
+        mpCurrentColorSet = std::make_shared<model::ColorSet>(maColorSets[0]);
     }
 }
 
@@ -80,12 +80,12 @@ IMPL_LINK_NOARG(ThemeDialog, SelectItem, ValueSet*, void)
     if (nIndex >= maColorSets.size())
         return;
 
-    moCurrentColorSet = std::ref(maColorSets[nIndex]);
+    mpCurrentColorSet = std::make_shared<model::ColorSet>(maColorSets[nIndex]);
 }
 
 void ThemeDialog::runThemeColorEditDialog()
 {
-    auto pDialog = std::make_shared<svx::ThemeColorEditDialog>(mpWindow, 
*moCurrentColorSet);
+    auto pDialog = std::make_shared<svx::ThemeColorEditDialog>(mpWindow, 
*mpCurrentColorSet);
     weld::DialogController::runAsync(pDialog, [this, pDialog](sal_uInt32 
nResult) {
         if (nResult != RET_OK)
             return;
@@ -99,14 +99,15 @@ void ThemeDialog::runThemeColorEditDialog()
             initColorSets();
 
             mxValueSetThemeColors->SelectItem(maColorSets.size() - 1);
-            moCurrentColorSet = std::ref(maColorSets[maColorSets.size() - 1]);
+            mpCurrentColorSet
+                = 
std::make_shared<model::ColorSet>(maColorSets[maColorSets.size() - 1]);
         }
     });
 }
 
 IMPL_LINK(ThemeDialog, ButtonClicked, weld::Button&, rButton, void)
 {
-    if (moCurrentColorSet && mxAdd.get() == &rButton)
+    if (mpCurrentColorSet && mxAdd.get() == &rButton)
     {
         runThemeColorEditDialog();
     }
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index d165300292f7..2a316a25080f 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -47,7 +47,6 @@
 #include <svx/fmdpage.hxx>
 #include <svx/theme/ThemeColorChanger.hxx>
 #include <svx/ColorSets.hxx>
-#include <svx/theme/ThemeColorPaletteManager.hxx>
 
 #include <sdr/contact/viewcontactofsdrpage.hxx>
 #include <svx/sdr/contact/viewobjectcontact.hxx>
@@ -58,8 +57,6 @@
 #include <rtl/strbuf.hxx>
 #include <libxml/xmlwriter.h>
 #include <docmodel/theme/Theme.hxx>
-#include <sfx2/lokhelper.hxx>
-#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 
@@ -1205,7 +1202,6 @@ SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
         {
             std::shared_ptr<model::ColorSet> pDefaultColorSet(new 
model::ColorSet(*pColorSet));
             mpTheme->setColorSet(pDefaultColorSet);
-            sendLOKitThemeChangedCallback();
         }
     }
 }
@@ -1283,8 +1279,6 @@ void 
SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme)
 
     mpTheme = pTheme;
 
-    sendLOKitThemeChangedCallback();
-
     if (mpTheme && mpTheme->getColorSet() && mpSdrPage->IsMasterPage())
     {
         SdrModel& rModel = mpSdrPage->getSdrModelFromSdrPage();
@@ -1298,20 +1292,11 @@ void 
SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme)
             }
 
             svx::ThemeColorChanger aChanger(pPage);
-            aChanger.apply(*mpTheme->getColorSet());
+            aChanger.apply(mpTheme->getColorSet());
         }
     }
 }
 
-void SdrPageProperties::sendLOKitThemeChangedCallback()
-{
-    if (!comphelper::LibreOfficeKit::isActive())
-        return;
-
-    svx::ThemeColorPaletteManager aManager(mpTheme->getColorSet());
-    SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
-}
-
 std::shared_ptr<model::Theme> const& SdrPageProperties::GetTheme() const
 {
     return mpTheme;
diff --git a/svx/source/theme/ThemeColorChanger.cxx 
b/svx/source/theme/ThemeColorChanger.cxx
index 06d199cc3896..2edc00820381 100644
--- a/svx/source/theme/ThemeColorChanger.cxx
+++ b/svx/source/theme/ThemeColorChanger.cxx
@@ -135,12 +135,12 @@ ThemeColorChanger::ThemeColorChanger(SdrPage* pPage)
 
 ThemeColorChanger::~ThemeColorChanger() = default;
 
-void ThemeColorChanger::apply(model::ColorSet const& rColorSet)
+void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     for (size_t nObject = 0; nObject < mpPage->GetObjCount(); ++nObject)
     {
         SdrObject* pObject = mpPage->GetObj(nObject);
-        theme::updateSdrObject(rColorSet, pObject);
+        theme::updateSdrObject(*pColorSet, pObject);
 
         // update child objects
         SdrObjList* pList = pObject->GetSubList();
@@ -149,7 +149,7 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
             SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups);
             while (aIter.IsMore())
             {
-                theme::updateSdrObject(rColorSet, aIter.Next());
+                theme::updateSdrObject(*pColorSet, aIter.Next());
             }
         }
     }
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index da41c8bb56a8..5d8480035f77 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -430,12 +430,12 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testThemeChanging)
     // Change theme colors
     {
         auto const& rColorSets = svx::ColorSets::get();
-        model::ColorSet const& rNewColorSet = rColorSets.getColorSet(0);
+        auto pNewColorSet = 
std::make_shared<model::ColorSet>(rColorSets.getColorSet(0));
         // check that the theme colors are as expected
-        CPPUNIT_ASSERT_EQUAL(OUString(u"LibreOffice"), rNewColorSet.getName());
+        CPPUNIT_ASSERT_EQUAL(OUString(u"LibreOffice"), 
pNewColorSet->getName());
 
         sw::ThemeColorChanger aChanger(pDoc->GetDocShell());
-        aChanger.apply(rNewColorSet);
+        aChanger.apply(pNewColorSet);
     }
 
     // Check new theme colors
diff --git a/sw/source/core/inc/ThemeColorChanger.hxx 
b/sw/source/core/inc/ThemeColorChanger.hxx
index e7e2620a41d0..6c3e9f3cc7f7 100644
--- a/sw/source/core/inc/ThemeColorChanger.hxx
+++ b/sw/source/core/inc/ThemeColorChanger.hxx
@@ -25,7 +25,7 @@ public:
     ThemeColorChanger(SwDocShell* pDocSh);
     virtual ~ThemeColorChanger() override;
 
-    void apply(model::ColorSet const& rColorSet) override;
+    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end sw namespace
diff --git a/sw/source/core/model/ThemeColorChanger.cxx 
b/sw/source/core/model/ThemeColorChanger.cxx
index e9ae920362a5..caf4de1787ce 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -345,7 +345,7 @@ ThemeColorChanger::ThemeColorChanger(SwDocShell* pDocSh)
 
 ThemeColorChanger::~ThemeColorChanger() = default;
 
-void ThemeColorChanger::apply(model::ColorSet const& rColorSet)
+void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     SwDoc* pDocument = mpDocSh->GetDoc();
     if (!pDocument)
@@ -362,8 +362,8 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
         pPage->getSdrPageProperties().SetTheme(pTheme);
     }
 
-    auto pNewColorSet = std::make_shared<model::ColorSet>(rColorSet);
-    auto pOldColorSet = pTheme->getColorSet();
+    std::shared_ptr<model::ColorSet> pNewColorSet = pColorSet;
+    std::shared_ptr<model::ColorSet> pOldColorSet = pTheme->getColorSet();
     pTheme->setColorSet(pNewColorSet);
 
     auto pUndoThemeChange
@@ -379,8 +379,8 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
         std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
 
         bool bChanged = false;
-        bChanged = bChanged || changeBackground(rAttrSet, *pNewSet, rColorSet);
-        bChanged = bChanged || changeBox(rAttrSet, *pNewSet, rColorSet);
+        bChanged = bChanged || changeBackground(rAttrSet, *pNewSet, 
*pColorSet);
+        bChanged = bChanged || changeBox(rAttrSet, *pNewSet, *pColorSet);
 
         if (bChanged)
         {
@@ -403,8 +403,8 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
             std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
 
             bool bChanged = false;
-            bChanged = changeBackground(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
-            bChanged = changeBox(rAttrSet, *pNewSet, rColorSet) || bChanged;
+            bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged;
 
             if (bChanged)
                 pDocument->ChgFormat(*pFrameFormat, *pNewSet);
@@ -423,11 +423,11 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
             std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
 
             bool bChanged = false;
-            bChanged = changeColor(rAttrSet, *pNewSet, rColorSet) || bChanged;
-            bChanged = changeOverlineColor(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
-            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
-            bChanged = changeBox(rAttrSet, *pNewSet, rColorSet) || bChanged;
-            bChanged = changeBackground(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
+            bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged;
+            bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged;
+            bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
 
             if (bChanged)
                 pDocument->ChgFormat(*pTextFormatCollection, *pNewSet);
@@ -446,9 +446,9 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
             std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
 
             bool bChanged = false;
-            bChanged = changeColor(rAttrSet, *pNewSet, rColorSet) || bChanged;
-            bChanged = changeOverlineColor(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
-            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, rColorSet) || 
bChanged;
+            bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged;
+            bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
             if (bChanged)
                 pDocument->ChgFormat(*pCharFormat, *pNewSet);
         }
@@ -456,7 +456,7 @@ void ThemeColorChanger::apply(model::ColorSet const& 
rColorSet)
     }
 
     // Direct format change
-    auto pHandler = std::make_shared<ThemeColorHandler>(*pDocument, rColorSet);
+    auto pHandler = std::make_shared<ThemeColorHandler>(*pDocument, 
*pColorSet);
     sw::ModelTraverser aModelTraverser(pDocument);
     aModelTraverser.addNodeHandler(pHandler);
     aModelTraverser.traverse();
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index 118df74e23a1..504c9fefa89d 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -91,15 +91,19 @@
 #include <SwRewriter.hxx>
 #include <GraphicSizeCheck.hxx>
 #include <svx/galleryitem.hxx>
+#include <svx/theme/ThemeColorPaletteManager.hxx>
 #include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
 #include <com/sun/star/gallery/GalleryItemType.hpp>
 #include <com/sun/star/beans/PropertyValues.hpp>
 #include <memory>
 
+
 #include <svx/unobrushitemhelper.hxx>
 #include <svx/dialog/ThemeDialog.hxx>
 #include <comphelper/scopeguard.hxx>
 #include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <osl/diagnose.h>
 
 #include <svx/svxdlg.hxx>
@@ -2976,11 +2980,15 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
                         if (RET_OK != nResult)
                             return;
 
-                        auto oColorSet = pDialog->getCurrentColorSet();
-                        if (oColorSet)
+                        auto pColorSet = pDialog->getCurrentColorSet();
+                        if (pColorSet)
                         {
-                            auto& rColorSet = (*oColorSet).get();
-                            pChanger->apply(rColorSet);
+                            pChanger->apply(pColorSet);
+                            if (comphelper::LibreOfficeKit::isActive())
+                            {
+                                svx::ThemeColorPaletteManager 
aManager(pColorSet);
+                                
SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
+                            }
                         }
                     });
                 }
diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx 
b/sw/source/uibase/sidebar/ThemePanel.cxx
index 2dabadbba545..55853a544f8e 100644
--- a/sw/source/uibase/sidebar/ThemePanel.cxx
+++ b/sw/source/uibase/sidebar/ThemePanel.cxx
@@ -97,7 +97,7 @@ void ThemePanel::DoubleClickHdl()
     model::ColorSet const& rColorSet = rColorSets.getColorSet(nIndex);
 
     ThemeColorChanger aChanger(pDocSh);
-    aChanger.apply(rColorSet);
+    aChanger.apply(std::make_shared<model::ColorSet>(rColorSet));
 }
 
 void ThemePanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/,

Reply via email to