LCOV - code coverage report
Current view: top level - vcl/source/edit - textdat2.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 74 0.0 %
Date: 2014-04-14 Functions: 0 47 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             : 
      20             : #ifndef INCLUDED_VCL_SOURCE_EDIT_TEXTDAT2_HXX
      21             : #define INCLUDED_VCL_SOURCE_EDIT_TEXTDAT2_HXX
      22             : 
      23             : #include <vcl/seleng.hxx>
      24             : #include <vcl/virdev.hxx>
      25             : #include <vcl/cursor.hxx>
      26             : 
      27             : #include <vector>
      28             : 
      29             : class TextNode;
      30             : class TextView;
      31             : 
      32             : #define PORTIONKIND_TEXT        0
      33             : #define PORTIONKIND_TAB         1
      34             : 
      35             : #define DELMODE_SIMPLE          0
      36             : #define DELMODE_RESTOFWORD      1
      37             : #define DELMODE_RESTOFCONTENT   2
      38             : 
      39             : #define DEL_LEFT    1
      40             : #define DEL_RIGHT   2
      41             : #define TRAVEL_X_DONTKNOW   0xFFFF
      42             : #define MAXCHARSINPARA      0x3FFF-CHARPOSGROW
      43             : 
      44             : #define LINE_SEP    0x0A
      45             : 
      46             : class TETextPortion
      47             : {
      48             : private:
      49             :     sal_uInt16      nLen;
      50             :     long        nWidth;
      51             :     sal_uInt8       nKind;
      52             :     sal_uInt8        nRightToLeft;
      53             : 
      54             :                 TETextPortion()             { nLen = 0; nKind = PORTIONKIND_TEXT; nWidth = -1; nRightToLeft = 0;}
      55             : 
      56             : public:
      57           0 :                 TETextPortion( sal_uInt16 nL )  {
      58           0 :                                                 nLen = nL;
      59           0 :                                                 nKind = PORTIONKIND_TEXT;
      60           0 :                                                 nWidth= -1;
      61           0 :                                                 nRightToLeft = 0;
      62           0 :                                             }
      63             : 
      64             :     sal_uInt16      GetLen() const              { return nLen; }
      65           0 :     sal_uInt16&     GetLen()                    { return nLen; }
      66             : 
      67             :     long        GetWidth()const             { return nWidth; }
      68           0 :     long&       GetWidth()                  { return nWidth; }
      69             : 
      70             :     sal_uInt8       GetKind() const             { return nKind; }
      71           0 :     sal_uInt8&      GetKind()                   { return nKind; }
      72             : 
      73             :     sal_uInt8       GetRightToLeft() const      { return nRightToLeft; }
      74           0 :     sal_uInt8&      GetRightToLeft()            { return nRightToLeft; }
      75           0 :     bool        IsRightToLeft() const       { return (nRightToLeft&1); }
      76             : 
      77           0 :     bool        HasValidSize() const        { return nWidth != (-1); }
      78             : };
      79             : 
      80             : typedef std::vector<TETextPortion*> TextPortionArray;
      81             : 
      82             : class TETextPortionList : public TextPortionArray
      83             : {
      84             : public:
      85             :     TETextPortionList();
      86             :     ~TETextPortionList();
      87             : 
      88             :     void    Reset();
      89             :     sal_uInt16  FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false );
      90             :     sal_uInt16  GetPortionStartIndex( sal_uInt16 nPortion );
      91             :     void    DeleteFromPortion( sal_uInt16 nDelFrom );
      92             : };
      93             : 
      94             : struct TEWritingDirectionInfo
      95             : {
      96             :     sal_uInt8    nType;
      97             :     sal_uInt16  nStartPos;
      98             :     sal_uInt16  nEndPos;
      99           0 :     TEWritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
     100             :     {
     101           0 :         nType = _Type;
     102           0 :         nStartPos = _Start;
     103           0 :         nEndPos = _End;
     104           0 :     }
     105             : };
     106             : 
     107             : class TextLine
     108             : {
     109             : private:
     110             :     sal_uInt16          mnStart;
     111             :     sal_uInt16          mnEnd;
     112             :     sal_uInt16          mnStartPortion;
     113             :     sal_uInt16          mnEndPortion;
     114             : 
     115             :     short           mnStartX;
     116             : 
     117             :     bool            mbInvalid;  // fuer geschickte Formatierung/Ausgabe
     118             : 
     119             : public:
     120           0 :                     TextLine()  {
     121           0 :                                     mnStart = mnEnd = 0;
     122           0 :                                     mnStartPortion = mnEndPortion = 0;
     123           0 :                                     mnStartX = 0;
     124           0 :                                     mbInvalid = true;
     125           0 :                                 }
     126             : 
     127             :     bool            IsIn( sal_uInt16 nIndex ) const
     128             :                         { return ( (nIndex >= mnStart ) && ( nIndex < mnEnd ) ); }
     129             : 
     130           0 :     bool            IsIn( sal_uInt16 nIndex, bool bInclEnd ) const
     131           0 :                         { return ( ( nIndex >= mnStart ) && ( bInclEnd ? ( nIndex <= mnEnd ) : ( nIndex < mnEnd ) ) ); }
     132             : 
     133           0 :     void            SetStart( sal_uInt16 n )            { mnStart = n; }
     134           0 :     sal_uInt16          GetStart() const                { return mnStart; }
     135           0 :     sal_uInt16&         GetStart()                      { return mnStart; }
     136             : 
     137           0 :     void            SetEnd( sal_uInt16 n )              { mnEnd = n; }
     138           0 :     sal_uInt16          GetEnd() const                  { return mnEnd; }
     139           0 :     sal_uInt16&         GetEnd()                        { return mnEnd; }
     140             : 
     141           0 :     void            SetStartPortion( sal_uInt16 n )     { mnStartPortion = n; }
     142           0 :     sal_uInt16          GetStartPortion() const         { return mnStartPortion; }
     143           0 :     sal_uInt16&         GetStartPortion()               { return mnStartPortion; }
     144             : 
     145           0 :     void            SetEndPortion( sal_uInt16 n )       { mnEndPortion = n; }
     146           0 :     sal_uInt16          GetEndPortion() const           { return mnEndPortion; }
     147           0 :     sal_uInt16&         GetEndPortion()                 { return mnEndPortion; }
     148             : 
     149           0 :     sal_uInt16          GetLen() const                  { return mnEnd - mnStart; }
     150             : 
     151           0 :     bool            IsInvalid() const               { return mbInvalid; }
     152           0 :     bool            IsValid() const                 { return !mbInvalid; }
     153           0 :     void            SetInvalid()                    { mbInvalid = true; }
     154           0 :     void            SetValid()                      { mbInvalid = false; }
     155             : 
     156             :     bool            IsEmpty() const                 { return (mnEnd > mnStart) ? false : true; }
     157             : 
     158           0 :     short           GetStartX() const               { return mnStartX; }
     159           0 :     void            SetStartX( short n )            { mnStartX = n; }
     160             : 
     161             :     inline bool operator == ( const TextLine& rLine ) const;
     162             :     inline bool operator != ( const TextLine& rLine ) const;
     163             : };
     164             : 
     165           0 : class TextLines : public std::vector<TextLine*> {
     166             : public:
     167           0 :     ~TextLines()
     168           0 :     {
     169           0 :         for( iterator it = begin(); it != end(); ++it )
     170           0 :             delete *it;
     171           0 :     }
     172             : };
     173             : 
     174           0 : inline bool TextLine::operator == ( const TextLine& rLine ) const
     175             : {
     176           0 :     return (    ( mnStart == rLine.mnStart ) &&
     177           0 :                 ( mnEnd == rLine.mnEnd ) &&
     178           0 :                 ( mnStartPortion == rLine.mnStartPortion ) &&
     179           0 :                 ( mnEndPortion == rLine.mnEndPortion ) );
     180             : }
     181             : 
     182             : inline bool TextLine::operator != ( const TextLine& rLine ) const
     183             : {
     184             :     return !( *this == rLine );
     185             : }
     186             : 
     187             : class TEParaPortion
     188             : {
     189             : private:
     190             :     TextNode*               mpNode;
     191             : 
     192             :     TextLines               maLines;
     193             :     TETextPortionList       maTextPortions;
     194             :     std::vector<TEWritingDirectionInfo> maWritingDirectionInfos;
     195             : 
     196             :     sal_uInt16              mnInvalidPosStart;
     197             :     short               mnInvalidDiff;
     198             : 
     199             :     bool                mbInvalid;
     200             :     bool                mbSimple;   // nur lineares Tippen
     201             : 
     202             :                         TEParaPortion( const TEParaPortion& ) {;}
     203             : 
     204             : public:
     205             :                         TEParaPortion( TextNode* pNode );
     206             :                         ~TEParaPortion();
     207             : 
     208           0 :     bool                IsInvalid() const           { return mbInvalid; }
     209           0 :     bool                IsSimpleInvalid() const     { return mbSimple; }
     210           0 :     void                SetNotSimpleInvalid()       { mbSimple = false; }
     211           0 :     void                SetValid()                  { mbInvalid = false; mbSimple = true;}
     212             : 
     213             :     void                MarkInvalid( sal_uInt16 nStart, short nDiff);
     214             :     void                MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
     215             : 
     216           0 :     sal_uInt16              GetInvalidPosStart() const  { return mnInvalidPosStart; }
     217           0 :     short               GetInvalidDiff() const      { return mnInvalidDiff; }
     218             : 
     219           0 :     TextNode*           GetNode() const             { return mpNode; }
     220           0 :     TextLines&          GetLines()                  { return maLines; }
     221           0 :     TETextPortionList&  GetTextPortions()           { return maTextPortions; }
     222           0 :     std::vector<TEWritingDirectionInfo>& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
     223             : 
     224             :     sal_uInt16              GetLineNumber( sal_uInt16 nIndex, bool bInclEnd );
     225             :     void                CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
     226             : };
     227             : 
     228             : class TEParaPortions : public ToolsList<TEParaPortion*>
     229             : {
     230             : public:
     231             :                     TEParaPortions();
     232             :                     ~TEParaPortions();
     233             :     void            Reset();
     234             : };
     235             : 
     236           0 : class TextSelFunctionSet: public FunctionSet
     237             : {
     238             : private:
     239             :     TextView*       mpView;
     240             : 
     241             : public:
     242             :                     TextSelFunctionSet( TextView* pView );
     243             : 
     244             :     virtual void    BeginDrag() SAL_OVERRIDE;
     245             : 
     246             :     virtual void    CreateAnchor() SAL_OVERRIDE;
     247             : 
     248             :     virtual bool    SetCursorAtPoint( const Point& rPointPixel, bool bDontSelectAtCursor = false ) SAL_OVERRIDE;
     249             : 
     250             :     virtual bool    IsSelectionAtPoint( const Point& rPointPixel ) SAL_OVERRIDE;
     251             :     virtual void    DeselectAll() SAL_OVERRIDE;
     252             : 
     253             :     virtual void    DeselectAtPoint( const Point& ) SAL_OVERRIDE;
     254             :     virtual void    DestroyAnchor() SAL_OVERRIDE;
     255             : };
     256             : 
     257             : class IdleFormatter : public Timer
     258             : {
     259             : private:
     260             :     TextView*   mpView;
     261             :     sal_uInt16      mnRestarts;
     262             : 
     263             : public:
     264             :                 IdleFormatter();
     265             :                 virtual ~IdleFormatter();
     266             : 
     267             :     void        DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts );
     268             :     void        ForceTimeout();
     269           0 :     TextView*   GetView()       { return mpView; }
     270             : };
     271             : 
     272           0 : struct TextDDInfo
     273             : {
     274             :     Cursor          maCursor;
     275             :     TextPaM         maDropPos;
     276             : 
     277             :     bool            mbStarterOfDD;
     278             :     bool            mbVisCursor;
     279             : 
     280           0 :     TextDDInfo()
     281           0 :     {
     282           0 :         maCursor.SetStyle( CURSOR_SHADOW );
     283           0 :         mbStarterOfDD = false;
     284           0 :         mbVisCursor = false;
     285           0 :     }
     286             : };
     287             : 
     288             : #endif // INCLUDED_VCL_SOURCE_EDIT_TEXTDAT2_HXX
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10