[Libreoffice-commits] core.git: 2 commits - framework/source include/svtools svtools/source

Ariel Constenla-Haile arielch at apache.org
Sun May 26 12:39:26 PDT 2013


 framework/source/uielement/generictoolbarcontroller.cxx  |    6 +
 framework/source/uielement/recentfilesmenucontroller.cxx |    4 
 framework/source/uielement/toolbarmanager.cxx            |   16 ++
 include/svtools/toolboxcontroller.hxx                    |   17 ++-
 svtools/source/uno/toolboxcontroller.cxx                 |   84 +++++----------
 5 files changed, 69 insertions(+), 58 deletions(-)

New commits:
commit 16db62a9c0894e655d8ecc82c8ed64db94187c75
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Sat May 25 22:10:31 2013 +0000

    Recent file list: small fix when no documents
    
    (cherry picked from commit da18984094aa5ae4a66731bf581103298b133738)
    
    Change-Id: I56413b68d28b206212561dcbf662940862cebeb7

diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index 2be9117..57cf1d2 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -186,7 +186,9 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
         {
             // No recent documents => insert "no document" string
             pVCLPopupMenu->InsertItem( 1, String( FwkResId( STR_NODOCUMENT ) ) );
-            pVCLPopupMenu->EnableItem( 1, sal_False );
+            // Do not disable it, otherwise the Toolbar controller and MenuButton
+            // will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT
+            pVCLPopupMenu->SetItemBits( 1, pVCLPopupMenu->GetItemBits( 1 ) | MIB_NOSELECT );
         }
     }
 }
commit 1e85fc5b2d8aeafb12f414c6bf0692fb2ca221eb
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Sat May 25 22:10:02 2013 +0000

    svt::ToolboxController clean-up
    
    Some small clean-up to use the PopupMenu ToolbarController
    
    (cherry picked from commit e1687ce159e787d98f79d29a3d2131cca4b6ec71)
    
    Conflicts:
    	svtools/inc/svtools/toolboxcontroller.hxx
    	svtools/source/uno/toolboxcontroller.cxx
    
    Change-Id: Ie5e0397c32352d52cf2664bdbab920923e74bd03

diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index 6ed7651..fc6ad41 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/framework/source/uielement/generictoolbarcontroller.cxx
@@ -362,8 +362,14 @@ MenuToolbarController::createPopupWindow() throw (::com::sun::star::uno::Runtime
         }
     }
 
+    if ( !pMenu || !m_pToolbar )
+        return NULL;
+
+    OSL_ENSURE ( pMenu->GetItemCount(), "Empty PopupMenu!" );
+
     ::Rectangle aRect( m_pToolbar->GetItemRect( m_nID ) );
     pMenu->Execute( m_pToolbar, aRect, POPUPMENU_EXECUTE_DOWN );
+
     return NULL;
 }
 } // namespace
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 2ddcda5..675e839 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -928,6 +928,9 @@ void ToolBarManager::CreateControllers()
             aPropValue.Name     = OUString( "ParentWindow" );
             aPropValue.Value    <<= xToolbarWindow;
             aPropertyVector.push_back( makeAny( aPropValue ));
+            aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
+            aPropValue.Value    = uno::makeAny( nId );
+            aPropertyVector.push_back( uno::makeAny( aPropValue ) );
 
             if ( nWidth > 0 )
             {
@@ -1041,6 +1044,9 @@ void ToolBarManager::CreateControllers()
                 aPropValue.Name = OUString( "ModuleIdentifier" );
                 aPropValue.Value <<= m_aModuleIdentifier;
                 aPropertyVector.push_back( makeAny( aPropValue ));
+                aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
+                aPropValue.Value    = uno::makeAny( nId );
+                aPropertyVector.push_back( uno::makeAny( aPropValue ) );
 
                 if ( nWidth > 0 )
                 {
@@ -1248,9 +1254,12 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
                             try
                             {
                                 Reference< XIndexAccess > xMenuContainer;
-                                if ( m_xDocUICfgMgr.is() )
+                                if ( m_xDocUICfgMgr.is() &&
+                                     m_xDocUICfgMgr->hasSettings( aCommandURL ) )
                                     xMenuContainer  = m_xDocUICfgMgr->getSettings( aCommandURL, sal_False );
-                                if ( !xMenuContainer.is() && m_xUICfgMgr.is() )
+                                if ( !xMenuContainer.is() &&
+                                     m_xUICfgMgr.is() &&
+                                     m_xUICfgMgr->hasSettings( aCommandURL ) )
                                     xMenuContainer = m_xUICfgMgr->getSettings( aCommandURL, sal_False );
                                 if ( xMenuContainer.is() && xMenuContainer->getCount() )
                                 {
@@ -1297,7 +1306,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
 
                     sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
                     if ( aMenuDesc.is() )
+                    {
                         m_aMenuMap[ nId ] = aMenuDesc;
+                        nItemBits |= TIB_DROPDOWNONLY;
+                    }
                     m_pToolBar->InsertItem( nId, aString, nItemBits );
                     m_pToolBar->SetItemCommand( nId, aCommandURL );
                     if ( !aTooltip.isEmpty() )
diff --git a/include/svtools/toolboxcontroller.hxx b/include/svtools/toolboxcontroller.hxx
index 6bccf93..0212661 100644
--- a/include/svtools/toolboxcontroller.hxx
+++ b/include/svtools/toolboxcontroller.hxx
@@ -37,6 +37,7 @@
 #include <comphelper/property.hxx>
 #include <comphelper/propertycontainer.hxx>
 #include <cppuhelper/propshlp.hxx>
+#include <tools/link.hxx>
 
 #include <boost/unordered_map.hpp>
 
@@ -44,7 +45,8 @@ class ToolBox;
 
 namespace svt
 {
-struct ToolboxController_Impl;
+
+struct DispatchInfo;
 
 class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener,
                           public ::com::sun::star::frame::XToolbarController,
@@ -112,12 +114,15 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
 
 
         const OUString& getCommandURL() const { return  m_aCommandURL; }
-        const OUString& getModuleName() const;
+        const OUString& getModuleName() const { return m_sModuleName; }
+
 
         void dispatchCommand( const OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
 
         void enable( bool bEnable );
 
+        DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, DispatchInfo* );
+
     protected:
         bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
         void setSupportVisibleProperty(sal_Bool bValue); //shizhoubo
@@ -142,17 +147,23 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
         void unbindListener();
         sal_Bool isBound() const;
         sal_Bool hasBigImages() const;
+        // TODO remove
         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
+        // TODO remove
         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParent() const;
 
         sal_Bool                                                                            m_bInitialized : 1,
                                                                                             m_bDisposed : 1;
+        sal_uInt16                                                                          m_nToolBoxId;
         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >                 m_xFrame;
-        ToolboxController_Impl*                                                             m_pImpl;
         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
         OUString                                                                            m_aCommandURL;
         URLToDispatchMap                                                                    m_aListenerMap;
         ::cppu::OMultiTypeInterfaceContainerHelper                                          m_aListenerContainer;   /// container for ALL Listener
+
+        ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >          m_xParentWindow;
+        ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer;
+        OUString m_sModuleName;
 };
 
 }
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index d077b24..f845aed 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -59,20 +59,6 @@ struct DispatchInfo
         : mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
 };
 
-struct ToolboxController_Impl
-{
-    ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >          m_xParentWindow;
-    ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer;
-    OUString m_sModuleName;
-     sal_uInt16 m_nToolBoxId;
-
-    DECL_STATIC_LINK( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo* );
-
-    ToolboxController_Impl()
-        : m_nToolBoxId( SAL_MAX_UINT16 )
-    {}
-};
-
 ToolboxController::ToolboxController(
     const Reference< XComponentContext >& rxContext,
     const Reference< XFrame >& xFrame,
@@ -82,6 +68,7 @@ ToolboxController::ToolboxController(
     ,   m_bSupportVisible(sal_False)
     ,   m_bInitialized( sal_False )
     ,   m_bDisposed( sal_False )
+    ,   m_nToolBoxId( SAL_MAX_UINT16 )
     ,   m_xFrame(xFrame)
     ,   m_xContext( rxContext )
     ,   m_aCommandURL( aCommandURL )
@@ -93,11 +80,9 @@ ToolboxController::ToolboxController(
         css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
         &m_bSupportVisible, getCppuType(&m_bSupportVisible));
 
-    m_pImpl = new ToolboxController_Impl;
-
     try
     {
-        m_pImpl->m_xUrlTransformer = URLTransformer::create( rxContext );
+        m_xUrlTransformer = URLTransformer::create( rxContext );
     }
     catch(const Exception&)
     {
@@ -110,19 +95,17 @@ ToolboxController::ToolboxController() :
     ,   m_bSupportVisible(sal_False)
     ,   m_bInitialized( sal_False )
     ,   m_bDisposed( sal_False )
+    ,   m_nToolBoxId( SAL_MAX_UINT16 )
     ,   m_aListenerContainer( m_aMutex )
 {
     registerProperty( OUString(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE),
         TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE,
         css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
         &m_bSupportVisible, getCppuType(&m_bSupportVisible));
-
-    m_pImpl = new ToolboxController_Impl;
 }
 
 ToolboxController::~ToolboxController()
 {
-    delete m_pImpl;
 }
 
 Reference< XFrame > ToolboxController::getFrameInterface() const
@@ -230,16 +213,18 @@ throw ( Exception, RuntimeException )
                         m_xContext = comphelper::getComponentContext(xMSF);
                 }
                 else if ( aPropValue.Name == "ParentWindow" )
-                    m_pImpl->m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
+                    m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
                 else if ( aPropValue.Name == "ModuleIdentifier" )
-                    aPropValue.Value >>= m_pImpl->m_sModuleName;
+                    aPropValue.Value >>= m_sModuleName;
+                else if ( aPropValue.Name == "Identifier" )
+                    aPropValue.Value >>= m_nToolBoxId;
             }
         }
 
         try
         {
-            if ( !m_pImpl->m_xUrlTransformer.is() && m_xContext.is() )
-                m_pImpl->m_xUrlTransformer = URLTransformer::create( m_xContext );
+            if ( !m_xUrlTransformer.is() && m_xContext.is() )
+                m_xUrlTransformer = URLTransformer::create( m_xContext );
         }
         catch(const Exception&)
         {
@@ -289,8 +274,8 @@ throw (::com::sun::star::uno::RuntimeException)
 
             com::sun::star::util::URL aTargetURL;
             aTargetURL.Complete = pIter->first;
-            if ( m_pImpl->m_xUrlTransformer.is() )
-                m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+            if ( m_xUrlTransformer.is() )
+                m_xUrlTransformer->parseStrict( aTargetURL );
 
             if ( xDispatch.is() && xStatusListener.is() )
                 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
@@ -388,8 +373,8 @@ throw (::com::sun::star::uno::RuntimeException)
             aArgs[0].Value  = makeAny( KeyModifier );
 
             aTargetURL.Complete = aCommandURL;
-            if ( m_pImpl->m_xUrlTransformer.is() )
-                m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+            if ( m_xUrlTransformer.is() )
+                m_xUrlTransformer->parseStrict( aTargetURL );
             xDispatch->dispatch( aTargetURL, aArgs );
         }
         catch ( DisposedException& )
@@ -449,8 +434,8 @@ void ToolboxController::addStatusListener( const OUString& aCommandURL )
             if ( m_xContext.is() && xDispatchProvider.is() )
             {
                 aTargetURL.Complete = aCommandURL;
-                if ( m_pImpl->m_xUrlTransformer.is() )
-                    m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+                if ( m_xUrlTransformer.is() )
+                    m_xUrlTransformer->parseStrict( aTargetURL );
                 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
 
                 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
@@ -501,8 +486,8 @@ void ToolboxController::removeStatusListener( const OUString& aCommandURL )
         {
             com::sun::star::util::URL aTargetURL;
             aTargetURL.Complete = aCommandURL;
-            if ( m_pImpl->m_xUrlTransformer.is() )
-                m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+            if ( m_xUrlTransformer.is() )
+                m_xUrlTransformer->parseStrict( aTargetURL );
 
             if ( xDispatch.is() && xStatusListener.is() )
                 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
@@ -534,8 +519,8 @@ void ToolboxController::bindListener()
             {
                 com::sun::star::util::URL aTargetURL;
                 aTargetURL.Complete = pIter->first;
-                if ( m_pImpl->m_xUrlTransformer.is() )
-                    m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+                if ( m_xUrlTransformer.is() )
+                    m_xUrlTransformer->parseStrict( aTargetURL );
 
                 Reference< XDispatch > xDispatch( pIter->second );
                 if ( xDispatch.is() )
@@ -623,8 +608,8 @@ void ToolboxController::unbindListener()
         {
             com::sun::star::util::URL aTargetURL;
             aTargetURL.Complete = pIter->first;
-            if ( m_pImpl->m_xUrlTransformer.is() )
-                m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+            if ( m_xUrlTransformer.is() )
+                m_xUrlTransformer->parseStrict( aTargetURL );
 
             Reference< XDispatch > xDispatch( pIter->second );
             if ( xDispatch.is() )
@@ -687,8 +672,8 @@ void ToolboxController::updateStatus( const OUString aCommandURL )
         if ( m_xContext.is() && xDispatchProvider.is() )
         {
             aTargetURL.Complete = aCommandURL;
-            if ( m_pImpl->m_xUrlTransformer.is() )
-                m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
+            if ( m_xUrlTransformer.is() )
+                m_xUrlTransformer->parseStrict( aTargetURL );
             xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
         }
     }
@@ -712,17 +697,12 @@ void ToolboxController::updateStatus( const OUString aCommandURL )
 
 Reference< XURLTransformer > ToolboxController::getURLTransformer() const
 {
-    return m_pImpl->m_xUrlTransformer;
+    return m_xUrlTransformer;
 }
 
 Reference< ::com::sun::star::awt::XWindow > ToolboxController::getParent() const
 {
-    return m_pImpl->m_xParentWindow;
-}
-
-const OUString& ToolboxController::getModuleName() const
-{
-    return m_pImpl->m_sModuleName;
+    return m_xParentWindow;
 }
 
 void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs )
@@ -736,7 +716,7 @@ void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequ
 
         Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW );
 
-        Application::PostUserEvent( STATIC_LINK(0, ToolboxController_Impl, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
+        Application::PostUserEvent( STATIC_LINK(0, ToolboxController, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
 
     }
     catch( Exception& )
@@ -810,7 +790,7 @@ throw( com::sun::star::uno::Exception)
 
 //--------------------------------------------------------------------
 
-IMPL_STATIC_LINK_NOINSTANCE( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
+IMPL_STATIC_LINK_NOINSTANCE( ToolboxController, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
 {
     pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs );
     delete pDispatchInfo;
@@ -829,12 +809,12 @@ void ToolboxController::enable( bool bEnable )
 
 bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
 {
-    if( (m_pImpl->m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
-        return m_pImpl->m_nToolBoxId;
+    if( (m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
+        return m_nToolBoxId;
 
     ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
 
-    if( (m_pImpl->m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
+    if( (m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
     {
         const sal_uInt16 nCount = pToolBox->GetItemCount();
         for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
@@ -842,7 +822,7 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
             const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
             if ( pToolBox->GetItemCommand( nItemId ) == String( m_aCommandURL ) )
             {
-                m_pImpl->m_nToolBoxId = nItemId;
+                m_nToolBoxId = nItemId;
                 break;
             }
         }
@@ -851,7 +831,7 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
     if( ppToolBox )
         *ppToolBox = pToolBox;
 
-    rItemId = m_pImpl->m_nToolBoxId;
+    rItemId = m_nToolBoxId;
 
     return (rItemId != SAL_MAX_UINT16) && (( ppToolBox == 0) || (*ppToolBox != 0) );
 }


More information about the Libreoffice-commits mailing list