LCOV - code coverage report
Current view: top level - svx/source/unodraw - unomtabl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 142 188 75.5 %
Date: 2012-08-25 Functions: 16 20 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 194 480 40.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <set>
      31                 :            : #include <comphelper/stl_types.hxx>
      32                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      33                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      34                 :            : #include <com/sun/star/drawing/PointSequence.hpp>
      35                 :            : #include <svl/style.hxx>
      36                 :            : 
      37                 :            : #include <cppuhelper/implbase2.hxx>
      38                 :            : #include <svl/itempool.hxx>
      39                 :            : #include <svl/itemset.hxx>
      40                 :            : #include <svl/lstner.hxx>
      41                 :            : #include <svx/xlnedit.hxx>
      42                 :            : #include <svx/xlnstit.hxx>
      43                 :            : #include <svx/svdmodel.hxx>
      44                 :            : #include <svx/xdef.hxx>
      45                 :            : #include <svx/xflhtit.hxx>
      46                 :            : 
      47                 :            : #include <vector>
      48                 :            : #include <osl/mutex.hxx>
      49                 :            : #include <vcl/svapp.hxx>
      50                 :            : 
      51                 :            : 
      52                 :            : #include "svx/unofill.hxx"
      53                 :            : 
      54                 :            : #include "svx/unoapi.hxx"
      55                 :            : 
      56                 :            : using namespace ::com::sun::star;
      57                 :            : using namespace ::rtl;
      58                 :            : using namespace ::cppu;
      59                 :            : 
      60                 :            : typedef std::vector< SfxItemSet* > ItemPoolVector;
      61                 :            : 
      62                 :            : class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >,
      63                 :            :                           public SfxListener
      64                 :            : {
      65                 :            : private:
      66                 :            :     SdrModel*       mpModel;
      67                 :            :     SfxItemPool*    mpModelPool;
      68                 :            : 
      69                 :            :     ItemPoolVector maItemSetVector;
      70                 :            : 
      71                 :            : public:
      72                 :            :     SvxUnoMarkerTable( SdrModel* pModel ) throw();
      73                 :            :     virtual ~SvxUnoMarkerTable() throw();
      74                 :            : 
      75                 :            :     void dispose();
      76                 :            : 
      77                 :            :     // SfxListener
      78                 :            :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
      79                 :            : 
      80                 :            :     void SAL_CALL ImplInsertByName( const OUString& aName, const uno::Any& aElement );
      81                 :            : 
      82                 :            :     // XServiceInfo
      83                 :            :     virtual OUString SAL_CALL getImplementationName(  ) throw( uno::RuntimeException );
      84                 :            :     virtual sal_Bool SAL_CALL supportsService( const  OUString& ServiceName ) throw( uno::RuntimeException);
      85                 :            :     virtual uno::Sequence<  OUString > SAL_CALL getSupportedServiceNames(  ) throw( uno::RuntimeException);
      86                 :            : 
      87                 :            :     // XNameContainer
      88                 :            :     virtual void SAL_CALL insertByName( const  OUString& aName, const  uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
      89                 :            :     virtual void SAL_CALL removeByName( const  OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
      90                 :            : 
      91                 :            :     // XNameReplace
      92                 :            :     virtual void SAL_CALL replaceByName( const  OUString& aName, const  uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
      93                 :            : 
      94                 :            :     // XNameAccess
      95                 :            :     virtual uno::Any SAL_CALL getByName( const  OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
      96                 :            :     virtual uno::Sequence<  OUString > SAL_CALL getElementNames(  ) throw( uno::RuntimeException);
      97                 :            :     virtual sal_Bool SAL_CALL hasByName( const  OUString& aName ) throw( uno::RuntimeException);
      98                 :            : 
      99                 :            :     // XElementAccess
     100                 :            :     virtual uno::Type SAL_CALL getElementType(  ) throw( uno::RuntimeException);
     101                 :            :     virtual sal_Bool SAL_CALL hasElements(  ) throw( uno::RuntimeException);
     102                 :            : };
     103                 :            : 
     104                 :         66 : SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw()
     105                 :            : : mpModel( pModel ),
     106 [ +  - ][ +  - ]:         66 :   mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL )
                 [ +  - ]
     107                 :            : {
     108         [ +  - ]:         66 :     if( pModel )
     109         [ +  - ]:         66 :         StartListening( *pModel );
     110                 :         66 : }
     111                 :            : 
     112         [ +  - ]:         63 : SvxUnoMarkerTable::~SvxUnoMarkerTable() throw()
     113                 :            : {
     114         [ +  - ]:         63 :     if( mpModel )
     115         [ +  - ]:         63 :         EndListening( *mpModel );
     116         [ +  - ]:         63 :     dispose();
     117         [ -  + ]:        126 : }
     118                 :            : 
     119                 :        137 : void SvxUnoMarkerTable::dispose()
     120                 :            : {
     121                 :        137 :     ItemPoolVector::iterator aIter = maItemSetVector.begin();
     122                 :        137 :     const ItemPoolVector::iterator aEnd = maItemSetVector.end();
     123                 :            : 
     124 [ +  - ][ +  + ]:        165 :     while( aIter != aEnd )
     125                 :            :     {
     126 [ +  - ][ +  - ]:         28 :         delete (*aIter++);
         [ +  - ][ +  - ]
     127                 :            :     }
     128                 :            : 
     129                 :        137 :     maItemSetVector.clear();
     130                 :        137 : }
     131                 :            : 
     132                 :            : // SfxListener
     133                 :       9550 : void SvxUnoMarkerTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
     134                 :            : {
     135 [ +  - ][ +  + ]:       9550 :     const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
     136                 :            : 
     137 [ +  + ][ +  + ]:       9550 :     if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() )
                 [ +  + ]
     138                 :         63 :         dispose();
     139                 :       9550 : }
     140                 :            : 
     141                 :          0 : sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const  OUString& ServiceName ) throw(uno::RuntimeException)
     142                 :            : {
     143         [ #  # ]:          0 :     uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
     144                 :          0 :     const OUString * pArray = aSNL.getConstArray();
     145                 :            : 
     146         [ #  # ]:          0 :     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
     147         [ #  # ]:          0 :         if( pArray[i] == ServiceName )
     148                 :          0 :             return sal_True;
     149                 :            : 
     150         [ #  # ]:          0 :     return sal_False;
     151                 :            : }
     152                 :            : 
     153                 :          0 : OUString SAL_CALL SvxUnoMarkerTable::getImplementationName() throw( uno::RuntimeException )
     154                 :            : {
     155                 :          0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoMarkerTable") );
     156                 :            : }
     157                 :            : 
     158                 :          0 : uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getSupportedServiceNames(  )
     159                 :            :     throw( uno::RuntimeException )
     160                 :            : {
     161                 :          0 :     uno::Sequence< OUString > aSNS( 1 );
     162 [ #  # ][ #  # ]:          0 :     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable" ));
     163                 :          0 :     return aSNS;
     164                 :            : }
     165                 :            : 
     166                 :         31 : void SAL_CALL SvxUnoMarkerTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement )
     167                 :            : {
     168 [ +  - ][ +  - ]:         31 :     SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND );
     169         [ +  - ]:         31 :     maItemSetVector.push_back( mpInSet );
     170                 :            : 
     171         [ +  - ]:         31 :     XLineEndItem aEndMarker;
     172 [ +  - ][ +  - ]:         31 :     aEndMarker.SetName( String( aName ) );
                 [ +  - ]
     173         [ +  - ]:         31 :     aEndMarker.PutValue( aElement );
     174                 :            : 
     175         [ +  - ]:         31 :     mpInSet->Put( aEndMarker, XATTR_LINEEND );
     176                 :            : 
     177         [ +  - ]:         31 :     XLineStartItem aStartMarker;
     178 [ +  - ][ +  - ]:         31 :     aStartMarker.SetName( String( aName ) );
                 [ +  - ]
     179         [ +  - ]:         31 :     aStartMarker.PutValue( aElement );
     180                 :            : 
     181 [ +  - ][ +  - ]:         31 :     mpInSet->Put( aStartMarker, XATTR_LINESTART );
                 [ +  - ]
     182                 :         31 : }
     183                 :            : 
     184                 :            : // XNameContainer
     185                 :         20 : void SAL_CALL SvxUnoMarkerTable::insertByName( const OUString& aApiName, const uno::Any& aElement )
     186                 :            :     throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
     187                 :            : {
     188         [ +  - ]:         20 :     SolarMutexGuard aGuard;
     189                 :            : 
     190 [ +  - ][ -  + ]:         20 :     if( hasByName( aApiName ) )
     191         [ #  # ]:          0 :         throw container::ElementExistException();
     192                 :            : 
     193         [ +  - ]:         20 :     String aName;
     194                 :         20 :     SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
     195                 :            : 
     196 [ +  - ][ +  - ]:         20 :     ImplInsertByName( aName, aElement );
         [ +  - ][ +  - ]
     197                 :         20 : }
     198                 :            : 
     199                 :         11 : void SAL_CALL SvxUnoMarkerTable::removeByName( const OUString& aApiName )
     200                 :            :     throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     201                 :            : {
     202         [ +  - ]:         11 :     SolarMutexGuard aGuard;
     203                 :            : 
     204                 :            :     // a little quickfix for 2.0 to let applications clear api
     205                 :            :     // created items that are not used
     206         [ +  - ]:         11 :     if ( aApiName == "~clear~" )
     207                 :            :     {
     208         [ +  - ]:         11 :         dispose();
     209                 :            :         return;
     210                 :            :     }
     211                 :            : 
     212         [ #  # ]:          0 :     String Name;
     213                 :          0 :     SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, Name );
     214                 :            : 
     215                 :          0 :     ItemPoolVector::iterator aIter = maItemSetVector.begin();
     216                 :          0 :     const ItemPoolVector::iterator aEnd = maItemSetVector.end();
     217                 :            : 
     218                 :            :     NameOrIndex *pItem;
     219         [ #  # ]:          0 :     const String aSearchName( Name );
     220                 :            : 
     221 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     222                 :            :     {
     223 [ #  # ][ #  # ]:          0 :         pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
     224 [ #  # ][ #  # ]:          0 :         if( pItem->GetName() == aSearchName )
         [ #  # ][ #  # ]
     225                 :            :         {
     226 [ #  # ][ #  # ]:          0 :             delete (*aIter);
                 [ #  # ]
     227         [ #  # ]:          0 :             maItemSetVector.erase( aIter );
     228                 :            :             return;
     229                 :            :         }
     230         [ #  # ]:          0 :         ++aIter;
     231                 :            :     }
     232                 :            : 
     233 [ #  # ][ #  # ]:          0 :     if( !hasByName( Name ) )
                 [ #  # ]
     234 [ #  # ][ #  # ]:         11 :         throw container::NoSuchElementException();
         [ #  # ][ #  # ]
         [ #  # ][ +  - ]
                 [ -  + ]
     235                 :            : }
     236                 :            : 
     237                 :            : // XNameReplace
     238                 :         11 : void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const uno::Any& aElement )
     239                 :            :     throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
     240                 :            : {
     241         [ +  - ]:         11 :     SolarMutexGuard aGuard;
     242                 :            : 
     243         [ +  - ]:         11 :     String aName;
     244                 :         11 :     SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
     245                 :            : 
     246                 :         11 :     ItemPoolVector::iterator aIter = maItemSetVector.begin();
     247                 :         11 :     const ItemPoolVector::iterator aEnd = maItemSetVector.end();
     248                 :            : 
     249                 :            :     NameOrIndex *pItem;
     250         [ +  - ]:         11 :     const String aSearchName( aName );
     251                 :            : 
     252 [ +  - ][ -  + ]:         11 :     while( aIter != aEnd )
     253                 :            :     {
     254 [ #  # ][ #  # ]:          0 :         pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
     255 [ #  # ][ #  # ]:          0 :         if( pItem->GetName() == aSearchName )
         [ #  # ][ #  # ]
     256                 :            :         {
     257         [ #  # ]:          0 :             XLineEndItem aEndMarker;
     258         [ #  # ]:          0 :             aEndMarker.SetName( aSearchName );
     259 [ #  # ][ #  # ]:          0 :             if( !aEndMarker.PutValue( aElement ) )
     260         [ #  # ]:          0 :                 throw lang::IllegalArgumentException();
     261                 :            : 
     262 [ #  # ][ #  # ]:          0 :             (*aIter)->Put( aEndMarker, XATTR_LINEEND );
     263                 :            : 
     264         [ #  # ]:          0 :             XLineStartItem aStartMarker;
     265         [ #  # ]:          0 :             aStartMarker.SetName( aSearchName );
     266         [ #  # ]:          0 :             aStartMarker.PutValue( aElement );
     267                 :            : 
     268 [ #  # ][ #  # ]:          0 :             (*aIter)->Put( aStartMarker, XATTR_LINESTART );
     269 [ #  # ][ #  # ]:         11 :             return;
     270                 :            :         }
     271         [ #  # ]:          0 :         ++aIter;
     272                 :            :     }
     273                 :            : 
     274                 :            :     // if it is not in our own sets, modify the pool!
     275                 :         11 :     sal_Bool bFound = sal_False;
     276                 :            : 
     277                 :            :     sal_uInt32 nSurrogate;
     278 [ +  - ][ +  - ]:         11 :     const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
     279         [ +  - ]:         22 :     for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
     280                 :            :     {
     281         [ +  - ]:         22 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
     282 [ +  - ][ +  - ]:         22 :         if( pItem && pItem->GetName() == aSearchName )
         [ +  - ][ +  + ]
         [ +  - ][ +  - ]
           [ +  +  #  # ]
     283                 :            :         {
     284         [ +  - ]:         11 :             pItem->PutValue( aElement );
     285                 :         11 :             bFound = sal_True;
     286                 :         11 :             break;
     287                 :            :         }
     288                 :            :     }
     289                 :            : 
     290 [ +  - ][ +  - ]:         11 :     const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
     291         [ +  - ]:         22 :     for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
     292                 :            :     {
     293         [ +  - ]:         22 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
     294 [ +  - ][ +  - ]:         22 :         if( pItem && pItem->GetName() == aSearchName )
         [ +  - ][ +  + ]
         [ +  - ][ +  - ]
           [ +  +  #  # ]
     295                 :            :         {
     296         [ +  - ]:         11 :             pItem->PutValue( aElement );
     297                 :         11 :             bFound = sal_True;
     298                 :         11 :             break;
     299                 :            :         }
     300                 :            :     }
     301                 :            : 
     302         [ +  - ]:         11 :     if( bFound )
     303 [ +  - ][ +  - ]:         11 :         ImplInsertByName( aName, aElement );
     304                 :            :     else
     305 [ #  # ][ +  - ]:         11 :         throw container::NoSuchElementException();
         [ -  + ][ +  - ]
         [ -  + ][ +  - ]
                 [ +  - ]
     306                 :            : }
     307                 :            : 
     308                 :         12 : static sal_Bool getByNameFromPool( const String& rSearchName, SfxItemPool* pPool, sal_uInt16 nWhich, uno::Any& rAny )
     309                 :            : {
     310                 :            :     NameOrIndex *pItem;
     311         [ +  - ]:         12 :     const sal_uInt32 nSurrogateCount = pPool ? pPool->GetItemCount2( nWhich ) : 0;
     312         [ +  - ]:         24 :     for( sal_uInt32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
     313                 :            :     {
     314                 :         24 :         pItem = (NameOrIndex*)pPool->GetItem2( nWhich, nSurrogate );
     315                 :            : 
     316 [ +  - ][ +  - ]:         24 :         if( pItem && pItem->GetName() == rSearchName )
         [ +  + ][ +  - ]
           [ +  +  #  # ]
                 [ +  - ]
     317                 :            :         {
     318                 :         12 :             pItem->QueryValue( rAny, 0 );
     319                 :         12 :             return sal_True;
     320                 :            :         }
     321                 :            :     }
     322                 :            : 
     323                 :         12 :     return sal_False;
     324                 :            : }
     325                 :            : 
     326                 :            : // XNameAccess
     327                 :         12 : uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aApiName )
     328                 :            :     throw( container::NoSuchElementException,  lang::WrappedTargetException, uno::RuntimeException)
     329                 :            : {
     330         [ +  - ]:         12 :     SolarMutexGuard aGuard;
     331                 :            : 
     332         [ +  - ]:         12 :     String aName;
     333                 :         12 :     SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
     334                 :            : 
     335                 :         12 :     uno::Any aAny;
     336                 :            : 
     337 [ +  - ][ +  - ]:         12 :     if( mpModelPool && aName.Len() != 0 )
                 [ +  - ]
     338                 :            :     {
     339                 :            :         do
     340                 :            :         {
     341         [ +  - ]:         12 :             const String aSearchName( aName );
     342 [ +  - ][ -  + ]:         12 :             if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINESTART, aAny ) )
     343                 :            :                 break;
     344                 :            : 
     345 [ #  # ][ #  # ]:          0 :             if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINEEND, aAny ) )
     346                 :            :                 break;
     347                 :            : 
     348 [ #  # ][ +  - ]:         12 :             throw container::NoSuchElementException();
     349                 :            :         }
     350                 :            :         while(0);
     351                 :            :     }
     352                 :            : 
     353 [ +  - ][ +  - ]:         12 :     return aAny;
     354                 :            : }
     355                 :            : 
     356                 :         24 : static void createNamesForPool( SfxItemPool* pPool, sal_uInt16 nWhich, std::set< OUString, comphelper::UStringLess >& rNameSet )
     357                 :            : {
     358         [ +  - ]:         24 :     const sal_uInt32 nSuroCount = pPool->GetItemCount2( nWhich );
     359                 :            :     sal_uInt32 nSurrogate;
     360                 :            : 
     361                 :            :     NameOrIndex* pItem;
     362                 :         24 :     OUString aName;
     363                 :            : 
     364         [ +  + ]:         72 :     for( nSurrogate = 0; nSurrogate < nSuroCount; nSurrogate++ )
     365                 :            :     {
     366         [ +  - ]:         48 :         pItem = (NameOrIndex*)pPool->GetItem2( nWhich, nSurrogate );
     367                 :            : 
     368 [ +  - ][ +  - ]:         48 :         if( pItem == NULL || pItem->GetName().Len() == 0 )
         [ +  + ][ +  - ]
                 [ +  - ]
           [ +  +  #  # ]
     369                 :         24 :             continue;
     370                 :            : 
     371 [ +  - ][ +  - ]:         24 :         SvxUnogetApiNameForItem( XATTR_LINEEND, pItem->GetName(), aName );
     372         [ +  - ]:         24 :         rNameSet.insert( aName );
     373                 :         24 :     }
     374                 :         24 : }
     375                 :            : 
     376                 :         12 : uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames()
     377                 :            :     throw( uno::RuntimeException )
     378                 :            : {
     379         [ +  - ]:         12 :     SolarMutexGuard aGuard;
     380                 :            : 
     381         [ +  - ]:         12 :     std::set< OUString, comphelper::UStringLess > aNameSet;
     382                 :            : 
     383                 :            :     // search model pool for line starts
     384         [ +  - ]:         12 :     createNamesForPool( mpModelPool, XATTR_LINESTART, aNameSet );
     385                 :            : 
     386                 :            :     // search model pool for line ends
     387         [ +  - ]:         12 :     createNamesForPool( mpModelPool, XATTR_LINEEND, aNameSet );
     388                 :            : 
     389         [ +  - ]:         12 :     uno::Sequence< OUString > aSeq( aNameSet.size() );
     390         [ +  - ]:         12 :     OUString* pNames = aSeq.getArray();
     391                 :            : 
     392                 :         12 :     std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() );
     393                 :         12 :     const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() );
     394                 :            : 
     395         [ +  + ]:         24 :     while( aIter != aEnd )
     396                 :            :     {
     397                 :         12 :         *pNames++ = *aIter++;
     398                 :            :     }
     399                 :            : 
     400         [ +  - ]:         12 :     return aSeq;
     401                 :            : }
     402                 :            : 
     403                 :         75 : sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName )
     404                 :            :     throw( uno::RuntimeException )
     405                 :            : {
     406         [ +  - ]:         75 :     SolarMutexGuard aGuard;
     407                 :            : 
     408         [ -  + ]:         75 :     if( aName.isEmpty() )
     409                 :          0 :         return sal_False;
     410                 :            : 
     411         [ +  - ]:         75 :     String aSearchName;
     412                 :            : 
     413                 :            :     NameOrIndex *pItem;
     414                 :            : 
     415                 :         75 :     SvxUnogetInternalNameForItem( XATTR_LINESTART, aName, aSearchName );
     416 [ +  - ][ +  - ]:         75 :     sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
     417                 :            :     sal_uInt32 nSurrogate;
     418         [ +  + ]:        140 :     for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
     419                 :            :     {
     420         [ +  - ]:         91 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
     421 [ +  + ][ +  - ]:         91 :         if( pItem && pItem->GetName() == aSearchName )
         [ +  - ][ +  + ]
         [ +  + ][ +  - ]
           [ +  +  #  # ]
     422                 :         26 :             return sal_True;
     423                 :            :     }
     424                 :            : 
     425                 :         49 :     SvxUnogetInternalNameForItem( XATTR_LINEEND, aName, aSearchName );
     426 [ +  - ][ +  - ]:         49 :     sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
     427         [ +  + ]:         67 :     for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
     428                 :            :     {
     429         [ +  - ]:         18 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
     430 [ +  - ][ +  - ]:         18 :         if( pItem && pItem->GetName() == aSearchName )
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
           [ -  +  #  # ]
     431                 :          0 :             return sal_True;
     432                 :            :     }
     433                 :            : 
     434 [ +  - ][ +  - ]:         75 :     return sal_False;
     435                 :            : }
     436                 :            : 
     437                 :            : // XElementAccess
     438                 :          0 : uno::Type SAL_CALL SvxUnoMarkerTable::getElementType(  )
     439                 :            :     throw( uno::RuntimeException )
     440                 :            : {
     441                 :          0 :     return ::getCppuType((const drawing::PointSequence*)0);
     442                 :            : }
     443                 :            : 
     444                 :         46 : sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements(  )
     445                 :            :     throw( uno::RuntimeException )
     446                 :            : {
     447         [ +  - ]:         46 :     SolarMutexGuard aGuard;
     448                 :            : 
     449                 :            :     NameOrIndex *pItem;
     450                 :            : 
     451 [ +  - ][ +  - ]:         46 :     const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
     452                 :            :     sal_uInt32 nSurrogate;
     453         [ +  + ]:         58 :     for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
     454                 :            :     {
     455         [ +  - ]:         24 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
     456 [ +  - ][ +  - ]:         24 :         if( pItem && pItem->GetName().Len() != 0 )
         [ +  + ][ +  - ]
                 [ +  - ]
           [ +  +  #  # ]
     457                 :         12 :             return sal_True;
     458                 :            :     }
     459                 :            : 
     460 [ +  - ][ +  - ]:         34 :     const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
     461         [ -  + ]:         34 :     for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
     462                 :            :     {
     463         [ #  # ]:          0 :         pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
     464 [ #  # ][ #  # ]:          0 :         if( pItem && pItem->GetName().Len() != 0 )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     465                 :          0 :             return sal_True;
     466                 :            :     }
     467                 :            : 
     468         [ +  - ]:         46 :     return sal_False;
     469                 :            : }
     470                 :            : 
     471                 :            : /**
     472                 :            :  * Create a hatchtable
     473                 :            :  */
     474                 :         66 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoMarkerTable_createInstance( SdrModel* pModel )
     475                 :            : {
     476                 :         66 :     return *new SvxUnoMarkerTable(pModel);
     477                 :            : }
     478                 :            : 
     479                 :            : 
     480                 :            : 
     481                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10