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

Mike Kaganski mike.kaganski at collabora.com
Thu Feb 22 17:12:51 UTC 2018


 sfx2/source/dialog/tabdlg.cxx |   43 +++++++++++++-----------------------------
 1 file changed, 14 insertions(+), 29 deletions(-)

New commits:
commit d4b4f5f1f4e452cb9f4a0e202b57c0a8610c1cad
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Feb 22 11:45:24 2018 +0100

    Remove useless special handling of single-value ranges
    
    ... as they are treated by generic code just fine.
    A check added to guard against overflow (0xFFFF + 1 -> 0).
    
    Change-Id: Ibef85191eab82002981e12f83f313f3d122da74c
    Reviewed-on: https://gerrit.libreoffice.org/50163
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 22d03b7073af..f6fd5f90299f 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -994,41 +994,26 @@ IMPL_LINK_NOARG(SfxTabDialog, BaseFmtHdl, Button*, void)
         {
             const sal_uInt16* pU = pTmpRanges + 1;
 
-            if ( *pTmpRanges == *pU )
+            // Correct Range with multiple values
+            sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU;
+            DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" );
+
+            if ( nTmp > nTmpEnd )
+            {
+                // If really sorted wrongly, then set new
+                std::swap(nTmp, nTmpEnd);
+            }
+
+            while ( nTmp && nTmp <= nTmpEnd ) // guard against overflow
             {
-                // Range which two identical values -> only set one Item
-                sal_uInt16 nWh = pPool->GetWhich( *pTmpRanges );
+                // Iterate over the Range and set the Items
+                sal_uInt16 nWh = pPool->GetWhich( nTmp );
                 m_pExampleSet->ClearItem( nWh );
                 aTmpSet.ClearItem( nWh );
                 // At the Outset of InvalidateItem,
                 // so that the change takes effect
                 m_pOutSet->InvalidateItem( nWh );
-            }
-            else
-            {
-                // Correct Range with multiple values
-                sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU;
-                DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" );
-
-                if ( nTmp > nTmpEnd )
-                {
-                    // If really sorted wrongly, then set new
-                    sal_uInt16 nTmp1 = nTmp;
-                    nTmp = nTmpEnd;
-                    nTmpEnd = nTmp1;
-                }
-
-                while ( nTmp <= nTmpEnd )
-                {
-                    // Iterate over the Range and set the Items
-                    sal_uInt16 nWh = pPool->GetWhich( nTmp );
-                    m_pExampleSet->ClearItem( nWh );
-                    aTmpSet.ClearItem( nWh );
-                    // At the Outset of InvalidateItem,
-                    // so that the change takes effect
-                    m_pOutSet->InvalidateItem( nWh );
-                    nTmp++;
-                }
+                nTmp++;
             }
             // Go to the next pair
             pTmpRanges += 2;


More information about the Libreoffice-commits mailing list