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 3b312ca78533459e529d01e0af90078af4f294eb Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Mar 11 13:27:23 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Mar 11 18:08:15 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164664 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx index 8bb8d192d2ff..10a5a6e88681 100644 --- a/include/tools/json_writer.hxx +++ b/include/tools/json_writer.hxx @@ -47,6 +47,7 @@ public: [[nodiscard]] ScopedJsonWriterNode startNode(std::string_view); [[nodiscard]] ScopedJsonWriterArray startArray(std::string_view); + [[nodiscard]] ScopedJsonWriterArray startAnonArray(); [[nodiscard]] ScopedJsonWriterStruct startStruct(); void put(std::u16string_view pPropName, const OUString& rPropValue); @@ -83,6 +84,7 @@ public: bool isDataEquals(std::string_view) 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 891a98cdc92f..662d8a4c2a1f 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -482,8 +482,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 e091ed8b8b76..a8aba1c00e2b 100644 --- a/tools/source/misc/json_writer.cxx +++ b/tools/source/misc/json_writer.cxx @@ -72,6 +72,12 @@ ScopedJsonWriterArray JsonWriter::startArray(std::string_view pNodeName) return ScopedJsonWriterArray(*this); } +ScopedJsonWriterArray JsonWriter::startAnonArray() +{ + startAnonBlock('['); + return ScopedJsonWriterArray(*this); +} + void JsonWriter::endArray() { assert(mStartNodeCount && "mismatched StartNode/EndNode somewhere"); @@ -84,13 +90,13 @@ void JsonWriter::endArray() validate(); } -ScopedJsonWriterStruct JsonWriter::startStruct() +void JsonWriter::startAnonBlock(const char cType) { ensureSpace(6); addCommaBeforeField(); - *mPos = '{'; + *mPos = cType; ++mPos; *mPos = ' '; ++mPos; @@ -98,7 +104,11 @@ ScopedJsonWriterStruct JsonWriter::startStruct() mbFirstFieldInNode = true; validate(); +} +ScopedJsonWriterStruct JsonWriter::startStruct() +{ + startAnonBlock('{'); return ScopedJsonWriterStruct(*this); }