merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / edit / textdoc.hxx
blob4e37f4c6c28bf41d4f3697b160cb17d0ba764df6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textdoc.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _TEXTDOC_HXX
32 #define _TEXTDOC_HXX
34 #include <svtools/svarray.hxx>
35 #include <svtools/textdata.hxx>
36 #include <txtattr.hxx>
38 #include <tools/debug.hxx>
39 #include <tools/string.hxx>
40 #include <tools/list.hxx>
42 typedef TextCharAttrib* TextCharAttribPtr;
43 SV_DECL_PTRARR_DEL( TextCharAttribs, TextCharAttribPtr, 0, 4 )
45 class TextCharAttribList : private TextCharAttribs
47 private:
48 BOOL mbHasEmptyAttribs;
50 TextCharAttribList( const TextCharAttribList& ) : TextCharAttribs() {}
52 public:
53 TextCharAttribList();
54 ~TextCharAttribList();
56 void Clear( BOOL bDestroyAttribs );
57 USHORT Count() const { return TextCharAttribs::Count(); }
59 TextCharAttrib* GetAttrib( USHORT n ) const { return TextCharAttribs::GetObject( n ); }
60 void RemoveAttrib( USHORT n ) { TextCharAttribs::Remove( n, 1 ); }
62 void InsertAttrib( TextCharAttrib* pAttrib );
64 void DeleteEmptyAttribs();
65 void ResortAttribs();
67 BOOL HasEmptyAttribs() const { return mbHasEmptyAttribs; }
68 BOOL& HasEmptyAttribs() { return mbHasEmptyAttribs; }
70 TextCharAttrib* FindAttrib( USHORT nWhich, USHORT nPos );
71 TextCharAttrib* FindNextAttrib( USHORT nWhich, USHORT nFromPos, USHORT nMaxPos = 0xFFFF ) const;
72 TextCharAttrib* FindEmptyAttrib( USHORT nWhich, USHORT nPos );
73 BOOL HasAttrib( USHORT nWhich ) const;
74 BOOL HasBoundingAttrib( USHORT nBound );
76 #ifdef DBG_UTIL
77 BOOL DbgCheckAttribs();
78 #endif
82 class TextNode
84 private:
85 String maText;
86 TextCharAttribList maCharAttribs;
88 TextNode( const TextNode& ) {;}
89 protected:
90 void ExpandAttribs( USHORT nIndex, USHORT nNewChars );
91 void CollapsAttribs( USHORT nIndex, USHORT nDelChars );
93 public:
94 TextNode( const String& rText );
97 const String& GetText() const { return maText; }
99 const TextCharAttribList& GetCharAttribs() const { return maCharAttribs; }
100 TextCharAttribList& GetCharAttribs() { return maCharAttribs; }
102 void InsertText( USHORT nPos, const String& rText );
103 void InsertText( USHORT nPos, sal_Unicode c );
104 void RemoveText( USHORT nPos, USHORT nChars );
106 TextNode* Split( USHORT nPos, BOOL bKeepEndigAttribs );
107 void Append( const TextNode& rNode );
110 class TextDoc
112 private:
113 ToolsList<TextNode*> maTextNodes;
114 USHORT mnLeftMargin;
116 protected:
117 void DestroyTextNodes();
119 public:
120 TextDoc();
121 ~TextDoc();
123 void Clear();
125 ToolsList<TextNode*>& GetNodes() { return maTextNodes; }
126 const ToolsList<TextNode*>& GetNodes() const { return maTextNodes; }
128 TextPaM RemoveChars( const TextPaM& rPaM, USHORT nChars );
129 TextPaM InsertText( const TextPaM& rPaM, sal_Unicode c );
130 TextPaM InsertText( const TextPaM& rPaM, const String& rStr );
132 TextPaM InsertParaBreak( const TextPaM& rPaM, BOOL bKeepEndingAttribs );
133 TextPaM ConnectParagraphs( TextNode* pLeft, TextNode* pRight );
135 ULONG GetTextLen( const sal_Unicode* pSep, const TextSelection* pSel = NULL ) const;
136 String GetText( const sal_Unicode* pSep ) const;
137 String GetText( ULONG nPara ) const;
139 void SetLeftMargin( USHORT n ) { mnLeftMargin = n; }
140 USHORT GetLeftMargin() const { return mnLeftMargin; }
142 // BOOL RemoveAttribs( TextNode* pNode, USHORT nStart, USHORT nEnd ), USHORT nWhich = 0 );
143 // BOOL RemoveAttribs( TextNode* pNode, USHORT nStart, USHORT nEnd, TextCharAttrib*& rpStarting, TextCharAttrib*& rpEnding, USHORT nWhich = 0 );
144 // void InsertAttrib( const EditCharAttrib* pAttr );
145 // void InsertAttribInSelection( const EditCharAttrib* pAttr );
146 // void FindAttribs( TextNode* pNode, USHORT nStartPos, USHORT nEndPos, SfxItemSet& rCurSet );
148 BOOL IsValidPaM( const TextPaM& rPaM );
151 #endif // _TEXTDOC_HXX