sd/qa/unit/tiledrendering/tiledrendering.cxx | 26 ++++++++++++++++++++++++++ sfx2/source/sidebar/SidebarController.cxx | 18 ++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-)
New commits: commit 7f7b1578dafc11705feb8d99f997041d84df5aee Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 21 17:01:20 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri Mar 22 13:14:26 2024 +0100 cool#8278 sfx2 lok: fix lost hide notification on sidebar switch Similar to commit 55feb670ca28e0a48ac82a65b5559598704d993e (cool#8278 sfx2 lok: fix unexpected non-json sidebar status update, 2024-03-21), the trouble here was not around hiding the sidebar but around switching between decks. This went wrong in commit aaf6ce108e91b1504befe19afcee471e3316ae7a (cool#7492 sfx2 lok: set language/locale on async sidebar update, 2024-01-11), where I didn't notice that SidebarController::SwitchToDeck() may emit two callbacks, so the effort to avoid code duplication went a bit too far: the hide+show case only emitted a show callback. Fix this by building a list of state changes to emit, so once se switch decks, not only the new one is "on", but also the old one is "off". (cherry picked from commit d8061151acf4e287b60a055a67b84c56989a37af) (cherry picked from commit a521fc2917e8f887f4e53788bf31935998ba1ad1) Conflicts: sd/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: I1678ee61e004697a6a5c6ecaf40a18b2d1d47e61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165158 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 236185d73c73..19a9ca350243 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -134,6 +134,7 @@ public: void testPasteUndo(); void testShapeEditInMultipleViews(); void testSidebarHide(); + void testSidebarSwitchDeck(); void testGetViewRenderState(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); @@ -196,6 +197,7 @@ public: CPPUNIT_TEST(testPasteUndo); CPPUNIT_TEST(testShapeEditInMultipleViews); CPPUNIT_TEST(testSidebarHide); + CPPUNIT_TEST(testSidebarSwitchDeck); CPPUNIT_TEST(testGetViewRenderState); CPPUNIT_TEST_SUITE_END(); @@ -3141,6 +3143,30 @@ void SdTiledRenderingTest::testSidebarHide() CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); } +void SdTiledRenderingTest::testSidebarSwitchDeck() +{ + // Given an impress document, with a visible sidebar (ModifyPage deck): + createDoc("dummy.odp"); + ViewCallback aView; + sfx2::sidebar::Sidebar::Setup(u""); + Scheduler::ProcessEventsToIdle(); + aView.m_aStateChanges.clear(); + + // When switching to the MasterSlidesPanel deck: + dispatchCommand(mxComponent, ".uno:MasterSlidesPanel", {}); + + // Then make sure notifications are sent for both the old and the new decks: + auto it = aView.m_aStateChanges.find(".uno:ModifyPage"); + // Without the accompanying fix in place, this test would have failed, the notification for the + // old deck was missing. + CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); + boost::property_tree::ptree aTree = it->second; + CPPUNIT_ASSERT(aTree.get_child_optional("state").has_value()); + CPPUNIT_ASSERT_EQUAL(std::string("false"), aTree.get_child("state").get_value<std::string>()); + it = aView.m_aStateChanges.find(".uno:MasterSlidesPanel"); + CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 82dee4895f03..65e8957ff6b8 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -811,30 +811,28 @@ void SidebarController::SwitchToDeck ( { if (const SfxViewShell* pViewShell = mpViewFrame->GetViewShell()) { - boost::property_tree::ptree aTree; - aTree.put("locale", comphelper::LibreOfficeKit::getLocale().getBcp47()); - bool bStateChanged = false; + std::vector<std::pair<std::string, std::string>> aStateChanges; if (msCurrentDeckId != rDeckDescriptor.msId) { const std::string hide = UnoNameFromDeckId(msCurrentDeckId, GetCurrentContext()); if (!hide.empty()) { - aTree.put("commandName", hide); - aTree.put("state", "false"); - bStateChanged = true; + aStateChanges.push_back({hide, std::string("false")}); } } const std::string show = UnoNameFromDeckId(rDeckDescriptor.msId, GetCurrentContext()); if (!show.empty()) { - aTree.put("commandName", show); - aTree.put("state", "true"); - bStateChanged = true; + aStateChanges.push_back({show, std::string("true")}); } - if (bStateChanged) + for (const auto& rStateChange : aStateChanges) { + boost::property_tree::ptree aTree; + aTree.put("locale", comphelper::LibreOfficeKit::getLocale().getBcp47()); + aTree.put("commandName", rStateChange.first); + aTree.put("state", rStateChange.second); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,