1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GraphicPropertyItemConverter.cxx,v $
10 * $Revision: 1.13.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "GraphicPropertyItemConverter.hxx"
34 #include "SchWhichPairs.hxx"
36 #include "ItemPropertyMap.hxx"
37 #include "PropertyHelper.hxx"
38 #include "CommonConverters.hxx"
40 // #ifndef _SFXINTITEM_HXX
41 // #include <svtools/intitem.hxx>
43 #include <svx/xflclit.hxx>
44 #include <svx/xlnclit.hxx>
45 #include <svx/xflbmtit.hxx>
46 #include <svx/xflbstit.hxx>
47 #include <svx/xbtmpit.hxx>
48 #include <svx/xflftrit.hxx>
49 #include <svx/xlndsit.hxx>
50 #include <svx/xflhtit.hxx>
51 #include <svx/xflgrit.hxx>
52 #include <svx/xfltrit.hxx>
53 #include <svx/xlntrit.hxx>
54 #include <svx/eeitem.hxx>
56 #include <svtools/eitem.hxx>
57 // for XFillGradientStepCountItem
58 #include <svx/xgrscit.hxx>
59 #include <com/sun/star/beans/XPropertyState.hpp>
60 #include <com/sun/star/chart2/FillBitmap.hpp>
61 #include <com/sun/star/awt/Gradient.hpp>
62 #include <com/sun/star/container/XNameAccess.hpp>
64 using namespace ::com::sun::star
;
68 ::comphelper::ItemPropertyMapType
& lcl_GetDataPointFilledPropertyMap()
70 static ::comphelper::ItemPropertyMapType
aDataPointPropertyFilledMap(
71 ::comphelper::MakeItemPropertyMap
72 IPM_MAP_ENTRY( XATTR_FILLSTYLE
, "FillStyle", 0 )
73 IPM_MAP_ENTRY( XATTR_FILLCOLOR
, "Color", 0 )
74 // IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "Transparency", 0 )
75 // IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "Gradient", 0 )
76 // IPM_MAP_ENTRY( XATTR_FILLHATCH, "Hatch", 0 )
77 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "BorderColor", 0 )
78 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "BorderStyle", 0 )
79 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "BorderWidth", 0 )
80 // IPM_MAP_ENTRY( XATTR_LINEDASH, "BorderDash", 0 )
81 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "BorderTransparency", 0 )
82 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND
, "FillBackground", 0 )
83 IPM_MAP_ENTRY( XATTR_FILLBMP_POS
, "FillBitmapRectanglePoint", 0 )
84 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX
, "FillBitmapSizeX", 0 )
85 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY
, "FillBitmapSizeY", 0 )
86 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG
, "FillBitmapLogicalSize", 0 )
87 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX
, "FillBitmapOffsetX", 0 )
88 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY
, "FillBitmapOffsetY", 0 )
89 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX
, "FillBitmapPositionOffsetX", 0 )
90 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY
, "FillBitmapPositionOffsetY", 0 )
93 return aDataPointPropertyFilledMap
;
95 ::comphelper::ItemPropertyMapType
& lcl_GetDataPointLinePropertyMap()
97 static ::comphelper::ItemPropertyMapType
aDataPointPropertyLineMap(
98 ::comphelper::MakeItemPropertyMap
99 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "Color", 0 )
100 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "Transparency", 0 )
101 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "LineStyle", 0 )
102 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "LineWidth", 0 )
103 // IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
106 return aDataPointPropertyLineMap
;
108 ::comphelper::ItemPropertyMapType
& lcl_GetLinePropertyMap()
110 static ::comphelper::ItemPropertyMapType
aLinePropertyMap(
111 ::comphelper::MakeItemPropertyMap
112 IPM_MAP_ENTRY( XATTR_LINESTYLE
, "LineStyle", 0 )
113 IPM_MAP_ENTRY( XATTR_LINEWIDTH
, "LineWidth", 0 )
114 // IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
115 IPM_MAP_ENTRY( XATTR_LINECOLOR
, "LineColor", 0 )
116 // IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "LineTransparence", 0 )
117 IPM_MAP_ENTRY( XATTR_LINEJOINT
, "LineJoint", 0 )
120 return aLinePropertyMap
;
122 ::comphelper::ItemPropertyMapType
& lcl_GetFillPropertyMap()
124 static ::comphelper::ItemPropertyMapType
aFillPropertyMap(
125 ::comphelper::MakeItemPropertyMap
126 IPM_MAP_ENTRY( XATTR_FILLSTYLE
, "FillStyle", 0 )
127 IPM_MAP_ENTRY( XATTR_FILLCOLOR
, "FillColor", 0 )
128 // IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "FillTransparence", 0 )
129 // IPM_MAP_ENTRY( XATTR_FILLBITMAP, "FillBitmapName", MID_NAME )
130 // IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "FillGradient", 0 )
131 // IPM_MAP_ENTRY( XATTR_FILLHATCH, "FillHatch", 0 )
132 IPM_MAP_ENTRY( XATTR_FILLBACKGROUND
, "FillBackground", 0 )
133 IPM_MAP_ENTRY( XATTR_FILLBMP_POS
, "FillBitmapRectanglePoint", 0 )
134 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX
, "FillBitmapSizeX", 0 )
135 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY
, "FillBitmapSizeY", 0 )
136 IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG
, "FillBitmapLogicalSize", 0 )
137 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX
, "FillBitmapOffsetX", 0 )
138 IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY
, "FillBitmapOffsetY", 0 )
139 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX
, "FillBitmapPositionOffsetX", 0 )
140 IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY
, "FillBitmapPositionOffsetY", 0 )
143 return aFillPropertyMap
;
146 bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType
)
148 return ( eType
== ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT
||
149 eType
== ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES
||
150 eType
== ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
);
153 bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType
)
155 return ( eType
!= ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES
);
158 bool lcl_SetContentForNamedProperty(
159 const uno::Reference
< lang::XMultiServiceFactory
> & xFactory
,
160 const ::rtl::OUString
& rTableName
,
161 NameOrIndex
& rItem
, BYTE nMemberId
)
163 bool bResult
= false;
166 ::rtl::OUString
aPropertyValue( rItem
.GetName());
167 uno::Reference
< container::XNameAccess
> xNameAcc(
168 xFactory
->createInstance( rTableName
),
171 xNameAcc
->hasByName( aPropertyValue
))
173 rItem
.PutValue( xNameAcc
->getByName( aPropertyValue
), nMemberId
);
180 } // anonymous namespace
182 // ========================================
189 GraphicPropertyItemConverter::GraphicPropertyItemConverter(
190 const uno::Reference
<
191 beans::XPropertySet
> & rPropertySet
,
192 SfxItemPool
& rItemPool
,
193 SdrModel
& rDrawModel
,
194 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
,
195 eGraphicObjectType eObjectType
/* = FILL_PROPERTIES */ ) :
196 ItemConverter( rPropertySet
, rItemPool
),
197 m_eGraphicObjectType( eObjectType
),
198 m_rDrawModel( rDrawModel
),
199 m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory
)
202 GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
205 const USHORT
* GraphicPropertyItemConverter::GetWhichPairs() const
207 const USHORT
* pResult
= NULL
;
209 switch( m_eGraphicObjectType
)
211 case LINE_DATA_POINT
:
212 case FILLED_DATA_POINT
:
213 pResult
= nRowWhichPairs
; break;
214 case LINE_PROPERTIES
:
215 pResult
= nLinePropertyWhichPairs
; break;
216 case FILL_PROPERTIES
:
217 pResult
= nFillPropertyWhichPairs
; break;
218 case LINE_AND_FILL_PROPERTIES
:
219 pResult
= nLineAndFillPropertyWhichPairs
; break;
225 bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId
, tPropertyNameWithMemberId
& rOutProperty
) const
227 ::comphelper::ItemPropertyMapType::const_iterator aEndIt
;
228 ::comphelper::ItemPropertyMapType::const_iterator aIt
;
230 switch( m_eGraphicObjectType
)
232 case LINE_DATA_POINT
:
233 aEndIt
= lcl_GetDataPointLinePropertyMap().end();
234 aIt
= lcl_GetDataPointLinePropertyMap().find( nWhichId
);
236 case FILLED_DATA_POINT
:
237 aEndIt
= lcl_GetDataPointFilledPropertyMap().end();
238 aIt
= lcl_GetDataPointFilledPropertyMap().find( nWhichId
);
240 case LINE_PROPERTIES
:
241 aEndIt
= lcl_GetLinePropertyMap().end();
242 aIt
= lcl_GetLinePropertyMap().find( nWhichId
);
245 case FILL_PROPERTIES
:
246 aEndIt
= lcl_GetFillPropertyMap().end();
247 aIt
= lcl_GetFillPropertyMap().find( nWhichId
);
250 case LINE_AND_FILL_PROPERTIES
:
252 aEndIt
= lcl_GetLinePropertyMap().end();
253 aIt
= lcl_GetLinePropertyMap().find( nWhichId
);
255 // not found => try fill
258 aEndIt
= lcl_GetFillPropertyMap().end();
259 aIt
= lcl_GetFillPropertyMap().find( nWhichId
);
267 rOutProperty
=(*aIt
).second
;
271 void GraphicPropertyItemConverter::FillSpecialItem(
272 USHORT nWhichId
, SfxItemSet
& rOutItemSet
) const
273 throw( uno::Exception
)
275 // if( m_eGraphicObjectType == LINE_DATA_POINT ||
276 // m_eGraphicObjectType == LINE_PROPERTIES )
282 case XATTR_FILLBMP_TILE
:
283 case XATTR_FILLBMP_STRETCH
:
285 drawing::BitmapMode aMode
= drawing::BitmapMode_REPEAT
;
286 if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode
)
288 rOutItemSet
.Put( XFillBmpTileItem( aMode
== drawing::BitmapMode_REPEAT
));
289 rOutItemSet
.Put( XFillBmpStretchItem( aMode
== drawing::BitmapMode_STRETCH
));
294 case XATTR_FILLFLOATTRANSPARENCE
:
297 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
299 ::rtl::OUString aPropName
=
300 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
301 ? C2U( "TransparencyGradientName" )
302 : C2U( "FillTransparenceGradientName" );
304 uno::Any
aValue( GetPropertySet()->getPropertyValue( aPropName
));
305 if( aValue
.hasValue())
307 XFillFloatTransparenceItem aItem
;
308 aItem
.PutValue( aValue
, MID_NAME
);
310 lcl_SetContentForNamedProperty(
311 m_xNamedPropertyTableFactory
, C2U("com.sun.star.drawing.TransparencyGradientTable"),
312 aItem
, MID_FILLGRADIENT
);
314 // this is important to enable the item
315 ::rtl::OUString aName
;
316 if( (aValue
>>= aName
) &&
319 aItem
.SetEnabled( TRUE
);
320 rOutItemSet
.Put( aItem
);
325 catch( beans::UnknownPropertyException ex
)
327 ASSERT_EXCEPTION( ex
);
331 case XATTR_GRADIENTSTEPCOUNT
:
332 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
334 ::rtl::OUString aPropName
=
335 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
336 ? C2U( "GradientStepCount" )
337 : C2U( "FillGradientStepCount" );
339 sal_Int16 nStepCount
= 0;
340 uno::Any
aValue( GetPropertySet()->getPropertyValue( aPropName
) );
341 if( hasLongOrShortValue(aValue
) )
343 nStepCount
= getShortForLongAlso(aValue
);
344 rOutItemSet
.Put( XGradientStepCountItem( nStepCount
));
350 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
352 ::rtl::OUString aPropName
=
353 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
354 ? C2U( "BorderDashName" )
355 : C2U( "LineDashName" );
358 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
360 lcl_SetContentForNamedProperty(
361 m_xNamedPropertyTableFactory
, C2U("com.sun.star.drawing.DashTable"),
362 aItem
, MID_LINEDASH
);
364 // translate model name to UI-name for predefined entries, so
365 // that the correct entry is chosen in the list of UI-names
366 XLineDashItem
* pItemToPut
= & aItem
;
367 pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
369 rOutItemSet
.Put( * pItemToPut
);
373 case XATTR_FILLGRADIENT
:
374 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
376 ::rtl::OUString aPropName
=
377 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
378 ? C2U( "GradientName" )
379 : C2U( "FillGradientName" );
381 XFillGradientItem aItem
;
382 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
384 lcl_SetContentForNamedProperty(
385 m_xNamedPropertyTableFactory
, C2U("com.sun.star.drawing.GradientTable"),
386 aItem
, MID_FILLGRADIENT
);
388 // translate model name to UI-name for predefined entries, so
389 // that the correct entry is chosen in the list of UI-names
390 XFillGradientItem
* pItemToPut
= & aItem
;
391 pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
393 rOutItemSet
.Put( * pItemToPut
);
397 case XATTR_FILLHATCH
:
398 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
400 ::rtl::OUString aPropName
=
401 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
403 : C2U( "FillHatchName" );
405 XFillHatchItem aItem
;
406 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
), MID_NAME
);
408 lcl_SetContentForNamedProperty(
409 m_xNamedPropertyTableFactory
, C2U("com.sun.star.drawing.HatchTable"),
410 aItem
, MID_FILLHATCH
);
412 // translate model name to UI-name for predefined entries, so
413 // that the correct entry is chosen in the list of UI-names
414 XFillHatchItem
* pItemToPut
= & aItem
;
415 pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
417 rOutItemSet
.Put( * pItemToPut
);
421 case XATTR_FILLBITMAP
:
422 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
424 XFillBitmapItem aItem
;
425 aItem
.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME
);
427 lcl_SetContentForNamedProperty(
428 m_xNamedPropertyTableFactory
, C2U("com.sun.star.drawing.BitmapTable"),
429 aItem
, MID_GRAFURL
);
431 // translate model name to UI-name for predefined entries, so
432 // that the correct entry is chosen in the list of UI-names
433 XFillBitmapItem
* pItemToPut
= & aItem
;
434 pItemToPut
= aItem
.checkForUniqueItem( & m_rDrawModel
);
436 rOutItemSet
.Put( * pItemToPut
);
440 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
441 // instead of sal_Int16
442 case XATTR_LINETRANSPARENCE
:
443 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
445 ::rtl::OUString aPropName
=
446 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
447 ? C2U( "BorderTransparency" )
448 : (m_eGraphicObjectType
== LINE_DATA_POINT
)
449 ? C2U( "Transparency" )
450 : C2U( "LineTransparence" );
452 XLineTransparenceItem aItem
;
453 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
) );
455 rOutItemSet
.Put( aItem
);
459 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
460 // instead of sal_Int16
461 case XATTR_FILLTRANSPARENCE
:
462 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
464 ::rtl::OUString aPropName
=
465 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
466 ? C2U( "Transparency" )
467 : C2U( "FillTransparence" );
469 XFillTransparenceItem aItem
;
470 aItem
.PutValue( GetPropertySet()->getPropertyValue( aPropName
) );
472 rOutItemSet
.Put( aItem
);
478 bool GraphicPropertyItemConverter::ApplySpecialItem(
479 USHORT nWhichId
, const SfxItemSet
& rItemSet
)
480 throw( uno::Exception
)
482 bool bChanged
= false;
488 case XATTR_FILLBMP_STRETCH
:
489 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
491 const ::rtl::OUString aModePropName
= C2U("FillBitmapMode");
492 bool bStretched
= static_cast< const XFillBmpStretchItem
& >(
493 rItemSet
.Get( XATTR_FILLBMP_STRETCH
)).GetValue();
494 drawing::BitmapMode aMode
=
495 (bStretched
? drawing::BitmapMode_STRETCH
: drawing::BitmapMode_NO_REPEAT
);
498 if( aValue
!= GetPropertySet()->getPropertyValue( aModePropName
))
500 GetPropertySet()->setPropertyValue( aModePropName
, aValue
);
506 case XATTR_FILLBMP_TILE
:
507 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
509 const ::rtl::OUString aModePropName
= C2U("FillBitmapMode");
510 bool bTiled
= static_cast< const XFillBmpTileItem
& >(
511 rItemSet
.Get( XATTR_FILLBMP_TILE
)).GetValue();
512 drawing::BitmapMode aMode
=
513 (bTiled
? drawing::BitmapMode_REPEAT
: drawing::BitmapMode_NO_REPEAT
);
516 if( aValue
!= GetPropertySet()->getPropertyValue( aModePropName
))
518 GetPropertySet()->setPropertyValue( aModePropName
, aValue
);
524 case XATTR_FILLFLOATTRANSPARENCE
:
527 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
529 ::rtl::OUString aPropName
=
530 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
531 ? C2U( "TransparencyGradientName" )
532 : C2U( "FillTransparenceGradientName" );
534 const XFillFloatTransparenceItem
& rItem
=
535 static_cast< const XFillFloatTransparenceItem
& >(
536 rItemSet
.Get( nWhichId
));
538 if( rItem
.IsEnabled() &&
539 rItem
.QueryValue( aValue
, MID_NAME
))
542 rItem
.QueryValue( aGradient
, MID_FILLGRADIENT
);
544 // add TransparencyGradient to list if it does not already exist
545 ::rtl::OUString aPreferredName
;
546 aValue
>>= aPreferredName
;
547 aValue
<<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
548 aGradient
, m_xNamedPropertyTableFactory
, aPreferredName
);
550 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
552 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
558 ::rtl::OUString aName
;
559 if( ( GetPropertySet()->getPropertyValue( aPropName
) >>= aName
)
560 && aName
.getLength() > 0 )
562 uno::Reference
< beans::XPropertyState
> xState( GetPropertySet(), uno::UNO_QUERY
);
564 xState
->setPropertyToDefault( aPropName
);
570 catch( beans::UnknownPropertyException ex
)
572 ASSERT_EXCEPTION( ex
);
576 case XATTR_GRADIENTSTEPCOUNT
:
578 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
580 ::rtl::OUString aPropName
=
581 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
582 ? C2U( "GradientStepCount" )
583 : C2U( "FillGradientStepCount" );
585 sal_Int16 nStepCount
= ( static_cast< const XGradientStepCountItem
& >(
586 rItemSet
.Get( nWhichId
))).GetValue();
588 aValue
<<= nStepCount
;
589 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
591 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
600 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
603 ::rtl::OUString aPropName
=
604 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
605 ? C2U( "BorderDashName" )
606 : C2U( "LineDashName" );
608 const XLineDashItem
& rItem
=
609 static_cast< const XLineDashItem
& >(
610 rItemSet
.Get( nWhichId
));
612 if( rItem
.QueryValue( aValue
, MID_NAME
))
614 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
616 // add LineDash to list
618 rItem
.QueryValue( aLineDash
, MID_LINEDASH
);
619 ::rtl::OUString aPreferredName
;
620 aValue
>>= aPreferredName
;
621 aValue
<<= PropertyHelper::addLineDashUniqueNameToTable(
622 aLineDash
, m_xNamedPropertyTableFactory
, aPreferredName
);
624 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
632 case XATTR_FILLGRADIENT
:
634 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
636 ::rtl::OUString aPropName
=
637 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
638 ? C2U( "GradientName" )
639 : C2U( "FillGradientName" );
641 const XFillGradientItem
& rItem
=
642 static_cast< const XFillGradientItem
& >(
643 rItemSet
.Get( nWhichId
));
645 if( rItem
.QueryValue( aValue
, MID_NAME
))
647 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
649 // add Gradient to list
651 rItem
.QueryValue( aGradient
, MID_FILLGRADIENT
);
652 ::rtl::OUString aPreferredName
;
653 aValue
>>= aPreferredName
;
654 aValue
<<= PropertyHelper::addGradientUniqueNameToTable(
655 aGradient
, m_xNamedPropertyTableFactory
, aPreferredName
);
657 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
665 case XATTR_FILLHATCH
:
667 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
669 ::rtl::OUString aPropName
=
670 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
672 : C2U( "FillHatchName" );
674 const XFillHatchItem
& rItem
=
675 static_cast< const XFillHatchItem
& >(
676 rItemSet
.Get( nWhichId
));
678 if( rItem
.QueryValue( aValue
, MID_NAME
))
680 if( aValue
!= GetPropertySet()->getPropertyValue( aPropName
))
684 rItem
.QueryValue( aHatch
, MID_FILLHATCH
);
685 ::rtl::OUString aPreferredName
;
686 aValue
>>= aPreferredName
;
687 aValue
<<= PropertyHelper::addHatchUniqueNameToTable(
688 aHatch
, m_xNamedPropertyTableFactory
, aPreferredName
);
690 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
698 case XATTR_FILLBITMAP
:
700 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
702 const XFillBitmapItem
& rItem
=
703 static_cast< const XFillBitmapItem
& >(
704 rItemSet
.Get( nWhichId
));
706 if( rItem
.QueryValue( aValue
, MID_NAME
))
708 if( aValue
!= GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
710 // add Bitmap to list
712 rItem
.QueryValue( aBitmap
, MID_GRAFURL
);
713 ::rtl::OUString aPreferredName
;
714 aValue
>>= aPreferredName
;
715 aValue
<<= PropertyHelper::addBitmapUniqueNameToTable(
716 aBitmap
, m_xNamedPropertyTableFactory
, aPreferredName
);
718 GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue
);
726 // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
727 // instead of sal_Int16
728 case XATTR_LINETRANSPARENCE
:
729 if( lcl_supportsLineProperties( m_eGraphicObjectType
))
731 ::rtl::OUString aPropName
=
732 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
733 ? C2U( "BorderTransparency" )
734 : (m_eGraphicObjectType
== LINE_DATA_POINT
)
735 ? C2U( "Transparency" )
736 : C2U( "LineTransparence" );
738 const XLineTransparenceItem
& rItem
=
739 static_cast< const XLineTransparenceItem
& >(
740 rItemSet
.Get( nWhichId
));
742 if( rItem
.QueryValue( aValue
))
744 OSL_ENSURE( ! aValue
.isExtractableTo(
745 ::getCppuType( reinterpret_cast< const sal_Int16
* >(0))),
746 "TransparenceItem QueryValue bug is fixed. Remove hack." );
747 sal_Int32 nValue
= 0;
748 if( aValue
>>= nValue
)
750 OSL_ENSURE( nValue
< SAL_MAX_INT16
, "Transparency value too large" );
751 sal_Int16
nValueToSet( static_cast< sal_Int16
>( nValue
));
752 aValue
<<= nValueToSet
;
754 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
759 OSL_ENSURE( false, "Wrong type in Transparency Any" );
765 // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
766 // instead of sal_Int16
767 case XATTR_FILLTRANSPARENCE
:
768 if( lcl_supportsFillProperties( m_eGraphicObjectType
))
770 ::rtl::OUString aPropName
=
771 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
772 ? C2U( "Transparency" )
773 : C2U( "FillTransparence" );
775 const XFillTransparenceItem
& rItem
=
776 static_cast< const XFillTransparenceItem
& >(
777 rItemSet
.Get( nWhichId
));
779 if( rItem
.QueryValue( aValue
))
781 OSL_ENSURE( ! aValue
.isExtractableTo(
782 ::getCppuType( reinterpret_cast< const sal_Int16
* >(0))),
783 "TransparenceItem QueryValue bug is fixed. Remove hack." );
784 sal_Int32 nValue
= 0;
785 if( aValue
>>= nValue
)
787 OSL_ENSURE( nValue
< SAL_MAX_INT16
, "Transparency value too large" );
788 sal_Int16
nValueToSet( static_cast< sal_Int16
>( nValue
));
789 aValue
<<= nValueToSet
;
791 GetPropertySet()->setPropertyValue( aPropName
, aValue
);
792 // if linear or no transparence is set, delete the gradient
793 ::rtl::OUString aTransGradPropName
=
794 (m_eGraphicObjectType
== FILLED_DATA_POINT
)
795 ? C2U( "TransparencyGradientName" )
796 : C2U( "FillTransparenceGradientName" );
797 GetPropertySet()->setPropertyValue(
798 aTransGradPropName
, uno::makeAny( ::rtl::OUString() ));
804 OSL_ENSURE( false, "Wrong type in Transparency Any" );
814 } // namespace wrapper