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 "GraphicPropertyItemConverter.hxx"
27 #include "SchWhichPairs.hxx"
28 #include "macros.hxx"
29 #include "ItemPropertyMap.hxx"
30 #include "PropertyHelper.hxx"
31 #include "CommonConverters.hxx"
32 #include <editeng/memberids.hrc>
33 #include <svx/xflclit.hxx>
34 #include <svx/xlnclit.hxx>
35 #include <svx/xflbmtit.hxx>
36 #include <svx/xflbstit.hxx>
37 #include <svx/xbtmpit.hxx>
38 #include <svx/xflftrit.hxx>
39 #include <svx/xlndsit.hxx>
40 #include <svx/xflhtit.hxx>
41 #include <svx/xflgrit.hxx>
42 #include <svx/xfltrit.hxx>
43 #include <svx/xlntrit.hxx>
44 #include <editeng/eeitem.hxx>
45 // for SfxBoolItem
46 #include <svl/eitem.hxx>
47 // for XFillGradientStepCountItem
48 #include <svx/xgrscit.hxx>
49 #include <com/sun/star/beans/XPropertyState.hpp>
50 #include <com/sun/star/chart2/FillBitmap.hpp>
51 #include <com/sun/star/awt/Gradient.hpp>
52 #include <com/sun/star/container/XNameAccess.hpp>
53
54 using namespace ::com::sun::star;
55
56 namespace
57 {
lcl_GetDataPointFilledPropertyMap()58 ::comphelper::ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap()
59 {
60 static ::comphelper::ItemPropertyMapType aDataPointPropertyFilledMap(
61 ::comphelper::MakeItemPropertyMap
62 IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
63 IPM_MAP_ENTRY( XATTR_FILLCOLOR, "Color", 0 )
64 // IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "Transparency", 0 )
65 // IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "Gradient", 0 )
66 // IPM_MAP_ENTRY( XATTR_FILLHATCH, "Hatch", 0 )
67 IPM_MAP_ENTRY( XATTR_LINECOLOR, "BorderColor", 0 )
68 IPM_MAP_ENTRY( XATTR_LINESTYLE, "BorderStyle", 0 )
69 IPM_MAP_ENTRY( XATTR_LINEWIDTH, "BorderWidth", 0 )
70 // IPM_MAP_ENTRY( XATTR_LINEDASH, "BorderDash", 0 )
71 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "BorderTransparency", 0 )
72 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
73 IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
74 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
75 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
76 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
77 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
78 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
79 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
80 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
81 );
82
83 return aDataPointPropertyFilledMap;
84 }
lcl_GetDataPointLinePropertyMap()85 ::comphelper::ItemPropertyMapType & lcl_GetDataPointLinePropertyMap()
86 {
87 static ::comphelper::ItemPropertyMapType aDataPointPropertyLineMap(
88 ::comphelper::MakeItemPropertyMap
89 IPM_MAP_ENTRY( XATTR_LINECOLOR, "Color", 0 )
90 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "Transparency", 0 )
91 IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
92 IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
93 // IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
94 );
95
96 return aDataPointPropertyLineMap;
97 }
lcl_GetLinePropertyMap()98 ::comphelper::ItemPropertyMapType & lcl_GetLinePropertyMap()
99 {
100 static ::comphelper::ItemPropertyMapType aLinePropertyMap(
101 ::comphelper::MakeItemPropertyMap
102 IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
103 IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
104 // IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
105 IPM_MAP_ENTRY( XATTR_LINECOLOR, "LineColor", 0 )
106 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "LineTransparence", 0 )
107 IPM_MAP_ENTRY( XATTR_LINEJOINT, "LineJoint", 0 )
108 );
109
110 return aLinePropertyMap;
111 }
lcl_GetFillPropertyMap()112 ::comphelper::ItemPropertyMapType & lcl_GetFillPropertyMap()
113 {
114 static ::comphelper::ItemPropertyMapType aFillPropertyMap(
115 ::comphelper::MakeItemPropertyMap
116 IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
117 IPM_MAP_ENTRY( XATTR_FILLCOLOR, "FillColor", 0 )
118 // IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "FillTransparence", 0 )
119 // IPM_MAP_ENTRY( XATTR_FILLBITMAP, "FillBitmapName", MID_NAME )
120 // IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "FillGradient", 0 )
121 // IPM_MAP_ENTRY( XATTR_FILLHATCH, "FillHatch", 0 )
122 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
123 IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
124 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
125 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
126 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
127 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
128 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
129 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
130 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
131 );
132
133 return aFillPropertyMap;
134 }
135
lcl_supportsFillProperties(::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType)136 bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
137 {
138 return ( eType == ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ||
139 eType == ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES ||
140 eType == ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
141 }
142
lcl_supportsLineProperties(::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType)143 bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
144 {
145 return ( eType != ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES );
146 }
147
lcl_SetContentForNamedProperty(const uno::Reference<lang::XMultiServiceFactory> & xFactory,const::rtl::OUString & rTableName,NameOrIndex & rItem,sal_uInt8 nMemberId)148 bool lcl_SetContentForNamedProperty(
149 const uno::Reference< lang::XMultiServiceFactory > & xFactory,
150 const ::rtl::OUString & rTableName,
151 NameOrIndex & rItem, sal_uInt8 nMemberId )
152 {
153 bool bResult = false;
154 if( xFactory.is())
155 {
156 ::rtl::OUString aPropertyValue( rItem.GetName());
157 uno::Reference< container::XNameAccess > xNameAcc(
158 xFactory->createInstance( rTableName ),
159 uno::UNO_QUERY );
160 if( xNameAcc.is() &&
161 xNameAcc->hasByName( aPropertyValue ))
162 {
163 rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId );
164 bResult = true;
165 }
166 }
167 return bResult;
168 }
169
170 } // anonymous namespace
171
172 // ========================================
173
174 namespace chart
175 {
176 namespace wrapper
177 {
178
GraphicPropertyItemConverter(const uno::Reference<beans::XPropertySet> & rPropertySet,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> & xNamedPropertyContainerFactory,eGraphicObjectType eObjectType)179 GraphicPropertyItemConverter::GraphicPropertyItemConverter(
180 const uno::Reference<
181 beans::XPropertySet > & rPropertySet,
182 SfxItemPool& rItemPool,
183 SdrModel& rDrawModel,
184 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
185 eGraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) :
186 ItemConverter( rPropertySet, rItemPool ),
187 m_eGraphicObjectType( eObjectType ),
188 m_rDrawModel( rDrawModel ),
189 m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory )
190 {}
191
~GraphicPropertyItemConverter()192 GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
193 {}
194
GetWhichPairs() const195 const sal_uInt16 * GraphicPropertyItemConverter::GetWhichPairs() const
196 {
197 const sal_uInt16 * pResult = NULL;
198
199 switch( m_eGraphicObjectType )
200 {
201 case LINE_DATA_POINT:
202 case FILLED_DATA_POINT:
203 pResult = nRowWhichPairs; break;
204 case LINE_PROPERTIES:
205 pResult = nLinePropertyWhichPairs; break;
206 case FILL_PROPERTIES:
207 pResult = nFillPropertyWhichPairs; break;
208 case LINE_AND_FILL_PROPERTIES:
209 pResult = nLineAndFillPropertyWhichPairs; break;
210 }
211
212 return pResult;
213 }
214
GetItemProperty(tWhichIdType nWhichId,tPropertyNameWithMemberId & rOutProperty) const215 bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
216 {
217 ::comphelper::ItemPropertyMapType::const_iterator aEndIt;
218 ::comphelper::ItemPropertyMapType::const_iterator aIt;
219
220 switch( m_eGraphicObjectType )
221 {
222 case LINE_DATA_POINT:
223 aEndIt = lcl_GetDataPointLinePropertyMap().end();
224 aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId );
225 break;
226 case FILLED_DATA_POINT:
227 aEndIt = lcl_GetDataPointFilledPropertyMap().end();
228 aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId );
229 break;
230 case LINE_PROPERTIES:
231 aEndIt = lcl_GetLinePropertyMap().end();
232 aIt = lcl_GetLinePropertyMap().find( nWhichId );
233 break;
234
235 case FILL_PROPERTIES:
236 aEndIt = lcl_GetFillPropertyMap().end();
237 aIt = lcl_GetFillPropertyMap().find( nWhichId );
238 break;
239
240 case LINE_AND_FILL_PROPERTIES:
241 // line
242 aEndIt = lcl_GetLinePropertyMap().end();
243 aIt = lcl_GetLinePropertyMap().find( nWhichId );
244
245 // not found => try fill
246 if( aIt == aEndIt )
247 {
248 aEndIt = lcl_GetFillPropertyMap().end();
249 aIt = lcl_GetFillPropertyMap().find( nWhichId );
250 }
251 break;
252 }
253
254 if( aIt == aEndIt )
255 return false;
256
257 rOutProperty =(*aIt).second;
258 return true;
259 }
260
FillSpecialItem(sal_uInt16 nWhichId,SfxItemSet & rOutItemSet) const261 void GraphicPropertyItemConverter::FillSpecialItem(
262 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
263 {
264 // if( m_eGraphicObjectType == LINE_DATA_POINT ||
265 // m_eGraphicObjectType == LINE_PROPERTIES )
266 // return;
267
268 switch( nWhichId )
269 {
270 // bitmap property
271 case XATTR_FILLBMP_TILE:
272 case XATTR_FILLBMP_STRETCH:
273 {
274 drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT;
275 if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode )
276 {
277 rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT ));
278 rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH ));
279 }
280 }
281 break;
282
283 case XATTR_FILLFLOATTRANSPARENCE:
284 try
285 {
286 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
287 {
288 ::rtl::OUString aPropName =
289 (m_eGraphicObjectType == FILLED_DATA_POINT)
290 ? C2U( "TransparencyGradientName" )
291 : C2U( "FillTransparenceGradientName" );
292
293 uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ));
294 if( aValue.hasValue())
295 {
296 XFillFloatTransparenceItem aItem;
297 aItem.PutValue( aValue, MID_NAME );
298
299 lcl_SetContentForNamedProperty(
300 m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"),
301 aItem, MID_FILLGRADIENT );
302
303 // this is important to enable the item
304 ::rtl::OUString aName;
305 if( (aValue >>= aName) &&
306 !aName.isEmpty())
307 {
308 aItem.SetEnabled( sal_True );
309 rOutItemSet.Put( aItem );
310 }
311 }
312 }
313 }
314 catch( beans::UnknownPropertyException ex )
315 {
316 ASSERT_EXCEPTION( ex );
317 }
318 break;
319
320 case XATTR_GRADIENTSTEPCOUNT:
321 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
322 {
323 ::rtl::OUString aPropName =
324 (m_eGraphicObjectType == FILLED_DATA_POINT)
325 ? C2U( "GradientStepCount" )
326 : C2U( "FillGradientStepCount" );
327
328 sal_Int16 nStepCount = 0;
329 uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) );
330 if( hasLongOrShortValue(aValue) )
331 {
332 nStepCount = getShortForLongAlso(aValue);
333 rOutItemSet.Put( XGradientStepCountItem( nStepCount ));
334 }
335 }
336 break;
337
338 case XATTR_LINEDASH:
339 if( lcl_supportsLineProperties( m_eGraphicObjectType ))
340 {
341 ::rtl::OUString aPropName =
342 (m_eGraphicObjectType == FILLED_DATA_POINT)
343 ? C2U( "BorderDashName" )
344 : C2U( "LineDashName" );
345
346 XLineDashItem aItem;
347 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
348
349 lcl_SetContentForNamedProperty(
350 m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"),
351 aItem, MID_LINEDASH );
352
353 // translate model name to UI-name for predefined entries, so
354 // that the correct entry is chosen in the list of UI-names
355 XLineDashItem * pItemToPut = & aItem;
356 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
357
358 rOutItemSet.Put( * pItemToPut );
359 }
360 break;
361
362 case XATTR_FILLGRADIENT:
363 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
364 {
365 ::rtl::OUString aPropName =
366 (m_eGraphicObjectType == FILLED_DATA_POINT)
367 ? C2U( "GradientName" )
368 : C2U( "FillGradientName" );
369
370 XFillGradientItem aItem;
371 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
372
373 lcl_SetContentForNamedProperty(
374 m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"),
375 aItem, MID_FILLGRADIENT );
376
377 // translate model name to UI-name for predefined entries, so
378 // that the correct entry is chosen in the list of UI-names
379 XFillGradientItem * pItemToPut = & aItem;
380 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
381
382 rOutItemSet.Put( * pItemToPut );
383 }
384 break;
385
386 case XATTR_FILLHATCH:
387 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
388 {
389 ::rtl::OUString aPropName =
390 (m_eGraphicObjectType == FILLED_DATA_POINT)
391 ? C2U( "HatchName" )
392 : C2U( "FillHatchName" );
393
394 XFillHatchItem aItem;
395 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
396
397 lcl_SetContentForNamedProperty(
398 m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"),
399 aItem, MID_FILLHATCH );
400
401 // translate model name to UI-name for predefined entries, so
402 // that the correct entry is chosen in the list of UI-names
403 XFillHatchItem * pItemToPut = & aItem;
404 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
405
406 rOutItemSet.Put( * pItemToPut );
407 }
408 break;
409
410 case XATTR_FILLBITMAP:
411 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
412 {
413 XFillBitmapItem aItem;
414 aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME );
415
416 lcl_SetContentForNamedProperty(
417 m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"),
418 aItem, MID_GRAFURL );
419
420 // translate model name to UI-name for predefined entries, so
421 // that the correct entry is chosen in the list of UI-names
422 XFillBitmapItem * pItemToPut = & aItem;
423 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
424
425 rOutItemSet.Put( * pItemToPut );
426 }
427 break;
428
429 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
430 // instead of sal_Int16
431 case XATTR_LINETRANSPARENCE:
432 if( lcl_supportsLineProperties( m_eGraphicObjectType ))
433 {
434 ::rtl::OUString aPropName =
435 (m_eGraphicObjectType == FILLED_DATA_POINT)
436 ? C2U( "BorderTransparency" )
437 : (m_eGraphicObjectType == LINE_DATA_POINT)
438 ? C2U( "Transparency" )
439 : C2U( "LineTransparence" );
440
441 XLineTransparenceItem aItem;
442 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
443
444 rOutItemSet.Put( aItem );
445 }
446 break;
447
448 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
449 // instead of sal_Int16
450 case XATTR_FILLTRANSPARENCE:
451 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
452 {
453 ::rtl::OUString aPropName =
454 (m_eGraphicObjectType == FILLED_DATA_POINT)
455 ? C2U( "Transparency" )
456 : C2U( "FillTransparence" );
457
458 XFillTransparenceItem aItem;
459 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
460
461 rOutItemSet.Put( aItem );
462 }
463 break;
464 }
465 }
466
ApplySpecialItem(sal_uInt16 nWhichId,const SfxItemSet & rItemSet)467 bool GraphicPropertyItemConverter::ApplySpecialItem(
468 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
469 {
470 bool bChanged = false;
471 uno::Any aValue;
472
473 switch( nWhichId )
474 {
475 // bitmap property
476 case XATTR_FILLBMP_STRETCH:
477 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
478 {
479 const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
480 bool bStretched = static_cast< const XFillBmpStretchItem & >(
481 rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue();
482 drawing::BitmapMode aMode =
483 (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT);
484
485 aValue <<= aMode;
486 if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
487 {
488 GetPropertySet()->setPropertyValue( aModePropName, aValue );
489 bChanged = true;
490 }
491 }
492 break;
493
494 case XATTR_FILLBMP_TILE:
495 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
496 {
497 const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
498 bool bTiled = static_cast< const XFillBmpTileItem & >(
499 rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue();
500 drawing::BitmapMode aMode =
501 (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT);
502
503 aValue <<= aMode;
504 if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
505 {
506 GetPropertySet()->setPropertyValue( aModePropName, aValue );
507 bChanged = true;
508 }
509 }
510 break;
511
512 case XATTR_FILLFLOATTRANSPARENCE:
513 try
514 {
515 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
516 {
517 ::rtl::OUString aPropName =
518 (m_eGraphicObjectType == FILLED_DATA_POINT)
519 ? C2U( "TransparencyGradientName" )
520 : C2U( "FillTransparenceGradientName" );
521
522 const XFillFloatTransparenceItem & rItem =
523 static_cast< const XFillFloatTransparenceItem & >(
524 rItemSet.Get( nWhichId ));
525
526 if( rItem.IsEnabled() &&
527 rItem.QueryValue( aValue, MID_NAME ))
528 {
529 uno::Any aGradient;
530 rItem.QueryValue( aGradient, MID_FILLGRADIENT );
531
532 // add TransparencyGradient to list if it does not already exist
533 ::rtl::OUString aPreferredName;
534 aValue >>= aPreferredName;
535 aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
536 aGradient, m_xNamedPropertyTableFactory, aPreferredName );
537
538 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
539 {
540 GetPropertySet()->setPropertyValue( aPropName, aValue );
541 bChanged = true;
542 }
543 }
544 else
545 {
546 ::rtl::OUString aName;
547 if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName )
548 && !aName.isEmpty() )
549 {
550 uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY );
551 if( xState.is())
552 xState->setPropertyToDefault( aPropName );
553 bChanged = true;
554 }
555 }
556 }
557 }
558 catch( beans::UnknownPropertyException ex )
559 {
560 ASSERT_EXCEPTION( ex );
561 }
562 break;
563
564 case XATTR_GRADIENTSTEPCOUNT:
565 {
566 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
567 {
568 ::rtl::OUString aPropName =
569 (m_eGraphicObjectType == FILLED_DATA_POINT)
570 ? C2U( "GradientStepCount" )
571 : C2U( "FillGradientStepCount" );
572
573 sal_Int16 nStepCount = ( static_cast< const XGradientStepCountItem & >(
574 rItemSet.Get( nWhichId ))).GetValue();
575
576 aValue <<= nStepCount;
577 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
578 {
579 GetPropertySet()->setPropertyValue( aPropName, aValue );
580 bChanged = true;
581 }
582 }
583 }
584 break;
585
586 case XATTR_LINEDASH:
587 {
588 if( lcl_supportsLineProperties( m_eGraphicObjectType ))
589 {
590
591 ::rtl::OUString aPropName =
592 (m_eGraphicObjectType == FILLED_DATA_POINT)
593 ? C2U( "BorderDashName" )
594 : C2U( "LineDashName" );
595
596 const XLineDashItem & rItem =
597 static_cast< const XLineDashItem & >(
598 rItemSet.Get( nWhichId ));
599
600 if( rItem.QueryValue( aValue, MID_NAME ))
601 {
602 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
603 {
604 // add LineDash to list
605 uno::Any aLineDash;
606 rItem.QueryValue( aLineDash, MID_LINEDASH );
607 ::rtl::OUString aPreferredName;
608 aValue >>= aPreferredName;
609 aValue <<= PropertyHelper::addLineDashUniqueNameToTable(
610 aLineDash, m_xNamedPropertyTableFactory, aPreferredName );
611
612 GetPropertySet()->setPropertyValue( aPropName, aValue );
613 bChanged = true;
614 }
615 }
616 }
617 }
618 break;
619
620 case XATTR_FILLGRADIENT:
621 {
622 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
623 {
624 ::rtl::OUString aPropName =
625 (m_eGraphicObjectType == FILLED_DATA_POINT)
626 ? C2U( "GradientName" )
627 : C2U( "FillGradientName" );
628
629 const XFillGradientItem & rItem =
630 static_cast< const XFillGradientItem & >(
631 rItemSet.Get( nWhichId ));
632
633 if( rItem.QueryValue( aValue, MID_NAME ))
634 {
635 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
636 {
637 // add Gradient to list
638 uno::Any aGradient;
639 rItem.QueryValue( aGradient, MID_FILLGRADIENT );
640 ::rtl::OUString aPreferredName;
641 aValue >>= aPreferredName;
642 aValue <<= PropertyHelper::addGradientUniqueNameToTable(
643 aGradient, m_xNamedPropertyTableFactory, aPreferredName );
644
645 GetPropertySet()->setPropertyValue( aPropName, aValue );
646 bChanged = true;
647 }
648 }
649 }
650 }
651 break;
652
653 case XATTR_FILLHATCH:
654 {
655 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
656 {
657 ::rtl::OUString aPropName =
658 (m_eGraphicObjectType == FILLED_DATA_POINT)
659 ? C2U( "HatchName" )
660 : C2U( "FillHatchName" );
661
662 const XFillHatchItem & rItem =
663 static_cast< const XFillHatchItem & >(
664 rItemSet.Get( nWhichId ));
665
666 if( rItem.QueryValue( aValue, MID_NAME ))
667 {
668 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
669 {
670 // add Hatch to list
671 uno::Any aHatch;
672 rItem.QueryValue( aHatch, MID_FILLHATCH );
673 ::rtl::OUString aPreferredName;
674 aValue >>= aPreferredName;
675 aValue <<= PropertyHelper::addHatchUniqueNameToTable(
676 aHatch, m_xNamedPropertyTableFactory, aPreferredName );
677
678 GetPropertySet()->setPropertyValue( aPropName, aValue );
679 bChanged = true;
680 }
681 }
682 }
683 }
684 break;
685
686 case XATTR_FILLBITMAP:
687 {
688 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
689 {
690 const XFillBitmapItem & rItem =
691 static_cast< const XFillBitmapItem & >(
692 rItemSet.Get( nWhichId ));
693
694 if( rItem.QueryValue( aValue, MID_NAME ))
695 {
696 if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
697 {
698 // add Bitmap to list
699 uno::Any aBitmap;
700 rItem.QueryValue( aBitmap, MID_GRAFURL );
701 ::rtl::OUString aPreferredName;
702 aValue >>= aPreferredName;
703 aValue <<= PropertyHelper::addBitmapUniqueNameToTable(
704 aBitmap, m_xNamedPropertyTableFactory, aPreferredName );
705
706 GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue );
707 bChanged = true;
708 }
709 }
710 }
711 }
712 break;
713
714 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
715 // instead of sal_Int16
716 case XATTR_LINETRANSPARENCE:
717 if( lcl_supportsLineProperties( m_eGraphicObjectType ))
718 {
719 ::rtl::OUString aPropName =
720 (m_eGraphicObjectType == FILLED_DATA_POINT)
721 ? C2U( "BorderTransparency" )
722 : (m_eGraphicObjectType == LINE_DATA_POINT)
723 ? C2U( "Transparency" )
724 : C2U( "LineTransparence" );
725
726 const XLineTransparenceItem & rItem =
727 static_cast< const XLineTransparenceItem & >(
728 rItemSet.Get( nWhichId ));
729
730 if( rItem.QueryValue( aValue ))
731 {
732 OSL_ENSURE( ! aValue.isExtractableTo(
733 ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
734 "TransparenceItem QueryValue bug is fixed. Remove hack." );
735 sal_Int32 nValue = 0;
736 if( aValue >>= nValue )
737 {
738 OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
739 sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
740 aValue <<= nValueToSet;
741
742 GetPropertySet()->setPropertyValue( aPropName, aValue );
743 bChanged = true;
744 }
745 else
746 {
747 OSL_ENSURE( false, "Wrong type in Transparency Any" );
748 }
749 }
750 }
751 break;
752
753 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
754 // instead of sal_Int16
755 case XATTR_FILLTRANSPARENCE:
756 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
757 {
758 ::rtl::OUString aPropName =
759 (m_eGraphicObjectType == FILLED_DATA_POINT)
760 ? C2U( "Transparency" )
761 : C2U( "FillTransparence" );
762
763 const XFillTransparenceItem & rItem =
764 static_cast< const XFillTransparenceItem & >(
765 rItemSet.Get( nWhichId ));
766
767 if( rItem.QueryValue( aValue ))
768 {
769 OSL_ENSURE( ! aValue.isExtractableTo(
770 ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
771 "TransparenceItem QueryValue bug is fixed. Remove hack." );
772 sal_Int32 nValue = 0;
773 if( aValue >>= nValue )
774 {
775 OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
776 sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
777 aValue <<= nValueToSet;
778
779 GetPropertySet()->setPropertyValue( aPropName, aValue );
780 // if linear or no transparence is set, delete the gradient
781 ::rtl::OUString aTransGradPropName =
782 (m_eGraphicObjectType == FILLED_DATA_POINT)
783 ? C2U( "TransparencyGradientName" )
784 : C2U( "FillTransparenceGradientName" );
785 GetPropertySet()->setPropertyValue(
786 aTransGradPropName, uno::makeAny( ::rtl::OUString() ));
787
788 bChanged = true;
789 }
790 else
791 {
792 OSL_ENSURE( false, "Wrong type in Transparency Any" );
793 }
794 }
795 }
796 break;
797 }
798
799 return bChanged;
800 }
801
802 } // namespace wrapper
803 } // namespace chart
804