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