bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / unodraw / XPropertyTable.cxx
blobc689c7f5be6f52a2d21183a26cd26caf86c18b69
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "svx/XPropertyTable.hxx"
22 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
23 #include <com/sun/star/drawing/LineDash.hpp>
24 #include <com/sun/star/awt/Gradient.hpp>
25 #include <com/sun/star/drawing/Hatch.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/container/XNameContainer.hpp>
28 #include <osl/mutex.hxx>
29 #include <vcl/svapp.hxx>
31 #include <cppuhelper/implbase2.hxx>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <svx/xdef.hxx>
35 #include "svx/unoapi.hxx"
36 #include <editeng/unoprnms.hxx>
37 #include <basegfx/polygon/b2dpolygon.hxx>
38 #include <basegfx/tools/unotools.hxx>
40 using namespace com::sun::star;
41 using namespace ::cppu;
43 class SvxUnoXPropertyTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
45 private:
46 XPropertyList* mpList;
47 sal_Int16 mnWhich;
49 long getCount() const { return mpList ? mpList->Count() : 0; }
50 XPropertyEntry* get( long index ) const;
51 public:
52 SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
54 virtual ~SvxUnoXPropertyTable() throw();
56 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(uno::RuntimeException) = 0;
57 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException, lang::IllegalArgumentException) = 0;
59 // XServiceInfo
60 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 // XNameContainer
63 virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 // XNameReplace
67 virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 // XNameAccess
70 virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 // XElementAccess
75 virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
79 : mpList( pList ), mnWhich( nWhich )
83 SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw()
87 XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const
89 if( mpList )
90 return mpList->Get(index);
91 else
92 return NULL;
95 // XServiceInfo
96 sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
97 throw( uno::RuntimeException, std::exception)
99 return cppu::supportsService(this, ServiceName);
102 // XNameContainer
103 void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
104 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
106 SolarMutexGuard aGuard;
108 if( NULL == mpList )
109 throw lang::IllegalArgumentException();
111 if( hasByName( aName ) )
112 throw container::ElementExistException();
114 OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
116 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
117 if( NULL == pNewEntry )
118 throw lang::IllegalArgumentException();
120 if( mpList )
121 mpList->Insert( pNewEntry );
124 void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
125 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
127 SolarMutexGuard aGuard;
129 OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, Name);
131 const long nCount = getCount();
132 long i;
133 for( i = 0; i < nCount; i++ )
135 XPropertyEntry* pEntry = get( i );
136 if (pEntry && aInternalName.equals(pEntry->GetName()))
138 if( mpList )
139 delete mpList->Remove( i );
140 return;
144 throw container::NoSuchElementException();
147 // XNameReplace
148 void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
149 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
151 SolarMutexGuard aGuard;
153 OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
155 const long nCount = getCount();
156 long i;
157 for( i = 0; i < nCount; i++ )
159 XPropertyEntry* pEntry = get( i );
160 if (pEntry && aInternalName.equals(pEntry->GetName()))
162 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
163 if( NULL == pNewEntry )
164 throw lang::IllegalArgumentException();
166 if( mpList )
167 delete mpList->Replace( pNewEntry, i );
168 return;
172 throw container::NoSuchElementException();
175 // XNameAccess
176 uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
177 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
179 SolarMutexGuard aGuard;
181 OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
183 const long nCount = getCount();
184 long i;
185 for( i = 0; i < nCount; i++ )
187 XPropertyEntry* pEntry = get( i );
189 if (pEntry && aInternalName.equals(pEntry->GetName()))
190 return getAny( pEntry );
193 throw container::NoSuchElementException();
196 uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
197 throw( uno::RuntimeException, std::exception)
199 SolarMutexGuard aGuard;
201 const long nCount = getCount();
202 uno::Sequence< OUString > aNames( nCount );
203 OUString* pNames = aNames.getArray();
204 long i;
205 for( i = 0; i < nCount; i++ )
207 XPropertyEntry* pEntry = get( i );
209 if (pEntry)
210 *pNames++ = SvxUnogetApiNameForItem(mnWhich, pEntry->GetName());
213 return aNames;
216 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
217 throw( uno::RuntimeException, std::exception)
219 SolarMutexGuard aGuard;
221 OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
223 const long nCount = mpList?mpList->Count():0;
224 long i;
225 for( i = 0; i < nCount; i++ )
227 XPropertyEntry* pEntry = get( i );
228 if (pEntry && aInternalName.equals(pEntry->GetName()))
229 return sal_True;
232 return sal_False;
235 // XElementAccess
236 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
237 throw( uno::RuntimeException, std::exception)
239 SolarMutexGuard aGuard;
241 return getCount() != 0;
246 class SvxUnoXColorTable : public SvxUnoXPropertyTable
248 public:
249 SvxUnoXColorTable( XPropertyList* pList ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pList ) {};
251 // SvxUnoXPropertyTable
252 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() SAL_OVERRIDE;
253 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() SAL_OVERRIDE;
255 // XElementAccess
256 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
258 // XServiceInfo
259 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
260 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
263 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXColorTable_createInstance( XPropertyList* pList ) throw()
265 return (OWeakObject*) new SvxUnoXColorTable( pList );
268 // SvxUnoXPropertyTable
269 uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
271 uno::Any aAny;
272 aAny <<= (sal_Int32)static_cast<const XColorEntry*>(pEntry)->GetColor().GetColor();
273 return aAny;
276 XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
278 sal_Int32 nColor = 0;
279 if( !(rAny >>= nColor) )
280 return NULL;
282 const Color aColor( (ColorData)nColor );
283 return new XColorEntry( aColor, rName );
286 // XElementAccess
287 uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
288 throw( uno::RuntimeException, std::exception )
290 return ::cppu::UnoType<sal_Int32>::get();
293 // XServiceInfo
294 OUString SAL_CALL SvxUnoXColorTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
296 return OUString( "SvxUnoXColorTable" );
299 uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
301 const OUString aServiceName( "com.sun.star.drawing.ColorTable" );
302 uno::Sequence< OUString > aServices( &aServiceName, 1 );
303 return aServices;
308 class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
310 public:
311 SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
313 // SvxUnoXPropertyTable
314 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() SAL_OVERRIDE;
315 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(lang::IllegalArgumentException) SAL_OVERRIDE;
317 // XElementAccess
318 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
320 // XServiceInfo
321 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
322 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
325 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
327 return (OWeakObject*)new SvxUnoXLineEndTable( pTable );
330 // SvxUnoXPropertyTable
331 uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
334 uno::Any aAny;
335 drawing::PolyPolygonBezierCoords aBezier;
336 basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier( static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd(),
337 aBezier );
338 aAny <<= aBezier;
339 return aAny;
342 XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw(lang::IllegalArgumentException)
345 if( !rAny.getValue() || rAny.getValueType() != cppu::UnoType<drawing::PolyPolygonBezierCoords>::get())
346 return NULL;
348 basegfx::B2DPolyPolygon aPolyPolygon;
349 drawing::PolyPolygonBezierCoords const * pCoords = static_cast<drawing::PolyPolygonBezierCoords const *>(rAny.getValue());
350 if( pCoords->Coordinates.getLength() > 0 )
351 aPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon( *pCoords );
353 // #86265# make sure polygon is closed
354 aPolyPolygon.setClosed(true);
356 return new XLineEndEntry( aPolyPolygon, rName );
359 // XElementAccess
360 uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
361 throw( uno::RuntimeException, std::exception )
363 return cppu::UnoType<drawing::PolyPolygonBezierCoords>::get();
366 // XServiceInfo
367 OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
369 return OUString( "SvxUnoXLineEndTable" );
372 uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
374 const OUString aServiceName( "com.sun.star.drawing.LineEndTable" );
375 uno::Sequence< OUString > aServices( &aServiceName, 1 );
376 return aServices;
381 class SvxUnoXDashTable : public SvxUnoXPropertyTable
383 public:
384 SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
386 // SvxUnoXPropertyTable
387 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() SAL_OVERRIDE;
388 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() SAL_OVERRIDE;
390 // XElementAccess
391 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
393 // XServiceInfo
394 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
395 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
400 return (OWeakObject*)new SvxUnoXDashTable( pTable );
403 // SvxUnoXPropertyTable
404 uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
406 const XDash& rXD = static_cast<const XDashEntry*>(pEntry)->GetDash();
408 drawing::LineDash aLineDash;
410 aLineDash.Style = (::com::sun::star::drawing::DashStyle)((sal_uInt16)rXD.GetDashStyle());
411 aLineDash.Dots = rXD.GetDots();
412 aLineDash.DotLen = rXD.GetDotLen();
413 aLineDash.Dashes = rXD.GetDashes();
414 aLineDash.DashLen = rXD.GetDashLen();
415 aLineDash.Distance = rXD.GetDistance();
417 uno::Any aAny;
418 aAny <<= aLineDash;
419 return aAny;
422 XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
424 drawing::LineDash aLineDash;
425 if(!(rAny >>= aLineDash))
426 return NULL;
428 XDash aXDash;
430 aXDash.SetDashStyle((css::drawing::DashStyle)((sal_uInt16)(aLineDash.Style)));
431 aXDash.SetDots(aLineDash.Dots);
432 aXDash.SetDotLen(aLineDash.DotLen);
433 aXDash.SetDashes(aLineDash.Dashes);
434 aXDash.SetDashLen(aLineDash.DashLen);
435 aXDash.SetDistance(aLineDash.Distance);
437 return new XDashEntry( aXDash, rName );
440 // XElementAccess
441 uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
442 throw( uno::RuntimeException, std::exception )
444 return cppu::UnoType<drawing::LineDash>::get();
447 // XServiceInfo
448 OUString SAL_CALL SvxUnoXDashTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
450 return OUString( "SvxUnoXDashTable" );
453 uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
455 const OUString aServiceName( "com.sun.star.drawing.DashTable" );
456 uno::Sequence< OUString > aServices( &aServiceName, 1 );
457 return aServices;
462 class SvxUnoXHatchTable : public SvxUnoXPropertyTable
464 public:
465 SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
467 // SvxUnoXPropertyTable
468 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() SAL_OVERRIDE;
469 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() SAL_OVERRIDE;
471 // XElementAccess
472 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
474 // XServiceInfo
475 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
476 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
479 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
481 return (OWeakObject*)new SvxUnoXHatchTable( pTable );
484 // SvxUnoXPropertyTable
485 uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
487 const XHatch& aHatch = static_cast<const XHatchEntry*>(pEntry)->GetHatch();
489 drawing::Hatch aUnoHatch;
491 aUnoHatch.Style = (drawing::HatchStyle)aHatch.GetHatchStyle();
492 aUnoHatch.Color = aHatch.GetColor().GetColor();
493 aUnoHatch.Distance = aHatch.GetDistance();
494 aUnoHatch.Angle = aHatch.GetAngle();
496 uno::Any aAny;
497 aAny <<= aUnoHatch;
498 return aAny;
501 XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
503 drawing::Hatch aUnoHatch;
504 if(!(rAny >>= aUnoHatch))
505 return NULL;
507 XHatch aXHatch;
508 aXHatch.SetHatchStyle( (css::drawing::HatchStyle)aUnoHatch.Style );
509 aXHatch.SetColor( aUnoHatch.Color );
510 aXHatch.SetDistance( aUnoHatch.Distance );
511 aXHatch.SetAngle( aUnoHatch.Angle );
513 return new XHatchEntry( aXHatch, rName );
516 // XElementAccess
517 uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
518 throw( uno::RuntimeException, std::exception )
520 return cppu::UnoType<drawing::Hatch>::get();
523 // XServiceInfo
524 OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
526 return OUString( "SvxUnoXHatchTable" );
529 uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
531 const OUString aServiceName( "com.sun.star.drawing.HatchTable" );
532 uno::Sequence< OUString > aServices( &aServiceName, 1 );
533 return aServices;
538 class SvxUnoXGradientTable : public SvxUnoXPropertyTable
540 public:
541 SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
543 // SvxUnoXPropertyTable
544 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() SAL_OVERRIDE;
545 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() SAL_OVERRIDE;
547 // XElementAccess
548 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
550 // XServiceInfo
551 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
552 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
555 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
557 return (OWeakObject*)new SvxUnoXGradientTable( pTable );
560 // SvxUnoXPropertyTable
561 uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
563 const XGradient& aXGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient();
564 awt::Gradient aGradient;
566 aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
567 aGradient.StartColor = (sal_Int32)aXGradient.GetStartColor().GetColor();
568 aGradient.EndColor = (sal_Int32)aXGradient.GetEndColor().GetColor();
569 aGradient.Angle = (short)aXGradient.GetAngle();
570 aGradient.Border = aXGradient.GetBorder();
571 aGradient.XOffset = aXGradient.GetXOffset();
572 aGradient.YOffset = aXGradient.GetYOffset();
573 aGradient.StartIntensity = aXGradient.GetStartIntens();
574 aGradient.EndIntensity = aXGradient.GetEndIntens();
575 aGradient.StepCount = aXGradient.GetSteps();
577 uno::Any aAny;
578 aAny <<= aGradient;
579 return aAny;
582 XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
584 awt::Gradient aGradient;
585 if(!(rAny >>= aGradient))
586 return NULL;
588 XGradient aXGradient;
590 aXGradient.SetGradientStyle( (css::awt::GradientStyle) aGradient.Style );
591 aXGradient.SetStartColor( aGradient.StartColor );
592 aXGradient.SetEndColor( aGradient.EndColor );
593 aXGradient.SetAngle( aGradient.Angle );
594 aXGradient.SetBorder( aGradient.Border );
595 aXGradient.SetXOffset( aGradient.XOffset );
596 aXGradient.SetYOffset( aGradient.YOffset );
597 aXGradient.SetStartIntens( aGradient.StartIntensity );
598 aXGradient.SetEndIntens( aGradient.EndIntensity );
599 aXGradient.SetSteps( aGradient.StepCount );
601 return new XGradientEntry( aXGradient, rName );
604 // XElementAccess
605 uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
606 throw( uno::RuntimeException, std::exception )
608 return cppu::UnoType<awt::Gradient>::get();
611 // XServiceInfo
612 OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
614 return OUString( "SvxUnoXGradientTable" );
617 uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
619 const OUString aServiceName( "com.sun.star.drawing.GradientTable" );
620 uno::Sequence< OUString > aServices( &aServiceName, 1 );
621 return aServices;
626 class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
628 public:
629 SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
631 // SvxUnoXPropertyTable
632 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(uno::RuntimeException) SAL_OVERRIDE;
633 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException) SAL_OVERRIDE;
635 // XElementAccess
636 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
638 // XServiceInfo
639 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
640 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
643 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
645 return (OWeakObject*)new SvxUnoXBitmapTable( pTable );
648 // SvxUnoXPropertyTable
649 uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw(uno::RuntimeException)
651 OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX);
652 const GraphicObject& rGraphicObject(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
653 aURL += OStringToOUString(rGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
655 uno::Any aAny;
656 aAny <<= aURL;
657 return aAny;
660 XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException)
662 OUString aURL;
663 if(!(rAny >>= aURL))
664 return NULL;
666 const GraphicObject aGrafObj(GraphicObject::CreateGraphicObjectFromURL(aURL));
668 return new XBitmapEntry(aGrafObj, rName);
671 // XElementAccess
672 uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
673 throw( uno::RuntimeException, std::exception )
675 return ::cppu::UnoType<OUString>::get();
678 // XServiceInfo
679 OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( ) throw( uno::RuntimeException, std::exception )
681 return OUString( "SvxUnoXBitmapTable" );
684 uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception)
686 const OUString aServiceName( "com.sun.star.drawing.BitmapTable" );
687 uno::Sequence< OUString > aServices( &aServiceName, 1 );
688 return aServices;
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */