[PATCH 2/3] fdo#42379: hide separators before calculating line breaks

Ivan Timofeev timofeev.i.s at gmail.com
Sat Jun 9 10:23:46 PDT 2012


it is nesessary since commit 1703501a100cd6d52578baeb4e8097218b285ffb,
ImplCalcBreaks looks for the last visible item.
(cherry picked from commit 243fefb72897f45448d946d571397b7bc4893e7d)
---
 vcl/source/window/toolbox.cxx |   62 ++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 28 deletions(-)

diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 9da3a7a..a055c6a 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2336,6 +2336,38 @@ Size ToolBox::ImplGetOptimalFloatingSize( FloatingSizeMode eMode )
     return aCurrentSize;
 }
 
+namespace
+{
+static void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
+{
+    bool bLastSep( true );
+    std::vector< ImplToolItem >::iterator it;
+    for ( it = rItems.begin(); it != rItems.end(); ++it )
+    {
+        if ( it->meType == TOOLBOXITEM_SEPARATOR )
+        {
+            it->mbVisible = sal_False;
+            if ( !bLastSep )
+            {
+                // check if any visible items have to appear behind it
+                std::vector< ImplToolItem >::iterator temp_it;
+                for ( temp_it = it+1; temp_it != rItems.end(); ++temp_it )
+                {
+                    if ( ((temp_it->meType == TOOLBOXITEM_BUTTON) &&
+                          temp_it->mbVisible) )
+                    {
+                        it->mbVisible = sal_True;
+                        break;
+                    }
+                }
+            }
+            bLastSep = true;
+        }
+        else if ( it->mbVisible )
+            bLastSep = false;
+    }
+}
+}
 
 void ToolBox::ImplFormat( sal_Bool bResize )
 {
@@ -2355,10 +2387,8 @@ void ToolBox::ImplFormat( sal_Bool bResize )
     long            nMax;   // width of layoutarea in pixels
     sal_uInt16          nFormatLine;
     sal_Bool            bMustFullPaint;
-    sal_Bool            bLastSep;
 
     std::vector< ImplToolItem >::iterator   it;
-    std::vector< ImplToolItem >::iterator   temp_it;
 
     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
     sal_Bool bIsInPopupMode = ImplIsInPopupMode();
@@ -2517,7 +2547,6 @@ void ToolBox::ImplFormat( sal_Bool bResize )
         long nX = nLeft;    // top-left offset
         long nY = nTop;
         nFormatLine = 1;
-        bLastSep    = sal_True;
 
         // save old scroll rectangles and reset them
         Rectangle aOldLowerRect = maLowerRect;
@@ -2552,6 +2581,8 @@ void ToolBox::ImplFormat( sal_Bool bResize )
         // do we have any toolbox items at all ?
         if ( !mpData->m_aItems.empty() || IsMenuEnabled() )
         {
+            lcl_hideDoubleSeparators( mpData->m_aItems );
+
             // compute line breaks and visible lines give the current window width (nMax)
             // the break indicators will be stored within each item (it->mbBreak)
             mnCurLines = ImplCalcBreaks( nMax, NULL, mbHorz );
@@ -2648,31 +2679,6 @@ void ToolBox::ImplFormat( sal_Bool bResize )
             it = mpData->m_aItems.begin();
             while ( it != mpData->m_aItems.end() )
             {
-                // hide double separators
-                if ( it->meType == TOOLBOXITEM_SEPARATOR )
-                {
-                    it->mbVisible = sal_False;
-                    if ( !bLastSep )
-                    {
-                        // check if any visible items have to appear behind it
-                        temp_it = it+1;
-                        while ( temp_it != mpData->m_aItems.end() )
-                        {
-                            if ( (temp_it->meType == TOOLBOXITEM_SEPARATOR) ||
-                                 ((temp_it->meType == TOOLBOXITEM_BUTTON) &&
-                                  temp_it->mbVisible) )
-                            {
-                                it->mbVisible = sal_True;
-                                break;
-                            }
-                            ++temp_it;
-                        }
-                    }
-                    bLastSep = sal_True;
-                }
-                else if ( it->mbVisible )
-                    bLastSep = sal_False;
-
                 it->mbShowWindow = sal_False;
 
                 // check for line break and advance nX/nY accordingly
-- 
1.7.10


--------------090600070206000008090701
Content-Type: text/x-diff;
 name="0003-fdo-35972-toolbarmanager-must-be-aware-of-changes-in.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0003-fdo-35972-toolbarmanager-must-be-aware-of-changes-in.pa";
 filename*1="tch"



More information about the LibreOffice mailing list