Kaydet (Commit) 4d6a17c6 authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

convert ShapePropertyId to scoped enum and use it for enumarray

new type ShapePropertyIds replaces vector and plain arrays
replace END enum member with LAST
remove PROP_END_LIST from plain arrays and properties script
store ShapepropertyInfo as reference in ObjectTypeFormatEntry
store ShapePropertyIds as reference ShapePropertyInfo

Change-Id: If273cc9e6c7bbd625dba5dc79f1c4ae0b21bdb3c
Reviewed-on: https://gerrit.libreoffice.org/28960Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 2aa61f07
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <vector> #include <vector>
#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Any.hxx>
#include <o3tl/enumarray.hxx>
#include <oox/dllapi.h> #include <oox/dllapi.h>
#include <oox/helper/propertymap.hxx> #include <oox/helper/propertymap.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
...@@ -43,41 +44,43 @@ namespace drawingml { ...@@ -43,41 +44,43 @@ namespace drawingml {
and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if
the newly inserted enum is inside the range they cover the newly inserted enum is inside the range they cover
*/ */
enum ShapePropertyId enum class ShapeProperty
{ {
SHAPEPROP_LineStyle, LineStyle,
SHAPEPROP_LineWidth, LineWidth,
SHAPEPROP_LineColor, LineColor,
SHAPEPROP_LineTransparency, LineTransparency,
SHAPEPROP_LineDash, /// Explicit line dash or name of a line dash stored in a global container. LineDash, /// Explicit line dash or name of a line dash stored in a global container.
SHAPEPROP_LineJoint, LineJoint,
SHAPEPROP_LineStart, /// Explicit line start marker or name of a line marker stored in a global container. LineStart, /// Explicit line start marker or name of a line marker stored in a global container.
SHAPEPROP_LineStartWidth, LineStartWidth,
SHAPEPROP_LineStartCenter, LineStartCenter,
SHAPEPROP_LineEnd, /// Explicit line end marker or name of a line marker stored in a global container. LineEnd, /// Explicit line end marker or name of a line marker stored in a global container.
SHAPEPROP_LineEndWidth, LineEndWidth,
SHAPEPROP_LineEndCenter, LineEndCenter,
SHAPEPROP_FillStyle, FillStyle,
SHAPEPROP_FillColor, FillColor,
SHAPEPROP_FillTransparency, FillTransparency,
SHAPEPROP_GradientTransparency, GradientTransparency,
SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container. FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container.
SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container. FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container.
SHAPEPROP_FillBitmapMode, FillBitmapMode,
SHAPEPROP_FillBitmapSizeX, FillBitmapSizeX,
SHAPEPROP_FillBitmapSizeY, FillBitmapSizeY,
SHAPEPROP_FillBitmapOffsetX, FillBitmapOffsetX,
SHAPEPROP_FillBitmapOffsetY, FillBitmapOffsetY,
SHAPEPROP_FillBitmapRectanglePoint, FillBitmapRectanglePoint,
SHAPEPROP_FillHatch, FillHatch,
SHAPEPROP_ShadowXDistance, ShadowXDistance,
SHAPEPROP_FillBitmapNameFromUrl, FillBitmapNameFromUrl,
SHAPEPROP_END LAST = FillBitmapNameFromUrl
}; };
typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds;
struct OOX_DLLPUBLIC ShapePropertyInfo struct OOX_DLLPUBLIC ShapePropertyInfo
{ {
std::vector<sal_Int32> maPropertyIds; const ShapePropertyIds& mrPropertyIds;
bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. 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 mbNamedLineDash; /// True = use named line dash instead of explicit line dash.
bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient.
...@@ -86,14 +89,14 @@ struct OOX_DLLPUBLIC ShapePropertyInfo ...@@ -86,14 +89,14 @@ struct OOX_DLLPUBLIC ShapePropertyInfo
static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods).
explicit ShapePropertyInfo( explicit ShapePropertyInfo(
const sal_Int32* pnPropertyIds, const ShapePropertyIds& rnPropertyIds,
bool bNamedLineMarker, bool bNamedLineMarker,
bool bNamedLineDash, bool bNamedLineDash,
bool bNamedFillGradient, bool bNamedFillGradient,
bool bNamedFillBitmapUrl ); bool bNamedFillBitmapUrl );
bool has( ShapePropertyId ePropId ) const { return maPropertyIds.size() > size_t(ePropId) && maPropertyIds[ ePropId ] >= 0; } bool has( ShapeProperty ePropId ) const { return mrPropertyIds[ ePropId ] >= 0; }
sal_Int32 operator[]( ShapePropertyId ePropId ) const { return maPropertyIds[ ePropId ]; } sal_Int32 operator[]( ShapeProperty ePropId ) const { return mrPropertyIds[ ePropId ]; }
}; };
...@@ -105,18 +108,18 @@ public: ...@@ -105,18 +108,18 @@ public:
const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
/** Returns true, if the specified property is supported. */ /** Returns true, if the specified property is supported. */
bool supportsProperty( ShapePropertyId ePropId ) const; bool supportsProperty( ShapeProperty ePropId ) const;
/** Returns true, if named line markers are supported, and the specified /** Returns true, if named line markers are supported, and the specified
line marker has already been inserted into the marker table. */ line marker has already been inserted into the marker table. */
bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const; bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const;
/** Sets the specified shape property to the passed value. */ /** Sets the specified shape property to the passed value. */
bool setAnyProperty( ShapePropertyId ePropId, const css::uno::Any& rValue ); bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue );
/** Sets the specified shape property to the passed value. */ /** Sets the specified shape property to the passed value. */
template< typename Type > template< typename Type >
bool setProperty( ShapePropertyId ePropId, const Type& rValue ) bool setProperty( ShapeProperty ePropId, const Type& rValue )
{ return setAnyProperty( ePropId, css::uno::Any( rValue ) ); } { return setAnyProperty( ePropId, css::uno::Any( rValue ) ); }
using PropertyMap::setAnyProperty; using PropertyMap::setAnyProperty;
...@@ -137,8 +140,8 @@ private: ...@@ -137,8 +140,8 @@ private:
bool setFillBitmapNameFromUrl( sal_Int32 nPropId, const css::uno::Any& rValue ); bool setFillBitmapNameFromUrl( sal_Int32 nPropId, const css::uno::Any& rValue );
// not implemented, to prevent implicit conversion from enum to int // not implemented, to prevent implicit conversion from enum to int
css::uno::Any& operator[]( ShapePropertyId ePropId ) = delete; css::uno::Any& operator[]( ShapeProperty ePropId ) = delete;
const css::uno::Any& operator[]( ShapePropertyId ePropId ) const = delete; const css::uno::Any& operator[]( ShapeProperty ePropId ) const = delete;
private: private:
ModelObjectHelper& mrModelObjHelper; ModelObjectHelper& mrModelObjHelper;
......
...@@ -326,16 +326,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -326,16 +326,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
case XML_solidFill: case XML_solidFill:
if( maFillColor.isUsed() ) if( maFillColor.isUsed() )
{ {
rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) ); rPropMap.setProperty( ShapeProperty::FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
if( maFillColor.hasTransparency() ) if( maFillColor.hasTransparency() )
rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() ); rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() );
eFillStyle = FillStyle_SOLID; eFillStyle = FillStyle_SOLID;
} }
break; break;
case XML_gradFill: case XML_gradFill:
// do not create gradient struct if property is not supported... // do not create gradient struct if property is not supported...
if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) ) if( rPropMap.supportsProperty( ShapeProperty::FillGradient ) )
{ {
sal_Int32 nEndTrans = 0; sal_Int32 nEndTrans = 0;
sal_Int32 nStartTrans = 0; sal_Int32 nStartTrans = 0;
...@@ -570,7 +570,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -570,7 +570,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
} }
// push gradient or named gradient to property map // push gradient or named gradient to property map
if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) ) if( rPropMap.setProperty( ShapeProperty::FillGradient, aGradient ) )
eFillStyle = FillStyle_GRADIENT; eFillStyle = FillStyle_GRADIENT;
// push gradient transparency to property map // push gradient transparency to property map
...@@ -581,7 +581,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -581,7 +581,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 ); aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 ); aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
aVal <<= aGrad; aVal <<= aGrad;
rPropMap.setProperty( SHAPEPROP_GradientTransparency, aGrad ); rPropMap.setProperty( ShapeProperty::GradientTransparency, aGrad );
} }
} }
...@@ -589,16 +589,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -589,16 +589,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
case XML_blipFill: case XML_blipFill:
// do not start complex graphic transformation if property is not supported... // do not start complex graphic transformation if property is not supported...
if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) ) if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( ShapeProperty::FillBitmapUrl ) )
{ {
Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr ); Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
// TODO: "rotate with shape" is not possible with our current core // TODO: "rotate with shape" is not possible with our current core
OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
// push bitmap or named bitmap to property map // push bitmap or named bitmap to property map
if( !aGraphicUrl.isEmpty() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapNameFromUrl ) && rPropMap.setProperty( SHAPEPROP_FillBitmapNameFromUrl, aGraphicUrl ) ) if( !aGraphicUrl.isEmpty() && rPropMap.supportsProperty( ShapeProperty::FillBitmapNameFromUrl ) && rPropMap.setProperty( ShapeProperty::FillBitmapNameFromUrl, aGraphicUrl ) )
eFillStyle = FillStyle_BITMAP; eFillStyle = FillStyle_BITMAP;
else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) ) else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( ShapeProperty::FillBitmapUrl, aGraphicUrl ) )
eFillStyle = FillStyle_BITMAP; eFillStyle = FillStyle_BITMAP;
// set other bitmap properties, if bitmap has been inserted into the map // set other bitmap properties, if bitmap has been inserted into the map
...@@ -606,14 +606,14 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -606,14 +606,14 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
{ {
// bitmap mode (single, repeat, stretch) // bitmap mode (single, repeat, stretch)
BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) ); BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
rPropMap.setProperty( SHAPEPROP_FillBitmapMode, eBitmapMode ); rPropMap.setProperty( ShapeProperty::FillBitmapMode, eBitmapMode );
// additional settings for repeated bitmap // additional settings for repeated bitmap
if( eBitmapMode == BitmapMode_REPEAT ) if( eBitmapMode == BitmapMode_REPEAT )
{ {
// anchor position inside bitmap // anchor position inside bitmap
RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) ); RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
rPropMap.setProperty( SHAPEPROP_FillBitmapRectanglePoint, eRectPoint ); rPropMap.setProperty( ShapeProperty::FillBitmapRectanglePoint, eRectPoint );
awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic ); awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic );
if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) ) if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
...@@ -621,16 +621,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -621,16 +621,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT ); double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 ); sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
rPropMap.setProperty( SHAPEPROP_FillBitmapSizeX, nFillBmpSizeX ); rPropMap.setProperty( ShapeProperty::FillBitmapSizeX, nFillBmpSizeX );
double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT ); double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 ); sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
rPropMap.setProperty( SHAPEPROP_FillBitmapSizeY, nFillBmpSizeY ); rPropMap.setProperty( ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
// offset of the first bitmap tile (given as EMUs), convert to percent // offset of the first bitmap tile (given as EMUs), convert to percent
sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 ); sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX ); rPropMap.setProperty( ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 ); sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetY, nTileOffsetY ); rPropMap.setProperty( ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
} }
} }
else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() ) else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() )
...@@ -657,7 +657,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -657,7 +657,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
case XML_pattFill: case XML_pattFill:
{ {
if( rPropMap.supportsProperty( SHAPEPROP_FillHatch ) ) if( rPropMap.supportsProperty( ShapeProperty::FillHatch ) )
{ {
Color aColor( maPatternProps.maPattFgColor ); Color aColor( maPatternProps.maPattFgColor );
if( aColor.isUsed() && maPatternProps.moPattPreset.has() ) if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
...@@ -665,14 +665,14 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -665,14 +665,14 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// we do not support hatches that have background // we do not support hatches that have background
// color too, so all this is some best-effort approach // color too, so all this is some best-effort approach
eFillStyle = FillStyle_HATCH; eFillStyle = FillStyle_HATCH;
rPropMap.setProperty( SHAPEPROP_FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) ); rPropMap.setProperty( ShapeProperty::FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
} }
else if ( maPatternProps.maPattBgColor.isUsed() ) else if ( maPatternProps.maPattBgColor.isUsed() )
{ {
aColor = maPatternProps.maPattBgColor; aColor = maPatternProps.maPattBgColor;
rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) ); rPropMap.setProperty( ShapeProperty::FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
if( aColor.hasTransparency() ) if( aColor.hasTransparency() )
rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() ); rPropMap.setProperty( ShapeProperty::FillTransparency, aColor.getTransparency() );
eFillStyle = FillStyle_SOLID; eFillStyle = FillStyle_SOLID;
} }
} }
...@@ -686,7 +686,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -686,7 +686,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
} }
// set final fill style property // set final fill style property
rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle ); rPropMap.setProperty( ShapeProperty::FillStyle, eFillStyle );
} }
} }
......
...@@ -320,15 +320,15 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, ...@@ -320,15 +320,15 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap,
{ {
if( bLineEnd ) if( bLineEnd )
{ {
rPropMap.setProperty( SHAPEPROP_LineEnd, aNamedMarker ); rPropMap.setProperty( ShapeProperty::LineEnd, aNamedMarker );
rPropMap.setProperty( SHAPEPROP_LineEndWidth, nMarkerWidth ); rPropMap.setProperty( ShapeProperty::LineEndWidth, nMarkerWidth );
rPropMap.setProperty( SHAPEPROP_LineEndCenter, bMarkerCenter ); rPropMap.setProperty( ShapeProperty::LineEndCenter, bMarkerCenter );
} }
else else
{ {
rPropMap.setProperty( SHAPEPROP_LineStart, aNamedMarker ); rPropMap.setProperty( ShapeProperty::LineStart, aNamedMarker );
rPropMap.setProperty( SHAPEPROP_LineStartWidth, nMarkerWidth ); rPropMap.setProperty( ShapeProperty::LineStartWidth, nMarkerWidth );
rPropMap.setProperty( SHAPEPROP_LineStartCenter, bMarkerCenter ); rPropMap.setProperty( ShapeProperty::LineStartCenter, bMarkerCenter );
} }
} }
} }
...@@ -386,27 +386,27 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -386,27 +386,27 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap,
aLineDash.DashLen *= nBaseLineWidth; aLineDash.DashLen *= nBaseLineWidth;
aLineDash.Distance *= nBaseLineWidth; aLineDash.Distance *= nBaseLineWidth;
if( rPropMap.setProperty( SHAPEPROP_LineDash, aLineDash ) ) if( rPropMap.setProperty( ShapeProperty::LineDash, aLineDash ) )
eLineStyle = drawing::LineStyle_DASH; eLineStyle = drawing::LineStyle_DASH;
} }
// set final line style property // set final line style property
rPropMap.setProperty( SHAPEPROP_LineStyle, eLineStyle ); rPropMap.setProperty( ShapeProperty::LineStyle, eLineStyle );
// line joint type // line joint type
if( moLineJoint.has() ) if( moLineJoint.has() )
rPropMap.setProperty( SHAPEPROP_LineJoint, lclGetLineJoint( moLineJoint.get() ) ); rPropMap.setProperty( ShapeProperty::LineJoint, lclGetLineJoint( moLineJoint.get() ) );
// line width in 1/100mm // line width in 1/100mm
rPropMap.setProperty( SHAPEPROP_LineWidth, nLineWidth ); rPropMap.setProperty( ShapeProperty::LineWidth, nLineWidth );
// line color and transparence // line color and transparence
Color aLineColor = maLineFill.getBestSolidColor(); Color aLineColor = maLineFill.getBestSolidColor();
if( aLineColor.isUsed() ) if( aLineColor.isUsed() )
{ {
rPropMap.setProperty( SHAPEPROP_LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) ); rPropMap.setProperty( ShapeProperty::LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) );
if( aLineColor.hasTransparency() ) if( aLineColor.hasTransparency() )
rPropMap.setProperty( SHAPEPROP_LineTransparency, aLineColor.getTransparency() ); rPropMap.setProperty( ShapeProperty::LineTransparency, aLineColor.getTransparency() );
} }
// line markers // line markers
......
...@@ -36,7 +36,7 @@ using namespace ::com::sun::star::uno; ...@@ -36,7 +36,7 @@ using namespace ::com::sun::star::uno;
namespace { namespace {
static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END + 1 ] = // one for the PROP_END_LIST static const ShapePropertyIds spnDefaultShapeIds =
{ {
PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint, PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint,
PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter, PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter,
...@@ -45,30 +45,21 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END + 1 ] = // one for the ...@@ -45,30 +45,21 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END + 1 ] = // one for the
PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint, PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
PROP_FillHatch, PROP_FillHatch,
PROP_ShadowXDistance, PROP_ShadowXDistance,
PROP_FillBitmapName, PROP_FillBitmapName
PROP_END_LIST
}; };
} // namespace } // namespace
ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false ); ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false );
ShapePropertyInfo::ShapePropertyInfo( const sal_Int32* pnPropertyIds, ShapePropertyInfo::ShapePropertyInfo( const ShapePropertyIds& rnPropertyIds,
bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmapUrl ) : bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmapUrl ) :
mrPropertyIds(rnPropertyIds),
mbNamedLineMarker( bNamedLineMarker ), mbNamedLineMarker( bNamedLineMarker ),
mbNamedLineDash( bNamedLineDash ), mbNamedLineDash( bNamedLineDash ),
mbNamedFillGradient( bNamedFillGradient ), mbNamedFillGradient( bNamedFillGradient ),
mbNamedFillBitmapUrl( bNamedFillBitmapUrl ) mbNamedFillBitmapUrl( bNamedFillBitmapUrl )
{ {
assert(pnPropertyIds);
// normally we should not reach PROP_COUNT but it prevents infinite loops if we hit a bug
for(size_t i = 0; i < static_cast<size_t>(PROP_COUNT); ++i)
{
if(pnPropertyIds[i] == PROP_END_LIST)
break;
maPropertyIds.push_back(pnPropertyIds[i]);
}
} }
ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const ShapePropertyInfo& rShapePropInfo ) : ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const ShapePropertyInfo& rShapePropInfo ) :
...@@ -77,7 +68,7 @@ ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const Sh ...@@ -77,7 +68,7 @@ ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const Sh
{ {
} }
bool ShapePropertyMap::supportsProperty( ShapePropertyId ePropId ) const bool ShapePropertyMap::supportsProperty( ShapeProperty ePropId ) const
{ {
return maShapePropInfo.has( ePropId ); return maShapePropInfo.has( ePropId );
} }
...@@ -87,7 +78,7 @@ bool ShapePropertyMap::hasNamedLineMarkerInTable( const OUString& rMarkerName ) ...@@ -87,7 +78,7 @@ bool ShapePropertyMap::hasNamedLineMarkerInTable( const OUString& rMarkerName )
return maShapePropInfo.mbNamedLineMarker && mrModelObjHelper.hasLineMarker( rMarkerName ); return maShapePropInfo.mbNamedLineMarker && mrModelObjHelper.hasLineMarker( rMarkerName );
} }
bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValue ) bool ShapePropertyMap::setAnyProperty( ShapeProperty ePropId, const Any& rValue )
{ {
// get current property identifier for the specified property // get current property identifier for the specified property
sal_Int32 nPropId = maShapePropInfo[ ePropId ]; sal_Int32 nPropId = maShapePropInfo[ ePropId ];
...@@ -96,23 +87,23 @@ bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValu ...@@ -96,23 +87,23 @@ bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValu
// special handling for properties supporting named objects in tables // special handling for properties supporting named objects in tables
switch( ePropId ) switch( ePropId )
{ {
case SHAPEPROP_LineStart: case ShapeProperty::LineStart:
case SHAPEPROP_LineEnd: case ShapeProperty::LineEnd:
return setLineMarker( nPropId, rValue ); return setLineMarker( nPropId, rValue );
case SHAPEPROP_LineDash: case ShapeProperty::LineDash:
return setLineDash( nPropId, rValue ); return setLineDash( nPropId, rValue );
case SHAPEPROP_FillGradient: case ShapeProperty::FillGradient:
return setFillGradient( nPropId, rValue ); return setFillGradient( nPropId, rValue );
case SHAPEPROP_GradientTransparency: case ShapeProperty::GradientTransparency:
return setGradientTrans( nPropId, rValue ); return setGradientTrans( nPropId, rValue );
case SHAPEPROP_FillBitmapUrl: case ShapeProperty::FillBitmapUrl:
return setFillBitmapUrl( nPropId, rValue ); return setFillBitmapUrl( nPropId, rValue );
case SHAPEPROP_FillBitmapNameFromUrl: case ShapeProperty::FillBitmapNameFromUrl:
return setFillBitmapNameFromUrl( nPropId, rValue ); return setFillBitmapNameFromUrl( nPropId, rValue );
default:; // suppress compiler warnings default:; // suppress compiler warnings
......
...@@ -53,7 +53,6 @@ foreach( sort( keys( %props ) ) ) ...@@ -53,7 +53,6 @@ foreach( sort( keys( %props ) ) )
print( IDFILE "const sal_Int32 PROP_COUNT = $i;\n" ); print( IDFILE "const sal_Int32 PROP_COUNT = $i;\n" );
print( IDFILE "const sal_Int32 PROP_INVALID = -1;\n" ); print( IDFILE "const sal_Int32 PROP_INVALID = -1;\n" );
print( IDFILE "const sal_Int32 PROP_END_LIST = -2;\n" );
close( IDFILE ); close( IDFILE );
close( NAMEFILE ); close( NAMEFILE );
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