LCOV - code coverage report
Current view: top level - sd/source/core - stlfamily.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 102 227 44.9 %
Date: 2012-08-25 Functions: 14 37 37.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 134 473 28.3 %

           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 <com/sun/star/lang/DisposedException.hpp>
      31                 :            : #include <com/sun/star/lang/IllegalAccessException.hpp>
      32                 :            : #include <comphelper/serviceinfohelper.hxx>
      33                 :            : 
      34                 :            : #include <osl/mutex.hxx>
      35                 :            : #include <vcl/svapp.hxx>
      36                 :            : 
      37                 :            : #include <svl/style.hxx>
      38                 :            : 
      39                 :            : #include <svx/unoprov.hxx>
      40                 :            : 
      41                 :            : #include "../ui/inc/strings.hrc"
      42                 :            : #include "stlfamily.hxx"
      43                 :            : #include "stlsheet.hxx"
      44                 :            : #include "sdresid.hxx"
      45                 :            : #include "drawdoc.hxx"
      46                 :            : #include "sdpage.hxx"
      47                 :            : #include "glob.hxx"
      48                 :            : 
      49                 :            : #include <map>
      50                 :            : 
      51                 :            : using ::rtl::OUString;
      52                 :            : using namespace ::com::sun::star::uno;
      53                 :            : using namespace ::com::sun::star::lang;
      54                 :            : using namespace ::com::sun::star::container;
      55                 :            : using namespace ::com::sun::star::style;
      56                 :            : using namespace ::com::sun::star::beans;
      57                 :            : 
      58                 :            : // ----------------------------------------------------------
      59                 :            : 
      60                 :            : typedef std::map< rtl::OUString, rtl::Reference< SdStyleSheet > > PresStyleMap;
      61                 :            : 
      62 [ +  - ][ +  - ]:        351 : struct SdStyleFamilyImpl
                 [ +  - ]
      63                 :            : {
      64                 :            :     SdrPageWeakRef mxMasterPage;
      65                 :            :     String maLayoutName;
      66                 :            : 
      67                 :            :     PresStyleMap& getStyleSheets();
      68                 :            :     rtl::Reference< SfxStyleSheetPool > mxPool;
      69                 :            : 
      70                 :            : private:
      71                 :            :     PresStyleMap maStyleSheets;
      72                 :            : };
      73                 :            : 
      74                 :        586 : PresStyleMap& SdStyleFamilyImpl::getStyleSheets()
      75                 :            : {
      76 [ +  - ][ +  - ]:        586 :     if( mxMasterPage.is() && (mxMasterPage->GetLayoutName() != maLayoutName) )
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
      77                 :            :     {
      78 [ +  - ][ +  - ]:         18 :         maLayoutName = mxMasterPage->GetLayoutName();
                 [ +  - ]
      79                 :            : 
      80         [ +  - ]:         18 :         String aLayoutName( maLayoutName );
      81 [ +  - ][ +  - ]:         18 :         const sal_uInt16 nLen = aLayoutName.Search(String( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4;
                 [ +  - ]
      82         [ +  - ]:         18 :         aLayoutName.Erase( nLen );
      83                 :            : 
      84 [ -  + ][ #  # ]:         18 :         if( (maStyleSheets.empty()) || !((*maStyleSheets.begin()).second->GetName().Equals( aLayoutName, 0, nLen )) )
         [ #  # ][ #  # ]
                 [ -  + ]
           [ +  -  #  # ]
      85                 :            :         {
      86                 :         18 :             maStyleSheets.clear();
      87                 :            : 
      88         [ +  - ]:         18 :             const SfxStyles& rStyles = mxPool->GetStyles();
      89 [ +  - ][ +  + ]:       1404 :             for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
      90                 :            :             {
      91                 :       1386 :                 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
      92 [ +  + ][ +  - ]:       1386 :                 if( pStyle && (pStyle->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) && (pStyle->GetName().Equals( aLayoutName, 0, nLen )) )
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
      93 [ +  - ][ +  - ]:        252 :                     maStyleSheets[ pStyle->GetApiName() ] = rtl::Reference< SdStyleSheet >( pStyle );
                 [ +  - ]
      94                 :            :             }
      95         [ +  - ]:         18 :         }
      96                 :            :     }
      97                 :            : 
      98                 :        586 :     return maStyleSheets;
      99                 :            : }
     100                 :            : 
     101                 :            : // ----------------------------------------------------------
     102                 :            : 
     103                 :        356 : SdStyleFamily::SdStyleFamily( const rtl::Reference< SfxStyleSheetPool >& xPool, SfxStyleFamily nFamily )
     104                 :            : : mnFamily( nFamily )
     105                 :            : , mxPool( xPool )
     106                 :        356 : , mpImpl( 0 )
     107                 :            : {
     108                 :        356 : }
     109                 :            : 
     110                 :            : // ----------------------------------------------------------
     111                 :            : 
     112                 :        177 : SdStyleFamily::SdStyleFamily( const rtl::Reference< SfxStyleSheetPool >& xPool, const SdPage* pMasterPage )
     113                 :            : : mnFamily( SD_STYLE_FAMILY_MASTERPAGE )
     114                 :            : , mxPool( xPool )
     115 [ +  - ][ +  - ]:        177 : , mpImpl( new SdStyleFamilyImpl() )
     116                 :            : {
     117         [ +  - ]:        177 :     mpImpl->mxMasterPage.reset( const_cast< SdPage* >( pMasterPage ) );
     118         [ +  - ]:        177 :     mpImpl->mxPool = xPool;
     119                 :        177 : }
     120                 :            : 
     121                 :            : // ----------------------------------------------------------
     122                 :            : 
     123                 :        524 : SdStyleFamily::~SdStyleFamily()
     124                 :            : {
     125                 :            :     DBG_ASSERT( !mxPool.is(), "SdStyleFamily::~SdStyleFamily(), dispose me first!" );
     126 [ -  + ][ #  # ]:        524 :     delete mpImpl;
     127         [ -  + ]:       1048 : }
     128                 :            : 
     129                 :            : // ----------------------------------------------------------
     130                 :            : 
     131                 :       1977 : void SdStyleFamily::throwIfDisposed() const throw(RuntimeException)
     132                 :            : {
     133         [ -  + ]:       1977 :     if( !mxPool.is() )
     134         [ #  # ]:          0 :         throw DisposedException();
     135                 :       1977 : }
     136                 :            : 
     137                 :            : // ----------------------------------------------------------
     138                 :            : 
     139                 :          0 : SdStyleSheet* SdStyleFamily::GetValidNewSheet( const Any& rElement ) throw(IllegalArgumentException)
     140                 :            : {
     141         [ #  # ]:          0 :     Reference< XStyle > xStyle( rElement, UNO_QUERY );
     142 [ #  # ][ #  # ]:          0 :     SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( xStyle.get() );
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     if( pStyle == 0 || (pStyle->GetFamily() != mnFamily) || (&pStyle->GetPool() != mxPool.get()) || (mxPool->Find( pStyle->GetName(), mnFamily) != 0) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     145         [ #  # ]:          0 :         throw IllegalArgumentException();
     146                 :            : 
     147                 :          0 :     return pStyle;
     148                 :            : }
     149                 :            : 
     150                 :            : // ----------------------------------------------------------
     151                 :            : 
     152                 :       1600 : SdStyleSheet* SdStyleFamily::GetSheetByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException )
     153                 :            : {
     154                 :       1600 :     SdStyleSheet* pRet = 0;
     155         [ +  - ]:       1600 :     if( !rName.isEmpty() )
     156                 :            :     {
     157         [ +  + ]:       1600 :         if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     158                 :            :         {
     159         [ +  - ]:        412 :             PresStyleMap& rStyleMap = mpImpl->getStyleSheets();
     160         [ +  - ]:        412 :             PresStyleMap::iterator iter( rStyleMap.find(rName) );
     161         [ +  - ]:        412 :             if( iter != rStyleMap.end() )
     162                 :        412 :                 pRet = (*iter).second.get();
     163                 :            :         }
     164                 :            :         else
     165                 :            :         {
     166                 :       1188 :             const SfxStyles& rStyles = mxPool->GetStyles();
     167 [ +  - ][ +  - ]:      25965 :             for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     168                 :            :             {
     169                 :      24777 :                 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     170 [ +  + ][ +  - ]:      24777 :                 if( pStyle && (pStyle->GetFamily() == mnFamily) && (pStyle->GetApiName() == rName) )
         [ +  + ][ +  + ]
           [ +  +  #  # ]
                 [ +  - ]
     171                 :            :                 {
     172                 :       1188 :                     pRet = pStyle;
     173                 :       1188 :                     break;
     174                 :            :                 }
     175                 :            :             }
     176                 :            :         }
     177                 :            :     }
     178         [ +  - ]:       1600 :     if( pRet )
     179                 :       1600 :         return pRet;
     180                 :            : 
     181         [ #  # ]:          0 :     throw NoSuchElementException();
     182                 :            : }
     183                 :            : 
     184                 :            : // ----------------------------------------------------------
     185                 :            : // XServiceInfo
     186                 :            : // ----------------------------------------------------------
     187                 :            : 
     188                 :          0 : OUString SAL_CALL SdStyleFamily::getImplementationName() throw(RuntimeException)
     189                 :            : {
     190                 :          0 :     return OUString( "SdStyleFamily" );
     191                 :            : }
     192                 :            : 
     193                 :            : // ----------------------------------------------------------
     194                 :            : 
     195                 :          0 : sal_Bool SAL_CALL SdStyleFamily::supportsService( const OUString& ServiceName ) throw(RuntimeException)
     196                 :            : {
     197                 :          0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     198                 :            : }
     199                 :            : 
     200                 :            : // ----------------------------------------------------------
     201                 :            : 
     202                 :          0 : Sequence< OUString > SAL_CALL SdStyleFamily::getSupportedServiceNames() throw(RuntimeException)
     203                 :            : {
     204                 :          0 :     OUString aServiceName( "com.sun.star.style.StyleFamily" );
     205         [ #  # ]:          0 :     Sequence< OUString > aSeq( &aServiceName, 1 );
     206                 :          0 :     return aSeq;
     207                 :            : }
     208                 :            : 
     209                 :            : // ----------------------------------------------------------
     210                 :            : // XNamed
     211                 :            : // ----------------------------------------------------------
     212                 :            : 
     213                 :       1628 : OUString SAL_CALL SdStyleFamily::getName() throw (RuntimeException)
     214                 :            : {
     215         [ +  + ]:       1628 :     if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     216                 :            :     {
     217                 :        300 :         SdPage* pPage = static_cast< SdPage* >( mpImpl->mxMasterPage.get() );
     218         [ -  + ]:        300 :         if( pPage == 0 )
     219         [ #  # ]:          0 :             throw DisposedException();
     220                 :            : 
     221         [ +  - ]:        300 :         String aLayoutName( pPage->GetLayoutName() );
     222         [ +  - ]:        300 :         const String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
     223 [ +  - ][ +  - ]:        300 :         aLayoutName.Erase(aLayoutName.Search(aSep));
     224                 :            : 
     225 [ +  - ][ +  - ]:        300 :         return OUString( aLayoutName );
                 [ +  - ]
     226                 :            :     }
     227                 :            :     else
     228                 :            :     {
     229                 :       1628 :         return SdStyleSheet::GetFamilyString( mnFamily );
     230                 :            :     }
     231                 :            : }
     232                 :            : 
     233                 :            : // ----------------------------------------------------------
     234                 :            : 
     235                 :          0 : void SAL_CALL SdStyleFamily::setName( const ::rtl::OUString& ) throw (RuntimeException)
     236                 :            : {
     237                 :          0 : }
     238                 :            : 
     239                 :            : // ----------------------------------------------------------
     240                 :            : // XNameAccess
     241                 :            : // ----------------------------------------------------------
     242                 :            : 
     243                 :       1600 : Any SAL_CALL SdStyleFamily::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
     244                 :            : {
     245         [ +  - ]:       1600 :     SolarMutexGuard aGuard;
     246         [ +  - ]:       1600 :     throwIfDisposed();
     247 [ +  - ][ +  - ]:       1600 :     return Any( Reference< XStyle >( static_cast<SfxUnoStyleSheet*>(GetSheetByName( rName )) ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     248                 :            : }
     249                 :            : 
     250                 :            : // ----------------------------------------------------------
     251                 :            : 
     252                 :         30 : Sequence< OUString > SAL_CALL SdStyleFamily::getElementNames() throw(RuntimeException)
     253                 :            : {
     254         [ +  - ]:         30 :     SolarMutexGuard aGuard;
     255                 :            : 
     256         [ +  - ]:         30 :     throwIfDisposed();
     257                 :            : 
     258         [ +  + ]:         30 :     if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     259                 :            :     {
     260         [ +  - ]:          4 :         PresStyleMap& rStyleMap = mpImpl->getStyleSheets();
     261         [ +  - ]:          4 :         Sequence< OUString > aNames( rStyleMap.size() );
     262                 :            : 
     263                 :          4 :         PresStyleMap::iterator iter( rStyleMap.begin() );
     264         [ +  - ]:          4 :         OUString* pNames = aNames.getArray();
     265         [ +  + ]:         60 :         while( iter != rStyleMap.end() )
     266                 :            :         {
     267                 :         56 :             rtl::Reference< SdStyleSheet > xStyle( (*iter++).second );
     268         [ +  - ]:         56 :             if( xStyle.is() )
     269                 :            :             {
     270         [ +  - ]:         56 :                 *pNames++ = xStyle->GetApiName();
     271                 :            :             }
     272                 :         56 :         }
     273                 :            : 
     274 [ +  - ][ +  - ]:          4 :         return aNames;
     275                 :            :     }
     276                 :            :     else
     277                 :            :     {
     278         [ +  - ]:         26 :         std::vector< OUString > aNames;
     279         [ +  - ]:         26 :         const SfxStyles& rStyles = mxPool->GetStyles();
     280 [ +  - ][ +  + ]:       2028 :         for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     281                 :            :         {
     282                 :       2002 :             SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     283 [ +  + ][ +  + ]:       2002 :             if( pStyle && (pStyle->GetFamily() == mnFamily) )
                 [ +  - ]
     284 [ +  - ][ +  - ]:        618 :                 aNames.push_back( pStyle->GetApiName() );
     285                 :            :         }
     286         [ +  - ]:         26 :         return Sequence< OUString >( &(*aNames.begin()), aNames.size() );
     287         [ +  - ]:         30 :     }
     288                 :            : }
     289                 :            : 
     290                 :            : // ----------------------------------------------------------
     291                 :            : 
     292                 :        347 : sal_Bool SAL_CALL SdStyleFamily::hasByName( const OUString& aName ) throw(RuntimeException)
     293                 :            : {
     294         [ +  - ]:        347 :     SolarMutexGuard aGuard;
     295         [ +  - ]:        347 :     throwIfDisposed();
     296                 :            : 
     297         [ +  - ]:        347 :     if( !aName.isEmpty() )
     298                 :            :     {
     299         [ +  + ]:        347 :         if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     300                 :            :         {
     301         [ +  - ]:        170 :             PresStyleMap& rStyleSheets = mpImpl->getStyleSheets();
     302         [ +  - ]:        170 :             PresStyleMap::iterator iter( rStyleSheets.find(aName) );
     303         [ +  - ]:        170 :             return ( iter != rStyleSheets.end() ) ? sal_True : sal_False;
     304                 :            :         }
     305                 :            :         else
     306                 :            :         {
     307         [ +  - ]:        177 :             const SfxStyles& rStyles = mxPool->GetStyles();
     308 [ +  - ][ +  - ]:       1698 :             for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     309                 :            :             {
     310                 :       1698 :                 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     311 [ +  + ][ +  - ]:       1698 :                 if( pStyle && (pStyle->GetFamily() == mnFamily) && ( pStyle->GetApiName() == aName ) )
         [ +  + ][ +  + ]
           [ +  +  #  # ]
                 [ +  - ]
     312                 :        177 :                     return sal_True;
     313                 :            :             }
     314                 :            :         }
     315                 :            :     }
     316                 :            : 
     317         [ +  - ]:        347 :     return sal_False;
     318                 :            : }
     319                 :            : 
     320                 :            : // ----------------------------------------------------------
     321                 :            : // XElementAccess
     322                 :            : // ----------------------------------------------------------
     323                 :            : 
     324                 :          0 : Type SAL_CALL SdStyleFamily::getElementType() throw(RuntimeException)
     325                 :            : {
     326                 :          0 :     return XStyle::static_type();
     327                 :            : }
     328                 :            : 
     329                 :            : // ----------------------------------------------------------
     330                 :            : 
     331                 :          0 : sal_Bool SAL_CALL SdStyleFamily::hasElements() throw(RuntimeException)
     332                 :            : {
     333         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     334         [ #  # ]:          0 :     throwIfDisposed();
     335                 :            : 
     336         [ #  # ]:          0 :     if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     337                 :            :     {
     338                 :          0 :         return sal_True;
     339                 :            :     }
     340                 :            :     else
     341                 :            :     {
     342         [ #  # ]:          0 :         const SfxStyles& rStyles = mxPool->GetStyles();
     343 [ #  # ][ #  # ]:          0 :         for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     344                 :            :         {
     345                 :          0 :             SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     346 [ #  # ][ #  # ]:          0 :             if( pStyle && (pStyle->GetFamily() == mnFamily) )
                 [ #  # ]
     347                 :          0 :                 return sal_True;
     348                 :            :         }
     349                 :            :     }
     350                 :            : 
     351         [ #  # ]:          0 :     return sal_False;
     352                 :            : }
     353                 :            : 
     354                 :            : // ----------------------------------------------------------
     355                 :            : // XIndexAccess
     356                 :            : // ----------------------------------------------------------
     357                 :            : 
     358                 :          0 : sal_Int32 SAL_CALL SdStyleFamily::getCount() throw(RuntimeException)
     359                 :            : {
     360         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     361         [ #  # ]:          0 :     throwIfDisposed();
     362                 :            : 
     363                 :          0 :     sal_Int32 nCount = 0;
     364         [ #  # ]:          0 :     if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     365                 :            :     {
     366         [ #  # ]:          0 :         return mpImpl->getStyleSheets().size();
     367                 :            :     }
     368                 :            :     else
     369                 :            :     {
     370         [ #  # ]:          0 :         const SfxStyles& rStyles = mxPool->GetStyles();
     371 [ #  # ][ #  # ]:          0 :         for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     372                 :            :         {
     373                 :          0 :             SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     374 [ #  # ][ #  # ]:          0 :             if( pStyle && (pStyle->GetFamily() == mnFamily) )
                 [ #  # ]
     375                 :          0 :                 nCount++;
     376                 :            :         }
     377                 :            :     }
     378                 :            : 
     379         [ #  # ]:          0 :     return nCount;
     380                 :            : }
     381                 :            : 
     382                 :            : // ----------------------------------------------------------
     383                 :            : 
     384                 :          0 : Any SAL_CALL SdStyleFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
     385                 :            : {
     386         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     387         [ #  # ]:          0 :     throwIfDisposed();
     388                 :            : 
     389         [ #  # ]:          0 :     if( Index >= 0 )
     390                 :            :     {
     391         [ #  # ]:          0 :         if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     392                 :            :         {
     393         [ #  # ]:          0 :             PresStyleMap& rStyleSheets = mpImpl->getStyleSheets();
     394         [ #  # ]:          0 :             if( !rStyleSheets.empty() )
     395                 :            :             {
     396                 :          0 :                 PresStyleMap::iterator iter( rStyleSheets.begin() );
     397 [ #  # ][ #  # ]:          0 :                 while( Index-- && (iter != rStyleSheets.end()) )
         [ #  # ][ #  # ]
     398                 :          0 :                     ++iter;
     399                 :            : 
     400 [ #  # ][ #  # ]:          0 :                 if( (Index==-1) && (iter != rStyleSheets.end()) )
         [ #  # ][ #  # ]
     401 [ #  # ][ #  # ]:          0 :                     return Any( Reference< XStyle >( (*iter).second.get() ) );
                 [ #  # ]
     402                 :            :             }
     403                 :            :         }
     404                 :            :         else
     405                 :            :         {
     406         [ #  # ]:          0 :             const SfxStyles& rStyles = mxPool->GetStyles();
     407 [ #  # ][ #  # ]:          0 :             for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter )
     408                 :            :             {
     409                 :          0 :                 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     410 [ #  # ][ #  # ]:          0 :                 if( pStyle && (pStyle->GetFamily() == mnFamily) )
                 [ #  # ]
     411                 :            :                 {
     412         [ #  # ]:          0 :                     if( Index-- == 0 )
     413 [ #  # ][ #  # ]:          0 :                         return Any( Reference< XStyle >( pStyle ) );
                 [ #  # ]
     414                 :            :                 }
     415                 :            :             }
     416                 :            :         }
     417                 :            :     }
     418                 :            : 
     419 [ #  # ][ #  # ]:          0 :     throw IndexOutOfBoundsException();
     420                 :            : }
     421                 :            : 
     422                 :            : // ----------------------------------------------------------
     423                 :            : // XNameContainer
     424                 :            : // ----------------------------------------------------------
     425                 :            : 
     426                 :          0 : void SAL_CALL SdStyleFamily::insertByName( const OUString& rName, const Any& rElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
     427                 :            : {
     428         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     429         [ #  # ]:          0 :     throwIfDisposed();
     430                 :            : 
     431         [ #  # ]:          0 :     if(rName.isEmpty())
     432         [ #  # ]:          0 :         throw IllegalArgumentException();
     433                 :            : 
     434         [ #  # ]:          0 :     SdStyleSheet* pStyle = GetValidNewSheet( rElement );
     435 [ #  # ][ #  # ]:          0 :     if( !pStyle->SetName( rName ) )
         [ #  # ][ #  # ]
     436         [ #  # ]:          0 :         throw ElementExistException();
     437                 :            : 
     438         [ #  # ]:          0 :     pStyle->SetApiName( rName );
     439 [ #  # ][ #  # ]:          0 :     mxPool->Insert( pStyle );
     440                 :          0 : }
     441                 :            : 
     442                 :            : // ----------------------------------------------------------
     443                 :            : 
     444                 :          0 : void SAL_CALL SdStyleFamily::removeByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
     445                 :            : {
     446         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     447         [ #  # ]:          0 :     throwIfDisposed();
     448                 :            : 
     449         [ #  # ]:          0 :     SdStyleSheet* pStyle = GetSheetByName( rName );
     450                 :            : 
     451         [ #  # ]:          0 :     if( !pStyle->IsUserDefined() )
     452         [ #  # ]:          0 :         throw WrappedTargetException();
     453                 :            : 
     454 [ #  # ][ #  # ]:          0 :     mxPool->Remove( pStyle );
     455                 :          0 : }
     456                 :            : 
     457                 :            : // ----------------------------------------------------------
     458                 :            : // XNameReplace
     459                 :            : // ----------------------------------------------------------
     460                 :            : 
     461                 :          0 : void SAL_CALL SdStyleFamily::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
     462                 :            : {
     463         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     464         [ #  # ]:          0 :     throwIfDisposed();
     465                 :            : 
     466         [ #  # ]:          0 :     SdStyleSheet* pOldStyle = GetSheetByName( rName );
     467         [ #  # ]:          0 :     SdStyleSheet* pNewStyle = GetValidNewSheet( aElement );
     468                 :            : 
     469         [ #  # ]:          0 :     mxPool->Remove( pOldStyle );
     470 [ #  # ][ #  # ]:          0 :     mxPool->Insert( pNewStyle );
     471                 :          0 : }
     472                 :            : 
     473                 :            : // ----------------------------------------------------------
     474                 :            : // XSingleServiceFactory
     475                 :            : // ----------------------------------------------------------
     476                 :            : 
     477                 :          0 : Reference< XInterface > SAL_CALL SdStyleFamily::createInstance() throw(Exception, RuntimeException)
     478                 :            : {
     479         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     480         [ #  # ]:          0 :     throwIfDisposed();
     481                 :            : 
     482         [ #  # ]:          0 :     if( mnFamily == SD_STYLE_FAMILY_MASTERPAGE )
     483                 :            :     {
     484         [ #  # ]:          0 :         throw IllegalAccessException();
     485                 :            :     }
     486                 :            :     else
     487                 :            :     {
     488 [ #  # ][ #  # ]:          0 :         return Reference< XInterface >( static_cast< XStyle* >( SdStyleSheet::CreateEmptyUserStyle( *mxPool.get(), mnFamily ) ) );
                 [ #  # ]
     489         [ #  # ]:          0 :     }
     490                 :            : }
     491                 :            : 
     492                 :            : // ----------------------------------------------------------
     493                 :            : 
     494                 :          0 : Reference< XInterface > SAL_CALL SdStyleFamily::createInstanceWithArguments( const Sequence< Any >&  ) throw(Exception, RuntimeException)
     495                 :            : {
     496                 :          0 :     return createInstance();
     497                 :            : }
     498                 :            : 
     499                 :            : // ----------------------------------------------------------
     500                 :            : // XComponent
     501                 :            : // ----------------------------------------------------------
     502                 :            : 
     503                 :        524 : void SAL_CALL SdStyleFamily::dispose(  ) throw (RuntimeException)
     504                 :            : {
     505         [ +  - ]:        524 :     if( mxPool.is() )
     506                 :        524 :         mxPool.clear();
     507                 :            : 
     508         [ +  + ]:        524 :     if( mpImpl )
     509                 :            :     {
     510         [ +  - ]:        174 :         delete mpImpl;
     511                 :        174 :         mpImpl = 0;
     512                 :            :     }
     513                 :        524 : }
     514                 :            : 
     515                 :            : // ----------------------------------------------------------
     516                 :            : 
     517                 :          0 : void SAL_CALL SdStyleFamily::addEventListener( const Reference< XEventListener >&  ) throw (RuntimeException)
     518                 :            : {
     519                 :          0 : }
     520                 :            : 
     521                 :            : // ----------------------------------------------------------
     522                 :            : 
     523                 :          0 : void SAL_CALL SdStyleFamily::removeEventListener( const Reference< XEventListener >&  ) throw (RuntimeException)
     524                 :            : {
     525                 :          0 : }
     526                 :            : 
     527                 :            : // ----------------------------------------------------------
     528                 :            : // XPropertySet
     529                 :            : // ----------------------------------------------------------
     530                 :            : 
     531                 :          0 : Reference<XPropertySetInfo> SdStyleFamily::getPropertySetInfo() throw (RuntimeException)
     532                 :            : {
     533                 :            :     OSL_FAIL( "###unexpected!" );
     534                 :          0 :     return Reference<XPropertySetInfo>();
     535                 :            : }
     536                 :            : 
     537                 :            : // ----------------------------------------------------------
     538                 :            : 
     539                 :          0 : void SdStyleFamily::setPropertyValue( const OUString& , const Any&  ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
     540                 :            : {
     541                 :            :     OSL_FAIL( "###unexpected!" );
     542                 :          0 : }
     543                 :            : 
     544                 :            : // ----------------------------------------------------------
     545                 :            : 
     546                 :          0 : Any SdStyleFamily::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     547                 :            : {
     548         [ #  # ]:          0 :     if ( PropertyName == "DisplayName" )
     549                 :            :     {
     550         [ #  # ]:          0 :         SolarMutexGuard aGuard;
     551                 :          0 :         OUString sDisplayName;
     552      [ #  #  # ]:          0 :         switch( mnFamily )
     553                 :            :         {
     554         [ #  # ]:          0 :             case SD_STYLE_FAMILY_MASTERPAGE:    sDisplayName = getName(); break;
     555 [ #  # ][ #  # ]:          0 :             case SD_STYLE_FAMILY_CELL:          sDisplayName = String( SdResId(STR_CELL_STYLE_FAMILY) ); break;
         [ #  # ][ #  # ]
     556 [ #  # ][ #  # ]:          0 :             default:                            sDisplayName = String( SdResId(STR_GRAPHICS_STYLE_FAMILY) ); break;
         [ #  # ][ #  # ]
     557                 :            :         }
     558 [ #  # ][ #  # ]:          0 :         return Any( sDisplayName );
     559                 :            :     }
     560                 :            :     else
     561                 :            :     {
     562 [ #  # ][ #  # ]:          0 :         throw UnknownPropertyException( "unknown property: " + PropertyName, static_cast<OWeakObject *>(this) );
     563                 :            :     }
     564                 :            : }
     565                 :            : 
     566                 :            : // ----------------------------------------------------------
     567                 :            : 
     568                 :          0 : void SdStyleFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     569                 :            : {
     570                 :            :     OSL_FAIL( "###unexpected!" );
     571                 :          0 : }
     572                 :            : 
     573                 :            : // ----------------------------------------------------------
     574                 :            : 
     575                 :          0 : void SdStyleFamily::removePropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     576                 :            : {
     577                 :            :     OSL_FAIL( "###unexpected!" );
     578                 :          0 : }
     579                 :            : 
     580                 :            : // ----------------------------------------------------------
     581                 :            : 
     582                 :          0 : void SdStyleFamily::addVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     583                 :            : {
     584                 :            :     OSL_FAIL( "###unexpected!" );
     585                 :          0 : }
     586                 :            : 
     587                 :            : // ----------------------------------------------------------
     588                 :            : 
     589                 :          0 : void SdStyleFamily::removeVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     590                 :            : {
     591                 :            :     OSL_FAIL( "###unexpected!" );
     592                 :          0 : }
     593                 :            : 
     594                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10