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 4d4ca1500e0fe919b5d5604f0e61f7bef744c59f
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 Apr 29 09:13:27 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>

diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index 5dd053f5a227..9b05e4df3173 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -37,6 +37,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;
@@ -91,6 +96,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 a1be44905351..06f88b4f6e74 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -189,6 +189,8 @@ private:
 
     sal_uInt16              nCurRefDlgId;
 
+    bool                    bIsTabChangeInProgress;
+
     std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster;
 
     // ugly hack for Add button in ScNameDlg
@@ -287,6 +289,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 f9e534d55cd2..c322786de7fa 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1891,6 +1891,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");
@@ -2092,7 +2095,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(
@@ -2135,6 +2137,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 af8496c347b6..681f4d26429d 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 8e1f6860d619..0e76df65f9f0 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -475,7 +475,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 426da02c94d8..d36a025fbaed 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -69,7 +69,6 @@ PaletteManager::PaletteManager() :
         pColorList = XColorList::CreateStdColorList();
     LoadPalettes();
     mnNumOfPalettes += m_Palettes.size();
-
 }
 
 PaletteManager::PaletteManager(const PaletteManager* pClone)
@@ -486,6 +485,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