From 2d2329f441aa67e8be9f77dcfa3d048e50651357 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 2 Dec 2016 10:09:15 +0000 Subject: coverity#1371200 Missing move assignment operator adjust things to not need one Change-Id: I1079f50d8813f86c4828be602687b4cbffe61415 --- slideshow/source/engine/shapes/backgroundshape.cxx | 23 +++++++------ slideshow/source/engine/shapes/drawshape.cxx | 24 ++++++------- slideshow/source/engine/shapes/gdimtftools.cxx | 39 +++++++++++----------- slideshow/source/engine/shapes/gdimtftools.hxx | 11 +++--- 4 files changed, 48 insertions(+), 49 deletions(-) (limited to 'slideshow/source') diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index 4b4a5b1384a0..b119d8ac77ed 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -123,16 +123,20 @@ namespace slideshow { uno::Reference< beans::XPropertySet > xPropSet( xDrawPage, uno::UNO_QUERY_THROW ); - GDIMetaFileSharedPtr pMtf( new GDIMetaFile() ); - // first try the page background (overrides // masterpage background), then try masterpage - if( !getMetaFile( uno::Reference(xDrawPage, uno::UNO_QUERY), - xDrawPage, *pMtf, MTF_LOAD_BACKGROUND_ONLY, - rContext.mxComponentContext ) && - !getMetaFile( uno::Reference(xMasterPage, uno::UNO_QUERY), - xDrawPage, *pMtf, MTF_LOAD_BACKGROUND_ONLY, - rContext.mxComponentContext )) + GDIMetaFileSharedPtr xMtf = getMetaFile(uno::Reference(xDrawPage, uno::UNO_QUERY), + xDrawPage, MTF_LOAD_BACKGROUND_ONLY, + rContext.mxComponentContext); + + if (!xMtf) + { + xMtf = getMetaFile( uno::Reference(xMasterPage, uno::UNO_QUERY), + xDrawPage, MTF_LOAD_BACKGROUND_ONLY, + rContext.mxComponentContext ); + } + + if (!xMtf) { throw ShapeLoadFailedException(); } @@ -140,13 +144,12 @@ namespace slideshow // there is a special background shape, add it // as the first one - sal_Int32 nDocWidth=0; sal_Int32 nDocHeight=0; xPropSet->getPropertyValue("Width") >>= nDocWidth; xPropSet->getPropertyValue("Height") >>= nDocHeight; - mpMtf = pMtf; + mpMtf = xMtf; maBounds = ::basegfx::B2DRectangle( 0,0,nDocWidth, nDocHeight ); } diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 877049b0b5ae..6bbdc534793f 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -82,12 +82,13 @@ namespace slideshow if ((mnCurrMtfLoadFlags & MTF_LOAD_SCROLL_TEXT_MTF) != MTF_LOAD_SCROLL_TEXT_MTF) { // reload with added flags: - mpCurrMtf.reset( new GDIMetaFile ); mnCurrMtfLoadFlags |= MTF_LOAD_SCROLL_TEXT_MTF; - getMetaFile( - uno::Reference(mxShape, uno::UNO_QUERY), - mxPage, *mpCurrMtf, mnCurrMtfLoadFlags, - mxComponentContext ); + mpCurrMtf = getMetaFile(uno::Reference(mxShape, uno::UNO_QUERY), + mxPage, mnCurrMtfLoadFlags, + mxComponentContext); + + if (!mpCurrMtf) + mpCurrMtf.reset( new GDIMetaFile ); // TODO(F1): Currently, the scroll metafile will // never contain any verbose text comments. Thus, @@ -402,13 +403,12 @@ namespace slideshow // must NOT be called from within initializer list, uses // state from mnCurrMtfLoadFlags! - mpCurrMtf.reset( new GDIMetaFile ); - getMetaFile( - uno::Reference(xShape, uno::UNO_QUERY), - xContainingPage, *mpCurrMtf, mnCurrMtfLoadFlags, - mxComponentContext ); - ENSURE_OR_THROW( mpCurrMtf, - "DrawShape::DrawShape(): Invalid metafile" ); + mpCurrMtf = getMetaFile(uno::Reference(xShape, uno::UNO_QUERY), + xContainingPage, mnCurrMtfLoadFlags, + mxComponentContext ); + if (!mpCurrMtf) + mpCurrMtf.reset(new GDIMetaFile); + maSubsetting.reset( mpCurrMtf ); prepareHyperlinkIndices(); diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index 6cd569e37aa1..c515b7a9fac1 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -127,7 +127,7 @@ public: against unsupported content, and, if necessary, returned as a pre-rendererd bitmap. */ - GDIMetaFile getMtf( bool bForeignSource ) const + GDIMetaFileSharedPtr getMtf( bool bForeignSource ) const { ::osl::MutexGuard aGuard( m_aMutex ); @@ -138,22 +138,19 @@ public: hasUnsupportedActions(aGraphic.GetGDIMetaFile()) ) ) { // wrap bitmap into GDIMetafile - GDIMetaFile aMtf; + GDIMetaFileSharedPtr xMtf(new GDIMetaFile); ::Point aEmptyPoint; ::BitmapEx aBmpEx( aGraphic.GetBitmapEx() ); - aMtf.AddAction( new MetaBmpExAction( aEmptyPoint, + xMtf->AddAction( new MetaBmpExAction( aEmptyPoint, aBmpEx ) ); - aMtf.SetPrefSize( aBmpEx.GetPrefSize() ); - aMtf.SetPrefMapMode( aBmpEx.GetPrefMapMode() ); + xMtf->SetPrefSize( aBmpEx.GetPrefSize() ); + xMtf->SetPrefMapMode( aBmpEx.GetPrefMapMode() ); - return aMtf; - } - else - { - return aGraphic.GetGDIMetaFile(); + return xMtf; } + return GDIMetaFileSharedPtr(new GDIMetaFile(aGraphic.GetGDIMetaFile())); } private: @@ -164,14 +161,16 @@ private: // Quick'n'dirty way: tunnel Graphic (only works for // in-process slideshow, of course) -bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, - const uno::Reference< drawing::XDrawPage >& xContainingPage, - GDIMetaFile& rMtf, - int mtfLoadFlags, - const uno::Reference< uno::XComponentContext >& rxContext ) +GDIMetaFileSharedPtr getMetaFile( const uno::Reference< lang::XComponent >& xSource, + const uno::Reference< drawing::XDrawPage >& xContainingPage, + int mtfLoadFlags, + const uno::Reference< uno::XComponentContext >& rxContext ) { - ENSURE_OR_RETURN_FALSE( rxContext.is(), - "getMetaFile(): Invalid context" ); + if (!rxContext.is()) + { + SAL_WARN("slideshow.opengl", "getMetaFile(): Invalid context" ); + return GDIMetaFileSharedPtr(); + } // create dummy XGraphicRenderer, which receives the // generated XGraphic from the GraphicExporter @@ -212,9 +211,9 @@ bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, xExporter->setSourceDocument( xSource ); if( !xExporter->filter( aProps ) ) - return false; + return GDIMetaFileSharedPtr(); - rMtf = pRenderer->getMtf( (mtfLoadFlags & MTF_LOAD_FOREIGN_SOURCE) != 0 ); + GDIMetaFileSharedPtr xMtf = pRenderer->getMtf( (mtfLoadFlags & MTF_LOAD_FOREIGN_SOURCE) != 0 ); // pRenderer is automatically destroyed when xRenderer // goes out of scope @@ -222,7 +221,7 @@ bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, // TODO(E3): Error handling. Exporter might have // generated nothing, a bitmap, threw an exception, // whatever. - return true; + return xMtf; } sal_Int32 getNextActionOffset( MetaAction * pCurrAct ) diff --git a/slideshow/source/engine/shapes/gdimtftools.hxx b/slideshow/source/engine/shapes/gdimtftools.hxx index 59e91c554686..d27e6ed5d89b 100644 --- a/slideshow/source/engine/shapes/gdimtftools.hxx +++ b/slideshow/source/engine/shapes/gdimtftools.hxx @@ -90,14 +90,11 @@ namespace slideshow import (currently, the UnoGraphicExporter needs this information). - @param o_rMtf - Metafile to extract shape content into */ - bool getMetaFile( const css::uno::Reference< css::lang::XComponent >& xSource, - const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage, - GDIMetaFile& o_rMtf, - int mtfLoadFlags, - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + GDIMetaFileSharedPtr getMetaFile( const css::uno::Reference< css::lang::XComponent >& xSource, + const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage, + int mtfLoadFlags, + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); /** Gets the next action offset for iterating meta actions which is most often returns 1. -- cgit