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

Noel Grandin noel.grandin at collabora.co.uk
Mon Apr 9 10:03:30 UTC 2018


 sc/source/filter/xml/xmlimprt.cxx |   85 ++++++++++++++++++--------------------
 sc/source/filter/xml/xmlimprt.hxx |   46 ++++++++++----------
 2 files changed, 65 insertions(+), 66 deletions(-)

New commits:
commit 2318501c14d9eb8cee050dc0d8f8ec646c520352
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 9 09:51:26 2018 +0200

    loplugin:useuniqueptr in ScXMLImport
    
    Change-Id: I49ea5e53c2826d78590c3f597683e22de256aacf
    Reviewed-on: https://gerrit.libreoffice.org/52616
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index c6f64e737540..86434cd10c0c 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -222,7 +222,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowCellAttrTokenMap()
     };
 
     if ( !pTableRowCellAttrTokenMap )
-        pTableRowCellAttrTokenMap = new SvXMLTokenMap( aTableRowCellAttrTokenMap );
+        pTableRowCellAttrTokenMap.reset(new SvXMLTokenMap( aTableRowCellAttrTokenMap ));
     return *pTableRowCellAttrTokenMap;
 }
 
@@ -435,7 +435,7 @@ const SvXMLTokenMap& ScXMLImport::GetDocElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap );
+        pDocElemTokenMap.reset(new SvXMLTokenMap( aDocTokenMap ));
 
     } // if( !pDocElemTokenMap )
 
@@ -455,7 +455,7 @@ const SvXMLTokenMap& ScXMLImport::GetContentValidationElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pContentValidationElemTokenMap = new SvXMLTokenMap( aContentValidationElemTokenMap );
+        pContentValidationElemTokenMap.reset(new SvXMLTokenMap( aContentValidationElemTokenMap ));
     } // if( !pContentValidationElemTokenMap )
 
     return *pContentValidationElemTokenMap;
@@ -471,7 +471,7 @@ const SvXMLTokenMap& ScXMLImport::GetContentValidationMessageElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pContentValidationMessageElemTokenMap = new SvXMLTokenMap( aContentValidationMessageElemTokenMap );
+        pContentValidationMessageElemTokenMap.reset(new SvXMLTokenMap( aContentValidationMessageElemTokenMap ));
     } // if( !pContentValidationMessageElemTokenMap )
 
     return *pContentValidationMessageElemTokenMap;
@@ -506,7 +506,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableElemTokenMap = new SvXMLTokenMap( aTableTokenMap );
+        pTableElemTokenMap.reset(new SvXMLTokenMap( aTableTokenMap ));
     } // if( !pTableElemTokenMap )
 
     return *pTableElemTokenMap;
@@ -525,7 +525,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowsElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableRowsElemTokenMap = new SvXMLTokenMap( aTableRowsElemTokenMap );
+        pTableRowsElemTokenMap.reset(new SvXMLTokenMap( aTableRowsElemTokenMap ));
     } // if( !pTableRowsElemTokenMap )
 
     return *pTableRowsElemTokenMap;
@@ -542,7 +542,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableRowElemTokenMap = new SvXMLTokenMap( aTableRowTokenMap );
+        pTableRowElemTokenMap.reset(new SvXMLTokenMap( aTableRowTokenMap ));
     } // if( !pTableRowElemTokenMap )
 
     return *pTableRowElemTokenMap;
@@ -562,7 +562,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowAttrTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableRowAttrTokenMap = new SvXMLTokenMap( aTableRowAttrTokenMap );
+        pTableRowAttrTokenMap.reset(new SvXMLTokenMap( aTableRowAttrTokenMap ));
     } // if( !pTableRowAttrTokenMap )
 
     return *pTableRowAttrTokenMap;
@@ -582,7 +582,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowCellElemTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableRowCellElemTokenMap = new SvXMLTokenMap( aTableRowCellTokenMap );
+        pTableRowCellElemTokenMap.reset(new SvXMLTokenMap( aTableRowCellTokenMap ));
     } // if( !pTableRowCellElemTokenMap )
 
     return *pTableRowCellElemTokenMap;
@@ -603,7 +603,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableAnnotationAttrTokenMap()
             XML_TOKEN_MAP_END
         };
 
-        pTableAnnotationAttrTokenMap = new SvXMLTokenMap( aTableAnnotationAttrTokenMap );
+        pTableAnnotationAttrTokenMap.reset(new SvXMLTokenMap( aTableAnnotationAttrTokenMap ));
     } // if( !pTableAnnotationAttrTokenMap )
 
     return *pTableAnnotationAttrTokenMap;
@@ -698,7 +698,7 @@ ScXMLImport::ScXMLImport(
     mbImportStyles(true),
     mbHasNewCondFormatData(false)
 {
-    pStylesImportHelper = new ScMyStylesImportHelper(*this);
+    pStylesImportHelper.reset(new ScMyStylesImportHelper(*this));
 
     xScPropHdlFactory = new XMLScPropHdlFactory;
     xCellStylesPropertySetMapper = new XMLPropertySetMapper(aXMLScCellStylesProperties, xScPropHdlFactory, false);
@@ -716,31 +716,31 @@ ScXMLImport::ScXMLImport(
 ScXMLImport::~ScXMLImport() throw()
 {
     //  delete pI18NMap;
-    delete pDocElemTokenMap;
-    delete pContentValidationElemTokenMap;
-    delete pContentValidationMessageElemTokenMap;
-    delete pTableElemTokenMap;
-    delete pTableRowsElemTokenMap;
-    delete pTableRowElemTokenMap;
-    delete pTableRowAttrTokenMap;
-    delete pTableRowCellElemTokenMap;
-    delete pTableRowCellAttrTokenMap;
-    delete pTableAnnotationAttrTokenMap;
-
-    delete pChangeTrackingImportHelper;
-    delete pNumberFormatAttributesExportHelper;
-    delete pStyleNumberFormats;
-    delete pStylesImportHelper;
-
-    delete m_pMyNamedExpressions;
-    delete pMyLabelRanges;
-    delete pValidations;
-    delete pDetectiveOpArray;
+    pDocElemTokenMap.reset();
+    pContentValidationElemTokenMap.reset();
+    pContentValidationMessageElemTokenMap.reset();
+    pTableElemTokenMap.reset();
+    pTableRowsElemTokenMap.reset();
+    pTableRowElemTokenMap.reset();
+    pTableRowAttrTokenMap.reset();
+    pTableRowCellElemTokenMap.reset();
+    pTableRowCellAttrTokenMap.reset();
+    pTableAnnotationAttrTokenMap.reset();
+
+    pChangeTrackingImportHelper.reset();
+    pNumberFormatAttributesExportHelper.reset();
+    pStyleNumberFormats.reset();
+    pStylesImportHelper.reset();
+
+    m_pMyNamedExpressions.reset();
+    pMyLabelRanges.reset();
+    pValidations.reset();
+    pDetectiveOpArray.reset();
 
     //call SvXMLImport dtor contents before deleting pSolarMutexGuard
     cleanup();
 
-    delete pSolarMutexGuard;
+    pSolarMutexGuard.reset();
 }
 
 void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& aArguments )
@@ -956,8 +956,8 @@ void ScXMLImport::AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp)
 ScXMLChangeTrackingImportHelper* ScXMLImport::GetChangeTrackingImportHelper()
 {
     if (!pChangeTrackingImportHelper)
-        pChangeTrackingImportHelper = new ScXMLChangeTrackingImportHelper();
-    return pChangeTrackingImportHelper;
+        pChangeTrackingImportHelper.reset(new ScXMLChangeTrackingImportHelper());
+    return pChangeTrackingImportHelper.get();
 }
 
 void ScXMLImport::InsertStyles()
@@ -1482,15 +1482,15 @@ bool ScXMLImport::SetNullDateOnUnitConverter()
 XMLNumberFormatAttributesExportHelper* ScXMLImport::GetNumberFormatAttributesExportHelper()
 {
     if (!pNumberFormatAttributesExportHelper)
-        pNumberFormatAttributesExportHelper = new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier());
-    return pNumberFormatAttributesExportHelper;
+        pNumberFormatAttributesExportHelper.reset(new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier()));
+    return pNumberFormatAttributesExportHelper.get();
 }
 
 ScMyStyleNumberFormats* ScXMLImport::GetStyleNumberFormats()
 {
     if (!pStyleNumberFormats)
-        pStyleNumberFormats = new ScMyStyleNumberFormats;
-    return pStyleNumberFormats;
+        pStyleNumberFormats.reset(new ScMyStyleNumberFormats);
+    return pStyleNumberFormats.get();
 }
 
 void ScXMLImport::SetStylesToRangesFinished()
@@ -1853,7 +1853,7 @@ void ScXMLImport::LockSolarMutex()
     if (nSolarMutexLocked == 0)
     {
         OSL_ENSURE(!pSolarMutexGuard, "Solar Mutex is locked");
-        pSolarMutexGuard = new SolarMutexGuard();
+        pSolarMutexGuard.reset(new SolarMutexGuard());
     }
     ++nSolarMutexLocked;
 }
@@ -1866,8 +1866,7 @@ void ScXMLImport::UnlockSolarMutex()
         if (nSolarMutexLocked == 0)
         {
             OSL_ENSURE(pSolarMutexGuard, "Solar Mutex is always unlocked");
-            delete pSolarMutexGuard;
-            pSolarMutexGuard = nullptr;
+            pSolarMutexGuard.reset();
         }
     }
 }
@@ -1999,8 +1998,8 @@ void ScXMLImport::NotifyEmbeddedFontRead()
 ScMyImpDetectiveOpArray* ScXMLImport::GetDetectiveOpArray()
 {
     if (!pDetectiveOpArray)
-        pDetectiveOpArray = new ScMyImpDetectiveOpArray();
-    return pDetectiveOpArray;
+        pDetectiveOpArray.reset(new ScMyImpDetectiveOpArray());
+    return pDetectiveOpArray.get();
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index ed7df03a0f79..59b4fb1fce18 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -242,8 +242,8 @@ class ScXMLImport: public SvXMLImport
     std::unique_ptr<sc::PivotTableSources> mpPivotSources;
 
     mutable std::unique_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
-    ScXMLChangeTrackingImportHelper*    pChangeTrackingImportHelper;
-    ScMyStylesImportHelper*        pStylesImportHelper;
+    std::unique_ptr<ScXMLChangeTrackingImportHelper>    pChangeTrackingImportHelper;
+    std::unique_ptr<ScMyStylesImportHelper>        pStylesImportHelper;
     OUString                       sNumberFormat;
     OUString                       sLocale;
     OUString                       sCellStyle;
@@ -254,32 +254,32 @@ class ScXMLImport: public SvXMLImport
     rtl::Reference < XMLPropertySetMapper >       xRowStylesPropertySetMapper;
     rtl::Reference < XMLPropertySetMapper >       xTableStylesPropertySetMapper;
 
-    SvXMLTokenMap           *pDocElemTokenMap;
-    SvXMLTokenMap           *pContentValidationElemTokenMap;
-    SvXMLTokenMap           *pContentValidationMessageElemTokenMap;
-    SvXMLTokenMap           *pTableElemTokenMap;
-    SvXMLTokenMap           *pTableRowsElemTokenMap;
-    SvXMLTokenMap           *pTableRowElemTokenMap;
-    SvXMLTokenMap           *pTableRowAttrTokenMap;
-    SvXMLTokenMap           *pTableRowCellElemTokenMap;
-    SvXMLTokenMap           *pTableRowCellAttrTokenMap;
-    SvXMLTokenMap           *pTableAnnotationAttrTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pDocElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pContentValidationElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pContentValidationMessageElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableRowsElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableRowElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableRowAttrTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableRowCellElemTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableRowCellAttrTokenMap;
+    std::unique_ptr<SvXMLTokenMap>           pTableAnnotationAttrTokenMap;
 
     sc::ImportPostProcessData* mpPostProcessData; /// Lift cycle managed elsewhere, no need to delete.
 
     ScMyTables              aTables;
 
-    ScMyNamedExpressions*   m_pMyNamedExpressions;
+    std::unique_ptr<ScMyNamedExpressions>   m_pMyNamedExpressions;
     SheetNamedExpMap m_SheetNamedExpressions;
 
-    ScMyLabelRanges*        pMyLabelRanges;
-    ScMyImportValidations*  pValidations;
-    ScMyImpDetectiveOpArray*    pDetectiveOpArray;
-    SolarMutexGuard*        pSolarMutexGuard;
+    std::unique_ptr<ScMyLabelRanges>            pMyLabelRanges;
+    std::unique_ptr<ScMyImportValidations>  pValidations;
+    std::unique_ptr<ScMyImpDetectiveOpArray>    pDetectiveOpArray;
+    std::unique_ptr<SolarMutexGuard>        pSolarMutexGuard;
 
     std::vector<OUString>          aTableStyles;
-    XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper;
-    ScMyStyleNumberFormats* pStyleNumberFormats;
+    std::unique_ptr<XMLNumberFormatAttributesExportHelper> pNumberFormatAttributesExportHelper;
+    std::unique_ptr<ScMyStyleNumberFormats> pStyleNumberFormats;
     css::uno::Reference <css::util::XNumberFormats> xNumberFormats;
     css::uno::Reference <css::util::XNumberFormatTypes> xNumberFormatTypes;
 
@@ -369,7 +369,7 @@ public:
     void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression)
     {
         if (!m_pMyNamedExpressions)
-            m_pMyNamedExpressions = new ScMyNamedExpressions;
+            m_pMyNamedExpressions.reset(new ScMyNamedExpressions);
         m_pMyNamedExpressions->push_back(std::unique_ptr<ScMyNamedExpression>(pMyNamedExpression));
     }
 
@@ -377,12 +377,12 @@ public:
 
     void AddLabelRange(std::unique_ptr<const ScMyLabelRange> pMyLabelRange) {
         if (!pMyLabelRanges)
-            pMyLabelRanges = new ScMyLabelRanges;
+            pMyLabelRanges.reset(new ScMyLabelRanges);
         pMyLabelRanges->push_back(std::move(pMyLabelRange)); }
 
     void AddValidation(const ScMyImportValidation& rValidation) {
         if (!pValidations)
-            pValidations = new ScMyImportValidations;
+            pValidations.reset(new ScMyImportValidations);
         pValidations->push_back(rValidation); }
     bool GetValidation(const OUString& sName, ScMyImportValidation& aValidation);
 
@@ -396,7 +396,7 @@ public:
     virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
 
     void SetTableStyle(const OUString& rValue) { aTableStyles.push_back(rValue); }
-    ScMyStylesImportHelper* GetStylesImportHelper() { return pStylesImportHelper; }
+    ScMyStylesImportHelper* GetStylesImportHelper() { return pStylesImportHelper.get(); }
     sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, const OUString& rCurrency);
     bool IsCurrencySymbol(const sal_Int32 nNumberFormat, const OUString& sCurrencySymbol, const OUString& sBankSymbol);
     void SetType(const css::uno::Reference <css::beans::XPropertySet>& rProperties,


More information about the Libreoffice-commits mailing list