Kaydet (Commit) 6797610b authored tarafından Markus Mohrhard's avatar Markus Mohrhard

use ptr_vector to prevent memory leak

Found by Lsan.

Change-Id: I727098ea3861bacf89209615e4b46e986a72c1ce
üst 0e061bd9
......@@ -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());
}
}
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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() )
{
......
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