LCOV - code coverage report
Current view: top level - sw/source/core/text - txtfld.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 229 268 85.4 %
Date: 2015-06-13 12:38:46 Functions: 9 9 100.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             : #include "hintids.hxx"
      21             : #include <fmtfld.hxx>
      22             : #include <txtfld.hxx>
      23             : #include <charfmt.hxx>
      24             : 
      25             : #include "viewsh.hxx"
      26             : #include "doc.hxx"
      27             : #include "rootfrm.hxx"
      28             : #include "pagefrm.hxx"
      29             : #include "ndtxt.hxx"
      30             : #include "fldbas.hxx"
      31             : #include "viewopt.hxx"
      32             : #include "flyfrm.hxx"
      33             : #include "viewimp.hxx"
      34             : #include "txtatr.hxx"
      35             : #include "swfont.hxx"
      36             : #include "fntcache.hxx"
      37             : #include "porfld.hxx"
      38             : #include "porftn.hxx"
      39             : #include "porref.hxx"
      40             : #include "portox.hxx"
      41             : #include "porhyph.hxx"
      42             : #include "porfly.hxx"
      43             : #include "itrform2.hxx"
      44             : #include "chpfld.hxx"
      45             : #include "dbfld.hxx"
      46             : #include "expfld.hxx"
      47             : #include "docufld.hxx"
      48             : #include "pagedesc.hxx"
      49             : #include <pormulti.hxx>
      50             : #include "fmtmeta.hxx"
      51             : #include "reffld.hxx"
      52             : #include "flddat.hxx"
      53             : #include "fmtautofmt.hxx"
      54             : #include <IDocumentSettingAccess.hxx>
      55             : #include <svl/itemiter.hxx>
      56             : 
      57         177 : static bool lcl_IsInBody( SwFrm *pFrm )
      58             : {
      59         177 :     if ( pFrm->IsInDocBody() )
      60         128 :         return true;
      61             :     else
      62             :     {
      63          49 :         const SwFrm *pTmp = pFrm;
      64             :         const SwFlyFrm *pFly;
      65         147 :         while ( 0 != (pFly = pTmp->FindFlyFrm()) )
      66          49 :             pTmp = pFly->GetAnchorFrm();
      67          49 :         return pTmp->IsInDocBody();
      68             :     }
      69             : }
      70             : 
      71        4186 : SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf,
      72             :                                                 const SwTextAttr *pHint ) const
      73             : {
      74        4186 :     SwExpandPortion *pRet = 0;
      75        4186 :     SwFrm *pFrame = pFrm;
      76        4186 :     SwField *pField = const_cast<SwField*>(pHint->GetFormatField().GetField());
      77        4186 :     const bool bName = rInf.GetOpt().IsFieldName();
      78             : 
      79        4186 :     SwCharFormat* pChFormat = 0;
      80        4186 :     bool bNewFlyPor = false;
      81        4186 :     sal_uInt16 subType = 0;
      82             : 
      83             :     // set language
      84        4186 :     const_cast<SwTextFormatter*>(this)->SeekAndChg( rInf );
      85        4186 :     if (pField->GetLanguage() != GetFnt()->GetLanguage())
      86             :     {
      87         566 :         pField->SetLanguage( GetFnt()->GetLanguage() );
      88             :         // let the visual note know about its new language
      89         566 :         if (pField->GetTyp()->Which()==RES_POSTITFLD)
      90          87 :             const_cast<SwFormatField*> (&pHint->GetFormatField())->Broadcast( SwFormatFieldHint( &pHint->GetFormatField(), SwFormatFieldHintWhich::LANGUAGE ) );
      91             :     }
      92             : 
      93        4186 :     SwViewShell *pSh = rInf.GetVsh();
      94        4186 :     SwDoc *const pDoc( (pSh) ? pSh->GetDoc() : 0 );
      95        4186 :     bool const bInClipboard( pDoc == nullptr || pDoc->IsClipBoard() );
      96        4186 :     bool bPlaceHolder = false;
      97             : 
      98        4186 :     switch( pField->GetTyp()->Which() )
      99             :     {
     100             :         case RES_SCRIPTFLD:
     101             :         case RES_POSTITFLD:
     102         121 :             pRet = new SwPostItsPortion( RES_SCRIPTFLD == pField->GetTyp()->Which() );
     103         121 :             break;
     104             : 
     105             :         case RES_COMBINED_CHARS:
     106             :             {
     107           0 :                 if( bName )
     108           0 :                     pRet = new SwFieldPortion( pField->GetFieldName() );
     109             :                 else
     110           0 :                     pRet = new SwCombinedPortion( pField->ExpandField(bInClipboard) );
     111             :             }
     112           0 :             break;
     113             : 
     114             :         case RES_HIDDENTXTFLD:
     115             :             {
     116             :                 OUString const aStr( (bName)
     117           0 :                         ? pField->GetFieldName()
     118           0 :                         : pField->ExpandField(bInClipboard) );
     119           0 :                 pRet = new SwHiddenPortion(aStr);
     120             :             }
     121           0 :             break;
     122             : 
     123             :         case RES_CHAPTERFLD:
     124           0 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
     125             :             {
     126             :                 static_cast<SwChapterField*>(pField)->ChangeExpansion( pFrame,
     127           0 :                     &static_txtattr_cast<SwTextField const*>(pHint)->GetTextNode());
     128             :             }
     129             :             {
     130             :                 OUString const aStr( (bName)
     131           0 :                         ? pField->GetFieldName()
     132           0 :                         : pField->ExpandField(bInClipboard) );
     133           0 :                 pRet = new SwFieldPortion( aStr );
     134             :             }
     135           0 :             break;
     136             : 
     137             :         case RES_DOCSTATFLD:
     138         323 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
     139             :             {
     140         262 :                 static_cast<SwDocStatField*>(pField)->ChangeExpansion( pFrame );
     141             :             }
     142             :             {
     143             :                 OUString const aStr( (bName)
     144           0 :                         ? pField->GetFieldName()
     145         323 :                         : pField->ExpandField(bInClipboard) );
     146         323 :                 pRet = new SwFieldPortion( aStr );
     147             :             }
     148         323 :             static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGECOOUNTFLD;
     149         323 :             break;
     150             : 
     151             :         case RES_PAGENUMBERFLD:
     152             :         {
     153        1875 :             if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFields() )
     154             :             {
     155        1504 :                 SwPageNumberFieldType *pPageNr = static_cast<SwPageNumberFieldType *>(pField->GetTyp());
     156             : 
     157        1504 :                 const SwRootFrm* pTmpRootFrm = pSh->GetLayout();
     158        1504 :                 const bool bVirt = pTmpRootFrm->IsVirtPageNum();
     159             : 
     160        1504 :                 sal_uInt16 nVirtNum = pFrame->GetVirtPageNum();
     161        1504 :                 sal_uInt16 nNumPages = pTmpRootFrm->GetPageNum();
     162        1504 :                 sal_Int16 nNumFormat = -1;
     163        1504 :                 if(SVX_NUM_PAGEDESC == pField->GetFormat())
     164        1453 :                     nNumFormat = pFrame->FindPageFrm()->GetPageDesc()->GetNumType().GetNumberingType();
     165             :                 static_cast<SwPageNumberField*>(pField)
     166        1504 :                     ->ChangeExpansion(nVirtNum, nNumPages);
     167             :                 pPageNr->ChangeExpansion(pDoc,
     168        1504 :                                             bVirt, nNumFormat > -1 ? &nNumFormat : 0);
     169             :             }
     170             :             {
     171             :                 OUString const aStr( (bName)
     172           0 :                         ? pField->GetFieldName()
     173        1875 :                         : pField->ExpandField(bInClipboard) );
     174        1875 :                 pRet = new SwFieldPortion( aStr );
     175             :             }
     176        1875 :             static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGENUMBERFLD;
     177        1875 :             break;
     178             :         }
     179             :         case RES_GETEXPFLD:
     180             :         {
     181           1 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
     182             :             {
     183           1 :                 SwGetExpField* pExpField = static_cast<SwGetExpField*>(pField);
     184           1 :                 if( !::lcl_IsInBody( pFrame ) )
     185             :                 {
     186           0 :                     pExpField->ChgBodyTextFlag( false );
     187             :                     pExpField->ChangeExpansion(*pFrame,
     188           0 :                             *static_txtattr_cast<SwTextField const*>(pHint));
     189             :                 }
     190           1 :                 else if( !pExpField->IsInBodyText() )
     191             :                 {
     192             :                     // Was something else previously, thus: expand first, then convert it!
     193             :                     pExpField->ChangeExpansion(*pFrame,
     194           0 :                             *static_txtattr_cast<SwTextField const*>(pHint));
     195           0 :                     pExpField->ChgBodyTextFlag( true );
     196             :                 }
     197             :             }
     198             :             {
     199             :                 OUString const aStr( (bName)
     200           0 :                         ? pField->GetFieldName()
     201           1 :                         : pField->ExpandField(bInClipboard) );
     202           1 :                 pRet = new SwFieldPortion( aStr );
     203             :             }
     204           1 :             break;
     205             :         }
     206             :         case RES_DBFLD:
     207             :         {
     208         176 :             if( !bName )
     209             :             {
     210         176 :                 SwDBField* pDBField = static_cast<SwDBField*>(pField);
     211         176 :                 pDBField->ChgBodyTextFlag( ::lcl_IsInBody( pFrame ) );
     212             :             }
     213             :             {
     214             :                 OUString const aStr( (bName)
     215           0 :                         ? pField->GetFieldName()
     216         176 :                         : pField->ExpandField(bInClipboard) );
     217         176 :                 pRet = new SwFieldPortion(aStr);
     218             :             }
     219         176 :             break;
     220             :         }
     221             :         case RES_REFPAGEGETFLD:
     222           0 :             if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
     223             :             {
     224             :                 static_cast<SwRefPageGetField*>(pField)->ChangeExpansion(pFrame,
     225           0 :                         static_txtattr_cast<SwTextField const*>(pHint));
     226             :             }
     227             :             {
     228             :                 OUString const aStr( (bName)
     229           0 :                         ? pField->GetFieldName()
     230           0 :                         : pField->ExpandField(bInClipboard) );
     231           0 :                 pRet = new SwFieldPortion(aStr);
     232             :             }
     233           0 :             break;
     234             : 
     235             :         case RES_JUMPEDITFLD:
     236          14 :             if( !bName )
     237          14 :                 pChFormat = static_cast<SwJumpEditField*>(pField)->GetCharFormat();
     238          14 :             bNewFlyPor = true;
     239          14 :             bPlaceHolder = true;
     240          14 :             break;
     241             :         case RES_GETREFFLD:
     242        1461 :             subType = static_cast<SwGetRefField*>(pField)->GetSubType();
     243             :             {
     244             :                 OUString const str( (bName)
     245           0 :                         ? pField->GetFieldName()
     246        1461 :                         : pField->ExpandField(bInClipboard) );
     247        1461 :                 pRet = new SwFieldPortion(str);
     248             :             }
     249        1461 :             if( subType == REF_BOOKMARK  )
     250        1456 :                 static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_BOOKMARKFLD;
     251           5 :             else if( subType == REF_SETREFATTR )
     252           3 :                 static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_SETREFATTRFLD;
     253        1461 :             break;
     254             :         case RES_DATETIMEFLD:
     255          23 :             subType = static_cast<SwDateTimeField*>(pField)->GetSubType();
     256             :             {
     257             :                 OUString const str( (bName)
     258           0 :                         ? pField->GetFieldName()
     259          23 :                         : pField->ExpandField(bInClipboard) );
     260          23 :                 pRet = new SwFieldPortion(str);
     261             :             }
     262          23 :             if( subType & DATEFLD  )
     263          19 :                 static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_DATEFLD;
     264           4 :             else if( subType & TIMEFLD )
     265           4 :                 static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_TIMEFLD;
     266          23 :             break;
     267             :         default:
     268             :             {
     269             :                 OUString const aStr( (bName)
     270           0 :                         ? pField->GetFieldName()
     271         192 :                         : pField->ExpandField(bInClipboard) );
     272         192 :                 pRet = new SwFieldPortion(aStr);
     273             :             }
     274             :     }
     275             : 
     276        4186 :     if( bNewFlyPor )
     277             :     {
     278          14 :         SwFont *pTmpFnt = 0;
     279          14 :         if( !bName )
     280             :         {
     281          14 :             pTmpFnt = new SwFont( *pFnt );
     282          14 :             pTmpFnt->SetDiffFnt( &pChFormat->GetAttrSet(), pFrm->GetTextNode()->getIDocumentSettingAccess() );
     283             :         }
     284             :         {
     285             :             OUString const aStr( (bName)
     286           0 :                     ? pField->GetFieldName()
     287          14 :                     : pField->ExpandField(bInClipboard) );
     288          14 :             pRet = new SwFieldPortion(aStr, pTmpFnt, bPlaceHolder);
     289             :         }
     290             :     }
     291             : 
     292        4186 :     return pRet;
     293             : }
     294             : 
     295          60 : static SwFieldPortion * lcl_NewMetaPortion(SwTextAttr & rHint, const bool bPrefix)
     296             : {
     297             :     ::sw::Meta *const pMeta(
     298          60 :         static_cast<SwFormatMeta &>(rHint.GetAttr()).GetMeta() );
     299          60 :     OUString fix;
     300          60 :     ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) );
     301             :     OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?");
     302          60 :     if (pField)
     303             :     {
     304          60 :         pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix);
     305             :     }
     306          60 :     return new SwFieldPortion( fix );
     307             : }
     308             : 
     309             : /**
     310             :  * Try to create a new portion with zero length, for an end of a hint
     311             :  * (where there is no CH_TXTATR). Because there may be multiple hint ends at a
     312             :  * given index, m_nHintEndIndex is used to keep track of the already created
     313             :  * portions. But the portions created here may actually be deleted again,
     314             :  * due to Underflow. In that case, m_nHintEndIndex must be decremented,
     315             :  * so the portion will be created again on the next line.
     316             :  */
     317      191478 : SwExpandPortion * SwTextFormatter::TryNewNoLengthPortion(SwTextFormatInfo & rInfo)
     318             : {
     319      191478 :     if (pHints)
     320             :     {
     321       99997 :         const sal_Int32 nIdx(rInfo.GetIdx());
     322      251987 :         while (m_nHintEndIndex < pHints->GetEndCount())
     323             :         {
     324      120971 :             SwTextAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) );
     325      120971 :             sal_Int32 const nEnd( *rHint.GetAnyEnd() );
     326      120971 :             if (nEnd > nIdx)
     327             :             {
     328       68948 :                 break;
     329             :             }
     330       52023 :             ++m_nHintEndIndex;
     331       52023 :             if (nEnd == nIdx)
     332             :             {
     333       51669 :                 if (RES_TXTATR_METAFIELD == rHint.Which())
     334             :                 {
     335             :                     SwFieldPortion *const pPortion(
     336          30 :                             lcl_NewMetaPortion(rHint, false));
     337          30 :                     pPortion->SetNoLength(); // no CH_TXTATR at hint end!
     338          30 :                     return pPortion;
     339             :                 }
     340             :             }
     341             :         }
     342             :     }
     343      191448 :     return 0;
     344             : }
     345             : 
     346        7073 : SwLinePortion *SwTextFormatter::NewExtraPortion( SwTextFormatInfo &rInf )
     347             : {
     348        7073 :     SwTextAttr *pHint = GetAttr( rInf.GetIdx() );
     349        7073 :     SwLinePortion *pRet = 0;
     350        7073 :     if( !pHint )
     351             :     {
     352           0 :         pRet = new SwTextPortion;
     353           0 :         pRet->SetLen( 1 );
     354           0 :         rInf.SetLen( 1 );
     355           0 :         return pRet;
     356             :     }
     357             : 
     358        7073 :     switch( pHint->Which() )
     359             :     {
     360             :     case RES_TXTATR_FLYCNT :
     361             :         {
     362        2200 :             pRet = NewFlyCntPortion( rInf, pHint );
     363        2200 :             break;
     364             :         }
     365             :     case RES_TXTATR_FTN :
     366             :         {
     367         145 :             pRet = NewFootnotePortion( rInf, pHint );
     368         145 :             break;
     369             :         }
     370             :     case RES_TXTATR_FIELD :
     371             :     case RES_TXTATR_ANNOTATION :
     372             :         {
     373        4186 :             pRet = NewFieldPortion( rInf, pHint );
     374        4186 :             break;
     375             :         }
     376             :     case RES_TXTATR_REFMARK :
     377             :         {
     378          58 :             pRet = new SwIsoRefPortion;
     379          58 :             break;
     380             :         }
     381             :     case RES_TXTATR_TOXMARK :
     382             :         {
     383         201 :             pRet = new SwIsoToxPortion;
     384         201 :             break;
     385             :         }
     386             :     case RES_TXTATR_METAFIELD:
     387             :         {
     388          30 :             pRet = lcl_NewMetaPortion( *pHint, true );
     389          30 :             break;
     390             :         }
     391             :     default: ;
     392             :     }
     393        7073 :     if( !pRet )
     394             :     {
     395         253 :         const OUString aNothing;
     396         253 :         pRet = new SwFieldPortion( aNothing );
     397         253 :         rInf.SetLen( 1 );
     398             :     }
     399        7073 :     return pRet;
     400             : }
     401             : 
     402             : /**
     403             :  * OOXML spec says that w:rPr inside w:pPr specifies formatting for the paragraph mark symbol (i.e. the control
     404             :  * character than can be configured to be shown). However, in practice MSO also uses it as direct formatting
     405             :  * for numbering in that paragraph. I don't know if the problem is in the spec or in MSWord.
     406             :  */
     407        6928 : static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTextFormatInfo& rInf, const IDocumentSettingAccess* pIDSA )
     408             : {
     409        6928 :     SwTextNode* node = rInf.GetTextFrm()->GetTextNode();
     410        6928 :     if( !pIDSA->get(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ))
     411        8934 :         return;
     412        4922 :     if( SwpHints* hints = node->GetpSwpHints())
     413             :     {
     414        4017 :         for( size_t i = 0; i < hints->Count(); ++i )
     415             :         {
     416        2837 :             SwTextAttr* hint = hints->GetTextHint( i );
     417             :             // Formatting for the paragraph mark is set to apply only to the (non-existent) extra character
     418             :             // the at end of the txt node.
     419        7932 :             if( hint->Which() == RES_TXTATR_AUTOFMT && hint->GetEnd() != NULL
     420        5095 :                 && hint->GetStart() == *hint->GetEnd() && hint->GetStart() == node->Len())
     421             :             {
     422         737 :                 std::shared_ptr<SfxItemSet> pSet(hint->GetAutoFormat().GetStyleHandle());
     423             : 
     424             :                 // Check each item and in case it should be ignored, then clear it.
     425        1474 :                 std::shared_ptr<SfxItemSet> pCleanedSet;
     426         737 :                 if (pSet.get())
     427             :                 {
     428         737 :                     pCleanedSet.reset(pSet->Clone());
     429             : 
     430         737 :                     SfxItemIter aIter(*pSet);
     431         737 :                     const SfxPoolItem* pItem = aIter.GetCurItem();
     432             :                     while (true)
     433             :                     {
     434        3958 :                         if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
     435         343 :                             pCleanedSet->ClearItem(pItem->Which());
     436             : 
     437        3958 :                         if (aIter.IsAtEnd())
     438         737 :                             break;
     439             : 
     440        3221 :                         pItem = aIter.NextItem();
     441         737 :                     }
     442             :                 }
     443        1474 :                 pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA);
     444             :             }
     445             :         }
     446             :     }
     447             : }
     448             : 
     449             : 
     450        7138 : SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) const
     451             : {
     452       21414 :     if( rInf.IsNumDone() || rInf.GetTextStart() != nStart
     453       14276 :                 || rInf.GetTextStart() != rInf.GetIdx() )
     454           0 :         return 0;
     455             : 
     456        7138 :     SwNumberPortion *pRet = 0;
     457        7138 :     const SwTextNode* pTextNd = GetTextFrm()->GetTextNode();
     458        7138 :     const SwNumRule* pNumRule = pTextNd->GetNumRule();
     459             : 
     460             :     // Has a "valid" number?
     461        7138 :     if( pTextNd->IsNumbered() && pTextNd->IsCountedInList())
     462             :     {
     463        7113 :         int nLevel = pTextNd->GetActualListLevel();
     464             : 
     465        7113 :         if (nLevel < 0)
     466           0 :             nLevel = 0;
     467             : 
     468        7113 :         if (nLevel >= MAXLEVEL)
     469           0 :             nLevel = MAXLEVEL - 1;
     470             : 
     471        7113 :         const SwNumFormat &rNumFormat = pNumRule->Get( nLevel );
     472        7113 :         const bool bLeft = SVX_ADJUST_LEFT == rNumFormat.GetNumAdjust();
     473        7113 :         const bool bCenter = SVX_ADJUST_CENTER == rNumFormat.GetNumAdjust();
     474             :         const bool bLabelAlignmentPosAndSpaceModeActive(
     475        7113 :                 rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT );
     476             :         const sal_uInt16 nMinDist = bLabelAlignmentPosAndSpaceModeActive
     477        7113 :                                 ? 0 : rNumFormat.GetCharTextDistance();
     478             : 
     479        7113 :         if( SVX_NUM_BITMAP == rNumFormat.GetNumberingType() )
     480             :         {
     481          70 :             pRet = new SwGrfNumPortion( const_cast<SwTextFrm*>(GetTextFrm()),
     482             :                                         pTextNd->GetLabelFollowedBy(),
     483          70 :                                         rNumFormat.GetBrush(),
     484             :                                         rNumFormat.GetGraphicOrientation(),
     485          70 :                                         rNumFormat.GetGraphicSize(),
     486             :                                         bLeft, bCenter, nMinDist,
     487         210 :                                         bLabelAlignmentPosAndSpaceModeActive );
     488          70 :             long nTmpA = rInf.GetLast()->GetAscent();
     489          70 :             long nTmpD = rInf.GetLast()->Height() - nTmpA;
     490          70 :             if( !rInf.IsTest() )
     491          35 :                 static_cast<SwGrfNumPortion*>(pRet)->SetBase( nTmpA, nTmpD, nTmpA, nTmpD );
     492             :         }
     493             :         else
     494             :         {
     495             :             // The SwFont is created dynamically and passed in the ctor,
     496             :             // as the CharFormat only returns an SV-Font.
     497             :             // In the dtor of SwNumberPortion, the SwFont is deleted.
     498        7043 :             SwFont *pNumFnt = 0;
     499        7043 :             const SwAttrSet* pFormat = rNumFormat.GetCharFormat() ?
     500        5046 :                                     &rNumFormat.GetCharFormat()->GetAttrSet() :
     501       12089 :                                     NULL;
     502        7043 :             const IDocumentSettingAccess* pIDSA = pTextNd->getIDocumentSettingAccess();
     503             : 
     504        7043 :             if( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() )
     505             :             {
     506        2443 :                 const vcl::Font *pFormatFnt = rNumFormat.GetBulletFont();
     507             : 
     508             :                 // Build a new bullet font basing on the current paragraph font:
     509        2443 :                 pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
     510             : 
     511             :                 // #i53199#
     512        2443 :                 if ( !pIDSA->get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
     513             :                 {
     514             :                     // i18463:
     515             :                     // Underline style of paragraph font should not be considered
     516             :                     // Overline style of paragraph font should not be considered
     517             :                     // Weight style of paragraph font should not be considered
     518             :                     // Posture style of paragraph font should not be considered
     519        2443 :                     pNumFnt->SetUnderline( UNDERLINE_NONE );
     520        2443 :                     pNumFnt->SetOverline( UNDERLINE_NONE );
     521        2443 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_LATIN );
     522        2443 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_CJK );
     523        2443 :                     pNumFnt->SetItalic( ITALIC_NONE, SW_CTL );
     524        2443 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_LATIN );
     525        2443 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CJK );
     526        2443 :                     pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CTL );
     527             :                 }
     528             : 
     529             :                 // Apply the explicit attributes from the character style
     530             :                 // associated with the numering to the new bullet font.
     531        2443 :                 if( pFormat )
     532        1417 :                     pNumFnt->SetDiffFnt( pFormat, pIDSA );
     533             : 
     534        2443 :                 checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA );
     535             : 
     536        2443 :                 if ( pFormatFnt )
     537             :                 {
     538        2110 :                     const sal_uInt8 nAct = pNumFnt->GetActual();
     539        2110 :                     pNumFnt->SetFamily( pFormatFnt->GetFamily(), nAct );
     540        2110 :                     pNumFnt->SetName( pFormatFnt->GetName(), nAct );
     541        2110 :                     pNumFnt->SetStyleName( pFormatFnt->GetStyleName(), nAct );
     542        2110 :                     pNumFnt->SetCharSet( pFormatFnt->GetCharSet(), nAct );
     543        2110 :                     pNumFnt->SetPitch( pFormatFnt->GetPitch(), nAct );
     544             :                 }
     545             : 
     546             :                 // we do not allow a vertical font
     547        2443 :                 pNumFnt->SetVertical( pNumFnt->GetOrientation(),
     548        4886 :                                       pFrm->IsVertical() );
     549             : 
     550             :                 // --> OD 2008-01-23 #newlistelevelattrs#
     551        2443 :                 pRet = new SwBulletPortion( rNumFormat.GetBulletChar(),
     552             :                                             pTextNd->GetLabelFollowedBy(),
     553             :                                             pNumFnt,
     554             :                                             bLeft, bCenter, nMinDist,
     555        2443 :                                             bLabelAlignmentPosAndSpaceModeActive );
     556             :             }
     557             :             else
     558             :             {
     559        4600 :                 OUString aText( pTextNd->GetNumString() );
     560        4600 :                 if ( !aText.isEmpty() )
     561             :                 {
     562        4485 :                     aText += pTextNd->GetLabelFollowedBy();
     563             :                 }
     564             : 
     565             :                 // Not just an optimization ...
     566             :                 // A number portion without text will be assigned a width of 0.
     567             :                 // The succeeding text portion will flow into the BreakCut in the BreakLine,
     568             :                 // although  we have rInf.GetLast()->GetFlyPortion()!
     569        4600 :                 if( !aText.isEmpty() )
     570             :                 {
     571             : 
     572             :                     // Build a new numbering font basing on the current paragraph font:
     573        4485 :                     pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
     574             : 
     575             :                     // #i53199#
     576        4485 :                     if ( !pIDSA->get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
     577             :                     {
     578             :                         // i18463:
     579             :                         // Underline style of paragraph font should not be considered
     580        4485 :                         pNumFnt->SetUnderline( UNDERLINE_NONE );
     581             :                         // Overline style of paragraph font should not be considered
     582        4485 :                         pNumFnt->SetOverline( UNDERLINE_NONE );
     583             :                     }
     584             : 
     585             :                     // Apply the explicit attributes from the character style
     586             :                     // associated with the numering to the new bullet font.
     587        4485 :                     if( pFormat )
     588        3615 :                         pNumFnt->SetDiffFnt( pFormat, pIDSA );
     589             : 
     590        4485 :                     checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA );
     591             : 
     592             :                     // we do not allow a vertical font
     593        4485 :                     pNumFnt->SetVertical( pNumFnt->GetOrientation(), pFrm->IsVertical() );
     594             : 
     595             :                     pRet = new SwNumberPortion( aText, pNumFnt,
     596             :                                                 bLeft, bCenter, nMinDist,
     597        4485 :                                                 bLabelAlignmentPosAndSpaceModeActive );
     598        4600 :                 }
     599             :             }
     600             :         }
     601             :     }
     602        7138 :     return pRet;
     603         177 : }
     604             : 
     605             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11