LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/text - frmpaint.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 274 352 77.8 %
Date: 2013-07-09 Functions: 15 15 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/text/HoriOrientation.hpp>
      22             : #include <hintids.hxx>
      23             : #include <tools/shl.hxx> // SW_MOD
      24             : #include <editeng/pgrditem.hxx>
      25             : #include <editeng/lrspitem.hxx>
      26             : #include <pagedesc.hxx> // SwPageDesc
      27             : #include <tgrditem.hxx>
      28             : #include <paratr.hxx>
      29             : 
      30             : #include <fmtline.hxx>
      31             : #include <lineinfo.hxx>
      32             : #include <charfmt.hxx>
      33             : #include "rootfrm.hxx"
      34             : #include <pagefrm.hxx>
      35             : #include <viewsh.hxx>   // ViewShell
      36             : #include <viewimp.hxx>  // SwViewImp
      37             : #include <viewopt.hxx>  // SwViewOption
      38             : #include <frmtool.hxx>  // DrawGraphic
      39             : #include <txtfrm.hxx>   // SwTxtFrm
      40             : #include <itrpaint.hxx> // SwTxtPainter
      41             : #include <txtpaint.hxx> // SwSaveClip
      42             : #include <txtcache.hxx> // SwTxtLineAccess
      43             : #include <flyfrm.hxx>   // SwFlyFrm
      44             : #include <redlnitr.hxx> // SwRedlineItr
      45             : #include <swmodule.hxx> // SW_MOD
      46             : #include <tabfrm.hxx>   // SwTabFrm (Redlining)
      47             : #include <SwGrammarMarkUp.hxx>
      48             : 
      49             : // #i12836# enhanced pdf export
      50             : #include <EnhancedPDFExportHelper.hxx>
      51             : 
      52             : #include <IDocumentStylePoolAccess.hxx>
      53             : #include <IDocumentLineNumberAccess.hxx>
      54             : 
      55             : // variable moved to class <numfunc:GetDefBulletConfig>
      56             : //extern const sal_Char sBulletFntName[];
      57             : namespace numfunc
      58             : {
      59             :     extern const String& GetDefBulletFontname();
      60             :     extern bool IsDefBulletFontUserDefined();
      61             : }
      62             : 
      63             : 
      64             : #define REDLINE_DISTANCE 567/4
      65             : #define REDLINE_MINDIST  567/10
      66             : 
      67             : using namespace ::com::sun::star;
      68             : 
      69             : ////////////////////////////////////////////////////////////
      70             : 
      71             : bool bInitFont = true;
      72             : 
      73             : class SwExtraPainter
      74             : {
      75             :     SwSaveClip aClip;
      76             :     SwRect aRect;
      77             :     const SwTxtFrm* pTxtFrm;
      78             :     ViewShell *pSh;
      79             :     SwFont* pFnt;
      80             :     const SwLineNumberInfo &rLineInf;
      81             :     SwTwips nX;
      82             :     SwTwips nRedX;
      83             :     sal_uLong nLineNr;
      84             :     MSHORT nDivider;
      85             :     bool bGoLeft;
      86             :     bool bLineNum;
      87          52 :     inline bool IsClipChg() { return aClip.IsChg(); }
      88             : public:
      89             :     SwExtraPainter( const SwTxtFrm *pFrm, ViewShell *pVwSh,
      90             :         const SwLineNumberInfo &rLnInf, const SwRect &rRct,
      91             :         sal_Int16 eHor, bool bLnNm );
      92          72 :     ~SwExtraPainter() { delete pFnt; }
      93          23 :     inline SwFont* GetFont() const { return pFnt; }
      94          63 :     inline void IncLineNr() { ++nLineNr; }
      95          70 :     inline bool HasNumber() { return !( nLineNr % rLineInf.GetCountBy() ); }
      96          26 :     inline bool HasDivider() { if( !nDivider ) return false;
      97           0 :         return !(nLineNr % rLineInf.GetDividerCountBy()); }
      98             : 
      99             :     void PaintExtra( SwTwips nY, long nAsc, long nMax, bool bRed );
     100             :     void PaintRedline( SwTwips nY, long nMax );
     101             : };
     102             : 
     103             : 
     104          72 : SwExtraPainter::SwExtraPainter( const SwTxtFrm *pFrm, ViewShell *pVwSh,
     105             :     const SwLineNumberInfo &rLnInf, const SwRect &rRct,
     106             :     sal_Int16 eHor, bool bLnNm )
     107          72 :     : aClip( pVwSh->GetWin() || pFrm->IsUndersized() ? pVwSh->GetOut() : 0 ),
     108             :       aRect( rRct ), pTxtFrm( pFrm ), pSh( pVwSh ), pFnt( 0 ), rLineInf( rLnInf ),
     109         144 :       nLineNr( 1L ), bLineNum( bLnNm )
     110             : {
     111          72 :     if( pFrm->IsUndersized() )
     112             :     {
     113           0 :         SwTwips nBottom = pFrm->Frm().Bottom();
     114           0 :         if( aRect.Bottom() > nBottom )
     115           0 :             aRect.Bottom( nBottom );
     116             :     }
     117          72 :     MSHORT nVirtPageNum = 0;
     118          72 :     if( bLineNum )
     119             :         {/* Initializes the Members necessary for line numbering:
     120             : 
     121             :             nDivider,   how often do we want a substring; 0 == never
     122             :             nX,         line number's x position
     123             :             pFnt,       line number's font
     124             :             nLineNr,    the first line number
     125             :             bLineNum is set back to sal_False if the numbering is completely
     126             :             outside of the paint rect */
     127          36 :         nDivider = rLineInf.GetDivider().Len() ? rLineInf.GetDividerCountBy() : 0;
     128          36 :         nX = pFrm->Frm().Left();
     129          36 :         SwCharFmt* pFmt = rLineInf.GetCharFmt( const_cast<IDocumentStylePoolAccess&>(*pFrm->GetNode()->getIDocumentStylePoolAccess()) );
     130             :         OSL_ENSURE( pFmt, "PaintExtraData without CharFmt" );
     131          36 :         pFnt = new SwFont( &pFmt->GetAttrSet(), pFrm->GetTxtNode()->getIDocumentSettingAccess() );
     132          36 :         pFnt->Invalidate();
     133          36 :         pFnt->ChgPhysFnt( pSh, *pSh->GetOut() );
     134          36 :         pFnt->SetVertical( 0, pFrm->IsVertical() );
     135          36 :         nLineNr += pFrm->GetAllLines() - pFrm->GetThisLines();
     136          36 :         LineNumberPosition ePos = rLineInf.GetPos();
     137          36 :         if( ePos != LINENUMBER_POS_LEFT && ePos != LINENUMBER_POS_RIGHT )
     138             :         {
     139           0 :             if( pFrm->FindPageFrm()->OnRightPage() )
     140             :             {
     141           0 :                 nVirtPageNum = 1;
     142             :                 ePos = ePos == LINENUMBER_POS_INSIDE ?
     143           0 :                         LINENUMBER_POS_LEFT : LINENUMBER_POS_RIGHT;
     144             :             }
     145             :             else
     146             :             {
     147           0 :                 nVirtPageNum = 2;
     148             :                 ePos = ePos == LINENUMBER_POS_OUTSIDE ?
     149           0 :                         LINENUMBER_POS_LEFT : LINENUMBER_POS_RIGHT;
     150             :             }
     151             :         }
     152          36 :         if( LINENUMBER_POS_LEFT == ePos )
     153             :         {
     154          36 :             bGoLeft = true;
     155          36 :             nX -= rLineInf.GetPosFromLeft();
     156          36 :             if( nX < aRect.Left() )
     157           0 :                 bLineNum = false;
     158             :         }
     159             :         else
     160             :         {
     161           0 :             bGoLeft = false;
     162           0 :             nX += pFrm->Frm().Width() + rLineInf.GetPosFromLeft();
     163           0 :             if( nX > aRect.Right() )
     164           0 :                 bLineNum = false;
     165             :         }
     166             :     }
     167          72 :     if( eHor != text::HoriOrientation::NONE )
     168             :     {
     169          72 :         if( text::HoriOrientation::INSIDE == eHor || text::HoriOrientation::OUTSIDE == eHor )
     170             :         {
     171           0 :             if( !nVirtPageNum )
     172           0 :                 nVirtPageNum = pFrm->FindPageFrm()->OnRightPage() ? 1 : 2;
     173           0 :             if( nVirtPageNum % 2 )
     174           0 :                 eHor = eHor == text::HoriOrientation::INSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT;
     175             :             else
     176           0 :                 eHor = eHor == text::HoriOrientation::OUTSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT;
     177             :         }
     178          72 :         const SwFrm* pTmpFrm = pFrm->FindTabFrm();
     179          72 :         if( !pTmpFrm )
     180          72 :             pTmpFrm = pFrm;
     181          72 :         nRedX = text::HoriOrientation::LEFT == eHor ? pTmpFrm->Frm().Left() - REDLINE_DISTANCE :
     182         144 :             pTmpFrm->Frm().Right() + REDLINE_DISTANCE;
     183             :     }
     184          72 : }
     185             : 
     186          22 : void SwExtraPainter::PaintExtra( SwTwips nY, long nAsc, long nMax, bool bRed )
     187             : {
     188             :   // Line number is stronger than the divider
     189          44 :     const OUString aTmp( HasNumber() ? rLineInf.GetNumType().GetNumStr( nLineNr )
     190          44 :                                 : rLineInf.GetDivider() );
     191             : 
     192             :     // Get script type of line numbering:
     193          22 :     pFnt->SetActual( SwScriptInfo::WhichFont( 0, &aTmp, 0 ) );
     194             : 
     195          44 :     SwDrawTextInfo aDrawInf( pSh, *pSh->GetOut(), 0, aTmp, 0, aTmp.getLength() );
     196          22 :     aDrawInf.SetSpace( 0 );
     197          22 :     aDrawInf.SetWrong( NULL );
     198          22 :     aDrawInf.SetGrammarCheck( NULL );
     199          22 :     aDrawInf.SetSmartTags( NULL ); // SMARTTAGS
     200          22 :     aDrawInf.SetLeft( 0 );
     201          22 :     aDrawInf.SetRight( LONG_MAX );
     202          22 :     aDrawInf.SetFrm( pTxtFrm );
     203          22 :     aDrawInf.SetFont( pFnt );
     204          22 :     aDrawInf.SetSnapToGrid( sal_False );
     205          22 :     aDrawInf.SetIgnoreFrmRTL( sal_True );
     206             : 
     207          22 :     bool bTooBig = pFnt->GetSize( pFnt->GetActual() ).Height() > nMax &&
     208          22 :                 pFnt->GetHeight( pSh, *pSh->GetOut() ) > nMax;
     209             :     SwFont* pTmpFnt;
     210          22 :     if( bTooBig )
     211             :     {
     212           0 :         pTmpFnt = new SwFont( *GetFont() );
     213           0 :         if( nMax >= 20 )
     214             :         {
     215           0 :             nMax *= 17;
     216           0 :             nMax /= 20;
     217             :         }
     218           0 :         pTmpFnt->SetSize( Size( 0, nMax ), pTmpFnt->GetActual() );
     219             :     }
     220             :     else
     221          22 :         pTmpFnt = GetFont();
     222          22 :     Point aTmpPos( nX, nY );
     223          22 :     aTmpPos.Y() += nAsc;
     224          22 :     bool bPaint = true;
     225          22 :     if( !IsClipChg() )
     226             :     {
     227          22 :         Size aSize = pTmpFnt->_GetTxtSize( aDrawInf );
     228          22 :         if( bGoLeft )
     229          22 :             aTmpPos.X() -= aSize.Width();
     230             :         // calculate rectangle containing the line number
     231          22 :         SwRect aRct( Point( aTmpPos.X(),
     232          44 :                          aTmpPos.Y() - pTmpFnt->GetAscent( pSh, *pSh->GetOut() )
     233          66 :                           ), aSize );
     234          22 :         if( !aRect.IsInside( aRct ) )
     235             :         {
     236           1 :             if( aRct.Intersection( aRect ).IsEmpty() )
     237           1 :                 bPaint = false;
     238             :             else
     239           0 :                 aClip.ChgClip( aRect, pTxtFrm );
     240             :         }
     241             :     }
     242           0 :     else if( bGoLeft )
     243           0 :         aTmpPos.X() -= pTmpFnt->_GetTxtSize( aDrawInf ).Width();
     244          22 :     aDrawInf.SetPos( aTmpPos );
     245          22 :     if( bPaint )
     246          21 :         pTmpFnt->_DrawText( aDrawInf );
     247             : 
     248          22 :     if( bTooBig )
     249           0 :         delete pTmpFnt;
     250          22 :     if( bRed )
     251             :     {
     252           0 :         long nDiff = bGoLeft ? nRedX - nX : nX - nRedX;
     253           0 :         if( nDiff > REDLINE_MINDIST )
     254           0 :             PaintRedline( nY, nMax );
     255          22 :     }
     256          22 : }
     257             : 
     258          30 : void SwExtraPainter::PaintRedline( SwTwips nY, long nMax )
     259             : {
     260          30 :     Point aStart( nRedX, nY );
     261          30 :     Point aEnd( nRedX, nY + nMax );
     262             : 
     263          30 :     if( !IsClipChg() )
     264             :     {
     265          30 :         SwRect aRct( aStart, aEnd );
     266          30 :         if( !aRect.IsInside( aRct ) )
     267             :         {
     268           0 :             if( aRct.Intersection( aRect ).IsEmpty() )
     269          30 :                 return;
     270           0 :             aClip.ChgClip( aRect, pTxtFrm );
     271             :         }
     272             :     }
     273          30 :     const Color aOldCol( pSh->GetOut()->GetLineColor() );
     274          30 :     pSh->GetOut()->SetLineColor( SW_MOD()->GetRedlineMarkColor() );
     275             : 
     276          30 :     if ( pTxtFrm->IsVertical() )
     277             :     {
     278           0 :         pTxtFrm->SwitchHorizontalToVertical( aStart );
     279           0 :         pTxtFrm->SwitchHorizontalToVertical( aEnd );
     280             :     }
     281             : 
     282          30 :     pSh->GetOut()->DrawLine( aStart, aEnd );
     283          30 :     pSh->GetOut()->SetLineColor( aOldCol );
     284             : }
     285             : 
     286          72 : void SwTxtFrm::PaintExtraData( const SwRect &rRect ) const
     287             : {
     288          72 :     if( Frm().Top() > rRect.Bottom() || Frm().Bottom() < rRect.Top() )
     289           0 :         return;
     290             : 
     291          72 :     const SwTxtNode& rTxtNode = *GetTxtNode();
     292          72 :     const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess();
     293          72 :     const SwLineNumberInfo &rLineInf = rTxtNode.getIDocumentLineNumberAccess()->GetLineNumberInfo();
     294          72 :     const SwFmtLineNumber &rLineNum = GetAttrSet()->GetLineNumber();
     295         180 :     bool bLineNum = !IsInTab() && rLineInf.IsPaintLineNumbers() &&
     296         108 :                ( !IsInFly() || rLineInf.IsCountInFlys() ) && rLineNum.IsCount();
     297          72 :     sal_Int16 eHor = (sal_Int16)SW_MOD()->GetRedlineMarkPos();
     298          72 :     if( eHor != text::HoriOrientation::NONE && !IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
     299           0 :         eHor = text::HoriOrientation::NONE;
     300          72 :     bool bRedLine = eHor != text::HoriOrientation::NONE;
     301          72 :     if ( bLineNum || bRedLine )
     302             :     {
     303          72 :         if( IsLocked() || IsHiddenNow() || !Prt().Height() )
     304           0 :             return;
     305          72 :         ViewShell *pSh = getRootFrm()->GetCurrShell();
     306             : 
     307          72 :         SWAP_IF_NOT_SWAPPED( this )
     308          72 :         SwRect rOldRect( rRect );
     309             : 
     310          72 :         if ( IsVertical() )
     311           0 :             SwitchVerticalToHorizontal( (SwRect&)rRect );
     312             : 
     313          72 :         SwLayoutModeModifier aLayoutModeModifier( *pSh->GetOut() );
     314          72 :         aLayoutModeModifier.Modify( sal_False );
     315             : 
     316             :         // #i16816# tagged pdf support
     317         144 :         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pSh->GetOut() );
     318             : 
     319         144 :         SwExtraPainter aExtra( this, pSh, rLineInf, rRect, eHor, bLineNum );
     320             : 
     321          72 :         if( HasPara() )
     322             :         {
     323          51 :             SwTxtFrmLocker aLock((SwTxtFrm*)this);
     324             : 
     325         102 :             SwTxtLineAccess aAccess( (SwTxtFrm*)this );
     326          51 :             aAccess.GetPara();
     327             : 
     328         102 :             SwTxtPaintInfo aInf( (SwTxtFrm*)this, rRect );
     329             : 
     330          51 :             aLayoutModeModifier.Modify( sal_False );
     331             : 
     332         102 :             SwTxtPainter  aLine( (SwTxtFrm*)this, &aInf );
     333          51 :             bool bNoDummy = !aLine.GetNext(); // Only one empty line!
     334             : 
     335         102 :             while( aLine.Y() + aLine.GetLineHeight() <= rRect.Top() )
     336             :             {
     337           0 :                 if( !aLine.GetCurr()->IsDummy() &&
     338           0 :                     ( rLineInf.IsCountBlankLines() ||
     339           0 :                       aLine.GetCurr()->HasCntnt() ) )
     340           0 :                     aExtra.IncLineNr();
     341           0 :                 if( !aLine.Next() )
     342             :                 {
     343           0 :                     (SwRect&)rRect = rOldRect;
     344           0 :                     UNDO_SWAP( this )
     345           0 :                     return;
     346             :                 }
     347             :             }
     348             : 
     349          51 :             long nBottom = rRect.Bottom();
     350             : 
     351          51 :             bool bNoPrtLine = 0 == GetMinPrtLine();
     352          51 :             if( !bNoPrtLine )
     353             :             {
     354           0 :                 while ( aLine.Y() < GetMinPrtLine() )
     355             :                 {
     356           0 :                     if( ( rLineInf.IsCountBlankLines() || aLine.GetCurr()->HasCntnt() )
     357           0 :                         && !aLine.GetCurr()->IsDummy() )
     358           0 :                         aExtra.IncLineNr();
     359           0 :                     if( !aLine.Next() )
     360           0 :                         break;
     361             :                 }
     362           0 :                 bNoPrtLine = aLine.Y() >= GetMinPrtLine();
     363             :             }
     364          51 :             if( bNoPrtLine )
     365             :             {
     366          63 :                 do
     367             :                 {
     368          63 :                     if( bNoDummy || !aLine.GetCurr()->IsDummy() )
     369             :                     {
     370          63 :                         bool bRed = bRedLine && aLine.GetCurr()->HasRedline();
     371          63 :                         if( rLineInf.IsCountBlankLines() || aLine.GetCurr()->HasCntnt() )
     372             :                         {
     373         128 :                             if( bLineNum &&
     374          67 :                                 ( aExtra.HasNumber() || aExtra.HasDivider() ) )
     375             :                             {
     376             :                                 KSHORT nTmpHeight, nTmpAscent;
     377          21 :                                 aLine.CalcAscentAndHeight( nTmpAscent, nTmpHeight );
     378             :                                 aExtra.PaintExtra( aLine.Y(), nTmpAscent,
     379          21 :                                     nTmpHeight, bRed );
     380          21 :                                 bRed = false;
     381             :                             }
     382          63 :                             aExtra.IncLineNr();
     383             :                         }
     384          63 :                         if( bRed )
     385          14 :                             aExtra.PaintRedline( aLine.Y(), aLine.GetLineHeight() );
     386             :                     }
     387          63 :                 } while( aLine.Next() && aLine.Y() <= nBottom );
     388          51 :             }
     389             :         }
     390             :         else
     391             :         {
     392          21 :             if ( MSHRT_MAX == pIDRA->GetRedlinePos(rTxtNode, USHRT_MAX) )
     393           5 :                 bRedLine = false;
     394             : 
     395          26 :             if( bLineNum && rLineInf.IsCountBlankLines() &&
     396           7 :                 ( aExtra.HasNumber() || aExtra.HasDivider() ) )
     397             :             {
     398           1 :                 aExtra.PaintExtra( Frm().Top()+Prt().Top(), aExtra.GetFont()
     399           2 :                     ->GetAscent( pSh, *pSh->GetOut() ), Prt().Height(), bRedLine );
     400             :             }
     401          20 :             else if( bRedLine )
     402          16 :                 aExtra.PaintRedline( Frm().Top()+Prt().Top(), Prt().Height() );
     403             :         }
     404             : 
     405          72 :         (SwRect&)rRect = rOldRect;
     406         144 :         UNDO_SWAP( this )
     407             :     }
     408             : }
     409             : 
     410        5538 : SwRect SwTxtFrm::Paint()
     411             : {
     412             : #if OSL_DEBUG_LEVEL > 1
     413             :     const SwTwips nDbgY = Frm().Top();
     414             :     (void)nDbgY;
     415             : #endif
     416             : 
     417             :     // finger layout
     418             :     OSL_ENSURE( GetValidPosFlag(), "+SwTxtFrm::Paint: no Calc()" );
     419             : 
     420        5538 :     SwRect aRet( Prt() );
     421        5538 :     if ( IsEmpty() || !HasPara() )
     422         908 :         aRet += Frm().Pos();
     423             :     else
     424             :     {
     425             :         // We return the right paint rect. Use the calculated PaintOfst as the
     426             :         // left margin
     427        4630 :         SwRepaint *pRepaint = GetPara()->GetRepaint();
     428             :         long l;
     429             :         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     430        4630 :         if ( IsVertLR() ) // mba: the following line was added, but we don't need it for the existing directions; kept for IsVertLR(), but should be checked
     431           0 :             pRepaint->Chg( ( GetUpper()->Frm() ).Pos() + ( GetUpper()->Prt() ).Pos(), ( GetUpper()->Prt() ).SSize() );
     432             : 
     433        4630 :         if( pRepaint->GetOfst() )
     434         558 :             pRepaint->Left( pRepaint->GetOfst() );
     435             : 
     436        4630 :         l = pRepaint->GetRightOfst();
     437        4630 :         if( l && ( pRepaint->GetOfst() || l > pRepaint->Right() ) )
     438        1105 :              pRepaint->Right( l );
     439        4630 :         pRepaint->SetOfst( 0 );
     440        4630 :         aRet = *pRepaint;
     441             : 
     442        4630 :         if ( IsRightToLeft() )
     443           0 :             SwitchLTRtoRTL( aRet );
     444             : 
     445        4630 :         if ( IsVertical() )
     446           0 :             SwitchHorizontalToVertical( aRet );
     447             :     }
     448        5538 :     ResetRepaint();
     449             : 
     450        5538 :     return aRet;
     451             : }
     452             : 
     453        3028 : sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const
     454             : {
     455        3028 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     456        3028 :     if( pSh && ( pSh->GetViewOptions()->IsParagraph() || bInitFont ) )
     457             :     {
     458          40 :         bInitFont = false;
     459          40 :         SwTxtFly aTxtFly( this );
     460          40 :         aTxtFly.SetTopRule();
     461          40 :         SwRect aRect;
     462          40 :         if( bCheck && aTxtFly.IsOn() && aTxtFly.IsAnyObj( aRect ) )
     463           0 :             return sal_False;
     464          40 :         else if( pSh->GetWin() )
     465             :         {
     466             :             SwFont *pFnt;
     467          37 :             const SwTxtNode& rTxtNode = *GetTxtNode();
     468          37 :             if ( rTxtNode.HasSwAttrSet() )
     469             :             {
     470           3 :                 const SwAttrSet *pAttrSet = &( rTxtNode.GetSwAttrSet() );
     471           3 :                 pFnt = new SwFont( pAttrSet, rTxtNode.getIDocumentSettingAccess() );
     472             :             }
     473             :             else
     474             :             {
     475          34 :                 SwFontAccess aFontAccess( &rTxtNode.GetAnyFmtColl(), pSh );
     476          34 :                 pFnt = new SwFont( *aFontAccess.Get()->GetFont() );
     477             :             }
     478             : 
     479          37 :             const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess();
     480          37 :             if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
     481             :             {
     482          37 :                 MSHORT nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX );
     483          37 :                 if( MSHRT_MAX != nRedlPos )
     484             :                 {
     485           1 :                     SwAttrHandler aAttrHandler;
     486           1 :                     aAttrHandler.Init(  rTxtNode.GetSwAttrSet(),
     487           2 :                                        *rTxtNode.getIDocumentSettingAccess(), NULL );
     488           1 :                     SwRedlineItr aRedln( rTxtNode, *pFnt, aAttrHandler, nRedlPos, sal_True );
     489             :                 }
     490             :             }
     491             : 
     492          37 :             if( pSh->GetViewOptions()->IsParagraph() && Prt().Height() )
     493             :             {
     494          15 :                 if( RTL_TEXTENCODING_SYMBOL == pFnt->GetCharSet( SW_LATIN ) &&
     495           0 :                     pFnt->GetName( SW_LATIN ) != numfunc::GetDefBulletFontname() )
     496             :                 {
     497           0 :                     pFnt->SetFamily( FAMILY_DONTKNOW, SW_LATIN );
     498           0 :                     pFnt->SetName( numfunc::GetDefBulletFontname(), SW_LATIN );
     499           0 :                     pFnt->SetStyleName( aEmptyStr, SW_LATIN );
     500           0 :                     pFnt->SetCharSet( RTL_TEXTENCODING_SYMBOL, SW_LATIN );
     501             :                 }
     502          15 :                 pFnt->SetVertical( 0, IsVertical() );
     503          15 :                 SwFrmSwapper aSwapper( this, sal_True );
     504          30 :                 SwLayoutModeModifier aLayoutModeModifier( *pSh->GetOut() );
     505          15 :                 aLayoutModeModifier.Modify( IsRightToLeft() );
     506             : 
     507          15 :                 pFnt->Invalidate();
     508          15 :                 pFnt->ChgPhysFnt( pSh, *pSh->GetOut() );
     509          15 :                 Point aPos = Frm().Pos() + Prt().Pos();
     510             : 
     511             :                 const SvxLRSpaceItem &rSpace =
     512          15 :                     GetTxtNode()->GetSwAttrSet().GetLRSpace();
     513             : 
     514          15 :                 if ( rSpace.GetTxtFirstLineOfst() > 0 )
     515           0 :                     aPos.X() += rSpace.GetTxtFirstLineOfst();
     516             : 
     517             :                 SwSaveClip *pClip;
     518          15 :                 if( IsUndersized() )
     519             :                 {
     520           0 :                     pClip = new SwSaveClip( pSh->GetOut() );
     521           0 :                     pClip->ChgClip( rRect );
     522             :                 }
     523             :                 else
     524          15 :                     pClip = NULL;
     525             : 
     526          15 :                 aPos.Y() += pFnt->GetAscent( pSh, *pSh->GetOut() );
     527             : 
     528          30 :                 if ( GetTxtNode()->GetSwAttrSet().GetParaGrid().GetValue() &&
     529          15 :                      IsInDocBody() )
     530             :                 {
     531          15 :                     GETGRID( FindPageFrm() )
     532          15 :                     if ( pGrid )
     533             :                     {
     534             :                         // center character in grid line
     535           0 :                         aPos.Y() += ( pGrid->GetBaseHeight() -
     536           0 :                                       pFnt->GetHeight( pSh, *pSh->GetOut() ) ) / 2;
     537             : 
     538           0 :                         if ( ! pGrid->GetRubyTextBelow() )
     539           0 :                             aPos.Y() += pGrid->GetRubyHeight();
     540             :                     }
     541             :                 }
     542             : 
     543             :                 // Don't show the paragraph mark for collapsed paragraphs, when they are hidden
     544          15 :                 if ( EmptyHeight( ) > 1 )
     545             :                 {
     546          15 :                     const OUString aTmp( CH_PAR );
     547          30 :                     SwDrawTextInfo aDrawInf( pSh, *pSh->GetOut(), 0, aTmp, 0, 1 );
     548          15 :                     aDrawInf.SetLeft( rRect.Left() );
     549          15 :                     aDrawInf.SetRight( rRect.Right() );
     550          15 :                     aDrawInf.SetPos( aPos );
     551          15 :                     aDrawInf.SetSpace( 0 );
     552          15 :                     aDrawInf.SetKanaComp( 0 );
     553          15 :                     aDrawInf.SetWrong( NULL );
     554          15 :                     aDrawInf.SetGrammarCheck( NULL );
     555          15 :                     aDrawInf.SetSmartTags( NULL ); // SMARTTAGS
     556          15 :                     aDrawInf.SetFrm( this );
     557          15 :                     aDrawInf.SetFont( pFnt );
     558          15 :                     aDrawInf.SetSnapToGrid( sal_False );
     559             : 
     560          30 :                     pFnt->_DrawText( aDrawInf );
     561             :                 }
     562          30 :                 delete pClip;
     563             :             }
     564          37 :             delete pFnt;
     565          37 :             return sal_True;
     566           3 :         }
     567             :     }
     568             :     else
     569        2988 :         return sal_True;
     570           3 :     return sal_False;
     571             : }
     572             : 
     573        9533 : void SwTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
     574             : {
     575        9533 :     ResetRepaint();
     576             : 
     577             :     // #i16816# tagged pdf support
     578        9533 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     579             : 
     580        9533 :     Num_Info aNumInfo( *this );
     581        9533 :     SwTaggedPDFHelper aTaggedPDFHelperNumbering( &aNumInfo, 0, 0, *pSh->GetOut() );
     582             : 
     583        9533 :     Frm_Info aFrmInfo( *this );
     584       19040 :     SwTaggedPDFHelper aTaggedPDFHelperParagraph( 0, &aFrmInfo, 0, *pSh->GetOut() );
     585             : 
     586        9533 :     if( !IsEmpty() || !PaintEmpty( rRect, sal_True ) )
     587             :     {
     588             : #if OSL_DEBUG_LEVEL > 1
     589             :         const SwTwips nDbgY = Frm().Top();
     590             :         (void)nDbgY;
     591             : #endif
     592             : 
     593        6511 :         if( IsLocked() || IsHiddenNow() || ! Prt().HasArea() )
     594          49 :             return;
     595             : 
     596             :         // It can happen that the IdleCollector withdrew my cached information
     597        6488 :         if( !HasPara() )
     598             :         {
     599             :             OSL_ENSURE( GetValidPosFlag(), "+SwTxtFrm::Paint: no Calc()" );
     600             : 
     601             :             // #i29062# pass info that we are currently
     602             :             // painting.
     603           3 :             ((SwTxtFrm*)this)->GetFormatted( true );
     604           3 :             if( IsEmpty() )
     605             :             {
     606           3 :                 PaintEmpty( rRect, sal_False );
     607           3 :                 return;
     608             :             }
     609           0 :             if( !HasPara() )
     610             :             {
     611             :                 OSL_ENSURE( !this, "+SwTxtFrm::Paint: missing format information" );
     612           0 :                 return;
     613             :             }
     614             :         }
     615             : 
     616             :         // We don't want to be interrupted while painting.
     617             :         // Do that after thr Format()!
     618        6485 :         SwTxtFrmLocker aLock((SwTxtFrm*)this);
     619             : 
     620             :         // We only paint the part of the TxtFrm which changed, is within the
     621             :         // range and was requested to paint.
     622             :         // One could think that the area rRect _needs_ to be painted, although
     623             :         // rRepaint is set. Indeed, we cannot avoid this problem from a formal
     624             :         // perspective. Luckily we can assume rRepaint to be empty when we need
     625             :         // paint the while Frm.
     626       12970 :         SwTxtLineAccess aAccess( (SwTxtFrm*)this );
     627        6485 :         SwParaPortion *pPara = aAccess.GetPara();
     628             : 
     629        6485 :         SwRepaint &rRepaint = *(pPara->GetRepaint());
     630             : 
     631             :         // Switch off recycling when in the FlyCntFrm.
     632             :         // A DrawRect is called for repainting the line anyways.
     633        6485 :         if( rRepaint.GetOfst() )
     634             :         {
     635           1 :             const SwFlyFrm *pFly = FindFlyFrm();
     636           1 :             if( pFly && pFly->IsFlyInCntFrm() )
     637           0 :                 rRepaint.SetOfst( 0 );
     638             :         }
     639             : 
     640             :         // Ge the String for painting. The length is of special interest.
     641             : 
     642             :         // Rectangle
     643             :         OSL_ENSURE( ! IsSwapped(), "A frame is swapped before Paint" );
     644        6485 :         SwRect aOldRect( rRect );
     645             : 
     646        6485 :         SWAP_IF_NOT_SWAPPED( this )
     647             : 
     648        6485 :         if ( IsVertical() )
     649           0 :             SwitchVerticalToHorizontal( (SwRect&)rRect );
     650             : 
     651        6485 :         if ( IsRightToLeft() )
     652           0 :             SwitchRTLtoLTR( (SwRect&)rRect );
     653             : 
     654       12970 :         SwTxtPaintInfo aInf( (SwTxtFrm*)this, rRect );
     655        6485 :         aInf.SetWrongList( ( (SwTxtNode*)GetTxtNode() )->GetWrong() );
     656        6485 :         aInf.SetGrammarCheckList( ( (SwTxtNode*)GetTxtNode() )->GetGrammarCheck() );
     657        6485 :         aInf.SetSmartTags( ( (SwTxtNode*)GetTxtNode() )->GetSmartTags() );  // SMARTTAGS
     658        6485 :         aInf.GetTxtFly()->SetTopRule();
     659             : 
     660       12970 :         SwTxtPainter  aLine( (SwTxtFrm*)this, &aInf );
     661             :         // Optimization: if no free flying Frm overlaps into our line, the
     662             :         // SwTxtFly just switches off
     663        6485 :         aInf.GetTxtFly()->Relax();
     664             : 
     665        6485 :         OutputDevice* pOut = aInf.GetOut();
     666        6485 :         const bool bOnWin = pSh->GetWin() != 0;
     667             : 
     668       12970 :         SwSaveClip aClip( bOnWin || IsUndersized() ? pOut : 0 );
     669             : 
     670             :         // Output loop: For each Line ... (which is still visible) ...
     671             :         //   adapt rRect (Top + 1, Bottom - 1)
     672             :         // Because the Iterator attaches the Lines without a gap to each other
     673        6485 :         aLine.TwipsToLine( rRect.Top() + 1 );
     674        6485 :         long nBottom = rRect.Bottom();
     675             : 
     676        6485 :         bool bNoPrtLine = 0 == GetMinPrtLine();
     677        6485 :         if( !bNoPrtLine )
     678             :         {
     679           0 :             while ( aLine.Y() < GetMinPrtLine() && aLine.Next() )
     680             :                 ;
     681           0 :             bNoPrtLine = aLine.Y() >= GetMinPrtLine();
     682             :         }
     683        6485 :         if( bNoPrtLine )
     684             :         {
     685       12829 :             do
     686             :             {
     687       12829 :                 aLine.DrawTextLine( rRect, aClip, IsUndersized() );
     688             : 
     689       12829 :             } while( aLine.Next() && aLine.Y() <= nBottom );
     690             :         }
     691             : 
     692             :         // Once is enough:
     693        6485 :         if( aLine.IsPaintDrop() )
     694           0 :             aLine.PaintDropPortion();
     695             : 
     696        6485 :         if( rRepaint.HasArea() )
     697        3805 :             rRepaint.Clear();
     698             : 
     699        6485 :         UNDO_SWAP( this )
     700        6485 :         (SwRect&)rRect = aOldRect;
     701             : 
     702        6485 :         OSL_ENSURE( ! IsSwapped(), "A frame is swapped after Paint" );
     703        9507 :     }
     704          99 : }
     705             : 
     706             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10