xref: /trunk/main/editeng/inc/editeng/editdata.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MyEDITDATA, wegen exportiertem EditData
25 #ifndef _MyEDITDATA_HXX
26 #define _MyEDITDATA_HXX
27 
28 #include <tools/string.hxx>
29 #include "editeng/editengdllapi.h"
30 
31 #include <svl/svarray.hxx>
32 
33 class SfxItemSet;
34 class SfxPoolItem;
35 class SvParser;
36 class SvxFieldItem;
37 
38 enum EETextFormat       { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
39 enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
40 enum EESelectionMode    { EE_SELMODE_STD, EE_SELMODE_TXTONLY, EE_SELMODE_HIDDEN };
41     // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is useful e.g. when you want show the selection
42     // only as long as your window (which the edit view works on) has the focus
43 enum EESpellState       { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
44 enum EVAnchorMode       {
45             ANCHOR_TOP_LEFT,    ANCHOR_VCENTER_LEFT,    ANCHOR_BOTTOM_LEFT,
46             ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
47             ANCHOR_TOP_RIGHT,   ANCHOR_VCENTER_RIGHT,   ANCHOR_BOTTOM_RIGHT };
48 
49 #define EE_PARA_NOT_FOUND       0xFFFFFFFF
50 #define EE_PARA_MAX             0xFFFFFFFF
51 #define EE_PARA_APPEND          0xFFFFFFFF
52 #define EE_PARA_ALL             0xFFFFFFFF
53 #define EE_APPEND               0xFFFF
54 #define EE_INDEX_NOT_FOUND      0xFFFF
55 #define EE_INDEX_MAX            0xFFFF
56 
57 // Fehlermeldungen fuer Read/Write-Methode
58 #define EE_READWRITE_OK              (SVSTREAM_OK)
59 #define EE_READWRITE_WRONGFORMAT     (SVSTREAM_ERRBASE_USER+1)
60 #define EE_READWRITE_GENERALERROR    (SVSTREAM_ERRBASE_USER+2)
61 
62 #define EDITUNDO_START              100
63 #define EDITUNDO_REMOVECHARS        100
64 #define EDITUNDO_CONNECTPARAS       101
65 #define EDITUNDO_REMOVEFEATURE      102
66 #define EDITUNDO_MOVEPARAGRAPHS     103
67 #define EDITUNDO_INSERTFEATURE      104
68 #define EDITUNDO_SPLITPARA          105
69 #define EDITUNDO_INSERTCHARS        106
70 #define EDITUNDO_DELCONTENT         107
71 #define EDITUNDO_DELETE             108
72 #define EDITUNDO_CUT                109
73 #define EDITUNDO_PASTE              110
74 #define EDITUNDO_INSERT             111
75 #define EDITUNDO_SRCHANDREPL        112
76 #define EDITUNDO_MOVEPARAS          113
77 #define EDITUNDO_PARAATTRIBS        114
78 #define EDITUNDO_ATTRIBS            115
79 #define EDITUNDO_DRAGANDDROP        116
80 #define EDITUNDO_READ               117
81 #define EDITUNDO_STYLESHEET         118
82 #define EDITUNDO_REPLACEALL         119
83 #define EDITUNDO_STRETCH            120
84 #define EDITUNDO_RESETATTRIBS       121
85 #define EDITUNDO_INDENTBLOCK        122
86 #define EDITUNDO_UNINDENTBLOCK      123
87 #define EDITUNDO_MARKSELECTION      124
88 #define EDITUNDO_TRANSLITERATE      125
89 #define EDITUNDO_END                125
90 
91 #define EDITUNDO_USER               200
92 
93 
94 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_SUMMATION            0x0001
95 #define EE_COMPATIBLEMODE_PARAGRAPHSPACING_BEFOREFIRSTPARAGRAPH 0x0002
96 
97 class EditView;
98 class EditEngine;
99 class ImpEditView;
100 class ImpEditEngine;
101 class EditTextObject;
102 class SfxStyleSheet;
103 
104 #define RGCHK_NONE          0   // Keine Korrektur der ViusArea beim Scrollen
105 #define RGCHK_NEG           1   // Keine neg. ViusArea beim Scrollen
106 #define RGCHK_PAPERSZ1      2   // VisArea muss in Papierbreite,Texthoehe liegen
107 
108 struct EPosition
109 {
110     sal_uInt32      nPara;
111     xub_StrLen  nIndex;
112 
EPositionEPosition113     EPosition() :
114         nPara( EE_PARA_NOT_FOUND ),
115         nIndex( EE_INDEX_NOT_FOUND )
116     {
117     }
118 
EPositionEPosition119     EPosition( sal_uInt32 nPara_, xub_StrLen nPos_ ) :
120         nPara( nPara_ ),
121         nIndex( nPos_ )
122     {
123     }
124 };
125 
126 struct ESelection
127 {
128     sal_uInt32      nStartPara;
129     xub_StrLen  nStartPos;
130     sal_uInt32      nEndPara;
131     xub_StrLen  nEndPos;
132 
ESelectionESelection133     ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
134 
ESelectionESelection135     ESelection( sal_uInt32 nStPara, xub_StrLen nStPos, sal_uInt32 nEPara, xub_StrLen nEPos ) :
136         nStartPara( nStPara ),
137         nStartPos( nStPos ),
138         nEndPara( nEPara ),
139         nEndPos( nEPos )
140     {
141     }
142 
ESelectionESelection143     ESelection( sal_uInt32 nPara, xub_StrLen nPos ) :
144         nStartPara( nPara ),
145         nStartPos( nPos ),
146         nEndPara( nPara ),
147         nEndPos( nPos )
148     {
149     }
150 
151     void    Adjust();
152     sal_Bool    IsEqual( const ESelection& rS ) const;
153     sal_Bool    IsLess( const ESelection& rS ) const;
154     sal_Bool    IsGreater( const ESelection& rS ) const;
155     sal_Bool    IsZero() const;
156     sal_Bool    HasRange() const;
157 };
158 
HasRange() const159 inline sal_Bool ESelection::HasRange() const
160 {
161     return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
162 }
163 
IsZero() const164 inline sal_Bool ESelection::IsZero() const
165 {
166     return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
167              ( nEndPara == 0 ) && ( nEndPos == 0 ) );
168 }
169 
IsEqual(const ESelection & rS) const170 inline sal_Bool ESelection::IsEqual( const ESelection& rS ) const
171 {
172     return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
173              ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
174 }
175 
IsLess(const ESelection & rS) const176 inline sal_Bool ESelection::IsLess( const ESelection& rS ) const
177 {
178     // Selektion muss justiert sein.
179     // => Nur pueffen, ob Ende von 'this' < Start von rS
180 
181     if ( ( nEndPara < rS.nStartPara ) ||
182          ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) ) )
183     {
184         return sal_True;
185     }
186     return sal_False;
187 }
188 
IsGreater(const ESelection & rS) const189 inline sal_Bool ESelection::IsGreater( const ESelection& rS ) const
190 {
191     // Selektion muss justiert sein.
192     // => Nur pueffen, ob Ende von 'this' > Start von rS
193 
194     if ( ( nStartPara > rS.nEndPara ) ||
195          ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) ) )
196     {
197         return sal_True;
198     }
199     return sal_False;
200 }
201 
Adjust()202 inline void ESelection::Adjust()
203 {
204     sal_Bool bSwap = sal_False;
205     if ( nStartPara > nEndPara )
206         bSwap = sal_True;
207     else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
208         bSwap = sal_True;
209 
210     if ( bSwap )
211     {
212         sal_uInt32 nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
213         nStartPara = nEndPara; nStartPos = nEndPos;
214         nEndPara = nSPar; nEndPos = nSPos;
215     }
216 }
217 
218 struct EDITENG_DLLPUBLIC EFieldInfo
219 {
220     SvxFieldItem*   pFieldItem;
221     String          aCurrentText;
222     EPosition       aPosition;
223 
224     EFieldInfo();
225     EFieldInfo( const SvxFieldItem& rFieldItem, sal_uInt32 nPara, sal_uInt16 nPos );
226     ~EFieldInfo();
227 
228     EFieldInfo( const EFieldInfo& );
229     EFieldInfo& operator= ( const EFieldInfo& );
230 };
231 
232 // -----------------------------------------------------------------------
233 
234 enum ImportState {
235                     RTFIMP_START, RTFIMP_END,               // nur pParser, nPara, nIndex
236                     RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR,   // nToken+nTokenValue
237                     RTFIMP_SETATTR,                         // pAttrs
238                     RTFIMP_INSERTTEXT,                      // aText
239                     RTFIMP_INSERTPARA,                      // -
240                     HTMLIMP_START, HTMLIMP_END,             // nur pParser, nPara, nIndex
241                     HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
242                     HTMLIMP_SETATTR,                        // pAttrs
243                     HTMLIMP_INSERTTEXT,                     // aText
244                     HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
245                     };
246 
247 struct ImportInfo
248 {
249     SvParser*               pParser;
250     ESelection              aSelection;
251     ImportState             eState;
252 
253     int                     nToken;
254     short                   nTokenValue;
255 
256     String                  aText;
257 
258     void*                   pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
259 
260     ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
261     ~ImportInfo();
262 };
263 
264 #define EE_SEARCH_WORDONLY      0x0001
265 #define EE_SEARCH_EXACT         0x0002
266 #define EE_SEARCH_BACKWARD      0x0004
267 #define EE_SEARCH_INSELECTION   0x0008
268 #define EE_SEARCH_REGEXPR       0x0010
269 #define EE_SEARCH_PATTERN       0x0020
270 
271 struct ParagraphInfos
272 {
ParagraphInfosParagraphInfos273     ParagraphInfos()
274         : nParaHeight( 0 )
275         , nLines( 0 )
276         , nFirstLineStartX( 0 )
277         , nFirstLineOffset( 0 )
278         , nFirstLineHeight( 0 )
279         , nFirstLineTextHeight ( 0 )
280         , nFirstLineMaxAscent( 0 )
281         , bValid( 0 )
282         {}
283     sal_uInt16  nParaHeight;
284     sal_uInt16  nLines;
285 
286     sal_uInt16  nFirstLineStartX;
287 
288     sal_uInt16  nFirstLineOffset;
289     sal_uInt16  nFirstLineHeight;
290     sal_uInt16  nFirstLineTextHeight;
291     sal_uInt16  nFirstLineMaxAscent;
292 
293     sal_Bool    bValid; // Bei einer Abfrage waehrend der Formatierung ungueltig!
294 };
295 
296 struct EECharAttrib
297 {
298     const SfxPoolItem*  pAttr;
299 
300     sal_uInt32              nPara;
301     xub_StrLen          nStart;
302     xub_StrLen          nEnd;
303 };
304 
305 SV_DECL_VARARR_VISIBILITY( EECharAttribArray, EECharAttrib, 0, 4, EDITENG_DLLPUBLIC )
306 
307 struct MoveParagraphsInfo
308 {
309     sal_uInt32  nStartPara;
310     sal_uInt32  nEndPara;
311     sal_uInt32  nDestPara;
312 
MoveParagraphsInfoMoveParagraphsInfo313     MoveParagraphsInfo( sal_uInt32 nS, sal_uInt32 nE, sal_uInt32 nD )
314         { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
315 };
316 
317 #define EE_ACTION_PASTE 1
318 #define EE_ACTION_DROP  2
319 
320 struct PasteOrDropInfos
321 {
322     sal_uInt16  nAction;
323     sal_uInt32  nStartPara;
324     sal_uInt32  nEndPara;
325 
PasteOrDropInfosPasteOrDropInfos326     PasteOrDropInfos() : nAction(0), nStartPara(EE_PARA_MAX), nEndPara(EE_PARA_MAX)  {}
327 };
328 
329 enum EENotifyType
330 {
331     /// EditEngine text was modified
332     EE_NOTIFY_TEXTMODIFIED,
333 
334     /// A paragraph was inserted into the EditEngine
335     EE_NOTIFY_PARAGRAPHINSERTED,
336 
337     /// A paragraph was removed from the EditEngine
338     EE_NOTIFY_PARAGRAPHREMOVED,
339 
340     /// Multiple paragraphs have been removed from the EditEngine
341     EE_NOTIFY_PARAGRAPHSMOVED,
342 
343     /// The height of at least one paragraph has changed
344     EE_NOTIFY_TEXTHEIGHTCHANGED,
345 
346     /// The view area of the EditEngine scrolled
347     EE_NOTIFY_TEXTVIEWSCROLLED,
348 
349     /// The selection and/or the cursor position has changed
350     EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
351 
352     /** Denotes the beginning of a collected amount of EditEngine
353         notification events. This event itself is not queued, but sent
354         immediately
355      */
356     EE_NOTIFY_BLOCKNOTIFICATION_START,
357 
358     /** Denotes the end of a collected amount of EditEngine
359         notification events. After this event, the queue is empty, and
360         a high-level operation such as "insert paragraph" is finished
361      */
362     EE_NOTIFY_BLOCKNOTIFICATION_END,
363 
364     /// Denotes the beginning of a high-level action triggered by a key press
365     EE_NOTIFY_INPUT_START,
366 
367     /// Denotes the end of a high-level action triggered by a key press
368     EE_NOTIFY_INPUT_END,
369     EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
370 };
371 
372 struct EENotify
373 {
374     EENotifyType    eNotificationType;
375     EditEngine*     pEditEngine;
376     EditView*       pEditView;
377 
378     sal_uInt32          nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
379 
380     sal_uInt32          nParam1;
381     sal_uInt32          nParam2;
382 
EENotifyEENotify383     EENotify( EENotifyType eType )
384         { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
385 };
386 
387 #endif // _MyEDITDATA_HXX
388