1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "GraphicPropertyItemConverter.hxx"
21 #include "SchWhichPairs.hxx"
23 #include "ItemPropertyMap.hxx"
24 #include "PropertyHelper.hxx"
25 #include "CommonConverters.hxx"
26 #include <editeng/memberids.hrc>
27 #include <svx/xflclit.hxx>
28 #include <svx/xlnclit.hxx>
29 #include <svx/xflbmtit.hxx>
30 #include <svx/xflbstit.hxx>
31 #include <svx/xbtmpit.hxx>
32 #include <svx/xflftrit.hxx>
33 #include <svx/xlndsit.hxx>
34 #include <svx/xflhtit.hxx>
35 #include <svx/xflgrit.hxx>
36 #include <svx/xfltrit.hxx>
37 #include <svx/xlntrit.hxx>
38 #include <editeng/eeitem.hxx>
39 #include <svl/eitem.hxx>
40 #include <svx/xgrscit.hxx>
41 #include <com/sun/star/beans/XPropertyState.hpp>
42 #include <com/sun/star/chart2/FillBitmap.hpp>
43 #include <com/sun/star/awt/Gradient.hpp>
44 #include <com/sun/star/container/XNameAccess.hpp>
46 using namespace ::com::sun::star
;
48 namespace chart
{ namespace wrapper
{
52 ItemPropertyMapType
& lcl_GetDataPointFilledPropertyMap()
54 static ItemPropertyMapType
aDataPointPropertyFilledMap(
56 IPM_MAP_ENTRY( XATTR_FILLSTYLE
, "FillStyle", 0 )
57 IPM_MAP_ENTRY( XATTR_FILLCOLOR
, "Color", 0 )
58 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "BorderColor", 0 )
59 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "BorderStyle", 0 )
60 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "BorderWidth", 0 )
61 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND
, "FillBackground", 0 )
62 IPM_MAP_ENTRY( XATTR_FILLBMP_POS
, "FillBitmapRectanglePoint", 0 )
63 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX
, "FillBitmapSizeX", 0 )
64 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY
, "FillBitmapSizeY", 0 )
65 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG
, "FillBitmapLogicalSize", 0 )
66 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX
, "FillBitmapOffsetX", 0 )
67 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY
, "FillBitmapOffsetY", 0 )
68 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX
, "FillBitmapPositionOffsetX", 0 )
69 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY
, "FillBitmapPositionOffsetY", 0 )
72 return aDataPointPropertyFilledMap
;
74 ItemPropertyMapType
& lcl_GetDataPointLinePropertyMap()
76 static ItemPropertyMapType
aDataPointPropertyLineMap(
78 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "Color", 0 )
79 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "LineStyle", 0 )
80 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "LineWidth", 0 )
83 return aDataPointPropertyLineMap
;
85 ItemPropertyMapType
& lcl_GetLinePropertyMap()
87 static ItemPropertyMapType
aLinePropertyMap(
89 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "LineStyle", 0 )
90 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "LineWidth", 0 )
91 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "LineColor", 0 )
92 IPM_MAP_ENTRY( XATTR_LINEJOINT
, "LineJoint", 0 )
95 return aLinePropertyMap
;
97 ItemPropertyMapType
& lcl_GetFillPropertyMap()
99 static ItemPropertyMapType
aFillPropertyMap(
101 IPM_MAP_ENTRY( XATTR_FILLSTYLE
, "FillStyle", 0 )
102 IPM_MAP_ENTRY( XATTR_FILLCOLOR
, "FillColor", 0 )
103 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND
, "FillBackground", 0 )
104 IPM_MAP_ENTRY( XATTR_FILLBMP_POS
, "FillBitmapRectanglePoint", 0 )
105 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX
, "FillBitmapSizeX", 0 )
106 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY
, "FillBitmapSizeY", 0 )
107 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG
, "FillBitmapLogicalSize", 0 )
108 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX
, "FillBitmapOffsetX", 0 )
109 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY
, "FillBitmapOffsetY", 0 )
110 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX
, "FillBitmapPositionOffsetX", 0 )
111 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY
, "FillBitmapPositionOffsetY", 0 )
114 return aFillPropertyMap
;
117 bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType
)
119 return ( eType
== ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT
||
120 eType
== ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES
||
121 eType
== ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
);
124 bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType
)
126 return ( eType
!= ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES
);
129 bool lcl_SetContentForNamedProperty(
130 const uno::Reference
< lang::XMultiServiceFactory
> & xFactory
,
131 const OUString
& rTableName
,
132 NameOrIndex
& rItem
, sal_uInt8 nMemberId
)
134 bool bResult
= false;
137 OUString
aPropertyValue( rItem
.GetName());
138 uno::Reference
< container::XNameAccess
> xNameAcc(
139 xFactory
->createInstance( rTableName
),
142 xNameAcc
->hasByName( aPropertyValue
))
144 rItem
.PutValue( xNameAcc
->getByName( aPropertyValue
), nMemberId
);
151 } // anonymous namespace
153 GraphicPropertyItemConverter::GraphicPropertyItemConverter(
154 const uno::Reference
<
155 beans::XPropertySet
> & rPropertySet
,
156 SfxItemPool
& rItemPool
,
157 SdrModel
& rDrawModel
,
158 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
,
159 eGraphicObjectType eObjectType
/* = FILL_PROPERTIES */ ) :
160 ItemConverter( rPropertySet
, rItemPool
),
161 m_eGraphicObjectType( eObjectType
),
162 m_rDrawModel( rDrawModel
),
163 m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory
)
166 GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
169 const sal_uInt16
* GraphicPropertyItemConverter::GetWhichPairs() const
171 const sal_uInt16
* pResult
= NULL
;
173 switch( m_eGraphicObjectType
)
175 case LINE_DATA_POINT
:
176 case FILLED_DATA_POINT
:
177 pResult
= nRowWhichPairs
; break;
178 case LINE_PROPERTIES
:
179 pResult
= nLinePropertyWhichPairs
; break;
180 case FILL_PROPERTIES
:
181 pResult
= nFillPropertyWhichPairs
; break;
182 case LINE_AND_FILL_PROPERTIES
:
183 pResult
= nLineAndFillPropertyWhichPairs
; break;
189 bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId
, tPropertyNameWithMemberId
& rOutProperty
) const
191 ItemPropertyMapType::const_iterator aEndIt
;
192 ItemPropertyMapType::const_iterator aIt
;
194 switch( m_eGraphicObjectType
)
196 case LINE_DATA_POINT
:
197 aEndIt
= lcl_GetDataPointLinePropertyMap().end();
198 aIt
= lcl_GetDataPointLinePropertyMap().find( nWhichId
);
200 case FILLED_DATA_POINT
:
201 aEndIt
= lcl_GetDataPointFilledPropertyMap().end();
202 aIt
= lcl_GetDataPointFilledPropertyMap().find( nWhichId
);
204 case LINE_PROPERTIES
:
205 aEndIt
= lcl_GetLinePropertyMap().end();
206 aIt
= lcl_GetLinePropertyMap().find( nWhichId
);
209 case FILL_PROPERTIES
:
210 aEndIt
= lcl_GetFillPropertyMap().end();
211 aIt
= lcl_GetFillPropertyMap().find( nWhichId
);
214 case LINE_AND_FILL_PROPERTIES
:
216 aEndIt
= lcl_GetLinePropertyMap().end();
217 aIt
= lcl_GetLinePropertyMap().find( nWhichId
);
219 // not found => try fill
222 aEndIt
= lcl_GetFillPropertyMap().end();
223 aIt
= lcl_GetFillPropertyMap().find( nWhichId
);
231 rOutProperty
=(*aIt
).second
;
235 void GraphicPropertyItemConverter::FillSpecialItem(
236 sal_uInt16 nWhichId
, SfxItemSet
& rOutItemSet
) const
237 throw (uno::Exception
, std::exception
)
242 case XATTR_FILLBMP_TILE
:
243 case XATTR_FILLBMP_STRETCH
:
245 drawing::BitmapMode aMode
= drawing::BitmapMode_REPEAT
;
246 if( GetPropertySet()->getPropertyValue( "FillBitmapMode" ) >>= aMode
)
248 rOutItemSet
.Put( XFillBmpTileItem( aMode
== drawing::BitmapMode_REPEAT
));
249 rOutItemSet
.Put( XFillBmpStretchItem( aMode
== drawing::BitmapMode_STRETCH
));
254 case XATTR_FILLFLOATTRANSPARENCE
:
257 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
260 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
261 ? OUString( "TransparencyGradientName" )
262 : OUString( "FillTransparenceGradientName" );
264 uno::Any
aValue( GetPropertySet()->getPropertyValue( aPropName
));
265 if( aValue
.hasValue())
267 XFillFloatTransparenceItem aItem
;
268 aItem
.PutValue( aValue
, MID_NAME
);
270 lcl_SetContentForNamedProperty(
271 m_xNamedPropertyTableFactory
, "com.sun.star.drawing.TransparencyGradientTable" ,
272 aItem
, MID_FILLGRADIENT
);
274 // this is important to enable the item
276 if( (aValue
>>= aName
) &&
279 aItem
.SetEnabled( true );
280 rOutItemSet
.Put( aItem
);
285 catch( const beans::UnknownPropertyException
&ex
)
287 ASSERT_EXCEPTION( ex
);
291 case XATTR_GRADIENTSTEPCOUNT
:
292 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
295 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
296 ? OUString( "GradientStepCount" )
297 : OUString( "FillGradientStepCount" );
299 uno::Any
aValue( GetPropertySet()->getPropertyValue( aPropName
) );
300 if( hasLongOrShortValue(aValue
) )
302 sal_Int16 nStepCount
= getShortForLongAlso(aValue
);
303 rOutItemSet
.Put( XGradientStepCountItem( nStepCount
));
309 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
312 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
313 ? OUString( "BorderDashName" )
314 : OUString( "LineDashName" );
317 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
319 lcl_SetContentForNamedProperty(
320 m_xNamedPropertyTableFactory
, "com.sun.star.drawing.DashTable" ,
321 aItem
, MID_LINEDASH
);
323 // translate model name to UI-name for predefined entries, so
324 // that the correct entry is chosen in the list of UI-names
325 XLineDashItem
* pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
328 rOutItemSet
.Put( *pItemToPut
);
330 rOutItemSet
.Put(aItem
);
334 case XATTR_FILLGRADIENT
:
335 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
338 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
339 ? OUString( "GradientName" )
340 : OUString( "FillGradientName" );
342 XFillGradientItem aItem
;
343 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
345 lcl_SetContentForNamedProperty(
346 m_xNamedPropertyTableFactory
, "com.sun.star.drawing.GradientTable" ,
347 aItem
, MID_FILLGRADIENT
);
349 // translate model name to UI-name for predefined entries, so
350 // that the correct entry is chosen in the list of UI-names
351 XFillGradientItem
* pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
354 rOutItemSet
.Put( *pItemToPut
);
356 rOutItemSet
.Put(aItem
);
360 case XATTR_FILLHATCH
:
361 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
364 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
365 ? OUString( "HatchName" )
366 : OUString( "FillHatchName" );
368 XFillHatchItem aItem
;
369 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
371 lcl_SetContentForNamedProperty(
372 m_xNamedPropertyTableFactory
, "com.sun.star.drawing.HatchTable" ,
373 aItem
, MID_FILLHATCH
);
375 // translate model name to UI-name for predefined entries, so
376 // that the correct entry is chosen in the list of UI-names
377 XFillHatchItem
* pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
380 rOutItemSet
.Put( *pItemToPut
);
382 rOutItemSet
.Put(aItem
);
386 case XATTR_FILLBITMAP
:
387 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
389 XFillBitmapItem aItem
;
390 aItem
.PutValue( GetPropertySet()->getPropertyValue( "FillBitmapName" ), MID_NAME
);
392 lcl_SetContentForNamedProperty(
393 m_xNamedPropertyTableFactory
, "com.sun.star.drawing.BitmapTable" ,
394 aItem
, MID_GRAFURL
);
396 // translate model name to UI-name for predefined entries, so
397 // that the correct entry is chosen in the list of UI-names
398 XFillBitmapItem
* pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
401 rOutItemSet
.Put( *pItemToPut
);
403 rOutItemSet
.Put(aItem
);
407 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
408 // instead of sal_Int16
409 case XATTR_LINETRANSPARENCE
:
410 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
413 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
414 ? OUString( "BorderTransparency" )
415 : (m_eGraphicObjectType
== LINE_DATA_POINT
)
416 ? OUString( "Transparency" )
417 : OUString( "LineTransparence" );
419 XLineTransparenceItem aItem
;
420 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
) );
422 rOutItemSet
.Put( aItem
);
426 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
427 // instead of sal_Int16
428 case XATTR_FILLTRANSPARENCE
:
429 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
432 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
433 ? OUString( "Transparency" )
434 : OUString( "FillTransparence" );
436 XFillTransparenceItem aItem
;
437 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
) );
439 rOutItemSet
.Put( aItem
);
445 bool GraphicPropertyItemConverter::ApplySpecialItem(
446 sal_uInt16 nWhichId
, const SfxItemSet
& rItemSet
)
447 throw( uno::Exception
)
449 bool bChanged
= false;
455 case XATTR_FILLBMP_STRETCH
:
456 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
458 const OUString
aModePropName("FillBitmapMode");
459 bool bStretched
= static_cast< const XFillBmpStretchItem
& >(
460 rItemSet
.Get( XATTR_FILLBMP_STRETCH
)).GetValue();
461 drawing::BitmapMode aMode
=
462 (bStretched
? drawing::BitmapMode_STRETCH
: drawing::BitmapMode_NO_REPEAT
);
465 if( aValue
!= GetPropertySet()->getPropertyValue( aModePropName
))
467 GetPropertySet()->setPropertyValue( aModePropName
, aValue
);
473 case XATTR_FILLBMP_TILE
:
474 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
476 const OUString
aModePropName("FillBitmapMode");
477 bool bTiled
= static_cast< const XFillBmpTileItem
& >(
478 rItemSet
.Get( XATTR_FILLBMP_TILE
)).GetValue();
479 drawing::BitmapMode aMode
=
480 (bTiled
? drawing::BitmapMode_REPEAT
: drawing::BitmapMode_NO_REPEAT
);
483 if( aValue
!= GetPropertySet()->getPropertyValue( aModePropName
))
485 GetPropertySet()->setPropertyValue( aModePropName
, aValue
);
491 case XATTR_FILLFLOATTRANSPARENCE
:
494 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
497 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
498 ? OUString( "TransparencyGradientName" )
499 : OUString( "FillTransparenceGradientName" );
501 const XFillFloatTransparenceItem
& rItem
=
502 static_cast< const XFillFloatTransparenceItem
& >(
503 rItemSet
.Get( nWhichId
));
505 if( rItem
.IsEnabled() &&
506 rItem
.QueryValue( aValue
, MID_NAME
))
509 rItem
.QueryValue( aGradient
, MID_FILLGRADIENT
);
511 // add TransparencyGradient to list if it does not already exist
512 OUString aPreferredName
;
513 aValue
>>= aPreferredName
;
514 aValue
<<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
515 aGradient
, m_xNamedPropertyTableFactory
, aPreferredName
);
517 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
519 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
526 if( ( GetPropertySet()->getPropertyValue( aPropName
) >>= aName
)
527 && !aName
.isEmpty() )
529 uno::Reference
< beans::XPropertyState
> xState( GetPropertySet(), uno::UNO_QUERY
);
531 xState
->setPropertyToDefault( aPropName
);
537 catch( const beans::UnknownPropertyException
&ex
)
539 ASSERT_EXCEPTION( ex
);
543 case XATTR_GRADIENTSTEPCOUNT
:
545 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
548 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
549 ? OUString( "GradientStepCount" )
550 : OUString( "FillGradientStepCount" );
552 sal_Int16 nStepCount
= ( static_cast< const XGradientStepCountItem
& >(
553 rItemSet
.Get( nWhichId
))).GetValue();
555 aValue
<<= nStepCount
;
556 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
558 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
567 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
571 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
572 ? OUString( "BorderDashName" )
573 : OUString( "LineDashName" );
575 const XLineDashItem
& rItem
=
576 static_cast< const XLineDashItem
& >(
577 rItemSet
.Get( nWhichId
));
579 if( rItem
.QueryValue( aValue
, MID_NAME
))
581 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
583 // add LineDash to list
585 rItem
.QueryValue( aLineDash
, MID_LINEDASH
);
586 OUString aPreferredName
;
587 aValue
>>= aPreferredName
;
588 aValue
<<= PropertyHelper::addLineDashUniqueNameToTable(
589 aLineDash
, m_xNamedPropertyTableFactory
, aPreferredName
);
591 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
599 case XATTR_FILLGRADIENT
:
601 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
604 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
605 ? OUString( "GradientName" )
606 : OUString( "FillGradientName" );
608 const XFillGradientItem
& rItem
=
609 static_cast< const XFillGradientItem
& >(
610 rItemSet
.Get( nWhichId
));
612 if( rItem
.QueryValue( aValue
, MID_NAME
))
614 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
616 // add Gradient to list
618 rItem
.QueryValue( aGradient
, MID_FILLGRADIENT
);
619 OUString aPreferredName
;
620 aValue
>>= aPreferredName
;
621 aValue
<<= PropertyHelper::addGradientUniqueNameToTable(
622 aGradient
, m_xNamedPropertyTableFactory
, aPreferredName
);
624 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
632 case XATTR_FILLHATCH
:
634 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
637 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
638 ? OUString( "HatchName" )
639 : OUString( "FillHatchName" );
641 const XFillHatchItem
& rItem
=
642 static_cast< const XFillHatchItem
& >(
643 rItemSet
.Get( nWhichId
));
645 if( rItem
.QueryValue( aValue
, MID_NAME
))
647 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
651 rItem
.QueryValue( aHatch
, MID_FILLHATCH
);
652 OUString aPreferredName
;
653 aValue
>>= aPreferredName
;
654 aValue
<<= PropertyHelper::addHatchUniqueNameToTable(
655 aHatch
, m_xNamedPropertyTableFactory
, aPreferredName
);
657 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
665 case XATTR_FILLBITMAP
:
667 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
669 const XFillBitmapItem
& rItem
=
670 static_cast< const XFillBitmapItem
& >(
671 rItemSet
.Get( nWhichId
));
673 if( rItem
.QueryValue( aValue
, MID_NAME
))
675 if( aValue
!= GetPropertySet()->getPropertyValue( "FillBitmapName" ))
677 // add Bitmap to list
679 rItem
.QueryValue( aBitmap
, MID_GRAFURL
);
680 OUString aPreferredName
;
681 aValue
>>= aPreferredName
;
682 aValue
<<= PropertyHelper::addBitmapUniqueNameToTable(
683 aBitmap
, m_xNamedPropertyTableFactory
, aPreferredName
);
685 GetPropertySet()->setPropertyValue( "FillBitmapName" , aValue
);
693 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
694 // instead of sal_Int16
695 case XATTR_LINETRANSPARENCE
:
696 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
699 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
700 ? OUString( "BorderTransparency" )
701 : (m_eGraphicObjectType
== LINE_DATA_POINT
)
702 ? OUString( "Transparency" )
703 : OUString( "LineTransparence" );
705 const XLineTransparenceItem
& rItem
=
706 static_cast< const XLineTransparenceItem
& >(
707 rItemSet
.Get( nWhichId
));
709 if( rItem
.QueryValue( aValue
))
711 OSL_ENSURE( ! aValue
.isExtractableTo(
712 cppu::UnoType
<sal_Int16
>::get()),
713 "TransparenceItem QueryValue bug is fixed. Remove hack." );
714 sal_Int32 nValue
= 0;
715 if( aValue
>>= nValue
)
717 OSL_ENSURE( nValue
< SAL_MAX_INT16
, "Transparency value too large" );
718 sal_Int16
nValueToSet( static_cast< sal_Int16
>( nValue
));
719 aValue
<<= nValueToSet
;
721 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
726 OSL_FAIL( "Wrong type in Transparency Any" );
732 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
733 // instead of sal_Int16
734 case XATTR_FILLTRANSPARENCE
:
735 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
738 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
739 ? OUString( "Transparency" )
740 : OUString( "FillTransparence" );
742 const XFillTransparenceItem
& rItem
=
743 static_cast< const XFillTransparenceItem
& >(
744 rItemSet
.Get( nWhichId
));
746 if( rItem
.QueryValue( aValue
))
748 OSL_ENSURE( ! aValue
.isExtractableTo(
749 cppu::UnoType
<sal_Int16
>::get()),
750 "TransparenceItem QueryValue bug is fixed. Remove hack." );
751 sal_Int32 nValue
= 0;
752 if( aValue
>>= nValue
)
754 OSL_ENSURE( nValue
< SAL_MAX_INT16
, "Transparency value too large" );
755 sal_Int16
nValueToSet( static_cast< sal_Int16
>( nValue
));
756 aValue
<<= nValueToSet
;
758 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
759 // if linear or no transparence is set, delete the gradient
760 OUString aTransGradPropName
=
761 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
762 ? OUString( "TransparencyGradientName" )
763 : OUString( "FillTransparenceGradientName" );
764 GetPropertySet()->setPropertyValue(
765 aTransGradPropName
, uno::makeAny( OUString() ));
771 OSL_FAIL( "Wrong type in Transparency Any" );
781 } // namespace wrapper
784 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */