Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <sax/tools/converter.hxx>
31 : :
32 : : #include <xmloff/xmlprmap.hxx>
33 : :
34 : : #include "SchXMLExport.hxx"
35 : : #include "XMLChartPropertySetMapper.hxx"
36 : : #include "SchXMLSeriesHelper.hxx"
37 : : #include "ColorPropertySet.hxx"
38 : : #include "SchXMLTools.hxx"
39 : : #include "SchXMLEnumConverter.hxx"
40 : :
41 : : #include <tools/debug.hxx>
42 : : #include <rtl/logfile.hxx>
43 : : #include <comphelper/processfactory.hxx>
44 : : #include <tools/globname.hxx>
45 : : #include <sot/clsids.hxx>
46 : :
47 : : #include <xmloff/nmspmap.hxx>
48 : : #include "xmloff/xmlnmspe.hxx"
49 : : #include <xmloff/xmltoken.hxx>
50 : : #include <xmloff/families.hxx>
51 : : #include <xmloff/xmlaustp.hxx>
52 : : #include <xmloff/xmluconv.hxx>
53 : : #include <xmloff/xmlmetae.hxx>
54 : : #include "xexptran.hxx"
55 : : #include <rtl/math.hxx>
56 : : // header for any2enum
57 : : #include <comphelper/extract.hxx>
58 : :
59 : : #include <list>
60 : : #include <typeinfo>
61 : : #include <algorithm>
62 : :
63 : : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
64 : : #include <com/sun/star/lang/XServiceInfo.hpp>
65 : : #include <com/sun/star/lang/XServiceName.hpp>
66 : : #include <com/sun/star/beans/XPropertySet.hpp>
67 : : #include <com/sun/star/uno/XComponentContext.hpp>
68 : : #include <com/sun/star/util/XRefreshable.hpp>
69 : :
70 : : #include <com/sun/star/chart/XAxis.hpp>
71 : : #include <com/sun/star/chart/XAxisSupplier.hpp>
72 : : #include <com/sun/star/chart/XChartDocument.hpp>
73 : : #include <com/sun/star/chart/ChartLegendPosition.hpp>
74 : : #include <com/sun/star/chart/ChartLegendExpansion.hpp>
75 : : #include <com/sun/star/chart/ChartDataRowSource.hpp>
76 : : #include <com/sun/star/chart/ChartAxisAssign.hpp>
77 : : #include <com/sun/star/chart/ChartAxisType.hpp>
78 : : #include <com/sun/star/chart/TimeIncrement.hpp>
79 : : #include <com/sun/star/chart/TimeInterval.hpp>
80 : : #include <com/sun/star/chart/TimeUnit.hpp>
81 : : #include <com/sun/star/chart/ChartSeriesAddress.hpp>
82 : : #include <com/sun/star/chart/X3DDisplay.hpp>
83 : : #include <com/sun/star/chart/XStatisticDisplay.hpp>
84 : : #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
85 : : #include <com/sun/star/chart/XDiagramPositioning.hpp>
86 : :
87 : : #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
88 : : #include <com/sun/star/chart2/AxisType.hpp>
89 : : #include <com/sun/star/chart2/XChartDocument.hpp>
90 : : #include <com/sun/star/chart2/XDiagram.hpp>
91 : : #include <com/sun/star/chart2/RelativePosition.hpp>
92 : : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
93 : : #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
94 : : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
95 : : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
96 : : #include <com/sun/star/chart2/data/XDataSource.hpp>
97 : : #include <com/sun/star/chart2/data/XDataSink.hpp>
98 : : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
99 : : #include <com/sun/star/chart2/data/XDataProvider.hpp>
100 : : #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
101 : : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
102 : : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
103 : : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
104 : :
105 : : #include <com/sun/star/util/MeasureUnit.hpp>
106 : : #include <com/sun/star/util/XStringMapping.hpp>
107 : : #include <com/sun/star/drawing/HomogenMatrix.hpp>
108 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
109 : : #include <com/sun/star/drawing/XShapes.hpp>
110 : : #include <com/sun/star/embed/Aspects.hpp>
111 : : #include <com/sun/star/embed/XVisualObject.hpp>
112 : : #include <com/sun/star/container/XChild.hpp>
113 : :
114 : :
115 : : #include "MultiPropertySetHandler.hxx"
116 : : #include "PropertyMap.hxx"
117 : :
118 : : using namespace com::sun::star;
119 : : using namespace ::xmloff::token;
120 : :
121 : : using ::rtl::OUString;
122 : : using ::rtl::OUStringBuffer;
123 : : using ::rtl::OUStringToOString;
124 : : using namespace ::com::sun::star;
125 : : using ::com::sun::star::uno::Sequence;
126 : : using ::com::sun::star::uno::Reference;
127 : : using ::com::sun::star::uno::Any;
128 : : using ::std::vector;
129 : :
130 : : // ========================================
131 : : // class SchXMLExportHelper_Impl
132 : : // ========================================
133 : :
134 : : class SchXMLExportHelper_Impl
135 : : {
136 : : public:
137 : : // first: data sequence for label, second: data sequence for values.
138 : : typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >,
139 : : ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > > tLabelValuesDataPair;
140 : : typedef ::std::vector< tLabelValuesDataPair > tDataSequenceCont;
141 : :
142 : : public:
143 : : SchXMLExportHelper_Impl( SvXMLExport& rExport,
144 : : SvXMLAutoStylePoolP& rASPool );
145 : :
146 : : virtual ~SchXMLExportHelper_Impl();
147 : :
148 : : // auto-styles
149 : : /// parse chart and collect all auto-styles used in current pool
150 : : void collectAutoStyles( com::sun::star::uno::Reference<
151 : : com::sun::star::chart::XChartDocument > rChartDoc );
152 : :
153 : : /// write the styles collected into the current pool as <style:style> elements
154 : : void exportAutoStyles();
155 : :
156 : : /** export the <chart:chart> element corresponding to rChartDoc
157 : : if bIncludeTable is true, the chart data is exported as <table:table>
158 : : element (inside the chart element).
159 : :
160 : : Otherwise the external references stored in the chart document are used
161 : : for writing the corresponding attributes at series
162 : :
163 : : All attributes contained in xAttrList are written at the chart element,
164 : : which ist the outer element of a chart. So these attributes can easily
165 : : be parsed again by the container
166 : : */
167 : : void exportChart( com::sun::star::uno::Reference<
168 : : com::sun::star::chart::XChartDocument > rChartDoc,
169 : : sal_Bool bIncludeTable );
170 : :
171 : : UniReference< XMLPropertySetMapper > GetPropertySetMapper() const;
172 : :
173 : 0 : void SetChartRangeAddress( const ::rtl::OUString& rAddress )
174 : 0 : { msChartAddress = rAddress; }
175 : 0 : void SetTableNumberList( const ::rtl::OUString& rList )
176 : 0 : { msTableNumberList = rList; }
177 : :
178 : : void InitRangeSegmentationProperties(
179 : : const ::com::sun::star::uno::Reference<
180 : : ::com::sun::star::chart2::XChartDocument > & xChartDoc );
181 : :
182 : : ::com::sun::star::awt::Size getPageSize(
183 : : const ::com::sun::star::uno::Reference<
184 : : ::com::sun::star::chart2::XChartDocument > & xChartDoc ) const;
185 : :
186 : : /** first parseDocument: collect autostyles and store names in this queue
187 : : second parseDocument: export content and use names from this queue
188 : : */
189 : : ::std::queue< ::rtl::OUString > maAutoStyleNameQueue;
190 : : void CollectAutoStyle(
191 : : const std::vector< XMLPropertyState >& aStates );
192 : : void AddAutoStyleAttribute(
193 : : const std::vector< XMLPropertyState >& aStates );
194 : :
195 : 109 : SvXMLAutoStylePoolP& GetAutoStylePoolP()
196 : 109 : { return mrAutoStylePool; }
197 : :
198 : : /// if bExportContent is false the auto-styles are collected
199 : : void parseDocument( com::sun::star::uno::Reference<
200 : : com::sun::star::chart::XChartDocument >& rChartDoc,
201 : : sal_Bool bExportContent,
202 : : sal_Bool bIncludeTable = sal_False );
203 : : void exportTable();
204 : : void exportPlotArea(
205 : : com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > xDiagram,
206 : : com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > xNewDiagram,
207 : : const ::com::sun::star::awt::Size & rPageSize,
208 : : sal_Bool bExportContent,
209 : : sal_Bool bIncludeTable );
210 : : void exportCoordinateRegion( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram );
211 : : void exportAxes( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > & xDiagram,
212 : : const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram,
213 : : sal_Bool bExportContent );
214 : : void exportAxis( enum XMLTokenEnum eDimension, enum XMLTokenEnum eAxisName,
215 : : const Reference< beans::XPropertySet > xAxisProps, const Reference< chart2::XAxis >& xChart2Axis,
216 : : const OUString& rCategoriesRanges,
217 : : bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, bool bExportContent );
218 : : void exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent );
219 : : void exportDateScale( const Reference< beans::XPropertySet > xAxisProps );
220 : : void exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent );
221 : :
222 : : void exportSeries(
223 : : const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram,
224 : : const ::com::sun::star::awt::Size & rPageSize,
225 : : sal_Bool bExportContent,
226 : : sal_Bool bHasTwoYAxes );
227 : : void exportCandleStickSeries(
228 : : const ::com::sun::star::uno::Sequence<
229 : : ::com::sun::star::uno::Reference<
230 : : ::com::sun::star::chart2::XDataSeries > > & aSeriesSeq,
231 : : const ::com::sun::star::uno::Reference<
232 : : ::com::sun::star::chart2::XDiagram > & xDiagram,
233 : : sal_Bool bJapaneseCandleSticks,
234 : : sal_Bool bExportContent );
235 : : void exportDataPoints(
236 : : const ::com::sun::star::uno::Reference<
237 : : ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
238 : : sal_Int32 nSeriesLength,
239 : : const ::com::sun::star::uno::Reference<
240 : : ::com::sun::star::chart2::XDiagram > & xDiagram,
241 : : sal_Bool bExportContent );
242 : : void exportRegressionCurve(
243 : : const ::com::sun::star::uno::Reference<
244 : : ::com::sun::star::chart2::XDataSeries > & xSeries,
245 : : const ::com::sun::star::uno::Reference<
246 : : ::com::sun::star::beans::XPropertySet > & xSeriesProp,
247 : : const ::com::sun::star::awt::Size & rPageSize,
248 : : sal_Bool bExportContent );
249 : :
250 : : void exportErrorBar (
251 : : const ::com::sun::star::uno::Reference<beans::XPropertySet> &xSeriesProp, bool bYError,
252 : : bool bExportContent );
253 : :
254 : : /// add svg position as attribute for current element
255 : : void addPosition( const ::com::sun::star::awt::Point & rPosition );
256 : : void addPosition( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
257 : : /// add svg size as attribute for current element
258 : : void addSize( const ::com::sun::star::awt::Size & rSize, bool bIsOOoNamespace = false );
259 : : void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape, bool bIsOOoNamespace = false );
260 : : /// fills the member msString with the appropriate String (i.e. "A3")
261 : : void getCellAddress( sal_Int32 nCol, sal_Int32 nRow );
262 : : /// exports a string as a paragraph element
263 : : void exportText( const ::rtl::OUString& rText, bool bConvertTabsLFs = false );
264 : : void exportErrorBarRanges();
265 : :
266 : : private:
267 : : SchXMLExportHelper_Impl(SchXMLExportHelper_Impl &); // not defined
268 : : SchXMLExportHelper_Impl operator =(SchXMLExportHelper_Impl &); // not defined
269 : :
270 : : public:
271 : : SvXMLExport& mrExport;
272 : : SvXMLAutoStylePoolP& mrAutoStylePool;
273 : : UniReference< XMLPropertyHandlerFactory > mxPropertyHandlerFactory;
274 : : UniReference< XMLPropertySetMapper > mxPropertySetMapper;
275 : : UniReference< XMLChartExportPropertyMapper > mxExpPropMapper;
276 : :
277 : : rtl::OUString msTableName;
278 : : rtl::OUStringBuffer msStringBuffer;
279 : : rtl::OUString msString;
280 : :
281 : : // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
282 : : sal_Bool mbHasSeriesLabels;
283 : : sal_Bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false
284 : : sal_Bool mbRowSourceColumns;
285 : : rtl::OUString msChartAddress;
286 : : rtl::OUString msTableNumberList;
287 : : ::com::sun::star::uno::Sequence< sal_Int32 > maSequenceMapping;
288 : :
289 : : rtl::OUString msCLSID;
290 : :
291 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxAdditionalShapes;
292 : :
293 : : tDataSequenceCont m_aDataSequencesToExport;
294 : : rtl::OUString maCategoriesRange;
295 : : };
296 : :
297 : : namespace
298 : : {
299 : 27 : Reference< uno::XComponentContext > lcl_getComponentContext()
300 : : {
301 : 27 : Reference< uno::XComponentContext > xContext;
302 : : try
303 : : {
304 [ + - ][ + - ]: 27 : Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
305 [ + - ]: 27 : if( xFactProp.is())
306 [ + - ][ + - ]: 27 : xFactProp->getPropertyValue(OUString( "DefaultContext" )) >>= xContext;
[ + - ][ # # ]
307 : : }
308 [ # # ]: 0 : catch( const uno::Exception& )
309 : : {
310 : : }
311 : :
312 : 27 : return xContext;
313 : : }
314 : :
315 : 108 : class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
316 : : {
317 : : public:
318 : 54 : explicit lcl_MatchesRole( const OUString & aRole ) :
319 : 54 : m_aRole( aRole )
320 : 54 : {}
321 : :
322 : 222 : bool operator () ( const Reference< chart2::data::XLabeledDataSequence > & xSeq ) const
323 : : {
324 [ - + ]: 222 : if( !xSeq.is() )
325 : 0 : return false;
326 [ + - ][ + - ]: 222 : Reference< beans::XPropertySet > xProp( xSeq->getValues(), uno::UNO_QUERY );
[ + - ]
327 : 222 : OUString aRole;
328 : :
329 : 222 : return ( xProp.is() &&
330 [ + - ]: 222 : (xProp->getPropertyValue(
331 [ + - ][ + - ]: 444 : OUString( "Role" ) ) >>= aRole ) &&
[ + - ][ + - ]
[ # # # #
# # ]
332 [ - + ]: 666 : m_aRole.equals( aRole ));
[ + - + - ]
333 : : }
334 : :
335 : : private:
336 : : OUString m_aRole;
337 : : };
338 : :
339 : : template< typename T >
340 : 120 : void lcl_SequenceToVectorAppend( const Sequence< T > & rSource, ::std::vector< T > & rDestination )
341 : : {
342 : 120 : rDestination.reserve( rDestination.size() + rSource.getLength());
343 : 120 : ::std::copy( rSource.getConstArray(), rSource.getConstArray() + rSource.getLength(),
344 : : ::std::back_inserter( rDestination ));
345 : 120 : }
346 : :
347 : : template< typename T >
348 : 9 : void lcl_SequenceToVector( const Sequence< T > & rSource, ::std::vector< T > & rDestination )
349 : : {
350 : 9 : rDestination.clear();
351 : 9 : lcl_SequenceToVectorAppend( rSource, rDestination );
352 : 9 : }
353 : :
354 : 36 : Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram )
355 : : {
356 : 36 : Reference< chart2::data::XLabeledDataSequence > xResult;
357 : : try
358 : : {
359 : : Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
360 [ + - ]: 36 : xDiagram, uno::UNO_QUERY_THROW );
361 : : Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
362 [ + - ][ + - ]: 36 : xCooSysCnt->getCoordinateSystems());
363 [ + + ]: 72 : for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
364 : : {
365 [ + - ]: 36 : Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
366 : : OSL_ASSERT( xCooSys.is());
367 [ + - ][ + + ]: 108 : for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
[ + - ]
368 : : {
369 [ + - ][ + - ]: 72 : const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
370 [ + + ]: 144 : for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI)
371 : : {
372 [ + - ][ + - ]: 72 : Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN, nI );
373 : : OSL_ASSERT( xAxis.is());
374 [ + - ]: 72 : if( xAxis.is())
375 : : {
376 [ + - ][ + - ]: 72 : chart2::ScaleData aScaleData = xAxis->getScaleData();
377 [ + + ]: 72 : if( aScaleData.Categories.is())
378 : : {
379 [ + - ]: 72 : xResult.set( aScaleData.Categories );
380 : : break;
381 [ + - ][ + + ]: 72 : }
382 : : }
383 [ + + ]: 72 : }
384 : : }
385 [ + - ][ # # ]: 72 : }
386 : : }
387 [ # # ]: 0 : catch( const uno::Exception & ex )
388 : : {
389 : : (void)ex; // avoid warning for pro build
390 : : OSL_FAIL( OUStringToOString(
391 : : OUString( "Exception caught. Type: " ) +
392 : : OUString::createFromAscii( typeid( ex ).name()) +
393 : : OUString( ", Message: " ) +
394 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
395 : : }
396 : :
397 : 36 : return xResult;
398 : : }
399 : :
400 : 27 : Reference< chart2::data::XDataSource > lcl_createDataSource(
401 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
402 : : {
403 : 27 : Reference< chart2::data::XDataSink > xSink;
404 [ + - ]: 27 : Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
405 [ + - ]: 27 : if( xContext.is() )
406 : : xSink.set(
407 [ + - ][ + - ]: 54 : xContext->getServiceManager()->createInstanceWithContext(
[ + - ]
408 : : OUString( "com.sun.star.chart2.data.DataSource" ),
409 [ + - ][ + - ]: 27 : xContext ), uno::UNO_QUERY_THROW );
410 [ + - ]: 27 : if( xSink.is())
411 [ + - ][ + - ]: 27 : xSink->setData( aData );
412 : :
413 [ + - ]: 27 : return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY );
414 : : }
415 : :
416 : 27 : Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequences( const Reference< chart2::XChartDocument >& xChartDoc )
417 : : {
418 [ + - ]: 27 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aContainer;
419 [ + - ]: 27 : if( xChartDoc.is() )
420 : : {
421 [ + - ][ + - ]: 27 : Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
422 [ + - ]: 27 : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
423 [ + - ][ + - ]: 276 : for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
[ + + ]
424 : 138 : ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
425 : : {
426 [ + - ]: 111 : Reference< chart2::data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
427 [ - + ]: 111 : if( !xDataSource.is() )
428 : 0 : continue;
429 [ + - ][ + - ]: 111 : uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
430 [ + - ]: 111 : lcl_SequenceToVectorAppend( aDataSequences, aContainer );
431 [ + - ][ + - ]: 138 : }
432 : : }
433 : :
434 [ + - ]: 27 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aRet( aContainer.size());
435 [ + - ][ + - ]: 27 : ::std::copy( aContainer.begin(), aContainer.end(), aRet.getArray());
436 : :
437 : 27 : return aRet;
438 : : }
439 : :
440 : : Reference< chart2::data::XLabeledDataSequence >
441 : 27 : lcl_getDataSequenceByRole(
442 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aLabeledSeq,
443 : : const OUString & rRole )
444 : : {
445 : 27 : Reference< chart2::data::XLabeledDataSequence > aNoResult;
446 : :
447 : 27 : const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray();
448 : 27 : const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength();
449 : : const Reference< chart2::data::XLabeledDataSequence > * pMatch =
450 [ + - ]: 27 : ::std::find_if( pBegin, pEnd, lcl_MatchesRole( rRole ));
451 : :
452 [ - + ]: 27 : if( pMatch != pEnd )
453 : 0 : return *pMatch;
454 : :
455 : 27 : return aNoResult;
456 : : }
457 : :
458 : 27 : Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( const Reference< chart2::XChartDocument >& xChartDoc, sal_Bool& rOutSourceHasCategoryLabels )
459 : : {
460 [ + - ]: 27 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeqVector;
461 : :
462 : : //categories are always the first sequence
463 [ + - ][ + - ]: 27 : Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
464 [ + - ]: 27 : Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xDiagram ) );
465 [ + - ]: 27 : if( xCategories.is() )
466 [ + - ]: 27 : aLabeledSeqVector.push_back( xCategories );
467 : 27 : rOutSourceHasCategoryLabels = sal_Bool(xCategories.is());
468 : :
469 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector(
470 [ + - ]: 27 : lcl_getAllSeriesSequences( xChartDoc ) );
471 : :
472 : : //the first x-values is always the next sequence //todo ... other x-values get lost for old format
473 : : Reference< chart2::data::XLabeledDataSequence > xXValues(
474 [ + - ]: 27 : lcl_getDataSequenceByRole( aSeriesSeqVector, OUString( "values-x" ) ) );
475 [ - + ]: 27 : if( xXValues.is() )
476 [ # # ]: 0 : aLabeledSeqVector.push_back( xXValues );
477 : :
478 : : //add all other sequences now without x-values
479 : 27 : lcl_MatchesRole aHasXValues( OUString( "values-x" ) );
480 [ + + ]: 138 : for( sal_Int32 nN=0; nN<aSeriesSeqVector.getLength(); nN++ )
481 : : {
482 [ + - ][ + - ]: 111 : if( !aHasXValues( aSeriesSeqVector[nN] ) )
[ + - ]
483 [ + - ][ + - ]: 111 : aLabeledSeqVector.push_back( aSeriesSeqVector[nN] );
484 : : }
485 : :
486 [ + - ]: 27 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( aLabeledSeqVector.size() );
487 [ + - ][ + - ]: 27 : ::std::copy( aLabeledSeqVector.begin(), aLabeledSeqVector.end(), aSeq.getArray() );
488 : :
489 [ + - ][ + - ]: 27 : return lcl_createDataSource( aSeq );
[ + - ]
490 : : }
491 : :
492 : 0 : bool lcl_isSeriesAttachedToFirstAxis(
493 : : const Reference< chart2::XDataSeries > & xDataSeries )
494 : : {
495 : 0 : bool bResult=true;
496 : :
497 : : try
498 : : {
499 : 0 : sal_Int32 nAxisIndex = 0;
500 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW );
501 [ # # ]: 0 : if( xProp.is() )
502 [ # # ][ # # ]: 0 : xProp->getPropertyValue( OUString( "AttachedAxisIndex" ) ) >>= nAxisIndex;
503 [ # # ]: 0 : bResult = (0==nAxisIndex);
504 : : }
505 : 0 : catch( const uno::Exception & ex )
506 : : {
507 : : (void)ex; // avoid warning for pro build
508 : : OSL_FAIL( OUStringToOString(
509 : : OUString( "Exception caught. Type: " ) +
510 : : OUString::createFromAscii( typeid( ex ).name()) +
511 : : OUString( ", Message: " ) +
512 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
513 : : }
514 : :
515 : 0 : return bResult;
516 : : }
517 : :
518 : 83 : OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc )
519 : : {
520 : 83 : OUString aResult = rRange;
521 [ + - ]: 83 : if( !xDoc.is() )
522 : : return aResult;
523 : : Reference< chart2::data::XRangeXMLConversion > xConversion(
524 [ + - ][ + - ]: 83 : xDoc->getDataProvider(), uno::UNO_QUERY );
[ + - ]
525 [ + - ]: 83 : if( xConversion.is())
526 [ + - ][ + - ]: 83 : aResult = xConversion->convertRangeToXML( rRange );
527 : 83 : return aResult;
528 : : }
529 : :
530 : : typedef ::std::pair< OUString, OUString > tLabelAndValueRange;
531 : :
532 : 0 : tLabelAndValueRange lcl_getLabelAndValueRangeByRole(
533 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
534 : : const OUString & rRole,
535 : : const Reference< chart2::XChartDocument > & xDoc,
536 : : SchXMLExportHelper_Impl::tDataSequenceCont & rOutSequencesToExport )
537 : : {
538 : 0 : tLabelAndValueRange aResult;
539 : :
540 : : Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
541 [ # # ]: 0 : lcl_getDataSequenceByRole( aSeqCnt, rRole ));
542 [ # # ]: 0 : if( xLabeledSeq.is())
543 : : {
544 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel());
545 [ # # ]: 0 : if( xLabelSeq.is())
546 [ # # ][ # # ]: 0 : aResult.first = lcl_ConvertRange( xLabelSeq->getSourceRangeRepresentation(), xDoc );
[ # # ]
547 : :
548 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues());
549 [ # # ]: 0 : if( xValueSeq.is())
550 [ # # ][ # # ]: 0 : aResult.second = lcl_ConvertRange( xValueSeq->getSourceRangeRepresentation(), xDoc );
[ # # ]
551 : :
552 [ # # ][ # # ]: 0 : if( xLabelSeq.is() || xValueSeq.is())
[ # # ]
553 [ # # ][ # # ]: 0 : rOutSequencesToExport.push_back( SchXMLExportHelper_Impl::tLabelValuesDataPair( xLabelSeq, xValueSeq ));
[ # # ]
554 : : }
555 : :
556 : 0 : return aResult;
557 : : }
558 : :
559 : 0 : sal_Int32 lcl_getSequenceLengthByRole(
560 : : const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
561 : : const OUString & rRole )
562 : : {
563 : : Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
564 [ # # ]: 0 : lcl_getDataSequenceByRole( aSeqCnt, rRole ));
565 [ # # ]: 0 : if( xLabeledSeq.is())
566 : : {
567 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getValues());
568 [ # # ][ # # ]: 0 : return xSeq->getData().getLength();
[ # # ]
569 : : }
570 : 0 : return 0;
571 : : }
572 : :
573 : 37 : OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence )
574 : : {
575 : 37 : OUStringBuffer aResult;
576 : 37 : bool bPrecedeWithSpace = false;
577 [ + + ]: 74 : for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex )
578 : : {
579 [ + - ]: 37 : if( !rSequence[nIndex].isEmpty())
580 : : {
581 [ - + ]: 37 : if( bPrecedeWithSpace )
582 [ # # ]: 0 : aResult.append( static_cast< sal_Unicode >( ' ' ));
583 [ + - ]: 37 : aResult.append( rSequence[nIndex] );
584 : 37 : bPrecedeWithSpace = true;
585 : : }
586 : : }
587 [ + - ]: 37 : return aResult.makeStringAndClear();
588 : : }
589 : :
590 : 37 : void lcl_getLabelStringSequence( Sequence< OUString >& rOutLabels, const Reference< chart2::data::XDataSequence > & xLabelSeq )
591 : : {
592 [ + - ]: 37 : uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY );
593 [ + - ]: 37 : if( xTextualDataSequence.is())
594 : : {
595 [ + - ][ + - ]: 37 : rOutLabels = xTextualDataSequence->getTextualData();
[ + - ][ + - ]
596 : : }
597 [ # # ]: 0 : else if( xLabelSeq.is())
598 : : {
599 [ # # ][ # # ]: 0 : Sequence< uno::Any > aAnies( xLabelSeq->getData());
600 [ # # ]: 0 : rOutLabels.realloc( aAnies.getLength());
601 [ # # ]: 0 : for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
602 [ # # ][ # # ]: 0 : aAnies[i] >>= rOutLabels[i];
[ # # ]
603 : 37 : }
604 : 37 : }
605 : :
606 : 9 : sal_Int32 lcl_getMaxSequenceLength(
607 : : const SchXMLExportHelper_Impl::tDataSequenceCont & rContainer )
608 : : {
609 : 9 : sal_Int32 nResult = 0;
610 [ + - ][ + + ]: 92 : for( SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( rContainer.begin());
611 : 46 : aIt != rContainer.end(); ++aIt )
612 : : {
613 [ + - ]: 37 : if( aIt->second.is())
614 : : {
615 [ + - ][ + - ]: 37 : sal_Int32 nSeqLength = aIt->second->getData().getLength();
[ + - ]
616 [ + + ]: 37 : if( nSeqLength > nResult )
617 : 9 : nResult = nSeqLength;
618 : : }
619 : : }
620 : 9 : return nResult;
621 : : }
622 : :
623 : 0 : uno::Sequence< rtl::OUString > lcl_DataSequenceToStringSequence(
624 : : const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
625 : : {
626 [ # # ]: 0 : uno::Sequence< rtl::OUString > aResult;
627 [ # # ]: 0 : if(!xDataSequence.is())
628 : : return aResult;
629 : :
630 [ # # ]: 0 : uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
631 [ # # ]: 0 : if( xTextualDataSequence.is() )
632 : : {
633 [ # # ][ # # ]: 0 : aResult = xTextualDataSequence->getTextualData();
[ # # ][ # # ]
634 : : }
635 : : else
636 : : {
637 [ # # ][ # # ]: 0 : uno::Sequence< uno::Any > aValues = xDataSequence->getData();
638 [ # # ]: 0 : aResult.realloc(aValues.getLength());
639 : :
640 [ # # ]: 0 : for(sal_Int32 nN=aValues.getLength();nN--;)
641 [ # # ][ # # ]: 0 : aValues[nN] >>= aResult[nN];
[ # # ]
642 : : }
643 : :
644 : 0 : return aResult;
645 : : }
646 : 37 : ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< chart2::data::XDataSequence > & xSeq )
647 : : {
648 : 37 : double fNan = 0.0;
649 : 37 : ::rtl::math::setNan( &fNan );
650 [ + - ]: 37 : ::std::vector< double > aResult;
651 [ + - ]: 37 : if(!xSeq.is())
652 : : return aResult;
653 : :
654 [ + - ]: 37 : uno::Sequence< double > aValuesSequence;
655 [ + - ]: 37 : Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
656 [ + - ]: 37 : if( xNumSeq.is() )
657 : : {
658 [ + - ][ + - ]: 37 : aValuesSequence = xNumSeq->getNumericalData();
[ + - ][ + - ]
659 : : }
660 : : else
661 : : {
662 [ # # ][ # # ]: 0 : Sequence< uno::Any > aAnies( xSeq->getData() );
663 [ # # ]: 0 : aValuesSequence.realloc( aAnies.getLength() );
664 [ # # ]: 0 : for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
665 [ # # ][ # # ]: 0 : aAnies[i] >>= aValuesSequence[i];
[ # # ]
666 : : }
667 : :
668 : : //special handling for x-values (if x-values do point to categories, indices are used instead )
669 [ + - ]: 37 : Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY );
670 [ + - ]: 37 : if( xProp.is() )
671 : : {
672 : 37 : OUString aRole;
673 [ + - ][ + - ]: 37 : xProp->getPropertyValue( OUString( "Role" ) ) >>= aRole;
674 [ - + ]: 37 : if( aRole.match( OUString( "values-x" ) ) )
675 : : {
676 : : //lcl_clearIfNoValuesButTextIsContained - replace by indices if the values are not appropriate
677 : 0 : bool bHasValue=false;
678 : 0 : bool bHasText=false;
679 : 0 : sal_Int32 nCount = aValuesSequence.getLength();
680 [ # # ]: 0 : for( sal_Int32 j = 0; j < nCount; ++j )
681 : : {
682 [ # # ][ # # ]: 0 : if( !::rtl::math::isNan( aValuesSequence[j] ) )
683 : : {
684 : 0 : bHasValue=true;
685 : 0 : break;
686 : : }
687 : : }
688 [ # # ]: 0 : if(!bHasValue)
689 : : {
690 : : //no double value is countained
691 : : //is there any text?
692 [ # # ]: 0 : uno::Sequence< rtl::OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) );
693 : 0 : sal_Int32 nTextCount = aStrings.getLength();
694 [ # # ]: 0 : for( sal_Int32 j = 0; j < nTextCount; ++j )
695 : : {
696 [ # # ][ # # ]: 0 : if( !aStrings[j].isEmpty() )
697 : : {
698 : 0 : bHasText=true;
699 : 0 : break;
700 : : }
701 [ # # ]: 0 : }
702 : : }
703 [ # # ][ # # ]: 0 : if( !bHasValue && bHasText )
704 : : {
705 [ # # ]: 0 : for( sal_Int32 j = 0; j < nCount; ++j )
706 [ # # ]: 0 : aValuesSequence[j] = j+1;
707 : : }
708 : 37 : }
709 : : }
710 : :
711 : 37 : ::std::copy( aValuesSequence.getConstArray(), aValuesSequence.getConstArray() + aValuesSequence.getLength(),
712 [ + - + - ]: 74 : ::std::back_inserter( aResult ));
713 [ + - ]: 37 : return aResult;
714 : : }
715 : :
716 : 37 : bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
717 : : {
718 [ - + ]: 37 : if( !xDataSequence.is() )
719 : 0 : return false;
720 [ + - ]: 37 : uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
721 [ + - ]: 37 : if( xProp.is() )
722 : : {
723 [ + - ]: 37 : uno::Sequence< sal_Int32 > aHiddenValues;
724 : : try
725 : : {
726 [ + - ][ + + ]: 37 : xProp->getPropertyValue( OUString( "HiddenValues" ) ) >>= aHiddenValues;
[ + - ][ - + ]
727 [ + - ]: 13 : if( !aHiddenValues.getLength() )
728 : 13 : return true;
729 : : }
730 [ + - ]: 24 : catch( const uno::Exception& )
731 : : {
732 : 24 : return true;
733 [ + - ][ - + ]: 37 : }
734 : : }
735 [ # # ][ # # ]: 0 : if( xDataSequence->getData().getLength() )
[ # # ][ # # ]
736 : 0 : return true;
737 : 37 : return false;
738 : : }
739 : :
740 : : typedef vector< OUString > tStringVector;
741 : : typedef vector< double > tDoubleVector;
742 : : typedef vector< vector< OUString > > t2DStringVector;
743 : : typedef vector< vector< double > > t2DNumberContainer;
744 : :
745 [ + - ][ + - ]: 18 : struct lcl_TableData
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
746 : : {
747 : : t2DNumberContainer aDataInRows;
748 : : tStringVector aDataRangeRepresentations;
749 : :
750 : : tStringVector aColumnDescriptions;
751 : : tStringVector aColumnDescriptions_Ranges;
752 : :
753 : : tStringVector aRowDescriptions;
754 : : tStringVector aRowDescriptions_Ranges;
755 : :
756 : : Sequence< Sequence< uno::Any > > aComplexColumnDescriptions;//outer index is columns - inner index is level
757 : : Sequence< Sequence< uno::Any > > aComplexRowDescriptions;//outer index is rows - inner index is level
758 : :
759 : : ::std::vector< sal_Int32 > aHiddenColumns;
760 : : };
761 : :
762 : : // ::std::bind2nd( ::std::mem_fun_ref( &T::resize ), nSize ) does not work
763 : : template< class T >
764 : : struct lcl_resize
765 : : {
766 : 9 : lcl_resize( typename T::size_type nSize, typename T::value_type fDefaultValue ) : m_nSize( nSize ), m_fDefaultValue( fDefaultValue ) {}
767 : 35 : void operator()( T & t )
768 : 35 : { t.resize( m_nSize, m_fDefaultValue ); }
769 : : private:
770 : : typename T::size_type m_nSize;
771 : : typename T::value_type m_fDefaultValue;
772 : : };
773 : :
774 : :
775 : : typedef ::std::map< sal_Int32, SchXMLExportHelper_Impl::tLabelValuesDataPair >
776 : : lcl_DataSequenceMap;
777 : :
778 : : struct lcl_SequenceToMapElement :
779 : : public ::std::unary_function< lcl_DataSequenceMap::mapped_type, lcl_DataSequenceMap::value_type >
780 : : {
781 : 8 : lcl_SequenceToMapElement()
782 : 8 : {}
783 : 24 : result_type operator() ( const argument_type & rContent )
784 : : {
785 : 24 : sal_Int32 nIndex = -1;
786 [ + - ]: 24 : if( rContent.second.is()) //has values
787 : : {
788 [ + - ][ + - ]: 24 : OUString aRangeRep( rContent.second->getSourceRangeRepresentation());
789 : 24 : nIndex = aRangeRep.toInt32();
790 : : }
791 [ # # ]: 0 : else if( rContent.first.is()) //has labels
792 [ # # ][ # # ]: 0 : nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32();
793 [ + - ]: 24 : return result_type( nIndex, rContent );
794 : : }
795 : : };
796 : :
797 : 8 : void lcl_ReorderInternalSequencesAccordingToTheirRangeName(
798 : : SchXMLExportHelper_Impl::tDataSequenceCont & rInOutSequences )
799 : : {
800 [ + - ]: 8 : lcl_DataSequenceMap aIndexSequenceMap;
801 : : ::std::transform( rInOutSequences.begin(), rInOutSequences.end(),
802 : : ::std::inserter( aIndexSequenceMap, aIndexSequenceMap.begin()),
803 [ + - ][ + - ]: 8 : lcl_SequenceToMapElement());
804 : :
805 : 8 : rInOutSequences.clear();
806 : 8 : sal_Int32 nIndex = 0;
807 [ + + ]: 64 : for( lcl_DataSequenceMap::const_iterator aIt = aIndexSequenceMap.begin();
808 : 32 : aIt != aIndexSequenceMap.end(); ++aIt, ++nIndex )
809 : : {
810 [ - + ]: 24 : if( aIt->first < 0 )
811 : 0 : continue;
812 : : // fill empty columns
813 [ - + ]: 24 : for( ; nIndex < aIt->first; ++nIndex )
814 : : rInOutSequences.push_back(
815 [ # # ][ # # ]: 0 : SchXMLExportHelper_Impl::tDataSequenceCont::value_type( 0, 0 ));
[ # # ][ # # ]
[ # # ]
816 : : OSL_ASSERT( nIndex == aIt->first );
817 [ + - ]: 24 : rInOutSequences.push_back( aIt->second );
818 : 8 : }
819 : 8 : }
820 : :
821 : :
822 : 9 : lcl_TableData lcl_getDataForLocalTable(
823 : : const SchXMLExportHelper_Impl::tDataSequenceCont & aSequencesToExport,
824 : : const Reference< chart2::XAnyDescriptionAccess >& xAnyDescriptionAccess,
825 : : const OUString& rCategoriesRange,
826 : : bool bSeriesFromColumns,
827 : : const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion )
828 : : {
829 : 9 : lcl_TableData aResult;
830 : :
831 : : try
832 : : {
833 [ + - ]: 9 : Sequence< OUString > aSimpleCategories;
834 [ + - ]: 9 : if( xAnyDescriptionAccess.is() )
835 : : {
836 : : //categories
837 [ + - ]: 9 : if( bSeriesFromColumns )
838 : : {
839 [ + - ][ + - ]: 9 : aSimpleCategories = xAnyDescriptionAccess->getRowDescriptions();
[ + - ][ + - ]
840 [ + - ][ + - ]: 9 : aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions();
[ + - ][ + - ]
841 : : }
842 : : else
843 : : {
844 [ # # ][ # # ]: 0 : aSimpleCategories = xAnyDescriptionAccess->getColumnDescriptions();
[ # # ][ # # ]
845 [ # # ][ # # ]: 0 : aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions();
[ # # ][ # # ]
846 : : }
847 : : }
848 : :
849 : : //series values and series labels
850 : 9 : SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size();
851 : 9 : SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin());
852 : 9 : SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end());
853 : 9 : SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( aBegin );
854 : :
855 [ + - ]: 9 : size_t nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport ));
856 : 9 : size_t nCategoriesLength( aSimpleCategories.getLength() );
857 [ - + ]: 9 : if( nCategoriesLength > nMaxSequenceLength )
858 : : {
859 [ # # ]: 0 : aSimpleCategories.realloc(nMaxSequenceLength);//#i110617#
860 : 0 : nCategoriesLength = nMaxSequenceLength;
861 : : }
862 [ + - ]: 9 : size_t nNumColumns( bSeriesFromColumns ? nNumSequences : nMaxSequenceLength );
863 [ + - ]: 9 : size_t nNumRows( bSeriesFromColumns ? nMaxSequenceLength : nNumSequences );
864 : :
865 : : // resize data
866 [ + - ]: 9 : aResult.aDataInRows.resize( nNumRows );
867 : 9 : double fNan = 0.0;
868 : 9 : ::rtl::math::setNan( &fNan );
869 : : ::std::for_each( aResult.aDataInRows.begin(), aResult.aDataInRows.end(),
870 [ + - ]: 9 : lcl_resize< t2DNumberContainer::value_type >( nNumColumns, fNan ));
871 [ + - ]: 9 : aResult.aColumnDescriptions.resize( nNumColumns );
872 [ + - ]: 9 : aResult.aComplexColumnDescriptions.realloc( nNumColumns );
873 [ + - ]: 9 : aResult.aRowDescriptions.resize( nNumRows );
874 [ + - ]: 9 : aResult.aComplexRowDescriptions.realloc( nNumRows );
875 : :
876 [ + - ]: 9 : tStringVector& rCategories = bSeriesFromColumns ? aResult.aRowDescriptions : aResult.aColumnDescriptions;
877 [ + - ]: 9 : tStringVector& rLabels = bSeriesFromColumns ? aResult.aColumnDescriptions : aResult.aRowDescriptions;
878 : :
879 : : //categories
880 [ + - ]: 9 : lcl_SequenceToVector( aSimpleCategories, rCategories );
881 [ + - ]: 9 : if( !rCategoriesRange.isEmpty() )
882 : : {
883 : 9 : OUString aRange(rCategoriesRange);
884 [ + - ]: 9 : if( xRangeConversion.is())
885 [ + - ][ + - ]: 9 : aRange = xRangeConversion->convertRangeToXML( aRange );
886 [ + - ]: 9 : if( bSeriesFromColumns )
887 [ + - ]: 9 : aResult.aRowDescriptions_Ranges.push_back( aRange );
888 : : else
889 [ # # ]: 9 : aResult.aColumnDescriptions_Ranges.push_back( aRange );
890 : : }
891 : :
892 : : // iterate over all sequences
893 : 9 : size_t nSeqIdx = 0;
894 [ + - ]: 9 : Sequence< Sequence< OUString > > aComplexLabels(nNumSequences);
895 [ + - ][ + + ]: 46 : for( ; aIt != aEnd; ++aIt, ++nSeqIdx )
896 : : {
897 : 37 : OUString aRange;
898 [ + - ]: 37 : Sequence< OUString >& rCurrentComplexLabel = aComplexLabels[nSeqIdx];
899 [ + - ]: 37 : if( aIt->first.is())
900 : : {
901 [ + - ]: 37 : lcl_getLabelStringSequence( rCurrentComplexLabel, aIt->first );
902 [ + - ]: 37 : rLabels[nSeqIdx] = lcl_flattenStringSequence( rCurrentComplexLabel );
903 [ + - ][ + - ]: 37 : aRange = aIt->first->getSourceRangeRepresentation();
904 [ + - ]: 37 : if( xRangeConversion.is())
905 [ + - ][ + - ]: 37 : aRange = xRangeConversion->convertRangeToXML( aRange );
906 : : }
907 [ # # ]: 0 : else if( aIt->second.is())
908 : : {
909 [ # # ]: 0 : rCurrentComplexLabel.realloc(1);
910 [ # # ]: 0 : rLabels[nSeqIdx] = rCurrentComplexLabel[0] = lcl_flattenStringSequence(
911 [ # # ][ # # ]: 0 : aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE ));
[ # # ][ # # ]
912 : : }
913 [ + - ]: 37 : if( bSeriesFromColumns )
914 [ + - ]: 37 : aResult.aColumnDescriptions_Ranges.push_back( aRange );
915 : : else
916 [ # # ]: 0 : aResult.aRowDescriptions_Ranges.push_back( aRange );
917 : :
918 [ + - ]: 37 : ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( aIt->second ));
919 [ + - ]: 37 : if( bSeriesFromColumns )
920 : : {
921 : 37 : const sal_Int32 nSize( static_cast< sal_Int32 >( aNumbers.size()));
922 [ + + ]: 172 : for( sal_Int32 nIdx=0; nIdx<nSize; ++nIdx )
923 [ + - ][ + - ]: 135 : aResult.aDataInRows[nIdx][nSeqIdx] = aNumbers[nIdx];
[ + - ]
924 : : }
925 : : else
926 [ # # ][ # # ]: 0 : aResult.aDataInRows[nSeqIdx] = aNumbers;
927 : :
928 [ + - ]: 37 : if( aIt->second.is())
929 : : {
930 [ + - ][ + - ]: 37 : aRange = aIt->second->getSourceRangeRepresentation();
931 [ + - ]: 37 : if( xRangeConversion.is())
932 [ + - ][ + - ]: 37 : aRange = xRangeConversion->convertRangeToXML( aRange );
933 : : }
934 [ + - ]: 37 : aResult.aDataRangeRepresentations.push_back( aRange );
935 : :
936 : : //is column hidden?
937 [ + - ][ - + ]: 37 : if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) )
[ # # ][ # # ]
[ - + ]
938 [ # # ]: 0 : aResult.aHiddenColumns.push_back(nSeqIdx);
939 : 37 : }
940 [ + - ]: 9 : Sequence< Sequence< Any > >& rComplexAnyLabels = bSeriesFromColumns ? aResult.aComplexColumnDescriptions : aResult.aComplexRowDescriptions;//#i116544#
941 [ + - ]: 9 : rComplexAnyLabels.realloc(aComplexLabels.getLength());
942 [ + + ]: 46 : for( sal_Int32 nN=0; nN<aComplexLabels.getLength();nN++ )
943 : : {
944 [ + - ]: 37 : Sequence< OUString >& rSource = aComplexLabels[nN];
945 [ + - ]: 37 : Sequence< Any >& rTarget = rComplexAnyLabels[nN];
946 [ + - ]: 37 : rTarget.realloc( rSource.getLength() );
947 [ + + ]: 74 : for( sal_Int32 i=0; i<rSource.getLength(); i++ )
948 [ + - ][ + - ]: 37 : rTarget[i] = uno::makeAny( rSource[i] );
[ + - ]
949 [ + - ][ + - ]: 9 : }
[ # # ]
950 : : }
951 [ # # ]: 0 : catch( const uno::Exception & rEx )
952 : : {
953 : : (void)rEx; // avoid warning for pro build
954 : : OSL_TRACE( OUStringToOString( OUString(
955 : : "something went wrong during table data collection: " ) + rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
956 : : }
957 : :
958 : 9 : return aResult;
959 : : }
960 : :
961 : 184 : void lcl_exportNumberFormat( const OUString& rPropertyName, const Reference< beans::XPropertySet >& xPropSet,
962 : : SvXMLExport& rExport )
963 : : {
964 [ + - ]: 184 : if( xPropSet.is())
965 : : {
966 : 184 : sal_Int32 nNumberFormat = 0;
967 [ + - ][ + - ]: 184 : Any aNumAny = xPropSet->getPropertyValue( rPropertyName );
968 [ + + ][ + - ]: 184 : if( (aNumAny >>= nNumberFormat) && (nNumberFormat != -1) )
[ + + ]
969 [ + - ]: 184 : rExport.addDataStyle( nNumberFormat );
970 : : }
971 : 184 : }
972 : :
973 : : ::std::vector< Reference< chart2::data::XDataSequence > >
974 : 0 : lcl_getErrorBarSequences( const Reference< beans::XPropertySet > & xErrorBarProp )
975 : : {
976 [ # # ]: 0 : ::std::vector< Reference< chart2::data::XDataSequence > > aResult;
977 [ # # ]: 0 : Reference< chart2::data::XDataSource > xErrorBarDataSource( xErrorBarProp, uno::UNO_QUERY );
978 [ # # ]: 0 : if( !xErrorBarDataSource.is())
979 : : return aResult;
980 : :
981 : 0 : const OUString aRolePrefix( "error-bars-" );
982 : :
983 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
984 [ # # ][ # # ]: 0 : xErrorBarDataSource->getDataSequences());
985 [ # # ]: 0 : for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
986 : : {
987 : : try
988 : : {
989 [ # # ][ # # ]: 0 : if( aSequences[nI].is())
990 : : {
991 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues());
[ # # ]
992 [ # # ]: 0 : Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
993 : 0 : OUString aRole;
994 [ # # ][ # # : 0 : if( ( xSeqProp->getPropertyValue(
# # # # ]
995 [ # # ][ # # ]: 0 : OUString( "Role" )) >>= aRole ) &&
[ # # ][ # # ]
[ # # # #
# # ]
996 : 0 : aRole.match( aRolePrefix ))
997 : : {
998 [ # # ]: 0 : aResult.push_back( xSequence );
999 [ # # ]: 0 : }
1000 : : }
1001 : : }
1002 [ # # ]: 0 : catch( const uno::Exception & rEx )
1003 : : {
1004 : : #ifdef DBG_UTIL
1005 : : rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
1006 : : OSL_TRACE( "chart:exporting error bar ranges: %s", aBStr.getStr());
1007 : : #else
1008 : : (void)rEx; // avoid warning
1009 : : #endif
1010 : : }
1011 : : }
1012 : :
1013 [ # # ]: 0 : return aResult;
1014 : : }
1015 : :
1016 : 0 : bool lcl_exportDomainForThisSequence( const Reference< chart2::data::XDataSequence > xValues, rtl::OUString& rFirstRangeForThisDomainIndex, SvXMLExport& rExport )
1017 : : {
1018 : 0 : bool bDomainExported = false;
1019 [ # # ]: 0 : if( xValues.is())
1020 : : {
1021 [ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( rExport.GetModel(), uno::UNO_QUERY );
1022 [ # # ][ # # ]: 0 : OUString aRange( lcl_ConvertRange( xValues->getSourceRangeRepresentation(), xNewDoc ) );
[ # # ]
1023 : :
1024 : : //work around error in OOo 2.0 (problems with multiple series having a domain element)
1025 [ # # ][ # # ]: 0 : if( rFirstRangeForThisDomainIndex.isEmpty() || !aRange.equals(rFirstRangeForThisDomainIndex) )
[ # # ]
1026 : : {
1027 [ # # ]: 0 : rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aRange);
1028 [ # # ]: 0 : SvXMLElementExport aDomain( rExport, XML_NAMESPACE_CHART, XML_DOMAIN, sal_True, sal_True );
1029 [ # # ]: 0 : bDomainExported = true;
1030 : : }
1031 : :
1032 [ # # ]: 0 : if( rFirstRangeForThisDomainIndex.isEmpty() )
1033 : 0 : rFirstRangeForThisDomainIndex = aRange;
1034 : : }
1035 : 0 : return bDomainExported;
1036 : : }
1037 : :
1038 : : } // anonymous namespace
1039 : :
1040 : 370 : struct SchXMLDataPointStruct
1041 : : {
1042 : : OUString maStyleName;
1043 : : sal_Int32 mnRepeat;
1044 : :
1045 : 148 : SchXMLDataPointStruct() : mnRepeat( 1 ) {}
1046 : : };
1047 : :
1048 : : // ========================================
1049 : : // class SchXMLExportHelper
1050 : : // ========================================
1051 : :
1052 : 27 : SchXMLExportHelper::SchXMLExportHelper( SvXMLExport& rExport, SvXMLAutoStylePoolP& rASPool )
1053 [ + - ][ + - ]: 27 : : m_pImpl( new SchXMLExportHelper_Impl( rExport, rASPool ) )
1054 : : {
1055 : 27 : }
1056 : :
1057 : 27 : SchXMLExportHelper::~SchXMLExportHelper()
1058 : : {
1059 [ + - ][ + - ]: 27 : delete m_pImpl;
1060 [ - + ]: 27 : }
1061 : :
1062 : 0 : const OUString& SchXMLExportHelper::getChartCLSID()
1063 : : {
1064 : 0 : return m_pImpl->msCLSID;
1065 : : }
1066 : :
1067 : 636 : UniReference< XMLPropertySetMapper > SchXMLExportHelper_Impl::GetPropertySetMapper() const
1068 : : {
1069 : 636 : return mxPropertySetMapper;
1070 : : }
1071 : :
1072 : 9 : void SchXMLExportHelper_Impl::exportAutoStyles()
1073 : : {
1074 [ + - ]: 9 : if( mxExpPropMapper.is())
1075 : : {
1076 : : //ToDo: when embedded in calc/writer this is not necessary because the
1077 : : // numberformatter is shared between both documents
1078 : 9 : mrExport.exportAutoDataStyles();
1079 : :
1080 : : // export chart auto styles
1081 : : mrAutoStylePool.exportXML(
1082 : : XML_STYLE_FAMILY_SCH_CHART_ID
1083 : 9 : , mrExport.GetDocHandler(),
1084 : 9 : mrExport.GetMM100UnitConverter(),
1085 : 9 : mrExport.GetNamespaceMap()
1086 : 9 : );
1087 : :
1088 : : // export auto styles for additional shapes
1089 [ + - ][ + - ]: 9 : mrExport.GetShapeExport()->exportAutoStyles();
1090 : : // and for text in additional shapes
1091 [ + - ][ + - ]: 9 : mrExport.GetTextParagraphExport()->exportTextAutoStyles();
1092 : : }
1093 : 9 : }
1094 : :
1095 : : // private methods
1096 : : // ---------------
1097 : :
1098 : 27 : SchXMLExportHelper_Impl::SchXMLExportHelper_Impl(
1099 : : SvXMLExport& rExport,
1100 : : SvXMLAutoStylePoolP& rASPool ) :
1101 : : mrExport( rExport ),
1102 : : mrAutoStylePool( rASPool ),
1103 : : mbHasSeriesLabels( sal_False ),
1104 : : mbHasCategoryLabels( sal_False ),
1105 [ + - ][ + - ]: 27 : mbRowSourceColumns( sal_True )
[ + - ]
1106 : : // #110680#
1107 : : // this id depends on the ServiceManager used due to the binary filter stripping.
1108 : : // ,msCLSID( rtl::OUString( SvGlobalName( SO3_SCH_CLASSID ).GetHexName()))
1109 : : {
1110 : : // #110680#
1111 : : // changed initialisation for msCLSID. Compare the ServiceInfo name with
1112 : : // the known name of the LegacyServiceManager.
1113 [ + - ][ + - ]: 27 : Reference<lang::XServiceInfo> xServiceInfo( mrExport.getServiceFactory(), uno::UNO_QUERY );
1114 : : DBG_ASSERT( xServiceInfo.is(), "XMultiServiceFactory without xServiceInfo (!)" );
1115 [ + - ][ + - ]: 27 : OUString rdbURL = xServiceInfo->getImplementationName();
1116 : 27 : OUString implLegacyServiceManagerName( "com.sun.star.comp.office.LegacyServiceManager" );
1117 : :
1118 [ - + ]: 27 : if( rdbURL.equals( implLegacyServiceManagerName ))
1119 : : {
1120 [ # # ][ # # ]: 0 : msCLSID = OUString( SvGlobalName( BF_SO3_SCH_CLASSID ).GetHexName());
[ # # ][ # # ]
[ # # ]
1121 : : }
1122 : : else
1123 : : {
1124 [ + - ][ + - ]: 27 : msCLSID = OUString( SvGlobalName( SO3_SCH_CLASSID ).GetHexName());
[ + - ][ + - ]
[ + - ]
1125 : : }
1126 : :
1127 : 27 : msTableName = OUString( "local-table" );
1128 : :
1129 : : // create factory
1130 [ + - ][ + - ]: 27 : mxPropertyHandlerFactory = new XMLChartPropHdlFactory;
[ + - ]
1131 : :
1132 [ + - ]: 27 : if( mxPropertyHandlerFactory.is() )
1133 : : {
1134 : : // create property set mapper
1135 [ + - ][ + - ]: 27 : mxPropertySetMapper = new XMLChartPropertySetMapper;
[ + - ]
1136 : : }
1137 : :
1138 [ + - ][ + - ]: 27 : mxExpPropMapper = new XMLChartExportPropertyMapper( mxPropertySetMapper, rExport );
[ + - ]
1139 : :
1140 : : // register chart auto-style family
1141 : : mrAutoStylePool.AddFamily(
1142 : : XML_STYLE_FAMILY_SCH_CHART_ID,
1143 : : OUString( XML_STYLE_FAMILY_SCH_CHART_NAME ),
1144 : 27 : mxExpPropMapper.get(),
1145 [ + - ]: 54 : OUString( XML_STYLE_FAMILY_SCH_CHART_PREFIX ));
1146 : :
1147 : : // register shape family
1148 : : mrAutoStylePool.AddFamily(
1149 : : XML_STYLE_FAMILY_SD_GRAPHICS_ID,
1150 : : OUString( XML_STYLE_FAMILY_SD_GRAPHICS_NAME ),
1151 : 27 : mxExpPropMapper.get(),
1152 [ + - ]: 54 : OUString( XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX ));
1153 : : // register paragraph family also for shapes
1154 : : mrAutoStylePool.AddFamily(
1155 : : XML_STYLE_FAMILY_TEXT_PARAGRAPH,
1156 [ + - ]: 27 : GetXMLToken( XML_PARAGRAPH ),
1157 : 27 : mxExpPropMapper.get(),
1158 [ + - ]: 54 : rtl::OUString( 'P' ));
1159 : : // register text family also for shapes
1160 : : mrAutoStylePool.AddFamily(
1161 : : XML_STYLE_FAMILY_TEXT_TEXT,
1162 [ + - ]: 27 : GetXMLToken( XML_TEXT ),
1163 : 27 : mxExpPropMapper.get(),
1164 [ + - ]: 54 : rtl::OUString( 'T' ));
1165 : 27 : }
1166 : :
1167 [ + - ][ + - ]: 27 : SchXMLExportHelper_Impl::~SchXMLExportHelper_Impl()
[ + - ][ + - ]
1168 : : {
1169 [ - + ]: 54 : }
1170 : :
1171 : 9 : void SchXMLExportHelper_Impl::collectAutoStyles( Reference< chart::XChartDocument > rChartDoc )
1172 : : {
1173 : 9 : parseDocument( rChartDoc, sal_False );
1174 : 9 : }
1175 : :
1176 : 9 : void SchXMLExportHelper_Impl::exportChart( Reference< chart::XChartDocument > rChartDoc,
1177 : : sal_Bool bIncludeTable )
1178 : : {
1179 : 9 : parseDocument( rChartDoc, sal_True, bIncludeTable );
1180 : : DBG_ASSERT( maAutoStyleNameQueue.empty(), "There are still remaining autostyle names in the queue" );
1181 : 9 : }
1182 : :
1183 : 0 : ::rtl::OUString lcl_GetStringFromNumberSequence( const ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping, bool bRemoveOneFromEachIndex /*should be true if having categories*/ )
1184 : : {
1185 : 0 : const sal_Int32* pArray = rSequenceMapping.getConstArray();
1186 : 0 : const sal_Int32 nSize = rSequenceMapping.getLength();
1187 : 0 : sal_Int32 i = 0;
1188 : 0 : OUStringBuffer aBuf;
1189 : 0 : bool bHasPredecessor = false;
1190 [ # # ]: 0 : for( i = 0; i < nSize; ++i )
1191 : : {
1192 : 0 : sal_Int32 nIndex = pArray[ i ];
1193 [ # # ]: 0 : if( bRemoveOneFromEachIndex )
1194 : 0 : --nIndex;
1195 [ # # ]: 0 : if(nIndex>=0)
1196 : : {
1197 [ # # ]: 0 : if(bHasPredecessor)
1198 [ # # ]: 0 : aBuf.append( static_cast< sal_Unicode >( ' ' ));
1199 [ # # ]: 0 : aBuf.append( nIndex, 10 );
1200 : 0 : bHasPredecessor = true;
1201 : : }
1202 : : }
1203 [ # # ]: 0 : return aBuf.makeStringAndClear();
1204 : : }
1205 : :
1206 : : /// if bExportContent is false the auto-styles are collected
1207 : 18 : void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& rChartDoc,
1208 : : sal_Bool bExportContent,
1209 : : sal_Bool bIncludeTable )
1210 : : {
1211 [ + - ]: 18 : Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY );
1212 [ + - ][ - + ]: 18 : if( !rChartDoc.is() || !xNewDoc.is() )
[ - + ]
1213 : : {
1214 : : OSL_FAIL( "No XChartDocument was given for export." );
1215 : 18 : return;
1216 : : }
1217 : :
1218 [ + - ]: 18 : awt::Size aPageSize( getPageSize( xNewDoc ));
1219 [ + + ]: 18 : if( bExportContent )
1220 [ + - ]: 9 : addSize( aPageSize );
1221 [ + - ][ + - ]: 18 : Reference< chart::XDiagram > xDiagram = rChartDoc->getDiagram();
1222 : 18 : Reference< chart2::XDiagram > xNewDiagram;
1223 [ + - ]: 18 : if( xNewDoc.is())
1224 [ + - ][ + - ]: 18 : xNewDiagram.set( xNewDoc->getFirstDiagram());
[ + - ]
1225 : :
1226 : : //todo remove if model changes are notified and view is updated automatically
1227 [ + + ]: 18 : if( bExportContent )
1228 : : {
1229 [ + - ]: 9 : Reference< util::XRefreshable > xRefreshable( xNewDoc, uno::UNO_QUERY );
1230 [ - + ]: 9 : if( xRefreshable.is() )
1231 [ # # ][ # # ]: 9 : xRefreshable->refresh();
1232 : : }
1233 : :
1234 : : // get Properties of ChartDocument
1235 : 18 : sal_Bool bHasMainTitle = sal_False;
1236 : 18 : sal_Bool bHasSubTitle = sal_False;
1237 : 18 : sal_Bool bHasLegend = sal_False;
1238 : 18 : util::DateTime aNullDate(0,0,0,0,30,12,1899);
1239 : :
1240 [ + - ]: 18 : std::vector< XMLPropertyState > aPropertyStates;
1241 : :
1242 [ + - ]: 18 : Reference< beans::XPropertySet > xDocPropSet( rChartDoc, uno::UNO_QUERY );
1243 [ + - ]: 18 : if( xDocPropSet.is())
1244 : : {
1245 : : try
1246 : : {
1247 [ + - ]: 18 : Any aAny( xDocPropSet->getPropertyValue(
1248 [ + - ]: 18 : OUString( "HasMainTitle" )));
1249 : 18 : aAny >>= bHasMainTitle;
1250 [ + - ]: 18 : aAny = xDocPropSet->getPropertyValue(
1251 [ + - ]: 18 : OUString( "HasSubTitle" ));
1252 : 18 : aAny >>= bHasSubTitle;
1253 [ + - ]: 18 : aAny = xDocPropSet->getPropertyValue(
1254 [ + - ]: 18 : OUString( "HasLegend" ));
1255 : 18 : aAny >>= bHasLegend;
1256 [ + + ]: 18 : if ( bIncludeTable )
1257 : : {
1258 : 8 : OUString sNullDate( "NullDate" );
1259 [ + - ][ + - ]: 8 : aAny = xDocPropSet->getPropertyValue(sNullDate);
1260 [ + - ]: 8 : if ( !aAny.hasValue() )
1261 : : {
1262 [ + - ]: 8 : Reference<container::XChild> xChild(rChartDoc, uno::UNO_QUERY );
1263 [ + - ]: 8 : if ( xChild.is() )
1264 : : {
1265 [ + - ][ + - ]: 8 : Reference< beans::XPropertySet > xParentDoc( xChild->getParent(),uno::UNO_QUERY);
[ + - ]
1266 [ + - ][ + - ]: 8 : if ( xParentDoc.is() && xParentDoc->getPropertySetInfo()->hasPropertyByName(sNullDate) )
[ + - ][ + - ]
[ - + ][ + + ]
[ - + # # ]
[ + + ]
1267 [ # # ][ # # ]: 8 : aAny = xParentDoc->getPropertyValue(sNullDate);
1268 : 8 : }
1269 : : }
1270 : :
1271 [ + - ]: 8 : aAny >>= aNullDate;
1272 [ # # ]: 18 : }
1273 : : }
1274 [ # # ]: 0 : catch( const beans::UnknownPropertyException & )
1275 : : {
1276 : : DBG_WARNING( "Required property not found in ChartDocument" );
1277 : : }
1278 : : }
1279 : :
1280 [ + + ][ + - ]: 18 : if ( bIncludeTable && (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 ) )
[ + - ][ - + ]
1281 : : {
1282 [ # # ]: 0 : SvXMLElementExport aSet( mrExport, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True );
1283 : : {
1284 : 0 : ::rtl::OUStringBuffer sBuffer;
1285 [ # # ]: 0 : ::sax::Converter::convertDateTime(sBuffer, aNullDate);
1286 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_TABLE,XML_DATE_VALUE,sBuffer.makeStringAndClear());
1287 [ # # ][ # # ]: 0 : SvXMLElementExport aNull( mrExport, XML_NAMESPACE_TABLE, XML_NULL_DATE, sal_True, sal_True );
1288 [ # # ]: 0 : }
1289 : : }
1290 : :
1291 : : // chart element
1292 : : // -------------
1293 : :
1294 : 18 : SvXMLElementExport* pElChart = 0;
1295 : : // get property states for autostyles
1296 [ + - ]: 18 : if( mxExpPropMapper.is())
1297 : : {
1298 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xPropSet( rChartDoc->getArea(), uno::UNO_QUERY );
[ + - ]
1299 [ + - ]: 18 : if( xPropSet.is())
1300 [ + - ]: 18 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
1301 : : }
1302 : :
1303 [ + + ]: 18 : if( bExportContent )
1304 : : {
1305 : : //export data provider in xlink:href attribute
1306 [ + - ][ + - ]: 9 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ + - ]
1307 [ + - ]: 9 : if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
1308 : : {
1309 : 9 : OUString aDataProviderURL( ".." );
1310 [ + - ][ + + ]: 9 : if( xNewDoc->hasInternalDataProvider() )
[ + - ]
1311 : 8 : aDataProviderURL = OUString( "." );
1312 : : else //special handling for data base data provider necessary
1313 : : {
1314 [ + - ][ + - ]: 1 : Reference< chart2::data::XDatabaseDataProvider > xDBDataProvider( xNewDoc->getDataProvider(), uno::UNO_QUERY );
[ + - ]
1315 [ - + ]: 1 : if( xDBDataProvider.is() )
1316 : 1 : aDataProviderURL = OUString( "." );
1317 : : }
1318 [ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL );
1319 [ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1320 : : }
1321 : :
1322 [ + - ][ + - ]: 9 : OUString sChartType( xDiagram->getDiagramType() );
1323 : :
1324 : : // attributes
1325 : : // determine class
1326 [ + - ]: 9 : if( !sChartType.isEmpty())
1327 : : {
1328 [ + - ]: 9 : enum XMLTokenEnum eXMLChartType = SchXMLTools::getTokenByChartType( sChartType, true /* bUseOldNames */ );
1329 : :
1330 : : DBG_ASSERT( eXMLChartType != XML_TOKEN_INVALID, "invalid chart class" );
1331 [ - + ]: 9 : if( eXMLChartType == XML_TOKEN_INVALID )
1332 : 0 : eXMLChartType = XML_BAR;
1333 : :
1334 [ - + ]: 9 : if( eXMLChartType == XML_ADD_IN )
1335 : : {
1336 : : // sChartType is the servie-name of the add-in
1337 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
1338 : 0 : mrExport.GetNamespaceMap().GetQNameByKey(
1339 [ # # ][ # # ]: 0 : XML_NAMESPACE_OOO, sChartType) );
1340 : : }
1341 [ + - ]: 9 : else if( eXMLChartType != XML_TOKEN_INVALID )
1342 : : {
1343 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
1344 : 9 : mrExport.GetNamespaceMap().GetQNameByKey(
1345 [ + - + - ]: 18 : XML_NAMESPACE_CHART, GetXMLToken(eXMLChartType )) );
[ + - ]
1346 : : }
1347 : :
1348 : : //column-mapping or row-mapping
1349 [ - + ]: 9 : if( maSequenceMapping.getLength() )
1350 : : {
1351 : 0 : enum XMLTokenEnum eTransToken = ::xmloff::token::XML_ROW_MAPPING;
1352 [ # # ]: 0 : if( mbRowSourceColumns )
1353 : 0 : eTransToken = ::xmloff::token::XML_COLUMN_MAPPING;
1354 : : ::rtl::OUString aSequenceMappingStr( lcl_GetStringFromNumberSequence(
1355 [ # # ][ # # ]: 0 : maSequenceMapping, mbHasCategoryLabels && !xNewDoc->hasInternalDataProvider() ) );
[ # # ][ # # ]
[ # # ]
1356 : :
1357 : : mrExport.AddAttribute( XML_NAMESPACE_CHART,
1358 [ # # ]: 0 : ::xmloff::token::GetXMLToken( eTransToken ),
1359 [ # # ]: 0 : aSequenceMappingStr );
1360 : : }
1361 : : }
1362 : : // write style name
1363 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
1364 : :
1365 : : //element
1366 [ + - ][ + - ]: 9 : pElChart = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_CHART, sal_True, sal_True );
1367 : : }
1368 : : else // autostyles
1369 : : {
1370 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
1371 : : }
1372 : : // remove property states for autostyles
1373 : 18 : aPropertyStates.clear();
1374 : :
1375 : : // title element
1376 : : // -------------
1377 : :
1378 [ - + ]: 18 : if( bHasMainTitle )
1379 : : {
1380 : : // get property states for autostyles
1381 [ # # ]: 0 : if( mxExpPropMapper.is())
1382 : : {
1383 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xPropSet( rChartDoc->getTitle(), uno::UNO_QUERY );
[ # # ]
1384 [ # # ]: 0 : if( xPropSet.is())
1385 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
1386 : : }
1387 [ # # ]: 0 : if( bExportContent )
1388 : : {
1389 [ # # ][ # # ]: 0 : Reference< drawing::XShape > xShape = rChartDoc->getTitle();
1390 [ # # ]: 0 : if( xShape.is()) // && "hasTitleBeenMoved"
1391 [ # # ]: 0 : addPosition( xShape );
1392 : :
1393 : : // write style name
1394 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
1395 : :
1396 : : // element
1397 [ # # ]: 0 : SvXMLElementExport aElTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
1398 : :
1399 : : // content (text:p)
1400 [ # # ]: 0 : Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
1401 [ # # ]: 0 : if( xPropSet.is())
1402 : : {
1403 [ # # ]: 0 : Any aAny( xPropSet->getPropertyValue(
1404 [ # # ]: 0 : OUString( "String" )));
1405 : 0 : OUString aText;
1406 : 0 : aAny >>= aText;
1407 [ # # ]: 0 : exportText( aText );
1408 [ # # ]: 0 : }
1409 : : }
1410 : : else // autostyles
1411 : : {
1412 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
1413 : : }
1414 : : // remove property states for autostyles
1415 : 0 : aPropertyStates.clear();
1416 : : }
1417 : :
1418 : : // subtitle element
1419 : : // ----------------
1420 : :
1421 [ - + ]: 18 : if( bHasSubTitle )
1422 : : {
1423 : : // get property states for autostyles
1424 [ # # ]: 0 : if( mxExpPropMapper.is())
1425 : : {
1426 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xPropSet( rChartDoc->getSubTitle(), uno::UNO_QUERY );
[ # # ]
1427 [ # # ]: 0 : if( xPropSet.is())
1428 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
1429 : : }
1430 : :
1431 [ # # ]: 0 : if( bExportContent )
1432 : : {
1433 [ # # ][ # # ]: 0 : Reference< drawing::XShape > xShape = rChartDoc->getSubTitle();
1434 [ # # ]: 0 : if( xShape.is())
1435 [ # # ]: 0 : addPosition( xShape );
1436 : :
1437 : : // write style name
1438 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
1439 : :
1440 : : // element (has no subelements)
1441 [ # # ]: 0 : SvXMLElementExport aElSubTitle( mrExport, XML_NAMESPACE_CHART, XML_SUBTITLE, sal_True, sal_True );
1442 : :
1443 : : // content (text:p)
1444 [ # # ]: 0 : Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
1445 [ # # ]: 0 : if( xPropSet.is())
1446 : : {
1447 [ # # ]: 0 : Any aAny( xPropSet->getPropertyValue(
1448 [ # # ]: 0 : OUString( "String" )));
1449 : 0 : OUString aText;
1450 : 0 : aAny >>= aText;
1451 [ # # ]: 0 : exportText( aText );
1452 [ # # ]: 0 : }
1453 : : }
1454 : : else // autostyles
1455 : : {
1456 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
1457 : : }
1458 : : // remove property states for autostyles
1459 : 0 : aPropertyStates.clear();
1460 : : }
1461 : :
1462 : : // legend element
1463 : : // --------------
1464 [ + - ]: 18 : if( bHasLegend )
1465 : : {
1466 : : // get property states for autostyles
1467 [ + - ]: 18 : if( mxExpPropMapper.is())
1468 : : {
1469 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xPropSet( rChartDoc->getLegend(), uno::UNO_QUERY );
[ + - ]
1470 [ + - ]: 18 : if( xPropSet.is())
1471 [ + - ]: 18 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
1472 : : }
1473 : :
1474 [ + + ]: 18 : if( bExportContent )
1475 : : {
1476 [ + - ][ + - ]: 9 : Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
[ + - ]
1477 [ + - ]: 9 : if( xProp.is())
1478 : : {
1479 : : // export legend anchor position
1480 : : try
1481 : : {
1482 [ + - ][ + - ]: 9 : Any aAny( xProp->getPropertyValue( OUString( "Alignment" )));
1483 [ + - ][ + - ]: 9 : if( SchXMLEnumConverter::getLegendPositionConverter().exportXML( msString, aAny, mrExport.GetMM100UnitConverter() ) )
[ + - ]
1484 [ + - ][ # # ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LEGEND_POSITION, msString );
1485 : : }
1486 [ # # ]: 0 : catch( const beans::UnknownPropertyException & )
1487 : : {
1488 : : DBG_WARNING( "Property Align not found in ChartLegend" );
1489 : : }
1490 : :
1491 : : // export absolute legend position
1492 [ + - ]: 9 : Reference< drawing::XShape > xLegendShape( xProp, uno::UNO_QUERY );
1493 [ + - ]: 9 : addPosition( xLegendShape );
1494 : :
1495 : : // export legend size
1496 [ + - ][ + - ]: 9 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ + - ]
1497 [ + - ][ + - ]: 9 : if( xLegendShape.is() && nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
[ + - ]
1498 : : {
1499 : : try
1500 : : {
1501 : 9 : chart::ChartLegendExpansion nLegendExpansion = chart::ChartLegendExpansion_HIGH;
1502 : 9 : OUString aExpansionString;
1503 [ + - ][ + - ]: 9 : Any aAny( xProp->getPropertyValue( OUString( "Expansion" )));
1504 [ + - ]: 9 : bool bHasExpansion = (aAny >>= nLegendExpansion);
1505 [ + - ][ + - ]: 9 : if( bHasExpansion && SchXMLEnumConverter::getLegendExpansionConverter().exportXML( aExpansionString, aAny, mrExport.GetMM100UnitConverter() ) )
[ + - ][ + - ]
[ + - ]
1506 : : {
1507 [ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION, aExpansionString );
1508 [ - + ]: 9 : if( nLegendExpansion == chart::ChartLegendExpansion_CUSTOM)
1509 : : {
1510 [ # # ][ # # ]: 0 : awt::Size aSize( xLegendShape->getSize() );
1511 [ # # ]: 0 : addSize( aSize, true );
1512 : 0 : rtl::OUStringBuffer aAspectRatioString;
1513 : : ::sax::Converter::convertDouble(
1514 : : aAspectRatioString,
1515 [ # # ]: 0 : double(aSize.Width)/double(aSize.Height));
1516 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION_ASPECT_RATIO, aAspectRatioString.makeStringAndClear() );
1517 : : }
1518 [ # # ]: 9 : }
1519 : : }
1520 [ # # ]: 0 : catch( const beans::UnknownPropertyException & )
1521 : : {
1522 : : DBG_WARNING( "Property Expansion not found in ChartLegend" );
1523 : : }
1524 : 9 : }
1525 : : }
1526 : :
1527 : : // write style name
1528 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
1529 : :
1530 : : // element
1531 [ + - ][ + - ]: 9 : SvXMLElementExport aLegend( mrExport, XML_NAMESPACE_CHART, XML_LEGEND, sal_True, sal_True );
1532 : : }
1533 : : else // autostyles
1534 : : {
1535 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
1536 : : }
1537 : : // remove property states for autostyles
1538 : 18 : aPropertyStates.clear();
1539 : : }
1540 : :
1541 : : // plot-area element
1542 : : // -----------------
1543 [ + - ]: 18 : if( xDiagram.is())
1544 [ + - ]: 18 : exportPlotArea( xDiagram, xNewDiagram, aPageSize, bExportContent, bIncludeTable );
1545 : :
1546 : : // export additional shapes
1547 : : // ------------------------
1548 [ + - ]: 18 : if( xDocPropSet.is() )
1549 : : {
1550 [ + + ]: 18 : if( bExportContent )
1551 : : {
1552 [ - + ]: 9 : if( mxAdditionalShapes.is())
1553 : : {
1554 : : // can't call exportShapes with all shapes because the
1555 : : // initialisation happend with the complete draw page and not
1556 : : // the XShapes object used here. Thus the shapes have to be
1557 : : // exported one by one
1558 [ # # ]: 0 : UniReference< XMLShapeExport > rShapeExport = mrExport.GetShapeExport();
1559 : 0 : Reference< drawing::XShape > xShape;
1560 [ # # ][ # # ]: 0 : const sal_Int32 nShapeCount( mxAdditionalShapes->getCount());
1561 [ # # ]: 0 : for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
1562 : : {
1563 [ # # ][ # # ]: 0 : mxAdditionalShapes->getByIndex( nShapeId ) >>= xShape;
[ # # ]
1564 : : DBG_ASSERT( xShape.is(), "Shape without an XShape?" );
1565 [ # # ]: 0 : if( ! xShape.is())
1566 : 0 : continue;
1567 : :
1568 [ # # ][ # # ]: 0 : rShapeExport->exportShape( xShape );
1569 [ # # ]: 0 : }
1570 : : // this would be the easier way if it worked:
1571 : : //mrExport.GetShapeExport()->exportShapes( mxAdditionalShapes );
1572 : : }
1573 : : }
1574 : : else
1575 : : {
1576 : : // get a sequence of non-chart shapes (inserted via clipboard)
1577 : : try
1578 : : {
1579 [ + - ][ + - ]: 9 : Any aShapesAny = xDocPropSet->getPropertyValue( OUString( "AdditionalShapes" ));
1580 [ # # ][ + - ]: 9 : aShapesAny >>= mxAdditionalShapes;
1581 : : }
1582 [ # # ]: 0 : catch( const uno::Exception & rEx )
1583 : : {
1584 : : (void)rEx; // avoid warning for pro build
1585 : : OSL_TRACE(
1586 : : OUStringToOString(
1587 : : OUString( "AdditionalShapes not found: " ) +
1588 : : rEx.Message,
1589 : : RTL_TEXTENCODING_ASCII_US ).getStr());
1590 : : }
1591 : :
1592 [ - + ]: 9 : if( mxAdditionalShapes.is())
1593 : : {
1594 : : // seek shapes has to be called for the whole page because in
1595 : : // the shape export the vector of shapes is accessed via the
1596 : : // ZOrder which might be (actually is) larger than the number of
1597 : : // shapes in mxAdditionalShapes
1598 [ # # ]: 0 : Reference< drawing::XDrawPageSupplier > xSupplier( rChartDoc, uno::UNO_QUERY );
1599 : : DBG_ASSERT( xSupplier.is(), "Cannot retrieve draw page to initialize shape export" );
1600 [ # # ]: 0 : if( xSupplier.is() )
1601 : : {
1602 [ # # ][ # # ]: 0 : Reference< drawing::XShapes > xDrawPage( xSupplier->getDrawPage(), uno::UNO_QUERY );
[ # # ]
1603 : : DBG_ASSERT( xDrawPage.is(), "Invalid draw page for initializing shape export" );
1604 [ # # ]: 0 : if( xDrawPage.is())
1605 [ # # ][ # # ]: 0 : mrExport.GetShapeExport()->seekShapes( xDrawPage );
[ # # ]
1606 : : }
1607 : :
1608 : : // can't call collectShapesAutoStyles with all shapes because
1609 : : // the initialisation happend with the complete draw page and
1610 : : // not the XShapes object used here. Thus the shapes have to be
1611 : : // exported one by one
1612 [ # # ]: 0 : UniReference< XMLShapeExport > rShapeExport = mrExport.GetShapeExport();
1613 : 0 : Reference< drawing::XShape > xShape;
1614 [ # # ][ # # ]: 0 : const sal_Int32 nShapeCount( mxAdditionalShapes->getCount());
1615 [ # # ]: 0 : for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
1616 : : {
1617 [ # # ][ # # ]: 0 : mxAdditionalShapes->getByIndex( nShapeId ) >>= xShape;
[ # # ]
1618 : : DBG_ASSERT( xShape.is(), "Shape without an XShape?" );
1619 [ # # ]: 0 : if( ! xShape.is())
1620 : 0 : continue;
1621 : :
1622 [ # # ][ # # ]: 0 : rShapeExport->collectShapeAutoStyles( xShape );
1623 [ # # ]: 0 : }
1624 : : }
1625 : : }
1626 : : }
1627 : :
1628 : : // table element
1629 : : // (is included as subelement of chart)
1630 : : // ------------------------------------
1631 [ + + ]: 18 : if( bExportContent )
1632 : : {
1633 : : // #85929# always export table, otherwise clipboard may loose data
1634 [ + - ]: 9 : exportTable();
1635 : : }
1636 : :
1637 : : // close <chart:chart> element
1638 [ + + ]: 18 : if( pElChart )
1639 [ + - ][ + - ]: 18 : delete pElChart;
[ + - ]
1640 : : }
1641 : :
1642 : 72 : void lcl_exportComplexLabel( const Sequence< uno::Any >& rComplexLabel, SvXMLExport& rExport )
1643 : : {
1644 : 72 : sal_Int32 nLength = rComplexLabel.getLength();
1645 [ - + ]: 72 : if( nLength<=1 )
1646 : 72 : return;
1647 [ # # ]: 0 : SvXMLElementExport aTextList( rExport, XML_NAMESPACE_TEXT, XML_LIST, sal_True, sal_True );
1648 [ # # ]: 0 : for(sal_Int32 nN=0; nN<nLength; nN++)
1649 : : {
1650 [ # # ]: 0 : SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, sal_True, sal_True );
1651 : 0 : OUString aString;
1652 : 0 : if( !(rComplexLabel[nN]>>=aString) )
1653 : : {
1654 : : //todo?
1655 : : }
1656 [ # # ]: 0 : SchXMLTools::exportText( rExport, aString, false /*bConvertTabsLFs*/ );
1657 [ # # ][ # # ]: 72 : }
1658 : : }
1659 : :
1660 : 9 : void SchXMLExportHelper_Impl::exportTable()
1661 : : {
1662 : : // table element
1663 : : // -------------
1664 [ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, msTableName );
1665 : :
1666 : : try
1667 : : {
1668 : 9 : bool bProtected = false;
1669 [ + - ]: 9 : Reference< beans::XPropertySet > xProps( mrExport.GetModel(), uno::UNO_QUERY_THROW );
1670 [ + - ][ + - ]: 9 : if ( ( xProps->getPropertyValue( OUString( "DisableDataTableDialog" ) ) >>= bProtected ) &&
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ - +
# # # # #
# ]
1671 : : bProtected )
1672 : : {
1673 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE );
1674 [ # # ]: 9 : }
1675 : : }
1676 [ # # ]: 0 : catch ( const uno::Exception& )
1677 : : {
1678 : : }
1679 : :
1680 [ + - ]: 9 : SvXMLElementExport aTable( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True );
1681 : :
1682 : 9 : bool bHasOwnData = false;
1683 [ + - ]: 9 : Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
1684 : 9 : Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
1685 [ + - ]: 9 : if( xNewDoc.is())
1686 : : {
1687 [ + - ][ + - ]: 9 : bHasOwnData = xNewDoc->hasInternalDataProvider();
1688 [ + - ][ + - ]: 9 : xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY );
[ + - ]
1689 : : }
1690 : :
1691 : 9 : Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess;
1692 : : {
1693 [ + - ]: 9 : Reference< chart::XChartDocument > xChartDoc( mrExport.GetModel(), uno::UNO_QUERY );
1694 [ + - ]: 9 : if( xChartDoc.is() )
1695 [ + - ][ + - ]: 9 : xAnyDescriptionAccess = Reference< chart2::XAnyDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY );
[ + - ][ + - ]
1696 : : }
1697 : :
1698 [ + + ]: 9 : if( bHasOwnData )
1699 [ + - ]: 8 : lcl_ReorderInternalSequencesAccordingToTheirRangeName( m_aDataSequencesToExport );
1700 : : lcl_TableData aData( lcl_getDataForLocalTable( m_aDataSequencesToExport
1701 : : , xAnyDescriptionAccess, maCategoriesRange
1702 [ + - ]: 9 : , mbRowSourceColumns, xRangeConversion ));
1703 : :
1704 [ + - ]: 9 : tStringVector::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin());
1705 [ + - ]: 9 : const tStringVector::const_iterator aDataRangeEndIter( aData.aDataRangeRepresentations.end());
1706 : :
1707 [ + - ]: 9 : tStringVector::const_iterator aRowDescriptions_RangeIter( aData.aRowDescriptions_Ranges.begin());
1708 [ + - ]: 9 : const tStringVector::const_iterator aRowDescriptions_RangeEnd( aData.aRowDescriptions_Ranges.end());
1709 : :
1710 : : // declare columns
1711 : : {
1712 [ + - ]: 9 : SvXMLElementExport aHeaderColumns( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, sal_True, sal_True );
1713 [ + - ][ + - ]: 9 : SvXMLElementExport aHeaderColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
[ + - ]
1714 : : }
1715 : : {
1716 [ + - ]: 9 : SvXMLElementExport aColumns( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, sal_True, sal_True );
1717 : :
1718 : 9 : sal_Int32 nNextIndex = 0;
1719 [ - + ]: 9 : for( size_t nN=0; nN< aData.aHiddenColumns.size(); nN++ )
1720 : : {
1721 : : //i91578 display of hidden values (copy paste scenario; export hidden flag thus it can be used during migration to locale table upon paste )
1722 [ # # ]: 0 : sal_Int32 nHiddenIndex = aData.aHiddenColumns[nN];
1723 [ # # ]: 0 : if( nHiddenIndex > nNextIndex )
1724 : : {
1725 : 0 : sal_Int64 nRepeat = static_cast< sal_Int64 >( nHiddenIndex - nNextIndex );
1726 [ # # ]: 0 : if(nRepeat>1)
1727 : : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
1728 [ # # ]: 0 : OUString::valueOf( nRepeat ));
1729 [ # # ][ # # ]: 0 : SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
1730 : : }
1731 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_VISIBILITY, GetXMLToken( XML_COLLAPSE ) );
1732 [ # # ]: 0 : SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
1733 : 0 : nNextIndex = nHiddenIndex+1;
1734 [ # # ]: 0 : }
1735 : :
1736 : 9 : sal_Int32 nEndIndex = aData.aColumnDescriptions.size()-1;
1737 [ + - ]: 9 : if( nEndIndex >= nNextIndex )
1738 : : {
1739 : 9 : sal_Int64 nRepeat = static_cast< sal_Int64 >( nEndIndex - nNextIndex + 1 );
1740 [ + - ]: 9 : if(nRepeat>1)
1741 : : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
1742 [ + - ]: 9 : OUString::valueOf( nRepeat ));
1743 [ + - ][ + - ]: 9 : SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
1744 [ + - ]: 9 : }
1745 : : }
1746 : :
1747 : : // export rows with content
1748 : : //export header row
1749 : : {
1750 [ + - ]: 9 : SvXMLElementExport aHeaderRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, sal_True, sal_True );
1751 [ + - ]: 9 : SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
1752 : :
1753 : : //first one empty cell for the row descriptions
1754 : : {
1755 [ + - ]: 9 : SvXMLElementExport aEmptyCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
1756 [ + - ][ + - ]: 9 : SvXMLElementExport aEmptyParagraph( mrExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_True );
[ + - ]
1757 : : }
1758 : :
1759 : : //export column descriptions
1760 [ + - ]: 9 : tStringVector::const_iterator aColumnDescriptions_RangeIter( aData.aColumnDescriptions_Ranges.begin());
1761 [ + - ]: 9 : const tStringVector::const_iterator aColumnDescriptions_RangeEnd( aData.aColumnDescriptions_Ranges.end());
1762 : 9 : const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions;
1763 : 9 : sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength();
1764 : 9 : sal_Int32 nC = 0;
1765 [ + - ][ + + ]: 92 : for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin())
[ + - ]
1766 : 46 : ; (aIt != aData.aColumnDescriptions.end())
1767 : : ; ++aIt, nC++ )
1768 : : {
1769 : 37 : bool bExportString = true;
1770 [ + - ]: 37 : if( nC < nComplexCount )
1771 : : {
1772 : 37 : const Sequence< uno::Any >& rComplexLabel = rComplexColumnDescriptions[nC];
1773 [ + - ]: 37 : if( rComplexLabel.getLength()>0 )
1774 : : {
1775 : 37 : double fValue=0.0;
1776 [ - + ]: 37 : if( rComplexLabel[0] >>=fValue )
1777 : : {
1778 : 0 : bExportString = false;
1779 : :
1780 : : ::sax::Converter::convertDouble(
1781 [ # # ]: 0 : msStringBuffer, fValue);
1782 [ # # ]: 0 : msString = msStringBuffer.makeStringAndClear();
1783 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT );
1784 [ # # ]: 37 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString );
1785 : : }
1786 : : }
1787 : : }
1788 [ + - ]: 37 : if( bExportString )
1789 : : {
1790 [ + - ]: 37 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING );
1791 : : }
1792 : :
1793 [ + - ]: 37 : SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
1794 [ + - ]: 37 : exportText( *aIt );
1795 [ + - ]: 37 : if( nC < nComplexCount )
1796 [ + - ]: 37 : lcl_exportComplexLabel( rComplexColumnDescriptions[nC], mrExport );
1797 [ + + ][ + - ]: 37 : if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
[ + - ][ + + ]
1798 : : {
1799 : : // remind the original range to allow a correct re-association when copying via clipboard
1800 [ + - ]: 13 : if (!(*aColumnDescriptions_RangeIter).isEmpty())
1801 [ + - ]: 13 : SchXMLTools::exportRangeToSomewhere( mrExport, *aColumnDescriptions_RangeIter );
1802 : 13 : ++aColumnDescriptions_RangeIter;
1803 : : }
1804 [ + - ]: 37 : }
1805 [ + - ][ + - ]: 9 : OSL_ASSERT( bHasOwnData || aColumnDescriptions_RangeIter == aColumnDescriptions_RangeEnd );
1806 : : } // closing row and header-rows elements
1807 : :
1808 : : // export value rows
1809 : : {
1810 [ + - ]: 9 : SvXMLElementExport aRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROWS, sal_True, sal_True );
1811 [ + - ]: 9 : tStringVector::const_iterator aRowDescriptionsIter( aData.aRowDescriptions.begin());
1812 : 9 : const Sequence< Sequence< uno::Any > >& rComplexRowDescriptions = aData.aComplexRowDescriptions;
1813 : 9 : sal_Int32 nComplexCount = rComplexRowDescriptions.getLength();
1814 : 9 : sal_Int32 nC = 0;
1815 : :
1816 [ + - ][ + - ]: 88 : for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin())
[ + + ][ + - ]
1817 : 44 : ; aRowIt != aData.aDataInRows.end()
1818 : : ; ++aRowIt, ++nC )
1819 : : {
1820 [ + - ]: 35 : SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
1821 : :
1822 : : //export row descriptions
1823 : : {
1824 : 35 : bool bExportString = true;
1825 [ + - ]: 35 : if( nC < nComplexCount )
1826 : : {
1827 : 35 : const Sequence< uno::Any >& rComplexLabel = rComplexRowDescriptions[nC];
1828 [ + - ]: 35 : if( rComplexLabel.getLength()>0 )
1829 : : {
1830 : 35 : double fValue=0.0;
1831 [ - + ]: 35 : if( rComplexLabel[0] >>=fValue )
1832 : : {
1833 : 0 : bExportString = false;
1834 : :
1835 [ # # ]: 0 : ::sax::Converter::convertDouble(msStringBuffer, fValue);
1836 [ # # ]: 0 : msString = msStringBuffer.makeStringAndClear();
1837 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT );
1838 [ # # ]: 35 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString );
1839 : : }
1840 : : }
1841 : : }
1842 [ + - ]: 35 : if( bExportString )
1843 : : {
1844 [ + - ]: 35 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING );
1845 : : }
1846 : :
1847 [ + - ]: 35 : SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
1848 [ + - ][ + - ]: 35 : if( aRowDescriptionsIter != aData.aRowDescriptions.end())
1849 : : {
1850 [ + - ]: 35 : exportText( *aRowDescriptionsIter );
1851 [ + - ]: 35 : if( nC < nComplexCount )
1852 [ + - ]: 35 : lcl_exportComplexLabel( rComplexRowDescriptions[nC], mrExport );
1853 [ + + ][ + - ]: 35 : if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
[ + + ][ + + ]
1854 : : {
1855 : : // remind the original range to allow a correct re-association when copying via clipboard
1856 [ + - ]: 1 : SchXMLTools::exportRangeToSomewhere( mrExport, *aRowDescriptions_RangeIter );
1857 : 1 : ++aRowDescriptions_RangeIter;
1858 : : }
1859 : 35 : ++aRowDescriptionsIter;
1860 [ + - ]: 35 : }
1861 : : }
1862 : :
1863 : : //export row values
1864 [ + - ]: 340 : for( t2DNumberContainer::value_type::const_iterator aColIt( aRowIt->begin());
[ + - + - ]
[ + + ]
1865 [ + - ]: 170 : aColIt != aRowIt->end(); ++aColIt )
1866 : : {
1867 [ + - ][ + - ]: 135 : ::sax::Converter::convertDouble( msStringBuffer, *aColIt );
1868 [ + - ]: 135 : msString = msStringBuffer.makeStringAndClear();
1869 [ + - ]: 135 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT );
1870 [ + - ]: 135 : mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString );
1871 [ + - ]: 135 : SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
1872 [ + - ]: 135 : exportText( msString, false ); // do not convert tabs and lfs
1873 [ + + ][ + - ]: 270 : if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
[ + + ][ - + ]
[ # # ][ + + ]
1874 [ # # ][ # # ]: 135 : ( mbRowSourceColumns || (aColIt == aRowIt->begin()) ) )
[ - + ][ # # ]
1875 : : {
1876 : : // remind the original range to allow a correct re-association when copying via clipboard
1877 [ + - ]: 13 : if (!(*aDataRangeIter).isEmpty())
1878 [ + - ]: 13 : SchXMLTools::exportRangeToSomewhere( mrExport, *aDataRangeIter );
1879 : 13 : ++aDataRangeIter;
1880 : : }
1881 [ + - ]: 135 : }
1882 [ + - ][ + - ]: 44 : }
1883 : : }
1884 : :
1885 : : // if range iterator was used it should have reached its end
1886 : : OSL_ASSERT( bHasOwnData || (aDataRangeIter == aDataRangeEndIter) );
1887 [ + - ][ + - ]: 9 : OSL_ASSERT( bHasOwnData || (aRowDescriptions_RangeIter == aRowDescriptions_RangeEnd) );
1888 : 9 : }
1889 : :
1890 : : namespace
1891 : : {
1892 : :
1893 : 36 : Reference< chart2::XCoordinateSystem > lcl_getCooSys( const Reference< chart2::XDiagram > & xNewDiagram )
1894 : : {
1895 : 36 : Reference< chart2::XCoordinateSystem > xCooSys;
1896 [ + - ]: 36 : Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDiagram, uno::UNO_QUERY );
1897 [ + - ]: 36 : if(xCooSysCnt.is())
1898 : : {
1899 [ + - ][ + - ]: 36 : Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
1900 [ + - ]: 36 : if(aCooSysSeq.getLength()>0)
1901 [ + - ][ + - ]: 36 : xCooSys = aCooSysSeq[0];
[ + - ]
1902 : : }
1903 : 36 : return xCooSys;
1904 : : }
1905 : :
1906 : 108 : Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem >& xCooSys,
1907 : : enum XMLTokenEnum eDimension, bool bPrimary=true )
1908 : : {
1909 : 108 : Reference< chart2::XAxis > xNewAxis;
1910 : : try
1911 : : {
1912 [ + - ]: 108 : if( xCooSys.is() )
1913 : : {
1914 : 108 : sal_Int32 nDimensionIndex=0;
1915 [ + + + - ]: 108 : switch( eDimension )
1916 : : {
1917 : : case XML_X:
1918 : 36 : nDimensionIndex=0;
1919 : 36 : break;
1920 : : case XML_Y:
1921 : 54 : nDimensionIndex=1;
1922 : 54 : break;
1923 : : case XML_Z:
1924 : 18 : nDimensionIndex=2;
1925 : 18 : break;
1926 : : default:
1927 : 0 : break;
1928 : : }
1929 : :
1930 [ + - ][ + + ]: 108 : xNewAxis = xCooSys->getAxisByDimension( nDimensionIndex, bPrimary ? 0 : 1 );
[ + + ][ + - ]
[ - + ]
1931 : : }
1932 : : }
1933 [ + - ]: 72 : catch( const uno::Exception & )
1934 : : {
1935 : : }
1936 : 108 : return xNewAxis;
1937 : : }
1938 : :
1939 : : }
1940 : :
1941 : 18 : void SchXMLExportHelper_Impl::exportPlotArea(
1942 : : Reference< chart::XDiagram > xDiagram,
1943 : : Reference< chart2::XDiagram > xNewDiagram,
1944 : : const awt::Size & rPageSize,
1945 : : sal_Bool bExportContent,
1946 : : sal_Bool bIncludeTable )
1947 : : {
1948 : : DBG_ASSERT( xDiagram.is(), "Invalid XDiagram as parameter" );
1949 [ + - ]: 18 : if( ! xDiagram.is())
1950 : 18 : return;
1951 : :
1952 : : // variables for autostyles
1953 : 18 : Reference< beans::XPropertySet > xPropSet;
1954 [ + - ]: 18 : std::vector< XMLPropertyState > aPropertyStates;
1955 : :
1956 : 18 : sal_Bool bIs3DChart = sal_False;
1957 : 18 : drawing::HomogenMatrix aTransMatrix;
1958 : :
1959 [ + - ]: 18 : msStringBuffer.setLength( 0 );
1960 : :
1961 : : // plot-area element
1962 : : // -----------------
1963 : :
1964 : 18 : SvXMLElementExport* pElPlotArea = 0;
1965 : : // get property states for autostyles
1966 [ + - ][ + - ]: 18 : xPropSet = Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY );
1967 [ + - ]: 18 : if( xPropSet.is())
1968 : : {
1969 [ + - ]: 18 : if( mxExpPropMapper.is())
1970 [ + - ]: 18 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
1971 : : }
1972 [ + + ]: 18 : if( bExportContent )
1973 : : {
1974 : 9 : UniReference< XMLShapeExport > rShapeExport;
1975 : :
1976 : : // write style name
1977 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
1978 : :
1979 [ + - ]: 9 : if( !msChartAddress.isEmpty() )
1980 : : {
1981 [ + + ]: 9 : if( !bIncludeTable )
1982 [ + - ]: 1 : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, msChartAddress );
1983 : :
1984 [ + - ]: 9 : Reference< chart::XChartDocument > xDoc( mrExport.GetModel(), uno::UNO_QUERY );
1985 [ + - ]: 9 : if( xDoc.is() )
1986 : : {
1987 [ + - ]: 9 : Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
1988 [ + - ]: 9 : if( xDocProp.is())
1989 : : {
1990 : 9 : Any aAny;
1991 : 9 : sal_Bool bFirstCol = false, bFirstRow = false;
1992 : :
1993 : : try
1994 : : {
1995 [ + - ]: 9 : aAny = xDocProp->getPropertyValue(
1996 [ + - ]: 9 : OUString( "DataSourceLabelsInFirstColumn" ));
1997 : 9 : aAny >>= bFirstCol;
1998 [ + - ]: 9 : aAny = xDocProp->getPropertyValue(
1999 [ + - ][ # # ]: 9 : OUString( "DataSourceLabelsInFirstRow" ));
2000 : 9 : aAny >>= bFirstRow;
2001 : :
2002 [ # # ][ - + ]: 9 : if( bFirstCol || bFirstRow )
2003 : : {
2004 : : mrExport.AddAttribute( XML_NAMESPACE_CHART,
2005 [ + - ]: 9 : ::xmloff::token::GetXMLToken( ::xmloff::token::XML_DATA_SOURCE_HAS_LABELS ),
2006 : : ( bFirstCol
2007 : : ? ( bFirstRow
2008 : : ? ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )
2009 : : : ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN ))
2010 [ + - ][ + - ]: 18 : : ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )));
[ + - ][ # # ]
[ # # ][ + - ]
2011 : : }
2012 : : }
2013 [ # # ]: 0 : catch( const beans::UnknownPropertyException & )
2014 : : {
2015 : : SAL_WARN( "xmloff.chart", "Properties missing" );
2016 : 9 : }
2017 : 9 : }
2018 : 9 : }
2019 : : }
2020 : :
2021 : : // #i72973#, #144135# only export table-number-list in OOo format (also for binary)
2022 [ + - ]: 9 : Reference< beans::XPropertySet > xExportInfo( mrExport.getExportInfo());
2023 [ + + ][ + - ]: 9 : if( !msTableNumberList.isEmpty() && xExportInfo.is())
[ + + ]
2024 : : {
2025 : : try
2026 : : {
2027 : 1 : OUString sExportTableNumListPropName( "ExportTableNumberList");
2028 [ + - ][ + - ]: 1 : Reference< beans::XPropertySetInfo > xInfo( xExportInfo->getPropertySetInfo());
2029 : 1 : bool bExportTableNumberList = false;
2030 [ + - ][ + - ]: 3 : if( xInfo.is() && xInfo->hasPropertyByName( sExportTableNumListPropName ) &&
[ + - ]
[ + - - + ]
[ # # ][ - + ]
2031 [ + - ][ + - ]: 2 : (xExportInfo->getPropertyValue( sExportTableNumListPropName ) >>= bExportTableNumberList) &&
[ + - ][ # # ]
2032 : : bExportTableNumberList )
2033 : : {
2034 : : // this attribute is for charts embedded in calc documents only.
2035 : : // With this you are able to store a file again in 5.0 binary format
2036 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_TABLE_NUMBER_LIST, msTableNumberList );
2037 [ # # ]: 1 : }
2038 : : }
2039 [ # # ]: 0 : catch( const uno::Exception & rEx )
2040 : : {
2041 : : #ifdef DBG_UTIL
2042 : : rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
2043 : : OSL_TRACE("chart:TableNumberList property caught: %s", aBStr.getStr());
2044 : : #else
2045 : : (void)rEx; // avoid warning
2046 : : #endif
2047 : : }
2048 : : }
2049 : :
2050 : : // attributes
2051 [ + - ]: 9 : Reference< drawing::XShape > xShape ( xDiagram, uno::UNO_QUERY );
2052 [ + - ]: 9 : if( xShape.is())
2053 : : {
2054 [ + - ]: 9 : addPosition( xShape );
2055 [ + - ]: 9 : addSize( xShape );
2056 : : }
2057 : :
2058 [ + - ]: 9 : if( xPropSet.is())
2059 : : {
2060 : 9 : Any aAny;
2061 : :
2062 : : // 3d attributes
2063 : : try
2064 : : {
2065 [ + - ][ + - ]: 9 : aAny = xPropSet->getPropertyValue( OUString( "Dim3D" ));
2066 : 9 : aAny >>= bIs3DChart;
2067 : :
2068 [ - + ]: 9 : if( bIs3DChart )
2069 : : {
2070 [ # # ][ # # ]: 0 : rShapeExport = mrExport.GetShapeExport();
[ # # # # ]
2071 [ # # ]: 0 : if( rShapeExport.is())
2072 [ # # ][ # # ]: 0 : rShapeExport->export3DSceneAttributes( xPropSet );
2073 : : }
2074 : : }
2075 [ # # ]: 0 : catch( const uno::Exception & rEx )
2076 : : {
2077 : : #ifdef DBG_UTIL
2078 : : rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
2079 : : OSL_TRACE( "chart:exportPlotAreaException caught: %s", aBStr.getStr());
2080 : : #else
2081 : : (void)rEx; // avoid warning
2082 : : #endif
2083 : 9 : }
2084 : : }
2085 : :
2086 : : // plot-area element
2087 [ + - ][ + - ]: 9 : pElPlotArea = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_PLOT_AREA, sal_True, sal_True );
2088 : :
2089 : : //inner position rectangle element
2090 [ + - ]: 9 : exportCoordinateRegion( xDiagram );
2091 : :
2092 : : // light sources (inside plot area element)
2093 [ - + # # ]: 9 : if( bIs3DChart &&
[ - + ]
2094 : 0 : rShapeExport.is())
2095 [ # # ][ # # ]: 9 : rShapeExport->export3DLamps( xPropSet );
[ + - ]
2096 : : }
2097 : : else // autostyles
2098 : : {
2099 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
2100 : : }
2101 : : // remove property states for autostyles
2102 : 18 : aPropertyStates.clear();
2103 : :
2104 : : // axis elements
2105 : : // -------------
2106 [ + - ]: 18 : exportAxes( xDiagram, xNewDiagram, bExportContent );
2107 : :
2108 : : // series elements
2109 : : // ---------------
2110 [ + - ][ + - ]: 18 : Reference< chart2::XAxis > xSecondYAxis = lcl_getAxis( lcl_getCooSys( xNewDiagram ), XML_Y, false );
2111 [ + - ]: 18 : exportSeries( xNewDiagram, rPageSize, bExportContent, xSecondYAxis.is() );
2112 : :
2113 : : // stock-chart elements
2114 [ + - ][ + - ]: 18 : OUString sChartType ( xDiagram->getDiagramType());
2115 [ - + ]: 18 : if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" )))
2116 : : {
2117 [ # # ]: 0 : Reference< chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY );
2118 [ # # ]: 0 : if( xStockPropProvider.is())
2119 : : {
2120 : : // stock-gain-marker
2121 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar();
2122 [ # # ]: 0 : if( xStockPropSet.is())
2123 : : {
2124 : 0 : aPropertyStates.clear();
2125 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
2126 : :
2127 [ # # ]: 0 : if( !aPropertyStates.empty() )
2128 : : {
2129 [ # # ]: 0 : if( bExportContent )
2130 : : {
2131 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
2132 : :
2133 [ # # ][ # # ]: 0 : SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, sal_True, sal_True );
2134 : : }
2135 : : else
2136 : : {
2137 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
2138 : : }
2139 : : }
2140 : : }
2141 : :
2142 : : // stock-loss-marker
2143 [ # # ][ # # ]: 0 : xStockPropSet = xStockPropProvider->getDownBar();
[ # # ]
2144 [ # # ]: 0 : if( xStockPropSet.is())
2145 : : {
2146 : 0 : aPropertyStates.clear();
2147 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
2148 : :
2149 [ # # ]: 0 : if( !aPropertyStates.empty() )
2150 : : {
2151 [ # # ]: 0 : if( bExportContent )
2152 : : {
2153 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
2154 : :
2155 [ # # ][ # # ]: 0 : SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, sal_True, sal_True );
2156 : : }
2157 : : else
2158 : : {
2159 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
2160 : : }
2161 : : }
2162 : : }
2163 : :
2164 : : // stock-range-line
2165 [ # # ][ # # ]: 0 : xStockPropSet = xStockPropProvider->getMinMaxLine();
[ # # ]
2166 [ # # ]: 0 : if( xStockPropSet.is())
2167 : : {
2168 : 0 : aPropertyStates.clear();
2169 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
2170 : :
2171 [ # # ]: 0 : if( !aPropertyStates.empty() )
2172 : : {
2173 [ # # ]: 0 : if( bExportContent )
2174 : : {
2175 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
2176 : :
2177 [ # # ][ # # ]: 0 : SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, sal_True, sal_True );
2178 : : }
2179 : : else
2180 : : {
2181 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
2182 : : }
2183 : : }
2184 : 0 : }
2185 : 0 : }
2186 : : }
2187 : :
2188 : : // wall and floor element
2189 : : // ----------------------
2190 : :
2191 [ + - ]: 18 : Reference< chart::X3DDisplay > xWallFloorSupplier( xDiagram, uno::UNO_QUERY );
2192 [ + - + - ]: 36 : if( mxExpPropMapper.is() &&
[ + - ]
2193 : 18 : xWallFloorSupplier.is())
2194 : : {
2195 : : // remove property states for autostyles
2196 : 18 : aPropertyStates.clear();
2197 : :
2198 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
[ + - ]
2199 [ + - ]: 18 : if( xWallPropSet.is())
2200 : : {
2201 [ + - ]: 18 : aPropertyStates = mxExpPropMapper->Filter( xWallPropSet );
2202 : :
2203 [ + - ]: 18 : if( !aPropertyStates.empty() )
2204 : : {
2205 : : // write element
2206 [ + + ]: 18 : if( bExportContent )
2207 : : {
2208 : : // add style name attribute
2209 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
2210 : :
2211 [ + - ][ + - ]: 9 : SvXMLElementExport aWall( mrExport, XML_NAMESPACE_CHART, XML_WALL, sal_True, sal_True );
2212 : : }
2213 : : else // autostyles
2214 : : {
2215 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
2216 : : }
2217 : : }
2218 : : }
2219 : :
2220 : : // floor element
2221 : : // -------------
2222 : :
2223 : : // remove property states for autostyles
2224 : 18 : aPropertyStates.clear();
2225 : :
2226 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xFloorPropSet( xWallFloorSupplier->getFloor(), uno::UNO_QUERY );
[ + - ]
2227 [ + - ]: 18 : if( xFloorPropSet.is())
2228 : : {
2229 [ + - ]: 18 : aPropertyStates = mxExpPropMapper->Filter( xFloorPropSet );
2230 : :
2231 [ + - ]: 18 : if( !aPropertyStates.empty() )
2232 : : {
2233 : : // write element
2234 [ + + ]: 18 : if( bExportContent )
2235 : : {
2236 : : // add style name attribute
2237 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
2238 : :
2239 [ + - ][ + - ]: 9 : SvXMLElementExport aFloor( mrExport, XML_NAMESPACE_CHART, XML_FLOOR, sal_True, sal_True );
2240 : : }
2241 : : else // autostyles
2242 : : {
2243 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
2244 : : }
2245 : : }
2246 : 18 : }
2247 : : }
2248 : :
2249 [ + + ]: 18 : if( pElPlotArea )
2250 [ + - ][ + - ]: 18 : delete pElPlotArea;
2251 : : }
2252 : :
2253 : 9 : void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< chart::XDiagram >& xDiagram )
2254 : : {
2255 [ + - ][ + - ]: 9 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ + - ]
2256 [ + - ]: 9 : if( nCurrentODFVersion <= SvtSaveOptions::ODFVER_012 )//do not export to ODF 1.2 or older
2257 : : return;
2258 : :
2259 [ + - ]: 9 : Reference< chart::XDiagramPositioning > xDiaPos( xDiagram, uno::UNO_QUERY );
2260 : : DBG_ASSERT( xDiaPos.is(), "Invalid xDiaPos as parameter" );
2261 [ - + ]: 9 : if( !xDiaPos.is() )
2262 : : return;
2263 : :
2264 [ + - ][ + - ]: 9 : awt::Rectangle aRect( xDiaPos->calculateDiagramPositionExcludingAxes() );
2265 [ + - ]: 9 : addPosition( awt::Point(aRect.X,aRect.Y) );
2266 [ + - ]: 9 : addSize( awt::Size(aRect.Width,aRect.Height) );
2267 : :
2268 [ + - ][ + - ]: 9 : SvXMLElementExport aCoordinateRegion( mrExport, XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, sal_True, sal_True );//#i100778# todo: change to chart namespace in future - dependent on fileformat
[ + - ]
2269 : : }
2270 : :
2271 : : namespace
2272 : : {
2273 : 0 : XMLTokenEnum lcl_getTimeUnitToken( sal_Int32 nTimeUnit )
2274 : : {
2275 : 0 : XMLTokenEnum eToken = XML_DAYS;
2276 [ # # # ]: 0 : switch( nTimeUnit )
2277 : : {
2278 : : case ::com::sun::star::chart::TimeUnit::YEAR:
2279 : 0 : eToken = XML_YEARS;
2280 : 0 : break;
2281 : : case ::com::sun::star::chart::TimeUnit::MONTH:
2282 : 0 : eToken = XML_MONTHS;
2283 : 0 : break;
2284 : : default://days
2285 : 0 : break;
2286 : : }
2287 : 0 : return eToken;
2288 : : }
2289 : : }
2290 : :
2291 : 9 : void SchXMLExportHelper_Impl::exportDateScale( const Reference< beans::XPropertySet > xAxisProps )
2292 : : {
2293 [ + - ]: 9 : if( !xAxisProps.is() )
2294 : 9 : return;
2295 : :
2296 : 9 : chart::TimeIncrement aIncrement;
2297 [ + - ][ + - ]: 9 : if( (xAxisProps->getPropertyValue( OUString( "TimeIncrement" )) >>= aIncrement) )
[ + - ][ + - ]
2298 : : {
2299 : 9 : sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::DAY;
2300 [ - + ]: 9 : if( aIncrement.TimeResolution >>= nTimeResolution )
2301 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, lcl_getTimeUnitToken( nTimeResolution ) );
2302 : :
2303 : 9 : OUStringBuffer aValue;
2304 : 9 : chart::TimeInterval aInterval;
2305 [ - + ][ + - ]: 9 : if( aIncrement.MajorTimeInterval >>= aInterval )
2306 : : {
2307 [ # # ]: 0 : ::sax::Converter::convertNumber( aValue, aInterval.Number );
2308 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, aValue.makeStringAndClear() );
2309 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) );
2310 : : }
2311 [ + - ][ - + ]: 9 : if( aIncrement.MinorTimeInterval >>= aInterval )
2312 : : {
2313 [ # # ]: 0 : ::sax::Converter::convertNumber( aValue, aInterval.Number );
2314 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, aValue.makeStringAndClear() );
2315 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) );
2316 : : }
2317 : :
2318 [ + - ][ + - ]: 9 : SvXMLElementExport aDateScale( mrExport, XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, sal_True, sal_True );//#i25706#todo: change namespace for next ODF version
2319 : 9 : }
2320 : : }
2321 : :
2322 : 36 : void SchXMLExportHelper_Impl::exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent )
2323 : : {
2324 [ - + ]: 36 : if( !xTitleProps.is() )
2325 : 36 : return;
2326 [ # # ]: 0 : std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xTitleProps );
2327 [ # # ]: 0 : if( bExportContent )
2328 : : {
2329 : 0 : OUString aText;
2330 [ # # ]: 0 : Any aAny( xTitleProps->getPropertyValue(
2331 [ # # ]: 0 : OUString( "String" )));
2332 : 0 : aAny >>= aText;
2333 : :
2334 [ # # ]: 0 : Reference< drawing::XShape > xShape( xTitleProps, uno::UNO_QUERY );
2335 [ # # ]: 0 : if( xShape.is())
2336 [ # # ]: 0 : addPosition( xShape );
2337 : :
2338 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
2339 [ # # ]: 0 : SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
2340 : :
2341 : : // paragraph containing title
2342 [ # # ][ # # ]: 0 : exportText( aText );
2343 : : }
2344 : : else
2345 : : {
2346 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
2347 : : }
2348 : 36 : aPropertyStates.clear();
2349 : : }
2350 : :
2351 : 72 : void SchXMLExportHelper_Impl::exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent )
2352 : : {
2353 [ + + ]: 72 : if( !xGridProperties.is() )
2354 : 72 : return;
2355 [ + - ]: 18 : std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xGridProperties );
2356 [ + + ]: 18 : if( bExportContent )
2357 : : {
2358 [ + - ]: 9 : AddAutoStyleAttribute( aPropertyStates );
2359 [ + - ][ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, bMajor ? XML_MAJOR : XML_MINOR );
2360 [ + - ][ + - ]: 9 : SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
2361 : : }
2362 : : else
2363 : : {
2364 [ + - ]: 9 : CollectAutoStyle( aPropertyStates );
2365 : : }
2366 : 72 : aPropertyStates.clear();
2367 : : }
2368 : :
2369 : : namespace
2370 : : {
2371 : :
2372 : : //returns true if a date scale needs to be exported
2373 : 9 : bool lcl_exportAxisType( const Reference< chart2::XAxis > xChart2Axis, SvXMLExport& rExport)
2374 : : {
2375 : 9 : bool bExportDateScale = false;
2376 [ - + ]: 9 : if( !xChart2Axis.is() )
2377 : 0 : return bExportDateScale;
2378 : :
2379 [ + - ][ + - ]: 9 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ + - ]
2380 [ - + ]: 9 : if( nCurrentODFVersion <= SvtSaveOptions::ODFVER_012 )//do not export to ODF 1.2 or older
2381 : 0 : return bExportDateScale;
2382 : :
2383 [ + - ][ + - ]: 9 : chart2::ScaleData aScale( xChart2Axis->getScaleData() );
2384 : : //#i25706#todo: change namespace for next ODF version
2385 : 9 : sal_uInt16 nNameSpace = XML_NAMESPACE_CHART_EXT;
2386 : :
2387 [ + - - ]: 9 : switch(aScale.AxisType)
2388 : : {
2389 : : case chart2::AxisType::CATEGORY:
2390 [ + - ]: 9 : if( aScale.AutoDateAxis )
2391 : : {
2392 [ + - ]: 9 : rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO );
2393 : 9 : bExportDateScale = true;
2394 : : }
2395 : : else
2396 [ # # ]: 0 : rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_TEXT );
2397 : 9 : break;
2398 : : case chart2::AxisType::DATE:
2399 [ # # ]: 0 : rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_DATE );
2400 : 0 : bExportDateScale = true;
2401 : 0 : break;
2402 : : default: //AUTOMATIC
2403 [ # # ]: 0 : rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO );
2404 : 0 : break;
2405 : : }
2406 : :
2407 [ + - ]: 9 : return bExportDateScale;
2408 : : }
2409 : :
2410 : : }
2411 : :
2412 : 36 : void SchXMLExportHelper_Impl::exportAxis(
2413 : : enum XMLTokenEnum eDimension,
2414 : : enum XMLTokenEnum eAxisName,
2415 : : const Reference< beans::XPropertySet > xAxisProps,
2416 : : const Reference< chart2::XAxis >& xChart2Axis,
2417 : : const OUString& rCategoriesRange,
2418 : : bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid,
2419 : : bool bExportContent )
2420 : : {
2421 [ + + ][ + - ]: 36 : static const OUString sNumFormat( OUString( "NumberFormat" ));
2422 [ + - ]: 36 : std::vector< XMLPropertyState > aPropertyStates;
2423 : 36 : SvXMLElementExport* pAxis = NULL;
2424 : :
2425 : : // get property states for autostyles
2426 [ + - ][ + - ]: 36 : if( xAxisProps.is() && mxExpPropMapper.is() )
[ + - ]
2427 : : {
2428 [ + - ]: 36 : lcl_exportNumberFormat( sNumFormat, xAxisProps, mrExport );
2429 [ + - ]: 36 : aPropertyStates = mxExpPropMapper->Filter( xAxisProps );
2430 : : }
2431 : :
2432 : 36 : bool bExportDateScale = false;
2433 [ + + ]: 36 : if( bExportContent )
2434 : : {
2435 [ + - ]: 18 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, eDimension );
2436 [ + - ]: 18 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, eAxisName );
2437 [ + - ]: 18 : AddAutoStyleAttribute( aPropertyStates ); // write style name
2438 [ + + ]: 18 : if( !rCategoriesRange.isEmpty() )
2439 [ + - ]: 9 : bExportDateScale = lcl_exportAxisType( xChart2Axis, mrExport );
2440 : :
2441 : : // open axis element
2442 [ + - ][ + - ]: 18 : pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
2443 : : }
2444 : : else
2445 : : {
2446 [ + - ]: 18 : CollectAutoStyle( aPropertyStates );
2447 : : }
2448 : 36 : aPropertyStates.clear();
2449 : :
2450 : : //date scale
2451 [ + + ]: 36 : if( bExportDateScale )
2452 [ + - ]: 9 : exportDateScale( xAxisProps );
2453 : :
2454 : 36 : Reference< beans::XPropertySet > xTitleProps;
2455 : 36 : Reference< beans::XPropertySet > xMajorGridProps;
2456 : 36 : Reference< beans::XPropertySet > xMinorGridProps;
2457 [ + - ]: 36 : Reference< chart::XAxis > xAxis( xAxisProps, uno::UNO_QUERY );
2458 [ + - ]: 36 : if( xAxis.is() )
2459 : : {
2460 [ - + ][ # # ]: 36 : xTitleProps = bHasTitle ? xAxis->getAxisTitle() : 0;
[ # # ][ + - ]
[ + - ]
2461 [ + - ][ + - ]: 36 : xMajorGridProps = bHasMajorGrid ? xAxis->getMajorGrid() : 0;
[ + - ][ + - ]
[ + + ]
2462 [ # # ][ # # ]: 36 : xMinorGridProps = bHasMinorGrid ? xAxis->getMinorGrid() : 0;
[ + - ][ + - ]
[ - + ]
2463 : : }
2464 : :
2465 : : // axis-title
2466 [ + - ]: 36 : exportAxisTitle( xTitleProps , bExportContent );
2467 : :
2468 : : // categories if we have a categories chart
2469 [ + + ][ + + ]: 36 : if( bExportContent && !rCategoriesRange.isEmpty() )
[ + + ]
2470 : : {
2471 [ + - ]: 9 : mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, rCategoriesRange );
2472 [ + - ][ + - ]: 9 : SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True );
2473 : : }
2474 : :
2475 : : // grid
2476 [ + - ]: 36 : exportGrid( xMajorGridProps, true, bExportContent );
2477 [ + - ]: 36 : exportGrid( xMinorGridProps, false, bExportContent );
2478 : :
2479 [ + + ]: 36 : if( pAxis )
2480 : : {
2481 : : //close axis element
2482 [ + - ][ + - ]: 18 : delete pAxis;
2483 : 18 : pAxis = NULL;
2484 : 36 : }
2485 : 36 : }
2486 : :
2487 : 18 : void SchXMLExportHelper_Impl::exportAxes(
2488 : : const Reference< chart::XDiagram > & xDiagram,
2489 : : const Reference< chart2::XDiagram > & xNewDiagram,
2490 : : sal_Bool bExportContent )
2491 : : {
2492 : : DBG_ASSERT( xDiagram.is(), "Invalid XDiagram as parameter" );
2493 [ + - ]: 18 : if( ! xDiagram.is())
2494 : 18 : return;
2495 : :
2496 : : // get some properties from document first
2497 : 18 : sal_Bool bHasXAxis = sal_False,
2498 : 18 : bHasYAxis = sal_False,
2499 : 18 : bHasZAxis = sal_False,
2500 : 18 : bHasSecondaryXAxis = sal_False,
2501 : 18 : bHasSecondaryYAxis = sal_False;
2502 : 18 : sal_Bool bHasXAxisTitle = sal_False,
2503 : 18 : bHasYAxisTitle = sal_False,
2504 : 18 : bHasZAxisTitle = sal_False,
2505 : 18 : bHasSecondaryXAxisTitle = sal_False,
2506 : 18 : bHasSecondaryYAxisTitle = sal_False;
2507 : 18 : sal_Bool bHasXAxisMajorGrid = sal_False,
2508 : 18 : bHasXAxisMinorGrid = sal_False,
2509 : 18 : bHasYAxisMajorGrid = sal_False,
2510 : 18 : bHasYAxisMinorGrid = sal_False,
2511 : 18 : bHasZAxisMajorGrid = sal_False,
2512 : 18 : bHasZAxisMinorGrid = sal_False;
2513 : :
2514 : : // get multiple properties using XMultiPropertySet
2515 [ + - ]: 18 : MultiPropertySetHandler aDiagramProperties (xDiagram);
2516 : :
2517 : : aDiagramProperties.Add (
2518 [ + - ]: 18 : OUString("HasXAxis"), bHasXAxis);
2519 : : aDiagramProperties.Add (
2520 [ + - ]: 18 : OUString("HasYAxis"), bHasYAxis);
2521 : : aDiagramProperties.Add (
2522 [ + - ]: 18 : OUString("HasZAxis"), bHasZAxis);
2523 : : aDiagramProperties.Add (
2524 [ + - ]: 18 : OUString("HasSecondaryXAxis"), bHasSecondaryXAxis);
2525 : : aDiagramProperties.Add (
2526 [ + - ]: 18 : OUString("HasSecondaryYAxis"), bHasSecondaryYAxis);
2527 : :
2528 : : aDiagramProperties.Add (
2529 [ + - ]: 18 : OUString ("HasXAxisTitle"), bHasXAxisTitle);
2530 : : aDiagramProperties.Add (
2531 [ + - ]: 18 : OUString ("HasYAxisTitle"), bHasYAxisTitle);
2532 : : aDiagramProperties.Add (
2533 [ + - ]: 18 : OUString ("HasZAxisTitle"), bHasZAxisTitle);
2534 : : aDiagramProperties.Add (
2535 [ + - ]: 18 : OUString ("HasSecondaryXAxisTitle"), bHasSecondaryXAxisTitle);
2536 : : aDiagramProperties.Add (
2537 [ + - ]: 18 : OUString ("HasSecondaryYAxisTitle"), bHasSecondaryYAxisTitle);
2538 : :
2539 : : aDiagramProperties.Add (
2540 [ + - ]: 18 : OUString ("HasXAxisGrid"), bHasXAxisMajorGrid);
2541 : : aDiagramProperties.Add (
2542 [ + - ]: 18 : OUString ("HasYAxisGrid"), bHasYAxisMajorGrid);
2543 : : aDiagramProperties.Add (
2544 [ + - ]: 18 : OUString ("HasZAxisGrid"), bHasZAxisMajorGrid);
2545 : :
2546 : : aDiagramProperties.Add (
2547 [ + - ]: 18 : OUString ("HasXAxisHelpGrid"), bHasXAxisMinorGrid);
2548 : : aDiagramProperties.Add (
2549 [ + - ]: 18 : OUString ("HasYAxisHelpGrid"), bHasYAxisMinorGrid);
2550 : : aDiagramProperties.Add (
2551 [ + - ]: 18 : OUString ("HasZAxisHelpGrid"), bHasZAxisMinorGrid);
2552 : :
2553 [ + - ]: 18 : if ( ! aDiagramProperties.GetProperties ())
2554 : : {
2555 : : DBG_WARNING ("Required properties not found in Chart diagram");
2556 : : }
2557 : :
2558 [ + - ]: 18 : Reference< chart2::XCoordinateSystem > xCooSys( lcl_getCooSys(xNewDiagram) );
2559 : :
2560 : : // write an axis element also if the axis itself is not visible, but a grid or a title
2561 : :
2562 : 18 : OUString aCategoriesRange;
2563 [ + - ]: 18 : Reference< chart::XAxisSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY );
2564 : :
2565 : : // x axis
2566 : : // -------
2567 [ + - ]: 18 : Reference< ::com::sun::star::chart2::XAxis > xNewAxis = lcl_getAxis( xCooSys, XML_X );
2568 [ + - ]: 18 : if( xNewAxis.is() )
2569 : : {
2570 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(0) : 0, uno::UNO_QUERY );
[ + - ][ # # ]
[ + - ]
2571 [ + + ][ + - ]: 18 : if( mbHasCategoryLabels && bExportContent )
2572 : : {
2573 [ + - ]: 9 : Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2574 [ + - ]: 9 : if( xCategories.is() )
2575 : : {
2576 [ + - ][ + - ]: 9 : Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2577 [ + - ]: 9 : if( xValues.is() )
2578 : : {
2579 [ + - ]: 9 : Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
2580 [ + - ][ + - ]: 9 : maCategoriesRange = xValues->getSourceRangeRepresentation();
2581 [ + - ]: 9 : aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc );
2582 : 9 : }
2583 : 9 : }
2584 : : }
2585 [ + - ]: 18 : exportAxis( XML_X, XML_PRIMARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasXAxisTitle, bHasXAxisMajorGrid, bHasXAxisMinorGrid, bExportContent );
2586 : 18 : aCategoriesRange = OUString();
2587 : : }
2588 : :
2589 : : // secondary x axis
2590 : : // -------
2591 [ + - ]: 18 : Reference< chart::XSecondAxisTitleSupplier > xSecondTitleSupp( xDiagram, uno::UNO_QUERY );
2592 [ + - ][ + - ]: 18 : xNewAxis = lcl_getAxis( xCooSys, XML_X, false );
2593 [ - + ]: 18 : if( xNewAxis.is() )
2594 : : {
2595 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(0) : 0, uno::UNO_QUERY );
[ # # ][ # # ]
[ # # ]
2596 [ # # ]: 0 : exportAxis( XML_X, XML_SECONDARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryXAxisTitle, false, false, bExportContent );
2597 : : }
2598 : :
2599 : : // y axis
2600 : : // -------
2601 [ + - ][ + - ]: 18 : xNewAxis = lcl_getAxis( xCooSys, XML_Y );
2602 [ + - ]: 18 : if( xNewAxis.is() )
2603 : : {
2604 [ + - ][ + - ]: 18 : Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(1) : 0, uno::UNO_QUERY );
[ + - ][ # # ]
[ + - ]
2605 [ + - ]: 18 : exportAxis( XML_Y, XML_PRIMARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasYAxisTitle, bHasYAxisMajorGrid, bHasYAxisMinorGrid, bExportContent );
2606 : : }
2607 : :
2608 : : // secondary y axis
2609 : : // -------
2610 [ + - ][ + - ]: 18 : xNewAxis = lcl_getAxis( xCooSys, XML_Y, false );
2611 [ - + ]: 18 : if( xNewAxis.is() )
2612 : : {
2613 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(1) : 0, uno::UNO_QUERY );
[ # # ][ # # ]
[ # # ]
2614 [ # # ]: 0 : exportAxis( XML_Y, XML_SECONDARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryYAxisTitle, false, false, bExportContent );
2615 : : }
2616 : :
2617 : : // z axis
2618 : : // -------
2619 [ + - ][ + - ]: 18 : xNewAxis = lcl_getAxis( xCooSys, XML_Z );
2620 [ - + ]: 18 : if( xNewAxis.is() )
2621 : : {
2622 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(2) : 0, uno::UNO_QUERY );
[ # # ][ # # ]
[ # # ]
2623 [ # # ]: 0 : exportAxis( XML_Z, XML_PRIMARY_Z, xAxisProps, xNewAxis, aCategoriesRange, bHasZAxisTitle, bHasZAxisMajorGrid, bHasZAxisMinorGrid, bExportContent );
2624 [ + - ]: 18 : }
2625 : : }
2626 : :
2627 : : namespace
2628 : : {
2629 : 0 : bool lcl_hasNoValuesButText( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
2630 : : {
2631 [ # # ]: 0 : if( !xDataSequence.is() )
2632 : 0 : return false;//have no data
2633 : :
2634 [ # # ]: 0 : Sequence< uno::Any > aData;
2635 [ # # ]: 0 : Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY );
2636 [ # # ]: 0 : if( xNumericalDataSequence.is() )
2637 : : {
2638 [ # # ][ # # ]: 0 : Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() );
2639 : 0 : sal_Int32 nCount = aDoubles.getLength();
2640 [ # # ]: 0 : for( sal_Int32 i = 0; i < nCount; ++i )
2641 : : {
2642 [ # # ][ # # ]: 0 : if( !::rtl::math::isNan( aDoubles[i] ) )
2643 : 0 : return false;//have double value
2644 [ # # ][ # # ]: 0 : }
2645 : : }
2646 : : else
2647 : : {
2648 [ # # ][ # # ]: 0 : aData = xDataSequence->getData();
[ # # ][ # # ]
2649 : 0 : double fDouble = 0.0;
2650 : 0 : sal_Int32 nCount = aData.getLength();
2651 [ # # ]: 0 : for( sal_Int32 i = 0; i < nCount; ++i )
2652 : : {
2653 [ # # ][ # # ]: 0 : if( (aData[i] >>= fDouble) && !::rtl::math::isNan( fDouble ) )
[ # # ][ # # ]
2654 : 0 : return false;//have double value
2655 : : }
2656 : :
2657 : : }
2658 : : //no values found
2659 : :
2660 [ # # ]: 0 : Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
2661 [ # # ]: 0 : if( xTextualDataSequence.is() )
2662 : : {
2663 [ # # ][ # # ]: 0 : uno::Sequence< rtl::OUString > aStrings( xTextualDataSequence->getTextualData() );
2664 : 0 : sal_Int32 nCount = aStrings.getLength();
2665 [ # # ]: 0 : for( sal_Int32 i = 0; i < nCount; ++i )
2666 : : {
2667 [ # # ][ # # ]: 0 : if( !aStrings[i].isEmpty() )
2668 : 0 : return true;//have text
2669 [ # # ][ # # ]: 0 : }
2670 : : }
2671 : : else
2672 : : {
2673 [ # # ]: 0 : if( !aData.getLength() )
2674 [ # # ][ # # ]: 0 : aData = xDataSequence->getData();
[ # # ][ # # ]
2675 : 0 : uno::Any aAny;
2676 : 0 : OUString aString;
2677 : 0 : sal_Int32 nCount = aData.getLength();
2678 [ # # ]: 0 : for( sal_Int32 i = 0; i < nCount; ++i )
2679 : : {
2680 [ # # ][ # # ]: 0 : if( (aData[i]>>=aString) && !aString.isEmpty() )
[ # # ][ # # ]
2681 : 0 : return true;//have text
2682 [ # # ][ # # ]: 0 : }
2683 : : }
2684 : : //no doubles and no texts
2685 [ # # ]: 0 : return false;
2686 : : }
2687 : : }
2688 : :
2689 : 18 : void SchXMLExportHelper_Impl::exportSeries(
2690 : : const Reference< chart2::XDiagram > & xNewDiagram,
2691 : : const awt::Size & rPageSize,
2692 : : sal_Bool bExportContent,
2693 : : sal_Bool bHasTwoYAxes )
2694 : : {
2695 [ + - ]: 18 : Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY );
2696 [ - + ]: 18 : if( ! xBCooSysCnt.is())
2697 : 18 : return;
2698 [ + - ]: 18 : Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
2699 : :
2700 : 18 : OUString aFirstXDomainRange;
2701 : 18 : OUString aFirstYDomainRange;
2702 : :
2703 [ + - ]: 18 : std::vector< XMLPropertyState > aPropertyStates;
2704 : :
2705 : 18 : const OUString sNumFormat("NumberFormat");
2706 : 18 : const OUString sPercentageNumFormat( "PercentageNumberFormat");
2707 : :
2708 : : Sequence< Reference< chart2::XCoordinateSystem > >
2709 [ + - ][ + - ]: 18 : aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
2710 [ + + ]: 36 : for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
2711 : : {
2712 [ + - ][ + - ]: 18 : Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
2713 [ - + ]: 18 : if( ! xCTCnt.is())
2714 : 0 : continue;
2715 [ + - ][ + - ]: 18 : Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
2716 [ + + ]: 36 : for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
2717 : : {
2718 [ + - ][ + - ]: 18 : Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY );
2719 [ - + ]: 18 : if( ! xDSCnt.is())
2720 : 0 : continue;
2721 : : // note: if xDSCnt.is() then also aCTSeq[nCTIdx]
2722 [ + - ][ + - ]: 18 : OUString aChartType( aCTSeq[nCTIdx]->getChartType());
[ + - ]
2723 [ + - ][ + - ]: 18 : OUString aLabelRole = aCTSeq[nCTIdx]->getRoleOfSequenceForSeriesLabel();
[ + - ]
2724 : :
2725 : : // special export for stock charts
2726 [ - + ]: 18 : if ( aChartType == "com.sun.star.chart2.CandleStickChartType" )
2727 : : {
2728 : 0 : sal_Bool bJapaneseCandleSticks = sal_False;
2729 [ # # ][ # # ]: 0 : Reference< beans::XPropertySet > xCTProp( aCTSeq[nCTIdx], uno::UNO_QUERY );
2730 [ # # ]: 0 : if( xCTProp.is())
2731 [ # # ][ # # ]: 0 : xCTProp->getPropertyValue( OUString( "Japanese" )) >>= bJapaneseCandleSticks;
2732 : : exportCandleStickSeries(
2733 [ # # ][ # # ]: 0 : xDSCnt->getDataSeries(), xNewDiagram, bJapaneseCandleSticks, bExportContent );
[ # # ][ # # ]
2734 : 0 : continue;
2735 : : }
2736 : :
2737 : : // export dataseries for current chart-type
2738 [ + - ][ + - ]: 18 : Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
2739 [ + + ]: 92 : for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
2740 : : {
2741 : : // export series
2742 [ + - ][ + - ]: 74 : Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
2743 [ + - ]: 74 : if( xSource.is())
2744 : : {
2745 : 74 : SvXMLElementExport* pSeries = NULL;
2746 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
2747 [ + - ][ + - ]: 74 : xSource->getDataSequences());
2748 : 74 : sal_Int32 nMainSequenceIndex = -1;
2749 : 74 : sal_Int32 nSeriesLength = 0;
2750 : 74 : sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
2751 : 74 : sal_Bool bHasMeanValueLine = false;
2752 : 74 : chart::ChartRegressionCurveType eRegressionType( chart::ChartRegressionCurveType_NONE );
2753 : 74 : Reference< beans::XPropertySet > xPropSet;
2754 [ + - ]: 74 : tLabelValuesDataPair aSeriesLabelValuesPair;
2755 : :
2756 : : // search for main sequence and create a series element
2757 : : {
2758 : 74 : Reference< chart2::data::XDataSequence > xValuesSeq;
2759 : 74 : Reference< chart2::data::XDataSequence > xLabelSeq;
2760 : 74 : sal_Int32 nSeqIdx=0;
2761 [ + + ]: 148 : for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
2762 : : {
2763 : 74 : OUString aRole;
2764 [ + - ][ + - ]: 74 : Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
[ + - ]
2765 [ + - ]: 74 : if( nMainSequenceIndex==-1 )
2766 : : {
2767 [ + - ]: 74 : Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
2768 [ + - ]: 74 : if( xSeqProp.is())
2769 [ + - ][ + - ]: 74 : xSeqProp->getPropertyValue(OUString( "Role" )) >>= aRole;
2770 : : // "main" sequence
2771 [ + - ]: 74 : if( aRole.equals( aLabelRole ))
2772 : : {
2773 [ + - ]: 74 : xValuesSeq.set( xTempValueSeq );
2774 [ + - ][ + - ]: 74 : xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
[ + - ][ + - ]
2775 : 74 : nMainSequenceIndex = nSeqIdx;
2776 : 74 : }
2777 : : }
2778 [ + - ][ + - ]: 74 : sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
[ + - ][ + - ]
[ + - ][ # # ]
2779 [ + - ]: 74 : if( nSeriesLength < nSequenceLength )
2780 : 74 : nSeriesLength = nSequenceLength;
2781 : 74 : }
2782 : :
2783 : : // have found the main sequence, then xValuesSeq and
2784 : : // xLabelSeq contain those. Otherwise both are empty
2785 : : {
2786 : : // get property states for autostyles
2787 : : try
2788 : : {
2789 : : xPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet(
2790 [ + - ][ + - ]: 74 : aSeriesSeq[nSeriesIdx], mrExport.GetModel() );
[ + - ][ # # ]
2791 : : }
2792 [ # # ]: 0 : catch( const uno::Exception & rEx )
2793 : : {
2794 : : (void)rEx; // avoid warning for pro build
2795 : : OSL_TRACE(
2796 : : OUStringToOString(
2797 : : OUString( "Series not found or no XPropertySet: " ) +
2798 : : rEx.Message,
2799 : : RTL_TEXTENCODING_ASCII_US ).getStr());
2800 : 0 : continue;
2801 : : }
2802 [ + - ]: 74 : if( xPropSet.is())
2803 : : {
2804 : : // determine attached axis
2805 : : try
2806 : : {
2807 [ + - ]: 74 : Any aAny( xPropSet->getPropertyValue(
2808 [ + - ]: 74 : OUString( "Axis" )));
2809 : 74 : aAny >>= nAttachedAxis;
2810 : :
2811 [ + - ]: 74 : aAny = xPropSet->getPropertyValue(
2812 [ + - ]: 74 : OUString( "MeanValue" ));
2813 : 74 : aAny >>= bHasMeanValueLine;
2814 : :
2815 [ + - ]: 74 : aAny = xPropSet->getPropertyValue(
2816 [ + - ]: 74 : OUString( "RegressionCurves" ));
2817 [ # # ][ + - ]: 74 : aAny >>= eRegressionType;
2818 : : }
2819 [ # # ]: 0 : catch( const beans::UnknownPropertyException & rEx )
2820 : : {
2821 : : (void)rEx; // avoid warning for pro build
2822 : : OSL_TRACE(
2823 : : OUStringToOString(
2824 : : OUString( "Required property not found in DataRowProperties: " ) +
2825 : : rEx.Message,
2826 : : RTL_TEXTENCODING_ASCII_US ).getStr());
2827 : : }
2828 : :
2829 [ + - ][ + - ]: 74 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ + - ]
2830 [ + - ]: 74 : if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
2831 : : {
2832 [ + - ]: 74 : lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
2833 [ + - ]: 74 : lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
2834 : : }
2835 : :
2836 [ + - ]: 74 : if( mxExpPropMapper.is())
2837 [ + - ]: 74 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
2838 : : }
2839 : :
2840 [ + + ]: 74 : if( bExportContent )
2841 : : {
2842 [ - + ]: 37 : if( bHasTwoYAxes )
2843 : : {
2844 [ # # ]: 0 : if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
2845 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
2846 : : else
2847 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
2848 : : }
2849 : :
2850 : : // write style name
2851 [ + - ]: 37 : AddAutoStyleAttribute( aPropertyStates );
2852 : :
2853 [ + - ]: 37 : if( xValuesSeq.is())
2854 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS,
2855 : : lcl_ConvertRange(
2856 [ + - ]: 37 : xValuesSeq->getSourceRangeRepresentation(),
2857 [ + - ][ + - ]: 37 : xNewDoc ));
[ + - ]
2858 : : else
2859 : : // #i75297# allow empty series, export empty range to have all ranges on import
2860 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, OUString());
2861 : :
2862 [ + - ]: 37 : if( xLabelSeq.is())
2863 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
2864 : : lcl_ConvertRange(
2865 [ + - ]: 37 : xLabelSeq->getSourceRangeRepresentation(),
2866 [ + - ][ + - ]: 37 : xNewDoc ));
[ + - ]
2867 [ - + ][ # # ]: 37 : if( xLabelSeq.is() || xValuesSeq.is() )
[ + - ]
2868 [ + - ][ + - ]: 37 : aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq );
[ + - ]
2869 : :
2870 : : // chart-type for mixed types
2871 : : enum XMLTokenEnum eCTToken(
2872 [ + - ]: 37 : SchXMLTools::getTokenByChartType( aChartType, false /* bUseOldNames */ ));
2873 : : //@todo: get token for current charttype
2874 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
2875 : 37 : mrExport.GetNamespaceMap().GetQNameByKey(
2876 [ + - + - ]: 74 : XML_NAMESPACE_CHART, GetXMLToken( eCTToken )));
[ + - ]
2877 : :
2878 : : // open series element until end of for loop
2879 [ + - ][ + - ]: 37 : pSeries = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
2880 : : }
2881 : : else // autostyles
2882 : : {
2883 [ + - ]: 37 : CollectAutoStyle( aPropertyStates );
2884 : : }
2885 : : // remove property states for autostyles
2886 [ - + ]: 148 : aPropertyStates.clear();
2887 [ + - ]: 148 : }
2888 : : }
2889 : :
2890 : : // export domain elements if we have a series parent element
2891 [ + + ]: 74 : if( pSeries )
2892 : : {
2893 : : // domain elements
2894 [ + - ]: 37 : if( bExportContent )
2895 : : {
2896 : 37 : bool bIsScatterChart = aChartType == "com.sun.star.chart2.ScatterChartType";
2897 : 37 : bool bIsBubbleChart = aChartType == "com.sun.star.chart2.BubbleChartType";
2898 : 37 : Reference< chart2::data::XDataSequence > xYValuesForBubbleChart;
2899 [ - + ]: 37 : if( bIsBubbleChart )
2900 : : {
2901 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString( "values-y" ) ) );
2902 [ # # ]: 0 : if( xSequence.is() )
2903 : : {
2904 [ # # ][ # # ]: 0 : xYValuesForBubbleChart = xSequence->getValues();
[ # # ]
2905 [ # # ][ # # ]: 0 : if( !lcl_exportDomainForThisSequence( xYValuesForBubbleChart, aFirstYDomainRange, mrExport ) )
2906 [ # # ]: 0 : xYValuesForBubbleChart = 0;
2907 : 0 : }
2908 : : }
2909 [ + - ][ - + ]: 37 : if( bIsScatterChart || bIsBubbleChart )
2910 : : {
2911 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString( "values-x" ) ) );
2912 [ # # ]: 0 : if( xSequence.is() )
2913 : : {
2914 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
2915 [ # # ][ # # ]: 0 : if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ) )
2916 [ # # ][ # # ]: 0 : m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues ));
[ # # ][ # # ]
2917 : : }
2918 [ # # ]: 0 : else if( nSeriesIdx==0 )
2919 : : {
2920 : : //might be that the categories are used as x-values (e.g. for date axis) -> export them accordingly
2921 [ # # ]: 0 : Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2922 [ # # ]: 0 : if( xCategories.is() )
2923 : : {
2924 [ # # ][ # # ]: 0 : Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2925 [ # # ][ # # ]: 0 : if( !lcl_hasNoValuesButText( xValues ) )
2926 [ # # ]: 0 : lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport );
2927 : 0 : }
2928 : 0 : }
2929 : : }
2930 [ - + ]: 37 : if( xYValuesForBubbleChart.is() )
2931 [ # # ][ # # ]: 37 : m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xYValuesForBubbleChart ));
[ # # ][ # # ]
2932 : : }
2933 : : }
2934 : :
2935 : : // add sequences for main sequence after domain sequences,
2936 : : // so that the export of the local table has the correct order
2937 [ + + - + : 111 : if( bExportContent &&
# # ][ + + ]
2938 : 37 : (aSeriesLabelValuesPair.first.is() || aSeriesLabelValuesPair.second.is()))
2939 [ + - ]: 37 : m_aDataSequencesToExport.push_back( aSeriesLabelValuesPair );
2940 : :
2941 : : // statistical objects:
2942 : : // regression curves and mean value lines
2943 [ - + # # : 74 : if( bHasMeanValueLine &&
# # ][ - + ]
2944 : 0 : xPropSet.is() &&
2945 : 0 : mxExpPropMapper.is() )
2946 : : {
2947 : 0 : Reference< beans::XPropertySet > xStatProp;
2948 : : try
2949 : : {
2950 [ # # ]: 0 : Any aPropAny( xPropSet->getPropertyValue(
2951 [ # # ]: 0 : OUString( "DataMeanValueProperties" )));
2952 [ # # ][ # # ]: 0 : aPropAny >>= xStatProp;
2953 : : }
2954 [ # # ]: 0 : catch( const uno::Exception & rEx )
2955 : : {
2956 : : (void)rEx; // avoid warning for pro build
2957 : : OSL_TRACE( "Exception caught during Export of series - optional DataMeanValueProperties not available: %s",
2958 : : OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
2959 : : }
2960 : :
2961 [ # # ]: 0 : if( xStatProp.is() )
2962 : : {
2963 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xStatProp );
2964 : :
2965 [ # # ]: 0 : if( !aPropertyStates.empty() )
2966 : : {
2967 : : // write element
2968 [ # # ]: 0 : if( bExportContent )
2969 : : {
2970 : : // add style name attribute
2971 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
2972 : :
2973 [ # # ][ # # ]: 0 : SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_MEAN_VALUE, sal_True, sal_True );
2974 : : }
2975 : : else // autostyles
2976 : : {
2977 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
2978 : : }
2979 : : }
2980 : 0 : }
2981 : : }
2982 : :
2983 [ - + # # : 74 : if( eRegressionType != chart::ChartRegressionCurveType_NONE &&
# # ][ - + ]
2984 : 0 : xPropSet.is() &&
2985 : 0 : mxExpPropMapper.is() )
2986 : : {
2987 [ # # ][ # # ]: 0 : exportRegressionCurve( aSeriesSeq[nSeriesIdx], xPropSet, rPageSize, bExportContent );
2988 : : }
2989 : :
2990 [ + - ]: 74 : exportErrorBar( xPropSet,false, bExportContent ); // X ErrorBar
2991 [ + - ]: 74 : exportErrorBar( xPropSet,true, bExportContent ); // Y ErrorBar
2992 : :
2993 : : exportDataPoints(
2994 [ + - ]: 74 : uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
2995 [ + - ][ + - ]: 74 : nSeriesLength, xNewDiagram, bExportContent );
2996 : :
2997 : : // close series element
2998 [ + + ]: 74 : if( pSeries )
2999 [ + - ][ + - ]: 74 : delete pSeries;
[ + - ][ - + ]
[ - + ][ + - ]
[ + - ]
3000 : : }
3001 [ + - ]: 74 : }
3002 : 18 : aPropertyStates.clear();
3003 [ - + ][ - + ]: 18 : }
[ + - ][ + - ]
3004 [ + - ][ + - ]: 36 : }
[ + - ][ + - ]
3005 : : }
3006 : :
3007 : 0 : void SchXMLExportHelper_Impl::exportRegressionCurve(
3008 : : const Reference< chart2::XDataSeries > & xSeries,
3009 : : const Reference< beans::XPropertySet > & xSeriesProp,
3010 : : const awt::Size & rPageSize,
3011 : : sal_Bool bExportContent )
3012 : : {
3013 : : OSL_ASSERT( mxExpPropMapper.is());
3014 : :
3015 [ # # ]: 0 : std::vector< XMLPropertyState > aPropertyStates;
3016 [ # # ]: 0 : std::vector< XMLPropertyState > aEquationPropertyStates;
3017 : 0 : Reference< beans::XPropertySet > xStatProp;
3018 : : try
3019 : : {
3020 [ # # ]: 0 : Any aPropAny( xSeriesProp->getPropertyValue(
3021 [ # # ]: 0 : OUString( "DataRegressionProperties" )));
3022 [ # # ][ # # ]: 0 : aPropAny >>= xStatProp;
3023 : : }
3024 [ # # ]: 0 : catch( const uno::Exception & rEx )
3025 : : {
3026 : : (void)rEx; // avoid warning for pro build
3027 : : OSL_TRACE( "Exception caught during Export of series - optional DataRegressionProperties not available: %s",
3028 : : OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
3029 : : }
3030 : :
3031 [ # # ]: 0 : if( xStatProp.is() )
3032 : : {
3033 [ # # ]: 0 : Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( xSeries ));
3034 : 0 : Reference< beans::XPropertySet > xEquationProperties;
3035 [ # # ]: 0 : if( xRegCurve.is())
3036 [ # # ][ # # ]: 0 : xEquationProperties.set( xRegCurve->getEquationProperties());
[ # # ]
3037 : :
3038 : 0 : bool bShowEquation = false;
3039 : 0 : bool bShowRSquared = false;
3040 : 0 : bool bExportEquation = false;
3041 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xStatProp );
3042 [ # # ]: 0 : if( xEquationProperties.is())
3043 : : {
3044 [ # # ]: 0 : xEquationProperties->getPropertyValue( OUString( "ShowEquation" ))
3045 [ # # ]: 0 : >>= bShowEquation;
3046 [ # # ]: 0 : xEquationProperties->getPropertyValue( OUString( "ShowCorrelationCoefficient" ))
3047 [ # # ]: 0 : >>= bShowRSquared;
3048 [ # # ][ # # ]: 0 : bExportEquation = ( bShowEquation || bShowRSquared );
3049 [ # # ][ # # ]: 0 : const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ # # ]
3050 [ # # ]: 0 : if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
3051 : 0 : bExportEquation=false;
3052 [ # # ]: 0 : if( bExportEquation )
3053 : : {
3054 : : // number format
3055 : 0 : sal_Int32 nNumberFormat = 0;
3056 [ # # # # ]: 0 : if( ( xEquationProperties->getPropertyValue(
[ # # ][ # # ]
3057 [ # # ][ # # ]: 0 : OUString( "NumberFormat" )) >>= nNumberFormat ) &&
[ # # ][ # # ]
[ # # # #
# # ]
3058 : : nNumberFormat != -1 )
3059 : : {
3060 [ # # ]: 0 : mrExport.addDataStyle( nNumberFormat );
3061 : : }
3062 [ # # ]: 0 : aEquationPropertyStates = mxExpPropMapper->Filter( xEquationProperties );
3063 : : }
3064 : : }
3065 : :
3066 [ # # ][ # # ]: 0 : if( !aPropertyStates.empty() || bExportEquation )
[ # # ]
3067 : : {
3068 : : // write element
3069 [ # # ]: 0 : if( bExportContent )
3070 : : {
3071 : : // add style name attribute
3072 [ # # ]: 0 : if( !aPropertyStates.empty())
3073 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
3074 [ # # ]: 0 : SvXMLElementExport aRegressionExport( mrExport, XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, sal_True, sal_True );
3075 [ # # ]: 0 : if( bExportEquation )
3076 : : {
3077 : : // default is true
3078 [ # # ]: 0 : if( !bShowEquation )
3079 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_FALSE );
3080 : : // default is false
3081 [ # # ]: 0 : if( bShowRSquared )
3082 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TRUE );
3083 : :
3084 : : // export position
3085 : 0 : chart2::RelativePosition aRelativePosition;
3086 [ # # # # ]: 0 : if( xEquationProperties->getPropertyValue(
3087 [ # # ][ # # ]: 0 : OUString( "RelativePosition")) >>= aRelativePosition )
3088 : : {
3089 : 0 : double fX = aRelativePosition.Primary * rPageSize.Width;
3090 : 0 : double fY = aRelativePosition.Secondary * rPageSize.Height;
3091 : 0 : awt::Point aPos;
3092 : 0 : aPos.X = static_cast< sal_Int32 >( ::rtl::math::round( fX ));
3093 : 0 : aPos.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY ));
3094 [ # # ]: 0 : addPosition( aPos );
3095 : : }
3096 : :
3097 [ # # ]: 0 : if( !aEquationPropertyStates.empty())
3098 [ # # ]: 0 : AddAutoStyleAttribute( aEquationPropertyStates );
3099 : :
3100 [ # # ][ # # ]: 0 : SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_EQUATION, sal_True, sal_True );
3101 [ # # ]: 0 : }
3102 : : }
3103 : : else // autostyles
3104 : : {
3105 [ # # ]: 0 : if( !aPropertyStates.empty())
3106 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
3107 [ # # ][ # # ]: 0 : if( bExportEquation && !aEquationPropertyStates.empty())
[ # # ]
3108 [ # # ]: 0 : CollectAutoStyle( aEquationPropertyStates );
3109 : : }
3110 : 0 : }
3111 : 0 : }
3112 : 0 : }
3113 : :
3114 : 148 : void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySet> &xSeriesProp,
3115 : : bool bYError, bool bExportContent )
3116 : : {
3117 : : assert(mxExpPropMapper.is());
3118 : :
3119 [ + - ]: 148 : const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
3120 : :
3121 : : /// Dont export X ErrorBars for older ODF versions.
3122 [ - + ][ + + ]: 148 : if ( !bYError && nCurrentVersion <= SvtSaveOptions::ODFVER_012 )
3123 : 148 : return;
3124 : :
3125 [ + - ]: 148 : if (xSeriesProp.is())
3126 : : {
3127 : 148 : bool bNegative = false, bPositive = false;
3128 : 148 : sal_Int32 nErrorBarStyle = chart::ErrorBarStyle::NONE;
3129 : 148 : Reference< beans::XPropertySet > xErrorBarProp;
3130 : :
3131 : : try
3132 : : {
3133 : 148 : Any aAny;
3134 : :
3135 [ + + ][ + - ]: 148 : aAny = xSeriesProp->getPropertyValue( bYError ? rtl::OUString("ErrorBarY") : rtl::OUString("ErrorBarX") );
[ + + ][ + + ]
[ # # # # ]
[ + - ]
3136 [ + - ]: 148 : aAny >>= xErrorBarProp;
3137 : :
3138 [ - + ]: 148 : if ( xErrorBarProp.is() )
3139 : : {
3140 [ # # ][ # # ]: 0 : aAny = xErrorBarProp->getPropertyValue("ShowNegativeError" );
3141 : 0 : aAny >>= bNegative;
3142 : :
3143 [ # # ][ # # ]: 0 : aAny = xErrorBarProp->getPropertyValue("ShowPositiveError" );
3144 : 0 : aAny >>= bPositive;
3145 : :
3146 [ # # ][ # # ]: 0 : aAny = xErrorBarProp->getPropertyValue("ErrorBarStyle" );
3147 : 0 : aAny >>= nErrorBarStyle;
3148 [ # # ]: 148 : }
3149 : : }
3150 [ # # ]: 0 : catch( const beans::UnknownPropertyException & rEx )
3151 : : {
3152 : : (void)rEx; // avoid warning for pro build
3153 : : OSL_TRACE(
3154 : : OUStringToOString(OUString("Required property not found in DataRowProperties: " ) +
3155 : : rEx.Message,
3156 : : RTL_TEXTENCODING_ASCII_US ).getStr());
3157 : : }
3158 : :
3159 [ - + ][ # # ]: 148 : if( nErrorBarStyle != chart::ErrorBarStyle::NONE && (bNegative || bPositive))
[ # # ]
3160 : : {
3161 [ # # ][ # # ]: 0 : if( bExportContent && nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
3162 : : {
3163 [ # # ]: 0 : uno::Reference< chart2::XChartDocument > xNewDoc(mrExport.GetModel(), uno::UNO_QUERY);
3164 : :
3165 : : // register data ranges for error bars for export in local table
3166 : : ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
3167 [ # # ]: 0 : lcl_getErrorBarSequences( xErrorBarProp ));
3168 [ # # ][ # # ]: 0 : for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
3169 [ # # ]: 0 : aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
3170 : : {
3171 [ # # ]: 0 : if ( nCurrentVersion > SvtSaveOptions::ODFVER_012 )
3172 : : {
3173 : 0 : rtl::OUString aRole, aRange;
3174 [ # # ]: 0 : Reference< beans::XPropertySet > xSeqProp( *aIt, uno::UNO_QUERY_THROW );
3175 [ # # ][ # # ]: 0 : xSeqProp->getPropertyValue("Role") >>= aRole;
3176 : :
3177 [ # # ][ # # ]: 0 : aRange = lcl_ConvertRange((*aIt)->getSourceRangeRepresentation(), xNewDoc );
[ # # ]
3178 : :
3179 [ # # ]: 0 : if ( aRole.indexOf("positive") != -1 )
3180 : : {
3181 [ # # ]: 0 : if ( bPositive )
3182 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_UPPER_RANGE, aRange );
3183 : : }
3184 : : else
3185 : : {
3186 [ # # ]: 0 : if ( bNegative )
3187 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_LOWER_RANGE, aRange );
3188 : 0 : }
3189 : : }
3190 : :
3191 [ # # ][ # # ]: 0 : m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
[ # # ][ # # ]
3192 : 0 : }
3193 : : }
3194 : :
3195 [ # # ]: 0 : std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xErrorBarProp );
3196 : :
3197 [ # # ]: 0 : if( !aPropertyStates.empty() )
3198 : : {
3199 : : // write element
3200 [ # # ]: 0 : if( bExportContent )
3201 : : {
3202 : : // add style name attribute
3203 [ # # ]: 0 : AddAutoStyleAttribute( aPropertyStates );
3204 : :
3205 [ # # ]: 0 : if( nCurrentVersion >= SvtSaveOptions::ODFVER_012 )
3206 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, bYError ? XML_Y : XML_X );//#i114149#
3207 [ # # ][ # # ]: 0 : SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, sal_True, sal_True );
3208 : : }
3209 : : else // autostyles
3210 : : {
3211 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
3212 : : }
3213 : 0 : }
3214 : 148 : }
3215 : : }
3216 : : }
3217 : :
3218 : 0 : void SchXMLExportHelper_Impl::exportCandleStickSeries(
3219 : : const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
3220 : : const Reference< chart2::XDiagram > & xDiagram,
3221 : : sal_Bool bJapaneseCandleSticks,
3222 : : sal_Bool bExportContent )
3223 : : {
3224 : :
3225 [ # # ]: 0 : for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
3226 : : {
3227 : 0 : Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
3228 [ # # ]: 0 : sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
3229 : : ? chart::ChartAxisAssign::PRIMARY_Y
3230 [ # # ]: 0 : : chart::ChartAxisAssign::SECONDARY_Y;
3231 : :
3232 [ # # ]: 0 : Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
3233 [ # # ]: 0 : if( xSource.is())
3234 : : {
3235 : : // export series in correct order (as we don't store roles)
3236 : : // with japanese candlesticks: open, low, high, close
3237 : : // otherwise: low, high, close
3238 : : Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
3239 [ # # ][ # # ]: 0 : xSource->getDataSequences());
3240 : :
3241 : : sal_Int32 nSeriesLength =
3242 [ # # ]: 0 : lcl_getSequenceLengthByRole( aSeqCnt, OUString( "values-last" ));
3243 : :
3244 [ # # ]: 0 : if( bExportContent )
3245 : : {
3246 [ # # ]: 0 : Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
3247 : : //@todo: export data points
3248 : :
3249 : : // open
3250 [ # # ]: 0 : if( bJapaneseCandleSticks )
3251 : : {
3252 : : tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3253 [ # # ]: 0 : aSeqCnt, OUString( "values-first" ), xNewDoc, m_aDataSequencesToExport ));
3254 [ # # ]: 0 : if( !aRanges.second.isEmpty())
3255 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
3256 [ # # ]: 0 : if( !aRanges.first.isEmpty())
3257 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
3258 [ # # ]: 0 : if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3259 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
3260 : : else
3261 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
3262 [ # # ]: 0 : SvXMLElementExport aOpenSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
3263 : : // export empty data points
3264 [ # # ][ # # ]: 0 : exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
[ # # ]
3265 : : }
3266 : :
3267 : : // low
3268 : : {
3269 : : tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3270 [ # # ]: 0 : aSeqCnt, OUString( "values-min" ), xNewDoc, m_aDataSequencesToExport ));
3271 [ # # ]: 0 : if( !aRanges.second.isEmpty())
3272 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
3273 [ # # ]: 0 : if( !aRanges.first.isEmpty())
3274 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
3275 [ # # ]: 0 : if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3276 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
3277 : : else
3278 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
3279 [ # # ]: 0 : SvXMLElementExport aLowSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
3280 : : // export empty data points
3281 [ # # ][ # # ]: 0 : exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
[ # # ]
3282 : : }
3283 : :
3284 : : // high
3285 : : {
3286 : : tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3287 [ # # ]: 0 : aSeqCnt, OUString( "values-max" ), xNewDoc, m_aDataSequencesToExport ));
3288 [ # # ]: 0 : if( !aRanges.second.isEmpty())
3289 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
3290 [ # # ]: 0 : if( !aRanges.first.isEmpty())
3291 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
3292 [ # # ]: 0 : if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3293 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
3294 : : else
3295 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
3296 [ # # ]: 0 : SvXMLElementExport aHighSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
3297 : : // export empty data points
3298 [ # # ][ # # ]: 0 : exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
[ # # ]
3299 : : }
3300 : :
3301 : : // close
3302 : : {
3303 : : tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3304 [ # # ]: 0 : aSeqCnt, OUString( "values-last" ), xNewDoc, m_aDataSequencesToExport ));
3305 [ # # ]: 0 : if( !aRanges.second.isEmpty())
3306 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
3307 [ # # ]: 0 : if( !aRanges.first.isEmpty())
3308 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
3309 [ # # ]: 0 : if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3310 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
3311 : : else
3312 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
3313 [ # # ]: 0 : SvXMLElementExport aCloseSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
3314 : : // export empty data points
3315 [ # # ][ # # ]: 0 : exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
[ # # ]
3316 : 0 : }
3317 : : }
3318 : : else // autostyles
3319 : : {
3320 : : // for close series
3321 [ # # ]: 0 : }
3322 : : // remove property states for autostyles
3323 : : }
3324 : 0 : }
3325 : 0 : }
3326 : :
3327 : 74 : void SchXMLExportHelper_Impl::exportDataPoints(
3328 : : const uno::Reference< beans::XPropertySet > & xSeriesProperties,
3329 : : sal_Int32 nSeriesLength,
3330 : : const uno::Reference< chart2::XDiagram > & xDiagram,
3331 : : sal_Bool bExportContent )
3332 : : {
3333 : : // data-points
3334 : : // -----------
3335 : : // write data-points only if they contain autostyles
3336 : : // objects with equal autostyles are grouped using the attribute
3337 : : // repeat="number"
3338 : :
3339 : : // Note: if only the nth data-point has autostyles there is an element
3340 : : // without style and repeat="n-1" attribute written in advance.
3341 : :
3342 : : // the sequence aDataPointSeq contains indices of data-points that
3343 : : // do have own attributes. This increases the performance substantially.
3344 : :
3345 : : // more performant version for #93600#
3346 [ + - ]: 74 : if( mxExpPropMapper.is())
3347 : : {
3348 [ + - ]: 74 : uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY );
3349 : :
3350 [ + - ]: 74 : std::vector< XMLPropertyState > aPropertyStates;
3351 : :
3352 : 74 : const OUString sNumFormat("NumberFormat");
3353 : 74 : const OUString sPercentageNumFormat( "PercentageNumberFormat");
3354 : :
3355 : 74 : bool bVaryColorsByPoint = false;
3356 [ + - ]: 74 : Sequence< sal_Int32 > aDataPointSeq;
3357 [ + - ]: 74 : if( xSeriesProperties.is())
3358 : : {
3359 [ + - ]: 74 : Any aAny = xSeriesProperties->getPropertyValue(
3360 [ + - ]: 74 : OUString( "AttributedDataPoints" ));
3361 [ + - ]: 74 : aAny >>= aDataPointSeq;
3362 [ + - ]: 74 : xSeriesProperties->getPropertyValue(
3363 [ + - ]: 74 : OUString( "VaryColorsByPoint" )) >>= bVaryColorsByPoint;
3364 : : }
3365 : :
3366 : :
3367 : 74 : sal_Int32 nSize = aDataPointSeq.getLength();
3368 : : DBG_ASSERT( nSize <= nSeriesLength, "Too many point attributes" );
3369 : :
3370 : 74 : const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
3371 : : sal_Int32 nElement;
3372 : : sal_Int32 nRepeat;
3373 : 74 : Reference< chart2::XColorScheme > xColorScheme;
3374 [ + - ]: 74 : if( xDiagram.is())
3375 [ + - ][ + - ]: 74 : xColorScheme.set( xDiagram->getDefaultColorScheme());
[ + - ]
3376 : :
3377 [ + - ]: 74 : ::std::list< SchXMLDataPointStruct > aDataPointList;
3378 : :
3379 : 74 : sal_Int32 nLastIndex = -1;
3380 : 74 : sal_Int32 nCurrIndex = 0;
3381 : :
3382 : : // collect elements
3383 [ - + ][ # # ]: 74 : if( bVaryColorsByPoint && xColorScheme.is() )
[ - + ]
3384 : : {
3385 [ # # ]: 0 : ::std::set< sal_Int32 > aAttrPointSet;
3386 : 0 : ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(),
3387 [ # # # # ]: 0 : ::std::inserter( aAttrPointSet, aAttrPointSet.begin()));
3388 : 0 : const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end());
3389 [ # # ]: 0 : for( nElement = 0; nElement < nSeriesLength; ++nElement )
3390 : : {
3391 : 0 : aPropertyStates.clear();
3392 : 0 : uno::Reference< beans::XPropertySet > xPropSet;
3393 : 0 : bool bExportNumFmt = false;
3394 [ # # ][ # # ]: 0 : if( aAttrPointSet.find( nElement ) != aEndIt )
[ # # ]
3395 : : {
3396 : : try
3397 : : {
3398 : : xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
3399 [ # # ][ # # ]: 0 : xSeries, nElement, mrExport.GetModel() );
[ # # ]
3400 : 0 : bExportNumFmt = true;
3401 : : }
3402 [ # # ]: 0 : catch( const uno::Exception & rEx )
3403 : : {
3404 : : (void)rEx; // avoid warning for pro build
3405 : : OSL_TRACE( "Exception caught during Export of data point: %s",
3406 : : OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
3407 : : }
3408 : : }
3409 : : else
3410 : : {
3411 : : // property set only containing the color
3412 : : xPropSet.set( new ::xmloff::chart::ColorPropertySet(
3413 [ # # ][ # # ]: 0 : xColorScheme->getColorByIndex( nElement )));
[ # # ][ # # ]
[ # # ]
3414 : : }
3415 : : DBG_ASSERT( xPropSet.is(), "Pie Segments should have properties" );
3416 [ # # ]: 0 : if( xPropSet.is())
3417 : : {
3418 [ # # ][ # # ]: 0 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ # # ]
3419 [ # # ][ # # ]: 0 : if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 && bExportNumFmt )
3420 : : {
3421 [ # # ]: 0 : lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
3422 [ # # ]: 0 : lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
3423 : : }
3424 : :
3425 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
3426 [ # # ]: 0 : if( !aPropertyStates.empty() )
3427 : : {
3428 [ # # ]: 0 : if( bExportContent )
3429 : : {
3430 : : // write data-point with style
3431 : : DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
3432 : :
3433 : 0 : SchXMLDataPointStruct aPoint;
3434 [ # # ]: 0 : aPoint.maStyleName = maAutoStyleNameQueue.front();
3435 [ # # ]: 0 : maAutoStyleNameQueue.pop();
3436 [ # # ]: 0 : aDataPointList.push_back( aPoint );
3437 : : }
3438 : : else
3439 : : {
3440 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
3441 : : }
3442 : : }
3443 : : }
3444 : 0 : }
3445 : : DBG_ASSERT( !bExportContent || (static_cast<sal_Int32>(aDataPointList.size()) == nSeriesLength),
3446 : 0 : "not enough data points on content export" );
3447 : : }
3448 : : else
3449 : : {
3450 [ - + ]: 74 : for( nElement = 0; nElement < nSize; ++nElement )
3451 : : {
3452 : 0 : aPropertyStates.clear();
3453 : 0 : nCurrIndex = pPoints[ nElement ];
3454 : : //assuming sorted indices in pPoints
3455 : :
3456 [ # # ][ # # ]: 0 : if( nCurrIndex<0 || nCurrIndex>=nSeriesLength )
3457 : : break;
3458 : :
3459 : : // write leading empty data points
3460 [ # # ]: 0 : if( nCurrIndex - nLastIndex > 1 )
3461 : : {
3462 : 0 : SchXMLDataPointStruct aPoint;
3463 : 0 : aPoint.mnRepeat = nCurrIndex - nLastIndex - 1;
3464 [ # # ]: 0 : aDataPointList.push_back( aPoint );
3465 : : }
3466 : :
3467 : 0 : uno::Reference< beans::XPropertySet > xPropSet;
3468 : : // get property states
3469 : : try
3470 : : {
3471 : : xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
3472 [ # # ][ # # ]: 0 : xSeries, nCurrIndex, mrExport.GetModel() );
[ # # ]
3473 : : }
3474 [ # # ]: 0 : catch( const uno::Exception & rEx )
3475 : : {
3476 : : (void)rEx; // avoid warning for pro build
3477 : : OSL_TRACE( "Exception caught during Export of data point: %s",
3478 : : OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
3479 : : }
3480 [ # # ]: 0 : if( xPropSet.is())
3481 : : {
3482 [ # # ][ # # ]: 0 : const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
[ # # ]
3483 [ # # ]: 0 : if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
3484 : : {
3485 [ # # ]: 0 : lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
3486 [ # # ]: 0 : lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
3487 : : }
3488 : :
3489 [ # # ]: 0 : aPropertyStates = mxExpPropMapper->Filter( xPropSet );
3490 [ # # ]: 0 : if( !aPropertyStates.empty() )
3491 : : {
3492 [ # # ]: 0 : if( bExportContent )
3493 : : {
3494 : : // write data-point with style
3495 : : DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
3496 : 0 : SchXMLDataPointStruct aPoint;
3497 [ # # ]: 0 : aPoint.maStyleName = maAutoStyleNameQueue.front();
3498 [ # # ]: 0 : maAutoStyleNameQueue.pop();
3499 : :
3500 [ # # ]: 0 : aDataPointList.push_back( aPoint );
3501 : 0 : nLastIndex = nCurrIndex;
3502 : : }
3503 : : else
3504 : : {
3505 [ # # ]: 0 : CollectAutoStyle( aPropertyStates );
3506 : : }
3507 : 0 : continue;
3508 : : }
3509 : : }
3510 : :
3511 : : // if we get here the property states are empty
3512 : 0 : SchXMLDataPointStruct aPoint;
3513 [ # # ]: 0 : aDataPointList.push_back( aPoint );
3514 : :
3515 : 0 : nLastIndex = nCurrIndex;
3516 [ # # ]: 0 : }
3517 : : // final empty elements
3518 : 74 : nRepeat = nSeriesLength - nLastIndex - 1;
3519 [ + - ]: 74 : if( nRepeat > 0 )
3520 : : {
3521 : 74 : SchXMLDataPointStruct aPoint;
3522 : 74 : aPoint.mnRepeat = nRepeat;
3523 [ + - ]: 74 : aDataPointList.push_back( aPoint );
3524 : : }
3525 : : }
3526 : :
3527 [ + + ]: 74 : if( bExportContent )
3528 : : {
3529 : : // write elements (merge equal ones)
3530 : 37 : ::std::list< SchXMLDataPointStruct >::iterator aIter = aDataPointList.begin();
3531 : 37 : SchXMLDataPointStruct aPoint;
3532 : 37 : SchXMLDataPointStruct aLastPoint;
3533 : :
3534 : : // initialize so that it doesn't matter if
3535 : : // the element is counted in the first iteration
3536 : 37 : aLastPoint.mnRepeat = 0;
3537 : :
3538 [ + + ]: 74 : for( ; aIter != aDataPointList.end(); ++aIter )
3539 : : {
3540 : 37 : aPoint = (*aIter);
3541 : :
3542 [ + - ]: 37 : if( aPoint.maStyleName == aLastPoint.maStyleName )
3543 : 37 : aPoint.mnRepeat += aLastPoint.mnRepeat;
3544 [ # # ]: 0 : else if( aLastPoint.mnRepeat > 0 )
3545 : : {
3546 : : // write last element
3547 [ # # ]: 0 : if( !aLastPoint.maStyleName.isEmpty() )
3548 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
3549 : :
3550 [ # # ]: 0 : if( aLastPoint.mnRepeat > 1 )
3551 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED,
3552 [ # # ]: 0 : OUString::valueOf( (sal_Int64)( aLastPoint.mnRepeat ) ));
3553 : :
3554 [ # # ][ # # ]: 0 : SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, sal_True, sal_True );
3555 : : }
3556 : 37 : aLastPoint = aPoint;
3557 : : }
3558 : : // write last element if it hasn't been written in last iteration
3559 [ + - ]: 37 : if( aPoint.maStyleName == aLastPoint.maStyleName )
3560 : : {
3561 [ - + ]: 37 : if( !aLastPoint.maStyleName.isEmpty() )
3562 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
3563 : :
3564 [ + - ]: 37 : if( aLastPoint.mnRepeat > 1 )
3565 : : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED,
3566 [ + - ]: 37 : OUString::valueOf( (sal_Int64)( aLastPoint.mnRepeat ) ));
3567 : :
3568 [ + - ][ + - ]: 37 : SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, sal_True, sal_True );
3569 : 37 : }
3570 [ + - ]: 74 : }
3571 : : }
3572 : 74 : }
3573 : :
3574 : 27 : void SchXMLExportHelper_Impl::addPosition( const awt::Point & rPosition )
3575 : : {
3576 : 27 : mrExport.GetMM100UnitConverter().convertMeasureToXML(
3577 : 27 : msStringBuffer, rPosition.X );
3578 : 27 : msString = msStringBuffer.makeStringAndClear();
3579 : 27 : mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, msString );
3580 : :
3581 : 27 : mrExport.GetMM100UnitConverter().convertMeasureToXML(
3582 : 27 : msStringBuffer, rPosition.Y );
3583 : 27 : msString = msStringBuffer.makeStringAndClear();
3584 : 27 : mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, msString );
3585 : 27 : }
3586 : :
3587 : 18 : void SchXMLExportHelper_Impl::addPosition( Reference< drawing::XShape > xShape )
3588 : : {
3589 [ + - ]: 18 : if( xShape.is())
3590 [ + - ]: 18 : addPosition( xShape->getPosition());
3591 : 18 : }
3592 : :
3593 : 27 : void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize, bool bIsOOoNamespace)
3594 : : {
3595 : 27 : mrExport.GetMM100UnitConverter().convertMeasureToXML(
3596 : 27 : msStringBuffer, rSize.Width );
3597 : 27 : msString = msStringBuffer.makeStringAndClear();
3598 [ - + ]: 27 : mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG , XML_WIDTH, msString );
3599 : :
3600 : :
3601 : 27 : mrExport.GetMM100UnitConverter().convertMeasureToXML(
3602 : 27 : msStringBuffer, rSize.Height);
3603 : 27 : msString = msStringBuffer.makeStringAndClear();
3604 [ - + ]: 27 : mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG, XML_HEIGHT, msString );
3605 : 27 : }
3606 : :
3607 : 9 : void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape, bool bIsOOoNamespace )
3608 : : {
3609 [ + - ]: 9 : if( xShape.is())
3610 [ + - ]: 9 : addSize( xShape->getSize(), bIsOOoNamespace );
3611 : 9 : }
3612 : :
3613 : 18 : awt::Size SchXMLExportHelper_Impl::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ) const
3614 : : {
3615 : 18 : awt::Size aSize( 8000, 7000 );
3616 [ + - ]: 18 : uno::Reference< embed::XVisualObject > xVisualObject( xChartDoc, uno::UNO_QUERY );
3617 : : DBG_ASSERT( xVisualObject.is(),"need XVisualObject for page size" );
3618 [ + - ]: 18 : if( xVisualObject.is() )
3619 [ + - ][ + - ]: 18 : aSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
3620 : :
3621 : 18 : return aSize;
3622 : : }
3623 : :
3624 : 109 : void SchXMLExportHelper_Impl::CollectAutoStyle( const std::vector< XMLPropertyState >& aStates )
3625 : : {
3626 [ + - ]: 109 : if( !aStates.empty() )
3627 [ + - ]: 109 : maAutoStyleNameQueue.push( GetAutoStylePoolP().Add( XML_STYLE_FAMILY_SCH_CHART_ID, aStates ));
3628 : 109 : }
3629 : :
3630 : 109 : void SchXMLExportHelper_Impl::AddAutoStyleAttribute( const std::vector< XMLPropertyState >& aStates )
3631 : : {
3632 [ + - ]: 109 : if( !aStates.empty() )
3633 : : {
3634 : : DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
3635 : :
3636 : 109 : mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, maAutoStyleNameQueue.front() );
3637 : 109 : maAutoStyleNameQueue.pop();
3638 : : }
3639 : 109 : }
3640 : :
3641 : 207 : void SchXMLExportHelper_Impl::exportText( const OUString& rText, bool bConvertTabsLFs )
3642 : : {
3643 : 207 : SchXMLTools::exportText( mrExport, rText, bConvertTabsLFs );
3644 : 207 : }
3645 : :
3646 : : // ========================================
3647 : : // class SchXMLExport
3648 : : // ========================================
3649 : :
3650 : : // #110680#
3651 : 27 : SchXMLExport::SchXMLExport(
3652 : : const Reference< lang::XMultiServiceFactory >& xServiceFactory,
3653 : : sal_uInt16 nExportFlags )
3654 : : : SvXMLExport( util::MeasureUnit::CM, xServiceFactory,
3655 : : ::xmloff::token::XML_CHART, nExportFlags ),
3656 : : maAutoStylePool( *this ),
3657 [ + - ][ + - ]: 27 : maExportHelper( *this, maAutoStylePool )
3658 : : {
3659 [ + - ][ + - ]: 27 : if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
3660 [ + - ][ + - ]: 27 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
[ + - ]
3661 : 27 : }
3662 : :
3663 : :
3664 [ + - ][ + - ]: 27 : SchXMLExport::~SchXMLExport()
3665 : : {
3666 : : // stop progress view
3667 [ - + ]: 27 : if( mxStatusIndicator.is())
3668 : : {
3669 [ # # ][ # # ]: 0 : mxStatusIndicator->end();
3670 [ # # ][ # # ]: 0 : mxStatusIndicator->reset();
3671 : : }
3672 [ - + ]: 54 : }
3673 : :
3674 : 27 : sal_uInt32 SchXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
3675 : : {
3676 [ + - ]: 27 : Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
3677 [ + - ]: 27 : maExportHelper.m_pImpl->InitRangeSegmentationProperties( xChartDoc );
3678 [ + - ]: 27 : return SvXMLExport::exportDoc( eClass );
3679 : : }
3680 : :
3681 : 9 : void SchXMLExport::_ExportStyles( sal_Bool bUsed )
3682 : : {
3683 : 9 : SvXMLExport::_ExportStyles( bUsed );
3684 : 9 : }
3685 : :
3686 : 0 : void SchXMLExport::_ExportMasterStyles()
3687 : : {
3688 : : // not available in chart
3689 : : DBG_WARNING( "Master Style Export requested. Not available for Chart" );
3690 : 0 : }
3691 : :
3692 : 9 : void SchXMLExport::_ExportAutoStyles()
3693 : : {
3694 : : // there are no styles that require their own autostyles
3695 [ + - ]: 9 : if( getExportFlags() & EXPORT_CONTENT )
3696 : : {
3697 [ + - ]: 9 : Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
3698 [ + - ]: 9 : if( xChartDoc.is())
3699 : : {
3700 [ + - ]: 9 : maExportHelper.m_pImpl->collectAutoStyles( xChartDoc );
3701 [ + - ]: 9 : maExportHelper.m_pImpl->exportAutoStyles();
3702 : : }
3703 : : else
3704 : : {
3705 : : OSL_FAIL( "Couldn't export chart due to wrong XModel (must be XChartDocument)" );
3706 : 9 : }
3707 : : }
3708 : 9 : }
3709 : :
3710 : 9 : void SchXMLExport::_ExportContent()
3711 : : {
3712 [ + - ]: 9 : Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
3713 [ + - ]: 9 : if( xChartDoc.is())
3714 : : {
3715 : : // determine if data comes from the outside
3716 : 9 : sal_Bool bIncludeTable = sal_True;
3717 : :
3718 [ + - ]: 9 : Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY );
3719 [ + - ]: 9 : if( xNewDoc.is())
3720 : : {
3721 : : // check if we have own data. If so we must not export the complete
3722 : : // range string, as this is our only indicator for having own or
3723 : : // external data. @todo: fix this in the file format!
3724 [ + - ][ + - ]: 9 : Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
[ + - ]
3725 [ + - ][ + - ]: 9 : if( ! (xDPServiceInfo.is() && xDPServiceInfo->getImplementationName() == "com.sun.star.comp.chart.InternalDataProvider" ))
[ + + ][ + - ]
[ + + # # ]
[ + - ]
3726 : : {
3727 : 1 : bIncludeTable = sal_False;
3728 : 9 : }
3729 : : }
3730 : : else
3731 : : {
3732 [ # # ]: 0 : Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY );
3733 [ # # ]: 0 : if( xServ.is())
3734 : : {
3735 [ # # # # ]: 0 : if( xServ->supportsService(
3736 [ # # ]: 0 : OUString( "com.sun.star.chart.ChartTableAddressSupplier" )))
3737 : : {
3738 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY );
3739 [ # # ]: 0 : if( xProp.is())
3740 : : {
3741 : 0 : Any aAny;
3742 : : try
3743 : : {
3744 : 0 : OUString sChartAddress;
3745 [ # # ]: 0 : aAny = xProp->getPropertyValue(
3746 [ # # ]: 0 : OUString( "ChartRangeAddress" ));
3747 : 0 : aAny >>= sChartAddress;
3748 : 0 : maExportHelper.m_pImpl->SetChartRangeAddress( sChartAddress );
3749 : :
3750 : 0 : OUString sTableNumberList;
3751 [ # # ]: 0 : aAny = xProp->getPropertyValue(
3752 [ # # ]: 0 : OUString( "TableNumberList" ));
3753 : 0 : aAny >>= sTableNumberList;
3754 : 0 : maExportHelper.m_pImpl->SetTableNumberList( sTableNumberList );
3755 : :
3756 : : // do not include own table if there are external addresses
3757 [ # # ]: 0 : bIncludeTable = sChartAddress.isEmpty();
3758 : : }
3759 [ # # ]: 0 : catch( const beans::UnknownPropertyException & )
3760 : : {
3761 : : OSL_FAIL( "Property ChartRangeAddress not supported by ChartDocument" );
3762 : 0 : }
3763 : 0 : }
3764 : : }
3765 : 0 : }
3766 : : }
3767 [ + - ]: 9 : maExportHelper.m_pImpl->exportChart( xChartDoc, bIncludeTable );
3768 : : }
3769 : : else
3770 : : {
3771 : : OSL_FAIL( "Couldn't export chart due to wrong XModel" );
3772 : 9 : }
3773 : 9 : }
3774 : :
3775 : 636 : UniReference< XMLPropertySetMapper > SchXMLExport::GetPropertySetMapper() const
3776 : : {
3777 : 636 : return maExportHelper.m_pImpl->GetPropertySetMapper();
3778 : : }
3779 : :
3780 : 27 : void SchXMLExportHelper_Impl::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
3781 : : {
3782 [ + - ]: 27 : if( xChartDoc.is())
3783 : : try
3784 : : {
3785 [ + - ][ + - ]: 27 : Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
3786 : : OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
3787 [ + - ]: 27 : if( xDataProvider.is())
3788 : : {
3789 [ + - ]: 27 : Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc, mbHasCategoryLabels ));
3790 [ + - ][ + - ]: 27 : Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
3791 : 27 : ::rtl::OUString sCellRange, sBrokenRange;
3792 : 27 : bool bBrokenRangeAvailable = false;
3793 [ + + ]: 138 : for( sal_Int32 i=0; i<aArgs.getLength(); ++i )
3794 : : {
3795 [ + - ][ + + ]: 111 : if ( aArgs[i].Name == "CellRangeRepresentation" )
3796 [ + - ]: 27 : aArgs[i].Value >>= sCellRange;
3797 [ + - ][ - + ]: 84 : else if ( aArgs[i].Name == "BrokenCellRangeForExport" )
3798 : : {
3799 [ # # ][ # # ]: 0 : if( aArgs[i].Value >>= sBrokenRange )
3800 : 0 : bBrokenRangeAvailable = true;
3801 : : }
3802 [ + - ][ + + ]: 84 : else if ( aArgs[i].Name == "DataRowSource" )
3803 : : {
3804 : : chart::ChartDataRowSource eRowSource;
3805 [ + - ][ + - ]: 27 : aArgs[i].Value >>= eRowSource;
3806 : 27 : mbRowSourceColumns = ( eRowSource == chart::ChartDataRowSource_COLUMNS );
3807 : : }
3808 [ + - ][ + + ]: 57 : else if ( aArgs[i].Name == "FirstCellAsLabel" )
3809 [ + - ]: 27 : aArgs[i].Value >>= mbHasSeriesLabels;
3810 [ + - ][ - + ]: 30 : else if ( aArgs[i].Name == "SequenceMapping" )
3811 [ # # ][ # # ]: 0 : aArgs[i].Value >>= maSequenceMapping;
3812 [ + - ][ + + ]: 30 : else if ( aArgs[i].Name == "TableNumberList" )
3813 [ + - ]: 3 : aArgs[i].Value >>= msTableNumberList;
3814 : : }
3815 : :
3816 : : // #i79009# For Writer we have to export a broken version of the
3817 : : // range, where every row number is noe too large, so that older
3818 : : // version can correctly read those files.
3819 [ - + ]: 27 : msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange);
3820 [ + - ]: 27 : if( !msChartAddress.isEmpty() )
3821 : : {
3822 : : // convert format to XML-conform one
3823 [ + - ]: 27 : Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
3824 [ + - ]: 27 : if( xConversion.is())
3825 [ + - ][ + - ]: 27 : msChartAddress = xConversion->convertRangeToXML( msChartAddress );
3826 [ + - ]: 27 : }
3827 [ # # ]: 27 : }
3828 : : }
3829 : 0 : catch( const uno::Exception & ex )
3830 : : {
3831 : : (void)ex; // avoid warning for pro build
3832 : : OSL_FAIL( OUStringToOString(
3833 : : OUString( "Exception caught. Type: " ) +
3834 : : OUString::createFromAscii( typeid( ex ).name()) +
3835 : : OUString( ", Message: " ) +
3836 : : ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
3837 : : }
3838 : 27 : }
3839 : :
3840 : : // export components ========================================
3841 : :
3842 : : // first version: everything goes in one storage
3843 : :
3844 : 0 : Sequence< OUString > SAL_CALL SchXMLExport_getSupportedServiceNames() throw()
3845 : : {
3846 : 0 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLExporter" );
3847 [ # # ]: 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3848 : 0 : return aSeq;
3849 : : }
3850 : :
3851 : 36 : OUString SAL_CALL SchXMLExport_getImplementationName() throw()
3852 : : {
3853 : 36 : return OUString( "SchXMLExport.Compact" );
3854 : : }
3855 : :
3856 : 0 : Reference< uno::XInterface > SAL_CALL SchXMLExport_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3857 : : {
3858 : : // #110680#
3859 : : // #103997# removed some flags from EXPORT_ALL
3860 [ # # ]: 0 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_ALL ^ ( EXPORT_SETTINGS | EXPORT_MASTERSTYLES | EXPORT_SCRIPTS ));
3861 : : }
3862 : :
3863 : : // Oasis format
3864 : 0 : Sequence< OUString > SAL_CALL SchXMLExport_Oasis_getSupportedServiceNames() throw()
3865 : : {
3866 : 0 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLOasisExporter" );
3867 [ # # ]: 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3868 : 0 : return aSeq;
3869 : : }
3870 : :
3871 : 51 : OUString SAL_CALL SchXMLExport_Oasis_getImplementationName() throw()
3872 : : {
3873 : 51 : return OUString( "SchXMLExport.Oasis.Compact" );
3874 : : }
3875 : :
3876 : 0 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3877 : : {
3878 : : // #103997# removed some flags from EXPORT_ALL
3879 : : return (cppu::OWeakObject*)new SchXMLExport( rSMgr,
3880 [ # # ]: 0 : (EXPORT_ALL ^ ( EXPORT_SETTINGS | EXPORT_MASTERSTYLES | EXPORT_SCRIPTS )) | EXPORT_OASIS );
3881 : : }
3882 : :
3883 : : // ============================================================
3884 : :
3885 : : // multiple storage version: one for content / styles / meta
3886 : :
3887 : 0 : Sequence< OUString > SAL_CALL SchXMLExport_Styles_getSupportedServiceNames() throw()
3888 : : {
3889 : 0 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLStylesExporter" );
3890 [ # # ]: 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3891 : 0 : return aSeq;
3892 : : }
3893 : :
3894 : 36 : OUString SAL_CALL SchXMLExport_Styles_getImplementationName() throw()
3895 : : {
3896 : 36 : return OUString( "SchXMLExport.Styles" );
3897 : : }
3898 : :
3899 : 0 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Styles_createInstance(const Reference< lang::XMultiServiceFactory >& rSMgr) throw( uno::Exception )
3900 : : {
3901 : : // #110680#
3902 [ # # ]: 0 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_STYLES );
3903 : : }
3904 : :
3905 : : // Oasis format
3906 : 5 : Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Styles_getSupportedServiceNames() throw()
3907 : : {
3908 : 5 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLOasisStylesExporter" );
3909 [ + - ]: 5 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3910 : 5 : return aSeq;
3911 : : }
3912 : :
3913 : 51 : OUString SAL_CALL SchXMLExport_Oasis_Styles_getImplementationName() throw()
3914 : : {
3915 : 51 : return OUString( "SchXMLExport.Oasis.Styles" );
3916 : : }
3917 : :
3918 : 9 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Styles_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3919 : : {
3920 [ + - ]: 9 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_STYLES | EXPORT_OASIS );
3921 : : }
3922 : :
3923 : : // ------------------------------------------------------------
3924 : :
3925 : 0 : Sequence< OUString > SAL_CALL SchXMLExport_Content_getSupportedServiceNames() throw()
3926 : : {
3927 : 0 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLContentExporter" );
3928 [ # # ]: 0 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3929 : 0 : return aSeq;
3930 : : }
3931 : :
3932 : 36 : OUString SAL_CALL SchXMLExport_Content_getImplementationName() throw()
3933 : : {
3934 : 36 : return OUString( "SchXMLExport.Content" );
3935 : : }
3936 : :
3937 : 0 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3938 : : {
3939 : : // #110680#
3940 [ # # ]: 0 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS );
3941 : : }
3942 : :
3943 : : // Oasis format
3944 : 5 : Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Content_getSupportedServiceNames() throw()
3945 : : {
3946 : 5 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLOasisContentExporter" );
3947 [ + - ]: 5 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3948 : 5 : return aSeq;
3949 : : }
3950 : :
3951 : 46 : OUString SAL_CALL SchXMLExport_Oasis_Content_getImplementationName() throw()
3952 : : {
3953 : 46 : return OUString( "SchXMLExport.Oasis.Content" );
3954 : : }
3955 : :
3956 : 9 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3957 : : {
3958 [ + - ]: 9 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS | EXPORT_OASIS );
3959 : : }
3960 : :
3961 : : // ------------------------------------------------------------
3962 : :
3963 : : // Oasis format
3964 : 5 : Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Meta_getSupportedServiceNames() throw()
3965 : : {
3966 : 5 : const OUString aServiceName( "com.sun.star.comp.Chart.XMLOasisMetaExporter" );
3967 [ + - ]: 5 : const Sequence< OUString > aSeq( &aServiceName, 1 );
3968 : 5 : return aSeq;
3969 : : }
3970 : :
3971 : 56 : OUString SAL_CALL SchXMLExport_Oasis_Meta_getImplementationName() throw()
3972 : : {
3973 : 56 : return OUString( "SchXMLExport.Oasis.Meta" );
3974 : : }
3975 : :
3976 : 9 : Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
3977 : : {
3978 [ + - ]: 9 : return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_META | EXPORT_OASIS );
3979 : : }
3980 : :
3981 : :
3982 : : // XServiceInfo
3983 : 0 : OUString SAL_CALL SchXMLExport::getImplementationName() throw( uno::RuntimeException )
3984 : : {
3985 [ # # # # : 0 : switch( getExportFlags())
# # # # ]
3986 : : {
3987 : : case EXPORT_ALL:
3988 : 0 : return SchXMLExport_getImplementationName();
3989 : : case EXPORT_STYLES:
3990 : 0 : return SchXMLExport_Styles_getImplementationName();
3991 : : case ( EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS ):
3992 : 0 : return SchXMLExport_Content_getImplementationName();
3993 : :
3994 : : // Oasis format
3995 : : case ( EXPORT_ALL | EXPORT_OASIS ):
3996 : 0 : return SchXMLExport_Oasis_getImplementationName();
3997 : : case ( EXPORT_STYLES | EXPORT_OASIS ):
3998 : 0 : return SchXMLExport_Oasis_Styles_getImplementationName();
3999 : : case ( EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS | EXPORT_OASIS ):
4000 : 0 : return SchXMLExport_Oasis_Content_getImplementationName();
4001 : : case ( EXPORT_META | EXPORT_OASIS ):
4002 : 0 : return SchXMLExport_Oasis_Meta_getImplementationName();
4003 : :
4004 : : case EXPORT_SETTINGS:
4005 : : // there is no settings component in chart
4006 : : default:
4007 : 0 : return OUString( "SchXMLExport" );
4008 : : }
4009 : : }
4010 : :
4011 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|