compilerplugins/clang/store/returnunique.cxx | 82 +++++++++++++++++++++++++++ sc/source/filter/excel/xiescher.cxx | 75 ++++++++++-------------- sc/source/filter/inc/xcl97esc.hxx | 4 - sc/source/filter/inc/xiescher.hxx | 36 ++++++----- sc/source/filter/xcl97/xcl97esc.cxx | 12 +-- 5 files changed, 144 insertions(+), 65 deletions(-)
New commits: commit f94d4952dcf7fe8a46883184dc841b1f64274656 Author: Stephan Bergmann <[email protected]> Date: Tue Oct 6 12:44:15 2015 +0200 Commit loplugin:returnunique to store/, for reference Change-Id: I359d8ab47276e5c801522251d5e141946d94ca5d diff --git a/compilerplugins/clang/store/returnunique.cxx b/compilerplugins/clang/store/returnunique.cxx new file mode 100644 index 0000000..d028e13 --- /dev/null +++ b/compilerplugins/clang/store/returnunique.cxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// Find places where a std::unique_ptr is release()'ed and returned as a raw +// pointer. Some occurrences of that might better be rewritten to return the +// unique_ptr is returned directly. (But other occurrences might be fine the +// way they are, hence place this plugin into store/). + +#include "plugin.hxx" + +namespace { + +class ReturnUnique: + public RecursiveASTVisitor<ReturnUnique>, public loplugin::Plugin +{ +public: + explicit ReturnUnique(InstantiationData const & data): Plugin(data) {} + + void run() override { + if (compiler.getLangOpts().CPlusPlus) { + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } + } + + bool VisitReturnStmt(ReturnStmt const * stmt); +}; + +bool ReturnUnique::VisitReturnStmt(ReturnStmt const * stmt) { + if (ignoreLocation(stmt)) { + return true; + } + auto const e1 = stmt->getRetValue(); + if (e1 == nullptr) { + return true; + } + auto const e2 = dyn_cast<CXXMemberCallExpr>(e1->IgnoreParenImpCasts()); + if (e2 == nullptr) { + return true; + } + auto const d1 = e2->getMethodDecl(); + if (d1 == nullptr) { // call via ptr to member + return true; + } + auto const d2 = d1->getParent(); + assert(d2 != nullptr); + assert(d2->getParent() != nullptr); + auto const d3 = dyn_cast<NamespaceDecl>(d2->getParent()); + if (d3 == nullptr + /* || dyn_cast<TranslationUnitDecl>(d3->getParent()) == nullptr */) + { + return true; + } + auto const id3 = d3->getIdentifier(); + if (id3 == nullptr /* || id3->getName() != "std" */) { + return true; + } + auto const id2 = d2->getIdentifier(); + if (id2 == nullptr || id2->getName() != "unique_ptr") { + return true; + } + auto const id1 = d1->getIdentifier(); + if (id1 == nullptr || id1->getName() != "release") { + return true; + } + report( + DiagnosticsEngine::Warning, "return std::unique_ptr::release", + e2->getLocStart()) + << stmt->getSourceRange(); + return true; +} + +loplugin::Plugin::Registration<ReturnUnique> X("returnunique"); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 7f37d443cf20d4e556a1a3240546e29c63cb0df3 Author: Stephan Bergmann <[email protected]> Date: Tue Oct 6 12:40:15 2015 +0200 Return SdrObjectPtr from some XclImpDrawObjBase::Create... etc. functions Change-Id: Ia68b68aaca7feaacd2245254b2f2d110e669aaef diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 2bab340..a9c67e7 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -108,6 +108,7 @@ #include "namebuff.hxx" #include <sfx2/docfile.hxx> #include <memory> +#include <utility> using namespace com::sun::star; using ::com::sun::star::uno::makeAny; @@ -143,16 +144,6 @@ using ::com::sun::star::script::XEventAttacherManager; using ::com::sun::star::table::CellAddress; using ::com::sun::star::table::CellRangeAddress; -namespace { - -struct SdrObjectFree { - void operator ()(SdrObject * obj) { SdrObject::Free(obj); } -}; - -typedef std::unique_ptr<SdrObject, SdrObjectFree> SdrObjectPtr; - -} // namespace - // Drawing objects ============================================================ XclImpDrawObjBase::XclImpDrawObjBase( const XclImpRoot& rRoot ) : @@ -426,7 +417,7 @@ sal_Size XclImpDrawObjBase::GetProgressSize() const return DoGetProgressSize(); } -SdrObject* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const +SdrObjectPtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const { SdrObjectPtr xSdrObj; if( bIsDff && !mbCustomDff ) @@ -435,7 +426,7 @@ SdrObject* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, con } else { - xSdrObj.reset( DoCreateSdrObj( rDffConv, rAnchorRect ) ); + xSdrObj = DoCreateSdrObj( rDffConv, rAnchorRect ); if( xSdrObj ) xSdrObj->SetModel( rDffConv.GetModel() ); //added for exporting OCX control @@ -510,7 +501,7 @@ SdrObject* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, con } } } - return xSdrObj.release(); + return xSdrObj; } void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const @@ -811,7 +802,7 @@ sal_Size XclImpDrawObjBase::DoGetProgressSize() const return 1; } -SdrObject* XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& ) const +SdrObjectPtr XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& ) const { rDffConv.Progress( GetProgressSize() ); return 0; @@ -1027,7 +1018,7 @@ sal_Size XclImpGroupObj::DoGetProgressSize() const return XclImpDrawObjBase::DoGetProgressSize() + maChildren.GetProgressSize(); } -SdrObject* XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& /*rAnchorRect*/ ) const +SdrObjectPtr XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& /*rAnchorRect*/ ) const { std::unique_ptr<SdrObjGroup, SdrObjectFree> xSdrObj( new SdrObjGroup ); // child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle @@ -1035,7 +1026,7 @@ SdrObject* XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const R for( ::std::vector< XclImpDrawObjRef >::const_iterator aIt = maChildren.begin(), aEnd = maChildren.end(); aIt != aEnd; ++aIt ) rDffConv.ProcessObject( rObjList, **aIt ); rDffConv.Progress(); - return xSdrObj.release(); + return std::move(xSdrObj); } XclImpLineObj::XclImpLineObj( const XclImpRoot& rRoot ) : @@ -1074,7 +1065,7 @@ void XclImpLineObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI ReadMacro5( rStrm, nMacroSize ); } -SdrObject* XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { ::basegfx::B2DPolygon aB2DPolygon; switch( mnStartPoint ) @@ -1168,7 +1159,7 @@ SdrObject* XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Re } } rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } XclImpRectObj::XclImpRectObj( const XclImpRoot& rRoot ) : @@ -1210,12 +1201,12 @@ void XclImpRectObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI ReadMacro5( rStrm, nMacroSize ); } -SdrObject* XclImpRectObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpRectObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { SdrObjectPtr xSdrObj( new SdrRectObj( rAnchorRect ) ); ConvertRectStyle( *xSdrObj ); rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } XclImpOvalObj::XclImpOvalObj( const XclImpRoot& rRoot ) : @@ -1223,12 +1214,12 @@ XclImpOvalObj::XclImpOvalObj( const XclImpRoot& rRoot ) : { } -SdrObject* XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { SdrObjectPtr xSdrObj( new SdrCircObj( OBJ_CIRC, rAnchorRect ) ); ConvertRectStyle( *xSdrObj ); rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } XclImpArcObj::XclImpArcObj( const XclImpRoot& rRoot ) : @@ -1263,7 +1254,7 @@ void XclImpArcObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uIn ReadMacro5( rStrm, nMacroSize ); } -SdrObject* XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { Rectangle aNewRect = rAnchorRect; long nStartAngle = 0; @@ -1301,7 +1292,7 @@ SdrObject* XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rec ConvertFillStyle( *xSdrObj, maFillData ); ConvertLineStyle( *xSdrObj, maLineData ); rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } XclImpPolygonObj::XclImpPolygonObj( const XclImpRoot& rRoot ) : @@ -1361,7 +1352,7 @@ namespace { } // namespace -SdrObject* XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { SdrObjectPtr xSdrObj; if( maCoords.size() >= 2 ) @@ -1379,7 +1370,7 @@ SdrObject* XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const ConvertRectStyle( *xSdrObj ); } rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } void XclImpObjTextData::ReadByteString( XclImpStream& rStrm ) @@ -1435,7 +1426,7 @@ void XclImpTextObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI maTextData.ReadFormats( rStrm ); } -SdrObject* XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { std::unique_ptr<SdrObjCustomShape, SdrObjectFree> xSdrObj( new SdrObjCustomShape ); xSdrObj->NbcSetSnapRect( rAnchorRect ); @@ -1447,7 +1438,7 @@ SdrObject* XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Re xSdrObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoSize ) ); xSdrObj->SetMergedItem( makeSdrTextWordWrapItem( true ) ); rDffConv.Progress(); - return xSdrObj.release(); + return std::move(xSdrObj); } void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const @@ -1701,7 +1692,7 @@ sal_Size XclImpChartObj::DoGetProgressSize() const return mxChart ? mxChart->GetProgressSize() : 1; } -SdrObject* XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { SdrObjectPtr xSdrObj; SfxObjectShell* pDocShell = GetDocShell(); @@ -1729,7 +1720,7 @@ SdrObject* XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const R xSdrObj.reset( new SdrOle2Obj( svt::EmbeddedObjectRef( xEmbObj, nAspect ), aEmbObjName, rAnchorRect ) ); } - return xSdrObj.release(); + return xSdrObj; } void XclImpChartObj::DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const @@ -1828,7 +1819,7 @@ XclImpControlHelper::~XclImpControlHelper() { } -SdrObject* XclImpControlHelper::CreateSdrObjectFromShape( +SdrObjectPtr XclImpControlHelper::CreateSdrObjectFromShape( const Reference< XShape >& rxShape, const Rectangle& rAnchorRect ) const { mxShape = rxShape; @@ -1839,7 +1830,7 @@ SdrObject* XclImpControlHelper::CreateSdrObjectFromShape( // #i30543# insert into control layer xSdrObj->NbcSetLayer( SC_LAYER_CONTROLS ); } - return xSdrObj.release(); + return xSdrObj; } void XclImpControlHelper::ApplySheetLinkProps() const @@ -2074,11 +2065,11 @@ void XclImpTbxObjBase::ConvertLabel( ScfPropertySet& rPropSet ) const ConvertFont( rPropSet ); } -SdrObject* XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { SdrObjectPtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) ); rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } void XclImpTbxObjBase::DoPreProcessSdrObj( XclImpDffConverter& /*rDffConv*/, SdrObject& /*rSdrObj*/ ) const @@ -2949,7 +2940,7 @@ void XclImpPictureObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRec } } -SdrObject* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const +SdrObjectPtr XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const { // try to create an OLE object or form control SdrObjectPtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) ); @@ -2975,7 +2966,7 @@ SdrObject* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const } rDffConv.Progress(); - return xSdrObj.release(); + return xSdrObj; } OUString XclImpPictureObj::GetObjName() const @@ -3370,7 +3361,7 @@ void XclImpDffConverter::FinalizeDrawing() SetModel( &maDataStack.back()->mrSdrModel, 1440 ); } -SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect ) +SdrObjectPtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect ) { SdrObjectPtr xSdrObj; @@ -3387,7 +3378,7 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, XclImpDffConvData& rConvData = GetConvData(); if( rConvData.mxCtrlForm.is() && InsertControl( xFormComp, aDummySize, &xShape, true ) ) { - xSdrObj.reset( rTbxObj.CreateSdrObjectFromShape( xShape, rAnchorRect ) ); + xSdrObj = rTbxObj.CreateSdrObjectFromShape( xShape, rAnchorRect ); // try to attach a macro to the control ScriptEventDescriptor aDescriptor; if( (rConvData.mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) ) @@ -3401,10 +3392,10 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, { } - return xSdrObj.release(); + return xSdrObj; } -SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect ) +SdrObjectPtr XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect ) { SdrObjectPtr xSdrObj; @@ -3432,7 +3423,7 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, ScfPropertySet aPropSet( xFComp ); aPropSet.SetStringProperty( "Name", rPicObj.GetObjName() ); InsertControl( xFComp, aSz,&xShape,true); - xSdrObj.reset( rPicObj.CreateSdrObjectFromShape( xShape, rAnchorRect ) ); + xSdrObj = rPicObj.CreateSdrObjectFromShape( xShape, rAnchorRect ); } } } @@ -3469,7 +3460,7 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, } } - return xSdrObj.release(); + return xSdrObj; } bool XclImpDffConverter::SupportsOleObjects() const diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx index df48ba8..6e55d35 100644 --- a/sc/source/filter/inc/xiescher.hxx +++ b/sc/source/filter/inc/xiescher.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SC_SOURCE_FILTER_INC_XIESCHER_HXX #include <filter/msfilter/msdffimp.hxx> +#include <svx/svdobj.hxx> #include <vcl/graph.hxx> #include "xlescher.hxx" #include "xiroot.hxx" @@ -46,6 +47,11 @@ class XclImpDrawing; // Drawing objects ============================================================ +struct SdrObjectFree { + void operator ()(SdrObject * obj) { SdrObject::Free(obj); } +}; +typedef std::unique_ptr<SdrObject, SdrObjectFree> SdrObjectPtr; + class XclImpDrawObjBase; typedef std::shared_ptr< XclImpDrawObjBase > XclImpDrawObjRef; @@ -120,7 +126,7 @@ public: /** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */ sal_Size GetProgressSize() const; /** Creates and returns an SdrObject from the contained data. Caller takes ownership! */ - SdrObject* CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const; + SdrObjectPtr CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const; /** Additional processing for the passed SdrObject before insertion into the drawing page (calls virtual DoPreProcessSdrObj() function). */ void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const; @@ -165,7 +171,7 @@ protected: /** Derived classes may return a progress bar size different from 1. */ virtual sal_Size DoGetProgressSize() const; /** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const; /** Derived classes may perform additional processing for the passed SdrObject before insertion. */ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const; /** Derived classes may perform additional processing for the passed SdrObject after insertion. */ @@ -247,7 +253,7 @@ protected: /** Returns a progress bar size that takes all group children into account. */ virtual sal_Size DoGetProgressSize() const SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; protected: XclImpDrawObjVector maChildren; /// Grouped objects. @@ -268,7 +274,7 @@ protected: /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */ virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; protected: XclObjLineData maLineData; /// BIFF5 line formatting. @@ -296,7 +302,7 @@ protected: /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */ virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; protected: XclObjFillData maFillData; /// BIFF5 fill formatting. @@ -312,7 +318,7 @@ public: protected: /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; }; /** An arc object. */ @@ -329,7 +335,7 @@ protected: /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */ virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; protected: XclObjFillData maFillData; /// BIFF5 fill formatting. @@ -352,7 +358,7 @@ protected: /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */ virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; protected: typedef std::vector< Point > PointVector; @@ -389,7 +395,7 @@ protected: /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */ virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; /** Inserts the contained text data at the passed object. */ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE; @@ -419,7 +425,7 @@ protected: /** Returns the needed size on the progress bar. */ virtual sal_Size DoGetProgressSize() const SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; /** Converts the chart document. */ virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE; @@ -463,7 +469,7 @@ public: inline bool HasCellLink() const { return mxCellLink != 0; } /** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */ - SdrObject* CreateSdrObjectFromShape( + SdrObjectPtr CreateSdrObjectFromShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, const Rectangle& rAnchorRect ) const; @@ -517,7 +523,7 @@ protected: void ConvertLabel( ScfPropertySet& rPropSet ) const; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; /** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE; @@ -840,7 +846,7 @@ protected: /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */ virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE; /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */ - virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; + virtual SdrObjectPtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE; /** Override to do additional processing on the SdrObject. */ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE; @@ -948,9 +954,9 @@ public: void FinalizeDrawing(); /** Creates the SdrObject for the passed Excel TBX form control object. */ - SdrObject* CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect ); + SdrObjectPtr CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect ); /** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */ - SdrObject* CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect ); + SdrObjectPtr CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect ); /** Returns true, if the conversion of OLE objects is supported. */ bool SupportsOleObjects() const; commit baa9c806e8730741d36009065d203121f623d5d9 Author: Stephan Bergmann <[email protected]> Date: Tue Oct 6 12:36:04 2015 +0200 Return std::unique_ptr from some XclEscherEx::Create... functions ...even if, for now, the return values are directly release()'ed anyway at the call sites Change-Id: I118c74787260b1ec7eabf5e300580aa5a16b2cfa diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx index a101bef..2cc94f5 100644 --- a/sc/source/filter/inc/xcl97esc.hxx +++ b/sc/source/filter/inc/xcl97esc.hxx @@ -101,14 +101,14 @@ public: void EndDocument(); /** Creates an OCX form control OBJ record from the passed form control. @descr Writes the form control data to the 'Ctls' stream. */ - XclExpOcxControlObj* CreateOCXCtrlObj( + std::unique_ptr<XclExpOcxControlObj> CreateOCXCtrlObj( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Rectangle* pChildAnchor ); private: tools::SvRef<SotStorageStream> mxCtlsStrm; /// The 'Ctls' stream. /** Creates a TBX form control OBJ record from the passed form control. */ - XclExpTbxControlObj* CreateTBXCtrlObj( + std::unique_ptr<XclExpTbxControlObj> CreateTBXCtrlObj( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Rectangle* pChildAnchor ); diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx index 6a36a78..28a2e16 100644 --- a/sc/source/filter/xcl97/xcl97esc.cxx +++ b/sc/source/filter/xcl97/xcl97esc.cxx @@ -251,9 +251,9 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape OSL_TRACE("XclEscherEx::StartShape, this control can't get the property ControlTypeinMSO!"); } if( nMsCtlType == 2 ) //OCX Form Control - pCurrXclObj = CreateOCXCtrlObj( rxShape, pChildAnchor ); + pCurrXclObj = CreateOCXCtrlObj( rxShape, pChildAnchor ).release(); else //TBX Form Control - pCurrXclObj = CreateTBXCtrlObj( rxShape, pChildAnchor ); + pCurrXclObj = CreateTBXCtrlObj( rxShape, pChildAnchor ).release(); if( !pCurrXclObj ) pCurrXclObj = new XclObjAny( mrObjMgr, rxShape, &GetDocRef() ); // just a metafile } @@ -408,7 +408,7 @@ void XclEscherEx::EndDocument() mpOutStrm->Seek( 0 ); } -XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) +std::unique_ptr<XclExpOcxControlObj> XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::unique_ptr< XclExpOcxControlObj > xOcxCtrl; @@ -435,10 +435,10 @@ XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, } } } - return xOcxCtrl.release(); + return xOcxCtrl; } -XclExpTbxControlObj* XclEscherEx::CreateTBXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) +std::unique_ptr<XclExpTbxControlObj> XclEscherEx::CreateTBXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::unique_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( mrObjMgr, xShape, pChildAnchor ) ); if( xTbxCtrl->GetObjType() == EXC_OBJTYPE_UNKNOWN ) @@ -450,7 +450,7 @@ XclExpTbxControlObj* XclEscherEx::CreateTBXCtrlObj( Reference< XShape > xShape, Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape ); ConvertTbxMacro( *xTbxCtrl, xCtrlModel ); } - return xTbxCtrl.release(); + return xTbxCtrl; } void XclEscherEx::ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, Reference< XControlModel > xCtrlModel ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
