LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/doc - fmtcol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 165 316 52.2 %
Date: 2012-12-27 Functions: 27 50 54.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <sal/macros.h>
      22             : #include <hintids.hxx>
      23             : #include <editeng/ulspitem.hxx>
      24             : #include <editeng/lrspitem.hxx>
      25             : #include <editeng/fhgtitem.hxx>
      26             : #include <doc.hxx>          // for GetAttrPool
      27             : #include <fmtcol.hxx>
      28             : #include <fmtcolfunc.hxx>
      29             : #include <hints.hxx>
      30             : #include <calc.hxx>
      31             : #include <node.hxx>
      32             : #include <numrule.hxx>
      33             : #include <paratr.hxx>
      34             : #include <switerator.hxx>
      35             : #include <svl/intitem.hxx>
      36             : 
      37       61540 : TYPEINIT1( SwTxtFmtColl, SwFmtColl );
      38        2046 : TYPEINIT1( SwGrfFmtColl, SwFmtColl );
      39        7044 : TYPEINIT1( SwConditionTxtFmtColl, SwTxtFmtColl );
      40           0 : TYPEINIT1( SwCollCondition, SwClient );
      41             : 
      42             : namespace TxtFmtCollFunc
      43             : {
      44             : 
      45             :     // #i71574#
      46        2481 :     void CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle(
      47             :                                             SwFmt* pFmt,
      48             :                                             const SwNumRuleItem* pNewNumRuleItem )
      49             :     {
      50        2481 :         SwTxtFmtColl* pTxtFmtColl = dynamic_cast<SwTxtFmtColl*>(pFmt);
      51        2481 :         if ( !pTxtFmtColl )
      52             :         {
      53             :             OSL_FAIL( "<TxtFmtCollFunc::CheckTxtFmtCollFuncForDeletionOfAssignmentToOutlineStyle> - misuse of method - it's only for instances of <SwTxtFmtColl>" );
      54        2481 :             return;
      55             :         }
      56             : 
      57             :         // #i73790#
      58        4903 :         if ( !pTxtFmtColl->StayAssignedToListLevelOfOutlineStyle() &&
      59        2422 :              pTxtFmtColl->IsAssignedToListLevelOfOutlineStyle() )
      60             :         {
      61         191 :             if ( !pNewNumRuleItem )
      62             :             {
      63         155 :                 pTxtFmtColl->GetItemState( RES_PARATR_NUMRULE, sal_False, (const SfxPoolItem**)&pNewNumRuleItem );
      64             :             }
      65         191 :             if ( pNewNumRuleItem )
      66             :             {
      67         191 :                 String sNumRuleName = pNewNumRuleItem->GetValue();
      68         382 :                 if ( sNumRuleName.Len() == 0 ||
      69         191 :                      sNumRuleName != pTxtFmtColl->GetDoc()->GetOutlineNumRule()->GetName() )
      70             :                 {
      71             :                     // delete assignment of paragraph style to list level of outline style.
      72           0 :                     pTxtFmtColl->DeleteAssignmentToListLevelOfOutlineStyle();
      73         191 :                 }
      74             :             }
      75             :         }
      76             :     }
      77             : 
      78         404 :     SwNumRule* GetNumRule( SwTxtFmtColl& rTxtFmtColl )
      79             :     {
      80         404 :         SwNumRule* pNumRule( 0 );
      81             : 
      82         404 :         const SwNumRuleItem* pNumRuleItem( 0 );
      83         404 :         rTxtFmtColl.GetItemState( RES_PARATR_NUMRULE, sal_False, (const SfxPoolItem**)&pNumRuleItem );
      84         404 :         if ( pNumRuleItem )
      85             :         {
      86         240 :             const String sNumRuleName = pNumRuleItem->GetValue();
      87         240 :             if ( sNumRuleName.Len() > 0 )
      88             :             {
      89         207 :                 pNumRule = rTxtFmtColl.GetDoc()->FindNumRulePtr( sNumRuleName );
      90         240 :             }
      91             :         }
      92             : 
      93         404 :         return pNumRule;
      94             :     }
      95             : 
      96         202 :     void AddToNumRule( SwTxtFmtColl& rTxtFmtColl )
      97             :     {
      98         202 :         SwNumRule* pNumRule = GetNumRule( rTxtFmtColl );
      99         202 :         if ( pNumRule )
     100             :         {
     101         182 :             pNumRule->AddParagraphStyle( rTxtFmtColl );
     102             :         }
     103         202 :     }
     104             : 
     105         202 :     void RemoveFromNumRule( SwTxtFmtColl& rTxtFmtColl )
     106             :     {
     107         202 :         SwNumRule* pNumRule = GetNumRule( rTxtFmtColl );
     108         202 :         if ( pNumRule )
     109             :         {
     110          25 :             pNumRule->RemoveParagraphStyle( rTxtFmtColl );
     111             :         }
     112         202 :     }
     113             : } // end of namespace TxtFmtCollFunc
     114             : 
     115             : /*
     116             :  * SwTxtFmtColl  TXT
     117             :  */
     118             : 
     119       23205 : void SwTxtFmtColl::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     120             : {
     121       23205 :     if( GetDoc()->IsInDtor() )
     122             :     {
     123         118 :         SwFmtColl::Modify( pOld, pNew );
     124       23205 :         return;
     125             :     }
     126             : 
     127       23087 :     bool bNewParent( false ); // #i66431# - adjust type of <bNewParent>
     128       23087 :     SvxULSpaceItem *pNewULSpace = 0, *pOldULSpace = 0;
     129       23087 :     SvxLRSpaceItem *pNewLRSpace = 0, *pOldLRSpace = 0;
     130       23087 :     SvxFontHeightItem* aFontSizeArr[3] = {0,0,0};
     131             :     // #i70223#
     132       23087 :     const bool bAssignedToListLevelOfOutlineStyle(IsAssignedToListLevelOfOutlineStyle());//#outline level ,zhaojianwei
     133       23087 :     const SwNumRuleItem* pNewNumRuleItem( 0L );
     134             : 
     135       23087 :     SwAttrSetChg *pNewChgSet = 0,  *pOldChgSet = 0;
     136             : 
     137       23087 :     switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
     138             :     {
     139             :     case RES_ATTRSET_CHG:
     140             :         // Only recalculate if we're not the sender!
     141       20742 :         pNewChgSet = (SwAttrSetChg*)pNew;
     142       20742 :         pOldChgSet = (SwAttrSetChg*)pOld;
     143       20742 :         pNewChgSet->GetChgSet()->GetItemState(
     144       20742 :             RES_LR_SPACE, sal_False, (const SfxPoolItem**)&pNewLRSpace );
     145       20742 :         pNewChgSet->GetChgSet()->GetItemState(
     146       20742 :             RES_UL_SPACE, sal_False, (const SfxPoolItem**)&pNewULSpace );
     147       20742 :         pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_FONTSIZE,
     148       20742 :                         sal_False, (const SfxPoolItem**)&(aFontSizeArr[0]) );
     149       20742 :         pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_CJK_FONTSIZE,
     150       20742 :                         sal_False, (const SfxPoolItem**)&(aFontSizeArr[1]) );
     151       20742 :         pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_CTL_FONTSIZE,
     152       20742 :                         sal_False, (const SfxPoolItem**)&(aFontSizeArr[2]) );
     153             :         // #i70223#, #i84745#
     154             :         // check, if attribute set is applied to this paragraph style
     155       21039 :         if ( bAssignedToListLevelOfOutlineStyle &&
     156         297 :              pNewChgSet->GetTheChgdSet() == &GetAttrSet() )
     157             :         {
     158          95 :             pNewChgSet->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, sal_False,
     159          95 :                                                    (const SfxPoolItem**)&pNewNumRuleItem );
     160             :         }
     161             : 
     162       20742 :         break;
     163             : 
     164             :     case RES_FMT_CHG:
     165        2345 :         if( GetAttrSet().GetParent() )
     166             :         {
     167        1885 :             const SfxItemSet* pParent = GetAttrSet().GetParent();
     168        1885 :             pNewLRSpace = (SvxLRSpaceItem*)&pParent->Get( RES_LR_SPACE );
     169        1885 :             pNewULSpace = (SvxULSpaceItem*)&pParent->Get( RES_UL_SPACE );
     170        1885 :             aFontSizeArr[0] = (SvxFontHeightItem*)&pParent->Get( RES_CHRATR_FONTSIZE );
     171        1885 :             aFontSizeArr[1] = (SvxFontHeightItem*)&pParent->Get( RES_CHRATR_CJK_FONTSIZE );
     172        1885 :             aFontSizeArr[2] = (SvxFontHeightItem*)&pParent->Get( RES_CHRATR_CTL_FONTSIZE );
     173             :             // #i66431# - modify has to be propagated, because of new parent format.
     174        1885 :             bNewParent = true;
     175             :         }
     176        2345 :         break;
     177             : 
     178             :     case RES_LR_SPACE:
     179           0 :         pNewLRSpace = (SvxLRSpaceItem*)pNew;
     180           0 :         break;
     181             :     case RES_UL_SPACE:
     182           0 :         pNewULSpace = (SvxULSpaceItem*)pNew;
     183           0 :         break;
     184             :     case RES_CHRATR_FONTSIZE:
     185           0 :         aFontSizeArr[0] = (SvxFontHeightItem*)pNew;
     186           0 :         break;
     187             :     case RES_CHRATR_CJK_FONTSIZE:
     188           0 :         aFontSizeArr[1] = (SvxFontHeightItem*)pNew;
     189           0 :         break;
     190             :     case RES_CHRATR_CTL_FONTSIZE:
     191           0 :         aFontSizeArr[2] = (SvxFontHeightItem*)pNew;
     192           0 :         break;
     193             :     // #i70223#
     194             :     case RES_PARATR_NUMRULE:
     195             :     {
     196           0 :         if ( bAssignedToListLevelOfOutlineStyle )
     197             :         {
     198           0 :             pNewNumRuleItem = (SwNumRuleItem*)pNew;
     199             :         }
     200             :     }
     201             :     default:
     202           0 :         break;
     203             :     }
     204             : 
     205             :     // #i70223#
     206       23087 :     if ( bAssignedToListLevelOfOutlineStyle && pNewNumRuleItem )
     207             :     {
     208             :         TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle(
     209          95 :                                                         this, pNewNumRuleItem );
     210             :     }
     211             : 
     212       23087 :     int bWeiter = sal_True;
     213             : 
     214             :     // Check against the own attributes
     215       25017 :     if( pNewLRSpace && SFX_ITEM_SET == GetItemState( RES_LR_SPACE, sal_False,
     216        1930 :                                         (const SfxPoolItem**)&pOldLRSpace ))
     217             :     {
     218          11 :         int bChg = sal_False;
     219          11 :         if( pOldLRSpace != pNewLRSpace )    // Avoid recursion (SetAttr!)
     220             :         {
     221           7 :             SvxLRSpaceItem aNew( *pOldLRSpace );
     222             :             // We had a relative value -> recalculate
     223           7 :             if( 100 != aNew.GetPropLeft() )
     224             :             {
     225           0 :                 long nTmp = aNew.GetLeft();     // keep so that we can compare
     226           0 :                 aNew.SetLeft( pNewLRSpace->GetLeft(), aNew.GetPropLeft() );
     227           0 :                 bChg |= nTmp != aNew.GetLeft();
     228             :             }
     229             :             // We had a relative value -> recalculate
     230           7 :             if( 100 != aNew.GetPropRight() )
     231             :             {
     232           0 :                 long nTmp = aNew.GetRight();    // keep so that we can compare
     233           0 :                 aNew.SetRight( pNewLRSpace->GetRight(), aNew.GetPropRight() );
     234           0 :                 bChg |= nTmp != aNew.GetRight();
     235             :             }
     236             :             // We had a relative value -> recalculate
     237           7 :             if( 100 != aNew.GetPropTxtFirstLineOfst() )
     238             :             {
     239           0 :                 short nTmp = aNew.GetTxtFirstLineOfst();    // keep so that we can compare
     240           0 :                 aNew.SetTxtFirstLineOfst( pNewLRSpace->GetTxtFirstLineOfst(),
     241           0 :                                             aNew.GetPropTxtFirstLineOfst() );
     242           0 :                 bChg |= nTmp != aNew.GetTxtFirstLineOfst();
     243             :             }
     244           7 :             if( bChg )
     245             :             {
     246           0 :                 SetFmtAttr( aNew );
     247           0 :                 bWeiter = 0 != pOldChgSet || bNewParent;
     248             :             }
     249             :             // We set it to absolute -> do not propagate it further, unless
     250             :             // we set it!
     251           7 :             else if( pNewChgSet )
     252           0 :                 bWeiter = pNewChgSet->GetTheChgdSet() == &GetAttrSet();
     253             :         }
     254             :     }
     255             : 
     256       25781 :     if( pNewULSpace && SFX_ITEM_SET == GetItemState(
     257        2694 :             RES_UL_SPACE, sal_False, (const SfxPoolItem**)&pOldULSpace ) &&
     258             :         pOldULSpace != pNewULSpace )    // Avoid recursion (SetAttr!)
     259             :     {
     260         802 :         SvxULSpaceItem aNew( *pOldULSpace );
     261         802 :         int bChg = sal_False;
     262             :         // We had a relative value -> recalculate
     263         802 :         if( 100 != aNew.GetPropUpper() )
     264             :         {
     265           0 :             sal_uInt16 nTmp = aNew.GetUpper();      // keep so that we can compare
     266           0 :             aNew.SetUpper( pNewULSpace->GetUpper(), aNew.GetPropUpper() );
     267           0 :             bChg |= nTmp != aNew.GetUpper();
     268             :         }
     269             :         // We had a relative value -> recalculate
     270         802 :         if( 100 != aNew.GetPropLower() )
     271             :         {
     272           0 :             sal_uInt16 nTmp = aNew.GetLower();      // keep so that we can compare
     273           0 :             aNew.SetLower( pNewULSpace->GetLower(), aNew.GetPropLower() );
     274           0 :             bChg |= nTmp != aNew.GetLower();
     275             :         }
     276         802 :         if( bChg )
     277             :         {
     278           0 :             SetFmtAttr( aNew );
     279           0 :             bWeiter = 0 != pOldChgSet || bNewParent;
     280             :         }
     281             :         // We set it to absolute -> do not propagate it further, unless
     282             :         // we set it!
     283         802 :         else if( pNewChgSet )
     284         166 :             bWeiter = pNewChgSet->GetTheChgdSet() == &GetAttrSet();
     285             :     }
     286             : 
     287             : 
     288       92348 :     for( int nC = 0, nArrLen = sizeof(aFontSizeArr) / sizeof( aFontSizeArr[0]);
     289             :             nC < nArrLen; ++nC )
     290             :     {
     291       69261 :         SvxFontHeightItem *pFSize = aFontSizeArr[ nC ], *pOldFSize;
     292       79983 :         if( pFSize && SFX_ITEM_SET == GetItemState(
     293       10722 :             pFSize->Which(), sal_False, (const SfxPoolItem**)&pOldFSize ) &&
     294             :             // Avoid recursion (SetAttr!)
     295             :             pFSize != pOldFSize )
     296             :         {
     297        4896 :             if( 100 == pOldFSize->GetProp() &&
     298        2448 :                 SFX_MAPUNIT_RELATIVE == pOldFSize->GetPropUnit() )
     299             :             {
     300             :                 // We set it to absolute -> do not propagate it further, unless
     301             :                 // we set it!
     302        2448 :                 if( pNewChgSet )
     303         832 :                     bWeiter = pNewChgSet->GetTheChgdSet() == &GetAttrSet();
     304             :             }
     305             :             else
     306             :             {
     307             :                 // We had a relative value -> recalculate
     308           0 :                 sal_uInt32 nTmp = pOldFSize->GetHeight();       // keep so that we can compare
     309           0 :                 SvxFontHeightItem aNew(240 , 100, pFSize->Which());
     310           0 :                 aNew.SetHeight( pFSize->GetHeight(), pOldFSize->GetProp(),
     311           0 :                                 pOldFSize->GetPropUnit() );
     312           0 :                 if( nTmp != aNew.GetHeight() )
     313             :                 {
     314           0 :                     SetFmtAttr( aNew );
     315           0 :                     bWeiter = 0 != pOldChgSet || bNewParent;
     316             :                 }
     317             :                 // We set it to absolute -> do not propagate it further, unless
     318             :                 // we set it!
     319           0 :                 else if( pNewChgSet )
     320           0 :                     bWeiter = pNewChgSet->GetTheChgdSet() == &GetAttrSet();
     321             :             }
     322             :         }
     323             :     }
     324             : 
     325       23087 :     if( bWeiter )
     326       22294 :         SwFmtColl::Modify( pOld, pNew );
     327             : }
     328             : 
     329           0 : bool SwTxtFmtColl::IsAtDocNodeSet() const
     330             : {
     331           0 :     SwIterator<SwCntntNode,SwFmtColl> aIter( *this );
     332           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     333           0 :     for( SwCntntNode* pNode = aIter.First(); pNode; pNode = aIter.Next() )
     334           0 :         if( &(pNode->GetNodes()) == &rNds )
     335           0 :             return true;
     336             : 
     337           0 :     return false;
     338             : }
     339             : 
     340        7031 : bool SwTxtFmtColl::SetFmtAttr( const SfxPoolItem& rAttr )
     341             : {
     342        7031 :     const bool bIsNumRuleItem = rAttr.Which() == RES_PARATR_NUMRULE;
     343        7031 :     if ( bIsNumRuleItem )
     344             :     {
     345         173 :         TxtFmtCollFunc::RemoveFromNumRule( *this );
     346             :     }
     347             : 
     348        7031 :     const bool bRet = SwFmtColl::SetFmtAttr( rAttr );
     349             : 
     350        7031 :     if ( bIsNumRuleItem )
     351             :     {
     352         173 :         TxtFmtCollFunc::AddToNumRule( *this );
     353             :     }
     354             : 
     355        7031 :     return bRet;
     356             : }
     357             : 
     358        2835 : bool SwTxtFmtColl::SetFmtAttr( const SfxItemSet& rSet )
     359             : {
     360             :     const bool bIsNumRuleItemAffected =
     361        2835 :                 rSet.GetItemState( RES_PARATR_NUMRULE, sal_False ) == SFX_ITEM_SET;
     362        2835 :     if ( bIsNumRuleItemAffected )
     363             :     {
     364          29 :         TxtFmtCollFunc::RemoveFromNumRule( *this );
     365             :     }
     366             : 
     367        2835 :     const bool bRet = SwFmtColl::SetFmtAttr( rSet );
     368             : 
     369        2835 :     if ( bIsNumRuleItemAffected )
     370             :     {
     371          29 :         TxtFmtCollFunc::AddToNumRule( *this );
     372             :     }
     373             : 
     374        2835 :     return bRet;
     375             : }
     376             : 
     377        2118 : bool SwTxtFmtColl::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
     378             : {
     379             :     const bool bIsNumRuleItemAffected =
     380             :                 ( nWhich2 != 0 && nWhich2 > nWhich1 )
     381             :                 ? ( nWhich1 <= RES_PARATR_NUMRULE &&
     382             :                     RES_PARATR_NUMRULE <= nWhich2 )
     383        2118 :                 : nWhich1 == RES_PARATR_NUMRULE;
     384        2118 :     if ( bIsNumRuleItemAffected )
     385             :     {
     386           0 :         TxtFmtCollFunc::RemoveFromNumRule( *this );
     387             :     }
     388             : 
     389        2118 :     const bool bRet = SwFmtColl::ResetFmtAttr( nWhich1, nWhich2 );
     390             : 
     391        2118 :     return bRet;
     392             : }
     393             : 
     394             : // #i73790#
     395         300 : sal_uInt16 SwTxtFmtColl::ResetAllFmtAttr()
     396             : {
     397         300 :     const bool bOldState( mbStayAssignedToListLevelOfOutlineStyle );
     398         300 :     mbStayAssignedToListLevelOfOutlineStyle = true;
     399             :     // #i70748#
     400             :     // Outline level is no longer a member, it is a attribute now.
     401             :     // Thus, it needs to be restored, if the paragraph style is assigned
     402             :     // to the outline style
     403         300 :     const int nAssignedOutlineStyleLevel = IsAssignedToListLevelOfOutlineStyle()
     404             :                                      ? GetAssignedOutlineStyleLevel()
     405         300 :                                      : -1;
     406             : 
     407         300 :     sal_uInt16 nRet = SwFmtColl::ResetAllFmtAttr();
     408             : 
     409             :     // #i70748#
     410         300 :     if ( nAssignedOutlineStyleLevel != -1 )
     411             :     {
     412          59 :         AssignToListLevelOfOutlineStyle( nAssignedOutlineStyleLevel );
     413             :     }
     414             : 
     415         300 :     mbStayAssignedToListLevelOfOutlineStyle = bOldState;
     416             : 
     417         300 :     return nRet;
     418             : }
     419             : 
     420           0 : bool SwTxtFmtColl::AreListLevelIndentsApplicable() const
     421             : {
     422           0 :     bool bAreListLevelIndentsApplicable( true );
     423             : 
     424           0 :     if ( GetItemState( RES_PARATR_NUMRULE ) != SFX_ITEM_SET )
     425             :     {
     426             :         // no list style applied to paragraph style
     427           0 :         bAreListLevelIndentsApplicable = false;
     428             :     }
     429           0 :     else if ( GetItemState( RES_LR_SPACE, sal_False ) == SFX_ITEM_SET )
     430             :     {
     431             :         // paragraph style has hard-set indent attributes
     432           0 :         bAreListLevelIndentsApplicable = false;
     433             :     }
     434           0 :     else if ( GetItemState( RES_PARATR_NUMRULE, sal_False ) == SFX_ITEM_SET )
     435             :     {
     436             :         // list style is directly applied to paragraph style and paragraph
     437             :         // style has no hard-set indent attributes
     438           0 :         bAreListLevelIndentsApplicable = true;
     439             :     }
     440             :     else
     441             :     {
     442             :         // list style is applied through one of the parent paragraph styles and
     443             :         // paragraph style has no hard-set indent attributes
     444             : 
     445             :         // check parent paragraph styles
     446           0 :         const SwTxtFmtColl* pColl = dynamic_cast<const SwTxtFmtColl*>(DerivedFrom());
     447           0 :         while ( pColl )
     448             :         {
     449           0 :             if ( pColl->GetAttrSet().GetItemState( RES_LR_SPACE, sal_False ) == SFX_ITEM_SET )
     450             :             {
     451             :                 // indent attributes found in the paragraph style hierarchy.
     452           0 :                 bAreListLevelIndentsApplicable = false;
     453           0 :                 break;
     454             :             }
     455             : 
     456           0 :             if ( pColl->GetAttrSet().GetItemState( RES_PARATR_NUMRULE, sal_False ) == SFX_ITEM_SET )
     457             :             {
     458             :                 // paragraph style with the list style found and until now no
     459             :                 // indent attributes are found in the paragraph style hierarchy.
     460           0 :                 bAreListLevelIndentsApplicable = true;
     461           0 :                 break;
     462             :             }
     463             : 
     464           0 :             pColl = dynamic_cast<const SwTxtFmtColl*>(pColl->DerivedFrom());
     465             :             OSL_ENSURE( pColl,
     466             :                     "<SwTxtFmtColl::AreListLevelIndentsApplicable()> - something wrong in paragraph style hierarchy. The applied list style is not found." );
     467             :         }
     468             :     }
     469             : 
     470           0 :     return bAreListLevelIndentsApplicable;
     471             : }
     472             : 
     473             : //FEATURE::CONDCOLL
     474             : 
     475           1 : SwCollCondition::SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
     476             :                                 sal_uLong nSubCond )
     477           1 :     : SwClient( pColl ), nCondition( nMasterCond )
     478             : {
     479           1 :     aSubCondition.nSubCondition = nSubCond;
     480           1 : }
     481             : 
     482             : 
     483           0 : SwCollCondition::SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
     484             :                                     const String& rSubExp )
     485           0 :     : SwClient( pColl ), nCondition( nMasterCond )
     486             : {
     487           0 :     if( USRFLD_EXPRESSION & nCondition )
     488           0 :         aSubCondition.pFldExpression = new String( rSubExp );
     489             :     else
     490           0 :         aSubCondition.nSubCondition = 0;
     491           0 : }
     492             : 
     493             : 
     494           0 : SwCollCondition::SwCollCondition( const SwCollCondition& rCopy )
     495           0 :     : SwClient( (SwModify*)rCopy.GetRegisteredIn() ), nCondition( rCopy.nCondition )
     496             : {
     497           0 :     if( USRFLD_EXPRESSION & rCopy.nCondition )
     498           0 :         aSubCondition.pFldExpression = new String( *rCopy.GetFldExpression() );
     499             :     else
     500           0 :         aSubCondition.nSubCondition = rCopy.aSubCondition.nSubCondition;
     501           0 : }
     502             : 
     503             : 
     504           2 : SwCollCondition::~SwCollCondition()
     505             : {
     506           1 :     if( USRFLD_EXPRESSION & nCondition )
     507           0 :         delete aSubCondition.pFldExpression;
     508           1 : }
     509             : 
     510           0 : void SwCollCondition::RegisterToFormat( SwFmt& rFmt )
     511             : {
     512           0 :     rFmt.Add( this );
     513           0 : }
     514             : 
     515             : 
     516             : 
     517           0 : int SwCollCondition::operator==( const SwCollCondition& rCmp ) const
     518             : {
     519           0 :     int nRet = 0;
     520           0 :     if( nCondition == rCmp.nCondition )
     521             :     {
     522           0 :         if( USRFLD_EXPRESSION & nCondition )
     523             :         {
     524             :             // The SubCondition contains the expression for the UserField
     525           0 :             const String* pTmp = aSubCondition.pFldExpression;
     526           0 :             if( !pTmp )
     527           0 :                 pTmp = rCmp.aSubCondition.pFldExpression;
     528           0 :             if( pTmp )
     529             :             {
     530           0 :                 SwTxtFmtColl* pColl = GetTxtFmtColl();
     531           0 :                 if( !pColl )
     532           0 :                     pColl = rCmp.GetTxtFmtColl();
     533             : 
     534           0 :                 if( pColl )
     535             :                 {
     536           0 :                     SwCalc aCalc( *pColl->GetDoc() );
     537           0 :                     nRet = 0 != aCalc.Calculate( *pTmp ).GetBool();
     538             :                 }
     539             :             }
     540             :         }
     541           0 :         else if( aSubCondition.nSubCondition ==
     542             :                     rCmp.aSubCondition.nSubCondition )
     543           0 :             nRet = 1;
     544             :     }
     545           0 :     return nRet;
     546             : }
     547             : 
     548             : 
     549           0 : void SwCollCondition::SetCondition( sal_uLong nCond, sal_uLong nSubCond )
     550             : {
     551           0 :     if( USRFLD_EXPRESSION & nCondition )
     552           0 :         delete aSubCondition.pFldExpression;
     553           0 :     nCondition = nCond;
     554           0 :     aSubCondition.nSubCondition = nSubCond;
     555           0 : }
     556             : 
     557             : 
     558         202 : SwConditionTxtFmtColl::~SwConditionTxtFmtColl()
     559             : {
     560         202 : }
     561             : 
     562           0 : const SwCollCondition* SwConditionTxtFmtColl::HasCondition(
     563             :                         const SwCollCondition& rCond ) const
     564             : {
     565           0 :     const SwCollCondition* pFnd = 0;
     566             :     sal_uInt16 n;
     567             : 
     568           0 :     for( n = 0; n < aCondColls.size(); ++n )
     569           0 :         if( *( pFnd = &aCondColls[ n ]) == rCond )
     570           0 :             break;
     571             : 
     572           0 :     return n < aCondColls.size() ? pFnd : 0;
     573             : }
     574             : 
     575             : 
     576           0 : void SwConditionTxtFmtColl::InsertCondition( const SwCollCondition& rCond )
     577             : {
     578           0 :     for( sal_uInt16 n = 0; n < aCondColls.size(); ++n )
     579           0 :         if( aCondColls[ n ] == rCond )
     580             :         {
     581           0 :             aCondColls.erase( aCondColls.begin() + n );
     582           0 :             break;
     583             :         }
     584             : 
     585             :     // Not found -> so insert it
     586           0 :     SwCollCondition* pNew = new SwCollCondition( rCond );
     587           0 :     aCondColls.push_back( pNew );
     588           0 : }
     589             : 
     590             : 
     591           0 : bool SwConditionTxtFmtColl::RemoveCondition( const SwCollCondition& rCond )
     592             : {
     593           0 :     bool bRet = false;
     594           0 :     for( sal_uInt16 n = 0; n < aCondColls.size(); ++n )
     595           0 :         if( aCondColls[ n ] == rCond )
     596             :         {
     597           0 :             aCondColls.erase( aCondColls.begin() + n );
     598           0 :             bRet = true;
     599             :         }
     600             : 
     601           0 :     return bRet;
     602             : }
     603             : 
     604           0 : void SwConditionTxtFmtColl::SetConditions( const SwFmtCollConditions& rCndClls )
     605             : {
     606             :     // Copy the Conditions, but first delete the old ones
     607           0 :     aCondColls.clear();
     608           0 :     SwDoc& rDoc = *GetDoc();
     609           0 :     for( sal_uInt16 n = 0; n < rCndClls.size(); ++n )
     610             :     {
     611           0 :         const SwCollCondition* pFnd = &rCndClls[ n ];
     612           0 :         SwTxtFmtColl* pTmpColl = pFnd->GetTxtFmtColl()
     613           0 :                                     ? rDoc.CopyTxtColl( *pFnd->GetTxtFmtColl() )
     614           0 :                                     : 0;
     615             :         SwCollCondition* pNew;
     616           0 :         if( USRFLD_EXPRESSION & pFnd->GetCondition() )
     617             :             pNew = new SwCollCondition( pTmpColl, pFnd->GetCondition(),
     618           0 :                                         *pFnd->GetFldExpression() );
     619             :         else
     620             :             pNew = new SwCollCondition( pTmpColl, pFnd->GetCondition(),
     621           0 :                                         pFnd->GetSubCondition() );
     622           0 :         aCondColls.push_back( pNew );
     623             :     }
     624           0 : }
     625             : //#outline level, zhaojianwei
     626         802 : void SwTxtFmtColl::SetAttrOutlineLevel( int nLevel)
     627             : {
     628             :     OSL_ENSURE( 0 <= nLevel && nLevel <= MAXLEVEL ,"SwTxtFmtColl: Level Out Of Range" );
     629             :     SetFmtAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL,
     630         802 :                             static_cast<sal_uInt16>(nLevel) ) );
     631         802 : }
     632             : 
     633        7296 : int SwTxtFmtColl::GetAttrOutlineLevel() const
     634             : {
     635        7296 :     return ((const SfxUInt16Item &)GetFmtAttr(RES_PARATR_OUTLINELEVEL)).GetValue();
     636             : }
     637             : 
     638        1783 : int SwTxtFmtColl::GetAssignedOutlineStyleLevel() const
     639             : {
     640             :     OSL_ENSURE( IsAssignedToListLevelOfOutlineStyle(),
     641             :         "<SwTxtFmtColl::GetAssignedOutlineStyleLevel()> - misuse of method");
     642        1783 :     return GetAttrOutlineLevel() - 1;
     643             : }
     644             : 
     645         138 : void SwTxtFmtColl::AssignToListLevelOfOutlineStyle(const int nAssignedListLevel)
     646             : {
     647         138 :     mbAssignedToOutlineStyle = true;
     648         138 :     SetAttrOutlineLevel(nAssignedListLevel+1);
     649             : 
     650             :     // #i100277#
     651         138 :     SwIterator<SwTxtFmtColl,SwFmtColl> aIter( *this );
     652         138 :     SwTxtFmtColl* pDerivedTxtFmtColl = aIter.First();
     653         276 :     while ( pDerivedTxtFmtColl != 0 )
     654             :     {
     655           0 :         if ( !pDerivedTxtFmtColl->IsAssignedToListLevelOfOutlineStyle() )
     656             :         {
     657           0 :             if ( pDerivedTxtFmtColl->GetItemState( RES_PARATR_NUMRULE, sal_False ) == SFX_ITEM_DEFAULT )
     658             :             {
     659           0 :                 SwNumRuleItem aItem(aEmptyStr);
     660           0 :                 pDerivedTxtFmtColl->SetFmtAttr( aItem );
     661             :             }
     662           0 :             if ( pDerivedTxtFmtColl->GetItemState( RES_PARATR_OUTLINELEVEL, sal_False ) == SFX_ITEM_DEFAULT )
     663             :             {
     664           0 :                 pDerivedTxtFmtColl->SetAttrOutlineLevel( 0 );
     665             :             }
     666             :         }
     667             : 
     668           0 :         pDerivedTxtFmtColl = aIter.Next();
     669         138 :     }
     670         138 : }
     671             : 
     672         163 : void SwTxtFmtColl::DeleteAssignmentToListLevelOfOutlineStyle()
     673             : {
     674         163 :     mbAssignedToOutlineStyle = false;
     675         163 :     ResetFmtAttr(RES_PARATR_OUTLINELEVEL);
     676         163 : }
     677             : //<-end,zhaojianwei
     678             : 
     679             : //FEATURE::CONDCOLL
     680             : 
     681             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10