[Libreoffice-commits] core.git: sfx2/source sfx2/uiconfig

Maxim Monastirsky momonasmon at gmail.com
Fri Sep 9 07:20:42 UTC 2016


 sfx2/source/dialog/recfloat.cxx    |  138 -------------------------------------
 sfx2/source/inc/recfloat.hxx       |    5 -
 sfx2/uiconfig/ui/floatingrecord.ui |    3 
 3 files changed, 1 insertion(+), 145 deletions(-)

New commits:
commit ccb986bae00ece4c1402ea89e66c9e46a331c8b1
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Fri Sep 9 10:00:34 2016 +0300

    Simplify SfxRecordingFloat_Impl by using SidebarToolBox
    
    Change-Id: I3d2348d8e3db91b0ae4e757efa14a0168604a2b0

diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index 780fb40..aebfd9c 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -18,15 +18,9 @@
  */
 
 #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
-#include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 #include <svl/eitem.hxx>
-#include <svtools/generictoolboxcontroller.hxx>
 #include <vcl/msgbox.hxx>
-#include <comphelper/processfactory.hxx>
 
 #include "recfloat.hxx"
 #include "dialog.hrc"
@@ -38,90 +32,6 @@
 #include <sfx2/viewsh.hxx>
 #include <sfx2/imagemgr.hxx>
 
-using namespace ::com::sun::star;
-
-static OUString GetLabelFromCommandURL( const OUString& rCommandURL, const uno::Reference< frame::XFrame >& xFrame )
-{
-    OUString aLabel;
-    OUString aModuleIdentifier;
-    uno::Reference< container::XNameAccess > xUICommandLabels;
-    uno::Reference< uno::XComponentContext > xContext;
-    uno::Reference< container::XNameAccess > xUICommandDescription;
-    uno::Reference< css::frame::XModuleManager2 > xModuleManager;
-
-    static uno::WeakReference< uno::XComponentContext > xTmpContext;
-    static uno::WeakReference< container::XNameAccess > xTmpNameAccess;
-    static uno::WeakReference< css::frame::XModuleManager2 > xTmpModuleMgr;
-
-    xContext = xTmpContext;
-    if ( !xContext.is() )
-    {
-        xContext = ::comphelper::getProcessComponentContext();
-        xTmpContext = xContext;
-    }
-
-    xUICommandDescription = xTmpNameAccess;
-    if ( !xUICommandDescription.is() )
-    {
-        xUICommandDescription = frame::theUICommandDescription::get(xContext);
-        xTmpNameAccess = xUICommandDescription;
-    }
-
-    xModuleManager = xTmpModuleMgr;
-    if ( !xModuleManager.is() )
-    {
-        xModuleManager = frame::ModuleManager::create(xContext);
-        xTmpModuleMgr = xModuleManager;
-    }
-
-    // Retrieve label from UI command description service
-    try
-    {
-        try
-        {
-            aModuleIdentifier = xModuleManager->identify( xFrame );
-        }
-        catch( uno::Exception& )
-        {
-        }
-
-        uno::Any a = xUICommandDescription->getByName( aModuleIdentifier );
-        uno::Reference< container::XNameAccess > xUICommands;
-        a >>= xUICommandLabels;
-    }
-    catch ( uno::Exception& )
-    {
-    }
-
-    if ( xUICommandLabels.is() )
-    {
-        try
-        {
-            if ( !rCommandURL.isEmpty() )
-            {
-                uno::Sequence< beans::PropertyValue > aPropSeq;
-                uno::Any a( xUICommandLabels->getByName( rCommandURL ));
-                if ( a >>= aPropSeq )
-                {
-                    for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
-                    {
-                        if ( aPropSeq[i].Name == "Label" )
-                        {
-                            aPropSeq[i].Value >>= aLabel;
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        catch (uno::Exception& )
-        {
-        }
-    }
-
-    return aLabel;
-}
-
 SFX_IMPL_FLOATINGWINDOW( SfxRecordingFloatWrapper_Impl, SID_RECORDING_FLOATWINDOW );
 
 SfxRecordingFloatWrapper_Impl::SfxRecordingFloatWrapper_Impl( vcl::Window* pParentWnd ,
@@ -169,29 +79,6 @@ SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(
                          pParent,
                          "FloatingRecord", "sfx/ui/floatingrecord.ui", pBind->GetActiveFrame() )
 {
-    get(m_pTbx, "toolbar");
-
-    // Retrieve label from helper function
-    uno::Reference< frame::XFrame > xFrame = getFrame();
-    OUString aCommandStr( ".uno:StopRecording" );
-    sal_uInt16 nItemId = m_pTbx->GetItemId(aCommandStr);
-    m_pTbx->SetItemText( nItemId, GetLabelFromCommandURL( aCommandStr, xFrame ));
-
-    // create a generic toolbox controller for our internal toolbox
-    svt::GenericToolboxController* pController = new svt::GenericToolboxController(
-                                                    ::comphelper::getProcessComponentContext(),
-                                                    xFrame,
-                                                    m_pTbx,
-                                                    nItemId,
-                                                    aCommandStr );
-    xStopRecTbxCtrl.set( static_cast< cppu::OWeakObject* >( pController ),
-                         uno::UNO_QUERY );
-    uno::Reference< util::XUpdatable > xUpdate( xStopRecTbxCtrl, uno::UNO_QUERY );
-    if ( xUpdate.is() )
-        xUpdate->update();
-
-    m_pTbx->SetSelectHdl( LINK( this, SfxRecordingFloat_Impl, Select ) );
-
     // start recording
     SfxBoolItem aItem( SID_RECORDMACRO, true );
     GetBindings().GetDispatcher()->ExecuteList(SID_RECORDMACRO,
@@ -203,23 +90,6 @@ SfxRecordingFloat_Impl::~SfxRecordingFloat_Impl()
     disposeOnce();
 }
 
-void SfxRecordingFloat_Impl::dispose()
-{
-    try
-    {
-        if ( xStopRecTbxCtrl.is() )
-        {
-            uno::Reference< lang::XComponent > xComp( xStopRecTbxCtrl, uno::UNO_QUERY );
-            xComp->dispose();
-        }
-    }
-    catch ( uno::Exception& )
-    {
-    }
-    m_pTbx.clear();
-    SfxFloatingWindow::dispose();
-}
-
 bool SfxRecordingFloat_Impl::Close()
 {
     bool bRet = SfxFloatingWindow::Close();
@@ -249,12 +119,4 @@ void SfxRecordingFloat_Impl::StateChanged( StateChangedType nStateChange )
     SfxFloatingWindow::StateChanged( nStateChange );
 }
 
-IMPL_LINK_TYPED( SfxRecordingFloat_Impl, Select, ToolBox*, pToolBar, void )
-{
-    (void)pToolBar;
-    sal_Int16   nKeyModifier( (sal_Int16)m_pTbx->GetModifier() );
-    if ( xStopRecTbxCtrl.is() )
-        xStopRecTbxCtrl->execute( nKeyModifier );
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/recfloat.hxx b/sfx2/source/inc/recfloat.hxx
index 7238e2a..fd02b24 100644
--- a/sfx2/source/inc/recfloat.hxx
+++ b/sfx2/source/inc/recfloat.hxx
@@ -39,19 +39,14 @@ public:
 
 class SfxRecordingFloat_Impl : public SfxFloatingWindow
 {
-    VclPtr<ToolBox>                m_pTbx;
-    css::uno::Reference< css::frame::XToolbarController > xStopRecTbxCtrl;
 public:
                         SfxRecordingFloat_Impl( SfxBindings* pBindings ,
                             SfxChildWindow* pChildWin ,
                             vcl::Window* pParent );
     virtual             ~SfxRecordingFloat_Impl();
-    virtual void        dispose() override;
     virtual bool        Close() override;
     virtual void        FillInfo( SfxChildWinInfo& rInfo ) const override;
     virtual void        StateChanged( StateChangedType nStateChange ) override;
-
-    DECL_LINK_TYPED( Select, ToolBox *, void );
 };
 
 #endif
diff --git a/sfx2/uiconfig/ui/floatingrecord.ui b/sfx2/uiconfig/ui/floatingrecord.ui
index 9136b38..56f521b 100644
--- a/sfx2/uiconfig/ui/floatingrecord.ui
+++ b/sfx2/uiconfig/ui/floatingrecord.ui
@@ -17,7 +17,7 @@
         <property name="vexpand">True</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkToolbar" id="toolbar">
+          <object class="sfxlo-SidebarToolBox" id="toolbar">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
@@ -31,7 +31,6 @@
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
                 <property name="action_name">.uno:StopRecording</property>
-                <property name="label" translatable="yes">Stop Recording</property>
                 <property name="use_underline">True</property>
               </object>
               <packing>


More information about the Libreoffice-commits mailing list