diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index affc44b8f5f2..17ef94553ec5 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -72,13 +72,11 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn ) , bIsInReadStyleTab( false) { pDfltFont.reset( new vcl::Font ); - pDfltColor.reset( new Color ); + mxDefaultColor = Color(); } SvxRTFParser::~SvxRTFParser() { - if( !aColorTbl.empty() ) - ClearColorTbl(); if( !aAttrStack.empty() ) ClearAttrStack(); } @@ -95,7 +93,7 @@ SvParserState SvxRTFParser::CallParser() if( !pInsPos ) return SvParserState::Error; - if( !aColorTbl.empty() ) + if( !maColorTable.empty() ) ClearColorTbl(); m_FontTable.clear(); m_StyleTable.clear(); @@ -422,11 +420,11 @@ void SvxRTFParser::ReadColorTable() { // one color is finished, fill in the table // try to map the values to SV internal names - Color* pColor = new Color( nRed, nGreen, nBlue ); - if( aColorTbl.empty() && + Color aColor( nRed, nGreen, nBlue ); + if( maColorTable.empty() && sal_uInt8(-1) == nRed && sal_uInt8(-1) == nGreen && sal_uInt8(-1) == nBlue ) - *pColor = COL_AUTO; - aColorTbl.push_back( pColor ); + aColor = COL_AUTO; + maColorTable.push_back( aColor ); nRed = 0; nGreen = 0; nBlue = 0; @@ -579,11 +577,7 @@ void SvxRTFParser::ReadFontTable() void SvxRTFParser::ClearColorTbl() { - while ( !aColorTbl.empty() ) - { - delete aColorTbl.back(); - aColorTbl.pop_back(); - } + maColorTable.clear(); } void SvxRTFParser::ClearAttrStack() diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx index 2069abb48877..5457cf9765ae 100644 --- a/include/editeng/svxrtf.hxx +++ b/include/editeng/svxrtf.hxx @@ -23,16 +23,15 @@ #include #include #include +#include #include -#include #include #include #include namespace vcl { class Font; } -class Color; struct SvxRTFStyleType; class SvxRTFItemStackType; class SvxRTFItemStackList : public std::vector> {}; @@ -160,7 +159,7 @@ struct RTFPardAttrMapIds class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser { - std::deque< Color* > aColorTbl; + std::vector maColorTable; SvxRTFFontTbl m_FontTable; SvxRTFStyleTbl m_StyleTable; std::deque< std::unique_ptr > aAttrStack; @@ -172,7 +171,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser std::unique_ptr pInsPos; SfxItemPool* pAttrPool; - std::unique_ptr pDfltColor; + std::optional mxDefaultColor; std::unique_ptr pDfltFont; std::unique_ptr pRTFDefaults; @@ -339,10 +338,9 @@ public: inline const Color& SvxRTFParser::GetColor( size_t nId ) const { - Color* pColor = pDfltColor.get(); - if( nId < aColorTbl.size() ) - pColor = aColorTbl[ nId ]; - return *pColor; + if( nId < maColorTable.size() ) + return maColorTable[ nId ]; + return *mxDefaultColor; } inline SfxItemSet& SvxRTFParser::GetAttrSet()