summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-10-26 10:17:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-26 13:01:53 +0100
commit39ae9d29be0b4308b6e6ab7ee52c3fe6d6dc7d0c (patch)
treec61e0c7a553190e165e69ba9180f50e69399388d
parentf49a6361ce4d7dc4efaca0b1701a3ca0e0702eb2 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--editeng/source/rtf/svxrtf.cxx20
-rw-r--r--include/editeng/svxrtf.hxx14
2 files changed, 13 insertions, 21 deletions
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()