LCOV - code coverage report
Current view: top level - sw/source/core/txtnode - swfont.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 672 911 73.8 %
Date: 2014-04-11 Functions: 36 39 92.3 %
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             : 
      22             : #include <com/sun/star/i18n/ScriptType.hpp>
      23             : #include <vcl/outdev.hxx>
      24             : #include <unotools/localedatawrapper.hxx>
      25             : #include <editeng/unolingu.hxx>
      26             : #include <editeng/brushitem.hxx>
      27             : #include <editeng/wrlmitem.hxx>
      28             : #include <editeng/blinkitem.hxx>
      29             : #include <editeng/nhypitem.hxx>
      30             : #include <editeng/kernitem.hxx>
      31             : #include <editeng/cmapitem.hxx>
      32             : #include <editeng/langitem.hxx>
      33             : #include <editeng/escapementitem.hxx>
      34             : #include <editeng/autokernitem.hxx>
      35             : #include <editeng/shdditem.hxx>
      36             : #include <editeng/charreliefitem.hxx>
      37             : #include <editeng/contouritem.hxx>
      38             : #include <editeng/colritem.hxx>
      39             : #include <editeng/charsetcoloritem.hxx>
      40             : #include <editeng/crossedoutitem.hxx>
      41             : #include <editeng/udlnitem.hxx>
      42             : #include <editeng/wghtitem.hxx>
      43             : #include <editeng/postitem.hxx>
      44             : #include <editeng/fhgtitem.hxx>
      45             : #include <editeng/fontitem.hxx>
      46             : #include <editeng/emphasismarkitem.hxx>
      47             : #include <editeng/charscaleitem.hxx>
      48             : #include <editeng/charrotateitem.hxx>
      49             : #include <editeng/twolinesitem.hxx>
      50             : #include <editeng/charhiddenitem.hxx>
      51             : #include <editeng/boxitem.hxx>
      52             : #include <editeng/shaditem.hxx>
      53             : #include <IDocumentSettingAccess.hxx>
      54             : #include <vcl/window.hxx>
      55             : #include <charatr.hxx>
      56             : #include <viewsh.hxx>
      57             : #include <swfont.hxx>
      58             : #include <fntcache.hxx>
      59             : #include <txtfrm.hxx>
      60             : #include <scriptinfo.hxx>
      61             : 
      62             : #ifdef DBG_UTIL
      63             : // global Variable
      64             : SvStatistics g_SvStat;
      65             : #endif
      66             : 
      67             : using namespace ::com::sun::star;
      68             : 
      69             : /************************************************************************
      70             :  * Hintergrundbrush setzen, z.B. bei Zeichenvorlagen
      71             :  ***********************************************************************/
      72        1686 : void SwFont::SetBackColor( Color* pNewColor )
      73             : {
      74        1686 :     delete pBackColor;
      75        1686 :     pBackColor = pNewColor;
      76        1686 :     bFntChg = sal_True;
      77        1686 :     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
      78        1686 : }
      79             : 
      80       37136 : void SwFont::SetTopBorder( const editeng::SvxBorderLine* pTopBorder )
      81             : {
      82       37136 :     if( pTopBorder )
      83         181 :         m_aTopBorder = *pTopBorder;
      84             :     else
      85             :     {
      86       36955 :         m_aTopBorder = boost::none;
      87       36955 :         m_nTopBorderDist = 0;
      88             :     }
      89       37136 :     bFntChg = sal_True;
      90       37136 :     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
      91       37136 : }
      92             : 
      93       37136 : void SwFont::SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder )
      94             : {
      95       37136 :     if( pBottomBorder )
      96         181 :         m_aBottomBorder = *pBottomBorder;
      97             :     else
      98             :     {
      99       36955 :         m_aBottomBorder = boost::none;
     100       36955 :         m_nBottomBorderDist = 0;
     101             :     }
     102       37136 :     bFntChg = sal_True;
     103       37136 :     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
     104       37136 : }
     105             : 
     106       37136 : void SwFont::SetRightBorder( const editeng::SvxBorderLine* pRightBorder )
     107             : {
     108       37136 :     if( pRightBorder )
     109         174 :         m_aRightBorder = *pRightBorder;
     110             :     else
     111             :     {
     112       36962 :         m_aRightBorder = boost::none;
     113       36962 :         m_nRightBorderDist = 0;
     114             :     }
     115       37136 :     bFntChg = sal_True;
     116       37136 :     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
     117       37136 : }
     118             : 
     119       37136 : void SwFont::SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder )
     120             : {
     121       37136 :     if( pLeftBorder )
     122         181 :         m_aLeftBorder = *pLeftBorder;
     123             :     else
     124             :     {
     125       36955 :         m_aLeftBorder = boost::none;
     126       36955 :         m_nLeftBorderDist = 0;
     127             :     }
     128       37136 :     bFntChg = sal_True;
     129       37136 :     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
     130       37136 : }
     131             : 
     132             : const boost::optional<editeng::SvxBorderLine>&
     133       14199 : SwFont::GetAbsTopBorder( const bool bVertLayout ) const
     134             : {
     135       14199 :     switch( GetOrientation( bVertLayout ) )
     136             :     {
     137             :         case 0 :
     138       14198 :             return m_aTopBorder;
     139             :             break;
     140             :         case 900 :
     141           1 :             return m_aRightBorder;
     142             :             break;
     143             :         case 1800 :
     144           0 :             return m_aBottomBorder;
     145             :             break;
     146             :         case 2700 :
     147           0 :             return m_aLeftBorder;
     148             :             break;
     149             :         default :
     150             :             assert(false);
     151           0 :             return m_aTopBorder;
     152             :             break;
     153             :     }
     154             : }
     155             : 
     156             : const boost::optional<editeng::SvxBorderLine>&
     157       14199 : SwFont::GetAbsBottomBorder( const bool bVertLayout ) const
     158             : {
     159       14199 :     switch( GetOrientation( bVertLayout ) )
     160             :     {
     161             :         case 0 :
     162       14198 :             return m_aBottomBorder;
     163             :             break;
     164             :         case 900 :
     165           1 :             return m_aLeftBorder;
     166             :             break;
     167             :         case 1800 :
     168           0 :             return m_aTopBorder;
     169             :             break;
     170             :         case 2700 :
     171           0 :             return m_aRightBorder;
     172             :             break;
     173             :         default :
     174             :             assert(false);
     175           0 :             return m_aBottomBorder;
     176             :             break;
     177             :     }
     178             : }
     179             : 
     180             : const boost::optional<editeng::SvxBorderLine>&
     181       14199 : SwFont::GetAbsLeftBorder( const bool bVertLayout ) const
     182             : {
     183       14199 :     switch( GetOrientation( bVertLayout ) )
     184             :     {
     185             :         case 0 :
     186       14198 :             return m_aLeftBorder;
     187             :             break;
     188             :         case 900 :
     189           1 :             return m_aTopBorder;
     190             :             break;
     191             :         case 1800 :
     192           0 :             return m_aRightBorder;
     193             :             break;
     194             :         case 2700 :
     195           0 :             return m_aBottomBorder;
     196             :             break;
     197             :         default :
     198             :             assert(false);
     199           0 :             return m_aLeftBorder;
     200             :             break;
     201             :     }
     202             : }
     203             : 
     204             : const boost::optional<editeng::SvxBorderLine>&
     205       14199 : SwFont::GetAbsRightBorder( const bool bVertLayout ) const
     206             : {
     207       14199 :     switch( GetOrientation( bVertLayout ) )
     208             :     {
     209             :         case 0 :
     210       14198 :             return m_aRightBorder;
     211             :             break;
     212             :         case 900 :
     213           1 :             return m_aBottomBorder;
     214             :             break;
     215             :         case 1800 :
     216           0 :             return m_aLeftBorder;
     217             :             break;
     218             :         case 2700 :
     219           0 :             return m_aTopBorder;
     220             :             break;
     221             :         default :
     222             :             assert(false);
     223           0 :             return m_aRightBorder;
     224             :             break;
     225             :     }
     226             : }
     227             : 
     228      131311 : SvxShadowLocation SwFont::GetAbsShadowLocation( const bool bVertLayout ) const
     229             : {
     230      131311 :     SvxShadowLocation aLocation = SVX_SHADOW_NONE;
     231      131311 :     switch( GetOrientation( bVertLayout ) )
     232             :     {
     233             :         case 0:
     234      131302 :             aLocation = m_aShadowLocation;
     235      131302 :             break;
     236             : 
     237             :         case 900:
     238           9 :             switch ( m_aShadowLocation )
     239             :             {
     240             :                 case SVX_SHADOW_TOPLEFT:
     241           0 :                     aLocation = SVX_SHADOW_BOTTOMLEFT;
     242           0 :                     break;
     243             :                 case SVX_SHADOW_TOPRIGHT:
     244           0 :                     aLocation = SVX_SHADOW_TOPLEFT;
     245           0 :                     break;
     246             :                 case SVX_SHADOW_BOTTOMLEFT:
     247           0 :                     aLocation = SVX_SHADOW_BOTTOMRIGHT;
     248           0 :                     break;
     249             :                 case SVX_SHADOW_BOTTOMRIGHT:
     250           0 :                     aLocation = SVX_SHADOW_TOPRIGHT;
     251           0 :                     break;
     252             :                 case SVX_SHADOW_NONE:
     253             :                 case SVX_SHADOW_END:
     254           9 :                     aLocation = m_aShadowLocation;
     255           9 :                     break;
     256             :             }
     257           9 :             break;
     258             : 
     259             :         case 1800:
     260           0 :             switch ( m_aShadowLocation )
     261             :             {
     262             :                 case SVX_SHADOW_TOPLEFT:
     263           0 :                     aLocation = SVX_SHADOW_BOTTOMRIGHT;
     264           0 :                     break;
     265             :                 case SVX_SHADOW_TOPRIGHT:
     266           0 :                     aLocation = SVX_SHADOW_BOTTOMLEFT;
     267           0 :                     break;
     268             :                 case SVX_SHADOW_BOTTOMLEFT:
     269           0 :                     aLocation = SVX_SHADOW_TOPRIGHT;
     270           0 :                     break;
     271             :                 case SVX_SHADOW_BOTTOMRIGHT:
     272           0 :                     aLocation = SVX_SHADOW_TOPLEFT;
     273           0 :                     break;
     274             :                 case SVX_SHADOW_NONE:
     275             :                 case SVX_SHADOW_END:
     276           0 :                     aLocation = m_aShadowLocation;
     277           0 :                     break;
     278             :             }
     279           0 :             break;
     280             : 
     281             :         case 2700:
     282           0 :             switch ( m_aShadowLocation )
     283             :             {
     284             :                 case SVX_SHADOW_TOPLEFT:
     285           0 :                     aLocation = SVX_SHADOW_TOPRIGHT;
     286           0 :                     break;
     287             :                 case SVX_SHADOW_TOPRIGHT:
     288           0 :                     aLocation = SVX_SHADOW_BOTTOMRIGHT;
     289           0 :                     break;
     290             :                 case SVX_SHADOW_BOTTOMLEFT:
     291           0 :                     aLocation = SVX_SHADOW_TOPLEFT;
     292           0 :                     break;
     293             :                 case SVX_SHADOW_BOTTOMRIGHT:
     294           0 :                     aLocation = SVX_SHADOW_BOTTOMLEFT;
     295           0 :                     break;
     296             :                 case SVX_SHADOW_NONE:
     297             :                 case SVX_SHADOW_END:
     298           0 :                     aLocation = m_aShadowLocation;
     299           0 :                     break;
     300             :             }
     301           0 :             break;
     302             : 
     303             :         default:
     304             :             assert(false);
     305           0 :             break;
     306             :     }
     307      131311 :     return aLocation;
     308             : }
     309             : 
     310      117112 : sal_uInt16 SwFont::CalcShadowSpace(
     311             :         const sal_uInt16 nShadow, const bool bVertLayout,
     312             :         const bool bSkipLeft, const bool bSkipRight ) const
     313             : {
     314      117112 :     sal_uInt16 nSpace = 0;
     315      117112 :     const sal_uInt16 nOrient = GetOrientation( bVertLayout );
     316      117112 :     const SvxShadowLocation aLoc = GetAbsShadowLocation( bVertLayout );
     317      117112 :     switch( nShadow )
     318             :     {
     319             :         case SHADOW_TOP:
     320       29278 :             if(( aLoc == SVX_SHADOW_TOPLEFT ||
     321           2 :                aLoc == SVX_SHADOW_TOPRIGHT ) &&
     322           0 :                ( nOrient == 0 || nOrient == 1800 ||
     323           0 :                ( nOrient == 900 && !bSkipRight ) ||
     324           0 :                ( nOrient == 2700 && !bSkipLeft )))
     325             :             {
     326           2 :                 nSpace = m_nShadowWidth;
     327             :             }
     328       29278 :             break;
     329             : 
     330             :         case SHADOW_BOTTOM:
     331       29278 :             if(( aLoc == SVX_SHADOW_BOTTOMLEFT ||
     332           8 :                aLoc == SVX_SHADOW_BOTTOMRIGHT ) &&
     333           0 :                ( nOrient == 0 || nOrient == 1800 ||
     334           0 :                ( nOrient == 900 && !bSkipLeft ) ||
     335           0 :                ( nOrient == 2700 && !bSkipRight )))
     336             :             {
     337           8 :                 nSpace = m_nShadowWidth;
     338             :             }
     339       29278 :             break;
     340             : 
     341             :         case SHADOW_LEFT:
     342       29278 :             if(( aLoc == SVX_SHADOW_TOPLEFT ||
     343           2 :                aLoc == SVX_SHADOW_BOTTOMLEFT ) &&
     344           2 :                ( nOrient == 900 || nOrient == 2700 ||
     345           2 :                ( nOrient == 0 && !bSkipLeft ) ||
     346           0 :                ( nOrient == 1800 && !bSkipRight )))
     347             :             {
     348           2 :                 nSpace = m_nShadowWidth;
     349             :             }
     350       29278 :             break;
     351             : 
     352             :          case SHADOW_RIGHT:
     353       29278 :             if(( aLoc == SVX_SHADOW_TOPRIGHT ||
     354           8 :                aLoc == SVX_SHADOW_BOTTOMRIGHT ) &&
     355           8 :                ( nOrient == 900 || nOrient == 2700 ||
     356           8 :                ( nOrient == 0 && !bSkipRight ) ||
     357           0 :                ( nOrient == 1800 && !bSkipLeft )))
     358             :             {
     359           8 :                 nSpace = m_nShadowWidth;
     360             :             }
     361       29278 :             break;
     362             :         default:
     363             :             assert(false);
     364           0 :             break;
     365             :     }
     366             : 
     367      117112 :     return nSpace;
     368             : }
     369             : 
     370             : // maps directions for vertical layout
     371       42681 : sal_uInt16 MapDirection( sal_uInt16 nDir, const sal_Bool bVertFormat )
     372             : {
     373       42681 :     if ( bVertFormat )
     374             :     {
     375           0 :         switch ( nDir )
     376             :         {
     377             :         case 0 :
     378           0 :             nDir = 2700;
     379           0 :             break;
     380             :         case 900 :
     381           0 :             nDir = 0;
     382           0 :             break;
     383             :         case 2700 :
     384           0 :             nDir = 1800;
     385           0 :             break;
     386             : #if OSL_DEBUG_LEVEL > 0
     387             :         default :
     388             :             OSL_FAIL( "Unsupported direction" );
     389             :             break;
     390             : #endif
     391             :         }
     392             :     }
     393       42681 :     return nDir;
     394             : }
     395             : 
     396             : // maps the absolute direction set at the font to its logical conterpart
     397             : // in the rotated environment
     398      341779 : sal_uInt16 UnMapDirection( sal_uInt16 nDir, const sal_Bool bVertFormat )
     399             : {
     400      341779 :     if ( bVertFormat )
     401             :     {
     402           0 :         switch ( nDir )
     403             :         {
     404             :         case 0 :
     405           0 :             nDir = 900;
     406           0 :             break;
     407             :         case 1800 :
     408           0 :             nDir = 2700;
     409           0 :             break;
     410             :         case 2700 :
     411           0 :             nDir = 0;
     412           0 :             break;
     413             : #if OSL_DEBUG_LEVEL > 0
     414             :         default :
     415             :             OSL_FAIL( "Unsupported direction" );
     416             :             break;
     417             : #endif
     418             :         }
     419             :     }
     420      341779 :     return nDir;
     421             : }
     422             : 
     423      340897 : sal_uInt16 SwFont::GetOrientation( const sal_Bool bVertFormat ) const
     424             : {
     425      340897 :     return UnMapDirection( aSub[nActual].GetOrientation(), bVertFormat );
     426             : }
     427             : 
     428       42681 : void SwFont::SetVertical( sal_uInt16 nDir, const sal_Bool bVertFormat )
     429             : {
     430             :     // map direction if frame has vertical layout
     431       42681 :     nDir = MapDirection( nDir, bVertFormat );
     432             : 
     433       42681 :     if( nDir != aSub[0].GetOrientation() )
     434             :     {
     435         781 :         bFntChg = sal_True;
     436         781 :         aSub[0].SetVertical( nDir, bVertFormat );
     437         781 :         aSub[1].SetVertical( nDir, bVertFormat || nDir > 1000 );
     438         781 :         aSub[2].SetVertical( nDir, bVertFormat );
     439             :     }
     440       42681 : }
     441             : 
     442             : /*************************************************************************
     443             :  Escapement:
     444             :     frEsc:  Fraction, Grad des Escapements
     445             :     Esc = resultierendes Escapement
     446             :     A1 = Original-Ascent            (nOrgAscent)
     447             :     A2 = verkleinerter Ascent       (nEscAscent)
     448             :     Ax = resultierender Ascent      (GetAscent())
     449             :     H1 = Original-Hoehe             (nOrgHeight)
     450             :     H2 = verkleinerter Hoehe        (nEscHeight)
     451             :     Hx = resultierender Hoehe       (GetHeight())
     452             :     Bx = resultierende Baseline fuer die Textausgabe (CalcPos())
     453             :          (Vorsicht: Y - A1!)
     454             : 
     455             :     Escapement:
     456             :         Esc = H1 * frEsc;
     457             : 
     458             :     Hochstellung:
     459             :         Ax = A2 + Esc;
     460             :         Hx = H2 + Esc;
     461             :         Bx = A1 - Esc;
     462             : 
     463             :     Tiefstellung:
     464             :         Ax = A1;
     465             :         Hx = A1 + Esc + (H2 - A2);
     466             :         Bx = A1 + Esc;
     467             : 
     468             : *************************************************************************/
     469             : 
     470             : // nEsc ist der Prozentwert
     471        5847 : sal_uInt16 SwSubFont::CalcEscAscent( const sal_uInt16 nOldAscent ) const
     472             : {
     473       11165 :     if( DFLT_ESC_AUTO_SUPER != GetEscapement() &&
     474        5318 :         DFLT_ESC_AUTO_SUB != GetEscapement() )
     475             :     {
     476        5293 :         const long nAscent = nOldAscent +
     477        5293 :                              ( (long) nOrgHeight * GetEscapement() ) / 100L;
     478        5293 :         if ( nAscent>0 )
     479        5293 :             return ( std::max( sal_uInt16 (nAscent), nOrgAscent ));
     480             :     }
     481         554 :     return nOrgAscent;
     482             : }
     483             : 
     484        1749 : void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
     485             :                          const IDocumentSettingAccess *pIDocumentSettingAccess )
     486             : {
     487        1749 :     delete pBackColor;
     488        1749 :     pBackColor = NULL;
     489             : 
     490        1749 :     if( pAttrSet )
     491             :     {
     492             :         const SfxPoolItem* pItem;
     493        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_FONT,
     494        1749 :             true, &pItem ))
     495             :         {
     496         115 :             const SvxFontItem *pFont = (const SvxFontItem *)pItem;
     497         115 :             aSub[SW_LATIN].SetFamily( pFont->GetFamily() );
     498         115 :             aSub[SW_LATIN].Font::SetName( pFont->GetFamilyName() );
     499         115 :             aSub[SW_LATIN].Font::SetStyleName( pFont->GetStyleName() );
     500         115 :             aSub[SW_LATIN].Font::SetPitch( pFont->GetPitch() );
     501         115 :             aSub[SW_LATIN].Font::SetCharSet( pFont->GetCharSet() );
     502             :         }
     503        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_FONTSIZE,
     504        1749 :             true, &pItem ))
     505             :         {
     506         346 :             const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
     507         346 :             aSub[SW_LATIN].SvxFont::SetPropr( 100 );
     508         346 :             aSub[SW_LATIN].aSize = aSub[SW_LATIN].Font::GetSize();
     509         346 :             Size aTmpSize = aSub[SW_LATIN].aSize;
     510         346 :             aTmpSize.Height() = pHeight->GetHeight();
     511         346 :             aSub[SW_LATIN].SetSize( aTmpSize );
     512             :         }
     513        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_POSTURE,
     514        1749 :             true, &pItem ))
     515          99 :             aSub[SW_LATIN].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
     516        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_WEIGHT,
     517        1749 :             true, &pItem ))
     518         105 :             aSub[SW_LATIN].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
     519        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_LANGUAGE,
     520        1749 :             true, &pItem ))
     521          30 :             aSub[SW_LATIN].SetLanguage( ((SvxLanguageItem*)pItem)->GetLanguage() );
     522             : 
     523        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONT,
     524        1749 :             true, &pItem ))
     525             :         {
     526          23 :             const SvxFontItem *pFont = (const SvxFontItem *)pItem;
     527          23 :             aSub[SW_CJK].SetFamily( pFont->GetFamily() );
     528          23 :             aSub[SW_CJK].Font::SetName( pFont->GetFamilyName() );
     529          23 :             aSub[SW_CJK].Font::SetStyleName( pFont->GetStyleName() );
     530          23 :             aSub[SW_CJK].Font::SetPitch( pFont->GetPitch() );
     531          23 :             aSub[SW_CJK].Font::SetCharSet( pFont->GetCharSet() );
     532             :         }
     533        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONTSIZE,
     534        1749 :             true, &pItem ))
     535             :         {
     536         344 :             const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
     537         344 :             aSub[SW_CJK].SvxFont::SetPropr( 100 );
     538         344 :             aSub[SW_CJK].aSize = aSub[SW_CJK].Font::GetSize();
     539         344 :             Size aTmpSize = aSub[SW_CJK].aSize;
     540         344 :             aTmpSize.Height() = pHeight->GetHeight();
     541         344 :             aSub[SW_CJK].SetSize( aTmpSize );
     542             :         }
     543        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_POSTURE,
     544        1749 :             true, &pItem ))
     545          99 :             aSub[SW_CJK].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
     546        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_WEIGHT,
     547        1749 :             true, &pItem ))
     548         103 :             aSub[SW_CJK].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
     549        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_LANGUAGE,
     550        1749 :             true, &pItem ))
     551             :         {
     552           0 :             LanguageType eNewLang = ((SvxLanguageItem*)pItem)->GetLanguage();
     553           0 :             aSub[SW_CJK].SetLanguage( eNewLang );
     554           0 :             aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
     555           0 :             aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
     556           0 :             aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
     557             :         }
     558             : 
     559        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONT,
     560        1749 :             true, &pItem ))
     561             :         {
     562         985 :             const SvxFontItem *pFont = (const SvxFontItem *)pItem;
     563         985 :             aSub[SW_CTL].SetFamily( pFont->GetFamily() );
     564         985 :             aSub[SW_CTL].Font::SetName( pFont->GetFamilyName() );
     565         985 :             aSub[SW_CTL].Font::SetStyleName( pFont->GetStyleName() );
     566         985 :             aSub[SW_CTL].Font::SetPitch( pFont->GetPitch() );
     567         985 :             aSub[SW_CTL].Font::SetCharSet( pFont->GetCharSet() );
     568             :         }
     569        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONTSIZE,
     570        1749 :             true, &pItem ))
     571             :         {
     572         217 :             const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
     573         217 :             aSub[SW_CTL].SvxFont::SetPropr( 100 );
     574         217 :             aSub[SW_CTL].aSize = aSub[SW_CTL].Font::GetSize();
     575         217 :             Size aTmpSize = aSub[SW_CTL].aSize;
     576         217 :             aTmpSize.Height() = pHeight->GetHeight();
     577         217 :             aSub[SW_CTL].SetSize( aTmpSize );
     578             :         }
     579        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_POSTURE,
     580        1749 :             true, &pItem ))
     581          30 :             aSub[SW_CTL].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
     582        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_WEIGHT,
     583        1749 :             true, &pItem ))
     584          34 :             aSub[SW_CTL].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
     585        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_LANGUAGE,
     586        1749 :             true, &pItem ))
     587           0 :             aSub[SW_CTL].SetLanguage( ((SvxLanguageItem*)pItem)->GetLanguage() );
     588             : 
     589        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_UNDERLINE,
     590        1749 :             true, &pItem ))
     591             :         {
     592         184 :             SetUnderline( ((SvxUnderlineItem*)pItem)->GetLineStyle() );
     593         184 :             SetUnderColor( ((SvxUnderlineItem*)pItem)->GetColor() );
     594             :         }
     595        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_OVERLINE,
     596        1749 :             true, &pItem ))
     597             :         {
     598           0 :             SetOverline( ((SvxOverlineItem*)pItem)->GetLineStyle() );
     599           0 :             SetOverColor( ((SvxOverlineItem*)pItem)->GetColor() );
     600             :         }
     601        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CROSSEDOUT,
     602        1749 :             true, &pItem ))
     603           4 :             SetStrikeout( ((SvxCrossedOutItem*)pItem)->GetStrikeout() );
     604        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_COLOR,
     605        1749 :             true, &pItem ))
     606         134 :             SetColor( ((SvxColorItem*)pItem)->GetValue() );
     607        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_EMPHASIS_MARK,
     608        1749 :             true, &pItem ))
     609         138 :             SetEmphasisMark( ((SvxEmphasisMarkItem*)pItem)->GetEmphasisMark() );
     610             : 
     611        1749 :         SetTransparent( sal_True );
     612        1749 :         SetAlign( ALIGN_BASELINE );
     613        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CONTOUR,
     614        1749 :             true, &pItem ))
     615           4 :             SetOutline( ((SvxContourItem*)pItem)->GetValue() );
     616        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
     617        1749 :             true, &pItem ))
     618           4 :             SetShadow( ((SvxShadowedItem*)pItem)->GetValue() );
     619        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_RELIEF,
     620        1749 :             true, &pItem ))
     621           0 :             SetRelief( (FontRelief)((SvxCharReliefItem*)pItem)->GetValue() );
     622        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
     623        1749 :             true, &pItem ))
     624           4 :             SetPropWidth(((SvxShadowedItem*)pItem)->GetValue() ? 50 : 100 );
     625        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_AUTOKERN,
     626        1749 :             true, &pItem ))
     627             :         {
     628           0 :             if( ((SvxAutoKernItem*)pItem)->GetValue() )
     629             :             {
     630           0 :                 SetAutoKern( ( !pIDocumentSettingAccess ||
     631           0 :                                !pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
     632             :                                 KERNING_FONTSPECIFIC :
     633           0 :                                 KERNING_ASIAN );
     634             :             }
     635             :             else
     636           0 :                 SetAutoKern( 0 );
     637             :         }
     638        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_WORDLINEMODE,
     639        1749 :             true, &pItem ))
     640           0 :             SetWordLineMode( ((SvxWordLineModeItem*)pItem)->GetValue() );
     641             : 
     642        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_ESCAPEMENT,
     643        1749 :             true, &pItem ))
     644             :         {
     645         221 :             const SvxEscapementItem *pEsc = (const SvxEscapementItem *)pItem;
     646         221 :             SetEscapement( pEsc->GetEsc() );
     647         221 :             if( aSub[SW_LATIN].IsEsc() )
     648         217 :                 SetProportion( pEsc->GetProp() );
     649             :         }
     650        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CASEMAP,
     651        1749 :             true, &pItem ))
     652           5 :             SetCaseMap( ((SvxCaseMapItem*)pItem)->GetCaseMap() );
     653        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_KERNING,
     654        1749 :             true, &pItem ))
     655          57 :             SetFixKerning( ((SvxKerningItem*)pItem)->GetValue() );
     656        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_NOHYPHEN,
     657        1749 :             true, &pItem ))
     658           0 :             SetNoHyph( ((SvxNoHyphenItem*)pItem)->GetValue() );
     659        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BLINK,
     660        1749 :             true, &pItem ))
     661           0 :             SetBlink( ((SvxBlinkItem*)pItem)->GetValue() );
     662        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_ROTATE,
     663        1749 :             true, &pItem ))
     664           0 :             SetVertical( ((SvxCharRotateItem*)pItem)->GetValue() );
     665        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
     666        1749 :             true, &pItem ))
     667           0 :             pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
     668        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
     669        1749 :             true, &pItem ))
     670           0 :             SetHighlightColor(((SvxBrushItem*)pItem)->GetColor());
     671        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
     672        1749 :             true, &pItem ))
     673             :         {
     674           0 :             const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
     675           0 :             SetTopBorder(pBoxItem->GetTop());
     676           0 :             SetBottomBorder(pBoxItem->GetBottom());
     677           0 :             SetRightBorder(pBoxItem->GetRight());
     678           0 :             SetLeftBorder(pBoxItem->GetLeft());
     679           0 :             SetTopBorderDist(pBoxItem->GetDistance(BOX_LINE_TOP));
     680           0 :             SetBottomBorderDist(pBoxItem->GetDistance(BOX_LINE_BOTTOM));
     681           0 :             SetRightBorderDist(pBoxItem->GetDistance(BOX_LINE_RIGHT));
     682           0 :             SetLeftBorderDist(pBoxItem->GetDistance(BOX_LINE_LEFT));
     683             :         }
     684        1749 :         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOW,
     685        1749 :             true, &pItem ))
     686             :         {
     687           0 :             const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
     688           0 :             SetShadowColor(pShadowItem->GetColor());
     689           0 :             SetShadowWidth(pShadowItem->GetWidth());
     690           0 :             SetShadowLocation(pShadowItem->GetLocation());
     691             :         }
     692        1749 :         const SfxPoolItem* pTwoLinesItem = 0;
     693        1749 :         if( SFX_ITEM_SET ==
     694        1749 :                 pAttrSet->GetItemState( RES_CHRATR_TWO_LINES, true, &pTwoLinesItem ))
     695           0 :             if ( ((SvxTwoLinesItem*)pTwoLinesItem)->GetValue() )
     696           0 :                 SetVertical( 0 );
     697             :     }
     698             :     else
     699             :     {
     700           0 :         Invalidate();
     701           0 :         bNoHyph = sal_False;
     702           0 :         bBlink = sal_False;
     703             :     }
     704        1749 :     bPaintBlank = sal_False;
     705        1749 :     bPaintWrong = sal_False;
     706             :     OSL_ENSURE( aSub[SW_LATIN].IsTransparent(), "SwFont: Transparent revolution" );
     707        1749 : }
     708             : 
     709             : // SwFont
     710             : 
     711      340357 : SwFont::SwFont( const SwFont &rFont )
     712             : {
     713      340357 :     aSub[SW_LATIN] = rFont.aSub[SW_LATIN];
     714      340357 :     aSub[SW_CJK] = rFont.aSub[SW_CJK];
     715      340357 :     aSub[SW_CTL] = rFont.aSub[SW_CTL];
     716      340357 :     nActual = rFont.nActual;
     717      340357 :     pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
     718      340357 :     m_aHighlightColor = rFont.m_aHighlightColor;
     719      340357 :     m_aTopBorder = rFont.m_aTopBorder;
     720      340357 :     m_aBottomBorder = rFont.m_aBottomBorder;
     721      340357 :     m_aRightBorder = rFont.m_aRightBorder;
     722      340357 :     m_aLeftBorder = rFont.m_aLeftBorder;
     723      340357 :     m_nTopBorderDist = rFont.m_nTopBorderDist;
     724      340357 :     m_nBottomBorderDist = rFont.m_nBottomBorderDist;
     725      340357 :     m_nRightBorderDist = rFont.m_nRightBorderDist;
     726      340357 :     m_nLeftBorderDist = rFont.m_nLeftBorderDist;
     727      340357 :     m_aShadowColor = rFont.m_aShadowColor;
     728      340357 :     m_nShadowWidth = rFont.m_nShadowWidth;
     729      340357 :     m_aShadowLocation = rFont.m_aShadowLocation;
     730      340357 :     aUnderColor = rFont.GetUnderColor();
     731      340357 :     aOverColor  = rFont.GetOverColor();
     732      340357 :     nToxCnt = 0;
     733      340357 :     nRefCnt = 0;
     734      340357 :     m_nMetaCount = 0;
     735      340357 :     m_nInputFieldCount = 0;
     736      340357 :     bFntChg = rFont.bFntChg;
     737      340357 :     bOrgChg = rFont.bOrgChg;
     738      340357 :     bPaintBlank = rFont.bPaintBlank;
     739      340357 :     bPaintWrong = sal_False;
     740      340357 :     bURL = rFont.bURL;
     741      340357 :     bGreyWave = rFont.bGreyWave;
     742      340357 :     bNoColReplace = rFont.bNoColReplace;
     743      340357 :     bNoHyph = rFont.bNoHyph;
     744      340357 :     bBlink = rFont.bBlink;
     745      340357 : }
     746             : 
     747       36851 : SwFont::SwFont( const SwAttrSet* pAttrSet,
     748       36851 :                 const IDocumentSettingAccess* pIDocumentSettingAccess )
     749             : {
     750       36851 :     nActual = SW_LATIN;
     751       36851 :     nToxCnt = 0;
     752       36851 :     nRefCnt = 0;
     753       36851 :     m_nMetaCount = 0;
     754       36851 :     m_nInputFieldCount = 0;
     755       36851 :     bPaintBlank = sal_False;
     756       36851 :     bPaintWrong = sal_False;
     757       36851 :     bURL = sal_False;
     758       36851 :     bGreyWave = sal_False;
     759       36851 :     bNoColReplace = sal_False;
     760       36851 :     bNoHyph = pAttrSet->GetNoHyphenHere().GetValue();
     761       36851 :     bBlink = pAttrSet->GetBlink().GetValue();
     762       36851 :     bOrgChg = sal_True;
     763             :     {
     764       36851 :         const SvxFontItem& rFont = pAttrSet->GetFont();
     765       36851 :         aSub[SW_LATIN].SetFamily( rFont.GetFamily() );
     766       36851 :         aSub[SW_LATIN].SetName( rFont.GetFamilyName() );
     767       36851 :         aSub[SW_LATIN].SetStyleName( rFont.GetStyleName() );
     768       36851 :         aSub[SW_LATIN].SetPitch( rFont.GetPitch() );
     769       36851 :         aSub[SW_LATIN].SetCharSet( rFont.GetCharSet() );
     770       36851 :         aSub[SW_LATIN].SvxFont::SetPropr( 100 );   // 100% der FontSize
     771       36851 :         Size aTmpSize = aSub[SW_LATIN].aSize;
     772       36851 :         aTmpSize.Height() = pAttrSet->GetSize().GetHeight();
     773       36851 :         aSub[SW_LATIN].SetSize( aTmpSize );
     774       36851 :         aSub[SW_LATIN].SetItalic( pAttrSet->GetPosture().GetPosture() );
     775       36851 :         aSub[SW_LATIN].SetWeight( pAttrSet->GetWeight().GetWeight() );
     776       36851 :         aSub[SW_LATIN].SetLanguage( pAttrSet->GetLanguage().GetLanguage() );
     777             :     }
     778             : 
     779             :     {
     780       36851 :         const SvxFontItem& rFont = pAttrSet->GetCJKFont();
     781       36851 :         aSub[SW_CJK].SetFamily( rFont.GetFamily() );
     782       36851 :         aSub[SW_CJK].SetName( rFont.GetFamilyName() );
     783       36851 :         aSub[SW_CJK].SetStyleName( rFont.GetStyleName() );
     784       36851 :         aSub[SW_CJK].SetPitch( rFont.GetPitch() );
     785       36851 :         aSub[SW_CJK].SetCharSet( rFont.GetCharSet() );
     786       36851 :         aSub[SW_CJK].SvxFont::SetPropr( 100 );   // 100% der FontSize
     787       36851 :         Size aTmpSize = aSub[SW_CJK].aSize;
     788       36851 :         aTmpSize.Height() = pAttrSet->GetCJKSize().GetHeight();
     789       36851 :         aSub[SW_CJK].SetSize( aTmpSize );
     790       36851 :         aSub[SW_CJK].SetItalic( pAttrSet->GetCJKPosture().GetPosture() );
     791       36851 :         aSub[SW_CJK].SetWeight( pAttrSet->GetCJKWeight().GetWeight() );
     792       36851 :         LanguageType eNewLang = pAttrSet->GetCJKLanguage().GetLanguage();
     793       36851 :         aSub[SW_CJK].SetLanguage( eNewLang );
     794       36851 :         aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
     795       36851 :         aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
     796       36851 :         aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
     797             :     }
     798             : 
     799             :     {
     800       36851 :         const SvxFontItem& rFont = pAttrSet->GetCTLFont();
     801       36851 :         aSub[SW_CTL].SetFamily( rFont.GetFamily() );
     802       36851 :         aSub[SW_CTL].SetName( rFont.GetFamilyName() );
     803       36851 :         aSub[SW_CTL].SetStyleName( rFont.GetStyleName() );
     804       36851 :         aSub[SW_CTL].SetPitch( rFont.GetPitch() );
     805       36851 :         aSub[SW_CTL].SetCharSet( rFont.GetCharSet() );
     806       36851 :         aSub[SW_CTL].SvxFont::SetPropr( 100 );   // 100% der FontSize
     807       36851 :         Size aTmpSize = aSub[SW_CTL].aSize;
     808       36851 :         aTmpSize.Height() = pAttrSet->GetCTLSize().GetHeight();
     809       36851 :         aSub[SW_CTL].SetSize( aTmpSize );
     810       36851 :         aSub[SW_CTL].SetItalic( pAttrSet->GetCTLPosture().GetPosture() );
     811       36851 :         aSub[SW_CTL].SetWeight( pAttrSet->GetCTLWeight().GetWeight() );
     812       36851 :         aSub[SW_CTL].SetLanguage( pAttrSet->GetCTLLanguage().GetLanguage() );
     813             :     }
     814       36851 :     if ( pAttrSet->GetCharHidden().GetValue() )
     815         328 :         SetUnderline( UNDERLINE_DOTTED );
     816             :     else
     817       36523 :         SetUnderline( pAttrSet->GetUnderline().GetLineStyle() );
     818       36851 :     SetUnderColor( pAttrSet->GetUnderline().GetColor() );
     819       36851 :     SetOverline( pAttrSet->GetOverline().GetLineStyle() );
     820       36851 :     SetOverColor( pAttrSet->GetOverline().GetColor() );
     821       36851 :     SetEmphasisMark( pAttrSet->GetEmphasisMark().GetEmphasisMark() );
     822       36851 :     SetStrikeout( pAttrSet->GetCrossedOut().GetStrikeout() );
     823       36851 :     SetColor( pAttrSet->GetColor().GetValue() );
     824       36851 :     SetTransparent( sal_True );
     825       36851 :     SetAlign( ALIGN_BASELINE );
     826       36851 :     SetOutline( pAttrSet->GetContour().GetValue() );
     827       36851 :     SetShadow( pAttrSet->GetShadowed().GetValue() );
     828       36851 :     SetPropWidth( pAttrSet->GetCharScaleW().GetValue() );
     829       36851 :     SetRelief( (FontRelief)pAttrSet->GetCharRelief().GetValue() );
     830       36851 :     if( pAttrSet->GetAutoKern().GetValue() )
     831             :     {
     832       31965 :         SetAutoKern( ( !pIDocumentSettingAccess ||
     833       31965 :                        !pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
     834             :                         KERNING_FONTSPECIFIC :
     835       63921 :                         KERNING_ASIAN );
     836             :     }
     837             :     else
     838        4886 :         SetAutoKern( 0 );
     839       36851 :     SetWordLineMode( pAttrSet->GetWordLineMode().GetValue() );
     840       36851 :     const SvxEscapementItem &rEsc = pAttrSet->GetEscapement();
     841       36851 :     SetEscapement( rEsc.GetEsc() );
     842       36851 :     if( aSub[SW_LATIN].IsEsc() )
     843        2046 :         SetProportion( rEsc.GetProp() );
     844       36851 :     SetCaseMap( pAttrSet->GetCaseMap().GetCaseMap() );
     845       36851 :     SetFixKerning( pAttrSet->GetKerning().GetValue() );
     846             :     const SfxPoolItem* pItem;
     847       36851 :     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
     848       36851 :         true, &pItem ))
     849        1755 :         pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
     850             :     else
     851       35096 :         pBackColor = NULL;
     852       36851 :     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
     853       36851 :         true, &pItem ))
     854           0 :         SetHighlightColor(((SvxBrushItem*)pItem)->GetColor());
     855             :     else
     856       36851 :         SetHighlightColor(COL_TRANSPARENT);
     857       36851 :     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
     858       36851 :         true, &pItem ))
     859             :     {
     860         264 :         const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
     861         264 :         SetTopBorder(pBoxItem->GetTop());
     862         264 :         SetBottomBorder(pBoxItem->GetBottom());
     863         264 :         SetRightBorder(pBoxItem->GetRight());
     864         264 :         SetLeftBorder(pBoxItem->GetLeft());
     865         264 :         SetTopBorderDist(pBoxItem->GetDistance(BOX_LINE_TOP));
     866         264 :         SetBottomBorderDist(pBoxItem->GetDistance(BOX_LINE_BOTTOM));
     867         264 :         SetRightBorderDist(pBoxItem->GetDistance(BOX_LINE_RIGHT));
     868         264 :         SetLeftBorderDist(pBoxItem->GetDistance(BOX_LINE_LEFT));
     869             :     }
     870             :     else
     871             :     {
     872       36587 :         SetTopBorder(0);
     873       36587 :         SetBottomBorder(0);
     874       36587 :         SetRightBorder(0);
     875       36587 :         SetLeftBorder(0);
     876       36587 :         SetTopBorderDist(0);
     877       36587 :         SetBottomBorderDist(0);
     878       36587 :         SetRightBorderDist(0);
     879       36587 :         SetLeftBorderDist(0);
     880             :     }
     881             : 
     882       36851 :     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOW,
     883       36851 :         true, &pItem ))
     884             :     {
     885         138 :         const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
     886         138 :         SetShadowColor(pShadowItem->GetColor());
     887         138 :         SetShadowWidth(pShadowItem->GetWidth());
     888         138 :         SetShadowLocation(pShadowItem->GetLocation());
     889             :     }
     890             :     else
     891             :     {
     892       36713 :         SetShadowColor(COL_TRANSPARENT);
     893       36713 :         SetShadowWidth(0);
     894       36713 :         SetShadowLocation(SVX_SHADOW_NONE);
     895             :     }
     896             : 
     897       36851 :     const SvxTwoLinesItem& rTwoLinesItem = pAttrSet->Get2Lines();
     898       36851 :     if ( ! rTwoLinesItem.GetValue() )
     899       35744 :         SetVertical( pAttrSet->GetCharRotate().GetValue() );
     900             :     else
     901        1107 :         SetVertical( 0 );
     902       36851 :     if( pIDocumentSettingAccess && pIDocumentSettingAccess->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 ))
     903             :     {
     904         153 :         aSub[ SW_LATIN ].smallCapsPercentage66 = true;
     905         153 :         aSub[ SW_CJK ].smallCapsPercentage66 = true;
     906         153 :         aSub[ SW_CTL ].smallCapsPercentage66 = true;
     907             :     }
     908       36851 : }
     909             : 
     910     1885975 : SwFont::~SwFont()
     911             : {
     912      377195 :     delete pBackColor;
     913     1508780 : }
     914             : 
     915     1143288 : SwSubFont& SwSubFont::operator=( const SwSubFont &rFont )
     916             : {
     917     1143288 :     SvxFont::operator=( rFont );
     918     1143288 :     pMagic = rFont.pMagic;
     919     1143288 :     nFntIndex = rFont.nFntIndex;
     920     1143288 :     nOrgHeight = rFont.nOrgHeight;
     921     1143288 :     nOrgAscent = rFont.nOrgAscent;
     922     1143288 :     nPropWidth = rFont.nPropWidth;
     923     1143288 :     aSize = rFont.aSize;
     924     1143288 :     smallCapsPercentage66 = rFont.smallCapsPercentage66;
     925     1143288 :     return *this;
     926             : }
     927             : 
     928       40739 : SwFont& SwFont::operator=( const SwFont &rFont )
     929             : {
     930       40739 :     aSub[SW_LATIN] = rFont.aSub[SW_LATIN];
     931       40739 :     aSub[SW_CJK] = rFont.aSub[SW_CJK];
     932       40739 :     aSub[SW_CTL] = rFont.aSub[SW_CTL];
     933       40739 :     nActual = rFont.nActual;
     934       40739 :     delete pBackColor;
     935       40739 :     pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
     936       40739 :     m_aHighlightColor = rFont.m_aHighlightColor;
     937       40739 :     m_aTopBorder = rFont.m_aTopBorder;
     938       40739 :     m_aBottomBorder = rFont.m_aBottomBorder;
     939       40739 :     m_aRightBorder = rFont.m_aRightBorder;
     940       40739 :     m_aLeftBorder = rFont.m_aLeftBorder;
     941       40739 :     m_nTopBorderDist = rFont.m_nTopBorderDist;
     942       40739 :     m_nBottomBorderDist = rFont.m_nBottomBorderDist;
     943       40739 :     m_nRightBorderDist = rFont.m_nRightBorderDist;
     944       40739 :     m_nLeftBorderDist = rFont.m_nLeftBorderDist;
     945       40739 :     m_aShadowColor = rFont.m_aShadowColor;
     946       40739 :     m_nShadowWidth = rFont.m_nShadowWidth;
     947       40739 :     m_aShadowLocation = rFont.m_aShadowLocation;
     948       40739 :     aUnderColor = rFont.GetUnderColor();
     949       40739 :     aOverColor  = rFont.GetOverColor();
     950       40739 :     nToxCnt = 0;
     951       40739 :     nRefCnt = 0;
     952       40739 :     m_nMetaCount = 0;
     953       40739 :     m_nInputFieldCount = 0;
     954       40739 :     bFntChg = rFont.bFntChg;
     955       40739 :     bOrgChg = rFont.bOrgChg;
     956       40739 :     bPaintBlank = rFont.bPaintBlank;
     957       40739 :     bPaintWrong = sal_False;
     958       40739 :     bURL = rFont.bURL;
     959       40739 :     bGreyWave = rFont.bGreyWave;
     960       40739 :     bNoColReplace = rFont.bNoColReplace;
     961       40739 :     bNoHyph = rFont.bNoHyph;
     962       40739 :     bBlink = rFont.bBlink;
     963       40739 :     return *this;
     964             : }
     965             : 
     966       20124 : void SwFont::GoMagic( SwViewShell *pSh, sal_uInt8 nWhich )
     967             : {
     968             :     SwFntAccess aFntAccess( aSub[nWhich].pMagic, aSub[nWhich].nFntIndex,
     969       20124 :                             &aSub[nWhich], pSh, sal_True );
     970       20124 : }
     971             : 
     972           0 : sal_Bool SwSubFont::IsSymbol( SwViewShell *pSh )
     973             : {
     974           0 :     SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh, sal_False );
     975           0 :     return aFntAccess.Get()->IsSymbol();
     976             : }
     977             : 
     978      363711 : sal_Bool SwSubFont::ChgFnt( SwViewShell *pSh, OutputDevice& rOut )
     979             : {
     980      363711 :     if ( pLastFont )
     981      360554 :         pLastFont->Unlock();
     982      363711 :     SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh, sal_True );
     983             :     SV_STAT( nChangeFont );
     984             : 
     985      363711 :     pLastFont = aFntAccess.Get();
     986             : 
     987      363711 :     pLastFont->SetDevFont( pSh, rOut );
     988             : 
     989      363711 :     pLastFont->Lock();
     990      711046 :     return UNDERLINE_NONE != GetUnderline() ||
     991      711033 :            UNDERLINE_NONE != GetOverline()  ||
     992      711033 :            STRIKEOUT_NONE != GetStrikeout();
     993             : }
     994             : 
     995      271503 : void SwFont::ChgPhysFnt( SwViewShell *pSh, OutputDevice& rOut )
     996             : {
     997      271503 :     if( bOrgChg && aSub[nActual].IsEsc() )
     998             :     {
     999        4303 :         const sal_uInt8 nOldProp = aSub[nActual].GetPropr();
    1000        4303 :         SetProportion( 100 );
    1001        4303 :         ChgFnt( pSh, rOut );
    1002             :         SwFntAccess aFntAccess( aSub[nActual].pMagic, aSub[nActual].nFntIndex,
    1003        4303 :                                 &aSub[nActual], pSh );
    1004        4303 :         aSub[nActual].nOrgHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
    1005        4303 :         aSub[nActual].nOrgAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
    1006        4303 :         SetProportion( nOldProp );
    1007        4303 :         bOrgChg = sal_False;
    1008             :     }
    1009             : 
    1010      271503 :     if( bFntChg )
    1011             :     {
    1012      271502 :         ChgFnt( pSh, rOut );
    1013      271502 :         bFntChg = bOrgChg;
    1014             :     }
    1015      271503 :     if( rOut.GetTextLineColor() != aUnderColor )
    1016         519 :         rOut.SetTextLineColor( aUnderColor );
    1017      271503 :     if( rOut.GetOverlineColor() != aOverColor )
    1018         130 :         rOut.SetOverlineColor( aOverColor );
    1019      271503 : }
    1020             : 
    1021             : /*************************************************************************
    1022             :  *                      SwFont::CalcEscHeight()
    1023             :  *         Height = MaxAscent + MaxDescent
    1024             :  *      MaxAscent = Max (T1_ascent, T2_ascent + (Esc * T1_height) );
    1025             :  *     MaxDescent = Max (T1_height-T1_ascent,
    1026             :  *                       T2_height-T2_ascent - (Esc * T1_height)
    1027             :  *************************************************************************/
    1028        4811 : sal_uInt16 SwSubFont::CalcEscHeight( const sal_uInt16 nOldHeight,
    1029             :                               const sal_uInt16 nOldAscent  ) const
    1030             : {
    1031        8724 :     if( DFLT_ESC_AUTO_SUPER != GetEscapement() &&
    1032        3913 :         DFLT_ESC_AUTO_SUB != GetEscapement() )
    1033             :     {
    1034        3860 :         long nDescent = nOldHeight - nOldAscent -
    1035        3860 :                              ( (long) nOrgHeight * GetEscapement() ) / 100L;
    1036             :         const sal_uInt16 nDesc = ( nDescent>0 ) ? std::max ( sal_uInt16(nDescent),
    1037        3860 :                    sal_uInt16(nOrgHeight - nOrgAscent) ) : nOrgHeight - nOrgAscent;
    1038        3860 :         return ( nDesc + CalcEscAscent( nOldAscent ) );
    1039             :     }
    1040         951 :     return nOrgHeight;
    1041             : }
    1042             : 
    1043        2162 : short SwSubFont::_CheckKerning( )
    1044             : {
    1045        2162 :     short nKernx = - short( Font::GetSize().Height() / 6 );
    1046             : 
    1047        2162 :     if ( nKernx < GetFixKerning() )
    1048        2162 :         return GetFixKerning();
    1049           0 :     return nKernx;
    1050             : }
    1051             : 
    1052      145977 : sal_uInt16 SwSubFont::GetAscent( SwViewShell *pSh, const OutputDevice& rOut )
    1053             : {
    1054             :     sal_uInt16 nAscent;
    1055      145977 :     SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh );
    1056      145977 :     nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
    1057      145977 :     if( GetEscapement() )
    1058        1987 :         nAscent = CalcEscAscent( nAscent );
    1059      145977 :     return nAscent;
    1060             : }
    1061             : 
    1062      200428 : sal_uInt16 SwSubFont::GetHeight( SwViewShell *pSh, const OutputDevice& rOut )
    1063             : {
    1064             :     SV_STAT( nGetTextSize );
    1065      200428 :     SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh );
    1066      200428 :     const sal_uInt16 nHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
    1067      200428 :     if ( GetEscapement() )
    1068             :     {
    1069        4018 :         const sal_uInt16 nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
    1070        4018 :         return CalcEscHeight( nHeight, nAscent ); // + nLeading;
    1071             :     }
    1072      196410 :     return nHeight; // + nLeading;
    1073             : }
    1074             : 
    1075       64489 : Size SwSubFont::_GetTxtSize( SwDrawTextInfo& rInf )
    1076             : {
    1077             :     // Robust: Eigentlich sollte der Font bereits eingestellt sein, aber
    1078             :     // sicher ist sicher ...
    1079      128964 :     if ( !pLastFont || pLastFont->GetOwner()!=pMagic ||
    1080       64475 :          !IsSameInstance( rInf.GetpOut()->GetFont() ) )
    1081       58062 :         ChgFnt( rInf.GetShell(), rInf.GetOut() );
    1082             : 
    1083       64489 :     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
    1084             : 
    1085       64489 :     Size aTxtSize;
    1086       64489 :     sal_Int32 nLn = ( rInf.GetLen() == COMPLETE_STRING ? rInf.GetText().getLength()
    1087       64489 :                                                    : rInf.GetLen() );
    1088       64489 :     rInf.SetLen( nLn );
    1089       64489 :     if( IsCapital() && nLn )
    1090          35 :         aTxtSize = GetCapitalSize( rInf );
    1091             :     else
    1092             :     {
    1093             :         SV_STAT( nGetTextSize );
    1094       64454 :         long nOldKern = rInf.GetKern();
    1095       64454 :         const OUString oldTxt = rInf.GetText();
    1096       64454 :         rInf.SetKern( CheckKerning() );
    1097       64454 :         if ( !IsCaseMap() )
    1098       64219 :             aTxtSize = pLastFont->GetTextSize( rInf );
    1099             :         else
    1100             :         {
    1101         235 :             OUString aTmp = CalcCaseMap( rInf.GetText() );
    1102         470 :             const OUString oldStr = rInf.GetText();
    1103         235 :             bool bCaseMapLengthDiffers(aTmp.getLength() != oldStr.getLength());
    1104             : 
    1105         235 :             if(bCaseMapLengthDiffers && rInf.GetLen())
    1106             :             {
    1107             :                 // #108203#
    1108             :                 // If the length of the original string and the CaseMapped one
    1109             :                 // are different, it is necessary to handle the given text part as
    1110             :                 // a single snippet since its size may differ, too.
    1111           0 :                 sal_Int32 nOldIdx(rInf.GetIdx());
    1112           0 :                 sal_Int32 nOldLen(rInf.GetLen());
    1113           0 :                 const OUString aSnippet(oldStr.copy(nOldIdx, nOldLen));
    1114           0 :                 OUString aNewText(CalcCaseMap(aSnippet));
    1115             : 
    1116           0 :                 rInf.SetText( aNewText );
    1117           0 :                 rInf.SetIdx( 0 );
    1118           0 :                 rInf.SetLen( aNewText.getLength() );
    1119             : 
    1120           0 :                 aTxtSize = pLastFont->GetTextSize( rInf );
    1121             : 
    1122           0 :                 rInf.SetIdx( nOldIdx );
    1123           0 :                 rInf.SetLen( nOldLen );
    1124             :             }
    1125             :             else
    1126             :             {
    1127         235 :                 rInf.SetText( aTmp );
    1128         235 :                 aTxtSize = pLastFont->GetTextSize( rInf );
    1129             :             }
    1130             : 
    1131         470 :             rInf.SetText(oldStr);
    1132             :         }
    1133       64454 :         rInf.SetKern( nOldKern );
    1134       64454 :         rInf.SetText(oldTxt);
    1135             :         // 15142: Ein Wort laenger als eine Zeile, beim Zeilenumbruch
    1136             :         //        hochgestellt, muss seine effektive Hoehe melden.
    1137       64454 :         if( GetEscapement() )
    1138             :         {
    1139         793 :             const sal_uInt16 nAscent = pLastFont->GetFontAscent( rInf.GetShell(),
    1140        1586 :                                                              rInf.GetOut() );
    1141         793 :             aTxtSize.Height() =
    1142         793 :                 (long)CalcEscHeight( (sal_uInt16)aTxtSize.Height(), nAscent);
    1143       64454 :         }
    1144             :     }
    1145             : 
    1146       64489 :     if (1==rInf.GetLen() && CH_TXT_ATR_FIELDSTART==rInf.GetText()[rInf.GetIdx()])
    1147             :     {
    1148           0 :         sal_Int32 nOldIdx(rInf.GetIdx());
    1149           0 :         sal_Int32 nOldLen(rInf.GetLen());
    1150           0 :         OUString aNewText(CH_TXT_ATR_SUBST_FIELDSTART);
    1151           0 :         rInf.SetText( aNewText );
    1152           0 :         rInf.SetIdx( 0 );
    1153           0 :         rInf.SetLen( aNewText.getLength() );
    1154           0 :         aTxtSize = pLastFont->GetTextSize( rInf );
    1155           0 :         rInf.SetIdx( nOldIdx );
    1156           0 :         rInf.SetLen( nOldLen );
    1157             :     }
    1158       64489 :     else if (1==rInf.GetLen() && CH_TXT_ATR_FIELDEND==rInf.GetText()[ rInf.GetIdx() ])
    1159             :     {
    1160           3 :         sal_Int32 nOldIdx(rInf.GetIdx());
    1161           3 :         sal_Int32 nOldLen(rInf.GetLen());
    1162           3 :         OUString aNewText(CH_TXT_ATR_SUBST_FIELDEND);
    1163           3 :         rInf.SetText( aNewText );
    1164           3 :         rInf.SetIdx( 0 );
    1165           3 :         rInf.SetLen( aNewText.getLength() );
    1166           3 :         aTxtSize = pLastFont->GetTextSize( rInf );
    1167           3 :         rInf.SetIdx( nOldIdx );
    1168           3 :         rInf.SetLen( nOldLen );
    1169             :     }
    1170             : 
    1171       64489 :     return aTxtSize;
    1172             : }
    1173             : 
    1174       14034 : void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const sal_Bool bGrey )
    1175             : {
    1176       14034 :     rInf.SetGreyWave( bGrey );
    1177       14034 :     sal_Int32 nLn = rInf.GetText().getLength();
    1178       14034 :     if( !rInf.GetLen() || !nLn )
    1179       14034 :         return;
    1180       14034 :     if( COMPLETE_STRING == rInf.GetLen() )
    1181          14 :         rInf.SetLen( nLn );
    1182             : 
    1183       14034 :     FontUnderline nOldUnder = UNDERLINE_NONE;
    1184       14034 :     SwUnderlineFont* pUnderFnt = 0;
    1185             : 
    1186       14034 :     if( rInf.GetUnderFnt() )
    1187             :     {
    1188          50 :         nOldUnder = GetUnderline();
    1189          50 :         SetUnderline( UNDERLINE_NONE );
    1190          50 :         pUnderFnt = rInf.GetUnderFnt();
    1191             :     }
    1192             : 
    1193       14034 :     if( !pLastFont || pLastFont->GetOwner()!=pMagic )
    1194          62 :         ChgFnt( rInf.GetShell(), rInf.GetOut() );
    1195             : 
    1196       14034 :     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
    1197             : 
    1198       14034 :     const Point aOldPos(rInf.GetPos());
    1199       14034 :     Point aPos( rInf.GetPos() );
    1200             : 
    1201       14034 :     if( GetEscapement() )
    1202         303 :         CalcEsc( rInf, aPos );
    1203             : 
    1204       14034 :     rInf.SetPos( aPos );
    1205       14034 :     rInf.SetKern( CheckKerning() + rInf.GetSperren() / SPACING_PRECISION_FACTOR );
    1206             : 
    1207       14034 :     if( IsCapital() )
    1208           3 :         DrawCapital( rInf );
    1209             :     else
    1210             :     {
    1211             :         SV_STAT( nDrawText );
    1212       14031 :         if ( !IsCaseMap() )
    1213       13912 :             pLastFont->DrawText( rInf );
    1214             :         else
    1215             :         {
    1216         119 :             const OUString oldStr = rInf.GetText();
    1217         238 :             OUString aString( CalcCaseMap(oldStr) );
    1218         119 :             bool bCaseMapLengthDiffers(aString.getLength() != oldStr.getLength());
    1219             : 
    1220         119 :             if(bCaseMapLengthDiffers && rInf.GetLen())
    1221             :             {
    1222             :                 // #108203#
    1223             :                 // If the length of the original string and the CaseMapped one
    1224             :                 // are different, it is necessary to handle the given text part as
    1225             :                 // a single snippet since its size may differ, too.
    1226           0 :                 sal_Int32 nOldIdx(rInf.GetIdx());
    1227           0 :                 sal_Int32 nOldLen(rInf.GetLen());
    1228           0 :                 const OUString aSnippet(oldStr.copy(nOldIdx, nOldLen));
    1229           0 :                 OUString aNewText = CalcCaseMap(aSnippet);
    1230             : 
    1231           0 :                 rInf.SetText( aNewText );
    1232           0 :                 rInf.SetIdx( 0 );
    1233           0 :                 rInf.SetLen( aNewText.getLength() );
    1234             : 
    1235           0 :                 pLastFont->DrawText( rInf );
    1236             : 
    1237           0 :                 rInf.SetIdx( nOldIdx );
    1238           0 :                 rInf.SetLen( nOldLen );
    1239             :             }
    1240             :             else
    1241             :             {
    1242         119 :                 rInf.SetText( aString );
    1243         119 :                 pLastFont->DrawText( rInf );
    1244             :             }
    1245             : 
    1246         238 :             rInf.SetText(oldStr);
    1247             :         }
    1248             :     }
    1249             : 
    1250       14034 :     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
    1251             :     {
    1252          50 :         Size aFontSize = _GetTxtSize( rInf );
    1253          50 :         const OUString oldStr = rInf.GetText();
    1254         100 :         OUString aStr("  ");
    1255             : 
    1256          50 :         sal_Int32 nOldIdx = rInf.GetIdx();
    1257          50 :         sal_Int32 nOldLen = rInf.GetLen();
    1258          50 :         long nSpace = 0;
    1259          50 :         if( rInf.GetSpace() )
    1260             :         {
    1261           0 :             sal_Int32 nTmpEnd = nOldIdx + nOldLen;
    1262           0 :             if (nTmpEnd > oldStr.getLength())
    1263           0 :                 nTmpEnd = oldStr.getLength();
    1264             : 
    1265           0 :             const SwScriptInfo* pSI = rInf.GetScriptInfo();
    1266             : 
    1267             :             const bool bAsianFont =
    1268           0 :                 ( rInf.GetFont() && SW_CJK == rInf.GetFont()->GetActual() );
    1269           0 :             for( sal_Int32 nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp )
    1270             :             {
    1271           0 :                 if (CH_BLANK == oldStr[nTmp] || bAsianFont ||
    1272           0 :                     ( nTmp + 1 < oldStr.getLength() && pSI &&
    1273           0 :                       i18n::ScriptType::ASIAN == pSI->ScriptType( nTmp + 1 ) ) )
    1274           0 :                     ++nSpace;
    1275             :             }
    1276             : 
    1277             :             // if next portion if a hole portion we do not consider any
    1278             :             // extra space added because the last character was ASIAN
    1279           0 :             if ( nSpace && rInf.IsSpaceStop() && bAsianFont )
    1280           0 :                  --nSpace;
    1281             : 
    1282           0 :             nSpace *= rInf.GetSpace() / SPACING_PRECISION_FACTOR;
    1283             :         }
    1284             : 
    1285          50 :         rInf.SetWidth( sal_uInt16(aFontSize.Width() + nSpace) );
    1286          50 :         rInf.SetText( aStr );
    1287          50 :         rInf.SetIdx( 0 );
    1288          50 :         rInf.SetLen( 2 );
    1289          50 :         SetUnderline( nOldUnder );
    1290          50 :         rInf.SetUnderFnt( 0 );
    1291             : 
    1292             :         // set position for underline font
    1293          50 :         rInf.SetPos( pUnderFnt->GetPos() );
    1294             : 
    1295          50 :         pUnderFnt->GetFont()._DrawStretchText( rInf );
    1296             : 
    1297          50 :         rInf.SetUnderFnt( pUnderFnt );
    1298          50 :         rInf.SetText(oldStr);
    1299          50 :         rInf.SetIdx( nOldIdx );
    1300         100 :         rInf.SetLen( nOldLen );
    1301             :     }
    1302             : 
    1303       14034 :     rInf.SetPos(aOldPos);
    1304             : }
    1305             : 
    1306          57 : void SwSubFont::_DrawStretchText( SwDrawTextInfo &rInf )
    1307             : {
    1308          57 :     if( !rInf.GetLen() || !rInf.GetText().getLength() )
    1309          57 :         return;
    1310             : 
    1311          57 :     FontUnderline nOldUnder = UNDERLINE_NONE;
    1312          57 :     SwUnderlineFont* pUnderFnt = 0;
    1313             : 
    1314          57 :     if( rInf.GetUnderFnt() )
    1315             :     {
    1316           0 :         nOldUnder = GetUnderline();
    1317           0 :         SetUnderline( UNDERLINE_NONE );
    1318           0 :         pUnderFnt = rInf.GetUnderFnt();
    1319             :     }
    1320             : 
    1321          57 :     if ( !pLastFont || pLastFont->GetOwner() != pMagic )
    1322          50 :         ChgFnt( rInf.GetShell(), rInf.GetOut() );
    1323             : 
    1324          57 :     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
    1325             : 
    1326          57 :     rInf.ApplyAutoColor();
    1327             : 
    1328          57 :     const Point aOldPos(rInf.GetPos());
    1329          57 :     Point aPos( rInf.GetPos() );
    1330             : 
    1331          57 :     if( GetEscapement() )
    1332           0 :         CalcEsc( rInf, aPos );
    1333             : 
    1334          57 :     rInf.SetKern( CheckKerning() + rInf.GetSperren() / SPACING_PRECISION_FACTOR );
    1335          57 :     rInf.SetPos( aPos );
    1336             : 
    1337          57 :     if( IsCapital() )
    1338           0 :         DrawStretchCapital( rInf );
    1339             :     else
    1340             :     {
    1341             :         SV_STAT( nDrawStretchText );
    1342             : 
    1343          57 :         if ( rInf.GetFrm() )
    1344             :         {
    1345          57 :             if ( rInf.GetFrm()->IsRightToLeft() )
    1346           0 :                 rInf.GetFrm()->SwitchLTRtoRTL( aPos );
    1347             : 
    1348          57 :             if ( rInf.GetFrm()->IsVertical() )
    1349           0 :                 rInf.GetFrm()->SwitchHorizontalToVertical( aPos );
    1350             : 
    1351          57 :             rInf.SetPos( aPos );
    1352             :         }
    1353             : 
    1354          57 :         if ( !IsCaseMap() )
    1355         114 :             rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(),
    1356         171 :                             rInf.GetText(), rInf.GetIdx(), rInf.GetLen() );
    1357             :         else
    1358           0 :             rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(), CalcCaseMap(
    1359           0 :                             rInf.GetText() ), rInf.GetIdx(), rInf.GetLen() );
    1360             :     }
    1361             : 
    1362          57 :     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
    1363             :     {
    1364           0 :         const OUString oldStr = rInf.GetText();
    1365           0 :         OUString aStr("  ");
    1366           0 :         sal_Int32 nOldIdx = rInf.GetIdx();
    1367           0 :         sal_Int32 nOldLen = rInf.GetLen();
    1368           0 :         rInf.SetText( aStr );
    1369           0 :         rInf.SetIdx( 0 );
    1370           0 :         rInf.SetLen( 2 );
    1371           0 :         SetUnderline( nOldUnder );
    1372           0 :         rInf.SetUnderFnt( 0 );
    1373             : 
    1374             :         // set position for underline font
    1375           0 :         rInf.SetPos( pUnderFnt->GetPos() );
    1376             : 
    1377           0 :         pUnderFnt->GetFont()._DrawStretchText( rInf );
    1378             : 
    1379           0 :         rInf.SetUnderFnt( pUnderFnt );
    1380           0 :         rInf.SetText(oldStr);
    1381           0 :         rInf.SetIdx( nOldIdx );
    1382           0 :         rInf.SetLen( nOldLen );
    1383             :     }
    1384             : 
    1385          57 :     rInf.SetPos(aOldPos);
    1386             : }
    1387             : 
    1388           0 : sal_Int32 SwSubFont::_GetCrsrOfst( SwDrawTextInfo& rInf )
    1389             : {
    1390           0 :     if ( !pLastFont || pLastFont->GetOwner()!=pMagic )
    1391           0 :         ChgFnt( rInf.GetShell(), rInf.GetOut() );
    1392             : 
    1393           0 :     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
    1394             : 
    1395           0 :     sal_Int32 nLn = rInf.GetLen() == COMPLETE_STRING ? rInf.GetText().getLength()
    1396           0 :                                                  : rInf.GetLen();
    1397           0 :     rInf.SetLen( nLn );
    1398           0 :     sal_Int32 nCrsr = 0;
    1399           0 :     if( IsCapital() && nLn )
    1400           0 :         nCrsr = GetCapitalCrsrOfst( rInf );
    1401             :     else
    1402             :     {
    1403           0 :         const OUString oldTxt = rInf.GetText();
    1404           0 :         long nOldKern = rInf.GetKern();
    1405           0 :         rInf.SetKern( CheckKerning() );
    1406             :         SV_STAT( nGetTextSize );
    1407           0 :         if ( !IsCaseMap() )
    1408           0 :             nCrsr = pLastFont->GetCrsrOfst( rInf );
    1409             :         else
    1410             :         {
    1411           0 :             OUString aTmp = CalcCaseMap( rInf.GetText() );
    1412           0 :             rInf.SetText( aTmp );
    1413           0 :             nCrsr = pLastFont->GetCrsrOfst( rInf );
    1414             :         }
    1415           0 :         rInf.SetKern( nOldKern );
    1416           0 :         rInf.SetText(oldTxt);
    1417             :     }
    1418           0 :     return nCrsr;
    1419             : }
    1420             : 
    1421         303 : void SwSubFont::CalcEsc( SwDrawTextInfo& rInf, Point& rPos )
    1422             : {
    1423             :     long nOfst;
    1424             : 
    1425             :     sal_uInt16 nDir = UnMapDirection(
    1426         303 :                 GetOrientation(), rInf.GetFrm() && rInf.GetFrm()->IsVertical() );
    1427             : 
    1428         303 :     switch ( GetEscapement() )
    1429             :     {
    1430             :     case DFLT_ESC_AUTO_SUB :
    1431           0 :         nOfst = nOrgHeight - nOrgAscent -
    1432           0 :             pLastFont->GetFontHeight( rInf.GetShell(), rInf.GetOut() ) +
    1433           0 :             pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() );
    1434             : 
    1435           0 :         switch ( nDir )
    1436             :         {
    1437             :         case 0 :
    1438           0 :             rPos.Y() += nOfst;
    1439           0 :             break;
    1440             :         case 900 :
    1441           0 :             rPos.X() += nOfst;
    1442           0 :             break;
    1443             :         case 2700 :
    1444           0 :             rPos.X() -= nOfst;
    1445           0 :             break;
    1446             :         }
    1447             : 
    1448           0 :         break;
    1449             :     case DFLT_ESC_AUTO_SUPER :
    1450         101 :         nOfst = pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() ) -
    1451         101 :                 nOrgAscent;
    1452             : 
    1453         101 :         switch ( nDir )
    1454             :         {
    1455             :         case 0 :
    1456         101 :             rPos.Y() += nOfst;
    1457         101 :             break;
    1458             :         case 900 :
    1459           0 :             rPos.X() += nOfst;
    1460           0 :             break;
    1461             :         case 2700 :
    1462           0 :             rPos.X() -= nOfst;
    1463           0 :             break;
    1464             :         }
    1465             : 
    1466         101 :         break;
    1467             :     default :
    1468         202 :         nOfst = ((long)nOrgHeight * GetEscapement()) / 100L;
    1469             : 
    1470         202 :         switch ( nDir )
    1471             :         {
    1472             :         case 0 :
    1473         202 :             rPos.Y() -= nOfst;
    1474         202 :             break;
    1475             :         case 900 :
    1476           0 :             rPos.X() -= nOfst;
    1477           0 :             break;
    1478             :         case 2700 :
    1479           0 :             rPos.X() += nOfst;
    1480           0 :             break;
    1481             :         }
    1482             :     }
    1483         303 : }
    1484             : 
    1485             : // used during painting of small capitals
    1486           3 : void SwDrawTextInfo::Shift( sal_uInt16 nDir )
    1487             : {
    1488             : #ifdef DBG_UTIL
    1489             :     OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
    1490             :     OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Width" );
    1491             : #endif
    1492             : 
    1493           3 :     const bool bBidiPor = ( GetFrm() && GetFrm()->IsRightToLeft() ) !=
    1494           3 :                           ( 0 != ( TEXT_LAYOUT_BIDI_RTL & GetpOut()->GetLayoutMode() ) );
    1495             : 
    1496             :     nDir = bBidiPor ?
    1497             :             1800 :
    1498           3 :             UnMapDirection( nDir, GetFrm() && GetFrm()->IsVertical() );
    1499             : 
    1500           3 :     switch ( nDir )
    1501             :     {
    1502             :     case 0 :
    1503           3 :         m_aPos.X() += GetSize().Width();
    1504           3 :         break;
    1505             :     case 900 :
    1506             :         OSL_ENSURE( m_aPos.Y() >= GetSize().Width(), "Going underground" );
    1507           0 :         m_aPos.Y() -= GetSize().Width();
    1508           0 :         break;
    1509             :     case 1800 :
    1510           0 :         m_aPos.X() -= GetSize().Width();
    1511           0 :         break;
    1512             :     case 2700 :
    1513           0 :         m_aPos.Y() += GetSize().Width();
    1514           0 :         break;
    1515             :     }
    1516           3 : }
    1517             : 
    1518             : /**
    1519             :  * @note Used for the "continuous underline" feature.
    1520             :  **/
    1521          49 : SwUnderlineFont::SwUnderlineFont( SwFont& rFnt, const Point& rPoint )
    1522          49 :         : aPos( rPoint ), pFnt( &rFnt )
    1523             : {
    1524          49 : };
    1525             : 
    1526          49 : SwUnderlineFont::~SwUnderlineFont()
    1527             : {
    1528          49 :      delete pFnt;
    1529          49 : }
    1530             : 
    1531             : /// Helper for filters to find true lineheight of a font
    1532           0 : long AttrSetToLineHeight( const IDocumentSettingAccess& rIDocumentSettingAccess,
    1533             :                           const SwAttrSet &rSet,
    1534             :                           const OutputDevice &rOut, sal_Int16 nScript)
    1535             : {
    1536           0 :     SwFont aFont(&rSet, &rIDocumentSettingAccess);
    1537             :     sal_uInt8 nActual;
    1538           0 :     switch (nScript)
    1539             :     {
    1540             :         default:
    1541             :         case i18n::ScriptType::LATIN:
    1542           0 :             nActual = SW_LATIN;
    1543           0 :             break;
    1544             :         case i18n::ScriptType::ASIAN:
    1545           0 :             nActual = SW_CJK;
    1546           0 :             break;
    1547             :         case i18n::ScriptType::COMPLEX:
    1548           0 :             nActual = SW_CTL;
    1549           0 :             break;
    1550             :     }
    1551           0 :     aFont.SetActual(nActual);
    1552             : 
    1553           0 :     OutputDevice &rMutableOut = const_cast<OutputDevice &>(rOut);
    1554           0 :     const Font aOldFont(rMutableOut.GetFont());
    1555             : 
    1556           0 :     rMutableOut.SetFont(aFont.GetActualFont());
    1557           0 :     long nHeight = rMutableOut.GetTextHeight();
    1558             : 
    1559           0 :     rMutableOut.SetFont(aOldFont);
    1560           0 :     return nHeight;
    1561             : }
    1562             : 
    1563             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10