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