Kaydet (Commit) e193ad83 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR(_HTMLAttrs) to std::deque

The code frequently inserts at both ends, so a deque made more
sense.
üst 35be7d75
......@@ -2304,7 +2304,7 @@ void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
void SwHTMLParser::EndContextAttrs( _HTMLAttrContext *pContext, sal_Bool bRemove )
{
_HTMLAttrs &rAttrs = pContext->GetAttrs();
for( sal_uInt16 i=0; i<rAttrs.Count(); i++ )
for( sal_uInt16 i=0; i<rAttrs.size(); i++ )
{
_HTMLAttr *pAttr = rAttrs[i];
......@@ -2324,8 +2324,8 @@ void SwHTMLParser::EndContextAttrs( _HTMLAttrContext *pContext, sal_Bool bRemove
EndAttr( pAttr );
}
if( bRemove && rAttrs.Count() )
rAttrs.Remove( 0, rAttrs.Count() );
if( bRemove && !rAttrs.empty() )
rAttrs.clear();
}
void SwHTMLParser::InsertParaAttrs( const SfxItemSet& rItemSet )
......@@ -2344,7 +2344,7 @@ void SwHTMLParser::InsertParaAttrs( const SfxItemSet& rItemSet )
NewAttr( ppAttr, *pItem );
if( RES_PARATR_BEGIN > nWhich )
(*ppAttr)->SetLikePara();
aParaAttrs.Insert( *ppAttr, aParaAttrs.Count() );
aParaAttrs.push_back( *ppAttr );
EndAttr( *ppAttr, 0, sal_False );
}
......
......@@ -147,8 +147,8 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
// koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
OSL_ENSURE( !aParaAttrs.Count(),
"Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
if( aParaAttrs.Count() )
aParaAttrs.Remove( 0, aParaAttrs.Count() );
if( !aParaAttrs.empty() )
aParaAttrs.clear();
const SwNodeIndex* pOldEndPara = &pPam->GetPoint()->nNode;
xub_StrLen nOldEndCnt = pPam->GetPoint()->nContent.GetIndex();
......@@ -204,9 +204,10 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
pNext->InsertPrev( pSetAttr );
else
{
sal_uInt16 nTmp =
pSetAttr->bInsAtStart ? 0 : aSetAttrTab.Count();
aSetAttrTab.Insert( pSetAttr, nTmp );
if (pSetAttr->bInsAtStart)
aSetAttrTab.push_front( pSetAttr );
else
aSetAttrTab.push_back( pSetAttr );
}
}
else if( pPrev )
......@@ -218,8 +219,10 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
pNext->InsertPrev( pPrev );
else
{
sal_uInt16 nTmp = pPrev->bInsAtStart ? 0 : aSetAttrTab.Count();
aSetAttrTab.Insert( pPrev, nTmp );
if (pPrev->bInsAtStart)
aSetAttrTab.push_front( pPrev );
else
aSetAttrTab.push_back( pPrev );
}
}
......@@ -398,7 +401,7 @@ void SwHTMLParser::EndContext( _HTMLAttrContext *pContext )
void SwHTMLParser::ClearContext( _HTMLAttrContext *pContext )
{
_HTMLAttrs &rAttrs = pContext->GetAttrs();
for( sal_uInt16 i=0; i<rAttrs.Count(); i++ )
for( sal_uInt16 i=0; i<rAttrs.size(); i++ )
{
// einfaches Loeschen reicht hier nicht, weil das
// Attribut auch aus seiner Liste ausgetragen werden
......@@ -524,7 +527,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
NewAttr( &aAttrTab.pDropCap, aDrop );
_HTMLAttrs &rAttrs = pContext->GetAttrs();
rAttrs.Insert( aAttrTab.pDropCap, rAttrs.Count() );
rAttrs.push_back( aAttrTab.pDropCap );
return;
}
......@@ -631,7 +634,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
// ... und noch die Kontext-Information speichern
_HTMLAttrs &rAttrs = pContext->GetAttrs();
rAttrs.Insert( aAttrTab.pULSpace, rAttrs.Count() );
rAttrs.push_back( aAttrTab.pULSpace );
pContext->SetULSpace( aULSpace.GetUpper(), aULSpace.GetLower() );
}
......@@ -668,7 +671,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
// ... und noch die Kontext-Information speichern
_HTMLAttrs &rAttrs = pContext->GetAttrs();
rAttrs.Insert( aAttrTab.pCharBrush, rAttrs.Count() );
rAttrs.push_back( aAttrTab.pCharBrush );
}
else if( pContext->GetToken() != HTML_TABLEHEADER_ON &&
pContext->GetToken() != HTML_TABLEDATA_ON )
......@@ -690,7 +693,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
// ... und noch die Kontext-Information speichern
_HTMLAttrs &rAttrs = pContext->GetAttrs();
rAttrs.Insert( *ppAttr, rAttrs.Count() );
rAttrs.push_back( *ppAttr );
}
// auf zum naechsten Item
......@@ -716,7 +719,7 @@ void SwHTMLParser::InsertAttr( _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
// und im Kontext merken
_HTMLAttrs &rAttrs = pCntxt->GetAttrs();
rAttrs.Insert( *ppAttr, rAttrs.Count() );
rAttrs.push_back( *ppAttr );
}
void SwHTMLParser::SplitPREListingXMP( _HTMLAttrContext *pCntxt )
......
......@@ -637,7 +637,7 @@ void SwHTMLParser::InsertComment( const String& rComment, const sal_Char *pTag )
sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
xub_StrLen nIdx = pPam->GetPoint()->nContent.GetIndex();
for( sal_uInt16 i = aSetAttrTab.Count(); i > 0; )
for( sal_uInt16 i = aSetAttrTab.size(); i > 0; )
{
_HTMLAttr *pAttr = aSetAttrTab[--i];
if( pAttr->GetSttParaIdx() != nNodeIdx ||
......
......@@ -250,7 +250,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
if( nUpper )
{
NewAttr( &aAttrTab.pULSpace, SvxULSpaceItem( 0, nLower, RES_UL_SPACE ) );
aParaAttrs.Insert( aAttrTab.pULSpace, aParaAttrs.Count() );
aParaAttrs.push_back( aAttrTab.pULSpace );
EndAttr( aAttrTab.pULSpace, 0, sal_False );
}
}
......@@ -1250,7 +1250,7 @@ void SwHTMLParser::InsertBookmark( const String& rName )
{
_HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(),
SfxStringItem( RES_FLTR_BOOKMARK, rName ));
aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
aSetAttrTab.push_back( pTmp );
}
sal_Bool SwHTMLParser::HasCurrentParaBookmarks( sal_Bool bIgnoreStack ) const
......@@ -1264,7 +1264,7 @@ sal_Bool SwHTMLParser::HasCurrentParaBookmarks( sal_Bool bIgnoreStack ) const
if( !bIgnoreStack )
{
_HTMLAttr* pAttr;
for( sal_uInt16 i = aSetAttrTab.Count(); i; )
for( sal_uInt16 i = aSetAttrTab.size(); i; )
{
pAttr = aSetAttrTab[ --i ];
if( RES_FLTR_BOOKMARK == pAttr->pItem->Which() )
......
......@@ -3127,8 +3127,8 @@ void _SectionSaveStruct::Restore( SwHTMLParser& rParser )
rParser.bNoParSpace = sal_False;
rParser.nOpenParaToken = 0;
if( rParser.aParaAttrs.Count() )
rParser.aParaAttrs.Remove( 0, rParser.aParaAttrs.Count() );
if( !rParser.aParaAttrs.empty() )
rParser.aParaAttrs.clear();
}
......@@ -3642,26 +3642,26 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions,
_HTMLAttr* pTmp =
new _HTMLAttr( *pPam->GetPoint(), aFontHeight );
aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
aSetAttrTab.push_back( pTmp );
aFontHeight.SetWhich( RES_CHRATR_CJK_FONTSIZE );
pTmp = new _HTMLAttr( *pPam->GetPoint(), aFontHeight );
aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
aSetAttrTab.push_back( pTmp );
aFontHeight.SetWhich( RES_CHRATR_CTL_FONTSIZE );
pTmp = new _HTMLAttr( *pPam->GetPoint(), aFontHeight );
aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
aSetAttrTab.push_back( pTmp );
pTmp = new _HTMLAttr( *pPam->GetPoint(),
SvxULSpaceItem( 0, 0, RES_UL_SPACE ) );
aSetAttrTab.Insert( pTmp, 0 ); // ja, 0, weil schon
aSetAttrTab.push_front( pTmp ); // ja, 0, weil schon
// vom Tabellenende vorher
// was gesetzt sein kann.
}
AppendTxtNode( AM_NOSPACE );
bAppended = sal_True;
}
else if( aParaAttrs.Count() )
else if( !aParaAttrs.empty() )
{
if( !bForceFrame )
{
......@@ -3669,11 +3669,11 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions,
// verschoben. Deshalb entfernen wir alle harten
// Attribute des Absatzes
for( sal_uInt16 i=0; i<aParaAttrs.Count(); i++ )
for( sal_uInt16 i=0; i<aParaAttrs.size(); i++ )
aParaAttrs[i]->Invalidate();
}
aParaAttrs.Remove( 0, aParaAttrs.Count() );
aParaAttrs.clear();
}
pSavePos = new SwPosition( *pPam->GetPoint() );
......@@ -3687,8 +3687,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions,
nFontStHeadStart = nFontStMin;
// die harten Attribute an diesem Absatz werden nie mehr ungueltig
if( aParaAttrs.Count() )
aParaAttrs.Remove( 0, aParaAttrs.Count() );
if( !aParaAttrs.empty() )
aParaAttrs.clear();
}
// einen Tabellen Kontext anlegen
......@@ -4177,7 +4177,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_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( aContexts.size() > nContextStAttrMin+1 )
while( (sal_uInt16)aContexts.size() > nContextStAttrMin+1 )
{
_HTMLAttrContext *pCntxt = PopContext();
EndContext( pCntxt );
......@@ -4909,7 +4909,7 @@ void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
NewAttr( &aAttrTab.pAdjust, SvxAdjustItem(SVX_ADJUST_CENTER, RES_PARATR_ADJUST) );
_HTMLAttrs &rAttrs = pCntxt->GetAttrs();
rAttrs.Insert( aAttrTab.pAdjust, rAttrs.Count() );
rAttrs.push_back( aAttrTab.pAdjust );
PushContext( pCntxt );
......@@ -4994,7 +4994,7 @@ void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
}
// Alle noch offenen Kontexte beenden
while( aContexts.size() > nContextStAttrMin+1 )
while( (sal_uInt16)aContexts.size() > nContextStAttrMin+1 )
{
_HTMLAttrContext *pCntxt = PopContext();
EndContext( pCntxt );
......
......@@ -71,8 +71,7 @@ extern HTMLOptionEnum aHTMLImgVAlignTable[];
// der Attribut Stack:
class _HTMLAttr;
typedef _HTMLAttr *_HTMLAttrPtr;
SV_DECL_PTRARR( _HTMLAttrs, _HTMLAttrPtr, 5 )
typedef std::deque<_HTMLAttr *> _HTMLAttrs;
class _HTMLAttr
{
......@@ -299,7 +298,7 @@ public:
inline sal_Bool IsULSpaceChanged() const { return bULSpaceChanged; }
inline void GetULSpace( sal_uInt16& rUpper, sal_uInt16& rLower ) const;
sal_Bool HasAttrs() const { return aAttrs.Count() != 0; }
sal_Bool HasAttrs() const { return aAttrs.size() != 0; }
const _HTMLAttrs& GetAttrs() const { return aAttrs; }
_HTMLAttrs& GetAttrs() { return aAttrs; }
......@@ -500,7 +499,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
inline void SetAttr( sal_Bool bChkEnd = sal_True, sal_Bool bBeforeTable = sal_False,
_HTMLAttrs *pPostIts = 0 )
{
if( aSetAttrTab.Count() || !aMoveFlyFrms.empty() )
if( !aSetAttrTab.empty() || !aMoveFlyFrms.empty() )
_SetAttr( bChkEnd, bBeforeTable, pPostIts );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment