Hi,
This is another one patch replacing SvULongs and SvUShorts with
std::vector.
Cheers,
Maciej
From 06db1aa6489e2fac7b088f30fe6cd85629c7ef08 Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Wed, 21 Sep 2011 09:19:50 +0200
Subject: [PATCH] Replace SvULongs and SVUShorts with std::vector
Replace SvULongs with std::vector<sal_uIntPtr> and SvUShorts with std::vector<sal_uInt16>
---
svx/inc/svx/numfmtsh.hxx | 8 +------
svx/source/dialog/fntctrl.cxx | 24 +++++++++------------
svx/source/fmcomp/fmgridcl.cxx | 44 ++++++++++++++++++++--------------------
svx/source/items/numfmtsh.cxx | 28 ++++++++++++------------
4 files changed, 47 insertions(+), 57 deletions(-)
diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx
index c29f71d..1fc0d7e 100644
--- a/svx/inc/svx/numfmtsh.hxx
+++ b/svx/inc/svx/numfmtsh.hxx
@@ -33,12 +33,6 @@
#include <tools/string.hxx>
#include <i18npool/lang.h>
-#ifndef _SVSTDARR_ULONGS
-#define _SVSTDARR_ULONGS
-#endif
-#ifndef _SVSTDARR_USHORTS
-#define _SVSTDARR_USHORTS
-#endif
#ifndef _SVSTDARR_STRINGS
#define _SVSTDARR_STRINGS
#endif
@@ -237,7 +231,7 @@ private:
sal_uInt32 nCurFormatKey;
short nCurCategory;
LanguageType eCurLanguage;
- SvUShorts aCurCurrencyList;
+ std::vector<sal_uInt16> aCurCurrencyList;
NfCurrencyEntry* pCurCurrencyEntry;
bool bBankingSymbol;
sal_uInt16 nCurCurrencyEntryPos;
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index 38be3d8..923a234 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -43,11 +43,10 @@
#include <com/sun/star/i18n/ScriptType.hdl>
#ifndef _SVSTDARR_HXX
-#define _SVSTDARR_USHORTS
-#define _SVSTDARR_ULONGS
#define _SVSTDARR_XUB_STRLEN
#include <svl/svstdarr.hxx>
#endif
+#include <vector>
#include <svtools/colorcfg.hxx>
#include <svx/fntctrl.hxx>
@@ -149,9 +148,9 @@ class FontPrevWin_Impl
sal_Bool bDelPrinter;
Reference < XBreakIterator > xBreak;
- SvULongs aTextWidth;
+ std::vector<sal_uIntPtr> aTextWidth;
SvXub_StrLens aScriptChg;
- SvUShorts aScriptType;
+ std::vector<sal_uInt16> aScriptType;
SvxFont aCJKFont;
SvxFont aCTLFont;
String aText;
@@ -248,14 +247,11 @@ inline sal_Bool FontPrevWin_Impl::Is100PercentFontWidthValid() const
void FontPrevWin_Impl::_CheckScript()
{
aScriptText = aText;
- size_t nCnt = aScriptChg.size();
- if( nCnt )
- {
- aScriptChg.clear();
- aScriptType.Remove( 0, nCnt );
- aTextWidth.Remove( 0, nCnt );
- nCnt = 0;
- }
+
+ aScriptChg.clear();
+ aScriptType.clear();
+ aTextWidth.clear();
+
if( !xBreak.is() )
{
Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
@@ -297,8 +293,8 @@ void FontPrevWin_Impl::_CheckScript()
{
aScriptChg.push_back( nChg );
}
- aScriptType.Insert( nScript, nCnt );
- aTextWidth.Insert( sal_uIntPtr(0), nCnt++ );
+ aScriptType.push_back( nScript );
+ aTextWidth.push_back( 0 );
if( nChg < aText.Len() )
nScript = xBreak->getScriptType( aText, nChg );
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 2837df8..0f1b0df 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -454,47 +454,47 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
sal_uInt16 nPos = GetModelColumnPos(nColId);
Reference< XPropertySet > xCol, xSecondCol;
- // erzeugen der Column in abhaengigkeit vom type, default textfeld
- SvULongs aPossibleTypes;
+ // Create Column based on type, default textfield
+ std::vector<sal_uInt16> aPossibleTypes;
switch (nDataType)
{
case DataType::BIT:
case DataType::BOOLEAN:
- aPossibleTypes.Insert(SID_FM_CHECKBOX, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_CHECKBOX);
break;
case DataType::TINYINT:
case DataType::SMALLINT:
case DataType::INTEGER:
- aPossibleTypes.Insert(SID_FM_NUMERICFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_NUMERICFIELD);
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
break;
case DataType::REAL:
case DataType::DOUBLE:
case DataType::NUMERIC:
case DataType::DECIMAL:
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_NUMERICFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
+ aPossibleTypes.push_back(SID_FM_NUMERICFIELD);
break;
case DataType::TIMESTAMP:
- aPossibleTypes.Insert(SID_FM_TWOFIELDS_DATE_N_TIME, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_DATEFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_TIMEFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_TWOFIELDS_DATE_N_TIME);
+ aPossibleTypes.push_back(SID_FM_DATEFIELD);
+ aPossibleTypes.push_back(SID_FM_TIMEFIELD);
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
break;
case DataType::DATE:
- aPossibleTypes.Insert(SID_FM_DATEFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_DATEFIELD);
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
break;
case DataType::TIME:
- aPossibleTypes.Insert(SID_FM_TIMEFIELD, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_TIMEFIELD);
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
break;
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
default:
- aPossibleTypes.Insert(SID_FM_EDIT, aPossibleTypes.Count());
- aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.push_back(SID_FM_EDIT);
+ aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
break;
}
// if it's a currency field, a a "currency field" option
@@ -502,7 +502,7 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
{
if ( ::comphelper::hasProperty(FM_PROP_ISCURRENCY, xField)
&& ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY)))
- aPossibleTypes.Insert(SID_FM_CURRENCYFIELD, 0);
+ aPossibleTypes.insert(aPossibleTypes.begin(), SID_FM_CURRENCYFIELD);
}
catch(Exception&)
{
@@ -510,18 +510,18 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
}
sal_Bool bDateNTimeCol = sal_False;
- if (aPossibleTypes.Count() != 0)
+ if (!aPossibleTypes.empty())
{
sal_Int32 nPreferedType = aPossibleTypes[0];
- if ((m_pImpl->nDropAction == DND_ACTION_LINK) && (aPossibleTypes.Count() > 1))
+ if ((m_pImpl->nDropAction == DND_ACTION_LINK) && (aPossibleTypes.size() > 1))
{
ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) );
PopupMenu aInsertMenu(SVX_RES(RID_SVXMNU_COLS));
PopupMenu aTypeMenu;
PopupMenu* pMenu = aInsertMenu.GetPopupMenu(SID_FM_INSERTCOL);
- for (sal_uInt32 i=0; i<aPossibleTypes.Count(); ++i)
- SetMenuItem(aImageList, sal_uInt16(aPossibleTypes[(sal_uInt16)i]), pMenu,
aTypeMenu, sal_True, 0);
+ for (std::vector<sal_uInt16>::iterator iter = aPossibleTypes.begin(); iter !=
aPossibleTypes.end(); ++iter)
+ SetMenuItem(aImageList, *iter, pMenu, aTypeMenu, sal_True, 0);
nPreferedType = aTypeMenu.Execute(this, m_pImpl->aDropPosPixel);
}
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index c759768..31edcd6 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -1518,7 +1518,7 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList,
sal_uInt16*
sal_uInt16 nTableCount=rCurrencyTable.Count();
*pPos=0;
- sal_uInt16 nCount=aCurCurrencyList.Count();
+ size_t nCount=aCurCurrencyList.size();
if(bFlag)
{
@@ -1527,14 +1527,14 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList,
sal_uInt16*
}
else
{
- for(sal_uInt16 i=1;i<nCount;i++)
+ for(size_t i=1;i<nCount;i++)
{
const sal_uInt16 j = aCurCurrencyList[i];
if (j != (sal_uInt16)-1 && j < nTableCount &&
pTmpCurrencyEntry == rCurrencyTable[j])
{
- *pPos=i;
- nCurCurrencyEntryPos=i;
+ *pPos=static_cast<sal_uInt16>(i);
+ nCurCurrencyEntryPos=static_cast<sal_uInt16>(i);
break;
}
}
@@ -1545,7 +1545,7 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList,
sal_uInt16*
void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, bool bFlag )
{
- aCurCurrencyList.Remove(0,aCurCurrencyList.Count());
+ aCurCurrencyList.clear();
const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
sal_uInt16 nCount=rCurrencyTable.Count();
@@ -1562,13 +1562,13 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, bool
bFlag
WSStringPtr pStr = new XubString(aString);
rList.Insert( pStr,rList.Count());
sal_uInt16 nAuto=(sal_uInt16)-1;
- aCurCurrencyList.Insert(nAuto,aCurCurrencyList.Count());
+ aCurCurrencyList.push_back(nAuto);
if(bFlag)
{
pStr = new XubString(aString);
rList.Insert( pStr,rList.Count());
- aCurCurrencyList.Insert((sal_uInt16)0,aCurCurrencyList.Count());
+ aCurCurrencyList.push_back(0);
++nStart;
}
@@ -1593,7 +1593,7 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, bool
bFlag
break; // insert before first greater than
}
rList.Insert( pStr,j);
- aCurCurrencyList.Insert(i,j);
+ aCurCurrencyList.insert(aCurCurrencyList.begin()+j, i);
}
// Append ISO codes to symbol list.
@@ -1619,7 +1619,7 @@ void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, bool
bFlag
if(bInsert)
{
rList.Insert( pStr,j);
- aCurCurrencyList.Insert(i,j);
+ aCurCurrencyList.insert(aCurCurrencyList.begin()+j, i);
}
}
@@ -1656,7 +1656,7 @@ void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos)
bBankingSymbol=(nPos>=nCount);
- if(nPos<aCurCurrencyList.Count())
+ if(nPos<aCurCurrencyList.size())
{
sal_uInt16 nCurrencyPos=aCurCurrencyList[nPos];
if(nCurrencyPos!=(sal_uInt16)-1)
@@ -1713,11 +1713,11 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat( const String&
rFmtString )
if(nPos!=(sal_uInt16)-1)
{
sal_uInt16 nStart=0;
- if(bTestBanking && aCurCurrencyList.Count()>nPos)
+ if(bTestBanking && aCurCurrencyList.size()>nPos)
{
nStart=nCount;
}
- for(sal_uInt16 j=nStart;j<aCurCurrencyList.Count();j++)
+ for(sal_uInt16 j=nStart;j<aCurCurrencyList.size();j++)
{
if(aCurCurrencyList[j]==nPos) return j;
}
@@ -1797,11 +1797,11 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat(const NfCurrencyEntry*
pTmpC
}
sal_uInt16 nStart=0;
- if(bTmpBanking && aCurCurrencyList.Count()>nPos)
+ if(bTmpBanking && aCurCurrencyList.size()>nPos)
{
nStart=nCount;
}
- for(sal_uInt16 j=nStart;j<aCurCurrencyList.Count();j++)
+ for(sal_uInt16 j=nStart;j<aCurCurrencyList.size();j++)
{
if(aCurCurrencyList[j]==nPos) return j;
}
--
1.7.4.1
Context
- [Libreoffice] Replace SvULongs and SvUShorts in svx with std::vector · Maciej Rumianowski
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.