Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : // MyEDITDATA, wegen exportiertem EditData
30 : : #ifndef _MyEDITDATA_HXX
31 : : #define _MyEDITDATA_HXX
32 : :
33 : : #include <tools/string.hxx>
34 : : #include "editeng/editengdllapi.h"
35 : :
36 : : class SfxItemSet;
37 : : class SfxPoolItem;
38 : : class SvParser;
39 : : class SvxFieldItem;
40 : :
41 : : enum EETextFormat { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
42 : : enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
43 : : enum EESelectionMode { EE_SELMODE_STD, EE_SELMODE_TXTONLY, EE_SELMODE_HIDDEN };
44 : : // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is usefull e.g. when you want show the selection
45 : : // only as long as your window (which the edit view works on) has the focus
46 : : enum EESpellState { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
47 : : enum EVAnchorMode {
48 : : ANCHOR_TOP_LEFT, ANCHOR_VCENTER_LEFT, ANCHOR_BOTTOM_LEFT,
49 : : ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
50 : : ANCHOR_TOP_RIGHT, ANCHOR_VCENTER_RIGHT, ANCHOR_BOTTOM_RIGHT };
51 : :
52 : : #define EE_PARA_NOT_FOUND 0xFFFF
53 : : #define EE_PARA_APPEND 0xFFFF
54 : : #define EE_PARA_ALL 0xFFFF
55 : : #define EE_INDEX_NOT_FOUND 0xFFFF
56 : :
57 : : EDITENG_DLLPUBLIC extern const size_t EE_APPEND;
58 : :
59 : : // Error messages for Read / Write Method
60 : : #define EE_READWRITE_OK (SVSTREAM_OK)
61 : : #define EE_READWRITE_WRONGFORMAT (SVSTREAM_ERRBASE_USER+1)
62 : : #define EE_READWRITE_GENERALERROR (SVSTREAM_ERRBASE_USER+2)
63 : :
64 : : #define EDITUNDO_START 100
65 : : #define EDITUNDO_REMOVECHARS 100
66 : : #define EDITUNDO_CONNECTPARAS 101
67 : : #define EDITUNDO_REMOVEFEATURE 102
68 : : #define EDITUNDO_MOVEPARAGRAPHS 103
69 : : #define EDITUNDO_INSERTFEATURE 104
70 : : #define EDITUNDO_SPLITPARA 105
71 : : #define EDITUNDO_INSERTCHARS 106
72 : : #define EDITUNDO_DELCONTENT 107
73 : : #define EDITUNDO_DELETE 108
74 : : #define EDITUNDO_CUT 109
75 : : #define EDITUNDO_PASTE 110
76 : : #define EDITUNDO_INSERT 111
77 : : #define EDITUNDO_SRCHANDREPL 112
78 : : #define EDITUNDO_MOVEPARAS 113
79 : : #define EDITUNDO_PARAATTRIBS 114
80 : : #define EDITUNDO_ATTRIBS 115
81 : : #define EDITUNDO_DRAGANDDROP 116
82 : : #define EDITUNDO_READ 117
83 : : #define EDITUNDO_STYLESHEET 118
84 : : #define EDITUNDO_REPLACEALL 119
85 : : #define EDITUNDO_STRETCH 120
86 : : #define EDITUNDO_RESETATTRIBS 121
87 : : #define EDITUNDO_INDENTBLOCK 122
88 : : #define EDITUNDO_UNINDENTBLOCK 123
89 : : #define EDITUNDO_MARKSELECTION 124
90 : : #define EDITUNDO_TRANSLITERATE 125
91 : : #define EDITUNDO_END 125
92 : :
93 : : #define EDITUNDO_USER 200
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 // No correction of ViusArea when scrolling
103 : : #define RGCHK_NEG 1 // No negative ViusArea when scrolling
104 : : #define RGCHK_PAPERSZ1 2 // VisArea must be within paper width, Text Size
105 : :
106 : : struct EPosition
107 : : {
108 : : sal_uInt16 nPara;
109 : : xub_StrLen nIndex;
110 : :
111 : 76 : EPosition() :
112 : : nPara( EE_PARA_NOT_FOUND ),
113 : 76 : nIndex( EE_INDEX_NOT_FOUND )
114 : : {
115 : 76 : }
116 : :
117 : 96 : EPosition( sal_uInt16 nPara_, xub_StrLen nPos_ ) :
118 : : nPara( nPara_ ),
119 : 96 : nIndex( nPos_ )
120 : : {
121 : 96 : }
122 : : };
123 : :
124 : : struct ESelection
125 : : {
126 : : sal_uInt16 nStartPara;
127 : : xub_StrLen nStartPos;
128 : : sal_uInt16 nEndPara;
129 : : xub_StrLen nEndPos;
130 : :
131 : 274309 : ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
132 : :
133 : 173976 : ESelection( sal_uInt16 nStPara, xub_StrLen nStPos, sal_uInt16 nEPara, xub_StrLen nEPos ) :
134 : : nStartPara( nStPara ),
135 : : nStartPos( nStPos ),
136 : : nEndPara( nEPara ),
137 : 173976 : nEndPos( nEPos )
138 : : {
139 : 173976 : }
140 : :
141 : 0 : ESelection( sal_uInt16 nPara, xub_StrLen nPos ) :
142 : : nStartPara( nPara ),
143 : : nStartPos( nPos ),
144 : : nEndPara( nPara ),
145 : 0 : nEndPos( nPos )
146 : : {
147 : 0 : }
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 : :
157 : 138 : inline sal_Bool ESelection::HasRange() const
158 : : {
159 [ + - ][ + + ]: 138 : return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
160 : : }
161 : :
162 : 0 : inline sal_Bool ESelection::IsZero() const
163 : : {
164 : : return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
165 [ # # ][ # # ]: 0 : ( nEndPara == 0 ) && ( nEndPos == 0 ) );
[ # # ][ # # ]
166 : : }
167 : :
168 : 1035 : inline sal_Bool ESelection::IsEqual( const ESelection& rS ) const
169 : : {
170 : : return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
171 [ + - ][ + - ]: 1035 : ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
[ + - ][ + - ]
172 : : }
173 : :
174 : 0 : inline sal_Bool ESelection::IsLess( const ESelection& rS ) const
175 : : {
176 : : // The selection must be adjusted.
177 : : // => Only check if end of 'this' < Start of rS
178 : :
179 [ # # ][ # # ]: 0 : if ( ( nEndPara < rS.nStartPara ) ||
[ # # # # ]
[ # # ]
180 : 0 : ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) ) )
181 : : {
182 : 0 : return sal_True;
183 : : }
184 : 0 : return sal_False;
185 : : }
186 : :
187 : 0 : inline sal_Bool ESelection::IsGreater( const ESelection& rS ) const
188 : : {
189 : : // The selection must be adjusted.
190 : : // => Only check if end of 'this' < Start of rS
191 : :
192 [ # # ][ # # ]: 0 : if ( ( nStartPara > rS.nEndPara ) ||
[ # # # # ]
[ # # ]
193 : 0 : ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) ) )
194 : : {
195 : 0 : return sal_True;
196 : : }
197 : 0 : return sal_False;
198 : : }
199 : :
200 : 1759 : inline void ESelection::Adjust()
201 : : {
202 : 1759 : sal_Bool bSwap = sal_False;
203 [ - + ]: 1759 : if ( nStartPara > nEndPara )
204 : 0 : bSwap = sal_True;
205 [ + - ][ - + ]: 1759 : else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
206 : 0 : bSwap = sal_True;
207 : :
208 [ - + ]: 1759 : if ( bSwap )
209 : : {
210 : 0 : sal_uInt16 nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
211 : 0 : nStartPara = nEndPara; nStartPos = nEndPos;
212 : 0 : nEndPara = nSPar; nEndPos = nSPos;
213 : : }
214 : 1759 : }
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, // only 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, // only 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 : : struct ParagraphInfos
263 : : {
264 : 3025 : ParagraphInfos()
265 : : : nParaHeight( 0 )
266 : : , nLines( 0 )
267 : : , nFirstLineStartX( 0 )
268 : : , nFirstLineOffset( 0 )
269 : : , nFirstLineHeight( 0 )
270 : : , nFirstLineTextHeight ( 0 )
271 : : , nFirstLineMaxAscent( 0 )
272 : 3025 : , bValid( 0 )
273 : 3025 : {}
274 : : sal_uInt16 nParaHeight;
275 : : sal_uInt16 nLines;
276 : :
277 : : sal_uInt16 nFirstLineStartX;
278 : :
279 : : sal_uInt16 nFirstLineOffset;
280 : : sal_uInt16 nFirstLineHeight;
281 : : sal_uInt16 nFirstLineTextHeight;
282 : : sal_uInt16 nFirstLineMaxAscent;
283 : :
284 : : sal_Bool bValid; // A query during formatting is not valid!
285 : : };
286 : :
287 : : struct EECharAttrib
288 : : {
289 : : const SfxPoolItem* pAttr;
290 : :
291 : : sal_uInt16 nPara;
292 : : xub_StrLen nStart;
293 : : xub_StrLen nEnd;
294 : : };
295 : :
296 : : struct MoveParagraphsInfo
297 : : {
298 : : sal_uInt16 nStartPara;
299 : : sal_uInt16 nEndPara;
300 : : sal_uInt16 nDestPara;
301 : :
302 : 0 : MoveParagraphsInfo( sal_uInt16 nS, sal_uInt16 nE, sal_uInt16 nD )
303 : 0 : { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
304 : : };
305 : :
306 : : #define EE_ACTION_PASTE 1
307 : : #define EE_ACTION_DROP 2
308 : :
309 : : struct PasteOrDropInfos
310 : : {
311 : : sal_uInt16 nAction;
312 : : sal_uInt16 nStartPara;
313 : : sal_uInt16 nEndPara;
314 : :
315 : 0 : PasteOrDropInfos() : nAction(0), nStartPara(0xFFFF), nEndPara(0xFFFF) {}
316 : : };
317 : :
318 : : enum EENotifyType
319 : : {
320 : : /// EditEngine text was modified
321 : : EE_NOTIFY_TEXTMODIFIED,
322 : :
323 : : /// A paragraph was inserted into the EditEngine
324 : : EE_NOTIFY_PARAGRAPHINSERTED,
325 : :
326 : : /// A paragraph was removed from the EditEngine
327 : : EE_NOTIFY_PARAGRAPHREMOVED,
328 : :
329 : : /// Multiple paragraphs have been removed from the EditEngine
330 : : EE_NOTIFY_PARAGRAPHSMOVED,
331 : :
332 : : /// The height of at least one paragraph has changed
333 : : EE_NOTIFY_TEXTHEIGHTCHANGED,
334 : :
335 : : /// The view area of the EditEngine scrolled
336 : : EE_NOTIFY_TEXTVIEWSCROLLED,
337 : :
338 : : /// The selection and/or the cursor position has changed
339 : : EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
340 : :
341 : : /** Denotes the beginning of a collected amount of EditEngine
342 : : notification events. This event itself is not queued, but sent
343 : : immediately
344 : : */
345 : : EE_NOTIFY_BLOCKNOTIFICATION_START,
346 : :
347 : : /** Denotes the end of a collected amount of EditEngine
348 : : notification events. After this event, the queue is empty, and
349 : : a high-level operation such as "insert paragraph" is finished
350 : : */
351 : : EE_NOTIFY_BLOCKNOTIFICATION_END,
352 : :
353 : : /// Denotes the beginning of a high-level action triggered by a key press
354 : : EE_NOTIFY_INPUT_START,
355 : :
356 : : /// Denotes the end of a high-level action triggered by a key press
357 : : EE_NOTIFY_INPUT_END
358 : : };
359 : :
360 : : struct EENotify
361 : : {
362 : : EENotifyType eNotificationType;
363 : : EditEngine* pEditEngine;
364 : : EditView* pEditView;
365 : :
366 : : sal_uInt16 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
367 : :
368 : : sal_uInt16 nParam1;
369 : : sal_uInt16 nParam2;
370 : :
371 : 928387 : EENotify( EENotifyType eType )
372 : 928387 : { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
373 : : };
374 : :
375 : : #endif // _MyEDITDATA_HXX
376 : :
377 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|