LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/text - porrst.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 145 294 49.3 %
Date: 2013-07-09 Functions: 15 27 55.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <sfx2/printer.hxx>
      22             : #include <editeng/lspcitem.hxx>
      23             : #include <editeng/adjustitem.hxx>
      24             : #include <editeng/escapementitem.hxx>
      25             : #include <editeng/lrspitem.hxx>
      26             : #include <editeng/pgrditem.hxx>
      27             : #include <vcl/window.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <viewsh.hxx>   // ViewShell
      30             : #include <viewopt.hxx>
      31             : #include <ndtxt.hxx>    // SwTxtNode
      32             : #include <pagefrm.hxx>  // SwPageFrm
      33             : #include <paratr.hxx>
      34             : #include <SwPortionHandler.hxx>
      35             : #include <porrst.hxx>
      36             : #include <inftxt.hxx>
      37             : #include <txtpaint.hxx> // ClipVout
      38             : #include <swfntcch.hxx> // SwFontAccess
      39             : #include <tgrditem.hxx>
      40             : #include <pagedesc.hxx> // SwPageDesc
      41             : #include <frmatr.hxx>
      42             : #include <redlnitr.hxx> // SwRedlineItr
      43             : #include <porfly.hxx>   // SwFlyPortion
      44             : #include <atrhndl.hxx>
      45             : #include "rootfrm.hxx"
      46             : 
      47             : #include <IDocumentRedlineAccess.hxx>
      48             : #include <IDocumentSettingAccess.hxx>
      49             : #include <IDocumentDeviceAccess.hxx>
      50             : 
      51             : #include <crsrsh.hxx>
      52             : 
      53             : /*************************************************************************
      54             :  *                      class SwTmpEndPortion
      55             :  *************************************************************************/
      56             : 
      57           0 : SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion )
      58             : {
      59           0 :     Height( rPortion.Height() );
      60           0 :     SetAscent( rPortion.GetAscent() );
      61           0 :     SetWhichPor( POR_TMPEND );
      62           0 : }
      63             : 
      64             : /*************************************************************************
      65             :  *                 virtual SwTmpEndPortion::Paint()
      66             :  *************************************************************************/
      67             : 
      68           0 : void SwTmpEndPortion::Paint( const SwTxtPaintInfo &rInf ) const
      69             : {
      70           0 :     if( rInf.OnWin() && rInf.GetOpt().IsParagraph() )
      71             :     {
      72           0 :         SwDefFontSave aSave( rInf );
      73           0 :         const OUString aTmp( CH_PAR );
      74           0 :         rInf.DrawText( aTmp, *this );
      75             :     }
      76           0 : }
      77             : 
      78             : /*************************************************************************
      79             :  *                      class SwBreakPortion
      80             :  *************************************************************************/
      81         141 : SwBreakPortion::SwBreakPortion( const SwLinePortion &rPortion )
      82         141 :     : SwLinePortion( rPortion )
      83             : {
      84         141 :     nLineLength = 1;
      85         141 :     SetWhichPor( POR_BRK );
      86         141 : }
      87             : 
      88           0 : xub_StrLen SwBreakPortion::GetCrsrOfst( const KSHORT ) const
      89           0 : { return 0; }
      90             : 
      91         344 : KSHORT SwBreakPortion::GetViewWidth( const SwTxtSizeInfo & ) const
      92         344 : { return 0; }
      93             : 
      94          62 : SwLinePortion *SwBreakPortion::Compress()
      95          62 : { return (GetPortion() && GetPortion()->InTxtGrp() ? 0 : this); }
      96             : 
      97         266 : void SwBreakPortion::Paint( const SwTxtPaintInfo &rInf ) const
      98             : {
      99         266 :     if( rInf.OnWin() && rInf.GetOpt().IsLineBreak() )
     100           0 :         rInf.DrawLineBreak( *this );
     101         266 : }
     102             : 
     103             : /*************************************************************************
     104             :  *                 virtual SwBreakPortion::Format()
     105             :  *************************************************************************/
     106             : 
     107         141 : sal_Bool SwBreakPortion::Format( SwTxtFormatInfo &rInf )
     108             : {
     109         141 :     const SwLinePortion *pRoot = rInf.GetRoot();
     110         141 :     Width( 0 );
     111         141 :     Height( pRoot->Height() );
     112         141 :     SetAscent( pRoot->GetAscent() );
     113         141 :     if ( rInf.GetIdx()+1 == rInf.GetTxt().getLength() )
     114          31 :         rInf.SetNewLine( sal_True );
     115         141 :     return sal_True;
     116             : }
     117             : 
     118             : /*************************************************************************
     119             :  *              virtual SwBreakPortion::HandlePortion()
     120             :  *************************************************************************/
     121             : 
     122           0 : void SwBreakPortion::HandlePortion( SwPortionHandler& rPH ) const
     123             : {
     124           0 :     rPH.Text( GetLen(), GetWhichPor() );
     125           0 : }
     126             : 
     127             : 
     128         135 : SwKernPortion::SwKernPortion( SwLinePortion &rPortion, short nKrn,
     129             :                               bool bBG, bool bGK ) :
     130         135 :     nKern( nKrn ), bBackground( bBG ), bGridKern( bGK )
     131             : {
     132         135 :     Height( rPortion.Height() );
     133         135 :     SetAscent( rPortion.GetAscent() );
     134         135 :     nLineLength = 0;
     135         135 :     SetWhichPor( POR_KERN );
     136         135 :     if( nKern > 0 )
     137         130 :         Width( nKern );
     138         135 :      rPortion.Insert( this );
     139         135 : }
     140             : 
     141           4 : SwKernPortion::SwKernPortion( const SwLinePortion& rPortion ) :
     142           4 :     nKern( 0 ), bBackground( false ), bGridKern( true )
     143             : {
     144           4 :     Height( rPortion.Height() );
     145           4 :     SetAscent( rPortion.GetAscent() );
     146             : 
     147           4 :     nLineLength = 0;
     148           4 :     SetWhichPor( POR_KERN );
     149           4 : }
     150             : 
     151           0 : void SwKernPortion::Paint( const SwTxtPaintInfo &rInf ) const
     152             : {
     153           0 :     if( Width() )
     154             :     {
     155             :         // bBackground is set for Kerning Portions between two fields
     156           0 :         if ( bBackground )
     157           0 :             rInf.DrawViewOpt( *this, POR_FLD );
     158             : 
     159           0 :         rInf.DrawBackBrush( *this );
     160             : 
     161             :         // do we have to repaint a post it portion?
     162           0 :         if( rInf.OnWin() && pPortion && !pPortion->Width() )
     163           0 :             pPortion->PrePaint( rInf, this );
     164             : 
     165           0 :         if( rInf.GetFont()->IsPaintBlank() )
     166             :         {
     167             :             static sal_Char const sDoubleSpace[] = "  ";
     168           0 :             XubString aTxtDouble( sDoubleSpace, RTL_TEXTENCODING_MS_1252 );
     169             :             //
     170           0 :             SwRect aClipRect;
     171           0 :             rInf.CalcRect( *this, &aClipRect, 0 );
     172           0 :             SwSaveClip aClip( (OutputDevice*)rInf.GetOut() );
     173           0 :             aClip.ChgClip( aClipRect, 0 );
     174           0 :             rInf.DrawText( aTxtDouble, *this, 0, 2, sal_True );
     175             :         }
     176             :     }
     177           0 : }
     178             : 
     179         138 : void SwKernPortion::FormatEOL( SwTxtFormatInfo &rInf )
     180             : {
     181         138 :     if ( bGridKern )
     182         141 :         return;
     183             : 
     184         135 :     if( rInf.GetLast() == this )
     185         135 :         rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) );
     186         135 :     if( nKern < 0 )
     187           5 :         Width( -nKern );
     188             :     else
     189         130 :         Width( 0 );
     190         135 :     rInf.GetLast()->FormatEOL( rInf );
     191             : }
     192             : 
     193          18 : SwArrowPortion::SwArrowPortion( const SwLinePortion &rPortion ) :
     194          18 :     bLeft( true )
     195             : {
     196          18 :     Height( rPortion.Height() );
     197          18 :     SetAscent( rPortion.GetAscent() );
     198          18 :     nLineLength = 0;
     199          18 :     SetWhichPor( POR_ARROW );
     200          18 : }
     201             : 
     202           9 : SwArrowPortion::SwArrowPortion( const SwTxtPaintInfo &rInf )
     203           9 :     : bLeft( false )
     204             : {
     205           9 :     Height( (sal_uInt16)(rInf.GetTxtFrm()->Prt().Height()) );
     206          18 :     aPos.X() = rInf.GetTxtFrm()->Frm().Left() +
     207          18 :                rInf.GetTxtFrm()->Prt().Right();
     208          18 :     aPos.Y() = rInf.GetTxtFrm()->Frm().Top() +
     209          18 :                rInf.GetTxtFrm()->Prt().Bottom();
     210           9 :     SetWhichPor( POR_ARROW );
     211           9 : }
     212             : 
     213           0 : void SwArrowPortion::Paint( const SwTxtPaintInfo &rInf ) const
     214             : {
     215           0 :     ((SwArrowPortion*)this)->aPos = rInf.GetPos();
     216           0 : }
     217             : 
     218          18 : SwLinePortion *SwArrowPortion::Compress() { return this; }
     219             : 
     220       12212 : SwTwips SwTxtFrm::EmptyHeight() const
     221             : {
     222       12212 :     if (IsCollapse()) {
     223          51 :         ViewShell *pSh = getRootFrm()->GetCurrShell();
     224          51 :         if ( pSh->IsA( TYPE(SwCrsrShell) ) ) {
     225          51 :             SwCrsrShell *pCrSh=(SwCrsrShell*)pSh;
     226          51 :             SwCntntFrm *pCurrFrm=pCrSh->GetCurrFrm();
     227          51 :             if (pCurrFrm==(SwCntntFrm*)this) {
     228             :                 // do nothing
     229             :             } else {
     230          51 :                 return 1;
     231             :             }
     232             :         } else {
     233           0 :             return 1;
     234             :         }
     235             :     }
     236             :     OSL_ENSURE( ! IsVertical() || ! IsSwapped(),"SwTxtFrm::EmptyHeight with swapped frame" );
     237             : 
     238             :     SwFont *pFnt;
     239       12161 :     const SwTxtNode& rTxtNode = *GetTxtNode();
     240       12161 :     const IDocumentSettingAccess* pIDSA = rTxtNode.getIDocumentSettingAccess();
     241       12161 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     242       12161 :     if ( rTxtNode.HasSwAttrSet() )
     243             :     {
     244        5855 :         const SwAttrSet *pAttrSet = &( rTxtNode.GetSwAttrSet() );
     245        5855 :         pFnt = new SwFont( pAttrSet, pIDSA );
     246             :     }
     247             :     else
     248             :     {
     249        6306 :         SwFontAccess aFontAccess( &rTxtNode.GetAnyFmtColl(), pSh);
     250        6306 :         pFnt = new SwFont( *aFontAccess.Get()->GetFont() );
     251        6306 :         pFnt->ChkMagic( pSh, pFnt->GetActual() );
     252             :     }
     253             : 
     254       12161 :     if ( IsVertical() )
     255           0 :         pFnt->SetVertical( 2700 );
     256             : 
     257       12161 :     OutputDevice* pOut = pSh ? pSh->GetOut() : 0;
     258       12257 :     if ( !pOut || !pSh->GetViewOptions()->getBrowseMode() ||
     259          96 :          pSh->GetViewOptions()->IsPrtFormat() )
     260             :     {
     261       12065 :         pOut = rTxtNode.getIDocumentDeviceAccess()->getReferenceDevice(true);
     262             :     }
     263             : 
     264       12161 :     const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess();
     265       12161 :     if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
     266             :     {
     267       12128 :         MSHORT nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX );
     268       12128 :         if( MSHRT_MAX != nRedlPos )
     269             :         {
     270          30 :             SwAttrHandler aAttrHandler;
     271          30 :             aAttrHandler.Init(  GetTxtNode()->GetSwAttrSet(),
     272          60 :                                *GetTxtNode()->getIDocumentSettingAccess(), NULL );
     273             :             SwRedlineItr aRedln( rTxtNode, *pFnt, aAttrHandler,
     274          30 :                                  nRedlPos, sal_True );
     275             :         }
     276             :     }
     277             : 
     278             :     SwTwips nRet;
     279       12161 :     if( !pOut )
     280           0 :         nRet = IsVertical() ?
     281           0 :                Prt().SSize().Width() + 1 :
     282           0 :                Prt().SSize().Height() + 1;
     283             :     else
     284             :     {
     285       12161 :         pFnt->SetFntChg( sal_True );
     286       12161 :         pFnt->ChgPhysFnt( pSh, *pOut );
     287       12161 :         nRet = pFnt->GetHeight( pSh, *pOut );
     288             :     }
     289       12161 :     delete pFnt;
     290       12161 :     return nRet;
     291             : }
     292             : 
     293             : /*************************************************************************
     294             :  *                      SwTxtFrm::FormatEmpty()
     295             :  *************************************************************************/
     296             : 
     297        4650 : sal_Bool SwTxtFrm::FormatEmpty()
     298             : {
     299             :     OSL_ENSURE( ! IsVertical() || ! IsSwapped(),"SwTxtFrm::FormatEmpty with swapped frame" );
     300             : 
     301        4650 :     bool bCollapse = EmptyHeight( ) == 1 && this->IsCollapse( );
     302             : 
     303       18159 :     if ( HasFollow() || GetTxtNode()->GetpSwpHints() ||
     304        8416 :         0 != GetTxtNode()->GetNumRule() ||
     305        8314 :         GetTxtNode()->HasHiddenCharAttribute( true ) ||
     306       12779 :          IsInFtn() || ( HasPara() && GetPara()->IsPrepMustFit() ) )
     307         641 :         return sal_False;
     308        4009 :     const SwAttrSet& aSet = GetTxtNode()->GetSwAttrSet();
     309        4009 :     const SvxAdjust nAdjust = aSet.GetAdjust().GetAdjust();
     310        8001 :     if( !bCollapse && ( ( ( ! IsRightToLeft() && ( SVX_ADJUST_LEFT != nAdjust ) ) ||
     311        7028 :           (   IsRightToLeft() && ( SVX_ADJUST_RIGHT != nAdjust ) ) ) ||
     312        3514 :           aSet.GetRegister().GetValue() ) )
     313         478 :         return sal_False;
     314        3531 :     const SvxLineSpacingItem &rSpacing = aSet.GetLineSpacing();
     315        7049 :     if( !bCollapse && ( SVX_LINE_SPACE_MIN == rSpacing.GetLineSpaceRule() ||
     316        6836 :         SVX_LINE_SPACE_FIX == rSpacing.GetLineSpaceRule() ||
     317        3416 :         aSet.GetLRSpace().IsAutoFirst() ) )
     318          98 :         return sal_False;
     319             :     else
     320             :     {
     321        3433 :         SwTxtFly aTxtFly( this );
     322        3433 :         SwRect aRect;
     323        3433 :         bool bFirstFlyCheck = 0 != Prt().Height();
     324       11752 :         if ( !bCollapse && bFirstFlyCheck &&
     325        5264 :              aTxtFly.IsOn() && aTxtFly.IsAnyObj( aRect ) )
     326         236 :             return sal_False;
     327             :         else
     328             :         {
     329        3197 :             SwTwips nHeight = EmptyHeight();
     330             : 
     331        6276 :             if ( GetTxtNode()->GetSwAttrSet().GetParaGrid().GetValue() &&
     332        3079 :                  IsInDocBody() )
     333             :             {
     334        2784 :                 GETGRID( FindPageFrm() )
     335        2784 :                 if ( pGrid )
     336           0 :                     nHeight = pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
     337             :             }
     338             : 
     339        3197 :             SWRECTFN( this )
     340        3197 :             const SwTwips nChg = nHeight - (Prt().*fnRect->fnGetHeight)();
     341             : 
     342        3197 :             if( !nChg )
     343        1145 :                 SetUndersized( sal_False );
     344        3197 :             AdjustFrm( nChg );
     345             : 
     346        3197 :             if( HasBlinkPor() )
     347             :             {
     348           0 :                 ClearPara();
     349           0 :                 ResetBlinkPor();
     350             :             }
     351        3197 :             SetCacheIdx( MSHRT_MAX );
     352        3197 :             if( !IsEmpty() )
     353             :             {
     354        1955 :                 SetEmpty( sal_True );
     355        1955 :                 SetCompletePaint();
     356             :             }
     357       11520 :             if( !bCollapse && !bFirstFlyCheck &&
     358        5697 :                  aTxtFly.IsOn() && aTxtFly.IsAnyObj( aRect ) )
     359          37 :                  return sal_False;
     360             : 
     361             :             // #i35635# - call method <HideAndShowObjects()>
     362             :             // to assure that objects anchored at the empty paragraph are
     363             :             // correctly visible resp. invisible.
     364        3160 :             HideAndShowObjects();
     365        3160 :             return sal_True;
     366        3433 :         }
     367             :     }
     368             : }
     369             : 
     370           0 : sal_Bool SwTxtFrm::FillRegister( SwTwips& rRegStart, KSHORT& rRegDiff )
     371             : {
     372           0 :     const SwFrm *pFrm = this;
     373           0 :     rRegDiff = 0;
     374           0 :     while( !( ( FRM_BODY | FRM_FLY )
     375           0 :            & pFrm->GetType() ) && pFrm->GetUpper() )
     376           0 :         pFrm = pFrm->GetUpper();
     377           0 :     if( ( FRM_BODY| FRM_FLY ) & pFrm->GetType() )
     378             :     {
     379           0 :         SWRECTFN( pFrm )
     380           0 :         rRegStart = (pFrm->*fnRect->fnGetPrtTop)();
     381           0 :         pFrm = pFrm->FindPageFrm();
     382           0 :         if( pFrm->IsPageFrm() )
     383             :         {
     384           0 :             SwPageDesc* pDesc = ((SwPageFrm*)pFrm)->FindPageDesc();
     385           0 :             if( pDesc )
     386             :             {
     387           0 :                 rRegDiff = pDesc->GetRegHeight();
     388           0 :                 if( !rRegDiff )
     389             :                 {
     390           0 :                     const SwTxtFmtColl *pFmt = pDesc->GetRegisterFmtColl();
     391           0 :                     if( pFmt )
     392             :                     {
     393           0 :                         const SvxLineSpacingItem &rSpace = pFmt->GetLineSpacing();
     394           0 :                         if( SVX_LINE_SPACE_FIX == rSpace.GetLineSpaceRule() )
     395             :                         {
     396           0 :                             rRegDiff = rSpace.GetLineHeight();
     397           0 :                             pDesc->SetRegHeight( rRegDiff );
     398           0 :                             pDesc->SetRegAscent( ( 4 * rRegDiff ) / 5 );
     399             :                         }
     400             :                         else
     401             :                         {
     402           0 :                             ViewShell *pSh = getRootFrm()->GetCurrShell();
     403           0 :                             SwFontAccess aFontAccess( pFmt, pSh );
     404           0 :                             SwFont aFnt( *aFontAccess.Get()->GetFont() );
     405             : 
     406           0 :                             OutputDevice *pOut = 0;
     407           0 :                             if( !pSh || !pSh->GetViewOptions()->getBrowseMode() ||
     408           0 :                                 pSh->GetViewOptions()->IsPrtFormat() )
     409           0 :                                 pOut = GetTxtNode()->getIDocumentDeviceAccess()->getReferenceDevice( true );
     410             : 
     411           0 :                             if( pSh && !pOut )
     412           0 :                                 pOut = pSh->GetWin();
     413             : 
     414           0 :                             if( !pOut )
     415           0 :                                 pOut = GetpApp()->GetDefaultDevice();
     416             : 
     417           0 :                             MapMode aOldMap( pOut->GetMapMode() );
     418           0 :                             pOut->SetMapMode( MapMode( MAP_TWIP ) );
     419             : 
     420           0 :                             aFnt.ChgFnt( pSh, *pOut );
     421           0 :                             rRegDiff = aFnt.GetHeight( pSh, *pOut );
     422           0 :                             KSHORT nNettoHeight = rRegDiff;
     423             : 
     424           0 :                             switch( rSpace.GetLineSpaceRule() )
     425             :                             {
     426             :                                 case SVX_LINE_SPACE_AUTO:
     427           0 :                                 break;
     428             :                                 case SVX_LINE_SPACE_MIN:
     429             :                                 {
     430           0 :                                     if( rRegDiff < KSHORT( rSpace.GetLineHeight() ) )
     431           0 :                                         rRegDiff = rSpace.GetLineHeight();
     432           0 :                                     break;
     433             :                                 }
     434             :                                 default:
     435             :                                     OSL_FAIL( ": unknown LineSpaceRule" );
     436             :                             }
     437           0 :                             switch( rSpace.GetInterLineSpaceRule() )
     438             :                             {
     439             :                                 case SVX_INTER_LINE_SPACE_OFF:
     440           0 :                                 break;
     441             :                                 case SVX_INTER_LINE_SPACE_PROP:
     442             :                                 {
     443           0 :                                     long nTmp = rSpace.GetPropLineSpace();
     444           0 :                                     if( nTmp < 50 )
     445           0 :                                         nTmp = nTmp ? 50 : 100;
     446           0 :                                     nTmp *= rRegDiff;
     447           0 :                                     nTmp /= 100;
     448           0 :                                     if( !nTmp )
     449           0 :                                         ++nTmp;
     450           0 :                                     rRegDiff = (KSHORT)nTmp;
     451           0 :                                     nNettoHeight = rRegDiff;
     452           0 :                                     break;
     453             :                                 }
     454             :                                 case SVX_INTER_LINE_SPACE_FIX:
     455             :                                 {
     456           0 :                                     rRegDiff = rRegDiff + rSpace.GetInterLineSpace();
     457           0 :                                     nNettoHeight = rRegDiff;
     458           0 :                                     break;
     459             :                                 }
     460             :                                 default: OSL_FAIL( ": unknown InterLineSpaceRule" );
     461             :                             }
     462           0 :                             pDesc->SetRegHeight( rRegDiff );
     463             :                             pDesc->SetRegAscent( rRegDiff - nNettoHeight +
     464           0 :                                                  aFnt.GetAscent( pSh, *pOut ) );
     465           0 :                             pOut->SetMapMode( aOldMap );
     466             :                         }
     467             :                     }
     468             :                 }
     469           0 :                 const long nTmpDiff = pDesc->GetRegAscent() - rRegDiff;
     470           0 :                 if ( bVert )
     471           0 :                     rRegStart -= nTmpDiff;
     472             :                 else
     473           0 :                     rRegStart += nTmpDiff;
     474             :             }
     475             :         }
     476             :     }
     477           0 :     return ( 0 != rRegDiff );
     478             : }
     479             : 
     480             : /*************************************************************************
     481             :  *              virtual SwHiddenTextPortion::Paint()
     482             :  *************************************************************************/
     483             : 
     484           0 : void SwHiddenTextPortion::Paint( const SwTxtPaintInfo & rInf) const
     485             : {
     486             :     (void)rInf;
     487             : #ifdef DBG_UTIL
     488             :     OutputDevice* pOut = (OutputDevice*)rInf.GetOut();
     489             :     Color aCol( SwViewOption::GetFieldShadingsColor() );
     490             :     Color aOldColor( pOut->GetFillColor() );
     491             :     pOut->SetFillColor( aCol );
     492             :     Point aPos( rInf.GetPos() );
     493             :     aPos.Y() -= 150;
     494             :     aPos.X() -= 25;
     495             :     SwRect aRect( aPos, Size( 100, 200 ) );
     496             :     ((OutputDevice*)pOut)->DrawRect( aRect.SVRect() );
     497             :     pOut->SetFillColor( aOldColor );
     498             : #endif
     499           0 : }
     500             : 
     501             : /*************************************************************************
     502             :  *              virtual SwHiddenTextPortion::Format()
     503             :  *************************************************************************/
     504             : 
     505           0 : sal_Bool SwHiddenTextPortion::Format( SwTxtFormatInfo &rInf )
     506             : {
     507           0 :     Width( 0 );
     508           0 :     rInf.GetTxtFrm()->HideFootnotes( rInf.GetIdx(), rInf.GetIdx() + GetLen() );
     509             : 
     510           0 :     return sal_False;
     511             : };
     512             : 
     513             : /*************************************************************************
     514             :  *              virtual SwControlCharPortion::Paint()
     515             :  *************************************************************************/
     516             : 
     517           0 : void SwControlCharPortion::Paint( const SwTxtPaintInfo &rInf ) const
     518             : {
     519           0 :     if ( Width() )  // is only set during prepaint mode
     520             :     {
     521           0 :         rInf.DrawViewOpt( *this, POR_CONTROLCHAR );
     522             : 
     523           0 :         if ( !rInf.GetOpt().IsPagePreview() &&
     524           0 :              !rInf.GetOpt().IsReadonly() &&
     525           0 :               SwViewOption::IsFieldShadings() &&
     526           0 :               CHAR_ZWNBSP != mcChar )
     527             :         {
     528           0 :             SwFont aTmpFont( *rInf.GetFont() );
     529           0 :             aTmpFont.SetEscapement( CHAR_ZWSP == mcChar ? DFLT_ESC_AUTO_SUB : -25 );
     530           0 :             const sal_uInt16 nProp = 40;
     531           0 :             aTmpFont.SetProportion( nProp );  // a smaller font
     532           0 :             SwFontSave aFontSave( rInf, &aTmpFont );
     533             : 
     534           0 :             String aOutString;
     535             : 
     536           0 :             switch ( mcChar )
     537             :             {
     538             :                 case CHAR_ZWSP :
     539           0 :                     aOutString = '/'; break;
     540             : //                case CHAR_LRM :
     541             : //                    rTxt = sal_Unicode(0x2514); break;
     542             : //                case CHAR_RLM :
     543             : //                    rTxt = sal_Unicode(0x2518); break;
     544             :             }
     545             : 
     546           0 :             if ( !mnHalfCharWidth )
     547           0 :                 mnHalfCharWidth = rInf.GetTxtSize( aOutString ).Width() / 2;
     548             : 
     549           0 :             Point aOldPos = rInf.GetPos();
     550           0 :             Point aNewPos( aOldPos );
     551           0 :             aNewPos.X() = aNewPos.X() + ( Width() / 2 ) - mnHalfCharWidth;
     552           0 :             const_cast< SwTxtPaintInfo& >( rInf ).SetPos( aNewPos );
     553             : 
     554           0 :             rInf.DrawText( aOutString, *this );
     555             : 
     556           0 :             const_cast< SwTxtPaintInfo& >( rInf ).SetPos( aOldPos );
     557             :         }
     558             :     }
     559           0 : }
     560             : 
     561             : /*************************************************************************
     562             :  *              virtual SwControlCharPortion::Format()
     563             :  *************************************************************************/
     564             : 
     565           0 : sal_Bool SwControlCharPortion::Format( SwTxtFormatInfo &rInf )
     566             : {
     567           0 :     const SwLinePortion* pRoot = rInf.GetRoot();
     568           0 :     Width( 0 );
     569           0 :     Height( pRoot->Height() );
     570           0 :     SetAscent( pRoot->GetAscent() );
     571             : 
     572           0 :     return sal_False;
     573             : }
     574             : 
     575             : /*************************************************************************
     576             :  *              virtual SwControlCharPortion::GetViewWidth()
     577             :  *************************************************************************/
     578             : 
     579           0 : KSHORT SwControlCharPortion::GetViewWidth( const SwTxtSizeInfo& rInf ) const
     580             : {
     581           0 :     if( !mnViewWidth )
     582           0 :         mnViewWidth = rInf.GetTxtSize(OUString(' ')).Width();
     583             : 
     584           0 :     return mnViewWidth;
     585          99 : }
     586             : 
     587             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10