1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _SCH_XMLTABLECONTEXT_HXX_
20 #define _SCH_XMLTABLECONTEXT_HXX_
22 #include <xmloff/xmlictxt.hxx>
23 #include "SchXMLImport.hxx"
24 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/chart/ChartDataRowSource.hpp>
28 #include "transporttypes.hxx"
30 namespace com
{ namespace sun
{ namespace star
{
31 namespace xml
{ namespace sax
{
38 // ========================================
40 class SchXMLTableContext
: public SvXMLImportContext
43 SchXMLImportHelper
& mrImportHelper
;
46 bool mbHasRowPermutation
;
47 bool mbHasColumnPermutation
;
48 ::com::sun::star::uno::Sequence
< sal_Int32
> maRowPermutation
;
49 ::com::sun::star::uno::Sequence
< sal_Int32
> maColumnPermutation
;
52 SchXMLTableContext( SchXMLImportHelper
& rImpHelper
,
54 const OUString
& rLocalName
,
55 SchXMLTable
& aTable
);
56 virtual ~SchXMLTableContext();
58 virtual SvXMLImportContext
* CreateChildContext(
60 const OUString
& rLocalName
,
61 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
62 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
63 virtual void EndElement();
65 void setRowPermutation( const ::com::sun::star::uno::Sequence
< sal_Int32
> & rPermutation
);
66 void setColumnPermutation( const ::com::sun::star::uno::Sequence
< sal_Int32
> & rPermutation
);
69 // ----------------------------------------
71 class SchXMLTableHelper
74 static void GetCellAddress( const OUString
& rStr
, sal_Int32
& rCol
, sal_Int32
& rRow
);
75 static sal_Bool
GetCellRangeAddress( const OUString
& rStr
, SchNumericCellRangeAddress
& rResult
);
76 static void PutTableContentIntoSequence(
77 const SchXMLTable
& rTable
,
78 SchNumericCellRangeAddress
& rAddress
,
79 sal_Int32 nSeriesIndex
,
80 com::sun::star::uno::Sequence
< com::sun::star::uno::Sequence
< double > >& aSequence
);
81 static void AdjustMax( const SchNumericCellRangeAddress
& rAddr
,
82 sal_Int32
& nRows
, sal_Int32
& nColumns
);
85 static void applyTableToInternalDataProvider( const SchXMLTable
& rTable
,
86 com::sun::star::uno::Reference
< com::sun::star::chart2::XChartDocument
> xChartDoc
);
88 /** This function reorders local data to fit the correct data structure.
89 Call it after the data series got their styles set.
91 static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable
& rTable
,
92 const tSchXMLLSequencesPerIndex
& rLSequencesPerIndex
,
93 com::sun::star::uno::Reference
< com::sun::star::chart2::XChartDocument
> xChartDoc
,
94 ::com::sun::star::chart::ChartDataRowSource eDataRowSource
);
97 // ========================================
99 // ----------------------------------------
100 // classes for columns
101 // ----------------------------------------
103 /** With this context all column elements are parsed to
104 determine the index of the column containing
105 the row descriptions and probably get an estimate
106 for the altogether number of columns
108 class SchXMLTableColumnsContext
: public SvXMLImportContext
111 SchXMLTable
& mrTable
;
114 SchXMLTableColumnsContext( SvXMLImport
& rImport
,
115 const OUString
& rLocalName
,
116 SchXMLTable
& aTable
);
117 virtual ~SchXMLTableColumnsContext();
119 virtual SvXMLImportContext
* CreateChildContext(
121 const OUString
& rLocalName
,
122 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
125 // ----------------------------------------
127 class SchXMLTableColumnContext
: public SvXMLImportContext
130 SchXMLTable
& mrTable
;
133 SchXMLTableColumnContext( SvXMLImport
& rImport
,
134 const OUString
& rLocalName
,
135 SchXMLTable
& aTable
);
136 virtual ~SchXMLTableColumnContext();
137 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
140 // ----------------------------------------
142 // ----------------------------------------
144 class SchXMLTableRowsContext
: public SvXMLImportContext
147 SchXMLImportHelper
& mrImportHelper
;
148 SchXMLTable
& mrTable
;
151 SchXMLTableRowsContext( SchXMLImportHelper
& rImpHelper
,
152 SvXMLImport
& rImport
,
153 const OUString
& rLocalName
,
154 SchXMLTable
& aTable
);
155 virtual ~SchXMLTableRowsContext();
157 virtual SvXMLImportContext
* CreateChildContext(
159 const OUString
& rLocalName
,
160 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
163 // ----------------------------------------
165 class SchXMLTableRowContext
: public SvXMLImportContext
168 SchXMLImportHelper
& mrImportHelper
;
169 SchXMLTable
& mrTable
;
172 SchXMLTableRowContext( SchXMLImportHelper
& rImpHelper
,
173 SvXMLImport
& rImport
,
174 const OUString
& rLocalName
,
175 SchXMLTable
& aTable
);
176 virtual ~SchXMLTableRowContext();
178 virtual SvXMLImportContext
* CreateChildContext(
180 const OUString
& rLocalName
,
181 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
184 // ----------------------------------------
185 // classes for cells and their content
186 // ----------------------------------------
188 class SchXMLTableCellContext
: public SvXMLImportContext
191 SchXMLImportHelper
& mrImportHelper
;
192 SchXMLTable
& mrTable
;
193 OUString maCellContent
;
198 SchXMLTableCellContext( SchXMLImportHelper
& rImpHelper
,
199 SvXMLImport
& rImport
,
200 const OUString
& rLocalName
,
201 SchXMLTable
& aTable
);
202 virtual ~SchXMLTableCellContext();
204 virtual SvXMLImportContext
* CreateChildContext(
206 const OUString
& rLocalName
,
207 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
208 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
209 virtual void EndElement();
212 #endif // _SCH_XMLTABLECONTEXT_HXX_
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */