sfx2/source/sidebar/SidebarController.cxx |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 1f088bb8dddfb71ebb7f5bba701a28c05651436b
Author:     Mike Kaganski <[email protected]>
AuthorDate: Wed Aug 17 12:52:55 2022 +0300
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Aug 17 13:02:33 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 <[email protected]>

diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index 4384482e6740..ff645ce23384 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -70,13 +70,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";
@@ -223,7 +223,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());
@@ -803,13 +803,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());
@@ -1326,7 +1326,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());
@@ -1364,7 +1364,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());

Reply via email to