/src/libreoffice/oox/source/drawingml/chart/chartspacefragment.cxx
Line | Count | Source |
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 | | |
20 | | #include <drawingml/chart/chartspacefragment.hxx> |
21 | | |
22 | | #include <drawingml/shapepropertiescontext.hxx> |
23 | | #include <drawingml/textbodycontext.hxx> |
24 | | #include <drawingml/chart/chartspacemodel.hxx> |
25 | | #include <drawingml/chart/plotareacontext.hxx> |
26 | | #include <drawingml/chart/titlecontext.hxx> |
27 | | #include <drawingml/chart/datasourcecontext.hxx> |
28 | | #include <oox/core/xmlfilterbase.hxx> |
29 | | #include <oox/helper/attributelist.hxx> |
30 | | #include <oox/token/namespaces.hxx> |
31 | | |
32 | | namespace oox::drawingml::chart { |
33 | | |
34 | | using namespace ::oox::core; |
35 | | |
36 | | ChartSpaceFragment::ChartSpaceFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, ChartSpaceModel& rModel ) : |
37 | 0 | FragmentBase< ChartSpaceModel >( rFilter, rFragmentPath, rModel ) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | ChartSpaceFragment::~ChartSpaceFragment() |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) |
46 | 0 | { |
47 | 0 | bool bMSO2007Document = getFilter().isMSO2007Document(); |
48 | 0 | switch( getCurrentElement() ) |
49 | 0 | { |
50 | 0 | case XML_ROOT_CONTEXT: |
51 | 0 | switch( nElement ) |
52 | 0 | { |
53 | 0 | case C_TOKEN( chartSpace ): |
54 | 0 | return this; |
55 | 0 | case CX_TOKEN(chartSpace) : |
56 | 0 | return this; |
57 | 0 | } |
58 | 0 | break; |
59 | | |
60 | 0 | case C_TOKEN( chartSpace ): |
61 | 0 | switch( nElement ) |
62 | 0 | { |
63 | 0 | case C_TOKEN ( date1904 ): |
64 | 0 | mrModel.mbDate1904 = rAttribs.getBool( XML_val, false ); |
65 | 0 | return nullptr; |
66 | 0 | case C_TOKEN( chart ): |
67 | 0 | return this; |
68 | 0 | case C_TOKEN( spPr ): |
69 | 0 | return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() ); |
70 | 0 | case C_TOKEN( style ): |
71 | 0 | mrModel.mnStyle = rAttribs.getInteger( XML_val, 2 ); |
72 | 0 | mrModel.mbExplicitStyle = true; |
73 | 0 | return nullptr; |
74 | 0 | case C_TOKEN( txPr ): |
75 | 0 | return new TextBodyContext( *this, mrModel.mxTextProp.create() ); |
76 | 0 | case C_TOKEN( userShapes ): |
77 | 0 | mrModel.maDrawingPath = getFragmentPathFromRelId( rAttribs.getStringDefaulted( R_TOKEN( id )) ); |
78 | 0 | return nullptr; |
79 | 0 | case C_TOKEN( pivotSource ): |
80 | 0 | mrModel.mbPivotChart = true; |
81 | 0 | return nullptr; |
82 | 0 | case C_TOKEN (externalData): |
83 | 0 | mrModel.maSheetPath = getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(id))); |
84 | 0 | return nullptr; |
85 | 0 | case C_TOKEN(clrMapOvr): |
86 | 0 | if (mrModel.mpClrMap) |
87 | 0 | for (auto nClrToken : { |
88 | 0 | XML_bg1, |
89 | 0 | XML_tx1, |
90 | 0 | XML_bg2, |
91 | 0 | XML_tx2, |
92 | 0 | XML_accent1, |
93 | 0 | XML_accent2, |
94 | 0 | XML_accent3, |
95 | 0 | XML_accent4, |
96 | 0 | XML_accent5, |
97 | 0 | XML_accent6, |
98 | 0 | XML_hlink, |
99 | 0 | XML_folHlink, |
100 | 0 | }) |
101 | 0 | if (auto oMappedToken = rAttribs.getToken(nClrToken)) |
102 | 0 | mrModel.mpClrMap->setColorMap(nClrToken, *oMappedToken); |
103 | 0 | return nullptr; |
104 | 0 | } |
105 | 0 | break; |
106 | | |
107 | 0 | case C_TOKEN( chart ): |
108 | 0 | switch( nElement ) |
109 | 0 | { |
110 | 0 | case C_TOKEN( autoTitleDeleted ): |
111 | 0 | { |
112 | |
|
113 | 0 | mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, !bMSO2007Document ); |
114 | 0 | return nullptr; |
115 | 0 | } |
116 | 0 | case C_TOKEN( backWall ): |
117 | 0 | return new WallFloorContext( *this, mrModel.mxBackWall.create() ); |
118 | 0 | case C_TOKEN( dispBlanksAs ): |
119 | 0 | { |
120 | | // default value is XML_gap for MSO 2007 and XML_zero in OOXML |
121 | 0 | mrModel.mnDispBlanksAs = rAttribs.getToken( XML_val, bMSO2007Document ? XML_gap : XML_zero ); |
122 | 0 | return nullptr; |
123 | 0 | } |
124 | 0 | case C_TOKEN( floor ): |
125 | 0 | return new WallFloorContext( *this, mrModel.mxFloor.create() ); |
126 | 0 | case C_TOKEN( legend ): |
127 | 0 | return new LegendContext( *this, mrModel.mxLegend.create() ); |
128 | 0 | case C_TOKEN( plotArea ): |
129 | 0 | return new PlotAreaContext( *this, mrModel.mxPlotArea.create() ); |
130 | 0 | case C_TOKEN( plotVisOnly ): |
131 | 0 | mrModel.mbPlotVisOnly = rAttribs.getBool( XML_val, !bMSO2007Document ); |
132 | 0 | return nullptr; |
133 | 0 | case C_TOKEN( showDLblsOverMax ): |
134 | 0 | mrModel.mbShowLabelsOverMax = rAttribs.getBool( XML_val, !bMSO2007Document ); |
135 | 0 | return nullptr; |
136 | 0 | case C_TOKEN( sideWall ): |
137 | 0 | return new WallFloorContext( *this, mrModel.mxSideWall.create() ); |
138 | 0 | case C_TOKEN( title ): |
139 | 0 | return new TitleContext( *this, mrModel.mxTitle.create() ); |
140 | 0 | case C_TOKEN( view3D ): |
141 | 0 | return new View3DContext( *this, mrModel.mxView3D.create(bMSO2007Document) ); |
142 | 0 | } |
143 | 0 | break; |
144 | | |
145 | | // chartex handling |
146 | 0 | case CX_TOKEN(chartSpace) : |
147 | 0 | switch (nElement) { |
148 | 0 | case CX_TOKEN(chartData): |
149 | 0 | return new DataSourceCxContext(*this, mrModel.maCxData.create()); |
150 | 0 | case CX_TOKEN(chart): |
151 | 0 | return this; |
152 | 0 | case CX_TOKEN(spPr): |
153 | 0 | return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() ); |
154 | 0 | case CX_TOKEN(txPr): |
155 | 0 | return new TextBodyContext( *this, mrModel.mxTextProp.create() ); |
156 | 0 | case CX_TOKEN(clrMapOvr): |
157 | | // TODO |
158 | 0 | return nullptr; |
159 | 0 | case CX_TOKEN(fmtOvrs): |
160 | | // TODO |
161 | 0 | return nullptr; |
162 | 0 | case CX_TOKEN(printSettings): |
163 | | // TODO |
164 | 0 | return nullptr; |
165 | 0 | case CX_TOKEN(extLst): |
166 | | // TODO |
167 | 0 | return nullptr; |
168 | 0 | default: |
169 | | // shouldn't happen |
170 | 0 | assert(false); |
171 | |
|
172 | 0 | } |
173 | 0 | break; |
174 | 0 | case CX_TOKEN(chart) : |
175 | 0 | switch (nElement) { |
176 | 0 | case CX_TOKEN(title): |
177 | 0 | return new TitleContext( *this, mrModel.mxTitle.create() ); |
178 | 0 | case CX_TOKEN(plotArea): |
179 | 0 | return new PlotAreaContext( *this, mrModel.mxPlotArea.create() ); |
180 | 0 | case CX_TOKEN(legend): |
181 | 0 | { |
182 | 0 | const bool bOverlay = rAttribs.getBool(XML_overlay, false); |
183 | 0 | const sal_Int32 nPos = rAttribs.getToken(XML_pos, XML_t); |
184 | |
|
185 | 0 | return new LegendContext( *this, mrModel.mxLegend.create(), |
186 | 0 | bOverlay, nPos); |
187 | 0 | } |
188 | 0 | case CX_TOKEN(extLst): |
189 | | // TODO |
190 | 0 | return nullptr; |
191 | 0 | default: |
192 | | // shouldn't happen |
193 | 0 | assert(false); |
194 | 0 | } |
195 | 0 | break; |
196 | 0 | } |
197 | 0 | return nullptr; |
198 | 0 | } |
199 | | |
200 | | } // namespace oox::drawingml::chart |
201 | | |
202 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |