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

Generated by: LCOV version 1.10