sd/qa/unit/tiledrendering/tiledrendering.cxx |   10 ++++++----
 sd/source/ui/view/ViewShellBase.cxx          |   11 +++++++++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit f3e3e6442eb84f0fc73f6ddb7a0656307ff50b1b
Author:     Méven Car <[email protected]>
AuthorDate: Thu Mar 21 10:52:06 2024 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Mar 21 16:40:05 2024 +0100

    impress: Use json to send StartWithPresentation state
    
    To prevent potential issue, use the json format.
    
    Change-Id: I7eedc855255a30abdfdf61c8315b4f8238c07ca9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165094
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 79fd5534de10..40e1fc7e4ef6 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2970,14 +2970,16 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, 
testShapeEditInMultipleViews)
 CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testStartPresentation)
 {
     SdXImpressDocument* pXImpressDocument = createDoc("test.ppsx");
-    ViewCallback aView1;
+    ViewCallback aView;
     CPPUNIT_ASSERT(pXImpressDocument->GetDoc()->IsStartWithPresentation());
     Scheduler::ProcessEventsToIdle();
 
-    CPPUNIT_ASSERT(aView1.m_aStateChanged.size() >= 1);
+    const auto it = aView.m_aStateChanges.find(".uno:StartWithPresentation");
+    CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
 
-    CPPUNIT_ASSERT(std::find(aView1.m_aStateChanged.begin(),
-        aView1.m_aStateChanged.end(), ".uno:StartWithPresentation=true") != 
aView1.m_aStateChanged.end());
+    const auto value = it->second;
+    CPPUNIT_ASSERT(value.get_child_optional("state").has_value());
+    CPPUNIT_ASSERT_EQUAL(std::string("true"), 
value.get_child("state").get_value<std::string>());
 }
 
 CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide)
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index b308ad108b0a..88f9c3e77e88 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -19,6 +19,8 @@
 
 #include <comphelper/processfactory.hxx>
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <ViewShellBase.hxx>
 #include <algorithm>
 #include <EventMultiplexer.hxx>
@@ -1026,8 +1028,13 @@ void ViewShellBase::afterCallbackRegistered()
 
     if (mpDocument && mpDocument->IsStartWithPresentation())
     {
-        this->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
-                                        
".uno:StartWithPresentation=true"_ostr);
+        // Be consistent with SidebarController, emit JSON.
+        boost::property_tree::ptree aTree;
+        aTree.put("commandName", ".uno:StartWithPresentation");
+        aTree.put("state", "true");
+        std::stringstream aStream;
+        boost::property_tree::write_json(aStream, aTree);
+        libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, 
OString(aStream.str()));
     }
 }
 

Reply via email to