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

Generated by: LCOV version 1.11