update dev300-m57
[ooovba.git] / svtools / source / edit / textdat2.hxx
blob2fcc96b5a3a0f43ead17da4c60a0b459cda97617
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: textdat2.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
32 #ifndef _TEXTDAT2_HXX
33 #define _TEXTDAT2_HXX
35 #include <svtools/svarray.hxx>
36 #include <tools/list.hxx>
37 #include <vcl/seleng.hxx>
38 #include <vcl/virdev.hxx>
39 #include <vcl/cursor.hxx>
41 class TextNode;
42 class TextView;
44 #define PORTIONKIND_TEXT 0
45 #define PORTIONKIND_TAB 1
47 #define DELMODE_SIMPLE 0
48 #define DELMODE_RESTOFWORD 1
49 #define DELMODE_RESTOFCONTENT 2
51 #define DEL_LEFT 1
52 #define DEL_RIGHT 2
53 #define TRAVEL_X_DONTKNOW 0xFFFF
54 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW
56 #define LINE_SEP 0x0A
59 class TETextPortion
61 private:
62 USHORT nLen;
63 long nWidth;
64 BYTE nKind;
65 BYTE nRightToLeft;
67 TETextPortion() { nLen = 0; nKind = PORTIONKIND_TEXT; nWidth = -1; nRightToLeft = 0;}
69 public:
70 TETextPortion( USHORT nL ) {
71 nLen = nL;
72 nKind = PORTIONKIND_TEXT;
73 nWidth= -1;
74 nRightToLeft = 0;
77 USHORT GetLen() const { return nLen; }
78 USHORT& GetLen() { return nLen; }
80 long GetWidth()const { return nWidth; }
81 long& GetWidth() { return nWidth; }
83 BYTE GetKind() const { return nKind; }
84 BYTE& GetKind() { return nKind; }
86 BYTE GetRightToLeft() const { return nRightToLeft; }
87 BYTE& GetRightToLeft() { return nRightToLeft; }
88 BOOL IsRightToLeft() const { return (nRightToLeft&1); }
90 BOOL HasValidSize() const { return nWidth != (-1); }
95 typedef TETextPortion* TextPortionPtr;
96 SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0, 8 )
98 class TETextPortionList : public TextPortionArray
100 public:
101 TETextPortionList();
102 ~TETextPortionList();
104 void Reset();
105 USHORT FindPortion( USHORT nCharPos, USHORT& rPortionStart, BOOL bPreferStartingPortion = FALSE );
106 USHORT GetPortionStartIndex( USHORT nPortion );
107 void DeleteFromPortion( USHORT nDelFrom );
110 struct TEWritingDirectionInfo
112 BYTE nType;
113 USHORT nStartPos;
114 USHORT nEndPos;
115 TEWritingDirectionInfo( BYTE _Type, USHORT _Start, USHORT _End )
117 nType = _Type;
118 nStartPos = _Start;
119 nEndPos = _End;
123 SV_DECL_VARARR( TEWritingDirectionInfos, TEWritingDirectionInfo, 0, 4 )
125 class TextLine
127 private:
128 USHORT mnStart;
129 USHORT mnEnd;
130 USHORT mnStartPortion;
131 USHORT mnEndPortion;
133 short mnStartX;
135 BOOL mbInvalid; // fuer geschickte Formatierung/Ausgabe
137 public:
138 TextLine() {
139 mnStart = mnEnd = 0;
140 mnStartPortion = mnEndPortion = 0;
141 mnStartX = 0;
142 mbInvalid = TRUE;
145 BOOL IsIn( USHORT nIndex ) const
146 { return ( (nIndex >= mnStart ) && ( nIndex < mnEnd ) ); }
148 BOOL IsIn( USHORT nIndex, BOOL bInclEnd ) const
149 { return ( ( nIndex >= mnStart ) && ( bInclEnd ? ( nIndex <= mnEnd ) : ( nIndex < mnEnd ) ) ); }
151 void SetStart( USHORT n ) { mnStart = n; }
152 USHORT GetStart() const { return mnStart; }
153 USHORT& GetStart() { return mnStart; }
155 void SetEnd( USHORT n ) { mnEnd = n; }
156 USHORT GetEnd() const { return mnEnd; }
157 USHORT& GetEnd() { return mnEnd; }
159 void SetStartPortion( USHORT n ) { mnStartPortion = n; }
160 USHORT GetStartPortion() const { return mnStartPortion; }
161 USHORT& GetStartPortion() { return mnStartPortion; }
163 void SetEndPortion( USHORT n ) { mnEndPortion = n; }
164 USHORT GetEndPortion() const { return mnEndPortion; }
165 USHORT& GetEndPortion() { return mnEndPortion; }
167 USHORT GetLen() const { return mnEnd - mnStart; }
169 BOOL IsInvalid() const { return mbInvalid; }
170 BOOL IsValid() const { return !mbInvalid; }
171 void SetInvalid() { mbInvalid = TRUE; }
172 void SetValid() { mbInvalid = FALSE; }
174 BOOL IsEmpty() const { return (mnEnd > mnStart) ? FALSE : TRUE; }
176 short GetStartX() const { return mnStartX; }
177 void SetStartX( short n ) { mnStartX = n; }
179 inline BOOL operator == ( const TextLine& rLine ) const;
180 inline BOOL operator != ( const TextLine& rLine ) const;
183 typedef TextLine* TextLinePtr;
184 SV_DECL_PTRARR_DEL( TextLines, TextLinePtr, 1, 4 )
186 inline BOOL TextLine::operator == ( const TextLine& rLine ) const
188 return ( ( mnStart == rLine.mnStart ) &&
189 ( mnEnd == rLine.mnEnd ) &&
190 ( mnStartPortion == rLine.mnStartPortion ) &&
191 ( mnEndPortion == rLine.mnEndPortion ) );
194 inline BOOL TextLine::operator != ( const TextLine& rLine ) const
196 return !( *this == rLine );
201 class TEParaPortion
203 private:
204 TextNode* mpNode;
206 TextLines maLines;
207 TETextPortionList maTextPortions;
208 TEWritingDirectionInfos maWritingDirectionInfos;
211 USHORT mnInvalidPosStart;
212 short mnInvalidDiff;
214 BOOL mbInvalid;
215 BOOL mbSimple; // nur lineares Tippen
218 TEParaPortion( const TEParaPortion& ) {;}
220 public:
221 TEParaPortion( TextNode* pNode );
222 ~TEParaPortion();
225 BOOL IsInvalid() const { return mbInvalid; }
226 BOOL IsSimpleInvalid() const { return mbSimple; }
227 void SetNotSimpleInvalid() { mbSimple = FALSE; }
228 void SetValid() { mbInvalid = FALSE; mbSimple = TRUE;}
230 void MarkInvalid( USHORT nStart, short nDiff);
231 void MarkSelectionInvalid( USHORT nStart, USHORT nEnd );
233 USHORT GetInvalidPosStart() const { return mnInvalidPosStart; }
234 short GetInvalidDiff() const { return mnInvalidDiff; }
236 TextNode* GetNode() const { return mpNode; }
237 TextLines& GetLines() { return maLines; }
238 TETextPortionList& GetTextPortions() { return maTextPortions; }
239 TEWritingDirectionInfos& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
242 USHORT GetLineNumber( USHORT nIndex, BOOL bInclEnd );
243 void CorrectValuesBehindLastFormattedLine( USHORT nLastFormattedLine );
247 class TEParaPortions : public ToolsList<TEParaPortion*>
249 public:
250 TEParaPortions();
251 ~TEParaPortions();
252 void Reset();
256 class TextSelFunctionSet: public FunctionSet
258 private:
259 TextView* mpView;
261 public:
262 TextSelFunctionSet( TextView* pView );
264 virtual void BeginDrag();
266 virtual void CreateAnchor();
268 virtual BOOL SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor = FALSE );
270 virtual BOOL IsSelectionAtPoint( const Point& rPointPixel );
271 virtual void DeselectAll();
273 virtual void DeselectAtPoint( const Point& );
274 virtual void DestroyAnchor();
278 class IdleFormatter : public Timer
280 private:
281 TextView* mpView;
282 USHORT mnRestarts;
284 public:
285 IdleFormatter();
286 ~IdleFormatter();
288 void DoIdleFormat( TextView* pV, USHORT nMaxRestarts );
289 void ForceTimeout();
290 TextView* GetView() { return mpView; }
293 struct TextDDInfo
295 Cursor maCursor;
296 TextPaM maDropPos;
298 BOOL mbStarterOfDD;
299 BOOL mbVisCursor;
301 TextDDInfo()
303 maCursor.SetStyle( CURSOR_SHADOW );
304 mbStarterOfDD = FALSE;
305 mbVisCursor = FALSE;
309 #endif // _TEXTDAT2_HXX