xref: /AOO41X/main/xmloff/source/chart/SchXMLChartContext.hxx (revision ecfe53c5d1886e1e0d215b0d140d05282ab1c477)
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_XMLCHARTCONTEXT_HXX_
24 #define _SCH_XMLCHARTCONTEXT_HXX_
25 
26 #include <xmloff/xmlictxt.hxx>
27 #include <com/sun/star/uno/Sequence.h>
28 #include <com/sun/star/drawing/XShape.hpp>
29 #include <com/sun/star/chart/ChartDataRowSource.hpp>
30 #include <com/sun/star/chart2/XChartDocument.hpp>
31 #include <com/sun/star/awt/Size.hpp>
32 
33 #include "transporttypes.hxx"
34 
35 #include <list>
36 #include <map>
37 
38 class SchXMLImport;
39 class SchXMLImportHelper;
40 
41 namespace com { namespace sun { namespace star {
42     namespace chart {
43         class XChartDocument;
44         class XDiagram;
45         struct ChartSeriesAddress;
46     }
47     namespace util {
48         class XStringMapping;
49     }
50     namespace xml { namespace sax {
51         class XAttributeList;
52     }}
53     namespace drawing {
54         class XShapes;
55     }
56 }}}
57 
58 // ----------------------------------------
59 
60 struct SeriesDefaultsAndStyles
61 {
62     //default values for series:
63     ::com::sun::star::uno::Any    maSymbolTypeDefault;
64     ::com::sun::star::uno::Any    maDataCaptionDefault;
65 
66     ::com::sun::star::uno::Any    maErrorIndicatorDefault;
67     ::com::sun::star::uno::Any    maErrorCategoryDefault;
68     ::com::sun::star::uno::Any    maConstantErrorLowDefault;
69     ::com::sun::star::uno::Any    maConstantErrorHighDefault;
70     ::com::sun::star::uno::Any    maPercentageErrorDefault;
71     ::com::sun::star::uno::Any    maErrorMarginDefault;
72 
73     ::com::sun::star::uno::Any    maMeanValueDefault;
74     ::com::sun::star::uno::Any    maRegressionCurvesDefault;
75 
76     ::com::sun::star::uno::Any    maStackedDefault;
77     ::com::sun::star::uno::Any    maPercentDefault;
78     ::com::sun::star::uno::Any    maDeepDefault;
79     ::com::sun::star::uno::Any    maStackedBarsConnectedDefault;
80 
81     //additional information
82     ::com::sun::star::uno::Any    maLinesOnProperty;
83 
84     //styles for series and datapoints
85     ::std::list< DataRowPointStyle > maSeriesStyleList;
86 };
87 
88 class SchXMLChartContext : public SvXMLImportContext
89 {
90 public:
91     SchXMLChartContext( SchXMLImportHelper& rImpHelper,
92                         SvXMLImport& rImport, const rtl::OUString& rLocalName );
93     virtual ~SchXMLChartContext();
94 
95     virtual void StartElement( const com::sun::star::uno::Reference<
96                                   com::sun::star::xml::sax::XAttributeList >& xAttrList );
97     virtual void EndElement();
98     virtual SvXMLImportContext *CreateChildContext(
99         sal_uInt16 nPrefix,
100         const rtl::OUString& rLocalName,
101         const com::sun::star::uno::Reference<
102             com::sun::star::xml::sax::XAttributeList >& xAttrList );
103 
104 private:
105     SchXMLTable maTable;
106     SchXMLImportHelper& mrImportHelper;
107 
108     ::rtl::OUString maMainTitle, maSubTitle;
109     com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos;
110     ::rtl::OUString m_aXLinkHRefAttributeToIndicateDataProvider;
111     bool m_bHasRangeAtPlotArea;
112     bool m_bHasTableElement;
113     sal_Bool mbAllRangeAddressesAvailable;
114     sal_Bool mbColHasLabels;
115     sal_Bool mbRowHasLabels;
116     ::com::sun::star::chart::ChartDataRowSource meDataRowSource;
117     bool mbIsStockChart;
118 
119     com::sun::star::uno::Sequence< com::sun::star::chart::ChartSeriesAddress > maSeriesAddresses;
120     ::rtl::OUString msCategoriesAddress;
121     ::rtl::OUString msChartAddress;
122 
123     SeriesDefaultsAndStyles maSeriesDefaultsAndStyles;
124     tSchXMLLSequencesPerIndex maLSequencesPerIndex;
125 
126     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxDrawPage;
127     ::rtl::OUString msColTrans;
128     ::rtl::OUString msRowTrans;
129     ::rtl::OUString maChartTypeServiceName;
130 
131     ::com::sun::star::awt::Size maChartSize;
132 
133     /** @descr  This method bundles some settings to the chart model and executes them with
134             a locked controller.  This includes setting the chart type.
135         @param  aServiceName The name of the service the diagram is initialized with.
136         @param  bSetWitchData   Indicates wether the data set takes it's data series from
137             rows or from columns.
138     */
139     void    InitChart   (const ::rtl::OUString & rChartTypeServiceName,
140                         sal_Bool bSetSwitchData);
141 
142     void MergeSeriesForStockChart();
143 };
144 
145 // ----------------------------------------
146 
147 class SchXMLTitleContext : public SvXMLImportContext
148 {
149 private:
150     SchXMLImportHelper& mrImportHelper;
151     rtl::OUString& mrTitle;
152     com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxTitleShape;
153     rtl::OUString msAutoStyleName;
154 
155 public:
156     SchXMLTitleContext( SchXMLImportHelper& rImpHelper,
157                         SvXMLImport& rImport, const rtl::OUString& rLocalName,
158                         rtl::OUString& rTitle,
159                         com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xTitleShape );
160     virtual ~SchXMLTitleContext();
161 
162     virtual void StartElement( const com::sun::star::uno::Reference<
163                                com::sun::star::xml::sax::XAttributeList >& xAttrList );
164     virtual SvXMLImportContext *CreateChildContext(
165         sal_uInt16 nPrefix,
166         const rtl::OUString& rLocalName,
167         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
168 };
169 
170 #endif  // _SCH_XMLCHARTCONTEXT_HXX_
171