1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _XMLOFF_SCH_XMLIMPORTHELPER_HXX_ 28 #define _XMLOFF_SCH_XMLIMPORTHELPER_HXX_ 29 30 #include <xmloff/uniref.hxx> 31 #include <xmloff/families.hxx> 32 #include <com/sun/star/util/XStringMapping.hpp> 33 #include <com/sun/star/chart/XChartDocument.hpp> 34 35 namespace com { namespace sun { namespace star { 36 namespace frame { 37 class XModel; 38 } 39 namespace task { 40 class XStatusIndicator; 41 } 42 namespace xml { 43 namespace sax { 44 class XAttributeList; 45 } 46 } 47 namespace chart2 { 48 namespace data { 49 class XDataProvider; 50 class XLabeledDataSequence; 51 } 52 class XChartDocument; 53 class XDataSeries; 54 } 55 }}} 56 57 class SvXMLUnitConverter; 58 class SvXMLStylesContext; 59 class XMLChartImportPropertyMapper; 60 class SvXMLTokenMap; 61 class SvXMLImportContext; 62 class SvXMLImport; 63 64 // ======================================== 65 66 /** With this class you can import a <chart:chart> element containing 67 its data as <table:table> element or without internal table. In 68 the latter case you have to provide a table address mapper that 69 converts table addresses in XML format to the appropriate application 70 format. 71 */ 72 class SchXMLImportHelper : public UniRefBase 73 { 74 private: 75 com::sun::star::uno::Reference< com::sun::star::chart::XChartDocument > mxChartDoc; 76 SvXMLStylesContext* mpAutoStyles; 77 78 SvXMLTokenMap* mpChartDocElemTokenMap; 79 SvXMLTokenMap* mpTableElemTokenMap; 80 SvXMLTokenMap* mpChartElemTokenMap; 81 SvXMLTokenMap* mpPlotAreaElemTokenMap; 82 SvXMLTokenMap* mpSeriesElemTokenMap; 83 84 SvXMLTokenMap* mpChartAttrTokenMap; 85 SvXMLTokenMap* mpPlotAreaAttrTokenMap; 86 SvXMLTokenMap* mpAutoStyleAttrTokenMap; 87 SvXMLTokenMap* mpCellAttrTokenMap; 88 SvXMLTokenMap* mpSeriesAttrTokenMap; 89 SvXMLTokenMap* mpRegEquationAttrTokenMap; 90 91 public: 92 93 SchXMLImportHelper(); 94 ~SchXMLImportHelper(); 95 96 /** get the context for reading the <chart:chart> element with subelements. 97 The result is stored in the XModel given if it also implements 98 XChartDocument 99 */ 100 SvXMLImportContext* CreateChartContext( 101 SvXMLImport& rImport, 102 sal_uInt16 nPrefix, const rtl::OUString& rLocalName, 103 const com::sun::star::uno::Reference< 104 com::sun::star::frame::XModel > xChartModel, 105 const com::sun::star::uno::Reference< 106 com::sun::star::xml::sax::XAttributeList >& xAttrList ); 107 108 /** set the auto-style context that will be used to retrieve auto-styles 109 used inside the following <chart:chart> element to parse 110 */ 111 void SetAutoStylesContext( SvXMLStylesContext* pAutoStyles ) { mpAutoStyles = pAutoStyles; } 112 SvXMLStylesContext* GetAutoStylesContext() const { return mpAutoStyles; } 113 114 const com::sun::star::uno::Reference< 115 com::sun::star::chart::XChartDocument >& GetChartDocument() 116 { return mxChartDoc; } 117 118 const SvXMLTokenMap& GetDocElemTokenMap(); 119 const SvXMLTokenMap& GetTableElemTokenMap(); 120 const SvXMLTokenMap& GetChartElemTokenMap(); 121 const SvXMLTokenMap& GetPlotAreaElemTokenMap(); 122 const SvXMLTokenMap& GetSeriesElemTokenMap(); 123 124 const SvXMLTokenMap& GetChartAttrTokenMap(); 125 const SvXMLTokenMap& GetPlotAreaAttrTokenMap(); 126 const SvXMLTokenMap& GetAutoStyleAttrTokenMap(); 127 const SvXMLTokenMap& GetCellAttrTokenMap(); 128 const SvXMLTokenMap& GetSeriesAttrTokenMap(); 129 const SvXMLTokenMap& GetRegEquationAttrTokenMap(); 130 131 static sal_uInt16 GetChartFamilyID() { return XML_STYLE_FAMILY_SCH_CHART_ID; } 132 133 /** @param bPushLastChartType If </sal_False>, in case a new chart type has to 134 be added (because it does not exist yet), it is appended at the 135 end of the chart-type container. When </sal_True>, a new chart type 136 is added at one position before the last one, i.e. the formerly 137 last chart type is pushed back, so that it remains the last one. 138 139 This is needed when the global chart type is set to type A, but 140 the first series has type B. Then B should appear before A (done 141 by passing true). Once a series of type A has been read, 142 following new chart types are again be added at the end (by 143 passing false). 144 */ 145 static ::com::sun::star::uno::Reference< 146 ::com::sun::star::chart2::XDataSeries > GetNewDataSeries( 147 const ::com::sun::star::uno::Reference< 148 ::com::sun::star::chart2::XChartDocument > & xDoc, 149 sal_Int32 nCoordinateSystemIndex, 150 const ::rtl::OUString & rChartTypeName, 151 bool bPushLastChartType = false ); 152 153 static void DeleteDataSeries( 154 const ::com::sun::star::uno::Reference< 155 ::com::sun::star::chart2::XDataSeries >& xSeries, 156 const ::com::sun::star::uno::Reference< 157 ::com::sun::star::chart2::XChartDocument > & xDoc ); 158 159 static ::com::sun::star::uno::Reference< 160 ::com::sun::star::chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence(); 161 }; 162 163 #endif // _XMLOFF_SCH_XMLIMPORTHELPER_HXX_ 164