include/tools/json_writer.hxx                 |    2 ++
 svx/source/tbxctrls/PaletteManager.cxx        |    3 +--
 svx/source/theme/ThemeColorPaletteManager.cxx |    4 +++-
 tools/source/misc/json_writer.cxx             |   14 ++++++++++++--
 4 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit c442b3d1aa47eba8c031792f4f14167a760c2e8e
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Mar 11 13:27:23 2024 +0000
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 11 15:34:25 2024 +0100

    Document Colors do not show any color in the Palette
    
    same is true for "Theme Colors", a problem since:
    
    commit 4ccc2f0e3f45c9d78f74b1848851bedf71f7382d
    Date:   Fri Mar 1 22:11:14 2024 +0200
    
        cool#8327 use tools::JsonWriter for theme colors
    
    Change-Id: Ibaab5df197bd8005037e066181e8a50bdda5ceda
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164658
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index ae9664b2da67..16615517ce75 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -49,6 +49,7 @@ public:
 
     [[nodiscard]] ScopedJsonWriterNode startNode(const char*);
     [[nodiscard]] ScopedJsonWriterArray startArray(const char*);
+    [[nodiscard]] ScopedJsonWriterArray startAnonArray();
     [[nodiscard]] ScopedJsonWriterStruct startStruct();
 
     void put(const OUString& pPropName, const OUString& rPropValue);
@@ -84,6 +85,7 @@ public:
     bool isDataEquals(const std::string&) const;
 
 private:
+    void startAnonBlock(const char cType);
     void endNode();
     void endArray();
     void endStruct();
diff --git a/svx/source/tbxctrls/PaletteManager.cxx 
b/svx/source/tbxctrls/PaletteManager.cxx
index c52dc549f852..aef5f34b71ae 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -477,8 +477,7 @@ void PaletteManager::generateJSON(tools::JsonWriter& aTree, 
const std::set<Color
     auto aColorIt = rColors.begin();
     while (aColorIt != rColors.end())
     {
-        auto aColorRowTree = aTree.startStruct();
-        auto aColorRowTree2 = aTree.startArray("");
+        auto aColorRowTree = aTree.startAnonArray();
 
         for (sal_uInt32 nColumn = 0; nColumn < nColumnCount; nColumn++)
         {
diff --git a/svx/source/theme/ThemeColorPaletteManager.cxx 
b/svx/source/theme/ThemeColorPaletteManager.cxx
index 5367232b4de4..b57eaff71115 100644
--- a/svx/source/theme/ThemeColorPaletteManager.cxx
+++ b/svx/source/theme/ThemeColorPaletteManager.cxx
@@ -135,9 +135,11 @@ void 
ThemeColorPaletteManager::generateJSON(tools::JsonWriter& aTree)
 
     for (size_t nEffect = 0; nEffect < 6; ++nEffect)
     {
-        auto aColorRowTree = aTree.startStruct();
+        auto aColorRowTree = aTree.startAnonArray();
         for (size_t nIndex = 0; nIndex < 12; ++nIndex)
         {
+            auto aColorTree = aTree.startStruct();
+
             auto const& rColorData = aThemePaletteCollection.maColors[nIndex];
             auto const& rEffectData = rColorData.maEffects[nEffect];
 
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 865b09d50e6a..6e082005b0d4 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -93,6 +93,12 @@ ScopedJsonWriterArray JsonWriter::startArray(const char* 
pNodeName)
     return ScopedJsonWriterArray(*this);
 }
 
+ScopedJsonWriterArray JsonWriter::startAnonArray()
+{
+    startAnonBlock('[');
+    return ScopedJsonWriterArray(*this);
+}
+
 void JsonWriter::endArray()
 {
     assert(mStartNodeCount && "mismatched StartNode/EndNode somewhere");
@@ -105,13 +111,13 @@ void JsonWriter::endArray()
     validate();
 }
 
-ScopedJsonWriterStruct JsonWriter::startStruct()
+void JsonWriter::startAnonBlock(const char cType)
 {
     ensureSpace(6);
 
     addCommaBeforeField();
 
-    *mPos = '{';
+    *mPos = cType;
     ++mPos;
     *mPos = ' ';
     ++mPos;
@@ -119,7 +125,11 @@ ScopedJsonWriterStruct JsonWriter::startStruct()
     mbFirstFieldInNode = true;
 
     validate();
+}
 
+ScopedJsonWriterStruct JsonWriter::startStruct()
+{
+    startAnonBlock('{');
     return ScopedJsonWriterStruct(*this);
 }
 

Reply via email to