LCOV - code coverage report
Current view: top level - svl/source/items - style.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 264 390 67.7 %
Date: 2012-08-25 Functions: 66 106 62.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 228 564 40.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <com/sun/star/lang/XComponent.hpp>
      21                 :            : 
      22                 :            : #include <tools/tenccvt.hxx>
      23                 :            : #include <comphelper/processfactory.hxx>
      24                 :            : #include <unotools/intlwrapper.hxx>
      25                 :            : #include <svl/smplhint.hxx>
      26                 :            : #include <svl/poolitem.hxx>
      27                 :            : #include <svl/itemset.hxx>
      28                 :            : #include <svl/itempool.hxx>
      29                 :            : #include <poolio.hxx>
      30                 :            : #include <svl/filerec.hxx>
      31                 :            : #include <svl/itemiter.hxx>
      32                 :            : #include <svl/style.hxx>
      33                 :            : #include <unotools/syslocale.hxx>
      34                 :            : #include <algorithm>
      35                 :            : #include <comphelper/servicehelper.hxx>
      36                 :            : 
      37                 :            : #ifdef DBG_UTIL
      38                 :            : class DbgStyleSheetReferences
      39                 :            : {
      40                 :            : public:
      41                 :            :     DbgStyleSheetReferences() : mnStyles(0), mnPools(0) {}
      42                 :            :     ~DbgStyleSheetReferences()
      43                 :            :     {
      44                 :            :         OSL_TRACE("DbgStyleSheetReferences\nSfxStyleSheetBase left %ld\nSfxStyleSheetBasePool left %ld", mnStyles, mnPools );
      45                 :            :     }
      46                 :            : 
      47                 :            :     sal_uInt32 mnStyles;
      48                 :            :     sal_uInt32 mnPools;
      49                 :            : }
      50                 :            : aDbgStyleSheetReferences;
      51                 :            : 
      52                 :            : #endif
      53                 :            : 
      54         [ -  + ]:        792 : TYPEINIT0(SfxStyleSheetBase)
      55                 :            : 
      56 [ +  + ][ -  + ]:      54344 : TYPEINIT3(SfxStyleSheet, SfxStyleSheetBase, SfxListener, SfxBroadcaster)
         [ -  + ][ -  + ]
      57                 :            : 
      58                 :            : 
      59                 :            : //=========================================================================
      60                 :            : 
      61 [ +  + ][ -  + ]:    2260691 : TYPEINIT1(SfxStyleSheetHint, SfxHint);
      62 [ +  + ][ +  + ]:      60764 : TYPEINIT1(SfxStyleSheetHintExtended, SfxStyleSheetHint);
      63 [ -  + ][ -  + ]:     103347 : TYPEINIT1(SfxStyleSheetPoolHint, SfxHint);
      64                 :            : 
      65                 :        198 : SfxStyleSheetHintExtended::SfxStyleSheetHintExtended
      66                 :            : (
      67                 :            :     sal_uInt16              nAction,        // SFX_STYLESHEET_... (s.o.)
      68                 :            :     const String&       rOldName,
      69                 :            :     SfxStyleSheetBase&  rStyleSheet     // geh"ort weiterhin dem Aufrufer
      70                 :            : )
      71                 :            : :   SfxStyleSheetHint( nAction, rStyleSheet ),
      72         [ +  - ]:        198 :     aName( rOldName )
      73                 :        198 : {}
      74                 :            : 
      75                 :            : //-------------------------------------------------------------------------
      76                 :            : 
      77                 :      61499 : SfxStyleSheetHint::SfxStyleSheetHint
      78                 :            : (
      79                 :            :     sal_uInt16              nAction,        // SFX_STYLESHEET_... (s.o.)
      80                 :            :     SfxStyleSheetBase&  rStyleSheet     // geh"ort weiterhin dem Aufrufer
      81                 :            : )
      82                 :            : :   pStyleSh( &rStyleSheet ),
      83                 :      61499 :     nHint( nAction )
      84                 :      61499 : {}
      85                 :            : 
      86                 :            : //=========================================================================
      87                 :            : 
      88                 :            : class SfxStyleSheetBasePool_Impl
      89                 :            : {
      90                 :            :   public:
      91                 :            :     SfxStyles aStyles;
      92                 :            :     SfxStyleSheetIterator *pIter;
      93                 :       2571 :     SfxStyleSheetBasePool_Impl() : pIter(0){}
      94 [ +  + ][ +  - ]:       2302 :     ~SfxStyleSheetBasePool_Impl(){delete pIter;}
      95                 :            : };
      96                 :            : 
      97                 :            : 
      98                 :            : //////////////////////////// SfxStyleSheetBase ///////////////////////////////
      99                 :            : 
     100                 :            : // Konstruktoren
     101                 :            : 
     102                 :      22833 : SfxStyleSheetBase::SfxStyleSheetBase( const XubString& rName, SfxStyleSheetBasePool* p, SfxStyleFamily eFam, sal_uInt16 mask )
     103                 :            :     : pPool( p )
     104                 :            :     , nFamily( eFam )
     105                 :            :     , aName( rName )
     106                 :            :     , aParent()
     107                 :            :     , aFollow( rName )
     108                 :            :     , pSet( NULL )
     109                 :            :     , nMask(mask)
     110                 :            :     , nHelpId( 0 )
     111 [ +  - ][ +  - ]:      22833 :     , bMySet( sal_False )
         [ +  - ][ +  - ]
     112                 :            : {
     113                 :            : #ifdef DBG_UTIL
     114                 :            :     aDbgStyleSheetReferences.mnStyles++;
     115                 :            : #endif
     116                 :      22833 : }
     117                 :            : 
     118                 :      18501 : SfxStyleSheetBase::SfxStyleSheetBase( const SfxStyleSheetBase& r )
     119                 :            :     : comphelper::OWeakTypeObject()
     120                 :            :     , pPool( r.pPool )
     121                 :            :     , nFamily( r.nFamily )
     122                 :            :     , aName( r.aName )
     123                 :            :     , aParent( r.aParent )
     124                 :            :     , aFollow( r.aFollow )
     125                 :            :     , aHelpFile( r.aHelpFile )
     126                 :            :     , nMask( r.nMask )
     127                 :            :     , nHelpId( r.nHelpId )
     128 [ +  - ][ +  - ]:      18501 :     , bMySet( r.bMySet )
         [ +  - ][ +  - ]
     129                 :            : {
     130                 :            : #ifdef DBG_UTIL
     131                 :            :     aDbgStyleSheetReferences.mnStyles++;
     132                 :            : #endif
     133         [ -  + ]:      18501 :     if( r.pSet )
     134 [ #  # ][ #  # ]:          0 :         pSet = bMySet ? new SfxItemSet( *r.pSet ) : r.pSet;
                 [ #  # ]
     135                 :            :     else
     136                 :      18501 :         pSet = NULL;
     137                 :      18501 : }
     138                 :            : 
     139 [ +  - ][ +  - ]:      40634 : SfxStyleSheetBase::~SfxStyleSheetBase()
         [ +  - ][ +  - ]
     140                 :            : {
     141                 :            : #ifdef DBG_UTIL
     142                 :            :     --aDbgStyleSheetReferences.mnStyles;
     143                 :            : #endif
     144                 :            : 
     145         [ +  + ]:      40634 :     if( bMySet )
     146                 :            :     {
     147 [ +  - ][ +  - ]:       3359 :         delete pSet;
     148                 :       3359 :         pSet = 0;
     149                 :            :     }
     150         [ -  + ]:      40634 : }
     151                 :            : 
     152                 :          0 : sal_uInt16 SfxStyleSheetBase::GetVersion() const
     153                 :            : {
     154                 :          0 :     return 0x0000;
     155                 :            : }
     156                 :            : 
     157                 :            : // Namen aendern
     158                 :            : 
     159                 :    3718113 : const XubString& SfxStyleSheetBase::GetName() const
     160                 :            : {
     161                 :    3718113 :     return aName;
     162                 :            : }
     163                 :            : 
     164                 :        198 : sal_Bool SfxStyleSheetBase::SetName( const XubString& rName )
     165                 :            : {
     166         [ -  + ]:        198 :     if(rName.Len() == 0)
     167                 :          0 :         return sal_False;
     168         [ +  - ]:        198 :     if( aName != rName )
     169                 :            :     {
     170         [ +  - ]:        198 :         String aOldName = aName;
     171         [ +  - ]:        198 :         SfxStyleSheetBase *pOther = pPool->Find( rName, nFamily ) ;
     172 [ -  + ][ #  # ]:        198 :         if ( pOther && pOther != this )
     173                 :          0 :             return sal_False;
     174                 :            : 
     175                 :        198 :         SfxStyleFamily eTmpFam = pPool->GetSearchFamily();
     176         [ +  - ]:        198 :         sal_uInt16 nTmpMask = pPool->GetSearchMask();
     177                 :            : 
     178         [ +  - ]:        198 :         pPool->SetSearchMask(nFamily);
     179                 :            : 
     180         [ +  - ]:        198 :         if ( aName.Len() )
     181         [ +  - ]:        198 :             pPool->ChangeParent( aName, rName, sal_False );
     182 [ +  - ][ +  + ]:        198 :         if ( aFollow.Equals( aName ) )
     183         [ +  - ]:        182 :             aFollow = rName;
     184         [ +  - ]:        198 :         aName = rName;
     185         [ +  - ]:        198 :         pPool->SetSearchMask(eTmpFam, nTmpMask);
     186                 :            :         pPool->Broadcast( SfxStyleSheetHintExtended(
     187 [ +  - ][ +  - ]:        198 :             SFX_STYLESHEET_MODIFIED, aOldName, *this ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     188                 :            :     }
     189                 :        198 :     return sal_True;
     190                 :            : }
     191                 :            : 
     192                 :       3818 : rtl::OUString SfxStyleSheetBase::GetDisplayName() const
     193                 :            : {
     194         [ +  - ]:       3818 :     if( maDisplayName.isEmpty() )
     195                 :            :     {
     196                 :       3818 :         return aName;
     197                 :            :     }
     198                 :            :     else
     199                 :            :     {
     200                 :       3818 :         return maDisplayName;
     201                 :            :     }
     202                 :            : }
     203                 :            : 
     204                 :          0 : void SfxStyleSheetBase::SetDisplayName( const rtl::OUString& rDisplayName )
     205                 :            : {
     206                 :          0 :     maDisplayName = rDisplayName;
     207                 :          0 : }
     208                 :            : 
     209                 :            : // Parent aendern
     210                 :            : 
     211                 :      26920 : const XubString& SfxStyleSheetBase::GetParent() const
     212                 :            : {
     213                 :      26920 :     return aParent;
     214                 :            : }
     215                 :            : 
     216                 :      13361 : sal_Bool SfxStyleSheetBase::SetParent( const XubString& rName )
     217                 :            : {
     218         [ -  + ]:      13361 :     if ( rName == aName )
     219                 :          0 :         return sal_False;
     220                 :            : 
     221         [ +  - ]:      13361 :     if( aParent != rName )
     222                 :            :     {
     223                 :      13361 :         SfxStyleSheetBase* pIter = pPool->Find(rName, nFamily);
     224 [ -  + ][ -  + ]:      13361 :         if( rName.Len() && !pIter )
                 [ +  - ]
     225                 :            :         {
     226                 :            :             OSL_FAIL( "StyleSheet-Parent nicht gefunden" );
     227                 :          0 :             return sal_False;
     228                 :            :         }
     229                 :            :         // rekursive Verknuepfungen verhindern
     230         [ +  - ]:      13361 :         if( aName.Len() )
     231         [ +  + ]:      36748 :             while(pIter)
     232                 :            :             {
     233         [ -  + ]:      23387 :                 if(pIter->GetName() == aName)
     234                 :          0 :                     return sal_False;
     235                 :      23387 :                 pIter = pPool->Find(pIter->GetParent(), nFamily);
     236                 :            :             }
     237                 :      13361 :         aParent = rName;
     238                 :            :     }
     239         [ +  - ]:      13361 :     pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
     240                 :      13361 :     return sal_True;
     241                 :            : }
     242                 :            : 
     243                 :            : // Follow aendern
     244                 :            : 
     245                 :        860 : const XubString& SfxStyleSheetBase::GetFollow() const
     246                 :            : {
     247                 :        860 :     return aFollow;
     248                 :            : }
     249                 :            : 
     250                 :         42 : sal_Bool SfxStyleSheetBase::SetFollow( const XubString& rName )
     251                 :            : {
     252         [ +  - ]:         42 :     if( aFollow != rName )
     253                 :            :     {
     254         [ -  + ]:         42 :         if( !pPool->Find( rName, nFamily ) )
     255                 :            :         {
     256                 :            :             OSL_FAIL( "StyleSheet-Follow nicht gefunden" );
     257                 :          0 :             return sal_False;
     258                 :            :         }
     259                 :         42 :         aFollow = rName;
     260                 :            :     }
     261         [ +  - ]:         42 :     pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
     262                 :         42 :     return sal_True;
     263                 :            : }
     264                 :            : 
     265                 :            : // Itemset setzen. Die Dflt-Implementation legt ein neues Set an.
     266                 :            : 
     267                 :          0 : SfxItemSet& SfxStyleSheetBase::GetItemSet()
     268                 :            : {
     269         [ #  # ]:          0 :     if( !pSet )
     270                 :            :     {
     271         [ #  # ]:          0 :         pSet = new SfxItemSet( pPool->GetPool() );
     272                 :          0 :         bMySet = sal_True;
     273                 :            :     }
     274                 :          0 :     return *pSet;
     275                 :            : }
     276                 :            : 
     277                 :            : // Hilfe-Datei und -ID setzen und abfragen
     278                 :            : 
     279                 :        705 : sal_uLong SfxStyleSheetBase::GetHelpId( String& rFile )
     280                 :            : {
     281                 :        705 :     rFile = aHelpFile;
     282                 :        705 :     return nHelpId;
     283                 :            : }
     284                 :            : 
     285                 :       9904 : void SfxStyleSheetBase::SetHelpId( const String& rFile, sal_uLong nId )
     286                 :            : {
     287                 :       9904 :     aHelpFile = rFile;
     288                 :       9904 :     nHelpId = nId;
     289                 :       9904 : }
     290                 :            : 
     291                 :            : // Folgevorlage m"oglich? Default: Ja
     292                 :            : 
     293                 :          0 : sal_Bool SfxStyleSheetBase::HasFollowSupport() const
     294                 :            : {
     295                 :          0 :     return sal_True;
     296                 :            : }
     297                 :            : 
     298                 :            : // Basisvorlage m"oglich? Default: Ja
     299                 :            : 
     300                 :          0 : sal_Bool SfxStyleSheetBase::HasParentSupport() const
     301                 :            : {
     302                 :          0 :     return sal_True;
     303                 :            : }
     304                 :            : 
     305                 :            : // Basisvorlage uf NULL setzen m"oglich? Default: Nein
     306                 :            : 
     307                 :          0 : sal_Bool SfxStyleSheetBase::HasClearParentSupport() const
     308                 :            : {
     309                 :          0 :     return sal_False;
     310                 :            : }
     311                 :            : 
     312                 :            : // Defaultmaessig sind alle StyleSheets Used
     313                 :            : 
     314                 :          0 : sal_Bool SfxStyleSheetBase::IsUsed() const
     315                 :            : {
     316                 :          0 :     return sal_True;
     317                 :            : }
     318                 :            : 
     319                 :            : // eingestellte Attribute ausgeben
     320                 :            : 
     321                 :            : 
     322                 :          0 : XubString SfxStyleSheetBase::GetDescription()
     323                 :            : {
     324                 :          0 :     return GetDescription( SFX_MAPUNIT_CM );
     325                 :            : }
     326                 :            : 
     327                 :            : // eingestellte Attribute ausgeben
     328                 :            : 
     329                 :          0 : XubString SfxStyleSheetBase::GetDescription( SfxMapUnit eMetric )
     330                 :            : {
     331 [ #  # ][ #  # ]:          0 :     SfxItemIter aIter( GetItemSet() );
     332         [ #  # ]:          0 :     XubString aDesc;
     333                 :          0 :     const SfxPoolItem* pItem = aIter.FirstItem();
     334                 :            : 
     335                 :            :     IntlWrapper aIntlWrapper(comphelper::getProcessServiceFactory(),
     336 [ #  # ][ #  # ]:          0 :             SvtSysLocale().GetLanguage());
         [ #  # ][ #  # ]
                 [ #  # ]
     337         [ #  # ]:          0 :     while ( pItem )
     338                 :            :     {
     339         [ #  # ]:          0 :         XubString aItemPresentation;
     340                 :            : 
     341 [ #  # ][ #  # ]:          0 :         if ( !IsInvalidItem( pItem ) &&
                 [ #  # ]
     342         [ #  # ]:          0 :              pPool->GetPool().GetPresentation(
     343                 :            :                 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
     344         [ #  # ]:          0 :                 eMetric, aItemPresentation, &aIntlWrapper ) )
     345                 :            :         {
     346 [ #  # ][ #  # ]:          0 :             if ( aDesc.Len() && aItemPresentation.Len() )
                 [ #  # ]
     347         [ #  # ]:          0 :                 aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" + "));
     348         [ #  # ]:          0 :             if ( aItemPresentation.Len() )
     349         [ #  # ]:          0 :                 aDesc += aItemPresentation;
     350                 :            :         }
     351         [ #  # ]:          0 :         pItem = aIter.NextItem();
     352         [ #  # ]:          0 :     }
     353 [ #  # ][ #  # ]:          0 :     return aDesc;
     354                 :            : }
     355                 :            : 
     356                 :            : /////////////////////////// SfxStyleSheetIterator ///////////////////////////////
     357                 :            : 
     358                 :     450198 : SfxStyleFamily SfxStyleSheetIterator::GetSearchFamily() const
     359                 :            : {
     360                 :     450198 :     return nSearchFamily;
     361                 :            : }
     362                 :            : 
     363                 :       7099 : inline sal_Bool SfxStyleSheetIterator::IsTrivialSearch()
     364                 :            : {
     365 [ +  - ][ -  + ]:       7099 :     return nMask == 0xFFFF && GetSearchFamily() == SFX_STYLE_FAMILY_ALL;
     366                 :            : }
     367                 :            : 
     368                 :     188908 : sal_Bool SfxStyleSheetIterator::DoesStyleMatch(SfxStyleSheetBase *pStyle)
     369                 :            : {
     370                 :     188908 :     return ((GetSearchFamily() == SFX_STYLE_FAMILY_ALL) ||
     371                 :     188908 :             ( pStyle->GetFamily() == GetSearchFamily() ))
     372                 :     124730 :         && (( pStyle->GetMask() & ( GetSearchMask() & ~SFXSTYLEBIT_USED )) ||
     373         [ #  # ]:          0 :             ( bSearchUsed ? pStyle->IsUsed() : sal_False ) ||
     374 [ -  + ][ +  - ]:     502546 :             GetSearchMask() == SFXSTYLEBIT_ALL );
           [ +  -  +  +  
                   +  + ]
     375                 :            : }
     376                 :            : 
     377                 :            : 
     378                 :     165467 : SfxStyleSheetIterator::SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase,
     379                 :     165467 :                                              SfxStyleFamily eFam, sal_uInt16 n)
     380                 :            : {
     381                 :     165467 :     pBasePool=pBase;
     382                 :     165467 :     nSearchFamily=eFam;
     383                 :     165467 :     bSearchUsed=sal_False;
     384 [ +  + ][ +  + ]:     165467 :         if((n != SFXSTYLEBIT_ALL ) && ((n & SFXSTYLEBIT_USED) == SFXSTYLEBIT_USED))
     385                 :            :     {
     386                 :       6086 :         bSearchUsed = sal_True;
     387                 :       6086 :         n &= ~SFXSTYLEBIT_USED;
     388                 :            :     }
     389                 :     165467 :     nMask=n;
     390                 :     165467 : }
     391                 :            : 
     392                 :     164462 : SfxStyleSheetIterator::~SfxStyleSheetIterator()
     393                 :            : {
     394         [ -  + ]:     165179 : }
     395                 :            : 
     396                 :            : 
     397                 :        193 : sal_uInt16 SfxStyleSheetIterator::Count()
     398                 :            : {
     399                 :        193 :     sal_uInt16 n = 0;
     400         [ -  + ]:        193 :     if( IsTrivialSearch())
     401                 :          0 :         n = (sal_uInt16) pBasePool->aStyles.size();
     402                 :            :     else
     403         [ +  + ]:       1557 :         for(sal_uInt16 i=0; i<pBasePool->aStyles.size(); i++)
     404                 :            :         {
     405                 :       1364 :             SfxStyleSheetBase* pStyle = pBasePool->aStyles[i].get();
     406         [ +  + ]:       1364 :             if(DoesStyleMatch(pStyle))
     407                 :        954 :                 n++;
     408                 :            :         }
     409                 :        193 :     return n;
     410                 :            : }
     411                 :            : 
     412                 :        143 : SfxStyleSheetBase* SfxStyleSheetIterator::operator[](sal_uInt16 nIdx)
     413                 :            : {
     414         [ -  + ]:        143 :     if( IsTrivialSearch())
     415                 :          0 :         return pBasePool->aStyles[nIdx].get();
     416                 :            : 
     417                 :        143 :     sal_uInt16 z = 0;
     418         [ +  - ]:        433 :     for(sal_uInt16 n=0; n<pBasePool->aStyles.size(); n++)
     419                 :            :     {
     420                 :        433 :         SfxStyleSheetBase* pStyle = pBasePool->aStyles[n].get();
     421         [ +  + ]:        433 :         if( DoesStyleMatch(pStyle))
     422                 :            :         {
     423         [ +  + ]:        431 :             if(z == nIdx)
     424                 :            :             {
     425                 :        143 :                 nAktPosition=n;
     426                 :        143 :                 return pAktStyle=pStyle;
     427                 :            :             }
     428                 :        288 :             ++z;
     429                 :            :         }
     430                 :            :     }
     431                 :            :     OSL_FAIL("falscher Index");
     432                 :        143 :     return 0;
     433                 :            : }
     434                 :            : 
     435                 :       3522 : SfxStyleSheetBase* SfxStyleSheetIterator::First()
     436                 :            : {
     437                 :       3522 :     sal_Int32 nIdx = -1;
     438                 :            : 
     439 [ -  + ][ #  # ]:       3522 :     if ( IsTrivialSearch() && pBasePool->aStyles.size() )
                 [ -  + ]
     440                 :          0 :         nIdx = 0;
     441                 :            :     else
     442         [ +  + ]:      40907 :         for( sal_uInt16 n = 0; n < pBasePool->aStyles.size(); n++ )
     443                 :            :         {
     444                 :      40871 :             SfxStyleSheetBase* pStyle = pBasePool->aStyles[n].get();
     445                 :            : 
     446         [ +  + ]:      40871 :             if ( DoesStyleMatch( pStyle ) )
     447                 :            :             {
     448                 :       3486 :                 nIdx = n;
     449                 :       3486 :                 break;
     450                 :            :             }
     451                 :            :         }
     452                 :            : 
     453         [ +  + ]:       3522 :     if ( nIdx != -1 )
     454                 :            :     {
     455                 :       3486 :         nAktPosition = (sal_uInt16)nIdx;
     456                 :       3486 :         return pAktStyle = pBasePool->aStyles[nIdx].get();
     457                 :            :     }
     458                 :       3522 :     return 0;
     459                 :            : }
     460                 :            : 
     461                 :            : 
     462                 :       3241 : SfxStyleSheetBase* SfxStyleSheetIterator::Next()
     463                 :            : {
     464                 :       3241 :     sal_Int32 nIdx = -1;
     465                 :            : 
     466   [ -  +  #  # ]:       3241 :     if ( IsTrivialSearch() &&
                 [ -  + ]
     467                 :          0 :          (sal_uInt16)pBasePool->aStyles.size() > nAktPosition + 1 )
     468                 :          0 :         nIdx = nAktPosition + 1;
     469                 :            :     else
     470         [ +  + ]:      13349 :         for( sal_uInt16 n = nAktPosition + 1; n < pBasePool->aStyles.size(); n++ )
     471                 :            :         {
     472                 :      13064 :             SfxStyleSheetBase* pStyle = pBasePool->aStyles[n].get();
     473                 :            : 
     474         [ +  + ]:      13064 :             if ( DoesStyleMatch( pStyle ) )
     475                 :            :             {
     476                 :       2956 :                 nIdx = n;
     477                 :       2956 :                 break;
     478                 :            :             }
     479                 :            :         }
     480                 :            : 
     481         [ +  + ]:       3241 :     if ( nIdx != -1 )
     482                 :            :     {
     483                 :       2956 :         nAktPosition = (sal_uInt16)nIdx;
     484                 :       2956 :         return pAktStyle = pBasePool->aStyles[nIdx].get();
     485                 :            :     }
     486                 :       3241 :     return 0;
     487                 :            : }
     488                 :            : 
     489                 :            : 
     490                 :     158509 : SfxStyleSheetBase* SfxStyleSheetIterator::Find(const rtl::OUString& rStr)
     491                 :            : {
     492         [ +  + ]:    3416264 :     for ( sal_uInt16 n = 0; n < pBasePool->aStyles.size(); ++n )
     493                 :            :     {
     494                 :    3374658 :         SfxStyleSheetBase* pStyle = pBasePool->aStyles[n].get();
     495                 :            : 
     496                 :            :         // #98454# performance: in case of bSearchUsed==sal_True it may be
     497                 :            :         // significant to first compare the name and only if it matches to call
     498                 :            :         // the style sheet IsUsed() method in DoesStyleMatch().
     499 [ +  - ][ +  - ]:    3374658 :         if ( pStyle->GetName().Equals( rStr ) && DoesStyleMatch( pStyle ) )
         [ +  + ][ +  - ]
         [ +  + ][ +  - ]
           [ +  +  #  # ]
                 [ +  - ]
     500                 :            :         {
     501                 :     116903 :             nAktPosition = n;
     502                 :     116903 :             return pAktStyle = pStyle;
     503                 :            :         }
     504                 :            :     }
     505                 :     158509 :     return 0;
     506                 :            : }
     507                 :            : 
     508                 :            : 
     509                 :     230114 : sal_uInt16 SfxStyleSheetIterator::GetSearchMask() const
     510                 :            : {
     511                 :     230114 :     sal_uInt16 mask = nMask;
     512                 :            : 
     513         [ +  + ]:     230114 :     if ( bSearchUsed )
     514                 :      38404 :         mask |= SFXSTYLEBIT_USED;
     515                 :     230114 :     return mask;
     516                 :            : }
     517                 :            : 
     518                 :            : /////////////////////////// SfxStyleSheetBasePool ///////////////////////////////
     519                 :            : 
     520                 :          0 : void SfxStyleSheetBasePool::Replace(
     521                 :            :     SfxStyleSheetBase& rSource, SfxStyleSheetBase& rTarget )
     522                 :            : {
     523                 :          0 :     rTarget.SetFollow( rSource.GetFollow() );
     524                 :          0 :     rTarget.SetParent( rSource.GetParent() );
     525                 :          0 :     SfxItemSet& rSourceSet = rSource.GetItemSet();
     526                 :          0 :     SfxItemSet& rTargetSet = rTarget.GetItemSet();
     527                 :          0 :     rTargetSet.Intersect( rSourceSet );
     528                 :          0 :     rTargetSet.Put( rSourceSet );
     529                 :          0 : }
     530                 :            : 
     531                 :      67640 : SfxStyleSheetIterator& SfxStyleSheetBasePool::GetIterator_Impl()
     532                 :            : {
     533                 :      67640 :     SfxStyleSheetIterator*& rpIter = pImp->pIter;
     534 [ +  + ][ +  + ]:      67640 :     if( !rpIter || (rpIter->GetSearchMask() != nMask) || (rpIter->GetSearchFamily() != nSearchFamily) )
         [ +  + ][ +  + ]
     535                 :            :     {
     536         [ +  + ]:       3289 :         delete rpIter;
     537                 :       3289 :         rpIter = CreateIterator( nSearchFamily, nMask );
     538                 :            :     }
     539                 :      67640 :     return *rpIter;
     540                 :            : }
     541                 :            : 
     542                 :            : 
     543                 :       2571 : SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r )
     544         [ +  - ]:       2571 :     : aAppName(r.GetName())
     545                 :            :     , rPool(r)
     546                 :            :     , nSearchFamily(SFX_STYLE_FAMILY_PARA)
     547 [ +  - ][ +  - ]:       5142 :     , nMask(0xFFFF)
                 [ +  - ]
     548                 :            : {
     549                 :            : #ifdef DBG_UTIL
     550                 :            :     aDbgStyleSheetReferences.mnPools++;
     551                 :            : #endif
     552                 :            : 
     553 [ +  - ][ +  - ]:       2571 :     pImp = new SfxStyleSheetBasePool_Impl;
     554                 :       2571 : }
     555                 :            : 
     556                 :          0 : SfxStyleSheetBasePool::SfxStyleSheetBasePool( const SfxStyleSheetBasePool& r )
     557                 :            :     : SfxBroadcaster( r )
     558                 :            :     , comphelper::OWeakTypeObject()
     559                 :            :     , aAppName(r.aAppName)
     560                 :            :     , rPool(r.rPool)
     561                 :            :     , nSearchFamily(r.nSearchFamily)
     562 [ #  # ][ #  # ]:          0 :     , nMask( r.nMask )
                 [ #  # ]
     563                 :            : {
     564                 :            : #ifdef DBG_UTIL
     565                 :            :     aDbgStyleSheetReferences.mnPools++;
     566                 :            : #endif
     567                 :            : 
     568 [ #  # ][ #  # ]:          0 :     pImp = new SfxStyleSheetBasePool_Impl;
     569         [ #  # ]:          0 :     *this += r;
     570                 :          0 : }
     571                 :            : 
     572 [ +  - ][ +  - ]:       2302 : SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
     573                 :            : {
     574                 :            : #ifdef DBG_UTIL
     575                 :            :     aDbgStyleSheetReferences.mnPools--;
     576                 :            : #endif
     577                 :            : 
     578 [ +  - ][ +  - ]:       2302 :     Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
                 [ +  - ]
     579         [ +  - ]:       2302 :     Clear();
     580 [ +  - ][ +  - ]:       2302 :     delete pImp;
     581         [ -  + ]:       2302 : }
     582                 :            : 
     583                 :          0 : sal_Bool SfxStyleSheetBasePool::SetParent(SfxStyleFamily eFam, const XubString& rStyle, const XubString& rParent)
     584                 :            : {
     585         [ #  # ]:          0 :     SfxStyleSheetIterator aIter(this,eFam,SFXSTYLEBIT_ALL);
     586                 :            :     SfxStyleSheetBase *pStyle =
     587 [ #  # ][ #  # ]:          0 :         aIter.Find(rStyle);
     588                 :            :     OSL_ENSURE(pStyle, "Vorlage nicht gefunden. Writer mit Solar <2541??");
     589         [ #  # ]:          0 :     if(pStyle)
     590         [ #  # ]:          0 :         return pStyle->SetParent(rParent);
     591                 :            :     else
     592         [ #  # ]:          0 :         return sal_False;
     593                 :            : }
     594                 :            : 
     595                 :            : 
     596                 :      86979 : void SfxStyleSheetBasePool::SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n)
     597                 :            : {
     598                 :      86979 :     nSearchFamily = eFam; nMask = n;
     599                 :      86979 : }
     600                 :            : 
     601                 :      19442 : sal_uInt16 SfxStyleSheetBasePool::GetSearchMask() const
     602                 :            : {
     603                 :      19442 :     return nMask;
     604                 :            : }
     605                 :            : 
     606                 :            : /////////////////////////////////// Factory ////////////////////////////////
     607                 :            : 
     608                 :            : 
     609                 :            : 
     610                 :       1722 : SfxStyleSheetIterator* SfxStyleSheetBasePool::CreateIterator
     611                 :            : (
     612                 :            :  SfxStyleFamily eFam,
     613                 :            :  sal_uInt16 mask
     614                 :            : )
     615                 :            : {
     616         [ +  - ]:       1722 :     return new SfxStyleSheetIterator(this,eFam,mask);
     617                 :            : }
     618                 :            : 
     619                 :            : 
     620                 :          0 : SfxStyleSheetBase* SfxStyleSheetBasePool::Create
     621                 :            : (
     622                 :            :     const XubString& rName,
     623                 :            :     SfxStyleFamily eFam,
     624                 :            :     sal_uInt16 mask
     625                 :            : )
     626                 :            : {
     627         [ #  # ]:          0 :     return new SfxStyleSheetBase( rName, this, eFam, mask );
     628                 :            : }
     629                 :            : 
     630                 :          0 : SfxStyleSheetBase* SfxStyleSheetBasePool::Create( const SfxStyleSheetBase& r )
     631                 :            : {
     632         [ #  # ]:          0 :     return new SfxStyleSheetBase( r );
     633                 :            : }
     634                 :            : 
     635                 :      15914 : SfxStyleSheetBase& SfxStyleSheetBasePool::Make( const XubString& rName, SfxStyleFamily eFam, sal_uInt16 mask, sal_uInt16 nPos)
     636                 :            : {
     637                 :            :     OSL_ENSURE( eFam != SFX_STYLE_FAMILY_ALL, "svl::SfxStyleSheetBasePool::Make(), FamilyAll is not a allowed Familie" );
     638                 :            : 
     639         [ +  - ]:      15914 :     SfxStyleSheetIterator aIter(this, eFam, mask);
     640 [ +  - ][ +  - ]:      15914 :     rtl::Reference< SfxStyleSheetBase > xStyle( aIter.Find( rName ) );
     641                 :            :     OSL_ENSURE( !xStyle.is(), "svl::SfxStyleSheetBasePool::Make(), StyleSheet already exists" );
     642         [ +  - ]:      15914 :     SfxStyleSheetIterator& rIter = GetIterator_Impl();
     643                 :            : 
     644         [ +  - ]:      15914 :     if( !xStyle.is() )
     645                 :            :     {
     646 [ +  - ][ +  - ]:      15914 :         xStyle = Create( rName, eFam, mask );
     647 [ -  + ][ #  # ]:      15914 :         if(0xffff == nPos || nPos == aStyles.size() || nPos == rIter.Count())
         [ #  # ][ #  # ]
                 [ +  - ]
     648                 :            :         {
     649         [ +  - ]:      15914 :             aStyles.push_back( xStyle );
     650                 :            :         }
     651                 :            :         else
     652                 :            :         {
     653         [ #  # ]:          0 :             rIter[nPos];
     654 [ #  # ][ #  # ]:          0 :             aStyles.insert( aStyles.begin() + rIter.GetPos(), xStyle );
     655                 :            :         }
     656 [ +  - ][ +  - ]:      15914 :         Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xStyle.get() ) );
                 [ +  - ]
     657                 :            :     }
     658         [ +  - ]:      15914 :     return *xStyle.get();
     659                 :            : }
     660                 :            : 
     661                 :            : /////////////////////////////// Kopieren ///////////////////////////////////
     662                 :            : 
     663                 :            : // Hilfsroutine: Falls eine Vorlage dieses Namens existiert, wird
     664                 :            : // sie neu erzeugt. Alle Vorlagen, die diese Vorlage zum Parent haben,
     665                 :            : // werden umgehaengt.
     666                 :            : 
     667                 :          0 : SfxStyleSheetBase& SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet )
     668                 :            : {
     669         [ #  # ]:          0 :     SfxStyleSheetIterator aIter(this, rSheet.GetFamily(), nMask);
     670 [ #  # ][ #  # ]:          0 :     SfxStyleSheetBase* pOld = aIter.Find( rSheet.GetName() );
                 [ #  # ]
     671         [ #  # ]:          0 :     Remove( pOld );
     672         [ #  # ]:          0 :     rtl::Reference< SfxStyleSheetBase > xNew( Create( rSheet ) );
     673         [ #  # ]:          0 :     aStyles.push_back( xNew );
     674 [ #  # ][ #  # ]:          0 :     Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CHANGED, *xNew.get() ) );
                 [ #  # ]
     675         [ #  # ]:          0 :     return *xNew.get();
     676                 :            : }
     677                 :            : 
     678                 :          0 : SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator=( const SfxStyleSheetBasePool& r )
     679                 :            : {
     680         [ #  # ]:          0 :     if( &r != this )
     681                 :            :     {
     682                 :          0 :         Clear();
     683                 :          0 :         *this += r;
     684                 :            :     }
     685                 :          0 :     return *this;
     686                 :            : }
     687                 :            : 
     688                 :          0 : SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator+=( const SfxStyleSheetBasePool& r )
     689                 :            : {
     690         [ #  # ]:          0 :     if( &r != this )
     691                 :            :     {
     692                 :          0 :         SfxStyles::const_iterator aIter( r.aStyles.begin() );
     693 [ #  # ][ #  # ]:          0 :         while( aIter != r.aStyles.end() )
     694                 :            :         {
     695 [ #  # ][ #  # ]:          0 :             Add(*(*aIter++).get());
     696                 :            :         }
     697                 :            :     }
     698                 :          0 :     return *this;
     699                 :            : }
     700                 :            : 
     701                 :            : //////////////////////////////// Suchen ////////////////////////////////////
     702                 :            : 
     703                 :       9961 : sal_uInt16 SfxStyleSheetBasePool::Count()
     704                 :            : {
     705                 :       9961 :     return GetIterator_Impl().Count();
     706                 :            : }
     707                 :            : 
     708                 :          0 : SfxStyleSheetBase *SfxStyleSheetBasePool::operator[](sal_uInt16 nIdx)
     709                 :            : {
     710                 :          0 :     return GetIterator_Impl()[nIdx];
     711                 :            : }
     712                 :            : 
     713                 :     142595 : SfxStyleSheetBase* SfxStyleSheetBasePool::Find(const XubString& rName,
     714                 :            :                                                SfxStyleFamily eFam,
     715                 :            :                                                sal_uInt16 mask)
     716                 :            : {
     717         [ +  - ]:     142595 :     SfxStyleSheetIterator aIter(this,eFam,mask);
     718 [ +  - ][ +  - ]:     142595 :     return aIter.Find(rName);
                 [ +  - ]
     719                 :            : }
     720                 :            : 
     721                 :       2798 : const SfxStyles& SfxStyleSheetBasePool::GetStyles()
     722                 :            : {
     723                 :       2798 :     return aStyles;
     724                 :            : }
     725                 :            : 
     726                 :      20743 : SfxStyleSheetBase* SfxStyleSheetBasePool::First()
     727                 :            : {
     728                 :      20743 :     return GetIterator_Impl().First();
     729                 :            : }
     730                 :            : 
     731                 :      21022 : SfxStyleSheetBase* SfxStyleSheetBasePool::Next()
     732                 :            : {
     733                 :      21022 :     return GetIterator_Impl().Next();
     734                 :            : }
     735                 :            : 
     736                 :            : //////////////////////////////// Loeschen /////////////////////////////////
     737                 :            : 
     738                 :          1 : void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p )
     739                 :            : {
     740         [ +  - ]:          1 :     if( p )
     741                 :            :     {
     742         [ +  - ]:          1 :         SfxStyles::iterator aIter( std::find( aStyles.begin(), aStyles.end(), rtl::Reference< SfxStyleSheetBase >( p ) ) );
     743   [ +  -  #  # ]:          1 :         if( aIter != aStyles.end() )
                 [ +  - ]
     744                 :            :         {
     745                 :            :             // Alle Styles umsetzen, deren Parent dieser hier ist
     746 [ +  - ][ +  - ]:          1 :             ChangeParent( p->GetName(), p->GetParent() );
                 [ +  - ]
     747                 :            : 
     748         [ +  - ]:          1 :             com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY );
     749         [ -  + ]:          1 :             if( xComp.is() ) try
     750                 :            :             {
     751 [ #  # ][ #  # ]:          0 :                 xComp->dispose();
     752                 :            :             }
     753         [ #  # ]:          0 :             catch( com::sun::star::uno::Exception& )
     754                 :            :             {
     755                 :            :             }
     756                 :            : 
     757         [ +  - ]:          1 :             aStyles.erase(aIter);
     758 [ +  - ][ +  - ]:          1 :             Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) );
                 [ +  - ]
     759                 :            :         }
     760                 :            :     }
     761                 :          1 : }
     762                 :            : 
     763                 :          0 : void SfxStyleSheetBasePool::Insert( SfxStyleSheetBase* p )
     764                 :            : {
     765                 :            : #if OSL_DEBUG_LEVEL > 0
     766                 :            :     OSL_ENSURE( p, "svl::SfxStyleSheetBasePool::Insert(), no stylesheet?" );
     767                 :            : 
     768                 :            :     SfxStyleSheetIterator aIter(this, p->GetFamily(), p->GetMask());
     769                 :            :     SfxStyleSheetBase* pOld = aIter.Find( p->GetName() );
     770                 :            :     OSL_ENSURE( !pOld, "svl::SfxStyleSheetBasePool::Insert(), StyleSheet already inserted" );
     771                 :            :     if( p->GetParent().Len() )
     772                 :            :     {
     773                 :            :         pOld = aIter.Find( p->GetParent() );
     774                 :            :         OSL_ENSURE( pOld, "svl::SfxStyleSheetBasePool::Insert(), Parent not found!" );
     775                 :            :     }
     776                 :            : #endif
     777         [ #  # ]:          0 :     aStyles.push_back( rtl::Reference< SfxStyleSheetBase >( p ) );
     778         [ #  # ]:          0 :     Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) );
     779                 :          0 : }
     780                 :            : 
     781                 :       2477 : void SfxStyleSheetBasePool::Clear()
     782                 :            : {
     783         [ +  - ]:       2477 :     SfxStyles aClearStyles;
     784                 :       2477 :     aClearStyles.swap( aStyles );
     785                 :            : 
     786                 :       2477 :     SfxStyles::iterator aIter( aClearStyles.begin() );
     787 [ +  - ][ +  + ]:      17805 :     while( aIter != aClearStyles.end() )
     788                 :            :     {
     789         [ +  - ]:      15328 :         com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY );
     790         [ +  + ]:      15328 :         if( xComp.is() ) try
     791                 :            :         {
     792 [ +  - ][ +  - ]:      11970 :             xComp->dispose();
     793                 :            :         }
     794         [ #  # ]:          0 :         catch( com::sun::star::uno::Exception& )
     795                 :            :         {
     796                 :            :         }
     797                 :            : 
     798 [ +  - ][ +  - ]:      15328 :         Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *(*aIter++).get() ) );
         [ +  - ][ +  - ]
     799                 :      17805 :     }
     800         [ #  # ]:       2477 : }
     801                 :            : 
     802                 :            : /////////////////////////// Parents umsetzen ////////////////////////////////
     803                 :            : 
     804                 :        199 : void SfxStyleSheetBasePool::ChangeParent(const XubString& rOld,
     805                 :            :                                          const XubString& rNew,
     806                 :            :                                          sal_Bool bVirtual)
     807                 :            : {
     808                 :        199 :     const sal_uInt16 nTmpMask = GetSearchMask();
     809                 :        199 :     SetSearchMask(GetSearchFamily(), 0xffff);
     810         [ +  + ]:       3894 :     for( SfxStyleSheetBase* p = First(); p; p = Next() )
     811                 :            :     {
     812         [ +  + ]:       3695 :         if( p->GetParent().Equals( rOld ) )
     813                 :            :         {
     814         [ -  + ]:        104 :             if(bVirtual)
     815                 :          0 :                 p->SetParent( rNew );
     816                 :            :             else
     817                 :        104 :                 p->aParent = rNew;
     818                 :            :         }
     819                 :            :     }
     820                 :        199 :     SetSearchMask(GetSearchFamily(), nTmpMask);
     821                 :        199 : }
     822                 :            : 
     823                 :            : /////////////////////////// Laden/Speichern /////////////////////////////////
     824                 :            : 
     825                 :          0 : void SfxStyleSheetBase::Load( SvStream&, sal_uInt16 )
     826                 :            : {
     827                 :          0 : }
     828                 :            : 
     829                 :          0 : void SfxStyleSheetBase::Store( SvStream& )
     830                 :            : {
     831                 :          0 : }
     832                 :            : 
     833                 :      32228 : SfxItemPool& SfxStyleSheetBasePool::GetPool()
     834                 :            : {
     835                 :      32228 :     return rPool;
     836                 :            : }
     837                 :            : 
     838                 :          0 : const SfxItemPool& SfxStyleSheetBasePool::GetPool() const
     839                 :            : {
     840                 :          0 :     return rPool;
     841                 :            : }
     842                 :            : 
     843                 :            : /////////////////////// SfxStyleSheet /////////////////////////////////
     844                 :            : 
     845                 :      15914 : SfxStyleSheet::SfxStyleSheet(const XubString &rName,
     846                 :            :                              const SfxStyleSheetBasePool& r_Pool,
     847                 :            :                              SfxStyleFamily eFam,
     848                 :            :                              sal_uInt16 mask ):
     849 [ +  - ][ +  - ]:      15914 :     SfxStyleSheetBase(rName, const_cast< SfxStyleSheetBasePool* >( &r_Pool ), eFam, mask)
     850                 :      15914 : {}
     851                 :            : 
     852                 :          0 : SfxStyleSheet::SfxStyleSheet(const SfxStyleSheet& rStyle) :
     853                 :            :     SfxStyleSheetBase(rStyle),
     854                 :            :     SfxListener( rStyle ),
     855 [ #  # ][ #  # ]:          0 :     SfxBroadcaster( rStyle )
     856                 :          0 : {}
     857                 :            : 
     858 [ +  - ][ +  - ]:      15329 : SfxStyleSheet::~SfxStyleSheet()
     859                 :            : {
     860 [ +  - ][ +  - ]:      15329 :     Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_INDESTRUCTION, *this ) );
                 [ +  - ]
     861         [ -  + ]:      15329 : }
     862                 :            : 
     863                 :            : 
     864                 :      18007 : sal_Bool SfxStyleSheet::SetParent( const XubString& rName )
     865                 :            : {
     866 [ +  - ][ +  + ]:      18007 :     if(aParent == rName)
     867                 :       4646 :         return sal_True;
     868         [ +  - ]:      13361 :     const XubString aOldParent(aParent);
     869 [ +  - ][ +  - ]:      13361 :     if(SfxStyleSheetBase::SetParent(rName)) {
     870                 :            :             // aus der Benachrichtigungskette des alten
     871                 :            :             // Parents gfs. austragen
     872         [ +  + ]:      13361 :         if(aOldParent.Len()) {
     873         [ +  - ]:       1196 :             SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aOldParent, nFamily, 0xffff);
     874         [ +  - ]:       1196 :             if(pParent)
     875         [ +  - ]:       1196 :                 EndListening(*pParent);
     876                 :            :         }
     877                 :            :             // in die Benachrichtigungskette des neuen
     878                 :            :             // Parents eintragen
     879         [ +  - ]:      13361 :         if(aParent.Len()) {
     880         [ +  - ]:      13361 :             SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aParent, nFamily, 0xffff);
     881         [ +  - ]:      13361 :             if(pParent)
     882         [ +  - ]:      13361 :                 StartListening(*pParent);
     883                 :            :         }
     884                 :      13361 :         return sal_True;
     885                 :            :     }
     886         [ +  - ]:      18007 :     return sal_False;
     887                 :            : }
     888                 :            : 
     889                 :            : // alle Zuhoerer benachtichtigen
     890                 :            : 
     891                 :     772633 : void SfxStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint )
     892                 :            : {
     893                 :     772633 :     Forward(rBC, rHint);
     894                 :     772633 : }
     895                 :            : 
     896                 :            : //////////////////////// SfxStyleSheetPool ///////////////////////////////
     897                 :            : 
     898                 :       1024 : SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool const& rSet)
     899                 :       1024 : : SfxStyleSheetBasePool( const_cast< SfxItemPool& >( rSet ) )
     900                 :            : {
     901                 :       1024 : }
     902                 :            : 
     903                 :            : /////////////////////////////////// Factory ////////////////////////////////
     904                 :            : 
     905                 :          0 : SfxStyleSheetBase* SfxStyleSheetPool::Create( const XubString& rName,
     906                 :            :                                     SfxStyleFamily eFam, sal_uInt16 mask )
     907                 :            : {
     908         [ #  # ]:          0 :     return new SfxStyleSheet( rName, *this, eFam, mask );
     909                 :            : }
     910                 :            : 
     911                 :          0 : SfxStyleSheetBase* SfxStyleSheetPool::Create( const SfxStyleSheet& r )
     912                 :            : {
     913         [ #  # ]:          0 :     return new SfxStyleSheet( r );
     914                 :            : }
     915                 :            : 
     916                 :            : // --------------------------------------------------------------------
     917                 :            : // class SfxUnoStyleSheet
     918                 :            : // --------------------------------------------------------------------
     919                 :            : 
     920                 :      12201 : SfxUnoStyleSheet::SfxUnoStyleSheet( const UniString& _rName, const SfxStyleSheetBasePool& _rPool, SfxStyleFamily _eFamily, sal_uInt16 _nMaske )
     921                 :      12201 : : ::cppu::ImplInheritanceHelper2< SfxStyleSheet, ::com::sun::star::style::XStyle, ::com::sun::star::lang::XUnoTunnel >( _rName, _rPool, _eFamily, _nMaske )
     922                 :            : {
     923                 :      12201 : }
     924                 :            : 
     925                 :            : // --------------------------------------------------------------------
     926                 :            : 
     927                 :       1763 : SfxUnoStyleSheet* SfxUnoStyleSheet::getUnoStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle )
     928                 :            : {
     929         [ -  + ]:       1763 :     SfxUnoStyleSheet* pRet = dynamic_cast< SfxUnoStyleSheet* >( xStyle.get() );
     930         [ -  + ]:       1763 :     if( !pRet )
     931                 :            :     {
     932         [ #  # ]:          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( xStyle, ::com::sun::star::uno::UNO_QUERY );
     933         [ #  # ]:          0 :         if( xUT.is() )
     934 [ #  # ][ #  # ]:          0 :             pRet = reinterpret_cast<SfxUnoStyleSheet*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SfxUnoStyleSheet::getIdentifier())));
                 [ #  # ]
     935                 :            :     }
     936                 :       1763 :     return pRet;
     937                 :            : }
     938                 :            : 
     939                 :            : // --------------------------------------------------------------------
     940                 :            : // XUnoTunnel
     941                 :            : // --------------------------------------------------------------------
     942                 :            : 
     943                 :          0 : ::sal_Int64 SAL_CALL SfxUnoStyleSheet::getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
     944                 :            : {
     945 [ #  # ][ #  # ]:          0 :     if( rId.getLength() == 16 && 0 == rtl_compareMemory( getIdentifier().getConstArray(), rId.getConstArray(), 16 ) )
                 [ #  # ]
     946                 :            :     {
     947                 :          0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
     948                 :            :     }
     949                 :            :     else
     950                 :            :     {
     951                 :          0 :         return 0;
     952                 :            :     }
     953                 :            : }
     954                 :            : 
     955                 :            : // --------------------------------------------------------------------
     956                 :            : 
     957                 :            : namespace
     958                 :            : {
     959                 :            :     class theSfxUnoStyleSheetIdentifier : public rtl::Static< UnoTunnelIdInit, theSfxUnoStyleSheetIdentifier > {};
     960                 :            : }
     961                 :            : 
     962                 :          0 : const ::com::sun::star::uno::Sequence< ::sal_Int8 >& SfxUnoStyleSheet::getIdentifier()
     963                 :            : {
     964                 :          0 :     return theSfxUnoStyleSheetIdentifier::get().getSeq();
     965                 :            : }
     966                 :            : 
     967                 :            : // --------------------------------------------------------------------
     968                 :            : 
     969                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10