diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-03-19 20:42:14 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-03-24 23:22:06 +0100 |
commit | 4c2393eae69902107febc62161fd842fdea953c4 (patch) | |
tree | 67a03c77bc867978f19b4fe6e37352930c2234a2 /sw | |
parent | 61df9ee7b13660a21d513f70410e6716c2409e20 (diff) |
sal_uInt16 to size_t and optimizations
Removed unneeded casts, adapted cycles, reduced scope...
Change-Id: I1781a9d4c42bd6b85f16e9573d0bc2b201084646
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/fesh.hxx | 4 | ||||
-rw-r--r-- | sw/inc/tabcol.hxx | 20 | ||||
-rw-r--r-- | sw/source/core/bastyp/tabcol.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 65 | ||||
-rw-r--r-- | sw/source/core/uibase/table/swtablerep.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/uibase/table/tablemgr.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/uibase/uiview/viewtab.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/vba/vbatablehelper.cxx | 28 |
12 files changed, 124 insertions, 126 deletions
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 65cf7c514e25..94a9f208fb34 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -701,8 +701,8 @@ public: sal_uInt16 GetCurColNum( SwGetCurColNumPara* pPara = 0 ) const; //0 == not in any column. sal_uInt16 GetCurMouseColNum( const Point &rPt, SwGetCurColNumPara* pPara = 0 ) const; - sal_uInt16 GetCurTabColNum() const; //0 == not in any table. - sal_uInt16 GetCurMouseTabColNum( const Point &rPt ) const; + size_t GetCurTabColNum() const; //0 == not in any table. + size_t GetCurMouseTabColNum( const Point &rPt ) const; sal_uInt16 GetCurOutColNum( SwGetCurColNumPara* pPara = 0 ) const; ///< Current outer column. sal_Bool IsTableRightToLeft() const; diff --git a/sw/inc/tabcol.hxx b/sw/inc/tabcol.hxx index 270a834d6673..b124658a68d8 100644 --- a/sw/inc/tabcol.hxx +++ b/sw/inc/tabcol.hxx @@ -60,19 +60,19 @@ public: SwTabCols( const SwTabCols& ); SwTabCols &operator=( const SwTabCols& ); bool operator==( const SwTabCols& rCmp ) const; - long& operator[]( sal_uInt16 nPos ) { return aData[nPos].nPos; } - long operator[]( sal_uInt16 nPos ) const { return aData[nPos].nPos; } - sal_uInt16 Count() const { return sal::static_int_cast< sal_uInt16 >(aData.size()); } + long& operator[]( size_t nPos ) { return aData[nPos].nPos; } + long operator[]( size_t nPos ) const { return aData[nPos].nPos; } + size_t Count() const { return aData.size(); } - sal_Bool IsHidden( sal_uInt16 nPos ) const { return aData[nPos].bHidden; } - void SetHidden( sal_uInt16 nPos, sal_Bool bValue ) { aData[nPos].bHidden = bValue; } + sal_Bool IsHidden( size_t nPos ) const { return aData[nPos].bHidden; } + void SetHidden( size_t nPos, sal_Bool bValue ) { aData[nPos].bHidden = bValue; } - void Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos ); - void Insert( long nValue, long nMin, long nMax, sal_Bool bValue, sal_uInt16 nPos ); - void Remove( sal_uInt16 nPos, sal_uInt16 nAnz = 1 ); + void Insert( long nValue, sal_Bool bValue, size_t nPos ); + void Insert( long nValue, long nMin, long nMax, sal_Bool bValue, size_t nPos ); + void Remove( size_t nPos, size_t nAnz = 1 ); - const SwTabColsEntry& GetEntry( sal_uInt16 nPos ) const { return aData[nPos]; } - SwTabColsEntry& GetEntry( sal_uInt16 nPos ) { return aData[nPos]; } + const SwTabColsEntry& GetEntry( size_t nPos ) const { return aData[nPos]; } + SwTabColsEntry& GetEntry( size_t nPos ) { return aData[nPos]; } long GetLeftMin() const { return nLeftMin; } long GetLeft() const { return nLeft; } diff --git a/sw/source/core/bastyp/tabcol.cxx b/sw/source/core/bastyp/tabcol.cxx index 9375daa28fb2..fcca7e209534 100644 --- a/sw/source/core/bastyp/tabcol.cxx +++ b/sw/source/core/bastyp/tabcol.cxx @@ -41,7 +41,7 @@ SwTabCols::SwTabCols( const SwTabCols& rCpy ) : aData( rCpy.GetData() ) { #if OSL_DEBUG_LEVEL > 0 - for ( sal_uInt16 i = 0; i < Count(); ++i ) + for ( size_t i = 0; i < Count(); ++i ) { SwTabColsEntry aEntry1 = aData[i]; SwTabColsEntry aEntry2 = rCpy.GetData()[i]; @@ -72,8 +72,6 @@ SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy ) bool SwTabCols::operator==( const SwTabCols& rCmp ) const { - sal_uInt16 i; - if ( !(nLeftMin == rCmp.GetLeftMin() && nLeft == rCmp.GetLeft() && nRight == rCmp.GetRight() && @@ -82,7 +80,7 @@ bool SwTabCols::operator==( const SwTabCols& rCmp ) const Count()== rCmp.Count()) ) return false; - for ( i = 0; i < Count(); ++i ) + for ( size_t i = 0; i < Count(); ++i ) { SwTabColsEntry aEntry1 = aData[i]; SwTabColsEntry aEntry2 = rCmp.GetData()[i]; @@ -94,7 +92,7 @@ bool SwTabCols::operator==( const SwTabCols& rCmp ) const } void SwTabCols::Insert( long nValue, long nMin, long nMax, - sal_Bool bValue, sal_uInt16 nPos ) + sal_Bool bValue, size_t nPos ) { SwTabColsEntry aEntry; aEntry.nPos = nValue; @@ -104,7 +102,7 @@ void SwTabCols::Insert( long nValue, long nMin, long nMax, aData.insert( aData.begin() + nPos, aEntry ); } -void SwTabCols::Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos ) +void SwTabCols::Insert( long nValue, sal_Bool bValue, size_t nPos ) { SwTabColsEntry aEntry; aEntry.nPos = nValue; @@ -122,7 +120,7 @@ void SwTabCols::Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos ) #endif } -void SwTabCols::Remove( sal_uInt16 nPos, sal_uInt16 nAnz ) +void SwTabCols::Remove( size_t nPos, size_t nAnz ) { SwTabColsEntries::iterator aStart = aData.begin() + nPos; aData.erase( aStart, aStart + nAnz ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 9223c7d76caf..317c9e63d7f0 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2655,7 +2655,7 @@ void SwDoc::GetTabRows( SwTabCols &rFill, const SwCursor* , } // transfer calculated values from BoundaryMap and HiddenMap into rFill: - sal_uInt16 nIdx = 0; + size_t nIdx = 0; for ( aIter = aBoundaries.begin(); aIter != aBoundaries.end(); ++aIter ) { const long nTabTop = (pTab->*fnRect->fnGetPrtTop)(); @@ -2793,14 +2793,14 @@ void SwDoc::SetTabRows( const SwTabCols &rNew, sal_Bool bCurColOnly, const SwCur GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_ATTR, NULL ); // check for differences between aOld and rNew: - const sal_uInt16 nCount = rNew.Count(); + const size_t nCount = rNew.Count(); const SwTable* pTable = pTab->GetTable(); OSL_ENSURE( pTable, "My colleague told me, this couldn't happen" ); - for ( sal_uInt16 i = 0; i <= nCount; ++i ) + for ( size_t i = 0; i <= nCount; ++i ) { - const sal_uInt16 nIdxStt = bVert ? nCount - i : i - 1; - const sal_uInt16 nIdxEnd = bVert ? nCount - i - 1 : i; + const size_t nIdxStt = bVert ? nCount - i : i - 1; + const size_t nIdxEnd = bVert ? nCount - i - 1 : i; const long nOldRowStart = i == 0 ? 0 : aOld[ nIdxStt ]; const long nOldRowEnd = i == nCount ? aOld.GetRight() : aOld[ nIdxEnd ]; diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 08bad4c638e5..744dafec5850 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1305,7 +1305,7 @@ static void lcl_CalcSubColValues( std::vector<sal_uInt16> &rToFill, const SwTabC SWRECTFN( pTab ) - for ( sal_uInt16 i = 0 ; i <= rCols.Count(); ++i ) + for ( size_t i = 0 ; i <= rCols.Count(); ++i ) { long nColLeft = i == 0 ? rCols.GetLeft() : rCols[i-1]; long nColRight = i == rCols.Count() ? rCols.GetRight() : rCols[i]; @@ -1313,7 +1313,7 @@ static void lcl_CalcSubColValues( std::vector<sal_uInt16> &rToFill, const SwTabC nColRight += rCols.GetLeftMin(); // Adapt values to the proportions of the Table (Follows) - if ( rCols.GetLeftMin() != sal_uInt16((pTab->Frm().*fnRect->fnGetLeft)()) ) + if ( rCols.GetLeftMin() != (pTab->Frm().*fnRect->fnGetLeft)() ) { const long nDiff = (pTab->Frm().*fnRect->fnGetLeft)() - rCols.GetLeftMin(); nColLeft += nDiff; @@ -1383,7 +1383,7 @@ static void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols bool bNotInCols = true; - for ( sal_uInt16 i = 0; i <= rCols.Count(); ++i ) + for ( size_t i = 0; i <= rCols.Count(); ++i ) { sal_uInt16 nFit = rToFill[i]; long nColLeft = i == 0 ? rCols.GetLeft() : rCols[i-1]; @@ -1467,8 +1467,6 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) std::vector<sal_uInt16> aWish(aTabCols.Count() + 1); std::vector<sal_uInt16> aMins(aTabCols.Count() + 1); - sal_uInt16 i; - ::lcl_CalcColValues( aWish, aTabCols, pStart, pEnd, sal_True ); // It's more robust if we calculate the minimum values for the whole Table @@ -1485,27 +1483,27 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) // We add up the current values, divide the result by their // count and get a desired value for balancing. sal_uInt16 nWish = 0, nCnt = 0; - for ( i = 0; i <= aTabCols.Count(); ++i ) + for ( size_t i = 0; i <= aTabCols.Count(); ++i ) { int nDiff = aWish[i]; if ( nDiff ) { if ( i == 0 ) - nWish = static_cast<sal_uInt16>( nWish + aTabCols[i] - aTabCols.GetLeft() ); + nWish += aTabCols[i] - aTabCols.GetLeft(); else if ( i == aTabCols.Count() ) - nWish = static_cast<sal_uInt16>(nWish + aTabCols.GetRight() - aTabCols[i-1] ); + nWish += aTabCols.GetRight() - aTabCols[i-1]; else - nWish = static_cast<sal_uInt16>(nWish + aTabCols[i] - aTabCols[i-1] ); + nWish += aTabCols[i] - aTabCols[i-1]; ++nCnt; } } - nWish = nWish / nCnt; - for ( i = 0; i < aWish.size(); ++i ) + nWish /= nCnt; + for ( size_t i = 0; i < aWish.size(); ++i ) if ( aWish[i] ) aWish[i] = nWish; } - const sal_uInt16 nOldRight = static_cast<sal_uInt16>(aTabCols.GetRight()); + const long nOldRight = aTabCols.GetRight(); // In order to make the implementation easier, but still use the available // space properly, we do this twice. @@ -1516,7 +1514,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) // the Table's width to exceed the maximum width. for ( sal_uInt16 k = 0; k < 2; ++k ) { - for ( i = 0; i <= aTabCols.Count(); ++i ) + for ( size_t i = 0; i <= aTabCols.Count(); ++i ) { int nDiff = aWish[i]; if ( nDiff ) @@ -1547,14 +1545,14 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) nDiff -= nTmpD; nTabRight -= nTmpD; } - for ( sal_uInt16 i2 = i; i2 < aTabCols.Count(); ++i2 ) + for ( size_t i2 = i; i2 < aTabCols.Count(); ++i2 ) aTabCols[i2] += nDiff; aTabCols.SetRight( nTabRight ); } } } - const sal_uInt16 nNewRight = static_cast<sal_uInt16>(aTabCols.GetRight()); + const long nNewRight = aTabCols.GetRight(); SwFrmFmt *pFmt = pTblNd->GetTable().GetFrmFmt(); const sal_Int16 nOriHori = pFmt->GetHoriOrient().GetHoriOrient(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index dcf268af4fde..2d0227bfbbc7 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1372,10 +1372,10 @@ sal_Bool SwFEShell::DeleteTblSel() |* SwFEShell::GetCurTabColNum() |* |*************************************************************************/ -sal_uInt16 SwFEShell::GetCurTabColNum() const +size_t SwFEShell::GetCurTabColNum() const { //!!!GetCurMouseTabColNum() mitpflegen!!!! - sal_uInt16 nRet = 0; + size_t nRet = 0; SwFrm *pFrm = GetCurrFrm(); OSL_ENSURE( pFrm, "Crsr parked?" ); @@ -1404,7 +1404,7 @@ sal_uInt16 SwFEShell::GetCurTabColNum() const if ( !::IsSame( nX, nRight ) ) { nX = nRight - nX + aTabCols.GetLeft(); - for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i ) + for ( size_t i = 0; i < aTabCols.Count(); ++i ) if ( ::IsSame( nX, aTabCols[i] ) ) { nRet = i + 1; @@ -1421,7 +1421,7 @@ sal_uInt16 SwFEShell::GetCurTabColNum() const if ( !::IsSame( nX, nLeft + aTabCols.GetLeft() ) ) { - for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i ) + for ( size_t i = 0; i < aTabCols.Count(); ++i ) if ( ::IsSame( nX, nLeft + aTabCols[i] ) ) { nRet = i + 1; @@ -2124,10 +2124,10 @@ sal_uInt16 SwFEShell::GetCurMouseColNum( const Point &rPt, return _GetCurColNum( GetBox( rPt ), pPara ); } -sal_uInt16 SwFEShell::GetCurMouseTabColNum( const Point &rPt ) const +size_t SwFEShell::GetCurMouseTabColNum( const Point &rPt ) const { //!!!GetCurTabColNum() mitpflegen!!!! - sal_uInt16 nRet = 0; + size_t nRet = 0; const SwFrm *pFrm = GetBox( rPt ); OSL_ENSURE( pFrm, "Table not found" ); @@ -2143,7 +2143,7 @@ sal_uInt16 SwFEShell::GetCurMouseTabColNum( const Point &rPt ) const if ( !::IsSame( nX, nLeft + aTabCols.GetLeft() ) ) { - for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i ) + for ( size_t i = 0; i < aTabCols.Count(); ++i ) if ( ::IsSame( nX, nLeft + aTabCols[i] ) ) { nRet = i + 1; diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 6edee7bbcfc9..a55b9a5eadd9 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -427,11 +427,11 @@ void SwTable::AdjustWidths( const long nOld, const long nNew ) |* SwTable::GetTabCols() |* |*************************************************************************/ -static void lcl_RefreshHidden( SwTabCols &rToFill, sal_uInt16 nPos ) +static void lcl_RefreshHidden( SwTabCols &rToFill, size_t nPos ) { - for ( sal_uInt16 i = 0; i < rToFill.Count(); ++i ) + for ( size_t i = 0; i < rToFill.Count(); ++i ) { - if ( std::abs((long)(nPos - rToFill[i])) <= COLFUZZY ) + if ( std::abs(static_cast<long>(nPos) - rToFill[i]) <= COLFUZZY ) { rToFill.SetHidden( i, sal_False ); break; @@ -488,7 +488,7 @@ static void lcl_SortedTabColInsert( SwTabCols &rToFill, const SwTableBox *pBox, } bool bInsert = !bRefreshHidden; - for ( sal_uInt16 j = 0; bInsert && (j < rToFill.Count()); ++j ) + for ( size_t j = 0; bInsert && (j < rToFill.Count()); ++j ) { long nCmp = rToFill[j]; if ( (nPos >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) && @@ -516,7 +516,7 @@ static void lcl_SortedTabColInsert( SwTabCols &rToFill, const SwTableBox *pBox, // check if nPos is entry: bool bFoundPos = false; bool bFoundMax = false; - for ( sal_uInt16 j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.Count(); ++j ) + for ( size_t j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.Count(); ++j ) { SwTabColsEntry& rEntry = rToFill.GetEntry( j ); long nCmp = rToFill[j]; @@ -586,8 +586,7 @@ void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, if ( bRefreshHidden ) { // remove corrections - sal_uInt16 i; - for ( i = 0; i < rToFill.Count(); ++i ) + for ( size_t i = 0; i < rToFill.Count(); ++i ) { SwTabColsEntry& rEntry = rToFill.GetEntry( i ); rEntry.nPos -= rToFill.GetLeft(); @@ -596,7 +595,7 @@ void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, } // All are hidden, so add the visible ones. - for ( i = 0; i < rToFill.Count(); ++i ) + for ( size_t i = 0; i < rToFill.Count(); ++i ) rToFill.SetHidden( i, sal_True ); } else @@ -623,8 +622,7 @@ void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, // 1. const SwTableBoxes &rBoxes = pStart->GetUpper()->GetTabBoxes(); - sal_uInt16 i; - for ( i = 0; i < rBoxes.size(); ++i ) + for ( size_t i = 0; i < rBoxes.size(); ++i ) ::lcl_ProcessBoxGet( rBoxes[i], rToFill, pTabFmt, bRefreshHidden ); // 2. and 3. @@ -644,7 +642,7 @@ void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, // 4. if ( !bCurRowOnly ) { - for ( i = 0; i < aLines.size(); ++i ) + for ( size_t i = 0; i < aLines.size(); ++i ) ::lcl_ProcessLineGet( aLines[i], rToFill, pTabFmt ); } @@ -655,7 +653,7 @@ void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, // relative to SwTabCols.nLeft. However, they are expected // relative to the left document border, i.e. SwTabCols.nLeftMin. // So all values need to be extended by nLeft. - for ( i = 0; i < rToFill.Count(); ++i ) + for ( size_t i = 0; i < rToFill.Count(); ++i ) { SwTabColsEntry& rEntry = rToFill.GetEntry( i ); rEntry.nPos += rToFill.GetLeft(); @@ -729,7 +727,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm ) pCur = pLine->GetUpper(); pLine = pCur ? pCur->GetUpper() : 0; } - long nLeftDiff; + long nLeftDiff = 0; long nRightDiff = 0; if ( nLeft != rParm.rOld.GetLeft() ) // There are still boxes before this. { @@ -738,44 +736,49 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm ) nWidth *= nOldAct; nWidth /= rParm.nOldWish; long nRight = nLeft + (long)nWidth; - sal_uInt16 nLeftPos = USHRT_MAX, - nRightPos = USHRT_MAX; - for ( sal_uInt16 i = 0; i < rParm.rOld.Count(); ++i ) + size_t nLeftPos = 0; + size_t nRightPos = 0; + bool bFoundLeftPos = false; + bool bFoundRightPos = false; + for ( size_t i = 0; i < rParm.rOld.Count(); ++i ) { if ( nLeft >= (rParm.rOld[i] - COLFUZZY) && nLeft <= (rParm.rOld[i] + COLFUZZY) ) + { nLeftPos = i; + bFoundLeftPos = true; + } else if ( nRight >= (rParm.rOld[i] - COLFUZZY) && nRight <= (rParm.rOld[i] + COLFUZZY) ) + { nRightPos = i; + bFoundRightPos = true; + } } - nLeftDiff = nLeftPos != USHRT_MAX ? - (int)rParm.rOld[nLeftPos] - (int)rParm.rNew[nLeftPos] : 0; - nRightDiff= nRightPos!= USHRT_MAX ? - (int)rParm.rNew[nRightPos] - (int)rParm.rOld[nRightPos] : 0; + nLeftDiff = bFoundLeftPos ? + rParm.rOld[nLeftPos] - rParm.rNew[nLeftPos] : 0; + nRightDiff= bFoundRightPos ? + rParm.rNew[nRightPos] - rParm.rOld[nRightPos] : 0; } else // The first box. { - nLeftDiff = (long)rParm.rOld.GetLeft() - (long)rParm.rNew.GetLeft(); + nLeftDiff = rParm.rOld.GetLeft() - rParm.rNew.GetLeft(); if ( rParm.rOld.Count() ) { // Calculate the difference to the edge touching the first box. sal_uInt64 nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth(); nWidth *= nOldAct; nWidth /= rParm.nOldWish; - long nTmp = (long)nWidth; - nTmp += rParm.rOld.GetLeft(); - sal_uInt16 nLeftPos = USHRT_MAX; - for ( sal_uInt16 i = 0; i < rParm.rOld.Count() && - nLeftPos == USHRT_MAX; ++i ) + const long nTmp = (long)nWidth + rParm.rOld.GetLeft(); + for ( size_t i = 0; i < rParm.rOld.Count(); ++i ) { if ( nTmp >= (rParm.rOld[i] - COLFUZZY) && nTmp <= (rParm.rOld[i] + COLFUZZY) ) - nLeftPos = i; + { + nRightDiff = rParm.rNew[i] - rParm.rOld[i]; + break; + } } - if ( nLeftPos != USHRT_MAX ) - nRightDiff = (long)rParm.rNew[nLeftPos] - - (long)rParm.rOld[nLeftPos]; } } @@ -1237,7 +1240,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew, const long nOldWidth = rParm.rOld.GetRight() - rParm.rOld.GetLeft(); if( nNewWidth < 1 || nOldWidth < 1 ) return; - for( sal_uInt16 i = 0; i <= rOld.Count(); ++i ) + for( size_t i = 0; i <= rOld.Count(); ++i ) { sal_uInt64 nNewPos; sal_uInt64 nOldPos; diff --git a/sw/source/core/uibase/table/swtablerep.cxx b/sw/source/core/uibase/table/swtablerep.cxx index f1176b07727f..640a9ee60e9d 100644 --- a/sw/source/core/uibase/table/swtablerep.cxx +++ b/sw/source/core/uibase/table/swtablerep.cxx @@ -94,15 +94,15 @@ sal_Bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const nOldRight = rTabCols.GetRight(); sal_Bool bSingleLine = sal_False; - sal_uInt16 i; - for ( i = 0; i < rTabCols.Count(); ++i ) + for ( size_t i = 0; i < rTabCols.Count(); ++i ) if(!pTColumns[i].bVisible) { bSingleLine = sal_True; break; } + sal_uInt16 i; SwTwips nPos = 0; SwTwips nLeft = GetLeftSpace(); rTabCols.SetLeft(nLeft); @@ -171,10 +171,10 @@ sal_Bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const } // intercept rounding errors - if(std::abs((long)nOldLeft - (long)rTabCols.GetLeft()) < 3) + if(std::abs(nOldLeft - rTabCols.GetLeft()) < 3) rTabCols.SetLeft(nOldLeft); - if(std::abs((long)nOldRight - (long)rTabCols.GetRight()) < 3) + if(std::abs(nOldRight - rTabCols.GetRight()) < 3) rTabCols.SetRight(nOldRight); if(GetRightSpace() >= 0 && diff --git a/sw/source/core/uibase/table/tablemgr.cxx b/sw/source/core/uibase/table/tablemgr.cxx index 1cab5746dca5..88064657977e 100644 --- a/sw/source/core/uibase/table/tablemgr.cxx +++ b/sw/source/core/uibase/table/tablemgr.cxx @@ -76,11 +76,11 @@ SwTwips SwTableFUNC::GetColWidth(sal_uInt16 nNum) const else { SwTwips nRValid = nNum < GetColCount() ? - aCols[(sal_uInt16)GetRightSeparator((int)nNum)]: - aCols.GetRight(); + aCols[GetRightSeparator(nNum)] : + aCols.GetRight(); SwTwips nLValid = nNum ? - aCols[(sal_uInt16)GetRightSeparator((int)nNum - 1)]: - aCols.GetLeft(); + aCols[GetRightSeparator(nNum - 1)] : + aCols.GetLeft(); nWidth = nRValid - nLValid; } } @@ -124,20 +124,20 @@ void SwTableFUNC::SetColWidth(sal_uInt16 nNum, SwTwips nNewWidth ) int nDiff = (int)(nNewWidth - nWidth); if( !nNum ) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(0)) ] += nDiff; + aCols[ GetRightSeparator(0) ] += nDiff; else if( nNum < GetColCount() ) { if(nDiff < GetColWidth(nNum + 1) - MINLAY) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum)) ] += nDiff; + aCols[ GetRightSeparator(nNum) ] += nDiff; else { int nDiffLeft = nDiff - (int)GetColWidth(nNum + 1) + (int)MINLAY; - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum)) ] += (nDiff - nDiffLeft); - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum - 1)) ] -= nDiffLeft; + aCols[ GetRightSeparator(nNum) ] += (nDiff - nDiffLeft); + aCols[ GetRightSeparator(nNum - 1) ] -= nDiffLeft; } } else - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum-1)) ] -= nDiff; + aCols[ GetRightSeparator(nNum-1) ] -= nDiff; } else aCols.SetRight( std::min( nNewWidth, aCols.GetRightMax()) ); @@ -316,9 +316,9 @@ uno::Reference< frame::XModel > SwTableFUNC::InsertChart( sal_uInt16 SwTableFUNC::GetCurColNum() const { - sal_uInt16 nPos = pSh->GetCurTabColNum(); - sal_uInt16 nCount = 0; - for(sal_uInt16 i = 0; i < nPos; i++ ) + const size_t nPos = pSh->GetCurTabColNum(); + size_t nCount = 0; + for( size_t i = 0; i < nPos; i++ ) if(aCols.IsHidden(i)) nCount ++; return nPos - nCount; @@ -326,8 +326,8 @@ sal_uInt16 SwTableFUNC::GetCurColNum() const sal_uInt16 SwTableFUNC::GetColCount() const { - sal_uInt16 nCount = 0; - for(sal_uInt16 i = 0; i < aCols.Count(); i++ ) + size_t nCount = 0; + for(size_t i = 0; i < aCols.Count(); i++ ) if(aCols.IsHidden(i)) nCount ++; return aCols.Count() - nCount; @@ -339,7 +339,7 @@ int SwTableFUNC::GetRightSeparator(int nNum) const int i = 0; while( nNum >= 0 ) { - if( !aCols.IsHidden( static_cast< sal_uInt16 >(i)) ) + if( !aCols.IsHidden(i) ) nNum--; i++; } diff --git a/sw/source/core/uibase/uiview/viewtab.cxx b/sw/source/core/uibase/uiview/viewtab.cxx index 997425b1b91f..83cd76885e3b 100644 --- a/sw/source/core/uibase/uiview/viewtab.cxx +++ b/sw/source/core/uibase/uiview/viewtab.cxx @@ -1430,7 +1430,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) else if ( bHasTable ) { SwTabCols aTabCols; - sal_uInt16 nNum; + size_t nNum = 0; if ( 0 != ( m_bSetTabColFromDoc = IsTabColFromDoc() ) ) { rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos ); @@ -1446,9 +1446,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found"); const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft(); - const int nRgt = (sal_uInt16)(bTableVertical ? nPageHeight : nPageWidth) - - (aTabCols.GetLeftMin() + - aTabCols.GetRight()); + const int nRgt = (bTableVertical ? nPageHeight : nPageWidth) - + (aTabCols.GetLeftMin() + aTabCols.GetRight()); const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0); const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0); @@ -1465,7 +1464,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) : rSh.IsTableRightToLeft(); if(bIsTableRTL) { - for ( sal_uInt16 i = aTabCols.Count(); i ; --i ) + for ( size_t i = aTabCols.Count(); i; --i ) { const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 ); nEnd = (sal_uInt16)aTabCols.GetRight(); @@ -1483,7 +1482,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) } else { - for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i ) + for ( size_t i = 0; i < aTabCols.Count(); ++i ) { const SwTabColsEntry& rEntry = aTabCols.GetEntry( i ); nEnd = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft()); @@ -1697,7 +1696,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) sal_uInt16 nStart = 0, nEnd; - for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i ) + for ( size_t i = 0; i < aTabCols.Count(); ++i ) { const SwTabColsEntry& rEntry = aTabCols.GetEntry( i ); if(bVerticalWriting) @@ -1756,7 +1755,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) { if( nFrmType & FRMTYPE_TABLE ) { - const sal_uInt16 nNum = rSh.GetCurTabColNum(); + const size_t nNum = rSh.GetCurTabColNum(); SwTabCols aTabCols; rSh.GetTabCols( aTabCols ); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index a3ab0748ff73..f387dc73ff89 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -644,11 +644,11 @@ static void lcl_GetTblSeparators(uno::Any& rRet, SwTable* pTable, SwTableBox* pB pTable->GetTabCols( aCols, pBox, sal_False, bRow ); - sal_uInt16 nSepCount = aCols.Count(); + const size_t nSepCount = aCols.Count(); uno::Sequence< text::TableColumnSeparator> aColSeq(nSepCount); - text::TableColumnSeparator* pArray = aColSeq.getArray(); + text::TableColumnSeparator* pArray = aColSeq.getArray(); bool bError = false; - for(sal_uInt16 i = 0; i < nSepCount; i++) + for(size_t i = 0; i < nSepCount; ++i) { pArray[i].Position = static_cast< sal_Int16 >(aCols[i]); pArray[i].IsVisible = !aCols.IsHidden(i); @@ -673,26 +673,26 @@ static void lcl_SetTblSeparators(const uno::Any& rVal, SwTable* pTable, SwTableB aOldCols.SetRightMax( UNO_TABLE_COLUMN_SUM ); pTable->GetTabCols( aOldCols, pBox, sal_False, bRow ); - sal_uInt16 nOldCount = aOldCols.Count(); + const size_t nOldCount = aOldCols.Count(); // there is no use in setting tab cols if there is only one column if( !nOldCount ) return; const uno::Sequence< text::TableColumnSeparator>* pSepSeq = (uno::Sequence< text::TableColumnSeparator>*) rVal.getValue(); - if(pSepSeq && pSepSeq->getLength() == nOldCount) + if(pSepSeq && static_cast<size_t>(pSepSeq->getLength()) == nOldCount) { SwTabCols aCols(aOldCols); sal_Bool bError = sal_False; const text::TableColumnSeparator* pArray = pSepSeq->getConstArray(); - sal_Int32 nLastValue = 0; + long nLastValue = 0; //sal_Int32 nTblWidth = aCols.GetRight() - aCols.GetLeft(); - for(sal_uInt16 i = 0; i < nOldCount; i++) + for(size_t i = 0; i < nOldCount; ++i) { aCols[i] = pArray[i].Position; if(pArray[i].IsVisible == aCols.IsHidden(i) || (!bRow && aCols.IsHidden(i)) || - long(aCols[i] - long(nLastValue)) < 0 || + aCols[i] < nLastValue || UNO_TABLE_COLUMN_SUM < aCols[i] ) { bError = sal_True; diff --git a/sw/source/ui/vba/vbatablehelper.cxx b/sw/source/ui/vba/vbatablehelper.cxx index 9b1e5530e838..2a2f1fb7a049 100644 --- a/sw/source/ui/vba/vbatablehelper.cxx +++ b/sw/source/ui/vba/vbatablehelper.cxx @@ -169,7 +169,7 @@ void SwVbaTableHelper::InitTabCols( SwTabCols& rCols, const SwTableBox *pStart, sal_Int32 SwVbaTableHelper::GetColCount( SwTabCols& rCols ) const { sal_Int32 nCount = 0; - for(sal_Int32 i = 0; i < rCols.Count(); i++ ) + for( size_t i = 0; i < rCols.Count(); ++i ) if(rCols.IsHidden(i)) nCount ++; return rCols.Count() - nCount; @@ -177,11 +177,11 @@ sal_Int32 SwVbaTableHelper::GetColCount( SwTabCols& rCols ) const sal_Int32 SwVbaTableHelper::GetRightSeparator( SwTabCols& rCols, sal_Int32 nNum) const { - OSL_ENSURE( nNum < (sal_Int32)GetColCount( rCols ) ,"Index out of range"); + OSL_ENSURE( nNum < GetColCount( rCols ) ,"Index out of range"); sal_Int32 i = 0; while( nNum >= 0 ) { - if( !rCols.IsHidden( static_cast< sal_uInt16 >(i)) ) + if( !rCols.IsHidden(i) ) nNum--; i++; } @@ -206,9 +206,9 @@ sal_Int32 SwVbaTableHelper::GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) thro if( rCols.Count() > 0 ) { - if(rCols.Count() == GetColCount( rCols )) + if(rCols.Count() == static_cast<size_t>(GetColCount( rCols ))) { - nWidth = (SwTwips)((nNum == rCols.Count()) ? + nWidth = ((static_cast<size_t>(nNum) == rCols.Count()) ? rCols.GetRight() - rCols[nNum-1] : nNum == 0 ? rCols[nNum] - rCols.GetLeft() : rCols[nNum] - rCols[nNum-1]); @@ -216,10 +216,10 @@ sal_Int32 SwVbaTableHelper::GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) thro else { SwTwips nRValid = nNum < GetColCount( rCols ) ? - rCols[(sal_uInt16)GetRightSeparator( rCols, nNum)]: + rCols[GetRightSeparator( rCols, nNum )]: rCols.GetRight(); SwTwips nLValid = nNum ? - rCols[(sal_uInt16)GetRightSeparator( rCols, nNum - 1)]: + rCols[GetRightSeparator( rCols, nNum - 1 )]: rCols.GetLeft(); nWidth = nRValid - nLValid; } @@ -234,7 +234,7 @@ void SwVbaTableHelper::SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 { double dAbsWidth = Millimeter::getInHundredthsOfOneMillimeter( _width ); sal_Int32 nTableWidth = getTableWidth( ); - sal_Int32 nNewWidth = (sal_Int32)( dAbsWidth/nTableWidth * UNO_TABLE_COLUMN_SUM ); + sal_Int32 nNewWidth = dAbsWidth/nTableWidth * UNO_TABLE_COLUMN_SUM; SwTableBox* pStart = GetTabBox( nCol, nRow ); SwTabCols aOldCols; @@ -245,22 +245,22 @@ void SwVbaTableHelper::SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 { SwTwips nWidth = GetColWidth( aCols, nCol); - int nDiff = (int)(nNewWidth - nWidth); + int nDiff = nNewWidth - nWidth; if( !nCol ) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(aCols, 0)) ] += nDiff; + aCols[ GetRightSeparator(aCols, 0) ] += nDiff; else if( nCol < GetColCount( aCols ) ) { if(nDiff < GetColWidth( aCols, nCol + 1) - MINLAY) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol)) ] += nDiff; + aCols[ GetRightSeparator( aCols, nCol ) ] += nDiff; else { int nDiffLeft = nDiff - (int)GetColWidth( aCols, nCol + 1) + (int)MINLAY; - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol)) ] += (nDiff - nDiffLeft); - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol - 1)) ] -= nDiffLeft; + aCols[ GetRightSeparator( aCols, nCol ) ] += (nDiff - nDiffLeft); + aCols[ GetRightSeparator( aCols, nCol - 1 ) ] -= nDiffLeft; } } else - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol-1)) ] -= nDiff; + aCols[ GetRightSeparator( aCols, nCol-1 ) ] -= nDiff; } else aCols.SetRight( std::min( (long)nNewWidth, aCols.GetRightMax()) ); |