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 #ifndef INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPLOTAREACONTEXT_HXX
20 #define INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPLOTAREACONTEXT_HXX
21 
22 #include "SchXMLChartContext.hxx"
23 #include <xmloff/xmlictxt.hxx>
24 #include <xmloff/prstylei.hxx>
25 #include <xmloff/shapeimport.hxx>
26 #include <com/sun/star/awt/Rectangle.hpp>
27 #include <com/sun/star/chart/ChartDataRowSource.hpp>
28 
29 #include "transporttypes.hxx"
30 
31 class SvXMLImport;
32 
33 namespace com { namespace sun { namespace star {
34     namespace chart {
35         class XDiagram;
36         class X3DDisplay;
37         class XStatisticDisplay;
38     }
39     namespace chart2 {
40         class XChartDocument;
41     }
42     namespace xml { namespace sax {
43         class XAttributeList;
44 }}}}}
45 
46 class SchXML3DSceneAttributesHelper : public SdXML3DSceneAttributesHelper
47 {
48 public:
49     explicit SchXML3DSceneAttributesHelper( SvXMLImport& rImporter );
50     virtual ~SchXML3DSceneAttributesHelper();
51 
52     void getCameraDefaultFromDiagram( const css::uno::Reference< css::chart::XDiagram >& xDiagram );
53 };
54 
55 class SchXMLPositionAttributesHelper
56 {
57 public:
58     explicit SchXMLPositionAttributesHelper( SvXMLImport& rImporter );
59     ~SchXMLPositionAttributesHelper();
60 
61     void readPositioningAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue );
62     void readAutomaticPositioningProperties( XMLPropStyleContext const * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt );
63 
64     bool hasPosSize() const;
65     bool isAutomatic() const;
getRectangle() const66     css::awt::Rectangle getRectangle() const { return css::awt::Rectangle( m_aPosition.X, m_aPosition.Y, m_aSize.Width, m_aSize.Height );}
67 
68 private:
69     SvXMLImport& m_rImport;
70 
71     css::awt::Point m_aPosition;
72     css::awt::Size m_aSize;
73 
74     bool m_bHasSizeWidth;
75     bool m_bHasSizeHeight;
76     bool m_bHasPositionX;
77     bool m_bHasPositionY;
78     bool m_bAutoSize;
79     bool m_bAutoPosition;
80 };
81 
82 class SchXMLPlotAreaContext : public SvXMLImportContext
83 {
84 public:
85     SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
86                            SvXMLImport& rImport, const OUString& rLocalName,
87                            const OUString& rXLinkHRefAttributeToIndicateDataProvider,
88                            OUString& rCategoriesAddress,
89                            OUString& rChartAddress,
90                            bool& bHasRangeAtPlotArea,
91                            bool & rAllRangeAddressesAvailable,
92                            bool & rColHasLabels,
93                            bool & rRowHasLabels,
94                            css::chart::ChartDataRowSource & rDataRowSource,
95                            SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
96                            const OUString& aChartTypeServiceName,
97                            tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
98                            const css::awt::Size & rChartSize );
99     virtual ~SchXMLPlotAreaContext() override;
100 
101     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
102     virtual SvXMLImportContextRef CreateChildContext(
103         sal_uInt16 nPrefix,
104         const OUString& rLocalName,
105         const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
106     virtual void EndElement() override;
107 
108 private:
109     SchXMLImportHelper& mrImportHelper;
110     css::uno::Reference< css::chart::XDiagram > mxDiagram;
111     css::uno::Reference< css::chart2::XChartDocument > mxNewDoc;
112     ::std::vector< SchXMLAxis > maAxes;
113     OUString& mrCategoriesAddress;
114     SeriesDefaultsAndStyles& mrSeriesDefaultsAndStyles;
115     sal_Int32 mnNumOfLinesProp;
116     bool  mbStockHasVolume;
117     sal_Int32 mnSeries;
118     GlobalSeriesImportInfo m_aGlobalSeriesImportInfo;
119 
120     SchXML3DSceneAttributesHelper maSceneImportHelper;
121     SchXMLPositionAttributesHelper m_aOuterPositioning;//including axes and axes titles
122     SchXMLPositionAttributesHelper m_aInnerPositioning;//excluding axes and axes titles
123     bool mbPercentStacked;
124     bool m_bAxisPositionAttributeImported;
125     OUString msAutoStyleName;
126     const OUString& m_rXLinkHRefAttributeToIndicateDataProvider;
127     OUString& mrChartAddress;
128     bool& m_rbHasRangeAtPlotArea;
129     bool & mrColHasLabels;
130     bool & mrRowHasLabels;
131     css::chart::ChartDataRowSource & mrDataRowSource;
132     OUString const maChartTypeServiceName;
133 
134     tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
135 
136     bool mbGlobalChartTypeUsedBySeries;
137     css::awt::Size const maChartSize;
138 };
139 
140 class SchXMLDataLabelSpanContext: public SvXMLImportContext
141 {
142 private:
143     ::std::vector<OUString>& mrLabels;
144 public:
145     SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels);
146     virtual void Characters( const OUString& rChars ) override;
147 };
148 
149 class SchXMLDataLabelParaContext: public SvXMLImportContext
150 {
151 private:
152     ::std::vector<OUString>& mrLabels;
153 public:
154     SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels);
155     virtual SvXMLImportContextRef CreateChildContext(
156         sal_uInt16 nPrefix,
157         const OUString& rLocalName,
158         const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
159 };
160 
161 class SchXMLDataLabelContext: public SvXMLImportContext
162 {
163 private:
164     ::std::vector<OUString>& mrLabels;
165 public:
166     SchXMLDataLabelContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels);
167     virtual SvXMLImportContextRef CreateChildContext(
168         sal_uInt16 nPrefix,
169         const OUString& rLocalName,
170         const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
171 };
172 
173 class SchXMLDataPointContext : public SvXMLImportContext
174 {
175 private:
176     SchXMLImportHelper& mrImportHelper;
177     ::std::vector< DataRowPointStyle >& mrStyleVector;
178     bool mbHasLabelParagraph = false;
179     sal_Int32& mrIndex;
180     DataRowPointStyle mDataPoint;
181 
182 public:
183     SchXMLDataPointContext(  SchXMLImportHelper& rImportHelper,
184                              SvXMLImport& rImport, const OUString& rLocalName,
185                              ::std::vector< DataRowPointStyle >& rStyleVector,
186                              const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
187                              sal_Int32& rIndex,
188                              bool bSymbolSizeForSeriesIsMissingInFile );
189     virtual ~SchXMLDataPointContext() override;
190 
191     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
192 
193     virtual SvXMLImportContextRef CreateChildContext(
194         sal_uInt16 nPrefix,
195         const OUString& rLocalName,
196         const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
197     virtual void EndElement() override;
198 };
199 
200 class SchXMLCoordinateRegionContext : public SvXMLImportContext
201 {
202 public:
203     SchXMLCoordinateRegionContext(
204             SvXMLImport& rImport
205             , sal_uInt16 nPrefix
206             , const OUString& rLocalName
207             , SchXMLPositionAttributesHelper& rPositioning );
208     virtual ~SchXMLCoordinateRegionContext() override;
209     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
210 
211 private:
212     SchXMLPositionAttributesHelper& m_rPositioning;
213 };
214 
215 class SchXMLWallFloorContext : public SvXMLImportContext
216 {
217 public:
218     enum ContextType
219     {
220         CONTEXT_TYPE_WALL,
221         CONTEXT_TYPE_FLOOR
222     };
223 
224 private:
225     SchXMLImportHelper& mrImportHelper;
226     css::uno::Reference< css::chart::X3DDisplay > mxWallFloorSupplier;
227     ContextType const meContextType;
228 
229 public:
230     SchXMLWallFloorContext( SchXMLImportHelper& rImportHelper,
231                             SvXMLImport& rImport,
232                             sal_uInt16 nPrefix,
233                             const OUString& rLocalName,
234                             css::uno::Reference< css::chart::XDiagram > const & xDiagram,
235                             ContextType eContextType );
236     virtual ~SchXMLWallFloorContext() override;
237     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
238 };
239 
240 class SchXMLStockContext : public SvXMLImportContext
241 {
242 public:
243     enum ContextType
244     {
245         CONTEXT_TYPE_GAIN,
246         CONTEXT_TYPE_LOSS,
247         CONTEXT_TYPE_RANGE
248     };
249 
250 private:
251     SchXMLImportHelper& mrImportHelper;
252     css::uno::Reference< css::chart::XStatisticDisplay > mxStockPropProvider;
253     ContextType const meContextType;
254 
255 public:
256     SchXMLStockContext( SchXMLImportHelper& rImportHelper,
257                         SvXMLImport& rImport,
258                         sal_uInt16 nPrefix,
259                         const OUString& rLocalName,
260                         css::uno::Reference< css::chart::XDiagram > const & xDiagram,
261                         ContextType eContextType );
262     virtual ~SchXMLStockContext() override;
263     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
264 };
265 
266 class SchXMLStatisticsObjectContext : public SvXMLImportContext
267 {
268 public:
269     enum ContextType
270     {
271         CONTEXT_TYPE_MEAN_VALUE_LINE,
272         CONTEXT_TYPE_ERROR_INDICATOR
273     };
274 
275     SchXMLStatisticsObjectContext(
276         SchXMLImportHelper& rImportHelper,
277         SvXMLImport& rImport,
278         sal_uInt16 nPrefix,
279         const OUString& rLocalName,
280         const OUString &rSeriesStyleName,
281         ::std::vector< DataRowPointStyle >& rStyleVector,
282         const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
283         ContextType eContextType,
284         tSchXMLLSequencesPerIndex & rLSequencesPerIndex );
285 
286     virtual ~SchXMLStatisticsObjectContext() override;
287 
288     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
289 
290 private:
291     SchXMLImportHelper &                           mrImportHelper;
292     ::std::vector< DataRowPointStyle > &           mrStyleVector;
293     css::uno::Reference< css::chart2::XDataSeries > m_xSeries;
294     ContextType const                              meContextType;
295     OUString const maSeriesStyleName;
296     tSchXMLLSequencesPerIndex& mrLSequencesPerIndex;
297 };
298 
299 #endif // INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPLOTAREACONTEXT_HXX
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
302