LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - unocpres.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 128 219 58.4 %
Date: 2012-08-25 Functions: 22 40 55.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 145 402 36.1 %

           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                 :            : #include <algorithm>
      30                 :            : 
      31                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      32                 :            : #include <osl/mutex.hxx>
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <svx/svdpage.hxx>
      35                 :            : #include <comphelper/extract.hxx>
      36                 :            : #include <comphelper/serviceinfohelper.hxx>
      37                 :            : 
      38                 :            : #include "unohelp.hxx"
      39                 :            : #include "unomodel.hxx"
      40                 :            : #include "drawdoc.hxx"
      41                 :            : #include "unocpres.hxx"
      42                 :            : #include "cusshow.hxx"
      43                 :            : #include "unopage.hxx"
      44                 :            : #include "customshowlist.hxx"
      45                 :            : 
      46                 :            : using namespace ::rtl;
      47                 :            : using namespace ::com::sun::star;
      48                 :            : 
      49                 :            : 
      50                 :          0 : uno::Reference< uno::XInterface > createUnoCustomShow( SdCustomShow* pShow )
      51                 :            : {
      52                 :          0 :     return (cppu::OWeakObject*)new SdXCustomPresentation( pShow, NULL );
      53                 :            : }
      54                 :            : 
      55                 :          6 : SdXCustomPresentation::SdXCustomPresentation() throw()
      56                 :            : :   mpSdCustomShow(NULL), mpModel(NULL),
      57                 :            :     aDisposeListeners( aDisposeContainerMutex ),
      58 [ +  - ][ +  - ]:          6 :     bDisposing( sal_False )
      59                 :            : {
      60                 :          6 : }
      61                 :            : 
      62                 :          0 : SdXCustomPresentation::SdXCustomPresentation( SdCustomShow* pShow, SdXImpressDocument* pMyModel) throw()
      63                 :            : :   mpSdCustomShow(pShow), mpModel(pMyModel),
      64                 :            :     aDisposeListeners( aDisposeContainerMutex ),
      65 [ #  # ][ #  # ]:          0 :     bDisposing( sal_False )
      66                 :            : {
      67                 :          0 : }
      68                 :            : 
      69 [ +  - ][ +  - ]:          6 : SdXCustomPresentation::~SdXCustomPresentation() throw()
      70                 :            : {
      71         [ -  + ]:         12 : }
      72                 :            : 
      73 [ +  - ][ +  - ]:         24 : UNO3_GETIMPLEMENTATION_IMPL( SdXCustomPresentation );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      74                 :            : 
      75                 :            : // XServiceInfo
      76                 :          0 : OUString SAL_CALL SdXCustomPresentation::getImplementationName()
      77                 :            :     throw(uno::RuntimeException)
      78                 :            : {
      79                 :          0 :     return OUString( "SdXCustomPresentation" ) ;
      80                 :            : }
      81                 :            : 
      82                 :          0 : sal_Bool SAL_CALL SdXCustomPresentation::supportsService( const OUString& ServiceName )
      83                 :            :     throw(uno::RuntimeException)
      84                 :            : {
      85                 :          0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
      86                 :            : }
      87                 :            : 
      88                 :          0 : uno::Sequence< OUString > SAL_CALL SdXCustomPresentation::getSupportedServiceNames()
      89                 :            :     throw(uno::RuntimeException)
      90                 :            : {
      91                 :          0 :     OUString aSN( "com.sun.star.presentation.CustomPresentation" );
      92         [ #  # ]:          0 :     uno::Sequence< OUString > aSeq( &aSN, 1 );
      93                 :          0 :     return aSeq;
      94                 :            : }
      95                 :            : 
      96                 :            : // XIndexContainer
      97                 :         10 : void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::Any& Element )
      98                 :            :     throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
      99                 :            : {
     100         [ +  - ]:         10 :     SolarMutexGuard aGuard;
     101                 :            : 
     102         [ -  + ]:         10 :     if( bDisposing )
     103         [ #  # ]:          0 :         throw lang::DisposedException();
     104                 :            : 
     105 [ +  - ][ +  - ]:         10 :     if( Index < 0 || Index > (sal_Int32)( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
         [ +  - ][ -  + ]
                 [ -  + ]
     106         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     107                 :            : 
     108                 :         10 :     uno::Reference< drawing::XDrawPage > xPage;
     109         [ +  - ]:         10 :     Element >>= xPage;
     110                 :            : 
     111         [ +  + ]:         10 :     if(!xPage.is())
     112         [ +  - ]:          4 :         throw lang::IllegalArgumentException();
     113                 :            : 
     114         [ +  - ]:          6 :     SdDrawPage* pPage = SdDrawPage::getImplementation( xPage );
     115                 :            : 
     116         [ +  - ]:          6 :     if(pPage)
     117                 :            :     {
     118         [ +  + ]:          6 :         if( NULL == mpModel )
     119         [ +  - ]:          2 :             mpModel = pPage->GetModel();
     120                 :            : 
     121 [ +  - ][ -  + ]:          6 :         if( NULL != mpModel && NULL == mpSdCustomShow && mpModel->GetDoc() )
         [ #  # ][ -  + ]
     122 [ #  # ][ #  # ]:          0 :             mpSdCustomShow = new SdCustomShow( mpModel->GetDoc() );
     123                 :            : 
     124 [ +  - ][ +  - ]:         12 :         mpSdCustomShow->PagesVector().insert(mpSdCustomShow->PagesVector().begin() + Index,
     125 [ +  - ][ +  - ]:         18 :             (SdPage*) pPage->GetSdrPage());
     126                 :            :     }
     127                 :            : 
     128         [ +  - ]:          6 :     if( mpModel )
     129         [ +  - ]:         10 :         mpModel->SetModified();
     130                 :          6 : }
     131                 :            : 
     132                 :         12 : void SAL_CALL SdXCustomPresentation::removeByIndex( sal_Int32 Index )
     133                 :            :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     134                 :            : {
     135         [ +  - ]:         12 :     SolarMutexGuard aGuard;
     136                 :            : 
     137         [ -  + ]:         12 :     if( bDisposing )
     138         [ #  # ]:          0 :         throw lang::DisposedException();
     139                 :            : 
     140         [ +  - ]:         12 :     if(mpSdCustomShow)
     141                 :            :     {
     142                 :         12 :         uno::Reference< drawing::XDrawPage > xPage;
     143 [ +  - ][ +  + ]:         12 :         getByIndex( Index ) >>= xPage;
     144                 :            : 
     145         [ +  - ]:          6 :         if( xPage.is() )
     146                 :            :         {
     147         [ +  - ]:          6 :             SvxDrawPage* pPage = SvxDrawPage::getImplementation( xPage );
     148         [ +  - ]:          6 :             if(pPage)
     149                 :            :             {
     150                 :            :                 SdCustomShow::PageVec::iterator it = std::find(
     151         [ +  - ]:          6 :                     mpSdCustomShow->PagesVector().begin(),
     152         [ +  - ]:          6 :                     mpSdCustomShow->PagesVector().end(),
     153         [ +  - ]:         18 :                     pPage->GetSdrPage());
     154 [ +  - ][ +  - ]:          6 :                 if (it != mpSdCustomShow->PagesVector().end())
                 [ +  - ]
     155 [ +  - ][ +  - ]:          6 :                     mpSdCustomShow->PagesVector().erase(it);
     156                 :            :             }
     157                 :         12 :         }
     158                 :            :     }
     159                 :            : 
     160         [ +  - ]:          6 :     if( mpModel )
     161         [ +  - ]:         12 :         mpModel->SetModified();
     162                 :          6 : }
     163                 :            : 
     164                 :            : // XIndexReplace
     165                 :          8 : void SAL_CALL SdXCustomPresentation::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
     166                 :            :     throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     167                 :            : {
     168                 :          8 :     removeByIndex( Index );
     169                 :          4 :     insertByIndex( Index, Element );
     170                 :          2 : }
     171                 :            : 
     172                 :            : // XElementAccess
     173                 :          2 : uno::Type SAL_CALL SdXCustomPresentation::getElementType()
     174                 :            :     throw(uno::RuntimeException)
     175                 :            : {
     176                 :          2 :     return ITYPE( drawing::XDrawPage );
     177                 :            : }
     178                 :            : 
     179                 :          2 : sal_Bool SAL_CALL SdXCustomPresentation::hasElements()
     180                 :            :     throw(uno::RuntimeException)
     181                 :            : {
     182         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     183                 :            : 
     184         [ -  + ]:          2 :     if( bDisposing )
     185         [ #  # ]:          0 :         throw lang::DisposedException();
     186                 :            : 
     187 [ +  - ][ +  - ]:          2 :     return getCount() > 0;
     188                 :            : }
     189                 :            : 
     190                 :            : // XIndexAccess
     191                 :          8 : sal_Int32 SAL_CALL SdXCustomPresentation::getCount()
     192                 :            :     throw(uno::RuntimeException)
     193                 :            : {
     194         [ +  - ]:          8 :     SolarMutexGuard aGuard;
     195         [ -  + ]:          8 :     if( bDisposing )
     196         [ #  # ]:          0 :         throw lang::DisposedException();
     197                 :            : 
     198 [ +  - ][ +  - ]:          8 :     return mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0;
                 [ +  - ]
     199                 :            : }
     200                 :            : 
     201                 :         26 : uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index )
     202                 :            :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     203                 :            : {
     204         [ +  - ]:         26 :     SolarMutexGuard aGuard;
     205                 :            : 
     206         [ -  + ]:         26 :     if( bDisposing )
     207         [ #  # ]:          0 :         throw lang::DisposedException();
     208                 :            : 
     209 [ +  - ][ +  - ]:         26 :     if( Index < 0 || Index >= (sal_Int32)mpSdCustomShow->PagesVector().size() )
         [ +  + ][ +  + ]
     210         [ +  - ]:          8 :         throw lang::IndexOutOfBoundsException();
     211                 :            : 
     212                 :         18 :     uno::Any aAny;
     213         [ +  - ]:         18 :     if(mpSdCustomShow )
     214                 :            :     {
     215 [ +  - ][ +  - ]:         18 :         SdrPage* pPage = (SdrPage*)mpSdCustomShow->PagesVector()[Index];
     216                 :            : 
     217         [ +  - ]:         18 :         if( pPage )
     218                 :            :         {
     219 [ +  - ][ +  - ]:         18 :             uno::Reference< drawing::XDrawPage > xRef( pPage->getUnoPage(), uno::UNO_QUERY );
     220         [ +  - ]:         18 :             aAny <<= xRef;
     221                 :            :         }
     222                 :            :     }
     223                 :            : 
     224         [ +  - ]:         26 :     return aAny;
     225                 :            : }
     226                 :            : 
     227                 :            : // XNamed
     228                 :          6 : OUString SAL_CALL SdXCustomPresentation::getName()
     229                 :            :     throw(uno::RuntimeException)
     230                 :            : {
     231         [ +  - ]:          6 :     SolarMutexGuard aGuard;
     232                 :            : 
     233         [ -  + ]:          6 :     if( bDisposing )
     234         [ #  # ]:          0 :         throw lang::DisposedException();
     235                 :            : 
     236         [ +  - ]:          6 :     if(mpSdCustomShow)
     237 [ +  - ][ +  - ]:          6 :         return mpSdCustomShow->GetName();
                 [ +  - ]
     238                 :            : 
     239         [ +  - ]:          6 :     return OUString();
     240                 :            : }
     241                 :            : 
     242                 :          4 : void SAL_CALL SdXCustomPresentation::setName( const OUString& aName )
     243                 :            :     throw(uno::RuntimeException)
     244                 :            : {
     245         [ +  - ]:          4 :     SolarMutexGuard aGuard;
     246                 :            : 
     247         [ -  + ]:          4 :     if( bDisposing )
     248         [ #  # ]:          0 :         throw lang::DisposedException();
     249                 :            : 
     250         [ +  - ]:          4 :     if(mpSdCustomShow)
     251 [ +  - ][ +  - ]:          4 :         mpSdCustomShow->SetName( aName );
         [ +  - ][ +  - ]
     252                 :          4 : }
     253                 :            : 
     254                 :            : // XComponent
     255                 :          6 : void SAL_CALL SdXCustomPresentation::dispose() throw(uno::RuntimeException)
     256                 :            : {
     257         [ +  - ]:          6 :     SolarMutexGuard aGuard;
     258                 :            : 
     259         [ -  + ]:          6 :     if( bDisposing )
     260                 :          6 :         return; // catched a recursion
     261                 :            : 
     262                 :          6 :     bDisposing = sal_True;
     263                 :            : 
     264         [ +  - ]:          6 :     uno::Reference< uno::XInterface > xSource( (cppu::OWeakObject*)this );
     265                 :            : 
     266         [ +  - ]:          6 :     lang::EventObject aEvt;
     267         [ +  - ]:          6 :     aEvt.Source = xSource;
     268         [ +  - ]:          6 :     aDisposeListeners.disposeAndClear(aEvt);
     269                 :            : 
     270 [ +  - ][ +  - ]:          6 :     mpSdCustomShow = NULL;
                 [ +  - ]
     271                 :            : }
     272                 :            : 
     273                 :            : //----------------------------------------------------------------------
     274                 :          0 : void SAL_CALL SdXCustomPresentation::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
     275                 :            :     throw(uno::RuntimeException)
     276                 :            : {
     277         [ #  # ]:          0 :     if( bDisposing )
     278         [ #  # ]:          0 :         throw lang::DisposedException();
     279                 :            : 
     280                 :          0 :     aDisposeListeners.addInterface(xListener);
     281                 :          0 : }
     282                 :            : 
     283                 :            : //----------------------------------------------------------------------
     284                 :          0 : void SAL_CALL SdXCustomPresentation::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException)
     285                 :            : {
     286         [ #  # ]:          0 :     if( !bDisposing )
     287                 :          0 :         aDisposeListeners.removeInterface(aListener);
     288                 :          0 : }
     289                 :            : 
     290                 :            : /*===========================================================================*
     291                 :            :  *  class SdXCustomPresentationAccess : public XCustomPresentationAccess,    *
     292                 :            :  *                                      public UsrObject                     *
     293                 :            :  *===========================================================================*/
     294                 :            : 
     295                 :         15 : SdXCustomPresentationAccess::SdXCustomPresentationAccess(SdXImpressDocument& rMyModel) throw()
     296                 :         15 : : mrModel(rMyModel)
     297                 :            : {
     298                 :         15 : }
     299                 :            : 
     300                 :         15 : SdXCustomPresentationAccess::~SdXCustomPresentationAccess() throw()
     301                 :            : {
     302         [ -  + ]:         30 : }
     303                 :            : 
     304                 :            : // XServiceInfo
     305                 :          0 : OUString SAL_CALL SdXCustomPresentationAccess::getImplementationName()
     306                 :            :     throw(uno::RuntimeException)
     307                 :            : {
     308                 :          0 :     return OUString( "SdXCustomPresentationAccess" );
     309                 :            : }
     310                 :            : 
     311                 :          0 : sal_Bool SAL_CALL SdXCustomPresentationAccess::supportsService( const OUString& ServiceName )
     312                 :            :     throw(uno::RuntimeException)
     313                 :            : {
     314                 :          0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     315                 :            : }
     316                 :            : 
     317                 :          0 : uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getSupportedServiceNames()
     318                 :            :     throw(uno::RuntimeException)
     319                 :            : {
     320                 :          0 :     const OUString aNS( "com.sun.star.presentation.CustomPresentationAccess" );
     321         [ #  # ]:          0 :     uno::Sequence< OUString > aSeq( &aNS, 1 );
     322                 :          0 :     return aSeq;
     323                 :            : }
     324                 :            : 
     325                 :            : // XSingleServiceFactory
     326                 :          6 : uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstance()
     327                 :            :     throw(uno::Exception, uno::RuntimeException)
     328                 :            : {
     329         [ +  - ]:          6 :     uno::Reference< uno::XInterface >  xRef( (::cppu::OWeakObject*)new SdXCustomPresentation() );
     330                 :          6 :     return xRef;
     331                 :            : }
     332                 :            : 
     333                 :          0 : uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstanceWithArguments( const uno::Sequence< uno::Any >& )
     334                 :            :     throw(uno::Exception, uno::RuntimeException)
     335                 :            : {
     336                 :          0 :     return createInstance();
     337                 :            : }
     338                 :            : 
     339                 :            : // XNameContainer
     340                 :          6 : void SAL_CALL SdXCustomPresentationAccess::insertByName( const OUString& aName, const uno::Any& aElement )
     341                 :            :     throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
     342                 :            : {
     343         [ +  - ]:          6 :     SolarMutexGuard aGuard;
     344                 :            : 
     345                 :            :     // get the documents custom show list
     346                 :          6 :     SdCustomShowList* pList = 0;
     347         [ +  - ]:          6 :     if(mrModel.GetDoc())
     348         [ +  - ]:          6 :         pList = mrModel.GetDoc()->GetCustomShowList(sal_True);
     349                 :            : 
     350                 :            :     // no list, no cookies
     351         [ -  + ]:          6 :     if( NULL == pList)
     352         [ #  # ]:          0 :         throw uno::RuntimeException();
     353                 :            : 
     354                 :            :     // do we have an container::XIndexContainer?
     355                 :          6 :     SdXCustomPresentation* pXShow = NULL;
     356                 :            : 
     357                 :          6 :     uno::Reference< container::XIndexContainer > xContainer;
     358 [ +  - ][ +  - ]:          6 :     if( (aElement >>= xContainer) && xContainer.is() )
         [ +  - ][ +  - ]
     359         [ +  - ]:          6 :         pXShow = SdXCustomPresentation::getImplementation(xContainer);
     360                 :            : 
     361         [ -  + ]:          6 :     if( NULL == pXShow )
     362         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     363                 :            : 
     364                 :            :     // get the internal custom show from the api wrapper
     365                 :          6 :     SdCustomShow* pShow = pXShow->GetSdCustomShow();
     366         [ +  - ]:          6 :     if( NULL == pShow )
     367                 :            :     {
     368 [ +  - ][ +  - ]:          6 :         pShow = new SdCustomShow( mrModel.GetDoc(), xContainer );
     369                 :          6 :         pXShow->SetSdCustomShow( pShow );
     370                 :            :     }
     371                 :            :     else
     372                 :            :     {
     373 [ #  # ][ #  # ]:          0 :         if( NULL == pXShow->GetModel() || *pXShow->GetModel() != mrModel )
         [ #  # ][ #  # ]
     374         [ #  # ]:          0 :             throw lang::IllegalArgumentException();
     375                 :            :     }
     376                 :            : 
     377                 :            :     // give it a name
     378 [ +  - ][ +  - ]:          6 :     pShow->SetName( aName);
                 [ +  - ]
     379                 :            : 
     380                 :            :     // check if this or another customshow with the same name already exists
     381 [ +  - ][ +  - ]:          8 :     for( SdCustomShow* pCompare = pList->First();
                 [ +  + ]
     382                 :            :          pCompare;
     383                 :            :          pCompare = pList->Next() )
     384                 :            :     {
     385 [ +  - ][ +  - ]:          2 :         if( pCompare == pShow || pCompare->GetName() == pShow->GetName() )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     386         [ #  # ]:          0 :             throw container::ElementExistException();
     387                 :            :     }
     388                 :            : 
     389         [ +  - ]:          6 :     pList->push_back(pShow);
     390                 :            : 
     391         [ +  - ]:          6 :     mrModel.SetModified();
     392                 :          6 : }
     393                 :            : 
     394                 :          0 : void SAL_CALL SdXCustomPresentationAccess::removeByName( const OUString& Name )
     395                 :            :     throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     396                 :            : {
     397         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     398                 :            : 
     399                 :          0 :     SdCustomShow* pShow = getSdCustomShow(Name);
     400                 :            : 
     401                 :          0 :     SdCustomShowList* pList = GetCustomShowList();
     402 [ #  # ][ #  # ]:          0 :     if(pList && pShow)
     403 [ #  # ][ #  # ]:          0 :         delete pList->Remove( pShow );
                 [ #  # ]
     404                 :            :     else
     405         [ #  # ]:          0 :         throw container::NoSuchElementException();
     406                 :            : 
     407         [ #  # ]:          0 :     mrModel.SetModified();
     408                 :          0 : }
     409                 :            : 
     410                 :            : // XNameReplace
     411                 :          0 : void SAL_CALL SdXCustomPresentationAccess::replaceByName( const OUString& aName, const uno::Any& aElement )
     412                 :            :     throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     413                 :            : {
     414                 :          0 :     removeByName( aName );
     415                 :          0 :     insertByName( aName, aElement );
     416                 :          0 : }
     417                 :            : 
     418                 :            : // XNameAccess
     419                 :          0 : uno::Any SAL_CALL SdXCustomPresentationAccess::getByName( const OUString& aName )
     420                 :            :     throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     421                 :            : {
     422         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     423                 :            : 
     424                 :          0 :     uno::Any aAny;
     425                 :            : 
     426                 :          0 :     SdCustomShow* pShow = getSdCustomShow(aName);
     427         [ #  # ]:          0 :     if(pShow)
     428                 :            :     {
     429 [ #  # ][ #  # ]:          0 :         uno::Reference< container::XIndexContainer >  xRef( pShow->getUnoCustomShow(), uno::UNO_QUERY );
     430         [ #  # ]:          0 :         aAny <<= xRef;
     431                 :            :     }
     432                 :            :     else
     433                 :            :     {
     434         [ #  # ]:          0 :         throw container::NoSuchElementException();
     435                 :            :     }
     436                 :            : 
     437         [ #  # ]:          0 :     return aAny;
     438                 :            : }
     439                 :            : 
     440                 :          4 : uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getElementNames()
     441                 :            :     throw(uno::RuntimeException)
     442                 :            : {
     443         [ +  - ]:          4 :     SolarMutexGuard aGuard;
     444                 :            : 
     445                 :          4 :     SdCustomShowList* pList = GetCustomShowList();
     446         [ -  + ]:          4 :     const sal_uInt32 nCount = pList ? pList->size() : 0;
     447                 :            : 
     448         [ +  - ]:          4 :     uno::Sequence< OUString > aSequence( nCount );
     449         [ +  - ]:          4 :     OUString* pStringList = aSequence.getArray();
     450                 :            : 
     451                 :          4 :     sal_uInt32 nIdx = 0;
     452         [ -  + ]:          4 :     while( nIdx < nCount )
     453                 :            :     {
     454         [ #  # ]:          0 :         const SdCustomShow* pShow = (*pList)[nIdx];
     455 [ #  # ][ #  # ]:          0 :         pStringList[nIdx] = pShow->GetName();
                 [ #  # ]
     456                 :          0 :         nIdx++;
     457                 :            :     }
     458                 :            : 
     459         [ +  - ]:          4 :     return aSequence;
     460                 :            : }
     461                 :            : 
     462                 :            : 
     463                 :          0 : sal_Bool SAL_CALL SdXCustomPresentationAccess::hasByName( const OUString& aName )
     464                 :            :     throw(uno::RuntimeException)
     465                 :            : {
     466         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     467         [ #  # ]:          0 :     return getSdCustomShow(aName) != NULL;
     468                 :            : }
     469                 :            : 
     470                 :            : // XElementAccess
     471                 :          0 : uno::Type SAL_CALL SdXCustomPresentationAccess::getElementType()
     472                 :            :     throw(uno::RuntimeException)
     473                 :            : {
     474                 :          0 :     return ITYPE( container::XIndexContainer );
     475                 :            : }
     476                 :            : 
     477                 :          0 : sal_Bool SAL_CALL SdXCustomPresentationAccess::hasElements()
     478                 :            :     throw(uno::RuntimeException)
     479                 :            : {
     480         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     481                 :            : 
     482                 :          0 :     SdCustomShowList* pList = GetCustomShowList();
     483 [ #  # ][ #  # ]:          0 :     return pList && !pList->empty();
                 [ #  # ]
     484                 :            : }
     485                 :            : 
     486                 :          0 : SdCustomShow * SdXCustomPresentationAccess::getSdCustomShow( const OUString& Name ) const throw()
     487                 :            : {
     488                 :          0 :     sal_uInt32 nIdx = 0;
     489                 :            : 
     490                 :          0 :     SdCustomShowList* pList = GetCustomShowList();
     491         [ #  # ]:          0 :     const sal_uInt32 nCount = pList ? pList->size() : 0;
     492                 :            : 
     493         [ #  # ]:          0 :     const String aName( Name );
     494                 :            : 
     495         [ #  # ]:          0 :     while( nIdx < nCount )
     496                 :            :     {
     497         [ #  # ]:          0 :         SdCustomShow* pShow = (*pList)[nIdx];
     498 [ #  # ][ #  # ]:          0 :         if( pShow->GetName() == aName )
         [ #  # ][ #  # ]
     499                 :          0 :             return pShow;
     500                 :          0 :         nIdx++;
     501                 :            :     }
     502         [ #  # ]:          0 :     return NULL;
     503                 :            : }
     504                 :            : 
     505                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10