chart2/source/inc/ChartColorPalettes.hxx   |    4 +++
 chart2/source/tools/ChartColorPalettes.cxx |   33 +++++++++++++++++++++++++++--
 desktop/source/lib/init.cxx                |   16 ++++++++------
 3 files changed, 45 insertions(+), 8 deletions(-)

New commits:
commit 4c965bc30a0bd06dd6f74897a8f41a53535f778d
Author:     Marco Cecchetti <marco.cecche...@collabora.com>
AuthorDate: Tue Jun 10 19:03:10 2025 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Jun 12 08:44:49 2025 +0200

    lok: chart: color palette: send value set info for mouse over
    
    Send geometric information about an item of a value set so that it is
    possible to simulate mouse enter events on the client
    
    Change-Id: I3b1d21c5cdbe72e3a1587e17d3ecc30bff712555
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186339
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/chart2/source/inc/ChartColorPalettes.hxx 
b/chart2/source/inc/ChartColorPalettes.hxx
index 48e5e252bae4..8cb02e042d19 100644
--- a/chart2/source/inc/ChartColorPalettes.hxx
+++ b/chart2/source/inc/ChartColorPalettes.hxx
@@ -22,6 +22,7 @@ public:
     typedef Link<const MouseEvent&, void> MouseEventHandler;
 
 private:
+    OUString msDrawingAreaId;
     std::vector<ChartColorPalette> maColorSets;
     MouseEventHandler maMouseMoveHdl;
 
@@ -39,6 +40,9 @@ public:
     void insert(ChartColorPalette const& rColorSet);
     const ChartColorPalette* getPalette(sal_uInt32 nItem) const;
     void setMouseMoveHdl(const MouseEventHandler& rLink);
+
+private:
+    void sendItemInfo() const;
 };
 } // end namespace chart
 
diff --git a/chart2/source/tools/ChartColorPalettes.cxx 
b/chart2/source/tools/ChartColorPalettes.cxx
index 1ff465d1fea1..73742c6b30c1 100644
--- a/chart2/source/tools/ChartColorPalettes.cxx
+++ b/chart2/source/tools/ChartColorPalettes.cxx
@@ -9,6 +9,10 @@
 
 #include <ChartColorPalettes.hxx>
 #include <ChartColorPaletteHelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
+#include <sfx2/viewsh.hxx>
+#include <tools/json_writer.hxx>
 #include <vcl/event.hxx>
 
 namespace chart
@@ -34,9 +38,11 @@ const ChartColorPalette* 
ChartColorPalettes::getPalette(const sal_uInt32 nItem)
 void ChartColorPalettes::SetDrawingArea(weld::DrawingArea* pDrawingArea)
 {
     ValueSet::SetDrawingArea(pDrawingArea);
+    msDrawingAreaId = pDrawingArea->get_buildable_name();
+
     SetStyle(WB_TABSTOP | WB_DOUBLEBORDER | WB_FLATVALUESET);
     SetItemWidth(BORDER * 6 + SIZE * ChartColorPaletteSize / 2);
-    SetItemHeight(BORDER * 5 + SIZE * 2);
+    SetItemHeight(BORDER * 4 + SIZE * 2);
 }
 
 void ChartColorPalettes::UserDraw(const UserDrawEvent& rUserDrawEvent)
@@ -55,6 +61,25 @@ void ChartColorPalettes::StyleUpdated()
     ValueSet::StyleUpdated();
 }
 
+void ChartColorPalettes::sendItemInfo() const
+{
+    if (!comphelper::LibreOfficeKit::isActive() || msDrawingAreaId.isEmpty())
+        return;
+
+    tools::JsonWriter aJsonWriter;
+    aJsonWriter.put("jsontype", "valueset");
+    aJsonWriter.put("action", "update");
+    aJsonWriter.put("drawingarea", msDrawingAreaId);
+    aJsonWriter.put("itemwidth", BORDER * 6 + SIZE * ChartColorPaletteSize / 
2);
+    aJsonWriter.put("itemheight", BORDER * 4 + SIZE * 2);
+
+    if (const SfxViewShell* pViewShell = SfxViewShell::Current())
+    {
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG,
+                                               
aJsonWriter.finishAndGetAsOString());
+    }
+}
+
 bool ChartColorPalettes::MouseMove(const MouseEvent& rMEvt)
 {
     bool bRes = ValueSet::MouseMove(rMEvt);
@@ -62,7 +87,11 @@ bool ChartColorPalettes::MouseMove(const MouseEvent& rMEvt)
     return bRes;
 }
 
-void ChartColorPalettes::setMouseMoveHdl(const MouseEventHandler& rLink) { 
maMouseMoveHdl = rLink; }
+void ChartColorPalettes::setMouseMoveHdl(const MouseEventHandler& rLink)
+{
+    sendItemInfo();
+    maMouseMoveHdl = rLink;
+}
 
 } // end namespace chart
 
commit 9f314348bf96136f2c7c6f263b6e9bf703e1d680
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Mar 16 14:43:15 2025 +0000
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jun 12 08:44:41 2025 +0200

    rework getStyles a little to create a getComponentStyles function
    
    Change-Id: I0fed7f27100289e4934bcf818831a6cd4f2c1701
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183005
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e9f55f0bc09f..4ec74f31dc39 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6449,13 +6449,11 @@ static char* getFontSubset (std::string_view aFontName)
     return pJson;
 }
 
-static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
+static char* getComponentStyles(const 
css::uno::Reference<css::lang::XComponent>& rComponent, int docType, const 
char* pCommand)
 {
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
     boost::property_tree::ptree aTree;
     aTree.put("commandName", pCommand);
-    uno::Reference<css::style::XStyleFamiliesSupplier> 
xStyleFamiliesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
+    uno::Reference<css::style::XStyleFamiliesSupplier> 
xStyleFamiliesSupplier(rComponent, uno::UNO_QUERY);
     const uno::Reference<container::XNameAccess> xStyleFamilies = 
xStyleFamiliesSupplier->getStyleFamilies();
     if (!xStyleFamilies.is())
     {
@@ -6489,7 +6487,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
         // should be shown in the normal dropdown, which we should add to the 
start of the list
         // to simplify their selection.
         if (sStyleFam == "ParagraphStyles"
-            && doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+            && docType == LOK_DOCTYPE_TEXT)
         {
             for (const OUString& rStyle: aWriterStyles)
             {
@@ -6507,7 +6505,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
             // Filter out the default styles - they are already at the top
             // of the list
             if (aDefaultStyleNames.find(rStyle) == aDefaultStyleNames.end() ||
-                (sStyleFam != "ParagraphStyles" || doc_getDocumentType(pThis) 
!= LOK_DOCTYPE_TEXT) )
+                (sStyleFam != "ParagraphStyles" || docType != 
LOK_DOCTYPE_TEXT) )
             {
                 boost::property_tree::ptree aChild;
                 aChild.put("", rStyle.toUtf8());
@@ -6576,6 +6574,12 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
     return pJson;
 }
 
+static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
+{
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+    return getComponentStyles(pDocument->mxComponent, 
doc_getDocumentType(pThis), pCommand);
+}
+
 namespace {
 
 enum class UndoOrRedo

Reply via email to