LCOV - code coverage report
Current view: top level - sw/source/core/text - pormulti.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 53 81.1 %
Date: 2014-11-03 Functions: 39 46 84.8 %
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_PORMULTI_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_TEXT_PORMULTI_HXX
      21             : 
      22             : #include "porlay.hxx"
      23             : #include "porexp.hxx"
      24             : 
      25             : class SwTxtFormatInfo;
      26             : class SwFldPortion;
      27             : class SwTxtCursor;
      28             : class SwLineLayout;
      29             : class SwTxtPaintInfo;
      30             : class SwTxtAttr;
      31             : class SfxPoolItem;
      32             : class SwFont;
      33             : 
      34             : // SwMultiCreator is a small structure to create a multiportion.
      35             : // It contains the kind of multiportion and a textattribute
      36             : // or a poolitem.
      37             : // The GetMultiCreator-function fills this structure and
      38             : // the Ctor of the SwMultiPortion uses it.
      39             : #define SW_MC_DOUBLE    0
      40             : #define SW_MC_RUBY      1
      41             : #define SW_MC_ROTATE    2
      42             : #define SW_MC_BIDI      3
      43             : 
      44             : struct SwMultiCreator
      45             : {
      46             :     const SwTxtAttr* pAttr;
      47             :     const SfxPoolItem* pItem;
      48             :     sal_uInt8 nId;
      49             :     sal_uInt8 nLevel;
      50             : };
      51             : 
      52             : // A two-line-portion (SwMultiPortion) could have surrounding brackets,
      53             : // in this case the structure SwBracket will be used.
      54             : struct SwBracket
      55             : {
      56             :     sal_Int32 nStart;      // Start of text attribute determins the font
      57             :     sal_uInt16 nAscent;         // Ascent of the brackets
      58             :     sal_uInt16 nHeight;         // Height of them
      59             :     sal_uInt16 nPreWidth;       // Width of the opening bracket
      60             :     sal_uInt16 nPostWidth;      // Width of the closing bracket
      61             :     sal_Unicode cPre;       // Initial character, e.g. '('
      62             :     sal_Unicode cPost;      // Final character, e.g. ')'
      63             :     sal_uInt8 nPreScript;       // Script of the initial character
      64             :     sal_uInt8 nPostScript;       // Script of the final character
      65             : };
      66             : 
      67             : // The SwMultiPortion is line portion inside a line portion,
      68             : // it's a group of portions,
      69             : // e.g. a double line portion in a line
      70             : // or phonetics (ruby)
      71             : // or combined characters
      72             : // or a rotated portion.
      73             : class SwMultiPortion : public SwLinePortion
      74             : {
      75             :     SwLineLayout aRoot;     // One or more lines
      76             :     SwFldPortion *pFldRest; // Field rest from the previous line
      77             :     bool bTab1      :1;     // First line tabulator
      78             :     bool bTab2      :1;     // Second line includes tabulator
      79             :     bool bDouble    :1;     // Double line
      80             :     bool bRuby      :1;     // Phonetics
      81             :     bool bBidi      :1;
      82             :     bool bTop       :1;     // Phonetic position
      83             :     bool bFormatted :1;     // Already formatted
      84             :     bool bFollowFld :1;     // Field follow inside
      85             :     bool bFlyInCntnt:1;     // Fly as character inside
      86             :     sal_uInt8 nDirection:2; // Direction (0/90/180/270 degrees)
      87             : protected:
      88         500 :     SwMultiPortion(sal_Int32 nEnd)
      89             :         : pFldRest(0)
      90             :         , bTab1(false)
      91             :         , bTab2(false)
      92             :         , bDouble(false)
      93             :         , bRuby(false)
      94             :         , bBidi(false)
      95             :         , bTop(false)
      96             :         , bFormatted(false)
      97             :         , bFollowFld(false)
      98             :         , bFlyInCntnt(false)
      99         500 :         , nDirection(0)
     100             :     {
     101         500 :         SetWhichPor(POR_MULTI);
     102         500 :         SetLen(nEnd);
     103         500 :     }
     104          20 :     void SetDouble() { bDouble = true; }
     105         336 :     void SetRuby() { bRuby = true; }
     106          62 :     void SetBidi() { bBidi = true; }
     107         336 :     void SetTop( bool bNew ) { bTop = bNew; }
     108          20 :     void SetTab1( bool bNew ) { bTab1 = bNew; }
     109          20 :     void SetTab2( bool bNew ) { bTab2 = bNew; }
     110         500 :     void SetDirection( sal_uInt8 nNew ) { nDirection = nNew; }
     111           8 :     bool GetTab1() const { return bTab1; }
     112          56 :     bool GetTab2() const { return bTab2; }
     113             : public:
     114             :     virtual ~SwMultiPortion();
     115          22 :     const SwLineLayout& GetRoot() const { return aRoot; }
     116       11376 :     SwLineLayout& GetRoot() { return aRoot; }
     117             :     SwFldPortion* GetFldRest() { return pFldRest; }
     118             :     void SetFldRest( SwFldPortion* pNew ) { pFldRest = pNew; }
     119             : 
     120        2076 :     inline bool HasTabulator() const { return bTab1 || bTab2; }
     121         500 :     inline bool IsFormatted() const { return bFormatted; }
     122         500 :     inline void SetFormatted() { bFormatted = true; }
     123           0 :     inline bool IsFollowFld() const { return bFollowFld; }
     124           0 :     inline void SetFollowFld() { bFollowFld = true; }
     125        1260 :     inline bool HasFlyInCntnt() const { return bFlyInCntnt; }
     126        1076 :     inline void SetFlyInCntnt( bool bNew ) { bFlyInCntnt = bNew; }
     127        5884 :     inline bool IsDouble() const { return bDouble; }
     128        5472 :     inline bool IsRuby() const { return bRuby; }
     129        9470 :     inline bool IsBidi() const { return bBidi; }
     130        3758 :     inline bool OnTop() const { return bTop; }
     131             :     void ActualizeTabulator();
     132             : 
     133             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
     134             :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const SAL_OVERRIDE;
     135             :     virtual bool ChgSpaceAdd( SwLineLayout* pCurr, long nSpaceAdd ) const;
     136             : 
     137             :     // Summarize the internal lines to calculate the (external) size
     138             :     void CalcSize( SwTxtFormatter& rLine, SwTxtFormatInfo &rInf );
     139             : 
     140             :     inline bool HasBrackets() const;
     141        3914 :     inline bool HasRotation() const { return 0 != (1 & nDirection); }
     142           4 :     inline bool IsRevers() const { return 0 != (2 & nDirection); }
     143         382 :     inline sal_uInt8 GetDirection() const { return nDirection; }
     144             :     inline sal_uInt16 GetFontRotation() const
     145             :         { return ( HasRotation() ? ( IsRevers() ? 2700 : 900 ) : 0 ); }
     146             : 
     147             :     // Accessibility: pass information about this portion to the PortionHandler
     148             :     virtual void HandlePortion( SwPortionHandler& rPH ) const SAL_OVERRIDE;
     149             : 
     150             :     OUTPUT_OPERATOR_OVERRIDE
     151             : };
     152             : 
     153             : class SwDoubleLinePortion : public SwMultiPortion
     154             : {
     155             :     SwBracket* pBracket;    // Surrounding brackets
     156             :     SwTwips nLineDiff;      // Difference of the width of the both lines
     157             :     sal_Int32 nBlank1;     // Number of blanks in the first line
     158             :     sal_Int32 nBlank2;     // Number of blanks in the second line
     159             : public:
     160             :     SwDoubleLinePortion( SwDoubleLinePortion& rDouble, sal_Int32 nEnd );
     161             :     SwDoubleLinePortion( const SwMultiCreator& rCreate, sal_Int32 nEnd );
     162             :     virtual ~SwDoubleLinePortion();
     163             : 
     164         854 :     inline SwBracket* GetBrackets() const { return pBracket; }
     165             :     void SetBrackets( const SwDoubleLinePortion& rDouble );
     166             :     void PaintBracket( SwTxtPaintInfo& rInf, long nSpaceAdd, bool bOpen ) const;
     167             :     void FormatBrackets( SwTxtFormatInfo &rInf, SwTwips& nMaxWidth );
     168          88 :     inline sal_uInt16 PreWidth() const { return pBracket->nPreWidth; };
     169          40 :     inline sal_uInt16 PostWidth() const { return pBracket->nPostWidth; }
     170           0 :     inline void ClearBrackets()
     171           0 :         { pBracket->nPreWidth = pBracket->nPostWidth=0; Width( 0 ); }
     172          16 :     inline sal_uInt16 BracketWidth(){ return PreWidth() + PostWidth(); }
     173             : 
     174             :     void CalcBlanks( SwTxtFormatInfo &rInf );
     175             :     static void ResetSpaceAdd( SwLineLayout* pCurr );
     176          40 :     inline SwTwips GetLineDiff() const { return nLineDiff; }
     177           0 :     inline sal_Int32 GetSpaceCnt() const
     178           0 :         { return ( nLineDiff < 0 ) ? nBlank2 : nBlank1; }
     179           0 :     inline sal_Int32 GetSmallerSpaceCnt() const
     180           0 :         { return ( nLineDiff < 0 ) ? nBlank1 : nBlank2; }
     181             :     inline sal_Int32 GetBlank1() const { return nBlank1; }
     182             :     inline sal_Int32 GetBlank2() const { return nBlank2; }
     183             : 
     184             :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const SAL_OVERRIDE;
     185             :     virtual bool ChgSpaceAdd( SwLineLayout* pCurr, long nSpaceAdd ) const SAL_OVERRIDE;
     186             : };
     187             : 
     188         672 : class SwRubyPortion : public SwMultiPortion
     189             : {
     190             :     sal_Int32 nRubyOffset;
     191             :     sal_uInt16 nAdjustment;
     192             :     void _Adjust( SwTxtFormatInfo &rInf);
     193             : public:
     194             :     SwRubyPortion( const SwRubyPortion& rRuby, sal_Int32 nEnd );
     195             : 
     196             :     SwRubyPortion( const SwMultiCreator& rCreate, const SwFont& rFnt,
     197             :                    const IDocumentSettingAccess& rIDocumentSettingAccess,
     198             :                    sal_Int32 nEnd, sal_Int32 nOffs,
     199             :                    const bool* pForceRubyPos );
     200             : 
     201             :     void CalcRubyOffset();
     202         336 :     inline void Adjust( SwTxtFormatInfo &rInf )
     203         336 :         { if(nAdjustment && GetRoot().GetNext()) _Adjust(rInf); }
     204           0 :     inline sal_uInt16 GetAdjustment() const { return nAdjustment; }
     205           0 :     inline sal_Int32 GetRubyOffset() const { return nRubyOffset; }
     206             : };
     207             : 
     208         164 : class SwRotatedPortion : public SwMultiPortion
     209             : {
     210             : public:
     211           2 :     SwRotatedPortion( sal_Int32 nEnd, sal_uInt8 nDir = 1 )
     212           2 :         : SwMultiPortion( nEnd ) { SetDirection( nDir ); }
     213             :     SwRotatedPortion( const SwMultiCreator& rCreate, sal_Int32 nEnd,
     214             :                       bool bRTL );
     215             : };
     216             : 
     217         124 : class SwBidiPortion : public SwMultiPortion
     218             : {
     219             :     sal_uInt8 nLevel;
     220             : 
     221             : public:
     222             :     SwBidiPortion( sal_Int32 nEnd, sal_uInt8 nLv );
     223             : 
     224         344 :     inline sal_uInt8 GetLevel() const { return nLevel; }
     225             :     // Get number of blanks for justified alignment
     226             :     sal_Int32 GetSpaceCnt( const SwTxtSizeInfo &rInf ) const;
     227             :     // Calculates extra spacing based on number of blanks
     228             :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const SAL_OVERRIDE;
     229             :     // Manipulate the spacing array at pCurr
     230             :     virtual bool ChgSpaceAdd( SwLineLayout* pCurr, long nSpaceAdd ) const SAL_OVERRIDE;
     231             : };
     232             : 
     233             : // For cursor travelling in multiportions
     234             : 
     235             : class SwTxtCursorSave
     236             : {
     237             :     SwTxtCursor* pTxtCrsr;
     238             :     SwLineLayout* pCurr;
     239             :     sal_Int32 nStart;
     240             :     sal_uInt16 nWidth;
     241             :     sal_uInt8 nOldProp;
     242             :     bool bSpaceChg;
     243             : public:
     244             :     SwTxtCursorSave( SwTxtCursor* pTxtCursor, SwMultiPortion* pMulti,
     245             :         SwTwips nY, sal_uInt16& nX, sal_Int32 nCurrStart, long nSpaceAdd );
     246             :     ~SwTxtCursorSave();
     247             : };
     248             : 
     249        2728 : inline bool SwMultiPortion::HasBrackets() const
     250             : {
     251        2728 :     return IsDouble() && 0 != ((SwDoubleLinePortion*)this)->GetBrackets();
     252             : }
     253             : 
     254             : #endif
     255             : 
     256             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10