Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "DataPointItemConverter.hxx"
21 : : #include "SchWhichPairs.hxx"
22 : : #include "macros.hxx"
23 : : #include "ItemPropertyMap.hxx"
24 : :
25 : : #include "GraphicPropertyItemConverter.hxx"
26 : : #include "CharacterPropertyItemConverter.hxx"
27 : : #include "StatisticsItemConverter.hxx"
28 : : #include "SeriesOptionsItemConverter.hxx"
29 : : #include "DataSeriesHelper.hxx"
30 : : #include "DiagramHelper.hxx"
31 : : #include "ChartModelHelper.hxx"
32 : : #include "ChartTypeHelper.hxx"
33 : : #include <svx/chrtitem.hxx>
34 : : #include <com/sun/star/chart2/DataPointLabel.hpp>
35 : : #include <com/sun/star/chart2/Symbol.hpp>
36 : :
37 : : // header for class XFillColorItem
38 : : #include <svx/xflclit.hxx>
39 : : #include <svl/intitem.hxx>
40 : : #include <editeng/sizeitem.hxx>
41 : : // header for class SfxStringItem
42 : : #include <svl/stritem.hxx>
43 : : #include <editeng/brshitem.hxx>
44 : : //SfxIntegerListItem
45 : : #include <svl/ilstitem.hxx>
46 : : #include <vcl/graph.hxx>
47 : : #include <com/sun/star/graphic/XGraphic.hpp>
48 : :
49 : : // for SVX_SYMBOLTYPE_...
50 : : #include <svx/tabline.hxx>
51 : :
52 : : #include <functional>
53 : : #include <algorithm>
54 : :
55 : : using namespace ::com::sun::star;
56 : : using namespace ::com::sun::star::chart2;
57 : : using ::com::sun::star::uno::Reference;
58 : :
59 : : namespace
60 : : {
61 : 0 : ::comphelper::ItemPropertyMapType & lcl_GetDataPointPropertyMap()
62 : : {
63 : : static ::comphelper::ItemPropertyMapType aDataPointPropertyMap(
64 : : ::comphelper::MakeItemPropertyMap
65 : : IPM_MAP_ENTRY( SCHATTR_STYLE_SHAPE, "Geometry3D", 0 )
66 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
[ # # ]
67 : :
68 : 0 : return aDataPointPropertyMap;
69 : : };
70 : :
71 : 0 : sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
72 : : {
73 : 0 : sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
74 [ # # # # : 0 : switch( rSymbol.Style )
# # ]
75 : : {
76 : : case chart2::SymbolStyle_NONE:
77 : 0 : nStyle = SVX_SYMBOLTYPE_NONE;
78 : 0 : break;
79 : : case chart2::SymbolStyle_AUTO:
80 : 0 : nStyle = SVX_SYMBOLTYPE_AUTO;
81 : 0 : break;
82 : : case chart2::SymbolStyle_GRAPHIC:
83 : 0 : nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
84 : 0 : break;
85 : : case chart2::SymbolStyle_STANDARD:
86 : 0 : nStyle = rSymbol.StandardSymbol;
87 : 0 : break;
88 : :
89 : : case chart2::SymbolStyle_POLYGON:
90 : : // to avoid warning
91 : : case chart2::SymbolStyle_MAKE_FIXED_SIZE:
92 : : // nothing
93 : 0 : break;
94 : : }
95 : 0 : return nStyle;
96 : : }
97 : :
98 : 0 : bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
99 : : {
100 : 0 : bool bChanged = false;
101 [ # # ]: 0 : if( !xPropertySet.is() )
102 : 0 : return bChanged;
103 [ # # ][ # # ]: 0 : rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" );
[ # # ]
104 [ # # ]: 0 : sal_uInt16 nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
105 : :
106 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET != rItemSet.GetItemState( nSourceWhich ) )
107 : 0 : return bChanged;
108 : :
109 : 0 : uno::Any aValue;
110 : : bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
111 [ # # ]: 0 : rItemSet.Get( nSourceWhich )).GetValue() );
112 [ # # ]: 0 : if( !bUseSourceFormat )
113 : : {
114 [ # # ]: 0 : SfxItemState aState = rItemSet.GetItemState( nWhichId );
115 [ # # ]: 0 : if( aState == SFX_ITEM_SET )
116 : : {
117 : : sal_Int32 nFmt = static_cast< sal_Int32 >(
118 : : static_cast< const SfxUInt32Item & >(
119 [ # # ]: 0 : rItemSet.Get( nWhichId )).GetValue());
120 [ # # ]: 0 : aValue = uno::makeAny(nFmt);
121 : : }
122 : : else
123 : 0 : return bChanged;
124 : : }
125 : :
126 [ # # ][ # # ]: 0 : uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
127 [ # # ]: 0 : if( bOverwriteAttributedDataPointsAlso )
128 : : {
129 [ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
130 [ # # ][ # # ]: 0 : if( aValue != aOldValue ||
[ # # ]
131 [ # # ]: 0 : ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
132 : : {
133 [ # # ]: 0 : ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue );
134 : 0 : bChanged = true;
135 : 0 : }
136 : : }
137 [ # # ]: 0 : else if( aOldValue != aValue )
138 : : {
139 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue(aPropertyName, aValue );
140 : 0 : bChanged = true;
141 : : }
142 : 0 : return bChanged;
143 : : }
144 : :
145 : 0 : bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
146 : : {
147 : 0 : bool bChanged = false;
148 [ # # ]: 0 : if( !xPropertySet.is() )
149 : 0 : return bChanged;
150 [ # # ][ # # ]: 0 : rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" );
[ # # ]
151 [ # # ]: 0 : sal_uInt16 nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
152 : :
153 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET != rItemSet.GetItemState( nWhichId ) )
154 : 0 : return bChanged;
155 : :
156 : 0 : uno::Any aNewValue;
157 : : bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
158 [ # # ]: 0 : rItemSet.Get( nWhichId )).GetValue() );
159 [ # # ]: 0 : if( !bUseSourceFormat )
160 : : {
161 [ # # ]: 0 : SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
162 [ # # ]: 0 : if( aState == SFX_ITEM_SET )
163 : : {
164 : : sal_Int32 nFormatKey = static_cast< sal_Int32 >(
165 : : static_cast< const SfxUInt32Item & >(
166 [ # # ]: 0 : rItemSet.Get( nFormatWhich )).GetValue());
167 [ # # ]: 0 : aNewValue <<= nFormatKey;
168 : : }
169 : : else
170 : 0 : return bChanged;
171 : : }
172 : :
173 [ # # ][ # # ]: 0 : uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
174 [ # # ]: 0 : if( bOverwriteAttributedDataPointsAlso )
175 : : {
176 [ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
177 [ # # ][ # # ]: 0 : if( aNewValue != aOldValue ||
[ # # ]
178 [ # # ]: 0 : ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
179 : : {
180 [ # # ]: 0 : ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue );
181 : 0 : bChanged = true;
182 : 0 : }
183 : : }
184 [ # # ]: 0 : else if( aOldValue != aNewValue )
185 : : {
186 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( aPropertyName, aNewValue );
187 : 0 : bChanged = true;
188 : : }
189 : :
190 : 0 : return bChanged;
191 : : }
192 : :
193 : : } // anonymous namespace
194 : :
195 : : namespace chart
196 : : {
197 : : namespace wrapper
198 : : {
199 : :
200 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
201 : 0 : DataPointItemConverter::DataPointItemConverter(
202 : : const uno::Reference< frame::XModel > & xChartModel,
203 : : const uno::Reference< uno::XComponentContext > & xContext,
204 : : const uno::Reference< beans::XPropertySet > & rPropertySet,
205 : : const uno::Reference< XDataSeries > & xSeries,
206 : : SfxItemPool& rItemPool,
207 : : SdrModel& rDrawModel,
208 : : NumberFormatterWrapper * pNumFormatter,
209 : : const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
210 : : GraphicPropertyItemConverter::eGraphicObjectType eMapTo /* = FILL_PROPERTIES */,
211 : : ::std::auto_ptr< awt::Size > pRefSize /* = NULL */,
212 : : bool bDataSeries /* = false */,
213 : : bool bUseSpecialFillColor /* = false */,
214 : : sal_Int32 nSpecialFillColor /* =0 */,
215 : : bool bOverwriteLabelsForAttributedDataPointsAlso /*false*/,
216 : : sal_Int32 nNumberFormat,
217 : : sal_Int32 nPercentNumberFormat
218 : : ) :
219 : : ItemConverter( rPropertySet, rItemPool ),
220 : : m_pNumberFormatterWrapper( pNumFormatter ),
221 : : m_bDataSeries( bDataSeries ),
222 : : m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
223 : : m_bUseSpecialFillColor(bUseSpecialFillColor),
224 : : m_nSpecialFillColor(nSpecialFillColor),
225 : : m_nNumberFormat(nNumberFormat),
226 : : m_nPercentNumberFormat(nPercentNumberFormat),
227 : : m_aAvailableLabelPlacements(),
228 [ # # ][ # # ]: 0 : m_bForbidPercentValue(true)
[ # # ][ # # ]
229 : : {
230 : : m_aConverters.push_back( new GraphicPropertyItemConverter(
231 [ # # ][ # # ]: 0 : rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
[ # # ]
232 : : m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize,
233 [ # # ][ # # ]: 0 : C2U( "ReferencePageSize" )));
[ # # ][ # # ]
234 [ # # ]: 0 : if( bDataSeries )
235 : : {
236 [ # # ][ # # ]: 0 : m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
[ # # ]
237 [ # # ][ # # ]: 0 : m_aConverters.push_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool ));
[ # # ]
238 : : }
239 : :
240 [ # # ]: 0 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
241 [ # # ]: 0 : uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
242 : 0 : bool bFound = false;
243 : 0 : bool bAmbiguous = false;
244 [ # # ]: 0 : sal_Bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
245 [ # # ][ # # ]: 0 : m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, DiagramHelper::getDimension( xDiagram ), bSwapXAndY, xSeries );
[ # # ][ # # ]
246 : :
247 [ # # ]: 0 : m_bForbidPercentValue = AxisType::CATEGORY != ChartTypeHelper::getAxisType( xChartType, 0 );
248 : 0 : }
249 : : SAL_WNODEPRECATED_DECLARATIONS_POP
250 : :
251 [ # # ]: 0 : DataPointItemConverter::~DataPointItemConverter()
252 : : {
253 : : ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
254 [ # # ]: 0 : ::comphelper::DeleteItemConverterPtr() );
255 [ # # ]: 0 : }
256 : :
257 : 0 : void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
258 : : {
259 : : ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
260 [ # # ]: 0 : ::comphelper::FillItemSetFunc( rOutItemSet ));
261 : :
262 : : // own items
263 : 0 : ItemConverter::FillItemSet( rOutItemSet );
264 : :
265 [ # # ]: 0 : if( m_bUseSpecialFillColor )
266 : : {
267 : 0 : Color aColor(m_nSpecialFillColor);
268 [ # # ][ # # ]: 0 : rOutItemSet.Put( XFillColorItem( String(), aColor ) );
[ # # ][ # # ]
[ # # ]
269 : : }
270 : 0 : }
271 : :
272 : 0 : bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
273 : : {
274 : 0 : bool bResult = false;
275 : :
276 : : ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
277 [ # # ]: 0 : ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
278 : :
279 : : // own items
280 [ # # ][ # # ]: 0 : return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
[ # # ]
281 : : }
282 : :
283 : 0 : const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const
284 : : {
285 : : // must span all used items!
286 [ # # ]: 0 : if( m_bDataSeries )
287 : 0 : return nRowWhichPairs;
288 : 0 : return nDataPointWhichPairs;
289 : : }
290 : :
291 : 0 : bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
292 : : {
293 [ # # ]: 0 : ::comphelper::ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
294 [ # # ]: 0 : ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
295 : :
296 [ # # ]: 0 : if( aIt == rMap.end())
297 : 0 : return false;
298 : :
299 : 0 : rOutProperty =(*aIt).second;
300 : 0 : return true;
301 : : }
302 : :
303 : :
304 : 0 : bool DataPointItemConverter::ApplySpecialItem(
305 : : sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
306 : : throw( uno::Exception )
307 : : {
308 : 0 : bool bChanged = false;
309 : 0 : uno::Any aValue;
310 : :
311 [ # # # # : 0 : switch( nWhichId )
# # # # #
# ]
312 : : {
313 : : case SCHATTR_DATADESCR_SHOW_NUMBER:
314 : : case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
315 : : case SCHATTR_DATADESCR_SHOW_CATEGORY:
316 : : case SCHATTR_DATADESCR_SHOW_SYMBOL:
317 : : {
318 [ # # ]: 0 : const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
319 : :
320 [ # # ][ # # ]: 0 : uno::Any aOldValue( GetPropertySet()->getPropertyValue( C2U( "Label" ) ));
[ # # ][ # # ]
321 : 0 : chart2::DataPointLabel aLabel;
322 [ # # ][ # # ]: 0 : if( aOldValue >>= aLabel )
323 : : {
324 : : sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
325 : : (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
326 [ # # ][ # # ]: 0 : (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
[ # # ]
327 : 0 : sal_Bool bOldValue = rValue;
328 : 0 : rValue = static_cast< sal_Bool >( rItem.GetValue() );
329 [ # # ]: 0 : if( m_bOverwriteLabelsForAttributedDataPointsAlso )
330 : : {
331 [ # # ][ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
332 [ # # ][ # # ]: 0 : if( bOldValue != rValue ||
[ # # ]
333 [ # # ][ # # ]: 0 : DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "Label" ), aOldValue ) )
[ # # ][ # # ]
334 : : {
335 [ # # ][ # # ]: 0 : DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny( aLabel ) );
[ # # ]
336 : 0 : bChanged = true;
337 : 0 : }
338 : : }
339 [ # # ]: 0 : else if( bOldValue != rValue )
340 : : {
341 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ));
[ # # ][ # # ]
[ # # ]
342 : 0 : bChanged = true;
343 : : }
344 : 0 : }
345 : : }
346 : 0 : break;
347 : :
348 : : case SID_ATTR_NUMBERFORMAT_VALUE:
349 : : case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
350 : : {
351 [ # # ][ # # ]: 0 : bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
352 : : }
353 : 0 : break;
354 : :
355 : : case SID_ATTR_NUMBERFORMAT_SOURCE:
356 : : case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
357 : : {
358 [ # # ][ # # ]: 0 : bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
359 : : }
360 : 0 : break;
361 : :
362 : : case SCHATTR_DATADESCR_SEPARATOR:
363 : : {
364 [ # # ][ # # ]: 0 : rtl::OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
365 : 0 : rtl::OUString aOldValue;
366 : : try
367 : : {
368 [ # # ][ # # ]: 0 : GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aOldValue;
[ # # ][ # # ]
369 [ # # ]: 0 : if( m_bOverwriteLabelsForAttributedDataPointsAlso )
370 : : {
371 [ # # ][ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
372 [ # # ][ # # ]: 0 : if( !aOldValue.equals(aNewValue) ||
[ # # ]
373 [ # # ][ # # ]: 0 : DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aOldValue ) ) )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
374 : : {
375 [ # # ][ # # ]: 0 : DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aNewValue ) );
[ # # ]
376 : 0 : bChanged = true;
377 : 0 : }
378 : : }
379 [ # # ]: 0 : else if( !aOldValue.equals(aNewValue) )
380 : : {
381 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "LabelSeparator" ), uno::makeAny( aNewValue ));
[ # # ][ # # ]
[ # # ][ # # ]
382 : 0 : bChanged = true;
383 : : }
384 : : }
385 [ # # ]: 0 : catch( const uno::Exception& e )
386 : : {
387 : : ASSERT_EXCEPTION( e );
388 : 0 : }
389 : : }
390 : 0 : break;
391 : :
392 : : case SCHATTR_DATADESCR_PLACEMENT:
393 : : {
394 : :
395 : : try
396 : : {
397 [ # # ]: 0 : sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
398 : 0 : sal_Int32 nOld =0;
399 [ # # ][ # # ]: 0 : if( !(GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nOld) )
[ # # ][ # # ]
[ # # ]
400 : : {
401 [ # # ]: 0 : if( m_aAvailableLabelPlacements.getLength() )
402 [ # # ]: 0 : nOld = m_aAvailableLabelPlacements[0];
403 : : }
404 [ # # ]: 0 : if( m_bOverwriteLabelsForAttributedDataPointsAlso )
405 : : {
406 [ # # ][ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
407 [ # # ][ # # ]: 0 : if( nOld!=nNew ||
[ # # ]
408 [ # # ][ # # ]: 0 : DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nOld ) ) )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
409 : : {
410 [ # # ][ # # ]: 0 : DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nNew ) );
[ # # ]
411 : 0 : bChanged = true;
412 : 0 : }
413 : : }
414 [ # # ]: 0 : else if( nOld!=nNew )
415 : : {
416 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "LabelPlacement" ), uno::makeAny( nNew ));
[ # # ][ # # ]
[ # # ][ # # ]
417 : 0 : bChanged = true;
418 : : }
419 : : }
420 [ # # ]: 0 : catch( const uno::Exception& e )
421 : : {
422 : : ASSERT_EXCEPTION( e );
423 : : }
424 : : }
425 : 0 : break;
426 : :
427 : : case SCHATTR_STYLE_SYMBOL:
428 : : {
429 : : sal_Int32 nStyle =
430 : : static_cast< const SfxInt32Item & >(
431 [ # # ]: 0 : rItemSet.Get( nWhichId )).GetValue();
432 [ # # ]: 0 : chart2::Symbol aSymbol;
433 : :
434 [ # # ][ # # ]: 0 : GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
[ # # ][ # # ]
[ # # ]
435 : 0 : sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
436 : :
437 [ # # ]: 0 : if( nStyle != nOldStyle )
438 : : {
439 : 0 : bool bDeleteSymbol = false;
440 [ # # # # : 0 : switch( nStyle )
# ]
441 : : {
442 : : case SVX_SYMBOLTYPE_NONE:
443 : 0 : aSymbol.Style = chart2::SymbolStyle_NONE;
444 : 0 : break;
445 : : case SVX_SYMBOLTYPE_AUTO:
446 : 0 : aSymbol.Style = chart2::SymbolStyle_AUTO;
447 : 0 : break;
448 : : case SVX_SYMBOLTYPE_BRUSHITEM:
449 : 0 : aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
450 : 0 : break;
451 : : case SVX_SYMBOLTYPE_UNKNOWN:
452 : 0 : bDeleteSymbol = true;
453 : 0 : break;
454 : :
455 : : default:
456 : 0 : aSymbol.Style = chart2::SymbolStyle_STANDARD;
457 : 0 : aSymbol.StandardSymbol = nStyle;
458 : : }
459 : :
460 [ # # ]: 0 : if( bDeleteSymbol )
461 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::Any());
[ # # ][ # # ]
462 : : else
463 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "Symbol" ),
464 [ # # ][ # # ]: 0 : uno::makeAny( aSymbol ));
[ # # ]
465 : 0 : bChanged = true;
466 [ # # ]: 0 : }
467 : : }
468 : 0 : break;
469 : :
470 : : case SCHATTR_SYMBOL_SIZE:
471 : : {
472 : : Size aSize = static_cast< const SvxSizeItem & >(
473 [ # # ]: 0 : rItemSet.Get( nWhichId )).GetSize();
474 [ # # ]: 0 : chart2::Symbol aSymbol;
475 : :
476 [ # # ][ # # ]: 0 : GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
[ # # ][ # # ]
[ # # ]
477 [ # # ]: 0 : if( aSize.getWidth() != aSymbol.Size.Width ||
[ # # # # ]
478 : 0 : aSize.getHeight() != aSymbol.Size.Height )
479 : : {
480 : 0 : aSymbol.Size.Width = aSize.getWidth();
481 : 0 : aSymbol.Size.Height = aSize.getHeight();
482 : :
483 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
[ # # ][ # # ]
[ # # ]
484 : 0 : bChanged = true;
485 [ # # ]: 0 : }
486 : : }
487 : 0 : break;
488 : :
489 : : case SCHATTR_SYMBOL_BRUSH:
490 : : {
491 : : const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
492 [ # # ]: 0 : rItemSet.Get( nWhichId )));
493 : 0 : uno::Any aXGraphicAny;
494 [ # # ]: 0 : const Graphic *pGraphic( rBrshItem.GetGraphic());
495 [ # # ]: 0 : if( pGraphic )
496 : : {
497 [ # # ]: 0 : uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
498 [ # # ]: 0 : if( xGraphic.is())
499 : : {
500 [ # # ]: 0 : aXGraphicAny <<= xGraphic;
501 [ # # ]: 0 : chart2::Symbol aSymbol;
502 [ # # ][ # # ]: 0 : GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
[ # # ][ # # ]
[ # # ]
503 [ # # ][ # # ]: 0 : if( aSymbol.Graphic != xGraphic )
504 : : {
505 [ # # ]: 0 : aSymbol.Graphic = xGraphic;
506 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
[ # # ][ # # ]
[ # # ]
507 : 0 : bChanged = true;
508 [ # # ]: 0 : }
509 : 0 : }
510 : 0 : }
511 : : }
512 : 0 : break;
513 : :
514 : : case SCHATTR_TEXT_DEGREES:
515 : : {
516 : : double fValue = static_cast< double >(
517 : : static_cast< const SfxInt32Item & >(
518 [ # # ]: 0 : rItemSet.Get( nWhichId )).GetValue()) / 100.0;
519 : 0 : double fOldValue = 0.0;
520 : : bool bPropExisted =
521 [ # # ][ # # ]: 0 : ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldValue );
[ # # ][ # # ]
522 : :
523 [ # # ][ # # ]: 0 : if( ! bPropExisted ||
[ # # ]
524 : : ( bPropExisted && fOldValue != fValue ))
525 : : {
526 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fValue ));
[ # # ][ # # ]
[ # # ]
527 : 0 : bChanged = true;
528 : : }
529 : : }
530 : 0 : break;
531 : : }
532 : :
533 : 0 : return bChanged;
534 : : }
535 : :
536 : 0 : void DataPointItemConverter::FillSpecialItem(
537 : : sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
538 : : throw( uno::Exception )
539 : : {
540 [ # # # # : 0 : switch( nWhichId )
# # # # #
# # # #
# ]
541 : : {
542 : : case SCHATTR_DATADESCR_SHOW_NUMBER:
543 : : case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
544 : : case SCHATTR_DATADESCR_SHOW_CATEGORY:
545 : : case SCHATTR_DATADESCR_SHOW_SYMBOL:
546 : : {
547 : 0 : chart2::DataPointLabel aLabel;
548 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U( "Label" )) >>= aLabel )
[ # # ][ # # ]
[ # # ][ # # ]
549 : : {
550 : : sal_Bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
551 : : (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
552 [ # # ][ # # ]: 0 : (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
[ # # ]
553 : :
554 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
[ # # ]
555 : :
556 [ # # ]: 0 : if( m_bOverwriteLabelsForAttributedDataPointsAlso )
557 : : {
558 [ # # # # ]: 0 : if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
559 [ # # ][ # # ]: 0 : Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), C2U( "Label" ), uno::makeAny(aLabel) ) )
[ # # ][ # # ]
560 : : {
561 [ # # ]: 0 : rOutItemSet.InvalidateItem(nWhichId);
562 : : }
563 : : }
564 : : }
565 : : }
566 : 0 : break;
567 : :
568 : : case SID_ATTR_NUMBERFORMAT_VALUE:
569 : : {
570 : 0 : sal_Int32 nKey = 0;
571 [ # # ][ # # ]: 0 : if( !(GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nKey) )
[ # # ][ # # ]
[ # # ]
572 : 0 : nKey = m_nNumberFormat;
573 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
[ # # ]
574 : : }
575 : 0 : break;
576 : :
577 : : case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
578 : : {
579 : 0 : sal_Int32 nKey = 0;
580 [ # # ][ # # ]: 0 : if( !(GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )) >>= nKey) )
[ # # ][ # # ]
[ # # ]
581 : 0 : nKey = m_nPercentNumberFormat;
582 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
[ # # ]
583 : : }
584 : 0 : break;
585 : :
586 : : case SID_ATTR_NUMBERFORMAT_SOURCE:
587 : : {
588 [ # # ][ # # ]: 0 : bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
[ # # ]
589 [ # # ]: 0 : rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
590 : : }
591 : 0 : break;
592 : : case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
593 : : {
594 [ # # ][ # # ]: 0 : bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )).hasValue());
[ # # ]
595 [ # # ]: 0 : rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
596 : : }
597 : 0 : break;
598 : :
599 : : case SCHATTR_DATADESCR_SEPARATOR:
600 : : {
601 : 0 : rtl::OUString aValue;
602 : : try
603 : : {
604 [ # # ][ # # ]: 0 : GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aValue;
[ # # ][ # # ]
605 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
[ # # ][ # # ]
[ # # ][ # # ]
606 : : }
607 [ # # ]: 0 : catch( const uno::Exception& e )
608 : : {
609 : : ASSERT_EXCEPTION( e );
610 : 0 : }
611 : : }
612 : 0 : break;
613 : :
614 : : case SCHATTR_DATADESCR_PLACEMENT:
615 : : {
616 : : try
617 : : {
618 : 0 : sal_Int32 nPlacement=0;
619 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nPlacement )
[ # # ][ # # ]
[ # # ]
620 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
[ # # ]
621 [ # # ]: 0 : else if( m_aAvailableLabelPlacements.getLength() )
622 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
[ # # ][ # # ]
623 : : }
624 : 0 : catch( const uno::Exception& e )
625 : : {
626 : : ASSERT_EXCEPTION( e );
627 : : }
628 : : }
629 : 0 : break;
630 : :
631 : : case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
632 : : {
633 [ # # ]: 0 : rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
634 : : }
635 : 0 : break;
636 : :
637 : : case SCHATTR_DATADESCR_NO_PERCENTVALUE:
638 : : {
639 [ # # ]: 0 : rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
640 : : }
641 : 0 : break;
642 : :
643 : : case SCHATTR_STYLE_SYMBOL:
644 : : {
645 [ # # ]: 0 : chart2::Symbol aSymbol;
646 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
[ # # ][ # # ]
[ # # ][ # # ]
647 [ # # ][ # # ]: 0 : rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
[ # # ][ # # ]
648 : : }
649 : 0 : break;
650 : :
651 : : case SCHATTR_SYMBOL_SIZE:
652 : : {
653 [ # # ]: 0 : chart2::Symbol aSymbol;
654 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
[ # # ][ # # ]
[ # # ][ # # ]
655 : : rOutItemSet.Put(
656 [ # # ][ # # ]: 0 : SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
[ # # ][ # # ]
657 : : }
658 : 0 : break;
659 : :
660 : : case SCHATTR_SYMBOL_BRUSH:
661 : : {
662 [ # # ]: 0 : chart2::Symbol aSymbol;
663 [ # # ][ # # ]: 0 : if(( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ]
664 : 0 : && aSymbol.Graphic.is() )
665 : : {
666 [ # # ][ # # ]: 0 : rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
[ # # ][ # # ]
[ # # ]
667 [ # # ]: 0 : }
668 : : }
669 : 0 : break;
670 : :
671 : : case SCHATTR_TEXT_DEGREES:
672 : : {
673 : 0 : double fValue = 0;
674 : :
675 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fValue )
[ # # ][ # # ]
[ # # ]
676 : : {
677 : : rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
678 [ # # ][ # # ]: 0 : ::rtl::math::round( fValue * 100.0 ) ) ));
[ # # ]
679 : : }
680 : : }
681 : 0 : break;
682 : : }
683 : 0 : }
684 : :
685 : : } // namespace wrapper
686 : : } // namespace chart
687 : :
688 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|