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