update credits
[LibreOffice.git] / vcl / source / edit / textdat2.hxx
blob8c6da16e1b26758e1dab52c755cb247de1eba6a4
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 _TEXTDAT2_HXX
21 #define _TEXTDAT2_HXX
23 #include <vcl/seleng.hxx>
24 #include <vcl/virdev.hxx>
25 #include <vcl/cursor.hxx>
27 #include <vector>
29 class TextNode;
30 class TextView;
32 #define PORTIONKIND_TEXT 0
33 #define PORTIONKIND_TAB 1
35 #define DELMODE_SIMPLE 0
36 #define DELMODE_RESTOFWORD 1
37 #define DELMODE_RESTOFCONTENT 2
39 #define DEL_LEFT 1
40 #define DEL_RIGHT 2
41 #define TRAVEL_X_DONTKNOW 0xFFFF
42 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW
44 #define LINE_SEP 0x0A
46 class TETextPortion
48 private:
49 sal_uInt16 nLen;
50 long nWidth;
51 sal_uInt8 nKind;
52 sal_uInt8 nRightToLeft;
54 TETextPortion() { nLen = 0; nKind = PORTIONKIND_TEXT; nWidth = -1; nRightToLeft = 0;}
56 public:
57 TETextPortion( sal_uInt16 nL ) {
58 nLen = nL;
59 nKind = PORTIONKIND_TEXT;
60 nWidth= -1;
61 nRightToLeft = 0;
64 sal_uInt16 GetLen() const { return nLen; }
65 sal_uInt16& GetLen() { return nLen; }
67 long GetWidth()const { return nWidth; }
68 long& GetWidth() { return nWidth; }
70 sal_uInt8 GetKind() const { return nKind; }
71 sal_uInt8& GetKind() { return nKind; }
73 sal_uInt8 GetRightToLeft() const { return nRightToLeft; }
74 sal_uInt8& GetRightToLeft() { return nRightToLeft; }
75 sal_Bool IsRightToLeft() const { return (nRightToLeft&1); }
77 sal_Bool HasValidSize() const { return nWidth != (-1); }
82 typedef std::vector<TETextPortion*> TextPortionArray;
84 class TETextPortionList : public TextPortionArray
86 public:
87 TETextPortionList();
88 ~TETextPortionList();
90 void Reset();
91 sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False );
92 sal_uInt16 GetPortionStartIndex( sal_uInt16 nPortion );
93 void DeleteFromPortion( sal_uInt16 nDelFrom );
96 struct TEWritingDirectionInfo
98 sal_uInt8 nType;
99 sal_uInt16 nStartPos;
100 sal_uInt16 nEndPos;
101 TEWritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
103 nType = _Type;
104 nStartPos = _Start;
105 nEndPos = _End;
109 class TextLine
111 private:
112 sal_uInt16 mnStart;
113 sal_uInt16 mnEnd;
114 sal_uInt16 mnStartPortion;
115 sal_uInt16 mnEndPortion;
117 short mnStartX;
119 sal_Bool mbInvalid; // fuer geschickte Formatierung/Ausgabe
121 public:
122 TextLine() {
123 mnStart = mnEnd = 0;
124 mnStartPortion = mnEndPortion = 0;
125 mnStartX = 0;
126 mbInvalid = sal_True;
129 sal_Bool IsIn( sal_uInt16 nIndex ) const
130 { return ( (nIndex >= mnStart ) && ( nIndex < mnEnd ) ); }
132 sal_Bool IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
133 { return ( ( nIndex >= mnStart ) && ( bInclEnd ? ( nIndex <= mnEnd ) : ( nIndex < mnEnd ) ) ); }
135 void SetStart( sal_uInt16 n ) { mnStart = n; }
136 sal_uInt16 GetStart() const { return mnStart; }
137 sal_uInt16& GetStart() { return mnStart; }
139 void SetEnd( sal_uInt16 n ) { mnEnd = n; }
140 sal_uInt16 GetEnd() const { return mnEnd; }
141 sal_uInt16& GetEnd() { return mnEnd; }
143 void SetStartPortion( sal_uInt16 n ) { mnStartPortion = n; }
144 sal_uInt16 GetStartPortion() const { return mnStartPortion; }
145 sal_uInt16& GetStartPortion() { return mnStartPortion; }
147 void SetEndPortion( sal_uInt16 n ) { mnEndPortion = n; }
148 sal_uInt16 GetEndPortion() const { return mnEndPortion; }
149 sal_uInt16& GetEndPortion() { return mnEndPortion; }
151 sal_uInt16 GetLen() const { return mnEnd - mnStart; }
153 sal_Bool IsInvalid() const { return mbInvalid; }
154 sal_Bool IsValid() const { return !mbInvalid; }
155 void SetInvalid() { mbInvalid = sal_True; }
156 void SetValid() { mbInvalid = sal_False; }
158 sal_Bool IsEmpty() const { return (mnEnd > mnStart) ? sal_False : sal_True; }
160 short GetStartX() const { return mnStartX; }
161 void SetStartX( short n ) { mnStartX = n; }
163 inline sal_Bool operator == ( const TextLine& rLine ) const;
164 inline sal_Bool operator != ( const TextLine& rLine ) const;
167 class TextLines : public std::vector<TextLine*> {
168 public:
169 ~TextLines()
171 for( iterator it = begin(); it != end(); ++it )
172 delete *it;
176 inline sal_Bool TextLine::operator == ( const TextLine& rLine ) const
178 return ( ( mnStart == rLine.mnStart ) &&
179 ( mnEnd == rLine.mnEnd ) &&
180 ( mnStartPortion == rLine.mnStartPortion ) &&
181 ( mnEndPortion == rLine.mnEndPortion ) );
184 inline sal_Bool TextLine::operator != ( const TextLine& rLine ) const
186 return !( *this == rLine );
191 class TEParaPortion
193 private:
194 TextNode* mpNode;
196 TextLines maLines;
197 TETextPortionList maTextPortions;
198 std::vector<TEWritingDirectionInfo> maWritingDirectionInfos;
201 sal_uInt16 mnInvalidPosStart;
202 short mnInvalidDiff;
204 sal_Bool mbInvalid;
205 sal_Bool mbSimple; // nur lineares Tippen
208 TEParaPortion( const TEParaPortion& ) {;}
210 public:
211 TEParaPortion( TextNode* pNode );
212 ~TEParaPortion();
215 sal_Bool IsInvalid() const { return mbInvalid; }
216 sal_Bool IsSimpleInvalid() const { return mbSimple; }
217 void SetNotSimpleInvalid() { mbSimple = sal_False; }
218 void SetValid() { mbInvalid = sal_False; mbSimple = sal_True;}
220 void MarkInvalid( sal_uInt16 nStart, short nDiff);
221 void MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
223 sal_uInt16 GetInvalidPosStart() const { return mnInvalidPosStart; }
224 short GetInvalidDiff() const { return mnInvalidDiff; }
226 TextNode* GetNode() const { return mpNode; }
227 TextLines& GetLines() { return maLines; }
228 TETextPortionList& GetTextPortions() { return maTextPortions; }
229 std::vector<TEWritingDirectionInfo>& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
232 sal_uInt16 GetLineNumber( sal_uInt16 nIndex, sal_Bool bInclEnd );
233 void CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
237 class TEParaPortions : public ToolsList<TEParaPortion*>
239 public:
240 TEParaPortions();
241 ~TEParaPortions();
242 void Reset();
246 class TextSelFunctionSet: public FunctionSet
248 private:
249 TextView* mpView;
251 public:
252 TextSelFunctionSet( TextView* pView );
254 virtual void BeginDrag();
256 virtual void CreateAnchor();
258 virtual sal_Bool SetCursorAtPoint( const Point& rPointPixel, sal_Bool bDontSelectAtCursor = sal_False );
260 virtual sal_Bool IsSelectionAtPoint( const Point& rPointPixel );
261 virtual void DeselectAll();
263 virtual void DeselectAtPoint( const Point& );
264 virtual void DestroyAnchor();
268 class IdleFormatter : public Timer
270 private:
271 TextView* mpView;
272 sal_uInt16 mnRestarts;
274 public:
275 IdleFormatter();
276 ~IdleFormatter();
278 void DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts );
279 void ForceTimeout();
280 TextView* GetView() { return mpView; }
283 struct TextDDInfo
285 Cursor maCursor;
286 TextPaM maDropPos;
288 sal_Bool mbStarterOfDD;
289 sal_Bool mbVisCursor;
291 TextDDInfo()
293 maCursor.SetStyle( CURSOR_SHADOW );
294 mbStarterOfDD = sal_False;
295 mbVisCursor = sal_False;
299 #endif // _TEXTDAT2_HXX
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */