fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / vcl / source / edit / textdoc.hxx
blob85d94dedd6afca4203b26e9a3aa80fb2097a4b21
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _TEXTDOC_HXX
21 #define _TEXTDOC_HXX
23 #include <vcl/textdata.hxx>
24 #include <vcl/txtattr.hxx>
26 #include <tools/string.hxx>
27 #include <vector>
29 class TextCharAttribs : public std::vector<TextCharAttrib*> {
30 public:
31 ~TextCharAttribs()
33 for( iterator it = begin(); it != end(); ++it )
34 delete *it;
38 class TextCharAttribList : private TextCharAttribs
40 private:
41 sal_Bool mbHasEmptyAttribs;
43 TextCharAttribList( const TextCharAttribList& ) : TextCharAttribs() {}
45 public:
46 TextCharAttribList();
47 ~TextCharAttribList();
49 void Clear( sal_Bool bDestroyAttribs );
50 sal_uInt16 Count() const { return TextCharAttribs::size(); }
52 TextCharAttrib* GetAttrib( sal_uInt16 n ) const { return TextCharAttribs::operator[]( n ); }
53 void RemoveAttrib( sal_uInt16 n ) { TextCharAttribs::erase( begin() + n ); }
55 void InsertAttrib( TextCharAttrib* pAttrib );
57 void DeleteEmptyAttribs();
58 void ResortAttribs();
60 sal_Bool HasEmptyAttribs() const { return mbHasEmptyAttribs; }
61 sal_Bool& HasEmptyAttribs() { return mbHasEmptyAttribs; }
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 );
71 class TextNode
73 private:
74 String maText;
75 TextCharAttribList maCharAttribs;
77 TextNode( const TextNode& ) {;}
78 protected:
79 void ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars );
80 void CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars );
82 public:
83 TextNode( const String& rText );
86 const String& GetText() const { return maText; }
88 const TextCharAttribList& GetCharAttribs() const { return maCharAttribs; }
89 TextCharAttribList& GetCharAttribs() { return maCharAttribs; }
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 );
95 TextNode* Split( sal_uInt16 nPos, sal_Bool bKeepEndigAttribs );
96 void Append( const TextNode& rNode );
99 class TextDoc
101 private:
102 ToolsList<TextNode*> maTextNodes;
103 sal_uInt16 mnLeftMargin;
105 protected:
106 void DestroyTextNodes();
108 public:
109 TextDoc();
110 ~TextDoc();
112 void Clear();
114 ToolsList<TextNode*>& GetNodes() { return maTextNodes; }
115 const ToolsList<TextNode*>& GetNodes() const { return maTextNodes; }
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 );
121 TextPaM InsertParaBreak( const TextPaM& rPaM, sal_Bool bKeepEndingAttribs );
122 TextPaM ConnectParagraphs( TextNode* pLeft, TextNode* pRight );
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;
128 void SetLeftMargin( sal_uInt16 n ) { mnLeftMargin = n; }
129 sal_uInt16 GetLeftMargin() const { return mnLeftMargin; }
131 sal_Bool IsValidPaM( const TextPaM& rPaM );
134 #endif // _TEXTDOC_HXX
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */