Hi,
I replaced some usages of SvUShorts with std::vectors.
License is LGPLv3+/MPL
Cheers,
Daniel
From b15d4e4363f567c4c0a42c9fb830745b2625ca44 Mon Sep 17 00:00:00 2001
From: Daniel Di Marco <d.dimarco@gmx.de>
Date: Mon, 19 Sep 2011 23:18:28 +0000
Subject: [PATCH] replaced some SvUShorts with std::vector
---
sw/source/core/crsr/findtxt.cxx | 9 ++-----
sw/source/core/crsr/viscrs.cxx | 11 ++-------
sw/source/core/doc/tblrwcl.cxx | 6 ++--
sw/source/core/docnode/ndtbl.cxx | 43 ++++++++++++++++++-------------------
sw/source/core/inc/tblrwcl.hxx | 10 ++------
sw/source/core/txtnode/ndtxt.cxx | 15 +++++++------
sw/source/ui/app/docstyle.cxx | 20 ++++++++---------
7 files changed, 50 insertions(+), 64 deletions(-)
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 3add534..9a86bac 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -32,9 +32,6 @@
#include <com/sun/star/util/SearchOptions.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
-#define _SVSTDARR_USHORTS
-#include <svl/svstdarr.hxx>
-
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
@@ -76,7 +73,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart,
bool bNewHint = true;
bool bNewSoftHyphen = true;
const xub_StrLen nEnd = rEnde;
- SvUShorts aReplaced;
+ std::vector<sal_uInt16> aReplaced;
do
{
@@ -155,7 +152,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart,
else
{
if ( bEmpty )
- aReplaced.Insert( nAkt, aReplaced.Count() );
+ aReplaced.push_back( nAkt );
rRet.SetChar( nAkt, '\x7f' );
}
}
@@ -178,7 +175,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart,
}
while ( true );
- for( sal_uInt16 i = aReplaced.Count(); i; )
+ for( sal_uInt16 i = aReplaced.size(); i; )
{
const xub_StrLen nTmp = aReplaced[ --i ];
if( nTmp == rRet.Len() - 1 )
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 3ec97b2..9ec4b0a 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -30,11 +30,6 @@
#include "precompiled_sw.hxx"
-#ifndef _SVSTDARR_HXX
-#define _SVSTDARR_USHORTS
-#include <svl/svstdarr.hxx>
-#endif
-
#include <vcl/dialog.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/wrkwin.hxx>
@@ -560,21 +555,21 @@ short SwShellCrsr::MaxReplaceArived()
{
// Terminate old actions. The table-frames get constructed and
// a SSelection can be created.
- SvUShorts aArr;
+ std::vector<sal_uInt16> aArr;
sal_uInt16 nActCnt;
ViewShell *pShell = const_cast< SwCrsrShell* >( GetShell() ),
*pSh = pShell;
do {
for( nActCnt = 0; pSh->ActionPend(); ++nActCnt )
pSh->EndAction();
- aArr.Insert( nActCnt, aArr.Count() );
+ aArr.push_back( nActCnt );
} while( pShell != ( pSh = (ViewShell*)pSh->GetNext() ) );
{
nRet = QueryBox( pDlg, SW_RES( MSG_COMCORE_ASKSEARCH )).Execute();
}
- for( sal_uInt16 n = 0; n < aArr.Count(); ++n )
+ for( sal_uInt16 n = 0; n < aArr.size(); ++n )
{
for( nActCnt = aArr[n]; nActCnt--; )
pSh->StartAction();
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 82fa926..49c5ddf 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -111,7 +111,7 @@ struct CR_SetBoxWidth
{
SwSelBoxes aBoxes;
SwSortTableLines aLines;
- SvUShorts aLinesWidth;
+ std::vector<sal_uInt16> aLinesWidth;
SwShareBoxFmts aShareFmts;
SwTableNode* pTblNd;
SwUndoTblNdsChg* pUndo;
@@ -143,7 +143,7 @@ struct CR_SetBoxWidth
bSplittBox( rCpy.bSplittBox ), bAnyBoxFnd( rCpy.bAnyBoxFnd )
{
aLines.Insert( &rCpy.aLines );
- aLinesWidth.Insert( &rCpy.aLinesWidth, 0 );
+ aLinesWidth = rCpy.aLinesWidth;
}
SwUndoTblNdsChg* CreateUndo( SwUndoId eUndoType )
@@ -161,7 +161,7 @@ struct CR_SetBoxWidth
SwTableLinePtr p = (SwTableLine*)rBox.GetUpper();
sal_uInt16 nFndPos;
if( aLines.Insert( p, nFndPos ))
- aLinesWidth.Insert( nWidth, nFndPos );
+ aLinesWidth.insert( aLinesWidth.begin()+nFndPos, nWidth );
else
aLinesWidth[ nFndPos ] = aLinesWidth[ nFndPos ] + nWidth;
}
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index ad98a53..eceaaa9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -898,7 +898,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
new SwEndNode( rRange.aEnd, *pTblNd );
SwDoc* pDoc = GetDoc();
- SvUShorts aPosArr( 0, 16 );
+ std::vector<sal_uInt16> aPosArr;
SwTable * pTable = &pTblNd->GetTable();
SwTableLine* pLine;
SwTableBox* pBox;
@@ -927,17 +927,16 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
{
if( *pTxt == cCh )
{
- aPosArr.Insert( static_cast<sal_uInt16>(
- aFInfo.GetCharPos( nChPos+1, sal_False )),
- aPosArr.Count() );
+ aPosArr.push_back( static_cast<sal_uInt16>(
+ aFInfo.GetCharPos( nChPos+1, sal_False )) );
}
}
- aPosArr.Insert(
+ aPosArr.push_back(
static_cast<sal_uInt16>(aFInfo.GetFrm()->IsVertical() ?
aFInfo.GetFrm()->Prt().Bottom() :
- aFInfo.GetFrm()->Prt().Right()),
- aPosArr.Count() );
+ aFInfo.GetFrm()->Prt().Right()) );
+
}
}
@@ -1046,15 +1045,15 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode
cCh,
// fehlen der 1. Line Boxen, dann kann man das Breiten Array
// vergessen!
if( !n )
- aPosArr.Remove( 0, aPosArr.Count() );
+ aPosArr.clear();
}
}
- if( aPosArr.Count() )
+ if( aPosArr.size() )
{
SwTableLines& rLns = pTable->GetTabLines();
sal_uInt16 nLastPos = 0;
- for( n = 0; n < aPosArr.Count(); ++n )
+ for( n = 0; n < aPosArr.size(); ++n )
{
SwTableBoxFmt *pNewFmt = pDoc->MakeTableBoxFmt();
pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
@@ -1283,7 +1282,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes,
#endif
SwDoc* pDoc = GetDoc();
- SvUShorts aPosArr( 0, 16 );
+ std::vector<sal_uInt16> aPosArr;
SwTable * pTable = &pTblNd->GetTable();
SwTableLine* pLine;
SwTableBox* pBox;
@@ -1369,11 +1368,11 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t &
rTableNodes,
// die Tabelle ausgleichen, leere Sections einfuegen
sal_uInt16 n;
- if( aPosArr.Count() )
+ if( aPosArr.size() )
{
SwTableLines& rLns = pTable->GetTabLines();
sal_uInt16 nLastPos = 0;
- for( n = 0; n < aPosArr.Count(); ++n )
+ for( n = 0; n < aPosArr.size(); ++n )
{
SwTableBoxFmt *pNewFmt = pDoc->MakeTableBoxFmt();
pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
@@ -2933,7 +2932,7 @@ void SwCollectTblLineBoxes::AddToUndoHistory( const SwCntntNode& rNd )
void SwCollectTblLineBoxes::AddBox( const SwTableBox& rBox )
{
- aPosArr.Insert( nWidth, aPosArr.Count() );
+ aPosArr.push_back(nWidth);
SwTableBox* p = (SwTableBox*)&rBox;
aBoxes.Insert( p, aBoxes.Count() );
nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth();
@@ -2944,9 +2943,9 @@ const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
const SwTableBox* pRet = 0;
sal_uInt16 n;
- if( aPosArr.Count() )
+ if( aPosArr.size() )
{
- for( n = 0; n < aPosArr.Count(); ++n )
+ for( n = 0; n < aPosArr.size(); ++n )
if( aPosArr[ n ] == nWidth )
break;
else if( aPosArr[ n ] > nWidth )
@@ -2956,7 +2955,7 @@ const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
break;
}
- if( n >= aPosArr.Count() )
+ if( n >= aPosArr.size() )
--n;
nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth();
@@ -2969,9 +2968,9 @@ sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16
nOldWidth
{
sal_uInt16 n;
- if( aPosArr.Count() )
+ if( aPosArr.size() )
{
- for( n = 0; n < aPosArr.Count(); ++n )
+ for( n = 0; n < aPosArr.size(); ++n )
if( aPosArr[ n ] == nOffset )
break;
else if( aPosArr[ n ] > nOffset )
@@ -2981,11 +2980,11 @@ sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16
nOldWidth
break;
}
- aPosArr.Remove( 0, n );
+ aPosArr.clear();
aBoxes.Remove( 0, n );
// dann die Positionen der neuen Size anpassen
- for( n = 0; n < aPosArr.Count(); ++n )
+ for( n = 0; n < aPosArr.size(); ++n )
{
sal_uLong nSize = nWidth;
nSize *= ( aPosArr[ n ] - nOffset );
@@ -2993,7 +2992,7 @@ sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16
nOldWidth
aPosArr[ n ] = sal_uInt16( nSize );
}
}
- return 0 != aPosArr.Count();
+ return 0 != aPosArr.size();
}
sal_Bool lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara )
diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx
index 23866a3..df93e44 100644
--- a/sw/source/core/inc/tblrwcl.hxx
+++ b/sw/source/core/inc/tblrwcl.hxx
@@ -27,10 +27,6 @@
************************************************************************/
#ifndef _TBLRWCL_HXX
#define _TBLRWCL_HXX
-#ifndef _SVSTDARR_HXX
-#define _SVSTDARR_USHORTS
-#include <svl/svstdarr.hxx>
-#endif
#include <vector>
#include <swtypes.hxx>
#include <tblsel.hxx>
@@ -87,7 +83,7 @@ SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0
class SwCollectTblLineBoxes
{
- SvUShorts aPosArr;
+ std::vector<sal_uInt16> aPosArr;
SwSelBoxes_SAR aBoxes;
SwHistory* pHst;
sal_uInt16 nMode, nWidth;
@@ -96,7 +92,7 @@ class SwCollectTblLineBoxes
public:
SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 )
- : aPosArr( 16, 16 ), aBoxes( 16, 16 ),
+ : aBoxes( 16, 16 ),
pHst( pHist ), nMode( nMd ), nWidth( 0 ),
bGetFromTop( bTop ), bGetValues( sal_True )
@@ -111,7 +107,7 @@ public:
{
// hier wird die EndPos der Spalte benoetigt!
if( pWidth )
- *pWidth = nPos+1 == aPosArr.Count() ? nWidth
+ *pWidth = nPos+1 == aPosArr.size() ? nWidth
: aPosArr[ nPos+1 ];
return *aBoxes[ nPos ];
}
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 56ad4f4..a38c2d1 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3135,7 +3135,7 @@ const ModelToViewHelper::ConversionMap*
XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
sal_Bool bExpandFlds, sal_Bool bWithNum ) const
{
- SvUShorts aRedlArr;
+ std::vector<sal_uInt16> aRedlArr;
const SwDoc* pDoc = GetDoc();
sal_uInt16 nRedlPos = pDoc->GetRedlinePos( *this, nsRedlineType_t::REDLINE_DELETE );
if( USHRT_MAX != nRedlPos )
@@ -3156,18 +3156,19 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
else if( pREnd->nNode == nNdIdx )
{
// von 0 bis nContent ist alles geloescht
- aRedlArr.Insert( xub_StrLen(0), aRedlArr.Count() );
- aRedlArr.Insert( pREnd->nContent.GetIndex(), aRedlArr.Count() );
+ aRedlArr.push_back( xub_StrLen(0) );
+ aRedlArr.push_back( pREnd->nContent.GetIndex() );
}
}
else if( pRStt->nNode == nNdIdx )
{
- aRedlArr.Insert( pRStt->nContent.GetIndex(), aRedlArr.Count() );
+ //aRedlArr.Insert( pRStt->nContent.GetIndex(), aRedlArr.Count() );
+ aRedlArr.push_back( pRStt->nContent.GetIndex() );
if( pREnd->nNode == nNdIdx )
- aRedlArr.Insert( pREnd->nContent.GetIndex(), aRedlArr.Count() );
+ aRedlArr.push_back( pREnd->nContent.GetIndex() );
else
{
- aRedlArr.Insert( GetTxt().Len(), aRedlArr.Count() );
+ aRedlArr.push_back( GetTxt().Len() );
break; // mehr kann nicht kommen
}
}
@@ -3180,7 +3181,7 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
XubString aTxt( GetTxt().Copy( nIdx, nLen ) );
xub_StrLen nTxtStt = nIdx, nIdxEnd = nIdx + aTxt.Len();
- for( sal_uInt16 n = 0; n < aRedlArr.Count(); n += 2 )
+ for( sal_uInt16 n = 0; n < aRedlArr.size(); n += 2 )
{
xub_StrLen nStt = aRedlArr[ n ], nEnd = aRedlArr[ n+1 ];
if( ( nIdx <= nStt && nStt <= nIdxEnd ) ||
diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx
index b0f0734..6631e70 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -29,8 +29,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-#define _SVSTDARR_USHORTS
-
#include <svl/smplhint.hxx>
#include <hintids.hxx>
#include <svl/itemiter.hxx>
@@ -1445,30 +1443,30 @@ void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc )
{
case SFX_STYLE_FAMILY_CHAR:
{
- SvUShorts aDelArr;
+ std::vector<sal_uInt16> aDelArr;
const SwCharFmts& rTbl = *rDoc.GetCharFmts();
for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
{
void* p = (void*)rTbl[ n ];
if( USHRT_MAX == rArr.GetPos( p ))
- aDelArr.Insert( n, 0 );
+ aDelArr.insert( aDelArr.begin(), n );
}
- for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelCharFmt( aDelArr[ n ] );
}
break;
case SFX_STYLE_FAMILY_PARA :
{
- SvUShorts aDelArr;
+ std::vector<sal_uInt16> aDelArr;
const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
{
void* p = (void*)rTbl[ n ];
if( USHRT_MAX == rArr.GetPos( p ))
- aDelArr.Insert( n, 0 );
+ aDelArr.insert( aDelArr.begin(), n );
}
- for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelTxtFmtColl( aDelArr[ n ] );
}
break;
@@ -1490,15 +1488,15 @@ void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc )
case SFX_STYLE_FAMILY_PAGE:
{
- SvUShorts aDelArr;
+ std::vector<sal_uInt16> aDelArr;
for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
{
void* p =
(void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n );
if( USHRT_MAX == rArr.GetPos( p ))
- aDelArr.Insert( n, 0 );
+ aDelArr.insert( aDelArr.begin(), n );
}
- for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelPageDesc( aDelArr[ n ] );
}
break;
--
1.7.6.1
Context
- [Libreoffice] [PATCH] SvUShorts -> std::vector · Daniel Di Marco
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.