LCOV - code coverage report
Current view: top level - vcl/source/edit - textdoc.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 17 76.5 %
Date: 2012-08-25 Functions: 10 13 76.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 14 21.4 %

           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                 :            : #ifndef _TEXTDOC_HXX
      30                 :            : #define _TEXTDOC_HXX
      31                 :            : 
      32                 :            : #include <vcl/textdata.hxx>
      33                 :            : #include <vcl/txtattr.hxx>
      34                 :            : 
      35                 :            : #include <tools/string.hxx>
      36                 :            : #include <vector>
      37                 :            : 
      38                 :        218 : class TextCharAttribs : public std::vector<TextCharAttrib*> {
      39                 :            : public:
      40                 :        218 :     ~TextCharAttribs()
      41                 :        218 :     {
      42 [ +  - ][ -  + ]:        218 :         for( iterator it = begin(); it != end(); ++it )
      43 [ #  # ][ #  # ]:          0 :             delete *it;
      44                 :        218 :     }
      45                 :            : };
      46                 :            : 
      47                 :            : class TextCharAttribList : private TextCharAttribs
      48                 :            : {
      49                 :            : private:
      50                 :            :     sal_Bool            mbHasEmptyAttribs;
      51                 :            : 
      52                 :            :                     TextCharAttribList( const TextCharAttribList& ) : TextCharAttribs() {}
      53                 :            : 
      54                 :            : public:
      55                 :            :                     TextCharAttribList();
      56                 :            :                     ~TextCharAttribList();
      57                 :            : 
      58                 :            :     void            Clear( sal_Bool bDestroyAttribs );
      59                 :        325 :     sal_uInt16          Count() const               { return TextCharAttribs::size(); }
      60                 :            : 
      61                 :          0 :     TextCharAttrib* GetAttrib( sal_uInt16 n ) const { return TextCharAttribs::operator[]( n ); }
      62 [ #  # ][ #  # ]:          0 :     void            RemoveAttrib( sal_uInt16 n )    { TextCharAttribs::erase( begin() + n ); }
      63                 :            : 
      64                 :            :     void            InsertAttrib( TextCharAttrib* pAttrib );
      65                 :            : 
      66                 :            :     void            DeleteEmptyAttribs();
      67                 :            :     void            ResortAttribs();
      68                 :            : 
      69                 :            :     sal_Bool            HasEmptyAttribs() const { return mbHasEmptyAttribs; }
      70                 :        218 :     sal_Bool&           HasEmptyAttribs()       { return mbHasEmptyAttribs; }
      71                 :            : 
      72                 :            :     TextCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
      73                 :            :     TextCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos, sal_uInt16 nMaxPos = 0xFFFF ) const;
      74                 :            :     TextCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
      75                 :            :     sal_Bool            HasAttrib( sal_uInt16 nWhich ) const;
      76                 :            :     sal_Bool            HasBoundingAttrib( sal_uInt16 nBound );
      77                 :            : };
      78                 :            : 
      79                 :            : 
      80         [ +  - ]:        218 : class TextNode
      81                 :            : {
      82                 :            : private:
      83                 :            :     String              maText;
      84                 :            :     TextCharAttribList  maCharAttribs;
      85                 :            : 
      86                 :            :                         TextNode( const TextNode& ) {;}
      87                 :            : protected:
      88                 :            :     void                ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars );
      89                 :            :     void                CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars );
      90                 :            : 
      91                 :            : public:
      92                 :            :                         TextNode( const String& rText );
      93                 :            : 
      94                 :            : 
      95                 :       3517 :     const String&               GetText() const         { return maText; }
      96                 :            : 
      97                 :          0 :     const TextCharAttribList&   GetCharAttribs() const  { return maCharAttribs; }
      98                 :        491 :     TextCharAttribList&         GetCharAttribs()        { return maCharAttribs; }
      99                 :            : 
     100                 :            :     void                InsertText( sal_uInt16 nPos, const String& rText );
     101                 :            :     void                InsertText( sal_uInt16 nPos, sal_Unicode c );
     102                 :            :     void                RemoveText( sal_uInt16 nPos, sal_uInt16 nChars );
     103                 :            : 
     104                 :            :     TextNode*           Split( sal_uInt16 nPos, sal_Bool bKeepEndigAttribs );
     105                 :            :     void                Append( const TextNode& rNode );
     106                 :            : };
     107                 :            : 
     108                 :            : class TextDoc
     109                 :            : {
     110                 :            : private:
     111                 :            :     ToolsList<TextNode*> maTextNodes;
     112                 :            :     sal_uInt16              mnLeftMargin;
     113                 :            : 
     114                 :            : protected:
     115                 :            :     void                DestroyTextNodes();
     116                 :            : 
     117                 :            : public:
     118                 :            :                         TextDoc();
     119                 :            :                         ~TextDoc();
     120                 :            : 
     121                 :            :     void                Clear();
     122                 :            : 
     123                 :       2773 :     ToolsList<TextNode*>&       GetNodes()              { return maTextNodes; }
     124                 :            :     const ToolsList<TextNode*>& GetNodes() const        { return maTextNodes; }
     125                 :            : 
     126                 :            :     TextPaM             RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars );
     127                 :            :     TextPaM             InsertText( const TextPaM& rPaM, sal_Unicode c );
     128                 :            :     TextPaM             InsertText( const TextPaM& rPaM, const String& rStr );
     129                 :            : 
     130                 :            :     TextPaM             InsertParaBreak( const TextPaM& rPaM, sal_Bool bKeepEndingAttribs );
     131                 :            :     TextPaM             ConnectParagraphs( TextNode* pLeft, TextNode* pRight );
     132                 :            : 
     133                 :            :     sal_uLong               GetTextLen( const sal_Unicode* pSep, const TextSelection* pSel = NULL ) const;
     134                 :            :     String              GetText( const sal_Unicode* pSep ) const;
     135                 :            :     String              GetText( sal_uLong nPara ) const;
     136                 :            : 
     137                 :         22 :     void                SetLeftMargin( sal_uInt16 n )   { mnLeftMargin = n; }
     138                 :        512 :     sal_uInt16              GetLeftMargin() const       { return mnLeftMargin; }
     139                 :            : 
     140                 :            :     sal_Bool                IsValidPaM( const TextPaM& rPaM );
     141                 :            : };
     142                 :            : 
     143                 :            : #endif // _TEXTDOC_HXX
     144                 :            : 
     145                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10