1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <vcl/seleng.hxx>
24 #include <vcl/virdev.hxx>
25 #include <vcl/cursor.hxx>
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
41 #define TRAVEL_X_DONTKNOW 0xFFFF
42 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW
52 sal_uInt8 nRightToLeft
;
54 TETextPortion() { nLen
= 0; nKind
= PORTIONKIND_TEXT
; nWidth
= -1; nRightToLeft
= 0;}
57 TETextPortion( sal_uInt16 nL
) {
59 nKind
= PORTIONKIND_TEXT
;
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
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
101 TEWritingDirectionInfo( sal_uInt8 _Type
, sal_uInt16 _Start
, sal_uInt16 _End
)
114 sal_uInt16 mnStartPortion
;
115 sal_uInt16 mnEndPortion
;
119 sal_Bool mbInvalid
; // fuer geschickte Formatierung/Ausgabe
124 mnStartPortion
= mnEndPortion
= 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
*> {
171 for( iterator it
= begin(); it
!= end(); ++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
);
197 TETextPortionList maTextPortions
;
198 std::vector
<TEWritingDirectionInfo
> maWritingDirectionInfos
;
201 sal_uInt16 mnInvalidPosStart
;
205 sal_Bool mbSimple
; // nur lineares Tippen
208 TEParaPortion( const TEParaPortion
& ) {;}
211 TEParaPortion( TextNode
* pNode
);
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
*>
246 class TextSelFunctionSet
: public FunctionSet
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
272 sal_uInt16 mnRestarts
;
278 void DoIdleFormat( TextView
* pV
, sal_uInt16 nMaxRestarts
);
280 TextView
* GetView() { return mpView
; }
288 sal_Bool mbStarterOfDD
;
289 sal_Bool mbVisCursor
;
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: */