summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-08-25 13:00:41 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-08-25 13:06:02 +0200
commit6797610bcfc41d2af57db03c5d9b52cfc30d09ed (patch)
tree61204dca0b766544962961a104f8db9bb6559ace /oox
parent0e061bd9a6d6c464bb63043d99257a36dc740496 (diff)
use ptr_vector to prevent memory leak
Found by Lsan. Change-Id: I727098ea3861bacf89209615e4b46e986a72c1ce
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/effectproperties.cxx16
-rw-r--r--oox/source/drawingml/effectproperties.hxx4
-rw-r--r--oox/source/drawingml/effectpropertiescontext.cxx24
-rw-r--r--oox/source/drawingml/shape.cxx6
4 files changed, 26 insertions, 24 deletions
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
index da94669561ab..2fa608aef1cf 100644
--- a/oox/source/drawingml/effectproperties.cxx
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -35,16 +35,16 @@ void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
const GraphicHelper& rGraphicHelper ) const
{
- for( std::vector< Effect* >::const_iterator it = maEffects.begin(); it != maEffects.end(); ++it )
- if( (*it)->msName == "outerShdw" )
+ for( boost::ptr_vector< Effect >::const_iterator it = maEffects.begin(); it != maEffects.end(); ++it )
+ if( it->msName == "outerShdw" )
{
sal_Int32 nAttrDir = 0, nAttrDist = 0;
- std::map< OUString, css::uno::Any >::iterator attribIt = (*it)->maAttribs.find( "dir" );
- if( attribIt != (*it)->maAttribs.end() )
+ std::map< OUString, css::uno::Any >::const_iterator attribIt = it->maAttribs.find( "dir" );
+ if( attribIt != it->maAttribs.end() )
attribIt->second >>= nAttrDir;
- attribIt = (*it)->maAttribs.find( "dist" );
- if( attribIt != (*it)->maAttribs.end() )
+ attribIt = it->maAttribs.find( "dist" );
+ if( attribIt != it->maAttribs.end() )
attribIt->second >>= nAttrDist;
// Negative X or Y dist indicates left or up, respectively
@@ -56,8 +56,8 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
rPropMap.setProperty( PROP_Shadow, true );
rPropMap.setProperty( PROP_ShadowXDistance, nXDist);
rPropMap.setProperty( PROP_ShadowYDistance, nYDist);
- rPropMap.setProperty( PROP_ShadowColor, (*it)->moColor.getColor(rGraphicHelper, -1 ) );
- rPropMap.setProperty( PROP_ShadowTransparence, (*it)->moColor.getTransparency());
+ rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper, -1 ) );
+ rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency());
}
}
diff --git a/oox/source/drawingml/effectproperties.hxx b/oox/source/drawingml/effectproperties.hxx
index dae858c82db4..4256b8d776d3 100644
--- a/oox/source/drawingml/effectproperties.hxx
+++ b/oox/source/drawingml/effectproperties.hxx
@@ -14,6 +14,8 @@
#include <oox/drawingml/color.hxx>
#include <oox/helper/propertymap.hxx>
+#include <boost/ptr_container/ptr_vector.hpp>
+
namespace oox {
namespace drawingml {
@@ -42,7 +44,7 @@ struct EffectProperties
EffectShadowProperties maShadow;
/** Stores all effect properties, including those not supported by core yet */
- std::vector< Effect* > maEffects;
+ boost::ptr_vector< Effect > maEffects;
/** Overwrites all members that are explicitly set in rSourceProps. */
void assignUsed( const EffectProperties& rSourceProps );
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index c99d364c83c6..7d6549cc0785 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -76,22 +76,22 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
{
case A_TOKEN( outerShdw ):
{
- mrEffectProperties.maEffects[nPos]->msName = "outerShdw";
- saveUnsupportedAttribs( *mrEffectProperties.maEffects[nPos], rAttribs );
+ mrEffectProperties.maEffects[nPos].msName = "outerShdw";
+ saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
- return new ColorContext( *this, mrEffectProperties.maEffects[nPos]->moColor );
+ return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
}
break;
case A_TOKEN( innerShdw ):
{
- mrEffectProperties.maEffects[nPos]->msName = "innerShdw";
- saveUnsupportedAttribs( *mrEffectProperties.maEffects[nPos], rAttribs );
+ mrEffectProperties.maEffects[nPos].msName = "innerShdw";
+ saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
- return new ColorContext( *this, mrEffectProperties.maEffects[nPos]->moColor );
+ return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
}
break;
case A_TOKEN( glow ):
@@ -100,15 +100,15 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
case A_TOKEN( blur ):
{
if( nElement == A_TOKEN( glow ) )
- mrEffectProperties.maEffects[nPos]->msName = "glow";
+ mrEffectProperties.maEffects[nPos].msName = "glow";
else if( nElement == A_TOKEN( softEdge ) )
- mrEffectProperties.maEffects[nPos]->msName = "softEdge";
+ mrEffectProperties.maEffects[nPos].msName = "softEdge";
else if( nElement == A_TOKEN( reflection ) )
- mrEffectProperties.maEffects[nPos]->msName = "reflection";
+ mrEffectProperties.maEffects[nPos].msName = "reflection";
else if( nElement == A_TOKEN( blur ) )
- mrEffectProperties.maEffects[nPos]->msName = "blur";
- saveUnsupportedAttribs( *mrEffectProperties.maEffects[nPos], rAttribs );
- return new ColorContext( *this, mrEffectProperties.maEffects[nPos]->moColor );
+ mrEffectProperties.maEffects[nPos].msName = "blur";
+ saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
+ return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
}
break;
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index af4acd1c7632..8545307558f5 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -919,16 +919,16 @@ Reference< XShape > Shape::createAndInsert(
{
Sequence< PropertyValue > aEffects( aEffectProperties.maEffects.size() );
sal_uInt32 i = 0;
- for( std::vector< Effect* >::iterator it = aEffectProperties.maEffects.begin();
+ for( boost::ptr_vector< Effect >::iterator it = aEffectProperties.maEffects.begin();
it != aEffectProperties.maEffects.end(); ++it )
{
- PropertyValue aEffect = (*it)->getEffect();
+ PropertyValue aEffect = it->getEffect();
if( !aEffect.Name.isEmpty() )
{
Sequence< PropertyValue > aEffectsGrabBag( 3 );
PUT_PROP( aEffectsGrabBag, 0, "Attribs", aEffect.Value );
- Color& aColor( (*it)->moColor );
+ Color& aColor( it->moColor );
OUString sColorScheme = aColor.getSchemeName();
if( sColorScheme.isEmpty() )
{