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

Generated by: LCOV version 1.10