[Libreoffice-commits] core.git: framework/inc framework/source sfx2/sdi sfx2/source

Maxim Monastirsky (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 11 08:33:47 UTC 2020


 framework/inc/uielement/toolbarmodemenucontroller.hxx    |    9 -
 framework/source/uielement/toolbarmodemenucontroller.cxx |   82 ---------------
 sfx2/sdi/sfx.sdi                                         |    2 
 sfx2/source/appl/appserv.cxx                             |    8 -
 4 files changed, 8 insertions(+), 93 deletions(-)

New commits:
commit 3239708375c81005d66627c09d1907848cd0cfda
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Mon Aug 10 18:35:22 2020 +0300
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Tue Aug 11 10:33:00 2020 +0200

    Simplify toolbar mode switching
    
    Change-Id: I3bd809ce3ef661f6566a73e639fbd5e4bb1b7e3f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100439
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/framework/inc/uielement/toolbarmodemenucontroller.hxx b/framework/inc/uielement/toolbarmodemenucontroller.hxx
index 6fe03f455206..44f667dcb8d2 100644
--- a/framework/inc/uielement/toolbarmodemenucontroller.hxx
+++ b/framework/inc/uielement/toolbarmodemenucontroller.hxx
@@ -53,15 +53,6 @@ namespace framework
             // XEventListener
             virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
 
-            struct ExecuteInfo
-            {
-                css::uno::Reference< css::frame::XDispatch >     xDispatch;
-                css::util::URL                                   aTargetURL;
-                css::uno::Sequence< css::beans::PropertyValue >  aArgs;
-            };
-
-            DECL_STATIC_LINK( ToolbarModeMenuController, ExecuteHdl_Impl, void*, void );
-
         private:
             void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu );
 
diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx
index c2f48162145d..86dbda38f5b9 100644
--- a/framework/source/uielement/toolbarmodemenucontroller.cxx
+++ b/framework/source/uielement/toolbarmodemenucontroller.cxx
@@ -36,6 +36,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
 #include <comphelper/types.hxx>
 #include <svtools/miscopt.hxx>
 #include <unotools/confignode.hxx>
@@ -226,65 +227,8 @@ void SAL_CALL ToolbarModeMenuController::statusChanged( const FeatureStateEvent&
 // XMenuListener
 void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent& rEvent )
 {
-    Reference< css::awt::XPopupMenu >   xPopupMenu;
-    Reference< XURLTransformer >        xURLTransformer;
-    Reference< XFrame >                 xFrame;
-
-    {
-        osl::MutexGuard aLock(m_aMutex);
-        xPopupMenu = m_xPopupMenu;
-        xURLTransformer = m_xURLTransformer;
-        xFrame = m_xFrame;
-    }
-
-    if ( !xPopupMenu.is() )
-        return;
-
-    VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu ));
-    if ( !pPopupMenu )
-        return;
-
-    SolarMutexGuard aSolarMutexGuard;
-    PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
-    OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId ));
-
-    {
-        URL aTargetURL;
-        Sequence<PropertyValue> aArgs;
-
-        aTargetURL.Complete = ".uno:Notebookbar?File:string=" + aCmd;
-        xURLTransformer->parseStrict( aTargetURL );
-        Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
-        if ( xDispatchProvider.is() )
-        {
-            Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(
-                                                aTargetURL, OUString(), 0 );
-
-            ExecuteInfo* pExecuteInfo = new ExecuteInfo;
-            pExecuteInfo->xDispatch     = xDispatch;
-            pExecuteInfo->aTargetURL    = aTargetURL;
-            pExecuteInfo->aArgs         = aArgs;
-            Application::PostUserEvent( LINK(nullptr,ToolbarModeMenuController, ExecuteHdl_Impl), pExecuteInfo );
-        }
-    }
-
-    URL aTargetURL;
-    Sequence<PropertyValue> aArgs;
-
-    aTargetURL.Complete = ".uno:ToolbarMode?Mode:string=" + aCmd;
-    xURLTransformer->parseStrict( aTargetURL );
-    Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
-    if ( xDispatchProvider.is() )
-    {
-        Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(
-                                                aTargetURL, OUString(), 0 );
-
-        ExecuteInfo* pExecuteInfo = new ExecuteInfo;
-        pExecuteInfo->xDispatch     = xDispatch;
-        pExecuteInfo->aTargetURL    = aTargetURL;
-        pExecuteInfo->aArgs         = aArgs;
-        Application::PostUserEvent( LINK(nullptr, ToolbarModeMenuController, ExecuteHdl_Impl), pExecuteInfo );
-    }
+    auto aArgs(comphelper::InitPropertySequence({{"Mode", makeAny(m_xPopupMenu->getCommand(rEvent.MenuId))}}));
+    dispatchCommand(m_aCommandURL, aArgs);
 }
 
 void SAL_CALL ToolbarModeMenuController::itemActivated( const css::awt::MenuEvent& )
@@ -351,26 +295,6 @@ void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt
     }
 }
 
-IMPL_STATIC_LINK( ToolbarModeMenuController, ExecuteHdl_Impl, void*, p, void )
-{
-    ExecuteInfo* pExecuteInfo = static_cast<ExecuteInfo*>(p);
-    try
-    {
-        // Asynchronous execution as this can lead to our own destruction!
-        // Framework can recycle our current frame and the layout manager disposes all user interface
-        // elements if a component gets detached from its frame!
-        if ( pExecuteInfo->xDispatch.is() )
-        {
-            pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
-        }
-    }
-    catch ( const Exception& )
-    {
-    }
-
-    delete pExecuteInfo;
-}
-
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 888a0e4b41da..a50b5f1a17a6 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -2615,7 +2615,7 @@ SfxVoidItem Notebookbar SID_NOTEBOOKBAR
 (SfxStringItem File SID_NOTEBOOKBAR)
 [
     AutoUpdate = TRUE,
-    FastCall = FALSE,
+    FastCall = TRUE,
     ReadOnlyDoc = TRUE,
     Toggle = FALSE,
     Container = FALSE,
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 68f80d7e99e3..b07974a9b34a 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -892,6 +892,10 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
                         }
                     }
 
+                    // Show/Hide the Notebookbar
+                    const SfxStringItem pItem(SID_NOTEBOOKBAR, aNewName);
+                    pViewFrame->GetDispatcher()->ExecuteList(SID_NOTEBOOKBAR, SfxCallMode::SYNCHRON, {&pItem});
+
                     // Show toolbars
                     for ( const OUString& rName : std::as_const(aMandatoryToolbars) )
                     {
@@ -929,10 +933,6 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
                         }
                     }
 
-                    // Show/Hide the Notebookbar
-                    const SfxPoolItem* pItem;
-                    pViewFrame->GetDispatcher()->QueryState( SID_NOTEBOOKBAR, pItem );
-
                     // Save settings
                     if ( pViewFrame == SfxViewFrame::Current() )
                     {


More information about the Libreoffice-commits mailing list