LCOV - code coverage report
Current view: top level - sw/source/core/text - porfld.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 27 40 67.5 %
Date: 2015-06-13 12:38:46 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 SwFormatVertOrient;
      29             : class SwFrm;
      30             : 
      31             : class SwFieldPortion : public SwExpandPortion
      32             : {
      33             :     friend class SwTextFormatter;
      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          23 :     inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
      52          10 :     inline bool IsNoLength() const  { return m_bNoLength; }
      53          30 :     inline void SetNoLength()       { m_bNoLength = true; }
      54             : 
      55             : public:
      56             :     SwFieldPortion( const SwFieldPortion& rField );
      57             :     SwFieldPortion( const OUString &rExpand, SwFont *pFnt = 0, bool bPlaceHolder = false );
      58             :     virtual ~SwFieldPortion();
      59             : 
      60             :     sal_uInt16 m_nAttrFieldType;
      61             :     void TakeNextOffset( const SwFieldPortion* pField );
      62             :     void CheckScript( const SwTextSizeInfo &rInf );
      63       12730 :     inline bool HasFont() const { return 0 != pFnt; }
      64             :     // #i89179# - made public
      65       41463 :     inline const SwFont *GetFont() const { return pFnt; }
      66             : 
      67         170 :     inline OUString GetExp() const { return aExpand; }
      68             :     virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const SAL_OVERRIDE;
      69             :     virtual bool Format( SwTextFormatInfo &rInf ) SAL_OVERRIDE;
      70             :     virtual void Paint( const SwTextPaintInfo &rInf ) const SAL_OVERRIDE;
      71             : 
      72             :     // Empty fields are also allowed
      73             :     virtual SwLinePortion *Compress() SAL_OVERRIDE;
      74             : 
      75             :     virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const SAL_OVERRIDE;
      76             : 
      77       62146 :     inline bool IsFollow() const { return bFollow; }
      78        9071 :     inline void SetFollow( bool bNew ) { bFollow = bNew; }
      79             : 
      80        9380 :     inline bool IsLeft() const { return bLeft; }
      81       16024 :     inline void SetLeft( bool bNew ) { bLeft = bNew; }
      82             : 
      83        7826 :     inline bool IsHide() const { return bHide; }
      84       31744 :     inline void SetHide( bool bNew ) { bHide = bNew; }
      85             : 
      86        8747 :     inline bool IsCenter() const { return bCenter; }
      87       15878 :     inline void SetCenter( bool bNew ) { bCenter = bNew; }
      88             : 
      89        1956 :     inline bool HasFollow() const { return bHasFollow; }
      90        8757 :     inline void SetHasFollow( bool bNew ) { bHasFollow = bNew; }
      91             : 
      92          13 :     inline sal_Int32 GetNextOffset() const { return nNextOffset; }
      93        9094 :     inline void SetNextOffset( sal_Int32 nNew ) { nNextOffset = nNew; }
      94             : 
      95          13 :     inline sal_Int32 GetNextScriptChg() const { return nNextScriptChg; }
      96             :     inline void SetNextScriptChg( sal_Int32 nNew ) { nNextScriptChg = nNew; }
      97             : 
      98             :     // Field cloner for SplitGlue
      99             :     virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
     100             : 
     101             :     // Extra GetTextSize because of pFnt
     102             :     virtual SwPosSize GetTextSize( const SwTextSizeInfo &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             : /**
     111             :  * Distinguish only for painting/hide
     112             :  */
     113           0 : class SwHiddenPortion : public SwFieldPortion
     114             : {
     115             : public:
     116           0 :     inline SwHiddenPortion( const OUString &rExpand, SwFont *pFntL = 0 )
     117           0 :          : SwFieldPortion( rExpand, pFntL )
     118           0 :         { SetLen(1); SetWhichPor( POR_HIDDEN ); }
     119             :     virtual void Paint( const SwTextPaintInfo &rInf ) const SAL_OVERRIDE;
     120             :     virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const SAL_OVERRIDE;
     121             : 
     122             :     // Field cloner for SplitGlue
     123             :     virtual SwFieldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     124             :     OUTPUT_OPERATOR_OVERRIDE
     125             : };
     126             : 
     127       29097 : class SwNumberPortion : public SwFieldPortion
     128             : {
     129             : protected:
     130             :     sal_uInt16  nFixWidth;      // See Glues
     131             :     sal_uInt16  nMinDist;       // Minimal distance to the text
     132             :     bool    mbLabelAlignmentPosAndSpaceModeActive;
     133             : 
     134             : public:
     135             :     SwNumberPortion( const OUString &rExpand,
     136             :                      SwFont *pFnt,
     137             :                      const bool bLeft,
     138             :                      const bool bCenter,
     139             :                      const sal_uInt16 nMinDst,
     140             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     141             :     virtual void Paint( const SwTextPaintInfo &rInf ) const SAL_OVERRIDE;
     142             :     virtual sal_Int32 GetCrsrOfst( const sal_uInt16 nOfst ) const SAL_OVERRIDE;
     143             :     virtual bool Format( SwTextFormatInfo &rInf ) SAL_OVERRIDE;
     144             : 
     145             :     // Field cloner for SplitGlue
     146             :     virtual SwFieldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     147             :     virtual void FormatEOL( SwTextFormatInfo &rInf ) SAL_OVERRIDE;
     148             : 
     149             :     OUTPUT_OPERATOR_OVERRIDE
     150             : };
     151             : 
     152        4886 : class SwBulletPortion : public SwNumberPortion
     153             : {
     154             : public:
     155             :     SwBulletPortion( const sal_Unicode cCh,
     156             :                      const OUString& rBulletFollowedBy,
     157             :                      SwFont *pFnt,
     158             :                      const bool bLeft,
     159             :                      const bool bCenter,
     160             :                      const sal_uInt16 nMinDst,
     161             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     162             :     OUTPUT_OPERATOR_OVERRIDE
     163             : };
     164             : 
     165             : class SwGrfNumPortion : public SwNumberPortion
     166             : {
     167             :     SvxBrushItem* pBrush;
     168             :     long            nId;    // For StopAnimation
     169             :     SwTwips         nYPos;  // _Always_ contains the current RelPos
     170             :     SwTwips         nGrfHeight;
     171             :     sal_Int16       eOrient;
     172             : public:
     173             :     SwGrfNumPortion( SwFrm *pFrm,
     174             :                      const OUString& rGraphicFollowedBy,
     175             :                      const SvxBrushItem* pGrfBrush,
     176             :                      const SwFormatVertOrient* pGrfOrient,
     177             :                      const Size& rGrfSize,
     178             :                      const bool bLeft,
     179             :                      const bool bCenter,
     180             :                      const sal_uInt16 nMinDst,
     181             :                      const bool bLabelAlignmentPosAndSpaceModeActive );
     182             :     virtual ~SwGrfNumPortion();
     183             :     virtual void Paint( const SwTextPaintInfo &rInf ) const SAL_OVERRIDE;
     184             :     virtual bool Format( SwTextFormatInfo &rInf ) SAL_OVERRIDE;
     185             : 
     186             :     void SetBase( long nLnAscent, long nLnDescent,
     187             :         long nFlyAscent, long nFlyDescent );
     188             : 
     189             :     void StopAnimation( OutputDevice* pOut );
     190             : 
     191          70 :     inline bool IsAnimated() const { return bAnimated; }
     192         140 :     inline void SetAnimated( bool bNew ) { bAnimated = bNew; }
     193           0 :     inline bool DontPaint() const { return bNoPaint; }
     194           0 :     inline void SetNoPaint( bool bNew ) { bNoPaint = bNew; }
     195         140 :     inline void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
     196           0 :     inline void SetId( long nNew ) const
     197           0 :         { const_cast<SwGrfNumPortion*>(this)->nId = nNew; }
     198         105 :     inline SwTwips GetRelPos() const { return nYPos; }
     199          70 :     inline SwTwips GetGrfHeight() const { return nGrfHeight; }
     200             :     inline SwTwips GetId() const { return nId; }
     201         210 :     inline sal_Int16 GetOrient() const { return eOrient; }
     202             : 
     203             :     OUTPUT_OPERATOR_OVERRIDE
     204             : };
     205             : 
     206             : /**
     207             :  * Used in for asian layout specialities to display up to six characters
     208             :  * in 2 rows and 2-3 columns.
     209             :  * E.g.: <pre>
     210             :  *        A..  A..  A.B  A.B   A.B.C   A.B.C
     211             :  *        ...  ..B  .C.  C.D   .D.E.   D.E.F
     212             :  *        </pre>
     213             :  */
     214           0 : class SwCombinedPortion : public SwFieldPortion
     215             : {
     216             :     sal_uInt16 aPos[6];     // up to six X positions
     217             :     sal_uInt16 aWidth[3];   // one width for every scripttype
     218             :     sal_uInt8 aScrType[6];  // scripttype of every character
     219             :     sal_uInt16 nUpPos;      // the Y position of the upper baseline
     220             :     sal_uInt16 nLowPos;     // the Y position of the lower baseline
     221             :     sal_uInt8 nProportion;  // relative font height
     222             : public:
     223             :     explicit SwCombinedPortion( const OUString &rExpand );
     224             :     virtual void Paint( const SwTextPaintInfo &rInf ) const SAL_OVERRIDE;
     225             :     virtual bool Format( SwTextFormatInfo &rInf ) SAL_OVERRIDE;
     226             :     virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const SAL_OVERRIDE;
     227             :     OUTPUT_OPERATOR_OVERRIDE
     228             : };
     229             : 
     230             : namespace sw { namespace mark {
     231             :     class IFieldmark;
     232             : } }
     233             : 
     234           0 : class SwFieldFormDropDownPortion : public SwFieldPortion
     235             : {
     236             : public:
     237           0 :     explicit SwFieldFormDropDownPortion(const OUString &rExpand)
     238           0 :         : SwFieldPortion(rExpand)
     239             :     {
     240           0 :     }
     241             :     // Field cloner for SplitGlue
     242             :     virtual SwFieldPortion *Clone( const OUString &rExpand ) const SAL_OVERRIDE;
     243             : };
     244             : 
     245             : #endif
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11