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>
30 template<typename T
> class SvParser
;
32 enum class HtmlTokenId
: sal_Int16
;
34 enum class EETextFormat
{ Text
= 0x20, Rtf
, Html
= 0x32, Xml
};
35 enum class EEHorizontalTextDirection
{ Default
, L2R
, R2L
};
36 enum class EESelectionMode
{ Std
, Hidden
};
37 // EESelectionMode::Hidden can be used to completely hide the selection. This is useful e.g. when you want show the selection
38 // only as long as your window (which the edit view works on) has the focus
39 enum class EESpellState
{ Ok
, NoSpeller
, ErrorFound
};
40 enum class EEAnchorMode
{
41 TopLeft
, TopHCenter
, TopRight
,
42 VCenterLeft
, VCenterHCenter
, VCenterRight
,
43 BottomLeft
, BottomHCenter
, BottomRight
};
45 #define EE_PARA_NOT_FOUND SAL_MAX_INT32
46 #define EE_PARA_APPEND SAL_MAX_INT32
47 #define EE_PARA_ALL SAL_MAX_INT32
48 #define EE_PARA_MAX_COUNT SAL_MAX_INT32
50 #define EE_INDEX_NOT_FOUND SAL_MAX_INT32
51 #define EE_TEXTPOS_ALL SAL_MAX_INT32
52 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32
54 EDITENG_DLLPUBLIC
extern const size_t EE_APPEND
;
56 // Error messages for Read / Write Method
57 #define EE_READWRITE_WRONGFORMAT ErrCode(ErrCodeArea::Svx, 1)
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
91 : nPara( EE_PARA_NOT_FOUND
)
92 , nIndex( EE_INDEX_NOT_FOUND
)
95 EPosition( sal_Int32 nPara_
, sal_Int32 nPos_
)
101 template<typename charT
, typename traits
>
102 inline std::basic_ostream
<charT
, traits
> & operator <<(
103 std::basic_ostream
<charT
, traits
> & stream
, EPosition
const& pos
)
105 return stream
<< "EPosition(" << pos
.nPara
<< ',' << pos
.nIndex
<< ")";
110 sal_Int32 nStartPara
;
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
)
125 ESelection( sal_Int32 nPara
, sal_Int32 nPos
)
126 : nStartPara( nPara
)
133 bool operator==( const ESelection
& rS
) const;
134 bool operator!=( const ESelection
& rS
) const { return !operator==(rS
); }
135 bool operator<( const ESelection
& rS
) const;
136 bool operator>( const ESelection
& rS
) const;
138 bool HasRange() const;
141 template<typename charT
, typename traits
>
142 inline std::basic_ostream
<charT
, traits
> & operator <<(
143 std::basic_ostream
<charT
, traits
> & stream
, ESelection
const& sel
)
145 return stream
<< "ESelection(" << sel
.nStartPara
<< ',' << sel
.nStartPos
<< "," << sel
.nEndPara
<< "," << sel
.nEndPos
<< ")";
148 inline bool ESelection::HasRange() const
150 return ( nStartPara
!= nEndPara
) || ( nStartPos
!= nEndPos
);
153 inline bool ESelection::IsZero() const
155 return ( ( nStartPara
== 0 ) && ( nStartPos
== 0 ) &&
156 ( nEndPara
== 0 ) && ( nEndPos
== 0 ) );
159 inline bool ESelection::operator==( const ESelection
& rS
) const
161 return ( ( nStartPara
== rS
.nStartPara
) && ( nStartPos
== rS
.nStartPos
) &&
162 ( nEndPara
== rS
.nEndPara
) && ( nEndPos
== rS
.nEndPos
) );
165 inline bool ESelection::operator<( const ESelection
& rS
) const
167 // The selection must be adjusted.
168 // => Only check if end of 'this' < Start of rS
169 return ( nEndPara
< rS
.nStartPara
) ||
170 ( ( nEndPara
== rS
.nStartPara
) && ( nEndPos
< rS
.nStartPos
) && !operator==( rS
) );
173 inline bool ESelection::operator>( const ESelection
& rS
) const
175 // The selection must be adjusted.
176 // => Only check if end of 'this' < Start of rS
177 return ( nStartPara
> rS
.nEndPara
) ||
178 ( ( nStartPara
== rS
.nEndPara
) && ( nStartPos
> rS
.nEndPos
) && !operator==( rS
) );
181 inline void ESelection::Adjust()
184 if ( nStartPara
> nEndPara
)
186 else if ( ( nStartPara
== nEndPara
) && ( nStartPos
> nEndPos
) )
191 sal_Int32 nSPar
= nStartPara
; sal_Int32 nSPos
= nStartPos
;
192 nStartPara
= nEndPara
; nStartPos
= nEndPos
;
193 nEndPara
= nSPar
; nEndPos
= nSPos
;
197 struct EDITENG_DLLPUBLIC EFieldInfo
199 std::unique_ptr
<SvxFieldItem
> pFieldItem
;
200 OUString aCurrentText
;
204 EFieldInfo( const SvxFieldItem
& rFieldItem
, sal_Int32 nPara
, sal_Int32 nPos
);
207 EFieldInfo( const EFieldInfo
& );
208 EFieldInfo
& operator= ( const EFieldInfo
& );
211 enum class RtfImportState
{
212 Start
, End
, // only pParser, nPara, nIndex
213 NextToken
, UnknownAttr
, // nToken+nTokenValue
218 enum class HtmlImportState
{
219 Start
, End
, // only pParser, nPara, nIndex
223 InsertPara
, InsertField
// -
226 struct HtmlImportInfo
228 SvParser
<HtmlTokenId
>* pParser
;
229 ESelection aSelection
;
230 HtmlImportState eState
;
236 HtmlImportInfo( HtmlImportState eState
, SvParser
<HtmlTokenId
>* pPrsrs
, const ESelection
& rSel
);
242 SvParser
<int>* pParser
;
243 ESelection aSelection
;
244 RtfImportState eState
;
249 RtfImportInfo( RtfImportState eState
, SvParser
<int>* pPrsrs
, const ESelection
& rSel
);
253 struct ParagraphInfos
256 : nFirstLineHeight( 0 )
257 , nFirstLineTextHeight ( 0 )
258 , nFirstLineMaxAscent( 0 )
262 sal_uInt16 nFirstLineHeight
;
263 sal_uInt16 nFirstLineTextHeight
;
264 sal_uInt16 nFirstLineMaxAscent
;
266 bool bValid
; // A query during formatting is not valid!
271 const SfxPoolItem
* pAttr
;
277 struct MoveParagraphsInfo
279 sal_Int32 nStartPara
;
283 MoveParagraphsInfo( sal_Int32 nS
, sal_Int32 nE
, sal_Int32 nD
)
284 { nStartPara
= nS
; nEndPara
= nE
; nDestPara
= nD
; }
287 struct PasteOrDropInfos
289 sal_Int32 nStartPara
;
292 PasteOrDropInfos() : nStartPara(-1), nEndPara(-1) {}
297 /// EditEngine text was modified
298 EE_NOTIFY_TEXTMODIFIED
,
300 /// A paragraph was inserted into the EditEngine
301 EE_NOTIFY_PARAGRAPHINSERTED
,
303 /// A paragraph was removed from the EditEngine
304 EE_NOTIFY_PARAGRAPHREMOVED
,
306 /// Multiple paragraphs have been removed from the EditEngine
307 EE_NOTIFY_PARAGRAPHSMOVED
,
309 /// The height of at least one paragraph has changed
310 EE_NOTIFY_TextHeightChanged
,
312 /// The view area of the EditEngine scrolled
313 EE_NOTIFY_TEXTVIEWSCROLLED
,
315 /// The selection and/or the cursor position has changed
316 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED
,
318 /// The EditEngine is in a valid state again. Process pending notifications.
319 EE_NOTIFY_PROCESSNOTIFICATIONS
,
321 EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
326 EENotifyType eNotificationType
;
328 sal_Int32 nParagraph
; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
333 EENotify( EENotifyType eType
)
334 { eNotificationType
= eType
; nParagraph
= EE_PARA_NOT_FOUND
; nParam1
= 0; nParam2
= 0; }
337 #endif // INCLUDED_EDITENG_EDITDATA_HXX
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */