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