include/svx/PaletteManager.hxx               |    6 ++++
 sc/source/ui/inc/tabvwsh.hxx                 |    5 +++
 sc/source/ui/view/tabview3.cxx               |    5 ++-
 sc/source/ui/view/tabvwsh4.cxx               |    1 
 sc/source/ui/view/tabvwshc.cxx               |    2 -
 svx/source/tbxctrls/PaletteManager.cxx       |   38 ++++++++++++++++++++++++++-
 svx/source/theme/ThemeColorChangerCommon.cxx |    2 +
 7 files changed, 56 insertions(+), 3 deletions(-)

New commits:
commit eaa5c029e91a3ad18e8a049b88ac216de2da35d7
Author:     Gülşah Köse <gulsah.k...@collabora.com>
AuthorDate: Tue Apr 15 17:13:06 2025 +0300
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Tue Jul 29 14:19:49 2025 +0200

    ONLINE: Send color names and values Online
    
    Signed-off-by: Gülşah Köse <gulsah.k...@collabora.com>
    Change-Id: I5a754b106468a0f00a6a1ee54ee4971460759300
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184285
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184766
    Tested-by: Jenkins

diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index c496b691e7ec..98c32fb855ad 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -35,6 +35,11 @@ namespace tools { class JsonWriter; }
 
 class SVXCORE_DLLPUBLIC PaletteManager : public 
std::enable_shared_from_this<PaletteManager>
 {
+    struct ColorEntry {
+        OUString hexCode;
+        OUString name;
+    };
+
     const sal_uInt16        mnMaxRecentColors;
 
     sal_uInt16              mnNumOfPalettes;
@@ -86,6 +91,7 @@ public:
 
     /// Appends node for Document Colors into the ptree
     static void generateJSON(tools::JsonWriter& aTree, const std::set<Color>& 
rColors);
+    static void generateColorNamesJSON(tools::JsonWriter& aTree);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 742245975dd2..be283fcffaf8 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -185,6 +185,8 @@ private:
 
     sal_uInt16              nCurRefDlgId;
 
+    bool                    bIsTabChangeInProgress;
+
     std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster;
 
     // ugly hack for Add button in ScNameDlg
@@ -283,6 +285,9 @@ public:
 
     void            SetActive();
 
+    void            SetTabChangeInProgress(bool bState) { 
bIsTabChangeInProgress = bState; }
+    bool            IsTabChangeInProgress() { return bIsTabChangeInProgress; }
+
     ::editeng::SvxBorderLine*   GetDefaultFrameLine() const { return 
pCurFrameLine.get(); }
     void            SetDefaultFrameLine(const ::editeng::SvxBorderLine* pLine 
);
 
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 5655e85efe68..614651c98f48 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1897,6 +1897,9 @@ void ScTabView::SelectTabPage( const sal_uInt16 nTab )
 
 void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool 
bSameTabButMoved )
 {
+    ScTabViewShell* pViewShell = aViewData.GetViewShell();
+    pViewShell->SetTabChangeInProgress(true);
+
     if ( !ValidTab(nTab) )
     {
         OSL_FAIL("SetTabNo: invalid sheet");
@@ -2098,7 +2101,6 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool 
bExtendSelection, bool bSa
 
     // disable invalidations for kit during tab switching
     {
-        ScTabViewShell* pViewShell = aViewData.GetViewShell();
         SfxLokCallbackInterface* pCallback = 
pViewShell->getLibreOfficeKitViewCallback();
         pViewShell->setLibreOfficeKitViewCallback(nullptr);
         comphelper::ScopeGuard aOutputGuard(
@@ -2141,6 +2143,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool 
bExtendSelection, bool bSa
     }
 
     OnLibreOfficeKitTabChanged();
+    pViewShell->SetTabChangeInProgress(false);
 }
 
 void ScTabView::AddWindowToForeignEditView(SfxViewShell* pViewShell, 
ScSplitPos eWhich)
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 794af32bde73..a2d3cf043e1f 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -2038,6 +2038,7 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame& rViewFrame,
     bInDispose(false),
     bMoveKeepEdit(false),
     nCurRefDlgId(0),
+    bIsTabChangeInProgress(false),
     mbInSwitch(false),
     m_pDragData(new ScDragData),
     m_pScCondFormatDlgData()
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 4cff2bdcadc2..742abae96556 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -473,7 +473,7 @@ void ScTabViewShell::afterCallbackRegistered()
     }
 
     SfxObjectShell* pDocShell = GetObjectShell();
-    if (pDocShell)
+    if (pDocShell && !IsTabChangeInProgress())
     {
         std::shared_ptr<model::ColorSet> pThemeColors = 
pDocShell->GetThemeColors();
         std::set<Color> aDocumentColors = pDocShell->GetDocColors();
diff --git a/svx/source/tbxctrls/PaletteManager.cxx 
b/svx/source/tbxctrls/PaletteManager.cxx
index 5af958c408cf..fd9d11b0e56a 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -69,7 +69,6 @@ PaletteManager::PaletteManager() :
         mpColorList = XColorList::CreateStdColorList();
     LoadPalettes();
     mnNumOfPalettes += m_Palettes.size();
-
 }
 
 PaletteManager::~PaletteManager()
@@ -466,6 +465,43 @@ void PaletteManager::DispatchColorCommand(const OUString& 
aCommand, const NamedC
     }
 }
 
+void PaletteManager::generateColorNamesJSON(tools::JsonWriter& aTree)
+{
+    XColorListRef xUserColorList;
+    OUString aPaletteStandard = SvxResId(RID_SVXSTR_COLOR_PALETTE_STANDARD);
+    PaletteManager aPaletteManager;
+    std::vector<OUString> aPaletteNames = aPaletteManager.GetPaletteList();
+    for (size_t i = 0, nLen = aPaletteNames.size(); i < nLen; ++i)
+    {
+        if (aPaletteStandard == aPaletteNames[i])
+        {
+            aPaletteManager.SetPalette(i);
+            xUserColorList
+                = 
XPropertyList::AsColorList(XPropertyList::CreatePropertyListFromURL(
+                    XPropertyListType::Color, 
aPaletteManager.GetSelectedPalettePath()));
+            if (!xUserColorList->Load())
+                xUserColorList = nullptr;
+            break;
+        }
+    }
+    if (xUserColorList)
+    {
+        auto colorNames = aTree.startArray("ColorNames");
+        int nCount = xUserColorList->Count();
+
+        for (int i = 0; i < nCount; i++)
+        {
+            XColorEntry* pColorEntry = xUserColorList->GetColor(i);
+            if (pColorEntry)
+            {
+                auto aColorTree = aTree.startStruct();
+                aTree.put("hexCode", pColorEntry->GetColor().AsRGBHEXString());
+                aTree.put("name", pColorEntry->GetName());
+            }
+        }
+    }
+}
+
 // TODO: make it generic, send any palette
 void PaletteManager::generateJSON(tools::JsonWriter& aTree, const 
std::set<Color>& rColors)
 {
diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx 
b/svx/source/theme/ThemeColorChangerCommon.cxx
index 39a20bd3441f..94a37908e36b 100644
--- a/svx/source/theme/ThemeColorChangerCommon.cxx
+++ b/svx/source/theme/ThemeColorChangerCommon.cxx
@@ -184,6 +184,8 @@ void notifyLOK(std::shared_ptr<model::ColorSet> const& 
pColorSet,
         if (rDocumentColors.size())
             PaletteManager::generateJSON(aTree, rDocumentColors);
 
+        PaletteManager::generateColorNamesJSON(aTree);
+
         SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aTree.finishAndGetAsOString());
     }
 }

Reply via email to