merge the formfield patch from ooo-build
[ooovba.git] / svx / source / unodraw / XPropertyTable.cxx
blob9324ed5a0bdfe6536216d0f5c89583469edce2ea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XPropertyTable.cxx,v $
10 * $Revision: 1.13 $
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_svx.hxx"
34 #include "XPropertyTable.hxx"
35 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
36 #include <com/sun/star/drawing/LineDash.hpp>
37 #include <com/sun/star/awt/Gradient.hpp>
38 #include <com/sun/star/drawing/Hatch.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/container/XNameContainer.hpp>
41 #include <vos/mutex.hxx>
42 #include <vcl/svapp.hxx>
44 #include <cppuhelper/implbase2.hxx>
45 #include "unopolyhelper.hxx"
46 #include <svx/xdef.hxx>
48 #include "unoapi.hxx"
49 #include <svx/unoprnms.hxx>
50 #include <basegfx/polygon/b2dpolygon.hxx>
52 using namespace com::sun::star;
53 using namespace ::cppu;
54 using namespace ::rtl;
55 using namespace ::vos;
57 class SvxUnoXPropertyTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
59 private:
60 XPropertyTable* mpTable;
61 XPropertyList* mpList;
62 sal_Int16 mnWhich;
64 long getCount() const { return mpList ? mpList->Count() : (mpTable?mpTable->Count():0); }
65 XPropertyEntry* get( long index ) const;
66 public:
67 SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
68 SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw();
70 virtual ~SvxUnoXPropertyTable() throw();
72 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() = 0;
73 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() = 0;
75 // XServiceInfo
76 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
78 // XNameContainer
79 virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
80 virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
82 // XNameReplace
83 virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
85 // XNameAccess
86 virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
87 virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException);
88 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
90 // XElementAccess
91 virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
94 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw()
95 : mpTable( pTable ), mpList( NULL ), mnWhich( nWhich )
99 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
100 : mpTable( NULL ), mpList( pList ), mnWhich( nWhich )
104 SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw()
108 XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const
110 if( mpTable )
111 return mpTable->Get( index, 0 );
112 else if( mpList )
113 return mpList->Get( index, 0 );
114 else
115 return NULL;
118 // XServiceInfo
119 sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
120 throw( uno::RuntimeException)
122 const uno::Sequence< OUString > aServices( getSupportedServiceNames() );
123 const OUString* pServices = aServices.getConstArray();
124 const sal_Int32 nCount = aServices.getLength();
125 sal_Int32 i;
126 for( i = 0; i < nCount; i++ )
128 if( *pServices++ == ServiceName )
129 return sal_True;
132 return sal_False;
135 // XNameContainer
136 void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
137 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
139 OGuard aGuard( Application::GetSolarMutex() );
141 if( NULL == mpList && NULL == mpTable )
142 throw lang::IllegalArgumentException();
144 if( hasByName( aName ) )
145 throw container::ElementExistException();
147 String aInternalName;
148 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
150 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
151 if( NULL == pNewEntry )
152 throw lang::IllegalArgumentException();
154 if( mpList )
155 mpList->Insert( pNewEntry );
156 else
157 mpTable->Insert( mpTable->Count(), pNewEntry );
160 void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
161 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
163 OGuard aGuard( Application::GetSolarMutex() );
165 String aInternalName;
166 SvxUnogetInternalNameForItem( mnWhich, Name, aInternalName );
168 const long nCount = getCount();
169 long i;
170 XPropertyEntry* pEntry;
171 for( i = 0; i < nCount; i++ )
173 pEntry = get( i );
174 if( pEntry && pEntry->GetName() == aInternalName )
176 if( mpList )
177 delete mpList->Remove( i, 0 );
178 else
179 delete mpTable->Remove( i, 0 );
180 return;
184 throw container::NoSuchElementException();
187 // XNameReplace
188 void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
189 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
191 OGuard aGuard( Application::GetSolarMutex() );
193 String aInternalName;
194 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
196 const long nCount = getCount();
197 long i;
198 XPropertyEntry* pEntry;
199 for( i = 0; i < nCount; i++ )
201 pEntry = get( i );
202 if( pEntry && pEntry->GetName() == aInternalName )
204 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
205 if( NULL == pNewEntry )
206 throw lang::IllegalArgumentException();
208 if( mpList )
209 delete mpList->Replace( pNewEntry, i );
210 else
211 delete mpTable->Replace( i, pNewEntry );
212 return;
216 throw container::NoSuchElementException();
219 // XNameAccess
220 uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
221 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
223 OGuard aGuard( Application::GetSolarMutex() );
225 String aInternalName;
226 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
228 const long nCount = getCount();
229 long i;
230 XPropertyEntry* pEntry;
231 for( i = 0; i < nCount; i++ )
233 pEntry = get( i );
235 if( pEntry && pEntry->GetName() == aInternalName )
236 return getAny( pEntry );
239 throw container::NoSuchElementException();
242 uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
243 throw( uno::RuntimeException)
245 OGuard aGuard( Application::GetSolarMutex() );
247 const long nCount = getCount();
248 uno::Sequence< OUString > aNames( nCount );
249 OUString* pNames = aNames.getArray();
250 long i;
251 XPropertyEntry* pEntry;
252 for( i = 0; i < nCount; i++ )
254 pEntry = get( i );
256 if( pEntry )
258 SvxUnogetApiNameForItem( mnWhich, pEntry->GetName(), *pNames );
259 pNames++;
263 return aNames;
266 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
267 throw( uno::RuntimeException)
269 OGuard aGuard( Application::GetSolarMutex() );
271 String aInternalName;
272 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
274 const long nCount = mpList?mpList->Count():0;
275 long i;
276 XPropertyEntry* pEntry;
277 for( i = 0; i < nCount; i++ )
279 pEntry = get( i );
280 if( pEntry && pEntry->GetName() == aInternalName )
281 return sal_True;
284 return sal_False;
287 // XElementAccess
288 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
289 throw( uno::RuntimeException)
291 OGuard aGuard( Application::GetSolarMutex() );
293 return getCount() != 0;
296 ///////////////////////////////////////////////////////////////////////
298 class SvxUnoXColorTable : public SvxUnoXPropertyTable
300 public:
301 SvxUnoXColorTable( XPropertyTable* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pTable ) {};
303 // SvxUnoXPropertyTable
304 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
305 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
307 // XElementAccess
308 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
310 // XServiceInfo
311 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
312 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
315 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXColorTable_createInstance( XPropertyTable* pTable ) throw()
317 return (OWeakObject*) new SvxUnoXColorTable( pTable );
320 // SvxUnoXPropertyTable
321 uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
323 uno::Any aAny;
324 aAny <<= (sal_Int32)((XColorEntry*)pEntry)->GetColor().GetColor();
325 return aAny;
328 XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
330 sal_Int32 nColor = 0;
331 if( !(rAny >>= nColor) )
332 return NULL;
334 const Color aColor( (ColorData)nColor );
335 const String aName( rName );
336 return new XColorEntry( aColor, aName );
339 // XElementAccess
340 uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
341 throw( uno::RuntimeException )
343 return ::getCppuType((const sal_Int32*)0);
346 // XServiceInfo
347 OUString SAL_CALL SvxUnoXColorTable::getImplementationName( ) throw( uno::RuntimeException )
349 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXColorTable" ) );
352 uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
354 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ColorTable" ) );
355 uno::Sequence< OUString > aServices( &aServiceName, 1 );
356 return aServices;
359 ///////////////////////////////////////////////////////////////////////
361 class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
363 public:
364 SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
366 // SvxUnoXPropertyTable
367 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
368 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
370 // XElementAccess
371 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
373 // XServiceInfo
374 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
375 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
378 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
380 return (OWeakObject*)new SvxUnoXLineEndTable( pTable );
383 // SvxUnoXPropertyTable
384 uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
387 uno::Any aAny;
388 drawing::PolyPolygonBezierCoords aBezier;
389 SvxConvertB2DPolyPolygonToPolyPolygonBezier( ((XLineEndEntry*)pEntry)->GetLineEnd(), aBezier );
390 aAny <<= aBezier;
391 return aAny;
394 XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
397 if( !rAny.getValue() || rAny.getValueType() != ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
398 return NULL;
400 basegfx::B2DPolyPolygon aPolyPolygon;
401 drawing::PolyPolygonBezierCoords* pCoords = (drawing::PolyPolygonBezierCoords*)rAny.getValue();
402 if( pCoords->Coordinates.getLength() > 0 )
403 aPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords );
405 // #86265# make sure polygon is closed
406 aPolyPolygon.setClosed(true);
408 const String aName( rName );
409 return new XLineEndEntry( aPolyPolygon, aName );
412 // XElementAccess
413 uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
414 throw( uno::RuntimeException )
416 return ::getCppuType((const drawing::PolyPolygonBezierCoords*)0);
419 // XServiceInfo
420 OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( ) throw( uno::RuntimeException )
422 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXLineEndTable" ) );
425 uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
427 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineEndTable" ) );
428 uno::Sequence< OUString > aServices( &aServiceName, 1 );
429 return aServices;
432 ///////////////////////////////////////////////////////////////////////
434 class SvxUnoXDashTable : public SvxUnoXPropertyTable
436 public:
437 SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
439 // SvxUnoXPropertyTable
440 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
441 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
443 // XElementAccess
444 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
446 // XServiceInfo
447 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
448 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
451 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
453 return (OWeakObject*)new SvxUnoXDashTable( pTable );
456 // SvxUnoXPropertyTable
457 uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
459 const XDash& rXD = ((XDashEntry*)pEntry)->GetDash();
461 drawing::LineDash aLineDash;
463 aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle());
464 aLineDash.Dots = rXD.GetDots();
465 aLineDash.DotLen = rXD.GetDotLen();
466 aLineDash.Dashes = rXD.GetDashes();
467 aLineDash.DashLen = rXD.GetDashLen();
468 aLineDash.Distance = rXD.GetDistance();
470 uno::Any aAny;
471 aAny <<= aLineDash;
472 return aAny;
475 XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
477 drawing::LineDash aLineDash;
478 if(!(rAny >>= aLineDash))
479 return NULL;
481 XDash aXDash;
483 aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style)));
484 aXDash.SetDots(aLineDash.Dots);
485 aXDash.SetDotLen(aLineDash.DotLen);
486 aXDash.SetDashes(aLineDash.Dashes);
487 aXDash.SetDashLen(aLineDash.DashLen);
488 aXDash.SetDistance(aLineDash.Distance);
490 const String aName( rName );
491 return new XDashEntry( aXDash, aName );
494 // XElementAccess
495 uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
496 throw( uno::RuntimeException )
498 return ::getCppuType((const drawing::LineDash*)0);
501 // XServiceInfo
502 OUString SAL_CALL SvxUnoXDashTable::getImplementationName( ) throw( uno::RuntimeException )
504 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXDashTable" ) );
507 uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
509 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) );
510 uno::Sequence< OUString > aServices( &aServiceName, 1 );
511 return aServices;
514 ///////////////////////////////////////////////////////////////////////
516 class SvxUnoXHatchTable : public SvxUnoXPropertyTable
518 public:
519 SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
521 // SvxUnoXPropertyTable
522 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
523 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
525 // XElementAccess
526 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
528 // XServiceInfo
529 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
530 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
533 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
535 return (OWeakObject*)new SvxUnoXHatchTable( pTable );
538 // SvxUnoXPropertyTable
539 uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
541 const XHatch& aHatch = ((XHatchEntry*)pEntry)->GetHatch();
543 drawing::Hatch aUnoHatch;
545 aUnoHatch.Style = (drawing::HatchStyle)aHatch.GetHatchStyle();
546 aUnoHatch.Color = aHatch.GetColor().GetColor();
547 aUnoHatch.Distance = aHatch.GetDistance();
548 aUnoHatch.Angle = aHatch.GetAngle();
550 uno::Any aAny;
551 aAny <<= aUnoHatch;
552 return aAny;
555 XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
557 drawing::Hatch aUnoHatch;
558 if(!(rAny >>= aUnoHatch))
559 return NULL;
561 XHatch aXHatch;
562 aXHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style );
563 aXHatch.SetColor( aUnoHatch.Color );
564 aXHatch.SetDistance( aUnoHatch.Distance );
565 aXHatch.SetAngle( aUnoHatch.Angle );
567 const String aName( rName );
568 return new XHatchEntry( aXHatch, aName );
571 // XElementAccess
572 uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
573 throw( uno::RuntimeException )
575 return ::getCppuType((const drawing::Hatch*)0);
578 // XServiceInfo
579 OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( ) throw( uno::RuntimeException )
581 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXHatchTable" ) );
584 uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
586 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) );
587 uno::Sequence< OUString > aServices( &aServiceName, 1 );
588 return aServices;
591 ///////////////////////////////////////////////////////////////////////
593 class SvxUnoXGradientTable : public SvxUnoXPropertyTable
595 public:
596 SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
598 // SvxUnoXPropertyTable
599 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
600 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
602 // XElementAccess
603 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
605 // XServiceInfo
606 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
607 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
610 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
612 return (OWeakObject*)new SvxUnoXGradientTable( pTable );
615 // SvxUnoXPropertyTable
616 uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
618 const XGradient& aXGradient = ((XGradientEntry*)pEntry)->GetGradient();
619 awt::Gradient aGradient;
621 aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
622 aGradient.StartColor = (INT32)aXGradient.GetStartColor().GetColor();
623 aGradient.EndColor = (INT32)aXGradient.GetEndColor().GetColor();
624 aGradient.Angle = (short)aXGradient.GetAngle();
625 aGradient.Border = aXGradient.GetBorder();
626 aGradient.XOffset = aXGradient.GetXOffset();
627 aGradient.YOffset = aXGradient.GetYOffset();
628 aGradient.StartIntensity = aXGradient.GetStartIntens();
629 aGradient.EndIntensity = aXGradient.GetEndIntens();
630 aGradient.StepCount = aXGradient.GetSteps();
632 uno::Any aAny;
633 aAny <<= aGradient;
634 return aAny;
637 XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
639 awt::Gradient aGradient;
640 if(!(rAny >>= aGradient))
641 return NULL;
643 XGradient aXGradient;
645 aXGradient.SetGradientStyle( (XGradientStyle) aGradient.Style );
646 aXGradient.SetStartColor( aGradient.StartColor );
647 aXGradient.SetEndColor( aGradient.EndColor );
648 aXGradient.SetAngle( aGradient.Angle );
649 aXGradient.SetBorder( aGradient.Border );
650 aXGradient.SetXOffset( aGradient.XOffset );
651 aXGradient.SetYOffset( aGradient.YOffset );
652 aXGradient.SetStartIntens( aGradient.StartIntensity );
653 aXGradient.SetEndIntens( aGradient.EndIntensity );
654 aXGradient.SetSteps( aGradient.StepCount );
656 const String aName( rName );
657 return new XGradientEntry( aXGradient, aName );
660 // XElementAccess
661 uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
662 throw( uno::RuntimeException )
664 return ::getCppuType((const awt::Gradient*)0);
667 // XServiceInfo
668 OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( ) throw( uno::RuntimeException )
670 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXGradientTable" ) );
673 uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
675 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) );
676 uno::Sequence< OUString > aServices( &aServiceName, 1 );
677 return aServices;
680 ///////////////////////////////////////////////////////////////////////
682 class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
684 public:
685 SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
687 // SvxUnoXPropertyTable
688 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
689 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
691 // XElementAccess
692 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
694 // XServiceInfo
695 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
696 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
699 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
701 return (OWeakObject*)new SvxUnoXBitmapTable( pTable );
704 // SvxUnoXPropertyTable
705 uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw()
707 OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
708 aURL += OUString::createFromAscii( ((XBitmapEntry*)pEntry)->GetXBitmap().GetGraphicObject().GetUniqueID().GetBuffer() );
710 uno::Any aAny;
711 aAny <<= aURL;
712 return aAny;
715 XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
717 OUString aURL;
718 if(!(rAny >>= aURL))
719 return NULL;
721 GraphicObject aGrafObj( CreateGraphicObjectFromURL( aURL ) );
722 XOBitmap aBMP( aGrafObj );
724 const String aName( rName );
725 return new XBitmapEntry( aBMP, aName );
728 // XElementAccess
729 uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
730 throw( uno::RuntimeException )
732 return ::getCppuType((const OUString*)0);
735 // XServiceInfo
736 OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( ) throw( uno::RuntimeException )
738 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXBitmapTable" ) );
741 uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
743 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) );
744 uno::Sequence< OUString > aServices( &aServiceName, 1 );
745 return aServices;