Line data Source code
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 _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
20 : #define _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
21 :
22 : #include <xmloff/uniref.hxx>
23 : #include <xmloff/families.hxx>
24 : #include <com/sun/star/util/XStringMapping.hpp>
25 : #include <com/sun/star/chart/XChartDocument.hpp>
26 :
27 : namespace com { namespace sun { namespace star {
28 : namespace frame {
29 : class XModel;
30 : }
31 : namespace task {
32 : class XStatusIndicator;
33 : }
34 : namespace xml {
35 : namespace sax {
36 : class XAttributeList;
37 : }
38 : }
39 : namespace chart2 {
40 : namespace data {
41 : class XDataProvider;
42 : class XLabeledDataSequence;
43 : }
44 : class XChartDocument;
45 : class XDataSeries;
46 : }
47 : }}}
48 :
49 : class SvXMLUnitConverter;
50 : class SvXMLStylesContext;
51 : class XMLChartImportPropertyMapper;
52 : class SvXMLTokenMap;
53 : class SvXMLImportContext;
54 : class SvXMLImport;
55 :
56 : // ========================================
57 :
58 : /** With this class you can import a <chart:chart> element containing
59 : its data as <table:table> element or without internal table. In
60 : the latter case you have to provide a table address mapper that
61 : converts table addresses in XML format to the appropriate application
62 : format.
63 : */
64 : class SchXMLImportHelper : public UniRefBase
65 : {
66 : private:
67 : com::sun::star::uno::Reference< com::sun::star::chart::XChartDocument > mxChartDoc;
68 : SvXMLStylesContext* mpAutoStyles;
69 :
70 : SvXMLTokenMap* mpChartDocElemTokenMap;
71 : SvXMLTokenMap* mpTableElemTokenMap;
72 : SvXMLTokenMap* mpChartElemTokenMap;
73 : SvXMLTokenMap* mpPlotAreaElemTokenMap;
74 : SvXMLTokenMap* mpSeriesElemTokenMap;
75 :
76 : SvXMLTokenMap* mpChartAttrTokenMap;
77 : SvXMLTokenMap* mpPlotAreaAttrTokenMap;
78 : SvXMLTokenMap* mpAutoStyleAttrTokenMap;
79 : SvXMLTokenMap* mpCellAttrTokenMap;
80 : SvXMLTokenMap* mpSeriesAttrTokenMap;
81 : SvXMLTokenMap* mpRegEquationAttrTokenMap;
82 :
83 : public:
84 :
85 : SchXMLImportHelper();
86 : ~SchXMLImportHelper();
87 :
88 : /** get the context for reading the <chart:chart> element with subelements.
89 : The result is stored in the XModel given if it also implements
90 : XChartDocument
91 : */
92 : SvXMLImportContext* CreateChartContext(
93 : SvXMLImport& rImport,
94 : sal_uInt16 nPrefix, const rtl::OUString& rLocalName,
95 : const com::sun::star::uno::Reference<
96 : com::sun::star::frame::XModel > xChartModel,
97 : const com::sun::star::uno::Reference<
98 : com::sun::star::xml::sax::XAttributeList >& xAttrList );
99 :
100 : /** set the auto-style context that will be used to retrieve auto-styles
101 : used inside the following <chart:chart> element to parse
102 : */
103 82 : void SetAutoStylesContext( SvXMLStylesContext* pAutoStyles ) { mpAutoStyles = pAutoStyles; }
104 0 : SvXMLStylesContext* GetAutoStylesContext() const { return mpAutoStyles; }
105 :
106 : const com::sun::star::uno::Reference<
107 0 : com::sun::star::chart::XChartDocument >& GetChartDocument()
108 0 : { return mxChartDoc; }
109 :
110 : const SvXMLTokenMap& GetDocElemTokenMap();
111 : const SvXMLTokenMap& GetTableElemTokenMap();
112 : const SvXMLTokenMap& GetChartElemTokenMap();
113 : const SvXMLTokenMap& GetPlotAreaElemTokenMap();
114 : const SvXMLTokenMap& GetSeriesElemTokenMap();
115 :
116 : const SvXMLTokenMap& GetChartAttrTokenMap();
117 : const SvXMLTokenMap& GetPlotAreaAttrTokenMap();
118 : const SvXMLTokenMap& GetCellAttrTokenMap();
119 : const SvXMLTokenMap& GetSeriesAttrTokenMap();
120 : const SvXMLTokenMap& GetRegEquationAttrTokenMap();
121 :
122 0 : static sal_uInt16 GetChartFamilyID() { return XML_STYLE_FAMILY_SCH_CHART_ID; }
123 :
124 : /** @param bPushLastChartType If </sal_False>, in case a new chart type has to
125 : be added (because it does not exist yet), it is appended at the
126 : end of the chart-type container. When </sal_True>, a new chart type
127 : is added at one position before the last one, i.e. the formerly
128 : last chart type is pushed back, so that it remains the last one.
129 :
130 : This is needed when the global chart type is set to type A, but
131 : the first series has type B. Then B should appear before A (done
132 : by passing true). Once a series of type A has been read,
133 : following new chart types are again be added at the end (by
134 : passing false).
135 : */
136 : static ::com::sun::star::uno::Reference<
137 : ::com::sun::star::chart2::XDataSeries > GetNewDataSeries(
138 : const ::com::sun::star::uno::Reference<
139 : ::com::sun::star::chart2::XChartDocument > & xDoc,
140 : sal_Int32 nCoordinateSystemIndex,
141 : const ::rtl::OUString & rChartTypeName,
142 : bool bPushLastChartType = false );
143 :
144 : static void DeleteDataSeries(
145 : const ::com::sun::star::uno::Reference<
146 : ::com::sun::star::chart2::XDataSeries >& xSeries,
147 : const ::com::sun::star::uno::Reference<
148 : ::com::sun::star::chart2::XChartDocument > & xDoc );
149 : };
150 :
151 : #endif // _XMLOFF_SCH_XMLIMPORTHELPER_HXX_
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|