1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
21 #define INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/chart2/FormattedString.hpp>
29 #include <oox/dllapi.h>
30 #include <oox/export/drawingml.hxx>
31 #include <oox/export/shapes.hxx>
32 #include <oox/export/utils.hxx>
33 #include <oox/token/tokens.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
36 #include <sax/fshelper.hxx>
38 namespace com::sun::star
{
47 struct RelativePosition
;
56 class XLabeledDataSequence
;
72 namespace oox::drawingml
{
88 AxisIdPair(AxesType nType
, sal_Int32 nId
, sal_Int32 nAx
)
96 A helper container class to collect the chart data point labels and the address
97 of the cell[range] from which the labels are sourced if that is the case. This
98 is then used to write the label texts under the extension tag <c15:datalabelsRange>.
100 @since LibreOffice 7.3.0
102 class DataLabelsRange
106 /// type of the internal container that stores the indexed label text.
107 typedef std::map
<sal_Int32
, OUString
> LabelsRangeMap
;
109 /// Returns whether the container is empty or not.
111 /// Returns the count of labels stored.
112 size_t count() const;
113 /// Indicates whether the container has a label with index specified by nIndex.
114 bool hasLabel(sal_Int32 nIndex
) const;
115 /// Returns the address of the cell[range] from which label contents are sourced.
116 const OUString
& getRange() const;
118 /// Sets the address of the cell[range] from which label contents are sourced.
119 void setRange(const OUString
& rRange
);
120 /// Adds a new indexed label text.
121 void setLabel(sal_Int32 nIndex
, const OUString
& rText
);
123 LabelsRangeMap::const_iterator
begin() const;
124 LabelsRangeMap::const_iterator
end() const;
128 LabelsRangeMap maLabels
;
132 class ChartExport final
: public DrawingML
{
135 // first: data sequence for label, second: data sequence for values.
136 typedef ::std::vector
< AxisIdPair
> AxisVector
;
139 sal_Int32 mnXmlNamespace
;
140 sal_Int32 mnSeriesCount
;
141 css::uno::Reference
< css::frame::XModel
> mxChartModel
;
142 css::uno::Reference
< css::chart::XDiagram
> mxDiagram
;
143 css::uno::Reference
< css::chart2::XDiagram
> mxNewDiagram
;
144 std::shared_ptr
<URLTransformer
> mpURLTransformer
;
146 // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
147 bool mbHasCategoryLabels
; //if the categories are only automatically generated this will be false
149 //css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes;
150 css::uno::Reference
< css::chart2::data::XDataSequence
> mxCategoriesValues
;
157 bool mbHasDateCategories
;
159 std::set
<sal_Int32
> maExportedAxis
;
162 sal_Int32
getChartType();
164 css::uno::Sequence
< css::uno::Sequence
< rtl::OUString
> > getSplitCategoriesList(const OUString
& rRange
);
166 OUString
parseFormula( const OUString
& rRange
);
169 void ExportContent_();
170 void exportChartSpace( const css::uno::Reference
<
171 css::chart::XChartDocument
>& rChartDoc
,
172 bool bIncludeTable
);
173 void exportChart( const css::uno::Reference
<
174 css::chart::XChartDocument
>& rChartDoc
);
175 void exportExternalData( const css::uno::Reference
<
176 css::chart::XChartDocument
>& rChartDoc
);
177 void exportLegend( const css::uno::Reference
<
178 css::chart::XChartDocument
>& rChartDoc
);
179 void exportTitle( const css::uno::Reference
< css::drawing::XShape
>& xShape
,
180 const css::uno::Sequence
< css::uno::Reference
< css::chart2::XFormattedString
> >& xFormattedSubTitle
=
181 css::uno::Sequence
< css::uno::Reference
< css::chart2::XFormattedString
> >() );
182 void exportPlotArea( const css::uno::Reference
<
183 css::chart::XChartDocument
>& rChartDoc
);
184 void exportAdditionalShapes( const css::uno::Reference
<css::chart::XChartDocument
>& rChartDoc
);
185 void exportFill( const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
186 void exportSolidFill(const css::uno::Reference
<css::beans::XPropertySet
>& xPropSet
);
187 void exportGradientFill( const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
188 void exportBitmapFill( const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
189 void exportHatch(const css::uno::Reference
<css::beans::XPropertySet
>& xPropSet
);
190 void exportDataTable( );
192 void exportAreaChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
193 void exportBarChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
194 void exportBubbleChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
195 void exportDoughnutChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
196 void exportLineChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
197 void exportOfPieChart( const css::uno::Reference
< css::chart2::XChartType
>&
198 xChartType
, const char* s_subtype
, double nSplitPos
);
199 void exportPieChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
200 void exportRadarChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
201 void exportScatterChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
202 void exportScatterChartSeries( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
,
203 const css::uno::Sequence
<css::uno::Reference
<css::chart2::XDataSeries
>>* pSeries
);
204 void exportStockChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
205 void exportSurfaceChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
206 void exportHiLowLines();
207 void exportUpDownBars(const css::uno::Reference
< css::chart2::XChartType
>& xChartType
);
209 void exportAllSeries(const css::uno::Reference
<css::chart2::XChartType
>& xChartType
, bool& rPrimaryAxes
);
210 void exportSeries(const css::uno::Reference
< css::chart2::XChartType
>& xChartType
,
211 const css::uno::Sequence
<css::uno::Reference
<css::chart2::XDataSeries
> >& rSeriesSeq
, bool& rPrimaryAxes
);
213 void exportVaryColors(const css::uno::Reference
<css::chart2::XChartType
>& xChartType
);
214 void exportCandleStickSeries(
215 const css::uno::Sequence
<
217 css::chart2::XDataSeries
> > & aSeriesSeq
,
218 bool& rPrimaryAxes
);
219 void exportSeriesText(
220 const css::uno::Reference
< css::chart2::data::XDataSequence
>& xValueSeq
);
221 void exportSeriesCategory(
222 const css::uno::Reference
< css::chart2::data::XDataSequence
>& xValueSeq
, sal_Int32 nValueType
= XML_cat
);
223 void exportSeriesValues(
224 const css::uno::Reference
< css::chart2::data::XDataSequence
>& xValueSeq
, sal_Int32 nValueType
= XML_val
);
225 void exportShapeProps( const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
226 void exportDataPoints(
227 const css::uno::Reference
< css::beans::XPropertySet
>& xSeriesProperties
,
228 sal_Int32 nSeriesLength
, sal_Int32 eChartType
);
229 void exportDataLabels( const css::uno::Reference
<css::chart2::XDataSeries
>& xSeries
, sal_Int32 nSeriesLength
,
230 sal_Int32 eChartType
, DataLabelsRange
& rDLblsRange
);
231 void exportGrouping( bool isBar
= false );
232 void exportTrendlines( const css::uno::Reference
< css::chart2::XDataSeries
>& xSeries
);
233 void exportMarker( const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
235 void exportFirstSliceAng();
237 void exportErrorBar(const css::uno::Reference
< css::beans::XPropertySet
>& xErrorBarProps
,
240 void exportManualLayout(const css::chart2::RelativePosition
& rPos
, const css::chart2::RelativeSize
& rSize
, const bool bIsExcludingDiagramPositioning
);
243 void exportAxis(const AxisIdPair
& rAxisIdPair
);
245 const css::uno::Reference
< css::beans::XPropertySet
>& xAxisProp
,
246 const css::uno::Reference
< css::drawing::XShape
>& xAxisTitle
,
247 const css::uno::Reference
< css::beans::XPropertySet
>& xMajorGrid
,
248 const css::uno::Reference
< css::beans::XPropertySet
>& xMinorGrid
,
250 const char* sAxisPos
,
251 const AxisIdPair
& rAxisIdPair
);
252 void exportAxesId(bool bPrimaryAxes
, bool bCheckCombinedAxes
= false);
254 bool isDeep3dChart();
256 void exportMissingValueTreatment(const css::uno::Reference
<css::beans::XPropertySet
>& xPropSet
);
258 OUString
getNumberFormatCode(sal_Int32 nKey
) const;
262 OOX_DLLPUBLIC
ChartExport( sal_Int32 nXmlNamespace
, ::sax_fastparser::FSHelperPtr pFS
, css::uno::Reference
< css::frame::XModel
> const & xModel
,
263 ::oox::core::XmlFilterBase
* pFB
, DocumentType eDocumentType
);
264 virtual ~ChartExport() {}
266 OOX_DLLPUBLIC
void SetURLTranslator(const std::shared_ptr
<URLTransformer
>& pTransformer
);
268 const css::uno::Reference
< css::frame::XModel
>& getModel() const { return mxChartModel
; }
270 OOX_DLLPUBLIC
void WriteChartObj( const css::uno::Reference
< css::drawing::XShape
>& xShape
, sal_Int32 nID
, sal_Int32 nChartCount
);
271 void exportTextProps(const css::uno::Reference
< css::beans::XPropertySet
>& xPropSet
);
273 OOX_DLLPUBLIC
void ExportContent();
274 void InitRangeSegmentationProperties(
275 const css::uno::Reference
<
276 css::chart2::XChartDocument
> & xChartDoc
);
281 #endif // INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */