sfx2/source/sidebar/SidebarController.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
New commits: commit 6f1c9906513bdd0a2b4c6d1bc3d8b841ea1971ee Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Aug 17 12:52:55 2022 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Aug 17 16:04:51 2022 +0200 Move application check to the point where it matters This simplifies and deduplicates call sites, and also makes sure that we don't lookup strings until we need that. Also helps adding a check for Math in a follow-up. Change-Id: I6b073253f19afbb9a95f29806ab306c6a9f63f18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138413 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 28914ddeb64d3c7a67093b75f399264e12a66a1d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138415 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 22d48cc90bf0..2709639cb7de 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -71,13 +71,13 @@ namespace const sal_Int32 gnWidthCloseThreshold (70); const sal_Int32 gnWidthOpenThreshold (40); - std::string UnoNameFromDeckId(std::u16string_view rsDeckId, bool isImpress = false) + std::string UnoNameFromDeckId(std::u16string_view rsDeckId, const sfx2::sidebar::Context& context) { if (rsDeckId == u"SdCustomAnimationDeck") return ".uno:CustomAnimation"; if (rsDeckId == u"PropertyDeck") - return isImpress ? ".uno:ModifyPage" : ".uno:Sidebar"; + return vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(context.msApplication) ? ".uno:ModifyPage" : ".uno:Sidebar"; if (rsDeckId == u"SdLayoutsDeck") return ".uno:ModifyPage"; @@ -225,7 +225,7 @@ void SidebarController::disposeDecks() { if (const SfxViewShell* pViewShell = mpViewFrame->GetViewShell()) { - const std::string hide = UnoNameFromDeckId(msCurrentDeckId, vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(GetCurrentContext().msApplication)); + const std::string hide = UnoNameFromDeckId(msCurrentDeckId, GetCurrentContext()); if (!hide.empty()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, (hide + "=false").c_str()); @@ -801,13 +801,13 @@ void SidebarController::SwitchToDeck ( { if (msCurrentDeckId != rDeckDescriptor.msId) { - const std::string hide = UnoNameFromDeckId(msCurrentDeckId, vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(GetCurrentContext().msApplication)); + const std::string hide = UnoNameFromDeckId(msCurrentDeckId, GetCurrentContext()); if (!hide.empty()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, (hide + "=false").c_str()); } - const std::string show = UnoNameFromDeckId(rDeckDescriptor.msId, vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(GetCurrentContext().msApplication)); + const std::string show = UnoNameFromDeckId(rDeckDescriptor.msId, GetCurrentContext()); if (!show.empty()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, (show + "=true").c_str()); @@ -1325,7 +1325,7 @@ void SidebarController::UpdateDeckOpenState() if (const SfxViewShell* pViewShell = mpViewFrame->GetViewShell()) { - const std::string uno = UnoNameFromDeckId(msCurrentDeckId, vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(GetCurrentContext().msApplication)); + const std::string uno = UnoNameFromDeckId(msCurrentDeckId, GetCurrentContext()); if (!uno.empty()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, (uno + "=true").c_str()); @@ -1363,7 +1363,7 @@ void SidebarController::UpdateDeckOpenState() if (const SfxViewShell* pViewShell = mpViewFrame->GetViewShell()) { - const std::string uno = UnoNameFromDeckId(msCurrentDeckId, vcl::EnumContext::Application::Impress == vcl::EnumContext::GetApplicationEnum(GetCurrentContext().msApplication)); + const std::string uno = UnoNameFromDeckId(msCurrentDeckId, GetCurrentContext()); if (!uno.empty()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, (uno + "=false").c_str());