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>
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
37namespace 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
66namespace oox {
67namespace core {
68 class XmlFilterBase;
69}}
70
71namespace oox::drawingml {
72
74{
80};
81
84 sal_Int32 nAxisId;
85 sal_Int32 nCrossAx;
86
87 AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
89 , nAxisId(nId)
90 , nCrossAx(nAx)
91 {}
92};
93
102{
103public:
104
106 typedef std::map<sal_Int32, OUString> LabelsRangeMap;
107
109 bool empty() const;
111 size_t count() const;
113 bool hasLabel(sal_Int32 nIndex) const;
115 const OUString & getRange() const;
116
118 void setRange(const OUString& rRange);
120 void setLabel(sal_Int32 nIndex, const OUString& rText);
121
122 LabelsRangeMap::const_iterator begin() const;
123 LabelsRangeMap::const_iterator end() const;
124
125private:
126 OUString maRange;
128};
129
130
131class OOX_DLLPUBLIC ChartExport final : public DrawingML {
132
133public:
134 // first: data sequence for label, second: data sequence for values.
135 typedef ::std::vector< AxisIdPair > AxisVector;
136
137private:
138 sal_Int32 mnXmlNamespace;
139 sal_Int32 mnSeriesCount;
140 css::uno::Reference< css::frame::XModel > mxChartModel;
141 css::uno::Reference< css::chart::XDiagram > mxDiagram;
142 css::uno::Reference< css::chart2::XDiagram > mxNewDiagram;
143 std::shared_ptr<URLTransformer> mpURLTransformer;
144
145 // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
146 bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false
147
148 //css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes;
149 css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues;
150
157
158 std::set<sal_Int32> maExportedAxis;
159
160private:
161 sal_Int32 getChartType();
162
163 css::uno::Sequence< css::uno::Sequence< rtl::OUString > > getSplitCategoriesList(const OUString& rRange);
164
165 OUString parseFormula( const OUString& rRange );
166 void InitPlotArea();
167
168 void ExportContent_();
169 void exportChartSpace( const css::uno::Reference<
170 css::chart::XChartDocument >& rChartDoc,
171 bool bIncludeTable );
172 void exportChart( const css::uno::Reference<
173 css::chart::XChartDocument >& rChartDoc );
174 void exportExternalData( const css::uno::Reference<
175 css::chart::XChartDocument >& rChartDoc );
176 void exportLegend( const css::uno::Reference<
177 css::chart::XChartDocument >& rChartDoc );
178 void exportTitle( const css::uno::Reference< css::drawing::XShape >& xShape,
179 const OUString* pSubText = nullptr );
180 void exportPlotArea( const css::uno::Reference<
181 css::chart::XChartDocument >& rChartDoc );
182 void exportAdditionalShapes( const css::uno::Reference<css::chart::XChartDocument >& rChartDoc );
183 void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
184 void exportSolidFill(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
185 void exportGradientFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
186 void exportBitmapFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
187 void exportHatch(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
188 void exportDataTable( );
189
190 void exportAreaChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
191 void exportBarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
192 void exportBubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
193 void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
194 void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
195 void exportPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
196 void exportRadarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
197 void exportScatterChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
198 void exportScatterChartSeries( const css::uno::Reference< css::chart2::XChartType >& xChartType,
199 const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>* pSeries);
200 void exportStockChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
201 void exportSurfaceChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
202 void exportHiLowLines();
203 void exportUpDownBars(const css::uno::Reference< css::chart2::XChartType >& xChartType );
204
205 void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes);
206 void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType,
207 const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes);
208
209 void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType);
210 void exportCandleStickSeries(
211 const css::uno::Sequence<
212 css::uno::Reference<
213 css::chart2::XDataSeries > > & aSeriesSeq,
214 bool& rPrimaryAxes );
215 void exportSeriesText(
216 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq );
217 void exportSeriesCategory(
218 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_cat );
219 void exportSeriesValues(
220 const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
221 void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
222 void exportDataPoints(
223 const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties,
224 sal_Int32 nSeriesLength, sal_Int32 eChartType );
225 void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength,
226 sal_Int32 eChartType, DataLabelsRange& rDLblsRange );
227 void exportGrouping( bool isBar = false );
228 void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
229 void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
230 void exportSmooth();
231 void exportFirstSliceAng();
232
233 void exportErrorBar(const css::uno::Reference< css::beans::XPropertySet >& xErrorBarProps,
234 bool bYError);
235
236 void exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning);
237
238 void exportAxes( );
239 void exportAxis(const AxisIdPair& rAxisIdPair);
240 void _exportAxis(
241 const css::uno::Reference< css::beans::XPropertySet >& xAxisProp,
242 const css::uno::Reference< css::drawing::XShape >& xAxisTitle,
243 const css::uno::Reference< css::beans::XPropertySet >& xMajorGrid,
244 const css::uno::Reference< css::beans::XPropertySet >& xMinorGrid,
245 sal_Int32 nAxisType,
246 const char* sAxisPos,
247 const AxisIdPair& rAxisIdPair );
248 void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false);
249 void exportView3D();
250 bool isDeep3dChart();
251
252 void exportMissingValueTreatment(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
253
254 OUString getNumberFormatCode(sal_Int32 nKey) const;
255
256public:
257
258 ChartExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, css::uno::Reference< css::frame::XModel > const & xModel,
259 ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType );
260 virtual ~ChartExport() {}
261
262 void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
263
264 const css::uno::Reference< css::frame::XModel >& getModel() const { return mxChartModel; }
265
266 void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nID, sal_Int32 nChartCount );
267 void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
268
269 void ExportContent();
270 void InitRangeSegmentationProperties(
271 const css::uno::Reference<
272 css::chart2::XChartDocument > & xChartDoc );
273};
274
275}
276
277#endif // INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
278
279/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::frame::XModel > & getModel() const
css::uno::Reference< css::chart2::XDiagram > mxNewDiagram
css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues
css::uno::Reference< css::chart::XDiagram > mxDiagram
std::set< sal_Int32 > maExportedAxis
css::uno::Reference< css::frame::XModel > mxChartModel
std::shared_ptr< URLTransformer > mpURLTransformer
::std::vector< AxisIdPair > AxisVector
A helper container class to collect the chart data point labels and the address of the cell[range] fr...
const OUString & getRange() const
Returns the address of the cell[range] from which label contents are sourced.
void setRange(const OUString &rRange)
Sets the address of the cell[range] from which label contents are sourced.
bool empty() const
Returns whether the container is empty or not.
void setLabel(sal_Int32 nIndex, const OUString &rText)
Adds a new indexed label text.
LabelsRangeMap::const_iterator begin() const
size_t count() const
Returns the count of labels stored.
std::map< sal_Int32, OUString > LabelsRangeMap
type of the internal container that stores the indexed label text.
bool hasLabel(sal_Int32 nIndex) const
Indicates whether the container has a label with index specified by nIndex.
LabelsRangeMap::const_iterator end() const
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
class SAL_NO_VTABLE XPropertySet
std::shared_ptr< FastSerializerHelper > FSHelperPtr
sal_Int16 nId
Definition: olehelper.cxx:98
QPRO_FUNC_TYPE nType
AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
Definition: chartexport.hxx:87