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

Maxim Monastirsky momonasmon at gmail.com
Sat Jan 9 12:59:52 PST 2016


 framework/inc/uielement/toolbarmerger.hxx           |    6 ++++-
 framework/source/uielement/addonstoolbarmanager.cxx |    6 +++--
 framework/source/uielement/toolbarmanager.cxx       |    2 +
 framework/source/uielement/toolbarmerger.cxx        |   23 ++++++++++++++------
 4 files changed, 28 insertions(+), 9 deletions(-)

New commits:
commit ee3cd777e187669f2d9dec156854c00cab948a50
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Sat Jan 9 22:46:16 2016 +0200

    Fix Addons.xcu toolbar items width handling
    
    This is useful for some complex controls (e.g. Combobox).
    Regression of cb4177b5f6d2c63548fa544a19b36001c57193e4
    
    Change-Id: I683cc20e9db72a4dd58d89063ec6bfcd05a1068e

diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx
index ea1ab34..4ad1467 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -44,6 +44,7 @@ struct AddonsParams
     OUString aImageId;
     OUString aTarget;
     OUString aControlType;
+    sal_uInt16 nWidth;
 };
 
 struct AddonToolbarItem
@@ -54,6 +55,7 @@ struct AddonToolbarItem
     OUString aTarget;
     OUString aContext;
     OUString aControlType;
+    sal_uInt16 nWidth;
 };
 
 typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
@@ -79,7 +81,8 @@ class ToolBarMerger
                                                    OUString& rImageIdentifier,
                                                    OUString& rTarget,
                                                    OUString& rContext,
-                                                   OUString& rControlType );
+                                                   OUString& rControlType,
+                                                   sal_uInt16& rWidth );
 
         static ReferenceToolbarPathInfo FindReferencePoint( ToolBox* pToolbar,
                                                             const OUString& rReferencePoint );
@@ -131,6 +134,7 @@ class ToolBarMerger
             ToolBox*        pToolbar,
             const OUString& rCommandURL,
             sal_uInt16      nId,
+            sal_uInt16      nWidth,
             const OUString& rControlType );
 
         static void CreateToolbarItem( ToolBox* pToolbox,
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx
index d6e2327..80f6e80 100644
--- a/framework/source/uielement/addonstoolbarmanager.cxx
+++ b/framework/source/uielement/addonstoolbarmanager.cxx
@@ -229,10 +229,11 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
         OUString   aContext;
         OUString   aTarget;
         OUString   aControlType;
+        sal_uInt16 nWidth( 0 );
 
         const Sequence< PropertyValue >& rSeq = rAddonToolbar[n];
 
-        ToolBarMerger::ConvertSequenceToValues( rSeq, aURL, aTitle, aImageId, aTarget, aContext, aControlType );
+        ToolBarMerger::ConvertSequenceToValues( rSeq, aURL, aTitle, aImageId, aTarget, aContext, aControlType, nWidth );
 
         if ( IsCorrectContext( aModuleIdentifier, aContext ))
         {
@@ -263,6 +264,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
                 AddonsParams* pRuntimeItemData = new AddonsParams;
                 pRuntimeItemData->aImageId  = aImageId;
                 pRuntimeItemData->aTarget   = aTarget;
+                pRuntimeItemData->nWidth    = nWidth;
                 m_pToolBar->SetItemData( nId, pRuntimeItemData );
                 m_pToolBar->SetItemCommand( nId, aURL );
 
@@ -308,7 +310,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
                 {
                     ::cppu::OWeakObject* pController = nullptr;
 
-                    pController = ToolBarMerger::CreateController( m_xContext, m_xFrame, m_pToolBar, aURL, nId, aControlType );
+                    pController = ToolBarMerger::CreateController( m_xContext, m_xFrame, m_pToolBar, aURL, nId, nWidth, aControlType );
                     xController.set( pController, UNO_QUERY );
                 }
 
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 25eda26..061bf5c 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -707,6 +707,7 @@ void ToolBarManager::CreateControllers()
                 {
                     // retrieve additional parameters
                     OUString aControlType = static_cast< AddonsParams* >( m_pToolBar->GetItemData( nId ))->aControlType;
+                    sal_uInt16 nWidth = static_cast< AddonsParams* >( m_pToolBar->GetItemData( nId ))->nWidth;
 
                     Reference< XStatusListener > xStatusListener(
                         ToolBarMerger::CreateController( m_xContext,
@@ -714,6 +715,7 @@ void ToolBarManager::CreateControllers()
                                                          m_pToolBar,
                                                          aCommandURL,
                                                          nId,
+                                                         nWidth,
                                                          aControlType ), UNO_QUERY );
 
                     xController = xStatusListener;
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 8d12efb..4f97ee2 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -33,6 +33,7 @@ static const char MERGE_TOOLBAR_IMAGEID[]         = "ImageIdentifier";
 static const char MERGE_TOOLBAR_CONTEXT[]         = "Context";
 static const char MERGE_TOOLBAR_TARGET[]          = "Target";
 static const char MERGE_TOOLBAR_CONTROLTYPE[]     = "ControlType";
+static const char MERGE_TOOLBAR_WIDTH[]           = "Width";
 
 static const char MERGECOMMAND_ADDAFTER[]         = "AddAfter";
 static const char MERGECOMMAND_ADDBEFORE[]        = "AddBefore";
@@ -120,7 +121,8 @@ bool ToolBarMerger::ConvertSeqSeqToVector(
                                  aAddonToolbarItem.aImageIdentifier,
                                  aAddonToolbarItem.aTarget,
                                  aAddonToolbarItem.aContext,
-                                 aAddonToolbarItem.aControlType );
+                                 aAddonToolbarItem.aControlType,
+                                 aAddonToolbarItem.nWidth );
         rContainer.push_back( aAddonToolbarItem );
     }
 
@@ -184,7 +186,8 @@ void ToolBarMerger::ConvertSequenceToValues(
     OUString& rImageIdentifier,
     OUString& rTarget,
     OUString& rContext,
-    OUString& rControlType )
+    OUString& rControlType,
+    sal_uInt16& rWidth )
 {
     for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
     {
@@ -200,6 +203,12 @@ void ToolBarMerger::ConvertSequenceToValues(
             rSequence[i].Value >>= rTarget;
         else if ( rSequence[i].Name == MERGE_TOOLBAR_CONTROLTYPE )
             rSequence[i].Value >>= rControlType;
+        else if ( rSequence[i].Name == MERGE_TOOLBAR_WIDTH )
+        {
+            sal_Int32 aValue = 0;
+            rSequence[i].Value >>= aValue;
+            rWidth = sal_uInt16( aValue );
+        }
     }
 }
 
@@ -622,6 +631,7 @@ bool ToolBarMerger::RemoveItems(
     ToolBox*               pToolbar,
     const OUString& rCommandURL,
     sal_uInt16             nId,
+    sal_uInt16             nWidth,
     const OUString& rControlType )
 {
     ::cppu::OWeakObject* pResult( nullptr );
@@ -629,15 +639,15 @@ bool ToolBarMerger::RemoveItems(
     if ( rControlType == TOOLBARCONTROLLER_BUTTON )
         pResult = new ButtonToolbarController( rxContext, pToolbar, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_COMBOBOX )
-        pResult = new ComboboxToolbarController( rxContext, xFrame, pToolbar, nId, 0, rCommandURL );
+        pResult = new ComboboxToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_EDIT )
-        pResult = new EditToolbarController( rxContext, xFrame, pToolbar, nId, 0, rCommandURL );
+        pResult = new EditToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_SPINFIELD )
-        pResult = new SpinfieldToolbarController( rxContext, xFrame, pToolbar, nId, 0, rCommandURL );
+        pResult = new SpinfieldToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_IMGBUTTON )
         pResult = new ImageButtonToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBOX )
-        pResult = new DropdownToolbarController( rxContext, xFrame, pToolbar, nId, 0, rCommandURL );
+        pResult = new DropdownToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBTN )
         pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
                                                      ToggleButtonToolbarController::STYLE_DROPDOWNBUTTON, rCommandURL );
@@ -664,6 +674,7 @@ void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, sal_uInt16 nPos, sal_u
     pAddonParams->aImageId     = rItem.aImageIdentifier;
     pAddonParams->aTarget      = rItem.aTarget;
     pAddonParams->aControlType = rItem.aControlType;
+    pAddonParams->nWidth       = rItem.nWidth;
     pToolbar->SetItemData( nItemId, pAddonParams );
 }
 


More information about the Libreoffice-commits mailing list