Avoid potential negative array index access to cached text.
[LibreOffice.git] / xmloff / source / chart / PropertyMaps.cxx
blob964e317e780cd0cb64949f24ffaf8ea86794fa96
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "PropertyMap.hxx"
22 #include <sax/tools/converter.hxx>
24 #include "SchXMLTools.hxx"
25 #include <XMLChartPropertySetMapper.hxx>
26 #include "XMLErrorIndicatorPropertyHdl.hxx"
27 #include "XMLErrorBarStylePropertyHdl.hxx"
28 #include "XMLTextOrientationHdl.hxx"
29 #include "XMLSymbolTypePropertyHdl.hxx"
30 #include "XMLAxisPositionPropertyHdl.hxx"
31 #include <propimp0.hxx>
33 #include <xmloff/EnumPropertyHdl.hxx>
34 #include <comphelper/attributelist.hxx>
35 #include <xmloff/namespacemap.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include <xmloff/shapeimport.hxx>
38 #include <xmloff/xmlexp.hxx>
39 #include <xmloff/xmltoken.hxx>
40 #include <xmloff/prhdlfac.hxx>
42 #include <com/sun/star/awt/Size.hpp>
43 #include <com/sun/star/drawing/LineStyle.hpp>
44 #include <com/sun/star/drawing/FillStyle.hpp>
45 #include <com/sun/star/chart/ChartAxisMarks.hpp>
46 #include <com/sun/star/chart/ChartDataCaption.hpp>
47 #include <com/sun/star/chart2/MovingAverageType.hpp>
48 #include <com/sun/star/chart2/XChartDocument.hpp>
49 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
50 #include <com/sun/star/graphic/XGraphic.hpp>
52 #include <rtl/ustrbuf.hxx>
53 #include <xmlprop.hxx>
55 #define SCH_XML_SETFLAG( status, flag ) (status)|= (flag)
56 #define SCH_XML_UNSETFLAG( status, flag ) (status) = ((status) | (flag)) - (flag)
58 using namespace com::sun::star;
59 using namespace ::xmloff::token;
60 using namespace css::chart2;
63 #define MAP_FULL( ApiName, NameSpace, XMLTokenName, XMLType, ContextId, EarliestODFVersionForExport ) { ApiName, NameSpace, xmloff::token::XMLTokenName, XMLType|XML_TYPE_PROP_CHART, ContextId, EarliestODFVersionForExport, false }
64 #define MAP_ENTRY( a, ns, nm, t ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_010, false }
65 #define MAP_ENTRY_ODF12( a, ns, nm, t ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_012, false }
66 #define MAP_ENTRY_ODF13( a, ns, nm, t ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_013, false }
67 #define MAP_ENTRY_ODF_EXT( a, ns, nm, t ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED, false }
68 #define MAP_ENTRY_ODF_EXT_IMPORT( a, ns, nm, t ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED, true }
69 #define MAP_CONTEXT( a, ns, nm, t, c ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, c, SvtSaveOptions::ODFSVER_010, false }
70 #define MAP_SPECIAL( a, ns, nm, t, c ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFSVER_010, false }
71 #define MAP_SPECIAL_ODF12( a, ns, nm, t, c ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFSVER_012, false }
72 #define MAP_SPECIAL_ODF13( a, ns, nm, t, c ) { a, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFSVER_013, false }
73 #define MAP_ENTRY_END { nullptr }
75 // PropertyMap for Chart properties drawing- and
76 // textproperties are added later using the chaining
77 // mechanism
79 const XMLPropertyMapEntry aXMLChartPropMap[] =
81 // chart subtypes
82 MAP_ENTRY( PROP_UpDown, XML_NAMESPACE_CHART, XML_JAPANESE_CANDLE_STICK, XML_TYPE_BOOL ), // formerly XML_STOCK_UPDOWN_BARS
83 MAP_CONTEXT( PROP_Volume, XML_NAMESPACE_CHART, XML_STOCK_WITH_VOLUME, XML_TYPE_BOOL, XML_SCH_CONTEXT_STOCK_WITH_VOLUME ),
84 MAP_ENTRY( PROP_Dim3D, XML_NAMESPACE_CHART, XML_THREE_DIMENSIONAL, XML_TYPE_BOOL ),
85 MAP_ENTRY( PROP_Deep, XML_NAMESPACE_CHART, XML_DEEP, XML_TYPE_BOOL ),
86 MAP_ENTRY( PROP_Lines, XML_NAMESPACE_CHART, XML_LINES, XML_TYPE_BOOL ),
87 MAP_ENTRY( PROP_Percent, XML_NAMESPACE_CHART, XML_PERCENTAGE, XML_TYPE_BOOL ),
88 MAP_ENTRY( PROP_SolidType, XML_NAMESPACE_CHART, XML_SOLID_TYPE, XML_SCH_TYPE_SOLID_TYPE ),
89 // ODF 1.3 OFFICE-3662 added values
90 MAP_ENTRY( PROP_SplineType, XML_NAMESPACE_CHART, XML_INTERPOLATION, XML_SCH_TYPE_INTERPOLATION ),
91 MAP_ENTRY( PROP_Stacked, XML_NAMESPACE_CHART, XML_STACKED, XML_TYPE_BOOL ),
92 // type: "none", "automatic", "named-symbol" or "image"
93 MAP_ENTRY( PROP_SymbolType, XML_NAMESPACE_CHART, XML_SYMBOL_TYPE, XML_SCH_TYPE_SYMBOL_TYPE | MID_FLAG_MULTI_PROPERTY ),
94 // if type=="named-symbol" => name of symbol (square, diamond, ...)
95 MAP_ENTRY( PROP_SymbolType, XML_NAMESPACE_CHART, XML_SYMBOL_NAME, XML_SCH_TYPE_NAMED_SYMBOL | MID_FLAG_MULTI_PROPERTY ),
96 // if type=="image" => an xlink:href element with a linked (package) URI
97 MAP_SPECIAL( PROP_SymbolBitmap, XML_NAMESPACE_CHART, XML_SYMBOL_IMAGE, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE ),
98 MAP_SPECIAL( PROP_SymbolSize, XML_NAMESPACE_CHART, XML_SYMBOL_WIDTH, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH ),
99 MAP_SPECIAL( PROP_SymbolSize, XML_NAMESPACE_CHART, XML_SYMBOL_HEIGHT, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ),
100 MAP_ENTRY( PROP_Vertical, XML_NAMESPACE_CHART, XML_VERTICAL, XML_TYPE_BOOL ),
101 // #i32368# property should no longer be used as XML-property (in OASIS
102 // format), but is still ex-/imported for compatibility with the OOo file format
103 MAP_CONTEXT( PROP_NumberOfLines, XML_NAMESPACE_CHART, XML_LINES_USED, XML_TYPE_NUMBER, XML_SCH_CONTEXT_LINES_USED ),
104 MAP_ENTRY( PROP_StackedBarsConnected, XML_NAMESPACE_CHART, XML_CONNECT_BARS, XML_TYPE_BOOL ),
106 MAP_ENTRY_ODF12( PROP_GroupBarsPerAxis, XML_NAMESPACE_CHART, XML_GROUP_BARS_PER_AXIS, XML_TYPE_BOOL ),
107 MAP_ENTRY_ODF12( PROP_IncludeHiddenCells, XML_NAMESPACE_CHART, XML_INCLUDE_HIDDEN_CELLS, XML_TYPE_BOOL ),
108 MAP_ENTRY_ODF12( PROP_AutomaticPosition, XML_NAMESPACE_CHART, XML_AUTOMATIC_POSITION, XML_TYPE_BOOL ),
109 MAP_ENTRY_ODF12( PROP_AutomaticSize, XML_NAMESPACE_CHART, XML_AUTOMATIC_SIZE, XML_TYPE_BOOL ),
110 MAP_ENTRY_ODF12( PROP_StartingAngle, XML_NAMESPACE_CHART, XML_ANGLE_OFFSET, XML_TYPE_NUMBER ),
111 MAP_ENTRY_ODF12( PROP_MissingValueTreatment, XML_NAMESPACE_CHART, XML_TREAT_EMPTY_CELLS, XML_SCH_TYPE_MISSING_VALUE_TREATMENT ),
112 // #72304 Chart data table flags
113 MAP_ENTRY_ODF_EXT( PROP_DataTableHBorder, XML_NAMESPACE_LO_EXT, XML_DATA_TABLE_SHOW_HORZ_BORDER, XML_TYPE_BOOL ),
114 MAP_ENTRY_ODF_EXT( PROP_DataTableVBorder, XML_NAMESPACE_LO_EXT, XML_DATA_TABLE_SHOW_VERT_BORDER, XML_TYPE_BOOL ),
115 MAP_ENTRY_ODF_EXT( PROP_DataTableOutline, XML_NAMESPACE_LO_EXT, XML_DATA_TABLE_SHOW_OUTLINE, XML_TYPE_BOOL ),
116 MAP_ENTRY_ODF_EXT_IMPORT( PROP_DataTableHBorder, XML_NAMESPACE_CHART, XML_DATA_TABLE_SHOW_HORZ_BORDER, XML_TYPE_BOOL ),
117 MAP_ENTRY_ODF_EXT_IMPORT( PROP_DataTableVBorder, XML_NAMESPACE_CHART, XML_DATA_TABLE_SHOW_VERT_BORDER, XML_TYPE_BOOL ),
118 MAP_ENTRY_ODF_EXT_IMPORT( PROP_DataTableOutline, XML_NAMESPACE_CHART, XML_DATA_TABLE_SHOW_OUTLINE, XML_TYPE_BOOL ),
119 // Chart display units flags
120 MAP_ENTRY_ODF_EXT( PROP_DisplayUnits, XML_NAMESPACE_LO_EXT, XML_CHART_DUNITS_DISPLAYUNITS, XML_TYPE_BOOL ),
121 MAP_ENTRY_ODF_EXT( PROP_BuiltInUnit, XML_NAMESPACE_LO_EXT, XML_CHART_DUNITS_BUILTINUNIT, XML_TYPE_STRING ),
122 MAP_ENTRY_ODF_EXT( PROP_ExternalData, XML_NAMESPACE_LO_EXT, XML_EXTERNALDATA, XML_TYPE_STRING),
124 MAP_ENTRY_ODF_EXT( PROP_LabelBorderColor, XML_NAMESPACE_LO_EXT, XML_LABEL_STROKE_COLOR, XML_TYPE_COLOR ),
125 MAP_ENTRY_ODF_EXT( PROP_LabelBorderStyle, XML_NAMESPACE_LO_EXT, XML_LABEL_STROKE, XML_SCH_TYPE_LABEL_BORDER_STYLE ),
126 MAP_ENTRY_ODF_EXT( PROP_LabelBorderTransparency, XML_NAMESPACE_LO_EXT, XML_LABEL_STROKE_OPACITY, XML_SCH_TYPE_LABEL_BORDER_OPACITY ),
127 MAP_ENTRY_ODF_EXT( PROP_LabelBorderWidth, XML_NAMESPACE_LO_EXT, XML_LABEL_STROKE_WIDTH, XML_TYPE_MEASURE ),
129 MAP_ENTRY_ODF_EXT( PROP_LabelFillColor, XML_NAMESPACE_LO_EXT, XML_LABEL_FILL_COLOR, XML_TYPE_COLOR ),
130 MAP_ENTRY_ODF_EXT( PROP_LabelFillStyle, XML_NAMESPACE_LO_EXT, XML_LABEL_FILL, XML_SCH_TYPE_LABEL_FILL_STYLE ),
131 MAP_ENTRY_ODF_EXT( PROP_LabelFillBackground, XML_NAMESPACE_LO_EXT, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL ),
132 MAP_ENTRY_ODF_EXT( PROP_LabelFillHatchName, XML_NAMESPACE_LO_EXT, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME),
134 // Data table
135 MAP_ENTRY_ODF_EXT( PROP_HBorder, XML_NAMESPACE_LO_EXT, XML_SHOW_HORIZONTAL_BORDER, XML_TYPE_BOOL ),
136 MAP_ENTRY_ODF_EXT( PROP_VBorder, XML_NAMESPACE_LO_EXT, XML_SHOW_VERTICAL_BORDER, XML_TYPE_BOOL ),
137 MAP_ENTRY_ODF_EXT( PROP_Outline, XML_NAMESPACE_LO_EXT, XML_SHOW_OUTLINE, XML_TYPE_BOOL ),
138 MAP_ENTRY_ODF_EXT( PROP_Keys, XML_NAMESPACE_LO_EXT, XML_SHOW_KEYS, XML_TYPE_BOOL ),
140 MAP_ENTRY( PROP_ScaleText, XML_NAMESPACE_CHART, XML_SCALE_TEXT, XML_TYPE_BOOL ),
142 // spline settings
143 MAP_ENTRY( PROP_SplineOrder, XML_NAMESPACE_CHART, XML_SPLINE_ORDER, XML_TYPE_NUMBER ),
144 MAP_ENTRY( PROP_SplineResolution, XML_NAMESPACE_CHART, XML_SPLINE_RESOLUTION, XML_TYPE_NUMBER ),
146 // plot-area properties
147 MAP_ENTRY( PROP_DataRowSource, XML_NAMESPACE_CHART, XML_SERIES_SOURCE, XML_SCH_TYPE_DATAROWSOURCE ),
148 MAP_ENTRY_ODF12( PROP_SortByXValues, XML_NAMESPACE_CHART, XML_SORT_BY_X_VALUES, XML_TYPE_BOOL ),
149 MAP_ENTRY_ODF12( PROP_RightAngledAxes, XML_NAMESPACE_CHART, XML_RIGHT_ANGLED_AXES, XML_TYPE_BOOL ),
151 // axis properties
152 MAP_ENTRY( PROP_DisplayLabels, XML_NAMESPACE_CHART, XML_DISPLAY_LABEL, XML_TYPE_BOOL ),
153 MAP_SPECIAL( PROP_Marks, XML_NAMESPACE_CHART, XML_TICK_MARKS_MAJOR_INNER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER ), // convert one constant
154 MAP_SPECIAL( PROP_Marks, XML_NAMESPACE_CHART, XML_TICK_MARKS_MAJOR_OUTER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER ), // to two bools
155 MAP_SPECIAL( PROP_HelpMarks, XML_NAMESPACE_CHART, XML_TICK_MARKS_MINOR_INNER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER ), // see above
156 MAP_SPECIAL( PROP_HelpMarks, XML_NAMESPACE_CHART, XML_TICK_MARKS_MINOR_OUTER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER ),
157 MAP_CONTEXT( PROP_Logarithmic, XML_NAMESPACE_CHART, XML_LOGARITHMIC, XML_TYPE_BOOL, XML_SCH_CONTEXT_LOGARITHMIC ),
158 MAP_CONTEXT( PROP_Min, XML_NAMESPACE_CHART, XML_MINIMUM, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_MIN ),
159 MAP_CONTEXT( PROP_Max, XML_NAMESPACE_CHART, XML_MAXIMUM, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_MAX ),
160 MAP_CONTEXT( PROP_Origin, XML_NAMESPACE_CHART, XML_ORIGIN, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_ORIGIN ),
161 MAP_CONTEXT( PROP_StepMain, XML_NAMESPACE_CHART, XML_INTERVAL_MAJOR, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_STEP_MAIN ),
162 MAP_CONTEXT( PROP_StepHelpCount, XML_NAMESPACE_CHART, XML_INTERVAL_MINOR_DIVISOR, XML_TYPE_NUMBER, XML_SCH_CONTEXT_STEP_HELP_COUNT ),
163 MAP_ENTRY( PROP_GapWidth, XML_NAMESPACE_CHART, XML_GAP_WIDTH, XML_TYPE_NUMBER ),
164 MAP_ENTRY( PROP_Overlap, XML_NAMESPACE_CHART, XML_OVERLAP, XML_TYPE_NUMBER ),
165 MAP_ENTRY( PROP_TextCanOverlap, XML_NAMESPACE_CHART, XML_TEXT_OVERLAP, XML_TYPE_BOOL ),
166 MAP_ENTRY_ODF12( PROP_ReverseDirection, XML_NAMESPACE_CHART, XML_REVERSE_DIRECTION, XML_TYPE_BOOL ),
167 MAP_ENTRY( PROP_TextBreak, XML_NAMESPACE_TEXT, XML_LINE_BREAK, XML_TYPE_BOOL ),
168 MAP_ENTRY_ODF_EXT( PROP_TryStaggeringFirst, XML_NAMESPACE_LO_EXT, XML_TRY_STAGGERING_FIRST, XML_TYPE_BOOL ),
169 MAP_ENTRY( PROP_ArrangeOrder, XML_NAMESPACE_CHART, XML_LABEL_ARRANGEMENT, XML_SCH_TYPE_AXIS_ARRANGEMENT ),
170 MAP_SPECIAL( PROP_NumberFormat, XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ),
171 MAP_ENTRY( PROP_LinkNumberFormatToSource, XML_NAMESPACE_CHART, XML_LINK_DATA_STYLE_TO_SOURCE, XML_TYPE_BOOL ),
172 MAP_ENTRY( PROP_Visible, XML_NAMESPACE_CHART, XML_VISIBLE, XML_TYPE_BOOL ),
173 MAP_ENTRY_ODF_EXT( PROP_MajorOrigin, XML_NAMESPACE_LO_EXT, XML_MAJOR_ORIGIN, XML_TYPE_DOUBLE ),
175 MAP_FULL( PROP_CrossoverPosition, XML_NAMESPACE_CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFSVER_012 ),
176 MAP_FULL( PROP_CrossoverValue, XML_NAMESPACE_CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION_VALUE|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFSVER_012 ),
177 MAP_FULL( PROP_LabelPosition, XML_NAMESPACE_CHART, XML_AXIS_LABEL_POSITION, XML_SCH_TYPE_AXIS_LABEL_POSITION, 0, SvtSaveOptions::ODFSVER_012 ),
178 MAP_FULL( PROP_MarkPosition, XML_NAMESPACE_CHART, XML_TICK_MARK_POSITION, XML_SCH_TYPE_TICK_MARK_POSITION, 0, SvtSaveOptions::ODFSVER_012 ),
180 // statistical properties
182 MAP_ENTRY( PROP_MeanValue, XML_NAMESPACE_CHART, XML_MEAN_VALUE, XML_TYPE_BOOL ),
183 MAP_ENTRY( PROP_ErrorMargin, XML_NAMESPACE_CHART, XML_ERROR_MARGIN, XML_TYPE_DOUBLE ),
184 MAP_ENTRY( PROP_PositiveError, XML_NAMESPACE_CHART, XML_ERROR_LOWER_LIMIT, XML_TYPE_DOUBLE),
185 MAP_ENTRY( PROP_NegativeError, XML_NAMESPACE_CHART, XML_ERROR_UPPER_LIMIT, XML_TYPE_DOUBLE),
186 MAP_ENTRY( PROP_ShowPositiveError, XML_NAMESPACE_CHART, XML_ERROR_UPPER_INDICATOR, XML_TYPE_BOOL),
187 MAP_ENTRY( PROP_ShowNegativeError, XML_NAMESPACE_CHART, XML_ERROR_LOWER_INDICATOR, XML_TYPE_BOOL),
188 MAP_ENTRY( PROP_ErrorBarStyle, XML_NAMESPACE_CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
189 MAP_ENTRY( PROP_PercentageError, XML_NAMESPACE_CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
191 // regression curve properties
192 MAP_SPECIAL( PROP_RegressionType, XML_NAMESPACE_CHART, XML_REGRESSION_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ),
193 MAP_SPECIAL_ODF13( PROP_MovingAverageType, XML_NAMESPACE_LO_EXT, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE ),
194 MAP_SPECIAL_ODF13( PROP_MovingAverageType, XML_NAMESPACE_CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE ),
196 // ODF 1.3 OFFICE-3958
197 MAP_ENTRY_ODF13( PROP_CurveName, XML_NAMESPACE_LO_EXT, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ),
198 MAP_ENTRY_ODF13( PROP_CurveName, XML_NAMESPACE_CHART, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ),
199 MAP_ENTRY_ODF13( PROP_PolynomialDegree, XML_NAMESPACE_LO_EXT, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ),
200 MAP_ENTRY_ODF13( PROP_PolynomialDegree, XML_NAMESPACE_CHART, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ),
201 MAP_ENTRY_ODF13( PROP_ForceIntercept, XML_NAMESPACE_LO_EXT, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ),
202 MAP_ENTRY_ODF13( PROP_ForceIntercept, XML_NAMESPACE_CHART, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ),
203 MAP_ENTRY_ODF13( PROP_InterceptValue, XML_NAMESPACE_LO_EXT, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ),
204 MAP_ENTRY_ODF13( PROP_InterceptValue, XML_NAMESPACE_CHART, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ),
206 // ODF 1.3 OFFICE-3959
207 MAP_ENTRY_ODF13( PROP_MovingAveragePeriod, XML_NAMESPACE_LO_EXT, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ),
208 MAP_ENTRY_ODF13( PROP_MovingAveragePeriod, XML_NAMESPACE_CHART, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ),
210 MAP_ENTRY_ODF_EXT( PROP_ExtrapolateForward, XML_NAMESPACE_LO_EXT, XML_REGRESSION_EXTRAPOLATE_FORWARD, XML_TYPE_DOUBLE ),
211 MAP_ENTRY_ODF_EXT( PROP_ExtrapolateBackward, XML_NAMESPACE_LO_EXT, XML_REGRESSION_EXTRAPOLATE_BACKWARD, XML_TYPE_DOUBLE ),
212 MAP_ENTRY_ODF_EXT_IMPORT( PROP_ExtrapolateForward, XML_NAMESPACE_CHART, XML_REGRESSION_EXTRAPOLATE_FORWARD, XML_TYPE_DOUBLE ),
213 MAP_ENTRY_ODF_EXT_IMPORT( PROP_ExtrapolateBackward, XML_NAMESPACE_CHART, XML_REGRESSION_EXTRAPOLATE_BACKWARD, XML_TYPE_DOUBLE ),
215 MAP_ENTRY_ODF_EXT( PROP_XName, XML_NAMESPACE_LO_EXT, XML_REGRESSION_X_NAME, XML_TYPE_STRING ),
216 MAP_ENTRY_ODF_EXT( PROP_YName, XML_NAMESPACE_LO_EXT, XML_REGRESSION_Y_NAME, XML_TYPE_STRING ),
218 MAP_SPECIAL_ODF12( PROP_ErrorBarRangePositive, XML_NAMESPACE_CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE ), // export only
219 MAP_SPECIAL_ODF12( PROP_ErrorBarRangeNegative, XML_NAMESPACE_CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE ), // export only
221 // errorbars properties (chart2)
222 MAP_ENTRY_ODF_EXT( PROP_Weight, XML_NAMESPACE_LO_EXT, XML_ERROR_STANDARD_WEIGHT, XML_TYPE_DOUBLE),
223 MAP_ENTRY_ODF_EXT_IMPORT( PROP_Weight, XML_NAMESPACE_CHART, XML_ERROR_STANDARD_WEIGHT, XML_TYPE_DOUBLE),
225 // series/data-point properties
226 MAP_SPECIAL( PROP_DataCaption, XML_NAMESPACE_CHART, XML_DATA_LABEL_NUMBER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER ), // convert one constant
227 MAP_SPECIAL( PROP_DataCaption, XML_NAMESPACE_CHART, XML_DATA_LABEL_TEXT, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT ), // to 'tristate' and two bools
228 MAP_SPECIAL( PROP_DataCaption, XML_NAMESPACE_CHART, XML_DATA_LABEL_SYMBOL, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL ),
229 MAP_SPECIAL_ODF13( PROP_DataCaption, XML_NAMESPACE_CHART, XML_DATA_LABEL_SERIES, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SERIES ),
230 MAP_SPECIAL_ODF12( PROP_LabelSeparator, XML_NAMESPACE_CHART, XML_LABEL_SEPARATOR, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR ),
231 MAP_ENTRY_ODF12( PROP_LabelPlacement, XML_NAMESPACE_CHART, XML_LABEL_POSITION, XML_SCH_TYPE_LABEL_PLACEMENT_TYPE ),
232 MAP_ENTRY( PROP_SegmentOffset, XML_NAMESPACE_CHART, XML_PIE_OFFSET, XML_TYPE_NUMBER ),
233 MAP_SPECIAL_ODF12( PROP_PercentageNumberFormat, XML_NAMESPACE_STYLE, XML_PERCENTAGE_DATA_STYLE_NAME, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ),
234 MAP_ENTRY_ODF_EXT( PROP_ShowCustomLeaderLines, XML_NAMESPACE_LO_EXT, XML_CUSTOM_LEADERLINES, XML_TYPE_BOOL ),
236 // text properties for titles
237 MAP_SPECIAL( PROP_TextRotation, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION ), // convert 1/100th degrees to degrees
238 MAP_ENTRY( PROP_StackedText, XML_NAMESPACE_STYLE, XML_DIRECTION, XML_SCH_TYPE_TEXT_ORIENTATION ),
240 // for compatibility to pre 6.0beta documents
241 // MAP_SPECIAL( PROP_SymbolBitmap", CHART, XML_SYMBOL_IMAGE_NAME, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME ),
243 MAP_ENTRY( PROP_ChartUserDefinedAttributes, XML_NAMESPACE_TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM ),
245 MAP_ENTRY_END
248 // maps for enums to XML attributes
250 const SvXMLEnumMapEntry<css::chart::ChartAxisLabelPosition> aXMLChartAxisLabelPositionEnumMap[] =
252 { ::xmloff::token::XML_NEAR_AXIS, css::chart::ChartAxisLabelPosition_NEAR_AXIS },
253 { ::xmloff::token::XML_NEAR_AXIS_OTHER_SIDE, css::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE },
254 { ::xmloff::token::XML_OUTSIDE_START, css::chart::ChartAxisLabelPosition_OUTSIDE_START },
255 { ::xmloff::token::XML_OUTSIDE_END, css::chart::ChartAxisLabelPosition_OUTSIDE_END },
256 { ::xmloff::token::XML_OUTSIDE_MINIMUM, css::chart::ChartAxisLabelPosition_OUTSIDE_START },//#i114142#
257 { ::xmloff::token::XML_OUTSIDE_MAXIMUM, css::chart::ChartAxisLabelPosition_OUTSIDE_END },//#i114142#
258 { ::xmloff::token::XML_TOKEN_INVALID, css::chart::ChartAxisLabelPosition(0) }
261 const SvXMLEnumMapEntry<css::chart::ChartAxisMarkPosition> aXMLChartAxisMarkPositionEnumMap[] =
263 { ::xmloff::token::XML_AT_LABELS, css::chart::ChartAxisMarkPosition_AT_LABELS },
264 { ::xmloff::token::XML_AT_AXIS, css::chart::ChartAxisMarkPosition_AT_AXIS },
265 { ::xmloff::token::XML_AT_LABELS_AND_AXIS, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS },
266 { ::xmloff::token::XML_TOKEN_INVALID, css::chart::ChartAxisMarkPosition(0) }
269 const SvXMLEnumMapEntry<css::chart::ChartAxisArrangeOrderType> aXMLChartAxisArrangementEnumMap[] =
271 { ::xmloff::token::XML_SIDE_BY_SIDE, css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE },
272 { ::xmloff::token::XML_STAGGER_EVEN, css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN },
273 { ::xmloff::token::XML_STAGGER_ODD, css::chart::ChartAxisArrangeOrderType_STAGGER_ODD },
274 { ::xmloff::token::XML_TOKEN_INVALID, css::chart::ChartAxisArrangeOrderType(0) }
277 const SvXMLEnumMapEntry<sal_Int32> aXMLChartErrorBarStyleEnumMap[] =
279 { ::xmloff::token::XML_NONE, css::chart::ErrorBarStyle::NONE },
280 { ::xmloff::token::XML_VARIANCE, css::chart::ErrorBarStyle::VARIANCE },
281 { ::xmloff::token::XML_STANDARD_DEVIATION, css::chart::ErrorBarStyle::STANDARD_DEVIATION },
282 { ::xmloff::token::XML_CONSTANT, css::chart::ErrorBarStyle::ABSOLUTE },
283 { ::xmloff::token::XML_PERCENTAGE, css::chart::ErrorBarStyle::RELATIVE },
284 { ::xmloff::token::XML_ERROR_MARGIN, css::chart::ErrorBarStyle::ERROR_MARGIN },
285 { ::xmloff::token::XML_STANDARD_ERROR, css::chart::ErrorBarStyle::STANDARD_ERROR },
286 { ::xmloff::token::XML_CELL_RANGE, css::chart::ErrorBarStyle::FROM_DATA },
287 { ::xmloff::token::XML_TOKEN_INVALID, 0 }
290 const SvXMLEnumMapEntry<sal_Int32> aXMLChartSolidTypeEnumMap[] =
292 { ::xmloff::token::XML_CUBOID, css::chart::ChartSolidType::RECTANGULAR_SOLID },
293 { ::xmloff::token::XML_CYLINDER, css::chart::ChartSolidType::CYLINDER },
294 { ::xmloff::token::XML_CONE, css::chart::ChartSolidType::CONE },
295 { ::xmloff::token::XML_PYRAMID, css::chart::ChartSolidType::PYRAMID },
296 { ::xmloff::token::XML_TOKEN_INVALID, 0 }
299 const SvXMLEnumMapEntry<css::chart::ChartDataRowSource> aXMLChartDataRowSourceTypeEnumMap[] =
301 { ::xmloff::token::XML_COLUMNS, css::chart::ChartDataRowSource_COLUMNS },
302 { ::xmloff::token::XML_ROWS, css::chart::ChartDataRowSource_ROWS },
303 { ::xmloff::token::XML_TOKEN_INVALID, css::chart::ChartDataRowSource(0) }
306 const SvXMLEnumMapEntry<sal_Int32> g_XMLChartInterpolationTypeEnumMap_ODF12[] =
308 // this is neither an enum nor a constants group, but just a
309 // documented long property
310 { ::xmloff::token::XML_NONE, 0 },
311 { ::xmloff::token::XML_CUBIC_SPLINE, 1 },
312 { ::xmloff::token::XML_B_SPLINE, 2 },
313 { ::xmloff::token::XML_TOKEN_INVALID, 0 }
316 const SvXMLEnumMapEntry<sal_Int32> g_XMLChartInterpolationTypeEnumMap[] =
318 // this is neither an enum nor a constants group, but just a
319 // documented long property
320 { ::xmloff::token::XML_NONE, 0 },
321 { ::xmloff::token::XML_CUBIC_SPLINE, 1 },
322 { ::xmloff::token::XML_B_SPLINE, 2 },
323 { ::xmloff::token::XML_STEP_START, 3 },
324 { ::xmloff::token::XML_STEP_END, 4 },
325 { ::xmloff::token::XML_STEP_CENTER_X, 5 },
326 { ::xmloff::token::XML_STEP_CENTER_Y, 6 },
327 // the GNM values should only be used for reading Gnumeric ods files
328 // they should never be used for writing ods file
329 { ::xmloff::token::XML_GNM_STEP_START, 3 },
330 { ::xmloff::token::XML_GNM_STEP_END, 4 },
331 { ::xmloff::token::XML_GNM_STEP_CENTER_X, 5 },
332 { ::xmloff::token::XML_GNM_STEP_CENTER_Y, 6 },
333 { ::xmloff::token::XML_TOKEN_INVALID, 0 }
336 const SvXMLEnumMapEntry<sal_Int32> aXMLChartDataLabelPlacementEnumMap[] =
338 { ::xmloff::token::XML_AVOID_OVERLAP, css::chart::DataLabelPlacement::AVOID_OVERLAP },
339 { ::xmloff::token::XML_CENTER, css::chart::DataLabelPlacement::CENTER },
340 { ::xmloff::token::XML_TOP, css::chart::DataLabelPlacement::TOP },
341 { ::xmloff::token::XML_TOP_LEFT, css::chart::DataLabelPlacement::TOP_LEFT },
342 { ::xmloff::token::XML_LEFT, css::chart::DataLabelPlacement::LEFT },
343 { ::xmloff::token::XML_BOTTOM_LEFT, css::chart::DataLabelPlacement::BOTTOM_LEFT },
344 { ::xmloff::token::XML_BOTTOM, css::chart::DataLabelPlacement::BOTTOM },
345 { ::xmloff::token::XML_BOTTOM_RIGHT, css::chart::DataLabelPlacement::BOTTOM_RIGHT },
346 { ::xmloff::token::XML_RIGHT, css::chart::DataLabelPlacement::RIGHT },
347 { ::xmloff::token::XML_TOP_RIGHT, css::chart::DataLabelPlacement::TOP_RIGHT },
348 { ::xmloff::token::XML_INSIDE, css::chart::DataLabelPlacement::INSIDE },
349 { ::xmloff::token::XML_OUTSIDE, css::chart::DataLabelPlacement::OUTSIDE },
350 { ::xmloff::token::XML_NEAR_ORIGIN, css::chart::DataLabelPlacement::NEAR_ORIGIN },
351 { ::xmloff::token::XML_TOKEN_INVALID, 0 }
354 const SvXMLEnumMapEntry<sal_Int32> aXMLChartMissingValueTreatmentEnumMap[] =
356 { ::xmloff::token::XML_LEAVE_GAP, css::chart::MissingValueTreatment::LEAVE_GAP },
357 { ::xmloff::token::XML_USE_ZERO, css::chart::MissingValueTreatment::USE_ZERO },
358 { ::xmloff::token::XML_IGNORE, css::chart::MissingValueTreatment::CONTINUE },
359 { ::xmloff::token::XML_TOKEN_INVALID,0 },
362 namespace {
364 SvXMLEnumMapEntry<drawing::LineStyle> const aLineStyleMap[] =
366 { XML_NONE, drawing::LineStyle_NONE },
367 { XML_SOLID, drawing::LineStyle_SOLID },
368 { XML_DASH, drawing::LineStyle_DASH },
369 { XML_TOKEN_INVALID, drawing::LineStyle(0) }
372 SvXMLEnumMapEntry<drawing::FillStyle> const aFillStyleMap[] =
374 { XML_NONE, drawing::FillStyle_NONE },
375 { XML_SOLID, drawing::FillStyle_SOLID },
376 { XML_HATCH, drawing::FillStyle_HATCH }
381 // the following class implementations are in this file:
383 // * XMLChartPropHdlFactory
384 // * XMLChartPropertySetMapper
385 // * XMLChartExportPropertyMapper
386 // * XMLChartImportPropertyMapper
387 // * SchXMLStyleExport
389 XMLChartPropHdlFactory::XMLChartPropHdlFactory(SvXMLExport const*const pExport)
390 : m_pExport(pExport)
394 XMLChartPropHdlFactory::~XMLChartPropHdlFactory()
398 const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const
400 const XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
401 if( ! pHdl )
403 switch( nType )
405 case XML_SCH_TYPE_AXIS_POSITION:
406 pHdl = new XMLAxisPositionPropertyHdl( false );
407 break;
408 case XML_SCH_TYPE_AXIS_POSITION_VALUE:
409 pHdl = new XMLAxisPositionPropertyHdl( true );
410 break;
412 case XML_SCH_TYPE_AXIS_LABEL_POSITION:
413 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisLabelPositionEnumMap);
414 break;
416 case XML_SCH_TYPE_TICK_MARK_POSITION:
417 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisMarkPositionEnumMap);
418 break;
420 case XML_SCH_TYPE_AXIS_ARRANGEMENT:
421 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisArrangementEnumMap);
422 break;
424 case XML_SCH_TYPE_ERROR_BAR_STYLE:
425 // here we have a constant rather than an enum
426 pHdl = new XMLErrorBarStylePropertyHdl( aXMLChartErrorBarStyleEnumMap );
427 break;
429 case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
430 pHdl = new XMLErrorIndicatorPropertyHdl( false );
431 break;
432 case XML_SCH_TYPE_ERROR_INDICATOR_UPPER:
433 pHdl = new XMLErrorIndicatorPropertyHdl( true );
434 break;
436 case XML_SCH_TYPE_SOLID_TYPE:
437 // here we have a constant rather than an enum
438 pHdl = new XMLEnumPropertyHdl( aXMLChartSolidTypeEnumMap );
439 break;
440 case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE:
441 // here we have a constant rather than an enum
442 pHdl = new XMLEnumPropertyHdl( aXMLChartDataLabelPlacementEnumMap );
443 break;
444 case XML_SCH_TYPE_DATAROWSOURCE:
445 pHdl = new XMLEnumPropertyHdl( aXMLChartDataRowSourceTypeEnumMap);
446 break;
447 case XML_SCH_TYPE_TEXT_ORIENTATION:
448 pHdl = new XMLTextOrientationHdl;
449 break;
451 case XML_SCH_TYPE_INTERPOLATION:
452 if (m_pExport && m_pExport->getSaneDefaultVersion() < SvtSaveOptions::ODFSVER_013)
454 pHdl = new XMLEnumPropertyHdl(g_XMLChartInterpolationTypeEnumMap_ODF12);
456 else // ODF 1.3 OFFICE-3662
458 pHdl = new XMLEnumPropertyHdl(g_XMLChartInterpolationTypeEnumMap);
460 break;
461 case XML_SCH_TYPE_SYMBOL_TYPE:
462 pHdl = new XMLSymbolTypePropertyHdl( false );
463 break;
465 case XML_SCH_TYPE_NAMED_SYMBOL:
466 pHdl = new XMLSymbolTypePropertyHdl( true );
467 break;
469 case XML_SCH_TYPE_MISSING_VALUE_TREATMENT:
470 pHdl = new XMLEnumPropertyHdl( aXMLChartMissingValueTreatmentEnumMap );
471 break;
472 case XML_SCH_TYPE_LABEL_BORDER_STYLE:
473 pHdl = new XMLEnumPropertyHdl( aLineStyleMap );
474 break;
475 case XML_SCH_TYPE_LABEL_BORDER_OPACITY:
476 pHdl = new XMLOpacityPropertyHdl(nullptr);
477 break;
478 case XML_SCH_TYPE_LABEL_FILL_STYLE:
479 pHdl = new XMLEnumPropertyHdl( aFillStyleMap );
480 break;
481 default:
484 if( pHdl )
485 PutHdlCache( nType, pHdl );
488 return pHdl;
491 XMLChartPropertySetMapper::XMLChartPropertySetMapper(SvXMLExport const*const pExport)
492 : XMLPropertySetMapper(aXMLChartPropMap, new XMLChartPropHdlFactory(pExport), pExport != nullptr)
496 XMLChartPropertySetMapper::~XMLChartPropertySetMapper()
500 XMLChartExportPropertyMapper::XMLChartExportPropertyMapper( const rtl::Reference< XMLPropertySetMapper >& rMapper,
501 SvXMLExport& rExport) :
502 SvXMLExportPropertyMapper( rMapper ),
503 mrExport( rExport )
505 // chain draw properties
506 ChainExportMapper( XMLShapeExport::CreateShapePropMapper( rExport ));
508 // chain text properties
509 ChainExportMapper( XMLTextParagraphExport::CreateParaExtPropMapper( rExport ));
512 XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper()
516 void XMLChartExportPropertyMapper::ContextFilter(
517 bool bEnableFoFontFamily,
518 std::vector< XMLPropertyState >& rProperties,
519 const uno::Reference< beans::XPropertySet >& rPropSet ) const
521 OUString aAutoPropName;
522 bool bCheckAuto = false;
524 // filter properties
525 for( auto& rProperty : rProperties )
527 // find properties with context
528 // to prevent writing this property set mnIndex member to -1
529 switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
531 // if Auto... is set the corresponding properties mustn't be exported
532 case XML_SCH_CONTEXT_MIN:
533 bCheckAuto = true;
534 aAutoPropName = "AutoMin";
535 break;
536 case XML_SCH_CONTEXT_MAX:
537 bCheckAuto = true;
538 aAutoPropName = "AutoMax";
539 break;
540 case XML_SCH_CONTEXT_STEP_MAIN:
541 bCheckAuto = true;
542 aAutoPropName = "AutoStepMain";
543 break;
544 case XML_SCH_CONTEXT_STEP_HELP_COUNT:
545 bCheckAuto = true;
546 aAutoPropName = "AutoStepHelp";
547 break;
549 case XML_SCH_CONTEXT_ORIGIN:
550 bCheckAuto = true;
551 aAutoPropName = "AutoOrigin";
552 break;
554 // the following property is deprecated
555 // element-item symbol-image is used now
556 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
557 rProperty.mnIndex = -1;
558 break;
560 case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
561 case XML_SCH_CONTEXT_LINES_USED:
562 // note this avoids export of the properties in OASIS format,
563 // but also for the OOo XML Flat format (used by binfilter),
564 // because there, the transformation to OOo is done after the
565 // complete export of the chart in OASIS format.
566 if( mrExport.getExportFlags() & SvXMLExportFlags::OASIS )
567 rProperty.mnIndex = -1;
568 break;
571 if( bCheckAuto )
573 if( rPropSet.is())
577 bool bAuto = false;
578 uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
579 aAny >>= bAuto;
580 if( bAuto )
581 rProperty.mnIndex = -1;
583 catch(const beans::UnknownPropertyException&)
587 bCheckAuto = false;
591 SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet);
594 void XMLChartExportPropertyMapper::handleElementItem(
595 SvXMLExport& rExport,
596 const XMLPropertyState& rProperty, SvXmlExportFlags nFlags,
597 const ::std::vector< XMLPropertyState > *pProperties,
598 sal_uInt32 nIdx ) const
600 switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
602 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
604 uno::Reference<graphic::XGraphic> xGraphic;
605 rProperty.maValue >>= xGraphic;
607 OUString sInternalURL;
608 // export as XLink reference into the package
609 // if embedding is off
610 if (xGraphic.is())
612 OUString aOutMimeType;
613 sInternalURL = mrExport.AddEmbeddedXGraphic(xGraphic, aOutMimeType);
615 if (!sInternalURL.isEmpty())
617 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sInternalURL);
621 sal_uInt32 nPropIndex = rProperty.mnIndex;
622 // this is the element that has to live until the next statement
623 SvXMLElementExport aElem( mrExport,
624 getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
625 getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
626 true, true );
628 // export as Base64 embedded graphic
629 // if embedding is on
630 if (xGraphic.is())
631 mrExport.AddEmbeddedXGraphicAsBase64(xGraphic);
634 break;
636 case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
638 OUString aSeparator;
639 rProperty.maValue >>= aSeparator;
641 if( !aSeparator.isEmpty() )
643 sal_uInt32 nPropIndex = rProperty.mnIndex;
644 SvXMLElementExport aElem( mrExport,
645 getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
646 getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
647 true, true );
649 SchXMLTools::exportText( mrExport, aSeparator, true );
652 break;
654 default:
655 // call parent
656 SvXMLExportPropertyMapper::handleElementItem( rExport, rProperty,
657 nFlags, pProperties, nIdx );
658 break;
662 namespace {
664 OUString convertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
666 OUString aResult = rRange;
667 if( !xDoc.is() )
668 return aResult;
669 uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
670 xDoc->getDataProvider(), uno::UNO_QUERY );
673 if( xConversion.is())
674 aResult = xConversion->convertRangeToXML( rRange );
676 catch (css::lang::IllegalArgumentException&)
680 return aResult;
685 void XMLChartExportPropertyMapper::handleSpecialItem(
686 comphelper::AttributeList& rAttrList, const XMLPropertyState& rProperty,
687 const SvXMLUnitConverter& rUnitConverter,
688 const SvXMLNamespaceMap& rNamespaceMap,
689 const ::std::vector< XMLPropertyState > *pProperties,
690 sal_uInt32 nIdx ) const
692 bool bHandled = false;
694 sal_Int32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
696 if( nContextId )
698 bHandled = true;
700 OUString sAttrName = getPropertySetMapper()->GetEntryXMLName( rProperty.mnIndex );
701 sal_uInt16 nNameSpace = getPropertySetMapper()->GetEntryNameSpace( rProperty.mnIndex );
702 OUStringBuffer sValueBuffer;
704 sal_Int32 nValue = 0;
705 bool bValue = false;
707 switch( nContextId )
709 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
710 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
711 rProperty.maValue >>= nValue;
712 bValue = (( nValue & chart::ChartAxisMarks::INNER ) == chart::ChartAxisMarks::INNER );
713 ::sax::Converter::convertBool( sValueBuffer, bValue );
714 break;
715 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
716 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
717 rProperty.maValue >>= nValue;
718 bValue = (( nValue & chart::ChartAxisMarks::OUTER ) == chart::ChartAxisMarks::OUTER );
719 ::sax::Converter::convertBool( sValueBuffer, bValue );
720 break;
721 case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
723 // convert from 100th degrees to degrees (double)
724 rProperty.maValue >>= nValue;
725 double fVal = static_cast<double>(nValue) / 100.0;
726 ::sax::Converter::convertDouble( sValueBuffer, fVal );
728 break;
729 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
731 rProperty.maValue >>= nValue;
732 if( ( nValue & chart::ChartDataCaption::VALUE ) == chart::ChartDataCaption::VALUE )
734 if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
736 const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(
737 mrExport.getSaneDefaultVersion());
738 if (nCurrentVersion < SvtSaveOptions::ODFSVER_012)
739 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
740 else
741 sValueBuffer.append( GetXMLToken( XML_VALUE_AND_PERCENTAGE ));
743 else
744 sValueBuffer.append( GetXMLToken( XML_VALUE ));
746 else if(( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
747 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
748 else
749 sValueBuffer.append( GetXMLToken( XML_NONE ));
751 break;
752 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
753 rProperty.maValue >>= nValue;
754 bValue = (( nValue & chart::ChartDataCaption::TEXT ) == chart::ChartDataCaption::TEXT );
755 ::sax::Converter::convertBool( sValueBuffer, bValue );
756 break;
757 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
758 rProperty.maValue >>= nValue;
759 bValue = (( nValue & chart::ChartDataCaption::SYMBOL ) == chart::ChartDataCaption::SYMBOL );
760 ::sax::Converter::convertBool( sValueBuffer, bValue );
761 break;
762 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SERIES:
763 rProperty.maValue >>= nValue;
764 bValue = (( nValue & chart::ChartDataCaption::DATA_SERIES ) == chart::ChartDataCaption::DATA_SERIES );
765 ::sax::Converter::convertBool( sValueBuffer, bValue );
766 break;
767 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
768 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
770 awt::Size aSize;
771 rProperty.maValue >>= aSize;
772 rUnitConverter.convertMeasureToXML( sValueBuffer,
773 nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
774 ? aSize.Width
775 : aSize.Height );
777 break;
779 case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT:
781 // just for import
782 break;
785 case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE:
787 OUString aRangeStr;
788 rProperty.maValue >>= aRangeStr;
789 sValueBuffer.append(convertRange(aRangeStr, mxChartDoc));
791 break;
792 case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
794 const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(
795 mrExport.getSaneDefaultVersion());
797 OUString aServiceName;
798 rProperty.maValue >>= aServiceName;
799 if (aServiceName == "com.sun.star.chart2.LinearRegressionCurve")
800 sValueBuffer.append( GetXMLToken( XML_LINEAR ));
801 else if (aServiceName == "com.sun.star.chart2.LogarithmicRegressionCurve")
802 sValueBuffer.append( GetXMLToken( XML_LOGARITHMIC ));
803 else if (aServiceName == "com.sun.star.chart2.ExponentialRegressionCurve")
804 sValueBuffer.append( GetXMLToken( XML_EXPONENTIAL ));
805 else if (aServiceName == "com.sun.star.chart2.PotentialRegressionCurve")
806 sValueBuffer.append( GetXMLToken( XML_POWER ));
807 else if (nCurrentVersion >= SvtSaveOptions::ODFSVER_013 && aServiceName == "com.sun.star.chart2.PolynomialRegressionCurve")
808 { // ODF 1.3 OFFICE-3958
809 sValueBuffer.append( GetXMLToken( XML_POLYNOMIAL ));
811 else if (nCurrentVersion >= SvtSaveOptions::ODFSVER_013 && aServiceName == "com.sun.star.chart2.MovingAverageRegressionCurve")
812 { // ODF 1.3 OFFICE-3959
813 sValueBuffer.append( GetXMLToken( XML_MOVING_AVERAGE ));
816 break;
818 case XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE:
820 rProperty.maValue >>= nValue;
821 if (nValue == MovingAverageType::Prior)
822 sValueBuffer.append( GetXMLToken( XML_PRIOR ));
823 else if (nValue == MovingAverageType::Central)
824 sValueBuffer.append( GetXMLToken( XML_CENTRAL ));
825 else if (nValue == MovingAverageType::AveragedAbscissa)
826 sValueBuffer.append( GetXMLToken( XML_AVERAGED_ABSCISSA ));
827 else // default
828 sValueBuffer.append( GetXMLToken( XML_PRIOR ));
830 break;
832 default:
833 bHandled = false;
834 break;
837 if( !sValueBuffer.isEmpty())
839 OUString sValue = sValueBuffer.makeStringAndClear();
840 sAttrName = rNamespaceMap.GetQNameByKey( nNameSpace, sAttrName );
841 rAttrList.AddAttribute( sAttrName, sValue );
845 if( !bHandled )
847 // call parent
848 SvXMLExportPropertyMapper::handleSpecialItem( rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
852 void XMLChartExportPropertyMapper::setChartDoc( const uno::Reference< chart2::XChartDocument >& xChartDoc )
854 mxChartDoc = xChartDoc;
857 XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const rtl::Reference< XMLPropertySetMapper >& rMapper,
858 const SvXMLImport& _rImport ) :
859 SvXMLImportPropertyMapper( rMapper, const_cast< SvXMLImport & >( _rImport )),
860 mrImport( const_cast< SvXMLImport & > ( _rImport ))
862 // chain shape mapper for drawing properties
864 // give an empty model. It is only used for numbering rules that don't exist in chart
865 uno::Reference< frame::XModel > xEmptyModel;
866 ChainImportMapper( XMLShapeImportHelper::CreateShapePropMapper( xEmptyModel, mrImport ));
868 //#i14365# save and load writing-mode for chart elements
869 //The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
870 //We remove that property here only for chart thus the chart can use the correct mapping from the writer paragraph settings (attribute 'writing-mode' <-> property 'WritingMode')
871 sal_Int32 nUnwantedWrongEntry = maPropMapper->FindEntryIndex( "TextWritingMode", XML_NAMESPACE_STYLE, GetXMLToken(XML_WRITING_MODE) );
872 maPropMapper->RemoveEntry(nUnwantedWrongEntry);
874 // do not chain text properties: on import this is done by shape mapper
875 // to import old documents
878 XMLChartImportPropertyMapper::~XMLChartImportPropertyMapper()
882 bool XMLChartImportPropertyMapper::handleSpecialItem(
883 XMLPropertyState& rProperty,
884 ::std::vector< XMLPropertyState >& rProperties,
885 const OUString& rValue,
886 const SvXMLUnitConverter& rUnitConverter,
887 const SvXMLNamespaceMap& rNamespaceMap ) const
889 sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
890 bool bRet = (nContextId != 0);
892 if( nContextId )
894 sal_Int32 nValue = 0;
895 bool bValue = false;
897 switch( nContextId )
899 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
900 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
901 (void)::sax::Converter::convertBool( bValue, rValue );
902 // modify old value
903 rProperty.maValue >>= nValue;
904 if( bValue )
905 SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::INNER );
906 else
907 SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::INNER );
908 rProperty.maValue <<= nValue;
909 break;
910 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
911 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
912 (void)::sax::Converter::convertBool( bValue, rValue );
913 // modify old value
914 rProperty.maValue >>= nValue;
915 if( bValue )
916 SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::OUTER );
917 else
918 SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::OUTER );
919 rProperty.maValue <<= nValue;
920 break;
921 case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
923 // convert from degrees (double) to 100th degrees (integer)
924 double fVal;
925 ::sax::Converter::convertDouble( fVal, rValue );
926 nValue = static_cast<sal_Int32>( fVal * 100.0 );
927 rProperty.maValue <<= nValue;
929 break;
930 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
932 // modify old value
933 rProperty.maValue >>= nValue;
934 if( IsXMLToken( rValue, XML_NONE ))
935 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
936 else if( IsXMLToken( rValue, XML_VALUE_AND_PERCENTAGE ) )
937 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
938 else if( IsXMLToken( rValue, XML_VALUE ) )
939 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE );
940 else // must be XML_PERCENTAGE
941 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::PERCENT );
942 rProperty.maValue <<= nValue;
944 break;
945 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
946 rProperty.maValue >>= nValue;
947 (void)::sax::Converter::convertBool( bValue, rValue );
948 if( bValue )
949 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::TEXT );
950 else
951 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::TEXT );
952 rProperty.maValue <<= nValue;
953 break;
954 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
955 rProperty.maValue >>= nValue;
956 (void)::sax::Converter::convertBool( bValue, rValue );
957 if( bValue )
958 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
959 else
960 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
961 rProperty.maValue <<= nValue;
962 break;
963 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SERIES:
964 rProperty.maValue >>= nValue;
965 (void)::sax::Converter::convertBool( bValue, rValue );
966 if( bValue )
967 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::DATA_SERIES );
968 else
969 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::DATA_SERIES );
970 rProperty.maValue <<= nValue;
971 break;
972 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
973 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
975 awt::Size aSize;
976 rProperty.maValue >>= aSize;
977 rUnitConverter.convertMeasureToCore(
978 (nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH)
979 ? aSize.Width
980 : aSize.Height,
981 rValue );
982 rProperty.maValue <<= aSize;
984 break;
986 case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE:
988 rProperty.maValue <<= rValue;
990 break;
992 // deprecated from 6.0 beta on
993 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
994 rProperty.maValue <<= mrImport.loadGraphicByURL(rValue);
995 break;
997 case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
999 if (IsXMLToken( rValue, XML_LINEAR ))
1000 rProperty.maValue <<= OUString("com.sun.star.chart2.LinearRegressionCurve");
1001 else if (IsXMLToken( rValue, XML_LOGARITHMIC))
1002 rProperty.maValue <<= OUString("com.sun.star.chart2.LogarithmicRegressionCurve");
1003 else if (IsXMLToken( rValue, XML_EXPONENTIAL))
1004 rProperty.maValue <<= OUString("com.sun.star.chart2.ExponentialRegressionCurve");
1005 else if (IsXMLToken( rValue, XML_POWER))
1006 rProperty.maValue <<= OUString("com.sun.star.chart2.PotentialRegressionCurve");
1007 else if (IsXMLToken( rValue, XML_POLYNOMIAL))
1008 rProperty.maValue <<= OUString("com.sun.star.chart2.PolynomialRegressionCurve");
1009 else if (IsXMLToken( rValue, XML_MOVING_AVERAGE))
1010 rProperty.maValue <<= OUString("com.sun.star.chart2.MovingAverageRegressionCurve");
1012 break;
1014 case XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE:
1016 if (IsXMLToken( rValue, XML_PRIOR ))
1017 rProperty.maValue <<= MovingAverageType::Prior;
1018 else if (IsXMLToken( rValue, XML_CENTRAL))
1019 rProperty.maValue <<= MovingAverageType::Central;
1020 else if (IsXMLToken( rValue, XML_AVERAGED_ABSCISSA))
1021 rProperty.maValue <<= MovingAverageType::AveragedAbscissa;
1022 else // default
1023 rProperty.maValue <<= MovingAverageType::Prior;
1025 break;
1027 default:
1028 bRet = false;
1029 break;
1033 // if we didn't handle it, the parent should
1034 if( !bRet )
1036 // call parent
1037 bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap );
1040 return bRet;
1043 void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
1047 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */