1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLTABLECONTEXT_HXX 20 #define INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLTABLECONTEXT_HXX 21 22 #include <xmloff/xmlictxt.hxx> 23 #include <xmloff/SchXMLImportHelper.hxx> 24 #include <com/sun/star/uno/Sequence.hxx> 25 26 #include <com/sun/star/chart/ChartDataRowSource.hpp> 27 28 #include "transporttypes.hxx" 29 30 namespace com { namespace sun { namespace star { 31 namespace xml { namespace sax { 32 class XAttributeList; 33 }} 34 namespace chart { 35 class XChartDocument; 36 }}}} 37 38 class SchXMLTableContext : public SvXMLImportContext 39 { 40 private: 41 SchXMLImportHelper& mrImportHelper; 42 SchXMLTable& mrTable; 43 44 bool mbHasRowPermutation; 45 bool mbHasColumnPermutation; 46 css::uno::Sequence< sal_Int32 > maRowPermutation; 47 css::uno::Sequence< sal_Int32 > maColumnPermutation; 48 49 public: 50 SchXMLTableContext( SchXMLImportHelper& rImpHelper, 51 SvXMLImport& rImport, 52 const OUString& rLocalName, 53 SchXMLTable& aTable ); 54 virtual ~SchXMLTableContext() override; 55 56 virtual SvXMLImportContextRef CreateChildContext( 57 sal_uInt16 nPrefix, 58 const OUString& rLocalName, 59 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 60 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 61 virtual void EndElement() override; 62 63 void setRowPermutation( const css::uno::Sequence< sal_Int32 > & rPermutation ); 64 void setColumnPermutation( const css::uno::Sequence< sal_Int32 > & rPermutation ); 65 }; 66 67 class SchXMLTableHelper 68 { 69 public: 70 static void applyTableToInternalDataProvider( const SchXMLTable& rTable, 71 const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc ); 72 73 /** This function reorders local data to fit the correct data structure. 74 Call it after the data series got their styles set. 75 */ 76 static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable, 77 const tSchXMLLSequencesPerIndex & rLSequencesPerIndex, 78 const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc, 79 css::chart::ChartDataRowSource eDataRowSource ); 80 }; 81 82 // classes for columns 83 84 /** With this context all column elements are parsed to 85 determine the index of the column containing 86 the row descriptions and probably get an estimate 87 for the altogether number of columns 88 */ 89 class SchXMLTableColumnsContext : public SvXMLImportContext 90 { 91 private: 92 SchXMLTable& mrTable; 93 94 public: 95 SchXMLTableColumnsContext( SvXMLImport& rImport, 96 const OUString& rLocalName, 97 SchXMLTable& aTable ); 98 virtual ~SchXMLTableColumnsContext() override; 99 100 virtual SvXMLImportContextRef CreateChildContext( 101 sal_uInt16 nPrefix, 102 const OUString& rLocalName, 103 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 104 }; 105 106 class SchXMLTableColumnContext : public SvXMLImportContext 107 { 108 private: 109 SchXMLTable& mrTable; 110 111 public: 112 SchXMLTableColumnContext( SvXMLImport& rImport, 113 const OUString& rLocalName, 114 SchXMLTable& aTable ); 115 virtual ~SchXMLTableColumnContext() override; 116 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 117 }; 118 119 // classes for rows 120 121 class SchXMLTableRowsContext : public SvXMLImportContext 122 { 123 private: 124 SchXMLImportHelper& mrImportHelper; 125 SchXMLTable& mrTable; 126 127 public: 128 SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper, 129 SvXMLImport& rImport, 130 const OUString& rLocalName, 131 SchXMLTable& aTable ); 132 virtual ~SchXMLTableRowsContext() override; 133 134 virtual SvXMLImportContextRef CreateChildContext( 135 sal_uInt16 nPrefix, 136 const OUString& rLocalName, 137 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 138 }; 139 140 class SchXMLTableRowContext : public SvXMLImportContext 141 { 142 private: 143 SchXMLImportHelper& mrImportHelper; 144 SchXMLTable& mrTable; 145 146 public: 147 SchXMLTableRowContext( SchXMLImportHelper& rImpHelper, 148 SvXMLImport& rImport, 149 const OUString& rLocalName, 150 SchXMLTable& aTable ); 151 virtual ~SchXMLTableRowContext() override; 152 153 virtual SvXMLImportContextRef CreateChildContext( 154 sal_uInt16 nPrefix, 155 const OUString& rLocalName, 156 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 157 }; 158 159 // classes for cells and their content 160 161 class SchXMLTableCellContext : public SvXMLImportContext 162 { 163 private: 164 SchXMLImportHelper& mrImportHelper; 165 SchXMLTable& mrTable; 166 OUString maCellContent; 167 OUString maRangeId; 168 bool mbReadText; 169 170 public: 171 SchXMLTableCellContext( SchXMLImportHelper& rImpHelper, 172 SvXMLImport& rImport, 173 const OUString& rLocalName, 174 SchXMLTable& aTable ); 175 virtual ~SchXMLTableCellContext() override; 176 177 virtual SvXMLImportContextRef CreateChildContext( 178 sal_uInt16 nPrefix, 179 const OUString& rLocalName, 180 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 181 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; 182 virtual void EndElement() override; 183 }; 184 185 #endif // INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLTABLECONTEXT_HXX 186 187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 188