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