diff options
author | Thorsten Behrens <tbehrens@novell.com> | 2011-04-27 01:31:35 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-04-27 01:31:35 +0200 |
commit | 48c61f72dd9e205f3d44838ae21cde0419538f1c (patch) | |
tree | 22eb884e19dd4f7c5b7dfaa0ba10bb77e12e3f19 /oox/source/drawingml | |
parent | f433a86839499662cfc1356882b0538f01d850b6 (diff) | |
parent | 275e5c6544ff2f90cf6bd57b6a8a6293fe10943c (diff) |
Merge commit 'ooo/DEV300_m106' into integration/dev300_m106
Conflicts:
binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpegc.c
filter/source/config/fragments/filters/SVG___Scalable_Vector_Graphics.xcu
filter/source/config/fragments/internalgraphicfilters/svg_Import.xcu
filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu
filter/source/graphicfilter/eos2met/eos2met.cxx
filter/source/msfilter/msvbahelper.cxx
filter/source/svg/makefile.mk
filter/source/svg/svgexport.cxx
filter/source/svg/svgfilter.cxx
filter/source/svg/svgfilter.hxx
filter/source/svg/svgfontexport.cxx
filter/source/svg/svgfontexport.hxx
filter/source/svg/svgwriter.cxx
filter/source/svg/svgwriter.hxx
oox/inc/oox/core/relations.hxx
oox/inc/oox/core/relationshandler.hxx
oox/inc/oox/dump/biffdumper.hxx
oox/inc/oox/dump/dffdumper.hxx
oox/inc/oox/dump/dumperbase.hxx
oox/inc/oox/dump/oledumper.hxx
oox/inc/oox/dump/pptxdumper.hxx
oox/inc/oox/helper/containerhelper.hxx
oox/inc/oox/helper/propertyset.hxx
oox/inc/oox/xls/commentsbuffer.hxx
oox/inc/oox/xls/sharedformulabuffer.hxx
oox/source/drawingml/shape.cxx
oox/source/dump/oledumper.cxx
oox/source/helper/binaryinputstream.cxx
oox/source/helper/binaryoutputstream.cxx
oox/source/helper/binarystreambase.cxx
oox/source/helper/propertyset.cxx
oox/source/ole/vbacontrol.cxx
oox/source/ole/vbaproject.cxx
oox/source/token/namespaces.hxx.tail
oox/source/vml/vmlshape.cxx
oox/source/xls/commentsbuffer.cxx
oox/source/xls/condformatbuffer.cxx
oox/source/xls/drawingfragment.cxx
oox/source/xls/formulaparser.cxx
oox/source/xls/pivotcachebuffer.cxx
oox/source/xls/richstring.cxx
oox/source/xls/sharedformulabuffer.cxx
oox/source/xls/sheetdatacontext.cxx
oox/source/xls/worksheethelper.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/chart/chartdrawingfragment.cxx | 55 | ||||
-rwxr-xr-x[-rw-r--r--] | oox/source/drawingml/chart/makefile.mk | 0 | ||||
-rw-r--r-- | oox/source/drawingml/chart/objectformatter.cxx | 212 | ||||
-rw-r--r-- | oox/source/drawingml/color.cxx | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | oox/source/drawingml/diagram/makefile.mk | 0 | ||||
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 122 | ||||
-rw-r--r-- | oox/source/drawingml/lineproperties.cxx | 172 | ||||
-rwxr-xr-x[-rw-r--r--] | oox/source/drawingml/makefile.mk | 1 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 31 | ||||
-rwxr-xr-x | oox/source/drawingml/shapepropertymap.cxx | 194 | ||||
-rwxr-xr-x[-rw-r--r--] | oox/source/drawingml/table/makefile.mk | 0 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 6 |
12 files changed, 433 insertions, 364 deletions
diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index 6c9c2e7ebde5..10a8bd12b16e 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -84,42 +84,41 @@ void ShapeAnchor::setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OU } } -Rectangle ShapeAnchor::calcEmuLocation( const EmuRectangle& rEmuChartRect ) const +EmuRectangle ShapeAnchor::calcAnchorRectEmu( const EmuRectangle& rChartRect ) const { - Rectangle aLoc( -1, -1, -1, -1 ); + EmuRectangle aAnchorRect( -1, -1, -1, -1 ); - OSL_ENSURE( maFrom.isValid(), "ShapeAnchor::calcEmuLocation - invalid from position" ); - OSL_ENSURE( mbRelSize ? maTo.isValid() : maSize.isValid(), "ShapeAnchor::calcEmuLocation - invalid to/size" ); + OSL_ENSURE( maFrom.isValid(), "ShapeAnchor::calcAnchorRectEmu - invalid from position" ); + OSL_ENSURE( mbRelSize ? maTo.isValid() : maSize.isValid(), "ShapeAnchor::calcAnchorRectEmu - invalid to/size" ); if( maFrom.isValid() && (mbRelSize ? maTo.isValid() : maSize.isValid()) ) { // calculate shape position - aLoc.X = getLimitedValue< sal_Int32, double >( maFrom.mfX * rEmuChartRect.Width, 0, SAL_MAX_INT32 ); - aLoc.Y = getLimitedValue< sal_Int32, double >( maFrom.mfY * rEmuChartRect.Height, 0, SAL_MAX_INT32 ); + aAnchorRect.X = static_cast< sal_Int64 >( maFrom.mfX * rChartRect.Width + 0.5 ); + aAnchorRect.Y = static_cast< sal_Int64 >( maFrom.mfY * rChartRect.Height + 0.5 ); // calculate shape size if( mbRelSize ) { - aLoc.Width = getLimitedValue< sal_Int32, double >( maTo.mfX * rEmuChartRect.Width, 0, SAL_MAX_INT32 ) - aLoc.X; - if( aLoc.Width < 0 ) + aAnchorRect.Width = static_cast< sal_Int64 >( maTo.mfX * rChartRect.Width + 0.5 ) - aAnchorRect.X; + if( aAnchorRect.Width < 0 ) { - aLoc.X += aLoc.Width; - aLoc.Width *= -1; + aAnchorRect.X += aAnchorRect.Width; + aAnchorRect.Width *= -1; } - aLoc.Height = getLimitedValue< sal_Int32, double >( maTo.mfY * rEmuChartRect.Height, 0, SAL_MAX_INT32 ) - aLoc.Y; - if( aLoc.Height < 0 ) + aAnchorRect.Height = static_cast< sal_Int64 >( maTo.mfY * rChartRect.Height + 0.5 ) - aAnchorRect.Y; + if( aAnchorRect.Height < 0 ) { - aLoc.Y += aLoc.Height; - aLoc.Height *= -1; + aAnchorRect.Y += aAnchorRect.Height; + aAnchorRect.Height *= -1; } } else { - aLoc.Width = getLimitedValue< sal_Int32, sal_Int64 >( maSize.Width, 0, SAL_MAX_INT32 ); - aLoc.Height = getLimitedValue< sal_Int32, sal_Int64 >( maSize.Height, 0, SAL_MAX_INT32 ); + aAnchorRect.setSize( maSize ); } } - return aLoc; + return aAnchorRect; } // ============================================================================ @@ -130,10 +129,10 @@ ChartDrawingFragment::ChartDrawingFragment( XmlFilterBase& rFilter, mxDrawPage( rxDrawPage ), mbOleSupport( bOleSupport ) { - maEmuChartRect.X = static_cast< sal_Int64 >( rShapesOffset.X ) * 360; - maEmuChartRect.Y = static_cast< sal_Int64 >( rShapesOffset.Y ) * 360; - maEmuChartRect.Width = static_cast< sal_Int64 >( rChartSize.Width ) * 360; - maEmuChartRect.Height = static_cast< sal_Int64 >( rChartSize.Height ) * 360; + maChartRectEmu.X = convertHmmToEmu( rShapesOffset.X ); + maChartRectEmu.Y = convertHmmToEmu( rShapesOffset.Y ); + maChartRectEmu.Width = convertHmmToEmu( rChartSize.Width ); + maChartRectEmu.Height = convertHmmToEmu( rChartSize.Height ); } ChartDrawingFragment::~ChartDrawingFragment() @@ -217,9 +216,17 @@ void ChartDrawingFragment::onEndElement() { if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() ) { - Rectangle aLoc = mxAnchor->calcEmuLocation( maEmuChartRect ); - if( (aLoc.X >= 0) && (aLoc.Y >= 0) && (aLoc.Width >= 0) && (aLoc.Height >= 0) ) - mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, &aLoc ); + EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( maChartRectEmu ); + if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) ) + { + // TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle) + Rectangle aShapeRectEmu32( + getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ), + getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ), + getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Width, 0, SAL_MAX_INT32 ), + getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Height, 0, SAL_MAX_INT32 ) ); + mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, &aShapeRectEmu32 ); + } } mxShape.reset(); mxAnchor.reset(); diff --git a/oox/source/drawingml/chart/makefile.mk b/oox/source/drawingml/chart/makefile.mk index 84762e6a2540..84762e6a2540 100644..100755 --- a/oox/source/drawingml/chart/makefile.mk +++ b/oox/source/drawingml/chart/makefile.mk diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index af633dcfd0fa..c6a3c39cf0f4 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -35,6 +35,7 @@ #include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/fillproperties.hxx" #include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/drawingml/textparagraph.hxx" #include "oox/drawingml/theme.hxx" @@ -490,19 +491,50 @@ const AutoTextEntry* lclGetAutoTextEntry( const AutoTextEntry* pEntries, sal_Int // ---------------------------------------------------------------------------- -/** Enumerates different sets of property names for chart object formatting. */ -enum PropertyType +/** Property identifiers for common chart objects, to be used in ShapePropertyInfo. */ +static const sal_Int32 spnCommonPropIds[] = { - PROPERTYTYPE_COMMON, /// Common objects, no special handling. - PROPERTYTYPE_LINEARSERIES, /// Specific to linear data series. - PROPERTYTYPE_FILLEDSERIES /// Specific to filled data series. + PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName, + PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, + PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint }; +/** Property identifiers for linear data series, to be used in ShapePropertyInfo. */ +static const sal_Int32 spnLinearPropIds[] = +{ + PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName, + 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 +}; + +/** 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 +}; + +/** Property info for common chart objects, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true ); +/** Property info for linear data series, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true ); +/** Property info for filled data series, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true ); + +// ---------------------------------------------------------------------------- + /** Contains information about formatting of a specific chart object type. */ struct ObjectTypeFormatEntry { ObjectType meObjType; /// Object type for automatic format. - PropertyType mePropType; /// Property type for property names. + const ShapePropertyInfo* mpPropInfo; /// Property info for the ShapePropertyMap class. const AutoFormatEntry* mpAutoLines; /// Automatic line formatting for all chart styles. const AutoFormatEntry* mpAutoFills; /// Automatic fill formatting for all chart styles. const AutoFormatEntry* mpAutoEffects; /// Automatic effect formatting for all chart styles. @@ -518,37 +550,38 @@ struct ObjectTypeFormatEntry static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = { - // object type property type auto text auto line auto fill auto effect - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, PROPERTYTYPE_COMMON, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, PROPERTYTYPE_COMMON, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, PROPERTYTYPE_COMMON, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_WALL, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, spWallFloorFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR, PROPERTYTYPE_COMMON, 0, spFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_AXIS, PROPERTYTYPE_COMMON, spOtherTexts, spAxisLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE, PROPERTYTYPE_COMMON, spAxisTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT, PROPERTYTYPE_COMMON, spAxisTitleTexts, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE, PROPERTYTYPE_COMMON, 0, spMajorGridLines ), - TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE, PROPERTYTYPE_COMMON, 0, spMinorGridLines ), - TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D, PROPERTYTYPE_LINEARSERIES, 0, spLinearSeriesLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, PROPERTYTYPE_FILLEDSERIES, 0, spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, PROPERTYTYPE_FILLEDSERIES, 0, spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL, PROPERTYTYPE_COMMON, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, PROPERTYTYPE_COMMON, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_SERLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, PROPERTYTYPE_LINEARSERIES, 0, spOtherLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), - TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, PROPERTYTYPE_COMMON, spOtherTexts, spChartSpaceLines ) + // object type property info auto text auto line auto fill auto effect + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, &saCommonPropInfo, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, &saCommonPropInfo, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_WALL, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spWallFloorFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR, &saCommonPropInfo, 0, spFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_AXIS, &saCommonPropInfo, spOtherTexts, spAxisLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE, &saCommonPropInfo, 0, spMajorGridLines ), + TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE, &saCommonPropInfo, 0, spMinorGridLines ), + TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D, &saLinearPropInfo, 0, spLinearSeriesLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_SERLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, &saLinearPropInfo, 0, spOtherLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, &saCommonPropInfo, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, &saCommonPropInfo, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), + TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, &saCommonPropInfo, spOtherTexts, spChartSpaceLines ) }; #undef TYPEFORMAT_FRAME #undef TYPEFORMAT_LINE + // ---------------------------------------------------------------------------- void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptionsModel& rPicOptions ) @@ -557,15 +590,6 @@ void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptions orFillProps.maBlipProps.moBitmapMode = bStacked ? XML_tile : XML_stretch; } -// ---------------------------------------------------------------------------- - -const sal_Int32 spnCommonLineIds[ LineId_END ] = { PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; -const sal_Int32 spnLinearLineIds[ LineId_END ] = { PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; -const sal_Int32 spnFilledLineIds[ LineId_END ] = { PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; - -const sal_Int32 spnCommonFillIds[ FillId_END ] = { PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName, PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint }; -const sal_Int32 spnFilledFillIds[ FillId_END ] = { PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName, PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint }; - } // namespace // ============================================================================ @@ -607,18 +631,16 @@ class LineFormatter : public DetailFormatterBase public: explicit LineFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts line formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ); private: LinePropertiesPtr mxAutoLine; /// Automatic line properties. - LinePropertyIds& mrLinePropIds; /// Property identifiers for border/line formatting. }; // ---------------------------------------------------------------------------- @@ -628,19 +650,17 @@ class FillFormatter : public DetailFormatterBase public: explicit FillFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts area formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ); private: FillPropertiesPtr mxAutoFill; /// Automatic fill properties. - FillPropertyIds& mrFillPropIds; /// Property identifiers for fill formatting. }; // ---------------------------------------------------------------------------- @@ -650,12 +670,11 @@ class EffectFormatter : public DetailFormatterBase public: explicit EffectFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts effect formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ); }; @@ -732,6 +751,7 @@ private: FillFormatter maFillFormatter; /// Converter for fill formatting. EffectFormatter maEffectFormatter; /// Converter for effect formatting. TextFormatter maTextFormatter; /// Converter for text formatting. + ModelObjectHelper& mrModelObjHelper; /// Helper for named drawing formatting. const ObjectTypeFormatEntry& mrEntry; /// Additional settings. }; @@ -744,11 +764,6 @@ struct ObjectFormatterData const XmlFilterBase& mrFilter; /// Base filter object. ObjectTypeFormatterMap maTypeFormatters; /// Formatters for all types of objects in a chart. ModelObjectHelper maModelObjHelper; /// Helper for named drawing formatting (dashes, gradients, bitmaps). - LinePropertyIds maCommonLineIds; /// Property identifiers for common border formatting. - LinePropertyIds maLinearLineIds; /// Property identifiers for line formatting of linear series. - LinePropertyIds maFilledLineIds; /// Property identifiers for line formatting of filled series. - FillPropertyIds maCommonFillIds; /// Property identifiers for common area fill. - FillPropertyIds maFilledFillIds; /// Property identifiers for area fill of filled series. Reference< XNumberFormats > mxNumFmts; /// Number formats collection of container document. Reference< XNumberFormatTypes > mxNumTypes; /// Number format types collection of container document. Locale maEnUsLocale; /// Locale struct containing en-US. @@ -761,9 +776,6 @@ struct ObjectFormatterData const ChartSpaceModel& rChartSpace ); ObjectTypeFormatter* getTypeFormatter( ObjectType eObjType ); - - LinePropertyIds& getLinePropertyIds( PropertyType ePropType ); - FillPropertyIds& getFillPropertyIds( PropertyType ePropType ); }; // ============================================================================ @@ -860,9 +872,8 @@ sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 // ============================================================================ -LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType ePropType ) : - DetailFormatterBase( rData, pAutoFormatEntry ), - mrLinePropIds( rData.getLinePropertyIds( ePropType ) ) +LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : + DetailFormatterBase( rData, pAutoFormatEntry ) { if( pAutoFormatEntry ) { @@ -877,21 +888,20 @@ LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* } } -void LineFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ) +void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ) { LineProperties aLineProps; if( mxAutoLine.get() ) aLineProps.assignUsed( *mxAutoLine ); if( rxShapeProp.is() ) aLineProps.assignUsed( rxShapeProp->getLineProperties() ); - aLineProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrLinePropIds, getPhColor( nSeriesIdx ) ); + aLineProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), getPhColor( nSeriesIdx ) ); } // ============================================================================ -FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType ePropType ) : - DetailFormatterBase( rData, pAutoFormatEntry ), - mrFillPropIds( rData.getFillPropertyIds( ePropType ) ) +FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : + DetailFormatterBase( rData, pAutoFormatEntry ) { if( pAutoFormatEntry ) { @@ -903,7 +913,7 @@ FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* } } -void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) +void FillFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) { FillProperties aFillProps; if( mxAutoFill.get() ) @@ -912,17 +922,17 @@ void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aFillProps.assignUsed( rxShapeProp->getFillProperties() ); if( pPicOptions ) lclConvertPictureOptions( aFillProps, *pPicOptions ); - aFillProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); + aFillProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), 0, getPhColor( nSeriesIdx ) ); } // ============================================================================ -EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType /*ePropType*/ ) : +EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : DetailFormatterBase( rData, pAutoFormatEntry ) { } -void EffectFormatter::convertFormatting( PropertySet& /*rPropSet*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) +void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) { } @@ -980,20 +990,23 @@ void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Te // ============================================================================ ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace ) : - maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ), rEntry.mePropType ), - maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ), rEntry.mePropType ), - maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ), rEntry.mePropType ), + maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ) ), + maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ) ), + maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ) ), maTextFormatter( rData, lclGetAutoTextEntry( rEntry.mpAutoTexts, rChartSpace.mnStyle ), rChartSpace.mxTextProp ), + mrModelObjHelper( rData.maModelObjHelper ), mrEntry( rEntry ) { } void ObjectTypeFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) { - maLineFormatter.convertFormatting( rPropSet, rxShapeProp, nSeriesIdx ); + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); + maLineFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx ); if( mrEntry.mbIsFrame ) - maFillFormatter.convertFormatting( rPropSet, rxShapeProp, pPicOptions, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, rxShapeProp, nSeriesIdx ); + maFillFormatter.convertFormatting( aPropMap, rxShapeProp, pPicOptions, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp ) @@ -1014,16 +1027,20 @@ void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const Te void ObjectTypeFormatter::convertAutomaticLine( PropertySet& rPropSet, sal_Int32 nSeriesIdx ) { + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); ModelRef< Shape > xShapeProp; - maLineFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); + maLineFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 nSeriesIdx ) { + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); ModelRef< Shape > xShapeProp; - maFillFormatter.convertFormatting( rPropSet, xShapeProp, 0, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); + maFillFormatter.convertFormatting( aPropMap, xShapeProp, 0, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } // ============================================================================ @@ -1031,11 +1048,6 @@ void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) : mrFilter( rFilter ), maModelObjHelper( Reference< XMultiServiceFactory >( rxChartDoc, UNO_QUERY ) ), - maCommonLineIds( spnCommonLineIds, true, false ), - maLinearLineIds( spnLinearLineIds, true, false ), - maFilledLineIds( spnFilledLineIds, true, false ), - maCommonFillIds( spnCommonFillIds, true, true ), - maFilledFillIds( spnFilledFillIds, true, true ), maEnUsLocale( CREATE_OUSTRING( "en" ), CREATE_OUSTRING( "US" ), OUString() ), mnMaxSeriesIdx( -1 ) { @@ -1061,28 +1073,6 @@ ObjectTypeFormatter* ObjectFormatterData::getTypeFormatter( ObjectType eObjType return maTypeFormatters.get( eObjType ).get(); } -LinePropertyIds& ObjectFormatterData::getLinePropertyIds( PropertyType ePropType ) -{ - switch( ePropType ) - { - case PROPERTYTYPE_COMMON: return maCommonLineIds; - case PROPERTYTYPE_LINEARSERIES: return maLinearLineIds; - case PROPERTYTYPE_FILLEDSERIES: return maFilledLineIds; - } - return maCommonLineIds; -} - -FillPropertyIds& ObjectFormatterData::getFillPropertyIds( PropertyType ePropType ) -{ - switch( ePropType ) - { - case PROPERTYTYPE_COMMON: return maCommonFillIds; - case PROPERTYTYPE_LINEARSERIES: return maCommonFillIds; - case PROPERTYTYPE_FILLEDSERIES: return maFilledFillIds; - } - return maCommonFillIds; -} - // ============================================================================ ObjectFormatter::ObjectFormatter( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) : @@ -1161,7 +1151,7 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat; if( rNumberFormat.mbSourceLinked || (rNumberFormat.maFormatCode.getLength() == 0) ) { - rPropSet.setProperty( nPropId, Any() ); + rPropSet.setAnyProperty( nPropId, Any() ); } else try { diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 88d24b1c4644..9b2ce7ec324e 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -513,12 +513,12 @@ sal_Int32 Color::getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr return mnC1; } -bool Color::hasTransparence() const +bool Color::hasTransparency() const { return mnAlpha < MAX_PERCENT; } -sal_Int16 Color::getTransparence() const +sal_Int16 Color::getTransparency() const { return static_cast< sal_Int16 >( (MAX_PERCENT - mnAlpha) / PER_PERCENT ); } diff --git a/oox/source/drawingml/diagram/makefile.mk b/oox/source/drawingml/diagram/makefile.mk index 9d526ed3d3fb..9d526ed3d3fb 100644..100755 --- a/oox/source/drawingml/diagram/makefile.mk +++ b/oox/source/drawingml/diagram/makefile.mk diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index f1abd70f0a09..699f8a92ab65 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -27,6 +27,7 @@ ************************************************************************/ #include "oox/drawingml/fillproperties.hxx" + #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Gradient.hpp> @@ -38,10 +39,8 @@ #include <com/sun/star/drawing/RectanglePoint.hpp> #include <com/sun/star/graphic/XGraphicTransformer.hpp> #include "oox/helper/graphichelper.hxx" -#include "oox/helper/modelobjecthelper.hxx" -#include "oox/helper/propertymap.hxx" -#include "oox/helper/propertyset.hxx" #include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/token/tokens.hxx" using namespace ::com::sun::star; @@ -62,21 +61,6 @@ namespace drawingml { namespace { -static const sal_Int32 spnDefaultFillIds[ FillId_END ] = -{ - PROP_FillStyle, - PROP_FillColor, - PROP_FillTransparence, - PROP_FillGradient, - PROP_FillBitmapURL, - PROP_FillBitmapMode, - PROP_FillBitmapSizeX, - PROP_FillBitmapSizeY, - PROP_FillBitmapPositionOffsetX, - PROP_FillBitmapPositionOffsetY, - PROP_FillBitmapRectanglePoint -}; - BitmapMode lclGetBitmapMode( sal_Int32 nToken ) { switch( nToken ) @@ -130,16 +114,6 @@ const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const R // ============================================================================ -FillPropertyIds::FillPropertyIds( const sal_Int32* pnPropertyIds, bool bNamedFillGradient, bool bNamedFillBitmap ) : - mpnPropertyIds( pnPropertyIds ), - mbNamedFillGradient( bNamedFillGradient ), - mbNamedFillBitmap( bNamedFillBitmap ) -{ - OSL_ENSURE( mpnPropertyIds != 0, "FillPropertyIds::FillPropertyIds - missing property identifiers" ); -} - -// ============================================================================ - void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps ) { if( !rSourceProps.maGradientStops.empty() ) @@ -186,8 +160,6 @@ void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps ) // ============================================================================ -FillPropertyIds FillProperties::DEFAULT_IDS( spnDefaultFillIds, false, false ); - void FillProperties::assignUsed( const FillProperties& rSourceProps ) { moFillType.assignIfUsed( rSourceProps.moFillType ); @@ -216,9 +188,8 @@ Color FillProperties::getBestSolidColor() const return aSolidColor; } -void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const +void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { if( moFillType.has() ) { @@ -232,16 +203,16 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM case XML_solidFill: if( maFillColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rGraphicHelper, nPhClr ) ); - if( maFillColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ FillTransparenceId ], maFillColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) ); + if( maFillColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() ); eFillStyle = FillStyle_SOLID; } break; case XML_gradFill: // do not create gradient struct if property is not supported... - if( rPropIds.has( FillGradientId ) ) + if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) ) { awt::Gradient aGradient; aGradient.Angle = 900; @@ -291,62 +262,35 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 ); // push gradient or named gradient to property map - if( rPropIds.mbNamedFillGradient ) - { - OUString aGradientName = rModelObjHelper.insertFillGradient( aGradient ); - if( aGradientName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ FillGradientId ], aGradientName ); - eFillStyle = FillStyle_GRADIENT; - } - } - else - { - rPropMap.setProperty( rPropIds[ FillGradientId ], aGradient ); + if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) ) eFillStyle = FillStyle_GRADIENT; - } } break; case XML_blipFill: // do not start complex graphic transformation if property is not supported... - if( maBlipProps.mxGraphic.is() && rPropIds.has( FillBitmapUrlId ) ) + if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) ) { // TODO: "rotate with shape" is not possible with our current core OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic ); - if( aGraphicUrl.getLength() > 0 ) - { - // push bitmap or named bitmap to property map - if( rPropIds.mbNamedFillBitmap ) - { - OUString aBitmapName = rModelObjHelper.insertFillBitmap( aGraphicUrl ); - if( aBitmapName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ FillBitmapUrlId ], aBitmapName ); - eFillStyle = FillStyle_BITMAP; - } - } - else - { - rPropMap.setProperty( rPropIds[ FillBitmapUrlId ], aGraphicUrl ); - eFillStyle = FillStyle_BITMAP; - } - } + // push bitmap or named bitmap to property map + if( (aGraphicUrl.getLength() > 0) && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) ) + eFillStyle = FillStyle_BITMAP; // set other bitmap properties, if bitmap has been inserted into the map if( eFillStyle == FillStyle_BITMAP ) { // bitmap mode (single, repeat, stretch) BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) ); - rPropMap.setProperty( rPropIds[ FillBitmapModeId ], eBitmapMode ); + rPropMap.setProperty( SHAPEPROP_FillBitmapMode, eBitmapMode ); // additional settings for repeated bitmap if( eBitmapMode == BitmapMode_REPEAT ) { // anchor position inside bitmap RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) ); - rPropMap.setProperty( rPropIds[ FillBitmapRectanglePointId ], eRectPoint ); + rPropMap.setProperty( SHAPEPROP_FillBitmapRectanglePoint, eRectPoint ); awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic ); if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) ) @@ -354,16 +298,16 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM // 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 ); sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 ); - rPropMap.setProperty( rPropIds[ FillBitmapSizeXId ], nFillBmpSizeX ); + rPropMap.setProperty( SHAPEPROP_FillBitmapSizeX, nFillBmpSizeX ); 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 ); - rPropMap.setProperty( rPropIds[ FillBitmapSizeYId ], nFillBmpSizeY ); + rPropMap.setProperty( SHAPEPROP_FillBitmapSizeY, nFillBmpSizeY ); // 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 ); - rPropMap.setProperty( rPropIds[ FillBitmapOffsetXId ], nTileOffsetX ); + rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX ); sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 ); - rPropMap.setProperty( rPropIds[ FillBitmapOffsetYId ], nTileOffsetY ); + rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetY, nTileOffsetY ); } } } @@ -376,9 +320,9 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM Color aColor = getBestSolidColor(); if( aColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rGraphicHelper, nPhClr ) ); - if( aColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ FillTransparenceId ], aColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) ); + if( aColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() ); eFillStyle = FillStyle_SOLID; } } @@ -391,19 +335,10 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM } // set final fill style property - rPropMap.setProperty( rPropIds[ FillStyleId ], eFillStyle ); + rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle ); } } -void FillProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nShapeRotation, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ void GraphicProperties::assignUsed( const GraphicProperties& rSourceProps ) @@ -421,9 +356,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe { sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr ); sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr ); - if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparence() ) try + if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparency() ) try { - sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparence(); + sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparency(); sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) / 39.062 ); // ?!? correct ?!? Reference< XGraphicTransformer > xTransformer( maBlipProps.mxGraphic, UNO_QUERY_THROW ); xGraphic = xTransformer->colorChange( maBlipProps.mxGraphic, nFromColor, 9, nToColor, nToAlpha ); @@ -476,13 +411,6 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe rPropMap[ PROP_AdjustContrast ] <<= nContrast; } -void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rGraphicHelper, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 8f1dd244ff26..2fd4a37d292f 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -29,6 +29,7 @@ #include "oox/drawingml/lineproperties.hxx" #include <vector> #include <rtl/ustrbuf.hxx> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/drawing/FlagSequence.hpp> #include <com/sun/star/drawing/LineDash.hpp> @@ -36,14 +37,13 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/PointSequence.hpp> #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/helper/containerhelper.hxx" #include "oox/helper/graphichelper.hxx" -#include "oox/helper/modelobjecthelper.hxx" -#include "oox/helper/propertymap.hxx" -#include "oox/helper/propertyset.hxx" -#include "oox/drawingml/drawingmltypes.hxx" #include "oox/token/tokens.hxx" +using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; using ::rtl::OUString; @@ -60,24 +60,6 @@ namespace drawingml { namespace { -static const sal_Int32 spnDefaultLineIds[ LineId_END ] = -{ - PROP_LineStyle, - PROP_LineWidth, - PROP_LineColor, - PROP_LineTransparence, - PROP_LineDash, - PROP_LineJoint, - PROP_LineStartName, - PROP_LineStartWidth, - PROP_LineStartCenter, - PROP_LineEndName, - PROP_LineEndWidth, - PROP_LineEndCenter -}; - -// ---------------------------------------------------------------------------- - void lclSetDashData( LineDash& orLineDash, sal_Int16 nDots, sal_Int32 nDotLen, sal_Int16 nDashes, sal_Int32 nDashLen, sal_Int32 nDistance ) { @@ -196,15 +178,16 @@ sal_Int32 lclGetArrowSize( sal_Int32 nToken ) // ---------------------------------------------------------------------------- -void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& rArrowProps, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nLineWidth, bool bLineEnd ) +void lclPushMarkerProperties( ShapePropertyMap& rPropMap, + const LineArrowProperties& rArrowProps, sal_Int32 nLineWidth, bool bLineEnd ) { - PolyPolygonBezierCoords aMarker; - OUString aMarkerName; - sal_Int32 nMarkerWidth = 0; - bool bMarkerCenter = false; + /* Store the marker polygon and the marker name in a single value, to be + able to pass both to the ShapePropertyMap::setProperty() function. */ + NamedValue aNamedMarker; OUStringBuffer aBuffer; + sal_Int32 nMarkerWidth = 0; + bool bMarkerCenter = false; sal_Int32 nArrowType = rArrowProps.moArrowType.get( XML_none ); switch( nArrowType ) { @@ -234,7 +217,7 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& sal_Int32 nNameIndex = nWidth * 3 + nLength + 1; aBuffer.append( sal_Unicode( ' ' ) ).append( nNameIndex ); - aMarkerName = aBuffer.makeStringAndClear(); + OUString aMarkerName = aBuffer.makeStringAndClear(); bool bIsArrow = nArrowType == XML_arrow; double fArrowLength = 1.0; @@ -251,12 +234,15 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& case OOX_ARROWSIZE_MEDIUM: fArrowWidth = (bIsArrow ? 4.5 : 3.0); break; case OOX_ARROWSIZE_LARGE: fArrowWidth = (bIsArrow ? 6.0 : 5.0); break; } - // set arrow width relative to line width (convert line width from EMUs to 1/100 mm) - sal_Int32 nApiLineWidth = ::std::max< sal_Int32 >( GetCoordinate( nLineWidth ), 70 ); - nMarkerWidth = static_cast< sal_Int32 >( fArrowWidth * nApiLineWidth ); - - // test if the arrow already exists, do not create it again in this case - if( !rPropIds.mbNamedLineMarker || !rModelObjHelper.hasLineMarker( aMarkerName ) ) + // set arrow width relative to line width + sal_Int32 nBaseLineWidth = ::std::max< sal_Int32 >( nLineWidth, 70 ); + nMarkerWidth = static_cast< sal_Int32 >( fArrowWidth * nBaseLineWidth ); + + /* Test if the marker already exists in the marker table, do not + create it again in this case. If markers are inserted explicitly + instead by their name, the polygon will be created always. + TODO: this can be optimized by using a map. */ + if( !rPropMap.hasNamedLineMarkerInTable( aMarkerName ) ) { // pass X and Y as percentage to OOX_ARROW_POINT #define OOX_ARROW_POINT( x, y ) Point( static_cast< sal_Int32 >( fArrowWidth * x ), static_cast< sal_Int32 >( fArrowLength * y ) ) @@ -311,46 +297,44 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& } #undef OOX_ARROW_POINT - OSL_ENSURE( !aPoints.empty(), "ApiLineMarkerProperties::ApiLineMarkerProperties - missing arrow coordinates" ); + OSL_ENSURE( !aPoints.empty(), "lclPushMarkerProperties - missing arrow coordinates" ); if( !aPoints.empty() ) { - aMarker.Coordinates.realloc( 1 ); - aMarker.Coordinates[ 0 ] = ContainerHelper::vectorToSequence( aPoints ); + PolyPolygonBezierCoords aMarkerCoords; + aMarkerCoords.Coordinates.realloc( 1 ); + aMarkerCoords.Coordinates[ 0 ] = ContainerHelper::vectorToSequence( aPoints ); ::std::vector< PolygonFlags > aFlags( aPoints.size(), PolygonFlags_NORMAL ); - aMarker.Flags.realloc( 1 ); - aMarker.Flags[ 0 ] = ContainerHelper::vectorToSequence( aFlags ); + aMarkerCoords.Flags.realloc( 1 ); + aMarkerCoords.Flags[ 0 ] = ContainerHelper::vectorToSequence( aFlags ); - if( rPropIds.mbNamedLineMarker && !rModelObjHelper.insertLineMarker( aMarkerName, aMarker ) ) - aMarkerName = OUString(); - } - else - { - aMarkerName = OUString(); + aNamedMarker.Name = aMarkerName; + aNamedMarker.Value <<= aMarkerCoords; } } + else + { + /* Named marker object exists already in the marker table, pass + its name only. This will set the name as property value, but + does not create a new object in the marker table. */ + aNamedMarker.Name = aMarkerName; + } } - // push the properties (filled aMarkerName indicates valid marker) - if( aMarkerName.getLength() > 0 ) + // push the properties (filled aNamedMarker.Name indicates valid marker) + if( aNamedMarker.Name.getLength() > 0 ) { if( bLineEnd ) { - if( rPropIds.mbNamedLineMarker ) - rPropMap.setProperty( rPropIds[ LineEndId ], aMarkerName ); - else - rPropMap.setProperty( rPropIds[ LineEndId ], aMarker ); - rPropMap.setProperty( rPropIds[ LineEndWidthId ], nMarkerWidth ); - rPropMap.setProperty( rPropIds[ LineEndCenterId ], bMarkerCenter ); + rPropMap.setProperty( SHAPEPROP_LineEnd, aNamedMarker ); + rPropMap.setProperty( SHAPEPROP_LineEndWidth, nMarkerWidth ); + rPropMap.setProperty( SHAPEPROP_LineEndCenter, bMarkerCenter ); } else { - if( rPropIds.mbNamedLineMarker ) - rPropMap.setProperty( rPropIds[ LineStartId ], aMarkerName ); - else - rPropMap.setProperty( rPropIds[ LineStartId ], aMarker ); - rPropMap.setProperty( rPropIds[ LineStartWidthId ], nMarkerWidth ); - rPropMap.setProperty( rPropIds[ LineStartCenterId ], bMarkerCenter ); + rPropMap.setProperty( SHAPEPROP_LineStart, aNamedMarker ); + rPropMap.setProperty( SHAPEPROP_LineStartWidth, nMarkerWidth ); + rPropMap.setProperty( SHAPEPROP_LineStartCenter, bMarkerCenter ); } } } @@ -359,16 +343,6 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& // ============================================================================ -LinePropertyIds::LinePropertyIds( const sal_Int32* pnPropertyIds, bool bNamedLineDash, bool bNamedLineMarker ) : - mpnPropertyIds( pnPropertyIds ), - mbNamedLineDash( bNamedLineDash ), - mbNamedLineMarker( bNamedLineMarker ) -{ - OSL_ENSURE( mpnPropertyIds != 0, "LinePropertyIds::LinePropertyIds - missing property identifiers" ); -} - -// ============================================================================ - void LineArrowProperties::assignUsed( const LineArrowProperties& rSourceProps ) { moArrowType.assignIfUsed( rSourceProps.moArrowType ); @@ -378,8 +352,6 @@ void LineArrowProperties::assignUsed( const LineArrowProperties& rSourceProps ) // ============================================================================ -LinePropertyIds LineProperties::DEFAULT_IDS( spnDefaultLineIds, false, true ); - void LineProperties::assignUsed( const LineProperties& rSourceProps ) { maStartArrow.assignUsed( rSourceProps.maStartArrow ); @@ -394,8 +366,8 @@ void LineProperties::assignUsed( const LineProperties& rSourceProps ) moLineJoint.assignIfUsed( rSourceProps.moLineJoint ); } -void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { // line fill type must exist, otherwise ignore other properties if( maLineFill.moFillType.has() ) @@ -403,6 +375,9 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM // line style (our core only supports none and solid) LineStyle eLineStyle = (maLineFill.moFillType.get() == XML_noFill) ? LineStyle_NONE : LineStyle_SOLID; + // convert line width from EMUs to 1/100mm + sal_Int32 nLineWidth = convertEmuToHmm( moLineWidth.get( 0 ) ); + // create line dash from preset dash token (not for invisible line) if( (eLineStyle != LineStyle_NONE) && (moPresetDash.differsFrom( XML_solid ) || (!moPresetDash && !maCustomDash.empty())) ) { @@ -416,61 +391,40 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM lclConvertCustomDash( aLineDash, maCustomDash ); // convert relative dash/dot length to absolute length - sal_Int32 nLineWidth = GetCoordinate( moLineWidth.get( 103500 ) ); - aLineDash.DotLen *= nLineWidth; - aLineDash.DashLen *= nLineWidth; - aLineDash.Distance *= nLineWidth; + sal_Int32 nBaseLineWidth = ::std::max< sal_Int32 >( nLineWidth, 35 ); + aLineDash.DotLen *= nBaseLineWidth; + aLineDash.DashLen *= nBaseLineWidth; + aLineDash.Distance *= nBaseLineWidth; - if( rPropIds.mbNamedLineDash ) - { - OUString aDashName = rModelObjHelper.insertLineDash( aLineDash ); - if( aDashName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ LineDashId ], aDashName ); - eLineStyle = LineStyle_DASH; - } - } - else - { - rPropMap.setProperty( rPropIds[ LineDashId ], aLineDash ); + if( rPropMap.setProperty( SHAPEPROP_LineDash, aLineDash ) ) eLineStyle = LineStyle_DASH; - } } // set final line style property - rPropMap.setProperty( rPropIds[ LineStyleId ], eLineStyle ); + rPropMap.setProperty( SHAPEPROP_LineStyle, eLineStyle ); // line joint type if( moLineJoint.has() ) - rPropMap.setProperty( rPropIds[ LineJointId ], lclGetLineJoint( moLineJoint.get() ) ); + rPropMap.setProperty( SHAPEPROP_LineJoint, lclGetLineJoint( moLineJoint.get() ) ); - // convert line width from EMUs to 1/100 mm - if( moLineWidth.has() ) - rPropMap.setProperty( rPropIds[ LineWidthId ], GetCoordinate( moLineWidth.get() ) ); + // line width in 1/100mm + rPropMap.setProperty( SHAPEPROP_LineWidth, nLineWidth ); // line color and transparence Color aLineColor = maLineFill.getBestSolidColor(); if( aLineColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rGraphicHelper, nPhClr ) ); - if( aLineColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ LineTransparenceId ], aLineColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) ); + if( aLineColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_LineTransparency, aLineColor.getTransparency() ); } // line markers - lclPushMarkerProperties( rPropMap, maStartArrow, rModelObjHelper, rPropIds, moLineWidth.get( 0 ), false ); - lclPushMarkerProperties( rPropMap, maEndArrow, rModelObjHelper, rPropIds, moLineWidth.get( 0 ), true ); + lclPushMarkerProperties( rPropMap, maStartArrow, nLineWidth, false ); + lclPushMarkerProperties( rPropMap, maEndArrow, nLineWidth, true ); } } -void LineProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/makefile.mk b/oox/source/drawingml/makefile.mk index e2d4ea6b8f3d..0546fb4c233d 100644..100755 --- a/oox/source/drawingml/makefile.mk +++ b/oox/source/drawingml/makefile.mk @@ -62,6 +62,7 @@ SLOFILES = \ $(SLO)$/shapecontext.obj\ $(SLO)$/shapegroupcontext.obj\ $(SLO)$/shapepropertiescontext.obj\ + $(SLO)$/shapepropertymap.obj\ $(SLO)$/shapestylecontext.obj\ $(SLO)$/spdefcontext.obj\ $(SLO)$/textbody.obj\ diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 86dea33d8eac..f934146f1e3b 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -31,6 +31,7 @@ #include "oox/drawingml/theme.hxx" #include "oox/drawingml/fillproperties.hxx" #include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/drawingml/table/tableproperties.hxx" #include "oox/drawingml/chart/chartconverter.hxx" @@ -399,7 +400,6 @@ Reference< XShape > Shape::createAndInsert( } } - ModelObjectHelper& rModelObjectHelper = rFilterBase.getModelObjectHelper(); const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper(); LineProperties aLineProperties; @@ -434,28 +434,21 @@ Reference< XShape > Shape::createAndInsert( aLineProperties.assignUsed( getLineProperties() ); aFillProperties.assignUsed( getFillProperties() ); - PropertyMap aShapeProperties; - PropertyMap::const_iterator aShapePropIter; + ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() ); // add properties from textbody to shape properties if( mpTextBody.get() ) - { - for ( aShapePropIter = mpTextBody->getTextProperties().maPropertyMap.begin(); - aShapePropIter != mpTextBody->getTextProperties().maPropertyMap.end(); ++aShapePropIter ) - aShapeProperties[ (*aShapePropIter).first ] = (*aShapePropIter).second; - } - - aShapeProperties.insert( getShapeProperties().begin(), getShapeProperties().end() ); - aShapeProperties.insert( maDefaultShapeProperties.begin(), maDefaultShapeProperties.end() ); + aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap ); // applying properties - PropertySet aPropSet( xSet ); - if ( aServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) ) - mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rGraphicHelper ); - if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TableShape")) ) ) + aShapeProps.assignUsed( getShapeProperties() ); + aShapeProps.assignUsed( maDefaultShapeProperties ); + if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) + mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper ); + if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.TableShape" ) ) ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); - aFillProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); - aLineProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, LineProperties::DEFAULT_IDS, nLinePhClr ); + aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr ); + aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr ); // applying autogrowheight property before setting shape size, because // the shape size might be changed if currently autogrowheight is true @@ -463,12 +456,12 @@ Reference< XShape > Shape::createAndInsert( Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight ); if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) ) - if( /*const Any* pAutoGrowHeight =*/ aShapeProperties.getProperty( PROP_TextAutoGrowHeight ) ) + if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) ) xSet->setPropertyValue( rPropName, Any( false ) ); // do not set properties at a group shape (this causes assertions from svx) if( aServiceName != OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GroupShape")) ) - aPropSet.setProperties( aShapeProperties ); + PropertySet( xSet ).setProperties( aShapeProps ); if( bIsCustomShape ) { diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx new file mode 100755 index 000000000000..521ed28871ee --- /dev/null +++ b/oox/source/drawingml/shapepropertymap.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/drawingml/shapepropertymap.hxx" + +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/drawing/LineDash.hpp> +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include "oox/helper/modelobjecthelper.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::uno; + +using ::rtl::OUString; + +// ============================================================================ + +namespace { + +static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] = +{ + 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_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradient, + PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, + PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint +}; + +} // namespace + +ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false ); + +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" ); +} + +// ============================================================================ + +ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const ShapePropertyInfo& rShapePropInfo ) : + mrModelObjHelper( rModelObjHelper ), + maShapePropInfo( rShapePropInfo ) +{ +} + +bool ShapePropertyMap::supportsProperty( ShapePropertyId ePropId ) const +{ + return maShapePropInfo.has( ePropId ); +} + +bool ShapePropertyMap::hasNamedLineMarkerInTable( const OUString& rMarkerName ) const +{ + return maShapePropInfo.mbNamedLineMarker && mrModelObjHelper.hasLineMarker( rMarkerName ); +} + +bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValue ) +{ + // get current property identifier for the specified property + sal_Int32 nPropId = maShapePropInfo[ ePropId ]; + if( nPropId < 0 ) return false; + + // special handling for properties supporting named objects in tables + switch( ePropId ) + { + case SHAPEPROP_LineStart: + case SHAPEPROP_LineEnd: + return setLineMarker( nPropId, rValue ); + + case SHAPEPROP_LineDash: + return setLineDash( nPropId, rValue ); + + case SHAPEPROP_FillGradient: + return setFillGradient( nPropId, rValue ); + + case SHAPEPROP_FillBitmapUrl: + return setFillBitmapUrl( nPropId, rValue ); + + default:; // suppress compiler warnings + } + + // set plain property value + operator[]( nPropId ) = rValue; + return true; +} + +// private -------------------------------------------------------------------- + +bool ShapePropertyMap::setLineMarker( sal_Int32 nPropId, const Any& rValue ) +{ + NamedValue aNamedMarker; + if( (rValue >>= aNamedMarker) && (aNamedMarker.Name.getLength() > 0) ) + { + // push line marker explicitly + if( !maShapePropInfo.mbNamedLineMarker ) + return setAnyProperty( nPropId, aNamedMarker.Value ); + + // create named line marker (if coordinates have been passed) and push its name + bool bInserted = !aNamedMarker.Value.has< PolyPolygonBezierCoords >() || + mrModelObjHelper.insertLineMarker( aNamedMarker.Name, aNamedMarker.Value.get< PolyPolygonBezierCoords >() ); + return bInserted && setProperty( nPropId, aNamedMarker.Name ); + } + return false; +} + +bool ShapePropertyMap::setLineDash( sal_Int32 nPropId, const Any& rValue ) +{ + // push line dash explicitly + if( !maShapePropInfo.mbNamedLineDash ) + return setAnyProperty( nPropId, rValue ); + + // create named line dash and push its name + if( rValue.has< LineDash >() ) + { + OUString aDashName = mrModelObjHelper.insertLineDash( rValue.get< LineDash >() ); + return (aDashName.getLength() > 0) && setProperty( nPropId, aDashName ); + } + + return false; +} + +bool ShapePropertyMap::setFillGradient( sal_Int32 nPropId, const Any& rValue ) +{ + // push gradient explicitly + if( !maShapePropInfo.mbNamedFillGradient ) + return setAnyProperty( nPropId, rValue ); + + // create named gradient and push its name + if( rValue.has< Gradient >() ) + { + OUString aGradientName = mrModelObjHelper.insertFillGradient( rValue.get< Gradient >() ); + return (aGradientName.getLength() > 0) && setProperty( nPropId, aGradientName ); + } + + return false; +} + +bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue ) +{ + // push bitmap URL explicitly + if( !maShapePropInfo.mbNamedFillBitmapUrl ) + return setAnyProperty( nPropId, rValue ); + + // create named bitmap URL and push its name + if( rValue.has< OUString >() ) + { + OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() ); + return (aBitmapUrlName.getLength() > 0) && setProperty( nPropId, aBitmapUrlName ); + } + + return false; +} + +// ============================================================================ + +} // namespace drawingml +} // namespace oox diff --git a/oox/source/drawingml/table/makefile.mk b/oox/source/drawingml/table/makefile.mk index fa71971fc278..fa71971fc278 100644..100755 --- a/oox/source/drawingml/table/makefile.mk +++ b/oox/source/drawingml/table/makefile.mk diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 0fa2de867b3d..be51773de826 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -28,6 +28,7 @@ #include "oox/drawingml/table/tablecell.hxx" #include "oox/drawingml/table/tableproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/helper/propertyset.hxx" @@ -363,9 +364,10 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR ); aFillProperties.assignUsed( maFillProperties ); - PropertySet aPropSet( xPropSet ); + ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() ); // TODO: phClr? - aFillProperties.pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); + aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() ); + PropertySet( xPropSet ).setProperties( aPropMap ); } } } } |