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>
This commit is contained in:
parent
f49a6361ce
commit
39ae9d29be
2 changed files with 13 additions and 21 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue