LCOV - code coverage report
Current view: top level - vcl/source/edit - textdat2.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 71 71.8 %
Date: 2012-08-25 Functions: 34 47 72.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 24 16.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #ifndef _TEXTDAT2_HXX
      31                 :            : #define _TEXTDAT2_HXX
      32                 :            : 
      33                 :            : #include <vcl/seleng.hxx>
      34                 :            : #include <vcl/virdev.hxx>
      35                 :            : #include <vcl/cursor.hxx>
      36                 :            : 
      37                 :            : #include <vector>
      38                 :            : 
      39                 :            : class TextNode;
      40                 :            : class TextView;
      41                 :            : 
      42                 :            : #define PORTIONKIND_TEXT        0
      43                 :            : #define PORTIONKIND_TAB         1
      44                 :            : 
      45                 :            : #define DELMODE_SIMPLE          0
      46                 :            : #define DELMODE_RESTOFWORD      1
      47                 :            : #define DELMODE_RESTOFCONTENT   2
      48                 :            : 
      49                 :            : #define DEL_LEFT    1
      50                 :            : #define DEL_RIGHT   2
      51                 :            : #define TRAVEL_X_DONTKNOW   0xFFFF
      52                 :            : #define MAXCHARSINPARA      0x3FFF-CHARPOSGROW
      53                 :            : 
      54                 :            : #define LINE_SEP    0x0A
      55                 :            : 
      56                 :            : 
      57                 :            : class TETextPortion
      58                 :            : {
      59                 :            : private:
      60                 :            :     sal_uInt16      nLen;
      61                 :            :     long        nWidth;
      62                 :            :     sal_uInt8       nKind;
      63                 :            :     sal_uInt8        nRightToLeft;
      64                 :            : 
      65                 :            :                 TETextPortion()             { nLen = 0; nKind = PORTIONKIND_TEXT; nWidth = -1; nRightToLeft = 0;}
      66                 :            : 
      67                 :            : public:
      68                 :        596 :                 TETextPortion( sal_uInt16 nL )  {
      69                 :        596 :                                                 nLen = nL;
      70                 :        596 :                                                 nKind = PORTIONKIND_TEXT;
      71                 :        596 :                                                 nWidth= -1;
      72                 :        596 :                                                 nRightToLeft = 0;
      73                 :        596 :                                             }
      74                 :            : 
      75                 :            :     sal_uInt16      GetLen() const              { return nLen; }
      76                 :       1659 :     sal_uInt16&     GetLen()                    { return nLen; }
      77                 :            : 
      78                 :            :     long        GetWidth()const             { return nWidth; }
      79                 :       1721 :     long&       GetWidth()                  { return nWidth; }
      80                 :            : 
      81                 :            :     sal_uInt8       GetKind() const             { return nKind; }
      82                 :       1171 :     sal_uInt8&      GetKind()                   { return nKind; }
      83                 :            : 
      84                 :            :     sal_uInt8       GetRightToLeft() const      { return nRightToLeft; }
      85                 :        627 :     sal_uInt8&      GetRightToLeft()            { return nRightToLeft; }
      86                 :        406 :     sal_Bool        IsRightToLeft() const       { return (nRightToLeft&1); }
      87                 :            : 
      88                 :          0 :     sal_Bool        HasValidSize() const        { return nWidth != (-1); }
      89                 :            : };
      90                 :            : 
      91                 :            : 
      92                 :            : 
      93                 :            : typedef std::vector<TETextPortion*> TextPortionArray;
      94                 :            : 
      95                 :            : class TETextPortionList : public TextPortionArray
      96                 :            : {
      97                 :            : public:
      98                 :            :     TETextPortionList();
      99                 :            :     ~TETextPortionList();
     100                 :            : 
     101                 :            :     void    Reset();
     102                 :            :     sal_uInt16  FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False );
     103                 :            :     sal_uInt16  GetPortionStartIndex( sal_uInt16 nPortion );
     104                 :            :     void    DeleteFromPortion( sal_uInt16 nDelFrom );
     105                 :            : };
     106                 :            : 
     107                 :            : struct TEWritingDirectionInfo
     108                 :            : {
     109                 :            :     sal_uInt8    nType;
     110                 :            :     sal_uInt16  nStartPos;
     111                 :            :     sal_uInt16  nEndPos;
     112                 :         92 :     TEWritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
     113                 :            :     {
     114                 :         92 :         nType = _Type;
     115                 :         92 :         nStartPos = _Start;
     116                 :         92 :         nEndPos = _End;
     117                 :         92 :     }
     118                 :            : };
     119                 :            : 
     120                 :            : class TextLine
     121                 :            : {
     122                 :            : private:
     123                 :            :     sal_uInt16          mnStart;
     124                 :            :     sal_uInt16          mnEnd;
     125                 :            :     sal_uInt16          mnStartPortion;
     126                 :            :     sal_uInt16          mnEndPortion;
     127                 :            : 
     128                 :            :     short           mnStartX;
     129                 :            : 
     130                 :            :     sal_Bool            mbInvalid;  // fuer geschickte Formatierung/Ausgabe
     131                 :            : 
     132                 :            : public:
     133                 :        556 :                     TextLine()  {
     134                 :        556 :                                     mnStart = mnEnd = 0;
     135                 :        556 :                                     mnStartPortion = mnEndPortion = 0;
     136                 :        556 :                                     mnStartX = 0;
     137                 :        556 :                                     mbInvalid = sal_True;
     138                 :        556 :                                 }
     139                 :            : 
     140                 :            :     sal_Bool            IsIn( sal_uInt16 nIndex ) const
     141                 :            :                         { return ( (nIndex >= mnStart ) && ( nIndex < mnEnd ) ); }
     142                 :            : 
     143                 :          0 :     sal_Bool            IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
     144 [ #  # ][ #  # ]:          0 :                         { return ( ( nIndex >= mnStart ) && ( bInclEnd ? ( nIndex <= mnEnd ) : ( nIndex < mnEnd ) ) ); }
         [ #  # ][ #  # ]
     145                 :            : 
     146                 :        504 :     void            SetStart( sal_uInt16 n )            { mnStart = n; }
     147                 :          0 :     sal_uInt16          GetStart() const                { return mnStart; }
     148                 :       1399 :     sal_uInt16&         GetStart()                      { return mnStart; }
     149                 :            : 
     150                 :        596 :     void            SetEnd( sal_uInt16 n )              { mnEnd = n; }
     151                 :          0 :     sal_uInt16          GetEnd() const                  { return mnEnd; }
     152                 :        233 :     sal_uInt16&         GetEnd()                        { return mnEnd; }
     153                 :            : 
     154                 :          0 :     void            SetStartPortion( sal_uInt16 n )     { mnStartPortion = n; }
     155                 :          0 :     sal_uInt16          GetStartPortion() const         { return mnStartPortion; }
     156                 :       1254 :     sal_uInt16&         GetStartPortion()               { return mnStartPortion; }
     157                 :            : 
     158                 :         92 :     void            SetEndPortion( sal_uInt16 n )       { mnEndPortion = n; }
     159                 :          0 :     sal_uInt16          GetEndPortion() const           { return mnEndPortion; }
     160                 :       1346 :     sal_uInt16&         GetEndPortion()                 { return mnEndPortion; }
     161                 :            : 
     162                 :          0 :     sal_uInt16          GetLen() const                  { return mnEnd - mnStart; }
     163                 :            : 
     164                 :        596 :     sal_Bool            IsInvalid() const               { return mbInvalid; }
     165                 :        596 :     sal_Bool            IsValid() const                 { return !mbInvalid; }
     166                 :         92 :     void            SetInvalid()                    { mbInvalid = sal_True; }
     167                 :         52 :     void            SetValid()                      { mbInvalid = sal_False; }
     168                 :            : 
     169                 :            :     sal_Bool            IsEmpty() const                 { return (mnEnd > mnStart) ? sal_False : sal_True; }
     170                 :            : 
     171                 :        624 :     short           GetStartX() const               { return mnStartX; }
     172                 :        570 :     void            SetStartX( short n )            { mnStartX = n; }
     173                 :            : 
     174                 :            :     inline sal_Bool operator == ( const TextLine& rLine ) const;
     175                 :            :     inline sal_Bool operator != ( const TextLine& rLine ) const;
     176                 :            : };
     177                 :            : 
     178                 :        218 : class TextLines : public std::vector<TextLine*> {
     179                 :            : public:
     180                 :        218 :     ~TextLines()
     181                 :        218 :     {
     182 [ +  - ][ +  + ]:        436 :         for( iterator it = begin(); it != end(); ++it )
     183                 :        218 :             delete *it;
     184                 :        218 :     }
     185                 :            : };
     186                 :            : 
     187                 :          0 : inline sal_Bool TextLine::operator == ( const TextLine& rLine ) const
     188                 :            : {
     189                 :            :     return (    ( mnStart == rLine.mnStart ) &&
     190                 :            :                 ( mnEnd == rLine.mnEnd ) &&
     191                 :            :                 ( mnStartPortion == rLine.mnStartPortion ) &&
     192 [ #  # ][ #  # ]:          0 :                 ( mnEndPortion == rLine.mnEndPortion ) );
         [ #  # ][ #  # ]
     193                 :            : }
     194                 :            : 
     195                 :            : inline sal_Bool TextLine::operator != ( const TextLine& rLine ) const
     196                 :            : {
     197                 :            :     return !( *this == rLine );
     198                 :            : }
     199                 :            : 
     200                 :            : 
     201                 :            : 
     202                 :            : class TEParaPortion
     203                 :            : {
     204                 :            : private:
     205                 :            :     TextNode*               mpNode;
     206                 :            : 
     207                 :            :     TextLines               maLines;
     208                 :            :     TETextPortionList       maTextPortions;
     209                 :            :     std::vector<TEWritingDirectionInfo> maWritingDirectionInfos;
     210                 :            : 
     211                 :            : 
     212                 :            :     sal_uInt16              mnInvalidPosStart;
     213                 :            :     short               mnInvalidDiff;
     214                 :            : 
     215                 :            :     sal_Bool                mbInvalid;
     216                 :            :     sal_Bool                mbSimple;   // nur lineares Tippen
     217                 :            : 
     218                 :            : 
     219                 :            :                         TEParaPortion( const TEParaPortion& ) {;}
     220                 :            : 
     221                 :            : public:
     222                 :            :                         TEParaPortion( TextNode* pNode );
     223                 :            :                         ~TEParaPortion();
     224                 :            : 
     225                 :            : 
     226                 :        685 :     sal_Bool                IsInvalid() const           { return mbInvalid; }
     227                 :        276 :     sal_Bool                IsSimpleInvalid() const     { return mbSimple; }
     228                 :          0 :     void                SetNotSimpleInvalid()       { mbSimple = sal_False; }
     229                 :        596 :     void                SetValid()                  { mbInvalid = sal_False; mbSimple = sal_True;}
     230                 :            : 
     231                 :            :     void                MarkInvalid( sal_uInt16 nStart, short nDiff);
     232                 :            :     void                MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
     233                 :            : 
     234                 :         92 :     sal_uInt16              GetInvalidPosStart() const  { return mnInvalidPosStart; }
     235                 :         92 :     short               GetInvalidDiff() const      { return mnInvalidDiff; }
     236                 :            : 
     237                 :       1429 :     TextNode*           GetNode() const             { return mpNode; }
     238                 :       8965 :     TextLines&          GetLines()                  { return maLines; }
     239                 :       4360 :     TETextPortionList&  GetTextPortions()           { return maTextPortions; }
     240                 :        552 :     std::vector<TEWritingDirectionInfo>& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
     241                 :            : 
     242                 :            : 
     243                 :            :     sal_uInt16              GetLineNumber( sal_uInt16 nIndex, sal_Bool bInclEnd );
     244                 :            :     void                CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
     245                 :            : };
     246                 :            : 
     247                 :            : 
     248                 :            : class TEParaPortions : public ToolsList<TEParaPortion*>
     249                 :            : {
     250                 :            : public:
     251                 :            :                     TEParaPortions();
     252                 :            :                     ~TEParaPortions();
     253                 :            :     void            Reset();
     254                 :            : };
     255                 :            : 
     256                 :            : 
     257         [ -  + ]:        180 : class TextSelFunctionSet: public FunctionSet
     258                 :            : {
     259                 :            : private:
     260                 :            :     TextView*       mpView;
     261                 :            : 
     262                 :            : public:
     263                 :            :                     TextSelFunctionSet( TextView* pView );
     264                 :            : 
     265                 :            :     virtual void    BeginDrag();
     266                 :            : 
     267                 :            :     virtual void    CreateAnchor();
     268                 :            : 
     269                 :            :     virtual sal_Bool    SetCursorAtPoint( const Point& rPointPixel, sal_Bool bDontSelectAtCursor = sal_False );
     270                 :            : 
     271                 :            :     virtual sal_Bool    IsSelectionAtPoint( const Point& rPointPixel );
     272                 :            :     virtual void    DeselectAll();
     273                 :            : 
     274                 :            :     virtual void    DeselectAtPoint( const Point& );
     275                 :            :     virtual void    DestroyAnchor();
     276                 :            : };
     277                 :            : 
     278                 :            : 
     279                 :            : class IdleFormatter : public Timer
     280                 :            : {
     281                 :            : private:
     282                 :            :     TextView*   mpView;
     283                 :            :     sal_uInt16      mnRestarts;
     284                 :            : 
     285                 :            : public:
     286                 :            :                 IdleFormatter();
     287                 :            :                 ~IdleFormatter();
     288                 :            : 
     289                 :            :     void        DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts );
     290                 :            :     void        ForceTimeout();
     291                 :          0 :     TextView*   GetView()       { return mpView; }
     292                 :            : };
     293                 :            : 
     294                 :          0 : struct TextDDInfo
     295                 :            : {
     296                 :            :     Cursor          maCursor;
     297                 :            :     TextPaM         maDropPos;
     298                 :            : 
     299                 :            :     sal_Bool            mbStarterOfDD;
     300                 :            :     sal_Bool            mbVisCursor;
     301                 :            : 
     302                 :          0 :     TextDDInfo()
     303                 :          0 :     {
     304         [ #  # ]:          0 :         maCursor.SetStyle( CURSOR_SHADOW );
     305                 :          0 :         mbStarterOfDD = sal_False;
     306                 :          0 :         mbVisCursor = sal_False;
     307                 :          0 :     }
     308                 :            : };
     309                 :            : 
     310                 :            : #endif // _TEXTDAT2_HXX
     311                 :            : 
     312                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10