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 _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
24 #define _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
25 
26 #include <xmloff/uniref.hxx>
27 #include <xmloff/families.hxx>
28 #include <com/sun/star/util/XStringMapping.hpp>
29 #include <com/sun/star/chart/XChartDocument.hpp>
30 
31 namespace com { namespace sun { namespace star {
32 	namespace frame {
33 		class XModel;
34 	}
35 	namespace task {
36 		class XStatusIndicator;
37 	}
38 	namespace xml {
39 		namespace sax {
40             class XAttributeList;
41         }
42     }
43     namespace chart2 {
44         namespace data {
45             class XDataProvider;
46             class XLabeledDataSequence;
47         }
48         class XChartDocument;
49         class XDataSeries;
50     }
51 }}}
52 
53 class SvXMLUnitConverter;
54 class SvXMLStylesContext;
55 class XMLChartImportPropertyMapper;
56 class SvXMLTokenMap;
57 class SvXMLImportContext;
58 class SvXMLImport;
59 
60 // ========================================
61 
62 /** With this class you can import a <chart:chart> element containing
63 	its data as <table:table> element or without internal table. In
64 	the latter case you have to provide a table address mapper that
65 	converts table addresses in XML format to the appropriate application
66 	format.
67  */
68 class SchXMLImportHelper : public UniRefBase
69 {
70 private:
71 	com::sun::star::uno::Reference< com::sun::star::chart::XChartDocument > mxChartDoc;
72 	SvXMLStylesContext* mpAutoStyles;
73 
74 	SvXMLTokenMap* mpChartDocElemTokenMap;
75 	SvXMLTokenMap* mpTableElemTokenMap;
76 	SvXMLTokenMap* mpChartElemTokenMap;
77 	SvXMLTokenMap* mpPlotAreaElemTokenMap;
78 	SvXMLTokenMap* mpSeriesElemTokenMap;
79 
80     SvXMLTokenMap* mpChartAttrTokenMap;
81 	SvXMLTokenMap* mpPlotAreaAttrTokenMap;
82 	SvXMLTokenMap* mpAutoStyleAttrTokenMap;
83 	SvXMLTokenMap* mpCellAttrTokenMap;
84 	SvXMLTokenMap* mpSeriesAttrTokenMap;
85 	SvXMLTokenMap* mpRegEquationAttrTokenMap;
86 
87 public:
88 
89 	SchXMLImportHelper();
90 	~SchXMLImportHelper();
91 
92 	/** get the context for reading the <chart:chart> element with subelements.
93 		The result is stored in the XModel given if it also implements
94 		XChartDocument
95 	 */
96 	SvXMLImportContext* CreateChartContext(
97 		SvXMLImport& rImport,
98 		sal_uInt16 nPrefix, const rtl::OUString& rLocalName,
99 		const com::sun::star::uno::Reference<
100 			com::sun::star::frame::XModel > xChartModel,
101 		const com::sun::star::uno::Reference<
102 			com::sun::star::xml::sax::XAttributeList >& xAttrList );
103 
104 	/** set the auto-style context that will be used to retrieve auto-styles
105 		used inside the following <chart:chart> element to parse
106 	 */
SetAutoStylesContext(SvXMLStylesContext * pAutoStyles)107 	void SetAutoStylesContext( SvXMLStylesContext* pAutoStyles ) { mpAutoStyles = pAutoStyles; }
GetAutoStylesContext() const108 	SvXMLStylesContext* GetAutoStylesContext() const { return mpAutoStyles; }
109 
110 	const com::sun::star::uno::Reference<
GetChartDocument()111 		com::sun::star::chart::XChartDocument >& GetChartDocument()
112 		{ return mxChartDoc; }
113 
114 	const SvXMLTokenMap& GetDocElemTokenMap();
115 	const SvXMLTokenMap& GetTableElemTokenMap();
116 	const SvXMLTokenMap& GetChartElemTokenMap();
117 	const SvXMLTokenMap& GetPlotAreaElemTokenMap();
118 	const SvXMLTokenMap& GetSeriesElemTokenMap();
119 
120 	const SvXMLTokenMap& GetChartAttrTokenMap();
121 	const SvXMLTokenMap& GetPlotAreaAttrTokenMap();
122 	const SvXMLTokenMap& GetAutoStyleAttrTokenMap();
123 	const SvXMLTokenMap& GetCellAttrTokenMap();
124 	const SvXMLTokenMap& GetSeriesAttrTokenMap();
125 	const SvXMLTokenMap& GetRegEquationAttrTokenMap();
126 
GetChartFamilyID()127 	static sal_uInt16 GetChartFamilyID() { return XML_STYLE_FAMILY_SCH_CHART_ID; }
128 
129     /** @param bPushLastChartType If </sal_False>, in case a new chart type has to
130                be added (because it does not exist yet), it is appended at the
131                end of the chart-type container.  When </sal_True>, a new chart type
132                is added at one position before the last one, i.e. the formerly
133                last chart type is pushed back, so that it remains the last one.
134 
135                This is needed when the global chart type is set to type A, but
136                the first series has type B. Then B should appear before A (done
137                by passing true).  Once a series of type A has been read,
138                following new chart types are again be added at the end (by
139                passing false).
140      */
141     static ::com::sun::star::uno::Reference<
142                 ::com::sun::star::chart2::XDataSeries > GetNewDataSeries(
143                     const ::com::sun::star::uno::Reference<
144                         ::com::sun::star::chart2::XChartDocument > & xDoc,
145                     sal_Int32 nCoordinateSystemIndex,
146                     const ::rtl::OUString & rChartTypeName,
147                     bool bPushLastChartType = false );
148 
149     static void DeleteDataSeries(
150                     const ::com::sun::star::uno::Reference<
151                         ::com::sun::star::chart2::XDataSeries >& xSeries,
152                     const ::com::sun::star::uno::Reference<
153                         ::com::sun::star::chart2::XChartDocument > & xDoc );
154 
155     static ::com::sun::star::uno::Reference<
156             ::com::sun::star::chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence();
157 };
158 
159 #endif	// _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
160