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