sd/qa/unit/tiledrendering/tiledrendering.cxx | 24 ++++++++++++++++++++++++ sfx2/source/sidebar/SidebarController.cxx | 18 ++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-)
New commits: commit d8061151acf4e287b60a055a67b84c56989a37af Author: Miklos Vajna <[email protected]> AuthorDate: Thu Mar 21 17:01:20 2024 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Mar 21 21:30:17 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". Change-Id: I1678ee61e004697a6a5c6ecaf40a18b2d1d47e61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165108 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 8f0fd9cfc4ae..d270579e6c07 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -2983,6 +2983,30 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide) CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); } +CPPUNIT_TEST_FIXTURE(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_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 468ad56f080f..2437f7167db3 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -816,30 +816,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,
