1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX 21 #define INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX 22 23 #include <set> 24 #include <vector> 25 26 #include <com/sun/star/uno/Reference.hxx> 27 #include <com/sun/star/uno/Sequence.hxx> 28 #include <oox/dllapi.h> 29 #include <oox/export/drawingml.hxx> 30 #include <oox/export/utils.hxx> 31 #include <oox/token/tokens.hxx> 32 #include <rtl/ustring.hxx> 33 #include <sal/types.h> 34 #include <sax/fshelper.hxx> 35 36 namespace com { namespace sun { namespace star { 37 namespace beans { 38 class XPropertySet; 39 } 40 namespace chart { 41 class XDiagram; 42 class XChartDocument; 43 } 44 namespace chart2 { 45 struct RelativePosition; 46 struct RelativeSize; 47 class XDiagram; 48 class XChartDocument; 49 class XDataSeries; 50 class XChartType; 51 namespace data 52 { 53 class XDataSequence; 54 class XLabeledDataSequence; 55 } 56 } 57 namespace drawing { 58 class XShape; 59 } 60 namespace frame { 61 class XModel; 62 } 63 }}} 64 65 namespace oox { 66 namespace core { 67 class XmlFilterBase; 68 }} 69 70 namespace oox { namespace drawingml { 71 72 enum AxesType 73 { 74 AXIS_PRIMARY_X = 1, 75 AXIS_PRIMARY_Y = 2, 76 AXIS_PRIMARY_Z = 3, 77 AXIS_SECONDARY_X = 4, 78 AXIS_SECONDARY_Y = 5 79 }; 80 81 struct AxisIdPair{ 82 AxesType const nAxisType; 83 sal_Int32 const nAxisId; 84 sal_Int32 const nCrossAx; 85 AxisIdPairoox::drawingml::AxisIdPair86 AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx) 87 : nAxisType(nType) 88 , nAxisId(nId) 89 , nCrossAx(nAx) 90 {} 91 }; 92 93 class OOX_DLLPUBLIC ChartExport final : public DrawingML { 94 95 public: 96 // first: data sequence for label, second: data sequence for values. 97 typedef ::std::vector< AxisIdPair > AxisVector; 98 99 private: 100 sal_Int32 const mnXmlNamespace; 101 sal_Int32 mnSeriesCount; 102 css::uno::Reference< css::frame::XModel > mxChartModel; 103 css::uno::Reference< css::chart::XDiagram > mxDiagram; 104 css::uno::Reference< css::chart2::XDiagram > mxNewDiagram; 105 std::shared_ptr<URLTransformer> mpURLTransformer; 106 107 // members filled by InitRangeSegmentationProperties (retrieved from DataProvider) 108 bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false 109 bool mbIsCategoryPositionShifted; //if the value axis crosses the category axis between tickmarks this will be true 110 111 //css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes; 112 css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues; 113 114 AxisVector maAxes; 115 bool mbHasZAxis; 116 bool mbIs3DChart; 117 bool mbStacked; 118 bool mbPercent; 119 120 std::set<sal_Int32> maExportedAxis; 121 122 private: 123 sal_Int32 getChartType(); 124 125 css::uno::Sequence< css::uno::Sequence< rtl::OUString > > getSplitCategoriesList(const OUString& rRange); 126 127 OUString parseFormula( const OUString& rRange ); 128 void InitPlotArea(); 129 130 void ExportContent_(); 131 void exportChartSpace( const css::uno::Reference< 132 css::chart::XChartDocument >& rChartDoc, 133 bool bIncludeTable ); 134 void exportChart( const css::uno::Reference< 135 css::chart::XChartDocument >& rChartDoc ); 136 void exportExternalData( const css::uno::Reference< 137 css::chart::XChartDocument >& rChartDoc ); 138 void exportLegend( const css::uno::Reference< 139 css::chart::XChartDocument >& rChartDoc ); 140 void exportTitle( const css::uno::Reference< css::drawing::XShape >& xShape, 141 const OUString* pSubText = nullptr ); 142 void exportPlotArea( const css::uno::Reference< 143 css::chart::XChartDocument >& rChartDoc ); 144 void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); 145 void exportGradientFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); 146 void exportBitmapFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); 147 void exportHatch(const css::uno::Reference<css::beans::XPropertySet>& xPropSet); 148 void exportDataTable( ); 149 150 void exportAreaChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 151 void exportBarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 152 void exportBubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 153 void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 154 void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 155 void exportPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 156 void exportRadarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 157 void exportScatterChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 158 void exportScatterChartSeries( const css::uno::Reference< css::chart2::XChartType >& xChartType, 159 css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>* pSeries); 160 void exportStockChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 161 void exportSurfaceChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); 162 void exportHiLowLines(); 163 void exportUpDownBars(const css::uno::Reference< css::chart2::XChartType >& xChartType ); 164 165 void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes); 166 void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType, 167 css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes); 168 169 void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType); 170 void exportCandleStickSeries( 171 const css::uno::Sequence< 172 css::uno::Reference< 173 css::chart2::XDataSeries > > & aSeriesSeq, 174 bool& rPrimaryAxes ); 175 void exportSeriesText( 176 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq ); 177 void exportSeriesCategory( 178 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq ); 179 void exportSeriesValues( 180 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val ); 181 void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); 182 void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet); 183 void exportDataPoints( 184 const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties, 185 sal_Int32 nSeriesLength, sal_Int32 eChartType ); 186 void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength, sal_Int32 eChartType ); 187 void exportGrouping( bool isBar = false ); 188 void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); 189 void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); 190 void exportSmooth(); 191 void exportFirstSliceAng(); 192 193 void exportErrorBar(const css::uno::Reference< css::beans::XPropertySet >& xErrorBarProps, 194 bool bYError); 195 196 void exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning); 197 198 void exportAxes( ); 199 void exportAxis(const AxisIdPair& rAxisIdPair); 200 void _exportAxis( 201 const css::uno::Reference< css::beans::XPropertySet >& xAxisProp, 202 const css::uno::Reference< css::drawing::XShape >& xAxisTitle, 203 const css::uno::Reference< css::beans::XPropertySet >& xMajorGrid, 204 const css::uno::Reference< css::beans::XPropertySet >& xMinorGrid, 205 sal_Int32 nAxisType, 206 const char* sAxisPos, 207 const AxisIdPair& rAxisIdPair ); 208 void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false); 209 void exportView3D(); 210 bool isDeep3dChart(); 211 212 void exportMissingValueTreatment(const css::uno::Reference<css::beans::XPropertySet>& xPropSet); 213 214 OUString getNumberFormatCode(sal_Int32 nKey) const; 215 216 public: 217 218 ChartExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, css::uno::Reference< css::frame::XModel > const & xModel, 219 ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType ); ~ChartExport()220 virtual ~ChartExport() {} 221 222 void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer); 223 getModel() const224 const css::uno::Reference< css::frame::XModel >& getModel() const { return mxChartModel; } 225 226 void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nID, sal_Int32 nChartCount ); 227 228 void ExportContent(); 229 void InitRangeSegmentationProperties( 230 const css::uno::Reference< 231 css::chart2::XChartDocument > & xChartDoc ); 232 }; 233 234 }} 235 236 #endif // INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX 237 238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 239