1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _MyEDITDATA_HXX
22 #define _MyEDITDATA_HXX
24 #include <tools/string.hxx>
25 #include "editeng/editengdllapi.h"
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
};
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_UINT16
49 #define EE_TEXTPOS_ALL SAL_MAX_UINT16
50 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_UINT16
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_START 100
60 #define EDITUNDO_REMOVECHARS 100
61 #define EDITUNDO_CONNECTPARAS 101
62 #define EDITUNDO_REMOVEFEATURE 102
63 #define EDITUNDO_MOVEPARAGRAPHS 103
64 #define EDITUNDO_INSERTFEATURE 104
65 #define EDITUNDO_SPLITPARA 105
66 #define EDITUNDO_INSERTCHARS 106
67 #define EDITUNDO_DELCONTENT 107
68 #define EDITUNDO_DELETE 108
69 #define EDITUNDO_CUT 109
70 #define EDITUNDO_PASTE 110
71 #define EDITUNDO_INSERT 111
72 #define EDITUNDO_SRCHANDREPL 112
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_STRETCH 120
81 #define EDITUNDO_RESETATTRIBS 121
82 #define EDITUNDO_INDENTBLOCK 122
83 #define EDITUNDO_UNINDENTBLOCK 123
84 #define EDITUNDO_MARKSELECTION 124
85 #define EDITUNDO_TRANSLITERATE 125
86 #define EDITUNDO_END 125
88 #define EDITUNDO_USER 200
97 #define RGCHK_NONE 0 // No correction of ViusArea when scrolling
98 #define RGCHK_NEG 1 // No negative ViusArea when scrolling
99 #define RGCHK_PAPERSZ1 2 // VisArea must be within paper width, Text Size
107 nPara( EE_PARA_NOT_FOUND
),
108 nIndex( EE_INDEX_NOT_FOUND
)
112 EPosition( sal_Int32 nPara_
, xub_StrLen nPos_
) :
121 sal_Int32 nStartPara
;
122 xub_StrLen nStartPos
;
126 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
128 ESelection( sal_Int32 nStPara
, xub_StrLen nStPos
, sal_Int32 nEPara
, xub_StrLen nEPos
) :
129 nStartPara( nStPara
),
136 ESelection( sal_Int32 nPara
, xub_StrLen nPos
) :
145 sal_Bool
IsEqual( const ESelection
& rS
) const;
146 sal_Bool
IsLess( const ESelection
& rS
) const;
147 sal_Bool
IsGreater( const ESelection
& rS
) const;
148 sal_Bool
IsZero() const;
149 sal_Bool
HasRange() const;
152 inline sal_Bool
ESelection::HasRange() const
154 return ( nStartPara
!= nEndPara
) || ( nStartPos
!= nEndPos
);
157 inline sal_Bool
ESelection::IsZero() const
159 return ( ( nStartPara
== 0 ) && ( nStartPos
== 0 ) &&
160 ( nEndPara
== 0 ) && ( nEndPos
== 0 ) );
163 inline sal_Bool
ESelection::IsEqual( const ESelection
& rS
) const
165 return ( ( nStartPara
== rS
.nStartPara
) && ( nStartPos
== rS
.nStartPos
) &&
166 ( nEndPara
== rS
.nEndPara
) && ( nEndPos
== rS
.nEndPos
) );
169 inline sal_Bool
ESelection::IsLess( const ESelection
& rS
) const
171 // The selection must be adjusted.
172 // => Only check if end of 'this' < Start of rS
174 if ( ( nEndPara
< rS
.nStartPara
) ||
175 ( ( nEndPara
== rS
.nStartPara
) && ( nEndPos
< rS
.nStartPos
) && !IsEqual( rS
) ) )
182 inline sal_Bool
ESelection::IsGreater( const ESelection
& rS
) const
184 // The selection must be adjusted.
185 // => Only check if end of 'this' < Start of rS
187 if ( ( nStartPara
> rS
.nEndPara
) ||
188 ( ( nStartPara
== rS
.nEndPara
) && ( nStartPos
> rS
.nEndPos
) && !IsEqual( rS
) ) )
195 inline void ESelection::Adjust()
197 sal_Bool bSwap
= sal_False
;
198 if ( nStartPara
> nEndPara
)
200 else if ( ( nStartPara
== nEndPara
) && ( nStartPos
> nEndPos
) )
205 sal_Int32 nSPar
= nStartPara
; sal_uInt16 nSPos
= nStartPos
;
206 nStartPara
= nEndPara
; nStartPos
= nEndPos
;
207 nEndPara
= nSPar
; nEndPos
= nSPos
;
211 struct EDITENG_DLLPUBLIC EFieldInfo
213 SvxFieldItem
* pFieldItem
;
218 EFieldInfo( const SvxFieldItem
& rFieldItem
, sal_Int32 nPara
, sal_uInt16 nPos
);
221 EFieldInfo( const EFieldInfo
& );
222 EFieldInfo
& operator= ( const EFieldInfo
& );
225 // -----------------------------------------------------------------------
228 RTFIMP_START
, RTFIMP_END
, // only pParser, nPara, nIndex
229 RTFIMP_NEXTTOKEN
, RTFIMP_UNKNOWNATTR
, // nToken+nTokenValue
230 RTFIMP_SETATTR
, // pAttrs
231 RTFIMP_INSERTTEXT
, // aText
232 RTFIMP_INSERTPARA
, // -
233 HTMLIMP_START
, HTMLIMP_END
, // only pParser, nPara, nIndex
234 HTMLIMP_NEXTTOKEN
, HTMLIMP_UNKNOWNATTR
, // nToken
235 HTMLIMP_SETATTR
, // pAttrs
236 HTMLIMP_INSERTTEXT
, // aText
237 HTMLIMP_INSERTPARA
, HTMLIMP_INSERTFIELD
// -
243 ESelection aSelection
;
251 void* pAttrs
; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
253 ImportInfo( ImportState eState
, SvParser
* pPrsrs
, const ESelection
& rSel
);
257 struct ParagraphInfos
262 , nFirstLineStartX( 0 )
263 , nFirstLineOffset( 0 )
264 , nFirstLineHeight( 0 )
265 , nFirstLineTextHeight ( 0 )
266 , nFirstLineMaxAscent( 0 )
269 sal_uInt16 nParaHeight
;
272 sal_uInt16 nFirstLineStartX
;
274 sal_uInt16 nFirstLineOffset
;
275 sal_uInt16 nFirstLineHeight
;
276 sal_uInt16 nFirstLineTextHeight
;
277 sal_uInt16 nFirstLineMaxAscent
;
279 sal_Bool bValid
; // A query during formatting is not valid!
284 const SfxPoolItem
* pAttr
;
291 struct MoveParagraphsInfo
293 sal_Int32 nStartPara
;
297 MoveParagraphsInfo( sal_Int32 nS
, sal_Int32 nE
, sal_Int32 nD
)
298 { nStartPara
= nS
; nEndPara
= nE
; nDestPara
= nD
; }
301 #define EE_ACTION_PASTE 1
302 #define EE_ACTION_DROP 2
304 struct PasteOrDropInfos
307 sal_Int32 nStartPara
;
310 PasteOrDropInfos() : nAction(0), nStartPara(0xFFFFFFFF), nEndPara(0xFFFFFFFF) {}
315 /// EditEngine text was modified
316 EE_NOTIFY_TEXTMODIFIED
,
318 /// A paragraph was inserted into the EditEngine
319 EE_NOTIFY_PARAGRAPHINSERTED
,
321 /// A paragraph was removed from the EditEngine
322 EE_NOTIFY_PARAGRAPHREMOVED
,
324 /// Multiple paragraphs have been removed from the EditEngine
325 EE_NOTIFY_PARAGRAPHSMOVED
,
327 /// The height of at least one paragraph has changed
328 EE_NOTIFY_TEXTHEIGHTCHANGED
,
330 /// The view area of the EditEngine scrolled
331 EE_NOTIFY_TEXTVIEWSCROLLED
,
333 /// The selection and/or the cursor position has changed
334 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED
,
336 /** Denotes the beginning of a collected amount of EditEngine
337 notification events. This event itself is not queued, but sent
340 EE_NOTIFY_BLOCKNOTIFICATION_START
,
342 /** Denotes the end of a collected amount of EditEngine
343 notification events. After this event, the queue is empty, and
344 a high-level operation such as "insert paragraph" is finished
346 EE_NOTIFY_BLOCKNOTIFICATION_END
,
348 /// Denotes the beginning of a high-level action triggered by a key press
349 EE_NOTIFY_INPUT_START
,
351 /// Denotes the end of a high-level action triggered by a key press
357 EENotifyType eNotificationType
;
358 EditEngine
* pEditEngine
;
361 sal_Int32 nParagraph
; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
366 EENotify( EENotifyType eType
)
367 { eNotificationType
= eType
; pEditEngine
= NULL
; pEditView
= NULL
; nParagraph
= EE_PARA_NOT_FOUND
; nParam1
= 0; nParam2
= 0; }
370 #endif // _MyEDITDATA_HXX
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */