LibreOffice Module editeng (master) 1
editdata.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20// MyEDITDATA, wegen exportiertem EditData
21#ifndef INCLUDED_EDITENG_EDITDATA_HXX
22#define INCLUDED_EDITENG_EDITDATA_HXX
23
24#include <rtl/ustring.hxx>
26#include <i18nlangtag/lang.h>
27#include <memory>
28#include <ostream>
29
30class SfxPoolItem;
31template<typename T> class SvParser;
32class SvxFieldItem;
33enum class HtmlTokenId : sal_Int16;
34
35enum class EETextFormat { Text = 0x20, Rtf, Html = 0x32, Xml };
37enum 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
41enum class EEAnchorMode {
45
47
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
52
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
56
57EDITENG_DLLPUBLIC extern const size_t EE_APPEND;
58
59// Error messages for Read / Write Method
60#define EE_READWRITE_WRONGFORMAT ErrCode(ErrCodeArea::Svx, 1)
61
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
85
86#define EDITUNDO_USER 200
87
89{
90 sal_Int32 nPara;
91 sal_Int32 nIndex;
92
96 { }
97
98 EPosition( sal_Int32 nPara_, sal_Int32 nPos_ )
99 : nPara( nPara_ )
100 , nIndex( nPos_ )
101 { }
102};
103
104template<typename charT, typename traits>
105inline std::basic_ostream<charT, traits> & operator <<(
106 std::basic_ostream<charT, traits> & stream, EPosition const& pos)
107{
108 return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")";
109}
110
112{
113 sal_Int32 nStartPara;
114 sal_Int32 nStartPos;
115 sal_Int32 nEndPara;
116 sal_Int32 nEndPos;
117
118 ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
119
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 )
126 { }
127
128 ESelection( sal_Int32 nPara, sal_Int32 nPos )
129 : nStartPara( nPara )
130 , nStartPos( nPos )
131 , nEndPara( nPara )
132 , nEndPos( nPos )
133 { }
134
135 void Adjust();
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;
140 bool IsZero() const;
141 bool HasRange() const;
142};
143
144template<typename charT, typename traits>
145inline std::basic_ostream<charT, traits> & operator <<(
146 std::basic_ostream<charT, traits> & stream, ESelection const& sel)
147{
148 return stream << "ESelection(" << sel.nStartPara << ',' << sel.nStartPos << "," << sel.nEndPara << "," << sel.nEndPos << ")";
149}
150
151inline bool ESelection::HasRange() const
152{
153 return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
154}
155
156inline bool ESelection::IsZero() const
157{
158 return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
159 ( nEndPara == 0 ) && ( nEndPos == 0 ) );
160}
161
162inline bool ESelection::operator==( const ESelection& rS ) const
163{
164 return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
165 ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
166}
167
168inline bool ESelection::operator<( const ESelection& rS ) const
169{
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 ) );
174}
175
176inline bool ESelection::operator>( const ESelection& rS ) const
177{
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 ) );
182}
183
185{
186 bool bSwap = false;
187 if ( nStartPara > nEndPara )
188 bSwap = true;
189 else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
190 bSwap = true;
191
192 if ( bSwap )
193 {
194 sal_Int32 nSPar = nStartPara; sal_Int32 nSPos = nStartPos;
196 nEndPara = nSPar; nEndPos = nSPos;
197 }
198}
199
201{
202 std::unique_ptr<SvxFieldItem> pFieldItem;
203 OUString aCurrentText;
205
206 EFieldInfo();
207 EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos );
208 ~EFieldInfo();
209
210 EFieldInfo( const EFieldInfo& );
211 EFieldInfo& operator= ( const EFieldInfo& );
212};
213
214enum class RtfImportState {
215 Start, End, // only pParser, nPara, nIndex
216 NextToken, UnknownAttr, // nToken+nTokenValue
217 SetAttr, // pAttrs
218 InsertText, // aText
219 InsertPara, // -
220 };
221enum class HtmlImportState {
222 Start, End, // only pParser, nPara, nIndex
223 NextToken, // nToken
224 SetAttr, // pAttrs
225 InsertText, // aText
227 };
228
230{
234
236
237 OUString aText;
238
241};
242
244{
248
251
253};
254
256{
258 : nFirstLineHeight( 0 )
261 , bValid( false )
262 {}
263
267
268 bool bValid; // A query during formatting is not valid!
269};
270
272{
274
275 sal_Int32 nStart;
276 sal_Int32 nEnd;
277 EECharAttrib(sal_Int32 nSt, sal_Int32 nE, const SfxPoolItem* pA = nullptr)
278 : pAttr(pA)
279 , nStart(nSt)
280 , nEnd(nE)
281 {
282 }
283};
284
286{
287 sal_Int32 nStartPara;
288 sal_Int32 nEndPara;
289 sal_Int32 nDestPara;
290
291 MoveParagraphsInfo( sal_Int32 nS, sal_Int32 nE, sal_Int32 nD )
292 { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
293};
294
296{
297 sal_Int32 nStartPara;
298 sal_Int32 nEndPara;
299
301};
302
304{
307
310
313
316
319
322
325
328
331
333{
335
336 sal_Int32 nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
337
338 sal_Int32 nParam1;
339 sal_Int32 nParam2;
340
343};
344
345namespace editeng
346{
347
349{
351 sal_Int32 nStart = -1;
352 sal_Int32 nEnd = -1;
353};
354
355}
356
357#endif // INCLUDED_EDITENG_EDITDATA_HXX
358
359/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
Reference< XOutputStream > stream
#define EE_PARA_NOT_FOUND
Definition: editdata.hxx:48
EENotifyType
Definition: editdata.hxx:304
@ EE_NOTIFY_PARAGRAPHSMOVED
Multiple paragraphs have been removed from the EditEngine.
Definition: editdata.hxx:315
@ EE_NOTIFY_TEXTVIEWSCROLLED
The view area of the EditEngine scrolled.
Definition: editdata.hxx:321
@ EE_NOTIFY_PARAGRAPHREMOVED
A paragraph was removed from the EditEngine.
Definition: editdata.hxx:312
@ EE_NOTIFY_TEXTVIEWSELECTIONCHANGED
The selection and/or the cursor position has changed.
Definition: editdata.hxx:324
@ EE_NOTIFY_PARAGRAPHINSERTED
A paragraph was inserted into the EditEngine.
Definition: editdata.hxx:309
@ EE_NOTIFY_PROCESSNOTIFICATIONS
The EditEngine is in a valid state again. Process pending notifications.
Definition: editdata.hxx:327
@ EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
Definition: editdata.hxx:329
@ EE_NOTIFY_TextHeightChanged
The height of at least one paragraph has changed.
Definition: editdata.hxx:318
@ EE_NOTIFY_TEXTMODIFIED
EditEngine text was modified.
Definition: editdata.hxx:306
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, EPosition const &pos)
Definition: editdata.hxx:105
EETextFormat
Definition: editdata.hxx:35
EDITENG_DLLPUBLIC const size_t EE_APPEND
Definition: editdata.cxx:14
EESpellState
Definition: editdata.hxx:40
EERemoveParaAttribsMode
Definition: editdata.hxx:46
#define EE_INDEX_NOT_FOUND
Definition: editdata.hxx:53
HtmlImportState
Definition: editdata.hxx:221
EEAnchorMode
Definition: editdata.hxx:41
RtfImportState
Definition: editdata.hxx:214
EEHorizontalTextDirection
Definition: editdata.hxx:36
EESelectionMode
Definition: editdata.hxx:37
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
DocumentType eType
HtmlTokenId
#define LANGUAGE_DONTKNOW
sal_uInt16 nPos
sal_Int32 nEnd
Definition: editdata.hxx:276
const SfxPoolItem * pAttr
Definition: editdata.hxx:273
sal_Int32 nStart
Definition: editdata.hxx:275
EECharAttrib(sal_Int32 nSt, sal_Int32 nE, const SfxPoolItem *pA=nullptr)
Definition: editdata.hxx:277
sal_Int32 nParam1
Definition: editdata.hxx:338
EENotifyType eNotificationType
Definition: editdata.hxx:334
sal_Int32 nParam2
Definition: editdata.hxx:339
sal_Int32 nParagraph
Definition: editdata.hxx:336
EENotify(EENotifyType eType)
Definition: editdata.hxx:341
std::unique_ptr< SvxFieldItem > pFieldItem
Definition: editdata.hxx:202
EPosition aPosition
Definition: editdata.hxx:204
OUString aCurrentText
Definition: editdata.hxx:203
sal_Int32 nIndex
Definition: editdata.hxx:91
EPosition(sal_Int32 nPara_, sal_Int32 nPos_)
Definition: editdata.hxx:98
sal_Int32 nPara
Definition: editdata.hxx:90
ESelection(sal_Int32 nPara, sal_Int32 nPos)
Definition: editdata.hxx:128
bool HasRange() const
Definition: editdata.hxx:151
sal_Int32 nStartPara
Definition: editdata.hxx:113
sal_Int32 nEndPos
Definition: editdata.hxx:116
bool IsZero() const
Definition: editdata.hxx:156
sal_Int32 nStartPos
Definition: editdata.hxx:114
void Adjust()
Definition: editdata.hxx:184
bool operator!=(const ESelection &rS) const
Definition: editdata.hxx:137
bool operator==(const ESelection &rS) const
Definition: editdata.hxx:162
ESelection(sal_Int32 nStPara, sal_Int32 nStPos, sal_Int32 nEPara, sal_Int32 nEPos)
Definition: editdata.hxx:120
sal_Int32 nEndPara
Definition: editdata.hxx:115
bool operator<(const ESelection &rS) const
Definition: editdata.hxx:168
bool operator>(const ESelection &rS) const
Definition: editdata.hxx:176
SvParser< HtmlTokenId > * pParser
Definition: editdata.hxx:231
ESelection aSelection
Definition: editdata.hxx:232
HtmlTokenId nToken
Definition: editdata.hxx:235
OUString aText
Definition: editdata.hxx:237
HtmlImportInfo(HtmlImportState eState, SvParser< HtmlTokenId > *pPrsrs, const ESelection &rSel)
Definition: eertfpar.cxx:38
HtmlImportState eState
Definition: editdata.hxx:233
sal_Int32 nDestPara
Definition: editdata.hxx:289
MoveParagraphsInfo(sal_Int32 nS, sal_Int32 nE, sal_Int32 nD)
Definition: editdata.hxx:291
sal_Int32 nEndPara
Definition: editdata.hxx:288
sal_Int32 nStartPara
Definition: editdata.hxx:287
sal_uInt16 nFirstLineTextHeight
Definition: editdata.hxx:265
sal_uInt16 nFirstLineMaxAscent
Definition: editdata.hxx:266
sal_uInt16 nFirstLineHeight
Definition: editdata.hxx:264
sal_Int32 nStartPara
Definition: editdata.hxx:297
sal_Int32 nEndPara
Definition: editdata.hxx:298
ESelection aSelection
Definition: editdata.hxx:246
SvParser< int > * pParser
Definition: editdata.hxx:245
short nTokenValue
Definition: editdata.hxx:250
RtfImportState eState
Definition: editdata.hxx:247
RtfImportInfo(RtfImportState eState, SvParser< int > *pPrsrs, const ESelection &rSel)
Definition: eertfpar.cxx:50
LanguageType nLang
Definition: editdata.hxx:350
size_t pos