Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svx / editdata.hxx
blob0453ae6fed7a4bbae13cf3408ff0093d73da10af
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: editdata.hxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 // MyEDITDATA, wegen exportiertem EditData
32 #ifndef _MyEDITDATA_HXX
33 #define _MyEDITDATA_HXX
35 #ifndef _STRING_HXX //autogen
36 #include <tools/string.hxx>
37 #endif
39 #include <bf_svtools/svarray.hxx>
40 namespace binfilter {
42 class SfxItemSet;
43 class SfxPoolItem;
44 class SfxStyleSheet;
46 class SvParser;
47 class SvxFieldItem;
49 enum EETextFormat { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
50 enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
51 enum EESelectionMode { EE_SELMODE_STD, EE_SELMODE_TXTONLY };
52 enum EESpellState { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
53 enum EVAnchorMode {
54 ANCHOR_TOP_LEFT, ANCHOR_VCENTER_LEFT, ANCHOR_BOTTOM_LEFT,
55 ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
56 ANCHOR_TOP_RIGHT, ANCHOR_VCENTER_RIGHT, ANCHOR_BOTTOM_RIGHT };
58 #define EE_PARA_NOT_FOUND 0xFFFF
59 #define EE_PARA_APPEND 0xFFFF
60 #define EE_PARA_ALL 0xFFFF
61 #define EE_APPEND 0xFFFF
62 #define EE_INDEX_NOT_FOUND 0xFFFF
64 // Fehlermeldungen fuer Read/Write-Methode
65 #define EE_READWRITE_OK (SVSTREAM_OK)
66 #define EE_READWRITE_WRONGFORMAT (SVSTREAM_ERRBASE_USER+1)
67 #define EE_READWRITE_GENERALERROR (SVSTREAM_ERRBASE_USER+2)
69 #define EDITUNDO_START 100
70 #define EDITUNDO_REMOVECHARS 100
71 #define EDITUNDO_CONNECTPARAS 101
72 #define EDITUNDO_REMOVEFEATURE 102
73 #define EDITUNDO_MOVEPARAGRAPHS 103
74 #define EDITUNDO_INSERTFEATURE 104
75 #define EDITUNDO_SPLITPARA 105
76 #define EDITUNDO_INSERTCHARS 106
77 #define EDITUNDO_DELCONTENT 107
78 #define EDITUNDO_DELETE 108
79 #define EDITUNDO_CUT 109
80 #define EDITUNDO_PASTE 110
81 #define EDITUNDO_INSERT 111
82 #define EDITUNDO_SRCHANDREPL 112
83 #define EDITUNDO_MOVEPARAS 113
84 #define EDITUNDO_PARAATTRIBS 114
85 #define EDITUNDO_ATTRIBS 115
86 #define EDITUNDO_DRAGANDDROP 116
87 #define EDITUNDO_READ 117
88 #define EDITUNDO_STYLESHEET 118
89 #define EDITUNDO_REPLACEALL 119
90 #define EDITUNDO_STRETCH 120
91 #define EDITUNDO_RESETATTRIBS 121
92 #define EDITUNDO_INDENTBLOCK 122
93 #define EDITUNDO_UNINDENTBLOCK 123
94 #define EDITUNDO_MARKSELECTION 124
95 #define EDITUNDO_TRANSLITERATE 125
96 #define EDITUNDO_END 125
98 #define EDITUNDO_USER 200
100 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_SUMMATION 0x0001
101 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_BEFOREFIRSTPARAGRAPH 0x0002
103 class EditView;
104 class EditEngine;
105 class ImpEditView;
106 class ImpEditEngine;
107 class EditTextObject;
109 #define RGCHK_NONE 0 // Keine Korrektur der ViusArea beim Scrollen
110 #define RGCHK_NEG 1 // Keine neg. ViusArea beim Scrollen
111 #define RGCHK_PAPERSZ1 2 // VisArea muss in Papierbreite,Texthoehe liegen
113 struct EPosition
115 USHORT nPara;
116 xub_StrLen nIndex;
118 EPosition()
120 nPara = EE_PARA_NOT_FOUND;
121 nIndex = EE_INDEX_NOT_FOUND;
124 EPosition( USHORT nPara_, xub_StrLen nPos_ )
126 nPara = nPara_;
127 nIndex = nPos_;
130 EPosition( const EPosition& rPosition )
132 nPara = rPosition.nPara;
133 nIndex = rPosition.nIndex;
137 struct ESelection
139 USHORT nStartPara;
140 xub_StrLen nStartPos;
141 USHORT nEndPara;
142 xub_StrLen nEndPos;
144 ESelection() { nStartPara = 0; nStartPos = 0; nEndPara = 0; nEndPos = 0; }
146 ESelection( USHORT nStPara, xub_StrLen nStPos, USHORT nEPara, xub_StrLen nEPos )
148 nStartPara = nStPara;
149 nStartPos = nStPos;
150 nEndPara = nEPara;
151 nEndPos = nEPos;
154 ESelection( USHORT nPara, xub_StrLen nPos )
156 nStartPara = nPara;
157 nStartPos = nPos;
158 nEndPara = nPara;
159 nEndPos = nPos;
162 ESelection( const ESelection& r )
164 nStartPara = r.nStartPara;
165 nStartPos = r.nStartPos;
166 nEndPara = r.nEndPara;
167 nEndPos = r.nEndPos;
170 ESelection& operator = ( const ESelection& r )
172 nStartPara = r.nStartPara;
173 nStartPos = r.nStartPos;
174 nEndPara = r.nEndPara;
175 nEndPos = r.nEndPos;
176 return *this;
179 void Adjust();
180 BOOL IsEqual( const ESelection& rS );
181 BOOL IsLess( const ESelection& rS );
182 BOOL IsGreater( const ESelection& rS );
183 BOOL IsZero();
184 BOOL HasRange() const;
187 inline BOOL ESelection::HasRange() const
189 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
192 inline sal_Bool ESelection::IsZero()
194 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
195 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
198 inline sal_Bool ESelection::IsEqual( const ESelection& rS )
200 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
201 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
204 inline sal_Bool ESelection::IsLess( const ESelection& rS )
206 // Selektion muss justiert sein.
207 // => Nur pueffen, ob Ende von 'this' < Start von rS
209 if ( ( nEndPara < rS.nStartPara ) ||
210 ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) ) )
212 return sal_True;
214 return sal_False;
217 inline sal_Bool ESelection::IsGreater( const ESelection& rS )
219 // Selektion muss justiert sein.
220 // => Nur pueffen, ob Ende von 'this' > Start von rS
222 if ( ( nStartPara > rS.nEndPara ) ||
223 ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) ) )
225 return sal_True;
227 return sal_False;
230 inline void ESelection::Adjust()
232 sal_Bool bSwap = sal_False;
233 if ( nStartPara > nEndPara )
234 bSwap = sal_True;
235 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
236 bSwap = sal_True;
238 if ( bSwap )
240 sal_uInt16 nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
241 nStartPara = nEndPara; nStartPos = nEndPos;
242 nEndPara = nSPar; nEndPos = nSPos;
246 struct EFieldInfo
248 SvxFieldItem* pFieldItem;
249 String aCurrentText;
250 EPosition aPosition;
252 EFieldInfo();
253 EFieldInfo( const SvxFieldItem& rFieldItem, USHORT nPara, USHORT nPos );
254 ~EFieldInfo();
256 EFieldInfo( const EFieldInfo& );
259 // -----------------------------------------------------------------------
261 enum ImportState {
262 RTFIMP_START, RTFIMP_END, // nur pParser, nPara, nIndex
263 RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR, // nToken+nTokenValue
264 RTFIMP_SETATTR, // pAttrs
265 RTFIMP_INSERTTEXT, // aText
266 RTFIMP_INSERTPARA, // -
267 HTMLIMP_START, HTMLIMP_END, // nur pParser, nPara, nIndex
268 HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
269 HTMLIMP_SETATTR, // pAttrs
270 HTMLIMP_INSERTTEXT, // aText
271 HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
274 struct ImportInfo
276 SvParser* pParser;
277 ESelection aSelection;
278 ImportState eState;
280 int nToken;
281 short nTokenValue;
283 String aText;
285 void* pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
287 ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
288 ~ImportInfo();
291 #define EE_SEARCH_WORDONLY 0x0001
292 #define EE_SEARCH_EXACT 0x0002
293 #define EE_SEARCH_BACKWARD 0x0004
294 #define EE_SEARCH_INSELECTION 0x0008
295 #define EE_SEARCH_REGEXPR 0x0010
296 #define EE_SEARCH_PATTERN 0x0020
298 struct ParagraphInfos
300 USHORT nParaHeight;
301 USHORT nLines;
303 USHORT nFirstLineStartX;
305 USHORT nFirstLineOffset;
306 USHORT nFirstLineHeight;
307 USHORT nFirstLineTextHeight;
308 USHORT nFirstLineMaxAscent;
310 BOOL bValid; // Bei einer Abfrage waehrend der Formatierung ungueltig!
313 struct EECharAttrib
315 const SfxPoolItem* pAttr;
317 USHORT nPara;
318 xub_StrLen nStart;
319 xub_StrLen nEnd;
322 SV_DECL_VARARR( EECharAttribArray, EECharAttrib, 0, 4 )//STRIP008 ;
324 struct MoveParagraphsInfo
326 USHORT nStartPara;
327 USHORT nEndPara;
328 USHORT nDestPara;
330 MoveParagraphsInfo( USHORT nS, USHORT nE, USHORT nD )
331 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
334 #define EE_ACTION_PASTE 1
335 #define EE_ACTION_DROP 2
337 struct PasteOrDropInfos
339 USHORT nAction;
340 USHORT nStartPara;
341 USHORT nEndPara;
342 SfxStyleSheet* pLevel0Style;
343 SfxStyleSheet* pLevelNStyle;
345 PasteOrDropInfos()
346 { nStartPara = 0xFFFF; nEndPara = 0xFFFF;
347 pLevel0Style = NULL; pLevelNStyle = NULL; nAction = 0; }
350 enum EENotifyType
352 /// EditEngine text was modified
353 EE_NOTIFY_TEXTMODIFIED,
355 /// A paragraph was inserted into the EditEngine
356 EE_NOTIFY_PARAGRAPHINSERTED,
358 /// A paragraph was removed from the EditEngine
359 EE_NOTIFY_PARAGRAPHREMOVED,
361 /// Multiple paragraphs have been removed from the EditEngine
362 EE_NOTIFY_PARAGRAPHSMOVED,
364 /// The height of at least one paragraph has changed
365 EE_NOTIFY_TEXTHEIGHTCHANGED,
367 /// The view area of the EditEngine scrolled
368 EE_NOTIFY_TEXTVIEWSCROLLED,
370 /// The selection and/or the cursor position has changed
371 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
373 /** Denotes the beginning of a collected amount of EditEngine
374 notification events. This event itself is not queued, but sent
375 immediately
377 EE_NOTIFY_BLOCKNOTIFICATION_START,
379 /** Denotes the end of a collected amount of EditEngine
380 notification events. After this event, the queue is empty, and
381 a high-level operation such as "insert paragraph" is finished
383 EE_NOTIFY_BLOCKNOTIFICATION_END,
385 /// Denotes the beginning of a high-level action triggered by a key press
386 EE_NOTIFY_INPUT_START,
388 /// Denotes the end of a high-level action triggered by a key press
389 EE_NOTIFY_INPUT_END
392 struct EENotify
394 EENotifyType eNotificationType;
395 EditEngine* pEditEngine;
396 EditView* pEditView;
398 USHORT nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
400 USHORT nParam1;
401 USHORT nParam2;
403 EENotify( EENotifyType eType )
404 { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
407 }//end of namespace binfilter
408 #endif // _MyEDITDATA_HXX