xref: /AOO41X/main/xmloff/source/chart/SchXMLTableContext.hxx (revision ecfe53c5d1886e1e0d215b0d140d05282ab1c477)
1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SCH_XMLTABLECONTEXT_HXX_
24cdf0e10cSrcweir #define _SCH_XMLTABLECONTEXT_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
27cdf0e10cSrcweir #include "SchXMLImport.hxx"
28cdf0e10cSrcweir // #include "SchXMLChartContext.hxx"
29cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "transporttypes.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace com { namespace sun { namespace star {
36cdf0e10cSrcweir 	namespace frame {
37cdf0e10cSrcweir 		class XModel;
38cdf0e10cSrcweir 	}
39cdf0e10cSrcweir 	namespace xml { namespace sax {
40cdf0e10cSrcweir 		class XAttributeList;
41cdf0e10cSrcweir 	}}
42cdf0e10cSrcweir 	namespace chart {
43cdf0e10cSrcweir 		class XChartDocument;
44cdf0e10cSrcweir 		struct ChartSeriesAddress;
45cdf0e10cSrcweir }}}}
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // ========================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class SchXMLTableContext : public SvXMLImportContext
50cdf0e10cSrcweir {
51cdf0e10cSrcweir private:
52cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
53cdf0e10cSrcweir 	SchXMLTable& mrTable;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     bool mbHasRowPermutation;
56cdf0e10cSrcweir     bool mbHasColumnPermutation;
57cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int32 > maRowPermutation;
58cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int32 > maColumnPermutation;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir 	SchXMLTableContext( SchXMLImportHelper& rImpHelper,
62cdf0e10cSrcweir 						SvXMLImport& rImport,
63cdf0e10cSrcweir 						const rtl::OUString& rLocalName,
64cdf0e10cSrcweir 						SchXMLTable& aTable );
65cdf0e10cSrcweir 	virtual ~SchXMLTableContext();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
68cdf0e10cSrcweir 		sal_uInt16 nPrefix,
69cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
70cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
71cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
72cdf0e10cSrcweir 	virtual void EndElement();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     void setRowPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
75cdf0e10cSrcweir     void setColumnPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
76cdf0e10cSrcweir };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // ----------------------------------------
79cdf0e10cSrcweir 
80cdf0e10cSrcweir class SchXMLTableHelper
81cdf0e10cSrcweir {
82cdf0e10cSrcweir private:
83cdf0e10cSrcweir 	static void GetCellAddress( const rtl::OUString& rStr, sal_Int32& rCol, sal_Int32& rRow );
84cdf0e10cSrcweir 	static sal_Bool GetCellRangeAddress( const rtl::OUString& rStr, SchNumericCellRangeAddress& rResult );
85cdf0e10cSrcweir 	static void PutTableContentIntoSequence(
86cdf0e10cSrcweir 		const SchXMLTable& rTable,
87cdf0e10cSrcweir 		SchNumericCellRangeAddress& rAddress,
88cdf0e10cSrcweir 		sal_Int32 nSeriesIndex,
89cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< double > >& aSequence );
90cdf0e10cSrcweir 	static void AdjustMax( const SchNumericCellRangeAddress& rAddr,
91cdf0e10cSrcweir 						   sal_Int32& nRows, sal_Int32& nColumns );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir 	static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
95cdf0e10cSrcweir 							com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     /** This function reorders local data to fit the correct data structure.
98cdf0e10cSrcweir         Call it after the data series got their styles set.
99cdf0e10cSrcweir      */
100cdf0e10cSrcweir 	static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable,
101cdf0e10cSrcweir                                   const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
102cdf0e10cSrcweir                                   com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
103cdf0e10cSrcweir                                   ::com::sun::star::chart::ChartDataRowSource eDataRowSource );
104cdf0e10cSrcweir };
105cdf0e10cSrcweir 
106cdf0e10cSrcweir // ========================================
107cdf0e10cSrcweir 
108cdf0e10cSrcweir // ----------------------------------------
109cdf0e10cSrcweir // classes for columns
110cdf0e10cSrcweir // ----------------------------------------
111cdf0e10cSrcweir 
112cdf0e10cSrcweir /** With this context all column elements are parsed to
113cdf0e10cSrcweir 	determine the index of the column containing
114cdf0e10cSrcweir 	the row descriptions and probably get an estimate
115cdf0e10cSrcweir 	for the altogether number of columns
116cdf0e10cSrcweir  */
117cdf0e10cSrcweir class SchXMLTableColumnsContext : public SvXMLImportContext
118cdf0e10cSrcweir {
119cdf0e10cSrcweir private:
120cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
121cdf0e10cSrcweir 	SchXMLTable& mrTable;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir 	SchXMLTableColumnsContext( SchXMLImportHelper& rImpHelper,
125cdf0e10cSrcweir 							   SvXMLImport& rImport,
126cdf0e10cSrcweir 							   const rtl::OUString& rLocalName,
127cdf0e10cSrcweir 							   SchXMLTable& aTable );
128cdf0e10cSrcweir 	virtual ~SchXMLTableColumnsContext();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
131cdf0e10cSrcweir 		sal_uInt16 nPrefix,
132cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
133cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
134cdf0e10cSrcweir };
135cdf0e10cSrcweir 
136cdf0e10cSrcweir // ----------------------------------------
137cdf0e10cSrcweir 
138cdf0e10cSrcweir class SchXMLTableColumnContext : public SvXMLImportContext
139cdf0e10cSrcweir {
140cdf0e10cSrcweir private:
141cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
142cdf0e10cSrcweir 	SchXMLTable& mrTable;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir public:
145cdf0e10cSrcweir 	SchXMLTableColumnContext( SchXMLImportHelper& rImpHelper,
146cdf0e10cSrcweir 							  SvXMLImport& rImport,
147cdf0e10cSrcweir 							  const rtl::OUString& rLocalName,
148cdf0e10cSrcweir 							  SchXMLTable& aTable );
149cdf0e10cSrcweir 	virtual ~SchXMLTableColumnContext();
150cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
151cdf0e10cSrcweir };
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // ----------------------------------------
154cdf0e10cSrcweir // classes for rows
155cdf0e10cSrcweir // ----------------------------------------
156cdf0e10cSrcweir 
157cdf0e10cSrcweir class SchXMLTableRowsContext : public SvXMLImportContext
158cdf0e10cSrcweir {
159cdf0e10cSrcweir private:
160cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
161cdf0e10cSrcweir 	SchXMLTable& mrTable;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir public:
164cdf0e10cSrcweir 	SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper,
165cdf0e10cSrcweir 							SvXMLImport& rImport,
166cdf0e10cSrcweir 							const rtl::OUString& rLocalName,
167cdf0e10cSrcweir 							SchXMLTable& aTable );
168cdf0e10cSrcweir 	virtual ~SchXMLTableRowsContext();
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
171cdf0e10cSrcweir 		sal_uInt16 nPrefix,
172cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
173cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
174cdf0e10cSrcweir };
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // ----------------------------------------
177cdf0e10cSrcweir 
178cdf0e10cSrcweir class SchXMLTableRowContext : public SvXMLImportContext
179cdf0e10cSrcweir {
180cdf0e10cSrcweir private:
181cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
182cdf0e10cSrcweir 	SchXMLTable& mrTable;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir public:
185cdf0e10cSrcweir 	SchXMLTableRowContext( SchXMLImportHelper& rImpHelper,
186cdf0e10cSrcweir 						   SvXMLImport& rImport,
187cdf0e10cSrcweir 						   const rtl::OUString& rLocalName,
188cdf0e10cSrcweir 						   SchXMLTable& aTable );
189cdf0e10cSrcweir 	virtual ~SchXMLTableRowContext();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
192cdf0e10cSrcweir 		sal_uInt16 nPrefix,
193cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
194cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
195cdf0e10cSrcweir };
196cdf0e10cSrcweir 
197cdf0e10cSrcweir // ----------------------------------------
198cdf0e10cSrcweir // classes for cells and their content
199cdf0e10cSrcweir // ----------------------------------------
200cdf0e10cSrcweir 
201cdf0e10cSrcweir class SchXMLTableCellContext : public SvXMLImportContext
202cdf0e10cSrcweir {
203cdf0e10cSrcweir private:
204cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
205cdf0e10cSrcweir 	SchXMLTable& mrTable;
206cdf0e10cSrcweir 	rtl::OUString maCellContent;
207cdf0e10cSrcweir     rtl::OUString maRangeId;
208cdf0e10cSrcweir 	sal_Bool mbReadText;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir public:
211cdf0e10cSrcweir 	SchXMLTableCellContext( SchXMLImportHelper& rImpHelper,
212cdf0e10cSrcweir 							SvXMLImport& rImport,
213cdf0e10cSrcweir 							const rtl::OUString& rLocalName,
214cdf0e10cSrcweir 							SchXMLTable& aTable );
215cdf0e10cSrcweir 	virtual ~SchXMLTableCellContext();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
218cdf0e10cSrcweir 		sal_uInt16 nPrefix,
219cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
220cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
221cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
222cdf0e10cSrcweir 	virtual void EndElement();
223cdf0e10cSrcweir };
224cdf0e10cSrcweir 
225cdf0e10cSrcweir #endif	// _SCH_XMLTABLECONTEXT_HXX_
226