[Libreoffice-commits] core.git: starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Mar 11 13:22:37 PDT 2015


 starmath/source/cfgitem.cxx |   30 ++++++++++++------------------
 starmath/source/cfgitem.hxx |    9 +++++----
 2 files changed, 17 insertions(+), 22 deletions(-)

New commits:
commit f16f322ce4cbdfbd01b74eea8f68038fe0cb457f
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Mar 11 18:45:33 2015 +0900

    Adapt std::unique_ptr to SmMathConfig
    
    Change-Id: I89c03719c1727aa70d187fcb6ba4630694549301
    Reviewed-on: https://gerrit.libreoffice.org/14833
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index 3b12c54..7616043 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 2fe2cdd..5b881eb 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;
 


More information about the Libreoffice-commits mailing list