summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-03-04 21:10:10 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-03-04 21:17:40 +0100
commit20a7a705b572f02049ebe76b2e8cc84c4f4b3d05 (patch)
treed8df168107b21511d4c994e8a8f265fd85060b5b
parentbbaad88a5c5643365afc438fc53e864e4233a628 (diff)
in the old design all lists needed to be the same size, fdo75200
We did not crash in the invalid memory access because the lists were continuous in memory and we would just pick the next id. However it crashed when trying to map some of the ids to non existant strings. This commit also removes the need for the earlier fix for this bug that just hit the problem behind some checks much later in the call chain. Change-Id: Ic6658987815c4e84ed2449934c310e30dcd0ed4c
-rw-r--r--include/oox/drawingml/shapepropertymap.hxx8
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx35
-rw-r--r--oox/source/drawingml/shapepropertymap.cxx15
-rw-r--r--oox/source/token/properties.pl1
4 files changed, 45 insertions, 14 deletions
diff --git a/include/oox/drawingml/shapepropertymap.hxx b/include/oox/drawingml/shapepropertymap.hxx
index c2c6896b9f61..29b0ba2979bf 100644
--- a/include/oox/drawingml/shapepropertymap.hxx
+++ b/include/oox/drawingml/shapepropertymap.hxx
@@ -23,6 +23,8 @@
#include <oox/helper/propertymap.hxx>
#include <oox/dllapi.h>
+#include <vector>
+
namespace oox { class ModelObjectHelper; }
namespace oox {
@@ -70,7 +72,7 @@ enum ShapePropertyId
struct OOX_DLLPUBLIC ShapePropertyInfo
{
- const sal_Int32* mpnPropertyIds; /// Pointer to array of property identifiers for all SHAPEPROP properties.
+ std::vector<sal_Int32> maPropertyIds;
bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker.
bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash.
bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient.
@@ -85,8 +87,8 @@ struct OOX_DLLPUBLIC ShapePropertyInfo
bool bNamedFillGradient,
bool bNamedFillBitmapUrl );
- bool has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; }
- sal_Int32 operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; }
+ bool has( ShapePropertyId ePropId ) const { return maPropertyIds.size() > size_t(ePropId) && maPropertyIds[ ePropId ] >= 0; }
+ sal_Int32 operator[]( ShapePropertyId ePropId ) const { return maPropertyIds[ ePropId ]; }
};
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 297ad7b4df6b..adcc3f3eb648 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -469,7 +469,8 @@ static const sal_Int32 spnCommonPropIds[] =
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_INVALID, PROP_FillGradientName,
PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
- PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
+ PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
+ PROP_END_LIST
};
/** Property identifiers for linear data series, to be used in ShapePropertyInfo. */
@@ -479,17 +480,37 @@ static const sal_Int32 spnLinearPropIds[] =
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
- PROP_INVALID, PROP_INVALID, PROP_INVALID
+ PROP_INVALID, PROP_INVALID, PROP_INVALID,
+ PROP_END_LIST
};
/** Property identifiers for filled data series, to be used in ShapePropertyInfo. */
static const sal_Int32 spnFilledPropIds[] =
{
- PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName,
- PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
- PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName,
- PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
- PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
+ PROP_BorderStyle,
+ PROP_BorderWidth,
+ PROP_BorderColor,
+ PROP_BorderTransparency,
+ PROP_BorderDashName,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_INVALID,
+ PROP_FillStyle,
+ PROP_Color,
+ PROP_Transparency,
+ PROP_GradientName,
+ PROP_FillBitmapName,
+ PROP_FillBitmapMode,
+ PROP_FillBitmapSizeX,
+ PROP_FillBitmapSizeY,
+ PROP_FillBitmapPositionOffsetX,
+ PROP_FillBitmapPositionOffsetY,
+ PROP_FillBitmapRectanglePoint,
+ PROP_END_LIST
};
/** Property info for common chart objects, to be used in ShapePropertyMap. */
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index 2ea89e63b9e8..446282bc26fa 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -39,7 +39,7 @@ using namespace ::com::sun::star::uno;
namespace {
-static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] =
+static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END + 1 ] = // one for the PROP_END_LIST
{
PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint,
PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter,
@@ -47,7 +47,8 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] =
PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
PROP_FillHatch,
- PROP_ShadowXDistance
+ PROP_ShadowXDistance,
+ PROP_END_LIST
};
} // namespace
@@ -56,13 +57,19 @@ ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, f
ShapePropertyInfo::ShapePropertyInfo( const sal_Int32* pnPropertyIds,
bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmapUrl ) :
- mpnPropertyIds( pnPropertyIds ),
mbNamedLineMarker( bNamedLineMarker ),
mbNamedLineDash( bNamedLineDash ),
mbNamedFillGradient( bNamedFillGradient ),
mbNamedFillBitmapUrl( bNamedFillBitmapUrl )
{
- OSL_ENSURE( mpnPropertyIds != 0, "ShapePropertyInfo::ShapePropertyInfo - missing property identifiers" );
+ assert(pnPropertyIds);
+ for(size_t i = 0;; ++i)
+ {
+ if(pnPropertyIds[i] == PROP_END_LIST)
+ break;
+
+ maPropertyIds.push_back(pnPropertyIds[i]);
+ }
}
diff --git a/oox/source/token/properties.pl b/oox/source/token/properties.pl
index d2a2d80153ef..3a8e87208410 100644
--- a/oox/source/token/properties.pl
+++ b/oox/source/token/properties.pl
@@ -53,6 +53,7 @@ foreach( sort( keys( %props ) ) )
print( IDFILE "const sal_Int32 PROP_COUNT = $i;\n" );
print( IDFILE "const sal_Int32 PROP_INVALID = -1;\n" );
+print( IDFILE "const sal_Int32 PROP_END_LIST = -2;\n" );
close( IDFILE );
close( NAMEFILE );