LCOV - code coverage report
Current view: top level - sw/source/core/text - atrstck.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 319 367 86.9 %
Date: 2012-08-25 Functions: 19 21 90.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 231 347 66.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <atrhndl.hxx>
      30                 :            : #include <svl/itemiter.hxx>
      31                 :            : #include <vcl/outdev.hxx>
      32                 :            : #include <editeng/cmapitem.hxx>
      33                 :            : #include <editeng/colritem.hxx>
      34                 :            : #include <editeng/cntritem.hxx>
      35                 :            : #include <editeng/crsditem.hxx>
      36                 :            : #include <editeng/escpitem.hxx>
      37                 :            : #include <editeng/fontitem.hxx>
      38                 :            : #include <editeng/fhgtitem.hxx>
      39                 :            : #include <editeng/kernitem.hxx>
      40                 :            : #include <editeng/charreliefitem.hxx>
      41                 :            : #include <editeng/langitem.hxx>
      42                 :            : #include <editeng/postitem.hxx>
      43                 :            : #include <editeng/shdditem.hxx>
      44                 :            : #include <editeng/udlnitem.hxx>
      45                 :            : #include <editeng/wghtitem.hxx>
      46                 :            : #include <editeng/wrlmitem.hxx>
      47                 :            : #include <editeng/akrnitem.hxx>
      48                 :            : #include <editeng/blnkitem.hxx>
      49                 :            : #include <editeng/charrotateitem.hxx>
      50                 :            : #include <editeng/emphitem.hxx>
      51                 :            : #include <editeng/charscaleitem.hxx>
      52                 :            : #include <editeng/twolinesitem.hxx>
      53                 :            : #include <editeng/charhiddenitem.hxx>
      54                 :            : #include <viewopt.hxx>
      55                 :            : #include <charfmt.hxx>
      56                 :            : #include <fchrfmt.hxx>
      57                 :            : #include <fmtautofmt.hxx>
      58                 :            : #include <editeng/brshitem.hxx>
      59                 :            : #include <fmtinfmt.hxx>
      60                 :            : #include <txtinet.hxx>
      61                 :            : #include <IDocumentSettingAccess.hxx>
      62                 :            : #include <viewsh.hxx>   // ViewShell
      63                 :            : #include <viewopt.hxx>  // SwViewOptions
      64                 :            : 
      65                 :            : #define STACK_INCREMENT 4
      66                 :            : 
      67                 :            : /*************************************************************************
      68                 :            :  *                      Attribute to Stack Mapping
      69                 :            :  *
      70                 :            :  * Attributes applied to a text are pushed on different stacks. For each
      71                 :            :  * stack, the top most attribute on the stack is valid. Because some
      72                 :            :  * kinds of attributes have to be pushed to the same stacks we map their
      73                 :            :  * ids to stack ids
      74                 :            :  * Attention: The first NUM_DEFAULT_VALUES ( defined in swfntcch.hxx == 35 )
      75                 :            :  * are stored in the defaultitem-cache, if you add one, you have to increase
      76                 :            :  * NUM_DEFAULT_VALUES.
      77                 :            :  * Also adjust NUM_ATTRIBUTE_STACKS in atrhndl.hxx.
      78                 :            :  *************************************************************************/
      79                 :            : 
      80                 :            : const sal_uInt8 StackPos[ static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) -
      81                 :            :                      static_cast<sal_uInt16>(RES_CHRATR_BEGIN) + 1 ] =
      82                 :            : {
      83                 :            :      0, //                                       //  0
      84                 :            :      1, // RES_CHRATR_CASEMAP = RES_CHRATR_BEGIN //  1
      85                 :            :      0, // RES_CHRATR_CHARSETCOLOR,              //  2
      86                 :            :      2, // RES_CHRATR_COLOR,                     //  3
      87                 :            :      3, // RES_CHRATR_CONTOUR,                   //  4
      88                 :            :      4, // RES_CHRATR_CROSSEDOUT,                //  5
      89                 :            :      5, // RES_CHRATR_ESCAPEMENT,                //  6
      90                 :            :      6, // RES_CHRATR_FONT,                      //  7
      91                 :            :      7, // RES_CHRATR_FONTSIZE,                  //  8
      92                 :            :      8, // RES_CHRATR_KERNING,                   //  9
      93                 :            :      9, // RES_CHRATR_LANGUAGE,                  // 10
      94                 :            :     10, // RES_CHRATR_POSTURE,                   // 11
      95                 :            :      0, // RES_CHRATR_PROPORTIONALFONTSIZE,      // 12
      96                 :            :     11, // RES_CHRATR_SHADOWED,                  // 13
      97                 :            :     12, // RES_CHRATR_UNDERLINE,                 // 14
      98                 :            :     13, // RES_CHRATR_WEIGHT,                    // 15
      99                 :            :     14, // RES_CHRATR_WORDLINEMODE,              // 16
     100                 :            :     15, // RES_CHRATR_AUTOKERN,                  // 17
     101                 :            :     16, // RES_CHRATR_BLINK,                     // 18
     102                 :            :     17, // RES_CHRATR_NOHYPHEN,                  // 19
     103                 :            :      0, // RES_CHRATR_NOLINEBREAK,               // 20
     104                 :            :     18, // RES_CHRATR_BACKGROUND,                // 21
     105                 :            :     19, // RES_CHRATR_CJK_FONT,                  // 22
     106                 :            :     20, // RES_CHRATR_CJK_FONTSIZE,              // 23
     107                 :            :     21, // RES_CHRATR_CJK_LANGUAGE,              // 24
     108                 :            :     22, // RES_CHRATR_CJK_POSTURE,               // 25
     109                 :            :     23, // RES_CHRATR_CJK_WEIGHT,                // 26
     110                 :            :     24, // RES_CHRATR_CTL_FONT,                  // 27
     111                 :            :     25, // RES_CHRATR_CTL_FONTSIZE,              // 28
     112                 :            :     26, // RES_CHRATR_CTL_LANGUAGE,              // 29
     113                 :            :     27, // RES_CHRATR_CTL_POSTURE,               // 30
     114                 :            :     28, // RES_CHRATR_CTL_WEIGHT,                // 31
     115                 :            :     29, // RES_CHRATR_ROTATE,                    // 32
     116                 :            :     30, // RES_CHRATR_EMPHASIS_MARK,             // 33
     117                 :            :     31, // RES_CHRATR_TWO_LINES,                 // 34
     118                 :            :     32, // RES_CHRATR_SCALEW,                    // 35
     119                 :            :     33, // RES_CHRATR_RELIEF,                    // 36
     120                 :            :     34, // RES_CHRATR_HIDDEN,                    // 37
     121                 :            :     35, // RES_CHRATR_OVERLINE,                  // 38
     122                 :            :      0, // RES_CHRATR_RSID,                      // 39
     123                 :            :      0, // RES_DUMMY1,                           // 40
     124                 :            :     36, // RES_TXTATR_REFMARK,                   // 41
     125                 :            :     37, // RES_TXTATR_TOXMARK,                   // 42
     126                 :            :     38, // RES_TXTATR_META,                      // 43
     127                 :            :     38, // RES_TXTATR_METAFIELD,                 // 44
     128                 :            :      0, // RES_TXTATR_AUTOFMT,                   // 45
     129                 :            :      0, // RES_TXTATR_INETFMT                    // 46
     130                 :            :      0, // RES_TXTATR_CHARFMT,                   // 47
     131                 :            :     39, // RES_TXTATR_CJK_RUBY,                  // 48
     132                 :            :      0, // RES_TXTATR_UNKNOWN_CONTAINER,         // 49
     133                 :            :      0, // RES_TXTATR_DUMMY5                     // 50
     134                 :            : };
     135                 :            : 
     136                 :            : /*************************************************************************
     137                 :            :  *                      CharFmt::GetItem
     138                 :            :  * returns the item set associated with an character/inet/auto style
     139                 :            :  *************************************************************************/
     140                 :            : 
     141                 :            : namespace CharFmt
     142                 :            : {
     143                 :            : 
     144                 :      44611 : const SfxItemSet* GetItemSet( const SfxPoolItem& rAttr )
     145                 :            : {
     146                 :      44611 :     const SfxItemSet* pSet = 0;
     147                 :            : 
     148         [ +  + ]:      44611 :     if ( RES_TXTATR_AUTOFMT == rAttr.Which() )
     149                 :            :     {
     150                 :      38115 :         pSet = static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle().get();
     151                 :            :     }
     152                 :            :     else
     153                 :            :     {
     154                 :            :         // Get the attributes from the template
     155                 :       6496 :         SwCharFmt* pFmt = RES_TXTATR_INETFMT == rAttr.Which() ?
     156                 :       3757 :                         ((SwFmtINetFmt&)rAttr).GetTxtINetFmt()->GetCharFmt() :
     157         [ +  + ]:      10253 :                         ((SwFmtCharFmt&)rAttr).GetCharFmt();
     158         [ +  + ]:       6496 :         if( pFmt )
     159                 :            :         {
     160                 :       6093 :             pSet = &pFmt->GetAttrSet();
     161                 :            :         }
     162                 :            :     }
     163                 :            : 
     164                 :      44611 :     return pSet;
     165                 :            : }
     166                 :            : 
     167                 :            : /*************************************************************************
     168                 :            :  *                      CharFmt::GetItem
     169                 :            :  * extracts pool item of type nWhich from rAttr
     170                 :            :  *************************************************************************/
     171                 :            : 
     172                 :      32748 : const SfxPoolItem* GetItem( const SwTxtAttr& rAttr, sal_uInt16 nWhich )
     173                 :            : {
     174   [ +  +  +  +  :      94747 :     if ( RES_TXTATR_INETFMT == rAttr.Which() ||
           +  + ][ +  + ]
     175                 :      31482 :          RES_TXTATR_CHARFMT == rAttr.Which() ||
     176                 :      30517 :          RES_TXTATR_AUTOFMT == rAttr.Which() )
     177                 :            :     {
     178         [ +  - ]:      22339 :         const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
     179         [ +  + ]:      22339 :         if ( !pSet ) return 0;
     180                 :            : 
     181         [ +  - ]:      22255 :        bool bInParent = RES_TXTATR_AUTOFMT != rAttr.Which();
     182                 :            :        const SfxPoolItem* pItem;
     183         [ +  - ]:      22255 :        sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( nWhich, bInParent, &pItem );
     184                 :            : 
     185         [ +  + ]:      22339 :        return bRet ? pItem : 0;
     186                 :            :     }
     187                 :            : 
     188         [ -  + ]:      32748 :     return ( nWhich == rAttr.Which() ) ? &rAttr.GetAttr() : 0;
     189                 :            : }
     190                 :            : 
     191                 :            : /*************************************************************************
     192                 :            :  *                      CharFmt::IsItemIncluded
     193                 :            :  * checks if item is included in character/inet/auto style
     194                 :            :  *************************************************************************/
     195                 :            : 
     196                 :       3264 : sal_Bool IsItemIncluded( const sal_uInt16 nWhich, const SwTxtAttr *pAttr )
     197                 :            : {
     198                 :       3264 :     sal_Bool bRet = sal_False;
     199                 :            : 
     200                 :       3264 :     const SfxItemSet* pItemSet = CharFmt::GetItemSet( pAttr->GetAttr() );
     201         [ +  + ]:       3264 :     if ( pItemSet )
     202                 :       3200 :         bRet = SFX_ITEM_SET == pItemSet->GetItemState( nWhich, sal_True );
     203                 :            : 
     204                 :       3264 :     return bRet;
     205                 :            : }
     206                 :            : 
     207                 :            : }
     208                 :            : 
     209                 :            : /*************************************************************************
     210                 :            :  *                      lcl_ChgHyperLinkColor
     211                 :            :  * The color of hyperlinks is taken from the associated character attribute,
     212                 :            :  * depending on its 'visited' state. There are actually two cases, which
     213                 :            :  * should override the colors from the character attribute:
     214                 :            :  * 1. We never take the 'visited' color during printing/pdf export/preview
     215                 :            :  * 2. The user has choosen to override these colors in the view options
     216                 :            :  *************************************************************************/
     217                 :            : 
     218                 :      19276 : bool lcl_ChgHyperLinkColor( const SwTxtAttr& rAttr,
     219                 :            :                             const SfxPoolItem& rItem,
     220                 :            :                             const ViewShell* pShell,
     221                 :            :                             Color* pColor )
     222                 :            : {
     223   [ +  -  +  +  :      41842 :     if ( !pShell ||
           +  + ][ +  + ]
     224                 :      19276 :          RES_TXTATR_INETFMT != rAttr.Which() ||
     225                 :       3290 :          RES_CHRATR_COLOR != rItem.Which() )
     226                 :      18618 :         return false;
     227                 :            : 
     228                 :            :     // #i15455#
     229                 :            :     // 1. case:
     230                 :            :     // We do not want to show visited links:
     231                 :            :     // (printing, pdf export, page preview)
     232                 :            :     //
     233   [ +  -  +  -  :       1974 :     if ( pShell->GetOut()->GetOutDevType() == OUTDEV_PRINTER ||
           -  + ][ -  + ]
     234                 :        658 :          pShell->GetViewOptions()->IsPDFExport() ||
     235                 :        658 :          pShell->GetViewOptions()->IsPagePreview() )
     236                 :            :     {
     237         [ #  # ]:          0 :         if ( ((SwTxtINetFmt&)rAttr).IsVisited() )
     238                 :            :         {
     239         [ #  # ]:          0 :             if ( pColor )
     240                 :            :             {
     241                 :            :                 // take color from character format 'unvisited link'
     242                 :            :                 SwTxtINetFmt& rInetAttr( const_cast<SwTxtINetFmt&>(
     243                 :          0 :                     static_cast<const SwTxtINetFmt&>(rAttr)) );
     244                 :          0 :                 rInetAttr.SetVisited( false );
     245         [ #  # ]:          0 :                 const SwCharFmt* pTmpFmt = ((SwTxtINetFmt&)rAttr).GetCharFmt();
     246                 :            :                 const SfxPoolItem* pItem;
     247         [ #  # ]:          0 :                 pTmpFmt->GetItemState( RES_CHRATR_COLOR, sal_True, &pItem );
     248                 :          0 :                 *pColor = ((SvxColorItem*)pItem)->GetValue();
     249                 :          0 :                 rInetAttr.SetVisited( true );
     250                 :            :             }
     251                 :          0 :             return true;
     252                 :            :         }
     253                 :            : 
     254                 :          0 :         return false;
     255                 :            :     }
     256                 :            : 
     257                 :            :     //
     258                 :            :     // 2. case:
     259                 :            :     // We do not want to apply the color set in the hyperlink
     260                 :            :     // attribute, instead we take the colors from the view options:
     261                 :            :     //
     262   [ +  -  -  +  :       2632 :     if ( pShell->GetWin() &&
          #  #  +  -  -  
              + ][ -  + ]
     263                 :            :         (
     264                 :        658 :           (((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsVisitedLinks()) ||
     265                 :       1316 :           (!((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsLinks())
     266                 :            :         )
     267                 :            :        )
     268                 :            :     {
     269         [ #  # ]:          0 :         if ( pColor )
     270                 :            :         {
     271         [ #  # ]:          0 :             if ( ((SwTxtINetFmt&)rAttr).IsVisited() )
     272                 :            :             {
     273                 :            :                 // take color from view option 'visited link color'
     274                 :          0 :                 *pColor = SwViewOption::GetVisitedLinksColor();
     275                 :            :             }
     276                 :            :             else
     277                 :            :             {
     278                 :            :                 // take color from view option 'unvisited link color'
     279                 :          0 :                 *pColor = SwViewOption::GetLinksColor();
     280                 :            :             }
     281                 :            :         }
     282                 :          0 :         return true;
     283                 :            :     }
     284                 :            : 
     285                 :      19276 :     return false;
     286                 :            : }
     287                 :            : 
     288                 :            : /*************************************************************************
     289                 :            :  *                      SwAttrHandler::SwAttrStack::SwAttrStack()
     290                 :            :  *************************************************************************/
     291                 :            : 
     292                 :    3788240 : inline SwAttrHandler::SwAttrStack::SwAttrStack()
     293                 :    3788240 :     : nCount( 0 ), nSize( INITIAL_NUM_ATTR )
     294                 :            : {
     295                 :    3788240 :     pArray = pInitialArray;
     296                 :    3788240 : }
     297                 :            : 
     298                 :            : /*************************************************************************
     299                 :            :  *                      SwAttrHandler::SwAttrStack::Insert()
     300                 :            :  *************************************************************************/
     301                 :            : 
     302                 :      21980 : void SwAttrHandler::SwAttrStack::Insert( const SwTxtAttr& rAttr, const sal_uInt16 nPos )
     303                 :            : {
     304                 :            :     // do we still have enough space?
     305         [ +  + ]:      21980 :     if ( nCount >= nSize )
     306                 :            :     {
     307                 :            :          // we are still in our initial array
     308         [ +  - ]:         40 :         if ( INITIAL_NUM_ATTR == nSize )
     309                 :            :         {
     310                 :         40 :             nSize += STACK_INCREMENT;
     311                 :         40 :             pArray = new SwTxtAttr*[ nSize ];
     312                 :            :             // copy from pInitArray to new Array
     313                 :            :             memcpy( pArray, pInitialArray,
     314                 :            :                     INITIAL_NUM_ATTR * sizeof(SwTxtAttr*)
     315                 :         40 :                     );
     316                 :            :         }
     317                 :            :         // we are in new memory
     318                 :            :         else
     319                 :            :         {
     320                 :          0 :             nSize += STACK_INCREMENT;
     321                 :          0 :             SwTxtAttr** pTmpArray = new SwTxtAttr*[ nSize ];
     322                 :            :             // copy from pArray to new Array
     323                 :          0 :             memcpy( pTmpArray, pArray, nCount * sizeof(SwTxtAttr*) );
     324                 :            :             // free old array
     325         [ #  # ]:          0 :             delete [] pArray;
     326                 :          0 :             pArray = pTmpArray;
     327                 :            :         }
     328                 :            :     }
     329                 :            : 
     330                 :            :     OSL_ENSURE( nPos <= nCount, "wrong position for insert operation");
     331                 :            : 
     332         [ -  + ]:      21980 :     if ( nPos < nCount )
     333                 :          0 :         memmove( pArray + nPos + 1, pArray + nPos,
     334                 :            :                 ( nCount - nPos ) * sizeof(SwTxtAttr*)
     335                 :          0 :                 );
     336                 :      21980 :     pArray[ nPos ] = (SwTxtAttr*)&rAttr;
     337                 :            : 
     338                 :      21980 :     nCount++;
     339                 :      21980 : }
     340                 :            : 
     341                 :            : /*************************************************************************
     342                 :            :  *                      SwAttrHandler::SwAttrStack::Remove()
     343                 :            :  *************************************************************************/
     344                 :            : 
     345                 :       4466 : void SwAttrHandler::SwAttrStack::Remove( const SwTxtAttr& rAttr )
     346                 :            : {
     347                 :       4466 :     sal_uInt16 nPos = Pos( rAttr );
     348         [ +  - ]:       4466 :     if ( nPos < nCount )
     349                 :            :     {
     350                 :      13398 :         memmove( pArray + nPos, pArray + nPos + 1,
     351                 :            :                 ( nCount - 1 - nPos ) * sizeof(SwTxtAttr*)
     352                 :      17864 :                 );
     353                 :       4466 :         nCount--;
     354                 :            :     }
     355                 :       4466 : }
     356                 :            : 
     357                 :            : /*************************************************************************
     358                 :            :  *                      SwAttrHandler::SwAttrStack::Top()
     359                 :            :  *************************************************************************/
     360                 :            : 
     361                 :      32758 : const SwTxtAttr* SwAttrHandler::SwAttrStack::Top() const
     362                 :            : {
     363         [ +  + ]:      32758 :     return nCount ? pArray[ nCount - 1 ] : 0;
     364                 :            : }
     365                 :            : 
     366                 :            : /*************************************************************************
     367                 :            :  *                      SwAttrHandler::SwAttrStack::Pos()
     368                 :            :  *************************************************************************/
     369                 :            : 
     370                 :       4466 : sal_uInt16 SwAttrHandler::SwAttrStack::Pos( const SwTxtAttr& rAttr ) const
     371                 :            : {
     372         [ -  + ]:       4466 :     if ( ! nCount )
     373                 :            :         // empty stack
     374                 :          0 :         return USHRT_MAX;
     375                 :            : 
     376         [ +  - ]:       4466 :     for ( sal_uInt16 nIdx = nCount; nIdx > 0; )
     377                 :            :     {
     378         [ +  - ]:       4466 :         if ( &rAttr == pArray[ --nIdx ] )
     379                 :       4466 :             return nIdx;
     380                 :            :     }
     381                 :            : 
     382                 :            :     // element not found
     383                 :       4466 :     return USHRT_MAX;
     384                 :            : }
     385                 :            : 
     386                 :            : /*************************************************************************
     387                 :            :  *                      SwAttrHandler::SwAttrHandler()
     388                 :            :  *************************************************************************/
     389                 :            : 
     390         [ +  + ]:    3882946 : SwAttrHandler::SwAttrHandler() : mpShell( 0 ), pFnt( 0 ), bVertLayout( sal_False )
     391                 :            : 
     392                 :            : {
     393                 :      94706 :     memset( pDefaultArray, 0, NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
     394                 :      94706 : }
     395                 :            : 
     396                 :    3788240 : SwAttrHandler::~SwAttrHandler()
     397                 :            : {
     398 [ +  - ][ +  - ]:      94706 :     delete pFnt;
     399 [ +  - ][ +  + ]:    3882946 : }
           [ #  #  #  # ]
     400                 :            : 
     401                 :            : /*************************************************************************
     402                 :            :  *                      SwAttrHandler::Init()
     403                 :            :  *************************************************************************/
     404                 :            : 
     405                 :          0 : void SwAttrHandler::Init( const SwAttrSet& rAttrSet,
     406                 :            :                           const IDocumentSettingAccess& rIDocumentSettingAcces,
     407                 :            :                           const ViewShell* pSh )
     408                 :            : {
     409                 :          0 :     mpIDocumentSettingAccess = &rIDocumentSettingAcces;
     410                 :          0 :     mpShell = pSh;
     411                 :            : 
     412         [ #  # ]:          0 :     for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++ )
     413                 :          0 :         pDefaultArray[ StackPos[ i ] ] = &rAttrSet.Get( i, sal_True );
     414                 :          0 : }
     415                 :            : 
     416                 :      94706 : void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
     417                 :            :                           const IDocumentSettingAccess& rIDocumentSettingAcces,
     418                 :            :                           const ViewShell* pSh,
     419                 :            :                           SwFont& rFnt, sal_Bool bVL )
     420                 :            : {
     421                 :            :     // initialize default array
     422                 :            :     memcpy( pDefaultArray, pPoolItem,
     423                 :      94706 :             NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
     424                 :            : 
     425                 :      94706 :     mpIDocumentSettingAccess = &rIDocumentSettingAcces;
     426                 :      94706 :     mpShell = pSh;
     427                 :            : 
     428                 :            :     // do we have to apply additional paragraph attributes?
     429                 :      94706 :     bVertLayout = bVL;
     430                 :            : 
     431 [ +  + ][ +  - ]:      94706 :     if ( pAS && pAS->Count() )
                 [ +  + ]
     432                 :            :     {
     433         [ +  - ]:      14499 :         SfxItemIter aIter( *pAS );
     434                 :            :         sal_uInt16 nWhich;
     435                 :      14499 :         const SfxPoolItem* pItem = aIter.GetCurItem();
     436                 :      86187 :         while( sal_True )
     437                 :            :         {
     438                 :     100686 :             nWhich = pItem->Which();
     439         [ +  + ]:     100686 :             if (isCHRATR(nWhich))
     440                 :            :             {
     441                 :      51489 :                 pDefaultArray[ StackPos[ nWhich ] ] = pItem;
     442         [ +  - ]:      51489 :                 FontChg( *pItem, rFnt, sal_True );
     443                 :            :             }
     444                 :            : 
     445         [ +  + ]:     100686 :             if( aIter.IsAtEnd() )
     446                 :      14499 :                 break;
     447                 :            : 
     448         [ +  - ]:      86187 :             pItem = aIter.NextItem();
     449         [ +  - ]:      14499 :         }
     450                 :            :     }
     451                 :            : 
     452                 :            :     // It is possible, that Init is called more than once, e.g., in a
     453                 :            :     // SwTxtFrm::FormatOnceMore situation.
     454         [ -  + ]:      94706 :     delete pFnt;
     455         [ +  - ]:      94706 :     pFnt = new SwFont( rFnt );
     456                 :      94706 : }
     457                 :            : 
     458                 :       8426 : void SwAttrHandler::Reset( )
     459                 :            : {
     460         [ +  + ]:     345466 :     for ( sal_uInt16 i = 0; i < NUM_ATTRIBUTE_STACKS; i++ )
     461                 :     337040 :         aAttrStack[ i ].Reset();
     462                 :       8426 : }
     463                 :            : 
     464                 :            : /*************************************************************************
     465                 :            :  *                      SwAttrHandler::PushAndChg()
     466                 :            :  *************************************************************************/
     467                 :            : 
     468                 :       6699 : void SwAttrHandler::PushAndChg( const SwTxtAttr& rAttr, SwFont& rFnt )
     469                 :            : {
     470                 :            :     // these special attributes in fact represent a collection of attributes
     471                 :            :     // they have to be pushed to each stack they belong to
     472   [ +  +  +  +  :      17586 :     if ( RES_TXTATR_INETFMT == rAttr.Which() ||
           +  + ][ +  + ]
     473                 :       5917 :          RES_TXTATR_CHARFMT == rAttr.Which() ||
     474                 :       4970 :          RES_TXTATR_AUTOFMT == rAttr.Which() )
     475                 :            :     {
     476                 :       3372 :         const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
     477         [ +  + ]:       9947 :         if ( !pSet ) return;
     478                 :            : 
     479         [ +  + ]:     133168 :         for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
     480                 :            :         {
     481                 :            :             const SfxPoolItem* pItem;
     482 [ +  - ][ +  - ]:     129920 :             sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( i, rAttr.Which() != RES_TXTATR_AUTOFMT, &pItem );
     483                 :            : 
     484         [ +  + ]:     129920 :             if ( bRet )
     485                 :            :             {
     486                 :            :                 // we push rAttr onto the appropriate stack
     487 [ +  - ][ +  - ]:      18653 :                 if ( Push( rAttr, *pItem ) )
     488                 :            :                 {
     489                 :            :                     // we let pItem change rFnt
     490                 :      18653 :                     Color aColor;
     491 [ -  + ][ +  - ]:      18653 :                     if ( lcl_ChgHyperLinkColor( rAttr, *pItem, mpShell, &aColor ) )
     492                 :            :                     {
     493         [ #  # ]:          0 :                         SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
     494 [ #  # ][ #  # ]:          0 :                         FontChg( aItemNext, rFnt, sal_True );
     495                 :            :                     }
     496                 :            :                     else
     497         [ +  - ]:      18653 :                         FontChg( *pItem, rFnt, sal_True );
     498                 :            :                 }
     499                 :            :             }
     500                 :            :         }
     501                 :            :     }
     502                 :            :     // this is the usual case, we have a basic attribute, push it onto the
     503                 :            :     // stack and change the font
     504                 :            :     else
     505                 :            :     {
     506         [ +  - ]:       3327 :         if ( Push( rAttr, rAttr.GetAttr() ) )
     507                 :            :             // we let pItem change rFnt
     508                 :       3327 :             FontChg( rAttr.GetAttr(), rFnt, sal_True );
     509                 :            :     }
     510                 :            : }
     511                 :            : 
     512                 :            : /*************************************************************************
     513                 :            :  *                      SwAttrHandler::Push()
     514                 :            :  *************************************************************************/
     515                 :            : 
     516                 :      21980 : sal_Bool SwAttrHandler::Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem )
     517                 :            : {
     518                 :            :     OSL_ENSURE( rItem.Which() < RES_TXTATR_WITHEND_END,
     519                 :            :             "I do not want this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
     520                 :            : 
     521                 :            :     // robust
     522         [ -  + ]:      21980 :     if ( RES_TXTATR_WITHEND_END <= rItem.Which() )
     523                 :          0 :         return sal_False;
     524                 :            : 
     525                 :      21980 :     sal_uInt16 nStack = StackPos[ rItem.Which() ];
     526                 :            : 
     527                 :            :     // attributes originating from redlining have highest priority
     528                 :            :     // second priority are hyperlink attributes, which have a color replacement
     529                 :      21980 :     const SwTxtAttr* pTopAttr = aAttrStack[ nStack ].Top();
     530   [ +  -  +  -  :      23102 :     if ( !pTopAttr || rAttr.IsPriorityAttr() ||
           +  - ][ +  - ]
                 [ +  + ]
     531                 :        561 :             ( !pTopAttr->IsPriorityAttr() &&
     532                 :        561 :               !lcl_ChgHyperLinkColor( *pTopAttr, rItem, mpShell, 0 ) ) )
     533                 :            :     {
     534                 :      21980 :         aAttrStack[ nStack ].Push( rAttr );
     535                 :      21980 :         return sal_True;
     536                 :            :     }
     537                 :            : 
     538                 :          0 :     sal_uInt16 nPos = aAttrStack[ nStack ].Count();
     539                 :            :     OSL_ENSURE( nPos, "empty stack?" );
     540                 :          0 :     aAttrStack[ nStack ].Insert( rAttr, nPos - 1 );
     541                 :      21980 :     return sal_False;
     542                 :            : }
     543                 :            : 
     544                 :            : /*************************************************************************
     545                 :            :  *                      SwAttrHandler::PopAndChg()
     546                 :            :  *************************************************************************/
     547                 :            : 
     548                 :       2340 : void SwAttrHandler::PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt )
     549                 :            : {
     550         [ -  + ]:       2340 :     if ( RES_TXTATR_WITHEND_END <= rAttr.Which() )
     551                 :          0 :         return; // robust
     552                 :            : 
     553                 :            :     // these special attributes in fact represent a collection of attributes
     554                 :            :     // they have to be removed from each stack they belong to
     555   [ +  +  +  +  :       6086 :     if ( RES_TXTATR_INETFMT == rAttr.Which() ||
           +  + ][ +  + ]
     556                 :       1924 :          RES_TXTATR_CHARFMT == rAttr.Which() ||
     557                 :       1822 :          RES_TXTATR_AUTOFMT == rAttr.Which() )
     558                 :            :     {
     559                 :        628 :         const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
     560         [ +  + ]:        628 :         if ( !pSet ) return;
     561                 :            : 
     562         [ +  + ]:      24764 :         for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
     563                 :            :         {
     564                 :            :             const SfxPoolItem* pItem;
     565 [ +  - ][ +  - ]:      24160 :             sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( i, RES_TXTATR_AUTOFMT != rAttr.Which(), &pItem );
     566         [ +  + ]:      24160 :             if ( bRet )
     567                 :            :             {
     568                 :            :                 // we remove rAttr from the appropriate stack
     569                 :       2754 :                 sal_uInt16 nStackPos = StackPos[ i ];
     570         [ +  - ]:       2754 :                 aAttrStack[ nStackPos ].Remove( rAttr );
     571                 :            :                 // reset font according to attribute on top of stack
     572                 :            :                 // or default value
     573         [ +  - ]:       2754 :                 ActivateTop( rFnt, i );
     574                 :            :             }
     575                 :            :         }
     576                 :            :     }
     577                 :            :     // this is the usual case, we have a basic attribute, remove it from the
     578                 :            :     // stack and reset the font
     579                 :            :     else
     580                 :            :     {
     581                 :       1712 :         aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr );
     582                 :            :         // reset font according to attribute on top of stack
     583                 :            :         // or default value
     584                 :       2340 :         ActivateTop( rFnt, rAttr.Which() );
     585                 :            :     }
     586                 :            : }
     587                 :            : 
     588                 :            : /*************************************************************************
     589                 :            :  *                      SwAttrHandler::Pop()
     590                 :            :  *
     591                 :            :  * only used during redlining
     592                 :            :  *************************************************************************/
     593                 :            : 
     594                 :          0 : void SwAttrHandler::Pop( const SwTxtAttr& rAttr )
     595                 :            : {
     596                 :            :     OSL_ENSURE( rAttr.Which() < RES_TXTATR_WITHEND_END,
     597                 :            :             "I do not have this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
     598                 :            : 
     599         [ #  # ]:          0 :     if ( rAttr.Which() < RES_TXTATR_WITHEND_END )
     600                 :            :     {
     601                 :          0 :         aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr );
     602                 :            :     }
     603                 :          0 : }
     604                 :            : 
     605                 :            : /*************************************************************************
     606                 :            :  *                      SwAttrHandler::ActivateTop()
     607                 :            :  *************************************************************************/
     608                 :       4528 : void SwAttrHandler::ActivateTop( SwFont& rFnt, const sal_uInt16 nAttr )
     609                 :            : {
     610                 :            :     OSL_ENSURE( nAttr < RES_TXTATR_WITHEND_END,
     611                 :            :             "I cannot activate this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
     612                 :            : 
     613                 :       4528 :     const sal_uInt16 nStackPos = StackPos[ nAttr ];
     614                 :       4528 :     const SwTxtAttr* pTopAt = aAttrStack[ nStackPos ].Top();
     615         [ +  + ]:       4528 :     if ( pTopAt )
     616                 :            :     {
     617                 :            :         // check if top attribute is collection of attributes
     618   [ +  -  +  +  :        889 :         if ( RES_TXTATR_INETFMT == pTopAt->Which() ||
           -  + ][ +  + ]
     619                 :        317 :              RES_TXTATR_CHARFMT == pTopAt->Which() ||
     620                 :        255 :              RES_TXTATR_AUTOFMT == pTopAt->Which() )
     621                 :            :         {
     622         [ +  - ]:         62 :             const SfxItemSet* pSet = CharFmt::GetItemSet( pTopAt->GetAttr() );
     623                 :            :             const SfxPoolItem* pItemNext;
     624 [ +  - ][ +  - ]:         62 :             pSet->GetItemState( nAttr, RES_TXTATR_AUTOFMT != pTopAt->Which(), &pItemNext );
     625                 :            : 
     626                 :         62 :             Color aColor;
     627 [ -  + ][ +  - ]:         62 :             if ( lcl_ChgHyperLinkColor( *pTopAt, *pItemNext, mpShell, &aColor ) )
     628                 :            :             {
     629         [ #  # ]:          0 :                 SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
     630 [ #  # ][ #  # ]:          0 :                 FontChg( aItemNext, rFnt, sal_False );
     631                 :            :             }
     632                 :            :             else
     633         [ +  - ]:         62 :                 FontChg( *pItemNext, rFnt, sal_False );
     634                 :            :         }
     635                 :            :         else
     636                 :        255 :             FontChg( pTopAt->GetAttr(), rFnt, sal_False );
     637                 :            :     }
     638                 :            : 
     639                 :            :     // default value has to be set, we only have default values for char attribs
     640         [ +  + ]:       4211 :     else if ( nStackPos < NUM_DEFAULT_VALUES )
     641                 :       2754 :         FontChg( *pDefaultArray[ nStackPos ], rFnt, sal_False );
     642         [ +  + ]:       1457 :     else if ( RES_TXTATR_REFMARK == nAttr )
     643                 :         21 :         rFnt.GetRef()--;
     644         [ +  + ]:       1436 :     else if ( RES_TXTATR_TOXMARK == nAttr )
     645                 :         20 :         rFnt.GetTox()--;
     646 [ +  + ][ +  + ]:       1416 :     else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) )
     647                 :            :     {
     648                 :        887 :         rFnt.GetMeta()--;
     649                 :            :     }
     650         [ +  - ]:        529 :     else if ( RES_TXTATR_CJK_RUBY == nAttr )
     651                 :            :     {
     652                 :            :         // ruby stack has no more attributes
     653                 :            :         // check, if an rotation attribute has to be applied
     654                 :        529 :         sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
     655                 :        529 :         sal_Bool bTwoLineAct = sal_False;
     656                 :        529 :         const SfxPoolItem* pTwoLineItem = 0;
     657                 :        529 :         const SwTxtAttr* pTwoLineAttr = aAttrStack[ nTwoLineStack ].Top();
     658                 :            : 
     659         [ -  + ]:        529 :         if ( pTwoLineAttr )
     660                 :            :         {
     661                 :          0 :              pTwoLineItem = CharFmt::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
     662                 :          0 :              bTwoLineAct = ((SvxTwoLinesItem*)pTwoLineItem)->GetValue();
     663                 :            :         }
     664                 :            :         else
     665                 :            :             bTwoLineAct =
     666                 :        529 :                 ((SvxTwoLinesItem*)pDefaultArray[ nTwoLineStack ])->GetValue();
     667                 :            : 
     668         [ -  + ]:        529 :         if ( bTwoLineAct )
     669                 :       4528 :             return;
     670                 :            : 
     671                 :            :         // eventually, an rotate attribute has to be activated
     672                 :        529 :         sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
     673                 :        529 :         const SfxPoolItem* pRotateItem = 0;
     674                 :        529 :         const SwTxtAttr* pRotateAttr = aAttrStack[ nRotateStack ].Top();
     675                 :            : 
     676         [ -  + ]:        529 :         if ( pRotateAttr )
     677                 :            :         {
     678                 :          0 :             pRotateItem = CharFmt::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
     679                 :          0 :             rFnt.SetVertical( ((SvxCharRotateItem*)pRotateItem)->GetValue(),
     680                 :          0 :                                bVertLayout );
     681                 :            :         }
     682                 :            :         else
     683                 :            :             rFnt.SetVertical(
     684                 :        529 :                 ((SvxCharRotateItem*)pDefaultArray[ nRotateStack ])->GetValue(),
     685                 :            :                  bVertLayout
     686                 :        529 :             );
     687                 :            :     }
     688                 :            : }
     689                 :            : 
     690                 :            : /*************************************************************************
     691                 :            :  *                      Font Changing Function
     692                 :            :  *
     693                 :            :  * When popping an attribute from the stack, the top mose remaining
     694                 :            :  * attribute in the stack becomes valid. The following function change
     695                 :            :  * a font depending on the stack id.
     696                 :            :  *************************************************************************/
     697                 :            : 
     698                 :      76540 : void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPush )
     699                 :            : {
     700   [ +  +  +  +  :      76540 :     switch ( rItem.Which() )
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
             +  +  +  +  
                      + ]
     701                 :            :     {
     702                 :            :         case RES_CHRATR_CASEMAP :
     703                 :       2736 :             rFnt.SetCaseMap( ((SvxCaseMapItem&)rItem).GetCaseMap() );
     704                 :       2736 :             break;
     705                 :            :         case RES_CHRATR_COLOR :
     706                 :       4506 :             rFnt.SetColor( ((SvxColorItem&)rItem).GetValue() );
     707                 :       4506 :             break;
     708                 :            :         case RES_CHRATR_CONTOUR :
     709                 :       1994 :             rFnt.SetOutline( ((SvxContourItem&)rItem).GetValue() );
     710                 :       1994 :             break;
     711                 :            :         case RES_CHRATR_CROSSEDOUT :
     712                 :       2672 :             rFnt.SetStrikeout( ((SvxCrossedOutItem&)rItem).GetStrikeout() );
     713                 :       2672 :             break;
     714                 :            :         case RES_CHRATR_ESCAPEMENT :
     715                 :       3401 :             rFnt.SetEscapement( ((SvxEscapementItem&)rItem).GetEsc() );
     716                 :       3401 :             rFnt.SetProportion( ((SvxEscapementItem&)rItem).GetProp() );
     717                 :       3401 :             break;
     718                 :            :         case RES_CHRATR_FONT :
     719                 :       4368 :             rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_LATIN );
     720                 :       4368 :             rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_LATIN );
     721                 :       4368 :             rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_LATIN );
     722                 :       4368 :             rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_LATIN );
     723                 :       4368 :             rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_LATIN );
     724                 :       4368 :             break;
     725                 :            :         case RES_CHRATR_FONTSIZE :
     726         [ +  - ]:       4524 :             rFnt.SetSize(Size(0,((SvxFontHeightItem&)rItem).GetHeight() ), SW_LATIN );
     727                 :       4524 :             break;
     728                 :            :         case RES_CHRATR_KERNING :
     729                 :       2390 :             rFnt.SetFixKerning( ((SvxKerningItem&)rItem).GetValue() );
     730                 :       2390 :             break;
     731                 :            :         case RES_CHRATR_LANGUAGE :
     732                 :       4387 :             rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_LATIN );
     733                 :       4387 :             break;
     734                 :            :         case RES_CHRATR_POSTURE :
     735                 :       3798 :             rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_LATIN );
     736                 :       3798 :             break;
     737                 :            :         case RES_CHRATR_SHADOWED :
     738                 :       2270 :             rFnt.SetShadow( ((SvxShadowedItem&)rItem).GetValue() );
     739                 :       2270 :             break;
     740                 :            :         case RES_CHRATR_UNDERLINE :
     741                 :            :         {
     742                 :       4344 :             const sal_uInt16 nStackPos = StackPos[ RES_CHRATR_HIDDEN ];
     743                 :       4344 :             const SwTxtAttr* pTopAt = aAttrStack[ nStackPos ].Top();
     744                 :            : 
     745                 :            :             const SfxPoolItem* pTmpItem = pTopAt ?
     746                 :            :                                           CharFmt::GetItem( *pTopAt, RES_CHRATR_HIDDEN ) :
     747         [ +  + ]:       4344 :                                           pDefaultArray[ nStackPos ];
     748                 :            : 
     749 [ +  - ][ +  - ]:       8688 :             if( (mpShell && !mpShell->GetWin()) ||
           [ +  -  +  - ]
                 [ +  - ]
     750                 :       4344 :                 (pTmpItem && !static_cast<const SvxCharHiddenItem*>(pTmpItem)->GetValue()) )
     751                 :            :             {
     752                 :       4344 :                 rFnt.SetUnderline( ((SvxUnderlineItem&)rItem).GetLineStyle() );
     753                 :       4344 :                 rFnt.SetUnderColor( ((SvxUnderlineItem&)rItem).GetColor() );
     754                 :            :             }
     755                 :       4344 :             break;
     756                 :            :         }
     757                 :            :         case RES_CHRATR_OVERLINE :
     758                 :        104 :             rFnt.SetOverline( ((SvxOverlineItem&)rItem).GetLineStyle() );
     759                 :        104 :             rFnt.SetOverColor( ((SvxOverlineItem&)rItem).GetColor() );
     760                 :        104 :             break;
     761                 :            :         case RES_CHRATR_WEIGHT :
     762                 :       1857 :             rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_LATIN );
     763                 :       1857 :             break;
     764                 :            :         case RES_CHRATR_WORDLINEMODE :
     765                 :       2450 :             rFnt.SetWordLineMode( ((SvxWordLineModeItem&)rItem).GetValue() );
     766                 :       2450 :             break;
     767                 :            :         case RES_CHRATR_AUTOKERN :
     768         [ +  + ]:       2994 :             if( ((SvxAutoKernItem&)rItem).GetValue() )
     769                 :            :             {
     770                 :        116 :                 rFnt.SetAutoKern( ( !mpIDocumentSettingAccess ||
     771                 :        116 :                                     !mpIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
     772                 :            :                                      KERNING_FONTSPECIFIC :
     773   [ +  -  +  - ]:        232 :                                      KERNING_ASIAN );
     774                 :            :             }
     775                 :            :             else
     776                 :       2878 :                 rFnt.SetAutoKern( 0 );
     777                 :       2994 :             break;
     778                 :            :         case RES_CHRATR_BLINK :
     779                 :       2590 :             rFnt.SetBlink( ((SvxBlinkItem&)rItem).GetValue() );
     780                 :       2590 :             break;
     781                 :            :         case RES_CHRATR_BACKGROUND :
     782                 :       2870 :             rFnt.SetBackColor(new Color( ((SvxBrushItem&)rItem).GetColor() ) );
     783                 :       2870 :             break;
     784                 :            :         case RES_CHRATR_CJK_FONT :
     785                 :        846 :             rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_CJK );
     786                 :        846 :             rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_CJK );
     787                 :        846 :             rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_CJK );
     788                 :        846 :             rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_CJK );
     789                 :        846 :             rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_CJK );
     790                 :        846 :             break;
     791                 :            :         case RES_CHRATR_CJK_FONTSIZE :
     792         [ +  - ]:       1840 :             rFnt.SetSize(Size( 0, ((SvxFontHeightItem&)rItem).GetHeight()), SW_CJK);
     793                 :       1840 :             break;
     794                 :            :         case RES_CHRATR_CJK_LANGUAGE :
     795                 :       2086 :             rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_CJK );
     796                 :       2086 :             break;
     797                 :            :         case RES_CHRATR_CJK_POSTURE :
     798                 :       1056 :             rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_CJK );
     799                 :       1056 :             break;
     800                 :            :         case RES_CHRATR_CJK_WEIGHT :
     801                 :        154 :             rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_CJK );
     802                 :        154 :             break;
     803                 :            :         case RES_CHRATR_CTL_FONT :
     804                 :        819 :             rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_CTL );
     805                 :        819 :             rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_CTL );
     806                 :        819 :             rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_CTL );
     807                 :        819 :             rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_CTL );
     808                 :        819 :             rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_CTL );
     809                 :        819 :             break;
     810                 :            :         case RES_CHRATR_CTL_FONTSIZE :
     811         [ +  - ]:       1413 :             rFnt.SetSize(Size(0, ((SvxFontHeightItem&)rItem).GetHeight() ), SW_CTL);
     812                 :       1413 :             break;
     813                 :            :         case RES_CHRATR_CTL_LANGUAGE :
     814                 :       1708 :             rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_CTL );
     815                 :       1708 :             break;
     816                 :            :         case RES_CHRATR_CTL_POSTURE :
     817                 :        812 :             rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_CTL );
     818                 :        812 :             break;
     819                 :            :         case RES_CHRATR_CTL_WEIGHT :
     820                 :         97 :             rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_CTL );
     821                 :         97 :             break;
     822                 :            :         case RES_CHRATR_EMPHASIS_MARK :
     823                 :            :             rFnt.SetEmphasisMark(
     824                 :       1686 :                      ((SvxEmphasisMarkItem&)rItem).GetEmphasisMark()
     825                 :       1686 :                      );
     826                 :       1686 :             break;
     827                 :            :         case RES_CHRATR_SCALEW :
     828                 :        854 :             rFnt.SetPropWidth( ((SvxCharScaleWidthItem&)rItem).GetValue() );
     829                 :        854 :             break;
     830                 :            :         case RES_CHRATR_RELIEF :
     831                 :       1584 :             rFnt.SetRelief( (FontRelief)((SvxCharReliefItem&)rItem).GetValue() );
     832                 :       1584 :             break;
     833                 :            :         case RES_CHRATR_HIDDEN :
     834 [ +  - ][ +  - ]:        126 :             if( mpShell && mpShell->GetWin())
                 [ +  - ]
     835                 :            :             {
     836         [ +  + ]:        126 :                 if ( ((SvxCharHiddenItem&)rItem).GetValue() )
     837                 :         64 :                     rFnt.SetUnderline( UNDERLINE_DOTTED );
     838                 :            :                 else
     839                 :         62 :                     ActivateTop( rFnt, RES_CHRATR_UNDERLINE );
     840                 :            :             }
     841                 :        126 :             break;
     842                 :            :         case RES_CHRATR_ROTATE :
     843                 :            :         {
     844                 :            :             // rotate attribute is applied, when:
     845                 :            :             // 1. ruby stack is empty and
     846                 :            :             // 2. top of two line stack ( or default attribute )is an
     847                 :            :             //    deactivated two line attribute
     848                 :            :             const bool bRuby =
     849                 :       1074 :                 0 != aAttrStack[ StackPos[ RES_TXTATR_CJK_RUBY ] ].Count();
     850                 :            : 
     851         [ +  + ]:       1074 :             if ( bRuby )
     852                 :        316 :                 break;
     853                 :            : 
     854                 :        758 :             sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
     855                 :        758 :             sal_Bool bTwoLineAct = sal_False;
     856                 :        758 :             const SfxPoolItem* pTwoLineItem = 0;
     857                 :        758 :             const SwTxtAttr* pTwoLineAttr = aAttrStack[ nTwoLineStack ].Top();
     858                 :            : 
     859         [ -  + ]:        758 :             if ( pTwoLineAttr )
     860                 :            :             {
     861                 :          0 :                 pTwoLineItem = CharFmt::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
     862                 :          0 :                 bTwoLineAct = ((SvxTwoLinesItem*)pTwoLineItem)->GetValue();
     863                 :            :             }
     864                 :            :             else
     865                 :            :                 bTwoLineAct =
     866                 :        758 :                     ((SvxTwoLinesItem*)pDefaultArray[ nTwoLineStack ])->GetValue();
     867                 :            : 
     868         [ +  - ]:        758 :             if ( !bTwoLineAct )
     869                 :        758 :                 rFnt.SetVertical( ((SvxCharRotateItem&)rItem).GetValue(),
     870                 :        758 :                                    bVertLayout );
     871                 :            : 
     872                 :        758 :             break;
     873                 :            :         }
     874                 :            :         case RES_CHRATR_TWO_LINES :
     875                 :            :         {
     876                 :            :             sal_Bool bRuby = 0 !=
     877                 :       1960 :                     aAttrStack[ StackPos[ RES_TXTATR_CJK_RUBY ] ].Count();
     878                 :       1960 :             sal_Bool bTwoLineAct = sal_False;
     879                 :            : 
     880                 :            :             // two line is activated, if
     881                 :            :             // 1. no ruby attribute is set and
     882                 :            :             // 2. attribute is active
     883                 :       1960 :             bTwoLineAct = ((SvxTwoLinesItem&)rItem).GetValue();
     884                 :            : 
     885 [ +  + ][ +  + ]:       1960 :             if ( !bRuby && bTwoLineAct )
     886                 :            :             {
     887                 :       1482 :                 rFnt.SetVertical( 0, bVertLayout );
     888                 :       1482 :                 break;
     889                 :            :             }
     890                 :            : 
     891                 :            :             // a deactivating two line attribute is on top of stack,
     892                 :            :             // check if rotate attribute has to be enabled
     893         [ +  + ]:        478 :             if ( bRuby )
     894                 :        388 :                 break;
     895                 :            : 
     896                 :         90 :             sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
     897                 :         90 :             const SfxPoolItem* pRotateItem = 0;
     898                 :         90 :             const SwTxtAttr* pRotateAttr = aAttrStack[ nRotateStack ].Top();
     899                 :            : 
     900         [ +  + ]:         90 :             if ( pRotateAttr )
     901                 :            :             {
     902                 :         62 :                 pRotateItem = CharFmt::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
     903                 :         62 :                 rFnt.SetVertical( ((SvxCharRotateItem*)pRotateItem)->GetValue(),
     904                 :         62 :                                    bVertLayout );
     905                 :            :             }
     906                 :            :             else
     907                 :            :                 rFnt.SetVertical(
     908                 :         28 :                     ((SvxCharRotateItem*)pDefaultArray[ nRotateStack ])->GetValue(),
     909                 :            :                      bVertLayout
     910                 :         28 :                 );
     911                 :         90 :             break;
     912                 :            :         }
     913                 :            :         case RES_TXTATR_CJK_RUBY :
     914                 :       1634 :             rFnt.SetVertical( 0, bVertLayout );
     915                 :       1634 :             break;
     916                 :            :         case RES_TXTATR_REFMARK :
     917         [ +  + ]:        291 :             if ( bPush )
     918                 :        267 :                 rFnt.GetRef()++;
     919                 :            :             else
     920                 :         24 :                 rFnt.GetRef()--;
     921                 :        291 :             break;
     922                 :            :         case RES_TXTATR_TOXMARK :
     923         [ +  + ]:        303 :             if ( bPush )
     924                 :        279 :                 rFnt.GetTox()++;
     925                 :            :             else
     926                 :         24 :                 rFnt.GetTox()--;
     927                 :        303 :             break;
     928                 :            :         case RES_TXTATR_META:
     929                 :            :         case RES_TXTATR_METAFIELD:
     930         [ +  + ]:       1354 :             if ( bPush )
     931                 :       1147 :                 rFnt.GetMeta()++;
     932                 :            :             else
     933                 :        207 :                 rFnt.GetMeta()--;
     934                 :       1354 :             break;
     935                 :            :     }
     936                 :      76540 : }
     937                 :            : 
     938                 :            : // Takes the default font and calculated the ascent and height
     939                 :         27 : void SwAttrHandler::GetDefaultAscentAndHeight( ViewShell* pShell, OutputDevice& rOut,
     940                 :            :                                                sal_uInt16& nAscent, sal_uInt16& nHeight ) const
     941                 :            : {
     942                 :            :     OSL_ENSURE( pFnt, "No font available for GetDefaultAscentAndHeight" );
     943                 :            : 
     944         [ +  - ]:         27 :     if ( pFnt )
     945                 :            :     {
     946         [ +  - ]:         27 :         SwFont aFont( *pFnt );
     947         [ +  - ]:         27 :         nHeight = aFont.GetHeight( pShell, rOut );
     948 [ +  - ][ +  - ]:         27 :         nAscent = aFont.GetAscent( pShell, rOut );
     949                 :            :     }
     950                 :         27 : }
     951                 :            : 
     952                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10