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

Generated by: LCOV version 1.10