Kaydet (Commit) f16f322c authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Michael Stahl

Adapt std::unique_ptr to SmMathConfig

Change-Id: I89c03719c1727aa70d187fcb6ba4630694549301
Reviewed-on: https://gerrit.libreoffice.org/14833Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 7867b976
...@@ -328,23 +328,19 @@ const OUString SmFontFormatList::GetNewFontFormatId() const ...@@ -328,23 +328,19 @@ const OUString SmFontFormatList::GetNewFontFormatId() const
SmMathConfig::SmMathConfig() : SmMathConfig::SmMathConfig() :
ConfigItem(OUString(aRootName)) ConfigItem(OUString(aRootName))
, pFormat()
, pOther()
, pFontFormatList()
, pSymbolMgr()
, bIsOtherModified(false)
, bIsFormatModified(false)
{ {
pFormat = 0;
pOther = 0;
pFontFormatList = 0;
pSymbolMgr = 0;
bIsOtherModified = bIsFormatModified = false;
} }
SmMathConfig::~SmMathConfig() SmMathConfig::~SmMathConfig()
{ {
Save(); Save();
delete pFormat;
delete pOther;
delete pFontFormatList;
delete pSymbolMgr;
} }
...@@ -461,7 +457,7 @@ SmSymbolManager & SmMathConfig::GetSymbolManager() ...@@ -461,7 +457,7 @@ SmSymbolManager & SmMathConfig::GetSymbolManager()
{ {
if (!pSymbolMgr) if (!pSymbolMgr)
{ {
pSymbolMgr = new SmSymbolManager; pSymbolMgr.reset(new SmSymbolManager);
pSymbolMgr->Load(); pSymbolMgr->Load();
} }
return *pSymbolMgr; return *pSymbolMgr;
...@@ -571,7 +567,7 @@ SmFontFormatList & SmMathConfig::GetFontFormatList() ...@@ -571,7 +567,7 @@ SmFontFormatList & SmMathConfig::GetFontFormatList()
void SmMathConfig::LoadFontFormatList() void SmMathConfig::LoadFontFormatList()
{ {
if (!pFontFormatList) if (!pFontFormatList)
pFontFormatList = new SmFontFormatList; pFontFormatList.reset(new SmFontFormatList);
else else
pFontFormatList->Clear(); pFontFormatList->Clear();
...@@ -750,8 +746,8 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols ) ...@@ -750,8 +746,8 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
// remove unused font-formats from list // remove unused font-formats from list
SmFontFormatList &rFntFmtList = GetFontFormatList(); SmFontFormatList &rFntFmtList = GetFontFormatList();
size_t nCnt = rFntFmtList.GetCount(); size_t nCnt = rFntFmtList.GetCount();
SmFontFormat *pTmpFormat = new SmFontFormat[ nCnt ]; std::unique_ptr<SmFontFormat[]> pTmpFormat(new SmFontFormat[ nCnt ]);
OUString *pId = new OUString [ nCnt ]; std::unique_ptr<OUString[]> pId(new OUString[ nCnt ]);
size_t k; size_t k;
for (k = 0; k < nCnt; ++k) for (k = 0; k < nCnt; ++k)
{ {
...@@ -765,15 +761,13 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols ) ...@@ -765,15 +761,13 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
rFntFmtList.RemoveFontFormat( pId[k] ); rFntFmtList.RemoveFontFormat( pId[k] );
} }
} }
delete [] pId;
delete [] pTmpFormat;
} }
void SmMathConfig::LoadOther() void SmMathConfig::LoadOther()
{ {
if (!pOther) if (!pOther)
pOther = new SmCfgOther; pOther.reset(new SmCfgOther);
pOther->bPrintTitle = officecfg::Office::Math::Print::Title::get(); pOther->bPrintTitle = officecfg::Office::Math::Print::Title::get();
pOther->bPrintFormulaText = officecfg::Office::Math::Print::FormulaText::get(); pOther->bPrintFormulaText = officecfg::Office::Math::Print::FormulaText::get();
...@@ -814,7 +808,7 @@ void SmMathConfig::SaveOther() ...@@ -814,7 +808,7 @@ void SmMathConfig::SaveOther()
void SmMathConfig::LoadFormat() void SmMathConfig::LoadFormat()
{ {
if (!pFormat) if (!pFormat)
pFormat = new SmFormat; pFormat.reset(new SmFormat);
Sequence< OUString > aNames = lcl_GetFormatPropertyNames(); Sequence< OUString > aNames = lcl_GetFormatPropertyNames();
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <symbol.hxx> #include <symbol.hxx>
#include <types.hxx> #include <types.hxx>
#include <memory>
class SmSym; class SmSym;
class SmFormat; class SmFormat;
...@@ -92,10 +93,10 @@ public: ...@@ -92,10 +93,10 @@ public:
class SmMathConfig : public utl::ConfigItem class SmMathConfig : public utl::ConfigItem
{ {
SmFormat * pFormat; std::unique_ptr<SmFormat> pFormat;
SmCfgOther * pOther; std::unique_ptr<SmCfgOther> pOther;
SmFontFormatList * pFontFormatList; std::unique_ptr<SmFontFormatList> pFontFormatList;
SmSymbolManager * pSymbolMgr; std::unique_ptr<SmSymbolManager> pSymbolMgr;
bool bIsOtherModified; bool bIsOtherModified;
bool bIsFormatModified; bool bIsFormatModified;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment