diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-02-22 11:45:24 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-25 21:23:00 +0200 |
commit | 22d4bfbbc1a4bf1ef2969b55a765c2e774ff0b9f (patch) | |
tree | d9fd48e3000a67965509f95d6ef00e90243db163 | |
parent | ff38d125aee0a7f121c9f20ecde63a9270516088 (diff) |
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@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit d4b4f5f1f4e452cb9f4a0e202b57c0a8610c1cad)
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 9fe10f844c14..f6dc0b2fce1a 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -997,41 +997,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; |