Branch libreoffice-5-0-4
[LibreOffice.git] / include / editeng / editdata.hxx
blob1847780973c751928a5eb74203d28c844e49124d
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_REMOVEFEATURE 102
62 #define EDITUNDO_MOVEPARAGRAPHS 103
63 #define EDITUNDO_INSERTFEATURE 104
64 #define EDITUNDO_SPLITPARA 105
65 #define EDITUNDO_INSERTCHARS 106
66 #define EDITUNDO_DELCONTENT 107
67 #define EDITUNDO_DELETE 108
68 #define EDITUNDO_CUT 109
69 #define EDITUNDO_PASTE 110
70 #define EDITUNDO_INSERT 111
71 #define EDITUNDO_SRCHANDREPL 112
72 #define EDITUNDO_MOVEPARAS 113
73 #define EDITUNDO_PARAATTRIBS 114
74 #define EDITUNDO_ATTRIBS 115
75 #define EDITUNDO_DRAGANDDROP 116
76 #define EDITUNDO_READ 117
77 #define EDITUNDO_STYLESHEET 118
78 #define EDITUNDO_REPLACEALL 119
79 #define EDITUNDO_STRETCH 120
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 #define RGCHK_NONE 0 // No correction of ViusArea when scrolling
96 #define RGCHK_NEG 1 // No negative ViusArea when scrolling
97 #define RGCHK_PAPERSZ1 2 // VisArea must be within paper width, Text Size
99 struct EPosition
101 sal_Int32 nPara;
102 sal_Int32 nIndex;
104 EPosition()
105 : nPara( EE_PARA_NOT_FOUND )
106 , nIndex( EE_INDEX_NOT_FOUND )
109 EPosition( sal_Int32 nPara_, sal_Int32 nPos_ )
110 : nPara( nPara_ )
111 , nIndex( nPos_ )
115 struct ESelection
117 sal_Int32 nStartPara;
118 sal_Int32 nStartPos;
119 sal_Int32 nEndPara;
120 sal_Int32 nEndPos;
122 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
124 ESelection( sal_Int32 nStPara, sal_Int32 nStPos,
125 sal_Int32 nEPara, sal_Int32 nEPos )
126 : nStartPara( nStPara )
127 , nStartPos( nStPos )
128 , nEndPara( nEPara )
129 , nEndPos( nEPos )
132 ESelection( sal_Int32 nPara, sal_Int32 nPos )
133 : nStartPara( nPara )
134 , nStartPos( nPos )
135 , nEndPara( nPara )
136 , nEndPos( nPos )
139 void Adjust();
140 bool IsEqual( const ESelection& rS ) const;
141 bool IsLess( const ESelection& rS ) const;
142 bool IsGreater( const ESelection& rS ) const;
143 bool IsZero() const;
144 bool HasRange() const;
147 inline bool ESelection::HasRange() const
149 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
152 inline bool ESelection::IsZero() const
154 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
155 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
158 inline bool ESelection::IsEqual( const ESelection& rS ) const
160 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
161 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
164 inline bool ESelection::IsLess( const ESelection& rS ) const
166 // The selection must be adjusted.
167 // => Only check if end of 'this' < Start of rS
168 return ( nEndPara < rS.nStartPara ) ||
169 ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) );
172 inline bool ESelection::IsGreater( const ESelection& rS ) const
174 // The selection must be adjusted.
175 // => Only check if end of 'this' < Start of rS
176 return ( nStartPara > rS.nEndPara ) ||
177 ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) );
180 inline void ESelection::Adjust()
182 bool bSwap = false;
183 if ( nStartPara > nEndPara )
184 bSwap = true;
185 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
186 bSwap = true;
188 if ( bSwap )
190 sal_Int32 nSPar = nStartPara; sal_Int32 nSPos = nStartPos;
191 nStartPara = nEndPara; nStartPos = nEndPos;
192 nEndPara = nSPar; nEndPos = nSPos;
196 struct EDITENG_DLLPUBLIC EFieldInfo
198 SvxFieldItem* pFieldItem;
199 OUString aCurrentText;
200 EPosition aPosition;
202 EFieldInfo();
203 EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos );
204 ~EFieldInfo();
206 EFieldInfo( const EFieldInfo& );
207 EFieldInfo& operator= ( const EFieldInfo& );
210 enum ImportState {
211 RTFIMP_START, RTFIMP_END, // only pParser, nPara, nIndex
212 RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR, // nToken+nTokenValue
213 RTFIMP_SETATTR, // pAttrs
214 RTFIMP_INSERTTEXT, // aText
215 RTFIMP_INSERTPARA, // -
216 HTMLIMP_START, HTMLIMP_END, // only pParser, nPara, nIndex
217 HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
218 HTMLIMP_SETATTR, // pAttrs
219 HTMLIMP_INSERTTEXT, // aText
220 HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
223 struct ImportInfo
225 SvParser* pParser;
226 ESelection aSelection;
227 ImportState eState;
229 int nToken;
230 short nTokenValue;
232 OUString aText;
234 void* pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
236 ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
237 ~ImportInfo();
240 struct ParagraphInfos
242 ParagraphInfos()
243 : nParaHeight( 0 )
244 , nLines( 0 )
245 , nFirstLineStartX( 0 )
246 , nFirstLineOffset( 0 )
247 , nFirstLineHeight( 0 )
248 , nFirstLineTextHeight ( 0 )
249 , nFirstLineMaxAscent( 0 )
250 , bValid( false )
252 sal_uInt16 nParaHeight;
253 sal_uInt16 nLines;
255 sal_uInt16 nFirstLineStartX;
257 sal_uInt16 nFirstLineOffset;
258 sal_uInt16 nFirstLineHeight;
259 sal_uInt16 nFirstLineTextHeight;
260 sal_uInt16 nFirstLineMaxAscent;
262 bool bValid; // A query during formatting is not valid!
265 struct EECharAttrib
267 const SfxPoolItem* pAttr;
269 sal_Int32 nPara;
270 sal_Int32 nStart;
271 sal_Int32 nEnd;
274 struct MoveParagraphsInfo
276 sal_Int32 nStartPara;
277 sal_Int32 nEndPara;
278 sal_Int32 nDestPara;
280 MoveParagraphsInfo( sal_Int32 nS, sal_Int32 nE, sal_Int32 nD )
281 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
284 #define EE_ACTION_PASTE 1
285 #define EE_ACTION_DROP 2
287 struct PasteOrDropInfos
289 sal_uInt16 nAction;
290 sal_Int32 nStartPara;
291 sal_Int32 nEndPara;
293 PasteOrDropInfos() : nAction(0), nStartPara(-1), nEndPara(-1) {}
296 enum EENotifyType
298 /// EditEngine text was modified
299 EE_NOTIFY_TEXTMODIFIED,
301 /// A paragraph was inserted into the EditEngine
302 EE_NOTIFY_PARAGRAPHINSERTED,
304 /// A paragraph was removed from the EditEngine
305 EE_NOTIFY_PARAGRAPHREMOVED,
307 /// Multiple paragraphs have been removed from the EditEngine
308 EE_NOTIFY_PARAGRAPHSMOVED,
310 /// The height of at least one paragraph has changed
311 EE_NOTIFY_TEXTHEIGHTCHANGED,
313 /// The view area of the EditEngine scrolled
314 EE_NOTIFY_TEXTVIEWSCROLLED,
316 /// The selection and/or the cursor position has changed
317 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
319 /** Denotes the beginning of a collected amount of EditEngine
320 notification events. This event itself is not queued, but sent
321 immediately
323 EE_NOTIFY_BLOCKNOTIFICATION_START,
325 /** Denotes the end of a collected amount of EditEngine
326 notification events. After this event, the queue is empty, and
327 a high-level operation such as "insert paragraph" is finished
329 EE_NOTIFY_BLOCKNOTIFICATION_END,
331 /// Denotes the beginning of a high-level action triggered by a key press
332 EE_NOTIFY_INPUT_START,
334 /// Denotes the end of a high-level action triggered by a key press
335 EE_NOTIFY_INPUT_END,
336 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
339 struct EENotify
341 EENotifyType eNotificationType;
342 EditEngine* pEditEngine;
343 EditView* pEditView;
345 sal_Int32 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
347 sal_Int32 nParam1;
348 sal_Int32 nParam2;
350 EENotify( EENotifyType eType )
351 { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
354 #endif // INCLUDED_EDITENG_EDITDATA_HXX
356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */