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

Caolán McNamara caolanm at redhat.com
Thu Aug 25 21:44:19 UTC 2016


 sc/source/filter/xml/xmldpimp.cxx |   26 +++++++++++++-------------
 sc/source/filter/xml/xmldpimp.hxx |   16 ++++++++--------
 2 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit 74475239774daddc9accbafbf53725b44325260e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 25 21:21:54 2016 +0100

    coverity#704161 Resource leak in object
    
    Change-Id: I111f815526c3f50238f5df6f795abb397bb089e2

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 9f593d2..f57105f 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -949,7 +949,7 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
                                       ScXMLDataPilotTableContext* pTempDataPilotTable) :
     SvXMLImportContext( rImport, nPrfx, rLName ),
     pDataPilotTable(pTempDataPilotTable),
-    pDim(nullptr),
+    xDim(),
     fStart(0.0),
     fEnd(0.0),
     fStep(0.0),
@@ -1032,9 +1032,9 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
 
     if (bHasName)
     {
-        pDim = new ScDPSaveDimension(sName, bDataLayout);
+        xDim.reset(new ScDPSaveDimension(sName, bDataLayout));
         if (!aDisplayName.isEmpty())
-            pDim->SetLayoutName(aDisplayName);
+            xDim->SetLayoutName(aDisplayName);
     }
 }
 
@@ -1070,9 +1070,9 @@ SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( sal_uInt16 n
 
 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
 {
-    if (pDim)
+    if (xDim)
     {
-        pDim->AddMember(pMember);
+        xDim->AddMember(pMember);
         if (!pMember->GetIsVisible())
             // This member is hidden.
             mbHasHiddenMember = true;
@@ -1083,8 +1083,8 @@ void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
 
 void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString& rName)
 {
-    if (pDim)
-        pDim->SetSubtotalName(rName);
+    if (xDim)
+        xDim->SetSubtotalName(rName);
 }
 
 void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<OUString>& rMembers, const OUString& rName)
@@ -1097,16 +1097,16 @@ void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<OUString>& rMember
 
 void ScXMLDataPilotFieldContext::EndElement()
 {
-    if (pDim)
+    if (xDim)
     {
-        pDim->SetUsedHierarchy(nUsedHierarchy);
-        pDim->SetFunction(nFunction);
-        pDim->SetOrientation(nOrientation);
+        xDim->SetUsedHierarchy(nUsedHierarchy);
+        xDim->SetFunction(nFunction);
+        xDim->SetOrientation(nOrientation);
         if (bSelectedPage)
         {
-            pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage);
+            pDataPilotTable->SetSelectedPage(xDim->GetName(), sSelectedPage);
         }
-        pDataPilotTable->AddDimension(pDim);
+        pDataPilotTable->AddDimension(xDim.release());
         if (bIsGroupField)
         {
             ScDPNumGroupInfo aInfo;
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 17e5a32..5216263 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -304,7 +304,7 @@ struct ScXMLDataPilotGroup
 class ScXMLDataPilotFieldContext : public SvXMLImportContext
 {
     ScXMLDataPilotTableContext* pDataPilotTable;
-    ScDPSaveDimension*          pDim;
+    std::unique_ptr<ScDPSaveDimension> xDim;
 
     ::std::vector<ScXMLDataPilotGroup> aGroups;
     OUString                    sGroupSource;
@@ -342,15 +342,15 @@ public:
 
     virtual void EndElement() override;
 
-    void SetShowEmpty(const bool bValue) { if (pDim) pDim->SetShowEmpty(bValue); }
-    void SetRepeatItemLabels(const bool bSet) { if (pDim) pDim->SetRepeatItemLabels(bSet); }
-    void SetSubTotals(const sal_uInt16* pFunctions, const sal_Int16 nCount) { if(pDim) pDim->SetSubTotals(nCount, pFunctions); }
+    void SetShowEmpty(const bool bValue) { if (xDim) xDim->SetShowEmpty(bValue); }
+    void SetRepeatItemLabels(const bool bSet) { if (xDim) xDim->SetRepeatItemLabels(bSet); }
+    void SetSubTotals(const sal_uInt16* pFunctions, const sal_Int16 nCount) { if (xDim) xDim->SetSubTotals(nCount, pFunctions); }
     void AddMember(ScDPSaveMember* pMember);
     void SetSubTotalName(const OUString& rName);
-    void SetFieldReference(const css::sheet::DataPilotFieldReference& aRef) { if (pDim) pDim->SetReferenceValue(&aRef); }
-    void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (pDim) pDim->SetAutoShowInfo(&aInfo); }
-    void SetSortInfo(const css::sheet::DataPilotFieldSortInfo& aInfo) { if (pDim) pDim->SetSortInfo(&aInfo); }
-    void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo& aInfo) { if (pDim) pDim->SetLayoutInfo(&aInfo); }
+    void SetFieldReference(const css::sheet::DataPilotFieldReference& aRef) { if (xDim) xDim->SetReferenceValue(&aRef); }
+    void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (xDim) xDim->SetAutoShowInfo(&aInfo); }
+    void SetSortInfo(const css::sheet::DataPilotFieldSortInfo& aInfo) { if (xDim) xDim->SetSortInfo(&aInfo); }
+    void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo& aInfo) { if (xDim) xDim->SetLayoutInfo(&aInfo); }
     void SetGrouping(const OUString& rGroupSource, const double& rStart, const double& rEnd, const double& rStep,
         sal_Int32 nPart, bool bDate, bool bAutoSt, bool bAutoE)
     {


More information about the Libreoffice-commits mailing list