build fix
[LibreOffice.git] / include / editeng / editdata.hxx
blob33de259fc6c2f33de6e66b25b627b759b8d9efab
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 // MyEDITDATA, wegen exportiertem EditData
21 #ifndef INCLUDED_EDITENG_EDITDATA_HXX
22 #define INCLUDED_EDITENG_EDITDATA_HXX
24 #include <rtl/ustring.hxx>
25 #include <editeng/editengdllapi.h>
27 class SfxItemSet;
28 class SfxPoolItem;
29 class SvParser;
30 class SvxFieldItem;
32 enum EETextFormat { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
33 enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
34 enum EESelectionMode { EE_SELMODE_STD, EE_SELMODE_TXTONLY, EE_SELMODE_HIDDEN };
35 // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is useful e.g. when you want show the selection
36 // only as long as your window (which the edit view works on) has the focus
37 enum EESpellState { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
38 enum EVAnchorMode {
39 ANCHOR_TOP_LEFT, ANCHOR_VCENTER_LEFT, ANCHOR_BOTTOM_LEFT,
40 ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
41 ANCHOR_TOP_RIGHT, ANCHOR_VCENTER_RIGHT, ANCHOR_BOTTOM_RIGHT };
43 #define EE_PARA_NOT_FOUND SAL_MAX_INT32
44 #define EE_PARA_APPEND SAL_MAX_INT32
45 #define EE_PARA_ALL SAL_MAX_INT32
46 #define EE_PARA_MAX_COUNT SAL_MAX_INT32
48 #define EE_INDEX_NOT_FOUND SAL_MAX_INT32
49 #define EE_TEXTPOS_ALL SAL_MAX_INT32
50 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32
52 EDITENG_DLLPUBLIC extern const size_t EE_APPEND;
54 // Error messages for Read / Write Method
55 #define EE_READWRITE_OK (SVSTREAM_OK)
56 #define EE_READWRITE_WRONGFORMAT (SVSTREAM_ERRBASE_USER+1)
57 #define EE_READWRITE_GENERALERROR (SVSTREAM_ERRBASE_USER+2)
59 #define EDITUNDO_REMOVECHARS 100
60 #define EDITUNDO_CONNECTPARAS 101
61 #define EDITUNDO_MOVEPARAGRAPHS 103
62 #define EDITUNDO_INSERTFEATURE 104
63 #define EDITUNDO_SPLITPARA 105
64 #define EDITUNDO_INSERTCHARS 106
65 #define EDITUNDO_DELCONTENT 107
66 #define EDITUNDO_DELETE 108
67 #define EDITUNDO_CUT 109
68 #define EDITUNDO_PASTE 110
69 #define EDITUNDO_INSERT 111
70 #define EDITUNDO_MOVEPARAS 113
71 #define EDITUNDO_PARAATTRIBS 114
72 #define EDITUNDO_ATTRIBS 115
73 #define EDITUNDO_DRAGANDDROP 116
74 #define EDITUNDO_READ 117
75 #define EDITUNDO_STYLESHEET 118
76 #define EDITUNDO_REPLACEALL 119
77 #define EDITUNDO_RESETATTRIBS 121
78 #define EDITUNDO_INDENTBLOCK 122
79 #define EDITUNDO_UNINDENTBLOCK 123
80 #define EDITUNDO_MARKSELECTION 124
81 #define EDITUNDO_TRANSLITERATE 125
83 #define EDITUNDO_USER 200
85 class EditView;
86 class EditEngine;
87 class ImpEditView;
88 class ImpEditEngine;
89 class EditTextObject;
90 class SfxStyleSheet;
92 struct EPosition
94 sal_Int32 nPara;
95 sal_Int32 nIndex;
97 EPosition()
98 : nPara( EE_PARA_NOT_FOUND )
99 , nIndex( EE_INDEX_NOT_FOUND )
102 EPosition( sal_Int32 nPara_, sal_Int32 nPos_ )
103 : nPara( nPara_ )
104 , nIndex( nPos_ )
108 struct ESelection
110 sal_Int32 nStartPara;
111 sal_Int32 nStartPos;
112 sal_Int32 nEndPara;
113 sal_Int32 nEndPos;
115 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
117 ESelection( sal_Int32 nStPara, sal_Int32 nStPos,
118 sal_Int32 nEPara, sal_Int32 nEPos )
119 : nStartPara( nStPara )
120 , nStartPos( nStPos )
121 , nEndPara( nEPara )
122 , nEndPos( nEPos )
125 ESelection( sal_Int32 nPara, sal_Int32 nPos )
126 : nStartPara( nPara )
127 , nStartPos( nPos )
128 , nEndPara( nPara )
129 , nEndPos( nPos )
132 void Adjust();
133 bool IsEqual( const ESelection& rS ) const;
134 bool IsLess( const ESelection& rS ) const;
135 bool IsGreater( const ESelection& rS ) const;
136 bool IsZero() const;
137 bool HasRange() const;
140 inline bool ESelection::HasRange() const
142 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
145 inline bool ESelection::IsZero() const
147 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
148 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
151 inline bool ESelection::IsEqual( const ESelection& rS ) const
153 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
154 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
157 inline bool ESelection::IsLess( const ESelection& rS ) const
159 // The selection must be adjusted.
160 // => Only check if end of 'this' < Start of rS
161 return ( nEndPara < rS.nStartPara ) ||
162 ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) );
165 inline bool ESelection::IsGreater( const ESelection& rS ) const
167 // The selection must be adjusted.
168 // => Only check if end of 'this' < Start of rS
169 return ( nStartPara > rS.nEndPara ) ||
170 ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) );
173 inline void ESelection::Adjust()
175 bool bSwap = false;
176 if ( nStartPara > nEndPara )
177 bSwap = true;
178 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
179 bSwap = true;
181 if ( bSwap )
183 sal_Int32 nSPar = nStartPara; sal_Int32 nSPos = nStartPos;
184 nStartPara = nEndPara; nStartPos = nEndPos;
185 nEndPara = nSPar; nEndPos = nSPos;
189 struct EDITENG_DLLPUBLIC EFieldInfo
191 SvxFieldItem* pFieldItem;
192 OUString aCurrentText;
193 EPosition aPosition;
195 EFieldInfo();
196 EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos );
197 ~EFieldInfo();
199 EFieldInfo( const EFieldInfo& );
200 EFieldInfo& operator= ( const EFieldInfo& );
203 enum ImportState {
204 RTFIMP_START, RTFIMP_END, // only pParser, nPara, nIndex
205 RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR, // nToken+nTokenValue
206 RTFIMP_SETATTR, // pAttrs
207 RTFIMP_INSERTTEXT, // aText
208 RTFIMP_INSERTPARA, // -
209 HTMLIMP_START, HTMLIMP_END, // only pParser, nPara, nIndex
210 HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
211 HTMLIMP_SETATTR, // pAttrs
212 HTMLIMP_INSERTTEXT, // aText
213 HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
216 struct ImportInfo
218 SvParser* pParser;
219 ESelection aSelection;
220 ImportState eState;
222 int nToken;
223 short nTokenValue;
225 OUString aText;
227 void* pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
229 ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
230 ~ImportInfo();
233 struct ParagraphInfos
235 ParagraphInfos()
236 : nParaHeight( 0 )
237 , nLines( 0 )
238 , nFirstLineStartX( 0 )
239 , nFirstLineOffset( 0 )
240 , nFirstLineHeight( 0 )
241 , nFirstLineTextHeight ( 0 )
242 , nFirstLineMaxAscent( 0 )
243 , bValid( false )
245 sal_uInt16 nParaHeight;
246 sal_uInt16 nLines;
248 sal_uInt16 nFirstLineStartX;
250 sal_uInt16 nFirstLineOffset;
251 sal_uInt16 nFirstLineHeight;
252 sal_uInt16 nFirstLineTextHeight;
253 sal_uInt16 nFirstLineMaxAscent;
255 bool bValid; // A query during formatting is not valid!
258 struct EECharAttrib
260 const SfxPoolItem* pAttr;
262 sal_Int32 nPara;
263 sal_Int32 nStart;
264 sal_Int32 nEnd;
267 struct MoveParagraphsInfo
269 sal_Int32 nStartPara;
270 sal_Int32 nEndPara;
271 sal_Int32 nDestPara;
273 MoveParagraphsInfo( sal_Int32 nS, sal_Int32 nE, sal_Int32 nD )
274 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
277 struct PasteOrDropInfos
279 sal_Int32 nStartPara;
280 sal_Int32 nEndPara;
282 PasteOrDropInfos() : nStartPara(-1), nEndPara(-1) {}
285 enum EENotifyType
287 /// EditEngine text was modified
288 EE_NOTIFY_TEXTMODIFIED,
290 /// A paragraph was inserted into the EditEngine
291 EE_NOTIFY_PARAGRAPHINSERTED,
293 /// A paragraph was removed from the EditEngine
294 EE_NOTIFY_PARAGRAPHREMOVED,
296 /// Multiple paragraphs have been removed from the EditEngine
297 EE_NOTIFY_PARAGRAPHSMOVED,
299 /// The height of at least one paragraph has changed
300 EE_NOTIFY_TEXTHEIGHTCHANGED,
302 /// The view area of the EditEngine scrolled
303 EE_NOTIFY_TEXTVIEWSCROLLED,
305 /// The selection and/or the cursor position has changed
306 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
308 /** Denotes the beginning of a collected amount of EditEngine
309 notification events. This event itself is not queued, but sent
310 immediately
312 EE_NOTIFY_BLOCKNOTIFICATION_START,
314 /** Denotes the end of a collected amount of EditEngine
315 notification events. After this event, the queue is empty, and
316 a high-level operation such as "insert paragraph" is finished
318 EE_NOTIFY_BLOCKNOTIFICATION_END,
320 /// Denotes the beginning of a high-level action triggered by a key press
321 EE_NOTIFY_INPUT_START,
323 /// Denotes the end of a high-level action triggered by a key press
324 EE_NOTIFY_INPUT_END,
325 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
328 struct EENotify
330 EENotifyType eNotificationType;
331 EditEngine* pEditEngine;
332 EditView* pEditView;
334 sal_Int32 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
336 sal_Int32 nParam1;
337 sal_Int32 nParam2;
339 EENotify( EENotifyType eType )
340 { eNotificationType = eType; pEditEngine = nullptr; pEditView = nullptr; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
343 #endif // INCLUDED_EDITENG_EDITDATA_HXX
345 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */