[Libreoffice-commits] .: 5 commits - o3tl/inc sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 21 09:07:06 PDT 2012


 o3tl/inc/o3tl/sorted_vector.hxx     |    5 -
 sw/inc/cellfml.hxx                  |    2 
 sw/inc/crsrsh.hxx                   |    2 
 sw/inc/swcrsr.hxx                   |    8 +-
 sw/inc/swtable.hxx                  |   10 +--
 sw/inc/unotbl.hxx                   |    5 +
 sw/source/core/access/acccell.cxx   |    3 -
 sw/source/core/access/acctable.cxx  |    2 
 sw/source/core/crsr/crsrsh.cxx      |    9 +--
 sw/source/core/crsr/swcrsr.cxx      |   52 ++++++++++++-------
 sw/source/core/crsr/unocrsr.cxx     |   11 ++--
 sw/source/core/crsr/viscrs.cxx      |   14 ++---
 sw/source/core/doc/tblcpy.cxx       |    4 +
 sw/source/core/doc/tblrwcl.cxx      |   97 +++++++++++++++++++++---------------
 sw/source/core/docnode/ndcopy.cxx   |    2 
 sw/source/core/docnode/ndsect.cxx   |    2 
 sw/source/core/docnode/ndtbl.cxx    |   14 ++---
 sw/source/core/docnode/ndtbl1.cxx   |   10 ++-
 sw/source/core/edit/edtab.cxx       |    6 +-
 sw/source/core/fields/cellfml.cxx   |    9 +--
 sw/source/core/fields/ddetbl.cxx    |    2 
 sw/source/core/frmedt/fetab.cxx     |   20 ++++---
 sw/source/core/frmedt/tblsel.cxx    |   24 +++++---
 sw/source/core/inc/UndoTable.hxx    |    4 -
 sw/source/core/table/swnewtable.cxx |   62 +++++++++++------------
 sw/source/core/table/swtable.cxx    |   38 ++++++++------
 sw/source/core/undo/untbl.cxx       |   43 +++++++++------
 sw/source/core/unocore/unochart.cxx |    2 
 sw/source/core/unocore/unotbl.cxx   |   33 +++++++-----
 sw/source/filter/html/htmltab.cxx   |    3 -
 sw/source/filter/html/swhtml.hxx    |    2 
 31 files changed, 288 insertions(+), 212 deletions(-)

New commits:
commit 8e72fd8866fbef881a12049fd4ca87f5dea8d671
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 21 15:32:32 2012 +0200

    use scoped_array in lcl_UnMerge
    
    Change-Id: I00c899612d499273725ff8071aff1c93c7d17327

diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index ed0c47e..6ba86f5 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -43,6 +43,7 @@
 #include <set>
 #include <list>
 #include <memory>
+#include <boost/scoped_array.hpp>
 #include <editeng/boxitem.hxx>
 #include <editeng/protitem.hxx>
 #include <swtblfmt.hxx>
@@ -1097,10 +1098,10 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, size_t nCnt,
         return;
     if( nCnt > nCount )
         nCnt = nCount;
-    size_t *const pSplitIdx = new size_t[ nCnt ];
+    ::boost::scoped_array<size_t> const pSplitIdx(new size_t[nCnt]);
     if( bSameHeight )
     {
-        SwTwips *pHeights = new SwTwips[ nCount ];
+        ::boost::scoped_array<SwTwips> const pHeights(new SwTwips[nCount]);
         SwTwips nHeight = 0;
         for (size_t i = 0; i < nCount; ++i)
         {
@@ -1118,7 +1119,6 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, size_t nCnt,
                 nSumH += pHeights[ nIdx++ ];
             pSplitIdx[ i - 1 ] = nIdx;
         }
-        delete[] pHeights;
     }
     else
     {
@@ -1136,7 +1136,6 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, size_t nCnt,
         while( ++nIdx < nNextIdx )
             aBoxes[ nIdx ]->setRowSpan( nIdx - nNextIdx );
     }
-    delete[] pSplitIdx;
 }
 
 /** lcl_FillSelBoxes(..) puts all boxes of a given line into the selection structure
commit 2422544bb81170f7248046aa0a77efc14033deb9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 21 15:31:45 2012 +0200

    little cleanup in GetTblSel
    
    Change-Id: Idd8639d2f017342ae0227a44b75680179ca376a4

diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 4826701..f639f83 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -287,10 +287,9 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
         const SwCellFrm* pCurrentTopRightFrm    = 0;
         const SwCellFrm* pCurrentBottomLeftFrm  = 0;
         const SwCellFrm* pCurrentBottomRightFrm  = 0;
-        size_t i = 0;
 
         // Now find boxes for each entry and emit
-        for ( ; i < aUnions.size() && bTblIsValid; ++i)
+        for (size_t i = 0; i < aUnions.size() && bTblIsValid; ++i)
         {
             SwSelUnion *pUnion = &aUnions[i];
             const SwTabFrm *pTable = pUnion->GetTable();
@@ -425,8 +424,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
             break;
         }
 
-        i = 0;
-        rBoxes.erase( rBoxes.begin() + i, rBoxes.end() );
+        rBoxes.clear();
         --nLoopMax;
 
     } while( sal_True );
commit b844f06b36cf9a6c1411861a08701c8f9be2af0d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 21 15:18:23 2012 +0200

    fdo#48692: fix problems with large number of table cells:
    
    SwSelBoxes containers are filled from SwTableSortBoxes in various
    places, so adapt that to use size_t integers as well.
    
    Change-Id: Ia55f020bb9ada94bb22802d9adabb055a22edd2f

diff --git a/sw/inc/cellfml.hxx b/sw/inc/cellfml.hxx
index 6c020f1..d5a6f2d 100644
--- a/sw/inc/cellfml.hxx
+++ b/sw/inc/cellfml.hxx
@@ -152,7 +152,7 @@ public:
             eNmType = EXTRNL_NAME;
         }
 
-    sal_uInt16 GetBoxesOfFormula( const SwTable& rTbl, SwSelBoxes& rBoxes );
+    void GetBoxesOfFormula(const SwTable& rTbl, SwSelBoxes& rBoxes);
     // are all boxes valid which this formula relies on?
     bool HasValidBoxes() const;
 };
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 7630214..632b021 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -655,7 +655,7 @@ public:
 
     const SwShellTableCrsr* GetTableCrsr() const { return pTblCrsr; }
     SwShellTableCrsr* GetTableCrsr() { return pTblCrsr; }
-    sal_uInt16 UpdateTblSelBoxes();
+    size_t UpdateTblSelBoxes();
 
     sal_Bool GotoFtnTxt();      ///< jump from content to footnote
     sal_Bool GotoFtnAnchor();   ///< jump from footnote to anchor
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index 2a1c563..30901f3 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -270,7 +270,7 @@ class SwTableCursor : public virtual SwCursor
 protected:
     sal_uLong nTblPtNd, nTblMkNd;
     xub_StrLen nTblPtCnt, nTblMkCnt;
-    SwSelBoxes aSelBoxes;
+    SwSelBoxes m_SelectedBoxes;
     sal_Bool bChg : 1;
     sal_Bool bParked : 1;       // Table-cursor was parked.
 
@@ -286,9 +286,9 @@ public:
     virtual sal_Bool GotoTable( const String& rName );
 
     void InsertBox( const SwTableBox& rTblBox );
-    void DeleteBox( sal_uInt16 nPos ) { aSelBoxes.erase( aSelBoxes.begin() + nPos ); bChg = sal_True; }
-    sal_uInt16 GetBoxesCount() const { return aSelBoxes.size(); }
-    const SwSelBoxes& GetBoxes() const { return aSelBoxes; }
+    void DeleteBox(size_t nPos);
+    size_t GetSelectedBoxesCount() const { return m_SelectedBoxes.size(); }
+    const SwSelBoxes& GetSelectedBoxes() const { return m_SelectedBoxes; }
 
     // Creates cursor for all boxes.
     SwCursor* MakeBoxSels( SwCursor* pAktCrsr );
diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx
index 914a766..a96a2f1 100644
--- a/sw/source/core/access/acccell.cxx
+++ b/sw/source/core/access/acccell.cxx
@@ -72,7 +72,8 @@ sal_Bool SwAccessibleCell::IsSelected()
                 static_cast< const SwCellFrm * >( GetFrm() );
             SwTableBox *pBox =
                 const_cast< SwTableBox *>( pCFrm->GetTabBox() );
-            bRet = pCSh->GetTableCrsr()->GetBoxes().find( pBox ) != pCSh->GetTableCrsr()->GetBoxes().end();
+            SwSelBoxes const& rBoxes(pCSh->GetTableCrsr()->GetSelectedBoxes());
+            bRet = rBoxes.find(pBox) != rBoxes.end();
         }
     }
 
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 735c314..9c39db2 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -603,7 +603,7 @@ const SwSelBoxes *SwAccessibleTable::GetSelBoxes() const
     const SwCrsrShell *pCSh = GetCrsrShell();
     if( (pCSh != NULL) && pCSh->IsTableMode() )
     {
-        pSelBoxes = &pCSh->GetTableCrsr()->GetBoxes();
+        pSelBoxes = &pCSh->GetTableCrsr()->GetSelectedBoxes();
     }
 
     return pSelBoxes;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 64da8ea..8a6a5bf 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2658,12 +2658,13 @@ sal_Bool SwCrsrShell::ShouldWait() const
             pPam->End()->nNode.GetIndex();
 }
 
-
-sal_uInt16 SwCrsrShell::UpdateTblSelBoxes()
+size_t SwCrsrShell::UpdateTblSelBoxes()
 {
-    if( pTblCrsr && ( pTblCrsr->IsChgd() || !pTblCrsr->GetBoxesCount() ))
+    if (pTblCrsr && (pTblCrsr->IsChgd() || !pTblCrsr->GetSelectedBoxesCount()))
+    {
          GetLayout()->MakeTblCrsrs( *pTblCrsr );
-    return pTblCrsr ? pTblCrsr->GetBoxesCount() : 0;
+    }
+    return (pTblCrsr) ? pTblCrsr->GetSelectedBoxesCount() : 0;
 }
 
 /// show the current selected "object"
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index c1e0b40..d698865 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -2099,21 +2099,23 @@ SwTableCursor::SwTableCursor( const SwPosition &rPos, SwPaM* pRing )
 SwTableCursor::~SwTableCursor() {}
 
 
-sal_Bool lcl_SeekEntry( const SwSelBoxes& rTmp, const SwStartNode* pSrch, sal_uInt16& rFndPos )
+static bool
+lcl_SeekEntry(const SwSelBoxes& rTmp, SwStartNode const*const pSrch,
+        size_t & o_rFndPos)
 {
     sal_uLong nIdx = pSrch->GetIndex();
 
-    sal_uInt16 nO = rTmp.size();
+    size_t nO = rTmp.size();
     if( nO > 0 )
     {
         nO--;
-        sal_uInt16 nU = 0;
+        size_t nU = 0;
         while( nU <= nO )
         {
-            sal_uInt16 nM = nU + ( nO - nU ) / 2;
+            size_t nM = nU + ( nO - nU ) / 2;
             if( rTmp[ nM ]->GetSttNd() == pSrch )
             {
-                rFndPos = nM;
+                o_rFndPos = nM;
                 return sal_True;
             }
             else if( rTmp[ nM ]->GetSttIdx() < nIdx )
@@ -2146,14 +2148,14 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr )
 
         // create temporary copies so that all boxes that
         // have already cursors can be removed
-        SwSelBoxes aTmp( aSelBoxes );
+        SwSelBoxes aTmp(m_SelectedBoxes);
 
         // compare old and new ones
         SwNodes& rNds = pAktCrsr->GetDoc()->GetNodes();
-        sal_uInt16 nPos;
         const SwStartNode* pSttNd;
         SwPaM* pCur = pAktCrsr;
         do {
+            size_t nPos;
             sal_Bool bDel = sal_False;
             pSttNd = pCur->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
             if( !pCur->HasMark() || !pSttNd ||
@@ -2198,7 +2200,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr )
             }
         } while ( pAktCrsr != pCur );
 
-        for( nPos = 0; nPos < aTmp.size(); ++nPos )
+        for (size_t nPos = 0; nPos < aTmp.size(); ++nPos)
         {
             pSttNd = aTmp[ nPos ]->GetSttNd();
 
@@ -2239,7 +2241,14 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr )
 void SwTableCursor::InsertBox( const SwTableBox& rTblBox )
 {
     SwTableBox* pBox = (SwTableBox*)&rTblBox;
-    aSelBoxes.insert( pBox );
+    m_SelectedBoxes.insert(pBox);
+    bChg = sal_True;
+}
+
+
+void SwTableCursor::DeleteBox(size_t const nPos)
+{
+    m_SelectedBoxes.erase(m_SelectedBoxes.begin() + nPos);
     bChg = sal_True;
 }
 
@@ -2255,7 +2264,7 @@ bool SwTableCursor::NewTableSelection()
             pTableNode->GetTable().IsNewModel() )
         {
             bRet = true;
-            SwSelBoxes aNew( aSelBoxes );
+            SwSelBoxes aNew(m_SelectedBoxes);
             pTableNode->GetTable().CreateSelection( pStart, pEnd, aNew,
                 SwTable::SEARCH_NONE, false );
             ActualizeSelection( aNew );
@@ -2266,10 +2275,10 @@ bool SwTableCursor::NewTableSelection()
 
 void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew )
 {
-    sal_uInt16 nOld = 0, nNew = 0;
-    while ( nOld < aSelBoxes.size() && nNew < rNew.size() )
+    size_t nOld = 0, nNew = 0;
+    while (nOld < m_SelectedBoxes.size() && nNew < rNew.size())
     {
-        const SwTableBox* pPOld = aSelBoxes[ nOld ];
+        SwTableBox const*const pPOld = m_SelectedBoxes[ nOld ];
         const SwTableBox* pPNew = rNew[ nNew ];
         if( pPOld == pPNew )
         {   // this box will stay
@@ -2277,7 +2286,9 @@ void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew )
             ++nNew;
         }
         else if( pPOld->GetSttIdx() < pPNew->GetSttIdx() )
+        {
             DeleteBox( nOld ); // this box has to go
+        }
         else
         {
             InsertBox( *pPNew ); // this is a new one
@@ -2286,11 +2297,15 @@ void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew )
         }
     }
 
-    while( nOld < aSelBoxes.size() )
+    while (nOld < m_SelectedBoxes.size())
+    {
         DeleteBox( nOld ); // some more to delete
+    }
 
-    for( ; nNew < rNew.size(); ++nNew ) // some more to insert
+    for ( ; nNew < rNew.size(); ++nNew ) // some more to insert
+    {
         InsertBox( *rNew[ nNew ] );
+    }
 }
 
 sal_Bool SwTableCursor::IsCrsrMovedUpdt()
@@ -2329,14 +2344,15 @@ void SwTableCursor::ParkCrsr()
 sal_Bool SwTableCursor::HasReadOnlyBoxSel() const
 {
     sal_Bool bRet = sal_False;
-    for( sal_uInt16 n = aSelBoxes.size(); n;  )
-        if( aSelBoxes[ --n ]->GetFrmFmt()->GetProtect().IsCntntProtected() )
+    for (size_t n = m_SelectedBoxes.size(); n; )
+    {
+        if (m_SelectedBoxes[--n]->GetFrmFmt()->GetProtect().IsCntntProtected())
         {
             bRet = sal_True;
             break;
         }
+    }
     return bRet;
 }
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx
index 571c313..a1342a9 100644
--- a/sw/source/core/crsr/unocrsr.cxx
+++ b/sw/source/core/crsr/unocrsr.cxx
@@ -233,16 +233,17 @@ void SwUnoTableCrsr::MakeBoxSels()
 
     if ( !bMakeTblCrsrs )
     {
-        SwSelBoxes& rTmpBoxes = (SwSelBoxes&)GetBoxes();
-        sal_uInt16 nCount = 0;
-        while( nCount < rTmpBoxes.size() )
-            DeleteBox( nCount );
+        SwSelBoxes const& rTmpBoxes = GetSelectedBoxes();
+        while (!rTmpBoxes.empty())
+        {
+            DeleteBox(0);
+        }
     }
 
     if( IsChgd() )
     {
         SwTableCursor::MakeBoxSels( &aTblSel );
-        if( !GetBoxesCount() )
+        if (!GetSelectedBoxesCount())
         {
             const SwTableBox* pBox;
             const SwNode* pBoxNd = GetPoint()->nNode.GetNode().FindTableBoxStartNode();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 22a4b7c..09eebb7 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -630,15 +630,14 @@ void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
 void SwShellTableCrsr::FillRects()
 {
     // Calculate the new rectangles. If the cursor is still "parked" do nothing
-    if( aSelBoxes.empty() || bParked ||
-        !GetPoint()->nNode.GetIndex() )
+    if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
         return;
 
     SwRegionRects aReg( GetShell()->VisArea() );
     SwNodes& rNds = GetDoc()->GetNodes();
-    for( sal_uInt16 n = 0; n < aSelBoxes.size(); ++n )
+    for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
     {
-        const SwStartNode* pSttNd = aSelBoxes[n]->GetSttNd();
+        const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd();
         const SwTableNode* pSelTblNd = pSttNd->FindTableNode();
 
         SwNodeIndex aIdx( *pSttNd );
@@ -681,14 +680,13 @@ void SwShellTableCrsr::FillRects()
 sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const
 {
     // Calculate the new rectangles. If the cursor is still "parked" do nothing
-    if( aSelBoxes.empty() || bParked ||
-        !GetPoint()->nNode.GetIndex()  )
+    if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
         return sal_False;
 
     SwNodes& rNds = GetDoc()->GetNodes();
-    for( sal_uInt16 n = 0; n < aSelBoxes.size(); ++n )
+    for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
     {
-        SwNodeIndex aIdx( *aSelBoxes[ n ]->GetSttNd() );
+        SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() );
         SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
         if( !pCNd )
             continue;
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 273a865..8c5858f 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -1011,9 +1011,11 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes,
     if( 1 == rCpyTbl.GetTabSortBoxes().size() )
     {
         SwTableBox *pTmpBx = rCpyTbl.GetTabSortBoxes()[0];
-        for( sal_uInt16 n = 0; n < rSelBoxes.size(); ++n )
+        for (size_t n = 0; n < rSelBoxes.size(); ++n)
+        {
             lcl_CpyBox( rCpyTbl, pTmpBx, *this,
                         (SwTableBox*)rSelBoxes[n], sal_True, pUndo );
+        }
     }
     else
         for( nLn = 0; nLn < aFndBox.GetLines().size(); ++nLn )
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index ef8857f..4a5876f 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -103,7 +103,7 @@ struct _CpyTabFrm
 
 struct CR_SetBoxWidth
 {
-    SwSelBoxes aBoxes;
+    SwSelBoxes m_Boxes;
     SwTableLineWidthMap_t m_LineWidthMap;
     SwShareBoxFmts aShareFmts;
     SwTableNode* pTblNd;
@@ -141,7 +141,7 @@ struct CR_SetBoxWidth
 
     SwUndoTblNdsChg* CreateUndo( SwUndoId eUndoType )
     {
-        return pUndo = new SwUndoTblNdsChg( eUndoType, aBoxes, *pTblNd );
+        return pUndo = new SwUndoTblNdsChg( eUndoType, m_Boxes, *pTblNd );
     }
 
     void LoopClear()
@@ -220,7 +220,7 @@ void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize );
 
 struct CR_SetLineHeight
 {
-    SwSelBoxes aBoxes;
+    SwSelBoxes m_Boxes;
     SwShareBoxFmts aShareFmts;
     SwTableNode* pTblNd;
     SwUndoTblNdsChg* pUndo;
@@ -250,7 +250,7 @@ struct CR_SetLineHeight
 
     SwUndoTblNdsChg* CreateUndo( SwUndoId nUndoType )
     {
-        return pUndo = new SwUndoTblNdsChg( nUndoType, aBoxes, *pTblNd );
+        return pUndo = new SwUndoTblNdsChg( nUndoType, m_Boxes, *pTblNd );
     }
 };
 
@@ -940,10 +940,11 @@ void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo,
     } while( pBox->GetTabLines().empty() );
 }
 
-SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns,
+static SwTableBox*
+lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns,
                                 SwTwips nBoxStt, SwTwips nBoxWidth,
                                 sal_uInt16 nLinePos, sal_Bool bNxt,
-                                SwSelBoxes* pAllDelBoxes, sal_uInt16* pCurPos )
+                                SwSelBoxes* pAllDelBoxes, size_t *const pCurPos)
 {
     SwTableBox* pFndBox = 0;
     do {
@@ -983,7 +984,7 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns,
             SwSelBoxes::const_iterator aFndIt = pAllDelBoxes->find( pFndBox);
             if( aFndIt == pAllDelBoxes->end() )
                 break;
-            sal_uInt16 nFndPos = aFndIt - pAllDelBoxes->begin() ;
+            size_t const nFndPos = aFndIt - pAllDelBoxes->begin() ;
 
             // else, we keep on searching.
             // We do not need to recheck the Box, however
@@ -996,10 +997,11 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns,
     return pFndBox;
 }
 
-void lcl_SaveUpperLowerBorder( SwTable& rTbl, const SwTableBox& rBox,
+static void
+lcl_SaveUpperLowerBorder( SwTable& rTbl, const SwTableBox& rBox,
                                 SwShareBoxFmts& rShareFmts,
                                 SwSelBoxes* pAllDelBoxes = 0,
-                                sal_uInt16* pCurPos = 0 )
+                                size_t *const pCurPos = 0 )
 {
 //JP 16.04.97:  2. part for Bug 36271
     sal_Bool bChgd = sal_False;
@@ -1104,18 +1106,20 @@ sal_Bool SwTable::DeleteSel(
     if( bCorrBorder )
     {
         SwSelBoxes aBoxes( rBoxes );
-        for( sal_uInt16 n = 0; n < aBoxes.size(); ++n )
+        for (size_t n = 0; n < aBoxes.size(); ++n)
+        {
             ::lcl_SaveUpperLowerBorder( *this, *rBoxes[ n ], aShareFmts,
                                         &aBoxes, &n );
+        }
     }
 
     PrepareDelBoxes( rBoxes );
 
     SwChartDataProvider *pPCD = pDoc->GetChartDataProvider();
     // Delete boxes from last to first
-    for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
+    for (size_t n = 0; n < rBoxes.size(); ++n)
     {
-        sal_uInt16 nIdx = rBoxes.size() - 1 - n;
+        size_t const nIdx = rBoxes.size() - 1 - n;
 
         // First adapt the data-sequence for chart if necessary
         // (needed to move the implementation cursor properly to it's new
@@ -1163,7 +1167,7 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16
     if ( bSameHeight )
     {
         pRowHeights = new long[ rBoxes.size() ];
-        for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
+        for (size_t n = 0; n < rBoxes.size(); ++n)
         {
             SwTableBox* pSelBox = rBoxes[n];
             const SwRowFrm* pRow = GetRowFrm( *pSelBox->GetUpper() );
@@ -1178,7 +1182,7 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16
     aFndBox.SetTableLines( rBoxes, *this );
     aFndBox.DelFrms( *this );
 
-    for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
+    for (size_t n = 0; n < rBoxes.size(); ++n)
     {
         SwTableBox* pSelBox = rBoxes[n];
         OSL_ENSURE( pSelBox, "Box is not within the Table" );
@@ -1309,7 +1313,7 @@ sal_Bool SwTable::SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nC
     _CpyTabFrms aFrmArr;
     std::vector<SwTableBoxFmt*> aLastBoxArr;
     sal_uInt16 nFndPos;
-    for( sal_uInt16 n = 0; n < aSelBoxes.size(); ++n )
+    for (size_t n = 0; n < aSelBoxes.size(); ++n)
     {
         SwTableBox* pSelBox = aSelBoxes[n];
         OSL_ENSURE( pSelBox, "Box steht nicht in der Tabelle" );
@@ -2768,7 +2772,9 @@ sal_Bool lcl_InsSelBox( SwTableLine* pLine, CR_SetBoxWidth& rParam,
                     return sal_False;
 
                 if( pBox->GetSttNd() )
-                    rParam.aBoxes.insert( pBox );
+                {
+                    rParam.m_Boxes.insert(pBox);
+                }
 
                 break;
             }
@@ -3163,7 +3169,7 @@ sal_Bool lcl_DeleteBox_Rekursiv( CR_SetBoxWidth& rParam, SwTableBox& rBox,
             else
             {
                 SwTableBox* pBox = &rBox;
-                rParam.aBoxes.insert( pBox );
+                rParam.m_Boxes.insert(pBox);
             }
         }
         else
@@ -3510,7 +3516,7 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo,
     // Find all Boxes/Lines
     SwTable& rTbl = rParam.pTblNd->GetTable();
 
-    if( rParam.aBoxes.empty() )
+    if (rParam.m_Boxes.empty())
     {
         // Get the Boxes
         if( rParam.bBigger )
@@ -3522,15 +3528,18 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo,
     }
 
     // Prevent deleting the whole Table
-    if( rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().size() )
+    if (rParam.bBigger
+        && rParam.m_Boxes.size() == rTbl.GetTabSortBoxes().size())
+    {
         return 0;
+    }
 
     _FndBox* pFndBox = new _FndBox( 0, 0 );
     if( rParam.bBigger )
-        pFndBox->SetTableLines( rParam.aBoxes, rTbl );
+        pFndBox->SetTableLines( rParam.m_Boxes, rTbl );
     else
     {
-        _FndPara aPara( rParam.aBoxes, pFndBox );
+        _FndPara aPara(rParam.m_Boxes, pFndBox);
         ForEach_FndLineCopyCol( rTbl.GetTabLines(), &aPara );
         OSL_ENSURE( pFndBox->GetLines().size(), "Where are the Boxes" );
         pFndBox->SetTableLines( rTbl );
@@ -3665,10 +3674,10 @@ sal_Bool SwTable::SetColWidth( SwTableBox& rAktBox, sal_uInt16 eType,
                     pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo,
                                                     aTmpLst, nDistStt );
                     if (aParam.bBigger &&
-                        aParam.aBoxes.size() == m_TabSortContentBoxes.size())
+                        aParam.m_Boxes.size() == m_TabSortContentBoxes.size())
                     {
                         // This whole Table is to be deleted!
-                        GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes );
+                        GetFrmFmt()->GetDoc()->DeleteRowCol(aParam.m_Boxes);
                         return sal_False;
                     }
 
@@ -4045,18 +4054,21 @@ _FndBox* lcl_SaveInsDelData( CR_SetLineHeight& rParam, SwUndo** ppUndo,
     // Find all Boxes/Lines
     SwTable& rTbl = rParam.pTblNd->GetTable();
 
-    OSL_ENSURE( !rParam.aBoxes.empty(), "We can't go on without Boxes!" );
+    OSL_ENSURE( !rParam.m_Boxes.empty(), "We can't go on without Boxes!" );
 
     // Prevent deleting the whole Table
-    if( !rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().size() )
+    if (!rParam.bBigger
+        && rParam.m_Boxes.size() == rTbl.GetTabSortBoxes().size())
+    {
         return 0;
+    }
 
     _FndBox* pFndBox = new _FndBox( 0, 0 );
     if( !rParam.bBigger )
-        pFndBox->SetTableLines( rParam.aBoxes, rTbl );
+        pFndBox->SetTableLines( rParam.m_Boxes, rTbl );
     else
     {
-        _FndPara aPara( rParam.aBoxes, pFndBox );
+        _FndPara aPara(rParam.m_Boxes, pFndBox);
         ForEach_FndLineCopyCol( rTbl.GetTabLines(), &aPara );
         OSL_ENSURE( pFndBox->GetLines().size(), "Where are the Boxes?" );
         pFndBox->SetTableLines( rTbl );
@@ -4192,16 +4204,18 @@ sal_Bool lcl_InsDelSelLine( SwTableLine* pLine, CR_SetLineHeight& rParam,
         SwDoc* pDoc = pLine->GetFrmFmt()->GetDoc();
         if( !rParam.bBigger )
         {
-            sal_uInt16 n;
-
-            for( n = rBoxes.size(); n; )
+            for (size_t n = rBoxes.size(); n; )
+            {
                 ::lcl_SaveUpperLowerBorder( rParam.pTblNd->GetTable(),
                                                     *rBoxes[ --n ],
                                                     rParam.aShareFmts );
-            for( n = rBoxes.size(); n; )
+            }
+            for (size_t n = rBoxes.size(); n; )
+            {
                 ::_DeleteBox( rParam.pTblNd->GetTable(),
                                     rBoxes[ --n ], rParam.pUndo, sal_False,
                                     sal_False, &rParam.aShareFmts );
+            }
         }
         else
         {
@@ -4266,7 +4280,9 @@ sal_Bool lcl_InsDelSelLine( SwTableLine* pLine, CR_SetLineHeight& rParam,
                 return sal_False;
 
             if( pBox->GetSttNd() )
-                rParam.aBoxes.insert( pBox );
+            {
+                rParam.m_Boxes.insert(pBox);
+            }
             else
             {
                 for( sal_uInt16 i = pBox->GetTabLines().size(); i; )
@@ -4359,17 +4375,19 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType,
                 {
                     if( bInsDel )
                     {
-                        if( aParam.aBoxes.empty() )
+                        if (aParam.m_Boxes.empty())
+                        {
                             ::lcl_InsDelSelLine( (*pLines)[ nBaseLinePos ],
                                                     aParam, 0, sal_True );
+                        }
 
                         pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo, aTmpLst );
 
                         // delete complete table when last row is deleted
                         if( !bBigger &&
-                            aParam.aBoxes.size() == m_TabSortContentBoxes.size())
+                            aParam.m_Boxes.size() == m_TabSortContentBoxes.size())
                         {
-                            GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes );
+                            GetFrmFmt()->GetDoc()->DeleteRowCol(aParam.m_Boxes);
                             return sal_False;
                         }
 
@@ -4445,9 +4463,11 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType,
                     // Adjust
                     if( bInsDel )
                     {
-                        if( aParam.aBoxes.empty() )
+                        if (aParam.m_Boxes.empty())
+                        {
                             ::lcl_InsDelSelLine( (*pLines)[ nBaseLinePos ],
                                                     aParam, 0, sal_True );
+                        }
                         pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo, aTmpLst );
                         if( ppUndo )
                             *ppUndo = aParam.CreateUndo(
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index f334b7b..a39e015 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2170,7 +2170,7 @@ sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 n
         aTmpLst.insert( rTbl.GetTabSortBoxes() );
         if( !bVert )
         {
-            for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
+            for (size_t n = 0; n < rBoxes.size(); ++n)
             {
                 const SwStartNode* pSttNd = rBoxes[ n ]->GetSttNd();
                 aNdsCnts.push_back( pSttNd->EndOfSectionIndex() -
@@ -2546,7 +2546,7 @@ bool FuzzyCompare::operator() ( long s1, long s2 ) const
 
 bool lcl_IsFrmInColumn( const SwCellFrm& rFrm, SwSelBoxes& rBoxes )
 {
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {
         if ( rFrm.GetTabBox() == rBoxes[ i ] )
             return true;
@@ -4469,7 +4469,7 @@ sal_Bool SwDoc::UnProtectCells( const SwSelBoxes& rBoxes )
                 : 0;
 
         std::vector<SwFrmFmt*> aFmts, aNewFmts;
-        for( sal_uInt16 i = rBoxes.size(); i; )
+        for (size_t i = rBoxes.size(); i; )
         {
             SwTableBox* pBox = rBoxes[ --i ];
             SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index c10e722..024fd77 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1137,8 +1137,8 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew )
         }
 
         std::vector<SwTblFmtCmp*> aFmtCmp;
-        aFmtCmp.reserve( Max( 255, (int)aBoxes.size() ) );
-        for ( sal_uInt16 i = 0; i < aBoxes.size(); ++i )
+        aFmtCmp.reserve(std::max<size_t>(255, aBoxes.size()));
+        for (size_t i = 0; i < aBoxes.size(); ++i)
         {
             SwTableBox *pBox = aBoxes[i];
 
@@ -1183,7 +1183,7 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons
         bRet = sal_True;
         sal_Bool bOneFound = sal_False;
         const sal_uInt16 nWhich = rToFill.Which();
-        for( sal_uInt16 i = 0; i < aBoxes.size(); ++i )
+        for (size_t i = 0; i < aBoxes.size(); ++i)
         {
             switch ( nWhich )
             {
@@ -1253,7 +1253,8 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor ) const
     SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
     SwSelBoxes aBoxes;
     if( pTblNd && ::lcl_GetBoxSel( rCursor, aBoxes ))
-        for( sal_uInt16 i = 0; i < aBoxes.size(); ++i )
+    {
+        for (size_t i = 0; i < aBoxes.size(); ++i)
         {
             const SwFmtVertOrient &rOri =
                             aBoxes[i]->GetFrmFmt()->GetVertOrient();
@@ -1265,6 +1266,7 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor ) const
                 break;
             }
         }
+    }
     return nAlign;
 }
 
diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx
index 43f09ca..2a84453 100644
--- a/sw/source/core/edit/edtab.cxx
+++ b/sw/source/core/edit/edtab.cxx
@@ -272,7 +272,7 @@ sal_Bool SwEditShell::GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const
         } while( sal_False );
     }
 
-    for( sal_uInt16 n = 0; n < aBoxes.size(); ++n )
+    for (size_t n = 0; n < aBoxes.size(); ++n)
     {
         const SwTableBox* pSelBox = aBoxes[ n ];
         const SwTableBoxFmt* pTblFmt = (SwTableBoxFmt*)pSelBox->GetFrmFmt();
@@ -320,8 +320,10 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet )
 
     StartAllAction();
     GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
-    for( sal_uInt16 n = 0; n < aBoxes.size(); ++n )
+    for (size_t n = 0; n < aBoxes.size(); ++n)
+    {
         GetDoc()->SetTblBoxFormulaAttrs( *aBoxes[ n ], rSet );
+    }
     GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
     EndAllAction();
 }
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 102b1e2..430067f 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -346,8 +346,8 @@ void SwTableFormula::_MakeFormula( const SwTable& rTbl, String& rNewStr,
 
         rNewStr += '(';
         bool bDelim = false;
-        for( sal_uInt16 n = 0; n < aBoxes.size() &&
-                           !pCalcPara->rCalc.IsCalcError(); ++n )
+        for (size_t n = 0; n < aBoxes.size() &&
+                           !pCalcPara->rCalc.IsCalcError(); ++n)
         {
             const SwTableBox* pTblBox = aBoxes[n];
             if ( pTblBox->getRowSpan() >= 1 )
@@ -869,14 +869,13 @@ String lcl_BoxNmToRel( const SwTable& rTbl, const SwTableNode& rTblNd,
     return sTmp;
 }
 
-sal_uInt16 SwTableFormula::GetBoxesOfFormula( const SwTable& rTbl,
+void SwTableFormula::GetBoxesOfFormula( const SwTable& rTbl,
                                         SwSelBoxes& rBoxes )
 {
     rBoxes.clear();
 
     BoxNmToPtr( &rTbl );
     ScanString( &SwTableFormula::_GetFmlBoxes, rTbl, &rBoxes );
-    return rBoxes.size();
 }
 
 void SwTableFormula::_GetFmlBoxes( const SwTable& rTbl, String& ,
@@ -956,7 +955,7 @@ void SwTableFormula::GetBoxes( const SwTableBox& rSttBox,
                 break;
 
             // dann mal die Tabellenkoepfe raus:
-            for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
+            for (size_t n = 0; n < rBoxes.size(); ++n)
             {
                 pLine = rBoxes[n]->GetUpper();
                 while( pLine->GetUpper() )
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 5e5b137..0ce3062 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -95,11 +95,11 @@ class TblWait
 {
     SwWait *pWait;
 public:
-    TblWait( sal_uInt16 nCnt, SwFrm *pFrm, SwDocShell &rDocShell, sal_uInt16 nCnt2 = 0);
+    TblWait(size_t nCnt, SwFrm *pFrm, SwDocShell &rDocShell, size_t nCnt2 = 0);
     ~TblWait() { delete pWait; }
 };
 
-TblWait::TblWait( sal_uInt16 nCnt, SwFrm *pFrm, SwDocShell &rDocShell, sal_uInt16 nCnt2):
+TblWait::TblWait(size_t const nCnt, SwFrm *pFrm, SwDocShell &rDocShell, size_t const nCnt2):
     pWait( 0 )
 {
     sal_Bool bWait = 20 < nCnt || 20 < nCnt2 || (pFrm &&
@@ -478,7 +478,8 @@ sal_uInt16 SwFEShell::MergeTab()
             SET_CURR_SHELL( this );
             StartAllAction();
 
-            TblWait( pTableCrsr->GetBoxesCount(), 0, *GetDoc()->GetDocShell(),
+            TblWait(pTableCrsr->GetSelectedBoxesCount(), 0,
+                    *GetDoc()->GetDocShell(),
                      pTblNd->GetTable().GetTabLines().size() );
 
             nRet = GetDoc()->MergeTbl( *pTableCrsr );
@@ -1207,7 +1208,8 @@ void SwFEShell::AdjustCellWidth( sal_Bool bBalance )
 
     // switch on wait-cursor, as we do not know how
     // much content is affected
-    TblWait aWait( USHRT_MAX, 0, *GetDoc()->GetDocShell() );
+    TblWait aWait(::std::numeric_limits<size_t>::max(), 0,
+                  *GetDoc()->GetDocShell());
 
     GetDoc()->AdjustCellWidth( *getShellCrsr( false ), bBalance );
     EndAllActionAndCall();
@@ -1236,7 +1238,7 @@ sal_Bool SwFEShell::IsAdjustCellWidthAllowed( sal_Bool bBalance ) const
         aBoxes.insert( pBox );
     }
 
-    for ( sal_uInt16 i = 0; i < aBoxes.size(); ++i )
+    for (size_t i = 0; i < aBoxes.size(); ++i)
     {
         SwTableBox *pBox = aBoxes[i];
         if ( pBox->GetSttNd() )
@@ -2337,8 +2339,8 @@ sal_Bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& rFml
 {
     SwTblBoxFormula aTmp( rFml );
     SwSelBoxes aBoxes;
-
-    for( sal_uInt16 nSelBoxes = aTmp.GetBoxesOfFormula( rTbl,aBoxes ); nSelBoxes; )
+    aTmp.GetBoxesOfFormula(rTbl, aBoxes);
+    for (size_t nSelBoxes = aBoxes.size(); nSelBoxes; )
     {
         SwTableBox* pBox = aBoxes[ --nSelBoxes ];
         SwCellFrms::iterator iC;
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index aa8fbc4..4826701 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -138,21 +138,25 @@ void GetTblSelCrs( const SwCrsrShell &rShell, SwSelBoxes& rBoxes )
 {
     rBoxes.clear();
     if( rShell.IsTableMode() && ((SwCrsrShell&)rShell).UpdateTblSelBoxes())
-        rBoxes.insert( (SwSelBoxes&)rShell.GetTableCrsr()->GetBoxes() );
+    {
+        rBoxes.insert(rShell.GetTableCrsr()->GetSelectedBoxes());
+    }
 }
 
 void GetTblSelCrs( const SwTableCursor& rTblCrsr, SwSelBoxes& rBoxes )
 {
     rBoxes.clear();
 
-    if( rTblCrsr.IsChgd() || !rTblCrsr.GetBoxesCount() )
+    if (rTblCrsr.IsChgd() || !rTblCrsr.GetSelectedBoxesCount())
     {
         SwTableCursor* pTCrsr = (SwTableCursor*)&rTblCrsr;
         pTCrsr->GetDoc()->GetCurrentLayout()->MakeTblCrsrs( *pTCrsr );  //swmod 080218
     }
 
-    if( rTblCrsr.GetBoxesCount() )
-        rBoxes.insert( (SwSelBoxes&)rTblCrsr.GetBoxes() );
+    if (rTblCrsr.GetSelectedBoxesCount())
+    {
+        rBoxes.insert(rTblCrsr.GetSelectedBoxes());
+    }
 }
 
 void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes,
@@ -267,7 +271,6 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
     sal_Bool bTblIsValid;
     // #i55421# Reduced value 10
     int nLoopMax = 10;
-    sal_uInt16 i;
 
     do {
         bTblIsValid = sal_True;
@@ -284,9 +287,10 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
         const SwCellFrm* pCurrentTopRightFrm    = 0;
         const SwCellFrm* pCurrentBottomLeftFrm  = 0;
         const SwCellFrm* pCurrentBottomRightFrm  = 0;
+        size_t i = 0;
 
         // Now find boxes for each entry and emit
-        for( i = 0; i < aUnions.size() && bTblIsValid; ++i )
+        for ( ; i < aUnions.size() && bTblIsValid; ++i)
         {
             SwSelUnion *pUnion = &aUnions[i];
             const SwTabFrm *pTable = pUnion->GetTable();
@@ -848,12 +852,14 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
 sal_Bool HasProtectedCells( const SwSelBoxes& rBoxes )
 {
     sal_Bool bRet = sal_False;
-    for( sal_uInt16 n = 0, nCnt = rBoxes.size(); n < nCnt; ++n )
+    for (size_t n = 0; n < rBoxes.size(); ++n)
+    {
         if( rBoxes[ n ]->GetFrmFmt()->GetProtect().IsCntntProtected() )
         {
             bRet = sal_True;
             break;
         }
+    }
     return bRet;
 }
 
@@ -2112,7 +2118,7 @@ void _FndBox::SetTableLines( const SwSelBoxes &rBoxes, const SwTable &rTable )
     sal_uInt16 nStPos = USHRT_MAX;
     sal_uInt16 nEndPos= 0;
 
-    for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {
         SwTableLine *pLine = rBoxes[i]->GetUpper();
         while ( pLine->GetUpper() )
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index d22552d..32bae43 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -176,7 +176,7 @@ public:
 class SwUndoTblNdsChg : public SwUndo, private boost::noncopyable
 {
     _SaveTable* pSaveTbl;
-    std::set<sal_uLong> aBoxes;
+    std::set<sal_uLong> m_Boxes;
     struct _BoxMove
     {
         sal_uLong index;    ///< Index of this box.
@@ -229,7 +229,7 @@ class SwUndoTblMerge : public SwUndo, private SwUndRng
 {
     sal_uLong nTblNode;
     _SaveTable* pSaveTbl;
-    std::set<sal_uLong> aBoxes;
+    std::set<sal_uLong> m_Boxes;
     std::vector<sal_uLong> aNewSttNds;
     SwUndoMoves* pMoves;
     SwHistory* pHistory;
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 5fa2377..ed0c47e 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -610,7 +610,7 @@ long lcl_InsertPosition( SwTable &rTable, std::vector<sal_uInt16>& rInsPos,
 {
     sal_Int32 nAddWidth = 0;
     long nCount = 0;
-    for( sal_uInt16 j = 0; j < rBoxes.size(); ++j )
+    for (size_t j = 0; j < rBoxes.size(); ++j)
     {
         SwTableBox *pBox = rBoxes[j];
         SwTableLine* pLine = pBox->GetUpper();
@@ -852,9 +852,9 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
     {
         // The selected boxes in the current line
         const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
-        sal_uInt16 nColCount = pBoxes->size();
+        size_t nColCount = pBoxes->size();
         // Iteration over the selected cell in the current row
-        for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+        for (size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol)
         {
             SwTableBox* pBox = (*pBoxes)[nCurrCol];
             rMerged.insert( pBox );
@@ -930,8 +930,8 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
         for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
         {
             const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
-            sal_uInt16 nColCount = pBoxes->size();
-            for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+            size_t nColCount = pBoxes->size();
+            for (size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol)
             {
                 SwTableBox* pBox = (*pBoxes)[nCurrCol];
                 if( nCurrCol )
@@ -1087,22 +1087,22 @@ void lcl_getAllMergedBoxes( const SwTable& rTable, SwSelBoxes& rBoxes, SwTableBo
     and its overlapped cells to split them into several pieces.
 */
 
-void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt,
+void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, size_t nCnt,
     sal_Bool bSameHeight )
 {
     SwSelBoxes aBoxes;
     lcl_getAllMergedBoxes( rTable, aBoxes, rBox );
-    sal_uInt16 nCount = aBoxes.size();
+    size_t const nCount = aBoxes.size();
     if( nCount < 2 )
         return;
     if( nCnt > nCount )
         nCnt = nCount;
-    sal_uInt16 *pSplitIdx = new sal_uInt16[ nCnt ];
+    size_t *const pSplitIdx = new size_t[ nCnt ];
     if( bSameHeight )
     {
         SwTwips *pHeights = new SwTwips[ nCount ];
         SwTwips nHeight = 0;
-        for( sal_uInt16 i = 0; i < nCount; ++i )
+        for (size_t i = 0; i < nCount; ++i)
         {
             SwTableLine* pLine = aBoxes[ i ]->GetUpper();
             SwFrmFmt *pRowFmt = pLine->GetFrmFmt();
@@ -1110,8 +1110,8 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt,
             nHeight += pHeights[ i ];
         }
         SwTwips nSumH = 0;
-        sal_uInt16 nIdx = 0;
-        for( sal_uInt16 i = 1; i <= nCnt; ++i )
+        size_t nIdx = 0;
+        for (size_t i = 1; i <= nCnt; ++i)
         {
             SwTwips nSplit = ( i * nHeight ) / nCnt;
             while( nSumH < nSplit && nIdx < nCount )
@@ -1122,13 +1122,15 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt,
     }
     else
     {
-        for( long i = 1; i <= nCnt; ++i )
-            pSplitIdx[ i - 1 ] = (sal_uInt16)( ( i * nCount ) / nCnt );
+        for (size_t i = 1; i <= nCnt; ++i)
+        {
+            pSplitIdx[ i - 1 ] = ( i * nCount ) / nCnt;
+        }
     }
-    sal_uInt16 nIdx = 0;
-    for( long i = 0; i < nCnt; ++i )
+    size_t nIdx = 0;
+    for (size_t i = 0; i < nCnt; ++i)
     {
-        sal_uInt16 nNextIdx = pSplitIdx[ i ];
+        size_t nNextIdx = pSplitIdx[ i ];
         aBoxes[ nIdx ]->setRowSpan( nNextIdx - nIdx );
         lcl_InvalidateCellFrm( *aBoxes[ nIdx ] );
         while( ++nIdx < nNextIdx )
@@ -1206,7 +1208,7 @@ void lcl_SophisticatedFillLineIndices( SwLineOffsetArray &rArr,
 {
     std::list< SwLineOffset > aBoxes;
     SwLineOffset aLnOfs( USHRT_MAX, USHRT_MAX );
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {   // Collect all end line indices and the row spans
         const SwTableBox &rBox = rBoxes[ i ]->FindStartOfRowSpan( rTable );
         OSL_ENSURE( rBox.getRowSpan() > 0, "Didn't I say 'StartOfRowSpan' ??" );
@@ -1305,7 +1307,7 @@ sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLines &rNe
     SwLineOffset aLnOfs( USHRT_MAX, USHRT_MAX );
     sal_uInt16 nFirst = USHRT_MAX; // becomes the index of the first line
     sal_uInt16 nLast = 0; // becomes the index of the last line of the splitting
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {   // Collect all pairs (start+end) of line indices to split
         const SwTableBox &rBox = rBoxes[ i ]->FindStartOfRowSpan( rTable );
         OSL_ENSURE( rBox.getRowSpan() > 0, "Didn't I say 'StartOfRowSpan' ??" );
@@ -1362,7 +1364,7 @@ sal_uInt16 lcl_LineIndex( const SwTable& rTable, const SwSelBoxes& rBoxes,
 {
     sal_uInt16 nDirect = USHRT_MAX;
     sal_uInt16 nSpan = USHRT_MAX;
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {
         SwTableBox *pBox = rBoxes[i];
         const SwTableLine* pLine = rBoxes[i]->GetUpper();
@@ -1458,15 +1460,15 @@ sal_Bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16
         }
     }
 
-    std::set< sal_uInt16> aIndices;
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    std::set<size_t> aIndices;
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {
         OSL_ENSURE( rBoxes[i]->getRowSpan() != 1, "Forgot to split?" );
         if( rBoxes[i]->getRowSpan() > 1 )
             aIndices.insert( i );
     }
 
-    std::set< sal_uInt16 >::iterator pCurrBox = aIndices.begin();
+    std::set<size_t>::iterator pCurrBox = aIndices.begin();
     while( pCurrBox != aIndices.end() )
         lcl_UnMerge( *this, *rBoxes[*pCurrBox++], nCnt, bSameHeight );
 
@@ -1547,7 +1549,7 @@ void SwTable::PrepareDelBoxes( const SwSelBoxes& rBoxes )
 {
     if( IsNewModel() )
     {
-        for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+        for (size_t i = 0; i < rBoxes.size(); ++i)
         {
             SwTableBox* pBox = rBoxes[i];
             long nRowSpan = pBox->getRowSpan();
@@ -1627,7 +1629,7 @@ void lcl_SearchSelBox( const SwTable &rTable, SwSelBoxes& rBoxes, long nMin, lon
                 ( !bChkProtected ||
                 !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) )
             {
-                sal_uInt16 nOldCnt = rBoxes.size();
+                size_t const nOldCnt = rBoxes.size();
                 rBoxes.insert( pBox );
                 if( bColumn && nRowSpan != 1 && nOldCnt < rBoxes.size() )
                 {
@@ -1802,8 +1804,8 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax
         return;
 
     sal_uInt16 nLineCnt = aLines.size();
-    sal_uInt16 nBoxCnt = rBoxes.size();
-    sal_uInt16 nBox = 0;
+    size_t const nBoxCnt = rBoxes.size();
+    size_t nBox = 0;
     for( sal_uInt16 nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow )
     {
         SwTableLine* pLine = aLines[nRow];
@@ -1821,7 +1823,6 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax
             }
         }
     }
-    nBox = 0;
     for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow )
     {
         SwTableLine* pLine = aLines[nRow];
@@ -1896,7 +1897,7 @@ void SwTable::PrepareDeleteCol( long nMin, long nMax )
 
 void SwTable::ExpandSelection( SwSelBoxes& rBoxes ) const
 {
-    for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
+    for (size_t i = 0; i < rBoxes.size(); ++i)
     {
         SwTableBox *pBox = rBoxes[i];
         long nRowSpan = pBox->getRowSpan();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index bd6c6cd..ef83b55 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1523,11 +1523,13 @@ SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction,
 
 void SwUndoTblNdsChg::ReNewBoxes( const SwSelBoxes& rBoxes )
 {
-    if( rBoxes.size() != aBoxes.size() )
+    if (rBoxes.size() != m_Boxes.size())
     {
-        aBoxes.clear();
-        for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
-            aBoxes.insert( rBoxes[n]->GetSttIdx() );
+        m_Boxes.clear();
+        for (size_t n = 0; n < rBoxes.size(); ++n)
+        {
+            m_Boxes.insert( rBoxes[n]->GetSttIdx() );
+        }
     }
 }
 
@@ -1622,7 +1624,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
             const SwTableLine* pBoxLine = pBox->GetUpper();
             sal_uInt16 nLineDiff = lcl_FindParentLines(rTbl,*pBox).GetPos(pBoxLine);
             sal_uInt16 nLineNo = 0;
-            for( sal_uInt16 j = 0; j < rBoxes.size(); ++j )
+            for (size_t j = 0; j < rBoxes.size(); ++j)
             {
                 pCheckBox = rBoxes[j];
                 if( pCheckBox->GetUpper()->GetUpper() == pBox->GetUpper()->GetUpper() )
@@ -1644,7 +1646,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
             OSL_ENSURE( pSourceBox, "Splitted source box not found!" );
             // find out how many nodes the source box used to have
             // (to help determine bNodesMoved flag below)
-            sal_uInt16 nNdsPos = 0;
+            size_t nNdsPos = 0;
             while( rBoxes[ nNdsPos ] != pSourceBox )
                 ++nNdsPos;
             sal_uLong nNodes = rNodeCnts[ nNdsPos ];
@@ -1814,7 +1816,8 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
     CHECK_TABLE( pTblNd->GetTable() )
 
     SwSelBoxes aSelBoxes;
-    for( std::set<sal_uLong>::iterator it = aBoxes.begin(); it != aBoxes.end(); ++it )
+    for (std::set<sal_uLong>::iterator it = m_Boxes.begin();
+            it != m_Boxes.end(); ++it)
     {
         SwTableBox* pBox = pTblNd->GetTable().GetTblBox( *it );
         aSelBoxes.insert( pBox );
@@ -1961,7 +1964,7 @@ CHECKTABLE(pTblNd->GetTable())
     sal_uInt16 n;
 
     std::set<sal_uLong>::iterator it;
-    for( it = aBoxes.begin(); it != aBoxes.end(); ++it )
+    for (it = m_Boxes.begin(); it != m_Boxes.end(); ++it)
     {
         aIdx = *it;
         SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection( aIdx,
@@ -2104,8 +2107,10 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r
 void SwUndoTblMerge::SetSelBoxes( const SwSelBoxes& rBoxes )
 {
     // memorize selection
-    for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
-        aBoxes.insert( rBoxes[n]->GetSttIdx() );
+    for (size_t n = 0; n < rBoxes.size(); ++n)
+    {
+        m_Boxes.insert(rBoxes[n]->GetSttIdx());
+    }
 
     // as separator for inserts of new boxes after shifting
     aNewSttNds.push_back( (sal_uLong)0 );
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 3602a4b..ec52188 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1684,7 +1684,7 @@ void SwChartDataProvider::AddRowCols(
     if (rTable.IsTblComplex())
         return;
 
-    const sal_uInt16 nBoxes = rBoxes.size();
+    const size_t nBoxes = rBoxes.size();
     if (nBoxes < 1 || nLines < 1)
         return;
 
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 64eba7a..b3163b9 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1517,10 +1517,12 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor*
         pUnoCrsr->SetMark();
         *pUnoCrsr->GetMark() = *pTableSelection->GetMark();
     }
-    const SwSelBoxes& rBoxes = pTableSelection->GetBoxes();
+    const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
     SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr);
-    for(sal_uInt16 i = 0; i < rBoxes.size(); i++)
+    for (size_t i = 0; i < rBoxes.size(); i++)
+    {
         pTableCrsr->InsertBox( *rBoxes[i] );
+    }
 
     pUnoCrsr->Add(&aCrsrDepend);
     SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
@@ -1689,9 +1691,11 @@ sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException )
             bRet = TBLMERGE_OK == pTblCrsr->GetDoc()->MergeTbl(*pTblCrsr);
             if(bRet)
             {
-                sal_uInt16 nCount = pTblCrsr->GetBoxesCount();
-                while(nCount--)
+                size_t nCount = pTblCrsr->GetSelectedBoxesCount();
+                while (--nCount)
+                {
                     pTblCrsr->DeleteBox(nCount);
+                }
             }
         }
         pTblCrsr->MakeBoxSels();
@@ -1716,7 +1720,8 @@ sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) th
         pTblCrsr->MakeBoxSels();
         {
             UnoActionContext aContext(pUnoCrsr->GetDoc());
-            bRet = pTblCrsr->GetDoc()->SplitTbl( pTblCrsr->GetBoxes(), !Horizontal, Count );
+            bRet = pTblCrsr->GetDoc()->SplitTbl(
+                    pTblCrsr->GetSelectedBoxes(), !Horizontal, Count);
         }
         pTblCrsr->MakeBoxSels();
     }
@@ -4595,7 +4600,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
         SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
         pTableCrsr->MakeBoxSels();
         UnoActionContext aContext( pFmt->GetDoc() );
-        pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), aSortOpt);
+        pFmt->GetDoc()->SortTbl(pTableCrsr->GetSelectedBoxes(), aSortOpt);
     }
 }
 
commit 5b89b1dd909f76154266cd51558e97152cff5f64
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 21 15:07:10 2012 +0200

    o3tl::sorted_vector::insert should take const parameter
    
    Change-Id: I139f9d008770da94341b8e6c08c9247478aa186a

diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index 90aacbf..d8bceb7 100644
--- a/o3tl/inc/o3tl/sorted_vector.hxx
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -134,14 +134,13 @@ public:
         return (ret.second) ? ret.first : end();
     }
 
-    void insert( sorted_vector<Value,Compare,Find> &rOther )
+    void insert(sorted_vector<Value,Compare,Find> const& rOther)
     {
        // optimisation for the rather common case that we are overwriting this with the contents
        // of another sorted vector
        if ( empty() )
        {
-           base_t::insert( begin_nonconst(),
-                   rOther.begin_nonconst(), rOther.end_nonconst() );
+           base_t::insert(begin_nonconst(), rOther.begin(), rOther.end());
        }
        else
            for( const_iterator it = rOther.begin(); it != rOther.end(); ++it )
commit 5f91f8a368343d8921a01edb7359cd300892f09d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 20 23:59:14 2012 +0200

    fdo#48692: fix problems with large number of table cells:
    
    The SwTableSortBoxes is now a STL container which can have more than
    2^16 elements but unfortunately there are a lot of 16 bit integers used
    to index it all over the place, causing infinite loops and possibly
    worse problems; fix that to use size_t.
    
    Change-Id: I868ec9dd0629be4fbe4d6b8f294fb765e3d662ec

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 0a887c6..709fce4 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -106,13 +106,13 @@ class SW_DLLPUBLIC SwTable: public SwClient          //Client of FrmFmt.
 
 protected:
     SwTableLines aLines;
-    SwTableSortBoxes aSortCntBoxes;
+    SwTableSortBoxes m_TabSortContentBoxes;
     SwServerObjectRef refObj;   // In case DataServer -> pointer is set.
 
     SwHTMLTableLayout *pHTMLLayout;
 
     // Usually, the table node of a SwTable can be accessed by getting a box
-    // out of aSortCntBoxes, which know their SwStartNode. But in some rare
+    // out of m_TabSortContentBoxes, which know their SwStartNode. But in some rare
     // cases, we need to know the table node of a SwTable, before the table
     // boxes have been build (SwTableNode::MakeCopy with tables in tables).
     SwTableNode* pTableNode;
@@ -263,8 +263,8 @@ public:
         { _FindSuperfluousRows( rBoxes, 0, 0 ); }
     void CheckRowSpan( SwTableLine* &rpLine, bool bUp ) const;
 
-          SwTableSortBoxes& GetTabSortBoxes()       { return aSortCntBoxes; }
-    const SwTableSortBoxes& GetTabSortBoxes() const { return aSortCntBoxes; }
+          SwTableSortBoxes& GetTabSortBoxes()       { return m_TabSortContentBoxes; }
+    const SwTableSortBoxes& GetTabSortBoxes() const { return m_TabSortContentBoxes; }
 
     // Read 1st number and delete it from string (used by GetTblBox and SwTblFld).
 
@@ -321,7 +321,7 @@ public:
     // Clean up structure a bit.
     void GCLines();
 
-    // Returns the table node via aSortCntBoxes or pTableNode.
+    // Returns the table node via m_TabSortContentBoxes or pTableNode.
     SwTableNode* GetTableNode() const;
     void SetTableNode( SwTableNode* pNode ) { pTableNode = pNode; }
 
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 3191c0c..7c7f166 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -97,7 +97,8 @@ class SwXCell : public SwXCellBaseClass,
     const SwStartNode*      pStartNode; // only set in XML import
 
     // table position where pBox was found last
-    sal_uInt16              nFndPos;
+    size_t nFndPos;
+    static size_t const NOTFOUND = ::std::numeric_limits<size_t>::max();
 
 protected:
     virtual const SwStartNode *GetStartNode() const;
@@ -115,7 +116,7 @@ protected:
    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
 
 public:
-    SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, sal_uInt16 nPos=USHRT_MAX );
+    SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, size_t nPos = NOTFOUND);
     SwXCell(SwFrmFmt* pTblFmt, const SwStartNode& rStartNode); // XML import interface
 
 
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index c043f7b..ef8857f 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -708,7 +708,8 @@ void _FndBoxAppendRowLine( SwTableLine* pLine, _FndPara* pFndPara )
 
 sal_Bool SwTable::AppendRow( SwDoc* pDoc, sal_uInt16 nCnt )
 {
-    SwTableNode* pTblNd = (SwTableNode*)aSortCntBoxes[0]->GetSttNd()->FindTableNode();
+    SwTableNode *const pTblNd = const_cast<SwTableNode*>(
+        m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode());
     if( !pTblNd )
         return sal_False;
 
@@ -3663,8 +3664,8 @@ sal_Bool SwTable::SetColWidth( SwTableBox& rAktBox, sal_uInt16 eType,
                 {
                     pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo,
                                                     aTmpLst, nDistStt );
-                    if( aParam.bBigger && aParam.aBoxes.size() ==
-                                    aSortCntBoxes.size() )
+                    if (aParam.bBigger &&
+                        aParam.aBoxes.size() == m_TabSortContentBoxes.size())
                     {
                         // This whole Table is to be deleted!
                         GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes );
@@ -4366,7 +4367,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType,
 
                         // delete complete table when last row is deleted
                         if( !bBigger &&
-                            aParam.aBoxes.size() == aSortCntBoxes.size() )
+                            aParam.aBoxes.size() == m_TabSortContentBoxes.size())
                         {
                             GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes );
                             return sal_False;
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index c15e6fc..d8b448e 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -473,7 +473,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
     // does not seem to be used, because the table does not have any contents yet
     // (see IsUsed). Therefore the inner table gets the same name as the outer table.
     // We have to make sure that the table node of the SwTable is accessible, even
-    // without any content in aSortCntBoxes. #i26629#
+    // without any content in m_TabSortContentBoxes. #i26629#
     pTblNd->GetTable().SetTableNode( pTblNd );
     rNds._Copy( aRg, aInsPos, sal_False );
     pTblNd->GetTable().SetTableNode( 0 );
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 81d495a..2197ca6 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -121,7 +121,7 @@ bool lcl_IsInSameTblBox( SwNodes& _rNds,
     // dann suche den StartNode der Box
     const SwTableSortBoxes& rSortBoxes = pTblNd->GetTable().GetTabSortBoxes();
     sal_uLong nIdx = _rNd.GetIndex();
-    for( sal_uInt16 n = 0; n < rSortBoxes.size(); ++n )
+    for (size_t n = 0; n < rSortBoxes.size(); ++n)
     {
         const SwStartNode* pNd = rSortBoxes[ n ]->GetSttNd();
         if ( pNd->GetIndex() < nIdx && nIdx < pNd->EndOfSectionIndex() )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 944e920..f334b7b 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -862,8 +862,10 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
     // JP 03.04.97: Inhalt der Boxen auf Zahlen abpruefen
     if( IsInsTblFormatNum() )
     {
-        for( sal_uInt16 nBoxes = pNdTbl->GetTabSortBoxes().size(); nBoxes; )
+        for (size_t nBoxes = pNdTbl->GetTabSortBoxes().size(); nBoxes; )
+        {
             ChkBoxNumFmt( *pNdTbl->GetTabSortBoxes()[ --nBoxes ], sal_False );
+        }
     }
 
     sal_uLong nIdx = pTblNd->GetIndex();
@@ -4420,7 +4422,7 @@ sal_Bool SwDoc::_UnProtectTblCells( SwTable& rTbl )
         :   0;
 
     SwTableSortBoxes& rSrtBox = rTbl.GetTabSortBoxes();
-    for( sal_uInt16 i = rSrtBox.size(); i; )
+    for (size_t i = rSrtBox.size(); i; )
     {
         SwFrmFmt *pBoxFmt = rSrtBox[ --i ]->GetFrmFmt();
         if( pBoxFmt->GetProtect().IsCntntProtected() )
@@ -4561,7 +4563,7 @@ sal_Bool SwDoc::HasTblAnyProtection( const SwPosition* pPos,
     if( pTbl )
     {
         SwTableSortBoxes& rSrtBox = pTbl->GetTabSortBoxes();
-        for( sal_uInt16 i = rSrtBox.size(); i; )
+        for (size_t i = rSrtBox.size(); i; )
         {
             SwFrmFmt *pBoxFmt = rSrtBox[ --i ]->GetFrmFmt();
             if( pBoxFmt->GetProtect().IsCntntProtected() )
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 54f1642..73c30ea 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -49,7 +49,7 @@ SwDDETable::SwDDETable( SwTable& rTable, SwDDEFieldType* pDDEType,
     : SwTable( rTable ), aDepend( this, pDDEType )
 {
     // Kopiere/move die Daten der Tabelle
-    aSortCntBoxes.insert( rTable.GetTabSortBoxes()  ); // move die Inh. Boxen
+    m_TabSortContentBoxes.insert(rTable.GetTabSortBoxes());
     rTable.GetTabSortBoxes().clear();
 
     aLines.insert( aLines.begin(),
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 8e04d6e..5e5b137 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1276,7 +1276,7 @@ sal_Bool SwFEShell::SetTableAutoFmt( const SwTableAutoFmt& rNew )
     else
     {
         const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes();
-        for( sal_uInt16 n = 0; n < rTBoxes.size(); ++n )
+        for (size_t n = 0; n < rTBoxes.size(); ++n)
         {
             SwTableBox* pBox = rTBoxes[ n ];
             aBoxes.insert( pBox );
@@ -1315,7 +1315,7 @@ sal_Bool SwFEShell::GetTableAutoFmt( SwTableAutoFmt& rGet )
     else
     {
         const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes();
-        for( sal_uInt16 n = 0; n < rTBoxes.size(); ++n )
+        for (size_t n = 0; n < rTBoxes.size(); ++n)
         {
             SwTableBox* pBox = rTBoxes[ n ];
             aBoxes.insert( pBox );
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 5784ada..5310ae2 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -281,8 +281,10 @@ SwTable::SwTable( const SwTable& rTable )
 
 void DelBoxNode( SwTableSortBoxes& rSortCntBoxes )
 {
-    for( sal_uInt16 n = 0; n < rSortCntBoxes.size(); ++n )
+    for (size_t n = 0; n < rSortCntBoxes.size(); ++n)
+    {
         rSortCntBoxes[ n ]->pSttNd = 0;
+    }
 }
 
 SwTable::~SwTable()
@@ -307,8 +309,8 @@ SwTable::~SwTable()
     // are preserved and are deleted by the lines/boxes arrays dtor.
     // Note: unfortunately not enough, pointers to the StartNode of the
     // section need deletion.
-    DelBoxNode( aSortCntBoxes );
-    aSortCntBoxes.clear();
+    DelBoxNode(m_TabSortContentBoxes);
+    m_TabSortContentBoxes.clear();
     delete pHTMLLayout;
 }
 
@@ -1502,9 +1504,13 @@ SwTableBox* SwTable::GetTblBox( sal_uLong nSttIdx )
     // In case the layout doesn't exist yet or anything else goes wrong.
     if ( !pRet )
     {
-        for( sal_uInt16 n = aSortCntBoxes.size(); n; )
-            if( aSortCntBoxes[ --n ]->GetSttIdx() == nSttIdx )
-                return aSortCntBoxes[ n ];
+        for (size_t n = m_TabSortContentBoxes.size(); n; )
+        {
+            if (m_TabSortContentBoxes[ --n ]->GetSttIdx() == nSttIdx)
+            {
+                return m_TabSortContentBoxes[ n ];
+            }
+        }
     }
     return pRet;
 }
@@ -1514,9 +1520,13 @@ sal_Bool SwTable::IsTblComplex() const
     // Returns sal_True for complex tables, i.e. tables that contain nestings,
     // like containing boxes not part of the first line, e.g. results of
     // splits/merges which lead to more complex structures.
-    for( sal_uInt16 n = 0; n < aSortCntBoxes.size(); ++n )
-        if( aSortCntBoxes[ n ]->GetUpper()->GetUpper() )
+    for (size_t n = 0; n < m_TabSortContentBoxes.size(); ++n)
+    {
+        if (m_TabSortContentBoxes[ n ]->GetUpper()->GetUpper())
+        {
             return sal_True;
+        }
+    }
     return sal_False;
 }
 
@@ -1950,9 +1960,9 @@ sal_Bool SwTable::GetInfo( SfxPoolItem& rInfo ) const
         const SwTableNode* pTblNode = GetTableNode();
         if( pTblNode && &pTblNode->GetNodes() == ((SwAutoFmtGetDocNode&)rInfo).pNodes )
         {
-            if ( !aSortCntBoxes.empty() )
+            if (!m_TabSortContentBoxes.empty())
             {
-                  SwNodeIndex aIdx( *aSortCntBoxes[ 0 ]->GetSttNd() );
+                SwNodeIndex aIdx( *m_TabSortContentBoxes[0]->GetSttNd() );
                 ((SwAutoFmtGetDocNode&)rInfo).pCntntNode =
                                 GetFrmFmt()->GetDoc()->GetNodes().GoNext( &aIdx );
             }
@@ -1963,10 +1973,10 @@ sal_Bool SwTable::GetInfo( SfxPoolItem& rInfo ) const
     case RES_FINDNEARESTNODE:
         if( GetFrmFmt() && ((SwFmtPageDesc&)GetFrmFmt()->GetFmtAttr(
             RES_PAGEDESC )).GetPageDesc() &&
-            !aSortCntBoxes.empty() &&
-            aSortCntBoxes[ 0 ]->GetSttNd()->GetNodes().IsDocNodes() )
-            ((SwFindNearestNode&)rInfo).CheckNode( *
-                aSortCntBoxes[ 0 ]->GetSttNd()->FindTableNode() );
+            !m_TabSortContentBoxes.empty() &&
+            m_TabSortContentBoxes[0]->GetSttNd()->GetNodes().IsDocNodes() )
+            static_cast<SwFindNearestNode&>(rInfo).CheckNode( *
+                m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode() );
         break;
 
     case RES_CONTENT_VISIBLE:
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index e5e4f0b..bd6c6cd 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -493,8 +493,10 @@ void SwUndoTblToTxt::UndoImpl(::sw::UndoRedoContext & rContext)
     if( bCheckNumFmt )
     {
         SwTableSortBoxes& rBxs = pTblNd->GetTable().GetTabSortBoxes();
-        for( sal_uInt16 nBoxes = rBxs.size(); nBoxes; )
+        for (size_t nBoxes = rBxs.size(); nBoxes; )
+        {
             rDoc.ChkBoxNumFmt( *rBxs[ --nBoxes ], sal_False );
+        }
     }
 
     if( pHistory )
@@ -1539,13 +1541,12 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
 {
     const SwTable& rTbl = rTblNd.GetTable();
     const SwTableSortBoxes& rTblBoxes = rTbl.GetTabSortBoxes();
-    sal_uInt16 n;
-    sal_uInt16 i;
 
     OSL_ENSURE( ! IsDelBox(), "wrong Action" );
     pNewSttNds.reset( new std::set<_BoxMove> );
 
-    for( n = 0, i = 0; n < rOld.size(); ++i )
+    size_t i = 0;
+    for (size_t  n = 0; n < rOld.size(); ++i)
     {
         if( rOld[ n ] == rTblBoxes[ i ] )
             ++n;
@@ -1599,7 +1600,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
     OSL_ENSURE( rTbl.IsNewModel() || rOld.size() + nCount * rBoxes.size() == rTblBoxes.size(),
         "unexpected boxes" );
     OSL_ENSURE( rOld.size() <= rTblBoxes.size(), "more unexpected boxes" );
-    for( sal_uInt16 n = 0, i = 0; i < rTblBoxes.size(); ++i )
+    for (size_t n = 0, i = 0; i < rTblBoxes.size(); ++i)
     {
         if( ( n < rOld.size() ) &&
             ( rOld[ n ] == rTblBoxes[ i ] ) )
@@ -1726,8 +1727,9 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
         std::vector<_BoxMove> aTmp( pNewSttNds->begin(), pNewSttNds->end() );
 
         // backwards
-        for( int n = aTmp.size() - 1; n >= 0 ; --n)
+        for (size_t n = aTmp.size(); n > 0 ; )
         {
+            --n;
             // delete box from table structure
             sal_uLong nIdx = aTmp[n].index;
             SwTableBox* pBox = pTblNd->GetTable().GetTblBox( nIdx );
@@ -1746,7 +1748,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
                 SwNodeIndex aInsPos( *(pLine->GetTabBoxes()[0]->GetSttNd()), 2 );
 
                 // adjust all StartNode indices
-                sal_uInt16 i = n;
+                size_t i = n;
                 sal_uLong nSttIdx = aInsPos.GetIndex() - 2,
                        nNdCnt = aRg.aEnd.GetIndex() - aRg.aStart.GetIndex();
                 while( i && aTmp[ --i ].index > nSttIdx )
@@ -3108,7 +3110,7 @@ void CheckTable( const SwTable& rTbl )
 {
     const SwNodes& rNds = rTbl.GetFrmFmt()->GetDoc()->GetNodes();
     const SwTableSortBoxes& rSrtArr = rTbl.GetTabSortBoxes();
-    for( sal_uInt16 n = 0; n < rSrtArr.size(); ++n )
+    for (size_t n = 0; n < rSrtArr.size(); ++n)
     {
         const SwTableBox* pBox = rSrtArr[ n ];
         const SwNode* pNd = pBox->GetSttNd();
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 7b9dc1b..64eba7a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -740,7 +740,7 @@ void lcl_setValue( SwXCell &rCell, double nVal )
  ******************************************************************/
 TYPEINIT1(SwXCell, SwClient);
 
-SwXCell::SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBx, sal_uInt16 nPos ) :
+SwXCell::SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBx, size_t const nPos) :
     SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
     SwClient(pTblFmt),
     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
@@ -756,7 +756,7 @@ SwXCell::SwXCell(SwFrmFmt* pTblFmt, const SwStartNode& rStartNode) :
     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
     pBox(0),
     pStartNode(&rStartNode),
-    nFndPos(USHRT_MAX)
+    nFndPos(NOTFOUND)
 {
 }
 
@@ -1214,7 +1214,7 @@ SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTab
         //wenn es die Box gibt, dann wird auch eine Zelle zurueckgegeben
         if( it != pTable->GetTabSortBoxes().end() )
         {
-            sal_uInt16 nPos = it - pTable->GetTabSortBoxes().begin();
+            size_t const nPos = it - pTable->GetTabSortBoxes().begin();
             SwIterator<SwXCell,SwFmt> aIter( *pTblFmt );
             SwXCell* pXCell = aIter.First();
             while( pXCell )
@@ -1226,7 +1226,9 @@ SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTab
             }
             //sonst anlegen
             if(!pXCell)
-                pXCell = new SwXCell(pTblFmt, pBox, nPos );
+            {
+                pXCell = new SwXCell(pTblFmt, pBox, nPos);
+            }
             pRet = pXCell;
         }
     }
@@ -1250,7 +1252,7 @@ SwTableBox* SwXCell::FindBox(SwTable* pTable, SwTableBox* pBox2)
     }
 
     // box not found: reset nFndPos pointer
-    nFndPos = USHRT_MAX;
+    nFndPos = NOTFOUND;
     return 0;
 }
 
@@ -2931,7 +2933,7 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor
         SwTable* pTable = SwTable::FindTable( pFmt );
         SwSelBoxes aBoxes;
         const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
-        for( sal_uInt16 n = 0; n < rTBoxes.size(); ++n )
+        for (size_t n = 0; n < rTBoxes.size(); ++n)
         {
             SwTableBox* pBox = rTBoxes[ n ];
             aBoxes.insert( pBox );
@@ -2959,7 +2961,7 @@ void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumen
                 {
                     SwSelBoxes aBoxes;
                     const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
-                    for( sal_uInt16 n = 0; n < rTBoxes.size(); ++n )
+                    for (size_t n = 0; n < rTBoxes.size(); ++n)
                     {
                         SwTableBox* pBox = rTBoxes[ n ];
                         aBoxes.insert( pBox );
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index d7e117d..ae4e4fe 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -5463,7 +5463,8 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust,
             bUpperSpace = sal_True;
             SetTxtCollAttrs();
 
-            nParaCnt = nParaCnt - Min(nParaCnt, (sal_uInt16)pTCntxt->GetTableNode()->GetTable().GetTabSortBoxes().size());
+            nParaCnt = nParaCnt - std::min(nParaCnt,
+                pTCntxt->GetTableNode()->GetTable().GetTabSortBoxes().size());
 
             // ggfs. eine Tabelle anspringen
             if( JUMPTO_TABLE == eJumpTo && pTable->GetSwTable() &&
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index efdd279..c9289ef 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -422,7 +422,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     sal_uInt16  nFontStHeadStart;   // Elemente im Font-Stack bei <Hn>
     sal_uInt16  nSBModuleCnt;       // Zaehler fuer Basic-Module
     sal_uInt16  nMissingImgMaps;    // Wie viele Image-Maps fehlen noch?
-    sal_uInt16  nParaCnt;
+    size_t nParaCnt;
     sal_uInt16  nContextStMin;      // Untergrenze fuer PopContext
     sal_uInt16  nContextStAttrMin;  // Untergrenze fuer Attributierung
     sal_uInt16  nSelectEntryCnt;    // Anzahl der Eintraege der akt. Listbox


More information about the Libreoffice-commits mailing list