From 6ca077ee7156123ec38a6cfdde7168749589d0ff Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 1 Mar 2023 11:51:07 +0200 Subject: no need to allocate Gradient separately it is only one pointer big Change-Id: I21afdeb8015c658c7b9d5db24bceeb8e43694272 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148038 Tested-by: Jenkins Reviewed-by: Noel Grandin --- filter/source/svg/svgwriter.cxx | 15 ++++++++------- filter/source/svg/svgwriter.hxx | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'filter') diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index e4420dc27e71..d6909bcdb070 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2119,10 +2119,11 @@ void SVGActionWriter::ImplWriteShape( const SVGShapeDescriptor& rShape ) ImplMap( rShape.maShapePolyPoly, aPolyPoly ); const bool bLineOnly - = (rShape.maShapeFillColor == COL_TRANSPARENT) && (!rShape.mapShapeGradient); + = (rShape.maShapeFillColor == COL_TRANSPARENT) && (!rShape.moShapeGradient); tools::Rectangle aBoundRect( aPolyPoly.GetBoundRect() ); - maAttributeWriter.AddPaintAttr( rShape.maShapeLineColor, rShape.maShapeFillColor, &aBoundRect, rShape.mapShapeGradient.get() ); + maAttributeWriter.AddPaintAttr( rShape.maShapeLineColor, rShape.maShapeFillColor, &aBoundRect, + rShape.moShapeGradient ? &*rShape.moShapeGradient : nullptr ); if( !rShape.maId.isEmpty() ) mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, rShape.maId ); @@ -3440,7 +3441,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( bGradient ) { // step through following actions until the first Gradient/GradientEx action is found - while (!mapCurShape->mapShapeGradient && bSkip + while (!mapCurShape->moShapeGradient && bSkip && (++nCurAction < nCount)) { pAction = rMtf.GetAction( nCurAction ); @@ -3453,13 +3454,13 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, } else if( pAction->GetType() == MetaActionType::GRADIENTEX ) { - mapCurShape->mapShapeGradient.reset( new Gradient( - static_cast< const MetaGradientExAction* >( pAction )->GetGradient() ) ); + mapCurShape->moShapeGradient.emplace( + static_cast< const MetaGradientExAction* >( pAction )->GetGradient() ); } else if( pAction->GetType() == MetaActionType::GRADIENT ) { - mapCurShape->mapShapeGradient.reset( new Gradient( - static_cast< const MetaGradientAction* >( pAction )->GetGradient() ) ); + mapCurShape->moShapeGradient.emplace( + static_cast< const MetaGradientAction* >( pAction )->GetGradient() ); } } } diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index 022c2585c5ab..16ac77a20026 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -164,7 +164,7 @@ struct SVGShapeDescriptor Color maShapeLineColor; sal_Int32 mnStrokeWidth; SvtGraphicStroke::DashArray maDashArray; - ::std::unique_ptr< Gradient > mapShapeGradient; + ::std::optional< Gradient > moShapeGradient; OUString maId; basegfx::B2DLineJoin maLineJoin; css::drawing::LineCap maLineCap; -- cgit