LibreOffice Module oox (master)  1
chartexport.hxx
Go to the documentation of this file.
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/shapes.hxx>
31 #include <oox/export/utils.hxx>
32 #include <oox/token/tokens.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
35 #include <sax/fshelper.hxx>
36 
37 namespace com::sun::star {
38  namespace beans {
39  class XPropertySet;
40  }
41  namespace chart {
42  class XDiagram;
43  class XChartDocument;
44  }
45  namespace chart2 {
46  struct RelativePosition;
47  struct RelativeSize;
48  class XDiagram;
49  class XChartDocument;
50  class XDataSeries;
51  class XChartType;
52  namespace data
53  {
54  class XDataSequence;
55  class XLabeledDataSequence;
56  }
57  }
58  namespace drawing {
59  class XShape;
60  }
61  namespace frame {
62  class XModel;
63  }
64 }
65 
66 namespace oox {
67 namespace core {
68  class XmlFilterBase;
69 }}
70 
71 namespace oox::drawingml {
72 
74 {
80 };
81 
82 struct AxisIdPair{
84  sal_Int32 nAxisId;
85  sal_Int32 nCrossAx;
86 
87  AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
88  : nAxisType(nType)
89  , nAxisId(nId)
90  , nCrossAx(nAx)
91  {}
92 };
93 
94 class OOX_DLLPUBLIC ChartExport final : public DrawingML {
95 
96 public:
97  // first: data sequence for label, second: data sequence for values.
98  typedef ::std::vector< AxisIdPair > AxisVector;
99 
100 private:
101  sal_Int32 mnXmlNamespace;
102  sal_Int32 mnSeriesCount;
103  css::uno::Reference< css::frame::XModel > mxChartModel;
104  css::uno::Reference< css::chart::XDiagram > mxDiagram;
105  css::uno::Reference< css::chart2::XDiagram > mxNewDiagram;
106  std::shared_ptr<URLTransformer> mpURLTransformer;
107 
108  // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
109  bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false
110 
111  //css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes;
112  css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues;
113 
114  AxisVector maAxes;
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 exportAdditionalShapes( const css::uno::Reference<css::chart::XChartDocument >& rChartDoc );
145  void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
146  void exportSolidFill(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
147  void exportGradientFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
148  void exportBitmapFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
149  void exportHatch(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
150  void exportDataTable( );
151 
152  void exportAreaChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
153  void exportBarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
154  void exportBubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
155  void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
156  void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
157  void exportPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
158  void exportRadarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
159  void exportScatterChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
160  void exportScatterChartSeries( const css::uno::Reference< css::chart2::XChartType >& xChartType,
161  const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>* pSeries);
162  void exportStockChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
163  void exportSurfaceChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
164  void exportHiLowLines();
165  void exportUpDownBars(const css::uno::Reference< css::chart2::XChartType >& xChartType );
166 
167  void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes);
168  void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType,
169  const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes);
170 
171  void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType);
172  void exportCandleStickSeries(
173  const css::uno::Sequence<
174  css::uno::Reference<
175  css::chart2::XDataSeries > > & aSeriesSeq,
176  bool& rPrimaryAxes );
177  void exportSeriesText(
178  const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq );
179  void exportSeriesCategory(
180  const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_cat );
181  void exportSeriesValues(
182  const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
183  void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
184  void exportDataPoints(
185  const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties,
186  sal_Int32 nSeriesLength, sal_Int32 eChartType );
187  void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength, sal_Int32 eChartType );
188  void exportGrouping( bool isBar = false );
189  void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
190  void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
191  void exportSmooth();
192  void exportFirstSliceAng();
193 
194  void exportErrorBar(const css::uno::Reference< css::beans::XPropertySet >& xErrorBarProps,
195  bool bYError);
196 
197  void exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning);
198 
199  void exportAxes( );
200  void exportAxis(const AxisIdPair& rAxisIdPair);
201  void _exportAxis(
202  const css::uno::Reference< css::beans::XPropertySet >& xAxisProp,
203  const css::uno::Reference< css::drawing::XShape >& xAxisTitle,
204  const css::uno::Reference< css::beans::XPropertySet >& xMajorGrid,
205  const css::uno::Reference< css::beans::XPropertySet >& xMinorGrid,
206  sal_Int32 nAxisType,
207  const char* sAxisPos,
208  const AxisIdPair& rAxisIdPair );
209  void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false);
210  void exportView3D();
211  bool isDeep3dChart();
212 
213  void exportMissingValueTreatment(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
214 
215  OUString getNumberFormatCode(sal_Int32 nKey) const;
216 
217 public:
218 
219  ChartExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, css::uno::Reference< css::frame::XModel > const & xModel,
220  ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType );
221  virtual ~ChartExport() {}
222 
223  void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
224 
225  const css::uno::Reference< css::frame::XModel >& getModel() const { return mxChartModel; }
226 
227  void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nID, sal_Int32 nChartCount );
228  void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
229 
230  void ExportContent();
231  void InitRangeSegmentationProperties(
232  const css::uno::Reference<
233  css::chart2::XChartDocument > & xChartDoc );
234 };
235 
236 }
237 
238 #endif // INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
239 
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::chart::XDiagram > mxDiagram
css::uno::Reference< css::chart2::XDiagram > mxNewDiagram
sal_Int16 nId
Definition: olehelper.cxx:97
const css::uno::Reference< css::frame::XModel > & getModel() const
std::set< sal_Int32 > maExportedAxis
exports com.sun.star. chart2
exports com.sun.star. frame
exports com.sun.star. drawing
std::shared_ptr< URLTransformer > mpURLTransformer
css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues
class SAL_NO_VTABLE XPropertySet
::std::vector< AxisIdPair > AxisVector
Definition: chartexport.hxx:98
std::shared_ptr< FastSerializerHelper > FSHelperPtr
exports com.sun.star.chart2. data
exports com.sun.star. beans
css::uno::Reference< css::frame::XModel > mxChartModel
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
Definition: chartexport.hxx:87