summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-06-12 14:18:56 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-12 23:25:16 +0200
commit586df9f1ec5a733082ced2a51f416c8baa2cc914 (patch)
treeb44d7fd03bca760021d11722797593dc66da5f82 /editeng
parentc2fc98fa9e46cd18201d3940beb67d74630c8604 (diff)
Convert SV_DECL_PTRARR_DEL(SvxRTFItemStackList) to boost::ptr_vector
I had to make the destructor of SvxRTFItemStackType public. The combination of friend class, boost, and a private destructor does not make OSX's gcc happy. Change-Id: I2d9a3bff3c5edaf5435fb543389a9a2822c6b2ad
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/editeng/svxrtf.hxx18
-rw-r--r--editeng/source/rtf/svxrtf.cxx53
2 files changed, 33 insertions, 38 deletions
diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx
index 4d255da62bbb..926846fb4d86 100644
--- a/editeng/inc/editeng/svxrtf.hxx
+++ b/editeng/inc/editeng/svxrtf.hxx
@@ -39,6 +39,7 @@
#include <utility>
#include <vector>
#include "boost/ptr_container/ptr_map.hpp"
+#include "boost/ptr_container/ptr_vector.hpp"
class Font;
class Color;
@@ -46,7 +47,7 @@ class Graphic;
class DateTime;
struct SvxRTFStyleType;
class SvxRTFItemStackType;
-class SvxRTFItemStackList;
+class SvxRTFItemStackList : public boost::ptr_vector<SvxRTFItemStackType> {};
namespace com { namespace sun { namespace star {
namespace document {
@@ -88,12 +89,10 @@ typedef Color* ColorPtr;
typedef std::deque< ColorPtr > SvxRTFColorTbl;
typedef boost::ptr_map<short, Font> SvxRTFFontTbl;
typedef boost::ptr_map<sal_uInt16, SvxRTFStyleType> SvxRTFStyleTbl;
-typedef SvxRTFItemStackType* SvxRTFItemStackTypePtr;
-SV_DECL_PTRARR_DEL( SvxRTFItemStackList, SvxRTFItemStackTypePtr, 1 )
-// SvxRTFItemStack can't be "std::stack< SvxRTFItemStackTypePtr >" type, because
+// SvxRTFItemStack can't be "std::stack< SvxRTFItemStackType* >" type, because
// the methods are using operator[] in sw/source/filter/rtf/rtftbl.cxx file
-typedef std::deque< SvxRTFItemStackTypePtr > SvxRTFItemStack;
+typedef std::deque< SvxRTFItemStackType* > SvxRTFItemStack;
// own helper classes for the RTF Parser
struct SvxRTFStyleType
@@ -262,7 +261,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
void ClearStyleTbl();
void ClearAttrStack();
- SvxRTFItemStackTypePtr _GetAttrSet( int bCopyAttr=sal_False ); // Create new ItemStackType:s
+ SvxRTFItemStackType* _GetAttrSet( int bCopyAttr=sal_False ); // Create new ItemStackType:s
void _ClearStyleAttr( SvxRTFItemStackType& rStkType );
// Sets all the attributes that are different from the current
@@ -413,7 +412,6 @@ public:
class EDITENG_DLLPUBLIC SvxRTFItemStackType
{
friend class SvxRTFParser;
- friend class SvxRTFItemStackList;
SfxItemSet aAttrSet;
SvxNodeIdx *pSttNd, *pEndNd;
@@ -423,14 +421,14 @@ class EDITENG_DLLPUBLIC SvxRTFItemStackType
SvxRTFItemStackType( SfxItemPool&, const sal_uInt16* pWhichRange,
const SvxPosition& );
- ~SvxRTFItemStackType();
- void Add( SvxRTFItemStackTypePtr );
+ void Add( SvxRTFItemStackType* );
void Compress( const SvxRTFParser& );
public:
SvxRTFItemStackType( const SvxRTFItemStackType&, const SvxPosition&,
int bCopyAttr = sal_False );
+ ~SvxRTFItemStackType();
//cmc, I'm very suspicios about SetStartPos, it doesn't change
//its children's starting position, and the implementation looks
//bad, consider this deprecated.
@@ -469,7 +467,7 @@ inline const Color& SvxRTFParser::GetColor( size_t nId ) const
inline SfxItemSet& SvxRTFParser::GetAttrSet()
{
- SvxRTFItemStackTypePtr pTmp;
+ SvxRTFItemStackType* pTmp;
if( bNewGroup || 0 == ( pTmp = aAttrStack.empty() ? 0 : aAttrStack.back()) )
pTmp = _GetAttrSet();
return pTmp->aAttrSet;
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index c57d3c520641..48e3efb28f23 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -50,8 +50,6 @@
using namespace ::com::sun::star;
-SV_IMPL_PTRARR( SvxRTFItemStackList, SvxRTFItemStackType* )
-
CharSet lcl_GetDefaultTextEncodingForRTF()
{
@@ -224,11 +222,11 @@ INSINGLECHAR:
{
InsertText();
// all collected Attributes are set
- for( sal_uInt16 n = aAttrSetList.Count(); n; )
+ for( sal_uInt16 n = aAttrSetList.size(); n; )
{
- SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
+ SvxRTFItemStackType* pStkSet = &aAttrSetList[--n];
SetAttrSet( *pStkSet );
- aAttrSetList.DeleteAndDestroy( n );
+ aAttrSetList.pop_back();
}
}
break;
@@ -1005,8 +1003,8 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
// Last off the stack, thus cache it until the next text was
// read. (Span no attributes!)
- aAttrSetList.Insert( pOld, aAttrSetList.Count() );
- aAttrSetList.Insert( pNew, aAttrSetList.Count() );
+ aAttrSetList.push_back( pOld );
+ aAttrSetList.push_back( pNew );
}
pOld = 0; // Do not delete pOld
break;
@@ -1035,7 +1033,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
pAkt->Add( pOld );
// split up and create new entry, because it make no sense
// to create a "so long" depend list. Bug 95010
- if( bCrsrBack && 50 < pAkt->pChildList->Count() )
+ if( bCrsrBack && 50 < pAkt->pChildList->size() )
{
// at the beginning of a paragraph? Move back one position
MovePos( sal_True );
@@ -1057,7 +1055,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
else
// Last off the stack, thus cache it until the next text was
// read. (Span no attributes!)
- aAttrSetList.Insert( pOld, aAttrSetList.Count() );
+ aAttrSetList.push_back( pOld );
pOld = 0;
}
@@ -1081,11 +1079,11 @@ void SvxRTFParser::SetAllAttrOfStk() // end all Attr. and set it into doc
while( !aAttrStack.empty() )
AttrGroupEnd();
- for( sal_uInt16 n = aAttrSetList.Count(); n; )
+ for( sal_uInt16 n = aAttrSetList.size(); n; )
{
- SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
+ SvxRTFItemStackType* pStkSet = &aAttrSetList[--n];
SetAttrSet( *pStkSet );
- aAttrSetList.DeleteAndDestroy( n );
+ aAttrSetList.pop_back();
}
}
@@ -1103,8 +1101,8 @@ void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet )
// then process all the children
if( rSet.pChildList )
- for( sal_uInt16 n = 0; n < rSet.pChildList->Count(); ++n )
- SetAttrSet( *(*rSet.pChildList)[ n ] );
+ for( sal_uInt16 n = 0; n < rSet.pChildList->size(); ++n )
+ SetAttrSet( (*rSet.pChildList)[ n ] );
}
// Has no Text been inserted yet? (SttPos from the top Stack entry!)
@@ -1205,8 +1203,8 @@ SvxRTFItemStackType::~SvxRTFItemStackType()
void SvxRTFItemStackType::Add( SvxRTFItemStackType* pIns )
{
if( !pChildList )
- pChildList = new SvxRTFItemStackList( 4 );
- pChildList->Insert( pIns, pChildList->Count() );
+ pChildList = new SvxRTFItemStackList();
+ pChildList->push_back( pIns );
}
void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
@@ -1239,10 +1237,10 @@ void SvxRTFItemStackType::MoveFullNode(const SvxNodeIdx &rOldNode,
}
//And the same for all the children
- sal_uInt16 nCount = pChildList ? pChildList->Count() : 0;
+ sal_uInt16 nCount = pChildList ? pChildList->size() : 0;
for (sal_uInt16 i = 0; i < nCount; ++i)
{
- SvxRTFItemStackType* pStk = (*pChildList)[i];
+ SvxRTFItemStackType* pStk = &(*pChildList)[i];
pStk->MoveFullNode(rOldNode, rNewNode);
}
}
@@ -1257,7 +1255,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
DBG_ASSERT( pChildList, "There is no child list" );
sal_uInt16 n;
- SvxRTFItemStackType* pTmp = (*pChildList)[0];
+ SvxRTFItemStackType* pTmp = &(*pChildList)[0];
if( !pTmp->aAttrSet.Count() ||
pSttNd->GetIdx() != pTmp->pSttNd->GetIdx() ||
@@ -1268,9 +1266,9 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
xub_StrLen nLastCnt = pTmp->nEndCnt;
SfxItemSet aMrgSet( pTmp->aAttrSet );
- for( n = 1; n < pChildList->Count(); ++n )
+ for( n = 1; n < pChildList->size(); ++n )
{
- pTmp = (*pChildList)[n];
+ pTmp = &(*pChildList)[n];
if( pTmp->pChildList )
pTmp->Compress( rParser );
@@ -1280,8 +1278,8 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
: ( pTmp->nSttCnt != nLastCnt ||
pLastNd->GetIdx() != pTmp->pSttNd->GetIdx() ))
{
- while( ++n < pChildList->Count() )
- if( (pTmp = (*pChildList)[n])->pChildList )
+ while( ++n < pChildList->size() )
+ if( (pTmp = &(*pChildList)[n])->pChildList )
pTmp->Compress( rParser );
return;
}
@@ -1319,20 +1317,19 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
// It can be merged
aAttrSet.Put( aMrgSet );
- for( n = 0; n < pChildList->Count(); ++n )
+ for( n = 0; n < pChildList->size(); ++n )
{
- pTmp = (*pChildList)[n];
+ pTmp = &(*pChildList)[n];
pTmp->aAttrSet.Differentiate( aMrgSet );
if( !pTmp->pChildList && !pTmp->aAttrSet.Count() && !pTmp->nStyleNo )
{
- pChildList->Remove( n );
- delete pTmp;
+ pChildList->erase( pChildList->begin() + n );
--n;
continue;
}
}
- if( !pChildList->Count() )
+ if( pChildList->empty() )
{
delete pChildList;
pChildList = 0;