summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/inc/editeng/tstpitem.hxx34
-rw-r--r--editeng/source/items/paraitem.cxx46
-rw-r--r--sw/source/core/doc/docfmt.cxx7
-rw-r--r--sw/source/core/text/frmcrsr.cxx2
-rw-r--r--sw/source/core/text/txttab.cxx2
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx7
6 files changed, 44 insertions, 54 deletions
diff --git a/editeng/inc/editeng/tstpitem.hxx b/editeng/inc/editeng/tstpitem.hxx
index 90052bfc3426..62923aac3974 100644
--- a/editeng/inc/editeng/tstpitem.hxx
+++ b/editeng/inc/editeng/tstpitem.hxx
@@ -33,6 +33,7 @@
#include <svl/poolitem.hxx>
#include <editeng/svxenum.hxx>
#include <editeng/editengdllapi.h>
+#include <o3tl/sorted_vector.hxx>
// class SvxTabStop ------------------------------------------------------
@@ -103,16 +104,16 @@ public:
// class SvxTabStopItem --------------------------------------------------
-SV_DECL_VARARR_SORT_VISIBILITY( SvxTabStopArr, SvxTabStop, SVX_TAB_DEFCOUNT, EDITENG_DLLPUBLIC )
+typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
/* [Description]
This item describes a list of TabStops.
*/
-class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem, private SvxTabStopArr
+class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem
{
-//friend class SvxTabStopObject_Impl;
+ SvxTabStopArr maTabStops;
public:
TYPEINFO();
@@ -131,14 +132,14 @@ public:
sal_uInt16 GetPos( const sal_Int32 nPos ) const;
// unprivatized:
- sal_uInt16 Count() const { return SvxTabStopArr::Count(); }
- sal_Bool Insert( const SvxTabStop& rTab );
- void Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
+ sal_uInt16 Count() const { return maTabStops.size(); }
+ bool Insert( const SvxTabStop& rTab );
+ void Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
sal_uInt16 nEnd = USHRT_MAX );
- void Remove( SvxTabStop& rTab )
- { SvxTabStopArr::Remove( rTab ); }
- void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
- { SvxTabStopArr::Remove( nPos, nLen ); }
+ void Remove( SvxTabStop& rTab )
+ { maTabStops.erase( rTab ); }
+ void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
+ { maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
// Assignment operator, equality operator (caution: expensive!)
SvxTabStopItem& operator=( const SvxTabStopItem& rTSI );
@@ -147,15 +148,10 @@ public:
//int operator!=( const SvxTabStopItem& rTSI ) const
// { return !( operator==( rTSI ) ); }
- // SortedArrays returns only Stackobjects!
const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
- {
- DBG_ASSERT( GetStart() &&
- nPos < Count(), "op[]" );
- return *( GetStart() + nPos );
- }
- const SvxTabStop* GetStart() const
- { return SvxTabStopArr::GetData(); }
+ { return maTabStops[nPos]; }
+ SvxTabStop& operator[]( const sal_uInt16 nPos )
+ { return maTabStops[nPos]; }
// "pure virtual Methods" from SfxPoolItem
virtual int operator==( const SfxPoolItem& ) const;
@@ -171,8 +167,6 @@ public:
virtual SfxPoolItem* Create( SvStream&, sal_uInt16 ) const;
virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const;
- using SvxTabStopArr::Insert;
- using SvxTabStopArr::Remove;
};
#endif
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx
index 4549274fe90c..d611a09008cf 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -93,8 +93,6 @@ TYPEINIT1_FACTORY(SvxForbiddenRuleItem, SfxBoolItem, new SvxForbiddenRuleItem(sa
TYPEINIT1_FACTORY(SvxParaVertAlignItem, SfxUInt16Item, new SvxParaVertAlignItem(0, 0));
TYPEINIT1_FACTORY(SvxParaGridItem, SfxBoolItem, new SvxParaGridItem(sal_True, 0));
-SV_IMPL_VARARR_SORT( SvxTabStopArr, SvxTabStop )
-
// -----------------------------------------------------------------------
SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId )
@@ -913,7 +911,7 @@ XubString SvxTabStop::GetValueString() const
SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) :
SfxPoolItem( _nWhich ),
- SvxTabStopArr( sal_Int8(SVX_TAB_DEFCOUNT) )
+ maTabStops()
{
const sal_uInt16 nTabs = SVX_TAB_DEFCOUNT, nDist = SVX_TAB_DEFDIST;
const SvxTabAdjust eAdjst= SVX_TAB_ADJUST_DEFAULT;
@@ -921,7 +919,7 @@ SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) :
for (sal_uInt16 i = 0; i < nTabs; ++i)
{
SvxTabStop aTab( (i + 1) * nDist, eAdjst );
- SvxTabStopArr::Insert( aTab );
+ maTabStops.insert( aTab );
}
}
@@ -932,12 +930,12 @@ SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs,
const SvxTabAdjust eAdjst,
sal_uInt16 _nWhich ) :
SfxPoolItem( _nWhich ),
- SvxTabStopArr( sal_Int8(nTabs) )
+ maTabStops()
{
for ( sal_uInt16 i = 0; i < nTabs; ++i )
{
SvxTabStop aTab( (i + 1) * nDist, eAdjst );
- SvxTabStopArr::Insert( aTab );
+ maTabStops.insert( aTab );
}
}
@@ -945,33 +943,32 @@ SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs,
SvxTabStopItem::SvxTabStopItem( const SvxTabStopItem& rTSI ) :
SfxPoolItem( rTSI.Which() ),
- SvxTabStopArr( (sal_Int8)rTSI.Count() )
+ maTabStops( rTSI.maTabStops )
{
- SvxTabStopArr::Insert( &rTSI );
}
// -----------------------------------------------------------------------
sal_uInt16 SvxTabStopItem::GetPos( const SvxTabStop& rTab ) const
{
- sal_uInt16 nFound;
- return Seek_Entry( rTab, &nFound ) ? nFound : SVX_TAB_NOTFOUND;
+ SvxTabStopArr::const_iterator it = maTabStops.find( rTab );
+ return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
}
// -----------------------------------------------------------------------
sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const
{
- sal_uInt16 nFound;
- return Seek_Entry( SvxTabStop( nPos ), &nFound ) ? nFound : SVX_TAB_NOTFOUND;
+ SvxTabStopArr::const_iterator it = maTabStops.find( SvxTabStop( nPos ) );
+ return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
}
// -----------------------------------------------------------------------
SvxTabStopItem& SvxTabStopItem::operator=( const SvxTabStopItem& rTSI )
{
- Remove( 0, Count() );
- SvxTabStopArr::Insert( &rTSI );
+ maTabStops.clear();
+ maTabStops.insert( rTSI.maTabStops );
return *this;
}
@@ -988,7 +985,7 @@ bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
style::TabStop* pArr = aSeq.getArray();
for(sal_uInt16 i = 0; i < nCount; i++)
{
- const SvxTabStop& rTab = *(GetStart() + i);
+ const SvxTabStop& rTab = (*this)[i];
pArr[i].Position = bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos();
switch(rTab.GetAdjustment())
{
@@ -1008,7 +1005,7 @@ bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
}
case MID_STD_TAB:
{
- const SvxTabStop &rTab = *(GetStart());
+ const SvxTabStop &rTab = maTabStops.front();
rVal <<= (static_cast<sal_Int32>(bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos()));
break;
}
@@ -1068,7 +1065,7 @@ bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
}
}
- SvxTabStopArr::Remove( 0, Count() );
+ maTabStops.clear();
const style::TabStop* pArr = aSeq.getConstArray();
const sal_uInt16 nCount = (sal_uInt16)aSeq.getLength();
for(sal_uInt16 i = 0; i < nCount ; i++)
@@ -1101,9 +1098,9 @@ bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
nNewPos = MM100_TO_TWIP ( nNewPos );
if (nNewPos <= 0)
return sal_False;
- const SvxTabStop& rTab = *(GetStart());
+ const SvxTabStop& rTab = maTabStops.front();
SvxTabStop aNewTab ( nNewPos, rTab.GetAdjustment(), rTab.GetDecimal(), rTab.GetFill() );
- Remove ( 0 );
+ Remove( 0 );
Insert( aNewTab );
break;
}
@@ -1210,7 +1207,7 @@ SvStream& SvxTabStopItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ )
{
const SvxTabStopItem& rDefTab = (const SvxTabStopItem &)
pPool->GetDefaultItem( pPool->GetWhich( SID_ATTR_TABSTOP, sal_False ) );
- nDefDist = sal_uInt16( rDefTab.GetStart()->GetTabPos() );
+ nDefDist = sal_uInt16( rDefTab.maTabStops.front().GetTabPos() );
const sal_Int32 nPos = nTabs > 0 ? (*this)[nTabs-1].GetTabPos() : 0;
nCount = (sal_uInt16)(nPos / nDefDist);
nNew = (nCount + 1) * nDefDist;
@@ -1247,12 +1244,12 @@ SvStream& SvxTabStopItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ )
}
// -----------------------------------------------------------------------
-sal_Bool SvxTabStopItem::Insert( const SvxTabStop& rTab )
+bool SvxTabStopItem::Insert( const SvxTabStop& rTab )
{
sal_uInt16 nTabPos = GetPos(rTab);
if(SVX_TAB_NOTFOUND != nTabPos )
Remove(nTabPos);
- return SvxTabStopArr::Insert( rTab );
+ return maTabStops.insert( rTab ).second;
}
// -----------------------------------------------------------------------
void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart,
@@ -1265,7 +1262,10 @@ void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart,
if(SVX_TAB_NOTFOUND != nTabPos)
Remove(nTabPos);
}
- SvxTabStopArr::Insert( pTabs, nStart, nEnd );
+ for( sal_uInt16 i = nStart; i < nEnd && i < pTabs->Count(); i++ )
+ {
+ maTabStops.insert( (*pTabs)[i] );
+ }
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 2dfc3dfa36c0..4c67d512c0e7 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1136,12 +1136,9 @@ int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
return sal_False;
// Find the default's beginning
- SvxTabStop* pTabs = ((SvxTabStop*)rChgTabStop.GetStart())
- + (nOldCnt-1);
sal_uInt16 n;
-
- for( n = nOldCnt; n ; --n, --pTabs )
- if( SVX_TAB_ADJUST_DEFAULT != pTabs->GetAdjustment() )
+ for( n = nOldCnt; n ; --n )
+ if( SVX_TAB_ADJUST_DEFAULT != rChgTabStop[n - 1].GetAdjustment() )
break;
++n;
if( n < nOldCnt ) // delete the DefTabStops
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 18554060df5c..3210de660f87 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -1590,7 +1590,7 @@ static sal_Char const sDoubleSpace[] = " ";
const SvxTabStopItem& rTab =
(const SvxTabStopItem &)pSet->
GetPool()->GetDefaultItem( RES_PARATR_TABSTOP );
- MSHORT nDefTabDist = (MSHORT)rTab.GetStart()->GetTabPos();
+ MSHORT nDefTabDist = (MSHORT)rTab[0].GetTabPos();
nRightTab = nLeftTab - nTxtLeft;
nRightTab /= nDefTabDist;
nRightTab = nRightTab * nDefTabDist + nTxtLeft;
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 137da97912ea..a53cce96abcf 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -183,7 +183,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
(const SvxTabStopItem &)pFrm->GetAttrSet()->
GetPool()->GetDefaultItem( RES_PARATR_TABSTOP );
if( rTab.Count() )
- nDefTabDist = (KSHORT)rTab.GetStart()->GetTabPos();
+ nDefTabDist = (KSHORT)rTab[0].GetTabPos();
else
nDefTabDist = SVX_TAB_DEFDIST;
aLineInf.SetDefTabStop( nDefTabDist );
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index c210149fe91c..3498cab1beb6 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -3795,10 +3795,9 @@ void SwRTFParser::SetSwgValues( SfxItemSet& rSet )
if( nOffset )
{
// Tabs anpassen !!
- SvxTabStop* pTabs = (SvxTabStop*)aTStop.GetStart();
- for( sal_uInt16 n = aTStop.Count(); n; --n, ++pTabs)
- if( SVX_TAB_ADJUST_DEFAULT != pTabs->GetAdjustment() )
- pTabs->GetTabPos() -= nOffset;
+ for( sal_uInt16 n = 0; n < aTStop.Count(); ++n)
+ if( SVX_TAB_ADJUST_DEFAULT != aTStop[n].GetAdjustment() )
+ aTStop[n].GetTabPos() -= nOffset;
// negativer Einzug, dann auf 0 Pos einen Tab setzen
if( rLR.GetTxtFirstLineOfst() < 0 )