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 _SCH_XMLTABLECONTEXT_HXX_ 24 #define _SCH_XMLTABLECONTEXT_HXX_ 25 26 #include <xmloff/xmlictxt.hxx> 27 #include "SchXMLImport.hxx" 28 // #include "SchXMLChartContext.hxx" 29 #include <com/sun/star/uno/Sequence.hxx> 30 31 #include <com/sun/star/chart/ChartDataRowSource.hpp> 32 33 #include "transporttypes.hxx" 34 35 namespace com { namespace sun { namespace star { 36 namespace frame { 37 class XModel; 38 } 39 namespace xml { namespace sax { 40 class XAttributeList; 41 }} 42 namespace chart { 43 class XChartDocument; 44 struct ChartSeriesAddress; 45 }}}} 46 47 // ======================================== 48 49 class SchXMLTableContext : public SvXMLImportContext 50 { 51 private: 52 SchXMLImportHelper& mrImportHelper; 53 SchXMLTable& mrTable; 54 55 bool mbHasRowPermutation; 56 bool mbHasColumnPermutation; 57 ::com::sun::star::uno::Sequence< sal_Int32 > maRowPermutation; 58 ::com::sun::star::uno::Sequence< sal_Int32 > maColumnPermutation; 59 60 public: 61 SchXMLTableContext( SchXMLImportHelper& rImpHelper, 62 SvXMLImport& rImport, 63 const rtl::OUString& rLocalName, 64 SchXMLTable& aTable ); 65 virtual ~SchXMLTableContext(); 66 67 virtual SvXMLImportContext* CreateChildContext( 68 sal_uInt16 nPrefix, 69 const rtl::OUString& rLocalName, 70 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); 71 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 72 virtual void EndElement(); 73 74 void setRowPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation ); 75 void setColumnPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation ); 76 }; 77 78 // ---------------------------------------- 79 80 class SchXMLTableHelper 81 { 82 private: 83 static void GetCellAddress( const rtl::OUString& rStr, sal_Int32& rCol, sal_Int32& rRow ); 84 static sal_Bool GetCellRangeAddress( const rtl::OUString& rStr, SchNumericCellRangeAddress& rResult ); 85 static void PutTableContentIntoSequence( 86 const SchXMLTable& rTable, 87 SchNumericCellRangeAddress& rAddress, 88 sal_Int32 nSeriesIndex, 89 com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< double > >& aSequence ); 90 static void AdjustMax( const SchNumericCellRangeAddress& rAddr, 91 sal_Int32& nRows, sal_Int32& nColumns ); 92 93 public: 94 static void applyTableToInternalDataProvider( const SchXMLTable& rTable, 95 com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc ); 96 97 /** This function reorders local data to fit the correct data structure. 98 Call it after the data series got their styles set. 99 */ 100 static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable, 101 const tSchXMLLSequencesPerIndex & rLSequencesPerIndex, 102 com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc, 103 ::com::sun::star::chart::ChartDataRowSource eDataRowSource ); 104 }; 105 106 // ======================================== 107 108 // ---------------------------------------- 109 // classes for columns 110 // ---------------------------------------- 111 112 /** With this context all column elements are parsed to 113 determine the index of the column containing 114 the row descriptions and probably get an estimate 115 for the altogether number of columns 116 */ 117 class SchXMLTableColumnsContext : public SvXMLImportContext 118 { 119 private: 120 SchXMLImportHelper& mrImportHelper; 121 SchXMLTable& mrTable; 122 123 public: 124 SchXMLTableColumnsContext( SchXMLImportHelper& rImpHelper, 125 SvXMLImport& rImport, 126 const rtl::OUString& rLocalName, 127 SchXMLTable& aTable ); 128 virtual ~SchXMLTableColumnsContext(); 129 130 virtual SvXMLImportContext* CreateChildContext( 131 sal_uInt16 nPrefix, 132 const rtl::OUString& rLocalName, 133 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); 134 }; 135 136 // ---------------------------------------- 137 138 class SchXMLTableColumnContext : public SvXMLImportContext 139 { 140 private: 141 SchXMLImportHelper& mrImportHelper; 142 SchXMLTable& mrTable; 143 144 public: 145 SchXMLTableColumnContext( SchXMLImportHelper& rImpHelper, 146 SvXMLImport& rImport, 147 const rtl::OUString& rLocalName, 148 SchXMLTable& aTable ); 149 virtual ~SchXMLTableColumnContext(); 150 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 151 }; 152 153 // ---------------------------------------- 154 // classes for rows 155 // ---------------------------------------- 156 157 class SchXMLTableRowsContext : public SvXMLImportContext 158 { 159 private: 160 SchXMLImportHelper& mrImportHelper; 161 SchXMLTable& mrTable; 162 163 public: 164 SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper, 165 SvXMLImport& rImport, 166 const rtl::OUString& rLocalName, 167 SchXMLTable& aTable ); 168 virtual ~SchXMLTableRowsContext(); 169 170 virtual SvXMLImportContext* CreateChildContext( 171 sal_uInt16 nPrefix, 172 const rtl::OUString& rLocalName, 173 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); 174 }; 175 176 // ---------------------------------------- 177 178 class SchXMLTableRowContext : public SvXMLImportContext 179 { 180 private: 181 SchXMLImportHelper& mrImportHelper; 182 SchXMLTable& mrTable; 183 184 public: 185 SchXMLTableRowContext( SchXMLImportHelper& rImpHelper, 186 SvXMLImport& rImport, 187 const rtl::OUString& rLocalName, 188 SchXMLTable& aTable ); 189 virtual ~SchXMLTableRowContext(); 190 191 virtual SvXMLImportContext* CreateChildContext( 192 sal_uInt16 nPrefix, 193 const rtl::OUString& rLocalName, 194 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); 195 }; 196 197 // ---------------------------------------- 198 // classes for cells and their content 199 // ---------------------------------------- 200 201 class SchXMLTableCellContext : public SvXMLImportContext 202 { 203 private: 204 SchXMLImportHelper& mrImportHelper; 205 SchXMLTable& mrTable; 206 rtl::OUString maCellContent; 207 rtl::OUString maRangeId; 208 sal_Bool mbReadText; 209 210 public: 211 SchXMLTableCellContext( SchXMLImportHelper& rImpHelper, 212 SvXMLImport& rImport, 213 const rtl::OUString& rLocalName, 214 SchXMLTable& aTable ); 215 virtual ~SchXMLTableCellContext(); 216 217 virtual SvXMLImportContext* CreateChildContext( 218 sal_uInt16 nPrefix, 219 const rtl::OUString& rLocalName, 220 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); 221 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 222 virtual void EndElement(); 223 }; 224 225 #endif // _SCH_XMLTABLECONTEXT_HXX_ 226