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