[Libreoffice-commits] core.git: 7 commits - sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun Oct 26 02:38:21 PDT 2014
sw/source/core/inc/SwXMLTextBlocks.hxx | 1
sw/source/core/layout/pagechg.cxx | 15 +-
sw/source/core/layout/pagedesc.cxx | 2
sw/source/core/layout/paintfrm.cxx | 40 +++----
sw/source/core/layout/ssfrm.cxx | 10 +
sw/source/core/layout/tabfrm.cxx | 22 ++--
sw/source/core/layout/trvlfrm.cxx | 12 +-
sw/source/core/swg/SwXMLTextBlocks.cxx | 23 +---
sw/source/core/swg/swblocks.cxx | 33 +++---
sw/source/core/table/swnewtable.cxx | 169 ++++++++++++++++-----------------
10 files changed, 159 insertions(+), 168 deletions(-)
New commits:
commit 4eeee7647601c1b5c22d0d3881e47b1f3a46a304
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Oct 26 10:31:10 2014 +0100
Simplify and optimize booleans expressions
Change-Id: Ic5d736cdd48565c62958de72b08714922f1c56e5
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 811fb36..45a3252 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1176,7 +1176,7 @@ SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, bool bFtn )
if ( rDesc.GetNumOffset() )
{
::boost::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
- bWishedOdd = ((oNumOffset ? oNumOffset.get() : 0) % 2) ? true : false;
+ bWishedOdd = oNumOffset && (oNumOffset.get() % 2) != 0;
// use the opportunity to set the flag at root
pRoot->SetVirtPageNum( true );
}
@@ -1421,7 +1421,7 @@ void SwRootFrm::AssertFlyPages()
if ( nMaxPg > pPage->GetPhyPageNum() )
{
// Continue pages based on the rules of the PageDesc after the last page.
- bool bOdd = (pPage->GetPhyPageNum() % 2) ? sal_True : sal_False;
+ bool bOdd = (pPage->GetPhyPageNum() % 2) != 0;
SwPageDesc *pDesc = pPage->GetPageDesc();
SwFrm *pSibling = pPage->GetNext();
for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
@@ -1432,7 +1432,7 @@ void SwRootFrm::AssertFlyPages()
pPage = new SwPageFrm( pDoc->GetEmptyPageFmt(), this, pDesc );
pPage->Paste( this, pSibling );
pPage->PreparePage( false );
- bOdd = bOdd ? sal_False : sal_True;
+ bOdd = !bOdd;
++i;
}
pPage = new
@@ -1440,7 +1440,7 @@ void SwRootFrm::AssertFlyPages()
pDesc->GetLeftFmt()), this, pDesc );
pPage->Paste( this, pSibling );
pPage->PreparePage( false );
- bOdd = bOdd ? sal_False : sal_True;
+ bOdd = !bOdd;
pDesc = pDesc->GetFollow();
}
// If the endnote pages are now corrupt, destroy them.
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index d041840..f26f4cd 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -319,7 +319,7 @@ SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst)
bool SwPageDesc::IsFirstShared() const
{
- return eUse & nsUseOnPage::PD_FIRSTSHARE ? sal_True : sal_False;
+ return (eUse & nsUseOnPage::PD_FIRSTSHARE) != 0;
}
void SwPageDesc::ChgFirstShare( bool bNew )
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 75bc9cb..a382659 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -262,7 +262,7 @@ static double aEdgeScale = 0.5;
// The help lines will be collected and merged in pSubsLines. These will
// be compared with pLines before the work in order to avoid help lines
// to hide borders.
-// bTablines is sal_True during the Paint of a table.
+// bTablines is true during the Paint of a table.
static BorderLines *g_pBorderLines = 0;
static SwLineRects *pLines = 0;
static SwSubsRects *pSubsLines = 0;
@@ -3212,7 +3212,7 @@ void SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) c
SwLayAction aAction( (SwRootFrm*)this, pSh->Imp() );
aAction.SetPaint( false );
aAction.SetComplete( false );
- aAction.SetReschedule( pProgress ? sal_True : sal_False );
+ aAction.SetReschedule( pProgress != nullptr );
aAction.Action();
((SwRootFrm*)this)->ResetTurboFlag();
if ( !pSh->ActionPend() )
@@ -4161,7 +4161,7 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
tools::PolyPolygon aPoly;
if ( bContour )
{
- // OD 16.04.2003 #i13147# - add 2nd parameter with value <sal_True>
+ // OD 16.04.2003 #i13147# - add 2nd parameter with value <true>
// to indicate that method is called for paint in order to avoid
// load of the intrinsic graphic.
bContour = GetContour( aPoly, true );
@@ -6503,7 +6503,7 @@ void SwFrm::PaintBackground( const SwRect &rRect, const SwPageFrm *pPage,
}
// If still no background found for the fly frame, initialize the
// background brush <pItem> with global retouche color and set <bBack>
- // to sal_True, that fly frame will paint its background using this color.
+ // to true, that fly frame will paint its background using this color.
if ( !bBack )
{
// OD 10.01.2003 #i6467# - on print output, pdf output and
@@ -7434,7 +7434,7 @@ void SwFrm::Retouche( const SwPageFrm * pPage, const SwRect &rRect ) const
* Old description in German:
* Returns the Backgroundbrush for the area of the Frm.
* The Brush is defined by the Frm or by an upper, the first Brush is
- * used. If no Brush is defined for a Frm, sal_False is returned.
+ * used. If no Brush is defined for a Frm, false is returned.
*
* @param rpBrush
* output parameter - constant reference pointer the found background brush
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index bd54386..a4455f2 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -4261,7 +4261,7 @@ SwTwips SwRowFrm::ShrinkFrm( SwTwips nDist, bool bTst, bool bInfo )
return 0L;
}
- // bInfo may be set to sal_True by SwRowFrm::Format; we need to hangle this
+ // bInfo may be set to true by SwRowFrm::Format; we need to hangle this
// here accordingly
const bool bShrinkAnyway = bInfo;
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index b8fa9f9..a6dbddf 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -424,7 +424,7 @@ bool SwRootFrm::FillSelection( SwSelectionList& aSelList, const SwRect& rRect) c
/** Primary passes the call to the first page.
*
- * @return sal_False, if the passed Point gets changed
+ * @return false, if the passed Point gets changed
*/
bool SwRootFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
SwCrsrMoveState* pCMS, bool bTestBackground ) const
@@ -1592,7 +1592,7 @@ Point SwRootFrm::GetNextPrevCntntPos( const Point& rPoint, bool bNext ) const
/** Returns the absolute document position of the desired page.
*
- * Formatting is done only as far as needed and only if bFormat=sal_True.
+ * Formatting is done only as far as needed and only if bFormat=true.
* Pos is set to the one of the last page, if the page number was chosen to big.
*
* @return Null, if the operation failed.
@@ -1634,7 +1634,7 @@ SwPageFrm* SwRootFrm::GetPageByPageNum( sal_uInt16 _nPageNum ) const
}
/**
- * @return sal_True, when the given physical pagenumber does't exist or this page is an empty page.
+ * @return true, when the given physical pagenumber does't exist or this page is an empty page.
*/
bool SwRootFrm::IsDummyPage( sal_uInt16 nPageNum ) const
{
@@ -1644,7 +1644,7 @@ bool SwRootFrm::IsDummyPage( sal_uInt16 nPageNum ) const
const SwPageFrm *pPage = (const SwPageFrm*)Lower();
while( pPage && nPageNum < pPage->GetPhyPageNum() )
pPage = (const SwPageFrm*)pPage->GetNext();
- return pPage ? pPage->IsEmptyPage() : sal_True;
+ return !pPage || pPage->IsEmptyPage();
}
/** Is the Frm or rather the Section in which it lies protected?
@@ -1762,7 +1762,7 @@ bool SwFrm::WannaRightPage() const
OSL_ENSURE( pDesc, "No pagedescriptor" );
bool bOdd;
if( oPgNum )
- bOdd = (oPgNum.get() % 2) ? sal_True : sal_False;
+ bOdd = (oPgNum.get() % 2) != 0;
else
{
bOdd = pPage->OnRightPage();
commit 3bcbcb12c525028f55caf104bdfaa1b604a7be8e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Oct 26 10:12:13 2014 +0100
sal_uInt16 to more proper integer types
Change-Id: I8a541e6466b66d6ca41e7b1556db3c72764582d1
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index c274279..811fb36 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -369,7 +369,7 @@ static void lcl_MakeObjs( const SwFrmFmts &rTbl, SwPageFrm *pPage )
{
// formats are in the special table of the document
- for ( sal_uInt16 i = 0; i < rTbl.size(); ++i )
+ for ( size_t i = 0; i < rTbl.size(); ++i )
{
SdrObject *pSdrObj;
SwFrmFmt *pFmt = rTbl[i];
@@ -1403,9 +1403,8 @@ void SwRootFrm::AssertFlyPages()
// what page targets the "last" Fly?
sal_uInt16 nMaxPg = 0;
- sal_uInt16 i;
- for ( i = 0; i < pTbl->size(); ++i )
+ for ( size_t i = 0; i < pTbl->size(); ++i )
{
const SwFmtAnchor &rAnch = (*pTbl)[i]->GetAnchor();
if ( !rAnch.GetCntntAnchor() && nMaxPg < rAnch.GetPageNum() )
@@ -1425,7 +1424,7 @@ void SwRootFrm::AssertFlyPages()
bool bOdd = (pPage->GetPhyPageNum() % 2) ? sal_True : sal_False;
SwPageDesc *pDesc = pPage->GetPageDesc();
SwFrm *pSibling = pPage->GetNext();
- for ( i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
+ for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
{
if ( !(bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
{
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 8c177fc..75bc9cb 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -746,11 +746,11 @@ void SwLineRects::ConnectEdges( OutputDevice *pOut )
bool bRemove = false;
// For each line test all following ones.
- for ( sal_uInt16 k = 0; !bRemove && k < aCheck.size(); ++k )
+ for ( size_t k = 0; !bRemove && k < aCheck.size(); ++k )
{
SwLineRect &rR1 = *aCheck[k];
- for ( sal_uInt16 k2 = k+1; !bRemove && k2 < aCheck.size(); ++k2 )
+ for ( size_t k2 = k+1; !bRemove && k2 < aCheck.size(); ++k2 )
{
SwLineRect &rR2 = *aCheck[k2];
if ( bVert )
@@ -2263,7 +2263,7 @@ void DrawGraphic(
else
bGrfBackgrdAlreadyDrawn = true;
// loop rectangles of background region, which has to be drawn
- for( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ for( size_t i = 0; i < aRegion.size(); ++i )
{
pOutDev->DrawRect( aRegion[i].SVRect() );
}
@@ -4274,12 +4274,12 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
{
pOut->SetClipRegion(vcl::Region(aPoly));
}
- for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ for ( size_t i = 0; i < aRegion.size(); ++i )
PaintBackground( aRegion[i], pPage, rAttrs, false, true );
pOut->Pop();
}
else
- for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ for ( size_t i = 0; i < aRegion.size(); ++i )
PaintBackground( aRegion[i], pPage, rAttrs, false, true );
}
@@ -4605,7 +4605,7 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect,
pOut->SetDrawMode( nOldDrawMode );
- for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ for ( size_t i = 0; i < aRegion.size(); ++i )
{
SwRect &rOut = aRegion[i];
aOut = rOut;
@@ -4690,7 +4690,7 @@ void SwFrm::PaintBorderLine( const SwRect& rRect,
//{
// SwRegionRects aRegion( aOut, 4 );
// ::lcl_SubtractFlys( this, pPage, aOut, aRegion );
- // for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ // for ( size_t i = 0; i < aRegion.size(); ++i )
// pLines->AddLineRect( aRegion[i], pColor, nStyle, pTab, nSubCol );
//}
//else
@@ -4818,12 +4818,10 @@ static void lcl_SubTopBottom( SwRect& _iorRect,
static sal_uInt16 lcl_GetLineWidth( const SvxBorderLine* pLine )
{
- sal_uInt16 result = 0;
-
if ( pLine != NULL )
- result = pLine->GetScaledWidth();
+ return pLine->GetScaledWidth();
- return result;
+ return 0;
}
static double lcl_GetExtent( const SvxBorderLine* pSideLine, const SvxBorderLine* pOppositeLine )
@@ -4961,7 +4959,7 @@ static void lcl_PaintLeftRightLine( const bool _bLeft,
// Shift the left border to the left.
Point aCurPos = aRect.Pos();
- sal_uInt16 nOffset = pLeftRightBorder->GetDistance();
+ const sal_uInt16 nOffset = pLeftRightBorder->GetDistance();
aCurPos.X() -= nOffset;
aCurPos.Y() -= nOffset;
aRect.Pos(aCurPos);
@@ -5038,7 +5036,7 @@ static void lcl_PaintTopBottomLine( const bool _bTop,
(aRect.*_rRectFn->fnGetHeight)() );
// Push the top border up a bit.
- sal_uInt16 nOffset = pTopBottomBorder->GetDistance();
+ const sal_uInt16 nOffset = pTopBottomBorder->GetDistance();
Point aCurPos = aRect.Pos();
aCurPos.X() -= nOffset;
aCurPos.Y() -= nOffset;
@@ -5122,7 +5120,7 @@ void PaintCharacterBorder(
if( aTopBorder )
{
- sal_uInt16 nOffset = aTopBorder->GetDistance();
+ const sal_uInt16 nOffset = aTopBorder->GetDistance();
Point aLeftTop(
aAlignedRect.Left() - nOffset,
@@ -5161,7 +5159,7 @@ void PaintCharacterBorder(
if( aLeftBorder )
{
- sal_uInt16 nOffset = aLeftBorder->GetDistance();
+ const sal_uInt16 nOffset = aLeftBorder->GetDistance();
Point aLeftTop(
aAlignedRect.Left() - nOffset,
@@ -7382,7 +7380,7 @@ void SwFrm::Retouche( const SwPageFrm * pPage, const SwRect &rRect ) const
// #i16816# tagged pdf support
SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pSh->GetOut() );
- for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
+ for ( size_t i = 0; i < aRegion.size(); ++i )
{
SwRect &rRetouche = aRegion[i];
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 5ca1929..bd54386 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -87,7 +87,7 @@ SwTabFrm::SwTabFrm( SwTable &rTab, SwFrm* pSib ):
//Create the lines and insert them.
const SwTableLines &rLines = rTab.GetTabLines();
SwFrm *pTmpPrev = 0;
- for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
+ for ( size_t i = 0; i < rLines.size(); ++i )
{
SwRowFrm *pNew = new SwRowFrm( *rLines[i], this );
if( pNew->Lower() )
@@ -1357,8 +1357,8 @@ bool SwCntntFrm::CalcLowers( SwLayoutFrm* pLay, const SwLayoutFrm* pDontLeave,
SWRECTFN( pLay )
// FME 2007-08-30 #i81146# new loop control
- sal_uInt16 nLoopControlRuns = 0;
- const sal_uInt16 nLoopControlMax = 10;
+ int nLoopControlRuns = 0;
+ const int nLoopControlMax = 10;
const SwModify* pLoopControlCond = 0;
while ( pCnt && pDontLeave->IsAnLower( pCnt ) )
@@ -1481,15 +1481,15 @@ static bool lcl_InnerCalcLayout( SwFrm *pFrm,
static void lcl_RecalcRow( SwRowFrm& rRow, long nBottom )
{
// FME 2007-08-30 #i81146# new loop control
- sal_uInt16 nLoopControlRuns_1 = 0;
+ int nLoopControlRuns_1 = 0;
sal_uInt16 nLoopControlStage_1 = 0;
- const sal_uInt16 nLoopControlMax = 10;
+ const int nLoopControlMax = 10;
bool bCheck = true;
do
{
// FME 2007-08-30 #i81146# new loop control
- sal_uInt16 nLoopControlRuns_2 = 0;
+ int nLoopControlRuns_2 = 0;
sal_uInt16 nLoopControlStage_2 = 0;
while( lcl_InnerCalcLayout( &rRow, nBottom ) )
@@ -3510,7 +3510,7 @@ SwRowFrm::SwRowFrm( const SwTableLine &rLine, SwFrm* pSib, bool bInsertContent )
//Create the boxes and insert them.
const SwTableBoxes &rBoxes = rLine.GetTabBoxes();
SwFrm *pTmpPrev = 0;
- for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+ for ( size_t i = 0; i < rBoxes.size(); ++i )
{
SwCellFrm *pNew = new SwCellFrm( *rBoxes[i], this, bInsertContent );
pNew->InsertBehind( this, pTmpPrev );
@@ -3957,7 +3957,7 @@ void SwRowFrm::Format( const SwBorderAttrs *pAttrs )
while ( pTmpRow && !pPrevTabLine )
{
- sal_uInt16 nIdx = 0;
+ size_t nIdx = 0;
const SwTableLines& rLines = pTmpRow->GetTabLine()->GetUpper() ?
pTmpRow->GetTabLine()->GetUpper()->GetTabLines() :
pTable->GetTabLines();
@@ -4399,7 +4399,7 @@ SwCellFrm::SwCellFrm( const SwTableBox &rBox, SwFrm* pSib, bool bInsertContent )
{
const SwTableLines &rLines = rBox.GetTabLines();
SwFrm *pTmpPrev = 0;
- for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
+ for ( size_t i = 0; i < rLines.size(); ++i )
{
SwRowFrm *pNew = new SwRowFrm( *rLines[i], this, bInsertContent );
pNew->InsertBehind( this, pTmpPrev );
@@ -4722,7 +4722,7 @@ void SwCellFrm::Format( const SwBorderAttrs *pAttrs )
const SwTableBox* pTmpBox = 0;
SwTwips nSumWidth = 0;
- sal_uInt16 i = 0;
+ size_t i = 0;
do
{
pTmpBox = rBoxes[ i++ ];
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index ce15334..b8fa9f9 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1903,7 +1903,7 @@ bool SwRootFrm::MakeTblCrsrs( SwTableCursor& rTblCrsr )
const bool bReadOnlyAvailable = rTblCrsr.IsReadOnlyAvailable();
- for ( sal_uInt16 i = 0; i < aUnions.size(); ++i )
+ for ( size_t i = 0; i < aUnions.size(); ++i )
{
SwSelUnion *pUnion = &aUnions[i];
const SwTabFrm *pTable = pUnion->GetTable();
commit 992859b4377e0b7a3a177f0a69dc4e6fec765483
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Oct 26 10:00:05 2014 +0100
Use an enum instead of a constant, and reduce its scope
Change-Id: Ica9d53103ffa98a72b27303352f2f3997a3386d5
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 3d94b59..5d0b269 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -202,8 +202,6 @@ void SwFrm::SetRightLeftMargins( long nRight, long nLeft)
Prt().Width( Frm().Width() - nLeft - nRight );
}
-const sal_uInt16 nMinVertCellHeight = 1135;
-
/// checks the layout direction and invalidates the lower frames rekursivly, if necessary.
void SwFrm::CheckDirChange()
{
@@ -225,13 +223,17 @@ void SwFrm::CheckDirChange()
if ( IsVertical() != GetUpper()->IsVertical() &&
((SwCellFrm*)this)->GetTabBox()->getRowSpan() == 1 )
{
+ enum {
+ MIN_VERT_CELL_HEIGHT = 1135
+ };
+
SwTableLine* pLine = (SwTableLine*)((SwCellFrm*)this)->GetTabBox()->GetUpper();
SwFrmFmt* pFrmFmt = pLine->GetFrmFmt();
SwFmtFrmSize aNew( pFrmFmt->GetFrmSize() );
if ( ATT_FIX_SIZE != aNew.GetHeightSizeType() )
aNew.SetHeightSizeType( ATT_MIN_SIZE );
- if ( aNew.GetHeight() < nMinVertCellHeight )
- aNew.SetHeight( nMinVertCellHeight );
+ if ( aNew.GetHeight() < MIN_VERT_CELL_HEIGHT )
+ aNew.SetHeight( MIN_VERT_CELL_HEIGHT );
SwDoc* pDoc = pFrmFmt->GetDoc();
pDoc->SetAttr( aNew, *pLine->ClaimFrmFmt() );
}
commit 1ccd386cd426e2e92ee6a585dfc8bdf5c9edf6e7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Oct 25 18:17:28 2014 +0200
Use USHRT_MAX consistently, minor cleanups
Change-Id: I1a2906a350baf7af7141aaa6124930485578a604
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx
index 2e34603..664ad6a 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -155,7 +155,7 @@ void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong,
const OUString& rPackageName, bool bOnlyTxt )
{
sal_uInt16 nIdx = GetIndex( rShort );
- if( nIdx != (sal_uInt16) -1 )
+ if (nIdx != USHRT_MAX)
{
delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx );
@@ -500,7 +500,7 @@ void SwXMLTextBlocks::CloseFile()
void SwXMLTextBlocks::SetIsTextOnly( const OUString& rShort, bool bNewValue )
{
sal_uInt16 nIdx = GetIndex ( rShort );
- if (nIdx != (sal_uInt16) -1 && nIdx != USHRT_MAX)
+ if (nIdx != USHRT_MAX)
aNames[nIdx]->bIsOnlyTxt = bNewValue;
}
@@ -513,7 +513,7 @@ bool SwXMLTextBlocks::IsOnlyTextBlock( const OUString& rShort ) const
{
sal_uInt16 nIdx = GetIndex ( rShort );
bool bRet = false;
- if (nIdx != (sal_uInt16) -1 && nIdx != USHRT_MAX)
+ if (nIdx != USHRT_MAX)
{
bRet = aNames[nIdx]->bIsOnlyTxt;
}
diff --git a/sw/source/core/swg/swblocks.cxx b/sw/source/core/swg/swblocks.cxx
index 0f2f83a..b920c89 100644
--- a/sw/source/core/swg/swblocks.cxx
+++ b/sw/source/core/swg/swblocks.cxx
@@ -90,7 +90,7 @@ SwImpBlocks::SwImpBlocks( const OUString& rFile, bool )
: aFile( rFile ),
aDateModified( Date::EMPTY ),
aTimeModified( tools::Time::EMPTY ),
- pDoc( 0 ), nCur( (sal_uInt16)-1 ),
+ pDoc( 0 ), nCur( USHRT_MAX ),
bReadOnly( true ), bInPutMuchBlocks( false ),
bInfoChanged(false)
{
@@ -146,7 +146,7 @@ sal_uInt16 SwImpBlocks::GetIndex( const OUString& rShort ) const
&& pName->aShort == s )
return i;
}
- return (sal_uInt16) -1;
+ return USHRT_MAX;
}
sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const
@@ -159,7 +159,7 @@ sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const
&& pName->aLong == rLong )
return i;
}
- return (sal_uInt16) -1;
+ return USHRT_MAX;
}
OUString SwImpBlocks::GetShortName( sal_uInt16 n ) const
@@ -187,7 +187,7 @@ void SwImpBlocks::AddName( const OUString& rShort, const OUString& rLong,
bool bOnlyTxt )
{
sal_uInt16 nIdx = GetIndex( rShort );
- if( nIdx != (sal_uInt16) -1 )
+ if( nIdx != USHRT_MAX )
{
delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx );
@@ -280,12 +280,12 @@ sal_uInt16 SwTextBlocks::GetCount() const
sal_uInt16 SwTextBlocks::GetIndex( const OUString& r ) const
{
- return pImp ? pImp->GetIndex( r ) : (sal_uInt16) -1;
+ return pImp ? pImp->GetIndex( r ) : USHRT_MAX;
}
sal_uInt16 SwTextBlocks::GetLongIndex( const OUString& r ) const
{
- return pImp ? (sal_uInt16)(pImp->GetLongIndex( r )) : (sal_uInt16) -1;
+ return pImp ? pImp->GetLongIndex( r ) : USHRT_MAX;
}
OUString SwTextBlocks::GetShortName( sal_uInt16 n ) const
@@ -317,7 +317,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n )
pImp->aNames.erase( pImp->aNames.begin() + n );
}
if( n == pImp->nCur )
- pImp->nCur = (sal_uInt16) -1;
+ pImp->nCur = USHRT_MAX;
if( !nErr )
nErr = pImp->MakeBlockList();
}
@@ -331,7 +331,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n )
sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString* l )
{
- sal_uInt16 nIdx = (sal_uInt16)-1;
+ sal_uInt16 nIdx = USHRT_MAX;
if( pImp && !pImp->bInPutMuchBlocks )
{
pImp->nCur = nIdx;
@@ -344,7 +344,8 @@ sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString
if( aNew.isEmpty() )
{
OSL_ENSURE( false, "No short name provided in the rename" );
- nErr = ERR_SWG_INTERNAL_ERROR; return (sal_uInt16) -1;
+ nErr = ERR_SWG_INTERNAL_ERROR;
+ return USHRT_MAX;
}
if( pImp->IsFileChanged() )
@@ -401,7 +402,7 @@ bool SwTextBlocks::BeginGetDoc( sal_uInt16 n )
pImp->ClearDoc();
nErr = pImp->GetDoc( n );
if( nErr )
- pImp->nCur = (sal_uInt16)-1;
+ pImp->nCur = USHRT_MAX;
else
pImp->nCur = n;
}
@@ -442,14 +443,14 @@ bool SwTextBlocks::BeginPutDoc( const OUString& s, const OUString& l )
sal_uInt16 SwTextBlocks::PutDoc()
{
- sal_uInt16 nIdx = (sal_uInt16)-1;
+ sal_uInt16 nIdx = USHRT_MAX;
if( pImp )
{
nErr = pImp->PutDoc();
if( !nErr )
{
pImp->nCur = GetIndex( pImp->aShort );
- if( pImp->nCur != (sal_uInt16) -1 )
+ if( pImp->nCur != USHRT_MAX )
pImp->aNames[ pImp->nCur ]->aLong = pImp->aLong;
else
{
@@ -472,7 +473,7 @@ sal_uInt16 SwTextBlocks::PutDoc()
sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName,
const OUString& rTxt )
{
- sal_uInt16 nIdx = (sal_uInt16) -1;
+ sal_uInt16 nIdx = USHRT_MAX;
if( pImp )
{
bool bOk = pImp->bInPutMuchBlocks;
@@ -488,11 +489,11 @@ sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName,
{
OUString aNew = GetAppCharClass().uppercase( rShort );
nErr = pImp->PutText( aNew, rName, rTxt );
- pImp->nCur = (sal_uInt16) -1;
+ pImp->nCur = USHRT_MAX;
if( !nErr )
{
nIdx = GetIndex( pImp->aShort );
- if( nIdx != (sal_uInt16) -1 )
+ if( nIdx != USHRT_MAX )
pImp->aNames[ nIdx ]->aLong = rName;
else
{
@@ -524,7 +525,7 @@ void SwTextBlocks::ClearDoc()
if( pImp )
{
pImp->ClearDoc();
- pImp->nCur = (sal_uInt16) -1;
+ pImp->nCur = USHRT_MAX;
}
}
commit ff61e912e8c965c318ebe5d03af2866738584463
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Oct 25 16:05:03 2014 +0200
Remove unneeded forward declaration
Change-Id: Ib650c1e191f5ed8f64bb8ac253e9f412b358e2e8
diff --git a/sw/source/core/inc/SwXMLTextBlocks.hxx b/sw/source/core/inc/SwXMLTextBlocks.hxx
index 6aa2c27..4c0e16c 100644
--- a/sw/source/core/inc/SwXMLTextBlocks.hxx
+++ b/sw/source/core/inc/SwXMLTextBlocks.hxx
@@ -27,7 +27,6 @@
class SwPaM;
class SwDoc;
class SvxMacroTableDtor;
-class SwImpBlocks;
#define SWXML_CONVBLOCK 0x0001
#define SWXML_NOROOTCOMMIT 0x0002
commit f595a6c4c7789b0244610a4daad7b6b60c3c4350
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Oct 19 11:09:43 2014 +0200
Reuse common code
Change-Id: I8f1e8203f8318183fa327e96e53bdd0fb599ed89
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx
index 108c119..2e34603 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -144,24 +144,13 @@ void SwXMLTextBlocks::ClearDoc()
pDoc->ClearDoc();
pDocShell->ClearEmbeddedObjects();
}
+
void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong, bool bOnlyTxt )
{
- sal_uInt16 nIdx = GetIndex( rShort );
- SwBlockName* pNew = NULL;
- if( nIdx != (sal_uInt16) -1 )
- {
- delete aNames[nIdx];
- aNames.erase( aNames.begin() + nIdx );
- }
-
aPackageName = GeneratePackageName( rShort );
- pNew = new SwBlockName( rShort, rLong, aPackageName );
-
- pNew->bIsOnlyTxtFlagInit = true;
- pNew->bIsOnlyTxt = bOnlyTxt;
- aNames.insert( pNew );
- bInfoChanged = true;
+ AddName(rShort, rLong, aPackageName, bOnlyTxt);
}
+
void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong,
const OUString& rPackageName, bool bOnlyTxt )
{
commit 8fea52beeea5158e1cd3cc945821c6710f86f48a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Oct 12 22:49:03 2014 +0200
sal_uInt16 to size_t
Change-Id: Id60ca700d090dba30aeda7cdb3b3256a7fa3814e
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 5992299..ad84ee3 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -117,7 +117,7 @@ if bSet is true, rMin and rMax will be set to the left and right border of the b
*/
-static void lcl_CheckMinMax( long& rMin, long& rMax, const SwTableLine& rLine, sal_uInt16 nCheck, bool bSet )
+static void lcl_CheckMinMax( long& rMin, long& rMax, const SwTableLine& rLine, size_t nCheck, bool bSet )
{
++nCheck;
if( rLine.GetTabBoxes().size() < nCheck )
@@ -128,7 +128,7 @@ static void lcl_CheckMinMax( long& rMin, long& rMax, const SwTableLine& rLine, s
long nNew = 0; // will be the right border of the current box
long nWidth = 0; // the width of the current box
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCheck; ++nCurrBox )
+ for( size_t nCurrBox = 0; nCurrBox < nCheck; ++nCurrBox )
{
SwTableBox* pBox = rLine.GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -161,8 +161,8 @@ static long lcl_Box2LeftBorder( const SwTableBox& rBox )
return 0;
long nLeft = 0;
const SwTableLine &rLine = *rBox.GetUpper();
- sal_uInt16 nCount = rLine.GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
+ const size_t nCount = rLine.GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
{
SwTableBox* pBox = rLine.GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -195,8 +195,8 @@ static SwTableBox* lcl_LeftBorder2Box( long nLeft, const SwTableLine* pLine )
if( !pLine )
return 0;
long nCurrLeft = 0;
- sal_uInt16 nCount = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
+ const size_t nCount = pLine->GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -269,8 +269,8 @@ static void lcl_ChangeRowSpan( const SwTable& rTable, const long nDiff,
bGoOn = false; // will be set to true if we found a non-master cell
// which has to be manipulated => we have to check the previous row, too.
const SwTableLine* pLine = rTable.GetTabLines()[ nRowIdx ];
- sal_uInt16 nBoxCount = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
+ const size_t nBoxCount = pLine->GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
{
long nRowSpan = pLine->GetTabBoxes()[nCurrBox]->getRowSpan();
long nAbsSpan = nRowSpan > 0 ? nRowSpan : -nRowSpan;
@@ -332,16 +332,17 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
if( !pStartNd || !pEndNd || pStartNd == pEndNd )
return 0;
- sal_uInt16 nLines = aLines.size();
- sal_uInt16 nTop = 0, nBottom = 0;
+ const size_t nLines = aLines.size();
+ size_t nTop = 0;
+ size_t nBottom = 0;
long nMin = 0, nMax = 0;
int nFound = 0;
- for( sal_uInt16 nRow = 0; nFound < 2 && nRow < nLines; ++nRow )
+ for( size_t nRow = 0; nFound < 2 && nRow < nLines; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
+ const size_t nCols = pLine->GetTabBoxes().size();
+ for( size_t nCol = 0; nCol < nCols; ++nCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCol];
OSL_ENSURE( pBox, "Missing table box" );
@@ -371,12 +372,12 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
SwBoxSelection* pRet = new SwBoxSelection();
std::list< std::pair< SwTableBox*, long > > aNewWidthList;
- sal_uInt16 nCheckBottom = nBottom;
+ size_t nCheckBottom = nBottom;
long nLeftSpan = 0;
long nRightSpan = 0;
long nLeftSpanCnt = 0;
long nRightSpanCnt = 0;
- for( sal_uInt16 nRow = nTop; nRow <= nBottom && bOkay; ++nRow )
+ for( size_t nRow = nTop; nRow <= nBottom && bOkay; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
@@ -384,8 +385,8 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
long nLeft = 0;
long nRight = 0;
long nRowSpan = 1;
- sal_uInt16 nCount = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
+ const size_t nCount = pLine->GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -447,9 +448,9 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
break;
}
if( nRowSpan > 1 && nRow + nRowSpan - 1 > nBottom )
- nBottom = nRow + (sal_uInt16)nRowSpan - 1;
+ nBottom = nRow + nRowSpan - 1;
if( nRowSpan < -1 && nRow - nRowSpan - 1 > nBottom )
- nBottom = (sal_uInt16)(nRow - nRowSpan - 1);
+ nBottom = nRow - nRowSpan - 1;
if( nRightSpanCnt && nRight == nMax )
bOkay = false;
}
@@ -484,9 +485,9 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
{
long nTmpSpan = pInnerBox->getRowSpan();
if( nTmpSpan > 1 )
- nBottom += (sal_uInt16)nTmpSpan - 1;
+ nBottom += nTmpSpan - 1;
else if( nTmpSpan < -1 )
- nBottom = (sal_uInt16)( nBottom - nTmpSpan - 1 );
+ nBottom -= nTmpSpan + 1;
}
SwTableBox* pOuterBox = pLeftBox;
do
@@ -496,7 +497,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
long nOutSpan = pOuterBox->getRowSpan();
if( nOutSpan != 1 )
{
- sal_uInt16 nCheck = nRow;
+ size_t nCheck = nRow;
if( nOutSpan < 0 )
{
const SwTableBox& rBox =
@@ -534,7 +535,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
nRightSpanCnt = nOutSpan;
}
}
- nCheck += (sal_uInt16)nOutSpan - 1;
+ nCheck += nOutSpan - 1;
if( nCheck > nCheckBottom )
nCheckBottom = nCheck;
}
@@ -663,7 +664,7 @@ bool SwTable::NewInsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes,
std::vector< sal_uInt16 > aInsPos( aLines.size(), USHRT_MAX );
{ // Calculation of the insert positions and the width of the new boxes
sal_uInt64 nTableWidth = 0;
- for( sal_uInt16 i = 0; i < aLines[0]->GetTabBoxes().size(); ++i )
+ for( size_t i = 0; i < aLines[0]->GetTabBoxes().size(); ++i )
nTableWidth += aLines[0]->GetTabBoxes()[i]->GetFrmFmt()->GetFrmSize().GetWidth();
// Fill the vector of insert positions and the (average) width to insert
@@ -693,10 +694,10 @@ bool SwTable::NewInsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes,
SwTableNode* pTblNd = GetTableNode();
std::vector<SwTableBoxFmt*> aInsFormat( nCnt, 0 );
- sal_uInt16 nLastLine = USHRT_MAX;
+ size_t nLastLine = SAL_MAX_SIZE;
long nLastRowSpan = 1;
- for( sal_uInt16 i = 0; i < aLines.size(); ++i )
+ for( size_t i = 0; i < aLines.size(); ++i )
{
SwTableLine* pLine = aLines[ i ];
sal_uInt16 nInsPos = aInsPos[i];
@@ -709,7 +710,7 @@ bool SwTable::NewInsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes,
long nRowSpan = pBox->getRowSpan();
long nDiff = i - nLastLine;
bool bNewSpan = false;
- if( nLastLine != USHRT_MAX && nDiff <= nLastRowSpan &&
+ if( nLastLine != SAL_MAX_SIZE && nDiff <= nLastRowSpan &&
nRowSpan != nDiff - nLastRowSpan )
{
bNewSpan = true;
@@ -774,7 +775,7 @@ bool SwTable::NewInsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes,
{
const SwTableBoxes &rTabBoxes = aLines[0]->GetTabBoxes();
long nNewWidth = 0;
- for( sal_uInt16 i = 0; i < rTabBoxes.size(); ++i )
+ for( size_t i = 0; i < rTabBoxes.size(); ++i )
nNewWidth += rTabBoxes[i]->GetFrmFmt()->GetFrmSize().GetWidth();
OSL_ENSURE( nNewWidth > 0, "Very small" );
}
@@ -841,15 +842,15 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
SwPosition aInsPos( *pMergeBox->GetSttNd()->EndOfSectionNode() );
SwPaM aChkPam( aInsPos );
// The number of lines in the selection rectangle: nLineCount
- const sal_uInt16 nLineCount = sal_uInt16(pSel->aBoxes.size());
+ const size_t nLineCount = pSel->aBoxes.size();
// BTW: nLineCount is the rowspan of the new master cell
- long nRowSpan = nLineCount;
+ long nRowSpan = static_cast<long>(nLineCount);
// We will need the first and last line of the selection
// to check if there any superfluous row after merging
SwTableLine* pFirstLn = 0;
SwTableLine* pLastLn = 0;
// Iteration over the lines of the selection...
- for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
+ for( size_t nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
{
// The selected boxes in the current line
const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
@@ -927,7 +928,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
// pNewFmt will be set to the new master box and the overlapped cells
SwFrmFmt* pNewFmt = pMergeBox->ClaimFrmFmt();
pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, pSel->mnMergeWidth, 0 ) );
- for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
+ for( size_t nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
{
const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
size_t nColCount = pBoxes->size();
@@ -983,9 +984,9 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes,
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
+ const size_t nCols = pLine->GetTabBoxes().size();
bool bSuperfl = true;
- for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
+ for( size_t nCol = 0; nCol < nCols; ++nCol )
{
SwTableBox *pBox = pLine->GetTabBoxes()[nCol];
if( pBox->getRowSpan() > 0 &&
@@ -997,7 +998,7 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes,
}
if( bSuperfl )
{
- for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
+ for( size_t nCol = 0; nCol < nCols; ++nCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCol];
rBoxes.insert( pBox );
@@ -1142,8 +1143,8 @@ static void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, size_t nCnt,
static void lcl_FillSelBoxes( SwSelBoxes &rBoxes, SwTableLine &rLine )
{
- sal_uInt16 nBoxCount = rLine.GetTabBoxes().size();
- for( sal_uInt16 i = 0; i < nBoxCount; ++i )
+ const size_t nBoxCount = rLine.GetTabBoxes().size();
+ for( size_t i = 0; i < nBoxCount; ++i )
rBoxes.insert( rLine.GetTabBoxes()[i] );
}
@@ -1169,11 +1170,11 @@ void SwTable::InsertSpannedRow( SwDoc* pDoc, sal_uInt16 nRowIdx, sal_uInt16 nCnt
pFrmFmt->SetFmtAttr( aFSz );
}
_InsertRow( pDoc, aBoxes, nCnt, true );
- sal_uInt16 nBoxCount = rLine.GetTabBoxes().size();
+ const size_t nBoxCount = rLine.GetTabBoxes().size();
for( sal_uInt16 n = 0; n < nCnt; ++n )
{
SwTableLine *pNewLine = GetTabLines()[ nRowIdx + nCnt - n ];
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
+ for( size_t nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
{
long nRowSpan = rLine.GetTabBoxes()[nCurrBox]->getRowSpan();
if( nRowSpan > 0 )
@@ -1504,12 +1505,12 @@ bool SwTable::InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
SwSelBoxes aLineBoxes;
lcl_FillSelBoxes( aLineBoxes, *pLine );
_InsertRow( pDoc, aLineBoxes, nCnt, bBehind );
- sal_uInt16 nBoxCount = pLine->GetTabBoxes().size();
+ const size_t nBoxCount = pLine->GetTabBoxes().size();
sal_uInt16 nOfs = bBehind ? 0 : 1;
for( sal_uInt16 n = 0; n < nCnt; ++n )
{
SwTableLine *pNewLine = GetTabLines()[ nRowIdx+nCnt-n-nOfs];
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
+ for( size_t nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox )
{
long nRowSpan = pLine->GetTabBoxes()[nCurrBox]->getRowSpan();
if( bBehind )
@@ -1611,8 +1612,8 @@ static void lcl_SearchSelBox( const SwTable &rTable, SwSelBoxes& rBoxes, long nM
long nLeft = 0;
long nRight = 0;
long nMid = ( nMax + nMin )/ 2;
- sal_uInt16 nCount = rLine.GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
+ const size_t nCount = rLine.GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
{
SwTableBox* pBox = rLine.GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -1672,10 +1673,11 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
{
rBoxes.clear();
// Looking for start and end of the selection given by SwNode-pointer
- sal_uInt16 nLines = aLines.size();
+ const size_t nLines = aLines.size();
// nTop becomes the line number of the upper box
// nBottom becomes the line number of the lower box
- sal_uInt16 nTop = 0, nBottom = 0;
+ size_t nTop = 0;
+ size_t nBottom = 0;
// nUpperMin becomes the left border value of the upper box
// nUpperMax becomes the right border of the upper box
// nLowerMin and nLowerMax the borders of the lower box
@@ -1684,12 +1686,12 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
// nFound will incremented if a box is found
// 0 => no box found; 1 => the upper box has been found; 2 => both found
int nFound = 0;
- for( sal_uInt16 nRow = 0; nFound < 2 && nRow < nLines; ++nRow )
+ for( size_t nRow = 0; nFound < 2 && nRow < nLines; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
+ const size_t nCols = pLine->GetTabBoxes().size();
+ for( size_t nCol = 0; nCol < nCols; ++nCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCol];
OSL_ENSURE( pBox, "Missing table box" );
@@ -1729,12 +1731,12 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
// Selection of a row is quiet easy:
// every (unprotected) box between start and end line
// with a positive row span will be collected
- for( sal_uInt16 nRow = nTop; nRow <= nBottom; ++nRow )
+ for( size_t nRow = nTop; nRow <= nBottom; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
- sal_uInt16 nCount = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
+ const size_t nCount = pLine->GetTabBoxes().size();
+ for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
OSL_ENSURE( pBox, "Missing table box" );
@@ -1773,7 +1775,7 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
const bool bColumn = eSearch == SEARCH_COL;
if( bColumn )
{
- for( sal_uInt16 i = 0; i < nTop; ++i )
+ for( size_t i = 0; i < nTop; ++i )
lcl_SearchSelBox( *this, rBoxes, nUpperMin, nUpperMax,
*aLines[i], bChkProtected, bColumn );
}
@@ -1781,13 +1783,13 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
{
long nMin = nUpperMin < nLowerMin ? nUpperMin : nLowerMin;
long nMax = nUpperMax < nLowerMax ? nLowerMax : nUpperMax;
- for( sal_uInt16 i = nTop; i <= nBottom; ++i )
+ for( size_t i = nTop; i <= nBottom; ++i )
lcl_SearchSelBox( *this, rBoxes, nMin, nMax, *aLines[i],
bChkProtected, bColumn );
}
if( bColumn )
{
- for( sal_uInt16 i = nBottom + 1; i < nLines; ++i )
+ for( size_t i = nBottom + 1; i < nLines; ++i )
lcl_SearchSelBox( *this, rBoxes, nLowerMin, nLowerMax, *aLines[i],
bChkProtected, true );
}
@@ -1805,15 +1807,15 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax
if( aLines.empty() || rBoxes.empty() )
return;
- sal_uInt16 nLineCnt = aLines.size();
- size_t const nBoxCnt = rBoxes.size();
+ const size_t nLineCnt = aLines.size();
+ const size_t nBoxCnt = rBoxes.size();
size_t nBox = 0;
- for( sal_uInt16 nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow )
+ for( size_t nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
OSL_ENSURE( pLine, "Missing table line" );
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
- for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
+ const size_t nCols = pLine->GetTabBoxes().size();
+ for( size_t nCol = 0; nCol < nCols; ++nCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCol];
OSL_ENSURE( pBox, "Missing table box" );
@@ -1825,13 +1827,13 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax
}
}
}
- for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow )
+ for( size_t nRow = 0; nRow < nLineCnt; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
+ const size_t nCols = pLine->GetTabBoxes().size();
long nLeft = 0;
long nRight = 0;
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCols; ++nCurrBox )
+ for( size_t nCurrBox = 0; nCurrBox < nCols; ++nCurrBox )
{
nLeft = nRight;
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
@@ -1854,14 +1856,14 @@ void SwTable::PrepareDeleteCol( long nMin, long nMax )
const SwTwips nTabSize = GetFrmFmt()->GetFrmSize().GetWidth();
if( nTabSize == nMax )
nMid = nMax;
- sal_uInt16 nLineCnt = aLines.size();
- for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow )
+ const size_t nLineCnt = aLines.size();
+ for( size_t nRow = 0; nRow < nLineCnt; ++nRow )
{
SwTableLine* pLine = aLines[nRow];
- sal_uInt16 nCols = pLine->GetTabBoxes().size();
+ const size_t nCols = pLine->GetTabBoxes().size();
long nLeft = 0;
long nRight = 0;
- for( sal_uInt16 nCurrBox = 0; nCurrBox < nCols; ++nCurrBox )
+ for( size_t nCurrBox = 0; nCurrBox < nCols; ++nCurrBox )
{
nLeft = nRight;
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
@@ -1926,8 +1928,8 @@ void SwTable::CheckRowSpan( SwTableLine* &rpLine, bool bUp ) const
{
bChange = false;
rpLine = GetTabLines()[ nLineIdx ];
- sal_uInt16 nCols = rpLine->GetTabBoxes().size();
- for( sal_uInt16 nCol = 0; !bChange && nCol < nCols; ++nCol )
+ const size_t nCols = rpLine->GetTabBoxes().size();
+ for( size_t nCol = 0; !bChange && nCol < nCols; ++nCol )
{
SwTableBox* pBox = rpLine->GetTabBoxes()[nCol];
if( pBox->getRowSpan() > 1 || pBox->getRowSpan() < -1 )
@@ -1947,13 +1949,13 @@ void SwTable::CheckRowSpan( SwTableLine* &rpLine, bool bUp ) const
}
else
{
- sal_uInt16 nMaxLine = GetTabLines().size();
+ const size_t nMaxLine = GetTabLines().size();
while( bChange )
{
bChange = false;
rpLine = GetTabLines()[ nLineIdx ];
- sal_uInt16 nCols = rpLine->GetTabBoxes().size();
- for( sal_uInt16 nCol = 0; !bChange && nCol < nCols; ++nCol )
+ const size_t nCols = rpLine->GetTabBoxes().size();
+ for( size_t nCol = 0; !bChange && nCol < nCols; ++nCol )
{
SwTableBox* pBox = rpLine->GetTabBoxes()[nCol];
if( pBox->getRowSpan() < 0 )
@@ -1980,10 +1982,10 @@ SwSaveRowSpan::SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn )
: mnSplitLine( nSplitLn )
{
bool bDontSave = true; // nothing changed, nothing to save
- sal_uInt16 nColCount = rBoxes.size();
+ const size_t nColCount = rBoxes.size();
OSL_ENSURE( nColCount, "Empty Table Line" );
mnRowSpans.resize( nColCount );
- for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+ for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
{
SwTableBox* pBox = rBoxes[nCurrCol];
OSL_ENSURE( pBox, "Missing Table Box" );
@@ -2011,12 +2013,12 @@ void SwTable::RestoreRowSpan( const SwSaveRowSpan& rSave )
if( rSave.mnSplitLine < nLineCount )
{
SwTableLine* pLine = GetTabLines()[rSave.mnSplitLine];
- sal_uInt16 nColCount = pLine->GetTabBoxes().size();
+ const size_t nColCount = pLine->GetTabBoxes().size();
OSL_ENSURE( nColCount, "Empty Table Line" );
OSL_ENSURE( nColCount == rSave.mnRowSpans.size(), "Wrong row span store" );
if( nColCount == rSave.mnRowSpans.size() )
{
- for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+ for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrCol];
OSL_ENSURE( pBox, "Missing Table Box" );
@@ -2074,11 +2076,11 @@ void SwTable::CleanUpBottomRowSpan( sal_uInt16 nDelLines )
{
if( !IsNewModel() )
return;
- sal_uInt16 nLastLine = GetTabLines().size()-1;
+ const size_t nLastLine = GetTabLines().size()-1;
SwTableLine* pLine = GetTabLines()[nLastLine];
- sal_uInt16 nColCount = pLine->GetTabBoxes().size();
+ const size_t nColCount = pLine->GetTabBoxes().size();
OSL_ENSURE( nColCount, "Empty Table Line" );
- for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+ for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrCol];
OSL_ENSURE( pBox, "Missing Table Box" );
@@ -2087,7 +2089,8 @@ void SwTable::CleanUpBottomRowSpan( sal_uInt16 nDelLines )
nRowSp = -nRowSp;
if( nRowSp > 1 )
{
- lcl_ChangeRowSpan( *this, -static_cast<long>(nDelLines), nLastLine, false );
+ lcl_ChangeRowSpan( *this, -static_cast<long>(nDelLines),
+ static_cast<sal_uInt16>(nLastLine), false );
break;
}
}
@@ -2106,19 +2109,19 @@ void SwTable::CheckConsistency() const
{
if( !IsNewModel() )
return;
- sal_uInt16 nLineCount = GetTabLines().size();
+ const size_t nLineCount = GetTabLines().size();
const SwTwips nTabSize = GetFrmFmt()->GetFrmSize().GetWidth();
SwTwips nLineWidth = 0;
std::list< RowSpanCheck > aRowSpanCells;
std::list< RowSpanCheck >::iterator aIter = aRowSpanCells.end();
- for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
+ for( size_t nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
{
SwTwips nWidth = 0;
SwTableLine* pLine = GetTabLines()[nCurrLine];
SAL_WARN_IF( !pLine, "sw.core", "Missing Table Line" );
- sal_uInt16 nColCount = pLine->GetTabBoxes().size();
+ const size_t nColCount = pLine->GetTabBoxes().size();
SAL_WARN_IF( !nColCount, "sw.core", "Empty Table Line" );
- for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+ for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
{
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrCol];
SAL_WARN_IF( !pBox, "sw.core", "Missing Table Box" );
More information about the Libreoffice-commits
mailing list