diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2015-03-11 18:45:33 +0900 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-03-11 20:22:12 +0000 |
commit | f16f322ce4cbdfbd01b74eea8f68038fe0cb457f (patch) | |
tree | 96ec53e49cb665c8b881e5736a014ca70bebe692 /starmath | |
parent | 7867b976e8cb68a30df3cc825ccaa021269e219a (diff) |
Adapt std::unique_ptr to SmMathConfig
Change-Id: I89c03719c1727aa70d187fcb6ba4630694549301
Reviewed-on: https://gerrit.libreoffice.org/14833
Tested-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/cfgitem.cxx | 30 | ||||
-rw-r--r-- | starmath/source/cfgitem.hxx | 9 |
2 files changed, 17 insertions, 22 deletions
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 3b12c54ed722..7616043124e8 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -328,23 +328,19 @@ const OUString SmFontFormatList::GetNewFontFormatId() const SmMathConfig::SmMathConfig() : ConfigItem(OUString(aRootName)) + , pFormat() + , pOther() + , pFontFormatList() + , pSymbolMgr() + , bIsOtherModified(false) + , bIsFormatModified(false) { - pFormat = 0; - pOther = 0; - pFontFormatList = 0; - pSymbolMgr = 0; - - bIsOtherModified = bIsFormatModified = false; } SmMathConfig::~SmMathConfig() { Save(); - delete pFormat; - delete pOther; - delete pFontFormatList; - delete pSymbolMgr; } @@ -461,7 +457,7 @@ SmSymbolManager & SmMathConfig::GetSymbolManager() { if (!pSymbolMgr) { - pSymbolMgr = new SmSymbolManager; + pSymbolMgr.reset(new SmSymbolManager); pSymbolMgr->Load(); } return *pSymbolMgr; @@ -571,7 +567,7 @@ SmFontFormatList & SmMathConfig::GetFontFormatList() void SmMathConfig::LoadFontFormatList() { if (!pFontFormatList) - pFontFormatList = new SmFontFormatList; + pFontFormatList.reset(new SmFontFormatList); else pFontFormatList->Clear(); @@ -750,8 +746,8 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols ) // remove unused font-formats from list SmFontFormatList &rFntFmtList = GetFontFormatList(); size_t nCnt = rFntFmtList.GetCount(); - SmFontFormat *pTmpFormat = new SmFontFormat[ nCnt ]; - OUString *pId = new OUString [ nCnt ]; + std::unique_ptr<SmFontFormat[]> pTmpFormat(new SmFontFormat[ nCnt ]); + std::unique_ptr<OUString[]> pId(new OUString[ nCnt ]); size_t k; for (k = 0; k < nCnt; ++k) { @@ -765,15 +761,13 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols ) rFntFmtList.RemoveFontFormat( pId[k] ); } } - delete [] pId; - delete [] pTmpFormat; } void SmMathConfig::LoadOther() { if (!pOther) - pOther = new SmCfgOther; + pOther.reset(new SmCfgOther); pOther->bPrintTitle = officecfg::Office::Math::Print::Title::get(); pOther->bPrintFormulaText = officecfg::Office::Math::Print::FormulaText::get(); @@ -814,7 +808,7 @@ void SmMathConfig::SaveOther() void SmMathConfig::LoadFormat() { if (!pFormat) - pFormat = new SmFormat; + pFormat.reset(new SmFormat); Sequence< OUString > aNames = lcl_GetFormatPropertyNames(); diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx index 2fe2cdd8c03d..5b881eba6f9c 100644 --- a/starmath/source/cfgitem.hxx +++ b/starmath/source/cfgitem.hxx @@ -33,6 +33,7 @@ #include <symbol.hxx> #include <types.hxx> +#include <memory> class SmSym; class SmFormat; @@ -92,10 +93,10 @@ public: class SmMathConfig : public utl::ConfigItem { - SmFormat * pFormat; - SmCfgOther * pOther; - SmFontFormatList * pFontFormatList; - SmSymbolManager * pSymbolMgr; + std::unique_ptr<SmFormat> pFormat; + std::unique_ptr<SmCfgOther> pOther; + std::unique_ptr<SmFontFormatList> pFontFormatList; + std::unique_ptr<SmSymbolManager> pSymbolMgr; bool bIsOtherModified; bool bIsFormatModified; |