LCOV - code coverage report
Current view: top level - sw/source/core/text - txtfld.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 167 228 73.2 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 147 382 38.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "hintids.hxx"
      30                 :            : #include <fmtfld.hxx>
      31                 :            : #include <txtfld.hxx>
      32                 :            : #include <charfmt.hxx>
      33                 :            : 
      34                 :            : #include "viewsh.hxx"   // NewFldPortion, GetDoc()
      35                 :            : #include "doc.hxx"      // NewFldPortion, GetSysFldType()
      36                 :            : #include "rootfrm.hxx"  // Info ueber virt. PageNumber
      37                 :            : #include "pagefrm.hxx"  // NewFldPortion, GetVirtPageNum()
      38                 :            : #include "ndtxt.hxx"    // NewNumberPortion, pHints->GetNum()
      39                 :            : #include "fldbas.hxx"      // SwField
      40                 :            : #include "viewopt.hxx"  // SwViewOptions
      41                 :            : #include "flyfrm.hxx"   //IsInBody()
      42                 :            : #include "viewimp.hxx"
      43                 :            : #include "txtatr.hxx"   // SwTxtFld
      44                 :            : #include "swfont.hxx"   // NewFldPortion, new SwFont
      45                 :            : #include "fntcache.hxx"   // NewFldPortion, SwFntAccess
      46                 :            : #include "porfld.hxx"
      47                 :            : #include "porftn.hxx"   // NewExtraPortion
      48                 :            : #include "porref.hxx"   // NewExtraPortion
      49                 :            : #include "portox.hxx"   // NewExtraPortion
      50                 :            : #include "porhyph.hxx"   // NewExtraPortion
      51                 :            : #include "porfly.hxx"   // NewExtraPortion
      52                 :            : #include "itrform2.hxx"   // SwTxtFormatter
      53                 :            : #include "chpfld.hxx"
      54                 :            : #include "dbfld.hxx"
      55                 :            : #include "expfld.hxx"
      56                 :            : #include "docufld.hxx"
      57                 :            : #include "pagedesc.hxx"  // NewFldPortion, GetNum()
      58                 :            : #include <pormulti.hxx>     // SwMultiPortion
      59                 :            : #include "fmtmeta.hxx" // lcl_NewMetaPortion
      60                 :            : 
      61                 :            : 
      62                 :            : /*************************************************************************
      63                 :            :  *                      SwTxtFormatter::NewFldPortion()
      64                 :            :  *************************************************************************/
      65                 :            : 
      66                 :            : 
      67                 :         14 : sal_Bool lcl_IsInBody( SwFrm *pFrm )
      68                 :            : {
      69         [ +  - ]:         14 :     if ( pFrm->IsInDocBody() )
      70                 :         14 :         return sal_True;
      71                 :            :     else
      72                 :            :     {
      73                 :          0 :         const SwFrm *pTmp = pFrm;
      74                 :            :         const SwFlyFrm *pFly;
      75         [ #  # ]:          0 :         while ( 0 != (pFly = pTmp->FindFlyFrm()) )
      76                 :          0 :             pTmp = pFly->GetAnchorFrm();
      77                 :         14 :         return pTmp->IsInDocBody();
      78                 :            :     }
      79                 :            : }
      80                 :            : 
      81                 :            : 
      82                 :        189 : SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf,
      83                 :            :                                                 const SwTxtAttr *pHint ) const
      84                 :            : {
      85                 :        189 :     SwExpandPortion *pRet = 0;
      86                 :        189 :     SwFrm *pFrame = (SwFrm*)pFrm;
      87                 :        189 :     SwField *pFld = (SwField*)pHint->GetFld().GetFld();
      88                 :        189 :     const sal_Bool bName = rInf.GetOpt().IsFldName();
      89                 :            : 
      90                 :        189 :     SwCharFmt* pChFmt = 0;
      91                 :        189 :     sal_Bool bNewFlyPor = sal_False,
      92                 :        189 :          bINet = sal_False;
      93                 :            : 
      94                 :            :     // set language
      95                 :        189 :     ((SwTxtFormatter*)this)->SeekAndChg( rInf );
      96         [ +  + ]:        189 :     if (pFld->GetLanguage() != GetFnt()->GetLanguage())
      97                 :            :     {
      98                 :        112 :         pFld->SetLanguage( GetFnt()->GetLanguage() );
      99                 :            :         // let the visual note know about its new language
     100         [ +  + ]:        112 :         if (pFld->GetTyp()->Which()==RES_POSTITFLD)
     101         [ +  - ]:         18 :             const_cast<SwFmtFld*> (&pHint->GetFld())->Broadcast( SwFmtFldHint( &pHint->GetFld(), SWFMTFLD_LANGUAGE ) );
     102                 :            :     }
     103                 :            : 
     104                 :        189 :     ViewShell *pSh = rInf.GetVsh();
     105         [ +  - ]:        189 :     SwDoc *const pDoc( (pSh) ? pSh->GetDoc() : 0 );
     106         [ +  - ]:        189 :     bool const bInClipboard( (pDoc) ? pDoc->IsClipBoard() : true );
     107                 :        189 :     sal_Bool bPlaceHolder = sal_False;
     108                 :            : 
     109   [ +  -  -  -  :        189 :     switch( pFld->GetTyp()->Which() )
          -  +  +  +  -  
                   +  + ]
     110                 :            :     {
     111                 :            :         case RES_SCRIPTFLD:
     112                 :            :         case RES_POSTITFLD:
     113         [ +  - ]:         18 :             pRet = new SwPostItsPortion( RES_SCRIPTFLD == pFld->GetTyp()->Which() );
     114                 :         18 :             break;
     115                 :            : 
     116                 :            :         case RES_COMBINED_CHARS:
     117                 :            :             {
     118         [ #  # ]:          0 :                 if( bName )
     119                 :            :                 {
     120         [ #  # ]:          0 :                     String const sName( pFld->GetFieldName() );
     121 [ #  # ][ #  # ]:          0 :                     pRet = new SwFldPortion(sName);
                 [ #  # ]
     122                 :            :                 }
     123                 :            :                 else
     124                 :            :                 {
     125         [ #  # ]:          0 :                     String const sContent( pFld->ExpandField(bInClipboard) );
     126 [ #  # ][ #  # ]:          0 :                     pRet = new SwCombinedPortion(sContent);
                 [ #  # ]
     127                 :            :                 }
     128                 :            :             }
     129                 :          0 :             break;
     130                 :            : 
     131                 :            :         case RES_HIDDENTXTFLD:
     132                 :            :             {
     133                 :            :                 String const str( (bName)
     134                 :          0 :                         ? pFld->GetFieldName()
     135 [ #  # ][ #  # ]:          0 :                         : pFld->ExpandField(bInClipboard) );
                 [ #  # ]
     136 [ #  # ][ #  # ]:          0 :                 pRet = new SwHiddenPortion(str);
                 [ #  # ]
     137                 :            :             }
     138                 :          0 :             break;
     139                 :            : 
     140                 :            :         case RES_CHAPTERFLD:
     141 [ #  # ][ #  # ]:          0 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() )
         [ #  # ][ #  # ]
     142                 :            :             {
     143                 :            :                 ((SwChapterField*)pFld)->ChangeExpansion( pFrame,
     144                 :          0 :                                         &((SwTxtFld*)pHint)->GetTxtNode() );
     145                 :            :             }
     146                 :            :             {
     147                 :            :                 String const str( (bName)
     148                 :          0 :                         ? pFld->GetFieldName()
     149 [ #  # ][ #  # ]:          0 :                         : pFld->ExpandField(bInClipboard) );
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :                 pRet = new SwFldPortion( str );
                 [ #  # ]
     151                 :            :             }
     152                 :          0 :             break;
     153                 :            : 
     154                 :            :         case RES_DOCSTATFLD:
     155 [ #  # ][ #  # ]:          0 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() )
         [ #  # ][ #  # ]
     156                 :            :             {
     157                 :          0 :                 ((SwDocStatField*)pFld)->ChangeExpansion( pFrame );
     158                 :            :             }
     159                 :            :             {
     160                 :            :                 String const str( (bName)
     161                 :          0 :                         ? pFld->GetFieldName()
     162 [ #  # ][ #  # ]:          0 :                         : pFld->ExpandField(bInClipboard) );
                 [ #  # ]
     163 [ #  # ][ #  # ]:          0 :                 pRet = new SwFldPortion( str );
                 [ #  # ]
     164                 :            :             }
     165                 :          0 :             break;
     166                 :            : 
     167                 :            :         case RES_PAGENUMBERFLD:
     168                 :            :         {
     169 [ +  - ][ +  - ]:         12 :             if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFlds() )//swmod 080122
         [ +  - ][ +  - ]
                 [ +  - ]
     170                 :            :             {
     171                 :         12 :                 SwPageNumberFieldType *pPageNr = (SwPageNumberFieldType *)pFld->GetTyp();
     172                 :            : 
     173         [ +  - ]:         12 :                 const SwRootFrm* pTmpRootFrm = pSh->GetLayout();
     174                 :         12 :                 const sal_Bool bVirt = pTmpRootFrm->IsVirtPageNum();
     175                 :            : 
     176         [ +  - ]:         12 :                 MSHORT nVirtNum = pFrame->GetVirtPageNum();
     177                 :         12 :                 MSHORT nNumPages = pTmpRootFrm->GetPageNum();
     178                 :         12 :                 sal_Int16 nNumFmt = -1;
     179         [ +  - ]:         12 :                 if(SVX_NUM_PAGEDESC == pFld->GetFormat())
     180         [ +  - ]:         12 :                     nNumFmt = pFrame->FindPageFrm()->GetPageDesc()->GetNumType().GetNumberingType();
     181                 :            : 
     182                 :            :                 pPageNr->ChangeExpansion( pDoc, nVirtNum, nNumPages,
     183 [ +  - ][ +  - ]:         12 :                                             bVirt, nNumFmt > -1 ? &nNumFmt : 0);
     184                 :            :             }
     185                 :            :             {
     186                 :            :                 String const str( (bName)
     187                 :          0 :                         ? pFld->GetFieldName()
     188 [ -  + ][ #  # ]:         12 :                         : pFld->ExpandField(bInClipboard) );
                 [ +  - ]
     189 [ +  - ][ +  - ]:         12 :                 pRet = new SwFldPortion( str );
                 [ +  - ]
     190                 :            :             }
     191                 :         12 :             break;
     192                 :            :         }
     193                 :            :         case RES_GETEXPFLD:
     194                 :            :         {
     195 [ +  - ][ +  - ]:          3 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() )
         [ +  - ][ +  - ]
     196                 :            :             {
     197                 :          3 :                 SwGetExpField* pExpFld = (SwGetExpField*)pFld;
     198         [ -  + ]:          3 :                 if( !::lcl_IsInBody( pFrame ) )
     199                 :            :                 {
     200                 :          0 :                     pExpFld->ChgBodyTxtFlag( sal_False );
     201                 :          0 :                     pExpFld->ChangeExpansion( *pFrame, *((SwTxtFld*)pHint) );
     202                 :            :                 }
     203         [ -  + ]:          3 :                 else if( !pExpFld->IsInBodyTxt() )
     204                 :            :                 {
     205                 :            :                     // war vorher anders, also erst expandieren, dann umsetzen!!
     206                 :          0 :                     pExpFld->ChangeExpansion( *pFrame, *((SwTxtFld*)pHint) );
     207                 :          0 :                     pExpFld->ChgBodyTxtFlag( sal_True );
     208                 :            :                 }
     209                 :            :             }
     210                 :            :             {
     211                 :            :                 String const str( (bName)
     212                 :          0 :                         ? pFld->GetFieldName()
     213 [ -  + ][ #  # ]:          3 :                         : pFld->ExpandField(bInClipboard) );
                 [ +  - ]
     214 [ +  - ][ +  - ]:          3 :                 pRet = new SwFldPortion( str );
                 [ +  - ]
     215                 :            :             }
     216                 :          3 :             break;
     217                 :            :         }
     218                 :            :         case RES_DBFLD:
     219                 :            :         {
     220         [ +  - ]:         11 :             if( !bName )
     221                 :            :             {
     222                 :         11 :                 SwDBField* pDBFld = (SwDBField*)pFld;
     223                 :         11 :                 pDBFld->ChgBodyTxtFlag( ::lcl_IsInBody( pFrame ) );
     224                 :            :             }
     225                 :            :             {
     226                 :            :                 String const str( (bName)
     227                 :          0 :                         ? pFld->GetFieldName()
     228 [ -  + ][ #  # ]:         11 :                         : pFld->ExpandField(bInClipboard) );
                 [ +  - ]
     229 [ +  - ][ +  - ]:         11 :                 pRet = new SwFldPortion(str);
                 [ +  - ]
     230                 :            :             }
     231                 :         11 :             break;
     232                 :            :         }
     233                 :            :         case RES_REFPAGEGETFLD:
     234 [ #  # ][ #  # ]:          0 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() )
         [ #  # ][ #  # ]
     235                 :            :             {
     236                 :          0 :                 ((SwRefPageGetField*)pFld)->ChangeExpansion( pFrame, (SwTxtFld*)pHint );
     237                 :            :             }
     238                 :            :             {
     239                 :            :                 String const str( (bName)
     240                 :          0 :                         ? pFld->GetFieldName()
     241 [ #  # ][ #  # ]:          0 :                         : pFld->ExpandField(bInClipboard) );
                 [ #  # ]
     242 [ #  # ][ #  # ]:          0 :                 pRet = new SwFldPortion(str);
                 [ #  # ]
     243                 :            :             }
     244                 :          0 :             break;
     245                 :            : 
     246                 :            :         case RES_JUMPEDITFLD:
     247         [ +  - ]:          7 :             if( !bName )
     248                 :          7 :                 pChFmt =  ((SwJumpEditField*)pFld)->GetCharFmt();
     249                 :          7 :             bNewFlyPor = sal_True;
     250                 :          7 :             bPlaceHolder = sal_True;
     251                 :          7 :             break;
     252                 :            : 
     253                 :            :         default:
     254                 :            :             {
     255                 :            :                 String const str( (bName)
     256                 :          0 :                         ? pFld->GetFieldName()
     257 [ -  + ][ #  # ]:        138 :                         : pFld->ExpandField(bInClipboard) );
                 [ +  - ]
     258 [ +  - ][ +  - ]:        138 :                 pRet = new SwFldPortion(str);
                 [ +  - ]
     259                 :            :             }
     260                 :            :     }
     261                 :            : 
     262         [ +  + ]:        189 :     if( bNewFlyPor )
     263                 :            :     {
     264                 :          7 :         SwFont *pTmpFnt = 0;
     265         [ +  - ]:          7 :         if( !bName )
     266                 :            :         {
     267         [ +  - ]:          7 :             pTmpFnt = new SwFont( *pFnt );
     268         [ -  + ]:          7 :             if( bINet )
     269                 :            :             {
     270                 :          0 :                 SwAttrPool* pPool = pChFmt->GetAttrSet().GetPool();
     271         [ #  # ]:          0 :                 SfxItemSet aSet( *pPool, RES_CHRATR_BEGIN, RES_CHRATR_END );
     272         [ #  # ]:          0 :                 SfxItemSet aTmpSet( aSet );
     273         [ #  # ]:          0 :                 pFrm->GetTxtNode()->GetAttr(aSet,rInf.GetIdx(),rInf.GetIdx()+1);
     274         [ #  # ]:          0 :                 aTmpSet.Set( pChFmt->GetAttrSet() );
     275         [ #  # ]:          0 :                 aTmpSet.Differentiate( aSet );
     276         [ #  # ]:          0 :                 if( aTmpSet.Count() )
     277 [ #  # ][ #  # ]:          0 :                     pTmpFnt->SetDiffFnt( &aTmpSet, pFrm->GetTxtNode()->getIDocumentSettingAccess() );
         [ #  # ][ #  # ]
     278                 :            :             }
     279                 :            :             else
     280                 :          7 :                 pTmpFnt->SetDiffFnt( &pChFmt->GetAttrSet(), pFrm->GetTxtNode()->getIDocumentSettingAccess() );
     281                 :            :         }
     282                 :            :         {
     283                 :            :             String const str( (bName)
     284                 :          0 :                     ? pFld->GetFieldName()
     285 [ -  + ][ #  # ]:          7 :                     : pFld->ExpandField(bInClipboard) );
                 [ +  - ]
     286 [ +  - ][ +  - ]:          7 :             pRet = new SwFldPortion(str, pTmpFnt, bPlaceHolder);
                 [ +  - ]
     287                 :            :         }
     288                 :            :     }
     289                 :            : 
     290                 :        189 :     return pRet;
     291                 :            : }
     292                 :            : 
     293                 :            : /*************************************************************************
     294                 :            :  *                      SwTxtFormatter::TryNewNoLengthPortion()
     295                 :            :  *************************************************************************/
     296                 :            : 
     297                 :         80 : SwFldPortion * lcl_NewMetaPortion(SwTxtAttr & rHint, const bool bPrefix)
     298                 :            : {
     299                 :            :     ::sw::Meta *const pMeta(
     300         [ +  - ]:         80 :         static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() );
     301                 :         80 :     ::rtl::OUString fix;
     302         [ -  + ]:         80 :     ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) );
     303                 :            :     OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?");
     304         [ +  - ]:         80 :     if (pField)
     305                 :            :     {
     306 [ +  + ][ +  + ]:         80 :         pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix);
                 [ +  - ]
     307                 :            :     }
     308 [ +  - ][ +  - ]:         80 :     return new SwFldPortion( fix );
         [ +  - ][ +  - ]
     309                 :            : }
     310                 :            : 
     311                 :            : /** Try to create a new portion with zero length, for an end of a hint
     312                 :            :     (where there is no CH_TXTATR). Because there may be multiple hint ends at a
     313                 :            :     given index, m_nHintEndIndex is used to keep track of the already created
     314                 :            :     portions. But the portions created here may actually be deleted again,
     315                 :            :     due to UnderFlow. In that case, m_nHintEndIndex must be decremented,
     316                 :            :     so the portion will be created again on the next line.
     317                 :            :  */
     318                 :            : SwExpandPortion *
     319                 :     107943 : SwTxtFormatter::TryNewNoLengthPortion(SwTxtFormatInfo & rInfo)
     320                 :            : {
     321         [ +  + ]:     107943 :     if (pHints)
     322                 :            :     {
     323                 :       9762 :         const xub_StrLen nIdx(rInfo.GetIdx());
     324         [ +  + ]:      19194 :         while (m_nHintEndIndex < pHints->GetEndCount())
     325                 :            :         {
     326                 :       9472 :             SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) );
     327                 :       9472 :             xub_StrLen const nEnd( *rHint.GetAnyEnd() );
     328         [ +  + ]:       9472 :             if (nEnd > nIdx)
     329                 :            :             {
     330                 :       4529 :                 break;
     331                 :            :             }
     332                 :       4943 :             ++m_nHintEndIndex;
     333         [ +  + ]:       4943 :             if (nEnd == nIdx)
     334                 :            :             {
     335         [ +  + ]:       4933 :                 if (RES_TXTATR_METAFIELD == rHint.Which())
     336                 :            :                 {
     337                 :            :                     SwFldPortion *const pPortion(
     338                 :         40 :                             lcl_NewMetaPortion(rHint, false));
     339                 :         40 :                     pPortion->SetNoLength(); // no CH_TXTATR at hint end!
     340                 :         40 :                     return pPortion;
     341                 :            :                 }
     342                 :            :             }
     343                 :            :         }
     344                 :            :     }
     345                 :     107943 :     return 0;
     346                 :            : }
     347                 :            : 
     348                 :            : /*************************************************************************
     349                 :            :  *                      SwTxtFormatter::NewExtraPortion()
     350                 :            :  *************************************************************************/
     351                 :            : 
     352                 :       2411 : SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf )
     353                 :            : {
     354                 :       2411 :     SwTxtAttr *pHint = GetAttr( rInf.GetIdx() );
     355                 :       2411 :     SwLinePortion *pRet = 0;
     356         [ -  + ]:       2411 :     if( !pHint )
     357                 :            :     {
     358         [ #  # ]:          0 :         pRet = new SwTxtPortion;
     359                 :          0 :         pRet->SetLen( 1 );
     360                 :          0 :         rInf.SetLen( 1 );
     361                 :          0 :         return pRet;
     362                 :            :     }
     363                 :            : 
     364   [ +  +  +  +  :       2411 :     switch( pHint->Which() )
                +  +  + ]
     365                 :            :     {
     366                 :            :         case RES_TXTATR_FLYCNT :
     367                 :            :         {
     368                 :       1290 :             pRet = NewFlyCntPortion( rInf, pHint );
     369                 :       1290 :             break;
     370                 :            :         }
     371                 :            :         case RES_TXTATR_FTN :
     372                 :            :         {
     373                 :        142 :             pRet = NewFtnPortion( rInf, pHint );
     374                 :        142 :             break;
     375                 :            :         }
     376                 :            :         case RES_TXTATR_FIELD :
     377                 :            :         {
     378                 :        189 :             pRet = NewFldPortion( rInf, pHint );
     379                 :        189 :             break;
     380                 :            :         }
     381                 :            :         case RES_TXTATR_REFMARK :
     382                 :            :         {
     383         [ +  - ]:        150 :             pRet = new SwIsoRefPortion;
     384                 :        150 :             break;
     385                 :            :         }
     386                 :            :         case RES_TXTATR_TOXMARK :
     387                 :            :         {
     388         [ +  - ]:        112 :             pRet = new SwIsoToxPortion;
     389                 :        112 :             break;
     390                 :            :         }
     391                 :            :         case RES_TXTATR_METAFIELD:
     392                 :            :         {
     393                 :         40 :             pRet = lcl_NewMetaPortion( *pHint, true );
     394                 :         40 :             break;
     395                 :            :         }
     396                 :            :         default: ;
     397                 :            :     }
     398         [ +  + ]:       2411 :     if( !pRet )
     399                 :            :     {
     400         [ +  - ]:        488 :         const XubString aNothing;
     401 [ +  - ][ +  - ]:        488 :         pRet = new SwFldPortion( aNothing );
     402         [ +  - ]:        488 :         rInf.SetLen( 1 );
     403                 :            :     }
     404                 :       2411 :     return pRet;
     405                 :            : }
     406                 :            : 
     407                 :            : /*************************************************************************
     408                 :            :  *                      SwTxtFormatter::NewNumberPortion()
     409                 :            :  *************************************************************************/
     410                 :            : 
     411                 :            : 
     412                 :        240 : SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const
     413                 :            : {
     414         [ +  - ]:        480 :     if( rInf.IsNumDone() || rInf.GetTxtStart() != nStart
           [ +  -  -  + ]
                 [ -  + ]
     415                 :        240 :                 || rInf.GetTxtStart() != rInf.GetIdx() )
     416                 :          0 :         return 0;
     417                 :            : 
     418                 :        240 :     SwNumberPortion *pRet = 0;
     419                 :        240 :     const SwTxtNode* pTxtNd = GetTxtFrm()->GetTxtNode();
     420                 :        240 :     const SwNumRule* pNumRule = pTxtNd->GetNumRule();
     421                 :            : 
     422                 :            :     // hat ein "gueltige" Nummer ?
     423 [ +  - ][ +  - ]:        240 :     if( pTxtNd->IsNumbered() && pTxtNd->IsCountedInList())
                 [ +  - ]
     424                 :            :     {
     425                 :        240 :         const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()) );
     426                 :        240 :         const sal_Bool bLeft = SVX_ADJUST_LEFT == rNumFmt.GetNumAdjust();
     427                 :        240 :         const sal_Bool bCenter = SVX_ADJUST_CENTER == rNumFmt.GetNumAdjust();
     428                 :            :         const bool bLabelAlignmentPosAndSpaceModeActive(
     429                 :        240 :                 rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT );
     430                 :            :         const KSHORT nMinDist = bLabelAlignmentPosAndSpaceModeActive
     431         [ +  + ]:        240 :                                 ? 0 : rNumFmt.GetCharTextDistance();
     432                 :            : 
     433         [ -  + ]:        240 :         if( SVX_NUM_BITMAP == rNumFmt.GetNumberingType() )
     434                 :            :         {
     435                 :          0 :             pRet = new SwGrfNumPortion( (SwFrm*)GetTxtFrm(),
     436                 :            :                                         pTxtNd->GetLabelFollowedBy(),
     437                 :          0 :                                         rNumFmt.GetBrush(),
     438                 :            :                                         rNumFmt.GetGraphicOrientation(),
     439                 :          0 :                                         rNumFmt.GetGraphicSize(),
     440                 :            :                                         bLeft, bCenter, nMinDist,
     441 [ #  # ][ #  # ]:          0 :                                         bLabelAlignmentPosAndSpaceModeActive );
                 [ #  # ]
     442                 :          0 :             long nTmpA = rInf.GetLast()->GetAscent();
     443                 :          0 :             long nTmpD = rInf.GetLast()->Height() - nTmpA;
     444         [ #  # ]:          0 :             if( !rInf.IsTest() )
     445                 :          0 :                 ((SwGrfNumPortion*)pRet)->SetBase( nTmpA, nTmpD, nTmpA, nTmpD );
     446                 :            :         }
     447                 :            :         else
     448                 :            :         {
     449                 :            :             // Der SwFont wird dynamisch angelegt und im CTOR uebergeben,
     450                 :            :             // weil das CharFmt nur einen SV-Font zurueckliefert.
     451                 :            :             // Im Dtor vom SwNumberPortion wird der SwFont deletet.
     452                 :        240 :             SwFont *pNumFnt = 0;
     453                 :        240 :             const SwAttrSet* pFmt = rNumFmt.GetCharFmt() ?
     454                 :         78 :                                     &rNumFmt.GetCharFmt()->GetAttrSet() :
     455         [ +  + ]:        318 :                                     NULL;
     456                 :        240 :             const IDocumentSettingAccess* pIDSA = pTxtNd->getIDocumentSettingAccess();
     457                 :            : 
     458         [ +  + ]:        240 :             if( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() )
     459                 :            :             {
     460                 :         36 :                 const Font *pFmtFnt = rNumFmt.GetBulletFont();
     461                 :            : 
     462                 :            :                 //
     463                 :            :                 // Build a new bullet font basing on the current paragraph font:
     464                 :            :                 //
     465         [ +  - ]:         36 :                 pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
     466                 :            : 
     467                 :            :                 // #i53199#
     468         [ +  - ]:         36 :                 if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
     469                 :            :                 {
     470                 :            :                     // i18463:
     471                 :            :                     // Underline style of paragraph font should not be considered
     472                 :            :                     // Overline style of paragraph font should not be considered
     473                 :            :                     // Weight style of paragraph font should not be considered
     474                 :            :                     // Posture style of paragraph font should not be considered
     475                 :         36 :                     pNumFnt->SetUnderline( UNDERLINE_NONE );
     476                 :         36 :                     pNumFnt->SetOverline( UNDERLINE_NONE );
     477                 :         36 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_LATIN );
     478                 :         36 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_CJK );
     479                 :         36 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_CTL );
     480                 :         36 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_LATIN );
     481                 :         36 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CJK );
     482                 :         36 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CTL );
     483                 :            :                 }
     484                 :            : 
     485                 :            :                 //
     486                 :            :                 // Apply the explicit attributes from the character style
     487                 :            :                 // associated with the numering to the new bullet font.
     488                 :            :                 //
     489         [ +  + ]:         36 :                 if( pFmt )
     490                 :         24 :                     pNumFnt->SetDiffFnt( pFmt, pIDSA );
     491                 :            : 
     492         [ +  - ]:         36 :                 if ( pFmtFnt )
     493                 :            :                 {
     494                 :         36 :                     const sal_uInt8 nAct = pNumFnt->GetActual();
     495                 :         36 :                     pNumFnt->SetFamily( pFmtFnt->GetFamily(), nAct );
     496                 :         36 :                     pNumFnt->SetName( pFmtFnt->GetName(), nAct );
     497                 :         36 :                     pNumFnt->SetStyleName( pFmtFnt->GetStyleName(), nAct );
     498                 :         36 :                     pNumFnt->SetCharSet( pFmtFnt->GetCharSet(), nAct );
     499                 :         36 :                     pNumFnt->SetPitch( pFmtFnt->GetPitch(), nAct );
     500                 :            :                 }
     501                 :            : 
     502                 :            :                 // we do not allow a vertical font
     503                 :         36 :                 pNumFnt->SetVertical( pNumFnt->GetOrientation(),
     504                 :         72 :                                       pFrm->IsVertical() );
     505                 :            : 
     506                 :            :                 // --> OD 2008-01-23 #newlistelevelattrs#
     507                 :         36 :                 pRet = new SwBulletPortion( rNumFmt.GetBulletChar(),
     508                 :            :                                             pTxtNd->GetLabelFollowedBy(),
     509                 :            :                                             pNumFnt,
     510                 :            :                                             bLeft, bCenter, nMinDist,
     511 [ +  - ][ +  - ]:         36 :                                             bLabelAlignmentPosAndSpaceModeActive );
     512                 :            :             }
     513                 :            :             else
     514                 :            :             {
     515         [ +  - ]:        204 :                 XubString aTxt( pTxtNd->GetNumString() );
     516         [ +  + ]:        204 :                 if ( aTxt.Len() > 0 )
     517                 :            :                 {
     518 [ +  - ][ +  - ]:        198 :                     aTxt.Insert( pTxtNd->GetLabelFollowedBy() );
                 [ +  - ]
     519                 :            :                 }
     520                 :            : 
     521                 :            :                 // 7974: Nicht nur eine Optimierung...
     522                 :            :                 // Eine Numberportion ohne Text wird die Breite von 0
     523                 :            :                 // erhalten. Die nachfolgende Textportion wird im BreakLine
     524                 :            :                 // in das BreakCut laufen, obwohl rInf.GetLast()->GetFlyPortion()
     525                 :            :                 // vorliegt!
     526         [ +  + ]:        204 :                 if( aTxt.Len() )
     527                 :            :                 {
     528                 :            :                     //
     529                 :            :                     // Build a new numbering font basing on the current paragraph font:
     530                 :            :                     //
     531 [ +  - ][ +  - ]:        198 :                     pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
                 [ +  - ]
     532                 :            : 
     533                 :            :                     // #i53199#
     534 [ +  - ][ +  - ]:        198 :                     if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
     535                 :            :                     {
     536                 :            :                         // i18463:
     537                 :            :                         // Underline style of paragraph font should not be considered
     538         [ +  - ]:        198 :                         pNumFnt->SetUnderline( UNDERLINE_NONE );
     539                 :            :                         // Overline style of paragraph font should not be considered
     540         [ +  - ]:        198 :                         pNumFnt->SetOverline( UNDERLINE_NONE );
     541                 :            :                     }
     542                 :            : 
     543                 :            : 
     544                 :            :                     //
     545                 :            :                     // Apply the explicit attributes from the character style
     546                 :            :                     // associated with the numering to the new bullet font.
     547                 :            :                     //
     548         [ +  + ]:        198 :                     if( pFmt )
     549         [ +  - ]:         54 :                         pNumFnt->SetDiffFnt( pFmt, pIDSA );
     550                 :            : 
     551                 :            :                     // we do not allow a vertical font
     552 [ +  - ][ +  - ]:        198 :                     pNumFnt->SetVertical( pNumFnt->GetOrientation(), pFrm->IsVertical() );
                 [ +  - ]
     553                 :            : 
     554                 :            :                     pRet = new SwNumberPortion( aTxt, pNumFnt,
     555                 :            :                                                 bLeft, bCenter, nMinDist,
     556 [ +  - ][ +  - ]:        198 :                                                 bLabelAlignmentPosAndSpaceModeActive );
     557         [ +  - ]:        204 :                 }
     558                 :            :             }
     559                 :            :         }
     560                 :            :     }
     561                 :        240 :     return pRet;
     562                 :            : }
     563                 :            : 
     564                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10