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 "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     throw( uno::Exception )
264 {
265 //     if( m_eGraphicObjectType == LINE_DATA_POINT ||
266 //         m_eGraphicObjectType == LINE_PROPERTIES )
267 //         return;
268 
269     switch( nWhichId )
270     {
271         // bitmap property
272         case XATTR_FILLBMP_TILE:
273         case XATTR_FILLBMP_STRETCH:
274         {
275             drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT;
276             if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode )
277             {
278                 rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT ));
279                 rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH ));
280             }
281         }
282         break;
283 
284         case XATTR_FILLFLOATTRANSPARENCE:
285             try
286             {
287                 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
288                 {
289                     ::rtl::OUString aPropName =
290                           (m_eGraphicObjectType == FILLED_DATA_POINT)
291                           ? C2U( "TransparencyGradientName" )
292                           : C2U( "FillTransparenceGradientName" );
293 
294                     uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ));
295                     if( aValue.hasValue())
296                     {
297                         XFillFloatTransparenceItem aItem;
298                         aItem.PutValue( aValue, MID_NAME );
299 
300                         lcl_SetContentForNamedProperty(
301                             m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"),
302                             aItem, MID_FILLGRADIENT );
303 
304                         // this is important to enable the item
305                         ::rtl::OUString aName;
306                         if( (aValue >>= aName) &&
307                             !aName.isEmpty())
308                         {
309                             aItem.SetEnabled( sal_True );
310                             rOutItemSet.Put( aItem );
311                         }
312                     }
313                 }
314             }
315             catch( beans::UnknownPropertyException ex )
316             {
317                 ASSERT_EXCEPTION( ex );
318             }
319         break;
320 
321         case XATTR_GRADIENTSTEPCOUNT:
322             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
323             {
324                 ::rtl::OUString aPropName =
325                     (m_eGraphicObjectType == FILLED_DATA_POINT)
326                     ? C2U( "GradientStepCount" )
327                     : C2U( "FillGradientStepCount" );
328 
329                 sal_Int16 nStepCount = 0;
330                 uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) );
331                 if( hasLongOrShortValue(aValue) )
332                 {
333                     nStepCount = getShortForLongAlso(aValue);
334                     rOutItemSet.Put( XGradientStepCountItem( nStepCount ));
335                 }
336             }
337         break;
338 
339         case XATTR_LINEDASH:
340             if( lcl_supportsLineProperties( m_eGraphicObjectType ))
341             {
342                 ::rtl::OUString aPropName =
343                     (m_eGraphicObjectType == FILLED_DATA_POINT)
344                     ? C2U( "BorderDashName" )
345                     : C2U( "LineDashName" );
346 
347                 XLineDashItem aItem;
348                 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
349 
350                 lcl_SetContentForNamedProperty(
351                     m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"),
352                     aItem, MID_LINEDASH );
353 
354                 // translate model name to UI-name for predefined entries, so
355                 // that the correct entry is chosen in the list of UI-names
356                 XLineDashItem * pItemToPut = & aItem;
357                 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
358 
359                 rOutItemSet.Put( * pItemToPut );
360             }
361         break;
362 
363         case XATTR_FILLGRADIENT:
364             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
365             {
366                 ::rtl::OUString aPropName =
367                     (m_eGraphicObjectType == FILLED_DATA_POINT)
368                     ? C2U( "GradientName" )
369                     : C2U( "FillGradientName" );
370 
371                 XFillGradientItem aItem;
372                 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
373 
374                 lcl_SetContentForNamedProperty(
375                     m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"),
376                     aItem, MID_FILLGRADIENT );
377 
378                 // translate model name to UI-name for predefined entries, so
379                 // that the correct entry is chosen in the list of UI-names
380                 XFillGradientItem * pItemToPut = & aItem;
381                 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
382 
383                 rOutItemSet.Put( * pItemToPut );
384             }
385         break;
386 
387         case XATTR_FILLHATCH:
388             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
389             {
390                 ::rtl::OUString aPropName =
391                     (m_eGraphicObjectType == FILLED_DATA_POINT)
392                     ? C2U( "HatchName" )
393                     : C2U( "FillHatchName" );
394 
395                 XFillHatchItem aItem;
396                 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
397 
398                 lcl_SetContentForNamedProperty(
399                     m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"),
400                     aItem, MID_FILLHATCH );
401 
402                 // translate model name to UI-name for predefined entries, so
403                 // that the correct entry is chosen in the list of UI-names
404                 XFillHatchItem * pItemToPut = & aItem;
405                 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
406 
407                 rOutItemSet.Put( * pItemToPut );
408             }
409         break;
410 
411         case XATTR_FILLBITMAP:
412             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
413             {
414                 XFillBitmapItem aItem;
415                 aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME );
416 
417                 lcl_SetContentForNamedProperty(
418                     m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"),
419                     aItem, MID_GRAFURL );
420 
421                 // translate model name to UI-name for predefined entries, so
422                 // that the correct entry is chosen in the list of UI-names
423                 XFillBitmapItem * pItemToPut = & aItem;
424                 pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
425 
426                 rOutItemSet.Put( * pItemToPut );
427             }
428         break;
429 
430         // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
431         // instead of sal_Int16
432         case XATTR_LINETRANSPARENCE:
433             if( lcl_supportsLineProperties( m_eGraphicObjectType ))
434             {
435                 ::rtl::OUString aPropName =
436                       (m_eGraphicObjectType == FILLED_DATA_POINT)
437                       ? C2U( "BorderTransparency" )
438                       : (m_eGraphicObjectType == LINE_DATA_POINT)
439                       ? C2U( "Transparency" )
440                       : C2U( "LineTransparence" );
441 
442                 XLineTransparenceItem aItem;
443                 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
444 
445                 rOutItemSet.Put( aItem );
446             }
447             break;
448 
449         // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
450         // instead of sal_Int16
451         case XATTR_FILLTRANSPARENCE:
452             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
453             {
454                 ::rtl::OUString aPropName =
455                       (m_eGraphicObjectType == FILLED_DATA_POINT)
456                       ? C2U( "Transparency" )
457                       : C2U( "FillTransparence" );
458 
459                 XFillTransparenceItem aItem;
460                 aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
461 
462                 rOutItemSet.Put( aItem );
463             }
464             break;
465     }
466 }
467 
ApplySpecialItem(sal_uInt16 nWhichId,const SfxItemSet & rItemSet)468 bool GraphicPropertyItemConverter::ApplySpecialItem(
469     sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
470     throw( uno::Exception )
471 {
472     bool bChanged = false;
473     uno::Any aValue;
474 
475     switch( nWhichId )
476     {
477         // bitmap property
478         case XATTR_FILLBMP_STRETCH:
479             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
480             {
481                 const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
482                 bool bStretched = static_cast< const XFillBmpStretchItem & >(
483                     rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue();
484                 drawing::BitmapMode aMode =
485                     (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT);
486 
487                 aValue <<= aMode;
488                 if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
489                 {
490                     GetPropertySet()->setPropertyValue( aModePropName, aValue );
491                     bChanged = true;
492                 }
493             }
494             break;
495 
496         case XATTR_FILLBMP_TILE:
497             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
498             {
499                 const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
500                 bool bTiled = static_cast< const XFillBmpTileItem & >(
501                     rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue();
502                 drawing::BitmapMode aMode =
503                     (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT);
504 
505                 aValue <<= aMode;
506                 if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
507                 {
508                     GetPropertySet()->setPropertyValue( aModePropName, aValue );
509                     bChanged = true;
510                 }
511             }
512             break;
513 
514         case XATTR_FILLFLOATTRANSPARENCE:
515             try
516             {
517                 if( lcl_supportsFillProperties( m_eGraphicObjectType ))
518                 {
519                     ::rtl::OUString aPropName =
520                           (m_eGraphicObjectType == FILLED_DATA_POINT)
521                           ? C2U( "TransparencyGradientName" )
522                           : C2U( "FillTransparenceGradientName" );
523 
524                     const XFillFloatTransparenceItem & rItem =
525                         static_cast< const XFillFloatTransparenceItem & >(
526                             rItemSet.Get( nWhichId ));
527 
528                     if( rItem.IsEnabled() &&
529                         rItem.QueryValue( aValue, MID_NAME ))
530                     {
531                         uno::Any aGradient;
532                         rItem.QueryValue( aGradient, MID_FILLGRADIENT );
533 
534                         // add TransparencyGradient to list if it does not already exist
535                         ::rtl::OUString aPreferredName;
536                         aValue >>= aPreferredName;
537                         aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
538                             aGradient, m_xNamedPropertyTableFactory, aPreferredName );
539 
540                         if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
541                         {
542                             GetPropertySet()->setPropertyValue( aPropName, aValue );
543                             bChanged = true;
544                         }
545                     }
546                     else
547                     {
548                         ::rtl::OUString aName;
549                         if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName )
550                             && !aName.isEmpty() )
551                         {
552                             uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY );
553                             if( xState.is())
554                                 xState->setPropertyToDefault( aPropName );
555                             bChanged = true;
556                         }
557                     }
558                 }
559             }
560             catch( beans::UnknownPropertyException ex )
561             {
562                 ASSERT_EXCEPTION( ex );
563             }
564         break;
565 
566         case XATTR_GRADIENTSTEPCOUNT:
567         {
568             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
569             {
570                 ::rtl::OUString aPropName =
571                     (m_eGraphicObjectType == FILLED_DATA_POINT)
572                     ? C2U( "GradientStepCount" )
573                     : C2U( "FillGradientStepCount" );
574 
575                 sal_Int16 nStepCount = ( static_cast< const XGradientStepCountItem & >(
576                             rItemSet.Get( nWhichId ))).GetValue();
577 
578                 aValue <<= nStepCount;
579                 if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
580                 {
581                     GetPropertySet()->setPropertyValue( aPropName, aValue );
582                     bChanged = true;
583                 }
584             }
585         }
586         break;
587 
588         case XATTR_LINEDASH:
589         {
590             if( lcl_supportsLineProperties( m_eGraphicObjectType ))
591             {
592 
593                 ::rtl::OUString aPropName =
594                     (m_eGraphicObjectType == FILLED_DATA_POINT)
595                     ? C2U( "BorderDashName" )
596                     : C2U( "LineDashName" );
597 
598                 const XLineDashItem & rItem =
599                     static_cast< const XLineDashItem & >(
600                         rItemSet.Get( nWhichId ));
601 
602                 if( rItem.QueryValue( aValue, MID_NAME ))
603                 {
604                     if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
605                     {
606                         // add LineDash to list
607                         uno::Any aLineDash;
608                         rItem.QueryValue( aLineDash, MID_LINEDASH );
609                         ::rtl::OUString aPreferredName;
610                         aValue >>= aPreferredName;
611                         aValue <<= PropertyHelper::addLineDashUniqueNameToTable(
612                             aLineDash, m_xNamedPropertyTableFactory, aPreferredName );
613 
614                         GetPropertySet()->setPropertyValue( aPropName, aValue );
615                         bChanged = true;
616                     }
617                 }
618             }
619         }
620         break;
621 
622         case XATTR_FILLGRADIENT:
623         {
624             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
625             {
626                 ::rtl::OUString aPropName =
627                     (m_eGraphicObjectType == FILLED_DATA_POINT)
628                     ? C2U( "GradientName" )
629                     : C2U( "FillGradientName" );
630 
631                 const XFillGradientItem & rItem =
632                     static_cast< const XFillGradientItem & >(
633                         rItemSet.Get( nWhichId ));
634 
635                 if( rItem.QueryValue( aValue, MID_NAME ))
636                 {
637                     if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
638                     {
639                         // add Gradient to list
640                         uno::Any aGradient;
641                         rItem.QueryValue( aGradient, MID_FILLGRADIENT );
642                         ::rtl::OUString aPreferredName;
643                         aValue >>= aPreferredName;
644                         aValue <<= PropertyHelper::addGradientUniqueNameToTable(
645                             aGradient, m_xNamedPropertyTableFactory, aPreferredName );
646 
647                         GetPropertySet()->setPropertyValue( aPropName, aValue );
648                         bChanged = true;
649                     }
650                 }
651             }
652         }
653         break;
654 
655         case XATTR_FILLHATCH:
656         {
657             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
658             {
659                 ::rtl::OUString aPropName =
660                     (m_eGraphicObjectType == FILLED_DATA_POINT)
661                     ? C2U( "HatchName" )
662                     : C2U( "FillHatchName" );
663 
664                 const XFillHatchItem & rItem =
665                     static_cast< const XFillHatchItem & >(
666                         rItemSet.Get( nWhichId ));
667 
668                 if( rItem.QueryValue( aValue, MID_NAME ))
669                 {
670                     if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
671                     {
672                         // add Hatch to list
673                         uno::Any aHatch;
674                         rItem.QueryValue( aHatch, MID_FILLHATCH );
675                         ::rtl::OUString aPreferredName;
676                         aValue >>= aPreferredName;
677                         aValue <<= PropertyHelper::addHatchUniqueNameToTable(
678                             aHatch, m_xNamedPropertyTableFactory, aPreferredName );
679 
680                         GetPropertySet()->setPropertyValue( aPropName, aValue );
681                         bChanged = true;
682                     }
683                 }
684             }
685         }
686         break;
687 
688         case XATTR_FILLBITMAP:
689         {
690             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
691             {
692                 const XFillBitmapItem & rItem =
693                     static_cast< const XFillBitmapItem & >(
694                         rItemSet.Get( nWhichId ));
695 
696                 if( rItem.QueryValue( aValue, MID_NAME ))
697                 {
698                     if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
699                     {
700                         // add Bitmap to list
701                         uno::Any aBitmap;
702                         rItem.QueryValue( aBitmap, MID_GRAFURL );
703                         ::rtl::OUString aPreferredName;
704                         aValue >>= aPreferredName;
705                         aValue <<= PropertyHelper::addBitmapUniqueNameToTable(
706                             aBitmap, m_xNamedPropertyTableFactory, aPreferredName );
707 
708                         GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue );
709                         bChanged = true;
710                     }
711                 }
712             }
713         }
714         break;
715 
716         // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
717         // instead of sal_Int16
718         case XATTR_LINETRANSPARENCE:
719             if( lcl_supportsLineProperties( m_eGraphicObjectType ))
720             {
721                 ::rtl::OUString aPropName =
722                       (m_eGraphicObjectType == FILLED_DATA_POINT)
723                       ? C2U( "BorderTransparency" )
724                       : (m_eGraphicObjectType == LINE_DATA_POINT)
725                       ? C2U( "Transparency" )
726                       : C2U( "LineTransparence" );
727 
728                 const XLineTransparenceItem & rItem =
729                     static_cast< const XLineTransparenceItem & >(
730                         rItemSet.Get( nWhichId ));
731 
732                 if( rItem.QueryValue( aValue ))
733                 {
734                     OSL_ENSURE( ! aValue.isExtractableTo(
735                                     ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
736                                 "TransparenceItem QueryValue bug is fixed. Remove hack." );
737                     sal_Int32 nValue = 0;
738                     if( aValue >>= nValue )
739                     {
740                         OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
741                         sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
742                         aValue <<= nValueToSet;
743 
744                         GetPropertySet()->setPropertyValue( aPropName, aValue );
745                         bChanged = true;
746                     }
747                     else
748                     {
749                         OSL_ENSURE( false, "Wrong type in Transparency Any" );
750                     }
751                 }
752             }
753             break;
754 
755         // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
756         // instead of sal_Int16
757         case XATTR_FILLTRANSPARENCE:
758             if( lcl_supportsFillProperties( m_eGraphicObjectType ))
759             {
760                 ::rtl::OUString aPropName =
761                       (m_eGraphicObjectType == FILLED_DATA_POINT)
762                       ? C2U( "Transparency" )
763                       : C2U( "FillTransparence" );
764 
765                 const XFillTransparenceItem & rItem =
766                     static_cast< const XFillTransparenceItem & >(
767                         rItemSet.Get( nWhichId ));
768 
769                 if( rItem.QueryValue( aValue ))
770                 {
771                     OSL_ENSURE( ! aValue.isExtractableTo(
772                                     ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
773                                 "TransparenceItem QueryValue bug is fixed. Remove hack." );
774                     sal_Int32 nValue = 0;
775                     if( aValue >>= nValue )
776                     {
777                         OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
778                         sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
779                         aValue <<= nValueToSet;
780 
781                         GetPropertySet()->setPropertyValue( aPropName, aValue );
782                         // if linear or no transparence is set, delete the gradient
783                         ::rtl::OUString aTransGradPropName =
784                               (m_eGraphicObjectType == FILLED_DATA_POINT)
785                               ? C2U( "TransparencyGradientName" )
786                               : C2U( "FillTransparenceGradientName" );
787                         GetPropertySet()->setPropertyValue(
788                             aTransGradPropName, uno::makeAny( ::rtl::OUString() ));
789 
790                         bChanged = true;
791                     }
792                     else
793                     {
794                         OSL_ENSURE( false, "Wrong type in Transparency Any" );
795                     }
796                 }
797             }
798             break;
799     }
800 
801     return bChanged;
802 }
803 
804 } //  namespace wrapper
805 } //  namespace chart
806