1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MyEDITDATA, wegen exportiertem EditData
25 #ifndef _MyEDITDATA_HXX
26 #define _MyEDITDATA_HXX
27
28 #include <tools/string.hxx>
29 #include "editeng/editengdllapi.h"
30
31 #include <svl/svarray.hxx>
32
33 class SfxItemSet;
34 class SfxPoolItem;
35 class SvParser;
36 class SvxFieldItem;
37
38 enum EETextFormat { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
39 enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
40 enum EESelectionMode { EE_SELMODE_STD, EE_SELMODE_TXTONLY, EE_SELMODE_HIDDEN };
41 // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is usefull e.g. when you want show the selection
42 // only as long as your window (which the edit view works on) has the focus
43 enum EESpellState { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
44 enum EVAnchorMode {
45 ANCHOR_TOP_LEFT, ANCHOR_VCENTER_LEFT, ANCHOR_BOTTOM_LEFT,
46 ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
47 ANCHOR_TOP_RIGHT, ANCHOR_VCENTER_RIGHT, ANCHOR_BOTTOM_RIGHT };
48
49 #define EE_PARA_NOT_FOUND 0xFFFF
50 #define EE_PARA_APPEND 0xFFFF
51 #define EE_PARA_ALL 0xFFFF
52 #define EE_APPEND 0xFFFF
53 #define EE_INDEX_NOT_FOUND 0xFFFF
54
55 // Fehlermeldungen fuer Read/Write-Methode
56 #define EE_READWRITE_OK (SVSTREAM_OK)
57 #define EE_READWRITE_WRONGFORMAT (SVSTREAM_ERRBASE_USER+1)
58 #define EE_READWRITE_GENERALERROR (SVSTREAM_ERRBASE_USER+2)
59
60 #define EDITUNDO_START 100
61 #define EDITUNDO_REMOVECHARS 100
62 #define EDITUNDO_CONNECTPARAS 101
63 #define EDITUNDO_REMOVEFEATURE 102
64 #define EDITUNDO_MOVEPARAGRAPHS 103
65 #define EDITUNDO_INSERTFEATURE 104
66 #define EDITUNDO_SPLITPARA 105
67 #define EDITUNDO_INSERTCHARS 106
68 #define EDITUNDO_DELCONTENT 107
69 #define EDITUNDO_DELETE 108
70 #define EDITUNDO_CUT 109
71 #define EDITUNDO_PASTE 110
72 #define EDITUNDO_INSERT 111
73 #define EDITUNDO_SRCHANDREPL 112
74 #define EDITUNDO_MOVEPARAS 113
75 #define EDITUNDO_PARAATTRIBS 114
76 #define EDITUNDO_ATTRIBS 115
77 #define EDITUNDO_DRAGANDDROP 116
78 #define EDITUNDO_READ 117
79 #define EDITUNDO_STYLESHEET 118
80 #define EDITUNDO_REPLACEALL 119
81 #define EDITUNDO_STRETCH 120
82 #define EDITUNDO_RESETATTRIBS 121
83 #define EDITUNDO_INDENTBLOCK 122
84 #define EDITUNDO_UNINDENTBLOCK 123
85 #define EDITUNDO_MARKSELECTION 124
86 #define EDITUNDO_TRANSLITERATE 125
87 #define EDITUNDO_END 125
88
89 #define EDITUNDO_USER 200
90
91
92 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_SUMMATION 0x0001
93 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_BEFOREFIRSTPARAGRAPH 0x0002
94
95 class EditView;
96 class EditEngine;
97 class ImpEditView;
98 class ImpEditEngine;
99 class EditTextObject;
100 class SfxStyleSheet;
101
102 #define RGCHK_NONE 0 // Keine Korrektur der ViusArea beim Scrollen
103 #define RGCHK_NEG 1 // Keine neg. ViusArea beim Scrollen
104 #define RGCHK_PAPERSZ1 2 // VisArea muss in Papierbreite,Texthoehe liegen
105
106 struct EPosition
107 {
108 sal_uInt16 nPara;
109 xub_StrLen nIndex;
110
EPositionEPosition111 EPosition() :
112 nPara( EE_PARA_NOT_FOUND ),
113 nIndex( EE_INDEX_NOT_FOUND )
114 {
115 }
116
EPositionEPosition117 EPosition( sal_uInt16 nPara_, xub_StrLen nPos_ ) :
118 nPara( nPara_ ),
119 nIndex( nPos_ )
120 {
121 }
122 };
123
124 struct ESelection
125 {
126 sal_uInt16 nStartPara;
127 xub_StrLen nStartPos;
128 sal_uInt16 nEndPara;
129 xub_StrLen nEndPos;
130
ESelectionESelection131 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
132
ESelectionESelection133 ESelection( sal_uInt16 nStPara, xub_StrLen nStPos, sal_uInt16 nEPara, xub_StrLen nEPos ) :
134 nStartPara( nStPara ),
135 nStartPos( nStPos ),
136 nEndPara( nEPara ),
137 nEndPos( nEPos )
138 {
139 }
140
ESelectionESelection141 ESelection( sal_uInt16 nPara, xub_StrLen nPos ) :
142 nStartPara( nPara ),
143 nStartPos( nPos ),
144 nEndPara( nPara ),
145 nEndPos( nPos )
146 {
147 }
148
149 void Adjust();
150 sal_Bool IsEqual( const ESelection& rS ) const;
151 sal_Bool IsLess( const ESelection& rS ) const;
152 sal_Bool IsGreater( const ESelection& rS ) const;
153 sal_Bool IsZero() const;
154 sal_Bool HasRange() const;
155 };
156
HasRange() const157 inline sal_Bool ESelection::HasRange() const
158 {
159 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
160 }
161
IsZero() const162 inline sal_Bool ESelection::IsZero() const
163 {
164 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
165 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
166 }
167
IsEqual(const ESelection & rS) const168 inline sal_Bool ESelection::IsEqual( const ESelection& rS ) const
169 {
170 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
171 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
172 }
173
IsLess(const ESelection & rS) const174 inline sal_Bool ESelection::IsLess( const ESelection& rS ) const
175 {
176 // Selektion muss justiert sein.
177 // => Nur pueffen, ob Ende von 'this' < Start von rS
178
179 if ( ( nEndPara < rS.nStartPara ) ||
180 ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) ) )
181 {
182 return sal_True;
183 }
184 return sal_False;
185 }
186
IsGreater(const ESelection & rS) const187 inline sal_Bool ESelection::IsGreater( const ESelection& rS ) const
188 {
189 // Selektion muss justiert sein.
190 // => Nur pueffen, ob Ende von 'this' > Start von rS
191
192 if ( ( nStartPara > rS.nEndPara ) ||
193 ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) ) )
194 {
195 return sal_True;
196 }
197 return sal_False;
198 }
199
Adjust()200 inline void ESelection::Adjust()
201 {
202 sal_Bool bSwap = sal_False;
203 if ( nStartPara > nEndPara )
204 bSwap = sal_True;
205 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
206 bSwap = sal_True;
207
208 if ( bSwap )
209 {
210 sal_uInt16 nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
211 nStartPara = nEndPara; nStartPos = nEndPos;
212 nEndPara = nSPar; nEndPos = nSPos;
213 }
214 }
215
216 struct EDITENG_DLLPUBLIC EFieldInfo
217 {
218 SvxFieldItem* pFieldItem;
219 String aCurrentText;
220 EPosition aPosition;
221
222 EFieldInfo();
223 EFieldInfo( const SvxFieldItem& rFieldItem, sal_uInt16 nPara, sal_uInt16 nPos );
224 ~EFieldInfo();
225
226 EFieldInfo( const EFieldInfo& );
227 EFieldInfo& operator= ( const EFieldInfo& );
228 };
229
230 // -----------------------------------------------------------------------
231
232 enum ImportState {
233 RTFIMP_START, RTFIMP_END, // nur pParser, nPara, nIndex
234 RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR, // nToken+nTokenValue
235 RTFIMP_SETATTR, // pAttrs
236 RTFIMP_INSERTTEXT, // aText
237 RTFIMP_INSERTPARA, // -
238 HTMLIMP_START, HTMLIMP_END, // nur pParser, nPara, nIndex
239 HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
240 HTMLIMP_SETATTR, // pAttrs
241 HTMLIMP_INSERTTEXT, // aText
242 HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
243 };
244
245 struct ImportInfo
246 {
247 SvParser* pParser;
248 ESelection aSelection;
249 ImportState eState;
250
251 int nToken;
252 short nTokenValue;
253
254 String aText;
255
256 void* pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
257
258 ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
259 ~ImportInfo();
260 };
261
262 #define EE_SEARCH_WORDONLY 0x0001
263 #define EE_SEARCH_EXACT 0x0002
264 #define EE_SEARCH_BACKWARD 0x0004
265 #define EE_SEARCH_INSELECTION 0x0008
266 #define EE_SEARCH_REGEXPR 0x0010
267 #define EE_SEARCH_PATTERN 0x0020
268
269 struct ParagraphInfos
270 {
ParagraphInfosParagraphInfos271 ParagraphInfos()
272 : nParaHeight( 0 )
273 , nLines( 0 )
274 , nFirstLineStartX( 0 )
275 , nFirstLineOffset( 0 )
276 , nFirstLineHeight( 0 )
277 , nFirstLineTextHeight ( 0 )
278 , nFirstLineMaxAscent( 0 )
279 , bValid( 0 )
280 {}
281 sal_uInt16 nParaHeight;
282 sal_uInt16 nLines;
283
284 sal_uInt16 nFirstLineStartX;
285
286 sal_uInt16 nFirstLineOffset;
287 sal_uInt16 nFirstLineHeight;
288 sal_uInt16 nFirstLineTextHeight;
289 sal_uInt16 nFirstLineMaxAscent;
290
291 sal_Bool bValid; // Bei einer Abfrage waehrend der Formatierung ungueltig!
292 };
293
294 struct EECharAttrib
295 {
296 const SfxPoolItem* pAttr;
297
298 sal_uInt16 nPara;
299 xub_StrLen nStart;
300 xub_StrLen nEnd;
301 };
302
303 SV_DECL_VARARR_VISIBILITY( EECharAttribArray, EECharAttrib, 0, 4, EDITENG_DLLPUBLIC )
304
305 struct MoveParagraphsInfo
306 {
307 sal_uInt16 nStartPara;
308 sal_uInt16 nEndPara;
309 sal_uInt16 nDestPara;
310
MoveParagraphsInfoMoveParagraphsInfo311 MoveParagraphsInfo( sal_uInt16 nS, sal_uInt16 nE, sal_uInt16 nD )
312 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
313 };
314
315 #define EE_ACTION_PASTE 1
316 #define EE_ACTION_DROP 2
317
318 struct PasteOrDropInfos
319 {
320 sal_uInt16 nAction;
321 sal_uInt16 nStartPara;
322 sal_uInt16 nEndPara;
323
PasteOrDropInfosPasteOrDropInfos324 PasteOrDropInfos() : nAction(0), nStartPara(0xFFFF), nEndPara(0xFFFF) {}
325 };
326
327 enum EENotifyType
328 {
329 /// EditEngine text was modified
330 EE_NOTIFY_TEXTMODIFIED,
331
332 /// A paragraph was inserted into the EditEngine
333 EE_NOTIFY_PARAGRAPHINSERTED,
334
335 /// A paragraph was removed from the EditEngine
336 EE_NOTIFY_PARAGRAPHREMOVED,
337
338 /// Multiple paragraphs have been removed from the EditEngine
339 EE_NOTIFY_PARAGRAPHSMOVED,
340
341 /// The height of at least one paragraph has changed
342 EE_NOTIFY_TEXTHEIGHTCHANGED,
343
344 /// The view area of the EditEngine scrolled
345 EE_NOTIFY_TEXTVIEWSCROLLED,
346
347 /// The selection and/or the cursor position has changed
348 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
349
350 /** Denotes the beginning of a collected amount of EditEngine
351 notification events. This event itself is not queued, but sent
352 immediately
353 */
354 EE_NOTIFY_BLOCKNOTIFICATION_START,
355
356 /** Denotes the end of a collected amount of EditEngine
357 notification events. After this event, the queue is empty, and
358 a high-level operation such as "insert paragraph" is finished
359 */
360 EE_NOTIFY_BLOCKNOTIFICATION_END,
361
362 /// Denotes the beginning of a high-level action triggered by a key press
363 EE_NOTIFY_INPUT_START,
364
365 /// Denotes the end of a high-level action triggered by a key press
366 EE_NOTIFY_INPUT_END,
367 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
368 };
369
370 struct EENotify
371 {
372 EENotifyType eNotificationType;
373 EditEngine* pEditEngine;
374 EditView* pEditView;
375
376 sal_uInt16 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
377
378 sal_uInt16 nParam1;
379 sal_uInt16 nParam2;
380
EENotifyEENotify381 EENotify( EENotifyType eType )
382 { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
383 };
384
385 #endif // _MyEDITDATA_HXX
386