/src/libreoffice/chart2/source/controller/itemsetwrapper/AxisItemConverter.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 <AxisItemConverter.hxx> |
21 | | #include <ItemPropertyMap.hxx> |
22 | | #include <CharacterPropertyItemConverter.hxx> |
23 | | #include <GraphicPropertyItemConverter.hxx> |
24 | | #include <chartview/ChartSfxItemIds.hxx> |
25 | | #include <chartview/ExplicitScaleValues.hxx> |
26 | | #include "SchWhichPairs.hxx" |
27 | | #include <ChartModel.hxx> |
28 | | #include <Axis.hxx> |
29 | | #include <AxisHelper.hxx> |
30 | | #include <CommonConverters.hxx> |
31 | | #include <ChartType.hxx> |
32 | | #include <Diagram.hxx> |
33 | | #include <unonames.hxx> |
34 | | #include <BaseCoordinateSystem.hxx> |
35 | | #include <ChartView.hxx> |
36 | | #include <memory> |
37 | | |
38 | | #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> |
39 | | #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> |
40 | | #include <com/sun/star/chart/ChartAxisPosition.hpp> |
41 | | #include <com/sun/star/chart/TimeInterval.hpp> |
42 | | #include <com/sun/star/chart2/AxisOrientation.hpp> |
43 | | #include <com/sun/star/chart2/AxisType.hpp> |
44 | | |
45 | | #include <osl/diagnose.h> |
46 | | #include <o3tl/any.hxx> |
47 | | #include <svl/eitem.hxx> |
48 | | #include <svx/chrtitem.hxx> |
49 | | #include <svx/sdangitm.hxx> |
50 | | #include <svl/intitem.hxx> |
51 | | #include <rtl/math.hxx> |
52 | | |
53 | | using namespace ::com::sun::star; |
54 | | using namespace ::com::sun::star::chart2; |
55 | | using ::com::sun::star::uno::Reference; |
56 | | using ::com::sun::star::chart::TimeInterval; |
57 | | using ::com::sun::star::chart::TimeIncrement; |
58 | | |
59 | | namespace chart::wrapper { |
60 | | |
61 | | namespace { |
62 | | |
63 | | ItemPropertyMapType & lcl_GetAxisPropertyMap() |
64 | 0 | { |
65 | 0 | static ItemPropertyMapType aAxisPropertyMap{ |
66 | 0 | {SCHATTR_AXIS_SHOWDESCR, {"DisplayLabels", 0}}, |
67 | 0 | {SCHATTR_AXIS_TICKS, {"MajorTickmarks", 0}}, |
68 | 0 | {SCHATTR_AXIS_HELPTICKS, {"MinorTickmarks", 0}}, |
69 | 0 | {SCHATTR_AXIS_LABEL_ORDER, {"ArrangeOrder", 0}}, |
70 | 0 | {SCHATTR_TEXT_STACKED, {"StackCharacters", 0}}, |
71 | 0 | {SCHATTR_AXIS_LABEL_BREAK, {"TextBreak", 0}}, |
72 | 0 | {SCHATTR_AXIS_LABEL_OVERLAP, {"TextOverlap", 0}}}; |
73 | 0 | return aAxisPropertyMap; |
74 | 0 | }; |
75 | | |
76 | | } // anonymous namespace |
77 | | |
78 | | AxisItemConverter::AxisItemConverter( |
79 | | const Reference< beans::XPropertySet > & rPropertySet, |
80 | | SfxItemPool& rItemPool, |
81 | | SdrModel& rDrawModel, |
82 | | const rtl::Reference<::chart::ChartModel> & xChartDoc, |
83 | | ::chart::ExplicitScaleData const * pScale /* = NULL */, |
84 | | ::chart::ExplicitIncrementData const * pIncrement /* = NULL */, |
85 | | const std::optional<awt::Size>& pRefSize ) : |
86 | 0 | ItemConverter( rPropertySet, rItemPool ), |
87 | 0 | m_xChartDoc( xChartDoc ) |
88 | 0 | { |
89 | 0 | if( pScale ) |
90 | 0 | m_pExplicitScale.reset( new ::chart::ExplicitScaleData( *pScale ) ); |
91 | 0 | if( pIncrement ) |
92 | 0 | m_pExplicitIncrement.reset( new ::chart::ExplicitIncrementData( *pIncrement ) ); |
93 | |
|
94 | 0 | m_aConverters.emplace_back( new GraphicPropertyItemConverter( |
95 | 0 | rPropertySet, rItemPool, rDrawModel, |
96 | 0 | xChartDoc, |
97 | 0 | GraphicObjectType::LineProperties )); |
98 | 0 | m_aConverters.emplace_back( |
99 | 0 | new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); |
100 | |
|
101 | 0 | m_xAxis = dynamic_cast<::chart::Axis*>(rPropertySet.get()); |
102 | 0 | assert(m_xAxis); |
103 | 0 | } |
104 | | |
105 | | AxisItemConverter::~AxisItemConverter() |
106 | 0 | { |
107 | 0 | } |
108 | | |
109 | | void AxisItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const |
110 | 0 | { |
111 | 0 | for( const auto& pConv : m_aConverters ) |
112 | 0 | pConv->FillItemSet( rOutItemSet ); |
113 | | |
114 | | // own items |
115 | 0 | ItemConverter::FillItemSet( rOutItemSet ); |
116 | 0 | } |
117 | | |
118 | | bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) |
119 | 0 | { |
120 | 0 | bool bResult = false; |
121 | |
|
122 | 0 | for( const auto& pConv : m_aConverters ) |
123 | 0 | bResult = pConv->ApplyItemSet( rItemSet ) || bResult; |
124 | | |
125 | | // own items |
126 | 0 | return ItemConverter::ApplyItemSet( rItemSet ) || bResult; |
127 | 0 | } |
128 | | |
129 | | const WhichRangesContainer& AxisItemConverter::GetWhichPairs() const |
130 | 0 | { |
131 | | // must span all used items! |
132 | 0 | return nAxisWhichPairs; |
133 | 0 | } |
134 | | |
135 | | bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const |
136 | 0 | { |
137 | 0 | ItemPropertyMapType & rMap( lcl_GetAxisPropertyMap()); |
138 | 0 | ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); |
139 | |
|
140 | 0 | if( aIt == rMap.end()) |
141 | 0 | return false; |
142 | | |
143 | 0 | rOutProperty =(*aIt).second; |
144 | |
|
145 | 0 | return true; |
146 | 0 | } |
147 | | |
148 | | static bool lcl_hasTimeIntervalValue( const uno::Any& rAny ) |
149 | 0 | { |
150 | 0 | bool bRet = false; |
151 | 0 | TimeInterval aValue; |
152 | 0 | if( rAny >>= aValue ) |
153 | 0 | bRet = true; |
154 | 0 | return bRet; |
155 | 0 | } |
156 | | |
157 | | void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const |
158 | 0 | { |
159 | 0 | if( !m_xAxis.is() ) |
160 | 0 | return; |
161 | | |
162 | 0 | const chart2::ScaleData aScale( m_xAxis->getScaleData() ); |
163 | 0 | const chart2::IncrementData& rIncrement( aScale.IncrementData ); |
164 | 0 | const uno::Sequence< chart2::SubIncrement >& rSubIncrements( aScale.IncrementData.SubIncrements ); |
165 | 0 | const TimeIncrement& rTimeIncrement( aScale.TimeIncrement ); |
166 | 0 | bool bDateAxis = (aScale.AxisType == chart2::AxisType::DATE); |
167 | 0 | if( m_pExplicitScale ) |
168 | 0 | bDateAxis = (m_pExplicitScale->AxisType == chart2::AxisType::DATE); |
169 | |
|
170 | 0 | switch( nWhichId ) |
171 | 0 | { |
172 | 0 | case SCHATTR_AXIS_AUTO_MAX: |
173 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); |
174 | 0 | break; |
175 | | |
176 | 0 | case SCHATTR_AXIS_MAX: |
177 | 0 | { |
178 | 0 | double fMax = 10.0; |
179 | 0 | if( aScale.Maximum >>= fMax ) |
180 | 0 | rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); |
181 | 0 | else |
182 | 0 | { |
183 | 0 | if( m_pExplicitScale ) |
184 | 0 | fMax = m_pExplicitScale->Maximum; |
185 | 0 | rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); |
186 | 0 | } |
187 | 0 | } |
188 | 0 | break; |
189 | | |
190 | 0 | case SCHATTR_AXIS_AUTO_MIN: |
191 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); |
192 | 0 | break; |
193 | | |
194 | 0 | case SCHATTR_AXIS_MIN: |
195 | 0 | { |
196 | 0 | double fMin = 0.0; |
197 | 0 | if( aScale.Minimum >>= fMin ) |
198 | 0 | rOutItemSet.Put( SvxDoubleItem( fMin, SCHATTR_AXIS_MIN ) ); |
199 | 0 | else if( m_pExplicitScale ) |
200 | 0 | rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, SCHATTR_AXIS_MIN )); |
201 | 0 | } |
202 | 0 | break; |
203 | | |
204 | 0 | case SCHATTR_AXIS_LOGARITHM: |
205 | 0 | { |
206 | 0 | bool bValue = AxisHelper::isLogarithmic( aScale.Scaling ); |
207 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); |
208 | 0 | } |
209 | 0 | break; |
210 | | |
211 | 0 | case SCHATTR_AXIS_REVERSE: |
212 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, (aScale.Orientation == AxisOrientation_REVERSE) )); |
213 | 0 | break; |
214 | | |
215 | | // Increment |
216 | 0 | case SCHATTR_AXIS_AUTO_STEP_MAIN: |
217 | 0 | if( bDateAxis ) |
218 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) ); |
219 | 0 | else |
220 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) ); |
221 | 0 | break; |
222 | | |
223 | 0 | case SCHATTR_AXIS_MAIN_TIME_UNIT: |
224 | 0 | { |
225 | 0 | TimeInterval aTimeInterval; |
226 | 0 | if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) |
227 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); |
228 | 0 | else if( m_pExplicitIncrement ) |
229 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) ); |
230 | 0 | } |
231 | 0 | break; |
232 | | |
233 | 0 | case SCHATTR_AXIS_STEP_MAIN: |
234 | 0 | if( bDateAxis ) |
235 | 0 | { |
236 | 0 | TimeInterval aTimeInterval; |
237 | 0 | if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) |
238 | 0 | rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); |
239 | 0 | else if( m_pExplicitIncrement ) |
240 | 0 | rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); |
241 | 0 | } |
242 | 0 | else |
243 | 0 | { |
244 | 0 | double fDistance = 1.0; |
245 | 0 | if( rIncrement.Distance >>= fDistance ) |
246 | 0 | rOutItemSet.Put( SvxDoubleItem(fDistance, SCHATTR_AXIS_STEP_MAIN )); |
247 | 0 | else if( m_pExplicitIncrement ) |
248 | 0 | rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, SCHATTR_AXIS_STEP_MAIN )); |
249 | 0 | } |
250 | 0 | break; |
251 | | |
252 | | // SubIncrement |
253 | 0 | case SCHATTR_AXIS_AUTO_STEP_HELP: |
254 | 0 | if( bDateAxis ) |
255 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) ); |
256 | 0 | else |
257 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, |
258 | 0 | ! ( rSubIncrements.hasElements() && rSubIncrements[0].IntervalCount.hasValue() ))); |
259 | 0 | break; |
260 | | |
261 | 0 | case SCHATTR_AXIS_HELP_TIME_UNIT: |
262 | 0 | { |
263 | 0 | TimeInterval aTimeInterval; |
264 | 0 | if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) |
265 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); |
266 | 0 | else if( m_pExplicitIncrement ) |
267 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) ); |
268 | 0 | } |
269 | 0 | break; |
270 | | |
271 | 0 | case SCHATTR_AXIS_STEP_HELP: |
272 | 0 | if( bDateAxis ) |
273 | 0 | { |
274 | 0 | TimeInterval aTimeInterval; |
275 | 0 | if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) |
276 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number )); |
277 | 0 | else if( m_pExplicitIncrement ) |
278 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number )); |
279 | 0 | } |
280 | 0 | else |
281 | 0 | { |
282 | 0 | if( rSubIncrements.hasElements() && rSubIncrements[0].IntervalCount.hasValue()) |
283 | 0 | { |
284 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, |
285 | 0 | *o3tl::doAccess<sal_Int32>( |
286 | 0 | rSubIncrements[0].IntervalCount) )); |
287 | 0 | } |
288 | 0 | else |
289 | 0 | { |
290 | 0 | if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() ) |
291 | 0 | { |
292 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, |
293 | 0 | m_pExplicitIncrement->SubIncrements[0].IntervalCount )); |
294 | 0 | } |
295 | 0 | } |
296 | 0 | } |
297 | 0 | break; |
298 | | |
299 | 0 | case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: |
300 | 0 | { |
301 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, |
302 | 0 | !rTimeIncrement.TimeResolution.hasValue() )); |
303 | 0 | } |
304 | 0 | break; |
305 | 0 | case SCHATTR_AXIS_TIME_RESOLUTION: |
306 | 0 | { |
307 | 0 | sal_Int32 nTimeResolution=0; |
308 | 0 | if( rTimeIncrement.TimeResolution >>= nTimeResolution ) |
309 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); |
310 | 0 | else if( m_pExplicitScale ) |
311 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) ); |
312 | 0 | } |
313 | 0 | break; |
314 | | |
315 | 0 | case SCHATTR_AXIS_AUTO_ORIGIN: |
316 | 0 | { |
317 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); |
318 | 0 | } |
319 | 0 | break; |
320 | | |
321 | 0 | case SCHATTR_AXIS_ORIGIN: |
322 | 0 | { |
323 | 0 | double fOrigin = 0.0; |
324 | 0 | if( !(aScale.Origin >>= fOrigin) ) |
325 | 0 | { |
326 | 0 | if( m_pExplicitScale ) |
327 | 0 | fOrigin = m_pExplicitScale->Origin; |
328 | 0 | } |
329 | 0 | rOutItemSet.Put( SvxDoubleItem( fOrigin, SCHATTR_AXIS_ORIGIN )); |
330 | 0 | } |
331 | 0 | break; |
332 | | |
333 | 0 | case SCHATTR_AXIS_POSITION: |
334 | 0 | { |
335 | 0 | css::chart::ChartAxisPosition eAxisPos( css::chart::ChartAxisPosition_ZERO ); |
336 | 0 | GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eAxisPos; |
337 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(eAxisPos) ) ); |
338 | 0 | } |
339 | 0 | break; |
340 | | |
341 | 0 | case SCHATTR_AXIS_POSITION_VALUE: |
342 | 0 | { |
343 | 0 | double fValue = 0.0; |
344 | 0 | if( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fValue ) |
345 | 0 | rOutItemSet.Put( SvxDoubleItem( fValue, SCHATTR_AXIS_POSITION_VALUE ) ); |
346 | 0 | } |
347 | 0 | break; |
348 | | |
349 | 0 | case SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT: |
350 | 0 | { |
351 | | //read only item |
352 | | //necessary tp display the crossing value with an appropriate format |
353 | |
|
354 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
355 | 0 | m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
356 | |
|
357 | 0 | rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); |
358 | |
|
359 | 0 | sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
360 | 0 | xCrossingMainAxis, xCooSys, m_xChartDoc); |
361 | |
|
362 | 0 | rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); |
363 | 0 | } |
364 | 0 | break; |
365 | | |
366 | 0 | case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: |
367 | 0 | rOutItemSet.Put(SfxBoolItem(nWhichId, aScale.ShiftedCategoryPosition)); |
368 | 0 | break; |
369 | | |
370 | 0 | case SCHATTR_AXIS_LABEL_POSITION: |
371 | 0 | { |
372 | 0 | css::chart::ChartAxisLabelPosition ePos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); |
373 | 0 | GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= ePos; |
374 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); |
375 | 0 | } |
376 | 0 | break; |
377 | | |
378 | 0 | case SCHATTR_AXIS_MARK_POSITION: |
379 | 0 | { |
380 | 0 | css::chart::ChartAxisMarkPosition ePos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); |
381 | 0 | GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= ePos; |
382 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); |
383 | 0 | } |
384 | 0 | break; |
385 | | |
386 | 0 | case SCHATTR_TEXT_DEGREES: |
387 | 0 | { |
388 | | // convert double to int (times 100) |
389 | 0 | double fVal = 0; |
390 | |
|
391 | 0 | if( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fVal ) |
392 | 0 | { |
393 | 0 | rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >( |
394 | 0 | ::rtl::math::round( fVal * 100.0 )) ) )); |
395 | 0 | } |
396 | 0 | } |
397 | 0 | break; |
398 | | |
399 | 0 | case SID_ATTR_NUMBERFORMAT_VALUE: |
400 | 0 | { |
401 | 0 | if( m_pExplicitScale ) |
402 | 0 | { |
403 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys( |
404 | 0 | AxisHelper::getCoordinateSystemOfAxis( |
405 | 0 | m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
406 | |
|
407 | 0 | sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
408 | 0 | m_xAxis, xCooSys, m_xChartDoc); |
409 | |
|
410 | 0 | rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); |
411 | 0 | } |
412 | 0 | } |
413 | 0 | break; |
414 | | |
415 | 0 | case SID_ATTR_NUMBERFORMAT_SOURCE: |
416 | 0 | { |
417 | 0 | bool bLinkToSource = true; |
418 | 0 | GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource; |
419 | 0 | rOutItemSet.Put(SfxBoolItem(nWhichId, bLinkToSource)); |
420 | 0 | } |
421 | 0 | break; |
422 | | |
423 | 0 | case SCHATTR_AXISTYPE: |
424 | 0 | rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); |
425 | 0 | break; |
426 | | |
427 | 0 | case SCHATTR_AXIS_AUTO_DATEAXIS: |
428 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, aScale.AutoDateAxis )); |
429 | 0 | break; |
430 | | |
431 | 0 | case SCHATTR_AXIS_ALLOW_DATEAXIS: |
432 | 0 | { |
433 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys( |
434 | 0 | AxisHelper::getCoordinateSystemOfAxis( m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
435 | 0 | sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; |
436 | 0 | AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); |
437 | 0 | auto xChartType = AxisHelper::getChartTypeByIndex(xCooSys, 0); |
438 | 0 | bool bChartTypeAllowsDateAxis = xChartType.is() ? xChartType->isSupportingDateAxis(nDimensionIndex) : true; |
439 | 0 | rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); |
440 | 0 | } |
441 | 0 | break; |
442 | 0 | } |
443 | 0 | } |
444 | | |
445 | | static bool lcl_isDateAxis( const SfxItemSet & rItemSet ) |
446 | 0 | { |
447 | 0 | sal_Int32 nAxisType = rItemSet.Get( SCHATTR_AXISTYPE ).GetValue();//css::chart2::AxisType |
448 | 0 | return (nAxisType == chart2::AxisType::DATE); |
449 | 0 | } |
450 | | |
451 | | static bool lcl_isAutoMajor( const SfxItemSet & rItemSet ) |
452 | 0 | { |
453 | 0 | bool bRet = rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN ).GetValue(); |
454 | 0 | return bRet; |
455 | 0 | } |
456 | | |
457 | | static bool lcl_isAutoMinor( const SfxItemSet & rItemSet ) |
458 | 0 | { |
459 | 0 | bool bRet = rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP ).GetValue(); |
460 | 0 | return bRet; |
461 | 0 | } |
462 | | |
463 | | bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) |
464 | 0 | { |
465 | 0 | if( !m_xAxis.is() ) |
466 | 0 | return false; |
467 | | |
468 | 0 | chart2::ScaleData aScale( m_xAxis->getScaleData() ); |
469 | |
|
470 | 0 | bool bSetScale = false; |
471 | 0 | bool bChangedOtherwise = false; |
472 | |
|
473 | 0 | uno::Any aValue; |
474 | |
|
475 | 0 | switch( nWhichId ) |
476 | 0 | { |
477 | 0 | case SCHATTR_AXIS_AUTO_MAX: |
478 | 0 | if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
479 | 0 | { |
480 | 0 | aScale.Maximum.clear(); |
481 | 0 | bSetScale = true; |
482 | 0 | } |
483 | | // else SCHATTR_AXIS_MAX must have some value |
484 | 0 | break; |
485 | | |
486 | 0 | case SCHATTR_AXIS_MAX: |
487 | | // only if auto if false |
488 | 0 | if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_MAX ).GetValue() )) |
489 | 0 | { |
490 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
491 | |
|
492 | 0 | if( aScale.Maximum != aValue ) |
493 | 0 | { |
494 | 0 | aScale.Maximum = aValue; |
495 | 0 | bSetScale = true; |
496 | 0 | } |
497 | 0 | } |
498 | 0 | break; |
499 | | |
500 | 0 | case SCHATTR_AXIS_AUTO_MIN: |
501 | 0 | if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
502 | 0 | { |
503 | 0 | aScale.Minimum.clear(); |
504 | 0 | bSetScale = true; |
505 | 0 | } |
506 | | // else SCHATTR_AXIS_MIN must have some value |
507 | 0 | break; |
508 | | |
509 | 0 | case SCHATTR_AXIS_MIN: |
510 | | // only if auto if false |
511 | 0 | if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_MIN ).GetValue() )) |
512 | 0 | { |
513 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
514 | |
|
515 | 0 | if( aScale.Minimum != aValue ) |
516 | 0 | { |
517 | 0 | aScale.Minimum = aValue; |
518 | 0 | bSetScale = true; |
519 | 0 | } |
520 | 0 | } |
521 | 0 | break; |
522 | | |
523 | 0 | case SCHATTR_AXIS_LOGARITHM: |
524 | 0 | { |
525 | 0 | bool bWasLogarithm = AxisHelper::isLogarithmic( aScale.Scaling ); |
526 | |
|
527 | 0 | if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
528 | 0 | { |
529 | | // logarithm is true |
530 | 0 | if( ! bWasLogarithm ) |
531 | 0 | { |
532 | 0 | aScale.Scaling = AxisHelper::createLogarithmicScaling( 10.0 ); |
533 | 0 | bSetScale = true; |
534 | 0 | } |
535 | 0 | } |
536 | 0 | else |
537 | 0 | { |
538 | | // logarithm is false => linear scaling |
539 | 0 | if( bWasLogarithm ) |
540 | 0 | { |
541 | 0 | aScale.Scaling = AxisHelper::createLinearScaling(); |
542 | 0 | bSetScale = true; |
543 | 0 | } |
544 | 0 | } |
545 | 0 | } |
546 | 0 | break; |
547 | | |
548 | 0 | case SCHATTR_AXIS_REVERSE: |
549 | 0 | { |
550 | 0 | bool bWasReverse = ( aScale.Orientation == AxisOrientation_REVERSE ); |
551 | 0 | bool bNewReverse = static_cast< const SfxBoolItem & >( |
552 | 0 | rItemSet.Get( nWhichId )).GetValue(); |
553 | 0 | if( bWasReverse != bNewReverse ) |
554 | 0 | { |
555 | 0 | aScale.Orientation = bNewReverse ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL; |
556 | 0 | bSetScale = true; |
557 | 0 | } |
558 | 0 | } |
559 | 0 | break; |
560 | | |
561 | | // Increment |
562 | 0 | case SCHATTR_AXIS_AUTO_STEP_MAIN: |
563 | 0 | if( lcl_isAutoMajor(rItemSet) ) |
564 | 0 | { |
565 | 0 | aScale.IncrementData.Distance.clear(); |
566 | 0 | aScale.TimeIncrement.MajorTimeInterval.clear(); |
567 | 0 | bSetScale = true; |
568 | 0 | } |
569 | | // else SCHATTR_AXIS_STEP_MAIN must have some value |
570 | 0 | break; |
571 | | |
572 | 0 | case SCHATTR_AXIS_MAIN_TIME_UNIT: |
573 | 0 | if( !lcl_isAutoMajor(rItemSet) ) |
574 | 0 | { |
575 | 0 | if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) |
576 | 0 | { |
577 | 0 | TimeInterval aTimeInterval; |
578 | 0 | aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; |
579 | 0 | aValue >>= aTimeInterval.TimeUnit; |
580 | 0 | aScale.TimeIncrement.MajorTimeInterval <<= aTimeInterval; |
581 | 0 | bSetScale = true; |
582 | 0 | } |
583 | 0 | } |
584 | 0 | break; |
585 | | |
586 | 0 | case SCHATTR_AXIS_STEP_MAIN: |
587 | | // only if auto if false |
588 | 0 | if( !lcl_isAutoMajor(rItemSet) ) |
589 | 0 | { |
590 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
591 | 0 | if( lcl_isDateAxis(rItemSet) ) |
592 | 0 | { |
593 | 0 | double fValue = 1.0; |
594 | 0 | if( aValue >>= fValue ) |
595 | 0 | { |
596 | 0 | TimeInterval aTimeInterval; |
597 | 0 | aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; |
598 | 0 | aTimeInterval.Number = static_cast<sal_Int32>(fValue); |
599 | 0 | aScale.TimeIncrement.MajorTimeInterval <<= aTimeInterval; |
600 | 0 | bSetScale = true; |
601 | 0 | } |
602 | 0 | } |
603 | 0 | else if( aScale.IncrementData.Distance != aValue ) |
604 | 0 | { |
605 | 0 | aScale.IncrementData.Distance = aValue; |
606 | 0 | bSetScale = true; |
607 | 0 | } |
608 | 0 | } |
609 | 0 | break; |
610 | | |
611 | | // SubIncrement |
612 | 0 | case SCHATTR_AXIS_AUTO_STEP_HELP: |
613 | 0 | if( lcl_isAutoMinor(rItemSet) ) |
614 | 0 | { |
615 | 0 | if( aScale.IncrementData.SubIncrements.hasElements() && |
616 | 0 | aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) |
617 | 0 | { |
618 | 0 | aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount.clear(); |
619 | 0 | bSetScale = true; |
620 | 0 | } |
621 | 0 | if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) |
622 | 0 | { |
623 | 0 | aScale.TimeIncrement.MinorTimeInterval.clear(); |
624 | 0 | bSetScale = true; |
625 | 0 | } |
626 | 0 | } |
627 | | // else SCHATTR_AXIS_STEP_MAIN must have some value |
628 | 0 | break; |
629 | | |
630 | 0 | case SCHATTR_AXIS_HELP_TIME_UNIT: |
631 | 0 | if( !lcl_isAutoMinor(rItemSet) ) |
632 | 0 | { |
633 | 0 | if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) |
634 | 0 | { |
635 | 0 | TimeInterval aTimeInterval; |
636 | 0 | aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; |
637 | 0 | aValue >>= aTimeInterval.TimeUnit; |
638 | 0 | aScale.TimeIncrement.MinorTimeInterval <<= aTimeInterval; |
639 | 0 | bSetScale = true; |
640 | 0 | } |
641 | 0 | } |
642 | 0 | break; |
643 | | |
644 | 0 | case SCHATTR_AXIS_STEP_HELP: |
645 | | // only if auto is false |
646 | 0 | if( !lcl_isAutoMinor(rItemSet) ) |
647 | 0 | { |
648 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
649 | 0 | if( lcl_isDateAxis(rItemSet) ) |
650 | 0 | { |
651 | 0 | TimeInterval aTimeInterval; |
652 | 0 | aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; |
653 | 0 | aValue >>= aTimeInterval.Number; |
654 | 0 | aScale.TimeIncrement.MinorTimeInterval <<= aTimeInterval; |
655 | 0 | bSetScale = true; |
656 | 0 | } |
657 | 0 | else if( aScale.IncrementData.SubIncrements.hasElements() ) |
658 | 0 | { |
659 | 0 | if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || |
660 | 0 | aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) |
661 | 0 | { |
662 | 0 | OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); |
663 | 0 | aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount = aValue; |
664 | 0 | bSetScale = true; |
665 | 0 | } |
666 | 0 | } |
667 | 0 | } |
668 | 0 | break; |
669 | | |
670 | 0 | case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: |
671 | 0 | if( static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() ) |
672 | 0 | { |
673 | 0 | aScale.TimeIncrement.TimeResolution.clear(); |
674 | 0 | bSetScale = true; |
675 | 0 | } |
676 | 0 | break; |
677 | 0 | case SCHATTR_AXIS_TIME_RESOLUTION: |
678 | | // only if auto is false |
679 | 0 | if( ! ( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION ).GetValue() )) |
680 | 0 | { |
681 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
682 | |
|
683 | 0 | if( aScale.TimeIncrement.TimeResolution != aValue ) |
684 | 0 | { |
685 | 0 | aScale.TimeIncrement.TimeResolution = aValue; |
686 | 0 | bSetScale = true; |
687 | 0 | } |
688 | 0 | } |
689 | 0 | break; |
690 | | |
691 | 0 | case SCHATTR_AXIS_AUTO_ORIGIN: |
692 | 0 | { |
693 | 0 | if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
694 | 0 | { |
695 | 0 | aScale.Origin.clear(); |
696 | 0 | bSetScale = true; |
697 | 0 | } |
698 | 0 | } |
699 | 0 | break; |
700 | | |
701 | 0 | case SCHATTR_AXIS_ORIGIN: |
702 | 0 | { |
703 | | // only if auto is false |
704 | 0 | if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_ORIGIN ).GetValue() )) |
705 | 0 | { |
706 | 0 | rItemSet.Get( nWhichId ).QueryValue( aValue ); |
707 | |
|
708 | 0 | if( aScale.Origin != aValue ) |
709 | 0 | { |
710 | 0 | aScale.Origin = aValue; |
711 | 0 | bSetScale = true; |
712 | |
|
713 | 0 | if( !AxisHelper::isAxisPositioningEnabled() ) |
714 | 0 | { |
715 | | //keep old and new settings for axis positioning in sync somehow |
716 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
717 | 0 | m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
718 | |
|
719 | 0 | sal_Int32 nDimensionIndex=0; |
720 | 0 | sal_Int32 nAxisIndex=0; |
721 | 0 | if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) |
722 | 0 | { |
723 | 0 | rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); |
724 | 0 | if( xCrossingMainAxis.is() ) |
725 | 0 | { |
726 | 0 | double fValue = 0.0; |
727 | 0 | if( aValue >>= fValue ) |
728 | 0 | { |
729 | 0 | xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_VALUE )); |
730 | 0 | xCrossingMainAxis->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); |
731 | 0 | } |
732 | 0 | else |
733 | 0 | xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_START )); |
734 | 0 | } |
735 | 0 | } |
736 | 0 | } |
737 | 0 | } |
738 | 0 | } |
739 | 0 | } |
740 | 0 | break; |
741 | | |
742 | 0 | case SCHATTR_AXIS_POSITION: |
743 | 0 | { |
744 | 0 | css::chart::ChartAxisPosition eAxisPos = |
745 | 0 | static_cast<css::chart::ChartAxisPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
746 | |
|
747 | 0 | css::chart::ChartAxisPosition eOldAxisPos( css::chart::ChartAxisPosition_ZERO ); |
748 | 0 | bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOldAxisPos ); |
749 | |
|
750 | 0 | if( !bPropExisted || ( eOldAxisPos != eAxisPos )) |
751 | 0 | { |
752 | 0 | GetPropertySet()->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eAxisPos )); |
753 | 0 | bChangedOtherwise = true; |
754 | | |
755 | | //move the parallel axes to the other side if necessary |
756 | 0 | if( eAxisPos==css::chart::ChartAxisPosition_START || eAxisPos==css::chart::ChartAxisPosition_END ) |
757 | 0 | { |
758 | 0 | rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); |
759 | 0 | rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); |
760 | 0 | if( xParallelAxis.is() ) |
761 | 0 | { |
762 | 0 | css::chart::ChartAxisPosition eOtherPos; |
763 | 0 | if( xParallelAxis->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOtherPos ) |
764 | 0 | { |
765 | 0 | if( eOtherPos == eAxisPos ) |
766 | 0 | { |
767 | 0 | css::chart::ChartAxisPosition eOppositePos = |
768 | 0 | (eAxisPos==css::chart::ChartAxisPosition_START) |
769 | 0 | ? css::chart::ChartAxisPosition_END |
770 | 0 | : css::chart::ChartAxisPosition_START; |
771 | 0 | xParallelAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eOppositePos )); |
772 | 0 | } |
773 | 0 | } |
774 | 0 | } |
775 | 0 | } |
776 | 0 | } |
777 | 0 | } |
778 | 0 | break; |
779 | | |
780 | 0 | case SCHATTR_AXIS_POSITION_VALUE: |
781 | 0 | { |
782 | 0 | double fValue = static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); |
783 | |
|
784 | 0 | double fOldValue = 0.0; |
785 | 0 | bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fOldValue ); |
786 | |
|
787 | 0 | if( !bPropExisted || ( fOldValue != fValue )) |
788 | 0 | { |
789 | 0 | GetPropertySet()->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); |
790 | 0 | bChangedOtherwise = true; |
791 | | |
792 | | //keep old and new settings for axis positioning in sync somehow |
793 | 0 | { |
794 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
795 | 0 | m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
796 | |
|
797 | 0 | sal_Int32 nDimensionIndex=0; |
798 | 0 | sal_Int32 nAxisIndex=0; |
799 | 0 | if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) |
800 | 0 | { |
801 | 0 | rtl::Reference< Axis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); |
802 | 0 | if( xCrossingMainAxis.is() ) |
803 | 0 | { |
804 | 0 | ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() ); |
805 | 0 | aCrossingScale.Origin <<= fValue; |
806 | 0 | xCrossingMainAxis->setScaleData(aCrossingScale); |
807 | 0 | } |
808 | 0 | } |
809 | 0 | } |
810 | 0 | } |
811 | 0 | } |
812 | 0 | break; |
813 | | |
814 | 0 | case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: |
815 | 0 | { |
816 | 0 | bool bNewValue = static_cast<const SfxBoolItem &> (rItemSet.Get(nWhichId)).GetValue(); |
817 | 0 | bool bOldValue = aScale.ShiftedCategoryPosition; |
818 | 0 | if (bOldValue != bNewValue) |
819 | 0 | { |
820 | 0 | aScale.ShiftedCategoryPosition = bNewValue; |
821 | 0 | bSetScale = true; |
822 | 0 | } |
823 | 0 | } |
824 | 0 | break; |
825 | | |
826 | 0 | case SCHATTR_AXIS_LABEL_POSITION: |
827 | 0 | { |
828 | 0 | css::chart::ChartAxisLabelPosition ePos = |
829 | 0 | static_cast<css::chart::ChartAxisLabelPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
830 | |
|
831 | 0 | css::chart::ChartAxisLabelPosition eOldPos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); |
832 | 0 | bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= eOldPos ); |
833 | |
|
834 | 0 | if( !bPropExisted || ( eOldPos != ePos )) |
835 | 0 | { |
836 | 0 | GetPropertySet()->setPropertyValue( u"LabelPosition"_ustr , uno::Any( ePos )); |
837 | 0 | bChangedOtherwise = true; |
838 | | |
839 | | //move the parallel axes to the other side if necessary |
840 | 0 | if( ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START || ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_END ) |
841 | 0 | { |
842 | 0 | rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); |
843 | 0 | rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); |
844 | 0 | if( xParallelAxis.is() ) |
845 | 0 | { |
846 | 0 | css::chart::ChartAxisLabelPosition eOtherPos; |
847 | 0 | if( xParallelAxis->getPropertyValue( u"LabelPosition"_ustr ) >>= eOtherPos ) |
848 | 0 | { |
849 | 0 | if( eOtherPos == ePos ) |
850 | 0 | { |
851 | 0 | css::chart::ChartAxisLabelPosition eOppositePos = |
852 | 0 | (ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START) |
853 | 0 | ? css::chart::ChartAxisLabelPosition_OUTSIDE_END |
854 | 0 | : css::chart::ChartAxisLabelPosition_OUTSIDE_START; |
855 | 0 | xParallelAxis->setPropertyValue( u"LabelPosition"_ustr , uno::Any( eOppositePos )); |
856 | 0 | } |
857 | 0 | } |
858 | 0 | } |
859 | 0 | } |
860 | 0 | } |
861 | 0 | } |
862 | 0 | break; |
863 | | |
864 | 0 | case SCHATTR_AXIS_MARK_POSITION: |
865 | 0 | { |
866 | 0 | css::chart::ChartAxisMarkPosition ePos = |
867 | 0 | static_cast<css::chart::ChartAxisMarkPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
868 | |
|
869 | 0 | css::chart::ChartAxisMarkPosition eOldPos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); |
870 | 0 | bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= eOldPos ); |
871 | |
|
872 | 0 | if( !bPropExisted || ( eOldPos != ePos )) |
873 | 0 | { |
874 | 0 | GetPropertySet()->setPropertyValue( u"MarkPosition"_ustr , uno::Any( ePos )); |
875 | 0 | bChangedOtherwise = true; |
876 | 0 | } |
877 | 0 | } |
878 | 0 | break; |
879 | | |
880 | 0 | case SCHATTR_TEXT_DEGREES: |
881 | 0 | { |
882 | 0 | double fVal = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); |
883 | 0 | double fOldVal = 0.0; |
884 | 0 | bool bPropExisted = |
885 | 0 | ( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fOldVal ); |
886 | |
|
887 | 0 | if( ! bPropExisted || fOldVal != fVal ) |
888 | 0 | { |
889 | 0 | GetPropertySet()->setPropertyValue( u"TextRotation"_ustr , uno::Any( fVal )); |
890 | 0 | bChangedOtherwise = true; |
891 | 0 | } |
892 | 0 | } |
893 | 0 | break; |
894 | | |
895 | 0 | case SID_ATTR_NUMBERFORMAT_VALUE: |
896 | 0 | { |
897 | 0 | if( m_pExplicitScale ) |
898 | 0 | { |
899 | 0 | bool bUseSourceFormat = |
900 | 0 | rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE ).GetValue(); |
901 | |
|
902 | 0 | if( ! bUseSourceFormat ) |
903 | 0 | { |
904 | 0 | sal_Int32 nFmt = static_cast< sal_Int32 >( |
905 | 0 | static_cast< const SfxUInt32Item & >( |
906 | 0 | rItemSet.Get( nWhichId )).GetValue()); |
907 | |
|
908 | 0 | aValue <<= nFmt; |
909 | 0 | if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) != aValue) |
910 | 0 | { |
911 | 0 | GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT , aValue); |
912 | 0 | bChangedOtherwise = true; |
913 | 0 | } |
914 | 0 | } |
915 | 0 | } |
916 | 0 | } |
917 | 0 | break; |
918 | | |
919 | 0 | case SID_ATTR_NUMBERFORMAT_SOURCE: |
920 | 0 | { |
921 | 0 | bool bUseSourceFormat = |
922 | 0 | static_cast< const SfxBoolItem & >( |
923 | 0 | rItemSet.Get( nWhichId )).GetValue(); |
924 | 0 | GetPropertySet()->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(bUseSourceFormat)); |
925 | |
|
926 | 0 | bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue(); |
927 | |
|
928 | 0 | bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet); |
929 | 0 | if( bChangedOtherwise ) |
930 | 0 | { |
931 | 0 | if( ! bUseSourceFormat ) |
932 | 0 | { |
933 | 0 | SfxItemState aState = rItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE ); |
934 | 0 | if( aState == SfxItemState::SET ) |
935 | 0 | { |
936 | 0 | sal_Int32 nFormatKey = static_cast< sal_Int32 >( |
937 | 0 | rItemSet.Get( SID_ATTR_NUMBERFORMAT_VALUE ).GetValue()); |
938 | 0 | aValue <<= nFormatKey; |
939 | 0 | } |
940 | 0 | else |
941 | 0 | { |
942 | 0 | rtl::Reference< BaseCoordinateSystem > xCooSys = |
943 | 0 | AxisHelper::getCoordinateSystemOfAxis( |
944 | 0 | m_xAxis, m_xChartDoc->getFirstChartDiagram() ); |
945 | |
|
946 | 0 | sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
947 | 0 | m_xAxis, xCooSys, m_xChartDoc); |
948 | |
|
949 | 0 | aValue <<= nFormatKey; |
950 | 0 | } |
951 | 0 | } |
952 | | // else set a void Any |
953 | 0 | GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT , aValue); |
954 | 0 | } |
955 | 0 | } |
956 | 0 | break; |
957 | | |
958 | 0 | case SCHATTR_AXISTYPE: |
959 | 0 | { |
960 | 0 | sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//css::chart2::AxisType |
961 | 0 | aScale.AxisType = nNewAxisType; |
962 | 0 | bSetScale = true; |
963 | 0 | } |
964 | 0 | break; |
965 | | |
966 | 0 | case SCHATTR_AXIS_AUTO_DATEAXIS: |
967 | 0 | { |
968 | 0 | bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); |
969 | 0 | bool bOldValue = aScale.AutoDateAxis; |
970 | 0 | if( bOldValue != bNewValue ) |
971 | 0 | { |
972 | 0 | aScale.AutoDateAxis = bNewValue; |
973 | 0 | bSetScale = true; |
974 | 0 | } |
975 | 0 | } |
976 | 0 | break; |
977 | 0 | } |
978 | | |
979 | 0 | if( bSetScale ) |
980 | 0 | m_xAxis->setScaleData( aScale ); |
981 | |
|
982 | 0 | return (bSetScale || bChangedOtherwise); |
983 | 0 | } |
984 | | |
985 | | } |
986 | | |
987 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |