1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SchXMLTableContext.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SCH_XMLTABLECONTEXT_HXX_
31 #define _SCH_XMLTABLECONTEXT_HXX_
33 #include <xmloff/xmlictxt.hxx>
34 #include "SchXMLImport.hxx"
35 // #include "SchXMLChartContext.hxx"
36 #include <com/sun/star/uno/Sequence.hxx>
38 #include <com/sun/star/chart/ChartDataRowSource.hpp>
40 #include "transporttypes.hxx"
42 namespace com
{ namespace sun
{ namespace star
{
46 namespace xml
{ namespace sax
{
51 class XChartDataArray
;
52 struct ChartSeriesAddress
;
55 // ========================================
57 class SchXMLTableContext
: public SvXMLImportContext
60 SchXMLImportHelper
& mrImportHelper
;
63 bool mbHasRowPermutation
;
64 bool mbHasColumnPermutation
;
65 ::com::sun::star::uno::Sequence
< sal_Int32
> maRowPermutation
;
66 ::com::sun::star::uno::Sequence
< sal_Int32
> maColumnPermutation
;
69 SchXMLTableContext( SchXMLImportHelper
& rImpHelper
,
71 const rtl::OUString
& rLocalName
,
72 SchXMLTable
& aTable
);
73 virtual ~SchXMLTableContext();
75 virtual SvXMLImportContext
* CreateChildContext(
77 const rtl::OUString
& rLocalName
,
78 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
79 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
80 virtual void EndElement();
82 void setRowPermutation( const ::com::sun::star::uno::Sequence
< sal_Int32
> & rPermutation
);
83 void setColumnPermutation( const ::com::sun::star::uno::Sequence
< sal_Int32
> & rPermutation
);
86 // ----------------------------------------
88 class SchXMLTableHelper
91 static void GetCellAddress( const rtl::OUString
& rStr
, sal_Int32
& rCol
, sal_Int32
& rRow
);
92 static sal_Bool
GetCellRangeAddress( const rtl::OUString
& rStr
, SchNumericCellRangeAddress
& rResult
);
93 static void PutTableContentIntoSequence(
94 const SchXMLTable
& rTable
,
95 SchNumericCellRangeAddress
& rAddress
,
96 sal_Int32 nSeriesIndex
,
97 com::sun::star::uno::Sequence
< com::sun::star::uno::Sequence
< double > >& aSequence
);
98 static void AdjustMax( const SchNumericCellRangeAddress
& rAddr
,
99 sal_Int32
& nRows
, sal_Int32
& nColumns
);
102 /// The data for the ChartDocument is applied linearly
103 static void applyTableSimple(
104 const SchXMLTable
& rTable
,
105 const com::sun::star::uno::Reference
< com::sun::star::chart::XChartDataArray
> & xData
);
107 /** The data for the ChartDocument is applied by reading the
108 table, the addresses of series, the addresses of labels,
109 the cell-range-address for the categories
111 static void applyTableToInternalDataProvider( const SchXMLTable
& rTable
,
112 com::sun::star::uno::Reference
< com::sun::star::chart2::XChartDocument
> xChartDoc
);
114 /** Second part of applyTableToInternalDataProvider that has to be called after the data series
115 got their styles set. This function reorders local data to fit the
116 correct data structure.
118 static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable
& rTable
,
119 const tSchXMLLSequencesPerIndex
& rLSequencesPerIndex
,
120 com::sun::star::uno::Reference
< com::sun::star::chart2::XChartDocument
> xChartDoc
,
121 ::com::sun::star::chart::ChartDataRowSource eDataRowSource
);
124 // ========================================
126 // ----------------------------------------
127 // classes for columns
128 // ----------------------------------------
130 /** With this context all column elements are parsed to
131 determine the index of the column containing
132 the row descriptions and probably get an estimate
133 for the altogether number of columns
135 class SchXMLTableColumnsContext
: public SvXMLImportContext
138 SchXMLImportHelper
& mrImportHelper
;
139 SchXMLTable
& mrTable
;
142 SchXMLTableColumnsContext( SchXMLImportHelper
& rImpHelper
,
143 SvXMLImport
& rImport
,
144 const rtl::OUString
& rLocalName
,
145 SchXMLTable
& aTable
);
146 virtual ~SchXMLTableColumnsContext();
148 virtual SvXMLImportContext
* CreateChildContext(
150 const rtl::OUString
& rLocalName
,
151 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
154 // ----------------------------------------
156 class SchXMLTableColumnContext
: public SvXMLImportContext
159 SchXMLImportHelper
& mrImportHelper
;
160 SchXMLTable
& mrTable
;
163 SchXMLTableColumnContext( SchXMLImportHelper
& rImpHelper
,
164 SvXMLImport
& rImport
,
165 const rtl::OUString
& rLocalName
,
166 SchXMLTable
& aTable
);
167 virtual ~SchXMLTableColumnContext();
168 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
171 // ----------------------------------------
173 // ----------------------------------------
175 class SchXMLTableRowsContext
: public SvXMLImportContext
178 SchXMLImportHelper
& mrImportHelper
;
179 SchXMLTable
& mrTable
;
182 SchXMLTableRowsContext( SchXMLImportHelper
& rImpHelper
,
183 SvXMLImport
& rImport
,
184 const rtl::OUString
& rLocalName
,
185 SchXMLTable
& aTable
);
186 virtual ~SchXMLTableRowsContext();
188 virtual SvXMLImportContext
* CreateChildContext(
190 const rtl::OUString
& rLocalName
,
191 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
194 // ----------------------------------------
196 class SchXMLTableRowContext
: public SvXMLImportContext
199 SchXMLImportHelper
& mrImportHelper
;
200 SchXMLTable
& mrTable
;
203 SchXMLTableRowContext( SchXMLImportHelper
& rImpHelper
,
204 SvXMLImport
& rImport
,
205 const rtl::OUString
& rLocalName
,
206 SchXMLTable
& aTable
);
207 virtual ~SchXMLTableRowContext();
209 virtual SvXMLImportContext
* CreateChildContext(
211 const rtl::OUString
& rLocalName
,
212 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
215 // ----------------------------------------
216 // classes for cells and their content
217 // ----------------------------------------
219 class SchXMLTableCellContext
: public SvXMLImportContext
222 SchXMLImportHelper
& mrImportHelper
;
223 SchXMLTable
& mrTable
;
224 rtl::OUString maCellContent
;
225 rtl::OUString maRangeId
;
229 SchXMLTableCellContext( SchXMLImportHelper
& rImpHelper
,
230 SvXMLImport
& rImport
,
231 const rtl::OUString
& rLocalName
,
232 SchXMLTable
& aTable
);
233 virtual ~SchXMLTableCellContext();
235 virtual SvXMLImportContext
* CreateChildContext(
237 const rtl::OUString
& rLocalName
,
238 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
239 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
240 virtual void EndElement();
243 #endif // _SCH_XMLTABLECONTEXT_HXX_