Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / editeng / editdata.hxx
blob9560c2e328633bb2059187350a1bafab9a44dcc5
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>
26 #include <memory>
28 class SfxItemSet;
29 class SfxPoolItem;
30 template<typename T> class SvParser;
31 class SvxFieldItem;
32 class SvxRTFItemStackType;
33 enum class HtmlTokenId : sal_Int16;
35 enum EETextFormat { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
36 enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
37 enum class EESelectionMode { Std, TxtOnly, Hidden };
38 // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is useful e.g. when you want show the selection
39 // only as long as your window (which the edit view works on) has the focus
40 enum class EESpellState { Ok, LanguageNotInstalled, NoSpeller, ErrorFound };
41 enum class EEAnchorMode {
42 TopLeft, TopHCenter, TopRight,
43 VCenterLeft, VCenterHCenter, VCenterRight,
44 BottomLeft, BottomHCenter, BottomRight };
46 #define EE_PARA_NOT_FOUND SAL_MAX_INT32
47 #define EE_PARA_APPEND SAL_MAX_INT32
48 #define EE_PARA_ALL SAL_MAX_INT32
49 #define EE_PARA_MAX_COUNT SAL_MAX_INT32
51 #define EE_INDEX_NOT_FOUND SAL_MAX_INT32
52 #define EE_TEXTPOS_ALL SAL_MAX_INT32
53 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32
55 EDITENG_DLLPUBLIC extern const size_t EE_APPEND;
57 // Error messages for Read / Write Method
58 #define EE_READWRITE_OK (SVSTREAM_OK)
59 #define EE_READWRITE_WRONGFORMAT (SVSTREAM_ERRBASE_USER+1)
60 #define EE_READWRITE_GENERALERROR (SVSTREAM_ERRBASE_USER+2)
62 #define EDITUNDO_REMOVECHARS 100
63 #define EDITUNDO_CONNECTPARAS 101
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_MOVEPARAS 113
74 #define EDITUNDO_PARAATTRIBS 114
75 #define EDITUNDO_ATTRIBS 115
76 #define EDITUNDO_DRAGANDDROP 116
77 #define EDITUNDO_READ 117
78 #define EDITUNDO_STYLESHEET 118
79 #define EDITUNDO_REPLACEALL 119
80 #define EDITUNDO_RESETATTRIBS 121
81 #define EDITUNDO_INDENTBLOCK 122
82 #define EDITUNDO_UNINDENTBLOCK 123
83 #define EDITUNDO_MARKSELECTION 124
84 #define EDITUNDO_TRANSLITERATE 125
86 #define EDITUNDO_USER 200
88 class EditView;
89 class EditEngine;
90 class ImpEditView;
91 class ImpEditEngine;
92 class EditTextObject;
93 class SfxStyleSheet;
95 struct EPosition
97 sal_Int32 nPara;
98 sal_Int32 nIndex;
100 EPosition()
101 : nPara( EE_PARA_NOT_FOUND )
102 , nIndex( EE_INDEX_NOT_FOUND )
105 EPosition( sal_Int32 nPara_, sal_Int32 nPos_ )
106 : nPara( nPara_ )
107 , nIndex( nPos_ )
111 struct ESelection
113 sal_Int32 nStartPara;
114 sal_Int32 nStartPos;
115 sal_Int32 nEndPara;
116 sal_Int32 nEndPos;
118 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
120 ESelection( sal_Int32 nStPara, sal_Int32 nStPos,
121 sal_Int32 nEPara, sal_Int32 nEPos )
122 : nStartPara( nStPara )
123 , nStartPos( nStPos )
124 , nEndPara( nEPara )
125 , nEndPos( nEPos )
128 ESelection( sal_Int32 nPara, sal_Int32 nPos )
129 : nStartPara( nPara )
130 , nStartPos( nPos )
131 , nEndPara( nPara )
132 , nEndPos( nPos )
135 void Adjust();
136 bool IsEqual( const ESelection& rS ) const;
137 bool IsLess( const ESelection& rS ) const;
138 bool IsGreater( const ESelection& rS ) const;
139 bool IsZero() const;
140 bool HasRange() const;
143 inline bool ESelection::HasRange() const
145 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
148 inline bool ESelection::IsZero() const
150 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
151 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
154 inline bool ESelection::IsEqual( const ESelection& rS ) const
156 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
157 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
160 inline bool ESelection::IsLess( const ESelection& rS ) const
162 // The selection must be adjusted.
163 // => Only check if end of 'this' < Start of rS
164 return ( nEndPara < rS.nStartPara ) ||
165 ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) );
168 inline bool ESelection::IsGreater( const ESelection& rS ) const
170 // The selection must be adjusted.
171 // => Only check if end of 'this' < Start of rS
172 return ( nStartPara > rS.nEndPara ) ||
173 ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) );
176 inline void ESelection::Adjust()
178 bool bSwap = false;
179 if ( nStartPara > nEndPara )
180 bSwap = true;
181 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
182 bSwap = true;
184 if ( bSwap )
186 sal_Int32 nSPar = nStartPara; sal_Int32 nSPos = nStartPos;
187 nStartPara = nEndPara; nStartPos = nEndPos;
188 nEndPara = nSPar; nEndPos = nSPos;
192 struct EDITENG_DLLPUBLIC EFieldInfo
194 std::unique_ptr<SvxFieldItem> pFieldItem;
195 OUString aCurrentText;
196 EPosition aPosition;
198 EFieldInfo();
199 EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos );
200 ~EFieldInfo();
202 EFieldInfo( const EFieldInfo& );
203 EFieldInfo& operator= ( const EFieldInfo& );
206 enum class RtfImportState {
207 Start, End, // only pParser, nPara, nIndex
208 NextToken, UnknownAttr, // nToken+nTokenValue
209 SetAttr, // pAttrs
210 InsertText, // aText
211 InsertPara, // -
213 enum class HtmlImportState {
214 Start, End, // only pParser, nPara, nIndex
215 NextToken, // nToken
216 SetAttr, // pAttrs
217 InsertText, // aText
218 InsertPara, InsertField // -
221 struct HtmlImportInfo
223 SvParser<HtmlTokenId>* pParser;
224 ESelection aSelection;
225 HtmlImportState eState;
227 HtmlTokenId nToken;
228 short nTokenValue;
230 OUString aText;
232 SfxItemSet* pAttrs;
234 HtmlImportInfo( HtmlImportState eState, SvParser<HtmlTokenId>* pPrsrs, const ESelection& rSel );
235 ~HtmlImportInfo();
238 struct RtfImportInfo
240 SvParser<int>* pParser;
241 ESelection aSelection;
242 RtfImportState eState;
244 int nToken;
245 short nTokenValue;
247 OUString aText;
249 SvxRTFItemStackType* pAttrs;
251 RtfImportInfo( RtfImportState eState, SvParser<int>* pPrsrs, const ESelection& rSel );
252 ~RtfImportInfo();
255 struct ParagraphInfos
257 ParagraphInfos()
258 : nParaHeight( 0 )
259 , nLines( 0 )
260 , nFirstLineStartX( 0 )
261 , nFirstLineOffset( 0 )
262 , nFirstLineHeight( 0 )
263 , nFirstLineTextHeight ( 0 )
264 , nFirstLineMaxAscent( 0 )
265 , bValid( false )
267 sal_uInt16 nParaHeight;
268 sal_uInt16 nLines;
270 sal_uInt16 nFirstLineStartX;
272 sal_uInt16 nFirstLineOffset;
273 sal_uInt16 nFirstLineHeight;
274 sal_uInt16 nFirstLineTextHeight;
275 sal_uInt16 nFirstLineMaxAscent;
277 bool bValid; // A query during formatting is not valid!
280 struct EECharAttrib
282 const SfxPoolItem* pAttr;
284 sal_Int32 nPara;
285 sal_Int32 nStart;
286 sal_Int32 nEnd;
289 struct MoveParagraphsInfo
291 sal_Int32 nStartPara;
292 sal_Int32 nEndPara;
293 sal_Int32 nDestPara;
295 MoveParagraphsInfo( sal_Int32 nS, sal_Int32 nE, sal_Int32 nD )
296 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
299 struct PasteOrDropInfos
301 sal_Int32 nStartPara;
302 sal_Int32 nEndPara;
304 PasteOrDropInfos() : nStartPara(-1), nEndPara(-1) {}
307 enum EENotifyType
309 /// EditEngine text was modified
310 EE_NOTIFY_TEXTMODIFIED,
312 /// A paragraph was inserted into the EditEngine
313 EE_NOTIFY_PARAGRAPHINSERTED,
315 /// A paragraph was removed from the EditEngine
316 EE_NOTIFY_PARAGRAPHREMOVED,
318 /// Multiple paragraphs have been removed from the EditEngine
319 EE_NOTIFY_PARAGRAPHSMOVED,
321 /// The height of at least one paragraph has changed
322 EE_NOTIFY_TextHeightChanged,
324 /// The view area of the EditEngine scrolled
325 EE_NOTIFY_TEXTVIEWSCROLLED,
327 /// The selection and/or the cursor position has changed
328 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
330 /** Denotes the beginning of a collected amount of EditEngine
331 notification events. This event itself is not queued, but sent
332 immediately
334 EE_NOTIFY_BLOCKNOTIFICATION_START,
336 /** Denotes the end of a collected amount of EditEngine
337 notification events. After this event, the queue is empty, and
338 a high-level operation such as "insert paragraph" is finished
340 EE_NOTIFY_BLOCKNOTIFICATION_END,
342 /// Denotes the beginning of a high-level action triggered by a key press
343 EE_NOTIFY_INPUT_START,
345 /// Denotes the end of a high-level action triggered by a key press
346 EE_NOTIFY_INPUT_END,
347 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
350 struct EENotify
352 EENotifyType eNotificationType;
353 EditEngine* pEditEngine;
354 EditView* pEditView;
356 sal_Int32 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
358 sal_Int32 nParam1;
359 sal_Int32 nParam2;
361 EENotify( EENotifyType eType )
362 { eNotificationType = eType; pEditEngine = nullptr; pEditView = nullptr; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
365 #endif // INCLUDED_EDITENG_EDITDATA_HXX
367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */