xref: /AOO41X/main/xmloff/source/chart/SchXMLTableContext.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _SCH_XMLTABLECONTEXT_HXX_
28*cdf0e10cSrcweir #define _SCH_XMLTABLECONTEXT_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
31*cdf0e10cSrcweir #include "SchXMLImport.hxx"
32*cdf0e10cSrcweir // #include "SchXMLChartContext.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "transporttypes.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
40*cdf0e10cSrcweir 	namespace frame {
41*cdf0e10cSrcweir 		class XModel;
42*cdf0e10cSrcweir 	}
43*cdf0e10cSrcweir 	namespace xml { namespace sax {
44*cdf0e10cSrcweir 		class XAttributeList;
45*cdf0e10cSrcweir 	}}
46*cdf0e10cSrcweir 	namespace chart {
47*cdf0e10cSrcweir 		class XChartDocument;
48*cdf0e10cSrcweir 		struct ChartSeriesAddress;
49*cdf0e10cSrcweir }}}}
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir // ========================================
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class SchXMLTableContext : public SvXMLImportContext
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir private:
56*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
57*cdf0e10cSrcweir 	SchXMLTable& mrTable;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     bool mbHasRowPermutation;
60*cdf0e10cSrcweir     bool mbHasColumnPermutation;
61*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int32 > maRowPermutation;
62*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int32 > maColumnPermutation;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir 	SchXMLTableContext( SchXMLImportHelper& rImpHelper,
66*cdf0e10cSrcweir 						SvXMLImport& rImport,
67*cdf0e10cSrcweir 						const rtl::OUString& rLocalName,
68*cdf0e10cSrcweir 						SchXMLTable& aTable );
69*cdf0e10cSrcweir 	virtual ~SchXMLTableContext();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
72*cdf0e10cSrcweir 		sal_uInt16 nPrefix,
73*cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
74*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
75*cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
76*cdf0e10cSrcweir 	virtual void EndElement();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     void setRowPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
79*cdf0e10cSrcweir     void setColumnPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
80*cdf0e10cSrcweir };
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir // ----------------------------------------
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir class SchXMLTableHelper
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir private:
87*cdf0e10cSrcweir 	static void GetCellAddress( const rtl::OUString& rStr, sal_Int32& rCol, sal_Int32& rRow );
88*cdf0e10cSrcweir 	static sal_Bool GetCellRangeAddress( const rtl::OUString& rStr, SchNumericCellRangeAddress& rResult );
89*cdf0e10cSrcweir 	static void PutTableContentIntoSequence(
90*cdf0e10cSrcweir 		const SchXMLTable& rTable,
91*cdf0e10cSrcweir 		SchNumericCellRangeAddress& rAddress,
92*cdf0e10cSrcweir 		sal_Int32 nSeriesIndex,
93*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< double > >& aSequence );
94*cdf0e10cSrcweir 	static void AdjustMax( const SchNumericCellRangeAddress& rAddr,
95*cdf0e10cSrcweir 						   sal_Int32& nRows, sal_Int32& nColumns );
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir public:
98*cdf0e10cSrcweir 	static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
99*cdf0e10cSrcweir 							com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     /** This function reorders local data to fit the correct data structure.
102*cdf0e10cSrcweir         Call it after the data series got their styles set.
103*cdf0e10cSrcweir      */
104*cdf0e10cSrcweir 	static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable,
105*cdf0e10cSrcweir                                   const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
106*cdf0e10cSrcweir                                   com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
107*cdf0e10cSrcweir                                   ::com::sun::star::chart::ChartDataRowSource eDataRowSource );
108*cdf0e10cSrcweir };
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir // ========================================
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir // ----------------------------------------
113*cdf0e10cSrcweir // classes for columns
114*cdf0e10cSrcweir // ----------------------------------------
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir /** With this context all column elements are parsed to
117*cdf0e10cSrcweir 	determine the index of the column containing
118*cdf0e10cSrcweir 	the row descriptions and probably get an estimate
119*cdf0e10cSrcweir 	for the altogether number of columns
120*cdf0e10cSrcweir  */
121*cdf0e10cSrcweir class SchXMLTableColumnsContext : public SvXMLImportContext
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir private:
124*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
125*cdf0e10cSrcweir 	SchXMLTable& mrTable;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir public:
128*cdf0e10cSrcweir 	SchXMLTableColumnsContext( SchXMLImportHelper& rImpHelper,
129*cdf0e10cSrcweir 							   SvXMLImport& rImport,
130*cdf0e10cSrcweir 							   const rtl::OUString& rLocalName,
131*cdf0e10cSrcweir 							   SchXMLTable& aTable );
132*cdf0e10cSrcweir 	virtual ~SchXMLTableColumnsContext();
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
135*cdf0e10cSrcweir 		sal_uInt16 nPrefix,
136*cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
137*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
138*cdf0e10cSrcweir };
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir // ----------------------------------------
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir class SchXMLTableColumnContext : public SvXMLImportContext
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir private:
145*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
146*cdf0e10cSrcweir 	SchXMLTable& mrTable;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir public:
149*cdf0e10cSrcweir 	SchXMLTableColumnContext( SchXMLImportHelper& rImpHelper,
150*cdf0e10cSrcweir 							  SvXMLImport& rImport,
151*cdf0e10cSrcweir 							  const rtl::OUString& rLocalName,
152*cdf0e10cSrcweir 							  SchXMLTable& aTable );
153*cdf0e10cSrcweir 	virtual ~SchXMLTableColumnContext();
154*cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
155*cdf0e10cSrcweir };
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir // ----------------------------------------
158*cdf0e10cSrcweir // classes for rows
159*cdf0e10cSrcweir // ----------------------------------------
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir class SchXMLTableRowsContext : public SvXMLImportContext
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir private:
164*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
165*cdf0e10cSrcweir 	SchXMLTable& mrTable;
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir public:
168*cdf0e10cSrcweir 	SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper,
169*cdf0e10cSrcweir 							SvXMLImport& rImport,
170*cdf0e10cSrcweir 							const rtl::OUString& rLocalName,
171*cdf0e10cSrcweir 							SchXMLTable& aTable );
172*cdf0e10cSrcweir 	virtual ~SchXMLTableRowsContext();
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
175*cdf0e10cSrcweir 		sal_uInt16 nPrefix,
176*cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
177*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
178*cdf0e10cSrcweir };
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // ----------------------------------------
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir class SchXMLTableRowContext : public SvXMLImportContext
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir private:
185*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
186*cdf0e10cSrcweir 	SchXMLTable& mrTable;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir public:
189*cdf0e10cSrcweir 	SchXMLTableRowContext( SchXMLImportHelper& rImpHelper,
190*cdf0e10cSrcweir 						   SvXMLImport& rImport,
191*cdf0e10cSrcweir 						   const rtl::OUString& rLocalName,
192*cdf0e10cSrcweir 						   SchXMLTable& aTable );
193*cdf0e10cSrcweir 	virtual ~SchXMLTableRowContext();
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
196*cdf0e10cSrcweir 		sal_uInt16 nPrefix,
197*cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
198*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
199*cdf0e10cSrcweir };
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir // ----------------------------------------
202*cdf0e10cSrcweir // classes for cells and their content
203*cdf0e10cSrcweir // ----------------------------------------
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir class SchXMLTableCellContext : public SvXMLImportContext
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir private:
208*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
209*cdf0e10cSrcweir 	SchXMLTable& mrTable;
210*cdf0e10cSrcweir 	rtl::OUString maCellContent;
211*cdf0e10cSrcweir     rtl::OUString maRangeId;
212*cdf0e10cSrcweir 	sal_Bool mbReadText;
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir public:
215*cdf0e10cSrcweir 	SchXMLTableCellContext( SchXMLImportHelper& rImpHelper,
216*cdf0e10cSrcweir 							SvXMLImport& rImport,
217*cdf0e10cSrcweir 							const rtl::OUString& rLocalName,
218*cdf0e10cSrcweir 							SchXMLTable& aTable );
219*cdf0e10cSrcweir 	virtual ~SchXMLTableCellContext();
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	virtual SvXMLImportContext* CreateChildContext(
222*cdf0e10cSrcweir 		sal_uInt16 nPrefix,
223*cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
224*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
225*cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
226*cdf0e10cSrcweir 	virtual void EndElement();
227*cdf0e10cSrcweir };
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir #endif	// _SCH_XMLTABLECONTEXT_HXX_
230