1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textdat2.hxx,v $
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 ************************************************************************/
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>
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
53 #define TRAVEL_X_DONTKNOW 0xFFFF
54 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW
67 TETextPortion() { nLen
= 0; nKind
= PORTIONKIND_TEXT
; nWidth
= -1; nRightToLeft
= 0;}
70 TETextPortion( USHORT nL
) {
72 nKind
= PORTIONKIND_TEXT
;
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
102 ~TETextPortionList();
105 USHORT
FindPortion( USHORT nCharPos
, USHORT
& rPortionStart
, BOOL bPreferStartingPortion
= FALSE
);
106 USHORT
GetPortionStartIndex( USHORT nPortion
);
107 void DeleteFromPortion( USHORT nDelFrom
);
110 struct TEWritingDirectionInfo
115 TEWritingDirectionInfo( BYTE _Type
, USHORT _Start
, USHORT _End
)
123 SV_DECL_VARARR( TEWritingDirectionInfos
, TEWritingDirectionInfo
, 0, 4 )
130 USHORT mnStartPortion
;
135 BOOL mbInvalid
; // fuer geschickte Formatierung/Ausgabe
140 mnStartPortion
= mnEndPortion
= 0;
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
);
207 TETextPortionList maTextPortions
;
208 TEWritingDirectionInfos maWritingDirectionInfos
;
211 USHORT mnInvalidPosStart
;
215 BOOL mbSimple
; // nur lineares Tippen
218 TEParaPortion( const TEParaPortion
& ) {;}
221 TEParaPortion( TextNode
* pNode
);
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
*>
256 class TextSelFunctionSet
: public FunctionSet
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
288 void DoIdleFormat( TextView
* pV
, USHORT nMaxRestarts
);
290 TextView
* GetView() { return mpView
; }
303 maCursor
.SetStyle( CURSOR_SHADOW
);
304 mbStarterOfDD
= FALSE
;
309 #endif // _TEXTDAT2_HXX