summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-02-21 19:01:17 +0400
committerIvan Timofeev <timofeev.i.s@gmail.com>2012-02-21 20:05:23 +0400
commita4aa96be3a9e24099a45850cadd5074d2db9a199 (patch)
tree720a4b9d019887420211d0d5d4bae284ca9a88a5 /editeng
parent5f06a2b734941a79983ecf8476b412bf6ce5e9e8 (diff)
convert svxrtf.hxx in editeng module from table.hxx to std::map
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/editeng/svxrtf.hxx7
-rw-r--r--editeng/source/editeng/eertfpar.cxx37
-rw-r--r--editeng/source/rtf/svxrtf.cxx40
3 files changed, 44 insertions, 40 deletions
diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx
index c79f2bd846f7..4d255da62bbb 100644
--- a/editeng/inc/editeng/svxrtf.hxx
+++ b/editeng/inc/editeng/svxrtf.hxx
@@ -29,7 +29,6 @@
#ifndef _SVXRTF_HXX
#define _SVXRTF_HXX
-#include <tools/table.hxx>
#include <tools/string.hxx>
#include <svl/itemset.hxx>
#include <svtools/parrtf.hxx>
@@ -39,6 +38,8 @@
#include <deque>
#include <utility>
#include <vector>
+#include "boost/ptr_container/ptr_map.hpp"
+
class Font;
class Color;
class Graphic;
@@ -85,8 +86,8 @@ public:
typedef Color* ColorPtr;
typedef std::deque< ColorPtr > SvxRTFColorTbl;
-DECLARE_TABLE( SvxRTFFontTbl, Font* )
-DECLARE_TABLE( SvxRTFStyleTbl, SvxRTFStyleType* )
+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 )
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index d5087166b6b8..4e7254fa1932 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -371,10 +371,11 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
if ( rSet.StyleNo() && pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
{
- SvxRTFStyleType* pS = GetStyleTbl().Get( rSet.StyleNo() );
- DBG_ASSERT( pS, "Template not defined in RTF!" );
- if ( pS )
+ SvxRTFStyleTbl::iterator it = GetStyleTbl().find( rSet.StyleNo() );
+ DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" );
+ if ( it != GetStyleTbl().end() )
{
+ SvxRTFStyleType* pS = it->second;
pImpEditEngine->SetStyleSheet( EditSelection( aStartPaM, aEndPaM ), (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( pS->sName, SFX_STYLE_FAMILY_ALL ) );
nOutlLevel = pS->nOutlineNo;
}
@@ -433,11 +434,17 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
SvxRTFStyleType* EditRTFParser::FindStyleSheet( const XubString& rName )
{
- SvxRTFStyleType* pS = GetStyleTbl().First();
- while ( pS && ( pS->sName != rName ) )
- pS = GetStyleTbl().Next();
+ SvxRTFStyleTbl aTable = GetStyleTbl();
+ SvxRTFStyleTbl::iterator it = aTable.begin();
+ while ( it != aTable.end() )
+ {
+ SvxRTFStyleType* pS = it->second;
+ if ( pS->sName == rName )
+ return pS;
+ ++it;
+ }
- return pS;
+ return NULL;
}
SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
@@ -451,9 +458,13 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
String aParent;
if ( pRTFStyle->nBasedOn )
{
- SvxRTFStyleType* pS = GetStyleTbl().Get( pRTFStyle->nBasedOn );
- if ( pS && ( pS !=pRTFStyle ) )
- aParent = pS->sName;
+ SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn );
+ if ( it != GetStyleTbl().end())
+ {
+ SvxRTFStyleType* pS = it->second;
+ if ( pS && ( pS !=pRTFStyle ) )
+ aParent = pS->sName;
+ }
}
pStyle = (SfxStyleSheet*) &pImpEditEngine->GetStyleSheetPool()->Make( aName, SFX_STYLE_FAMILY_PARA );
@@ -484,12 +495,10 @@ void EditRTFParser::CreateStyleSheets()
// the SvxRTFParser haa now created the template...
if ( pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
{
- SvxRTFStyleType* pRTFStyle = GetStyleTbl().First();
- while ( pRTFStyle )
+ for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
{
+ SvxRTFStyleType* pRTFStyle = it->second;
CreateStyleSheet( pRTFStyle );
-
- pRTFStyle = GetStyleTbl().Next();
}
}
}
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 8b9d93cd163c..165c3c395463 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -77,7 +77,6 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
int bReadNewDoc )
: SvRTFParser( rIn, 5 ),
rStrm(rIn),
- aFontTbl( 16, 4 ),
pInsPos( 0 ),
pAttrPool( &rPool ),
m_xDocProps( i_xDocProps ),
@@ -119,10 +118,6 @@ SvxRTFParser::~SvxRTFParser()
{
if( !aColorTbl.empty() )
ClearColorTbl();
- if( aFontTbl.Count() )
- ClearFontTbl();
- if( aStyleTbl.Count() )
- ClearStyleTbl();
if( !aAttrStack.empty() )
ClearAttrStack();
@@ -149,9 +144,9 @@ SvParserState SvxRTFParser::CallParser()
if( !aColorTbl.empty() )
ClearColorTbl();
- if( aFontTbl.Count() )
+ if( !aFontTbl.empty() )
ClearFontTbl();
- if( aStyleTbl.Count() )
+ if( !aStyleTbl.empty() )
ClearStyleTbl();
if( !aAttrStack.empty() )
ClearAttrStack();
@@ -194,7 +189,7 @@ void SvxRTFParser::NextToken( int nToken )
case RTF_DEFF:
if( bNewDoc )
{
- if( aFontTbl.Count() )
+ if( !aFontTbl.empty() )
// Can immediately be set
SetDefault( nToken, nTokenValue );
else
@@ -335,7 +330,7 @@ INSINGLECHAR:
void SvxRTFParser::ReadStyleTable()
{
int nToken, bSaveChkStyleAttr = bChkStyleAttr;
- short nStyleNo = 0;
+ sal_uInt16 nStyleNo = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!!
SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] );
pStyle->aAttrSet.Put( GetRTFDefaults() );
@@ -385,14 +380,12 @@ void SvxRTFParser::ReadStyleTable()
{
pStyle->sName = DelCharAtEnd( aToken, ';' );
- if( aStyleTbl.Count() )
+ if( !aStyleTbl.empty() )
{
- SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo );
- if( pOldSt )
- delete pOldSt;
+ aStyleTbl.erase(nStyleNo);
}
// All data from the font is available, so off to the table
- aStyleTbl.Insert( nStyleNo, pStyle );
+ aStyleTbl.insert( nStyleNo , pStyle);
pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] );
pStyle->aAttrSet.Put( GetRTFDefaults() );
nStyleNo = 0;
@@ -596,7 +589,7 @@ void SvxRTFParser::ReadFontTable()
(sFntNm += ';' ) += sAltNm;
pFont->SetName( sFntNm );
- aFontTbl.Insert( nInsFontNo, pFont );
+ aFontTbl.insert( nInsFontNo, pFont );
pFont = new Font();
pFont->SetCharSet( nSystemChar );
sAltNm.Erase();
@@ -798,14 +791,12 @@ void SvxRTFParser::ClearColorTbl()
void SvxRTFParser::ClearFontTbl()
{
- for( sal_uInt32 nCnt = aFontTbl.Count(); nCnt; )
- delete aFontTbl.GetObject( --nCnt );
+ aFontTbl.clear();
}
void SvxRTFParser::ClearStyleTbl()
{
- for( sal_uInt32 nCnt = aStyleTbl.Count(); nCnt; )
- delete aStyleTbl.GetObject( --nCnt );
+ aStyleTbl.clear();
}
void SvxRTFParser::ClearAttrStack()
@@ -833,8 +824,9 @@ String& SvxRTFParser::DelCharAtEnd( String& rStr, const sal_Unicode cDel )
const Font& SvxRTFParser::GetFont( sal_uInt16 nId )
{
- const Font* pFont = aFontTbl.Get( nId );
- if( !pFont )
+ SvxRTFFontTbl::const_iterator it = aFontTbl.find( nId );
+ const Font* pFont;
+ if( it == aFontTbl.end() )
{
const SvxFontItem& rDfltFont = (const SvxFontItem&)
pAttrPool->GetDefaultItem(
@@ -843,6 +835,8 @@ const Font& SvxRTFParser::GetFont( sal_uInt16 nId )
pDfltFont->SetFamily( rDfltFont.GetFamily() );
pFont = pDfltFont;
}
+ else
+ pFont = it->second;
return *pFont;
}
@@ -872,10 +866,9 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
const SfxPoolItem* pItem;
SfxWhichIter aIter( rSet );
- SvxRTFStyleType* pStyle;
if( !IsChkStyleAttr() ||
!rStkType.GetAttrSet().Count() ||
- 0 == ( pStyle = aStyleTbl.Get( rStkType.nStyleNo ) ))
+ aStyleTbl.count( rStkType.nStyleNo ) == 0 )
{
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
{
@@ -889,6 +882,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
{
// Delete all Attributes, which are already defined in the Style,
// from the current AttrSet.
+ SvxRTFStyleType* pStyle = aStyleTbl.find( rStkType.nStyleNo )->second;
SfxItemSet &rStyleSet = pStyle->aAttrSet;
const SfxPoolItem* pSItem;
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )