LCOV - code coverage report
Current view: top level - libreoffice/svx/source/unodraw - XPropertyTable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 281 10.3 %
Date: 2012-12-17 Functions: 26 67 38.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10