sd/qa/unit/tiledrendering/tiledrendering.cxx |   26 ++++++++++++++++++++++++++
 sd/source/ui/view/drviewsg.cxx               |   16 ++++++++++++++++
 2 files changed, 42 insertions(+)

New commits:
commit 13267d5a40331f1e038501e94638ffa9db935428
Author:     Gökay Şatır <[email protected]>
AuthorDate: Tue Sep 24 13:30:22 2024 +0300
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Sep 25 09:04:25 2024 +0200

    cool#7406 Inform lokit side about the grid state.
    
    When grid in impress or draw is turned on, we need to inform libreofficekit.
    So it can show relevant UI and act accordingly. Same goes for griduse 
command.
    
    Also add a test for the new state callbacks.
    
    Signed-off-by: Gökay Şatır <[email protected]>
    Change-Id: Ia5737ca0088e434f826eb7c40b0bec59049432af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173855
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 72a71bc23fb9..a545e7becd62 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1709,6 +1709,32 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testTdf105502)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aLastCell.mnRow);
 }
 
+CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testShowAndUseGridCallbacks)
+{
+    /*
+        Showing and hiding grid is done via one command. Command toggles the 
grid state.
+        Also "snapping the objects to grid" feature is toggled via one command.
+        Here we switch on and off these 2 features and check the callbacks.
+    */
+
+    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+    
pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+
+    ViewCallback aView;
+
+    dispatchCommand(mxComponent, ".uno:GridVisible", 
uno::Sequence<beans::PropertyValue>());
+    CPPUNIT_ASSERT(std::find(aView.m_aStateChanged.begin(), 
aView.m_aStateChanged.end(), ".uno:GridVisible=true") != 
aView.m_aStateChanged.end());
+
+    dispatchCommand(mxComponent, ".uno:GridVisible", 
uno::Sequence<beans::PropertyValue>());
+    CPPUNIT_ASSERT(std::find(aView.m_aStateChanged.begin(), 
aView.m_aStateChanged.end(), ".uno:GridVisible=false") != 
aView.m_aStateChanged.end());
+
+    dispatchCommand(mxComponent, ".uno:GridUse", 
uno::Sequence<beans::PropertyValue>());
+    CPPUNIT_ASSERT(std::find(aView.m_aStateChanged.begin(), 
aView.m_aStateChanged.end(), ".uno:GridUse=false") != 
aView.m_aStateChanged.end());
+
+    dispatchCommand(mxComponent, ".uno:GridUse", 
uno::Sequence<beans::PropertyValue>());
+    CPPUNIT_ASSERT(std::find(aView.m_aStateChanged.begin(), 
aView.m_aStateChanged.end(), ".uno:GridUse=true") != 
aView.m_aStateChanged.end());
+}
+
 CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentCallbacks)
 {
     // Load the document.
diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx
index 2563168433d8..c5e154f8dd67 100644
--- a/sd/source/ui/view/drviewsg.cxx
+++ b/sd/source/ui/view/drviewsg.cxx
@@ -29,6 +29,10 @@
 
 #include <app.hrc>
 
+#include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
 #include <drawdoc.hxx>
 #include <sdmod.hxx>
 #include <optsitem.hxx>
@@ -114,12 +118,24 @@ void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
         case SID_GRID_VISIBLE: // not here yet!
         {
             pOptions->SetGridVisible( !mpDrawView->IsGridVisible() );
+
+            if (comphelper::LibreOfficeKit::isActive())
+            {
+                OString state = !mpDrawView->IsGridVisible() ? 
".uno:GridVisible=true"_ostr: ".uno:GridVisible=false"_ostr;
+                
SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, 
state);
+            }
         }
         break;
 
         case SID_GRID_USE:
         {
             pOptions->SetUseGridSnap( !mpDrawView->IsGridSnap() );
+
+            if (comphelper::LibreOfficeKit::isActive())
+            {
+                OString state = !mpDrawView->IsGridSnap() ? 
".uno:GridUse=true"_ostr: ".uno:GridUse=false"_ostr;
+                
SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, 
state);
+            }
         }
         break;
 

Reply via email to