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