[Libreoffice-commits] core.git: 14 commits - sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun May 31 14:36:47 PDT 2015
sw/source/filter/html/css1atr.cxx | 46 +++++----
sw/source/filter/html/htmlatr.cxx | 158 +++++++++++++------------------
sw/source/filter/html/htmlcss1.cxx | 47 ++++-----
sw/source/filter/html/htmlctxt.cxx | 24 ++--
sw/source/filter/html/htmldrawreader.cxx | 8 -
sw/source/filter/html/htmldrawwriter.cxx | 4
sw/source/filter/html/htmlfld.cxx | 4
sw/source/filter/html/htmlfldw.cxx | 4
sw/source/filter/html/htmlflywriter.cxx | 11 --
sw/source/filter/html/htmlform.cxx | 29 ++---
sw/source/filter/html/htmlftn.cxx | 21 +---
sw/source/filter/html/htmlgrin.cxx | 2
sw/source/filter/html/htmlnumreader.cxx | 2
sw/source/filter/html/htmlsect.cxx | 6 -
sw/source/filter/html/htmltab.cxx | 24 ++--
sw/source/filter/html/swhtml.cxx | 15 +-
sw/source/filter/html/swhtml.hxx | 4
17 files changed, 195 insertions(+), 214 deletions(-)
New commits:
commit 778d5508f5be8d9e31e1634110137f8afdf0065e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 23:32:19 2015 +0200
Use more proper integer types and range-based for loops
Change-Id: Ie91ab1fad1b2f16380071b8c8fbb928151f85d4b
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
index e71d537..e0145c3 100644
--- a/sw/source/filter/html/htmlftn.cxx
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -89,7 +89,7 @@ sal_Int32 lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
bool bEndNote )
{
sal_Int32 nStrPos = 0;
- for( sal_uInt16 nPart = 0; nPart < 4; nPart++ )
+ for( int nPart = 0; nPart < 4; ++nPart )
{
OUString aPart;
if( -1 != nStrPos )
@@ -134,7 +134,7 @@ void SwHTMLParser::FillFootNoteInfo( const OUString& rContent )
sal_Int32 nStrPos = lcl_html_getEndNoteInfo( aInfo, rContent, false );
- for( sal_uInt16 nPart = 4; nPart < 8; nPart++ )
+ for( int nPart = 4; nPart < 8; ++nPart )
{
OUString aPart;
if( -1 != nStrPos )
@@ -271,7 +271,7 @@ Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
OUString sFootnoteName, sClass;
- sal_uInt16 nPos;
+ size_t nPos;
if( rFormatFootnote.IsEndNote() )
{
nPos = rHTMLWrt.pFootEndNotes ? rHTMLWrt.pFootEndNotes->size() : 0;
@@ -330,9 +330,8 @@ void SwHTMLWriter::OutFootEndNotes()
#endif
nFootNote = 0, nEndNote = 0;
- for( sal_uInt16 i=0; i<pFootEndNotes->size(); i++ )
+ for( auto *pTextFootnote : *pFootEndNotes )
{
- SwTextFootnote *pTextFootnote = (*pFootEndNotes)[i];
pFormatFootnote = &pTextFootnote->GetFootnote();
OUString sFootnoteName, sClass;
@@ -478,11 +477,11 @@ void SwHTMLWriter::OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote,
HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_anchor, false );
}
-static sal_uInt16 lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
+static int lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
OUString *pParts,
bool bEndNote )
{
- sal_uInt16 nParts = 0;
+ int nParts = 0;
sal_Int16 eFormat = rInfo.aFormat.GetNumberingType();
if( (bEndNote ? SVX_NUM_ROMAN_LOWER : SVX_NUM_ARABIC) != eFormat )
{
@@ -513,12 +512,12 @@ static sal_uInt16 lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
}
static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString *pParts,
- sal_uInt16 nParts, const sal_Char *pName )
+ int nParts, const sal_Char *pName )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
OUString aContent;
- for( sal_uInt16 i=0; i<nParts; i++ )
+ for( int i=0; i<nParts; ++i )
{
OUString aTmp( pParts[i] );
aTmp = aTmp.replaceAll( "\\", "\\\\" );
@@ -552,7 +551,7 @@ void SwHTMLWriter::OutFootEndNoteInfo()
{
const SwFootnoteInfo& rInfo = pDoc->GetFootnoteInfo();
OUString aParts[8];
- sal_uInt16 nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, false );
+ int nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, false );
if( rInfo.eNum != FTNNUM_DOC )
{
aParts[4] = rInfo.eNum == FTNNUM_CHAPTER ? OUString( "C" ) : OUString( "P" );
@@ -581,7 +580,7 @@ void SwHTMLWriter::OutFootEndNoteInfo()
{
const SwEndNoteInfo& rInfo = pDoc->GetEndNoteInfo();
OUString aParts[4];
- sal_uInt16 nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, true );
+ const int nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, true );
if( nParts > 0 )
lcl_html_outFootEndNoteInfo( *this, aParts, nParts,
OOO_STRING_SVTOOLS_HTML_META_sdendnote );
commit c8eb473ff1895ad01fe01e82b0a422f6cf5c351e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 23:22:30 2015 +0200
Use more proper integer types and range-based for loops
Change-Id: I04a53b2e6f48e597b5d2de79587458a9f7f61f4d
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index d3bd58c..eda765b 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -762,9 +762,8 @@ static void lcl_html_setEvents(
{
// Erstmal muss die Anzahl der Events ermittelt werden ...
sal_Int32 nEvents = 0;
- sal_uInt16 i;
- for( i = 0; HTML_ET_END != aEventTypeTable[i]; i++ )
+ for( int i = 0; HTML_ET_END != aEventTypeTable[i]; ++i )
{
const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
// Solange nicht alle Events implementiert sind, enthaelt die
@@ -772,9 +771,8 @@ static void lcl_html_setEvents(
if( pMacro && aEventListenerTable[i] )
nEvents++;
}
- for( i=0; i< rUnoMacroTable.size(); i++ )
+ for( const auto &rStr : rUnoMacroTable )
{
- const OUString& rStr(rUnoMacroTable[i]);
sal_Int32 nIndex = 0;
if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
continue;
@@ -791,7 +789,7 @@ static void lcl_html_setEvents(
script::ScriptEventDescriptor* pDescs = aDescs.getArray();
sal_Int32 nEvent = 0;
- for( i=0; HTML_ET_END != aEventTypeTable[i]; i++ )
+ for( int i=0; HTML_ET_END != aEventTypeTable[i]; ++i )
{
const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
if( pMacro && aEventListenerTable[i] )
@@ -805,9 +803,8 @@ static void lcl_html_setEvents(
}
}
- for( i=0; i< rUnoMacroTable.size(); ++i )
+ for( const auto &rStr : rUnoMacroTable )
{
- const OUString& rStr = rUnoMacroTable[i];
sal_Int32 nIndex = 0;
OUString sListener( rStr.getToken( 0, '-', nIndex ) );
if( sListener.isEmpty() || -1 == nIndex )
@@ -884,8 +881,10 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
if( !bHidden )
{
Any aTmp;
- sal_uInt16 nLeftSpace = 0, nRightSpace = 0,
- nUpperSpace = 0, nLowerSpace = 0;
+ sal_Int32 nLeftSpace = 0;
+ sal_Int32 nRightSpace = 0;
+ sal_Int32 nUpperSpace = 0;
+ sal_Int32 nLowerSpace = 0;
const uno::Reference< XMultiServiceFactory > & rServiceFactory =
pFormImpl->GetServiceFactory();
@@ -919,12 +918,12 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
aLRItem.SetTextFirstLineOfst( 0 );
if( rCSS1PropInfo.bLeftMargin )
{
- nLeftSpace = static_cast< sal_uInt16 >(convertTwipToMm100( aLRItem.GetLeft() ));
+ nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() );
rCSS1PropInfo.bLeftMargin = false;
}
if( rCSS1PropInfo.bRightMargin )
{
- nRightSpace = static_cast< sal_uInt16 >(convertTwipToMm100( aLRItem.GetRight() ));
+ nRightSpace = convertTwipToMm100( aLRItem.GetRight() );
rCSS1PropInfo.bRightMargin = false;
}
rCSS1ItemSet.ClearItem( RES_LR_SPACE );
@@ -932,10 +931,10 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
if( nLeftSpace || nRightSpace )
{
Any aAny2;
- aAny2 <<= (sal_Int32)nLeftSpace;
+ aAny2 <<= nLeftSpace;
xShapePropSet->setPropertyValue("LeftMargin", aAny2 );
- aAny2 <<= (sal_Int32)nRightSpace;
+ aAny2 <<= nRightSpace;
xShapePropSet->setPropertyValue("RightMargin", aAny2 );
}
@@ -961,10 +960,10 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
if( nUpperSpace || nLowerSpace )
{
uno::Any aAny2;
- aAny2 <<= (sal_Int32)nUpperSpace;
+ aAny2 <<= nUpperSpace;
xShapePropSet->setPropertyValue("TopMargin", aAny2 );
- aAny2 <<= (sal_Int32)nLowerSpace;
+ aAny2 <<= nLowerSpace;
xShapePropSet->setPropertyValue("BottomMargin", aAny2 );
}
commit ac52b11a150cd260cfb58aa3013abcf499d04468
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 23:11:52 2015 +0200
Use size_t and range-based fo loops
Change-Id: I41a30326a2507b1a21b7f9ed17edb21e373ab526
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index fe05420..9e24f9a 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -248,10 +248,9 @@ sal_uInt16 SwHTMLWriter::GuessFrmType( const SwFrameFormat& rFrameFormat,
bEmpty = true;
if( pHTMLPosFlyFrms )
{
- for( sal_uInt16 i=0; i<pHTMLPosFlyFrms->size(); i++ )
+ for( auto pHTMLPosFlyFrm : *pHTMLPosFlyFrms )
{
- sal_uLong nIdx = (*pHTMLPosFlyFrms)[i]
- ->GetNdIndex().GetIndex();
+ sal_uLong nIdx = pHTMLPosFlyFrm->GetNdIndex().GetIndex();
bEmpty = (nIdx != nStt) && (nIdx != nStt-1);
if( !bEmpty || nIdx > nStt )
break;
@@ -367,9 +366,9 @@ bool SwHTMLWriter::OutFlyFrm( sal_uLong nNdIdx, sal_Int32 nContentIdx, sal_uInt8
bFlysLeft = bRestart = false;
// suche nach dem Anfang der FlyFrames
- sal_uInt16 i;
+ size_t i {0};
- for( i = 0; i < pHTMLPosFlyFrms->size() &&
+ for( ; i < pHTMLPosFlyFrms->size() &&
(*pHTMLPosFlyFrms)[i]->GetNdIndex().GetIndex() < nNdIdx; i++ )
;
for( ; !bRestart && i < pHTMLPosFlyFrms->size() &&
@@ -1940,7 +1939,7 @@ void SwHTMLWriter::CollectLinkTargets()
const ImageMap *pIMap = pURL->GetMap();
if( pIMap )
{
- for( sal_uInt16 i=0; i<pIMap->GetIMapObjectCount(); i++ )
+ for( size_t i=0; i<pIMap->GetIMapObjectCount(); ++i )
{
const IMapObject* pObj = pIMap->GetIMapObject( i );
if( pObj )
commit 591b3d1551f6bddbbda1fbe7e6d5f766de6a29d3
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 23:02:26 2015 +0200
More proper tipes, avoid cast to wrong type
Change-Id: Ia323ed625b51bdb9dac3f3e2826b0dfec2141165
diff --git a/sw/source/filter/html/htmldrawwriter.cxx b/sw/source/filter/html/htmldrawwriter.cxx
index 17638a2..35e3b33 100644
--- a/sw/source/filter/html/htmldrawwriter.cxx
+++ b/sw/source/filter/html/htmldrawwriter.cxx
@@ -217,9 +217,9 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
}
else if( nAmount && Application::GetDefaultDevice() )
{
- nAmount = (sal_uInt16)(Application::GetDefaultDevice()
+ nAmount = Application::GetDefaultDevice()
->LogicToPixel( Size(nAmount,0),
- MapMode(MAP_TWIP) ).Width());
+ MapMode(MAP_TWIP) ).Width();
}
if( nAmount )
{
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 6f12c4d..9e3a9d9 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -351,7 +351,7 @@ void SwHTMLParser::NewField()
if( pFormatOption )
{
const OUString& rFormat = pFormatOption->GetString();
- for( sal_uInt16 k = 0; pFormatTable[k].pName; k++ )
+ for( int k = 0; pFormatTable[k].pName; ++k )
{
if( rFormat.equalsIgnoreAsciiCaseAscii( pFormatTable[k].pName ) )
{
@@ -616,7 +616,7 @@ void SwHTMLParser::InsertComment( const OUString& rComment, const sal_Char *pTag
sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
const sal_Int32 nIdx = pPam->GetPoint()->nContent.GetIndex();
- for( sal_uInt16 i = aSetAttrTab.size(); i > 0; )
+ for( auto i = aSetAttrTab.size(); i > 0; )
{
_HTMLAttr *pAttr = aSetAttrTab[--i];
if( pAttr->GetSttParaIdx() != nNodeIdx ||
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index 09501c1..ebfb23a 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -380,12 +380,12 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
rHTMLWrt.bTagOn = true;
const SfxPoolItem *aItems[5];
- sal_uInt16 nItems = 0;
+ int nItems = 0;
assert(pWhichIds && pRefWhichIds);
if (pWhichIds && pRefWhichIds)
{
- for( sal_uInt16 i=0; i<4; i++ )
+ for( int i=0; i<4; i++ )
{
const SfxPoolItem *pRefItem =
aScriptItemSet.GetItem( pRefWhichIds[i] );
commit d9733c229f4dbd1f33ffd09eb6d31253c64cc30c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 21:00:28 2015 +0200
Unuseful check, unless nLoop is signed (as returned by GetSNumber)
Change-Id: If3a24832251de6be9c4428bfedb6a2a612d6a375
diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx
index 1fd1266..da355ef 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -309,8 +309,8 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
}
else
{
- sal_uInt32 nLoop = rOption.GetSNumber();
- nCount = (sal_uInt16)(nLoop>0 ? nLoop : 0 );
+ const sal_Int32 nLoop = rOption.GetSNumber();
+ nCount = static_cast<sal_uInt16>(nLoop>0 ? nLoop : 0);
}
break;
commit a512942270525405ea646c88dc1d460152a7aa46
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 20:50:32 2015 +0200
Use auto, int
Change-Id: I39a7f83684d044602dd95e4523c43920d3caeac8
diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx
index 73ca7cc..1fd1266 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -424,7 +424,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
{
const SfxItemSet& rItemSet = pTextNd->GetAnyFormatColl().GetAttrSet();
const SfxPoolItem *pItem;
- for( sal_uInt16 i=0; nWhichIds[i]; i++ )
+ for( int i=0; nWhichIds[i]; ++i )
{
if( SfxItemState::SET == rItemSet.GetItemState( nWhichIds[i], true, &pItem ) )
PutEEPoolItem( aItemSet, *pItem );
@@ -433,7 +433,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
// die Attribute der Umgebung am Draw-Objekt setzen
_HTMLAttr** pHTMLAttributes = reinterpret_cast<_HTMLAttr**>(&aAttrTab);
- for (sal_uInt16 nCnt = sizeof(_HTMLAttrTable) / sizeof(_HTMLAttr*); nCnt--; ++pHTMLAttributes)
+ for (auto nCnt = sizeof(_HTMLAttrTable) / sizeof(_HTMLAttr*); nCnt--; ++pHTMLAttributes)
{
_HTMLAttr *pAttr = *pHTMLAttributes;
if( pAttr )
commit 0b8ae8aa7867e63f12517e4a575a700bd07f6d7d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 20:41:44 2015 +0200
Use size_t, auto and range-based for loops
Change-Id: I7f3672928b3d1ee937c7c6c2684b1396425b9fe6
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index 8772b68..0184637 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -47,10 +47,10 @@ class _HTMLAttrContext_SaveDoc
// wenn Attributierung nicht
// beibehalten werden soll.
- sal_uInt16 nContextStMin; // In Umgebung gueltige Stack-
+ size_t nContextStMin; // In Umgebung gueltige Stack-
// Untergrenze, wenn der Stack
// geschuetzt werden soll.
- sal_uInt16 nContextStAttrMin; // In Umgebung gueltige Stack-
+ size_t nContextStAttrMin; // In Umgebung gueltige Stack-
// Untergrenze, wenn die Attribute
// nicht beibehalten werden sollen.
@@ -63,7 +63,7 @@ public:
_HTMLAttrContext_SaveDoc() :
pPos( 0 ), pAttrTab( 0 ),
- nContextStMin( USHRT_MAX ), nContextStAttrMin( USHRT_MAX ),
+ nContextStMin( SIZE_MAX ), nContextStAttrMin( SIZE_MAX ),
bStripTrailingPara( false ), bKeepNumRules( false ),
bFixHeaderDist( false ), bFixFooterDist( false )
{}
@@ -80,11 +80,11 @@ public:
_HTMLAttrTable *GetAttrTab( bool bCreate= false );
- void SetContextStMin( sal_uInt16 nMin ) { nContextStMin = nMin; }
- sal_uInt16 GetContextStMin() const { return nContextStMin; }
+ void SetContextStMin( size_t nMin ) { nContextStMin = nMin; }
+ size_t GetContextStMin() const { return nContextStMin; }
- void SetContextStAttrMin( sal_uInt16 nMin ) { nContextStAttrMin = nMin; }
- sal_uInt16 GetContextStAttrMin() const { return nContextStAttrMin; }
+ void SetContextStAttrMin( size_t nMin ) { nContextStAttrMin = nMin; }
+ size_t GetContextStAttrMin() const { return nContextStAttrMin; }
void SetStripTrailingPara( bool bSet ) { bStripTrailingPara = bSet; }
bool GetStripTrailingPara() const { return bStripTrailingPara; }
@@ -309,10 +309,10 @@ void SwHTMLParser::RestoreDocContext( _HTMLAttrContext *pCntxt )
SetAttr();
}
- if( USHRT_MAX != pSave->GetContextStMin() )
+ if( SIZE_MAX != pSave->GetContextStMin() )
{
nContextStMin = pSave->GetContextStMin();
- if( USHRT_MAX != pSave->GetContextStAttrMin() )
+ if( SIZE_MAX != pSave->GetContextStAttrMin() )
nContextStAttrMin = pSave->GetContextStAttrMin();
}
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index ab51592..1246d1d 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -160,7 +160,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
SfxItemSet& rFrmItemSet )
{
const SfxItemSet *pCntnrItemSet = 0;
- sal_uInt16 i = aContexts.size();
+ auto i = aContexts.size();
while( !pCntnrItemSet && i > nContextStMin )
pCntnrItemSet = aContexts[--i]->GetFrmItemSet();
diff --git a/sw/source/filter/html/htmlnumreader.cxx b/sw/source/filter/html/htmlnumreader.cxx
index dc1d49b..d2a5fe3 100644
--- a/sw/source/filter/html/htmlnumreader.cxx
+++ b/sw/source/filter/html/htmlnumreader.cxx
@@ -559,7 +559,7 @@ void SwHTMLParser::EndNumBulListItem( int nToken, bool bSetColl,
// Kontext zu dem Token suchen und vom Stack holen
_HTMLAttrContext *pCntxt = 0;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
nToken &= ~1;
while( !pCntxt && nPos>nContextStMin )
{
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index 9b5325d..6cddcd9 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -389,7 +389,7 @@ void SwHTMLParser::EndDivision( int /*nToken*/ )
// Stack-Eintrag zu dem Token suchen (weil wir noch den Div-Stack
// haben unterscheiden wir erst einmal nicht zwischen DIV und CENTER
_HTMLAttrContext *pCntxt = 0;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( !pCntxt && nPos>nContextStMin )
{
switch( aContexts[--nPos]->GetToken() )
@@ -524,7 +524,7 @@ bool SwHTMLParser::EndSection( bool bLFStripped )
bool SwHTMLParser::EndSections( bool bLFStripped )
{
bool bSectionClosed = false;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( nPos>nContextStMin )
{
_HTMLAttrContext *pCntxt = aContexts[--nPos];
@@ -589,7 +589,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
//.is the multicol elememt contained in a container? That may be the
// case for 5.0 documents.
bool bInCntnr = false;
- sal_uInt16 i = aContexts.size();
+ auto i = aContexts.size();
while( !bInCntnr && i > nContextStMin )
bInCntnr = 0 != aContexts[--i]->GetFrmItemSet();
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index d01333d..b6e5bb5 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -108,8 +108,8 @@ class _HTMLTableContext
SwFrameFormat *pFrameFormat; // der Fly frame::Frame, containing the table
SwPosition *pPos; // position behind the table
- sal_uInt16 nContextStAttrMin;
- sal_uInt16 nContextStMin;
+ size_t nContextStAttrMin;
+ size_t nContextStMin;
bool bRestartPRE : 1;
bool bRestartXMP : 1;
@@ -119,8 +119,8 @@ public:
_HTMLAttrTable aAttrTab; // attributes
- _HTMLTableContext( SwPosition *pPs, sal_uInt16 nCntxtStMin,
- sal_uInt16 nCntxtStAttrMin ) :
+ _HTMLTableContext( SwPosition *pPs, size_t nCntxtStMin,
+ size_t nCntxtStAttrMin ) :
pTableNd( 0 ),
pFrameFormat( 0 ),
pPos( pPs ),
@@ -149,8 +149,8 @@ public:
void SetFrameFormat( SwFrameFormat *pFormat ) { pFrameFormat = pFormat; }
SwFrameFormat *GetFrameFormat() const { return pFrameFormat; }
- sal_uInt16 GetContextStMin() const { return nContextStMin; }
- sal_uInt16 GetContextStAttrMin() const { return nContextStAttrMin; }
+ size_t GetContextStMin() const { return nContextStMin; }
+ size_t GetContextStAttrMin() const { return nContextStAttrMin; }
};
// Cell content is a linked list with SwStartNodes and
@@ -2985,7 +2985,9 @@ SvxBrushItem* SwHTMLParser::CreateBrushItem( const Color *pColor,
class _SectionSaveStruct : public SwPendingStackData
{
sal_uInt16 nBaseFontStMinSave, nFontStMinSave, nFontStHeadStartSave;
- sal_uInt16 nDefListDeepSave, nContextStMinSave, nContextStAttrMinSave;
+ sal_uInt16 nDefListDeepSave;
+ size_t nContextStMinSave;
+ size_t nContextStAttrMinSave;
public:
@@ -2995,7 +2997,7 @@ public:
virtual ~_SectionSaveStruct();
#if OSL_DEBUG_LEVEL > 0
- sal_uInt16 GetContextStAttrMin() const { return nContextStAttrMinSave; }
+ size_t GetContextStAttrMin() const { return nContextStAttrMinSave; }
#endif
void Restore( SwHTMLParser& rParser );
};
@@ -3303,7 +3305,7 @@ void _CellSaveStruct::InsertCell( SwHTMLParser& rParser,
{
_HTMLAttr** pTable = reinterpret_cast<_HTMLAttr**>(&rParser.aAttrTab);
- for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ for( auto nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
nCnt--; ++pTable )
{
OSL_ENSURE( !*pTable, "Die Attribut-Tabelle ist nicht leer" );
@@ -4096,7 +4098,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
// Alle noch offenen Kontexte beenden. Wir nehmen hier
// AttrMin, weil nContxtStMin evtl. veraendert wurde.
// Da es durch EndContext wieder restauriert wird, geht das.
- while( (sal_uInt16)aContexts.size() > nContextStAttrMin+1 )
+ while( aContexts.size() > nContextStAttrMin+1 )
{
_HTMLAttrContext *pCntxt = PopContext();
EndContext( pCntxt );
@@ -4915,7 +4917,7 @@ void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
}
// Alle noch offenen Kontexte beenden
- while( (sal_uInt16)aContexts.size() > nContextStAttrMin+1 )
+ while( aContexts.size() > nContextStAttrMin+1 )
{
_HTMLAttrContext *pCntxt = PopContext();
EndContext( pCntxt );
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 4ab6dee..f5f501e 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -4085,7 +4085,7 @@ void SwHTMLParser::EndHeading()
// Kontext zu dem Token suchen und vom Stack holen
_HTMLAttrContext *pCntxt = 0;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( !pCntxt && nPos>nContextStMin )
{
switch( aContexts[--nPos]->GetToken() )
@@ -4283,7 +4283,7 @@ void SwHTMLParser::NewDefList()
nDefListDeep++;
bool bInDD = false, bNotInDD = false;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( !bInDD && !bNotInDD && nPos>nContextStMin )
{
sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
@@ -4377,7 +4377,7 @@ void SwHTMLParser::NewDefListItem( int nToken )
{
// festellen, ob das DD/DT in einer DL vorkommt
bool bInDefList = false, bNotInDefList = false;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( !bInDefList && !bNotInDefList && nPos>nContextStMin )
{
sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
@@ -4418,7 +4418,7 @@ void SwHTMLParser::EndDefListItem( int nToken, bool bSetColl,
// Kontext zu dem Token suchen und vom Stack holen
nToken &= ~1;
_HTMLAttrContext *pCntxt = 0;
- sal_uInt16 nPos = aContexts.size();
+ auto nPos = aContexts.size();
while( !pCntxt && nPos>nContextStMin )
{
sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
@@ -4547,9 +4547,8 @@ void SwHTMLParser::SetTextCollAttrs( _HTMLAttrContext *pContext )
sal_uInt16 nLeftMargin = 0, nRightMargin = 0; // die Einzuege und
short nFirstLineIndent = 0; // Abstaende
- sal_uInt16 i;
- for( i = nContextStAttrMin; i < aContexts.size(); i++ )
+ for( auto i = nContextStAttrMin; i < aContexts.size(); ++i )
{
const _HTMLAttrContext *pCntxt = aContexts[i];
@@ -4716,8 +4715,8 @@ void SwHTMLParser::SetTextCollAttrs( _HTMLAttrContext *pContext )
// bisherige harte Attributierung des Absatzes entfernen
if( !aParaAttrs.empty() )
{
- for( i=0; i<aParaAttrs.size(); i++ )
- aParaAttrs[i]->Invalidate();
+ for( auto pParaAttr : aParaAttrs )
+ pParaAttr->Invalidate();
aParaAttrs.clear();
}
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 8c9f9c1..4b9701d 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -418,8 +418,8 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
sal_uInt16 nSBModuleCnt; // Zaehler fuer Basic-Module
sal_uInt16 nMissingImgMaps; // Wie viele Image-Maps fehlen noch?
size_t nParaCnt;
- sal_uInt16 nContextStMin; // Untergrenze fuer PopContext
- sal_uInt16 nContextStAttrMin; // Untergrenze fuer Attributierung
+ size_t nContextStMin; // Untergrenze fuer PopContext
+ size_t nContextStAttrMin; // Untergrenze fuer Attributierung
sal_uInt16 nSelectEntryCnt; // Anzahl der Eintraege der akt. Listbox
sal_uInt16 nOpenParaToken; // ein geoeffnetes Absatz-Element
commit 1b554d3ada47063496b8cf4a28239da26a6537ae
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 19:30:46 2015 +0200
Use auto and range-based for loops
Change-Id: Idbef553cf734eb9eb194912e60f7811d35ce6c84
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index e3673e5..8772b68 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -143,7 +143,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
// alle noch offenen Attribute beenden und hinter der Tabelle
// neu aufspannen
_HTMLAttr** pHTMLAttributes = reinterpret_cast<_HTMLAttr**>(&aAttrTab);
- for (sal_uInt16 nCnt = sizeof(_HTMLAttrTable) / sizeof(_HTMLAttr*); nCnt--; ++pHTMLAttributes)
+ for (auto nCnt = sizeof(_HTMLAttrTable) / sizeof(_HTMLAttr*); nCnt--; ++pHTMLAttributes)
{
_HTMLAttr *pAttr = *pHTMLAttributes;
while( pAttr )
@@ -380,14 +380,14 @@ void SwHTMLParser::EndContext( _HTMLAttrContext *pContext )
void SwHTMLParser::ClearContext( _HTMLAttrContext *pContext )
{
_HTMLAttrs &rAttrs = pContext->GetAttrs();
- for( sal_uInt16 i=0; i<rAttrs.size(); i++ )
+ for( auto pAttr : rAttrs )
{
// einfaches Loeschen reicht hier nicht, weil das
// Attribut auch aus seiner Liste ausgetragen werden
// muss. Theoretisch koennt man natuerlich auch die Liste
// und die Attribute getrennt loeschen, aber wenn man
// dann was falsch gemacht hat, sieht es uebel aus.
- DeleteAttr( rAttrs[i] );
+ DeleteAttr( pAttr );
}
OSL_ENSURE( !pContext->GetSpansSection(),
commit 3a2549197b0d90a1cd94a13fe0514fec5d5e0fa6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 19:02:17 2015 +0200
Use more proper integer types and range-based for loops
Change-Id: Ie02ebb5337bb902b33685feba95d1265be084450
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index a756cdc..ff50777 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -189,7 +189,7 @@ static void SetCharFormatAttrs( SwCharFormat *pCharFormat, SfxItemSet& rItemSet
const SfxPoolItem *pItem;
static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
RES_CHRATR_CTL_FONTSIZE };
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i], false,
&pItem ) &&
@@ -320,7 +320,7 @@ static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet,
static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
RES_CHRATR_CTL_FONTSIZE };
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i], false,
&pItem ) &&
@@ -426,7 +426,7 @@ void SwCSS1Parser::SetPageDescAttrs( const SvxBrushItem *pBrush,
{
static sal_uInt16 aPoolIds[] = { RES_POOLPAGE_HTML, RES_POOLPAGE_FIRST,
RES_POOLPAGE_LEFT, RES_POOLPAGE_RIGHT };
- for( sal_uInt16 i=0; i<4; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aPoolIds); i++ )
{
const SwPageDesc *pPageDesc = GetPageDesc( aPoolIds[i], false );
if( pPageDesc )
@@ -675,9 +675,9 @@ static void RemoveScriptItems( SfxItemSet& rItemSet, sal_uInt16 nScript,
break;
}
- for( sal_uInt16 j=0; j < 3; j++ )
+ for( size_t j=0; j < SAL_N_ELEMENTS(aWhichIds); ++j )
{
- for( sal_uInt16 i=0; i < 5; i++ )
+ for( size_t i=0; i < SAL_N_ELEMENTS(aWhichIds[0]); ++i )
{
sal_uInt16 nWhich = aWhichIds[j][i];
const SfxPoolItem *pItem;
@@ -1221,14 +1221,14 @@ SwCharFormat* SwCSS1Parser::GetChrFormat( sal_uInt16 nToken2, const OUString& rC
SwTextFormatColl *SwCSS1Parser::GetTextCollFromPool( sal_uInt16 nPoolId ) const
{
- sal_uInt16 nOldArrLen = pDoc->GetTextFormatColls()->size();
+ const SwTextFormatColls::size_type nOldArrLen = pDoc->GetTextFormatColls()->size();
SwTextFormatColl *pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nPoolId, false );
if( bIsNewDoc )
{
- sal_uInt16 nArrLen = pDoc->GetTextFormatColls()->size();
- for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ )
+ const SwTextFormatColls::size_type nArrLen = pDoc->GetTextFormatColls()->size();
+ for( SwTextFormatColls::size_type i=nOldArrLen; i<nArrLen; ++i )
lcl_swcss1_setEncoding( *(*pDoc->GetTextFormatColls())[i],
GetDfltEncoding() );
}
@@ -1238,15 +1238,15 @@ SwTextFormatColl *SwCSS1Parser::GetTextCollFromPool( sal_uInt16 nPoolId ) const
SwCharFormat *SwCSS1Parser::GetCharFormatFromPool( sal_uInt16 nPoolId ) const
{
- sal_uInt16 nOldArrLen = pDoc->GetCharFormats()->size();
+ const SwCharFormats::size_type nOldArrLen = pDoc->GetCharFormats()->size();
SwCharFormat *pCharFormat = pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nPoolId );
if( bIsNewDoc )
{
- sal_uInt16 nArrLen = pDoc->GetCharFormats()->size();
+ const SwCharFormats::size_type nArrLen = pDoc->GetCharFormats()->size();
- for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ )
+ for( SwCharFormats::size_type i=nOldArrLen; i<nArrLen; i++ )
lcl_swcss1_setEncoding( *(*pDoc->GetCharFormats())[i],
GetDfltEncoding() );
}
@@ -2133,7 +2133,7 @@ void SwHTMLParser::SetFrameFormatAttrs( SfxItemSet &rItemSet,
_HTMLAttrContext *SwHTMLParser::PopContext( sal_uInt16 nToken, sal_uInt16 nLimit,
bool bRemove )
{
- sal_uInt16 nPos = aContexts.size();
+ _HTMLAttrContexts::size_type nPos = aContexts.size();
if( nPos <= nContextStMin )
return 0;
@@ -2176,7 +2176,7 @@ bool SwHTMLParser::GetMarginsFromContext( sal_uInt16& nLeft,
short& nIndent,
bool bIgnoreTopContext ) const
{
- sal_uInt16 nPos = aContexts.size();
+ _HTMLAttrContexts::size_type nPos = aContexts.size();
if( bIgnoreTopContext )
{
if( !nPos )
@@ -2222,7 +2222,7 @@ void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
sal_uInt16 nDfltColl = 0;
OUString aDfltClass;
- sal_uInt16 nPos = aContexts.size();
+ _HTMLAttrContexts::size_type nPos = aContexts.size();
while( nPos > nContextStAttrMin )
{
const _HTMLAttrContext *pCntxt = aContexts[--nPos];
@@ -2252,10 +2252,8 @@ void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
void SwHTMLParser::EndContextAttrs( _HTMLAttrContext *pContext, bool bRemove )
{
_HTMLAttrs &rAttrs = pContext->GetAttrs();
- for( sal_uInt16 i=0; i<rAttrs.size(); i++ )
+ for( auto pAttr : rAttrs )
{
- _HTMLAttr *pAttr = rAttrs[i];
-
if( RES_PARATR_DROP==pAttr->GetItem().Which() )
{
// Fuer DropCaps noch die Anzahl der Zeichen anpassen. Wenn
@@ -2311,7 +2309,7 @@ static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc )
static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
RES_CHRATR_CTL_FONT };
const SfxPoolItem *pItem;
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i], false,&pItem ) )
{
@@ -2336,8 +2334,7 @@ void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
// Set new encoding as pool default
static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
RES_CHRATR_CTL_FONT };
- sal_uInt16 i;
- for( i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
const SvxFontItem& rDfltFont =
static_cast<const SvxFontItem&>(pDoc->GetDefault( aWhichIds[i]));
@@ -2350,14 +2347,12 @@ void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
}
// Change all paragraph styles that do specify a font.
- sal_uInt16 nArrLen = pDoc->GetTextFormatColls()->size();
- for( i=1; i<nArrLen; i++ )
- lcl_swcss1_setEncoding( *(*pDoc->GetTextFormatColls())[i], eEnc );
+ for( auto pTextFormatColl : *pDoc->GetTextFormatColls() )
+ lcl_swcss1_setEncoding( *pTextFormatColl, eEnc );
// Change all character styles that do specify a font.
- nArrLen = pDoc->GetCharFormats()->size();
- for( i=1; i<nArrLen; i++ )
- lcl_swcss1_setEncoding( *(*pDoc->GetCharFormats())[i], eEnc );
+ for( auto pCharFormat : *pDoc->GetCharFormats() )
+ lcl_swcss1_setEncoding( *pCharFormat, eEnc );
}
SvxCSS1Parser::SetDfltEncoding( eEnc );
commit 18cf9461f58d652296424b25536543fe5371964b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 18:08:28 2015 +0200
Use more proper integer types and range-based for loops
Change-Id: I59dc93687063e1df082d5c96c691dd364cc78ddb
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 5664b4f..2b9fa87 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -356,10 +356,10 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
aSets[1] = 1;
break;
}
- for( sal_uInt16 i=0; i<4; i++ )
+ for( int i=0; i<4; ++i )
{
const SfxPoolItem& rRef = pFormat->GetFormatAttr( aWhichIds[nRef][i] );
- for( sal_uInt16 j=0; j<2; j++ )
+ for( size_t j=0; j<SAL_N_ELEMENTS(aSets); ++j )
{
const SfxPoolItem& rSet = pFormat->GetFormatAttr( aWhichIds[aSets[j]][i] );
if( rSet != rRef )
@@ -430,7 +430,7 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
static const sal_uInt16 aWhichIds[3] =
{ RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
RES_CHRATR_CTL_LANGUAGE };
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
if( aWhichIds[i] != nWhichId )
{
@@ -854,7 +854,7 @@ void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
{
static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i<SAL_N_ELEMENTS(aWhichIds); ++i )
{
// export language if it differs from the default language only.
const SfxPoolItem *pTmpItem;
@@ -1124,8 +1124,8 @@ class HTMLEndPosLst
// Eine SttEndPos in die Start- und Ende-Listen eintragen bzw. aus
// ihnen loeschen, wobei die Ende-Position bekannt ist
- void _InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos );
- void _RemoveItem( sal_uInt16 nEndPos );
+ void _InsertItem( HTMLStartEndPos *pPos, HTMLStartEndPositions::size_type nEndPos );
+ void _RemoveItem( HTMLStartEndPositions::size_type nEndPos );
// die "Art" es Attributs ermitteln
HTMLOnOffState GetHTMLItemState( const SfxPoolItem& rItem );
@@ -1140,7 +1140,7 @@ class HTMLEndPosLst
// das Ende eines gesplitteten Items anpassen
void FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
- sal_uInt16 nStartPos );
+ HTMLStartEndPositions::size_type nStartPos );
// Ein Attribut in die Listen eintragen und ggf. aufteilen
void InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
@@ -1185,23 +1185,22 @@ public:
bool IsHTMLMode( sal_uLong nMode ) const { return (nHTMLMode & nMode) != 0; }
};
-void HTMLEndPosLst::_InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos )
+void HTMLEndPosLst::_InsertItem( HTMLStartEndPos *pPos, HTMLStartEndPositions::size_type nEndPos )
{
// In der Start-Liste das Attribut hinter allen vorher und an
// der gleichen Position gestarteten Attributen einfuegen
sal_Int32 nStart = pPos->GetStart();
- sal_uInt16 i;
+ HTMLStartEndPositions::size_type i {0};
- for( i = 0; i < aStartLst.size() &&
- aStartLst[i]->GetStart() <= nStart; i++ )
- ;
+ while( i < aStartLst.size() && aStartLst[i]->GetStart() <= nStart )
+ ++i;
aStartLst.insert( aStartLst.begin() + i, pPos );
// die Position in der Ende-Liste wurde uebergeben
aEndLst.insert( aEndLst.begin() + nEndPos, pPos );
}
-void HTMLEndPosLst::_RemoveItem( sal_uInt16 nEndPos )
+void HTMLEndPosLst::_RemoveItem( HTMLStartEndPositions::size_type nEndPos )
{
HTMLStartEndPos *pPos = aEndLst[nEndPos];
@@ -1369,10 +1368,8 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
bool HTMLEndPosLst::ExistsOnTagItem( sal_uInt16 nWhich, sal_Int32 nPos )
{
- for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
+ for( auto pTest : aStartLst )
{
- HTMLStartEndPos *pTest = aStartLst[i];
-
if( pTest->GetStart() > nPos )
{
// dieses uns alle folgenden Attribute beginnen spaeter
@@ -1405,10 +1402,8 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
return false;
}
- for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
+ for( auto pTest : aStartLst )
{
- HTMLStartEndPos *pTest = aStartLst[i];
-
if( pTest->GetStart() > nStartPos )
{
// dieses uns alle folgenden Attribute beginnen spaeter
@@ -1437,7 +1432,7 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
}
void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
- sal_uInt16 nStartPos )
+ HTMLStartEndPositions::size_type nStartPos )
{
// die End-Position entsprechend fixen
pPos->SetEnd( nNewEnd );
@@ -1451,14 +1446,13 @@ void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
// es wird von nun an als letztes an der entsprechenden Position
// beendet
- HTMLStartEndPositions::size_type nEndPos;
- for( nEndPos=0; nEndPos < aEndLst.size() &&
- aEndLst[nEndPos]->GetEnd() <= nNewEnd; nEndPos++ )
- ;
+ HTMLStartEndPositions::size_type nEndPos {0};
+ while( nEndPos < aEndLst.size() && aEndLst[nEndPos]->GetEnd() <= nNewEnd )
+ ++nEndPos;
aEndLst.insert( aEndLst.begin() + nEndPos, pPos );
// jetzt noch die spaeter gestarteten Attribute anpassen
- for( sal_uInt16 i=nStartPos+1; i<aStartLst.size(); i++ )
+ for( HTMLStartEndPositions::size_type i = nStartPos+1; i<aStartLst.size(); ++i )
{
HTMLStartEndPos *pTest = aStartLst[i];
sal_Int32 nTestEnd = pTest->GetEnd();
@@ -1495,7 +1489,7 @@ void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
sal_Int32 nEnd )
{
- sal_uInt16 i;
+ HTMLStartEndPositions::size_type i;
for( i = 0; i < aEndLst.size(); i++ )
{
HTMLStartEndPos *pTest = aEndLst[i];
@@ -1535,7 +1529,7 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
// erstmal muessen wir die alten Items anhand der Startliste suchen
// und die neuen Item-Bereiche festlegen
- for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
+ for( HTMLStartEndPositions::size_type i=0; i<aStartLst.size(); ++i )
{
HTMLStartEndPos *pTest = aStartLst[i];
sal_Int32 nTestStart = pTest->GetStart();
@@ -1932,7 +1926,7 @@ void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
// Character border attribute must be the first which is written out
// because of border merge.
- sal_uInt16 nCharBoxIndex = 0;
+ HTMLStartEndPositions::size_type nCharBoxIndex = 0;
while( nCharBoxIndex < aStartLst.size() &&
aStartLst[nCharBoxIndex]->GetItem()->Which() != RES_CHRATR_BOX )
{
@@ -1940,7 +1934,7 @@ void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
}
// die Attribute in der Start-Liste sind aufsteigend sortiert
- for( sal_uInt16 i=0; i< aStartLst.size(); i++ )
+ for( HTMLStartEndPositions::size_type i=0; i< aStartLst.size(); ++i )
{
HTMLStartEndPos *pPos = 0;
if( nCharBoxIndex < aStartLst.size() )
@@ -1989,7 +1983,7 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
rHWrt.bTagOn = false;
// die Attribute in der End-Liste sind aufsteigend sortiert
- sal_uInt16 i=0;
+ HTMLStartEndPositions::size_type i {0};
while( i < aEndLst.size() )
{
HTMLStartEndPos *pPos = aEndLst[i];
commit bd54e40d69cd79fc4d79573c23a9dca460d71819
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 17:29:10 2015 +0200
Use std::find instead of custom code
Change-Id: I5841fa214b53e5b65b4c1251b4c033bb2e55dadc
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 39a28de..5664b4f 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -78,6 +78,7 @@
#include <svtools/HtmlWriter.hxx>
#include <memory>
+#include <algorithm>
using namespace css;
@@ -1121,10 +1122,6 @@ class HTMLEndPosLst
sal_uLong nHTMLMode;
bool bOutStyles : 1; // werden Styles exportiert
- // die Position eines Items in der Start-/Ende-Liste suchen
- sal_uInt16 _FindStartPos( const HTMLStartEndPos *pPos ) const;
- sal_uInt16 _FindEndPos( const HTMLStartEndPos *pPos ) const;
-
// Eine SttEndPos in die Start- und Ende-Listen eintragen bzw. aus
// ihnen loeschen, wobei die Ende-Position bekannt ist
void _InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos );
@@ -1188,29 +1185,6 @@ public:
bool IsHTMLMode( sal_uLong nMode ) const { return (nHTMLMode & nMode) != 0; }
};
-sal_uInt16 HTMLEndPosLst::_FindStartPos( const HTMLStartEndPos *pPos ) const
-{
- sal_uInt16 i;
- for( i = 0; i < aStartLst.size() && aStartLst[i] != pPos; i++ )
- ;
-
- OSL_ENSURE(i != aStartLst.size(), "Item not found in Start List!" );
-
- return i==aStartLst.size() ? USHRT_MAX : i;
-}
-
-sal_uInt16 HTMLEndPosLst::_FindEndPos( const HTMLStartEndPos *pPos ) const
-{
- sal_uInt16 i;
-
- for( i = 0; i < aEndLst.size() && aEndLst[i] != pPos; i++ )
- ;
-
- OSL_ENSURE(i != aEndLst.size(), "Item not found in End List!" );
-
- return i==aEndLst.size() ? USHRT_MAX : i;
-}
-
void HTMLEndPosLst::_InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos )
{
// In der Start-Liste das Attribut hinter allen vorher und an
@@ -1232,9 +1206,11 @@ void HTMLEndPosLst::_RemoveItem( sal_uInt16 nEndPos )
HTMLStartEndPos *pPos = aEndLst[nEndPos];
// jetzt Suchen wir es in der Start-Liste
- sal_uInt16 nStartPos = _FindStartPos( pPos );
- if( nStartPos != USHRT_MAX )
- aStartLst.erase( aStartLst.begin() + nStartPos );
+ HTMLStartEndPositions::iterator it =
+ std::find(aStartLst.begin(), aStartLst.end(), pPos );
+ OSL_ENSURE(it != aStartLst.end(), "Item not found in Start List!");
+ if( it != aStartLst.end() )
+ aStartLst.erase( it );
aEndLst.erase( aEndLst.begin() + nEndPos );
@@ -1467,12 +1443,15 @@ void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
pPos->SetEnd( nNewEnd );
// das Item aus der End-Liste entfernen
- sal_uInt16 nEndPos = _FindEndPos( pPos );
- if( nEndPos != USHRT_MAX )
- aEndLst.erase( aEndLst.begin() + nEndPos );
+ HTMLStartEndPositions::iterator it =
+ std::find(aEndLst.begin(), aEndLst.end(), pPos );
+ OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
+ if( it != aEndLst.end() )
+ aEndLst.erase( it );
// es wird von nun an als letztes an der entsprechenden Position
// beendet
+ HTMLStartEndPositions::size_type nEndPos;
for( nEndPos=0; nEndPos < aEndLst.size() &&
aEndLst[nEndPos]->GetEnd() <= nNewEnd; nEndPos++ )
;
@@ -1498,9 +1477,10 @@ void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
pTest->SetEnd( nNewEnd );
// das Attribut aus der End-Liste entfernen
- sal_uInt16 nEPos = _FindEndPos( pTest );
- if( nEPos != USHRT_MAX )
- aEndLst.erase( aEndLst.begin() + nEPos );
+ it = std::find(aEndLst.begin(), aEndLst.end(), pTest );
+ OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
+ if( it != aEndLst.end() )
+ aEndLst.erase( it );
// es endet jetzt als erstes Attribut an der entsprechenden
// Position. Diese Position in der Ende-Liste kennen wir schon.
@@ -1593,9 +1573,11 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
aStartLst.erase( aStartLst.begin() + i );
i--;
- sal_uInt16 nEndPos = _FindEndPos( pTest );
- if( nEndPos != USHRT_MAX )
- aEndLst.erase( aEndLst.begin() + nEndPos );
+ HTMLStartEndPositions::iterator it =
+ std::find(aEndLst.begin(), aEndLst.end(), pTest );
+ OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
+ if( it != aEndLst.end() )
+ aEndLst.erase( it );
}
// ggf den zweiten Teil des gesplitteten Attribts einfuegen
@@ -2024,9 +2006,14 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
bool bSkipOut = false;
if( pPos->GetItem()->Which() == RES_CHRATR_BOX )
{
- for(sal_uInt16 nIndex = _FindStartPos(pPos) + 1; nIndex < aStartLst.size(); ++nIndex )
+ HTMLStartEndPositions::iterator it =
+ std::find(aStartLst.begin(), aStartLst.end(), pPos );
+ OSL_ENSURE(it != aStartLst.end(), "Item not found in Start List!" );
+ if (it != aStartLst.end())
+ ++it;
+ while(it != aStartLst.end() )
{
- HTMLStartEndPos *pEndPos = aStartLst[nIndex];
+ HTMLStartEndPos *pEndPos = *it;
if( pEndPos->GetItem()->Which() == RES_CHRATR_BOX &&
*static_cast<const SvxBoxItem*>(pEndPos->GetItem()) ==
*static_cast<const SvxBoxItem*>(pPos->GetItem()) )
@@ -2035,6 +2022,7 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
bSkipOut = true;
break;
}
+ ++it;
}
}
if( !bSkipOut )
commit fd5d74c28a5c1775a3559f93233b52382991539a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 15:03:18 2015 +0200
Use more explicative names
Change-Id: Ie42b204b8cc81552b0fb18b8f4ef938787fa5c4d
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 879ac21..39a28de 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1058,7 +1058,7 @@ void OutHTML_SwFormatOff( Writer& rWrt, const SwHTMLTextCollOutputInfo& rInfo )
}
}
-class HTMLSttEndPos
+class HTMLStartEndPos
{
sal_Int32 nStart;
sal_Int32 nEnd;
@@ -1066,8 +1066,8 @@ class HTMLSttEndPos
public:
- HTMLSttEndPos( const SfxPoolItem& rItem, sal_Int32 nStt, sal_Int32 nE );
- ~HTMLSttEndPos();
+ HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt, sal_Int32 nE );
+ ~HTMLStartEndPos();
const SfxPoolItem *GetItem() const { return pItem; }
@@ -1078,19 +1078,19 @@ public:
void SetEnd( sal_Int32 nE ) { nEnd = nE; }
};
-HTMLSttEndPos::HTMLSttEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
+HTMLStartEndPos::HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
sal_Int32 nE ) :
nStart( nStt ),
nEnd( nE ),
pItem( rItem.Clone() )
{}
-HTMLSttEndPos::~HTMLSttEndPos()
+HTMLStartEndPos::~HTMLStartEndPos()
{
delete pItem;
}
-typedef std::vector<HTMLSttEndPos *> _HTMLEndLst;
+typedef std::vector<HTMLStartEndPos *> HTMLStartEndPositions;
enum HTMLOnOffState { HTML_NOT_SUPPORTED, // unsupported Attribute
HTML_REAL_VALUE, // Attribute with value
@@ -1104,8 +1104,8 @@ enum HTMLOnOffState { HTML_NOT_SUPPORTED, // unsupported Attribute
class HTMLEndPosLst
{
- _HTMLEndLst aStartLst; // nach Anfangs-Psoitionen sortierte Liste
- _HTMLEndLst aEndLst; // nach End-Psotionen sortierte Liste
+ HTMLStartEndPositions aStartLst; // nach Anfangs-Psoitionen sortierte Liste
+ HTMLStartEndPositions aEndLst; // nach End-Psotionen sortierte Liste
std::deque<sal_Int32> aScriptChgLst; // positions where script changes
// 0 is not contained in this list,
// but the text length
@@ -1122,12 +1122,12 @@ class HTMLEndPosLst
bool bOutStyles : 1; // werden Styles exportiert
// die Position eines Items in der Start-/Ende-Liste suchen
- sal_uInt16 _FindStartPos( const HTMLSttEndPos *pPos ) const;
- sal_uInt16 _FindEndPos( const HTMLSttEndPos *pPos ) const;
+ sal_uInt16 _FindStartPos( const HTMLStartEndPos *pPos ) const;
+ sal_uInt16 _FindEndPos( const HTMLStartEndPos *pPos ) const;
// Eine SttEndPos in die Start- und Ende-Listen eintragen bzw. aus
// ihnen loeschen, wobei die Ende-Position bekannt ist
- void _InsertItem( HTMLSttEndPos *pPos, sal_uInt16 nEndPos );
+ void _InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos );
void _RemoveItem( sal_uInt16 nEndPos );
// die "Art" es Attributs ermitteln
@@ -1142,7 +1142,7 @@ class HTMLEndPosLst
sal_Int32 nEndPos );
// das Ende eines gesplitteten Items anpassen
- void FixSplittedItem( HTMLSttEndPos *pPos, sal_Int32 nNewEnd,
+ void FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
sal_uInt16 nStartPos );
// Ein Attribut in die Listen eintragen und ggf. aufteilen
@@ -1188,7 +1188,7 @@ public:
bool IsHTMLMode( sal_uLong nMode ) const { return (nHTMLMode & nMode) != 0; }
};
-sal_uInt16 HTMLEndPosLst::_FindStartPos( const HTMLSttEndPos *pPos ) const
+sal_uInt16 HTMLEndPosLst::_FindStartPos( const HTMLStartEndPos *pPos ) const
{
sal_uInt16 i;
for( i = 0; i < aStartLst.size() && aStartLst[i] != pPos; i++ )
@@ -1199,7 +1199,7 @@ sal_uInt16 HTMLEndPosLst::_FindStartPos( const HTMLSttEndPos *pPos ) const
return i==aStartLst.size() ? USHRT_MAX : i;
}
-sal_uInt16 HTMLEndPosLst::_FindEndPos( const HTMLSttEndPos *pPos ) const
+sal_uInt16 HTMLEndPosLst::_FindEndPos( const HTMLStartEndPos *pPos ) const
{
sal_uInt16 i;
@@ -1211,7 +1211,7 @@ sal_uInt16 HTMLEndPosLst::_FindEndPos( const HTMLSttEndPos *pPos ) const
return i==aEndLst.size() ? USHRT_MAX : i;
}
-void HTMLEndPosLst::_InsertItem( HTMLSttEndPos *pPos, sal_uInt16 nEndPos )
+void HTMLEndPosLst::_InsertItem( HTMLStartEndPos *pPos, sal_uInt16 nEndPos )
{
// In der Start-Liste das Attribut hinter allen vorher und an
// der gleichen Position gestarteten Attributen einfuegen
@@ -1229,7 +1229,7 @@ void HTMLEndPosLst::_InsertItem( HTMLSttEndPos *pPos, sal_uInt16 nEndPos )
void HTMLEndPosLst::_RemoveItem( sal_uInt16 nEndPos )
{
- HTMLSttEndPos *pPos = aEndLst[nEndPos];
+ HTMLStartEndPos *pPos = aEndLst[nEndPos];
// jetzt Suchen wir es in der Start-Liste
sal_uInt16 nStartPos = _FindStartPos( pPos );
@@ -1395,7 +1395,7 @@ bool HTMLEndPosLst::ExistsOnTagItem( sal_uInt16 nWhich, sal_Int32 nPos )
{
for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
{
- HTMLSttEndPos *pTest = aStartLst[i];
+ HTMLStartEndPos *pTest = aStartLst[i];
if( pTest->GetStart() > nPos )
{
@@ -1431,7 +1431,7 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
{
- HTMLSttEndPos *pTest = aStartLst[i];
+ HTMLStartEndPos *pTest = aStartLst[i];
if( pTest->GetStart() > nStartPos )
{
@@ -1460,7 +1460,7 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
return false;
}
-void HTMLEndPosLst::FixSplittedItem( HTMLSttEndPos *pPos, sal_Int32 nNewEnd,
+void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
sal_uInt16 nStartPos )
{
// die End-Position entsprechend fixen
@@ -1481,7 +1481,7 @@ void HTMLEndPosLst::FixSplittedItem( HTMLSttEndPos *pPos, sal_Int32 nNewEnd,
// jetzt noch die spaeter gestarteten Attribute anpassen
for( sal_uInt16 i=nStartPos+1; i<aStartLst.size(); i++ )
{
- HTMLSttEndPos *pTest = aStartLst[i];
+ HTMLStartEndPos *pTest = aStartLst[i];
sal_Int32 nTestEnd = pTest->GetEnd();
if( pTest->GetStart() >= nNewEnd )
{
@@ -1518,7 +1518,7 @@ void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
sal_uInt16 i;
for( i = 0; i < aEndLst.size(); i++ )
{
- HTMLSttEndPos *pTest = aEndLst[i];
+ HTMLStartEndPos *pTest = aEndLst[i];
sal_Int32 nTestEnd = pTest->GetEnd();
if( nTestEnd <= nStart )
{
@@ -1531,7 +1531,7 @@ void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
{
// das Test-Attribut endet, bevor das neue endet. Das
// neue Attribut muss deshalb aufgesplittet werden
- _InsertItem( new HTMLSttEndPos( rItem, nStart, nTestEnd ), i );
+ _InsertItem( new HTMLStartEndPos( rItem, nStart, nTestEnd ), i );
nStart = nTestEnd;
}
}
@@ -1544,7 +1544,7 @@ void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
}
// ein Attribut muss noch eingefuegt werden
- _InsertItem( new HTMLSttEndPos( rItem, nStart, nEnd ), i );
+ _InsertItem( new HTMLStartEndPos( rItem, nStart, nEnd ), i );
}
void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
@@ -1557,7 +1557,7 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
for( sal_uInt16 i=0; i<aStartLst.size(); i++ )
{
- HTMLSttEndPos *pTest = aStartLst[i];
+ HTMLStartEndPos *pTest = aStartLst[i];
sal_Int32 nTestStart = pTest->GetStart();
sal_Int32 nTestEnd = pTest->GetEnd();
@@ -1960,7 +1960,7 @@ void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
// die Attribute in der Start-Liste sind aufsteigend sortiert
for( sal_uInt16 i=0; i< aStartLst.size(); i++ )
{
- HTMLSttEndPos *pPos = 0;
+ HTMLStartEndPos *pPos = 0;
if( nCharBoxIndex < aStartLst.size() )
{
if( i == 0 )
@@ -2010,7 +2010,7 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
sal_uInt16 i=0;
while( i < aEndLst.size() )
{
- HTMLSttEndPos *pPos = aEndLst[i];
+ HTMLStartEndPos *pPos = aEndLst[i];
sal_Int32 nEnd = pPos->GetEnd();
if( SAL_MAX_INT32 == nPos || nEnd == nPos )
@@ -2026,7 +2026,7 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
{
for(sal_uInt16 nIndex = _FindStartPos(pPos) + 1; nIndex < aStartLst.size(); ++nIndex )
{
- HTMLSttEndPos *pEndPos = aStartLst[nIndex];
+ HTMLStartEndPos *pEndPos = aStartLst[nIndex];
if( pEndPos->GetItem()->Which() == RES_CHRATR_BOX &&
*static_cast<const SvxBoxItem*>(pEndPos->GetItem()) ==
*static_cast<const SvxBoxItem*>(pPos->GetItem()) )
commit 379ada9ed447a71bee2ffd81dbd09214ce3dcd8d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 12:38:32 2015 +0200
Simplify and optimize (no need to count footnotes/endnotes)
Change-Id: I4b539ec929e62a3d65c8a3fa2e9eb7794abf2a37
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index c9c1061..574b4b2 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -123,7 +123,7 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rFormat,
sal_uInt16 nRefPoolId, bool bExtRef,
bool bPseudo=true );
static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
- SwDoc *pDoc, sal_uInt16 nNotes, bool bEndNote );
+ SwDoc *pDoc, bool bHasNotes, bool bEndNote );
static void OutCSS1_SwFormatDropAttrs( SwHTMLWriter& rHWrt,
const SwFormatDrop& rDrop,
const SfxItemSet *pCharFormatItemSet=0 );
@@ -622,17 +622,26 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, bool bUsed )
OutCSS1_SwFormat( *this, *pCFormat, &pDoc->getIDocumentStylePoolAccess(), pTemplate );
}
+ bool bHasEndNotes {false};
+ bool bHasFootNotes {false};
const SwFootnoteIdxs& rIdxs = pDoc->GetFootnoteIdxs();
- sal_uInt16 nEnd = 0, nFootnote = 0;
for( auto pIdx : rIdxs )
{
if( pIdx->GetFootnote().IsEndNote() )
- nEnd++;
+ {
+ bHasEndNotes = true;
+ if (bHasFootNotes)
+ break;
+ }
else
- nFootnote++;
+ {
+ bHasFootNotes = true;
+ if (bHasEndNotes)
+ break;
+ }
}
- OutCSS1_SwFootnoteInfo( *this, pDoc->GetFootnoteInfo(), pDoc, nFootnote, false );
- OutCSS1_SwFootnoteInfo( *this, pDoc->GetEndNoteInfo(), pDoc, nEnd, true );
+ OutCSS1_SwFootnoteInfo( *this, pDoc->GetFootnoteInfo(), pDoc, bHasFootNotes, false );
+ OutCSS1_SwFootnoteInfo( *this, pDoc->GetEndNoteInfo(), pDoc, bHasEndNotes, true );
if( !bFirstCSS1Rule )
{
@@ -1775,13 +1784,13 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
}
static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
- SwDoc *pDoc, sal_uInt16 nNotes, bool bEndNote )
+ SwDoc *pDoc, bool bHasNotes, bool bEndNote )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
OUString aSelector;
- if( nNotes > 0 )
+ if( bHasNotes )
{
aSelector = OOO_STRING_SVTOOLS_HTML_anchor "." +
( bEndNote ? OUString(OOO_STRING_SVTOOLS_HTML_sdendnote_anc)
@@ -1804,7 +1813,7 @@ static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
// exported, so that Netscape displays the document correctly.
// Otherwise it is sufficient, to export the differences to the
// footnote and endnote template.
- if( nNotes == 0 && rHTMLWrt.pTemplate )
+ if( !bHasNotes && rHTMLWrt.pTemplate )
{
SwFormat *pRefFormat = rHTMLWrt.pTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool(
static_cast< sal_uInt16 >(bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE) );
commit 1348dde6cea4bd3f436ee7657fa51b580ce50787
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun May 31 11:22:31 2015 +0200
Use more proper types and range-based for loops
Change-Id: I9e891923a1301e4b3d19c75102943f30f42965a1
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 9f7bc09..c9c1061 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -600,10 +600,8 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, bool bUsed )
// the Default-TextStyle is not also exported !!
// 0-Style is the Default; is never exported !!
- sal_uInt16 nArrLen = pDoc->GetTextFormatColls()->size();
- sal_uInt16 i;
-
- for( i = 1; i < nArrLen; i++ )
+ const size_t nTextFormats = pDoc->GetTextFormatColls()->size();
+ for( size_t i = 1; i < nTextFormats; ++i )
{
const SwTextFormatColl* pColl = (*pDoc->GetTextFormatColls())[i];
sal_uInt16 nPoolId = pColl->GetPoolFormatId();
@@ -613,8 +611,8 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, bool bUsed )
}
// the Default-TextStyle is not also exported !!
- nArrLen = pDoc->GetCharFormats()->size();
- for( i=1; i<nArrLen; i++ )
+ const size_t nCharFormats = pDoc->GetCharFormats()->size();
+ for( size_t i = 1; i < nCharFormats; ++i )
{
const SwCharFormat *pCFormat = (*pDoc->GetCharFormats())[i];
sal_uInt16 nPoolId = pCFormat->GetPoolFormatId();
@@ -625,11 +623,10 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, bool bUsed )
}
const SwFootnoteIdxs& rIdxs = pDoc->GetFootnoteIdxs();
- nArrLen = rIdxs.size();
sal_uInt16 nEnd = 0, nFootnote = 0;
- for( i=0; i < nArrLen; i++ )
+ for( auto pIdx : rIdxs )
{
- if( rIdxs[i]->GetFootnote().IsEndNote() )
+ if( pIdx->GetFootnote().IsEndNote() )
nEnd++;
else
nFootnote++;
@@ -1213,10 +1210,10 @@ bool SwHTMLWriter::HasScriptDependentItems( const SfxItemSet& rItemSet,
0, 0, 0
};
- for( sal_uInt16 i=0; aWhichIds[i]; i += 3 )
+ for( int i=0; aWhichIds[i]; i += 3 )
{
const SfxPoolItem *pItem = 0, *pItemCJK = 0, *pItemCTL = 0, *pTmp;
- sal_uInt16 nItemCount = 0;
+ int nItemCount = 0;
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i], false,
&pTmp ) )
{
More information about the Libreoffice-commits
mailing list