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_chart2.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 throw( uno::Exception )
314 {
315 bool bChanged = false;
316 uno::Any aValue;
317
318 switch( nWhichId )
319 {
320 case SCHATTR_DATADESCR_SHOW_NUMBER:
321 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
322 case SCHATTR_DATADESCR_SHOW_CATEGORY:
323 case SCHATTR_DATADESCR_SHOW_SYMBOL:
324 {
325 const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
326
327 uno::Any aOldValue( GetPropertySet()->getPropertyValue( C2U( "Label" ) ));
328 chart2::DataPointLabel aLabel;
329 if( aOldValue >>= aLabel )
330 {
331 sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
332 (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
333 (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
334 sal_Bool bOldValue = rValue;
335 rValue = static_cast< sal_Bool >( rItem.GetValue() );
336 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
337 {
338 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
339 if( bOldValue != rValue ||
340 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "Label" ), aOldValue ) )
341 {
342 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny( aLabel ) );
343 bChanged = true;
344 }
345 }
346 else if( bOldValue != rValue )
347 {
348 GetPropertySet()->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ));
349 bChanged = true;
350 }
351 }
352 }
353 break;
354
355 case SID_ATTR_NUMBERFORMAT_VALUE:
356 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
357 {
358 bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
359 }
360 break;
361
362 case SID_ATTR_NUMBERFORMAT_SOURCE:
363 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
364 {
365 bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
366 }
367 break;
368
369 case SCHATTR_DATADESCR_SEPARATOR:
370 {
371 rtl::OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
372 rtl::OUString aOldValue;
373 try
374 {
375 GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aOldValue;
376 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
377 {
378 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
379 if( !aOldValue.equals(aNewValue) ||
380 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aOldValue ) ) )
381 {
382 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aNewValue ) );
383 bChanged = true;
384 }
385 }
386 else if( !aOldValue.equals(aNewValue) )
387 {
388 GetPropertySet()->setPropertyValue( C2U( "LabelSeparator" ), uno::makeAny( aNewValue ));
389 bChanged = true;
390 }
391 }
392 catch( uno::Exception& e )
393 {
394 ASSERT_EXCEPTION( e );
395 }
396 }
397 break;
398
399 case SCHATTR_DATADESCR_PLACEMENT:
400 {
401
402 try
403 {
404 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
405 sal_Int32 nOld =0;
406 if( !(GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nOld) )
407 {
408 if( m_aAvailableLabelPlacements.getLength() )
409 nOld = m_aAvailableLabelPlacements[0];
410 }
411 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
412 {
413 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
414 if( nOld!=nNew ||
415 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nOld ) ) )
416 {
417 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nNew ) );
418 bChanged = true;
419 }
420 }
421 else if( nOld!=nNew )
422 {
423 GetPropertySet()->setPropertyValue( C2U( "LabelPlacement" ), uno::makeAny( nNew ));
424 bChanged = true;
425 }
426 }
427 catch( uno::Exception& e )
428 {
429 ASSERT_EXCEPTION( e );
430 }
431 }
432 break;
433
434 case SCHATTR_STYLE_SYMBOL:
435 {
436 sal_Int32 nStyle =
437 static_cast< const SfxInt32Item & >(
438 rItemSet.Get( nWhichId )).GetValue();
439 chart2::Symbol aSymbol;
440
441 GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
442 sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
443
444 if( nStyle != nOldStyle )
445 {
446 bool bDeleteSymbol = false;
447 switch( nStyle )
448 {
449 case SVX_SYMBOLTYPE_NONE:
450 aSymbol.Style = chart2::SymbolStyle_NONE;
451 break;
452 case SVX_SYMBOLTYPE_AUTO:
453 aSymbol.Style = chart2::SymbolStyle_AUTO;
454 break;
455 case SVX_SYMBOLTYPE_BRUSHITEM:
456 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
457 break;
458 case SVX_SYMBOLTYPE_UNKNOWN:
459 bDeleteSymbol = true;
460 break;
461
462 default:
463 aSymbol.Style = chart2::SymbolStyle_STANDARD;
464 aSymbol.StandardSymbol = nStyle;
465 }
466
467 if( bDeleteSymbol )
468 GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::Any());
469 else
470 GetPropertySet()->setPropertyValue( C2U( "Symbol" ),
471 uno::makeAny( aSymbol ));
472 bChanged = true;
473 }
474 }
475 break;
476
477 case SCHATTR_SYMBOL_SIZE:
478 {
479 Size aSize = static_cast< const SvxSizeItem & >(
480 rItemSet.Get( nWhichId )).GetSize();
481 chart2::Symbol aSymbol;
482
483 GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
484 if( aSize.getWidth() != aSymbol.Size.Width ||
485 aSize.getHeight() != aSymbol.Size.Height )
486 {
487 aSymbol.Size.Width = aSize.getWidth();
488 aSymbol.Size.Height = aSize.getHeight();
489
490 GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
491 bChanged = true;
492 }
493 }
494 break;
495
496 case SCHATTR_SYMBOL_BRUSH:
497 {
498 const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
499 rItemSet.Get( nWhichId )));
500 uno::Any aXGraphicAny;
501 const Graphic *pGraphic( rBrshItem.GetGraphic());
502 if( pGraphic )
503 {
504 uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
505 if( xGraphic.is())
506 {
507 aXGraphicAny <<= xGraphic;
508 chart2::Symbol aSymbol;
509 GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
510 if( aSymbol.Graphic != xGraphic )
511 {
512 aSymbol.Graphic = xGraphic;
513 GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
514 bChanged = true;
515 }
516 }
517 }
518 }
519 break;
520
521 case SCHATTR_TEXT_DEGREES:
522 {
523 double fValue = static_cast< double >(
524 static_cast< const SfxInt32Item & >(
525 rItemSet.Get( nWhichId )).GetValue()) / 100.0;
526 double fOldValue = 0.0;
527 bool bPropExisted =
528 ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldValue );
529
530 if( ! bPropExisted ||
531 ( bPropExisted && fOldValue != fValue ))
532 {
533 GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fValue ));
534 bChanged = true;
535 }
536 }
537 break;
538 }
539
540 return bChanged;
541 }
542
FillSpecialItem(sal_uInt16 nWhichId,SfxItemSet & rOutItemSet) const543 void DataPointItemConverter::FillSpecialItem(
544 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
545 throw( uno::Exception )
546 {
547 switch( nWhichId )
548 {
549 case SCHATTR_DATADESCR_SHOW_NUMBER:
550 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
551 case SCHATTR_DATADESCR_SHOW_CATEGORY:
552 case SCHATTR_DATADESCR_SHOW_SYMBOL:
553 {
554 chart2::DataPointLabel aLabel;
555 if( GetPropertySet()->getPropertyValue( C2U( "Label" )) >>= aLabel )
556 {
557 sal_Bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
558 (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
559 (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
560
561 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
562
563 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
564 {
565 if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
566 Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), C2U( "Label" ), uno::makeAny(aLabel) ) )
567 {
568 rOutItemSet.InvalidateItem(nWhichId);
569 }
570 }
571 }
572 }
573 break;
574
575 case SID_ATTR_NUMBERFORMAT_VALUE:
576 {
577 sal_Int32 nKey = 0;
578 if( !(GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nKey) )
579 nKey = m_nNumberFormat;
580 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
581 }
582 break;
583
584 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
585 {
586 sal_Int32 nKey = 0;
587 if( !(GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )) >>= nKey) )
588 nKey = m_nPercentNumberFormat;
589 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
590 }
591 break;
592
593 case SID_ATTR_NUMBERFORMAT_SOURCE:
594 {
595 bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
596 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
597 }
598 break;
599 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
600 {
601 bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )).hasValue());
602 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
603 }
604 break;
605
606 case SCHATTR_DATADESCR_SEPARATOR:
607 {
608 rtl::OUString aValue;
609 try
610 {
611 GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aValue;
612 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
613 }
614 catch( uno::Exception& e )
615 {
616 ASSERT_EXCEPTION( e );
617 }
618 }
619 break;
620
621 case SCHATTR_DATADESCR_PLACEMENT:
622 {
623 try
624 {
625 sal_Int32 nPlacement=0;
626 if( GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nPlacement )
627 rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
628 else if( m_aAvailableLabelPlacements.getLength() )
629 rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
630 }
631 catch( uno::Exception& e )
632 {
633 ASSERT_EXCEPTION( e );
634 }
635 }
636 break;
637
638 case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
639 {
640 SvULongs aList;
641 for ( sal_Int32 nN=0; nN<m_aAvailableLabelPlacements.getLength(); nN++ )
642 aList.Insert( m_aAvailableLabelPlacements[nN], sal::static_int_cast< sal_uInt16 >(nN) );
643 rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) );
644 }
645 break;
646
647 case SCHATTR_DATADESCR_NO_PERCENTVALUE:
648 {
649 rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
650 }
651 break;
652
653 case SCHATTR_STYLE_SYMBOL:
654 {
655 chart2::Symbol aSymbol;
656 if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
657 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
658 }
659 break;
660
661 case SCHATTR_SYMBOL_SIZE:
662 {
663 chart2::Symbol aSymbol;
664 if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
665 rOutItemSet.Put(
666 SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
667 }
668 break;
669
670 case SCHATTR_SYMBOL_BRUSH:
671 {
672 chart2::Symbol aSymbol;
673 if(( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
674 && aSymbol.Graphic.is() )
675 {
676 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
677 }
678 }
679 break;
680
681 case SCHATTR_TEXT_DEGREES:
682 {
683 double fValue = 0;
684
685 if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fValue )
686 {
687 rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
688 ::rtl::math::round( fValue * 100.0 ) ) ));
689 }
690 }
691 break;
692 }
693 }
694
695 } // namespace wrapper
696 } // namespace chart
697