Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "oox/drawingml/chart/plotareaconverter.hxx"
21 : :
22 : : #include <com/sun/star/chart/XChartDocument.hpp>
23 : : #include <com/sun/star/chart/XDiagramPositioning.hpp>
24 : : #include <com/sun/star/chart2/XChartDocument.hpp>
25 : : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
26 : : #include <com/sun/star/chart2/XDiagram.hpp>
27 : : #include <com/sun/star/drawing/Direction3D.hpp>
28 : : #include <com/sun/star/drawing/ProjectionMode.hpp>
29 : : #include <com/sun/star/drawing/ShadeMode.hpp>
30 : : #include "oox/drawingml/chart/axisconverter.hxx"
31 : : #include "oox/drawingml/chart/plotareamodel.hxx"
32 : : #include "oox/drawingml/chart/typegroupconverter.hxx"
33 : :
34 : : namespace oox {
35 : : namespace drawingml {
36 : : namespace chart {
37 : :
38 : : // ============================================================================
39 : :
40 : : using namespace ::com::sun::star::awt;
41 : : using namespace ::com::sun::star::chart2;
42 : : using namespace ::com::sun::star::uno;
43 : :
44 : : using ::rtl::OUString;
45 : :
46 : : // ============================================================================
47 : :
48 : : namespace {
49 : :
50 : : /** Axes set model. This is a helper for the plot area converter collecting all
51 : : type groups and axes of the primary or secondary axes set. */
52 : : struct AxesSetModel
53 : : {
54 : : typedef ModelVector< TypeGroupModel > TypeGroupVector;
55 : : typedef ModelMap< sal_Int32, AxisModel > AxisMap;
56 : :
57 : : TypeGroupVector maTypeGroups; /// All type groups containing data series.
58 : : AxisMap maAxes; /// All axes mapped by API axis type.
59 : :
60 [ # # ]: 0 : inline explicit AxesSetModel() {}
61 : 0 : inline ~AxesSetModel() {}
62 : : };
63 : :
64 : : // ============================================================================
65 : :
66 : : /** Axes set converter. This is a helper class for the plot area converter. */
67 : : class AxesSetConverter : public ConverterBase< AxesSetModel >
68 : : {
69 : : public:
70 : : explicit AxesSetConverter( const ConverterRoot& rParent, AxesSetModel& rModel );
71 : : virtual ~AxesSetConverter();
72 : :
73 : : /** Converts the axes set model to a chart2 diagram. Returns an automatic
74 : : chart title from a single series title, if possible. */
75 : : void convertFromModel(
76 : : const Reference< XDiagram >& rxDiagram,
77 : : View3DModel& rView3DModel,
78 : : sal_Int32 nAxesSetIdx,
79 : : bool bSupportsVaryColorsByPoint );
80 : :
81 : : /** Returns the automatic chart title if the axes set contains only one series. */
82 : 0 : inline const ::rtl::OUString& getAutomaticTitle() const { return maAutoTitle; }
83 : : /** Returns true, if the chart is three-dimensional. */
84 : 0 : inline bool is3dChart() const { return mb3dChart; }
85 : : /** Returns true, if chart type supports wall and floor format in 3D mode. */
86 : 0 : inline bool isWall3dChart() const { return mbWall3dChart; }
87 : : /** Returns true, if chart is a pie chart or doughnut chart. */
88 : 0 : inline bool isPieChart() const { return mbPieChart; }
89 : :
90 : : private:
91 : : ::rtl::OUString maAutoTitle;
92 : : bool mb3dChart;
93 : : bool mbWall3dChart;
94 : : bool mbPieChart;
95 : : };
96 : :
97 : : // ----------------------------------------------------------------------------
98 : :
99 : 0 : AxesSetConverter::AxesSetConverter( const ConverterRoot& rParent, AxesSetModel& rModel ) :
100 : : ConverterBase< AxesSetModel >( rParent, rModel ),
101 : : mb3dChart( false ),
102 : : mbWall3dChart( false ),
103 : 0 : mbPieChart( false )
104 : : {
105 : 0 : }
106 : :
107 : 0 : AxesSetConverter::~AxesSetConverter()
108 : : {
109 [ # # ]: 0 : }
110 : :
111 : 0 : ModelRef< AxisModel > lclGetOrCreateAxis( const AxesSetModel::AxisMap& rFromAxes, sal_Int32 nAxisIdx, sal_Int32 nDefTypeId )
112 : : {
113 [ # # ][ # # ]: 0 : ModelRef< AxisModel > xAxis = rFromAxes.get( nAxisIdx );
114 [ # # ]: 0 : if( !xAxis )
115 [ # # ]: 0 : xAxis.create( nDefTypeId ).mbDeleted = true; // missing axis is invisible
116 : 0 : return xAxis;
117 : : }
118 : :
119 : 0 : void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
120 : : View3DModel& rView3DModel, sal_Int32 nAxesSetIdx, bool bSupportsVaryColorsByPoint )
121 : : {
122 : : // create type group converter objects for all type groups
123 : : typedef RefVector< TypeGroupConverter > TypeGroupConvVector;
124 [ # # ]: 0 : TypeGroupConvVector aTypeGroups;
125 [ # # ][ # # ]: 0 : for( AxesSetModel::TypeGroupVector::iterator aIt = mrModel.maTypeGroups.begin(), aEnd = mrModel.maTypeGroups.end(); aIt != aEnd; ++aIt )
126 [ # # ][ # # ]: 0 : aTypeGroups.push_back( TypeGroupConvVector::value_type( new TypeGroupConverter( *this, **aIt ) ) );
[ # # ][ # # ]
[ # # ]
127 : :
128 : : OSL_ENSURE( !aTypeGroups.empty(), "AxesSetConverter::convertFromModel - no type groups in axes set" );
129 [ # # ]: 0 : if( !aTypeGroups.empty() ) try
130 : : {
131 : : // first type group needed for coordinate system and axis conversion
132 [ # # ]: 0 : TypeGroupConverter& rFirstTypeGroup = *aTypeGroups.front();
133 : :
134 : : // get automatic chart title, if there is only one type group
135 [ # # ]: 0 : if( aTypeGroups.size() == 1 )
136 [ # # ]: 0 : maAutoTitle = rFirstTypeGroup.getSingleSeriesTitle();
137 : :
138 : : /* Create a coordinate system. For now, all type groups from all axes sets
139 : : have to be inserted into one coordinate system. Later, chart2 should
140 : : support using one coordinate system for each axes set. */
141 : 0 : Reference< XCoordinateSystem > xCoordSystem;
142 [ # # ]: 0 : Reference< XCoordinateSystemContainer > xCoordSystemCont( rxDiagram, UNO_QUERY_THROW );
143 [ # # ][ # # ]: 0 : Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
144 [ # # ]: 0 : if( aCoordSystems.hasElements() )
145 : : {
146 : : OSL_ENSURE( aCoordSystems.getLength() == 1, "AxesSetConverter::convertFromModel - too many coordinate systems" );
147 [ # # ][ # # ]: 0 : xCoordSystem = aCoordSystems[ 0 ];
148 : : OSL_ENSURE( xCoordSystem.is(), "AxesSetConverter::convertFromModel - invalid coordinate system" );
149 : : }
150 : : else
151 : : {
152 [ # # ][ # # ]: 0 : xCoordSystem = rFirstTypeGroup.createCoordinateSystem();
153 [ # # ]: 0 : if( xCoordSystem.is() )
154 [ # # ][ # # ]: 0 : xCoordSystemCont->addCoordinateSystem( xCoordSystem );
155 : : }
156 : :
157 : : // 3D view settings
158 [ # # ]: 0 : mb3dChart = rFirstTypeGroup.is3dChart();
159 [ # # ]: 0 : mbWall3dChart = rFirstTypeGroup.isWall3dChart();
160 : 0 : mbPieChart = rFirstTypeGroup.getTypeInfo().meTypeCategory == TYPECATEGORY_PIE;
161 [ # # ]: 0 : if( mb3dChart )
162 : : {
163 [ # # ]: 0 : View3DConverter aView3DConv( *this, rView3DModel );
164 [ # # ][ # # ]: 0 : aView3DConv.convertFromModel( rxDiagram, rFirstTypeGroup );
165 : : }
166 : :
167 : : /* Convert all chart type groups. Each type group will add its series
168 : : to the data provider attached to the chart document. */
169 [ # # ]: 0 : if( xCoordSystem.is() )
170 : : {
171 : : // convert all axes (create missing axis models)
172 [ # # ][ # # ]: 0 : ModelRef< AxisModel > xXAxis = lclGetOrCreateAxis( mrModel.maAxes, API_X_AXIS, rFirstTypeGroup.getTypeInfo().mbCategoryAxis ? C_TOKEN( catAx ) : C_TOKEN( valAx ) );
173 [ # # ]: 0 : ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Y_AXIS, C_TOKEN( valAx ) );
174 : :
175 [ # # ]: 0 : AxisConverter aXAxisConv( *this, *xXAxis );
176 [ # # ]: 0 : aXAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xYAxis.get(), nAxesSetIdx, API_X_AXIS );
177 [ # # ]: 0 : AxisConverter aYAxisConv( *this, *xYAxis );
178 [ # # ]: 0 : aYAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xXAxis.get(), nAxesSetIdx, API_Y_AXIS );
179 : :
180 [ # # ][ # # ]: 0 : if( rFirstTypeGroup.isDeep3dChart() )
181 : : {
182 [ # # ]: 0 : ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Z_AXIS, C_TOKEN( serAx ) );
183 [ # # ]: 0 : AxisConverter aZAxisConv( *this, *xZAxis );
184 [ # # ][ # # ]: 0 : aZAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, 0, nAxesSetIdx, API_Z_AXIS );
[ # # ]
185 : : }
186 : :
187 : : // convert all chart type groups, this converts all series data and formatting
188 [ # # ][ # # ]: 0 : for( TypeGroupConvVector::iterator aTIt = aTypeGroups.begin(), aTEnd = aTypeGroups.end(); aTIt != aTEnd; ++aTIt )
189 [ # # ][ # # ]: 0 : (*aTIt)->convertFromModel( rxDiagram, xCoordSystem, nAxesSetIdx, bSupportsVaryColorsByPoint );
[ # # ][ # # ]
[ # # ]
190 [ # # ][ # # ]: 0 : }
191 : : }
192 [ # # ]: 0 : catch( Exception& )
193 : : {
194 : 0 : }
195 : 0 : }
196 : :
197 : : } // namespace
198 : :
199 : : // ============================================================================
200 : :
201 : 0 : View3DConverter::View3DConverter( const ConverterRoot& rParent, View3DModel& rModel ) :
202 : 0 : ConverterBase< View3DModel >( rParent, rModel )
203 : : {
204 : 0 : }
205 : :
206 : 0 : View3DConverter::~View3DConverter()
207 : : {
208 [ # # ]: 0 : }
209 : :
210 : 0 : void View3DConverter::convertFromModel( const Reference< XDiagram >& rxDiagram, TypeGroupConverter& rTypeGroup )
211 : : {
212 : : namespace cssd = ::com::sun::star::drawing;
213 [ # # ]: 0 : PropertySet aPropSet( rxDiagram );
214 : :
215 : 0 : sal_Int32 nRotationY = 0;
216 : 0 : sal_Int32 nRotationX = 0;
217 : 0 : bool bRightAngled = false;
218 : 0 : sal_Int32 nAmbientColor = 0;
219 : 0 : sal_Int32 nLightColor = 0;
220 : :
221 [ # # ]: 0 : if( rTypeGroup.getTypeInfo().meTypeCategory == TYPECATEGORY_PIE )
222 : : {
223 : : // Y rotation used as 'first pie slice angle' in 3D pie charts
224 [ # # ]: 0 : rTypeGroup.convertPieRotation( aPropSet, mrModel.monRotationY.get( 0 ) );
225 : : // X rotation a.k.a. elevation (map OOXML [0..90] to Chart2 [-90,0])
226 [ # # ]: 0 : nRotationX = getLimitedValue< sal_Int32, sal_Int32 >( mrModel.monRotationX.get( 15 ), 0, 90 ) - 90;
227 : : // no right-angled axes in pie charts
228 : 0 : bRightAngled = false;
229 : : // ambient color (Gray 30%)
230 : 0 : nAmbientColor = 0xB3B3B3;
231 : : // light color (Gray 70%)
232 : 0 : nLightColor = 0x4C4C4C;
233 : : }
234 : : else // 3D bar/area/line charts
235 : : {
236 : : // Y rotation (OOXML [0..359], Chart2 [-179,180])
237 : 0 : nRotationY = mrModel.monRotationY.get( 20 );
238 : : // X rotation a.k.a. elevation (OOXML [-90..90], Chart2 [-179,180])
239 [ # # ]: 0 : nRotationX = getLimitedValue< sal_Int32, sal_Int32 >( mrModel.monRotationX.get( 15 ), -90, 90 );
240 : : // right-angled axes
241 : 0 : bRightAngled = mrModel.mbRightAngled;
242 : : // ambient color (Gray 20%)
243 : 0 : nAmbientColor = 0xCCCCCC;
244 : : // light color (Gray 60%)
245 : 0 : nLightColor = 0x666666;
246 : : }
247 : :
248 : : // Y rotation (map OOXML [0..359] to Chart2 [-179,180])
249 : 0 : nRotationY %= 360;
250 [ # # ]: 0 : if( nRotationY > 180 ) nRotationY -= 360;
251 : : /* Perspective (map OOXML [0..200] to Chart2 [0,100]). Seems that MSO 2007 is
252 : : buggy here, the XML plugin of MSO 2003 writes the correct perspective in
253 : : the range from 0 to 100. We will emulate the wrong behaviour of MSO 2007. */
254 [ # # ]: 0 : sal_Int32 nPerspective = getLimitedValue< sal_Int32, sal_Int32 >( mrModel.mnPerspective / 2, 0, 100 );
255 : : // projection mode (parallel axes, if right-angled, #i90360# or if perspective is at 0%)
256 [ # # ][ # # ]: 0 : bool bParallel = bRightAngled || (nPerspective == 0);
257 [ # # ]: 0 : cssd::ProjectionMode eProjMode = bParallel ? cssd::ProjectionMode_PARALLEL : cssd::ProjectionMode_PERSPECTIVE;
258 : :
259 : : // set rotation properties
260 [ # # ]: 0 : aPropSet.setProperty( PROP_RotationVertical, nRotationY );
261 [ # # ]: 0 : aPropSet.setProperty( PROP_RotationHorizontal, nRotationX );
262 [ # # ]: 0 : aPropSet.setProperty( PROP_Perspective, nPerspective );
263 [ # # ]: 0 : aPropSet.setProperty( PROP_RightAngledAxes, bRightAngled );
264 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DScenePerspective, eProjMode );
265 : :
266 : : // set light settings
267 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneShadeMode, cssd::ShadeMode_FLAT );
268 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneAmbientColor, nAmbientColor );
269 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneLightOn1, false );
270 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneLightOn2, true );
271 [ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneLightColor2, nLightColor );
272 [ # # ][ # # ]: 0 : aPropSet.setProperty( PROP_D3DSceneLightDirection2, cssd::Direction3D( 0.2, 0.4, 1.0 ) );
273 : 0 : }
274 : :
275 : : // ============================================================================
276 : :
277 : 0 : WallFloorConverter::WallFloorConverter( const ConverterRoot& rParent, WallFloorModel& rModel ) :
278 : 0 : ConverterBase< WallFloorModel >( rParent, rModel )
279 : : {
280 : 0 : }
281 : :
282 : 0 : WallFloorConverter::~WallFloorConverter()
283 : : {
284 [ # # ]: 0 : }
285 : :
286 : 0 : void WallFloorConverter::convertFromModel( const Reference< XDiagram >& rxDiagram, ObjectType eObjType )
287 : : {
288 [ # # ]: 0 : if( rxDiagram.is() )
289 : : {
290 [ # # ]: 0 : PropertySet aPropSet;
291 [ # # # ]: 0 : switch( eObjType )
292 : : {
293 [ # # ][ # # ]: 0 : case OBJECTTYPE_FLOOR: aPropSet.set( rxDiagram->getFloor() ); break;
[ # # ]
294 [ # # ][ # # ]: 0 : case OBJECTTYPE_WALL: aPropSet.set( rxDiagram->getWall() ); break;
[ # # ]
295 : : default: OSL_FAIL( "WallFloorConverter::convertFromModel - invalid object type" );
296 : : }
297 [ # # ]: 0 : if( aPropSet.is() )
298 [ # # ][ # # ]: 0 : getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, mrModel.mxPicOptions.getOrCreate(), eObjType );
[ # # ][ # # ]
299 : : }
300 : 0 : }
301 : :
302 : : // ============================================================================
303 : :
304 : 0 : PlotAreaConverter::PlotAreaConverter( const ConverterRoot& rParent, PlotAreaModel& rModel ) :
305 : : ConverterBase< PlotAreaModel >( rParent, rModel ),
306 : : mb3dChart( false ),
307 : : mbWall3dChart( false ),
308 : 0 : mbPieChart( false )
309 : : {
310 : 0 : }
311 : :
312 : 0 : PlotAreaConverter::~PlotAreaConverter()
313 : : {
314 [ # # ]: 0 : }
315 : :
316 : 0 : void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel )
317 : : {
318 : : /* Create the diagram object and attach it to the chart document. One
319 : : diagram is used to carry all coordinate systems and data series. */
320 : 0 : Reference< XDiagram > xDiagram;
321 : : try
322 : : {
323 [ # # ][ # # ]: 0 : xDiagram.set( createInstance( CREATE_OUSTRING( "com.sun.star.chart2.Diagram" ) ), UNO_QUERY_THROW );
[ # # ]
324 [ # # ][ # # ]: 0 : getChartDocument()->setFirstDiagram( xDiagram );
[ # # ][ # # ]
325 : : }
326 [ # # ]: 0 : catch( Exception& )
327 : : {
328 : : }
329 : :
330 : : // store all axis models in a map, keyed by axis identifier
331 : : typedef ModelMap< sal_Int32, AxisModel > AxisMap;
332 [ # # ]: 0 : AxisMap aAxisMap;
333 [ # # ][ # # ]: 0 : for( PlotAreaModel::AxisVector::iterator aAIt = mrModel.maAxes.begin(), aAEnd = mrModel.maAxes.end(); aAIt != aAEnd; ++aAIt )
334 : : {
335 [ # # ]: 0 : PlotAreaModel::AxisVector::value_type xAxis = *aAIt;
336 : : OSL_ENSURE( xAxis->mnAxisId >= 0, "PlotAreaConverter::convertFromModel - invalid axis identifier" );
337 : : OSL_ENSURE( !aAxisMap.has( xAxis->mnAxisId ), "PlotAreaConverter::convertFromModel - axis identifiers not unique" );
338 [ # # ]: 0 : if( xAxis->mnAxisId >= 0 )
339 [ # # ][ # # ]: 0 : aAxisMap[ xAxis->mnAxisId ] = xAxis;
340 [ # # ]: 0 : }
341 : :
342 : : // group the type group models into different axes sets
343 : : typedef ModelVector< AxesSetModel > AxesSetVector;
344 [ # # ]: 0 : AxesSetVector aAxesSets;
345 : 0 : sal_Int32 nMaxSeriesIdx = -1;
346 [ # # ][ # # ]: 0 : for( PlotAreaModel::TypeGroupVector::iterator aTIt = mrModel.maTypeGroups.begin(), aTEnd = mrModel.maTypeGroups.end(); aTIt != aTEnd; ++aTIt )
347 : : {
348 [ # # ]: 0 : PlotAreaModel::TypeGroupVector::value_type xTypeGroup = *aTIt;
349 [ # # ]: 0 : if( !xTypeGroup->maSeries.empty() )
350 : : {
351 : : // try to find a compatible axes set for the type group
352 : 0 : AxesSetModel* pAxesSet = 0;
353 [ # # ][ # # ]: 0 : for( AxesSetVector::iterator aASIt = aAxesSets.begin(), aASEnd = aAxesSets.end(); !pAxesSet && (aASIt != aASEnd); ++aASIt )
[ # # ][ # # ]
354 [ # # ][ # # ]: 0 : if( (*aASIt)->maTypeGroups.front()->maAxisIds == xTypeGroup->maAxisIds )
355 : 0 : pAxesSet = aASIt->get();
356 : :
357 : : // not possible to insert into an existing axes set -> start a new axes set
358 [ # # ]: 0 : if( !pAxesSet )
359 : : {
360 [ # # ]: 0 : pAxesSet = &aAxesSets.create();
361 : : // find axis models used by the type group
362 : 0 : const TypeGroupModel::AxisIdVector& rAxisIds = xTypeGroup->maAxisIds;
363 [ # # ]: 0 : if( rAxisIds.size() >= 1 )
364 [ # # ][ # # ]: 0 : pAxesSet->maAxes[ API_X_AXIS ] = aAxisMap.get( rAxisIds[ 0 ] );
[ # # ][ # # ]
[ # # ]
365 [ # # ]: 0 : if( rAxisIds.size() >= 2 )
366 [ # # ][ # # ]: 0 : pAxesSet->maAxes[ API_Y_AXIS ] = aAxisMap.get( rAxisIds[ 1 ] );
[ # # ][ # # ]
[ # # ]
367 [ # # ]: 0 : if( rAxisIds.size() >= 3 )
368 [ # # ][ # # ]: 0 : pAxesSet->maAxes[ API_Z_AXIS ] = aAxisMap.get( rAxisIds[ 2 ] );
[ # # ][ # # ]
[ # # ]
369 : : }
370 : :
371 : : // insert the type group model
372 [ # # ]: 0 : pAxesSet->maTypeGroups.push_back( xTypeGroup );
373 : :
374 : : // collect the maximum series index for automatic series formatting
375 [ # # ][ # # ]: 0 : for( TypeGroupModel::SeriesVector::iterator aSIt = xTypeGroup->maSeries.begin(), aSEnd = xTypeGroup->maSeries.end(); aSIt != aSEnd; ++aSIt )
376 [ # # ]: 0 : nMaxSeriesIdx = ::std::max( nMaxSeriesIdx, (*aSIt)->mnIndex );
377 : : }
378 [ # # ]: 0 : }
379 [ # # ][ # # ]: 0 : getFormatter().setMaxSeriesIndex( nMaxSeriesIdx );
380 : :
381 : : // varying point colors only for single series in single chart type
382 : 0 : bool bSupportsVaryColorsByPoint = mrModel.maTypeGroups.size() == 1;
383 : :
384 : : // convert all axes sets
385 [ # # ][ # # ]: 0 : for( AxesSetVector::iterator aASBeg = aAxesSets.begin(), aASIt = aASBeg, aASEnd = aAxesSets.end(); aASIt != aASEnd; ++aASIt )
386 : : {
387 [ # # ]: 0 : AxesSetConverter aAxesSetConv( *this, **aASIt );
388 [ # # ]: 0 : sal_Int32 nAxesSetIdx = static_cast< sal_Int32 >( aASIt - aASBeg );
389 [ # # ]: 0 : aAxesSetConv.convertFromModel( xDiagram, rView3DModel, nAxesSetIdx, bSupportsVaryColorsByPoint );
390 [ # # ]: 0 : if( nAxesSetIdx == 0 )
391 : : {
392 : 0 : maAutoTitle = aAxesSetConv.getAutomaticTitle();
393 : 0 : mb3dChart = aAxesSetConv.is3dChart();
394 : 0 : mbWall3dChart = aAxesSetConv.isWall3dChart();
395 : 0 : mbPieChart = aAxesSetConv.isPieChart();
396 : : }
397 : : else
398 : : {
399 : 0 : maAutoTitle = OUString();
400 : : }
401 [ # # ]: 0 : }
402 : :
403 : : // plot area formatting
404 [ # # ][ # # ]: 0 : if( xDiagram.is() && !mb3dChart )
[ # # ]
405 : : {
406 [ # # ][ # # ]: 0 : PropertySet aPropSet( xDiagram->getWall() );
[ # # ]
407 [ # # ][ # # ]: 0 : getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, OBJECTTYPE_PLOTAREA2D );
[ # # ]
408 : 0 : }
409 : 0 : }
410 : :
411 : 0 : void PlotAreaConverter::convertPositionFromModel()
412 : : {
413 [ # # ]: 0 : LayoutModel& rLayout = mrModel.mxLayout.getOrCreate();
414 [ # # ]: 0 : LayoutConverter aLayoutConv( *this, rLayout );
415 : 0 : Rectangle aDiagramRect;
416 [ # # ][ # # ]: 0 : if( aLayoutConv.calcAbsRectangle( aDiagramRect ) ) try
417 : : {
418 : : namespace cssc = ::com::sun::star::chart;
419 [ # # ][ # # ]: 0 : Reference< cssc::XChartDocument > xChart1Doc( getChartDocument(), UNO_QUERY_THROW );
420 [ # # ][ # # ]: 0 : Reference< cssc::XDiagramPositioning > xPositioning( xChart1Doc->getDiagram(), UNO_QUERY_THROW );
[ # # ]
421 : : // for pie charts, always set inner plot area size to exclude the data labels as Excel does
422 [ # # ][ # # ]: 0 : sal_Int32 nTarget = (mbPieChart && (rLayout.mnTarget == XML_outer)) ? XML_inner : rLayout.mnTarget;
423 [ # # # ]: 0 : switch( nTarget )
424 : : {
425 : : case XML_inner:
426 [ # # ][ # # ]: 0 : xPositioning->setDiagramPositionExcludingAxes( aDiagramRect );
427 : 0 : break;
428 : : case XML_outer:
429 [ # # ][ # # ]: 0 : xPositioning->setDiagramPositionIncludingAxes( aDiagramRect );
430 : 0 : break;
431 : : default:
432 : : OSL_FAIL( "PlotAreaConverter::convertPositionFromModel - unknown positioning target" );
433 [ # # ]: 0 : }
434 : : }
435 [ # # ]: 0 : catch( Exception& )
436 : : {
437 [ # # ]: 0 : }
438 : 0 : }
439 : :
440 : : // ============================================================================
441 : :
442 : : } // namespace chart
443 : : } // namespace drawingml
444 [ + - ][ + - ]: 285 : } // namespace oox
445 : :
446 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|