1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SCH_XMLPLOTAREACONTEXT_HXX_
28 #define _SCH_XMLPLOTAREACONTEXT_HXX_
29 
30 #include "SchXMLImport.hxx"
31 #include "SchXMLChartContext.hxx"
32 #include <xmloff/xmlictxt.hxx>
33 #include <xmloff/shapeimport.hxx>
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <com/sun/star/chart/ChartSeriesAddress.hpp>
36 #include <com/sun/star/chart/ChartDataRowSource.hpp>
37 
38 #include "transporttypes.hxx"
39 
40 class SvXMLImport;
41 
42 namespace com { namespace sun { namespace star {
43 	namespace chart {
44 		class XDiagram;
45 		class X3DDisplay;
46         class XStatisticDisplay;
47 	}
48     namespace chart2 {
49         class XChartDocument;
50     }
51 	namespace xml { namespace sax {
52 		class XAttributeList;
53 }}}}}
54 
55 // ----------------------------------------
56 
57 class SchXML3DSceneAttributesHelper : public SdXML3DSceneAttributesHelper
58 {
59 public:
60     SchXML3DSceneAttributesHelper( SvXMLImport& rImporter );
61     virtual ~SchXML3DSceneAttributesHelper();
62 
63     void getCameraDefaultFromDiagram( const ::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram );
64 
65 private:
66     SchXML3DSceneAttributesHelper();
67 };
68 
69 // ----------------------------------------
70 
71 class SchXMLPositonAttributesHelper
72 {
73 public:
74 	SchXMLPositonAttributesHelper( SvXMLImport& rImporter );
75 	~SchXMLPositonAttributesHelper();
76 
77 	bool readPositioningAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue );
78     void readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt );
79 
80     bool hasPosSize() const;
81     bool isAutomatic() const;
82     ::com::sun::star::awt::Rectangle getRectangle() const;
83 
84 
85 private:
86     bool hasSize() const;
87     bool hasPosition() const;
88     ::com::sun::star::awt::Size getSize() const;
89     ::com::sun::star::awt::Point getPosition() const;
90 
91 	SvXMLImport& m_rImport;
92 
93 	::com::sun::star::awt::Point m_aPosition;
94     ::com::sun::star::awt::Size m_aSize;
95 
96     bool m_bHasSizeWidth;
97     bool m_bHasSizeHeight;
98     bool m_bHasPositionX;
99     bool m_bHasPositionY;
100     sal_Bool m_bAutoSize;
101     sal_Bool m_bAutoPosition;
102 };
103 
104 // ----------------------------------------
105 
106 class SchXMLPlotAreaContext : public SvXMLImportContext
107 {
108 public:
109 	SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
110 						   SvXMLImport& rImport, const rtl::OUString& rLocalName,
111                            const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
112 						   ::com::sun::star::uno::Sequence<
113 						       ::com::sun::star::chart::ChartSeriesAddress >& rSeriesAddresses,
114 						   ::rtl::OUString& rCategoriesAddress,
115                            ::rtl::OUString& rChartAddress,
116                            bool& bHasRangeAtPlotArea,
117                            sal_Bool & rAllRangeAddressesAvailable,
118                            sal_Bool & rColHasLabels,
119                            sal_Bool & rRowHasLabels,
120                            ::com::sun::star::chart::ChartDataRowSource & rDataRowSource,
121                            SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
122                            const ::rtl::OUString& aChartTypeServiceName,
123                            tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
124                            const ::com::sun::star::awt::Size & rChartSize );
125 	virtual ~SchXMLPlotAreaContext();
126 
127 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
128 	virtual SvXMLImportContext* CreateChildContext(
129 		sal_uInt16 nPrefix,
130 		const rtl::OUString& rLocalName,
131 		const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
132 	virtual void EndElement();
133 
134 private:
135 	SchXMLImportHelper& mrImportHelper;
136 	::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram;
137 	::com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > mxNewDoc;
138 	::std::vector< SchXMLAxis > maAxes;
139 	::com::sun::star::uno::Sequence< ::com::sun::star::chart::ChartSeriesAddress >& mrSeriesAddresses;
140 	rtl::OUString& mrCategoriesAddress;
141     SeriesDefaultsAndStyles& mrSeriesDefaultsAndStyles;
142     sal_Int32 mnNumOfLinesProp;
143     sal_Bool  mbStockHasVolume;
144 	sal_Int32 mnSeries;
145     GlobalSeriesImportInfo m_aGlobalSeriesImportInfo;
146 
147 	SchXML3DSceneAttributesHelper maSceneImportHelper;
148 	SchXMLPositonAttributesHelper m_aOuterPositioning;//including axes and axes titles
149     SchXMLPositonAttributesHelper m_aInnerPositioning;//excluding axes and axes titles
150     bool mbPercentStacked;
151     bool m_bAxisPositionAttributeImported;
152 	::rtl::OUString msAutoStyleName;
153     const ::rtl::OUString& m_rXLinkHRefAttributeToIndicateDataProvider;
154     ::rtl::OUString& mrChartAddress;
155     bool& m_rbHasRangeAtPlotArea;
156     sal_Bool & mrColHasLabels;
157     sal_Bool & mrRowHasLabels;
158     ::com::sun::star::chart::ChartDataRowSource & mrDataRowSource;
159     ::rtl::OUString maChartTypeServiceName;
160 
161     tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
162 
163     bool mbGlobalChartTypeUsedBySeries;
164     ::com::sun::star::awt::Size maChartSize;
165 };
166 
167 //----------------------------------------
168 
169 class SchXMLDataPointContext : public SvXMLImportContext
170 {
171 private:
172 	SchXMLImportHelper& mrImportHelper;
173 	::std::list< DataRowPointStyle >& mrStyleList;
174     ::com::sun::star::uno::Reference<
175                 ::com::sun::star::chart2::XDataSeries > m_xSeries;
176     sal_Int32& mrIndex;
177     bool mbSymbolSizeForSeriesIsMissingInFile;
178 
179 public:
180 	SchXMLDataPointContext(  SchXMLImportHelper& rImpHelper,
181 							 SvXMLImport& rImport, const rtl::OUString& rLocalName,
182 							 ::std::list< DataRowPointStyle >& rStyleList,
183                              const ::com::sun::star::uno::Reference<
184                                 ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32& rIndex,
185                                 bool bSymbolSizeForSeriesIsMissingInFile );
186 	virtual ~SchXMLDataPointContext();
187 
188 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
189 };
190 
191 // ----------------------------------------
192 
193 class SchXMLCoordinateRegionContext : public SvXMLImportContext
194 {
195 public:
196     SchXMLCoordinateRegionContext(
197             SvXMLImport& rImport
198             , sal_uInt16 nPrefix
199             , const rtl::OUString& rLocalName
200             , SchXMLPositonAttributesHelper& rPositioning );
201     virtual ~SchXMLCoordinateRegionContext();
202     virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
203 
204 private:
205 	SchXMLPositonAttributesHelper& m_rPositioning;
206 };
207 
208 // ----------------------------------------
209 
210 class SchXMLWallFloorContext : public SvXMLImportContext
211 {
212 public:
213 	enum ContextType
214 	{
215 		CONTEXT_TYPE_WALL,
216 		CONTEXT_TYPE_FLOOR
217 	};
218 
219 private:
220 	SchXMLImportHelper& mrImportHelper;
221 	::com::sun::star::uno::Reference< ::com::sun::star::chart::X3DDisplay > mxWallFloorSupplier;
222 	ContextType meContextType;
223 
224 public:
225 	SchXMLWallFloorContext( SchXMLImportHelper& rImportHelper,
226 							SvXMLImport& rImport,
227 							sal_uInt16 nPrefix,
228 							const rtl::OUString& rLocalName,
229 							::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram >& xDiagram,
230 							ContextType eContextType );
231 	virtual ~SchXMLWallFloorContext();
232 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
233 };
234 
235 // ----------------------------------------
236 
237 class SchXMLStockContext : public SvXMLImportContext
238 {
239 public:
240 	enum ContextType
241 	{
242 		CONTEXT_TYPE_GAIN,
243 		CONTEXT_TYPE_LOSS,
244 		CONTEXT_TYPE_RANGE
245 	};
246 
247 private:
248 	SchXMLImportHelper& mrImportHelper;
249 	::com::sun::star::uno::Reference< ::com::sun::star::chart::XStatisticDisplay > mxStockPropProvider;
250 	ContextType meContextType;
251 
252 public:
253 	SchXMLStockContext( SchXMLImportHelper& rImportHelper,
254                         SvXMLImport& rImport,
255                         sal_uInt16 nPrefix,
256                         const rtl::OUString& rLocalName,
257                         ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram >& xDiagram,
258                         ContextType eContextType );
259 	virtual ~SchXMLStockContext();
260 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
261 };
262 
263 // ----------------------------------------
264 
265 class SchXMLStatisticsObjectContext : public SvXMLImportContext
266 {
267 public:
268     enum ContextType
269     {
270         CONTEXT_TYPE_MEAN_VALUE_LINE,
271         CONTEXT_TYPE_REGRESSION_CURVE,
272         CONTEXT_TYPE_ERROR_INDICATOR
273     };
274 
275     SchXMLStatisticsObjectContext(
276         SchXMLImportHelper& rImportHelper,
277         SvXMLImport& rImport,
278         sal_uInt16 nPrefix,
279         const rtl::OUString& rLocalName,
280         ::std::list< DataRowPointStyle >& rStyleList,
281         const ::com::sun::star::uno::Reference<
282                 ::com::sun::star::chart2::XDataSeries >& xSeries,
283         ContextType eContextType,
284         const ::com::sun::star::awt::Size & rChartSize );
285 
286     virtual ~SchXMLStatisticsObjectContext();
287 
288 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
289 	virtual SvXMLImportContext* CreateChildContext(
290 		sal_uInt16 nPrefix,
291 		const rtl::OUString& rLocalName,
292 		const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
293 
294 private:
295     SchXMLImportHelper &                           mrImportHelper;
296 	::std::list< DataRowPointStyle > &             mrStyleList;
297     ::com::sun::star::uno::Reference<
298                 ::com::sun::star::chart2::XDataSeries > m_xSeries;
299 	ContextType                                    meContextType;
300     ::com::sun::star::awt::Size                    maChartSize;
301 };
302 
303 // ----------------------------------------
304 
305 class SchXMLEquationContext : public SvXMLImportContext
306 {
307 public:
308     SchXMLEquationContext(
309         SchXMLImportHelper& rImportHelper,
310         SvXMLImport& rImport,
311         sal_uInt16 nPrefix,
312         const rtl::OUString& rLocalName,
313         const ::com::sun::star::uno::Reference<
314                 ::com::sun::star::chart2::XDataSeries >& xSeries,
315         const ::com::sun::star::awt::Size & rChartSize,
316         DataRowPointStyle & rRegressionStyle );
317 
318     virtual ~SchXMLEquationContext();
319 
320 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
321 
322 private:
323     SchXMLImportHelper &                           mrImportHelper;
324     DataRowPointStyle &                            mrRegressionStyle;
325     ::com::sun::star::uno::Reference<
326                 ::com::sun::star::chart2::XDataSeries > m_xSeries;
327     ::com::sun::star::awt::Size maChartSize;
328 };
329 
330 #endif	// _SCH_XMLPLOTAREACONTEXT_HXX_
331