editeng/source/rtf/svxrtf.cxx | 20 +++++++------------- include/editeng/svxrtf.hxx | 14 ++++++-------- 2 files changed, 13 insertions(+), 21 deletions(-)
New commits: commit 39ae9d29be0b4308b6e6ab7ee52c3fe6d6dc7d0c Author: Noel <noelgran...@gmail.com> AuthorDate: Mon Oct 26 10:17:14 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Oct 26 13:01:53 2020 +0100 std::unique_ptr -> std::optional Change-Id: Icd4c818579a7b15454706ab4e02d47e1ac368160 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104796 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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 <svl/itemset.hxx> #include <svtools/parrtf.hxx> #include <rtl/ustring.hxx> +#include <tools/color.hxx> #include <editeng/editengdllapi.h> -#include <deque> #include <vector> #include <map> #include <memory> namespace vcl { class Font; } -class Color; struct SvxRTFStyleType; class SvxRTFItemStackType; class SvxRTFItemStackList : public std::vector<std::unique_ptr<SvxRTFItemStackType>> {}; @@ -160,7 +159,7 @@ struct RTFPardAttrMapIds class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser { - std::deque< Color* > aColorTbl; + std::vector<Color> maColorTable; SvxRTFFontTbl m_FontTable; SvxRTFStyleTbl m_StyleTable; std::deque< std::unique_ptr<SvxRTFItemStackType> > aAttrStack; @@ -172,7 +171,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser std::unique_ptr<EditPosition> pInsPos; SfxItemPool* pAttrPool; - std::unique_ptr<Color> pDfltColor; + std::optional<Color> mxDefaultColor; std::unique_ptr<vcl::Font> pDfltFont; std::unique_ptr<SfxItemSet> 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() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits