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_XMLCHARTCONTEXT_HXX_
28 #define _SCH_XMLCHARTCONTEXT_HXX_
29 
30 #include <xmloff/xmlictxt.hxx>
31 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/drawing/XShape.hpp>
33 #include <com/sun/star/chart/ChartDataRowSource.hpp>
34 #include <com/sun/star/chart2/XChartDocument.hpp>
35 #include <com/sun/star/awt/Size.hpp>
36 
37 #include "transporttypes.hxx"
38 
39 #include <list>
40 #include <map>
41 
42 class SchXMLImport;
43 class SchXMLImportHelper;
44 
45 namespace com { namespace sun { namespace star {
46 	namespace chart {
47 		class XChartDocument;
48 		class XDiagram;
49 		struct ChartSeriesAddress;
50 	}
51 	namespace util {
52 		class XStringMapping;
53 	}
54 	namespace xml { namespace sax {
55 		class XAttributeList;
56     }}
57     namespace drawing {
58         class XShapes;
59     }
60 }}}
61 
62 // ----------------------------------------
63 
64 struct SeriesDefaultsAndStyles
65 {
66     //default values for series:
67     ::com::sun::star::uno::Any    maSymbolTypeDefault;
68     ::com::sun::star::uno::Any    maDataCaptionDefault;
69 
70     ::com::sun::star::uno::Any    maErrorIndicatorDefault;
71     ::com::sun::star::uno::Any    maErrorCategoryDefault;
72     ::com::sun::star::uno::Any    maConstantErrorLowDefault;
73     ::com::sun::star::uno::Any    maConstantErrorHighDefault;
74     ::com::sun::star::uno::Any    maPercentageErrorDefault;
75     ::com::sun::star::uno::Any    maErrorMarginDefault;
76 
77     ::com::sun::star::uno::Any    maMeanValueDefault;
78     ::com::sun::star::uno::Any    maRegressionCurvesDefault;
79 
80     ::com::sun::star::uno::Any    maStackedDefault;
81     ::com::sun::star::uno::Any    maPercentDefault;
82     ::com::sun::star::uno::Any    maDeepDefault;
83     ::com::sun::star::uno::Any    maStackedBarsConnectedDefault;
84 
85     //additional information
86     ::com::sun::star::uno::Any    maLinesOnProperty;
87 
88     //styles for series and datapoints
89     ::std::list< DataRowPointStyle > maSeriesStyleList;
90 };
91 
92 class SchXMLChartContext : public SvXMLImportContext
93 {
94 public:
95 	SchXMLChartContext( SchXMLImportHelper& rImpHelper,
96 						SvXMLImport& rImport, const rtl::OUString& rLocalName );
97 	virtual ~SchXMLChartContext();
98 
99 	virtual void StartElement( const com::sun::star::uno::Reference<
100 							   	  com::sun::star::xml::sax::XAttributeList >& xAttrList );
101 	virtual void EndElement();
102 	virtual SvXMLImportContext *CreateChildContext(
103 		sal_uInt16 nPrefix,
104 		const rtl::OUString& rLocalName,
105 		const com::sun::star::uno::Reference<
106 			com::sun::star::xml::sax::XAttributeList >& xAttrList );
107 
108 private:
109 	SchXMLTable maTable;
110 	SchXMLImportHelper& mrImportHelper;
111 
112 	::rtl::OUString maMainTitle, maSubTitle;
113 	com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos;
114     ::rtl::OUString m_aXLinkHRefAttributeToIndicateDataProvider;
115     bool m_bHasRangeAtPlotArea;
116     bool m_bHasTableElement;
117     sal_Bool mbAllRangeAddressesAvailable;
118     sal_Bool mbColHasLabels;
119     sal_Bool mbRowHasLabels;
120     ::com::sun::star::chart::ChartDataRowSource meDataRowSource;
121     bool mbIsStockChart;
122 
123 	com::sun::star::uno::Sequence< com::sun::star::chart::ChartSeriesAddress > maSeriesAddresses;
124 	::rtl::OUString msCategoriesAddress;
125     ::rtl::OUString msChartAddress;
126 
127     SeriesDefaultsAndStyles maSeriesDefaultsAndStyles;
128     tSchXMLLSequencesPerIndex maLSequencesPerIndex;
129 
130     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxDrawPage;
131     ::rtl::OUString msColTrans;
132     ::rtl::OUString msRowTrans;
133     ::rtl::OUString maChartTypeServiceName;
134 
135     ::com::sun::star::awt::Size maChartSize;
136 
137 	/**	@descr	This method bundles some settings to the chart model and executes them with
138 			a locked controller.  This includes setting the chart type.
139 		@param	aServiceName The name of the service the diagram is initialized with.
140 		@param	bSetWitchData	Indicates wether the data set takes it's data series from
141 			rows or from columns.
142 	*/
143 	void	InitChart	(const ::rtl::OUString & rChartTypeServiceName,
144 						sal_Bool bSetSwitchData);
145 
146     void MergeSeriesForStockChart();
147 };
148 
149 // ----------------------------------------
150 
151 class SchXMLTitleContext : public SvXMLImportContext
152 {
153 private:
154 	SchXMLImportHelper& mrImportHelper;
155 	rtl::OUString& mrTitle;
156 	com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxTitleShape;
157 	rtl::OUString msAutoStyleName;
158 
159 public:
160 	SchXMLTitleContext( SchXMLImportHelper& rImpHelper,
161 						SvXMLImport& rImport, const rtl::OUString& rLocalName,
162 						rtl::OUString& rTitle,
163 						com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xTitleShape );
164 	virtual ~SchXMLTitleContext();
165 
166 	virtual void StartElement( const com::sun::star::uno::Reference<
167 							   com::sun::star::xml::sax::XAttributeList >& xAttrList );
168 	virtual SvXMLImportContext *CreateChildContext(
169 		sal_uInt16 nPrefix,
170 		const rtl::OUString& rLocalName,
171 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
172 };
173 
174 #endif	// _SCH_XMLCHARTCONTEXT_HXX_
175