Kaydet (Commit) 281f1281 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in XclExpChTrCellContent

Change-Id: I8002f1bbb45a48244b981051abc02c1414a2fa34
Reviewed-on: https://gerrit.libreoffice.org/57361
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 1ea64c9d
...@@ -464,15 +464,15 @@ struct XclExpChTrData ...@@ -464,15 +464,15 @@ struct XclExpChTrData
class XclExpChTrCellContent final : public XclExpChTrAction, protected XclExpRoot class XclExpChTrCellContent final : public XclExpChTrAction, protected XclExpRoot
{ {
XclExpChTrData* pOldData; std::unique_ptr<XclExpChTrData> pOldData;
XclExpChTrData* pNewData; std::unique_ptr<XclExpChTrData> pNewData;
sal_uInt16 nOldLength; // this is not the record size sal_uInt16 nOldLength; // this is not the record size
ScAddress aPosition; ScAddress aPosition;
static void MakeEmptyChTrData( XclExpChTrData*& rpData ); static void MakeEmptyChTrData( std::unique_ptr<XclExpChTrData>& rpData );
void GetCellData( void GetCellData(
const XclExpRoot& rRoot, const ScCellValue& rScCell, XclExpChTrData*& rpData, const XclExpRoot& rRoot, const ScCellValue& rScCell, std::unique_ptr<XclExpChTrData>& rpData,
sal_uInt32& rXclLength1, sal_uInt16& rXclLength2 ); sal_uInt32& rXclLength1, sal_uInt16& rXclLength2 );
virtual void SaveActionData( XclExpStream& rStrm ) const override; virtual void SaveActionData( XclExpStream& rStrm ) const override;
......
...@@ -838,21 +838,21 @@ XclExpChTrCellContent::XclExpChTrCellContent( ...@@ -838,21 +838,21 @@ XclExpChTrCellContent::XclExpChTrCellContent(
XclExpChTrCellContent::~XclExpChTrCellContent() XclExpChTrCellContent::~XclExpChTrCellContent()
{ {
delete pOldData; pOldData.reset();
delete pNewData; pNewData.reset();
} }
void XclExpChTrCellContent::MakeEmptyChTrData( XclExpChTrData*& rpData ) void XclExpChTrCellContent::MakeEmptyChTrData( std::unique_ptr<XclExpChTrData>& rpData )
{ {
if( rpData ) if( rpData )
rpData->Clear(); rpData->Clear();
else else
rpData = new XclExpChTrData; rpData.reset( new XclExpChTrData );
} }
void XclExpChTrCellContent::GetCellData( void XclExpChTrCellContent::GetCellData(
const XclExpRoot& rRoot, const ScCellValue& rScCell, const XclExpRoot& rRoot, const ScCellValue& rScCell,
XclExpChTrData*& rpData, sal_uInt32& rXclLength1, sal_uInt16& rXclLength2 ) std::unique_ptr<XclExpChTrData>& rpData, sal_uInt32& rXclLength1, sal_uInt16& rXclLength2 )
{ {
MakeEmptyChTrData( rpData ); MakeEmptyChTrData( rpData );
rXclLength1 = 0x0000003A; rXclLength1 = 0x0000003A;
...@@ -860,8 +860,7 @@ void XclExpChTrCellContent::GetCellData( ...@@ -860,8 +860,7 @@ void XclExpChTrCellContent::GetCellData(
if (rScCell.isEmpty()) if (rScCell.isEmpty())
{ {
delete rpData; rpData.reset();
rpData = nullptr;
return; return;
} }
...@@ -1069,7 +1068,7 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm ) ...@@ -1069,7 +1068,7 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm )
FSEND ); FSEND );
if( pOldData ) if( pOldData )
{ {
lcl_WriteCell( rRevisionLogStrm, XML_oc, aPosition, pOldData ); lcl_WriteCell( rRevisionLogStrm, XML_oc, aPosition, pOldData.get() );
if (!pNewData) if (!pNewData)
{ {
pStream->singleElement(XML_nc, pStream->singleElement(XML_nc,
...@@ -1079,7 +1078,7 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm ) ...@@ -1079,7 +1078,7 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm )
} }
if( pNewData ) if( pNewData )
{ {
lcl_WriteCell( rRevisionLogStrm, XML_nc, aPosition, pNewData ); lcl_WriteCell( rRevisionLogStrm, XML_nc, aPosition, pNewData.get() );
} }
// OOXTODO: XML_odxf, XML_ndxf, XML_extLst elements // OOXTODO: XML_odxf, XML_ndxf, XML_extLst elements
pStream->endElement( XML_rcc ); pStream->endElement( XML_rcc );
......
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