LCOV - code coverage report
Current view: top level - sw/source/core/text - porfld.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 27 40 67.5 %
Date: 2014-11-03 Functions: 29 40 72.5 %
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             : #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_PORFLD_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_TEXT_PORFLD_HXX
      21             : 
      22             : #include "swtypes.hxx"
      23             : #include "porexp.hxx"
      24             : #include <fmtornt.hxx>
      25             : 
      26             : class SwFont;
      27             : class SvxBrushItem;
      28             : class SwFmtVertOrient;
      29             : class SwFrm;
      30             : 
      31             : class SwFldPortion : public SwExpandPortion
      32             : {
      33             :     friend class SwTxtFormatter;
      34             : protected:
      35             :     OUString  aExpand;              // The expanded field
      36             :     SwFont  *pFnt;                  // For multi-line fields
      37             :     sal_Int32 nNextOffset;         // Offset of the follow in the original string
      38             :     sal_Int32 nNextScriptChg;
      39             :     sal_uInt16  nViewWidth;             // Screen width for empty fields
      40             :     bool bFollow : 1;           // 2nd or later part of a field
      41             :     bool bLeft : 1;             // Used by SwNumberPortion
      42             :     bool bHide : 1;             // Used by SwNumberPortion
      43             :     bool bCenter : 1;           // Used by SwNumberPortion
      44             :     bool bHasFollow : 1;        // Continues on the next line
      45             :     bool bAnimated : 1;         // Used by SwGrfNumPortion
      46             :     bool bNoPaint : 1;          // Used by SwGrfNumPortion
      47             :     bool bReplace : 1;          // Used by SwGrfNumPortion
      48             :     const bool bPlaceHolder : 1;
      49             :     bool m_bNoLength : 1;       // HACK for meta suffix (no CH_TXTATR)
      50             : 
      51          28 :     inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
      52          18 :     inline bool IsNoLength() const  { return m_bNoLength; }
      53          40 :     inline void SetNoLength()       { m_bNoLength = true; }
      54             : 
      55             : public:
      56             :     SwFldPortion( const SwFldPortion& rFld );
      57             :     SwFldPortion( const OUString &rExpand, SwFont *pFnt = 0, bool bPlaceHolder = false );
      58             :     virtual ~SwFldPortion();
      59             : 
      60             :     sal_uInt16 m_nAttrFldType;
      61             :     void TakeNextOffset( const SwFldPortion* pFld );
      62             :     void CheckScript( const SwTxtSizeInfo &rInf );
      63       16458 :     inline bool HasFont() const { return 0 != pFnt; }
      64             :     // #i89179# - made public
      65       43060 :     inline const SwFont *GetFont() const { return pFnt; }
      66             : 
      67         346 :     inline OUString GetExp() const { return aExpand; }
      68             :     virtual bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const SAL_OVERRIDE;
      69             :     virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
      70             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
      71             : 
      72             :     // Empty fields are also allowed
      73             :     virtual SwLinePortion *Compress() SAL_OVERRIDE;
      74             : 
      75             :     virtual sal_uInt16 GetViewWidth( const SwTxtSizeInfo &rInf ) const SAL_OVERRIDE;
      76             : 
      77       72654 :     inline bool IsFollow() const { return bFollow; }
      78        8720 :     inline void SetFollow( bool bNew ) { bFollow = bNew; }
      79             : 
      80        8594 :     inline bool IsLeft() const { return bLeft; }
      81       17046 :     inline void SetLeft( bool bNew ) { bLeft = bNew; }
      82             : 
      83        9454 :     inline bool IsHide() const { return bHide; }
      84       33620 :     inline void SetHide( bool bNew ) { bHide = bNew; }
      85             : 
      86        8030 :     inline bool IsCenter() const { return bCenter; }
      87       16810 :     inline void SetCenter( bool bNew ) { bCenter = bNew; }
      88             : 
      89        2700 :     inline bool HasFollow() const { return bHasFollow; }
      90        8048 :     inline void SetHasFollow( bool bNew ) { bHasFollow = bNew; }
      91             : 
      92          10 :     inline sal_Int32 GetNextOffset() const { return nNextOffset; }
      93        8748 :     inline void SetNextOffset( sal_Int32 nNew ) { nNextOffset = nNew; }
      94             : 
      95          10 :     inline sal_Int32 GetNextScriptChg() const { return nNextScriptChg; }
      96             :     inline void SetNextScriptChg( sal_Int32 nNew ) { nNextScriptChg = nNew; }
      97             : 
      98             :     // Field cloner for SplitGlue
      99             :     virtual SwFldPortion *Clone( const OUString &rExpand ) const;
     100             : 
     101             :     // Extra GetTxtSize because of pFnt
     102             :     virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const SAL_OVERRIDE;
     103             : 
     104             :     // Accessibility: pass information about this portion to the PortionHandler
     105             :     virtual void HandlePortion( SwPortionHandler& rPH ) const SAL_OVERRIDE;
     106             : 
     107             :     OUTPUT_OPERATOR_OVERRIDE
     108             : };
     109             : 
     110             : // Distinguish only for painting/hide
     111             : 
     112           0 : class SwHiddenPortion : public SwFldPortion
     113             : {
     114             : public:
     115           0 :     inline SwHiddenPortion( const OUString &rExpand, SwFont *pFntL = 0 )
     116           0 :          : SwFldPortion( rExpand, pFntL )
     117           0 :         { SetLen(1); SetWhichPor( POR_HIDDEN ); }
     118             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
     119             :     virtual bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const SAL_OVERRIDE;
     120             : 
     121             :     // Field cloner for SplitGlue
     122             :     virtual SwFldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     123             :     OUTPUT_OPERATOR_OVERRIDE
     124             : };
     125             : 
     126       27144 : class SwNumberPortion : public SwFldPortion
     127             : {
     128             : protected:
     129             :     sal_uInt16  nFixWidth;      // See Glues
     130             :     sal_uInt16  nMinDist;       // Minimal distance to the text
     131             :     bool    mbLabelAlignmentPosAndSpaceModeActive;
     132             : 
     133             : public:
     134             :     SwNumberPortion( const OUString &rExpand,
     135             :                      SwFont *pFnt,
     136             :                      const bool bLeft,
     137             :                      const bool bCenter,
     138             :                      const sal_uInt16 nMinDst,
     139             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     140             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
     141             :     virtual sal_Int32 GetCrsrOfst( const sal_uInt16 nOfst ) const SAL_OVERRIDE;
     142             :     virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
     143             : 
     144             :     // Field cloner for SplitGlue
     145             :     virtual SwFldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     146             :     virtual void FormatEOL( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
     147             : 
     148             :     OUTPUT_OPERATOR_OVERRIDE
     149             : };
     150             : 
     151       12200 : class SwBulletPortion : public SwNumberPortion
     152             : {
     153             : public:
     154             :     SwBulletPortion( const sal_Unicode cCh,
     155             :                      const OUString& rBulletFollowedBy,
     156             :                      SwFont *pFnt,
     157             :                      const bool bLeft,
     158             :                      const bool bCenter,
     159             :                      const sal_uInt16 nMinDst,
     160             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     161             :     OUTPUT_OPERATOR_OVERRIDE
     162             : };
     163             : 
     164             : class SwGrfNumPortion : public SwNumberPortion
     165             : {
     166             :     SvxBrushItem* pBrush;
     167             :     long            nId;    // For StopAnimation
     168             :     SwTwips         nYPos;  // _Always_ contains the current RelPos
     169             :     SwTwips         nGrfHeight;
     170             :     sal_Int16       eOrient;
     171             : public:
     172             :     SwGrfNumPortion( SwFrm *pFrm,
     173             :                      const OUString& rGraphicFollowedBy,
     174             :                      const SvxBrushItem* pGrfBrush,
     175             :                      const SwFmtVertOrient* pGrfOrient,
     176             :                      const Size& rGrfSize,
     177             :                      const bool bLeft,
     178             :                      const bool bCenter,
     179             :                      const sal_uInt16 nMinDst,
     180             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     181             :     virtual ~SwGrfNumPortion();
     182             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
     183             :     virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
     184             : 
     185             :     void SetBase( long nLnAscent, long nLnDescent,
     186             :         long nFlyAscent, long nFlyDescent );
     187             : 
     188             :     void StopAnimation( OutputDevice* pOut );
     189             : 
     190         140 :     inline bool IsAnimated() const { return bAnimated; }
     191         280 :     inline void SetAnimated( bool bNew ) { bAnimated = bNew; }
     192           0 :     inline bool DontPaint() const { return bNoPaint; }
     193           0 :     inline void SetNoPaint( bool bNew ) { bNoPaint = bNew; }
     194         280 :     inline void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
     195           0 :     inline void SetId( long nNew ) const
     196           0 :         { ((SwGrfNumPortion*)this)->nId = nNew; }
     197         210 :     inline SwTwips GetRelPos() const { return nYPos; }
     198         140 :     inline SwTwips GetGrfHeight() const { return nGrfHeight; }
     199             :     inline SwTwips GetId() const { return nId; }
     200         420 :     inline sal_Int16 GetOrient() const { return eOrient; }
     201             : 
     202             :     OUTPUT_OPERATOR_OVERRIDE
     203             : };
     204             : 
     205             : // Used in for asian layout specialities to display up to six characters
     206             : // in 2 rows and 2-3 columns.
     207             : // e.g.
     208             : //
     209             : //       A..  A..  A.B  A.B   A.B.C   A.B.C
     210             : //       ...  ..B  .C.  C.D   .D.E.   D.E.F
     211           0 : class SwCombinedPortion : public SwFldPortion
     212             : {
     213             :     sal_uInt16 aPos[6];     // up to six X positions
     214             :     sal_uInt16 aWidth[3];   // one width for every scripttype
     215             :     sal_uInt8 aScrType[6];  // scripttype of every character
     216             :     sal_uInt16 nUpPos;      // the Y position of the upper baseline
     217             :     sal_uInt16 nLowPos;     // the Y position of the lower baseline
     218             :     sal_uInt8 nProportion;  // relative font height
     219             : public:
     220             :     SwCombinedPortion( const OUString &rExpand );
     221             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
     222             :     virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
     223             :     virtual sal_uInt16 GetViewWidth( const SwTxtSizeInfo &rInf ) const SAL_OVERRIDE;
     224             :     OUTPUT_OPERATOR_OVERRIDE
     225             : };
     226             : 
     227             : namespace sw { namespace mark {
     228             :     class IFieldmark;
     229             : } }
     230             : 
     231           0 : class SwFieldFormDropDownPortion : public SwFldPortion
     232             : {
     233             : public:
     234           0 :     SwFieldFormDropDownPortion(const OUString &rExpand)
     235           0 :         : SwFldPortion(rExpand)
     236             :     {
     237           0 :     }
     238             :     // Field cloner for SplitGlue
     239             :     virtual SwFldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     240             : };
     241             : 
     242             : #endif
     243             : 
     244             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10