summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-07-19 14:26:38 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-26 14:30:11 +0200
commitef3990b07b1a9b05b135807765f9dd2732ee085b (patch)
tree9391376d7da8b85b2c1e345abf97804ce0b558d9 /editeng
parentf7f99968f2014c9e7f1f216c6ef0d2d31630087d (diff)
Convert SV_DECL_VARARR_SORT_VISIBILITY(SvxTabStopArr) o3tl::sorted_vector
And convert it from a private superclass to a member. The code is cleaner and easier to read as a consequence. Change-Id: I35501a208c96615ce5797ad06d34d3b7efc2c4db
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/editeng/tstpitem.hxx34
-rw-r--r--editeng/source/items/paraitem.cxx46
2 files changed, 37 insertions, 43 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] );
+ }
}