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

Generated by: LCOV version 1.10