1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26
27 #include "svx/XPropertyTable.hxx"
28 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
29 #include <com/sun/star/drawing/LineDash.hpp>
30 #include <com/sun/star/awt/Gradient.hpp>
31 #include <com/sun/star/drawing/Hatch.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <vos/mutex.hxx>
35 #include <vcl/svapp.hxx>
36
37 #include <cppuhelper/implbase2.hxx>
38 #include "unopolyhelper.hxx"
39 #include <svx/xdef.hxx>
40
41 #include "svx/unoapi.hxx"
42 #include <editeng/unoprnms.hxx>
43 #include <basegfx/polygon/b2dpolygon.hxx>
44
45 using namespace com::sun::star;
46 using namespace ::cppu;
47 using namespace ::rtl;
48 using namespace ::vos;
49
50 class SvxUnoXPropertyTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
51 {
52 private:
53 XPropertyList* mpList;
54 sal_Int16 mnWhich;
55
getCount() const56 long getCount() const { return mpList ? mpList->Count() : 0 ; }
57 XPropertyEntry* get( long index ) const;
58 public:
59 SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
60
61 virtual ~SvxUnoXPropertyTable() throw();
62
63 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() = 0;
64 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() = 0;
65
66 // XServiceInfo
67 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
68
69 // XNameContainer
70 virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
71 virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
72
73 // XNameReplace
74 virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
75
76 // XNameAccess
77 virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
78 virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException);
79 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
80
81 // XElementAccess
82 virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
83 };
84
SvxUnoXPropertyTable(sal_Int16 nWhich,XPropertyList * pList)85 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
86 : mpList( pList ), mnWhich( nWhich )
87 {
88 }
89
~SvxUnoXPropertyTable()90 SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw()
91 {
92 }
93
get(long index) const94 XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const
95 {
96 if( mpList )
97 return mpList->Get( index );
98 else
99 return NULL;
100 }
101
102 // XServiceInfo
supportsService(const OUString & ServiceName)103 sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
104 throw( uno::RuntimeException)
105 {
106 const uno::Sequence< OUString > aServices( getSupportedServiceNames() );
107 const OUString* pServices = aServices.getConstArray();
108 const sal_Int32 nCount = aServices.getLength();
109 sal_Int32 i;
110 for( i = 0; i < nCount; i++ )
111 {
112 if( *pServices++ == ServiceName )
113 return sal_True;
114 }
115
116 return sal_False;
117 }
118
119 // XNameContainer
insertByName(const OUString & aName,const uno::Any & aElement)120 void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
121 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
122 {
123 OGuard aGuard( Application::GetSolarMutex() );
124
125 if( NULL == mpList )
126 throw lang::IllegalArgumentException();
127
128 if( hasByName( aName ) )
129 throw container::ElementExistException();
130
131 String aInternalName;
132 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
133
134 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
135 if( NULL == pNewEntry )
136 throw lang::IllegalArgumentException();
137
138 if( mpList )
139 mpList->Insert( pNewEntry );
140 }
141
removeByName(const OUString & Name)142 void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
143 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
144 {
145 OGuard aGuard( Application::GetSolarMutex() );
146
147 String aInternalName;
148 SvxUnogetInternalNameForItem( mnWhich, Name, aInternalName );
149
150 const long nCount = getCount();
151 long i;
152 XPropertyEntry* pEntry;
153 for( i = 0; i < nCount; i++ )
154 {
155 pEntry = get( i );
156 if( pEntry && pEntry->GetName() == aInternalName )
157 {
158 if( mpList )
159 delete mpList->Remove( i );
160 return;
161 }
162 }
163
164 throw container::NoSuchElementException();
165 }
166
167 // XNameReplace
replaceByName(const OUString & aName,const uno::Any & aElement)168 void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
169 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
170 {
171 OGuard aGuard( Application::GetSolarMutex() );
172
173 String aInternalName;
174 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
175
176 const long nCount = getCount();
177 long i;
178 XPropertyEntry* pEntry;
179 for( i = 0; i < nCount; i++ )
180 {
181 pEntry = get( i );
182 if( pEntry && pEntry->GetName() == aInternalName )
183 {
184 XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
185 if( NULL == pNewEntry )
186 throw lang::IllegalArgumentException();
187
188 if( mpList )
189 delete mpList->Replace( pNewEntry, i );
190 return;
191 }
192 }
193
194 throw container::NoSuchElementException();
195 }
196
197 // XNameAccess
getByName(const OUString & aName)198 uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
199 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
200 {
201 OGuard aGuard( Application::GetSolarMutex() );
202
203 String aInternalName;
204 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
205
206 const long nCount = getCount();
207 long i;
208 XPropertyEntry* pEntry;
209 for( i = 0; i < nCount; i++ )
210 {
211 pEntry = get( i );
212
213 if( pEntry && pEntry->GetName() == aInternalName )
214 return getAny( pEntry );
215 }
216
217 throw container::NoSuchElementException();
218 }
219
getElementNames()220 uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
221 throw( uno::RuntimeException)
222 {
223 OGuard aGuard( Application::GetSolarMutex() );
224
225 const long nCount = getCount();
226 uno::Sequence< OUString > aNames( nCount );
227 OUString* pNames = aNames.getArray();
228 long i;
229 XPropertyEntry* pEntry;
230 for( i = 0; i < nCount; i++ )
231 {
232 pEntry = get( i );
233
234 if( pEntry )
235 {
236 SvxUnogetApiNameForItem( mnWhich, pEntry->GetName(), *pNames );
237 pNames++;
238 }
239 }
240
241 return aNames;
242 }
243
hasByName(const OUString & aName)244 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
245 throw( uno::RuntimeException)
246 {
247 OGuard aGuard( Application::GetSolarMutex() );
248
249 String aInternalName;
250 SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
251
252 const long nCount = mpList?mpList->Count():0;
253 long i;
254 XPropertyEntry* pEntry;
255 for( i = 0; i < nCount; i++ )
256 {
257 pEntry = get( i );
258 if( pEntry && pEntry->GetName() == aInternalName )
259 return sal_True;
260 }
261
262 return sal_False;
263 }
264
265 // XElementAccess
hasElements()266 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
267 throw( uno::RuntimeException)
268 {
269 OGuard aGuard( Application::GetSolarMutex() );
270
271 return getCount() != 0;
272 }
273
274 ///////////////////////////////////////////////////////////////////////
275
276 class SvxUnoXColorTable : public SvxUnoXPropertyTable
277 {
278 public:
SvxUnoXColorTable(XPropertyList * pTable)279 SvxUnoXColorTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pTable ) {};
280
281 // SvxUnoXPropertyTable
282 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
283 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
284
285 // XElementAccess
286 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
287
288 // XServiceInfo
289 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
290 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
291 };
292
SvxUnoXColorTable_createInstance(XPropertyList * pTable)293 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXColorTable_createInstance( XPropertyList* pTable ) throw()
294 {
295 return (OWeakObject*) new SvxUnoXColorTable( pTable );
296 }
297
298 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const299 uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
300 {
301 uno::Any aAny;
302 aAny <<= (sal_Int32)((XColorEntry*)pEntry)->GetColor().GetColor();
303 return aAny;
304 }
305
getEntry(const OUString & rName,const uno::Any & rAny) const306 XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
307 {
308 sal_Int32 nColor = 0;
309 if( !(rAny >>= nColor) )
310 return NULL;
311
312 const Color aColor( (ColorData)nColor );
313 const String aName( rName );
314 return new XColorEntry( aColor, aName );
315 }
316
317 // XElementAccess
getElementType()318 uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
319 throw( uno::RuntimeException )
320 {
321 return ::getCppuType((const sal_Int32*)0);
322 }
323
324 // XServiceInfo
getImplementationName()325 OUString SAL_CALL SvxUnoXColorTable::getImplementationName( ) throw( uno::RuntimeException )
326 {
327 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXColorTable" ) );
328 }
329
getSupportedServiceNames()330 uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
331 {
332 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ColorTable" ) );
333 uno::Sequence< OUString > aServices( &aServiceName, 1 );
334 return aServices;
335 }
336
337 ///////////////////////////////////////////////////////////////////////
338
339 class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
340 {
341 public:
SvxUnoXLineEndTable(XPropertyList * pTable)342 SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
343
344 // SvxUnoXPropertyTable
345 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
346 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
347
348 // XElementAccess
349 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
350
351 // XServiceInfo
352 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
353 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
354 };
355
SvxUnoXLineEndTable_createInstance(XPropertyList * pTable)356 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
357 {
358 return (OWeakObject*)new SvxUnoXLineEndTable( pTable );
359 }
360
361 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const362 uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
363 {
364
365 uno::Any aAny;
366 drawing::PolyPolygonBezierCoords aBezier;
367 SvxConvertB2DPolyPolygonToPolyPolygonBezier( ((XLineEndEntry*)pEntry)->GetLineEnd(), aBezier );
368 aAny <<= aBezier;
369 return aAny;
370 }
371
getEntry(const OUString & rName,const uno::Any & rAny) const372 XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
373 {
374
375 if( !rAny.getValue() || rAny.getValueType() != ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
376 return NULL;
377
378 basegfx::B2DPolyPolygon aPolyPolygon;
379 drawing::PolyPolygonBezierCoords* pCoords = (drawing::PolyPolygonBezierCoords*)rAny.getValue();
380 if( pCoords->Coordinates.getLength() > 0 )
381 aPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords );
382
383 // #86265# make sure polygon is closed
384 aPolyPolygon.setClosed(true);
385
386 const String aName( rName );
387 return new XLineEndEntry( aPolyPolygon, aName );
388 }
389
390 // XElementAccess
getElementType()391 uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
392 throw( uno::RuntimeException )
393 {
394 return ::getCppuType((const drawing::PolyPolygonBezierCoords*)0);
395 }
396
397 // XServiceInfo
getImplementationName()398 OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( ) throw( uno::RuntimeException )
399 {
400 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXLineEndTable" ) );
401 }
402
getSupportedServiceNames()403 uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
404 {
405 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineEndTable" ) );
406 uno::Sequence< OUString > aServices( &aServiceName, 1 );
407 return aServices;
408 }
409
410 ///////////////////////////////////////////////////////////////////////
411
412 class SvxUnoXDashTable : public SvxUnoXPropertyTable
413 {
414 public:
SvxUnoXDashTable(XPropertyList * pTable)415 SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
416
417 // SvxUnoXPropertyTable
418 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
419 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
420
421 // XElementAccess
422 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
423
424 // XServiceInfo
425 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
426 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
427 };
428
SvxUnoXDashTable_createInstance(XPropertyList * pTable)429 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
430 {
431 return (OWeakObject*)new SvxUnoXDashTable( pTable );
432 }
433
434 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const435 uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
436 {
437 const XDash& rXD = ((XDashEntry*)pEntry)->GetDash();
438
439 drawing::LineDash aLineDash;
440
441 aLineDash.Style = (::com::sun::star::drawing::DashStyle)((sal_uInt16)rXD.GetDashStyle());
442 aLineDash.Dots = rXD.GetDots();
443 aLineDash.DotLen = rXD.GetDotLen();
444 aLineDash.Dashes = rXD.GetDashes();
445 aLineDash.DashLen = rXD.GetDashLen();
446 aLineDash.Distance = rXD.GetDistance();
447
448 uno::Any aAny;
449 aAny <<= aLineDash;
450 return aAny;
451 }
452
getEntry(const OUString & rName,const uno::Any & rAny) const453 XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
454 {
455 drawing::LineDash aLineDash;
456 if(!(rAny >>= aLineDash))
457 return NULL;
458
459 XDash aXDash;
460
461 aXDash.SetDashStyle((XDashStyle)((sal_uInt16)(aLineDash.Style)));
462 aXDash.SetDots(aLineDash.Dots);
463 aXDash.SetDotLen(aLineDash.DotLen);
464 aXDash.SetDashes(aLineDash.Dashes);
465 aXDash.SetDashLen(aLineDash.DashLen);
466 aXDash.SetDistance(aLineDash.Distance);
467
468 const String aName( rName );
469 return new XDashEntry( aXDash, aName );
470 }
471
472 // XElementAccess
getElementType()473 uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
474 throw( uno::RuntimeException )
475 {
476 return ::getCppuType((const drawing::LineDash*)0);
477 }
478
479 // XServiceInfo
getImplementationName()480 OUString SAL_CALL SvxUnoXDashTable::getImplementationName( ) throw( uno::RuntimeException )
481 {
482 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXDashTable" ) );
483 }
484
getSupportedServiceNames()485 uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
486 {
487 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) );
488 uno::Sequence< OUString > aServices( &aServiceName, 1 );
489 return aServices;
490 }
491
492 ///////////////////////////////////////////////////////////////////////
493
494 class SvxUnoXHatchTable : public SvxUnoXPropertyTable
495 {
496 public:
SvxUnoXHatchTable(XPropertyList * pTable)497 SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
498
499 // SvxUnoXPropertyTable
500 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
501 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
502
503 // XElementAccess
504 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
505
506 // XServiceInfo
507 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
508 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
509 };
510
SvxUnoXHatchTable_createInstance(XPropertyList * pTable)511 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
512 {
513 return (OWeakObject*)new SvxUnoXHatchTable( pTable );
514 }
515
516 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const517 uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
518 {
519 const XHatch& aHatch = ((XHatchEntry*)pEntry)->GetHatch();
520
521 drawing::Hatch aUnoHatch;
522
523 aUnoHatch.Style = (drawing::HatchStyle)aHatch.GetHatchStyle();
524 aUnoHatch.Color = aHatch.GetColor().GetColor();
525 aUnoHatch.Distance = aHatch.GetDistance();
526 aUnoHatch.Angle = aHatch.GetAngle();
527
528 uno::Any aAny;
529 aAny <<= aUnoHatch;
530 return aAny;
531 }
532
getEntry(const OUString & rName,const uno::Any & rAny) const533 XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
534 {
535 drawing::Hatch aUnoHatch;
536 if(!(rAny >>= aUnoHatch))
537 return NULL;
538
539 XHatch aXHatch;
540 aXHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style );
541 aXHatch.SetColor( aUnoHatch.Color );
542 aXHatch.SetDistance( aUnoHatch.Distance );
543 aXHatch.SetAngle( aUnoHatch.Angle );
544
545 const String aName( rName );
546 return new XHatchEntry( aXHatch, aName );
547 }
548
549 // XElementAccess
getElementType()550 uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
551 throw( uno::RuntimeException )
552 {
553 return ::getCppuType((const drawing::Hatch*)0);
554 }
555
556 // XServiceInfo
getImplementationName()557 OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( ) throw( uno::RuntimeException )
558 {
559 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXHatchTable" ) );
560 }
561
getSupportedServiceNames()562 uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
563 {
564 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) );
565 uno::Sequence< OUString > aServices( &aServiceName, 1 );
566 return aServices;
567 }
568
569 ///////////////////////////////////////////////////////////////////////
570
571 class SvxUnoXGradientTable : public SvxUnoXPropertyTable
572 {
573 public:
SvxUnoXGradientTable(XPropertyList * pTable)574 SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
575
576 // SvxUnoXPropertyTable
577 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
578 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
579
580 // XElementAccess
581 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
582
583 // XServiceInfo
584 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
585 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
586 };
587
SvxUnoXGradientTable_createInstance(XPropertyList * pTable)588 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
589 {
590 return (OWeakObject*)new SvxUnoXGradientTable( pTable );
591 }
592
593 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const594 uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
595 {
596 const XGradient& aXGradient = ((XGradientEntry*)pEntry)->GetGradient();
597 awt::Gradient aGradient;
598
599 aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
600 aGradient.StartColor = (sal_Int32)aXGradient.GetStartColor().GetColor();
601 aGradient.EndColor = (sal_Int32)aXGradient.GetEndColor().GetColor();
602 aGradient.Angle = (short)aXGradient.GetAngle();
603 aGradient.Border = aXGradient.GetBorder();
604 aGradient.XOffset = aXGradient.GetXOffset();
605 aGradient.YOffset = aXGradient.GetYOffset();
606 aGradient.StartIntensity = aXGradient.GetStartIntens();
607 aGradient.EndIntensity = aXGradient.GetEndIntens();
608 aGradient.StepCount = aXGradient.GetSteps();
609
610 uno::Any aAny;
611 aAny <<= aGradient;
612 return aAny;
613 }
614
getEntry(const OUString & rName,const uno::Any & rAny) const615 XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
616 {
617 awt::Gradient aGradient;
618 if(!(rAny >>= aGradient))
619 return NULL;
620
621 XGradient aXGradient;
622
623 aXGradient.SetGradientStyle( (XGradientStyle) aGradient.Style );
624 aXGradient.SetStartColor( aGradient.StartColor );
625 aXGradient.SetEndColor( aGradient.EndColor );
626 aXGradient.SetAngle( aGradient.Angle );
627 aXGradient.SetBorder( aGradient.Border );
628 aXGradient.SetXOffset( aGradient.XOffset );
629 aXGradient.SetYOffset( aGradient.YOffset );
630 aXGradient.SetStartIntens( aGradient.StartIntensity );
631 aXGradient.SetEndIntens( aGradient.EndIntensity );
632 aXGradient.SetSteps( aGradient.StepCount );
633
634 const String aName( rName );
635 return new XGradientEntry( aXGradient, aName );
636 }
637
638 // XElementAccess
getElementType()639 uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
640 throw( uno::RuntimeException )
641 {
642 return ::getCppuType((const awt::Gradient*)0);
643 }
644
645 // XServiceInfo
getImplementationName()646 OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( ) throw( uno::RuntimeException )
647 {
648 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXGradientTable" ) );
649 }
650
getSupportedServiceNames()651 uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
652 {
653 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) );
654 uno::Sequence< OUString > aServices( &aServiceName, 1 );
655 return aServices;
656 }
657
658 ///////////////////////////////////////////////////////////////////////
659
660 class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
661 {
662 public:
SvxUnoXBitmapTable(XPropertyList * pTable)663 SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
664
665 // SvxUnoXPropertyTable
666 virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
667 virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
668
669 // XElementAccess
670 virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
671
672 // XServiceInfo
673 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
674 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
675 };
676
SvxUnoXBitmapTable_createInstance(XPropertyList * pTable)677 uno::Reference< uno::XInterface > SAL_CALL SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
678 {
679 return (OWeakObject*)new SvxUnoXBitmapTable( pTable );
680 }
681
682 // SvxUnoXPropertyTable
getAny(const XPropertyEntry * pEntry) const683 uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw()
684 {
685 OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
686 const GraphicObject& rGraphicObject(((XBitmapEntry*)pEntry)->GetGraphicObject());
687 aURL += OUString::createFromAscii(rGraphicObject.GetUniqueID().GetBuffer());
688
689 uno::Any aAny;
690 aAny <<= aURL;
691 return aAny;
692 }
693
getEntry(const OUString & rName,const uno::Any & rAny) const694 XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
695 {
696 OUString aURL;
697 if(!(rAny >>= aURL))
698 return NULL;
699
700 const GraphicObject aGrafObj(GraphicObject::CreateGraphicObjectFromURL(aURL));
701 const String aName(rName);
702
703 return new XBitmapEntry(aGrafObj, aName);
704 }
705
706 // XElementAccess
getElementType()707 uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
708 throw( uno::RuntimeException )
709 {
710 return ::getCppuType((const OUString*)0);
711 }
712
713 // XServiceInfo
getImplementationName()714 OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( ) throw( uno::RuntimeException )
715 {
716 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXBitmapTable" ) );
717 }
718
getSupportedServiceNames()719 uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
720 {
721 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) );
722 uno::Sequence< OUString > aServices( &aServiceName, 1 );
723 return aServices;
724 }
725