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 INCLUDED_EDITENG_EDITDATA_HXX
22 #define INCLUDED_EDITENG_EDITDATA_HXX
24 #include <rtl/ustring.hxx>
25 #include <editeng/editengdllapi.h>
26 #include <i18nlangtag/lang.h>
31 template<typename T
> class SvParser
;
33 enum class HtmlTokenId
: sal_Int16
;
35 enum class EETextFormat
{ Text
= 0x20, Rtf
, Html
= 0x32, Xml
};
36 enum class EEHorizontalTextDirection
{ Default
, L2R
, R2L
};
37 enum class EESelectionMode
{ Std
, Hidden
};
38 // EESelectionMode::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
, NoSpeller
, ErrorFound
};
41 enum class EEAnchorMode
{
42 TopLeft
, TopHCenter
, TopRight
,
43 VCenterLeft
, VCenterHCenter
, VCenterRight
,
44 BottomLeft
, BottomHCenter
, BottomRight
};
46 enum class EERemoveParaAttribsMode
{ RemoveAll
, RemoveCharItems
, RemoveNone
};
48 #define EE_PARA_NOT_FOUND SAL_MAX_INT32
49 #define EE_PARA_APPEND SAL_MAX_INT32
50 #define EE_PARA_ALL SAL_MAX_INT32
51 #define EE_PARA_MAX_COUNT SAL_MAX_INT32
53 #define EE_INDEX_NOT_FOUND SAL_MAX_INT32
54 #define EE_TEXTPOS_ALL SAL_MAX_INT32
55 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32
57 EDITENG_DLLPUBLIC
extern const size_t EE_APPEND
;
59 // Error messages for Read / Write Method
60 #define EE_READWRITE_WRONGFORMAT ErrCode(ErrCodeArea::Svx, 1)
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
94 : nPara( EE_PARA_NOT_FOUND
)
95 , nIndex( EE_INDEX_NOT_FOUND
)
98 EPosition( sal_Int32 nPara_
, sal_Int32 nPos_
)
104 template<typename charT
, typename traits
>
105 inline std::basic_ostream
<charT
, traits
> & operator <<(
106 std::basic_ostream
<charT
, traits
> & stream
, EPosition
const& pos
)
108 return stream
<< "EPosition(" << pos
.nPara
<< ',' << pos
.nIndex
<< ")";
113 sal_Int32 nStartPara
;
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
)
128 ESelection( sal_Int32 nPara
, sal_Int32 nPos
)
129 : nStartPara( nPara
)
136 bool operator==( const ESelection
& rS
) const;
137 bool operator!=( const ESelection
& rS
) const { return !operator==(rS
); }
138 bool operator<( const ESelection
& rS
) const;
139 bool operator>( const ESelection
& rS
) const;
141 bool HasRange() const;
144 template<typename charT
, typename traits
>
145 inline std::basic_ostream
<charT
, traits
> & operator <<(
146 std::basic_ostream
<charT
, traits
> & stream
, ESelection
const& sel
)
148 return stream
<< "ESelection(" << sel
.nStartPara
<< ',' << sel
.nStartPos
<< "," << sel
.nEndPara
<< "," << sel
.nEndPos
<< ")";
151 inline bool ESelection::HasRange() const
153 return ( nStartPara
!= nEndPara
) || ( nStartPos
!= nEndPos
);
156 inline bool ESelection::IsZero() const
158 return ( ( nStartPara
== 0 ) && ( nStartPos
== 0 ) &&
159 ( nEndPara
== 0 ) && ( nEndPos
== 0 ) );
162 inline bool ESelection::operator==( const ESelection
& rS
) const
164 return ( ( nStartPara
== rS
.nStartPara
) && ( nStartPos
== rS
.nStartPos
) &&
165 ( nEndPara
== rS
.nEndPara
) && ( nEndPos
== rS
.nEndPos
) );
168 inline bool ESelection::operator<( const ESelection
& rS
) const
170 // The selection must be adjusted.
171 // => Only check if end of 'this' < Start of rS
172 return ( nEndPara
< rS
.nStartPara
) ||
173 ( ( nEndPara
== rS
.nStartPara
) && ( nEndPos
< rS
.nStartPos
) && !operator==( rS
) );
176 inline bool ESelection::operator>( const ESelection
& rS
) const
178 // The selection must be adjusted.
179 // => Only check if end of 'this' < Start of rS
180 return ( nStartPara
> rS
.nEndPara
) ||
181 ( ( nStartPara
== rS
.nEndPara
) && ( nStartPos
> rS
.nEndPos
) && !operator==( rS
) );
184 inline void ESelection::Adjust()
187 if ( nStartPara
> nEndPara
)
189 else if ( ( nStartPara
== nEndPara
) && ( nStartPos
> nEndPos
) )
194 sal_Int32 nSPar
= nStartPara
; sal_Int32 nSPos
= nStartPos
;
195 nStartPara
= nEndPara
; nStartPos
= nEndPos
;
196 nEndPara
= nSPar
; nEndPos
= nSPos
;
200 struct EDITENG_DLLPUBLIC EFieldInfo
202 std::unique_ptr
<SvxFieldItem
> pFieldItem
;
203 OUString aCurrentText
;
207 EFieldInfo( const SvxFieldItem
& rFieldItem
, sal_Int32 nPara
, sal_Int32 nPos
);
210 EFieldInfo( const EFieldInfo
& );
211 EFieldInfo
& operator= ( const EFieldInfo
& );
214 enum class RtfImportState
{
215 Start
, End
, // only pParser, nPara, nIndex
216 NextToken
, UnknownAttr
, // nToken+nTokenValue
221 enum class HtmlImportState
{
222 Start
, End
, // only pParser, nPara, nIndex
226 InsertPara
, InsertField
// -
229 struct HtmlImportInfo
231 SvParser
<HtmlTokenId
>* pParser
;
232 ESelection aSelection
;
233 HtmlImportState eState
;
239 HtmlImportInfo( HtmlImportState eState
, SvParser
<HtmlTokenId
>* pPrsrs
, const ESelection
& rSel
);
245 SvParser
<int>* pParser
;
246 ESelection aSelection
;
247 RtfImportState eState
;
252 RtfImportInfo( RtfImportState eState
, SvParser
<int>* pPrsrs
, const ESelection
& rSel
);
255 struct ParagraphInfos
258 : nFirstLineHeight( 0 )
259 , nFirstLineTextHeight ( 0 )
260 , nFirstLineMaxAscent( 0 )
264 sal_uInt16 nFirstLineHeight
;
265 sal_uInt16 nFirstLineTextHeight
;
266 sal_uInt16 nFirstLineMaxAscent
;
268 bool bValid
; // A query during formatting is not valid!
273 const SfxPoolItem
* pAttr
;
277 EECharAttrib(sal_Int32 nSt
, sal_Int32 nE
, const SfxPoolItem
* pA
= nullptr)
285 struct MoveParagraphsInfo
287 sal_Int32 nStartPara
;
291 MoveParagraphsInfo( sal_Int32 nS
, sal_Int32 nE
, sal_Int32 nD
)
292 { nStartPara
= nS
; nEndPara
= nE
; nDestPara
= nD
; }
295 struct PasteOrDropInfos
297 sal_Int32 nStartPara
;
300 PasteOrDropInfos() : nStartPara(-1), nEndPara(-1) {}
305 /// EditEngine text was modified
306 EE_NOTIFY_TEXTMODIFIED
,
308 /// A paragraph was inserted into the EditEngine
309 EE_NOTIFY_PARAGRAPHINSERTED
,
311 /// A paragraph was removed from the EditEngine
312 EE_NOTIFY_PARAGRAPHREMOVED
,
314 /// Multiple paragraphs have been removed from the EditEngine
315 EE_NOTIFY_PARAGRAPHSMOVED
,
317 /// The height of at least one paragraph has changed
318 EE_NOTIFY_TextHeightChanged
,
320 /// The view area of the EditEngine scrolled
321 EE_NOTIFY_TEXTVIEWSCROLLED
,
323 /// The selection and/or the cursor position has changed
324 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED
,
326 /// The EditEngine is in a valid state again. Process pending notifications.
327 EE_NOTIFY_PROCESSNOTIFICATIONS
,
329 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
334 EENotifyType eNotificationType
;
336 sal_Int32 nParagraph
; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
341 EENotify( EENotifyType eType
)
342 { eNotificationType
= eType
; nParagraph
= EE_PARA_NOT_FOUND
; nParam1
= 0; nParam2
= 0; }
350 LanguageType nLang
= LANGUAGE_DONTKNOW
;
351 sal_Int32 nStart
= -1;
357 #endif // INCLUDED_EDITENG_EDITDATA_HXX
359 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */