1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: typegroupconverter.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "oox/drawingml/chart/typegroupconverter.hxx"
33 #include <com/sun/star/chart/DataLabelPlacement.hpp>
34 #include <com/sun/star/chart2/CurveStyle.hpp>
35 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
36 #include <com/sun/star/chart2/StackingDirection.hpp>
37 #include <com/sun/star/chart2/Symbol.hpp>
38 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
39 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
40 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
41 #include <com/sun/star/chart2/data/XDataSink.hpp>
42 #include <com/sun/star/drawing/LineStyle.hpp>
43 #include "oox/drawingml/lineproperties.hxx"
44 #include "oox/drawingml/chart/seriesconverter.hxx"
45 #include "oox/drawingml/chart/typegroupmodel.hxx"
46 #include "properties.hxx"
48 using ::rtl::OUString
;
49 using ::com::sun::star::uno::Reference
;
50 using ::com::sun::star::uno::Sequence
;
51 using ::com::sun::star::uno::Exception
;
52 using ::com::sun::star::uno::UNO_QUERY
;
53 using ::com::sun::star::uno::UNO_QUERY_THROW
;
54 using ::com::sun::star::beans::XPropertySet
;
55 using ::com::sun::star::chart2::XChartType
;
56 using ::com::sun::star::chart2::XChartTypeContainer
;
57 using ::com::sun::star::chart2::XCoordinateSystem
;
58 using ::com::sun::star::chart2::XDataSeries
;
59 using ::com::sun::star::chart2::XDataSeriesContainer
;
60 using ::com::sun::star::chart2::XDiagram
;
61 using ::com::sun::star::chart2::data::XDataSink
;
62 using ::com::sun::star::chart2::data::XLabeledDataSequence
;
68 // ============================================================================
72 // chart type service names
73 const sal_Char SERVICE_CHART2_AREA
[] = "com.sun.star.chart2.AreaChartType";
74 const sal_Char SERVICE_CHART2_CANDLE
[] = "com.sun.star.chart2.CandleStickChartType";
75 const sal_Char SERVICE_CHART2_COLUMN
[] = "com.sun.star.chart2.ColumnChartType";
76 const sal_Char SERVICE_CHART2_LINE
[] = "com.sun.star.chart2.LineChartType";
77 const sal_Char SERVICE_CHART2_NET
[] = "com.sun.star.chart2.NetChartType";
78 const sal_Char SERVICE_CHART2_FILLEDNET
[] = "com.sun.star.chart2.FilledNetChartType";
79 const sal_Char SERVICE_CHART2_PIE
[] = "com.sun.star.chart2.PieChartType";
80 const sal_Char SERVICE_CHART2_SCATTER
[] = "com.sun.star.chart2.ScatterChartType";
81 const sal_Char SERVICE_CHART2_BUBBLE
[] = "com.sun.star.chart2.BubbleChartType";
82 const sal_Char SERVICE_CHART2_SURFACE
[] = "com.sun.star.chart2.ColumnChartType"; // Todo
84 namespace csscd
= ::com::sun::star::chart::DataLabelPlacement
;
86 static const TypeGroupInfo spTypeInfos
[] =
88 // type-id type-category service varied-point-color default label pos comb2d supp3d polar area2d 1stvis xcateg swap stack revers betw picopt
89 { TYPEID_BAR
, TYPECATEGORY_BAR
, SERVICE_CHART2_COLUMN
, VARPOINTMODE_SINGLE
, csscd::OUTSIDE
, true, true, false, true, false, true, false, true, false, true, true },
90 { TYPEID_HORBAR
, TYPECATEGORY_BAR
, SERVICE_CHART2_COLUMN
, VARPOINTMODE_SINGLE
, csscd::OUTSIDE
, false, true, false, true, false, true, true, true, false, true, true },
91 { TYPEID_LINE
, TYPECATEGORY_LINE
, SERVICE_CHART2_LINE
, VARPOINTMODE_SINGLE
, csscd::RIGHT
, true, true, false, false, false, true, false, true, false, true, false },
92 { TYPEID_AREA
, TYPECATEGORY_LINE
, SERVICE_CHART2_AREA
, VARPOINTMODE_NONE
, csscd::CENTER
, true, true, false, true, false, true, false, true, true, false, false },
93 { TYPEID_STOCK
, TYPECATEGORY_LINE
, SERVICE_CHART2_CANDLE
, VARPOINTMODE_NONE
, csscd::RIGHT
, true, false, false, false, false, true, false, true, false, true, false },
94 { TYPEID_RADARLINE
, TYPECATEGORY_RADAR
, SERVICE_CHART2_NET
, VARPOINTMODE_SINGLE
, csscd::TOP
, false, false, true, false, false, true, false, false, false, false, false },
95 { TYPEID_RADARAREA
, TYPECATEGORY_RADAR
, SERVICE_CHART2_FILLEDNET
, VARPOINTMODE_NONE
, csscd::TOP
, false, false, true, true, false, true, false, false, true, false, false },
96 { TYPEID_PIE
, TYPECATEGORY_PIE
, SERVICE_CHART2_PIE
, VARPOINTMODE_MULTI
, csscd::AVOID_OVERLAP
, false, true, true, true, true, true, false, false, false, false, false },
97 { TYPEID_DOUGHNUT
, TYPECATEGORY_PIE
, SERVICE_CHART2_PIE
, VARPOINTMODE_MULTI
, csscd::AVOID_OVERLAP
, false, true, true, true, false, true, false, false, false, false, false },
98 { TYPEID_OFPIE
, TYPECATEGORY_PIE
, SERVICE_CHART2_PIE
, VARPOINTMODE_MULTI
, csscd::AVOID_OVERLAP
, false, true, true, true, true, true, false, false, false, false, false },
99 { TYPEID_SCATTER
, TYPECATEGORY_SCATTER
, SERVICE_CHART2_SCATTER
, VARPOINTMODE_SINGLE
, csscd::RIGHT
, true, true, false, false, false, false, false, false, false, false, false },
100 { TYPEID_BUBBLE
, TYPECATEGORY_SCATTER
, SERVICE_CHART2_BUBBLE
, VARPOINTMODE_SINGLE
, csscd::RIGHT
, false, false, false, true, false, false, false, false, false, false, false },
101 { TYPEID_SURFACE
, TYPECATEGORY_SURFACE
, SERVICE_CHART2_SURFACE
, VARPOINTMODE_NONE
, csscd::RIGHT
, false, true, false, true, false, true, false, false, false, false, false }
104 static const TypeGroupInfo saUnknownTypeInfo
=
105 { TYPEID_UNKNOWN
, TYPECATEGORY_BAR
, SERVICE_CHART2_COLUMN
, VARPOINTMODE_SINGLE
, csscd::OUTSIDE
, true, true, false, true, false, true, false, true, false, true, true };
107 const TypeGroupInfo
& lclGetTypeInfoFromTypeId( TypeId eTypeId
)
109 const TypeGroupInfo
* pEnd
= STATIC_ARRAY_END( spTypeInfos
);
110 for( const TypeGroupInfo
* pIt
= spTypeInfos
; pIt
!= pEnd
; ++pIt
)
111 if( pIt
->meTypeId
== eTypeId
)
113 OSL_ENSURE( eTypeId
== TYPEID_UNKNOWN
, "lclGetTypeInfoFromTypeId - unexpected chart type identifier" );
114 return saUnknownTypeInfo
;
119 // ============================================================================
121 UpDownBarsConverter::UpDownBarsConverter( const ConverterRoot
& rParent
, UpDownBarsModel
& rModel
) :
122 ConverterBase
< UpDownBarsModel
>( rParent
, rModel
)
126 UpDownBarsConverter::~UpDownBarsConverter()
130 void UpDownBarsConverter::convertFromModel( const Reference
< XChartType
>& rxChartType
)
132 PropertySet
aTypeProp( rxChartType
);
135 Reference
< XPropertySet
> xWhitePropSet
;
136 if( aTypeProp
.getProperty( xWhitePropSet
, PROP_WhiteDay
) )
138 PropertySet
aPropSet( xWhitePropSet
);
139 getFormatter().convertFrameFormatting( aPropSet
, mrModel
.mxUpBars
, OBJECTTYPE_UPBAR
);
143 Reference
< XPropertySet
> xBlackPropSet
;
144 if( aTypeProp
.getProperty( xBlackPropSet
, PROP_BlackDay
) )
146 PropertySet
aPropSet( xBlackPropSet
);
147 getFormatter().convertFrameFormatting( aPropSet
, mrModel
.mxDownBars
, OBJECTTYPE_DOWNBAR
);
151 // ============================================================================
153 TypeGroupConverter::TypeGroupConverter( const ConverterRoot
& rParent
, TypeGroupModel
& rModel
) :
154 ConverterBase
< TypeGroupModel
>( rParent
, rModel
),
157 TypeId eTypeId
= TYPEID_UNKNOWN
;
158 switch( mrModel
.mnTypeId
)
160 #define ENSURE_AXESCOUNT( min, max ) OSL_ENSURE( (min <= (int)mrModel.maAxisIds.size()) && ((int)mrModel.maAxisIds.size() <= max), "TypeGroupConverter::TypeGroupConverter - invalid axes count" )
161 case C_TOKEN( area3DChart
): ENSURE_AXESCOUNT( 2, 3 ); eTypeId
= TYPEID_AREA
; mb3dChart
= true; break;
162 case C_TOKEN( areaChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_AREA
; mb3dChart
= false; break;
163 case C_TOKEN( bar3DChart
): ENSURE_AXESCOUNT( 2, 3 ); eTypeId
= TYPEID_BAR
; mb3dChart
= true; break;
164 case C_TOKEN( barChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_BAR
; mb3dChart
= false; break;
165 case C_TOKEN( bubbleChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_BUBBLE
; mb3dChart
= false; break;
166 case C_TOKEN( doughnutChart
): ENSURE_AXESCOUNT( 0, 0 ); eTypeId
= TYPEID_DOUGHNUT
; mb3dChart
= false; break;
167 case C_TOKEN( line3DChart
): ENSURE_AXESCOUNT( 3, 3 ); eTypeId
= TYPEID_LINE
; mb3dChart
= true; break;
168 case C_TOKEN( lineChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_LINE
; mb3dChart
= false; break;
169 case C_TOKEN( ofPieChart
): ENSURE_AXESCOUNT( 0, 0 ); eTypeId
= TYPEID_OFPIE
; mb3dChart
= false; break;
170 case C_TOKEN( pie3DChart
): ENSURE_AXESCOUNT( 0, 0 ); eTypeId
= TYPEID_PIE
; mb3dChart
= true; break;
171 case C_TOKEN( pieChart
): ENSURE_AXESCOUNT( 0, 0 ); eTypeId
= TYPEID_PIE
; mb3dChart
= false; break;
172 case C_TOKEN( radarChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_RADARLINE
; mb3dChart
= false; break;
173 case C_TOKEN( scatterChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_SCATTER
; mb3dChart
= false; break;
174 case C_TOKEN( stockChart
): ENSURE_AXESCOUNT( 2, 2 ); eTypeId
= TYPEID_STOCK
; mb3dChart
= false; break;
175 case C_TOKEN( surface3DChart
): ENSURE_AXESCOUNT( 3, 3 ); eTypeId
= TYPEID_SURFACE
; mb3dChart
= true; break;
176 case C_TOKEN( surfaceChart
): ENSURE_AXESCOUNT( 2, 3 ); eTypeId
= TYPEID_SURFACE
; mb3dChart
= true; break; // 3D bar chart from all surface charts
177 default: OSL_ENSURE( false, "TypeGroupConverter::TypeGroupConverter - unknown chart type" );
178 #undef ENSURE_AXESCOUNT
181 // special handling for some chart types
185 if( mrModel
.mnBarDir
== XML_bar
)
186 eTypeId
= TYPEID_HORBAR
;
188 case TYPEID_RADARLINE
:
189 if( mrModel
.mnRadarStyle
== XML_filled
)
190 eTypeId
= TYPEID_RADARAREA
;
193 // create a deep 3D bar chart from surface charts
194 mrModel
.mnGrouping
= XML_standard
;
199 // set the chart type info struct for the current chart type
200 maTypeInfo
= lclGetTypeInfoFromTypeId( eTypeId
);
203 TypeGroupConverter::~TypeGroupConverter()
207 bool TypeGroupConverter::isStacked() const
209 return maTypeInfo
.mbSupportsStacking
&& (mrModel
.mnGrouping
== XML_stacked
);
212 bool TypeGroupConverter::isPercent() const
214 return maTypeInfo
.mbSupportsStacking
&& (mrModel
.mnGrouping
== XML_percentStacked
);
217 bool TypeGroupConverter::is3dChart() const
222 bool TypeGroupConverter::isWall3dChart() const
224 return mb3dChart
&& (maTypeInfo
.meTypeCategory
!= TYPECATEGORY_PIE
);
227 bool TypeGroupConverter::isDeep3dChart() const
229 return isWall3dChart() && (mrModel
.mnGrouping
== XML_standard
);
232 bool TypeGroupConverter::isSeriesFrameFormat() const
234 return mb3dChart
|| maTypeInfo
.mbSeriesIsFrame2d
;
237 ObjectType
TypeGroupConverter::getSeriesObjectType() const
239 return mb3dChart
? OBJECTTYPE_FILLEDSERIES3D
:
240 (maTypeInfo
.mbSeriesIsFrame2d
? OBJECTTYPE_FILLEDSERIES2D
: OBJECTTYPE_LINEARSERIES2D
);
243 bool TypeGroupConverter::isReverseSeries() const
245 return maTypeInfo
.mbReverseSeries
&& !mb3dChart
&& !isStacked() && !isPercent();
248 OUString
TypeGroupConverter::getSingleSeriesTitle() const
250 OUString aSeriesTitle
;
251 if( !mrModel
.maSeries
.empty() && (maTypeInfo
.mbSingleSeriesVis
|| (mrModel
.maSeries
.size() == 1)) )
252 if( const TextModel
* pText
= mrModel
.maSeries
.front()->mxText
.get() )
253 if( const DataSequenceModel
* pDataSeq
= pText
->mxDataSeq
.get() )
254 if( !pDataSeq
->maData
.empty() )
255 pDataSeq
->maData
.begin()->second
>>= aSeriesTitle
;
259 Reference
< XCoordinateSystem
> TypeGroupConverter::createCoordinateSystem()
261 // find service name for coordinate system
262 OUString aServiceName
;
263 if( maTypeInfo
.mbPolarCoordSystem
)
266 aServiceName
= CREATE_OUSTRING( "com.sun.star.chart2.PolarCoordinateSystem3d" );
268 aServiceName
= CREATE_OUSTRING( "com.sun.star.chart2.PolarCoordinateSystem2d" );
273 aServiceName
= CREATE_OUSTRING( "com.sun.star.chart2.CartesianCoordinateSystem3d" );
275 aServiceName
= CREATE_OUSTRING( "com.sun.star.chart2.CartesianCoordinateSystem2d" );
278 // create the coordinate system object
279 Reference
< XCoordinateSystem
> xCoordSystem( createInstance( aServiceName
), UNO_QUERY
);
282 if( maTypeInfo
.mbSwappedAxesSet
)
284 PropertySet
aPropSet( xCoordSystem
);
285 aPropSet
.setProperty( PROP_SwapXAndYAxis
, true );
291 Reference
< XLabeledDataSequence
> TypeGroupConverter::createCategorySequence()
293 Reference
< XLabeledDataSequence
> xLabeledSeq
;
294 /* Find first existing category sequence. The bahaviour of Excel 2007 is
295 different to Excel 2003, which always used the category sequence of the
296 first series, even if it was empty. */
297 for( TypeGroupModel::SeriesVector::iterator aIt
= mrModel
.maSeries
.begin(), aEnd
= mrModel
.maSeries
.end(); !xLabeledSeq
.is() && (aIt
!= aEnd
); ++aIt
)
299 if( (*aIt
)->maSources
.has( SeriesModel::CATEGORIES
) )
301 SeriesConverter
aSeriesConv( *this, **aIt
);
302 xLabeledSeq
= aSeriesConv
.createCategorySequence( CREATE_OUSTRING( "categories" ) );
308 void TypeGroupConverter::convertFromModel( const Reference
< XDiagram
>& rxDiagram
,
309 const Reference
< XCoordinateSystem
>& rxCoordSystem
,
310 sal_Int32 nAxesSetIdx
, bool bSupportsVaryColorsByPoint
)
314 // create the chart type object
315 OUString aService
= OUString::createFromAscii( maTypeInfo
.mpcServiceName
);
316 Reference
< XChartType
> xChartType( createInstance( aService
), UNO_QUERY_THROW
);
318 // additional properties
319 PropertySet
aDiaProp( rxDiagram
);
320 PropertySet
aTypeProp( xChartType
);
321 switch( maTypeInfo
.meTypeCategory
)
323 case TYPECATEGORY_BAR
:
325 Sequence
< sal_Int32
> aInt32Seq( 2 );
326 aInt32Seq
[ 0 ] = aInt32Seq
[ 1 ] = mrModel
.mnOverlap
;
327 aTypeProp
.setProperty( PROP_OverlapSequence
, aInt32Seq
);
328 aInt32Seq
[ 0 ] = aInt32Seq
[ 1 ] = mrModel
.mnGapWidth
;
329 aTypeProp
.setProperty( PROP_GapwidthSequence
, aInt32Seq
);
332 case TYPECATEGORY_PIE
:
334 aTypeProp
.setProperty( PROP_UseRings
, maTypeInfo
.meTypeId
== TYPEID_DOUGHNUT
);
335 /* #i85166# starting angle of first pie slice. 3D pie charts
336 use Y rotation setting in view3D element. Of-pie charts do
337 not support pie rotation. */
338 if( !is3dChart() && (maTypeInfo
.meTypeId
!= TYPEID_OFPIE
) )
339 convertPieRotation( aDiaProp
, mrModel
.mnFirstAngle
);
345 // create converter objects for all series models
346 typedef RefVector
< SeriesConverter
> SeriesConvVector
;
347 SeriesConvVector aSeries
;
348 for( TypeGroupModel::SeriesVector::iterator aIt
= mrModel
.maSeries
.begin(), aEnd
= mrModel
.maSeries
.end(); aIt
!= aEnd
; ++aIt
)
349 aSeries
.push_back( SeriesConvVector::value_type( new SeriesConverter( *this, **aIt
) ) );
351 // reverse series order for some unstacked 2D chart types
352 if( isReverseSeries() )
353 ::std::reverse( aSeries
.begin(), aSeries
.end() );
355 // decide whether to use varying colors for each data point
356 bool bVaryColorsByPoint
= bSupportsVaryColorsByPoint
&& mrModel
.mbVaryColors
;
357 switch( maTypeInfo
.meVarPointMode
)
359 case VARPOINTMODE_NONE
: bVaryColorsByPoint
= false; break;
360 case VARPOINTMODE_SINGLE
: bVaryColorsByPoint
&= (mrModel
.maSeries
.size() == 1); break;
361 case VARPOINTMODE_MULTI
: break;
364 /* Stock chart needs special processing. Create one 'big' series with
365 data sequences of different roles. */
366 if( maTypeInfo
.meTypeId
== TYPEID_STOCK
)
368 // create the data series object
369 Reference
< XDataSeries
> xDataSeries( createInstance( CREATE_OUSTRING( "com.sun.star.chart2.DataSeries" ) ), UNO_QUERY
);
370 Reference
< XDataSink
> xDataSink( xDataSeries
, UNO_QUERY
);
373 // create a list of data sequences from all series
374 ::std::vector
< Reference
< XLabeledDataSequence
> > aLabeledSeqVec
;
375 OSL_ENSURE( aSeries
.size() >= 3, "TypeGroupConverter::convertFromModel - too few stock chart series" );
376 int nRoleIdx
= (aSeries
.size() == 3) ? 1 : 0;
377 for( SeriesConvVector::iterator aIt
= aSeries
.begin(), aEnd
= aSeries
.end(); (nRoleIdx
< 4) && (aIt
!= aEnd
); ++nRoleIdx
, ++aIt
)
379 // create a data sequence with a specific role
383 case 0: aRole
= CREATE_OUSTRING( "values-first" ); break;
384 case 1: aRole
= CREATE_OUSTRING( "values-max" ); break;
385 case 2: aRole
= CREATE_OUSTRING( "values-min" ); break;
386 case 3: aRole
= CREATE_OUSTRING( "values-last" ); break;
388 Reference
< XLabeledDataSequence
> xDataSeq
= (*aIt
)->createValueSequence( aRole
);
390 aLabeledSeqVec
.push_back( xDataSeq
);
393 // attach labeled data sequences to series and insert series into chart type
394 xDataSink
->setData( ContainerHelper::vectorToSequence( aLabeledSeqVec
) );
396 // formatting of high/low lines
397 aTypeProp
.setProperty( PROP_ShowHighLow
, true );
398 PropertySet
aSeriesProp( xDataSeries
);
399 if( mrModel
.mxHiLowLines
.is() )
400 getFormatter().convertFrameFormatting( aSeriesProp
, mrModel
.mxHiLowLines
, OBJECTTYPE_HILOLINE
);
402 // hi/low-lines cannot be switched off via "ShowHighLow" property (?)
403 aSeriesProp
.setProperty( PROP_LineStyle
, ::com::sun::star::drawing::LineStyle_NONE
);
405 // formatting of up/down bars
406 bool bUpDownBars
= mrModel
.mxUpDownBars
.is();
407 aTypeProp
.setProperty( PROP_Japanese
, bUpDownBars
);
408 aTypeProp
.setProperty( PROP_ShowFirst
, bUpDownBars
);
411 UpDownBarsConverter
aUpDownConv( *this, *mrModel
.mxUpDownBars
);
412 aUpDownConv
.convertFromModel( xChartType
);
415 // insert the series into the chart type object
416 insertDataSeries( xChartType
, xDataSeries
, nAxesSetIdx
);
421 for( SeriesConvVector::iterator aIt
= aSeries
.begin(), aEnd
= aSeries
.end(); aIt
!= aEnd
; ++aIt
)
423 SeriesConverter
& rSeriesConv
= **aIt
;
424 Reference
< XDataSeries
> xDataSeries
= rSeriesConv
.createDataSeries( *this, bVaryColorsByPoint
);
425 insertDataSeries( xChartType
, xDataSeries
, nAxesSetIdx
);
427 /* Excel does not use the value of the c:smooth element of the
428 chart type to set a default line smoothing for the data
429 series. Line smoothing is always controlled by the c:smooth
430 element of the respective data series. If the element in the
431 data series is missing, line smoothing is off, regardless of
432 the c:smooth element of the chart type. */
433 #if !OOX_CHART_SMOOTHED_PER_SERIES
434 if( rSeriesConv
.getModel().mbSmooth
)
435 convertLineSmooth( aTypeProp
, true );
440 // add chart type object to coordinate system
441 Reference
< XChartTypeContainer
> xChartTypeCont( rxCoordSystem
, UNO_QUERY_THROW
);
442 xChartTypeCont
->addChartType( xChartType
);
444 // set existence of bar connector lines at diagram (only in stacked 2D bar charts)
445 if( mrModel
.mxSerLines
.is() && !mb3dChart
&& (maTypeInfo
.meTypeCategory
== TYPECATEGORY_BAR
) && (isStacked() || isPercent()) )
446 aDiaProp
.setProperty( PROP_ConnectBars
, true );
450 OSL_ENSURE( false, "TypeGroupConverter::convertFromModel - cannot add chart type" );
454 void TypeGroupConverter::convertMarker( PropertySet
& rPropSet
, sal_Int32 nOoxSymbol
, sal_Int32 nOoxSize
) const
456 if( !isSeriesFrameFormat() )
458 namespace cssc
= ::com::sun::star::chart2
;
461 cssc::Symbol aSymbol
;
462 aSymbol
.Style
= cssc::SymbolStyle_STANDARD
;
465 case XML_auto
: aSymbol
.Style
= cssc::SymbolStyle_AUTO
; break;
466 case XML_none
: aSymbol
.Style
= cssc::SymbolStyle_NONE
; break;
467 case XML_square
: aSymbol
.StandardSymbol
= 0; break; // square
468 case XML_diamond
: aSymbol
.StandardSymbol
= 1; break; // diamond
469 case XML_triangle
: aSymbol
.StandardSymbol
= 3; break; // arrow up
470 case XML_x
: aSymbol
.StandardSymbol
= 6; break; // bow tie
471 case XML_star
: aSymbol
.StandardSymbol
= 7; break; // sand glass
472 case XML_dot
: aSymbol
.StandardSymbol
= 4; break; // arrow right
473 case XML_dash
: aSymbol
.StandardSymbol
= 2; break; // arrow down
474 case XML_circle
: aSymbol
.StandardSymbol
= 4; break; // arrow right
475 case XML_plus
: aSymbol
.StandardSymbol
= 5; break; // arrow left
478 // symbol size (points in OOXML, 1/100 mm in Chart2)
479 sal_Int32 nSize
= static_cast< sal_Int32
>( nOoxSize
* (2540.0 / 72.0) + 0.5 );
480 aSymbol
.Size
.Width
= aSymbol
.Size
.Height
= nSize
;
483 rPropSet
.setProperty( PROP_Symbol
, aSymbol
);
487 void TypeGroupConverter::convertLineSmooth( PropertySet
& rPropSet
, bool bOoxSmooth
) const
489 if( !isSeriesFrameFormat() && (maTypeInfo
.meTypeCategory
!= TYPECATEGORY_RADAR
) )
491 namespace cssc
= ::com::sun::star::chart2
;
492 cssc::CurveStyle eCurveStyle
= bOoxSmooth
? cssc::CurveStyle_CUBIC_SPLINES
: cssc::CurveStyle_LINES
;
493 rPropSet
.setProperty( PROP_CurveStyle
, eCurveStyle
);
497 void TypeGroupConverter::convertBarGeometry( PropertySet
& rPropSet
, sal_Int32 nOoxShape
) const
499 if( mb3dChart
&& (maTypeInfo
.meTypeCategory
== TYPECATEGORY_BAR
) )
501 namespace cssc
= ::com::sun::star::chart2
;
503 sal_Int32 nGeom3d
= cssc::DataPointGeometry3D::CUBOID
;
506 case XML_box
: nGeom3d
= cssc::DataPointGeometry3D::CUBOID
; break;
507 case XML_cone
: nGeom3d
= cssc::DataPointGeometry3D::CONE
; break;
508 case XML_coneToMax
: nGeom3d
= cssc::DataPointGeometry3D::CONE
; break;
509 case XML_cylinder
: nGeom3d
= cssc::DataPointGeometry3D::CYLINDER
; break;
510 case XML_pyramid
: nGeom3d
= cssc::DataPointGeometry3D::PYRAMID
; break;
511 case XML_pyramidToMax
: nGeom3d
= cssc::DataPointGeometry3D::PYRAMID
; break;
512 default: OSL_ENSURE( false, "TypeGroupConverter::convertBarGeometry - unknown 3D bar shape type" );
514 rPropSet
.setProperty( PROP_Geometry3D
, nGeom3d
);
518 void TypeGroupConverter::convertPieRotation( PropertySet
& rPropSet
, sal_Int32 nOoxAngle
) const
520 if( maTypeInfo
.meTypeCategory
== TYPECATEGORY_PIE
)
522 // map OOXML [0,360] clockwise (0deg top) to Chart2 counterclockwise (0deg left)
523 sal_Int32 nAngle
= (450 - nOoxAngle
) % 360;
524 rPropSet
.setProperty( PROP_StartingAngle
, nAngle
);
528 void TypeGroupConverter::convertPieExplosion( PropertySet
& rPropSet
, sal_Int32 nOoxExplosion
) const
530 if( maTypeInfo
.meTypeCategory
== TYPECATEGORY_PIE
)
532 // pie explosion restricted to 100% in Chart2, set as double in range [0,1]
533 double fOffset
= getLimitedValue
< double >( nOoxExplosion
/ 100.0, 0.0, 1.0 );
534 rPropSet
.setProperty( PROP_Offset
, fOffset
);
538 // private --------------------------------------------------------------------
540 void TypeGroupConverter::insertDataSeries( const Reference
< XChartType
>& rxChartType
, const Reference
< XDataSeries
>& rxSeries
, sal_Int32 nAxesSetIdx
)
544 PropertySet
aSeriesProp( rxSeries
);
546 // series stacking mode
547 namespace cssc
= ::com::sun::star::chart2
;
548 cssc::StackingDirection eStacking
= cssc::StackingDirection_NO_STACKING
;
549 // stacked overrides deep-3d
550 if( isStacked() || isPercent() )
551 eStacking
= cssc::StackingDirection_Y_STACKING
;
552 else if( isDeep3dChart() )
553 eStacking
= cssc::StackingDirection_Z_STACKING
;
554 aSeriesProp
.setProperty( PROP_StackingDirection
, eStacking
);
556 // additional series properties
557 aSeriesProp
.setProperty( PROP_AttachedAxisIndex
, nAxesSetIdx
);
559 // insert series into container
562 Reference
< XDataSeriesContainer
> xSeriesCont( rxChartType
, UNO_QUERY_THROW
);
563 xSeriesCont
->addDataSeries( rxSeries
);
567 OSL_ENSURE( false, "TypeGroupConverter::insertDataSeries - cannot add data series" );
572 // ============================================================================
575 } // namespace drawingml