LCOV - code coverage report
Current view: top level - sw/source/core/inc - drawfont.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 186 207 89.9 %
Date: 2014-04-11 Functions: 61 69 88.4 %
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             : #ifndef INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : #include <tools/debug.hxx>
      25             : 
      26             : class SwTxtFrm;
      27             : class OutputDevice;
      28             : class SwViewShell;
      29             : class SwScriptInfo;
      30             : class Point;
      31             : class SwWrongList;
      32             : class Size;
      33             : class SwFont;
      34             : class Font;
      35             : class SwUnderlineFont;
      36             : 
      37             : // encapsulates information for drawing text
      38      108167 : class SwDrawTextInfo
      39             : {
      40             :     const SwTxtFrm* pFrm;
      41             :     OutputDevice* pOut;
      42             :     SwViewShell* pSh;
      43             :     const SwScriptInfo* pScriptInfo;
      44             :     Point m_aPos;
      45             :     OUString m_aText;
      46             :     const SwWrongList* pWrong;
      47             :     const SwWrongList* pGrammarCheck;
      48             :     const SwWrongList* pSmartTags;
      49             :     Size m_aSize;
      50             :     SwFont *pFnt;
      51             :     SwUnderlineFont* pUnderFnt;
      52             :     sal_Int32* pHyphPos;
      53             :     long nLeft;
      54             :     long nRight;
      55             :     long nKanaDiff;
      56             :     sal_Int32 nIdx;
      57             :     sal_Int32 nLen;
      58             :     sal_Int32 nOfst;
      59             :     sal_uInt16 nWidth;
      60             :     sal_uInt16 nAscent;
      61             :     sal_uInt16 nCompress;
      62             :     long nSperren;
      63             :     long nSpace;
      64             :     long nKern;
      65             :     sal_Int32 nNumberOfBlanks;
      66             :     sal_uInt8 nCursorBidiLevel;
      67             :     sal_Bool bBullet : 1;
      68             :     sal_Bool bUpper : 1;        // for small caps: upper case flag
      69             :     sal_Bool bDrawSpace : 1;    // for small caps: underline/ line through
      70             :     sal_Bool bGreyWave  : 1;    // grey wave line for extended text input
      71             :     // For underlining we need to know, if a section is right in front of a
      72             :     // whole block or a fix margin section.
      73             :     sal_Bool bSpaceStop : 1;
      74             :     sal_Bool bSnapToGrid : 1;   // Does paragraph snap to grid?
      75             :     // Paint text as if text has LTR direction, used for line numbering
      76             :     sal_Bool bIgnoreFrmRTL : 1;
      77             :     // GetCrsrOfst should not return the next position if screen position is
      78             :     // inside second half of bound rect, used for Accessibility
      79             :     sal_Bool bPosMatchesBounds :1;
      80             : 
      81             :     SwDrawTextInfo();          // prohibited
      82             : public:
      83             : 
      84             : #ifdef DBG_UTIL
      85             :     // These flags should control that the appropriate Set-function has been
      86             :     // called before calling the Get-function of a member
      87             :     bool m_bPos   : 1;
      88             :     bool m_bWrong : 1;
      89             :     bool m_bGrammarCheck : 1;
      90             :     bool m_bSize  : 1;
      91             :     bool m_bFnt   : 1;
      92             :     bool m_bHyph  : 1;
      93             :     bool m_bLeft  : 1;
      94             :     bool m_bRight : 1;
      95             :     bool m_bKana  : 1;
      96             :     bool m_bOfst  : 1;
      97             :     bool m_bAscent: 1;
      98             :     bool m_bSperr : 1;
      99             :     bool m_bSpace : 1;
     100             :     bool m_bNumberOfBlanks : 1;
     101             :     bool m_bUppr  : 1;
     102             :     bool m_bDrawSp: 1;
     103             : #endif
     104             : 
     105      108167 :     SwDrawTextInfo( SwViewShell *pS, OutputDevice &rO, const SwScriptInfo* pSI,
     106             :                     const OUString &rSt, sal_Int32 nI, sal_Int32 nL,
     107             :                     sal_uInt16 nW = 0, sal_Bool bB = sal_False )
     108      108167 :     {
     109      108167 :         pFrm = NULL;
     110      108167 :         pSh = pS;
     111      108167 :         pOut = &rO;
     112      108167 :         pScriptInfo = pSI;
     113      108167 :         m_aText = rSt;
     114      108167 :         nIdx = nI;
     115      108167 :         nLen = nL;
     116      108167 :         nKern = 0;
     117      108167 :         nCompress = 0;
     118      108167 :         nWidth = nW;
     119      108167 :         nNumberOfBlanks = 0;
     120      108167 :         nCursorBidiLevel = 0;
     121      108167 :         bBullet = bB;
     122      108167 :         pUnderFnt = 0;
     123      108167 :         bGreyWave = sal_False;
     124      108167 :         bSpaceStop = sal_False;
     125      108167 :         bSnapToGrid = sal_False;
     126      108167 :         bIgnoreFrmRTL = sal_False;
     127      108167 :         bPosMatchesBounds = sal_False;
     128             : 
     129             :         // These values are initialized but have to be set explicitly via their
     130             :         // Set-function before they may be accessed by their Get-function:
     131      108167 :         pWrong = 0;
     132      108167 :         pGrammarCheck = 0;
     133      108167 :         pSmartTags = 0;
     134      108167 :         pFnt = 0;
     135      108167 :         pHyphPos = 0;
     136      108167 :         nLeft = 0;
     137      108167 :         nRight = 0;
     138      108167 :         nKanaDiff = 0;
     139      108167 :         nOfst = 0;
     140      108167 :         nAscent = 0;
     141      108167 :         nSperren = 0;
     142      108167 :         nSpace = 0;
     143      108167 :         bUpper = sal_False;
     144      108167 :         bDrawSpace = sal_False;
     145             : 
     146             : #ifdef DBG_UTIL
     147             :         // these flags control whether the matching member variables have been
     148             :         // set by using the Set-function before they may be accessed by their
     149             :         // Get-function:
     150             :         m_bPos = m_bWrong = m_bGrammarCheck = m_bSize = m_bFnt = m_bAscent =
     151             :         m_bSpace = m_bNumberOfBlanks = m_bUppr =
     152             :         m_bDrawSp = m_bLeft = m_bRight = m_bKana = m_bOfst = m_bHyph =
     153             :         m_bSperr = false;
     154             : #endif
     155      108167 :     }
     156             : 
     157      299460 :     const SwTxtFrm* GetFrm() const
     158             :     {
     159      299460 :         return pFrm;
     160             :     }
     161             : 
     162      108157 :     void SetFrm( const SwTxtFrm* pNewFrm )
     163             :     {
     164      108157 :         pFrm = pNewFrm;
     165      108157 :     }
     166             : 
     167      302031 :     SwViewShell *GetShell() const
     168             :     {
     169      302031 :         return pSh;
     170             :     }
     171             : 
     172      738966 :     OutputDevice& GetOut() const
     173             :     {
     174      738966 :         return *pOut;
     175             :     }
     176             : 
     177      157195 :     OutputDevice *GetpOut() const
     178             :     {
     179      157195 :         return pOut;
     180             :     }
     181             : 
     182       14022 :     const SwScriptInfo* GetScriptInfo() const
     183             :     {
     184       14022 :         return pScriptInfo;
     185             :     }
     186             : 
     187       44648 :     const Point &GetPos() const
     188             :     {
     189             : #ifdef DBG_UTIL
     190             :         OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
     191             : #endif
     192       44648 :         return m_aPos;
     193             :     }
     194             : 
     195       29730 :     sal_Int32 *GetHyphPos() const
     196             :     {
     197             : #ifdef DBG_UTIL
     198             :         OSL_ENSURE( m_bHyph, "DrawTextInfo: Undefined Hyph Position" );
     199             : #endif
     200       29730 :         return pHyphPos;
     201             :     }
     202             : 
     203      901184 :     const OUString &GetText() const
     204             :     {
     205      901184 :         return m_aText;
     206             :     }
     207             : 
     208       20139 :     const SwWrongList* GetWrong() const
     209             :     {
     210             : #ifdef DBG_UTIL
     211             :         OSL_ENSURE( m_bWrong, "DrawTextInfo: Undefined WrongList" );
     212             : #endif
     213       20139 :         return pWrong;
     214             :     }
     215             : 
     216       13967 :     const SwWrongList* GetGrammarCheck() const
     217             :     {
     218             : #ifdef DBG_UTIL
     219             :         OSL_ENSURE( m_bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" );
     220             : #endif
     221       13967 :         return pGrammarCheck;
     222             :     }
     223             : 
     224       14197 :     const SwWrongList* GetSmartTags() const
     225             :     {
     226       14197 :         return pSmartTags;
     227             :     }
     228             : 
     229         333 :     const Size &GetSize() const
     230             :     {
     231             : #ifdef DBG_UTIL
     232             :         OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
     233             : #endif
     234         333 :         return m_aSize;
     235             :     }
     236             : 
     237      498132 :     SwFont* GetFont() const
     238             :     {
     239             : #ifdef DBG_UTIL
     240             :         OSL_ENSURE( m_bFnt, "DrawTextInfo: Undefined Font" );
     241             : #endif
     242      498132 :         return pFnt;
     243             :     }
     244             : 
     245       14141 :     SwUnderlineFont* GetUnderFnt() const
     246             :     {
     247       14141 :         return pUnderFnt;
     248             :     }
     249             : 
     250      844920 :     sal_Int32 GetIdx() const
     251             :     {
     252      844920 :         return nIdx;
     253             :     }
     254             : 
     255      623422 :     sal_Int32 GetLen() const
     256             :     {
     257      623422 :         return nLen;
     258             :     }
     259             : 
     260           0 :     sal_Int32 GetOfst() const
     261             :     {
     262             : #ifdef DBG_UTIL
     263             :         OSL_ENSURE( m_bOfst, "DrawTextInfo: Undefined Offset" );
     264             : #endif
     265           0 :         return nOfst;
     266             :     }
     267             : 
     268           2 :     sal_Int32 GetEnd() const
     269             :     {
     270           2 :         return nIdx + nLen;
     271             :     }
     272             : 
     273             :     long GetLeft() const
     274             :     {
     275             : #ifdef DBG_UTIL
     276             :         OSL_ENSURE( m_bLeft, "DrawTextInfo: Undefined left range" );
     277             : #endif
     278             :         return nLeft;
     279             :     }
     280             : 
     281             :     long GetRight() const
     282             :     {
     283             : #ifdef DBG_UTIL
     284             :         OSL_ENSURE( m_bRight, "DrawTextInfo: Undefined right range" );
     285             : #endif
     286             :         return nRight;
     287             :     }
     288             : 
     289       61834 :     long GetKanaDiff() const
     290             :     {
     291             : #ifdef DBG_UTIL
     292             :         OSL_ENSURE( m_bKana, "DrawTextInfo: Undefined kana difference" );
     293             : #endif
     294       61834 :         return nKanaDiff;
     295             :     }
     296             : 
     297          80 :     sal_uInt16 GetWidth() const
     298             :     {
     299          80 :         return nWidth;
     300             :     }
     301             : 
     302         166 :     sal_uInt16 GetAscent() const
     303             :     {
     304             : #ifdef DBG_UTIL
     305             :         OSL_ENSURE( m_bAscent, "DrawTextInfo: Undefined Ascent" );
     306             : #endif
     307         166 :         return nAscent;
     308             :     }
     309             : 
     310       94315 :     sal_uInt16 GetKanaComp() const
     311             :     {
     312       94315 :         return nCompress;
     313             :     }
     314             : 
     315       14091 :     long GetSperren() const
     316             :     {
     317             : #ifdef DBG_UTIL
     318             :         OSL_ENSURE( m_bSperr, "DrawTextInfo: Undefined >Sperren<" );
     319             : #endif
     320       14091 :         return nSperren;
     321             :     }
     322             : 
     323      774873 :     long GetKern() const
     324             :     {
     325      774873 :         return nKern;
     326             :     }
     327             : 
     328       16864 :     long GetSpace() const
     329             :     {
     330             : #ifdef DBG_UTIL
     331             :         OSL_ENSURE( m_bSpace, "DrawTextInfo: Undefined Spacing" );
     332             : #endif
     333       16864 :         return nSpace;
     334             :     }
     335             : 
     336           0 :     sal_Int32 GetNumberOfBlanks() const
     337             :     {
     338             : #ifdef DBG_UTIL
     339             :         OSL_ENSURE( m_bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" );
     340             : #endif
     341           0 :         return nNumberOfBlanks;
     342             :     }
     343             : 
     344           0 :     sal_uInt8 GetCursorBidiLevel() const
     345             :     {
     346           0 :         return nCursorBidiLevel;
     347             :     }
     348             : 
     349       14037 :     sal_Bool GetBullet() const
     350             :     {
     351       14037 :         return bBullet;
     352             :     }
     353             : 
     354         106 :     sal_Bool GetUpper() const
     355             :     {
     356             : #ifdef DBG_UTIL
     357             :         OSL_ENSURE( m_bUppr, "DrawTextInfo: Undefined Upperflag" );
     358             : #endif
     359         106 :         return bUpper;
     360             :     }
     361             : 
     362           2 :     sal_Bool GetDrawSpace() const
     363             :     {
     364             : #ifdef DBG_UTIL
     365             :         OSL_ENSURE( m_bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" );
     366             : #endif
     367           2 :         return bDrawSpace;
     368             :     }
     369             : 
     370       14028 :     sal_Bool GetGreyWave() const
     371             :     {
     372       14028 :         return bGreyWave;
     373             :     }
     374             : 
     375           0 :     sal_Bool IsSpaceStop() const
     376             :     {
     377           0 :         return bSpaceStop;
     378             :     }
     379             : 
     380      216634 :     sal_Bool SnapToGrid() const
     381             :     {
     382      216634 :         return bSnapToGrid;
     383             :     }
     384             : 
     385           4 :     sal_Bool IsIgnoreFrmRTL() const
     386             :     {
     387           4 :         return bIgnoreFrmRTL;
     388             :     }
     389             : 
     390           0 :     sal_Bool IsPosMatchesBounds() const
     391             :     {
     392           0 :         return bPosMatchesBounds;
     393             :     }
     394             : 
     395         224 :     void SetOut( OutputDevice &rNew )
     396             :     {
     397         224 :         pOut = &rNew;
     398         224 :     }
     399             : 
     400       42699 :     void SetPos( const Point &rNew )
     401             :     {
     402       42699 :         m_aPos = rNew;
     403             : #ifdef DBG_UTIL
     404             :         m_bPos = true;
     405             : #endif
     406       42699 :     }
     407             : 
     408       29732 :     void SetHyphPos( sal_Int32 *pNew )
     409             :     {
     410       29732 :         pHyphPos = pNew;
     411             : #ifdef DBG_UTIL
     412             :         m_bHyph = true;
     413             : #endif
     414       29732 :     }
     415             : 
     416       65345 :     void SetText( const OUString &rNew )
     417             :     {
     418       65345 :         m_aText = rNew;
     419       65345 :     }
     420             : 
     421       14037 :     void SetWrong( const SwWrongList* pNew )
     422             :     {
     423       14037 :         pWrong = pNew;
     424             : #ifdef DBG_UTIL
     425             :         m_bWrong = true;
     426             : #endif
     427       14037 :     }
     428             : 
     429       14037 :     void SetGrammarCheck( const SwWrongList* pNew )
     430             :     {
     431       14037 :         pGrammarCheck = pNew;
     432             : #ifdef DBG_UTIL
     433             :         m_bGrammarCheck = true;
     434             : #endif
     435       14037 :     }
     436             : 
     437       14037 :     void SetSmartTags( const SwWrongList* pNew )
     438             :     {
     439       14037 :         pSmartTags = pNew;
     440       14037 :     }
     441             : 
     442         278 :     void SetSize( const Size &rNew )
     443             :     {
     444         278 :         m_aSize = rNew;
     445             : #ifdef DBG_UTIL
     446             :         m_bSize = true;
     447             : #endif
     448         278 :     }
     449             : 
     450      172598 :     void SetFont( SwFont* pNew )
     451             :     {
     452      172598 :         pFnt = pNew;
     453             : #ifdef DBG_UTIL
     454             :         m_bFnt = true;
     455             : #endif
     456      172598 :     }
     457             : 
     458         218 :     void SetIdx( sal_Int32 nNew )
     459             :     {
     460         218 :         nIdx = nNew;
     461         218 :     }
     462             : 
     463       64761 :     void SetLen( sal_Int32 nNew )
     464             :     {
     465       64761 :         nLen = nNew;
     466       64761 :     }
     467             : 
     468           0 :     void SetOfst( sal_Int32 nNew )
     469             :     {
     470           0 :         nOfst = nNew;
     471             : #ifdef DBG_UTIL
     472             :         m_bOfst = true;
     473             : #endif
     474           0 :     }
     475             : 
     476       14041 :     void SetLeft( long nNew )
     477             :     {
     478       14041 :         nLeft = nNew;
     479             : #ifdef DBG_UTIL
     480             :         m_bLeft = true;
     481             : #endif
     482       14041 :     }
     483             : 
     484       14041 :     void SetRight( long nNew )
     485             :     {
     486       14041 :         nRight = nNew;
     487             : #ifdef DBG_UTIL
     488             :         m_bRight = true;
     489             : #endif
     490       14041 :     }
     491             : 
     492       64609 :     void SetKanaDiff( long nNew )
     493             :     {
     494       64609 :         nKanaDiff = nNew;
     495             : #ifdef DBG_UTIL
     496             :         m_bKana = true;
     497             : #endif
     498       64609 :     }
     499             : 
     500          56 :     void SetWidth( sal_uInt16 nNew )
     501             :     {
     502          56 :         nWidth = nNew;
     503          56 :     }
     504             : 
     505         166 :     void SetAscent( sal_uInt16 nNew )
     506             :     {
     507         166 :         nAscent = nNew;
     508             : #ifdef DBG_UTIL
     509             :         m_bAscent = true;
     510             : #endif
     511         166 :     }
     512             : 
     513      143237 :     void SetKern( long nNew )
     514             :     {
     515      143237 :         nKern = nNew;
     516      143237 :     }
     517             : 
     518       14078 :     void SetSpace( long nNew )
     519             :     {
     520       14078 :         if( nNew < 0 )
     521             :         {
     522           0 :             nSperren = -nNew;
     523           0 :             nSpace = 0;
     524             :         }
     525             :         else
     526             :         {
     527       14078 :             nSpace = nNew;
     528       14078 :             nSperren = 0;
     529             :         }
     530             : #ifdef DBG_UTIL
     531             :         m_bSpace = true;
     532             :         m_bSperr = true;
     533             : #endif
     534       14078 :     }
     535             : 
     536         228 :     void SetNumberOfBlanks( sal_Int32 nNew )
     537             :     {
     538             : #ifdef DBG_UTIL
     539             :         m_bNumberOfBlanks = true;
     540             : #endif
     541         228 :         nNumberOfBlanks = nNew;
     542         228 :     }
     543             : 
     544           0 :     void SetCursorBidiLevel( sal_uInt8 nNew )
     545             :     {
     546           0 :         nCursorBidiLevel = nNew;
     547           0 :     }
     548             : 
     549      108112 :     void SetKanaComp( short nNew )
     550             :     {
     551      108112 :         nCompress = nNew;
     552      108112 :     }
     553             : 
     554           6 :     void SetBullet( sal_Bool bNew )
     555             :     {
     556           6 :         bBullet = bNew;
     557           6 :     }
     558             : 
     559       14082 :     void SetUnderFnt( SwUnderlineFont* pULFnt )
     560             :     {
     561       14082 :         pUnderFnt = pULFnt;
     562       14082 :     }
     563             : 
     564         112 :     void SetUpper( sal_Bool bNew )
     565             :     {
     566         112 :         bUpper = bNew;
     567             : #ifdef DBG_UTIL
     568             :         m_bUppr = true;
     569             : #endif
     570         112 :     }
     571             : 
     572          40 :     void SetDrawSpace( sal_Bool bNew )
     573             :     {
     574          40 :         bDrawSpace = bNew;
     575             : #ifdef DBG_UTIL
     576             :         m_bDrawSp = true;
     577             : #endif
     578          40 :     }
     579             : 
     580       14034 :     void SetGreyWave( sal_Bool bNew )
     581             :     {
     582       14034 :         bGreyWave = bNew;
     583       14034 :     }
     584             : 
     585       13982 :     void SetSpaceStop( sal_Bool bNew )
     586             :     {
     587       13982 :         bSpaceStop = bNew;
     588       13982 :     }
     589             : 
     590      108157 :     void SetSnapToGrid( sal_Bool bNew )
     591             :     {
     592      108157 :         bSnapToGrid = bNew;
     593      108157 :     }
     594             : 
     595          47 :     void SetIgnoreFrmRTL( sal_Bool bNew )
     596             :     {
     597          47 :         bIgnoreFrmRTL = bNew;
     598          47 :     }
     599             : 
     600           0 :     void SetPosMatchesBounds( sal_Bool bNew )
     601             :     {
     602           0 :         bPosMatchesBounds = bNew;
     603           0 :     }
     604             : 
     605             :     void Shift( sal_uInt16 nDir );
     606             : 
     607             :     // sets a new color at the output device if necessary if a font is passed
     608             :     // as argument, the change if made to the font otherwise the font at the
     609             :     // output device is changed returns if the font has been changed
     610             :     sal_Bool ApplyAutoColor( Font* pFnt = 0 );
     611             : };
     612             : 
     613             : #endif
     614             : 
     615             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10