[Libreoffice-commits] .: 22 commits - sc/source sfx2/inc sfx2/source svl/inc svl/source svtools/inc svtools/source sw/source
Michael Stahl
mst at kemper.freedesktop.org
Fri Jun 8 13:58:31 PDT 2012
sc/source/core/data/documen2.cxx | 5
sfx2/inc/sfx2/dispatch.hxx | 16 +-
sfx2/inc/sfx2/linkmgr.hxx | 8 -
sfx2/inc/sfx2/macrconf.hxx | 4
sfx2/source/appl/appdde.cxx | 8 -
sfx2/source/appl/linkmgr2.cxx | 9 -
sfx2/source/appl/linksrc.cxx | 86 +++++++------
sfx2/source/control/bindings.cxx | 27 ++--
sfx2/source/control/dispatch.cxx | 1
sfx2/source/control/shell.cxx | 81 ++++++------
sfx2/source/dialog/splitwin.cxx | 39 +++---
sfx2/source/dialog/templdlg.cxx | 68 +++++-----
svl/inc/svl/lstner.hxx | 9 -
svl/source/items/aeitem.cxx | 46 +++----
svl/source/notify/lstner.cxx | 45 ++-----
svtools/inc/svtools/svxbox.hxx | 4
svtools/inc/svtools/texteng.hxx | 3
svtools/source/edit/textdat2.hxx | 17 +-
svtools/source/edit/textdata.cxx | 38 ++---
svtools/source/edit/textdoc.cxx | 56 +++-----
svtools/source/edit/textdoc.hxx | 17 +-
svtools/source/edit/texteng.cxx | 248 ++++++++++++++++++++-------------------
svtools/source/edit/textview.cxx | 24 +--
svtools/source/misc/itemdel.cxx | 9 -
sw/source/core/doc/docnew.cxx | 6
sw/source/core/doc/swserv.cxx | 9 -
26 files changed, 465 insertions(+), 418 deletions(-)
New commits:
commit ee5df868c448d4a5dbbed4a7249a7019e3091225
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Tue Jun 5 18:59:39 2012 +0200
Convert SV_DECL_PTRARR_DEL(SfxAllEnumValueArr) to std::vector
Change-Id: Ieff9e0a2a28fa4f14a130f3db987a88ff61161e2
diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx
index 5f66cbf..f70840a 100644
--- a/svl/source/items/aeitem.cxx
+++ b/svl/source/items/aeitem.cxx
@@ -29,8 +29,8 @@
#include <tools/string.hxx>
-#include <svl/svarray.hxx>
#include <svl/aeitem.hxx>
+#include <vector>
// STATIC DATA -----------------------------------------------------------
@@ -46,8 +46,15 @@ struct SfxAllEnumValue_Impl
rtl::OUString aText;
};
-SV_DECL_PTRARR_DEL(SfxAllEnumValueArr, SfxAllEnumValue_Impl*, 0)
-SV_IMPL_PTRARR(SfxAllEnumValueArr, SfxAllEnumValue_Impl*)
+class SfxAllEnumValueArr : public std::vector<SfxAllEnumValue_Impl*>
+{
+public:
+ ~SfxAllEnumValueArr()
+ {
+ for( const_iterator it = begin(); it != end(); ++it )
+ delete *it;
+ }
+};
// -----------------------------------------------------------------------
@@ -105,13 +112,12 @@ SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
pValues = new SfxAllEnumValueArr;
- for ( sal_uInt16 nPos = 0; nPos < rCopy.pValues->Count(); ++nPos )
+ for ( sal_uInt16 nPos = 0; nPos < rCopy.pValues->size(); ++nPos )
{
SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
- pVal->nValue = rCopy.pValues->GetObject(nPos)->nValue;
- pVal->aText = rCopy.pValues->GetObject(nPos)->aText;
- const SfxAllEnumValue_Impl *pTemp = pVal;
- pValues->Insert( pTemp, nPos );
+ pVal->nValue = (*rCopy.pValues)[nPos]->nValue;
+ pVal->aText = (*rCopy.pValues)[nPos]->aText;
+ pValues->insert( pValues->begin() + nPos, pVal );
}
if( rCopy.pDisabledValues )
@@ -134,7 +140,7 @@ SfxAllEnumItem::~SfxAllEnumItem()
sal_uInt16 SfxAllEnumItem::GetValueCount() const
{
DBG_CHKTHIS(SfxAllEnumItem, 0);
- return pValues ? pValues->Count() : 0;
+ return pValues ? pValues->size() : 0;
}
// -----------------------------------------------------------------------
@@ -142,8 +148,8 @@ sal_uInt16 SfxAllEnumItem::GetValueCount() const
rtl::OUString SfxAllEnumItem::GetValueTextByPos( sal_uInt16 nPos ) const
{
DBG_CHKTHIS(SfxAllEnumItem, 0);
- DBG_ASSERT( pValues && nPos < pValues->Count(), "enum overflow" );
- return pValues->GetObject(nPos)->aText;
+ DBG_ASSERT( pValues && nPos < pValues->size(), "enum overflow" );
+ return (*pValues)[nPos]->aText;
}
// -----------------------------------------------------------------------
@@ -151,8 +157,8 @@ rtl::OUString SfxAllEnumItem::GetValueTextByPos( sal_uInt16 nPos ) const
sal_uInt16 SfxAllEnumItem::GetValueByPos( sal_uInt16 nPos ) const
{
DBG_CHKTHIS(SfxAllEnumItem, 0);
- DBG_ASSERT( pValues && nPos < pValues->Count(), "enum overflow" );
- return pValues->GetObject(nPos)->nValue;
+ DBG_ASSERT( pValues && nPos < pValues->size(), "enum overflow" );
+ return (*pValues)[nPos]->nValue;
}
// -----------------------------------------------------------------------
@@ -191,8 +197,8 @@ sal_uInt16 SfxAllEnumItem::_GetPosByValue( sal_uInt16 nVal ) const
//!O: binaere Suche oder SortArray verwenden
sal_uInt16 nPos;
- for ( nPos = 0; nPos < pValues->Count(); ++nPos )
- if ( pValues->GetObject(nPos)->nValue >= nVal )
+ for ( nPos = 0; nPos < pValues->size(); ++nPos )
+ if ( (*pValues)[nPos]->nValue >= nVal )
return nPos;
return nPos;
}
@@ -211,7 +217,7 @@ sal_uInt16 SfxAllEnumItem::GetPosByValue( sal_uInt16 nValue ) const
{
DBG_CHKTHIS(SfxAllEnumItem, 0);
- if ( !pValues || !pValues->Count() )
+ if ( !pValues || pValues->empty() )
return nValue;
return SfxEnumItem::GetPosByValue( nValue );
@@ -225,14 +231,13 @@ void SfxAllEnumItem::InsertValue( sal_uInt16 nValue, const rtl::OUString &rValue
SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
pVal->nValue = nValue;
pVal->aText = rValue;
- const SfxAllEnumValue_Impl *pTemp = pVal;
if ( !pValues )
pValues = new SfxAllEnumValueArr;
else if ( GetPosByValue( nValue ) != USHRT_MAX )
// remove when exists
RemoveValue( nValue );
// then insert
- pValues->Insert( pTemp, _GetPosByValue(nValue) ); //! doppelte?!
+ pValues->insert( pValues->begin() + _GetPosByValue(nValue), pVal ); //! doppelte?!
}
// -----------------------------------------------------------------------
@@ -243,11 +248,10 @@ void SfxAllEnumItem::InsertValue( sal_uInt16 nValue )
SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
pVal->nValue = nValue;
pVal->aText = rtl::OUString::valueOf(static_cast<sal_Int32>(nValue));
- const SfxAllEnumValue_Impl *pTemp = pVal;
if ( !pValues )
pValues = new SfxAllEnumValueArr;
- pValues->Insert( pTemp, _GetPosByValue(nValue) ); //! doppelte?!
+ pValues->insert( pValues->begin() + _GetPosByValue(nValue), pVal ); //! doppelte?!
}
void SfxAllEnumItem::DisableValue( sal_uInt16 nValue )
@@ -278,7 +282,7 @@ void SfxAllEnumItem::RemoveValue( sal_uInt16 nValue )
DBG_CHKTHIS(SfxAllEnumItem, 0);
sal_uInt16 nPos = GetPosByValue(nValue);
DBG_ASSERT( nPos != USHRT_MAX, "removing value not in enum" );
- pValues->Remove( nPos );
+ pValues->erase( pValues->begin() + nPos );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 905fe5993ec3a3a22f01ea31fce6c884359d48ab
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sun Jun 3 18:58:57 2012 +0200
Convert SV_PTRARR_DECL(SfxBroadcasterArr_Impl) to std::deque
Change-Id: I24cdc05c559536e83101e4d811080746f92c74af
diff --git a/svl/inc/svl/lstner.hxx b/svl/inc/svl/lstner.hxx
index a2b5909..3a4513a 100644
--- a/svl/inc/svl/lstner.hxx
+++ b/svl/inc/svl/lstner.hxx
@@ -31,13 +31,12 @@
#include "svl/svldllapi.h"
#include <tools/rtti.hxx>
#include <svl/svarray.hxx>
+#include <deque>
class SfxBroadcaster;
class SfxHint;
-#ifndef _SFX_LSTNER_CXX
-typedef SvPtrarr SfxBroadcasterArr_Impl;
-#endif
+typedef std::deque<SfxBroadcaster*> SfxBroadcasterArr_Impl;
#define SFX_NOTIFY( rBC, rBCT, rHint, rHintT ) \
Notify( rBC, rHint )
@@ -64,9 +63,9 @@ public:
sal_Bool IsListening( SfxBroadcaster& rBroadcaster ) const;
sal_uInt16 GetBroadcasterCount() const
- { return aBCs.Count(); }
+ { return aBCs.size(); }
SfxBroadcaster* GetBroadcasterJOE( sal_uInt16 nNo ) const
- { return (SfxBroadcaster*) aBCs.GetObject(nNo); }
+ { return aBCs[nNo]; }
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 8973273..55da270 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -32,10 +32,8 @@
#include <svl/hint.hxx>
#include <svl/brdcst.hxx>
-SV_DECL_PTRARR( SfxBroadcasterArr_Impl, SfxBroadcaster*, 0 )
-
-#define _SFX_LSTNER_CXX
#include <svl/lstner.hxx>
+#include <algorithm>
//====================================================================
DBG_NAME(SfxListener)
@@ -56,19 +54,19 @@ SfxListener::SfxListener( const SfxListener &rListener )
{
DBG_CTOR(SfxListener, 0);
- for ( sal_uInt16 n = 0; n < rListener.aBCs.Count(); ++n )
+ for ( sal_uInt16 n = 0; n < rListener.aBCs.size(); ++n )
StartListening( *rListener.aBCs[n] );
}
//--------------------------------------------------------------------
-// unregisteres the SfxListener from its SfxBroadcasters
+// unregisters the SfxListener from its SfxBroadcasters
SfxListener::~SfxListener()
{
DBG_DTOR(SfxListener, 0);
- // unregister at all remainding broadcasters
- for ( sal_uInt16 nPos = 0; nPos < aBCs.Count(); ++nPos )
+ // unregister at all remaining broadcasters
+ for ( sal_uInt16 nPos = 0; nPos < aBCs.size(); ++nPos )
{
SfxBroadcaster *pBC = aBCs[nPos];
pBC->RemoveListener(*this);
@@ -77,19 +75,18 @@ SfxListener::~SfxListener()
//--------------------------------------------------------------------
-// unregisteres at a specific SfxBroadcaster
+// unregisters a specific SfxBroadcaster
-void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBC )
+void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBroadcaster )
{
DBG_CHKTHIS(SfxListener, 0);
- const SfxBroadcaster *pBC = &rBC;
- aBCs.Remove( aBCs.GetPos(pBC), 1 );
+ aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) );
}
//--------------------------------------------------------------------
-// registeres at a specific SfxBroadcaster
+// registers a specific SfxBroadcaster
sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPreventDups )
{
@@ -99,8 +96,7 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
{
if ( rBroadcaster.AddListener(*this) )
{
- const SfxBroadcaster *pBC = &rBroadcaster;
- aBCs.Insert( pBC, aBCs.Count() );
+ aBCs.push_back( &rBroadcaster );
DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
return sal_True;
@@ -112,7 +108,7 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
//--------------------------------------------------------------------
-// unregisteres at a specific SfxBroadcaster
+// unregisters a specific SfxBroadcaster
sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllDups )
{
@@ -124,8 +120,7 @@ sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllD
do
{
rBroadcaster.RemoveListener(*this);
- const SfxBroadcaster *pBC = &rBroadcaster;
- aBCs.Remove( aBCs.GetPos(pBC), 1 );
+ aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) );
}
while ( bAllDups && IsListening( rBroadcaster ) );
return sal_True;
@@ -133,18 +128,18 @@ sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllD
//--------------------------------------------------------------------
-// unregisteres all Broadcasters
+// unregisters all Broadcasters
void SfxListener::EndListeningAll()
{
DBG_CHKTHIS(SfxListener, 0);
// MI: bei Optimierung beachten: Seiteneffekte von RemoveListener beachten!
- while ( aBCs.Count() )
+ while ( !aBCs.empty() )
{
- SfxBroadcaster *pBC = aBCs.GetObject(0);
+ SfxBroadcaster *pBC = aBCs.front();
pBC->RemoveListener(*this);
- aBCs.Remove( 0, 1 );
+ aBCs.pop_front();
}
}
@@ -152,8 +147,7 @@ void SfxListener::EndListeningAll()
sal_Bool SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
{
- const SfxBroadcaster *pBC = &rBroadcaster;
- return USHRT_MAX != aBCs.GetPos( pBC );
+ return aBCs.end() != std::find( aBCs.begin(), aBCs.end(), &rBroadcaster );
}
//--------------------------------------------------------------------
@@ -161,14 +155,13 @@ sal_Bool SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
// base implementation of notification handler
#ifdef DBG_UTIL
-void SfxListener::Notify( SfxBroadcaster& rBC, const SfxHint& )
+void SfxListener::Notify( SfxBroadcaster& rBroadcaster, const SfxHint& )
#else
void SfxListener::Notify( SfxBroadcaster&, const SfxHint& )
#endif
{
#ifdef DBG_UTIL
- const SfxBroadcaster *pBC = &rBC;
- DBG_ASSERT( USHRT_MAX != aBCs.GetPos(pBC),
+ DBG_ASSERT(aBCs.end() != std::find(aBCs.begin(), aBCs.end(), &rBroadcaster),
"notification from unregistered broadcaster" );
#endif
}
commit be369facf912da2e0da27194738027fc5a07d779
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 22:49:14 2012 +0200
Convert SV_DECL_PTRARR(SvxEntryLst) to std::vector
Change-Id: Ib81f31a94a27b1415292fa1aca34c47c38e723b4
diff --git a/svtools/inc/svtools/svxbox.hxx b/svtools/inc/svtools/svxbox.hxx
index 81d8ff9..1fbf59b 100644
--- a/svtools/inc/svtools/svxbox.hxx
+++ b/svtools/inc/svtools/svxbox.hxx
@@ -41,7 +41,7 @@
class SvxBoxEntry;
class SvxListBase;
-SV_DECL_PTRARR( SvxEntryLst, SvxBoxEntry*, 10 )
+typedef std::vector<SvxBoxEntry*> SvxEntryLst;
// class SvxBoxEntry -----------------------------------------------------
@@ -55,7 +55,7 @@ public:
SvxBoxEntry( const SvxBoxEntry& rOrg );
SvxBoxEntry();
- String aName;
+ String aName;
sal_uInt16 nId;
private:
commit 725b725e9744c78f7fcf54a8cf42614fca7ce15e
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jun 8 22:27:29 2012 +0200
fix missing braces in TextEngine::CreateLines in previous commit
also fix various DBG_UTIL only code
Change-Id: I53b6c65f4a5769cb0e4849e3d30e6fb78449ecce
diff --git a/svtools/source/edit/textdata.cxx b/svtools/source/edit/textdata.cxx
index 16ac068..7d55ee1 100644
--- a/svtools/source/edit/textdata.cxx
+++ b/svtools/source/edit/textdata.cxx
@@ -194,9 +194,9 @@ sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, sal_Bool bInclEnd )
}
}
- // Dann sollte es am Ende der letzten Zeile sein!
- DBG_ASSERT( nChar == maLines[ maLines.Count() - 1 ]->GetEnd(), "Index voll daneben!" );
- DBG_ASSERT( !bInclEnd, "Zeile nicht gefunden: FindLine" );
+ // Then it should be at the end of the last line
+ OSL_ENSURE(nChar == maLines[maLines.size() - 1]->GetEnd(), "wrong Index");
+ OSL_ENSURE(!bInclEnd, "Line not found: FindLine");
return ( maLines.size() - 1 );
}
diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index 8a5d343..6cb4263 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -985,7 +985,7 @@ long TextEngine::ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex
TEParaPortion* pParaPortion = mpTEParaPortions->GetObject( nPara );
sal_uInt16 nTextPortionStart = 0;
- sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
+ size_t nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
DBG_ASSERT( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " );
@@ -1697,11 +1697,10 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uLong nPara )
if ( bLineBreak == sal_True )
{
- // -2: Die neue ist bereits eingefuegt.
- #ifdef DBG_UTIL
- TextLine* pLastLine = pTEParaPortion->GetLines().GetObject( pTEParaPortion->GetLines().Count()-2 );
- DBG_ASSERT( pLastLine, "Weicher Umbruch, keine Zeile ?!" );
- #endif
+ // -2: The new one is already inserted.
+ OSL_ENSURE(
+ pTEParaPortion->GetLines()[pTEParaPortion->GetLines().size()-2],
+ "Soft Break, no Line?!");
sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1 ;
pTmpLine->SetStartPortion( nPos );
pTmpLine->SetEndPortion( nPos );
@@ -1857,7 +1856,9 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
break;
}
}
- DBG_ASSERT( nP < pTEParaPortion->GetTextPortions().Count() || pTEParaPortion->GetTextPortions().empty(), "Nichts zum loeschen: CreateTextPortions" );
+ OSL_ENSURE(nP < pTEParaPortion->GetTextPortions().size()
+ || pTEParaPortion->GetTextPortions().empty(),
+ "Nothing to delete: CreateTextPortions");
if ( nInvPortion && ( nPortionStart+pTEParaPortion->GetTextPortions()[nInvPortion]->GetLen() > nStartPos ) )
{
// lieber eine davor...
@@ -1883,14 +1884,14 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
pTEParaPortion->GetTextPortions().push_back( pNew );
}
}
- DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "No Portions?!" );
+ OSL_ENSURE(pTEParaPortion->GetTextPortions().size(), "No Portions?!");
}
void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short nNewChars )
{
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara );
- DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "Keine Portions!" );
- DBG_ASSERT( nNewChars, "RecalcTextPortion mit Diff == 0" );
+ OSL_ENSURE(pTEParaPortion->GetTextPortions().size(), "no Portions!");
+ OSL_ENSURE(nNewChars, "RecalcTextPortion with Diff == 0");
TextNode* const pNode = pTEParaPortion->GetNode();
if ( nNewChars > 0 )
@@ -1971,7 +1972,8 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short
DBG_ASSERT( pTP->GetLen() > (-nNewChars), "Portion zu klein zum schrumpfen!" );
pTP->GetLen() = pTP->GetLen() + nNewChars;
}
- DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "RecalcTextPortions: Keine mehr da!" );
+ OSL_ENSURE( pTEParaPortion->GetTextPortions().size(),
+ "RecalcTextPortions: none are left!" );
}
}
@@ -2036,7 +2038,8 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan
nIndex = pLine->GetStart();
for ( sal_uInt16 y = pLine->GetStartPortion(); y <= pLine->GetEndPortion(); y++ )
{
- DBG_ASSERT( pPortion->GetTextPortions().Count(), "Zeile ohne Textportion im Paint!" );
+ OSL_ENSURE(pPortion->GetTextPortions().size(),
+ "Line without Textportion in Paint!");
TETextPortion* pTextPortion = pPortion->GetTextPortions()[ y ];
DBG_ASSERT( pTextPortion, "NULL-Pointer im Portioniterator in UpdateViews" );
@@ -2295,7 +2298,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
// ---------------------------------------------------------------
// Ab hier alle Zeilen durchformatieren...
// ---------------------------------------------------------------
- sal_uInt16 nDelFromLine = 0xFFFF;
+ size_t nDelFromLine = std::numeric_limits<size_t>::max();
sal_Bool bLineBreak = sal_False;
sal_uInt16 nIndex = pLine->GetStart();
@@ -2384,7 +2387,8 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
{
bEOL = sal_True;
pLine->SetEnd( nPortionEnd );
- DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "Keine TextPortions?" );
+ OSL_ENSURE(pTEParaPortion->GetTextPortions().size(),
+ "No TextPortions?");
pLine->SetEndPortion( (sal_uInt16)pTEParaPortion->GetTextPortions().size() - 1 );
}
@@ -2511,12 +2515,16 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
}
} // while ( Index < Len )
- if ( nDelFromLine != 0xFFFF )
+ if (nDelFromLine != std::numeric_limits<size_t>::max())
+ {
for( TextLines::iterator it = pTEParaPortion->GetLines().begin() + nDelFromLine;
it != pTEParaPortion->GetLines().end(); ++it )
+ {
delete *it;
+ }
pTEParaPortion->GetLines().erase( pTEParaPortion->GetLines().begin() + nDelFromLine,
pTEParaPortion->GetLines().end() );
+ }
DBG_ASSERT( pTEParaPortion->GetLines().size(), "Keine Zeile nach CreateLines!" );
commit 2076d5ce963a9e9b7beb2707134c8e069953a0e4
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 17:38:00 2012 +0200
Convert SV_DECL_PTRARR(TextPortionArray) to std::vector
Change-Id: I005e4569f1899effc85b1c4068eaee8d30de047b
diff --git a/svtools/source/edit/textdat2.hxx b/svtools/source/edit/textdat2.hxx
index 7806a9a..aa0916a 100644
--- a/svtools/source/edit/textdat2.hxx
+++ b/svtools/source/edit/textdat2.hxx
@@ -91,14 +91,13 @@ public:
-typedef TETextPortion* TextPortionPtr;
-SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0 )
+typedef std::vector<TETextPortion*> TextPortionArray;
class TETextPortionList : public TextPortionArray
{
public:
- TETextPortionList();
- ~TETextPortionList();
+ TETextPortionList();
+ ~TETextPortionList();
void Reset();
sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False );
diff --git a/svtools/source/edit/textdata.cxx b/svtools/source/edit/textdata.cxx
index a5f9aa1..16ac068 100644
--- a/svtools/source/edit/textdata.cxx
+++ b/svtools/source/edit/textdata.cxx
@@ -76,31 +76,31 @@ TETextPortionList::~TETextPortionList()
void TETextPortionList::Reset()
{
- for ( sal_uInt16 nPortion = 0; nPortion < Count(); nPortion++ )
- delete GetObject( nPortion );
- Remove( 0, Count() );
+ for ( iterator it = begin(); it != end(); ++it )
+ delete *it;
+ clear();
}
void TETextPortionList::DeleteFromPortion( sal_uInt16 nDelFrom )
{
- DBG_ASSERT( ( nDelFrom < Count() ) || ( (nDelFrom == 0) && (Count() == 0) ), "DeleteFromPortion: Out of range" );
- for ( sal_uInt16 nP = nDelFrom; nP < Count(); nP++ )
- delete GetObject( nP );
- Remove( nDelFrom, Count()-nDelFrom );
+ DBG_ASSERT( ( nDelFrom < size() ) || ( (nDelFrom == 0) && (size() == 0) ), "DeleteFromPortion: Out of range" );
+ for ( iterator it = begin() + nDelFrom; it != end(); ++it )
+ delete *it;
+ erase( begin() + nDelFrom, end() );
}
sal_uInt16 TETextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPortionStart, sal_Bool bPreferStartingPortion )
{
// Bei nCharPos an Portion-Grenze wird die linke Portion gefunden
sal_uInt16 nTmpPos = 0;
- for ( sal_uInt16 nPortion = 0; nPortion < Count(); nPortion++ )
+ for ( sal_uInt16 nPortion = 0; nPortion < size(); nPortion++ )
{
- TETextPortion* pPortion = GetObject( nPortion );
+ TETextPortion* pPortion = operator[]( nPortion );
nTmpPos = nTmpPos + pPortion->GetLen();
if ( nTmpPos >= nCharPos )
{
// take this one if we don't prefer the starting portion, or if it's the last one
- if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == Count() - 1 ) )
+ if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == size() - 1 ) )
{
nPortionStart = nTmpPos - pPortion->GetLen();
return nPortion;
@@ -108,7 +108,7 @@ sal_uInt16 TETextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPor
}
}
OSL_FAIL( "FindPortion: Nicht gefunden!" );
- return ( Count() - 1 );
+ return ( size() - 1 );
}
diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index 1a8d64b..8a5d343 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -989,7 +989,7 @@ long TextEngine::ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex
DBG_ASSERT( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " );
- TETextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion );
+ TETextPortion* pPortion = pParaPortion->GetTextPortions()[ nTextPortion ];
long nX = ImpGetPortionXOffset( nPara, pLine, nTextPortion );
@@ -1006,9 +1006,9 @@ long TextEngine::ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex
( IsRightToLeft() && pPortion->IsRightToLeft() ) )
{
nX += nPortionTextWidth;
- if ( ( pPortion->GetKind() == PORTIONKIND_TAB ) && ( (nTextPortion+1) < pParaPortion->GetTextPortions().Count() ) )
+ if ( ( pPortion->GetKind() == PORTIONKIND_TAB ) && ( (nTextPortion+1) < pParaPortion->GetTextPortions().size() ) )
{
- TETextPortion* pNextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion+1 );
+ TETextPortion* pNextPortion = pParaPortion->GetTextPortions()[ nTextPortion+1 ];
if ( ( pNextPortion->GetKind() != PORTIONKIND_TAB ) && (
( !IsRightToLeft() && pNextPortion->IsRightToLeft() ) ||
( IsRightToLeft() && !pNextPortion->IsRightToLeft() ) ) )
@@ -1157,7 +1157,7 @@ sal_uInt16 TextEngine::GetCharPos( sal_uLong nPortion, sal_uInt16 nLine, long nX
for ( sal_uInt16 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ )
{
- TETextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( i );
+ TETextPortion* pTextPortion = pPortion->GetTextPortions()[ i ];
nTmpX += pTextPortion->GetWidth();
if ( nTmpX > nXPos )
@@ -1213,7 +1213,7 @@ sal_uLong TextEngine::CalcTextWidth( sal_uLong nPara )
TextLine* pLine = pPortion->GetLines()[ --nLine ];
for ( sal_uInt16 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
{
- TETextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( nTP );
+ TETextPortion* pTextPortion = pPortion->GetTextPortions()[ nTP ];
nLineWidth += pTextPortion->GetWidth();
}
if ( nLineWidth > nParaWidth )
@@ -1693,7 +1693,7 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uLong nPara )
TETextPortion* pDummyPortion = new TETextPortion( 0 );
pDummyPortion->GetWidth() = 0;
- pTEParaPortion->GetTextPortions().Insert( pDummyPortion, pTEParaPortion->GetTextPortions().Count() );
+ pTEParaPortion->GetTextPortions().push_back( pDummyPortion );
if ( bLineBreak == sal_True )
{
@@ -1702,7 +1702,7 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uLong nPara )
TextLine* pLastLine = pTEParaPortion->GetLines().GetObject( pTEParaPortion->GetLines().Count()-2 );
DBG_ASSERT( pLastLine, "Weicher Umbruch, keine Zeile ?!" );
#endif
- sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().Count() - 1 ;
+ sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1 ;
pTmpLine->SetStartPortion( nPos );
pTmpLine->SetEndPortion( nPos );
}
@@ -1751,7 +1751,7 @@ void TextEngine::ImpBreakLine( sal_uLong nPara, TextLine* pLine, TETextPortion*,
{
// Blanks am Zeilenende generell unterdruecken...
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara );
- TETextPortion* pTP = pTEParaPortion->GetTextPortions().GetObject( nEndPortion );
+ TETextPortion* pTP = pTEParaPortion->GetTextPortions()[ nEndPortion ];
DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion am Anfang der Zeile?" );
pTP->GetWidth() = (long)CalcTextWidth( nPara, nBreakPos-pTP->GetLen(), pTP->GetLen()-1 );
}
@@ -1770,10 +1770,10 @@ sal_uInt16 TextEngine::SplitTextPortion( sal_uLong nPara, sal_uInt16 nPos )
sal_uInt16 nTmpPos = 0;
TETextPortion* pTextPortion = 0;
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara );
- sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().Count();
+ sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().size();
for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ )
{
- TETextPortion* pTP = pTEParaPortion->GetTextPortions().GetObject(nSplitPortion);
+ TETextPortion* pTP = pTEParaPortion->GetTextPortions()[nSplitPortion];
nTmpPos = nTmpPos + pTP->GetLen();
if ( nTmpPos >= nPos )
{
@@ -1789,7 +1789,7 @@ sal_uInt16 TextEngine::SplitTextPortion( sal_uLong nPara, sal_uInt16 nPos )
sal_uInt16 nOverlapp = nTmpPos - nPos;
pTextPortion->GetLen() = pTextPortion->GetLen() - nOverlapp;
TETextPortion* pNewPortion = new TETextPortion( nOverlapp );
- pTEParaPortion->GetTextPortions().Insert( pNewPortion, nSplitPortion+1 );
+ pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nSplitPortion + 1, pNewPortion );
pTextPortion->GetWidth() = (long)CalcTextWidth( nPara, nPos-pTextPortion->GetLen(), pTextPortion->GetLen() );
return nSplitPortion;
@@ -1846,9 +1846,9 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
sal_uInt16 nPortionStart = 0;
sal_uInt16 nInvPortion = 0;
sal_uInt16 nP;
- for ( nP = 0; nP < pTEParaPortion->GetTextPortions().Count(); nP++ )
+ for ( nP = 0; nP < pTEParaPortion->GetTextPortions().size(); nP++ )
{
- TETextPortion* pTmpPortion = pTEParaPortion->GetTextPortions().GetObject(nP);
+ TETextPortion* pTmpPortion = pTEParaPortion->GetTextPortions()[nP];
nPortionStart = nPortionStart + pTmpPortion->GetLen();
if ( nPortionStart >= nStartPos )
{
@@ -1857,14 +1857,14 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
break;
}
}
- DBG_ASSERT( nP < pTEParaPortion->GetTextPortions().Count() || !pTEParaPortion->GetTextPortions().Count(), "Nichts zum loeschen: CreateTextPortions" );
- if ( nInvPortion && ( nPortionStart+pTEParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen() > nStartPos ) )
+ DBG_ASSERT( nP < pTEParaPortion->GetTextPortions().Count() || pTEParaPortion->GetTextPortions().empty(), "Nichts zum loeschen: CreateTextPortions" );
+ if ( nInvPortion && ( nPortionStart+pTEParaPortion->GetTextPortions()[nInvPortion]->GetLen() > nStartPos ) )
{
// lieber eine davor...
// Aber nur wenn es mitten in der Portion war, sonst ist es evtl.
// die einzige in der Zeile davor !
nInvPortion--;
- nPortionStart = nPortionStart - pTEParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen();
+ nPortionStart = nPortionStart - pTEParaPortion->GetTextPortions()[nInvPortion]->GetLen();
}
pTEParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
@@ -1880,7 +1880,7 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
for ( ++nextIt; nextIt != aPositions.end(); ++aPositionsIt, ++nextIt )
{
TETextPortion* pNew = new TETextPortion( *nextIt - *aPositionsIt );
- pTEParaPortion->GetTextPortions().Insert( pNew, pTEParaPortion->GetTextPortions().Count());
+ pTEParaPortion->GetTextPortions().push_back( pNew );
}
}
DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "No Portions?!" );
@@ -1910,7 +1910,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short
// Eine leere Portion kann hier stehen, wenn der Absatz leer war,
// oder eine Zeile durch einen harten Zeilenumbruch entstanden ist.
- if ( ( nNewPortionPos < pTEParaPortion->GetTextPortions().Count() ) &&
+ if ( ( nNewPortionPos < pTEParaPortion->GetTextPortions().size() ) &&
!pTEParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
{
// Dann die leere Portion verwenden.
@@ -1921,7 +1921,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short
else
{
TETextPortion* pNewPortion = new TETextPortion( nNewChars );
- pTEParaPortion->GetTextPortions().Insert( pNewPortion, nNewPortionPos );
+ pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nNewPortionPos, pNewPortion );
}
}
else
@@ -1946,7 +1946,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short
sal_uInt16 nPortion = 0;
sal_uInt16 nPos = 0;
sal_uInt16 nEnd = nStartPos-nNewChars;
- sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().Count();
+ sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().size();
TETextPortion* pTP = 0;
for ( nPortion = 0; nPortion < nPortions; nPortion++ )
{
@@ -1963,7 +1963,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short
if ( ( nPos == nStartPos ) && ( (nPos+pTP->GetLen()) == nEnd ) )
{
// Portion entfernen;
- pTEParaPortion->GetTextPortions().Remove( nPortion );
+ pTEParaPortion->GetTextPortions().erase( pTEParaPortion->GetTextPortions().begin() + nPortion );
delete pTP;
}
else
@@ -2037,7 +2037,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan
for ( sal_uInt16 y = pLine->GetStartPortion(); y <= pLine->GetEndPortion(); y++ )
{
DBG_ASSERT( pPortion->GetTextPortions().Count(), "Zeile ohne Textportion im Paint!" );
- TETextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( y );
+ TETextPortion* pTextPortion = pPortion->GetTextPortions()[ y ];
DBG_ASSERT( pTextPortion, "NULL-Pointer im Portioniterator in UpdateViews" );
ImpInitLayoutMode( pOutDev /*, pTextPortion->IsRightToLeft() */);
@@ -2205,7 +2205,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
if ( pTEParaPortion->GetNode()->GetText().Len() == 0 )
{
// schnelle Sonderbehandlung...
- if ( pTEParaPortion->GetTextPortions().Count() )
+ if ( !pTEParaPortion->GetTextPortions().empty() )
pTEParaPortion->GetTextPortions().Reset();
if ( !pTEParaPortion->GetLines().empty() )
{
@@ -2249,11 +2249,11 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
sal_uInt16 nEnd = nStart - nInvalidDiff; // neg.
bQuickFormat = sal_True;
sal_uInt16 nPos = 0;
- sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().Count();
+ sal_uInt16 nPortions = pTEParaPortion->GetTextPortions().size();
for ( sal_uInt16 nTP = 0; nTP < nPortions; nTP++ )
{
// Es darf kein Start/Ende im geloeschten Bereich liegen.
- TETextPortion* const pTP = pTEParaPortion->GetTextPortions().GetObject( nTP );
+ TETextPortion* const pTP = pTEParaPortion->GetTextPortions()[ nTP ];
nPos = nPos + pTP->GetLen();
if ( ( nPos > nStart ) && ( nPos < nEnd ) )
{
@@ -2325,10 +2325,10 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
sal_Bool bBrokenLine = sal_False;
bLineBreak = sal_False;
- while ( ( nTmpWidth <= nXWidth ) && !bEOL && ( nTmpPortion < pTEParaPortion->GetTextPortions().Count() ) )
+ while ( ( nTmpWidth <= nXWidth ) && !bEOL && ( nTmpPortion < pTEParaPortion->GetTextPortions().size() ) )
{
nPortionStart = nTmpPos;
- pPortion = pTEParaPortion->GetTextPortions().GetObject( nTmpPortion );
+ pPortion = pTEParaPortion->GetTextPortions()[ nTmpPortion ];
DBG_ASSERT( pPortion->GetLen(), "Leere Portion in CreateLines ?!" );
if ( pNode->GetText().GetChar( nTmpPos ) == '\t' )
{
@@ -2385,7 +2385,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
bEOL = sal_True;
pLine->SetEnd( nPortionEnd );
DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "Keine TextPortions?" );
- pLine->SetEndPortion( (sal_uInt16)pTEParaPortion->GetTextPortions().Count() - 1 );
+ pLine->SetEndPortion( (sal_uInt16)pTEParaPortion->GetTextPortions().size() - 1 );
}
if ( bFixedEnd )
@@ -2411,7 +2411,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
long nTextWidth = 0;
for ( sal_uInt16 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
{
- TETextPortion* pTextPortion = pTEParaPortion->GetTextPortions().GetObject( nTP );
+ TETextPortion* pTextPortion = pTEParaPortion->GetTextPortions()[ nTP ];
nTextWidth += pTextPortion->GetWidth();
}
long nSpace = mnMaxTextWidth - nTextWidth;
@@ -3068,11 +3068,11 @@ long TextEngine::ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uIn
for ( sal_uInt16 i = pLine->GetStartPortion(); i < nTextPortion; i++ )
{
- TETextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( i );
+ TETextPortion* pPortion = pParaPortion->GetTextPortions()[ i ];
nX += pPortion->GetWidth();
}
- TETextPortion* pDestPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion );
+ TETextPortion* pDestPortion = pParaPortion->GetTextPortions()[ nTextPortion ];
if ( pDestPortion->GetKind() != PORTIONKIND_TAB )
{
if ( !IsRightToLeft() && pDestPortion->GetRightToLeft() )
@@ -3081,7 +3081,7 @@ long TextEngine::ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uIn
sal_uInt16 nTmpPortion = nTextPortion+1;
while ( nTmpPortion <= pLine->GetEndPortion() )
{
- TETextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion );
+ TETextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[ nTmpPortion ];
if ( pNextTextPortion->GetRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) )
nX += pNextTextPortion->GetWidth();
else
@@ -3093,7 +3093,7 @@ long TextEngine::ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uIn
while ( nTmpPortion > pLine->GetStartPortion() )
{
--nTmpPortion;
- TETextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion );
+ TETextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[ nTmpPortion ];
if ( pPrevTextPortion->GetRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) )
nX -= pPrevTextPortion->GetWidth();
else
@@ -3106,7 +3106,7 @@ long TextEngine::ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uIn
sal_uInt16 nTmpPortion = nTextPortion+1;
while ( nTmpPortion <= pLine->GetEndPortion() )
{
- TETextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion );
+ TETextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[ nTmpPortion ];
if ( !pNextTextPortion->IsRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) )
nX += pNextTextPortion->GetWidth();
else
@@ -3118,7 +3118,7 @@ long TextEngine::ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uIn
while ( nTmpPortion > pLine->GetStartPortion() )
{
--nTmpPortion;
- TETextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion );
+ TETextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[ nTmpPortion ];
if ( !pPrevTextPortion->IsRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) )
nX -= pPrevTextPortion->GetWidth();
else
@@ -3161,7 +3161,7 @@ long TextEngine::ImpGetOutputOffset( sal_uLong nPara, TextLine* pLine, sal_uInt1
sal_uInt16 nPortionStart;
sal_uInt16 nPortion = pPortion->GetTextPortions().FindPortion( nIndex, nPortionStart, sal_True );
- TETextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( nPortion );
+ TETextPortion* pTextPortion = pPortion->GetTextPortions()[ nPortion ];
long nX;
diff --git a/svtools/source/edit/textview.cxx b/svtools/source/edit/textview.cxx
index 12e3e88..b30bbfc 100644
--- a/svtools/source/edit/textview.cxx
+++ b/svtools/source/edit/textview.cxx
@@ -1755,7 +1755,7 @@ void TextView::ImpShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sa
sal_uInt16 nTextPortionStart = 0;
sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, sal_True );
- TETextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion );
+ TETextPortion* pTextPortion = pParaPortion->GetTextPortions()[ nTextPortion ];
if ( pTextPortion->GetKind() == PORTIONKIND_TAB )
{
if ( mpImpl->mpTextEngine->IsRightToLeft() )
commit 276814402e499805354cb55cfcf2a0015a01fc8e
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 14:31:30 2012 +0200
Forgot to add destructors for my PTRARR_DEL conversions
Change-Id: I6312c7372f0787e308320c79e80504b195df6272
diff --git a/svtools/source/edit/textdat2.hxx b/svtools/source/edit/textdat2.hxx
index cdbff90..7806a9a 100644
--- a/svtools/source/edit/textdat2.hxx
+++ b/svtools/source/edit/textdat2.hxx
@@ -177,7 +177,14 @@ public:
inline sal_Bool operator != ( const TextLine& rLine ) const;
};
-typedef std::vector<TextLine*> TextLines;
+class TextLines : public std::vector<TextLine*> {
+public:
+ ~TextLines()
+ {
+ for( iterator it = begin(); it != end(); ++it )
+ delete *it;
+ }
+};
inline sal_Bool TextLine::operator == ( const TextLine& rLine ) const
{
diff --git a/svtools/source/edit/textdoc.hxx b/svtools/source/edit/textdoc.hxx
index d8d2255..17607a9 100644
--- a/svtools/source/edit/textdoc.hxx
+++ b/svtools/source/edit/textdoc.hxx
@@ -36,7 +36,14 @@
#include <tools/string.hxx>
#include <vector>
-typedef std::vector<TextCharAttrib*> TextCharAttribs;
+class TextCharAttribs : public std::vector<TextCharAttrib*> {
+public:
+ ~TextCharAttribs()
+ {
+ for( iterator it = begin(); it != end(); ++it )
+ delete *it;
+ }
+};
class TextCharAttribList : private TextCharAttribs
{
commit 52c8cec6daeb24a95e09e6435304cfbdc9fb0dac
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 14:11:21 2012 +0200
Convert SV_DECL_PTRARR_DEL(TextLines) to std::vector
Change-Id: I31d228d4f4a1165e38d95c16a8f6309cae410c70
diff --git a/svtools/source/edit/textdat2.hxx b/svtools/source/edit/textdat2.hxx
index c34f5ec..cdbff90 100644
--- a/svtools/source/edit/textdat2.hxx
+++ b/svtools/source/edit/textdat2.hxx
@@ -177,8 +177,7 @@ public:
inline sal_Bool operator != ( const TextLine& rLine ) const;
};
-typedef TextLine* TextLinePtr;
- SV_DECL_PTRARR_DEL( TextLines, TextLinePtr, 1 )
+typedef std::vector<TextLine*> TextLines;
inline sal_Bool TextLine::operator == ( const TextLine& rLine ) const
{
diff --git a/svtools/source/edit/textdata.cxx b/svtools/source/edit/textdata.cxx
index 6d61ee1..a5f9aa1 100644
--- a/svtools/source/edit/textdata.cxx
+++ b/svtools/source/edit/textdata.cxx
@@ -32,8 +32,6 @@
#include <tools/debug.hxx>
-SV_IMPL_PTRARR( TextLines, TextLinePtr );
-
// -------------------------------------------------------------------------
// (+) class TextSelection
@@ -186,9 +184,9 @@ void TEParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /*nEnd*/
sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, sal_Bool bInclEnd )
{
- for ( sal_uInt16 nLine = 0; nLine < maLines.Count(); nLine++ )
+ for ( sal_uInt16 nLine = 0; nLine < maLines.size(); nLine++ )
{
- TextLine* pLine = maLines.GetObject( nLine );
+ TextLine* pLine = maLines[ nLine ];
if ( ( bInclEnd && ( pLine->GetEnd() >= nChar ) ) ||
( pLine->GetEnd() > nChar ) )
{
@@ -199,13 +197,13 @@ sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, sal_Bool bInclEnd )
// Dann sollte es am Ende der letzten Zeile sein!
DBG_ASSERT( nChar == maLines[ maLines.Count() - 1 ]->GetEnd(), "Index voll daneben!" );
DBG_ASSERT( !bInclEnd, "Zeile nicht gefunden: FindLine" );
- return ( maLines.Count() - 1 );
+ return ( maLines.size() - 1 );
}
void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine )
{
- sal_uInt16 nLines = maLines.Count();
+ sal_uInt16 nLines = maLines.size();
DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Leere Portion?" );
if ( nLastFormattedLine < ( nLines - 1 ) )
{
diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index 9fc4de9..1a8d64b 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -65,6 +65,7 @@
#include <set>
#include <vector>
+#include <boost/foreach.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -283,7 +284,7 @@ String TextEngine::GetTextLines( LineEnd aSeparator ) const
{
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nP );
- sal_uInt16 nLines = pTEParaPortion->GetLines().Count();
+ sal_uInt16 nLines = pTEParaPortion->GetLines().size();
for ( sal_uInt16 nL = 0; nL < nLines; nL++ )
{
TextLine* pLine = pTEParaPortion->GetLines()[nL];
@@ -903,7 +904,7 @@ Rectangle TextEngine::PaMtoEditCursor( const TextPaM& rPaM, sal_Bool bSpecial )
for ( sal_uLong nPortion = 0; nPortion < rPaM.GetPara(); nPortion++ )
{
TEParaPortion* pPortion = mpTEParaPortions->GetObject(nPortion);
- nY += pPortion->GetLines().Count() * mnCharHeight;
+ nY += pPortion->GetLines().size() * mnCharHeight;
}
}
@@ -936,9 +937,9 @@ Rectangle TextEngine::GetEditCursor( const TextPaM& rPaM, sal_Bool bSpecial, sal
long nY = 0;
sal_uInt16 nCurIndex = 0;
TextLine* pLine = 0;
- for ( sal_uInt16 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
+ for ( sal_uInt16 nLine = 0; nLine < pPortion->GetLines().size(); nLine++ )
{
- TextLine* pTmpLine = pPortion->GetLines().GetObject( nLine );
+ TextLine* pTmpLine = pPortion->GetLines()[ nLine ];
if ( ( pTmpLine->GetStart() == rPaM.GetIndex() ) || ( pTmpLine->IsIn( rPaM.GetIndex(), bSpecial ) ) )
{
pLine = pTmpLine;
@@ -953,7 +954,7 @@ Rectangle TextEngine::GetEditCursor( const TextPaM& rPaM, sal_Bool bSpecial, sal
// Cursor am Ende des Absatzes.
DBG_ASSERT( rPaM.GetIndex() == nCurIndex, "Index voll daneben in GetEditCursor!" );
- pLine = pPortion->GetLines().GetObject( pPortion->GetLines().Count()-1 );
+ pLine = pPortion->GetLines().back();
nY -= mnCharHeight;
nCurIndex = nCurIndex - pLine->GetLen();
}
@@ -1088,7 +1089,7 @@ TextPaM TextEngine::GetPaM( const Point& rDocPos, sal_Bool bSmart )
for ( sal_uLong nPortion = 0; nPortion < mpTEParaPortions->Count(); nPortion++ )
{
TEParaPortion* pPortion = mpTEParaPortions->GetObject( nPortion );
- long nTmpHeight = pPortion->GetLines().Count() * mnCharHeight;
+ long nTmpHeight = pPortion->GetLines().size() * mnCharHeight;
nY += nTmpHeight;
if ( nY > rDocPos.Y() )
{
@@ -1118,9 +1119,9 @@ sal_uInt16 TextEngine::ImpFindIndex( sal_uLong nPortion, const Point& rPosInPara
long nY = 0;
TextLine* pLine = 0;
sal_uInt16 nLine;
- for ( nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
+ for ( nLine = 0; nLine < pPortion->GetLines().size(); nLine++ )
{
- TextLine* pTmpLine = pPortion->GetLines().GetObject( nLine );
+ TextLine* pTmpLine = pPortion->GetLines()[ nLine ];
nY += mnCharHeight;
if ( nY > rPosInPara.Y() ) // das war 'se
{
@@ -1133,7 +1134,7 @@ sal_uInt16 TextEngine::ImpFindIndex( sal_uLong nPortion, const Point& rPosInPara
nCurIndex = GetCharPos( nPortion, nLine, rPosInPara.X(), bSmart );
if ( nCurIndex && ( nCurIndex == pLine->GetEnd() ) &&
- ( pLine != pPortion->GetLines().GetObject( pPortion->GetLines().Count()-1) ) )
+ ( pLine != pPortion->GetLines().back() ) )
{
uno::Reference < i18n::XBreakIterator > xBI = GetBreakIterator();
sal_Int32 nCount = 1;
@@ -1146,7 +1147,7 @@ sal_uInt16 TextEngine::GetCharPos( sal_uLong nPortion, sal_uInt16 nLine, long nX
{
TEParaPortion* pPortion = mpTEParaPortions->GetObject( nPortion );
- TextLine* pLine = pPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pPortion->GetLines()[ nLine ];
sal_uInt16 nCurIndex = pLine->GetStart();
@@ -1206,10 +1207,10 @@ sal_uLong TextEngine::CalcTextWidth( sal_uLong nPara )
{
sal_uLong nParaWidth = 0;
TEParaPortion* pPortion = mpTEParaPortions->GetObject( nPara );
- for ( sal_uInt16 nLine = pPortion->GetLines().Count(); nLine; )
+ for ( sal_uInt16 nLine = pPortion->GetLines().size(); nLine; )
{
sal_uLong nLineWidth = 0;
- TextLine* pLine = pPortion->GetLines().GetObject( --nLine );
+ TextLine* pLine = pPortion->GetLines()[ --nLine ];
for ( sal_uInt16 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
{
TETextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( nTP );
@@ -1286,7 +1287,7 @@ sal_uInt16 TextEngine::GetLineCount( sal_uLong nParagraph ) const
TEParaPortion* pPPortion = mpTEParaPortions->GetObject( nParagraph );
if ( pPPortion )
- return pPPortion->GetLines().Count();
+ return pPPortion->GetLines().size();
return 0xFFFF;
}
@@ -1296,9 +1297,9 @@ sal_uInt16 TextEngine::GetLineLen( sal_uLong nParagraph, sal_uInt16 nLine ) cons
DBG_ASSERT( nParagraph < mpTEParaPortions->Count(), "GetLineCount: Out of range" );
TEParaPortion* pPPortion = mpTEParaPortions->GetObject( nParagraph );
- if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
+ if ( pPPortion && ( nLine < pPPortion->GetLines().size() ) )
{
- TextLine* pLine = pPPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pPPortion->GetLines()[ nLine ];
return pLine->GetLen();
}
@@ -1312,7 +1313,7 @@ sal_uLong TextEngine::CalcParaHeight( sal_uLong nParagraph ) const
TEParaPortion* pPPortion = mpTEParaPortions->GetObject( nParagraph );
DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetParaHeight" );
if ( pPPortion )
- nHeight = pPPortion->GetLines().Count() * mnCharHeight;
+ nHeight = pPPortion->GetLines().size() * mnCharHeight;
return nHeight;
}
@@ -1324,12 +1325,12 @@ void TextEngine::UpdateSelections()
Range TextEngine::GetInvalidYOffsets( sal_uLong nPortion )
{
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPortion );
- sal_uInt16 nLines = pTEParaPortion->GetLines().Count();
+ sal_uInt16 nLines = pTEParaPortion->GetLines().size();
sal_uInt16 nLastInvalid, nFirstInvalid = 0;
sal_uInt16 nLine;
for ( nLine = 0; nLine < nLines; nLine++ )
{
- TextLine* pL = pTEParaPortion->GetLines().GetObject( nLine );
+ TextLine* pL = pTEParaPortion->GetLines()[ nLine ];
if ( pL->IsInvalid() )
{
nFirstInvalid = nLine;
@@ -1339,7 +1340,7 @@ Range TextEngine::GetInvalidYOffsets( sal_uLong nPortion )
for ( nLastInvalid = nFirstInvalid; nLastInvalid < nLines; nLastInvalid++ )
{
- TextLine* pL = pTEParaPortion->GetLines().GetObject( nLine );
+ TextLine* pL = pTEParaPortion->GetLines()[ nLine ];
if ( pL->IsValid() )
break;
}
@@ -1637,7 +1638,7 @@ void TextEngine::FormatDoc()
maInvalidRec.Bottom() = nY + CalcParaHeight( nPara );
}
nY += CalcParaHeight( nPara );
- if ( !mbHasMultiLineParas && pTEParaPortion->GetLines().Count() > 1 )
+ if ( !mbHasMultiLineParas && pTEParaPortion->GetLines().size() > 1 )
mbHasMultiLineParas = sal_True;
}
@@ -1679,7 +1680,7 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uLong nPara )
TextLine* pTmpLine = new TextLine;
pTmpLine->SetStart( pNode->GetText().Len() );
pTmpLine->SetEnd( pTmpLine->GetStart() );
- pTEParaPortion->GetLines().Insert( pTmpLine, pTEParaPortion->GetLines().Count() );
+ pTEParaPortion->GetLines().push_back( pTmpLine );
if ( ImpGetAlign() == TXTALIGN_CENTER )
pTmpLine->SetStartX( (short)(mnMaxTextWidth / 2) );
@@ -2017,11 +2018,11 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan
// --------------------------------------------------
// Ueber die Zeilen des Absatzes...
// --------------------------------------------------
- sal_uInt16 nLines = pPortion->GetLines().Count();
+ sal_uInt16 nLines = pPortion->GetLines().size();
sal_uInt16 nIndex = 0;
for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
{
- TextLine* pLine = pPortion->GetLines().GetObject(nLine);
+ TextLine* pLine = pPortion->GetLines()[nLine];
Point aTmpPos( rStartPos.X() + pLine->GetStartX(), nY );
if ( ( !pPaintArea || ( ( nY + mnCharHeight ) > pPaintArea->Top() ) )
@@ -2196,7 +2197,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara );
DBG_ASSERT( pTEParaPortion->IsInvalid(), "CreateLines: Portion nicht invalid!" );
- sal_uInt16 nOldLineCount = pTEParaPortion->GetLines().Count();
+ sal_uInt16 nOldLineCount = pTEParaPortion->GetLines().size();
// ---------------------------------------------------------------
// Schnelle Sonderbehandlung fuer leere Absaetze...
@@ -2206,21 +2207,25 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
// schnelle Sonderbehandlung...
if ( pTEParaPortion->GetTextPortions().Count() )
pTEParaPortion->GetTextPortions().Reset();
- if ( pTEParaPortion->GetLines().Count() )
- pTEParaPortion->GetLines().DeleteAndDestroy( 0, pTEParaPortion->GetLines().Count() );
+ if ( !pTEParaPortion->GetLines().empty() )
+ {
+ BOOST_FOREACH(TextLine* pLine, pTEParaPortion->GetLines())
+ delete pLine;
+ pTEParaPortion->GetLines().clear();
+ }
CreateAndInsertEmptyLine( nPara );
pTEParaPortion->SetValid();
- return nOldLineCount != pTEParaPortion->GetLines().Count();
+ return nOldLineCount != pTEParaPortion->GetLines().size();
}
// ---------------------------------------------------------------
// Initialisierung......
// ---------------------------------------------------------------
- if ( pTEParaPortion->GetLines().Count() == 0 )
+ if ( pTEParaPortion->GetLines().empty() )
{
TextLine* pL = new TextLine;
- pTEParaPortion->GetLines().Insert( pL, 0 );
+ pTEParaPortion->GetLines().push_back( pL );
}
const short nInvalidDiff = pTEParaPortion->GetInvalidDiff();
@@ -2269,10 +2274,10 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
// Zeilen flaggen => nicht removen !
// ---------------------------------------------------------------
- sal_uInt16 nLine = pTEParaPortion->GetLines().Count()-1;
+ sal_uInt16 nLine = pTEParaPortion->GetLines().size()-1;
for ( sal_uInt16 nL = 0; nL <= nLine; nL++ )
{
- TextLine* pLine = pTEParaPortion->GetLines().GetObject( nL );
+ TextLine* pLine = pTEParaPortion->GetLines()[ nL ];
if ( pLine->GetEnd() > nInvalidStart )
{
nLine = nL;
@@ -2285,7 +2290,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
if ( nLine && ( !pTEParaPortion->IsSimpleInvalid() || ( nInvalidEnd < pNode->GetText().Len() ) || ( nInvalidDiff <= 0 ) ) )
nLine--;
- TextLine* pLine = pTEParaPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pTEParaPortion->GetLines()[ nLine ];
// ---------------------------------------------------------------
// Ab hier alle Zeilen durchformatieren...
@@ -2484,8 +2489,8 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
// Naechste Zeile oder ggf. neue Zeile....
pLine = 0;
- if ( nLine < pTEParaPortion->GetLines().Count()-1 )
- pLine = pTEParaPortion->GetLines().GetObject( ++nLine );
+ if ( nLine < pTEParaPortion->GetLines().size()-1 )
+ pLine = pTEParaPortion->GetLines()[ ++nLine ];
if ( pLine && ( nIndex >= pNode->GetText().Len() ) )
{
nDelFromLine = nLine;
@@ -2494,7 +2499,7 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
if ( !pLine && ( nIndex < pNode->GetText().Len() ) )
{
pLine = new TextLine;
- pTEParaPortion->GetLines().Insert( pLine, ++nLine );
+ pTEParaPortion->GetLines().insert( pTEParaPortion->GetLines().begin() + ++nLine, pLine );
}
if ( pLine )
{
@@ -2507,16 +2512,20 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
} // while ( Index < Len )
if ( nDelFromLine != 0xFFFF )
- pTEParaPortion->GetLines().DeleteAndDestroy( nDelFromLine, pTEParaPortion->GetLines().Count() - nDelFromLine );
+ for( TextLines::iterator it = pTEParaPortion->GetLines().begin() + nDelFromLine;
+ it != pTEParaPortion->GetLines().end(); ++it )
+ delete *it;
+ pTEParaPortion->GetLines().erase( pTEParaPortion->GetLines().begin() + nDelFromLine,
+ pTEParaPortion->GetLines().end() );
- DBG_ASSERT( pTEParaPortion->GetLines().Count(), "Keine Zeile nach CreateLines!" );
+ DBG_ASSERT( pTEParaPortion->GetLines().size(), "Keine Zeile nach CreateLines!" );
if ( bLineBreak == sal_True )
CreateAndInsertEmptyLine( nPara );
pTEParaPortion->SetValid();
- return nOldLineCount != pTEParaPortion->GetLines().Count();
+ return nOldLineCount != pTEParaPortion->GetLines().size();
}
String TextEngine::GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord )
diff --git a/svtools/source/edit/textview.cxx b/svtools/source/edit/textview.cxx
index 75dbb5f..12e3e88 100644
--- a/svtools/source/edit/textview.cxx
+++ b/svtools/source/edit/textview.cxx
@@ -424,7 +424,7 @@ void TextView::ImpHighlight( const TextSelection& rSel )
{
TEParaPortion* pTEParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( nPara );
sal_uInt16 nStartLine = 0;
- sal_uInt16 nEndLine = pTEParaPortion->GetLines().Count() -1;
+ sal_uInt16 nEndLine = pTEParaPortion->GetLines().size() -1;
if ( nPara == nStartPara )
nStartLine = pTEParaPortion->GetLineNumber( aSel.GetStart().GetIndex(), sal_False );
if ( nPara == nEndPara )
@@ -433,7 +433,7 @@ void TextView::ImpHighlight( const TextSelection& rSel )
// ueber die Zeilen iterieren....
for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ )
{
- TextLine* pLine = pTEParaPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pTEParaPortion->GetLines()[ nLine ];
sal_uInt16 nStartIndex = pLine->GetStart();
sal_uInt16 nEndIndex = pLine->GetEnd();
if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) )
@@ -1032,7 +1032,7 @@ void TextView::Command( const CommandEvent& rCEvt )
TEParaPortion* pParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
sal_uInt16 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex(), sal_True );
- TextLine* pLine = pParaPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pParaPortion->GetLines()[ nLine ];
if ( pLine && ( nInputEnd > pLine->GetEnd() ) )
nInputEnd = pLine->GetEnd();
Rectangle aR2 = mpImpl->mpTextEngine->PaMtoEditCursor( TextPaM( aPaM.GetPara(), nInputEnd ) );
@@ -1571,7 +1571,7 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM )
// Wenn davor eine autom.Umgebrochene Zeile, und ich muss genau an das
// Ende dieser Zeile, landet der Cursor in der aktuellen Zeile am Anfang
// Siehe Problem: Letztes Zeichen einer autom.umgebr. Zeile = Cursor
- TextLine* pLine = pPPortion->GetLines().GetObject( nLine - 1 );
+ TextLine* pLine = pPPortion->GetLines()[ nLine - 1 ];
if ( aPaM.GetIndex() && ( aPaM.GetIndex() == pLine->GetEnd() ) )
aPaM.GetIndex()--;
}
@@ -1579,7 +1579,7 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM )
{
aPaM.GetPara()--;
pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
- sal_uInt16 nL = pPPortion->GetLines().Count() - 1;
+ sal_uInt16 nL = pPPortion->GetLines().size() - 1;
sal_uInt16 nCharPos = mpImpl->mpTextEngine->GetCharPos( aPaM.GetPara(), nL, nX+1 );
aPaM.GetIndex() = nCharPos;
}
@@ -1602,13 +1602,13 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM )
TEParaPortion* pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( rPaM.GetPara() );
sal_uInt16 nLine = pPPortion->GetLineNumber( rPaM.GetIndex(), sal_False );
- if ( nLine < ( pPPortion->GetLines().Count() - 1 ) )
+ if ( nLine < ( pPPortion->GetLines().size() - 1 ) )
{
sal_uInt16 nCharPos = mpImpl->mpTextEngine->GetCharPos( rPaM.GetPara(), nLine+1, nX );
aPaM.GetIndex() = nCharPos;
// Sonderbehandlung siehe CursorUp...
- TextLine* pLine = pPPortion->GetLines().GetObject( nLine + 1 );
+ TextLine* pLine = pPPortion->GetLines()[ nLine + 1 ];
if ( ( aPaM.GetIndex() == pLine->GetEnd() ) && ( aPaM.GetIndex() > pLine->GetStart() ) && aPaM.GetIndex() < pPPortion->GetNode()->GetText().Len() )
aPaM.GetIndex()--;
}
@@ -1618,8 +1618,8 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM )
pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
sal_uInt16 nCharPos = mpImpl->mpTextEngine->GetCharPos( aPaM.GetPara(), 0, nX+1 );
aPaM.GetIndex() = nCharPos;
- TextLine* pLine = pPPortion->GetLines().GetObject( 0 );
- if ( ( aPaM.GetIndex() == pLine->GetEnd() ) && ( aPaM.GetIndex() > pLine->GetStart() ) && ( pPPortion->GetLines().Count() > 1 ) )
+ TextLine* pLine = pPPortion->GetLines().front();
+ if ( ( aPaM.GetIndex() == pLine->GetEnd() ) && ( aPaM.GetIndex() > pLine->GetStart() ) && ( pPPortion->GetLines().size() > 1 ) )
aPaM.GetIndex()--;
}
@@ -1632,7 +1632,7 @@ TextPaM TextView::CursorStartOfLine( const TextPaM& rPaM )
TEParaPortion* pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( rPaM.GetPara() );
sal_uInt16 nLine = pPPortion->GetLineNumber( aPaM.GetIndex(), sal_False );
- TextLine* pLine = pPPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine->GetStart();
return aPaM;
@@ -1644,7 +1644,7 @@ TextPaM TextView::CursorEndOfLine( const TextPaM& rPaM )
TEParaPortion* pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( rPaM.GetPara() );
sal_uInt16 nLine = pPPortion->GetLineNumber( aPaM.GetIndex(), sal_False );
- TextLine* pLine = pPPortion->GetLines().GetObject( nLine );
+ TextLine* pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine->GetEnd();
if ( pLine->GetEnd() > pLine->GetStart() ) // Leerzeile
commit 341e6fba343bd90a8d2572b23a4c0b03141ef7f6
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 13:05:19 2012 +0200
Convert SV_DECL_PTRARR_DEL(TextCharAttribs) to std::vector
I couldn't use boost::ptr_vector because it sometimes removes
without free'ing
Change-Id: Ia12f66c708ef27757d7527ebe80edf7a9c7a59c2
diff --git a/svtools/source/edit/textdoc.cxx b/svtools/source/edit/textdoc.cxx
index eadeefb..5ca9997 100644
--- a/svtools/source/edit/textdoc.cxx
+++ b/svtools/source/edit/textdoc.cxx
@@ -30,21 +30,13 @@
#include <stdlib.h>
-SV_IMPL_PTRARR( TextCharAttribs, TextCharAttribPtr );
-
// Vergleichmethode wird von QuickSort gerufen...
-extern "C" {
-int SAL_CALL CompareStart( const void* pFirst, const void* pSecond )
+static bool CompareStart( const TextCharAttrib* pFirst, const TextCharAttrib* pSecond )
{
- if ( (*((TextCharAttrib**)pFirst))->GetStart() < (*((TextCharAttrib**)pSecond))->GetStart() )
- return (-1);
- else if ( (*((TextCharAttrib**)pFirst))->GetStart() > (*((TextCharAttrib**)pSecond))->GetStart() )
- return (1);
- return 0;
-}
+ return pFirst->GetStart() < pSecond->GetStart();
}
// -------------------------------------------------------------------------
@@ -86,9 +78,9 @@ TextCharAttribList::~TextCharAttribList()
void TextCharAttribList::Clear( sal_Bool bDestroyAttribs )
{
if ( bDestroyAttribs )
- TextCharAttribs::DeleteAndDestroy( 0, Count() );
- else
- TextCharAttribs::Remove( 0, Count() );
+ for(iterator it = begin(); it != end(); ++it)
+ delete *it;
+ TextCharAttribs::clear();
}
@@ -97,27 +89,27 @@ void TextCharAttribList::InsertAttrib( TextCharAttrib* pAttrib )
if ( pAttrib->IsEmpty() )
mbHasEmptyAttribs = sal_True;
- const sal_uInt16 nCount = Count();
+ const sal_uInt16 nCount = size();
const sal_uInt16 nStart = pAttrib->GetStart(); // vielleicht besser fuer Comp.Opt.
sal_Bool bInserted = sal_False;
for ( sal_uInt16 x = 0; x < nCount; x++ )
{
- TextCharAttrib* pCurAttrib = GetObject( x );
+ TextCharAttrib* pCurAttrib = GetAttrib( x );
if ( pCurAttrib->GetStart() > nStart )
{
- Insert( pAttrib, x );
+ insert( begin() + x, pAttrib );
bInserted = sal_True;
break;
}
}
if ( !bInserted )
- Insert( pAttrib, nCount );
+ push_back( pAttrib );
}
void TextCharAttribList::ResortAttribs()
{
- if ( Count() )
- qsort( (void*)GetData(), Count(), sizeof( TextCharAttrib* ), CompareStart );
+ if ( !empty() )
+ std::sort( begin(), end(), CompareStart );
}
TextCharAttrib* TextCharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
@@ -125,9 +117,9 @@ TextCharAttrib* TextCharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nP
// Rueckwaerts, falls eins dort endet, das naechste startet.
// => Das startende gilt...
- for ( sal_uInt16 nAttr = Count(); nAttr; )
+ for ( sal_uInt16 nAttr = size(); nAttr; )
{
- TextCharAttrib* pAttr = GetObject( --nAttr );
+ TextCharAttrib* pAttr = GetAttrib( --nAttr );
if ( pAttr->GetEnd() < nPos )
return 0;
@@ -141,10 +133,10 @@ TextCharAttrib* TextCharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nP
TextCharAttrib* TextCharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos, sal_uInt16 nMaxPos ) const
{
DBG_ASSERT( nWhich, "FindNextAttrib: Which?" );
- const sal_uInt16 nAttribs = Count();
+ const sal_uInt16 nAttribs = size();
for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
{
- TextCharAttrib* pAttr = GetObject( nAttr );
+ TextCharAttrib* pAttr = GetAttrib( nAttr );
if ( ( pAttr->GetStart() >= nFromPos ) &&
( pAttr->GetEnd() <= nMaxPos ) &&
( pAttr->Which() == nWhich ) )
@@ -155,9 +147,9 @@ TextCharAttrib* TextCharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uInt1
sal_Bool TextCharAttribList::HasAttrib( sal_uInt16 nWhich ) const
{
- for ( sal_uInt16 nAttr = Count(); nAttr; )
+ for ( sal_uInt16 nAttr = size(); nAttr; )
{
- const TextCharAttrib* pAttr = GetObject( --nAttr );
+ const TextCharAttrib* pAttr = GetAttrib( --nAttr );
if ( pAttr->Which() == nWhich )
return sal_True;
}
@@ -168,9 +160,9 @@ sal_Bool TextCharAttribList::HasBoundingAttrib( sal_uInt16 nBound )
{
// Rueckwaerts, falls eins dort endet, das naechste startet.
// => Das startende gilt...
- for ( sal_uInt16 nAttr = Count(); nAttr; )
+ for ( sal_uInt16 nAttr = size(); nAttr; )
{
- TextCharAttrib* pAttr = GetObject( --nAttr );
+ TextCharAttrib* pAttr = GetAttrib( --nAttr );
if ( pAttr->GetEnd() < nBound )
return sal_False;
@@ -186,10 +178,10 @@ TextCharAttrib* TextCharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt
if ( !mbHasEmptyAttribs )
return 0;
- const sal_uInt16 nAttribs = Count();
+ const sal_uInt16 nAttribs = size();
for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
{
- TextCharAttrib* pAttr = GetObject( nAttr );
+ TextCharAttrib* pAttr = GetAttrib( nAttr );
if ( pAttr->GetStart() > nPos )
return 0;
@@ -201,12 +193,12 @@ TextCharAttrib* TextCharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt
void TextCharAttribList::DeleteEmptyAttribs()
{
- for ( sal_uInt16 nAttr = 0; nAttr < Count(); nAttr++ )
+ for ( sal_uInt16 nAttr = 0; nAttr < size(); nAttr++ )
{
- TextCharAttrib* pAttr = GetObject( nAttr );
+ TextCharAttrib* pAttr = GetAttrib( nAttr );
if ( pAttr->IsEmpty() )
{
- Remove( nAttr );
+ erase( begin() + nAttr );
delete pAttr;
nAttr--;
}
diff --git a/svtools/source/edit/textdoc.hxx b/svtools/source/edit/textdoc.hxx
index 9fb6b41..d8d2255 100644
--- a/svtools/source/edit/textdoc.hxx
+++ b/svtools/source/edit/textdoc.hxx
@@ -34,9 +34,9 @@
#include <svtools/txtattr.hxx>
#include <tools/string.hxx>
+#include <vector>
-typedef TextCharAttrib* TextCharAttribPtr;
-SV_DECL_PTRARR_DEL( TextCharAttribs, TextCharAttribPtr, 0 )
+typedef std::vector<TextCharAttrib*> TextCharAttribs;
class TextCharAttribList : private TextCharAttribs
{
@@ -50,10 +50,10 @@ public:
~TextCharAttribList();
void Clear( sal_Bool bDestroyAttribs );
- sal_uInt16 Count() const { return TextCharAttribs::Count(); }
+ sal_uInt16 Count() const { return TextCharAttribs::size(); }
- TextCharAttrib* GetAttrib( sal_uInt16 n ) const { return TextCharAttribs::GetObject( n ); }
- void RemoveAttrib( sal_uInt16 n ) { TextCharAttribs::Remove( n, 1 ); }
+ TextCharAttrib* GetAttrib( sal_uInt16 n ) const { return TextCharAttribs::operator[]( n ); }
+ void RemoveAttrib( sal_uInt16 n ) { TextCharAttribs::erase( begin() + n ); }
void InsertAttrib( TextCharAttrib* pAttrib );
commit 3ca66ea9f38670e1c491e8a2063c2867afb12d39
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 12:23:29 2012 +0200
Convert SV_DECL_PTRARR(TextViews) to std::vector
Change-Id: Icd79dec8c77fc13cf82c66a2d64ca2325eaa66ab
diff --git a/svtools/inc/svtools/texteng.hxx b/svtools/inc/svtools/texteng.hxx
index ab897b2..b20a01b 100644
--- a/svtools/inc/svtools/texteng.hxx
+++ b/svtools/inc/svtools/texteng.hxx
@@ -34,7 +34,6 @@ class TextDoc;
class TextView;
class TextPaM;
class TextSelection;
-class TextViews;
class TEParaPortions;
class TextAttrib;
class TextCharAttrib;
@@ -80,6 +79,8 @@ class LocaleDataWrapper;
enum TxtAlign { TXTALIGN_LEFT, TXTALIGN_CENTER, TXTALIGN_RIGHT };
+typedef std::vector<TextView*> TextViews;
+
class SVT_DLLPUBLIC TextEngine : public SfxBroadcaster
{
friend class TextView;
diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index fa62f3f..9fc4de9 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -70,9 +70,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::rtl;
-typedef TextView* TextViewPtr;
-SV_DECL_PTRARR( TextViews, TextViewPtr, 0 )
-
// -------------------------------------------------------------------------
// (-) class TextEngine
@@ -140,7 +137,7 @@ TextEngine::~TextEngine()
void TextEngine::InsertView( TextView* pTextView )
{
- mpViews->Insert( pTextView, mpViews->Count() );
+ mpViews->push_back( pTextView );
pTextView->SetSelection( TextSelection() );
if ( !GetActiveView() )
@@ -149,11 +146,11 @@ void TextEngine::InsertView( TextView* pTextView )
void TextEngine::RemoveView( TextView* pTextView )
{
- sal_uInt16 nPos = mpViews->GetPos( pTextView );
- if( nPos != USHRT_MAX )
+ TextViews::iterator it = std::find( mpViews->begin(), mpViews->end(), pTextView );
+ if( it != mpViews->end() )
{
pTextView->HideCursor();
- mpViews->Remove( nPos, 1 );
+ mpViews->erase( it );
if ( pTextView == GetActiveView() )
SetActiveView( 0 );
}
@@ -161,12 +158,12 @@ void TextEngine::RemoveView( TextView* pTextView )
sal_uInt16 TextEngine::GetViewCount() const
{
- return mpViews->Count();
+ return mpViews->size();
}
TextView* TextEngine::GetView( sal_uInt16 nView ) const
{
- return mpViews->GetObject( nView );
+ return (*mpViews)[ nView ];
}
TextView* TextEngine::GetActiveView() const
@@ -227,9 +224,9 @@ void TextEngine::SetFont( const Font& rFont )
FormatFullDoc();
UpdateViews();
- for ( sal_uInt16 nView = mpViews->Count(); nView; )
+ for ( sal_uInt16 nView = mpViews->size(); nView; )
{
- TextView* pView = mpViews->GetObject( --nView );
+ TextView* pView = (*mpViews)[ --nView ];
pView->GetWindow()->SetInputContext( InputContext( GetFont(), !pView->IsReadOnly() ? INPUTCONTEXT_TEXT|INPUTCONTEXT_EXTTEXTINPUT : 0 ) );
}
}
@@ -450,9 +447,9 @@ void TextEngine::ImpRemoveText()
TextPaM aStartPaM( 0, 0 );
TextSelection aEmptySel( aStartPaM, aStartPaM );
- for ( sal_uInt16 nView = 0; nView < mpViews->Count(); nView++ )
+ for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ )
{
- TextView* pView = mpViews->GetObject( nView );
+ TextView* pView = (*mpViews)[ nView ];
pView->ImpSetSelection( aEmptySel );
}
ResetUndo();
@@ -473,9 +470,9 @@ void TextEngine::SetText( const XubString& rText )
if ( rText.Len() )
aPaM = ImpInsertText( aEmptySel, rText );
- for ( sal_uInt16 nView = 0; nView < mpViews->Count(); nView++ )
+ for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ )
{
- TextView* pView = mpViews->GetObject( nView );
+ TextView* pView = (*mpViews)[ nView ];
pView->ImpSetSelection( aEmptySel );
// Wenn kein Text, dann auch Kein Format&Update
@@ -1530,9 +1527,9 @@ void TextEngine::UpdateViews( TextView* pCurView )
DBG_ASSERT( IsFormatted(), "UpdateViews: Doc nicht formatiert!" );
- for ( sal_uInt16 nView = 0; nView < mpViews->Count(); nView++ )
+ for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ )
{
- TextView* pView = mpViews->GetObject( nView );
+ TextView* pView = (*mpViews)[ nView ];
pView->HideCursor();
Rectangle aClipRec( maInvalidRec );
@@ -2812,11 +2809,11 @@ void TextEngine::ImpParagraphInserted( sal_uLong nPara )
{
// Die aktive View braucht nicht angepasst werden, aber bei allen
// passiven muss die Selektion angepasst werden:
- if ( mpViews->Count() > 1 )
+ if ( mpViews->size() > 1 )
{
- for ( sal_uInt16 nView = mpViews->Count(); nView; )
+ for ( sal_uInt16 nView = mpViews->size(); nView; )
{
- TextView* pView = mpViews->GetObject( --nView );
+ TextView* pView = (*mpViews)[ --nView ];
if ( pView != GetActiveView() )
{
for ( int n = 0; n <= 1; n++ )
@@ -2833,11 +2830,11 @@ void TextEngine::ImpParagraphInserted( sal_uLong nPara )
void TextEngine::ImpParagraphRemoved( sal_uLong nPara )
{
- if ( mpViews->Count() > 1 )
+ if ( mpViews->size() > 1 )
{
- for ( sal_uInt16 nView = mpViews->Count(); nView; )
+ for ( sal_uInt16 nView = mpViews->size(); nView; )
{
- TextView* pView = mpViews->GetObject( --nView );
+ TextView* pView = (*mpViews)[ --nView ];
if ( pView != GetActiveView() )
{
sal_uLong nParas = mpDoc->GetNodes().Count();
@@ -2861,11 +2858,11 @@ void TextEngine::ImpParagraphRemoved( sal_uLong nPara )
void TextEngine::ImpCharsRemoved( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars )
{
- if ( mpViews->Count() > 1 )
+ if ( mpViews->size() > 1 )
{
- for ( sal_uInt16 nView = mpViews->Count(); nView; )
+ for ( sal_uInt16 nView = mpViews->size(); nView; )
{
- TextView* pView = mpViews->GetObject( --nView );
+ TextView* pView = (*mpViews)[ --nView ];
if ( pView != GetActiveView() )
{
sal_uInt16 nEnd = nPos+nChars;
@@ -2888,11 +2885,11 @@ void TextEngine::ImpCharsRemoved( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 n
void TextEngine::ImpCharsInserted( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars )
{
- if ( mpViews->Count() > 1 )
+ if ( mpViews->size() > 1 )
{
- for ( sal_uInt16 nView = mpViews->Count(); nView; )
+ for ( sal_uInt16 nView = mpViews->size(); nView; )
{
- TextView* pView = mpViews->GetObject( --nView );
+ TextView* pView = (*mpViews)[ --nView ];
if ( pView != GetActiveView() )
{
for ( int n = 0; n <= 1; n++ )
commit c70f358f89ea2aa08bacfc2a8ae56a4e86d84bd3
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat Jun 2 12:00:20 2012 +0200
Convert SV_DECL_PTRARR(SfxItemDesruptorList_Impl) to std::vector
Change-Id: I790bd9c17139fb03094b1e952e4c4ee61172f22f
diff --git a/svtools/source/misc/itemdel.cxx b/svtools/source/misc/itemdel.cxx
index 36b3f06..4d60877 100644
--- a/svtools/source/misc/itemdel.cxx
+++ b/svtools/source/misc/itemdel.cxx
@@ -31,6 +31,7 @@
#include <vcl/svapp.hxx>
#include <tools/errcode.hxx>
#include <limits.h>
+#include <vector>
#include <svl/svarray.hxx>
#include <svl/itempool.hxx>
@@ -55,7 +56,7 @@ public:
~SfxItemDesruptor_Impl();
};
-SV_DECL_PTRARR( SfxItemDesruptorList_Impl, SfxItemDesruptor_Impl*, 4 )
+typedef std::vector<SfxItemDesruptor_Impl*> SfxItemDesruptorList_Impl;
static SfxItemDesruptorList_Impl *pItemDesruptList = NULL;
@@ -76,8 +77,8 @@ SfxItemDesruptor_Impl::SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ):
SfxItemDesruptorList_Impl* &rpList = pItemDesruptList;
if ( !rpList )
rpList = new SfxItemDesruptorList_Impl;
- const SfxItemDesruptor_Impl *pThis = this;
- rpList->Insert( pThis, rpList->Count() );
+ SfxItemDesruptor_Impl *pThis = this;
+ rpList->push_back( pThis );
}
// ------------------------------------------------------------------------
@@ -93,7 +94,7 @@ SfxItemDesruptor_Impl::~SfxItemDesruptor_Impl()
DBG_ASSERT( rpList, "no DesruptorList" );
const SfxItemDesruptor_Impl *pThis = this;
if ( rpList ) HACK(warum?)
- rpList->Remove( rpList->GetPos(pThis) );
+ rpList->erase( std::find( rpList->begin(), rpList->end(), pThis ) );
// reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
pItem->SetRefCount( 0 );
commit 306fe606587153fe619f99bb06e1b4d402cb26f7
Author: Noel Grandin <noel at peralex.com>
Date: Wed Jun 6 14:53:38 2012 +0200
Convert SV_DECL_PTRARR( SvLinkSources) to std::set
Used a std::set because the code was enforcing uniqueness.
Change-Id: Ie9243ed17b1165b6a371d0ff2f1a856186697ba3
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 9125e8a..21d673d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -377,8 +377,9 @@ ScDocument::~ScDocument()
if ( GetLinkManager() )
{
// BaseLinks freigeben
- for ( sal_uInt16 n = pLinkManager->GetServers().Count(); n; )
- pLinkManager->GetServers()[ --n ]->Closed();
+ ::sfx2::SvLinkSources aTemp(pLinkManager->GetServers());
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it )
+ (*it)->Closed();
if ( pLinkManager->GetLinks().Count() )
pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() );
diff --git a/sfx2/inc/sfx2/linkmgr.hxx b/sfx2/inc/sfx2/linkmgr.hxx
index 544c782..f9fd7d5 100644
--- a/sfx2/inc/sfx2/linkmgr.hxx
+++ b/sfx2/inc/sfx2/linkmgr.hxx
@@ -35,6 +35,7 @@
#include <svl/svarray.hxx>
#include <vector>
+#include <set>
class SfxObjectShell;
class Graphic;
@@ -59,8 +60,7 @@ class SvBaseLinkRef;
typedef SvBaseLinkRef* SvBaseLinkRefPtr;
SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1 )
-typedef SvLinkSource* SvLinkSourcePtr;
-SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1 )
+typedef std::set<SvLinkSource*> SvLinkSources;
class SFX2_DLLPUBLIC LinkManager
{
@@ -162,9 +162,7 @@ public:
const SvLinkSources& GetServers() const { return aServerTbl; }
// Link register/delete
sal_Bool InsertServer( SvLinkSource* rObj );
- void RemoveServer( SvLinkSource* rObj );
- void RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 )
- { aServerTbl.Remove( nPos, nCnt ); }
+ void RemoveServer( SvLinkSource* rObj );
// A transfer is aborted, so cancel all download media
// (for the time beeing this is only of interest for the FileLinks!)
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index daec440..663e98e 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -387,19 +387,16 @@ SvLinkSourceRef LinkManager::CreateObj( SvBaseLink * pLink )
sal_Bool LinkManager::InsertServer( SvLinkSource* pObj )
{
// no duplicate inserts
- if( !pObj || USHRT_MAX != aServerTbl.GetPos( pObj ) )
+ if( !pObj )
return sal_False;
- aServerTbl.Insert( pObj, aServerTbl.Count() );
- return sal_True;
+ return aServerTbl.insert( pObj ).second;
}
void LinkManager::RemoveServer( SvLinkSource* pObj )
{
- sal_uInt16 nPos = aServerTbl.GetPos( pObj );
- if( USHRT_MAX != nPos )
- aServerTbl.Remove( nPos, 1 );
+ aServerTbl.erase( pObj );
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 3ed8f0a..2d3e7c1 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -511,8 +511,10 @@ SwDoc::~SwDoc()
// Release the BaseLinks
{
- for( sal_uInt16 n = pLinkMgr->GetServers().Count(); n; )
- pLinkMgr->GetServers()[ --n ]->Closed();
+ ::sfx2::SvLinkSources aTemp(pLinkMgr->GetServers());
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin();
+ it != aTemp.end(); ++it )
+ (*it)->Closed();
if( pLinkMgr->GetLinks().Count() )
pLinkMgr->Remove( 0, pLinkMgr->GetLinks().Count() );
diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx
index 1445b27..167a607 100644
--- a/sw/source/core/doc/swserv.cxx
+++ b/sw/source/core/doc/swserv.cxx
@@ -327,9 +327,10 @@ SwDataChanged::~SwDataChanged()
{
const ::sfx2::SvLinkSources& rServers = pDoc->GetLinkManager().GetServers();
- for( sal_uInt16 nCnt = rServers.Count(); nCnt; )
+ ::sfx2::SvLinkSources aTemp(rServers);
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it )
{
- ::sfx2::SvLinkSourceRef refObj( rServers[ --nCnt ] );
+ ::sfx2::SvLinkSourceRef refObj( *it );
// Any one else interested in the Object?
if( refObj->HasDataLinks() && refObj->ISA( SwServerObject ))
{
@@ -344,9 +345,7 @@ SwDataChanged::~SwDataChanged()
if( !refObj->HasDataLinks() )
{
// Then remove from the list
- // Object is not destroyed, if it still is there!
- if( nCnt < rServers.Count() && &refObj == rServers[ nCnt ] )
- pDoc->GetLinkManager().RemoveServer( nCnt, 1 );
+ pDoc->GetLinkManager().RemoveServer( *it );
}
}
}
commit 2186e7cbb03be308c1b02fae881e5e64d3afc36e
Author: Noel Grandin <noel at peralex.com>
Date: Tue Jun 5 11:45:19 2012 +0200
Convert SV_DECL_PTRARR_DEL(SfxItemPtrArray) to std::map
- Convert it to a map because that is a more natural structure
given how it's accessing the data
- Cleanup an old typedef alias that doesn't seem to be used anymore.
Change-Id: I46816d7270d165ddde381af0639169aaf009a16b
diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx
index 5aa01d9..e2b9607 100644
--- a/sfx2/inc/sfx2/dispatch.hxx
+++ b/sfx2/inc/sfx2/dispatch.hxx
@@ -36,6 +36,7 @@
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
+#include <map>
class SfxSlotServer;
class SfxShell;
@@ -72,11 +73,16 @@ namespace com
//=========================================================================
-typedef SfxPoolItem* SfxPoolItemPtr;
-SV_DECL_PTRARR_DEL( SfxItemPtrArray, SfxPoolItemPtr, 4 )
-
-// fuer shell.cxx
-typedef SfxItemPtrArray SfxItemArray_Impl;
+// Maps the Which() field to a pointer to a SfxPoolItem
+class SfxItemPtrMap : public std::map<sal_uInt16, SfxPoolItem*>
+{
+public:
+ ~SfxItemPtrMap()
+ {
+ for(iterator it = begin(); it != end(); ++it)
+ delete it->second;
+ }
+};
class SFX2_DLLPUBLIC SfxDispatcher
{
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 676e028..1e1bd68 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -76,7 +76,6 @@ DBG_NAME(SfxDispatcherFillState)
typedef boost::ptr_vector<SfxRequest> SfxRequestPtrArray;
-SV_IMPL_PTRARR( SfxItemPtrArray, SfxPoolItemPtr );
DECL_PTRSTACK(SfxShellStack_Impl, SfxShell*, 8, 4 );
struct SfxToDo_Impl
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 5ba4ad6..838c59a 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -79,7 +79,7 @@ using namespace com::sun::star;
struct SfxShell_Impl: public SfxBroadcaster
{
String aObjectName; // Name of Sbx-Objects
- SfxItemArray_Impl aItems; // Data exchange on Item level
+ SfxItemPtrMap aItems; // Data exchange on Item level
SfxViewShell* pViewSh; // SfxViewShell if Shell is
// ViewFrame/ViewShell/SubShell list
SfxViewFrame* pFrame; // Frame, if <UI-active>
@@ -305,9 +305,9 @@ const SfxPoolItem* SfxShell::GetItem
*/
{
- for ( sal_uInt16 nPos = 0; nPos < pImp->aItems.Count(); ++nPos )
- if ( pImp->aItems.GetObject(nPos)->Which() == nSlotId )
- return pImp->aItems.GetObject(nPos);
+ SfxItemPtrMap::iterator it = pImp->aItems.find( nSlotId );
+ if( it != pImp->aItems.end() )
+ return it->second;
return 0;
}
@@ -340,40 +340,39 @@ void SfxShell::PutItem
"items with Which-Ids aren't allowed here" );
// MSC made a mess here of WNT/W95, beware of changes
- const SfxPoolItem *pItem = rItem.Clone();
- SfxPoolItemHint aItemHint( (SfxPoolItem*) pItem );
+ SfxPoolItem *pItem = rItem.Clone();
+ SfxPoolItemHint aItemHint( pItem );
const sal_uInt16 nWhich = rItem.Which();
- SfxPoolItem **ppLoopItem = (SfxPoolItem**) pImp->aItems.GetData();
- sal_uInt16 nPos;
- for ( nPos = 0; nPos < pImp->aItems.Count(); ++nPos, ++ppLoopItem )
+
+ SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich );
+ if( it != pImp->aItems.end() )
{
- if ( (*ppLoopItem)->Which() == nWhich )
+ SfxPoolItem *pLoopItem = it->second;
+ // Replace Item
+ delete pLoopItem;
+ it->second = pItem;
+
+ // if active, notify Bindings
+ SfxDispatcher *pDispat = GetDispatcher();
+ if ( pDispat )
{
- // Replace Item
- delete *ppLoopItem;
- pImp->aItems.Remove(nPos);
- pImp->aItems.Insert( (SfxPoolItemPtr) pItem, nPos );
-
- // if active, notify Bindings
- SfxDispatcher *pDispat = GetDispatcher();
- if ( pDispat )
+ SfxBindings* pBindings = pDispat->GetBindings();
+ pBindings->Broadcast( aItemHint );
+ sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
+ SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
+ if ( pCache )
{
- SfxBindings* pBindings = pDispat->GetBindings();
- pBindings->Broadcast( aItemHint );
- sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
- SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
- if ( pCache )
- {
- pCache->SetState( SFX_ITEM_AVAILABLE, pItem->Clone(), sal_True );
- pCache->SetCachedState( sal_True );
- }
+ pCache->SetState( SFX_ITEM_AVAILABLE, pItem->Clone(), sal_True );
+ pCache->SetCachedState( sal_True );
}
- return;
}
+ return;
+ }
+ else
+ {
+ Broadcast( aItemHint );
+ pImp->aItems[ pItem->Which() ] = pItem;
}
-
- Broadcast( aItemHint );
- pImp->aItems.Insert((SfxPoolItemPtr)pItem, nPos );
}
//--------------------------------------------------------------------
commit 99093b9c6cb45ce834cc76c8917a3c77805fd536
Author: Noel Grandin <noel at peralex.com>
Date: Fri Jun 1 23:25:56 2012 +0200
Convert SV_DECL_PTRARR_SORT_DEL(SfxFoundCacheArr_Impl) to std::vector
The SV..SORT part is unused in this code so I ignored it in the
conversion.
Change-Id: I5e3338f3d5256e123f7979660d93ea02b8b4fd78
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 442065d..611159d 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -206,8 +206,15 @@ struct SfxFoundCache_Impl
//--------------------------------------------------------------------------
-SV_DECL_PTRARR_SORT_DEL(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*, 16)
-SV_IMPL_OP_PTRARR_SORT(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*);
+class SfxFoundCacheArr_Impl : public std::vector<SfxFoundCache_Impl*>
+{
+public:
+ ~SfxFoundCacheArr_Impl()
+ {
+ for(const_iterator it = begin(); it != end(); ++it)
+ delete *it;
+ }
+};
//==========================================================================
@@ -412,7 +419,7 @@ void SfxBindings::Update_Impl
// Post Status
const SfxInterface *pInterface =
rDispat.GetShell(pMsgServer->GetShellLevel())->GetInterface();
- for ( sal_uInt16 nPos = 0; nPos < aFound.Count(); ++nPos )
+ for ( sal_uInt16 nPos = 0; nPos < aFound.size(); ++nPos )
{
const SfxFoundCache_Impl *pFound = aFound[nPos];
sal_uInt16 nWhich = pFound->nWhichId;
@@ -1368,9 +1375,9 @@ SfxItemSet* SfxBindings::CreateSet_Impl
pFnc = pRealSlot->GetStateFnc();
// the RealSlot is always on
- const SfxFoundCache_Impl *pFound = new SfxFoundCache_Impl(
+ SfxFoundCache_Impl *pFound = new SfxFoundCache_Impl(
pRealSlot->GetSlotId(), pRealSlot->GetWhich(rPool), pRealSlot, pCache );
- rFound.Insert( pFound );
+ rFound.push_back( pFound );
sal_uInt16 nSlot = pRealSlot->GetSlotId();
if ( !(nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) )
@@ -1435,25 +1442,25 @@ SfxItemSet* SfxBindings::CreateSet_Impl
if ( bInsert && bSameMethod )
{
- const SfxFoundCache_Impl *pFoundCache = new SfxFoundCache_Impl(
+ SfxFoundCache_Impl *pFoundCache = new SfxFoundCache_Impl(
pSibling->GetSlotId(), pSibling->GetWhich(rPool),
pSibling, pSiblingCache );
- rFound.Insert( pFoundCache );
+ rFound.push_back( pFoundCache );
}
pSibling = pSibling->GetNextSlot();
}
// Create a Set from the ranges
- sal_uInt16 *pRanges = new sal_uInt16[rFound.Count() * 2 + 1];
+ sal_uInt16 *pRanges = new sal_uInt16[rFound.size() * 2 + 1];
int j = 0;
sal_uInt16 i = 0;
- while ( i < rFound.Count() )
+ while ( i < rFound.size() )
{
pRanges[j++] = rFound[i]->nWhichId;
// consecutive numbers
- for ( ; i < rFound.Count()-1; ++i )
+ for ( ; i < rFound.size()-1; ++i )
if ( rFound[i]->nWhichId+1 != rFound[i+1]->nWhichId )
break;
pRanges[j++] = rFound[i++]->nWhichId;
commit 0db8160a7958c306d7957bcd34ba6bfd3082b90b
Author: Noel Grandin <noel at peralex.com>
Date: Fri Jun 1 22:56:00 2012 +0200
Convert SV_DECL_PTRARR_DEL(SfxVerbSlotArr_Impl) to std::vector
Change-Id: I06bdcdf6e6b7f159783ce7ab381b7b21f7db4a98
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index a9b3f5c..5ba4ad6 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -61,9 +61,15 @@ DBG_NAME(SfxShell)
TYPEINIT0(SfxShell);
//====================================================================
-typedef SfxSlot* SfxSlotPtr;
-SV_DECL_PTRARR_DEL( SfxVerbSlotArr_Impl, SfxSlotPtr, 4 )
-SV_IMPL_PTRARR( SfxVerbSlotArr_Impl, SfxSlotPtr);
+class SfxVerbSlotArr_Impl : public std::vector<SfxSlot*>
+{
+public:
+ ~SfxVerbSlotArr_Impl()
+ {
+ for(const_iterator it = begin(); it != end(); ++it)
+ delete *it;
+ }
+};
using namespace com::sun::star;
@@ -979,7 +985,7 @@ void SfxShell::SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::em
{
SfxBindings *pBindings =
pViewSh->GetViewFrame()->GetDispatcher()->GetBindings();
- sal_uInt16 nCount = pImp->aSlotArr.Count();
+ sal_uInt16 nCount = pImp->aSlotArr.size();
for (sal_uInt16 n1=0; n1<nCount ; n1++)
{
sal_uInt16 nId = SID_VERB_START + n1;
@@ -1013,16 +1019,16 @@ void SfxShell::SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::em
pNewSlot->pFirstArgDef = 0;
pNewSlot->pUnoName = 0;
- if (pImp->aSlotArr.Count())
+ if (!pImp->aSlotArr.empty())
{
- SfxSlot *pSlot = (pImp->aSlotArr)[0];
+ SfxSlot *pSlot = pImp->aSlotArr[0];
pNewSlot->pNextSlot = pSlot->pNextSlot;
pSlot->pNextSlot = pNewSlot;
}
else
pNewSlot->pNextSlot = pNewSlot;
- pImp->aSlotArr.Insert(pNewSlot, (sal_uInt16) n);
+ pImp->aSlotArr.insert(pImp->aSlotArr.begin() + (sal_uInt16) n, pNewSlot);
}
pImp->aVerbList = aVerbs;
commit 7e350ac0674fad060a294dd132e368d560713005
Author: Noel Grandin <noel at peralex.com>
Date: Fri Jun 1 22:46:11 2012 +0200
Convert SV_DECL_PTRARR_DEL(SfxDockArr_Impl) to std::vector
Change-Id: I1856a276ee93f35c8f6e7f51c83d7d80c3efd86c
diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx
index e6f39e6..72a043a 100644
--- a/sfx2/source/dialog/splitwin.cxx
+++ b/sfx2/source/dialog/splitwin.cxx
@@ -65,9 +65,16 @@ struct SfxDock_Impl
long nSize;
};
-typedef SfxDock_Impl* SfxDockPtr;
-SV_DECL_PTRARR_DEL( SfxDockArr_Impl, SfxDockPtr, 4 )
-SV_IMPL_PTRARR( SfxDockArr_Impl, SfxDockPtr);
+class SfxDockArr_Impl : public std::vector<SfxDock_Impl*>
+{
+public:
+ ~SfxDockArr_Impl()
+ {
+ for(const_iterator it = begin(); it != end(); ++it)
+ delete *it;
+ }
+
+};
class SfxEmptySplitWin_Impl : public SplitWindow
{
@@ -273,7 +280,7 @@ SfxSplitWindow::SfxSplitWindow( Window* pParent, SfxChildAlignment eAl,
pDock->bNewLine = sal_True;
}
- pDockArr->Insert(pDock,n);
+ pDockArr->insert(pDockArr->begin() + n, pDock);
}
}
}
@@ -317,7 +324,7 @@ void SfxSplitWindow::SaveConfig_Impl()
sal_uInt16 nCount = 0;
sal_uInt16 n;
- for ( n=0; n<pDockArr->Count(); n++ )
+ for ( n=0; n<pDockArr->size(); n++ )
{
SfxDock_Impl *pDock = (*pDockArr)[n];
if ( pDock->bHide || pDock->pWin )
@@ -326,7 +333,7 @@ void SfxSplitWindow::SaveConfig_Impl()
aWinData += String::CreateFromInt32( nCount );
- for ( n=0; n<pDockArr->Count(); n++ )
+ for ( n=0; n<pDockArr->size(); n++ )
{
SfxDock_Impl *pDock = (*pDockArr)[n];
if ( !pDock->bHide && !pDock->pWin )
@@ -394,7 +401,7 @@ void SfxSplitWindow::Split()
SplitWindow::Split();
- sal_uInt16 nCount = pDockArr->Count();
+ sal_uInt16 nCount = pDockArr->size();
for ( sal_uInt16 n=0; n<nCount; n++ )
{
SfxDock_Impl *pD = (*pDockArr)[n];
@@ -440,7 +447,7 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize
sal_Bool bNewLine = sal_True;
sal_Bool bSaveConfig = sal_False;
SfxDock_Impl *pFoundDock=0;
- sal_uInt16 nCount = pDockArr->Count();
+ sal_uInt16 nCount = pDockArr->size();
for ( sal_uInt16 n=0; n<nCount; n++ )
{
SfxDock_Impl *pDock = (*pDockArr)[n];
@@ -500,7 +507,7 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize
// Not found, insert at end
pFoundDock = new SfxDock_Impl;
pFoundDock->bHide = sal_True;
- pDockArr->Insert( pFoundDock, nCount );
+ pDockArr->push_back( pFoundDock );
pFoundDock->nType = pDockWin->GetType();
nLine++;
nPos = 0;
@@ -527,7 +534,7 @@ void SfxSplitWindow::ReleaseWindow_Impl(SfxDockingWindow *pDockWin, sal_Bool bSa
{
SfxDock_Impl *pDock=0;
- sal_uInt16 nCount = pDockArr->Count();
+ sal_uInt16 nCount = pDockArr->size();
sal_Bool bFound = sal_False;
for ( sal_uInt16 n=0; n<nCount; n++ )
{
@@ -539,7 +546,7 @@ void SfxSplitWindow::ReleaseWindow_Impl(SfxDockingWindow *pDockWin, sal_Bool bSa
// Window has a position, this we forget
bFound = sal_True;
- pDockArr->Remove(n);
+ pDockArr->erase(pDockArr->begin() + n);
break;
}
}
@@ -599,7 +606,7 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize
// The window must be inserted before the first window so that it has the
// same or a greater position than pDockWin.
- sal_uInt16 nCount = pDockArr->Count();
+ sal_uInt16 nCount = pDockArr->size();
sal_uInt16 nLastWindowIdx(0);
// If no window is found, a first window is inserted
@@ -640,7 +647,7 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize
nInsertPos = nLastWindowIdx + 1; // ignore all non-windows after the last window
}
- pDockArr->Insert(pDock, nInsertPos);
+ pDockArr->insert(pDockArr->begin() + nInsertPos, pDock);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list