Kaydet (Commit) abbfb33c authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#982280 Resource leak in object

Change-Id: I005ed6f44925df7f380eadc4f9971bc1c030a0ca
üst 71c60f8f
...@@ -86,8 +86,8 @@ ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImpo ...@@ -86,8 +86,8 @@ ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImpo
ScRangeStringConverter::GetRangeListFromString(maRange, sRange, GetScImport().GetDocument(), ScRangeStringConverter::GetRangeListFromString(maRange, sRange, GetScImport().GetDocument(),
formula::FormulaGrammar::CONV_ODF); formula::FormulaGrammar::CONV_ODF);
mpFormat = new ScConditionalFormat(0, GetScImport().GetDocument()); mxFormat.reset(new ScConditionalFormat(0, GetScImport().GetDocument()));
mpFormat->AddRange(maRange); mxFormat->AddRange(maRange);
} }
SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt16 nPrefix, SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt16 nPrefix,
...@@ -101,19 +101,19 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1 ...@@ -101,19 +101,19 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1
switch (nToken) switch (nToken)
{ {
case XML_TOK_CONDFORMAT_CONDITION: case XML_TOK_CONDFORMAT_CONDITION:
pContext = new ScXMLCondContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat ); pContext = new ScXMLCondContext( GetScImport(), nPrefix, rLocalName, xAttrList, mxFormat.get() );
break; break;
case XML_TOK_CONDFORMAT_COLORSCALE: case XML_TOK_CONDFORMAT_COLORSCALE:
pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, mpFormat ); pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, mxFormat.get() );
break; break;
case XML_TOK_CONDFORMAT_DATABAR: case XML_TOK_CONDFORMAT_DATABAR:
pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat ); pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mxFormat.get() );
break; break;
case XML_TOK_CONDFORMAT_ICONSET: case XML_TOK_CONDFORMAT_ICONSET:
pContext = new ScXMLIconSetFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat ); pContext = new ScXMLIconSetFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mxFormat.get() );
break; break;
case XML_TOK_CONDFORMAT_DATE: case XML_TOK_CONDFORMAT_DATE:
pContext = new ScXMLDateContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat ); pContext = new ScXMLDateContext( GetScImport(), nPrefix, rLocalName, xAttrList, mxFormat.get() );
break; break;
default: default:
break; break;
...@@ -127,10 +127,15 @@ void ScXMLConditionalFormatContext::EndElement() ...@@ -127,10 +127,15 @@ void ScXMLConditionalFormatContext::EndElement()
ScDocument* pDoc = GetScImport().GetDocument(); ScDocument* pDoc = GetScImport().GetDocument();
SCTAB nTab = GetScImport().GetTables().GetCurrentSheet(); SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
sal_uLong nIndex = pDoc->AddCondFormat(mpFormat, nTab); ScConditionalFormat* pFormat = mxFormat.release();
mpFormat->SetKey(nIndex); sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
pFormat->SetKey(nIndex);
pDoc->AddCondFormatData( mpFormat->GetRange(), nTab, nIndex); pDoc->AddCondFormatData( pFormat->GetRange(), nTab, nIndex);
}
ScXMLConditionalFormatContext::~ScXMLConditionalFormatContext()
{
} }
ScXMLColorScaleFormatContext::ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx, ScXMLColorScaleFormatContext::ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList); ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
virtual ~ScXMLConditionalFormatContext() {} virtual ~ScXMLConditionalFormatContext();
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName, const OUString& rLocalName,
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
virtual void EndElement() SAL_OVERRIDE; virtual void EndElement() SAL_OVERRIDE;
private: private:
ScConditionalFormat* mpFormat; std::unique_ptr<ScConditionalFormat> mxFormat;
ScRangeList maRange; ScRangeList maRange;
}; };
......
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