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/token/tokens.hxx>
21 : : #include "oox/core/xmlfilterbase.hxx"
22 : : #include "oox/export/chartexport.hxx"
23 : : #include "oox/export/utils.hxx"
24 : : #include "oox/drawingml/chart/typegroupconverter.hxx"
25 : :
26 : : #include <cstdio>
27 : :
28 : : #include <com/sun/star/chart/XChartDocument.hpp>
29 : : #include <com/sun/star/chart/ChartLegendPosition.hpp>
30 : : #include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
31 : : #include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
32 : : #include <com/sun/star/chart/XAxisZSupplier.hpp>
33 : : #include <com/sun/star/chart/XChartDataArray.hpp>
34 : : #include <com/sun/star/chart/ChartDataRowSource.hpp>
35 : : #include <com/sun/star/chart/ChartAxisAssign.hpp>
36 : : #include <com/sun/star/chart/ChartSeriesAddress.hpp>
37 : : #include <com/sun/star/chart/X3DDisplay.hpp>
38 : : #include <com/sun/star/chart/XStatisticDisplay.hpp>
39 : : #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
40 : : #include <com/sun/star/chart/ChartSymbolType.hpp>
41 : : #include <com/sun/star/chart/ChartAxisMarks.hpp>
42 : : #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
43 : : #include <com/sun/star/chart/ChartAxisPosition.hpp>
44 : : #include <com/sun/star/chart/ChartSolidType.hpp>
45 : :
46 : : #include <com/sun/star/chart2/XChartDocument.hpp>
47 : : #include <com/sun/star/chart2/XDiagram.hpp>
48 : : #include <com/sun/star/chart2/RelativePosition.hpp>
49 : : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
50 : : #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
51 : : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
52 : : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
53 : : #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
54 : : #include <com/sun/star/chart2/data/XDataSource.hpp>
55 : : #include <com/sun/star/chart2/data/XDataSink.hpp>
56 : : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
57 : : #include <com/sun/star/chart2/data/XDataProvider.hpp>
58 : : #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
59 : : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
60 : : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
61 : : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
62 : :
63 : : #include <com/sun/star/beans/XPropertySet.hpp>
64 : : #include <com/sun/star/beans/XPropertyState.hpp>
65 : : #include <com/sun/star/container/XEnumerationAccess.hpp>
66 : : #include <com/sun/star/drawing/XShape.hpp>
67 : : #include <com/sun/star/drawing/FillStyle.hpp>
68 : : #include <com/sun/star/drawing/BitmapMode.hpp>
69 : :
70 : : #include <com/sun/star/table/CellAddress.hpp>
71 : : #include <com/sun/star/sheet/XFormulaParser.hpp>
72 : : #include <com/sun/star/sheet/XFormulaTokens.hpp>
73 : : #include <com/sun/star/sheet/FormulaToken.hpp>
74 : : #include <com/sun/star/sheet/AddressConvention.hpp>
75 : :
76 : : #include <com/sun/star/text/WritingMode.hpp>
77 : : #include <com/sun/star/container/XNamed.hpp>
78 : :
79 : : #include <comphelper/processfactory.hxx>
80 : : #include "SchXMLSeriesHelper.hxx"
81 : : #include "ColorPropertySet.hxx"
82 : : #include <set>
83 : : #include <time.h>
84 : :
85 : : using namespace ::com::sun::star;
86 : : using namespace ::com::sun::star::uno;
87 : : using namespace ::com::sun::star::drawing;
88 : : using namespace ::oox::core;
89 : : using ::com::sun::star::beans::PropertyState;
90 : : using ::com::sun::star::beans::PropertyValue;
91 : : using ::com::sun::star::beans::XPropertySet;
92 : : using ::com::sun::star::beans::XPropertyState;
93 : : using ::com::sun::star::container::XEnumeration;
94 : : using ::com::sun::star::container::XEnumerationAccess;
95 : : using ::com::sun::star::container::XIndexAccess;
96 : : using ::com::sun::star::container::XNamed;
97 : : using ::com::sun::star::io::XOutputStream;
98 : : using ::com::sun::star::table::CellAddress;
99 : : using ::com::sun::star::sheet::XFormulaParser;
100 : : using ::com::sun::star::sheet::XFormulaTokens;
101 : : using ::oox::core::XmlFilterBase;
102 : : using ::rtl::OString;
103 : : using ::rtl::OStringBuffer;
104 : : using ::rtl::OUString;
105 : : using ::rtl::OUStringBuffer;
106 : : using ::sax_fastparser::FSHelperPtr;
107 : :
108 : : DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
109 : :
110 : : #define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr()
111 : :
112 : : namespace oox { namespace drawingml {
113 : :
114 : : #define GETA(propName) \
115 : : GetProperty( rXPropSet, String( #propName ) )
116 : :
117 : : #define GETAD(propName) \
118 : : ( GetPropertyAndState( rXPropSet, rXPropState, String( #propName ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )
119 : :
120 : : #define GET(variable, propName) \
121 : : if ( GETA(propName) ) \
122 : : mAny >>= variable;
123 : :
124 : 0 : Reference< uno::XComponentContext > lcl_getComponentContext()
125 : : {
126 : 0 : Reference< uno::XComponentContext > xContext;
127 : : try
128 : : {
129 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
130 [ # # ]: 0 : if( xFactProp.is())
131 [ # # ][ # # ]: 0 : xFactProp->getPropertyValue(OUString("DefaultContext")) >>= xContext;
[ # # ][ # # ]
132 : : }
133 [ # # ]: 0 : catch( uno::Exception& )
134 : : {}
135 : :
136 : 0 : return xContext;
137 : : }
138 : :
139 : 0 : class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
140 : : {
141 : : public:
142 : 0 : explicit lcl_MatchesRole( const OUString & aRole ) :
143 : 0 : m_aRole( aRole )
144 : 0 : {}
145 : :
146 : 0 : bool operator () ( const Reference< chart2::data::XLabeledDataSequence > & xSeq ) const
147 : : {
148 [ # # ]: 0 : if( !xSeq.is() )
149 : 0 : return false;
150 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xProp( xSeq->getValues(), uno::UNO_QUERY );
[ # # ]
151 : 0 : OUString aRole;
152 : :
153 : 0 : return ( xProp.is() &&
154 [ # # ]: 0 : (xProp->getPropertyValue(
155 [ # # ][ # # ]: 0 : OUString( "Role" ) ) >>= aRole ) &&
[ # # ][ # # ]
[ # # # #
# # ]
156 [ # # ]: 0 : m_aRole.equals( aRole ));
[ # # # # ]
157 : : }
158 : :
159 : : private:
160 : : OUString m_aRole;
161 : : };
162 : :
163 : : template< typename T >
164 : 0 : void lcl_SequenceToVectorAppend( const Sequence< T > & rSource, ::std::vector< T > & rDestination )
165 : : {
166 : 0 : rDestination.reserve( rDestination.size() + rSource.getLength());
167 : 0 : ::std::copy( rSource.getConstArray(), rSource.getConstArray() + rSource.getLength(),
168 : : ::std::back_inserter( rDestination ));
169 : 0 : }
170 : :
171 : 0 : Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram )
172 : : {
173 : 0 : Reference< chart2::data::XLabeledDataSequence > xResult;
174 : : try
175 : : {
176 : : Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
177 [ # # ]: 0 : xDiagram, uno::UNO_QUERY_THROW );
178 : : Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
179 [ # # ][ # # ]: 0 : xCooSysCnt->getCoordinateSystems());
180 [ # # ]: 0 : for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
181 : : {
182 [ # # ]: 0 : Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
183 : : OSL_ASSERT( xCooSys.is());
184 [ # # ][ # # ]: 0 : for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
[ # # ]
185 : : {
186 [ # # ][ # # ]: 0 : const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
187 [ # # ]: 0 : for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI)
188 : : {
189 [ # # ][ # # ]: 0 : Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN, nI );
190 : : OSL_ASSERT( xAxis.is());
191 [ # # ]: 0 : if( xAxis.is())
192 : : {
193 [ # # ][ # # ]: 0 : chart2::ScaleData aScaleData = xAxis->getScaleData();
194 [ # # ]: 0 : if( aScaleData.Categories.is())
195 : : {
196 [ # # ]: 0 : xResult.set( aScaleData.Categories );
197 : : break;
198 [ # # ][ # # ]: 0 : }
199 : : }
200 [ # # ]: 0 : }
201 : : }
202 [ # # ][ # # ]: 0 : }
203 : : }
204 [ # # ]: 0 : catch( const uno::Exception & ex )
205 : : {
206 : : (void)ex; // avoid warning for pro build
207 : : OSL_FAIL( rtl::OUStringToOString(
208 : : OUString( "Exception caught. Type: " ) +
209 : : OUString::createFromAscii( typeid( ex ).name()) +
210 : : OUString( ", Message: " ) +
211 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
212 : : }
213 : :
214 : 0 : return xResult;
215 : : }
216 : :
217 : 0 : Reference< chart2::data::XDataSource > lcl_createDataSource(
218 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
219 : : {
220 : 0 : Reference< chart2::data::XDataSink > xSink;
221 [ # # ]: 0 : Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
222 [ # # ]: 0 : if( xContext.is() )
223 : : xSink.set(
224 [ # # ][ # # ]: 0 : xContext->getServiceManager()->createInstanceWithContext(
[ # # ]
225 : : OUString("com.sun.star.chart2.data.DataSource"),
226 [ # # ][ # # ]: 0 : xContext ), uno::UNO_QUERY_THROW );
227 [ # # ]: 0 : if( xSink.is())
228 [ # # ][ # # ]: 0 : xSink->setData( aData );
229 : :
230 [ # # ]: 0 : return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY );
231 : : }
232 : :
233 : 0 : Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequences( const Reference< chart2::XChartDocument >& xChartDoc )
234 : : {
235 [ # # ]: 0 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aContainer;
236 [ # # ]: 0 : if( xChartDoc.is() )
237 : : {
238 [ # # ][ # # ]: 0 : Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
239 [ # # ]: 0 : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
240 [ # # ][ # # ]: 0 : for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
[ # # ]
241 : 0 : ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
242 : : {
243 [ # # ]: 0 : Reference< chart2::data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
244 [ # # ]: 0 : if( !xDataSource.is() )
245 : 0 : continue;
246 [ # # ][ # # ]: 0 : uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
247 [ # # ]: 0 : lcl_SequenceToVectorAppend( aDataSequences, aContainer );
248 [ # # ][ # # ]: 0 : }
249 : : }
250 : :
251 [ # # ]: 0 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aRet( aContainer.size());
252 [ # # ][ # # ]: 0 : ::std::copy( aContainer.begin(), aContainer.end(), aRet.getArray());
253 : :
254 : 0 : return aRet;
255 : : }
256 : :
257 : : Reference< chart2::data::XLabeledDataSequence >
258 : 0 : lcl_getDataSequenceByRole(
259 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aLabeledSeq,
260 : : const OUString & rRole )
261 : : {
262 : 0 : Reference< chart2::data::XLabeledDataSequence > aNoResult;
263 : :
264 : 0 : const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray();
265 : 0 : const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength();
266 : : const Reference< chart2::data::XLabeledDataSequence > * pMatch =
267 [ # # ]: 0 : ::std::find_if( pBegin, pEnd, lcl_MatchesRole( rRole ));
268 : :
269 [ # # ]: 0 : if( pMatch != pEnd )
270 : 0 : return *pMatch;
271 : :
272 : 0 : return aNoResult;
273 : : }
274 : :
275 : 0 : Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( const Reference< chart2::XChartDocument >& xChartDoc, sal_Bool& rOutSourceHasCategoryLabels )
276 : : {
277 [ # # ]: 0 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeqVector;
278 : :
279 : : //categories are always the first sequence
280 [ # # ][ # # ]: 0 : Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
281 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xDiagram ) );
282 [ # # ]: 0 : if( xCategories.is() )
283 [ # # ]: 0 : aLabeledSeqVector.push_back( xCategories );
284 : 0 : rOutSourceHasCategoryLabels = sal_Bool(xCategories.is());
285 : :
286 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector(
287 [ # # ]: 0 : lcl_getAllSeriesSequences( xChartDoc ) );
288 : :
289 : : //the first x-values is always the next sequence //todo ... other x-values get lost for old format
290 : : Reference< chart2::data::XLabeledDataSequence > xXValues(
291 [ # # ]: 0 : lcl_getDataSequenceByRole( aSeriesSeqVector, OUString("values-x") ) );
292 [ # # ]: 0 : if( xXValues.is() )
293 [ # # ]: 0 : aLabeledSeqVector.push_back( xXValues );
294 : :
295 : : //add all other sequences now without x-values
296 : 0 : lcl_MatchesRole aHasXValues( OUString("values-x") );
297 [ # # ]: 0 : for( sal_Int32 nN=0; nN<aSeriesSeqVector.getLength(); nN++ )
298 : : {
299 [ # # ][ # # ]: 0 : if( !aHasXValues( aSeriesSeqVector[nN] ) )
[ # # ]
300 [ # # ][ # # ]: 0 : aLabeledSeqVector.push_back( aSeriesSeqVector[nN] );
301 : : }
302 : :
303 [ # # ]: 0 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( aLabeledSeqVector.size() );
304 [ # # ][ # # ]: 0 : ::std::copy( aLabeledSeqVector.begin(), aLabeledSeqVector.end(), aSeq.getArray() );
305 : :
306 [ # # ][ # # ]: 0 : return lcl_createDataSource( aSeq );
[ # # ]
307 : : }
308 : :
309 : 0 : bool lcl_isSeriesAttachedToFirstAxis(
310 : : const Reference< chart2::XDataSeries > & xDataSeries )
311 : : {
312 : 0 : bool bResult=true;
313 : :
314 : : try
315 : : {
316 : 0 : sal_Int32 nAxisIndex = 0;
317 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW );
318 [ # # ]: 0 : if( xProp.is() )
319 [ # # ][ # # ]: 0 : xProp->getPropertyValue( OUString( "AttachedAxisIndex" ) ) >>= nAxisIndex;
320 [ # # ]: 0 : bResult = (0==nAxisIndex);
321 : : }
322 : 0 : catch( const uno::Exception & ex )
323 : : {
324 : : (void)ex; // avoid warning for pro build
325 : : OSL_FAIL( rtl::OUStringToOString(
326 : : OUString( "Exception caught. Type: " ) +
327 : : OUString::createFromAscii( typeid( ex ).name()) +
328 : : OUString( ", Message: " ) +
329 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
330 : : }
331 : :
332 : 0 : return bResult;
333 : : }
334 : :
335 : 0 : OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence )
336 : : {
337 : 0 : OUStringBuffer aResult;
338 : 0 : bool bPrecedeWithSpace = false;
339 [ # # ]: 0 : for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex )
340 : : {
341 [ # # ]: 0 : if( !rSequence[nIndex].isEmpty())
342 : : {
343 [ # # ]: 0 : if( bPrecedeWithSpace )
344 [ # # ]: 0 : aResult.append( static_cast< sal_Unicode >( ' ' ));
345 [ # # ]: 0 : aResult.append( rSequence[nIndex] );
346 : 0 : bPrecedeWithSpace = true;
347 : : }
348 : : }
349 [ # # ]: 0 : return aResult.makeStringAndClear();
350 : : }
351 : :
352 : 0 : OUString lcl_getLabelString( const Reference< chart2::data::XDataSequence > & xLabelSeq )
353 : : {
354 [ # # ]: 0 : Sequence< OUString > aLabels;
355 : :
356 [ # # ]: 0 : uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY );
357 [ # # ]: 0 : if( xTextualDataSequence.is())
358 : : {
359 [ # # ][ # # ]: 0 : aLabels = xTextualDataSequence->getTextualData();
[ # # ][ # # ]
360 : : }
361 [ # # ]: 0 : else if( xLabelSeq.is())
362 : : {
363 [ # # ][ # # ]: 0 : Sequence< uno::Any > aAnies( xLabelSeq->getData());
364 [ # # ]: 0 : aLabels.realloc( aAnies.getLength());
365 [ # # ]: 0 : for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
366 [ # # ][ # # ]: 0 : aAnies[i] >>= aLabels[i];
[ # # ]
367 : : }
368 : :
369 [ # # ][ # # ]: 0 : return lcl_flattenStringSequence( aLabels );
370 : : }
371 : :
372 : 0 : void lcl_fillCategoriesIntoStringVector(
373 : : const Reference< chart2::data::XDataSequence > & xCategories,
374 : : ::std::vector< OUString > & rOutCategories )
375 : : {
376 : : OSL_ASSERT( xCategories.is());
377 [ # # ]: 0 : if( !xCategories.is())
378 : 0 : return;
379 [ # # ]: 0 : Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xCategories, uno::UNO_QUERY );
380 [ # # ]: 0 : if( xTextualDataSequence.is())
381 : : {
382 : 0 : rOutCategories.clear();
383 [ # # ][ # # ]: 0 : Sequence< OUString > aTextData( xTextualDataSequence->getTextualData());
384 : 0 : ::std::copy( aTextData.getConstArray(), aTextData.getConstArray() + aTextData.getLength(),
385 [ # # # # ]: 0 : ::std::back_inserter( rOutCategories ));
[ # # ]
386 : : }
387 : : else
388 : : {
389 [ # # ][ # # ]: 0 : Sequence< uno::Any > aAnies( xCategories->getData());
390 [ # # ]: 0 : rOutCategories.resize( aAnies.getLength());
391 [ # # ]: 0 : for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
392 [ # # ][ # # ]: 0 : aAnies[i] >>= rOutCategories[i];
393 : 0 : }
394 : : }
395 : :
396 : 0 : ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< chart2::data::XDataSequence > & xSeq )
397 : : {
398 : 0 : double fNan = 0.0;
399 : 0 : ::rtl::math::setNan( &fNan );
400 [ # # ]: 0 : ::std::vector< double > aResult;
401 : :
402 [ # # ]: 0 : Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
403 [ # # ]: 0 : if( xNumSeq.is())
404 : : {
405 [ # # ][ # # ]: 0 : Sequence< double > aValues( xNumSeq->getNumericalData());
406 : 0 : ::std::copy( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(),
407 [ # # # # ]: 0 : ::std::back_inserter( aResult ));
[ # # ]
408 : : }
409 [ # # ]: 0 : else if( xSeq.is())
410 : : {
411 [ # # ][ # # ]: 0 : Sequence< uno::Any > aAnies( xSeq->getData());
412 [ # # ]: 0 : aResult.resize( aAnies.getLength(), fNan );
413 [ # # ]: 0 : for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
414 [ # # ][ # # ]: 0 : aAnies[i] >>= aResult[i];
[ # # ]
415 : : }
416 : 0 : return aResult;
417 : : }
418 : :
419 : 0 : sal_Int32 lcl_getChartType( const OUString& sChartType )
420 : : {
421 : 0 : chart::TypeId eChartTypeId = chart::TYPEID_UNKNOWN;
422 [ # # # # ]: 0 : if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.BarDiagram" )))
[ # # ]
423 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ColumnChartType") ) ) )
424 : 0 : eChartTypeId = chart::TYPEID_BAR;
425 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.AreaDiagram" )))
[ # # ]
426 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.AreaChartType") ) ) )
427 : 0 : eChartTypeId = chart::TYPEID_AREA;
428 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.LineDiagram" )))
[ # # ]
429 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.LineChartType") ) ) )
430 : 0 : eChartTypeId = chart::TYPEID_LINE;
431 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.PieDiagram" )))
[ # # ]
432 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType") ) ) )
433 : 0 : eChartTypeId = chart::TYPEID_PIE;
434 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.DonutDiagram" )))
[ # # ]
435 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.DonutChartType") ) ) )
436 : 0 : eChartTypeId = chart::TYPEID_DOUGHNUT;
437 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.XYDiagram" )))
[ # # ]
438 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType") ) ) )
439 : 0 : eChartTypeId = chart::TYPEID_SCATTER;
440 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.NetDiagram" )))
[ # # ]
441 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.NetChartType") ) ) )
442 : 0 : eChartTypeId = chart::TYPEID_RADARLINE;
443 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.FilledNetDiagram" )))
[ # # ]
444 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.FilledNetChartType") ) ) )
445 : 0 : eChartTypeId = chart::TYPEID_RADARAREA;
446 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" )))
[ # # ]
447 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType") ) ) )
448 : 0 : eChartTypeId = chart::TYPEID_STOCK;
449 [ # # # # ]: 0 : else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.BubbleDiagram" )))
[ # # ]
450 : 0 : || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) ) )
451 : 0 : eChartTypeId = chart::TYPEID_BUBBLE;
452 : :
453 : 0 : return eChartTypeId;
454 : : }
455 : :
456 : 0 : sal_Int32 lcl_generateRandomValue()
457 : : {
458 : : static sal_Int32 MAX_NUMBER = 100000000;
459 : : //srand( unsigned( time( NULL ) ));
460 : 0 : return sal_Int32( rand() % MAX_NUMBER );
461 : : }
462 : :
463 : 0 : ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< frame::XModel >& xModel, XmlFilterBase* pFB, DocumentType eDocumentType )
464 : : : DrawingML( pFS, pFB, eDocumentType )
465 : : , mnXmlNamespace( nXmlNamespace )
466 : : , maFraction( 1, 576 )
467 : : , mxChartModel( xModel )
468 : : , mbHasSeriesLabels( sal_False )
469 : : , mbHasCategoryLabels( sal_False )
470 : : , mbRowSourceColumns( sal_True )
471 : : , mbHasXAxis( sal_False )
472 : : , mbHasYAxis( sal_False )
473 : : , mbHasZAxis( sal_False )
474 : : , mbHasSecondaryXAxis( sal_False )
475 : : , mbHasSecondaryYAxis( sal_False )
476 [ # # ][ # # ]: 0 : , mbIs3DChart( sal_False )
[ # # ][ # # ]
477 : : {
478 : 0 : }
479 : :
480 : 0 : sal_Int32 ChartExport::GetChartID( )
481 : : {
482 : 0 : sal_Int32 nID = GetFB()->GetUniqueId();
483 : 0 : return nID;
484 : : }
485 : :
486 : 0 : sal_Int32 ChartExport::getChartType( )
487 : : {
488 [ # # ][ # # ]: 0 : OUString sChartType = mxDiagram->getDiagramType();
489 [ # # ]: 0 : return lcl_getChartType( sChartType );
490 : : }
491 : :
492 : 0 : OUString ChartExport::parseFormula( const OUString& rRange )
493 : : {
494 : 0 : OUString aResult;
495 : 0 : Reference< XFormulaParser > xParser;
496 [ # # ][ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xSF( GetFB()->getModelFactory(), uno::UNO_QUERY );
497 [ # # ]: 0 : if( xSF.is() )
498 : : {
499 : : try
500 : : {
501 [ # # ][ # # ]: 0 : xParser.set( xSF->createInstance( OUString("com.sun.star.sheet.FormulaParser") ), UNO_QUERY );
[ # # ][ # # ]
502 : : }
503 [ # # ]: 0 : catch( Exception& )
504 : : {
505 : : }
506 : : }
507 [ # # ]: 0 : if( xParser.is() )
508 : : {
509 : : OSL_TRACE("ChartExport::parseFormula, parser is valid");
510 [ # # ]: 0 : Reference< XPropertySet > xParserProps( xParser, uno::UNO_QUERY );
511 [ # # ]: 0 : if( xParserProps.is() )
512 : : {
513 [ # # ][ # # ]: 0 : xParserProps->setPropertyValue( OUString("FormulaConvention"), uno::makeAny(::com::sun::star::sheet::AddressConvention::OOO) );
[ # # ]
514 : : }
515 [ # # ][ # # ]: 0 : uno::Sequence<sheet::FormulaToken> aTokens = xParser->parseFormula( rRange, CellAddress( 0, 0, 0 ) );
516 [ # # ]: 0 : if( xParserProps.is() )
517 : : {
518 [ # # ][ # # ]: 0 : xParserProps->setPropertyValue( OUString("FormulaConvention"), uno::makeAny(::com::sun::star::sheet::AddressConvention::XL_OOX) );
[ # # ]
519 : : }
520 [ # # ][ # # ]: 0 : aResult = xParser->printFormula( aTokens, CellAddress( 0, 0, 0 ) );
[ # # ]
521 : : }
522 : : else
523 : : {
524 : : OSL_TRACE("ChartExport::parseFormula, parser is invalid");
525 : : //FIXME: currently just using simple converter, e.g $Sheet1.$A$1:$C$1 -> Sheet1!$A$1:$C$1
526 [ # # ]: 0 : String aRange( rRange );
527 [ # # ][ # # ]: 0 : if( aRange.SearchAscii("$") == 0 )
528 [ # # ][ # # ]: 0 : aRange = aRange.Copy(1);
[ # # ]
529 [ # # ][ # # ]: 0 : aRange.SearchAndReplaceAllAscii(".$", rtl::OUString("!$") );
[ # # ]
530 [ # # ][ # # ]: 0 : aResult = aRange;
531 : : }
532 : :
533 : : OSL_TRACE("ChartExport::parseFormula, the originla formula is %s, the new formula is %s ", rtl::OUStringToOString( rRange, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( aResult, RTL_TEXTENCODING_UTF8 ).getStr());
534 : 0 : return aResult;
535 : : }
536 : :
537 : 0 : ChartExport& ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nChartCount )
538 : : {
539 : : OSL_TRACE("ChartExport::WriteChartObj -- writer chart object");
540 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
541 : :
542 [ # # ]: 0 : pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
543 : :
544 [ # # ]: 0 : pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
545 : :
546 : : // TODO: get the correct chart name chart id
547 [ # # ][ # # ]: 0 : OUString sName = S("Object 1");
[ # # ]
548 [ # # ]: 0 : Reference< XNamed > xNamed( xShape, UNO_QUERY );
549 [ # # ]: 0 : if (xNamed.is())
550 [ # # ][ # # ]: 0 : sName = xNamed->getName();
551 : :
552 [ # # ]: 0 : sal_Int32 nID = GetChartID();
553 : :
554 : : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
555 : : XML_id, I32S( nID ),
556 : : XML_name, USS( sName ),
557 [ # # ][ # # ]: 0 : FSEND );
558 : :
559 : : pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
560 [ # # ]: 0 : FSEND );
561 : :
562 [ # # ]: 0 : if( GetDocumentType() == DOCUMENT_PPTX )
563 : : pFS->singleElementNS( mnXmlNamespace, XML_nvPr,
564 [ # # ]: 0 : FSEND );
565 [ # # ]: 0 : pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
566 : :
567 : : // visual chart properties
568 [ # # ]: 0 : WriteShapeTransformation( xShape, mnXmlNamespace );
569 : :
570 : : // writer chart object
571 [ # # ]: 0 : pFS->startElement( FSNS( XML_a, XML_graphic ), FSEND );
572 : : pFS->startElement( FSNS( XML_a, XML_graphicData ),
573 : : XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart",
574 [ # # ]: 0 : FSEND );
575 : 0 : OUString sId;
576 : 0 : const char* sFullPath = NULL;
577 : 0 : const char* sRelativePath = NULL;
578 [ # # # # ]: 0 : switch( GetDocumentType() )
579 : : {
580 : : case DOCUMENT_DOCX:
581 : : {
582 : 0 : sFullPath = "word/charts/chart";
583 : 0 : sRelativePath = "charts/chart";
584 : 0 : break;
585 : : }
586 : : case DOCUMENT_PPTX:
587 : : {
588 : 0 : sFullPath = "ppt/charts/chart";
589 : 0 : sRelativePath = "../charts/chart";
590 : 0 : break;
591 : : }
592 : : case DOCUMENT_XLSX:
593 : : {
594 : 0 : sFullPath = "xl/charts/chart";
595 : 0 : sRelativePath = "../charts/chart";
596 : 0 : break;
597 : : }
598 : : default:
599 : : {
600 : 0 : sFullPath = "charts/chart";
601 : 0 : sRelativePath = "charts/chart";
602 : 0 : break;
603 : : }
604 : : }
605 : : OUString sFullStream = OUStringBuffer()
606 [ # # ]: 0 : .appendAscii(sFullPath)
607 [ # # ]: 0 : .append(nChartCount)
608 [ # # ]: 0 : .appendAscii( ".xml" )
609 [ # # ]: 0 : .makeStringAndClear();
610 : : OUString sRelativeStream = OUStringBuffer()
611 [ # # ]: 0 : .appendAscii(sRelativePath)
612 [ # # ]: 0 : .append(nChartCount)
613 [ # # ]: 0 : .appendAscii( ".xml" )
614 [ # # ]: 0 : .makeStringAndClear();
615 : : FSHelperPtr pChart = CreateOutputStream(
616 : : sFullStream,
617 : : sRelativeStream,
618 : : pFS->getOutputStream(),
619 : : "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
620 : : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
621 [ # # ][ # # ]: 0 : &sId );
622 : :
623 : : pFS->singleElement( FSNS( XML_c, XML_chart ),
624 : : FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart",
625 : : FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
626 : : FSNS( XML_r, XML_id ), USS( sId ),
627 [ # # ][ # # ]: 0 : FSEND );
628 : :
629 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_graphicData ) );
630 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_graphic ) );
631 [ # # ]: 0 : pFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
632 : :
633 [ # # ][ # # ]: 0 : SetFS( pChart );
[ # # ]
634 [ # # ]: 0 : ExportContent();
635 : :
636 [ # # ][ # # ]: 0 : return *this;
637 : : }
638 : :
639 : 0 : void ChartExport::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
640 : : {
641 [ # # ]: 0 : if( xChartDoc.is())
642 : : try
643 : : {
644 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
645 : : OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
646 [ # # ]: 0 : if( xDataProvider.is())
647 : : {
648 [ # # ]: 0 : Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc, mbHasCategoryLabels ));
649 [ # # ][ # # ]: 0 : Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
650 : 0 : ::rtl::OUString sCellRange, sBrokenRange;
651 : 0 : bool bBrokenRangeAvailable = false;
652 [ # # ]: 0 : for( sal_Int32 i=0; i<aArgs.getLength(); ++i )
653 : : {
654 [ # # ][ # # ]: 0 : if ( aArgs[i].Name == "CellRangeRepresentation" )
655 [ # # ]: 0 : aArgs[i].Value >>= sCellRange;
656 [ # # ][ # # ]: 0 : else if ( aArgs[i].Name == "BrokenCellRangeForExport" )
657 : : {
658 [ # # ][ # # ]: 0 : if( aArgs[i].Value >>= sBrokenRange )
659 : 0 : bBrokenRangeAvailable = true;
660 : : }
661 [ # # ][ # # ]: 0 : else if ( aArgs[i].Name == "DataRowSource" )
662 : : {
663 : : ::com::sun::star::chart::ChartDataRowSource eRowSource;
664 [ # # ][ # # ]: 0 : aArgs[i].Value >>= eRowSource;
665 : 0 : mbRowSourceColumns = ( eRowSource == ::com::sun::star::chart::ChartDataRowSource_COLUMNS );
666 : : }
667 [ # # ][ # # ]: 0 : else if ( aArgs[i].Name == "FirstCellAsLabel" )
668 [ # # ]: 0 : aArgs[i].Value >>= mbHasSeriesLabels;
669 [ # # ][ # # ]: 0 : else if ( aArgs[i].Name == "SequenceMapping" )
670 [ # # ][ # # ]: 0 : aArgs[i].Value >>= maSequenceMapping;
671 [ # # ][ # # ]: 0 : else if ( aArgs[i].Name == "TableNumberList" )
672 [ # # ]: 0 : aArgs[i].Value >>= msTableNumberList;
673 : : }
674 : :
675 : : // #i79009# For Writer we have to export a broken version of the
676 : : // range, where every row number is noe too large, so that older
677 : : // version can correctly read those files.
678 [ # # ]: 0 : msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange);
679 [ # # ]: 0 : if( !msChartAddress.isEmpty() )
680 : : {
681 : : // convert format to XML-conform one
682 [ # # ]: 0 : Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
683 [ # # ]: 0 : if( xConversion.is())
684 [ # # ][ # # ]: 0 : msChartAddress = xConversion->convertRangeToXML( msChartAddress );
685 [ # # ]: 0 : }
686 [ # # ]: 0 : }
687 : : }
688 : 0 : catch( const uno::Exception & ex )
689 : : {
690 : : (void)ex; // avoid warning for pro build
691 : : OSL_FAIL( rtl::OUStringToOString(
692 : : OUString( "Exception caught. Type: " ) +
693 : : OUString::createFromAscii( typeid( ex ).name()) +
694 : : OUString( ", Message: " ) +
695 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
696 : : }
697 : 0 : }
698 : :
699 : 0 : void ChartExport::ExportContent()
700 : : {
701 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY );
702 : : OSL_ASSERT( xChartDoc.is() );
703 [ # # ]: 0 : if( !xChartDoc.is() )
704 : 0 : return;
705 [ # # ]: 0 : InitRangeSegmentationProperties( xChartDoc );
706 : : // TODO: export chart
707 [ # # ][ # # ]: 0 : _ExportContent( );
708 : : }
709 : :
710 : 0 : void ChartExport::_ExportContent()
711 : : {
712 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::chart::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY );
713 [ # # ]: 0 : if( xChartDoc.is())
714 : : {
715 : : // determine if data comes from the outside
716 : 0 : sal_Bool bIncludeTable = sal_True;
717 : :
718 [ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY );
719 [ # # ]: 0 : if( xNewDoc.is())
720 : : {
721 : : // check if we have own data. If so we must not export the complete
722 : : // range string, as this is our only indicator for having own or
723 : : // external data. @todo: fix this in the file format!
724 [ # # ][ # # ]: 0 : Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
[ # # ]
725 [ # # ][ # # ]: 0 : if( ! (xDPServiceInfo.is() && xDPServiceInfo->getImplementationName() == "com.sun.star.comp.chart.InternalDataProvider" ))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
726 : : {
727 : 0 : bIncludeTable = sal_False;
728 : 0 : }
729 : : }
730 : : else
731 : : {
732 [ # # ]: 0 : Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY );
733 [ # # ]: 0 : if( xServ.is())
734 : : {
735 [ # # # # ]: 0 : if( xServ->supportsService(
736 [ # # ]: 0 : OUString("com.sun.star.chart.ChartTableAddressSupplier")))
737 : : {
738 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY );
739 [ # # ]: 0 : if( xProp.is())
740 : : {
741 : 0 : Any aAny;
742 : : try
743 : : {
744 : 0 : OUString sChartAddress;
745 [ # # ]: 0 : aAny = xProp->getPropertyValue(
746 [ # # ]: 0 : OUString("ChartRangeAddress"));
747 : 0 : aAny >>= msChartAddress;
748 : : //maExportHelper.SetChartRangeAddress( sChartAddress );
749 : :
750 : 0 : OUString sTableNumberList;
751 [ # # ]: 0 : aAny = xProp->getPropertyValue(
752 [ # # ]: 0 : OUString("TableNumberList"));
753 : 0 : aAny >>= msTableNumberList;
754 : : //maExportHelper.SetTableNumberList( sTableNumberList );
755 : :
756 : : // do not include own table if there are external addresses
757 [ # # ]: 0 : bIncludeTable = sChartAddress.isEmpty();
758 : : }
759 [ # # ]: 0 : catch( beans::UnknownPropertyException & )
760 : : {
761 : : OSL_FAIL( "Property ChartRangeAddress not supported by ChartDocument" );
762 : 0 : }
763 : 0 : }
764 : : }
765 : 0 : }
766 : : }
767 [ # # ]: 0 : exportChartSpace( xChartDoc, bIncludeTable );
768 : : }
769 : : else
770 : : {
771 : : OSL_FAIL( "Couldn't export chart due to wrong XModel" );
772 : 0 : }
773 : 0 : }
774 : :
775 : 0 : void ChartExport::exportChartSpace( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc,
776 : : sal_Bool bIncludeTable )
777 : : {
778 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
779 : : pFS->startElement( FSNS( XML_c, XML_chartSpace ),
780 : : FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart",
781 : : FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
782 : : FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
783 [ # # ]: 0 : FSEND );
784 : : // TODO: get the correct editing lanauge
785 : : pFS->singleElement( FSNS( XML_c, XML_lang ),
786 : : XML_val, "en-US",
787 [ # # ]: 0 : FSEND );
788 : :
789 : : if( !bIncludeTable )
790 : : {
791 : : // TODO:external data
792 : : }
793 : : //XML_chart
794 [ # # ]: 0 : exportChart(rChartDoc);
795 : :
796 : : // TODO: printSettings
797 : : // TODO: style
798 : : // TODO: text properties
799 : : // TODO: shape properties
800 [ # # ][ # # ]: 0 : Reference< XPropertySet > xPropSet( rChartDoc->getArea(), uno::UNO_QUERY );
[ # # ]
801 [ # # ]: 0 : if( xPropSet.is() )
802 [ # # ]: 0 : exportShapeProps( xPropSet );
803 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_chartSpace ) );
804 : 0 : }
805 : :
806 : 0 : void ChartExport::exportChart( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc )
807 : : {
808 [ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY );
809 [ # # ][ # # ]: 0 : mxDiagram.set( rChartDoc->getDiagram() );
[ # # ]
810 [ # # ]: 0 : if( xNewDoc.is())
811 [ # # ][ # # ]: 0 : mxNewDiagram.set( xNewDoc->getFirstDiagram());
[ # # ]
812 : :
813 : : // get Properties of ChartDocument
814 : 0 : sal_Bool bHasMainTitle = sal_False;
815 : 0 : sal_Bool bHasSubTitle = sal_False;
816 : 0 : sal_Bool bHasLegend = sal_False;
817 [ # # ]: 0 : Reference< beans::XPropertySet > xDocPropSet( rChartDoc, uno::UNO_QUERY );
818 [ # # ]: 0 : if( xDocPropSet.is())
819 : : {
820 : : try
821 : : {
822 [ # # ]: 0 : Any aAny( xDocPropSet->getPropertyValue(
823 [ # # ]: 0 : OUString( "HasMainTitle" )));
824 : 0 : aAny >>= bHasMainTitle;
825 [ # # ]: 0 : aAny = xDocPropSet->getPropertyValue(
826 [ # # ]: 0 : OUString( "HasSubTitle" ));
827 : 0 : aAny >>= bHasSubTitle;
828 [ # # ]: 0 : aAny = xDocPropSet->getPropertyValue(
829 [ # # ]: 0 : OUString( "HasLegend" ));
830 [ # # ]: 0 : aAny >>= bHasLegend;
831 : : }
832 [ # # ]: 0 : catch( beans::UnknownPropertyException & )
833 : : {
834 : : DBG_WARNING( "Required property not found in ChartDocument" );
835 : : }
836 : : } // if( xDocPropSet.is())
837 : :
838 : : // chart element
839 : : // -------------
840 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
841 : : pFS->startElement( FSNS( XML_c, XML_chart ),
842 [ # # ]: 0 : FSEND );
843 : :
844 : : // title
845 [ # # ]: 0 : if( bHasMainTitle )
846 : : {
847 [ # # ][ # # ]: 0 : Reference< drawing::XShape > xShape = rChartDoc->getTitle();
848 [ # # ]: 0 : if( xShape.is() )
849 [ # # ]: 0 : exportTitle( xShape );
850 : : }
851 [ # # ]: 0 : InitPlotArea( );
852 [ # # ]: 0 : if( mbIs3DChart )
853 : : {
854 [ # # ]: 0 : exportView3D();
855 : :
856 : : // sideWall
857 : :
858 : : // backWall
859 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xBackWall( mxNewDiagram->getWall(), uno::UNO_QUERY );
[ # # ]
860 [ # # ]: 0 : if( xBackWall.is() )
861 : : {
862 : : pFS->startElement( FSNS( XML_c, XML_backWall ),
863 [ # # ]: 0 : FSEND );
864 [ # # ]: 0 : exportShapeProps( xBackWall );
865 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_backWall ) );
866 : : }
867 : :
868 : : // floor
869 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xFloor( mxNewDiagram->getFloor(), uno::UNO_QUERY );
[ # # ]
870 [ # # ]: 0 : if( xFloor.is() )
871 : : {
872 : : pFS->startElement( FSNS( XML_c, XML_floor ),
873 [ # # ]: 0 : FSEND );
874 [ # # ]: 0 : exportShapeProps( xFloor );
875 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_floor ) );
876 : 0 : }
877 : :
878 : : }
879 : : // plot area
880 [ # # ]: 0 : exportPlotArea( );
881 : : // legend
882 [ # # ]: 0 : if( bHasLegend )
883 [ # # ]: 0 : exportLegend( rChartDoc );
884 : : // only visible cells should be plotted on the chart
885 : : pFS->singleElement( FSNS( XML_c, XML_plotVisOnly ),
886 : : XML_val, "1",
887 [ # # ]: 0 : FSEND );
888 : :
889 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_chart ) );
890 : 0 : }
891 : :
892 : 0 : void ChartExport::exportLegend( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc )
893 : : {
894 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
895 : : pFS->startElement( FSNS( XML_c, XML_legend ),
896 [ # # ]: 0 : FSEND );
897 : :
898 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
[ # # ]
899 [ # # ]: 0 : if( xProp.is() )
900 : : {
901 : : // position
902 : 0 : ::com::sun::star::chart::ChartLegendPosition aLegendPos = ::com::sun::star::chart::ChartLegendPosition_NONE;
903 : : try
904 : : {
905 [ # # ]: 0 : Any aAny( xProp->getPropertyValue(
906 [ # # ]: 0 : OUString( "Alignment" )));
907 [ # # ][ # # ]: 0 : aAny >>= aLegendPos;
908 : : }
909 [ # # ]: 0 : catch( beans::UnknownPropertyException & )
910 : : {
911 : : DBG_WARNING( "Property Align not found in ChartLegend" );
912 : : }
913 : :
914 : 0 : const char* strPos = NULL;
915 [ # # # # : 0 : switch( aLegendPos )
# # ]
916 : : {
917 : : case ::com::sun::star::chart::ChartLegendPosition_LEFT:
918 : 0 : strPos = "l";
919 : 0 : break;
920 : : case ::com::sun::star::chart::ChartLegendPosition_RIGHT:
921 : 0 : strPos = "r";
922 : 0 : break;
923 : : case ::com::sun::star::chart::ChartLegendPosition_TOP:
924 : 0 : strPos = "t";
925 : 0 : break;
926 : : case ::com::sun::star::chart::ChartLegendPosition_BOTTOM:
927 : 0 : strPos = "b";
928 : 0 : break;
929 : : case ::com::sun::star::chart::ChartLegendPosition_NONE:
930 : : case ::com::sun::star::chart::ChartLegendPosition_MAKE_FIXED_SIZE:
931 : : // nothing
932 : 0 : break;
933 : : }
934 : :
935 [ # # ]: 0 : if( strPos != NULL )
936 : : {
937 : : pFS->singleElement( FSNS( XML_c, XML_legendPos ),
938 : : XML_val, strPos,
939 [ # # ]: 0 : FSEND );
940 : : }
941 : :
942 : : // shape properties
943 [ # # ]: 0 : exportShapeProps( xProp );
944 : : }
945 : :
946 : : // legendEntry
947 : :
948 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_legend ) );
949 : 0 : }
950 : :
951 : 0 : void ChartExport::exportTitle( Reference< XShape > xShape )
952 : : {
953 : 0 : OUString sText;
954 [ # # ]: 0 : Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
955 [ # # ]: 0 : if( xPropSet.is())
956 : : {
957 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( OUString( "String" )) >>= sText;
958 : : }
959 [ # # ]: 0 : if( sText.isEmpty() )
960 : 0 : return;
961 : :
962 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
963 : : pFS->startElement( FSNS( XML_c, XML_title ),
964 [ # # ]: 0 : FSEND );
965 : : // TODO:customize layout
966 : : pFS->singleElement( FSNS( XML_c, XML_layout ),
967 [ # # ]: 0 : FSEND );
968 : :
969 : : pFS->startElement( FSNS( XML_c, XML_tx ),
970 [ # # ]: 0 : FSEND );
971 : : pFS->startElement( FSNS( XML_c, XML_rich ),
972 [ # # ]: 0 : FSEND );
973 : :
974 : : // TODO: bodyPr
975 : 0 : const char* sWritingMode = NULL;
976 : 0 : sal_Bool bVertical = sal_False;
977 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( OUString( "StackedText" )) >>= bVertical;
978 [ # # ]: 0 : if( bVertical )
979 : 0 : sWritingMode = "wordArtVert";
980 : :
981 : : pFS->singleElement( FSNS( XML_a, XML_bodyPr ),
982 : : XML_vert, sWritingMode,
983 [ # # ]: 0 : FSEND );
984 : : // TODO: lstStyle
985 : : pFS->singleElement( FSNS( XML_a, XML_lstStyle ),
986 [ # # ]: 0 : FSEND );
987 : : // FIXME: handle multipul paragraphs to parse aText
988 : : pFS->startElement( FSNS( XML_a, XML_p ),
989 [ # # ]: 0 : FSEND );
990 : :
991 : : pFS->startElement( FSNS( XML_a, XML_pPr ),
992 [ # # ]: 0 : FSEND );
993 : : pFS->singleElement( FSNS( XML_a, XML_defRPr ),
994 [ # # ]: 0 : FSEND );
995 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_pPr ) );
996 : :
997 : : pFS->startElement( FSNS( XML_a, XML_r ),
998 [ # # ]: 0 : FSEND );
999 [ # # ]: 0 : WriteRunProperties( xPropSet, sal_False );
1000 : : pFS->startElement( FSNS( XML_a, XML_t ),
1001 [ # # ]: 0 : FSEND );
1002 [ # # ]: 0 : pFS->writeEscaped( sText );
1003 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_t ) );
1004 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_r ) );
1005 : :
1006 [ # # ]: 0 : pFS->endElement( FSNS( XML_a, XML_p ) );
1007 : :
1008 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_rich ) );
1009 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_tx ) );
1010 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_title ) );
[ # # ][ # # ]
1011 : : }
1012 : :
1013 : 0 : void ChartExport::exportPlotArea( )
1014 : : {
1015 [ # # ]: 0 : Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( mxNewDiagram, uno::UNO_QUERY );
1016 [ # # ]: 0 : if( ! xBCooSysCnt.is())
1017 : : return;
1018 : :
1019 : : // plot-area element
1020 : : // -----------------
1021 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1022 : : pFS->startElement( FSNS( XML_c, XML_plotArea ),
1023 [ # # ]: 0 : FSEND );
1024 : : // layout
1025 : : pFS->singleElement( FSNS( XML_c, XML_layout ),
1026 [ # # ]: 0 : FSEND );
1027 : :
1028 : : // chart type
1029 : : Sequence< Reference< chart2::XCoordinateSystem > >
1030 [ # # ][ # # ]: 0 : aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
1031 [ # # ]: 0 : for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
1032 : : {
1033 [ # # ][ # # ]: 0 : Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
1034 [ # # ]: 0 : if( ! xCTCnt.is())
1035 : 0 : continue;
1036 [ # # ][ # # ]: 0 : Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
1037 [ # # ]: 0 : for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
1038 : : {
1039 [ # # ][ # # ]: 0 : Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY );
1040 [ # # ]: 0 : if( ! xDSCnt.is())
1041 : : return;
1042 [ # # ][ # # ]: 0 : Reference< chart2::XChartType > xChartType( aCTSeq[nCTIdx], uno::UNO_QUERY );
1043 [ # # ]: 0 : if( ! xChartType.is())
1044 : 0 : continue;
1045 : : // note: if xDSCnt.is() then also aCTSeq[nCTIdx]
1046 [ # # ][ # # ]: 0 : OUString aChartType( xChartType->getChartType());
1047 [ # # ]: 0 : sal_Int32 eChartType = lcl_getChartType( aChartType );
1048 [ # # # # : 0 : switch( eChartType )
# # # # #
# # # ]
1049 : : {
1050 : : case chart::TYPEID_BAR:
1051 : : {
1052 [ # # ]: 0 : exportBarChart( xChartType );
1053 : 0 : break;
1054 : : }
1055 : : case chart::TYPEID_AREA:
1056 : : {
1057 [ # # ]: 0 : exportAreaChart( xChartType );
1058 : 0 : break;
1059 : : }
1060 : : case chart::TYPEID_LINE:
1061 : : {
1062 [ # # ]: 0 : exportLineChart( xChartType );
1063 : 0 : break;
1064 : : }
1065 : : case chart::TYPEID_BUBBLE:
1066 : : {
1067 [ # # ]: 0 : exportBubbleChart( xChartType );
1068 : 0 : break;
1069 : : }
1070 : : case chart::TYPEID_DOUGHNUT:
1071 : : {
1072 [ # # ]: 0 : exportDoughnutChart( xChartType );
1073 : 0 : break;
1074 : : }
1075 : : case chart::TYPEID_OFPIE:
1076 : : {
1077 [ # # ]: 0 : exportOfPieChart( xChartType );
1078 : 0 : break;
1079 : : }
1080 : : case chart::TYPEID_PIE:
1081 : : {
1082 [ # # ]: 0 : exportPieChart( xChartType );
1083 : 0 : break;
1084 : : }
1085 : : case chart::TYPEID_RADARLINE:
1086 : : case chart::TYPEID_RADARAREA:
1087 : : {
1088 [ # # ]: 0 : exportRadarChart( xChartType );
1089 : 0 : break;
1090 : : }
1091 : : case chart::TYPEID_SCATTER:
1092 : : {
1093 [ # # ]: 0 : exportScatterChart( xChartType );
1094 : 0 : break;
1095 : : }
1096 : : case chart::TYPEID_STOCK:
1097 : : {
1098 [ # # ]: 0 : exportStockChart( xChartType );
1099 : 0 : break;
1100 : : }
1101 : : case chart::TYPEID_SURFACE:
1102 : : {
1103 [ # # ]: 0 : exportSuffaceChart( xChartType );
1104 : 0 : break;
1105 : : }
1106 : : default:
1107 : : {
1108 : : OSL_TRACE("ChartExport::exportPlotArea -- not support chart type");
1109 : 0 : break;
1110 : : }
1111 : : }
1112 : :
1113 [ # # ]: 0 : }
[ # # # ]
1114 [ # # ][ # # ]: 0 : }
[ # # # ]
1115 : : //Axis Data
1116 [ # # ]: 0 : exportAxes( );
1117 : :
1118 : : // shape properties
1119 [ # # ]: 0 : Reference< ::com::sun::star::chart::X3DDisplay > xWallFloorSupplier( mxDiagram, uno::UNO_QUERY );
1120 [ # # ]: 0 : if( xWallFloorSupplier.is() )
1121 : : {
1122 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
[ # # ]
1123 [ # # ]: 0 : if( xWallPropSet.is() )
1124 : : {
1125 [ # # ]: 0 : exportShapeProps( xWallPropSet );
1126 : 0 : }
1127 : : }
1128 : :
1129 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_plotArea ) );
[ # # ][ # # ]
[ # # ][ # # ]
1130 : :
1131 : : }
1132 : :
1133 : 0 : void ChartExport::exportAreaChart( Reference< chart2::XChartType > xChartType )
1134 : : {
1135 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1136 : 0 : sal_Int32 nTypeId = XML_areaChart;
1137 [ # # ]: 0 : if( mbIs3DChart )
1138 : 0 : nTypeId = XML_area3DChart;
1139 : : pFS->startElement( FSNS( XML_c, nTypeId ),
1140 [ # # ]: 0 : FSEND );
1141 : :
1142 [ # # ]: 0 : exportGrouping( );
1143 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1144 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1145 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1146 : :
1147 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nTypeId ) );
1148 : 0 : }
1149 : :
1150 : 0 : void ChartExport::exportBarChart( Reference< chart2::XChartType > xChartType )
1151 : : {
1152 : 0 : sal_Int32 nTypeId = XML_barChart;
1153 [ # # ]: 0 : if( mbIs3DChart )
1154 : 0 : nTypeId = XML_bar3DChart;
1155 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1156 : : pFS->startElement( FSNS( XML_c, nTypeId ),
1157 [ # # ]: 0 : FSEND );
1158 : : // bar direction
1159 : 0 : sal_Bool bVertical = sal_False;
1160 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
1161 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "Vertical" ) ) )
[ # # ][ # # ]
1162 : 0 : mAny >>= bVertical;
1163 : :
1164 [ # # ]: 0 : const char* bardir = bVertical? "bar":"col";
1165 : : pFS->singleElement( FSNS( XML_c, XML_barDir ),
1166 : : XML_val, bardir,
1167 [ # # ]: 0 : FSEND );
1168 : :
1169 [ # # ]: 0 : exportGrouping( sal_True );
1170 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1171 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1172 : :
1173 [ # # ]: 0 : Reference< XPropertySet > xTypeProp( xChartType, uno::UNO_QUERY );
1174 [ # # ]: 0 : if( mbIs3DChart )
1175 : : {
1176 : : // Shape
1177 : : namespace cssc = ::com::sun::star::chart;
1178 : 0 : sal_Int32 nGeom3d = cssc::ChartSolidType::RECTANGULAR_SOLID;
1179 [ # # ][ # # ]: 0 : if( xPropSet.is() && GetProperty( xPropSet, S("SolidType") ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1180 : 0 : mAny >>= nGeom3d;
1181 : 0 : const char* sShapeType = NULL;
1182 [ # # # # : 0 : switch( nGeom3d )
# ]
1183 : : {
1184 : : case cssc::ChartSolidType::RECTANGULAR_SOLID:
1185 : 0 : sShapeType = "box";
1186 : 0 : break;
1187 : : case cssc::ChartSolidType::CONE:
1188 : 0 : sShapeType = "cone";
1189 : 0 : break;
1190 : : case cssc::ChartSolidType::CYLINDER:
1191 : 0 : sShapeType = "cylinder";
1192 : 0 : break;
1193 : : case cssc::ChartSolidType::PYRAMID:
1194 : 0 : sShapeType = "pyramid";
1195 : 0 : break;
1196 : : }
1197 : : pFS->singleElement( FSNS( XML_c, XML_shape ),
1198 : : XML_val, sShapeType,
1199 [ # # ]: 0 : FSEND );
1200 : : }
1201 : :
1202 : : //overlap
1203 [ # # ][ # # ]: 0 : if( xTypeProp.is() && GetProperty( xTypeProp, S("OverlapSequence") ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1204 : : {
1205 [ # # ]: 0 : uno::Sequence< sal_Int32 > aBarPositionSequence;
1206 [ # # ]: 0 : mAny >>= aBarPositionSequence;
1207 [ # # ]: 0 : if( aBarPositionSequence.getLength() )
1208 : : {
1209 [ # # ]: 0 : sal_Int32 nOverlap = aBarPositionSequence[0];
1210 [ # # ]: 0 : if( nOverlap > 0 )
1211 : : pFS->singleElement( FSNS( XML_c, XML_overlap ),
1212 : : XML_val, I32S( nOverlap ),
1213 [ # # ]: 0 : FSEND );
1214 [ # # ]: 0 : }
1215 : : }
1216 [ # # ][ # # ]: 0 : if( xTypeProp.is() && GetProperty( xTypeProp, S("GapwidthSequence") ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1217 : : {
1218 [ # # ]: 0 : uno::Sequence< sal_Int32 > aBarPositionSequence;
1219 [ # # ]: 0 : mAny >>= aBarPositionSequence;
1220 [ # # ]: 0 : if( aBarPositionSequence.getLength() )
1221 : : {
1222 [ # # ]: 0 : sal_Int32 nGapWidth = aBarPositionSequence[0];
1223 : : pFS->singleElement( FSNS( XML_c, XML_gapWidth ),
1224 : : XML_val, I32S( nGapWidth ),
1225 [ # # ]: 0 : FSEND );
1226 [ # # ]: 0 : }
1227 : : }
1228 : :
1229 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1230 : :
1231 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nTypeId ) );
1232 : 0 : }
1233 : :
1234 : 0 : void ChartExport::exportBubbleChart( Reference< chart2::XChartType > xChartType )
1235 : : {
1236 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1237 : : pFS->startElement( FSNS( XML_c, XML_bubbleChart ),
1238 [ # # ]: 0 : FSEND );
1239 : :
1240 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1241 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1242 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1243 : :
1244 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_bubbleChart ) );
1245 : 0 : }
1246 : :
1247 : 0 : void ChartExport::exportDoughnutChart( Reference< chart2::XChartType > xChartType )
1248 : : {
1249 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1250 : : pFS->startElement( FSNS( XML_c, XML_doughnutChart ),
1251 [ # # ]: 0 : FSEND );
1252 : :
1253 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1254 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1255 : : // firstSliceAng
1256 [ # # ]: 0 : exportFirstSliceAng( );
1257 : : //FIXME: holeSize
1258 : 0 : sal_Int32 nHoleSize = 50;
1259 : : pFS->singleElement( FSNS( XML_c, XML_holeSize ),
1260 : : XML_val, I32S( nHoleSize ),
1261 [ # # ]: 0 : FSEND );
1262 : :
1263 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1264 : :
1265 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_doughnutChart ) );
1266 : 0 : }
1267 : :
1268 : 0 : void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType )
1269 : : {
1270 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1271 : 0 : sal_Int32 nTypeId = XML_lineChart;
1272 [ # # ]: 0 : if( mbIs3DChart )
1273 : 0 : nTypeId = XML_line3DChart;
1274 : : pFS->startElement( FSNS( XML_c, nTypeId ),
1275 [ # # ]: 0 : FSEND );
1276 : :
1277 [ # # ]: 0 : exportGrouping( );
1278 : : // TODO: show marker symbol in series?
1279 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1280 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1281 : :
1282 : : // show marker?
1283 : 0 : sal_Int32 nSymbolType = ::com::sun::star::chart::ChartSymbolType::NONE;
1284 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
1285 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "SymbolType" ) ) )
[ # # ][ # # ]
1286 : 0 : mAny >>= nSymbolType;
1287 : :
1288 [ # # ]: 0 : const char* marker = nSymbolType == ::com::sun::star::chart::ChartSymbolType::NONE? "0":"1";
1289 : : pFS->singleElement( FSNS( XML_c, XML_marker ),
1290 : : XML_val, marker,
1291 [ # # ]: 0 : FSEND );
1292 : :
1293 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1294 : :
1295 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nTypeId ) );
1296 : 0 : }
1297 : :
1298 : 0 : void ChartExport::exportOfPieChart( Reference< chart2::XChartType > /*xChartType*/ )
1299 : : {
1300 : : // TODO:
1301 : 0 : }
1302 : :
1303 : 0 : void ChartExport::exportPieChart( Reference< chart2::XChartType > xChartType )
1304 : : {
1305 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1306 : 0 : sal_Int32 nTypeId = XML_pieChart;
1307 [ # # ]: 0 : if( mbIs3DChart )
1308 : 0 : nTypeId = XML_pie3DChart;
1309 : : pFS->startElement( FSNS( XML_c, nTypeId ),
1310 [ # # ]: 0 : FSEND );
1311 : : // TODO: varyColors
1312 : 0 : const char* varyColors = "1";
1313 : : pFS->singleElement( FSNS( XML_c, XML_varyColors ),
1314 : : XML_val, varyColors,
1315 [ # # ]: 0 : FSEND );
1316 : :
1317 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1318 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1319 : :
1320 : : // firstSliceAng
1321 [ # # ]: 0 : exportFirstSliceAng( );
1322 : :
1323 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nTypeId ) );
1324 : 0 : }
1325 : :
1326 : 0 : void ChartExport::exportRadarChart( Reference< chart2::XChartType > xChartType)
1327 : : {
1328 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1329 : : pFS->startElement( FSNS( XML_c, XML_radarChart ),
1330 [ # # ]: 0 : FSEND );
1331 : :
1332 : : // radarStyle
1333 [ # # ]: 0 : sal_Int32 eChartType = getChartType( );
1334 : 0 : const char* radarStyle = NULL;
1335 [ # # ]: 0 : if( eChartType == chart::TYPEID_RADARAREA )
1336 : 0 : radarStyle = "filled";
1337 : : else
1338 : 0 : radarStyle = "marker";
1339 : : pFS->singleElement( FSNS( XML_c, XML_radarStyle ),
1340 : : XML_val, radarStyle,
1341 [ # # ]: 0 : FSEND );
1342 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1343 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1344 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1345 : :
1346 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_radarChart ) );
1347 : 0 : }
1348 : :
1349 : 0 : void ChartExport::exportScatterChart( Reference< chart2::XChartType > xChartType )
1350 : : {
1351 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1352 : : pFS->startElement( FSNS( XML_c, XML_scatterChart ),
1353 [ # # ]: 0 : FSEND );
1354 : : // TODO:scatterStyle
1355 : 0 : const char* scatterStyle = "lineMarker";
1356 : : pFS->singleElement( FSNS( XML_c, XML_scatterStyle ),
1357 : : XML_val, scatterStyle,
1358 [ # # ]: 0 : FSEND );
1359 : :
1360 : : // FIXME: should export xVal and yVal
1361 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1362 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1363 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1364 : :
1365 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_scatterChart ) );
1366 : 0 : }
1367 : :
1368 : 0 : void ChartExport::exportStockChart( Reference< chart2::XChartType > xChartType )
1369 : : {
1370 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1371 : : pFS->startElement( FSNS( XML_c, XML_stockChart ),
1372 [ # # ]: 0 : FSEND );
1373 : :
1374 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1375 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1376 : : // export stock properties
1377 [ # # ]: 0 : Reference< ::com::sun::star::chart::XStatisticDisplay > xStockPropProvider( mxDiagram, uno::UNO_QUERY );
1378 [ # # ]: 0 : if( xStockPropProvider.is())
1379 : : {
1380 : : // stock-range-line
1381 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getMinMaxLine();
1382 [ # # ]: 0 : if( xStockPropSet.is() )
1383 : : {
1384 : : pFS->startElement( FSNS( XML_c, XML_hiLowLines ),
1385 [ # # ]: 0 : FSEND );
1386 [ # # ]: 0 : exportShapeProps( xStockPropSet );
1387 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_hiLowLines ) );
1388 : : }
1389 : : // stock updownbar
1390 : : pFS->startElement( FSNS( XML_c, XML_upDownBars ),
1391 [ # # ]: 0 : FSEND );
1392 : : // TODO: gapWidth
1393 : 0 : sal_Int32 nGapWidth = 150;
1394 : : pFS->singleElement( FSNS( XML_c, XML_gapWidth ),
1395 : : XML_val, I32S( nGapWidth ),
1396 [ # # ]: 0 : FSEND );
1397 : :
1398 [ # # ][ # # ]: 0 : xStockPropSet = xStockPropProvider->getUpBar();
[ # # ]
1399 [ # # ]: 0 : if( xStockPropSet.is() )
1400 : : {
1401 : : pFS->startElement( FSNS( XML_c, XML_upBars ),
1402 [ # # ]: 0 : FSEND );
1403 [ # # ]: 0 : exportShapeProps( xStockPropSet );
1404 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_upBars ) );
1405 : : }
1406 : :
1407 [ # # ][ # # ]: 0 : xStockPropSet = xStockPropProvider->getDownBar();
[ # # ]
1408 [ # # ]: 0 : if( xStockPropSet.is() )
1409 : : {
1410 : : pFS->startElement( FSNS( XML_c, XML_downBars ),
1411 [ # # ]: 0 : FSEND );
1412 [ # # ]: 0 : exportShapeProps( xStockPropSet );
1413 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_downBars ) );
1414 : : }
1415 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_upDownBars ) );
1416 : : }
1417 : :
1418 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1419 : :
1420 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_stockChart ) );
1421 : 0 : }
1422 : :
1423 : 0 : void ChartExport::exportSuffaceChart( Reference< chart2::XChartType > xChartType )
1424 : : {
1425 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1426 : 0 : sal_Int32 nTypeId = XML_surfaceChart;
1427 [ # # ]: 0 : if( mbIs3DChart )
1428 : 0 : nTypeId = XML_surface3DChart;
1429 : : pFS->startElement( FSNS( XML_c, nTypeId ),
1430 [ # # ]: 0 : FSEND );
1431 : 0 : sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
1432 [ # # ]: 0 : exportSeries( xChartType, nAttachedAxis );
1433 [ # # ]: 0 : exportAxesId( nAttachedAxis );
1434 : :
1435 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nTypeId ) );
1436 : 0 : }
1437 : :
1438 : 0 : void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_Int32& nAttachedAxis )
1439 : : {
1440 : :
1441 [ # # ][ # # ]: 0 : OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel();
1442 [ # # ]: 0 : Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY );
1443 [ # # ]: 0 : if( ! xDSCnt.is())
1444 : : return;
1445 : :
1446 [ # # ][ # # ]: 0 : OUString aChartType( xChartType->getChartType());
1447 [ # # ]: 0 : sal_Int32 eChartType = lcl_getChartType( aChartType );
1448 : :
1449 : : // special export for stock charts
1450 [ # # ]: 0 : if( eChartType == chart::TYPEID_STOCK )
1451 : : {
1452 : 0 : sal_Bool bJapaneseCandleSticks = sal_False;
1453 [ # # ]: 0 : Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY );
1454 [ # # ]: 0 : if( xCTProp.is())
1455 [ # # ][ # # ]: 0 : xCTProp->getPropertyValue( OUString("Japanese")) >>= bJapaneseCandleSticks;
1456 : : exportCandleStickSeries(
1457 [ # # ][ # # ]: 0 : xDSCnt->getDataSeries(), bJapaneseCandleSticks, nAttachedAxis );
[ # # ][ # # ]
1458 : 0 : return;
1459 : : }
1460 : :
1461 : :
1462 : : // export dataseries for current chart-type
1463 [ # # ][ # # ]: 0 : Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
1464 [ # # ]: 0 : for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
1465 : : {
1466 : : // export series
1467 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
1468 [ # # ]: 0 : if( xSource.is())
1469 : : {
1470 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
1471 [ # # ][ # # ]: 0 : xSource->getDataSequences());
1472 : : // search for main sequence and create a series element
1473 : : {
1474 : 0 : sal_Int32 nMainSequenceIndex = -1;
1475 : 0 : sal_Int32 nSeriesLength = 0;
1476 : 0 : Reference< chart2::data::XDataSequence > xValuesSeq;
1477 : 0 : Reference< chart2::data::XDataSequence > xLabelSeq;
1478 : 0 : sal_Int32 nSeqIdx=0;
1479 [ # # ]: 0 : for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
1480 : : {
1481 : 0 : OUString aRole;
1482 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
[ # # ]
1483 [ # # ]: 0 : if( nMainSequenceIndex==-1 )
1484 : : {
1485 [ # # ]: 0 : Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
1486 [ # # ]: 0 : if( xSeqProp.is())
1487 [ # # ][ # # ]: 0 : xSeqProp->getPropertyValue(OUString("Role")) >>= aRole;
1488 : : // "main" sequence
1489 [ # # ]: 0 : if( aRole.equals( aLabelRole ))
1490 : : {
1491 [ # # ]: 0 : xValuesSeq.set( xTempValueSeq );
1492 [ # # ][ # # ]: 0 : xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
[ # # ][ # # ]
1493 : 0 : nMainSequenceIndex = nSeqIdx;
1494 : 0 : }
1495 : : }
1496 [ # # ][ # # ]: 0 : sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
[ # # ][ # # ]
[ # # ][ # # ]
1497 [ # # ]: 0 : if( nSeriesLength < nSequenceLength )
1498 : 0 : nSeriesLength = nSequenceLength;
1499 : 0 : }
1500 : :
1501 : : // have found the main sequence, then xValuesSeq and
1502 : : // xLabelSeq contain those. Otherwise both are empty
1503 : : {
1504 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1505 : : pFS->startElement( FSNS( XML_c, XML_ser ),
1506 [ # # ]: 0 : FSEND );
1507 : :
1508 : : // TODO: idx and order
1509 : : pFS->singleElement( FSNS( XML_c, XML_idx ),
1510 : : XML_val, I32S(nSeriesIdx),
1511 [ # # ]: 0 : FSEND );
1512 : : pFS->singleElement( FSNS( XML_c, XML_order ),
1513 : : XML_val, I32S(nSeriesIdx),
1514 [ # # ]: 0 : FSEND );
1515 : :
1516 : : // export label
1517 [ # # ]: 0 : if( xLabelSeq.is() )
1518 [ # # ]: 0 : exportSeriesText( xLabelSeq );
1519 : :
1520 : : // export shape properties
1521 : : Reference< XPropertySet > xPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet(
1522 [ # # ][ # # ]: 0 : aSeriesSeq[nSeriesIdx], getModel() );
[ # # ]
1523 [ # # ]: 0 : if( xPropSet.is() )
1524 : : {
1525 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S("Axis") ) )
[ # # ][ # # ]
1526 : : {
1527 : 0 : mAny >>= nAttachedAxis;
1528 [ # # ]: 0 : if( nAttachedAxis == ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y )
1529 : 0 : nAttachedAxis = AXIS_SECONDARY_Y;
1530 : : else
1531 : 0 : nAttachedAxis = AXIS_PRIMARY_Y;
1532 : : }
1533 [ # # ]: 0 : exportShapeProps( xPropSet );
1534 : : }
1535 : :
1536 [ # # # # : 0 : switch( eChartType )
# ]
1537 : : {
1538 : : case chart::TYPEID_LINE:
1539 : : {
1540 [ # # ]: 0 : exportMarker( );
1541 : 0 : break;
1542 : : }
1543 : : case chart::TYPEID_PIE:
1544 : : case chart::TYPEID_DOUGHNUT:
1545 : : {
1546 [ # # ][ # # ]: 0 : if( xPropSet.is() && GetProperty( xPropSet, S("SegmentOffset") ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1547 : : {
1548 : 0 : sal_Int32 nOffset = 0;
1549 : 0 : mAny >>= nOffset;
1550 : : pFS->singleElement( FSNS( XML_c, XML_explosion ),
1551 : : XML_val, I32S( nOffset ),
1552 [ # # ]: 0 : FSEND );
1553 : : }
1554 : 0 : break;
1555 : : }
1556 : : case chart::TYPEID_SCATTER:
1557 : : {
1558 [ # # ]: 0 : exportMarker( );
1559 [ # # ]: 0 : exportSmooth( );
1560 : 0 : break;
1561 : : }
1562 : : case chart::TYPEID_RADARLINE:
1563 : : {
1564 [ # # ]: 0 : exportMarker( );
1565 : 0 : break;
1566 : : }
1567 : : }
1568 : :
1569 : : // TODO: Data Labels: show data lables
1570 : :
1571 : : // export data points
1572 [ # # ][ # # ]: 0 : exportDataPoints( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
[ # # ]
1573 : :
1574 : : // export categories
1575 [ # # ]: 0 : if( mxCategoriesValues.is() )
1576 [ # # ]: 0 : exportSeriesCategory( mxCategoriesValues );
1577 : :
1578 [ # # ][ # # ]: 0 : if( (eChartType == chart::TYPEID_SCATTER)
1579 : : || (eChartType == chart::TYPEID_BUBBLE) )
1580 : : {
1581 : : // export xVal
1582 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString("values-x") ) );
1583 [ # # ]: 0 : if( xSequence.is() )
1584 : : {
1585 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
1586 [ # # ]: 0 : if( xValues.is() )
1587 [ # # ]: 0 : exportSeriesValues( xValues, XML_xVal );
1588 : 0 : }
1589 : : }
1590 : :
1591 : :
1592 [ # # ]: 0 : if( eChartType == chart::TYPEID_BUBBLE )
1593 : : {
1594 : : // export yVal
1595 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString("values-y") ) );
1596 [ # # ]: 0 : if( xSequence.is() )
1597 : : {
1598 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
1599 [ # # ]: 0 : if( xValues.is() )
1600 [ # # ]: 0 : exportSeriesValues( xValues, XML_yVal );
1601 : 0 : }
1602 : : }
1603 : :
1604 : : // export values
1605 [ # # ]: 0 : if( xValuesSeq.is() )
1606 : : {
1607 : 0 : sal_Int32 nYValueType = XML_val;
1608 [ # # ]: 0 : if( eChartType == chart::TYPEID_SCATTER )
1609 : 0 : nYValueType = XML_yVal;
1610 [ # # ]: 0 : else if( eChartType == chart::TYPEID_BUBBLE )
1611 : 0 : nYValueType = XML_bubbleSize;
1612 [ # # ]: 0 : exportSeriesValues( xValuesSeq, nYValueType );
1613 : : }
1614 : :
1615 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_ser ) );
1616 : 0 : }
1617 [ # # ]: 0 : }
1618 : : }
1619 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1620 : : }
1621 : :
1622 : 0 : void ChartExport::exportCandleStickSeries(
1623 : : const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
1624 : : sal_Bool /*bJapaneseCandleSticks*/,
1625 : : sal_Int32& nAttachedAxis )
1626 : : {
1627 [ # # ]: 0 : for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
1628 : : {
1629 : 0 : Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
1630 [ # # ][ # # ]: 0 : nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries ) ? AXIS_PRIMARY_Y : AXIS_SECONDARY_Y;
1631 : :
1632 [ # # ]: 0 : Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
1633 [ # # ]: 0 : if( xSource.is())
1634 : : {
1635 : : // export series in correct order (as we don't store roles)
1636 : : // with japanese candlesticks: open, low, high, close
1637 : : // otherwise: low, high, close
1638 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
1639 [ # # ][ # # ]: 0 : xSource->getDataSequences());
1640 : :
1641 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
1642 : 0 : const char* sSeries[] = {"values-first","values-max","values-min","values-last",0};
1643 [ # # ]: 0 : for( sal_Int32 idx = 0; sSeries[idx] != 0 ; idx++ )
1644 : : {
1645 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii(sSeries[idx]) ) );
1646 [ # # ]: 0 : if( xLabeledSeq.is())
1647 : : {
1648 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel());
1649 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues());
1650 : : {
1651 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1652 : : pFS->startElement( FSNS( XML_c, XML_ser ),
1653 [ # # ]: 0 : FSEND );
1654 : :
1655 : : // TODO: idx and order
1656 : : pFS->singleElement( FSNS( XML_c, XML_idx ),
1657 : : XML_val, I32S(idx),
1658 [ # # ]: 0 : FSEND );
1659 : : pFS->singleElement( FSNS( XML_c, XML_order ),
1660 : : XML_val, I32S(idx),
1661 [ # # ]: 0 : FSEND );
1662 : :
1663 : : // export label
1664 [ # # ]: 0 : if( xLabelSeq.is() )
1665 [ # # ]: 0 : exportSeriesText( xLabelSeq );
1666 : :
1667 : : // TODO:export shape properties
1668 : :
1669 : : // export categories
1670 [ # # ]: 0 : if( mxCategoriesValues.is() )
1671 [ # # ]: 0 : exportSeriesCategory( mxCategoriesValues );
1672 : :
1673 : : // export values
1674 [ # # ]: 0 : if( xValueSeq.is() )
1675 [ # # ]: 0 : exportSeriesValues( xValueSeq );
1676 : :
1677 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_ser ) );
1678 : 0 : }
1679 : : }
1680 [ # # ]: 0 : }
1681 : : }
1682 : 0 : }
1683 : 0 : }
1684 : :
1685 : :
1686 : :
1687 : 0 : void ChartExport::exportSeriesText( const Reference< chart2::data::XDataSequence > & xValueSeq )
1688 : : {
1689 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1690 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
1691 : : pFS->startElement( FSNS( XML_c, XML_tx ),
1692 [ # # ]: 0 : FSEND );
1693 : :
1694 [ # # ][ # # ]: 0 : OUString aCellRange = xValueSeq->getSourceRangeRepresentation();
1695 [ # # ]: 0 : aCellRange = parseFormula( aCellRange );
1696 : : pFS->startElement( FSNS( XML_c, XML_strRef ),
1697 [ # # ]: 0 : FSEND );
1698 : :
1699 : : pFS->startElement( FSNS( XML_c, XML_f ),
1700 [ # # ]: 0 : FSEND );
1701 [ # # ]: 0 : pFS->writeEscaped( aCellRange );
1702 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_f ) );
1703 : :
1704 [ # # ]: 0 : OUString aLabelString = lcl_getLabelString( xValueSeq );
1705 : : pFS->startElement( FSNS( XML_c, XML_strCache ),
1706 [ # # ]: 0 : FSEND );
1707 : : pFS->singleElement( FSNS( XML_c, XML_ptCount ),
1708 : : XML_val, "1",
1709 [ # # ]: 0 : FSEND );
1710 : : pFS->startElement( FSNS( XML_c, XML_pt ),
1711 : : XML_idx, "0",
1712 [ # # ]: 0 : FSEND );
1713 : : pFS->startElement( FSNS( XML_c, XML_v ),
1714 [ # # ]: 0 : FSEND );
1715 [ # # ]: 0 : pFS->writeEscaped( aLabelString );
1716 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_v ) );
1717 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_pt ) );
1718 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_strCache ) );
1719 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_strRef ) );
1720 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_tx ) );
1721 : 0 : }
1722 : :
1723 : 0 : void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequence > & xValueSeq )
1724 : : {
1725 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1726 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
1727 : : pFS->startElement( FSNS( XML_c, XML_cat ),
1728 [ # # ]: 0 : FSEND );
1729 : :
1730 [ # # ][ # # ]: 0 : OUString aCellRange = xValueSeq->getSourceRangeRepresentation();
1731 [ # # ]: 0 : aCellRange = parseFormula( aCellRange );
1732 : : // TODO: need to handle XML_multiLvlStrRef according to aCellRange
1733 : : pFS->startElement( FSNS( XML_c, XML_strRef ),
1734 [ # # ]: 0 : FSEND );
1735 : :
1736 : : pFS->startElement( FSNS( XML_c, XML_f ),
1737 [ # # ]: 0 : FSEND );
1738 [ # # ]: 0 : pFS->writeEscaped( aCellRange );
1739 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_f ) );
1740 : :
1741 [ # # ]: 0 : ::std::vector< OUString > aCategories;
1742 [ # # ]: 0 : lcl_fillCategoriesIntoStringVector( xValueSeq, aCategories );
1743 : 0 : sal_Int32 ptCount = aCategories.size();
1744 : : pFS->startElement( FSNS( XML_c, XML_strCache ),
1745 [ # # ]: 0 : FSEND );
1746 : : pFS->singleElement( FSNS( XML_c, XML_ptCount ),
1747 : : XML_val, I32S( ptCount ),
1748 [ # # ]: 0 : FSEND );
1749 [ # # ]: 0 : for( sal_Int32 i = 0; i < ptCount; i++ )
1750 : : {
1751 : : pFS->startElement( FSNS( XML_c, XML_pt ),
1752 : : XML_idx, I32S( i ),
1753 [ # # ]: 0 : FSEND );
1754 : : pFS->startElement( FSNS( XML_c, XML_v ),
1755 [ # # ]: 0 : FSEND );
1756 [ # # ]: 0 : pFS->writeEscaped( aCategories[i] );
1757 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_v ) );
1758 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_pt ) );
1759 : : }
1760 : :
1761 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_strCache ) );
1762 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_strRef ) );
1763 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_cat ) );
1764 : 0 : }
1765 : :
1766 : 0 : void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequence > & xValueSeq, sal_Int32 nValueType )
1767 : : {
1768 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1769 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
1770 : : pFS->startElement( FSNS( XML_c, nValueType ),
1771 [ # # ]: 0 : FSEND );
1772 : :
1773 [ # # ][ # # ]: 0 : OUString aCellRange = xValueSeq->getSourceRangeRepresentation();
1774 [ # # ]: 0 : aCellRange = parseFormula( aCellRange );
1775 : : // TODO: need to handle XML_multiLvlStrRef according to aCellRange
1776 : : pFS->startElement( FSNS( XML_c, XML_numRef ),
1777 [ # # ]: 0 : FSEND );
1778 : :
1779 : : pFS->startElement( FSNS( XML_c, XML_f ),
1780 [ # # ]: 0 : FSEND );
1781 [ # # ]: 0 : pFS->writeEscaped( aCellRange );
1782 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_f ) );
1783 : :
1784 [ # # ]: 0 : ::std::vector< double > aValues;
1785 [ # # ]: 0 : aValues = lcl_getAllValuesFromSequence( xValueSeq );
1786 : 0 : sal_Int32 ptCount = aValues.size();
1787 : : pFS->startElement( FSNS( XML_c, XML_numCache ),
1788 [ # # ]: 0 : FSEND );
1789 : : pFS->startElement( FSNS( XML_c, XML_formatCode ),
1790 [ # # ]: 0 : FSEND );
1791 : : // TODO: what format code?
1792 [ # # ]: 0 : pFS->writeEscaped( "General" );
1793 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_formatCode ) );
1794 : : pFS->singleElement( FSNS( XML_c, XML_ptCount ),
1795 : : XML_val, I32S( ptCount ),
1796 [ # # ]: 0 : FSEND );
1797 [ # # ]: 0 : for( sal_Int32 i = 0; i < ptCount; i++ )
1798 : : {
1799 : : pFS->startElement( FSNS( XML_c, XML_pt ),
1800 : : XML_idx, I32S( i ),
1801 [ # # ]: 0 : FSEND );
1802 : : pFS->startElement( FSNS( XML_c, XML_v ),
1803 [ # # ]: 0 : FSEND );
1804 [ # # ][ # # ]: 0 : pFS->write( aValues[i] );
1805 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_v ) );
1806 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_pt ) );
1807 : : }
1808 : :
1809 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_numCache ) );
1810 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_numRef ) );
1811 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nValueType ) );
1812 : 0 : }
1813 : :
1814 : 0 : void ChartExport::exportShapeProps( Reference< XPropertySet > xPropSet )
1815 : : {
1816 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
1817 : : pFS->startElement( FSNS( XML_c, XML_spPr ),
1818 [ # # ]: 0 : FSEND );
1819 : :
1820 [ # # ]: 0 : WriteFill( xPropSet );
1821 [ # # ]: 0 : WriteOutline( xPropSet );
1822 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_spPr ) );
1823 : 0 : }
1824 : :
1825 : 0 : void ChartExport::InitPlotArea( )
1826 : : {
1827 [ # # ]: 0 : Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY);
1828 : :
1829 : : // Check for supported services and then the properties provided by this service.
1830 [ # # ]: 0 : Reference<lang::XServiceInfo> xServiceInfo (mxDiagram, uno::UNO_QUERY);
1831 [ # # ]: 0 : if (xServiceInfo.is())
1832 : : {
1833 [ # # # # ]: 0 : if (xServiceInfo->supportsService(
1834 [ # # ]: 0 : OUString("com.sun.star.chart.ChartAxisXSupplier")))
1835 : : {
1836 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1837 [ # # ]: 0 : OUString("HasXAxis")) >>= mbHasXAxis;
1838 : : }
1839 [ # # # # ]: 0 : if (xServiceInfo->supportsService(
1840 [ # # ]: 0 : OUString("com.sun.star.chart.ChartAxisYSupplier")))
1841 : : {
1842 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1843 [ # # ]: 0 : OUString("HasYAxis")) >>= mbHasYAxis;
1844 : : }
1845 [ # # # # ]: 0 : if (xServiceInfo->supportsService(
1846 [ # # ]: 0 : OUString("com.sun.star.chart.ChartAxisZSupplier")))
1847 : : {
1848 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1849 [ # # ]: 0 : OUString("HasZAxis")) >>= mbHasZAxis;
1850 : : }
1851 [ # # # # ]: 0 : if (xServiceInfo->supportsService(
1852 [ # # ]: 0 : OUString("com.sun.star.chart.ChartTwoAxisXSupplier")))
1853 : : {
1854 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1855 [ # # ]: 0 : OUString("HasSecondaryXAxis")) >>= mbHasSecondaryXAxis;
1856 : : }
1857 [ # # # # ]: 0 : if (xServiceInfo->supportsService(
1858 [ # # ]: 0 : OUString("com.sun.star.chart.ChartTwoAxisYSupplier")))
1859 : : {
1860 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1861 [ # # ]: 0 : OUString("HasSecondaryYAxis")) >>= mbHasSecondaryYAxis;
1862 : : }
1863 : : }
1864 : :
1865 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1866 [ # # ]: 0 : OUString ("Dim3D")) >>= mbIs3DChart;
1867 : :
1868 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
1869 [ # # ][ # # ]: 0 : if( mbHasCategoryLabels && mxNewDiagram.is())
[ # # ]
1870 : : {
1871 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( mxNewDiagram ) );
1872 [ # # ]: 0 : if( xCategories.is() )
1873 : : {
1874 [ # # ][ # # ]: 0 : mxCategoriesValues.set( xCategories->getValues() );
[ # # ]
1875 : 0 : }
1876 : 0 : }
1877 : 0 : }
1878 : :
1879 : 0 : void ChartExport::exportAxes( )
1880 : : {
1881 : 0 : sal_Int32 nSize = maAxes.size();
1882 [ # # ]: 0 : for( sal_Int32 nIdx = 0; nIdx < nSize; nIdx++ )
1883 : : {
1884 : 0 : exportAxis( maAxes[nIdx] );
1885 : : }
1886 : 0 : }
1887 : :
1888 : 0 : void ChartExport::exportAxis( AxisIdPair aAxisIdPair )
1889 : : {
1890 : : // get some properties from document first
1891 : 0 : sal_Bool bHasXAxisTitle = sal_False,
1892 : 0 : bHasYAxisTitle = sal_False,
1893 : 0 : bHasZAxisTitle = sal_False,
1894 : 0 : bHasSecondaryXAxisTitle = sal_False,
1895 : 0 : bHasSecondaryYAxisTitle = sal_False;
1896 : 0 : sal_Bool bHasXAxisMajorGrid = sal_False,
1897 : 0 : bHasXAxisMinorGrid = sal_False,
1898 : 0 : bHasYAxisMajorGrid = sal_False,
1899 : 0 : bHasYAxisMinorGrid = sal_False,
1900 : 0 : bHasZAxisMajorGrid = sal_False,
1901 : 0 : bHasZAxisMinorGrid = sal_False;
1902 : :
1903 [ # # ]: 0 : Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY);
1904 : :
1905 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1906 [ # # ]: 0 : OUString ("HasXAxisTitle")) >>= bHasXAxisTitle;
1907 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1908 [ # # ]: 0 : OUString ("HasYAxisTitle")) >>= bHasYAxisTitle;
1909 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1910 [ # # ]: 0 : OUString ("HasZAxisTitle")) >>= bHasZAxisTitle;
1911 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1912 [ # # ]: 0 : OUString ("HasSecondaryXAxisTitle")) >>= bHasSecondaryXAxisTitle;
1913 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1914 [ # # ]: 0 : OUString ("HasSecondaryYAxisTitle")) >>= bHasSecondaryYAxisTitle;
1915 : :
1916 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1917 [ # # ]: 0 : OUString ("HasXAxisGrid")) >>= bHasXAxisMajorGrid;
1918 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1919 [ # # ]: 0 : OUString ("HasYAxisGrid")) >>= bHasYAxisMajorGrid;
1920 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1921 [ # # ]: 0 : OUString ("HasZAxisGrid")) >>= bHasZAxisMajorGrid;
1922 : :
1923 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1924 [ # # ]: 0 : OUString ("HasXAxisHelpGrid")) >>= bHasXAxisMinorGrid;
1925 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1926 [ # # ]: 0 : OUString ("HasYAxisHelpGrid")) >>= bHasYAxisMinorGrid;
1927 [ # # ]: 0 : xDiagramProperties->getPropertyValue(
1928 [ # # ]: 0 : OUString ("HasZAxisHelpGrid")) >>= bHasZAxisMinorGrid;
1929 : :
1930 : 0 : Reference< XPropertySet > xAxisProp;
1931 : 0 : Reference< drawing::XShape > xAxisTitle;
1932 : 0 : Reference< beans::XPropertySet > xMajorGrid;
1933 : 0 : Reference< beans::XPropertySet > xMinorGrid;
1934 : 0 : sal_Int32 nAxisType = XML_catAx;
1935 : 0 : const char* sAxPos = NULL;
1936 : :
1937 [ # # # # : 0 : switch( aAxisIdPair.nAxisType )
# ]
1938 : : {
1939 : : case AXIS_PRIMARY_X:
1940 : : {
1941 [ # # ]: 0 : Reference< ::com::sun::star::chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
1942 [ # # ]: 0 : if( xAxisXSupp.is())
1943 [ # # ][ # # ]: 0 : xAxisProp = xAxisXSupp->getXAxis();
[ # # ]
1944 [ # # ]: 0 : if( bHasXAxisTitle )
1945 [ # # ][ # # ]: 0 : xAxisTitle.set( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY );
[ # # ]
1946 [ # # ]: 0 : if( bHasXAxisMajorGrid )
1947 [ # # ][ # # ]: 0 : xMajorGrid.set( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY );
[ # # ]
1948 [ # # ]: 0 : if( bHasXAxisMinorGrid )
1949 [ # # ][ # # ]: 0 : xMinorGrid.set( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY );
[ # # ]
1950 : :
1951 [ # # ]: 0 : sal_Int32 eChartType = getChartType( );
1952 [ # # ][ # # ]: 0 : if( (eChartType == chart::TYPEID_SCATTER)
1953 : : || (eChartType == chart::TYPEID_BUBBLE) )
1954 : 0 : nAxisType = XML_valAx;
1955 [ # # ]: 0 : else if( eChartType == chart::TYPEID_STOCK )
1956 : 0 : nAxisType = XML_dateAx;
1957 : : // FIXME: axPos, need to check axis direction
1958 : 0 : sAxPos = "b";
1959 : 0 : break;
1960 : : }
1961 : : case AXIS_PRIMARY_Y:
1962 : : {
1963 [ # # ]: 0 : Reference< ::com::sun::star::chart::XAxisYSupplier > xAxisYSupp( mxDiagram, uno::UNO_QUERY );
1964 [ # # ]: 0 : if( xAxisYSupp.is())
1965 [ # # ][ # # ]: 0 : xAxisProp = xAxisYSupp->getYAxis();
[ # # ]
1966 [ # # ]: 0 : if( bHasYAxisTitle )
1967 [ # # ][ # # ]: 0 : xAxisTitle.set( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY );
[ # # ]
1968 [ # # ]: 0 : if( bHasYAxisMajorGrid )
1969 [ # # ][ # # ]: 0 : xMajorGrid.set( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY );
[ # # ]
1970 [ # # ]: 0 : if( bHasYAxisMinorGrid )
1971 [ # # ][ # # ]: 0 : xMinorGrid.set( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY );
[ # # ]
1972 : :
1973 : 0 : nAxisType = XML_valAx;
1974 : : // FIXME: axPos, need to check axis direction
1975 : 0 : sAxPos = "l";
1976 : 0 : break;
1977 : : }
1978 : : case AXIS_PRIMARY_Z:
1979 : : {
1980 [ # # ]: 0 : Reference< ::com::sun::star::chart::XAxisZSupplier > xAxisZSupp( mxDiagram, uno::UNO_QUERY );
1981 [ # # ]: 0 : if( xAxisZSupp.is())
1982 [ # # ][ # # ]: 0 : xAxisProp = xAxisZSupp->getZAxis();
[ # # ]
1983 [ # # ]: 0 : if( bHasZAxisTitle )
1984 [ # # ][ # # ]: 0 : xAxisTitle.set( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY );
[ # # ]
1985 [ # # ]: 0 : if( bHasZAxisMajorGrid )
1986 [ # # ][ # # ]: 0 : xMajorGrid.set( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY );
[ # # ]
1987 [ # # ]: 0 : if( bHasZAxisMinorGrid )
1988 [ # # ][ # # ]: 0 : xMinorGrid.set( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY );
[ # # ]
1989 : :
1990 [ # # ]: 0 : sal_Int32 eChartType = getChartType( );
1991 [ # # ][ # # ]: 0 : if( (eChartType == chart::TYPEID_SCATTER)
1992 : : || (eChartType == chart::TYPEID_BUBBLE) )
1993 : 0 : nAxisType = XML_valAx;
1994 [ # # ]: 0 : else if( eChartType == chart::TYPEID_STOCK )
1995 : 0 : nAxisType = XML_dateAx;
1996 : : // FIXME: axPos, need to check axis direction
1997 : 0 : sAxPos = "b";
1998 : 0 : break;
1999 : : }
2000 : : case AXIS_SECONDARY_Y:
2001 : : {
2002 [ # # ]: 0 : Reference< ::com::sun::star::chart::XTwoAxisYSupplier > xAxisTwoYSupp( mxDiagram, uno::UNO_QUERY );
2003 [ # # ]: 0 : if( xAxisTwoYSupp.is())
2004 [ # # ][ # # ]: 0 : xAxisProp = xAxisTwoYSupp->getSecondaryYAxis();
[ # # ]
2005 [ # # ]: 0 : if( bHasSecondaryYAxisTitle )
2006 : : {
2007 [ # # ]: 0 : Reference< ::com::sun::star::chart::XSecondAxisTitleSupplier > xAxisSupp( mxDiagram, uno::UNO_QUERY );
2008 [ # # ][ # # ]: 0 : xAxisTitle.set( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY );
[ # # ]
2009 : : }
2010 : :
2011 : 0 : nAxisType = XML_valAx;
2012 : : // FIXME: axPos, need to check axis direction
2013 : 0 : sAxPos = "l";
2014 : 0 : break;
2015 : : }
2016 : : }
2017 : :
2018 : :
2019 [ # # ]: 0 : _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, aAxisIdPair );
2020 : 0 : }
2021 : :
2022 : 0 : void ChartExport::_exportAxis(
2023 : : const Reference< XPropertySet >& xAxisProp,
2024 : : const Reference< drawing::XShape >& xAxisTitle,
2025 : : const Reference< XPropertySet >& xMajorGrid,
2026 : : const Reference< XPropertySet >& xMinorGrid,
2027 : : sal_Int32 nAxisType,
2028 : : const char* sAxisPos,
2029 : : AxisIdPair aAxisIdPair )
2030 : : {
2031 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2032 : : pFS->startElement( FSNS( XML_c, nAxisType ),
2033 [ # # ]: 0 : FSEND );
2034 : : pFS->singleElement( FSNS( XML_c, XML_axId ),
2035 : : XML_val, I32S( aAxisIdPair.nAxisId ),
2036 [ # # ]: 0 : FSEND );
2037 : :
2038 : : pFS->startElement( FSNS( XML_c, XML_scaling ),
2039 [ # # ]: 0 : FSEND );
2040 : : // orientation: minMax, maxMin
2041 : 0 : sal_Bool bReverseDirection = sal_False;
2042 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "ReverseDirection" ) ) )
[ # # ][ # # ]
2043 : 0 : mAny >>= bReverseDirection;
2044 : :
2045 [ # # ]: 0 : const char* orientation = bReverseDirection ? "maxMin":"minMax";
2046 : : pFS->singleElement( FSNS( XML_c, XML_orientation ),
2047 : : XML_val, orientation,
2048 [ # # ]: 0 : FSEND );
2049 : : // logBase, min, max
2050 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "Logarithmic" ) ) )
[ # # ][ # # ]
2051 : : {
2052 : 0 : sal_Bool bLogarithmic = sal_False;
2053 : 0 : mAny >>= bLogarithmic;
2054 [ # # ]: 0 : if( bLogarithmic )
2055 : : {
2056 : : // default value is 10?
2057 : 0 : sal_Int32 nLogBase = 10;
2058 : : pFS->singleElement( FSNS( XML_c, XML_logBase ),
2059 : : XML_val, I32S( nLogBase ),
2060 [ # # ]: 0 : FSEND );
2061 : : }
2062 : : }
2063 : 0 : sal_Bool bAutoMax = sal_False;
2064 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "AutoMax" ) ) )
[ # # ][ # # ]
2065 : 0 : mAny >>= bAutoMax;
2066 : :
2067 [ # # ][ # # ]: 0 : if( !bAutoMax && (GetProperty( xAxisProp, S( "Max" ) ) ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2068 : : {
2069 : 0 : double dMax = 0;
2070 : 0 : mAny >>= dMax;
2071 : : pFS->singleElement( FSNS( XML_c, XML_max ),
2072 : : XML_val, IS( dMax ),
2073 [ # # ]: 0 : FSEND );
2074 : : }
2075 : :
2076 : 0 : sal_Bool bAutoMin = sal_False;
2077 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "AutoMin" ) ) )
[ # # ][ # # ]
2078 : 0 : mAny >>= bAutoMin;
2079 : :
2080 [ # # ][ # # ]: 0 : if( !bAutoMin && (GetProperty( xAxisProp, S( "Min" ) ) ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2081 : : {
2082 : 0 : double dMin = 0;
2083 : 0 : mAny >>= dMin;
2084 : : pFS->singleElement( FSNS( XML_c, XML_min ),
2085 : : XML_val, IS( dMin ),
2086 [ # # ]: 0 : FSEND );
2087 : : }
2088 : :
2089 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_scaling ) );
2090 : :
2091 : : // title
2092 [ # # ]: 0 : if( xAxisTitle.is() )
2093 [ # # ]: 0 : exportTitle( xAxisTitle );
2094 : :
2095 : 0 : sal_Bool bVisible = sal_True;
2096 [ # # ]: 0 : if( xAxisProp.is() )
2097 : : {
2098 [ # # ]: 0 : xAxisProp->getPropertyValue(
2099 [ # # ]: 0 : OUString ("Visible")) >>= bVisible;
2100 : : }
2101 : :
2102 [ # # ]: 0 : if( !bVisible )
2103 : : {
2104 : : // other value?
2105 : : pFS->singleElement( FSNS( XML_c, XML_delete ),
2106 : : XML_val, "1",
2107 [ # # ]: 0 : FSEND );
2108 : : }
2109 : :
2110 : : // FIXME: axPos, need to check the property "ReverseDirection"
2111 : : pFS->singleElement( FSNS( XML_c, XML_axPos ),
2112 : : XML_val, sAxisPos,
2113 [ # # ]: 0 : FSEND );
2114 : : // major grid line
2115 [ # # ]: 0 : if( xMajorGrid.is())
2116 : : {
2117 : : pFS->startElement( FSNS( XML_c, XML_majorGridlines ),
2118 [ # # ]: 0 : FSEND );
2119 [ # # ]: 0 : exportShapeProps( xMajorGrid );
2120 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_majorGridlines ) );
2121 : : }
2122 : :
2123 : : // minor grid line
2124 [ # # ]: 0 : if( xMinorGrid.is())
2125 : : {
2126 : : pFS->startElement( FSNS( XML_c, XML_minorGridlines ),
2127 [ # # ]: 0 : FSEND );
2128 [ # # ]: 0 : exportShapeProps( xMajorGrid );
2129 [ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_minorGridlines ) );
2130 : : }
2131 : :
2132 : : // majorTickMark
2133 : 0 : sal_Int32 nValue = 0;
2134 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "Marks" ) ) )
[ # # ][ # # ]
2135 : : {
2136 : 0 : mAny >>= nValue;
2137 : 0 : sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER;
2138 : 0 : sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER;
2139 : 0 : const char* majorTickMark = NULL;
2140 [ # # ][ # # ]: 0 : if( bInner && bOuter )
2141 : 0 : majorTickMark = "cross";
2142 [ # # ]: 0 : else if( bInner )
2143 : 0 : majorTickMark = "in";
2144 [ # # ]: 0 : else if( bOuter )
2145 : 0 : majorTickMark = "out";
2146 : : else
2147 : 0 : majorTickMark = "none";
2148 : : pFS->singleElement( FSNS( XML_c, XML_majorTickMark ),
2149 : : XML_val, majorTickMark,
2150 [ # # ]: 0 : FSEND );
2151 : : }
2152 : : // minorTickMark
2153 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "HelpMarks" ) ) )
[ # # ][ # # ]
2154 : : {
2155 : 0 : mAny >>= nValue;
2156 : 0 : sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER;
2157 : 0 : sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER;
2158 : 0 : const char* minorTickMark = NULL;
2159 [ # # ][ # # ]: 0 : if( bInner && bOuter )
2160 : 0 : minorTickMark = "cross";
2161 [ # # ]: 0 : else if( bInner )
2162 : 0 : minorTickMark = "in";
2163 [ # # ]: 0 : else if( bOuter )
2164 : 0 : minorTickMark = "out";
2165 : : else
2166 : 0 : minorTickMark = "none";
2167 : : pFS->singleElement( FSNS( XML_c, XML_minorTickMark ),
2168 : : XML_val, minorTickMark,
2169 [ # # ]: 0 : FSEND );
2170 : : }
2171 : : // tickLblPos
2172 : 0 : const char* sTickLblPos = NULL;
2173 : 0 : sal_Bool bDisplayLabel = sal_True;
2174 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "DisplayLabels" ) ) )
[ # # ][ # # ]
2175 : 0 : mAny >>= bDisplayLabel;
2176 [ # # ][ # # ]: 0 : if( bDisplayLabel && (GetProperty( xAxisProp, S( "LabelPosition" ) ) ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2177 : : {
2178 : 0 : ::com::sun::star::chart::ChartAxisLabelPosition eLabelPosition = ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS;
2179 [ # # ]: 0 : mAny >>= eLabelPosition;
2180 [ # # # # ]: 0 : switch( eLabelPosition )
2181 : : {
2182 : : case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS:
2183 : : case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE:
2184 : 0 : sTickLblPos = "nextTo";
2185 : 0 : break;
2186 : : case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START:
2187 : 0 : sTickLblPos = "low";
2188 : 0 : break;
2189 : : case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END:
2190 : 0 : sTickLblPos = "high";
2191 : 0 : break;
2192 : : default:
2193 : 0 : sTickLblPos = "nextTo";
2194 : 0 : break;
2195 : : }
2196 : : }
2197 : : else
2198 : : {
2199 : 0 : sTickLblPos = "none";
2200 : : }
2201 : : pFS->singleElement( FSNS( XML_c, XML_tickLblPos ),
2202 : : XML_val, sTickLblPos,
2203 [ # # ]: 0 : FSEND );
2204 : :
2205 : : pFS->singleElement( FSNS( XML_c, XML_crossAx ),
2206 : : XML_val, I32S( aAxisIdPair.nCrossAx ),
2207 [ # # ]: 0 : FSEND );
2208 : :
2209 : : // crosses & crossesAt
2210 : 0 : sal_Bool bCrossesValue = sal_False;
2211 : 0 : const char* sCrosses = NULL;
2212 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "CrossoverPosition" ) ) )
[ # # ][ # # ]
2213 : : {
2214 : 0 : ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
2215 [ # # ]: 0 : mAny >>= ePosition;
2216 [ # # # # ]: 0 : switch( ePosition )
2217 : : {
2218 : : case ::com::sun::star::chart::ChartAxisPosition_START:
2219 : 0 : sCrosses = "min";
2220 : 0 : break;
2221 : : case ::com::sun::star::chart::ChartAxisPosition_END:
2222 : 0 : sCrosses = "max";
2223 : 0 : break;
2224 : : case ::com::sun::star::chart::ChartAxisPosition_ZERO:
2225 : 0 : sCrosses = "autoZero";
2226 : 0 : break;
2227 : : default:
2228 : 0 : bCrossesValue = sal_True;
2229 : 0 : break;
2230 : : }
2231 : : }
2232 : :
2233 [ # # ][ # # ]: 0 : if( bCrossesValue && GetProperty( xAxisProp, S("CrossoverValue" ) ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2234 : : {
2235 : 0 : double dValue = 0;
2236 : 0 : mAny >>= dValue;
2237 : : pFS->singleElement( FSNS( XML_c, XML_crossesAt ),
2238 : : XML_val, IS( dValue ),
2239 [ # # ]: 0 : FSEND );
2240 : : }
2241 : : else
2242 : : {
2243 : : pFS->singleElement( FSNS( XML_c, XML_crosses ),
2244 : : XML_val, sCrosses,
2245 [ # # ]: 0 : FSEND );
2246 : : }
2247 : :
2248 [ # # ]: 0 : if( nAxisType == XML_catAx )
2249 : : {
2250 : : // FIXME: seems not support? lblAlgn
2251 : 0 : const char* sLblAlgn = "ctr";
2252 : : pFS->singleElement( FSNS( XML_c, XML_lblAlgn ),
2253 : : XML_val, sLblAlgn,
2254 [ # # ]: 0 : FSEND );
2255 : : }
2256 [ # # ][ # # ]: 0 : if( ( nAxisType == XML_catAx )
2257 : : || ( nAxisType == XML_dateAx ) )
2258 : : {
2259 : : // FIXME: seems not support? use default value,
2260 : 0 : const char* isAuto = "1";
2261 : : pFS->singleElement( FSNS( XML_c, XML_auto ),
2262 : : XML_val, isAuto,
2263 [ # # ]: 0 : FSEND );
2264 : :
2265 : : // FIXME: seems not support? lblOffset
2266 : 0 : sal_Int32 nLblOffset = 100;
2267 : : pFS->singleElement( FSNS( XML_c, XML_lblOffset ),
2268 : : XML_val, I32S( nLblOffset ),
2269 [ # # ]: 0 : FSEND );
2270 : : }
2271 : :
2272 : : // majorUnit
2273 : 0 : sal_Bool bAutoStepMain = sal_False;
2274 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "AutoStepMain" ) ) )
[ # # ][ # # ]
2275 : 0 : mAny >>= bAutoStepMain;
2276 : :
2277 [ # # ][ # # ]: 0 : if( !bAutoStepMain && (GetProperty( xAxisProp, S( "StepMain" ) ) ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2278 : : {
2279 : 0 : double dMajorUnit = 0;
2280 : 0 : mAny >>= dMajorUnit;
2281 : : pFS->singleElement( FSNS( XML_c, XML_majorUnit ),
2282 : : XML_val, IS( dMajorUnit ),
2283 [ # # ]: 0 : FSEND );
2284 : : }
2285 : : // minorUnit
2286 : 0 : sal_Bool bAutoStepHelp = sal_False;
2287 [ # # ][ # # ]: 0 : if(GetProperty( xAxisProp, S( "AutoStepHelp" ) ) )
[ # # ][ # # ]
2288 : 0 : mAny >>= bAutoStepHelp;
2289 : :
2290 [ # # ][ # # ]: 0 : if( !bAutoStepHelp && (GetProperty( xAxisProp, S( "StepHelp" ) ) ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2291 : : {
2292 : 0 : double dMinorUnit = 0;
2293 : 0 : mAny >>= dMinorUnit;
2294 : : pFS->singleElement( FSNS( XML_c, XML_minorUnit ),
2295 : : XML_val, IS( dMinorUnit ),
2296 [ # # ]: 0 : FSEND );
2297 : : }
2298 : :
2299 : : // shape properties
2300 [ # # ]: 0 : exportShapeProps( xAxisProp );
2301 : : // TODO: text properties
2302 : :
2303 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, nAxisType ) );
2304 : 0 : }
2305 : :
2306 : 0 : void ChartExport::exportDataPoints(
2307 : : const uno::Reference< beans::XPropertySet > & xSeriesProperties,
2308 : : sal_Int32 nSeriesLength )
2309 : : {
2310 [ # # ]: 0 : uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY );
2311 : 0 : bool bVaryColorsByPoint = false;
2312 [ # # ]: 0 : Sequence< sal_Int32 > aDataPointSeq;
2313 [ # # ]: 0 : if( xSeriesProperties.is())
2314 : : {
2315 [ # # ]: 0 : Any aAny = xSeriesProperties->getPropertyValue(
2316 [ # # ]: 0 : OUString( "AttributedDataPoints" ));
2317 [ # # ]: 0 : aAny >>= aDataPointSeq;
2318 [ # # ]: 0 : xSeriesProperties->getPropertyValue(
2319 [ # # ]: 0 : OUString( "VaryColorsByPoint" )) >>= bVaryColorsByPoint;
2320 : : }
2321 : :
2322 : 0 : const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
2323 : : sal_Int32 nElement;
2324 : 0 : Reference< chart2::XColorScheme > xColorScheme;
2325 [ # # ]: 0 : if( mxNewDiagram.is())
2326 [ # # ][ # # ]: 0 : xColorScheme.set( mxNewDiagram->getDefaultColorScheme());
[ # # ]
2327 : :
2328 [ # # ][ # # ]: 0 : if( bVaryColorsByPoint && xColorScheme.is() )
[ # # ]
2329 : : {
2330 [ # # ]: 0 : ::std::set< sal_Int32 > aAttrPointSet;
2331 : 0 : ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(),
2332 [ # # # # ]: 0 : ::std::inserter( aAttrPointSet, aAttrPointSet.begin()));
2333 : 0 : const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end());
2334 [ # # ]: 0 : for( nElement = 0; nElement < nSeriesLength; ++nElement )
2335 : : {
2336 : 0 : uno::Reference< beans::XPropertySet > xPropSet;
2337 [ # # ][ # # ]: 0 : if( aAttrPointSet.find( nElement ) != aEndIt )
[ # # ]
2338 : : {
2339 : : try
2340 : : {
2341 : : xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
2342 [ # # ][ # # ]: 0 : xSeries, nElement, getModel() );
[ # # ][ # # ]
2343 : : }
2344 [ # # ]: 0 : catch( const uno::Exception & rEx )
2345 : : {
2346 : : (void)rEx; // avoid warning for pro build
2347 : : OSL_TRACE( "Exception caught during Export of data point: %s",
2348 : : rtl::OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
2349 : : }
2350 : : }
2351 : : else
2352 : : {
2353 : : // property set only containing the color
2354 [ # # ][ # # ]: 0 : xPropSet.set( new ColorPropertySet( xColorScheme->getColorByIndex( nElement )));
[ # # ][ # # ]
[ # # ]
2355 : : }
2356 : :
2357 [ # # ]: 0 : if( xPropSet.is() )
2358 : : {
2359 : : OSL_TRACE("ChartExport::exportDataPoints -- writer data points ");
2360 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2361 : : pFS->startElement( FSNS( XML_c, XML_dPt ),
2362 [ # # ]: 0 : FSEND );
2363 : : pFS->singleElement( FSNS( XML_c, XML_idx ),
2364 : : XML_val, I32S(nElement),
2365 [ # # ]: 0 : FSEND );
2366 [ # # ]: 0 : exportShapeProps( xPropSet );
2367 : :
2368 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_dPt ) );
2369 : : }
2370 : 0 : }
2371 [ # # ]: 0 : }
2372 : 0 : }
2373 : :
2374 : 0 : void ChartExport::exportAxesId( sal_Int32 nAttachedAxis )
2375 : : {
2376 : 0 : sal_Int32 nAxisIdx = lcl_generateRandomValue();
2377 : 0 : sal_Int32 nAxisIdy = lcl_generateRandomValue();
2378 [ # # ]: 0 : maAxes.push_back( AxisIdPair( AXIS_PRIMARY_X, nAxisIdx, nAxisIdy ) );
2379 [ # # ]: 0 : maAxes.push_back( AxisIdPair( nAttachedAxis, nAxisIdy, nAxisIdx ) );
2380 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2381 : : pFS->singleElement( FSNS( XML_c, XML_axId ),
2382 : : XML_val, I32S( nAxisIdx ),
2383 [ # # ]: 0 : FSEND );
2384 : : pFS->singleElement( FSNS( XML_c, XML_axId ),
2385 : : XML_val, I32S( nAxisIdy ),
2386 [ # # ]: 0 : FSEND );
2387 [ # # ]: 0 : if( mbHasZAxis )
2388 : : {
2389 : 0 : sal_Int32 nAxisIdz = 0;
2390 [ # # ][ # # ]: 0 : if( isDeep3dChart() )
2391 : : {
2392 : 0 : nAxisIdz = lcl_generateRandomValue();
2393 [ # # ]: 0 : maAxes.push_back( AxisIdPair( AXIS_PRIMARY_Z, nAxisIdz, nAxisIdy ) );
2394 : : }
2395 : : pFS->singleElement( FSNS( XML_c, XML_axId ),
2396 : : XML_val, I32S( nAxisIdz ),
2397 [ # # ]: 0 : FSEND );
2398 [ # # ]: 0 : }
2399 : 0 : }
2400 : :
2401 : 0 : void ChartExport::exportGrouping( sal_Bool isBar )
2402 : : {
2403 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2404 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
2405 : : // grouping
2406 : 0 : sal_Bool bStacked = sal_False;
2407 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "Stacked" ) ) )
[ # # ][ # # ]
2408 : 0 : mAny >>= bStacked;
2409 : 0 : sal_Bool bPercentage = sal_False;
2410 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "Percent" ) ) )
[ # # ][ # # ]
2411 : 0 : mAny >>= bPercentage;
2412 : :
2413 : 0 : const char* grouping = NULL;
2414 [ # # ]: 0 : if( bStacked )
2415 : 0 : grouping = "stacked";
2416 [ # # ]: 0 : else if( bPercentage )
2417 : 0 : grouping = "percentStacked";
2418 : : else
2419 : : {
2420 [ # # ][ # # ]: 0 : if( isBar && !isDeep3dChart() )
[ # # ][ # # ]
2421 : 0 : grouping = "clustered";
2422 : : else
2423 : 0 : grouping = "standard";
2424 : : }
2425 : : pFS->singleElement( FSNS( XML_c, XML_grouping ),
2426 : : XML_val, grouping,
2427 [ # # ][ # # ]: 0 : FSEND );
2428 : 0 : }
2429 : :
2430 : 0 : void ChartExport::exportMarker()
2431 : : {
2432 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2433 : : pFS->startElement( FSNS( XML_c, XML_marker ),
2434 [ # # ]: 0 : FSEND );
2435 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY );
2436 : 0 : sal_Int32 nSymbolType = ::com::sun::star::chart::ChartSymbolType::NONE;
2437 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "SymbolType" ) ) )
[ # # ][ # # ]
2438 : 0 : mAny >>= nSymbolType;
2439 : : // TODO: more properties support for marker
2440 [ # # ]: 0 : if( nSymbolType == ::com::sun::star::chart::ChartSymbolType::NONE )
2441 : : {
2442 : : pFS->singleElement( FSNS( XML_c, XML_symbol ),
2443 : : XML_val, "none",
2444 [ # # ]: 0 : FSEND );
2445 : : }
2446 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_marker ) );
2447 : 0 : }
2448 : :
2449 : 0 : void ChartExport::exportSmooth()
2450 : : {
2451 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2452 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY );
2453 : 0 : sal_Int32 nSplineType = 0;
2454 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "SplineType" ) ) )
[ # # ][ # # ]
2455 : 0 : mAny >>= nSplineType;
2456 [ # # ]: 0 : if( nSplineType != 0 )
2457 : : {
2458 : : pFS->singleElement( FSNS( XML_c, XML_smooth ),
2459 : : XML_val, "1",
2460 [ # # ]: 0 : FSEND );
2461 [ # # ]: 0 : }
2462 : 0 : }
2463 : :
2464 : 0 : void ChartExport::exportFirstSliceAng( )
2465 : : {
2466 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2467 : 0 : sal_Int32 nStartingAngle = 0;
2468 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
2469 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "StartingAngle" ) ) )
[ # # ][ # # ]
2470 : 0 : mAny >>= nStartingAngle;
2471 : :
2472 : : // convert to ooxml angle
2473 : 0 : nStartingAngle = (450 - nStartingAngle ) % 360;
2474 : : pFS->singleElement( FSNS( XML_c, XML_firstSliceAng ),
2475 : : XML_val, I32S( nStartingAngle ),
2476 [ # # ][ # # ]: 0 : FSEND );
2477 : 0 : }
2478 : :
2479 : 0 : void ChartExport::exportView3D()
2480 : : {
2481 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
2482 [ # # ]: 0 : if( !xPropSet.is() )
2483 : 0 : return;
2484 [ # # ]: 0 : FSHelperPtr pFS = GetFS();
2485 : : pFS->startElement( FSNS( XML_c, XML_view3D ),
2486 [ # # ]: 0 : FSEND );
2487 : : // rotX
2488 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "RotationHorizontal" ) ) )
[ # # ][ # # ]
2489 : : {
2490 : 0 : sal_Int32 nRotationX = 0;
2491 : 0 : mAny >>= nRotationX;
2492 : : // X rotation (map Chart2 [-179,180] to OOXML [0..359])
2493 [ # # ]: 0 : if( nRotationX < 0 )
2494 : 0 : nRotationX += 360;
2495 : : pFS->singleElement( FSNS( XML_c, XML_rotX ),
2496 : : XML_val, I32S( nRotationX ),
2497 [ # # ]: 0 : FSEND );
2498 : : }
2499 : : // rotY
2500 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "RotationVertical" ) ) )
[ # # ][ # # ]
2501 : : {
2502 : 0 : sal_Int32 nRotationY = 0;
2503 : 0 : mAny >>= nRotationY;
2504 : : // Y rotation (map Chart2 [-179,180] to OOXML [0..359])
2505 [ # # ]: 0 : if( nRotationY < 0 )
2506 : 0 : nRotationY += 360;
2507 : : pFS->singleElement( FSNS( XML_c, XML_rotY ),
2508 : : XML_val, I32S( nRotationY ),
2509 [ # # ]: 0 : FSEND );
2510 : : }
2511 : : // perspective
2512 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "Perspective" ) ) )
[ # # ][ # # ]
2513 : : {
2514 : 0 : sal_Int32 nPerspective = 0;
2515 : 0 : mAny >>= nPerspective;
2516 : : // map Chart2 [0,100] to OOXML [0..200]
2517 : 0 : nPerspective *= 2;
2518 : : pFS->singleElement( FSNS( XML_c, XML_perspective ),
2519 : : XML_val, I32S( nPerspective ),
2520 [ # # ]: 0 : FSEND );
2521 : : }
2522 : : // rAngAx
2523 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "RightAngledAxes" ) ) )
[ # # ][ # # ]
2524 : : {
2525 : 0 : sal_Bool bRightAngled = sal_False;
2526 : 0 : mAny >>= bRightAngled;
2527 [ # # ]: 0 : const char* sRightAngled = bRightAngled ? "1":"0";
2528 : : pFS->singleElement( FSNS( XML_c, XML_rAngAx ),
2529 : : XML_val, sRightAngled,
2530 [ # # ]: 0 : FSEND );
2531 : : }
2532 [ # # ][ # # ]: 0 : pFS->endElement( FSNS( XML_c, XML_view3D ) );
[ # # ]
2533 : : }
2534 : :
2535 : 0 : sal_Bool ChartExport::isDeep3dChart()
2536 : : {
2537 : 0 : sal_Bool isDeep = sal_False;
2538 [ # # ]: 0 : if( mbIs3DChart )
2539 : : {
2540 [ # # ]: 0 : Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
2541 [ # # ][ # # ]: 0 : if( GetProperty( xPropSet, S( "Deep" ) ) )
[ # # ][ # # ]
2542 : 0 : mAny >>= isDeep;
2543 : : }
2544 : 0 : return isDeep;
2545 : : }
2546 : :
2547 : : }// drawingml
2548 [ + - ][ + - ]: 285 : }// oox
2549 : :
2550 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|