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 #ifndef _IMPEDIT_HXX
24 #define _IMPEDIT_HXX
25
26 #include <editdoc.hxx>
27 #include <editsel.hxx>
28 #include <editundo.hxx>
29 #include <editobj2.hxx>
30 #include <editstt2.hxx>
31 #include <editeng/editdata.hxx>
32 #include <editeng/svxacorr.hxx>
33 #include <vcl/virdev.hxx>
34 #include <vcl/gdimtf.hxx>
35 #include <vcl/cursor.hxx>
36
37 #include <vcl/dndhelp.hxx>
38 #include <svl/ondemand.hxx>
39 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
40 #include <com/sun/star/linguistic2/SpellFailure.hpp>
41 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
42 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
43 #include <com/sun/star/linguistic2/XHyphenator.hpp>
44 #include <com/sun/star/lang/Locale.hpp>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/i18n/XBreakIterator.hpp>
47 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
48 #include <com/sun/star/i18n/WordType.hpp>
49 #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
50 #include <com/sun/star/uno/Sequence.hxx>
51
52 #include <i18npool/lang.h>
53 #include <vos/ref.hxx>
54
55 DBG_NAMEEX( EditView )
56 DBG_NAMEEX( EditEngine )
57
58 #define PIMPEE pImpEditView->pEditEngine->pImpEditEngine
59
60 #define DEL_LEFT 1
61 #define DEL_RIGHT 2
62 #define TRAVEL_X_DONTKNOW 0xFFFFFFFF
63 #define CURSOR_BIDILEVEL_DONTKNOW 0xFFFF
64 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW // Max 16K, because WYSIWYG array
65
66 #define ATTRSPECIAL_WHOLEWORD 1
67 #define ATTRSPECIAL_EDGE 2
68
69 #define GETCRSR_TXTONLY 0x0001
70 #define GETCRSR_STARTOFLINE 0x0002
71 #define GETCRSR_ENDOFLINE 0x0004
72 #define GETCRSR_PREFERPORTIONSTART 0x0008
73
74 #define LINE_SEP 0x0A
75
76 typedef EENotify* EENotifyPtr;
77 SV_DECL_PTRARR_DEL( NotifyList, EENotifyPtr, 1, 1 ) // IMPL is in outliner.cxx, move to EE later and share declaration, or use BlockNotifications from EE directly
78
79
80 class EditView;
81 class EditEngine;
82 class SvxFontTable;
83 class SvxColorList;
84
85 class SvxSearchItem;
86 class SvxLRSpaceItem;
87 class TextRanger;
88 class SvKeyValueIterator;
89 class SvxForbiddenCharactersTable;
90 class SvtCTLOptions;
91 #include <editeng/SpellPortions.hxx>
92
93 #include <editeng/eedata.hxx>
94
95 class SvUShorts;
96 class SvxNumberFormat;
97
98
99 namespace com {
100 namespace sun {
101 namespace star {
102 namespace datatransfer {
103 namespace clipboard {
104 class XClipboard;
105 }}}}}
106
107 namespace svtools {
108 class ColorConfig;
109 }
110
111 struct DragAndDropInfo
112 {
113 Rectangle aCurCursor;
114 Rectangle aCurSavedCursor;
115 sal_uInt16 nSensibleRange;
116 sal_uInt16 nCursorWidth;
117 ESelection aBeginDragSel;
118 EditPaM aDropDest;
119 sal_uInt16 nOutlinerDropDest;
120 ESelection aDropSel;
121 VirtualDevice* pBackground;
122 const SvxFieldItem* pField;
123 sal_Bool bVisCursor : 1;
124 sal_Bool bDroppedInMe : 1;
125 sal_Bool bStarterOfDD : 1;
126 sal_Bool bHasValidData : 1;
127 sal_Bool bUndoAction : 1;
128 sal_Bool bOutlinerMode : 1;
129 sal_Bool bDragAccepted : 1;
130
DragAndDropInfoDragAndDropInfo131 DragAndDropInfo()
132 {
133 pBackground = NULL; bVisCursor = sal_False; bDroppedInMe = sal_False; bStarterOfDD = sal_False;
134 bHasValidData = sal_False; bUndoAction = sal_False; bOutlinerMode = sal_False;
135 nSensibleRange = 0; nCursorWidth = 0; pField = 0; nOutlinerDropDest = 0; bDragAccepted = sal_False;
136 }
137 };
138
139 struct ImplIMEInfos
140 {
141 String aOldTextAfterStartPos;
142 sal_uInt16* pAttribs;
143 EditPaM aPos;
144 sal_uInt16 nLen;
145 sal_Bool bCursor;
146 sal_Bool bWasCursorOverwrite;
147
148 ImplIMEInfos( const EditPaM& rPos, const String& rOldTextAfterStartPos );
149 ~ImplIMEInfos();
150
151 void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL );
152 void DestroyAttribs();
153 };
154
155 // #i18881# to be able to identify the postions of changed words
156 // the positions of each portion need to be saved
157 typedef std::vector<EditSelection> SpellContentSelections;
158
159 struct SpellInfo
160 {
161 EESpellState eState;
162 EPaM aSpellStart;
163 EPaM aSpellTo;
164 EditPaM aCurSentenceStart;
165 sal_Bool bSpellToEnd;
166 sal_Bool bMultipleDoc;
167 ::svx::SpellPortions aLastSpellPortions;
168 SpellContentSelections aLastSpellContentSelections;
SpellInfoSpellInfo169 SpellInfo()
170 { bSpellToEnd = sal_True; eState = EE_SPELL_OK; bMultipleDoc = sal_False; }
171 };
172
173 // used for text conversion
174 struct ConvInfo
175 {
176 EPaM aConvStart;
177 EPaM aConvTo;
178 EPaM aConvContinue; // position to start search for next text portion (word) with
179 sal_Bool bConvToEnd;
180 sal_Bool bMultipleDoc;
181
ConvInfoConvInfo182 ConvInfo() { bConvToEnd = sal_True; bMultipleDoc = sal_False; }
183 };
184
185 struct FormatterFontMetric
186 {
187 sal_uInt16 nMaxAscent;
188 sal_uInt16 nMaxDescent;
189
FormatterFontMetricFormatterFontMetric190 FormatterFontMetric() { nMaxAscent = 0; nMaxDescent = 0; /* nMinLeading = 0xFFFF; */ }
GetHeightFormatterFontMetric191 sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; }
192 };
193
194 class IdleFormattter : public Timer
195 {
196 private:
197 EditView* pView;
198 int nRestarts;
199
200 public:
201 IdleFormattter();
202 ~IdleFormattter();
203
204 void DoIdleFormat( EditView* pV );
205 void ForceTimeout();
ResetRestarts()206 void ResetRestarts() { nRestarts = 0; }
GetView()207 EditView* GetView() { return pView; }
208 };
209
210 // ----------------------------------------------------------------------
211 // class ImpEditView
212 // ----------------------------------------------------------------------
213 class ImpEditView : public vcl::unohelper::DragAndDropClient
214 {
215 friend class EditView;
216 friend class EditEngine;
217 friend class ImpEditEngine;
218 using vcl::unohelper::DragAndDropClient::dragEnter;
219 using vcl::unohelper::DragAndDropClient::dragExit;
220 using vcl::unohelper::DragAndDropClient::dragOver;
221
222 private:
223 EditView* pEditView;
224 Cursor* pCursor;
225 Color* pBackgroundColor;
226 EditEngine* pEditEngine;
227 Window* pOutWin;
228 Pointer* pPointer;
229 DragAndDropInfo* pDragAndDropInfo;
230
231 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener > mxDnDListener;
232
233
234 long nInvMore;
235 sal_uLong nControl;
236 sal_uInt32 nTravelXPos;
237 sal_uInt16 nExtraCursorFlags;
238 sal_uInt16 nCursorBidiLevel;
239 sal_uInt16 nScrollDiffX;
240 sal_Bool bReadOnly;
241 sal_Bool bClickedInSelection;
242 sal_Bool bActiveDragAndDropListener;
243
244 Point aAnchorPoint;
245 Rectangle aOutArea;
246 Point aVisDocStartPos;
247 EESelectionMode eSelectionMode;
248 EditSelection aEditSelection;
249 EVAnchorMode eAnchorMode;
250
251 protected:
252
253 // DragAndDropClient
254 void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException);
255 void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException);
256 void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
257 void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException);
258 void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException);
259 void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
260
261 void ShowDDCursor( const Rectangle& rRect );
262 void HideDDCursor();
263
264 void ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, PolyPolygon* pPolyPoly );
265
266 public:
267 ImpEditView( EditView* pView, EditEngine* pEng, Window* pWindow );
268 ~ImpEditView();
269
GetEditViewPtr()270 EditView* GetEditViewPtr() { return pEditView; }
271
GetScrollDiffX() const272 sal_uInt16 GetScrollDiffX() const { return nScrollDiffX; }
SetScrollDiffX(sal_uInt16 n)273 void SetScrollDiffX( sal_uInt16 n ) { nScrollDiffX = n; }
274
GetCursorBidiLevel() const275 sal_uInt16 GetCursorBidiLevel() const { return nCursorBidiLevel; }
SetCursorBidiLevel(sal_uInt16 n)276 void SetCursorBidiLevel( sal_uInt16 n ) { nCursorBidiLevel = n; }
277
278 Point GetDocPos( const Point& rWindowPos ) const;
279 Point GetWindowPos( const Point& rDocPos ) const;
280 Rectangle GetWindowPos( const Rectangle& rDocPos ) const;
281
282 void SetOutputArea( const Rectangle& rRec );
283 void ResetOutputArea( const Rectangle& rRec );
GetOutputArea() const284 const Rectangle& GetOutputArea() const { return aOutArea; }
285
286 sal_Bool IsVertical() const;
287
288 sal_Bool PostKeyEvent( const KeyEvent& rKeyEvent );
289
290 sal_Bool MouseButtonUp( const MouseEvent& rMouseEvent );
291 sal_Bool MouseButtonDown( const MouseEvent& rMouseEvent );
292 sal_Bool MouseMove( const MouseEvent& rMouseEvent );
293 void Command( const CommandEvent& rCEvt );
294
295 void CutCopy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bCut );
296 void Paste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bUseSpecial = sal_False );
297
SetVisDocStartPos(const Point & rPos)298 void SetVisDocStartPos( const Point& rPos ) { aVisDocStartPos = rPos; }
GetVisDocStartPos() const299 const Point& GetVisDocStartPos() const { return aVisDocStartPos; }
300
GetVisDocLeft() const301 long GetVisDocLeft() const { return aVisDocStartPos.X(); }
GetVisDocTop() const302 long GetVisDocTop() const { return aVisDocStartPos.Y(); }
GetVisDocRight() const303 long GetVisDocRight() const { return aVisDocStartPos.X() + ( !IsVertical() ? aOutArea.GetWidth() : aOutArea.GetHeight() ); }
GetVisDocBottom() const304 long GetVisDocBottom() const { return aVisDocStartPos.Y() + ( !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth() ); }
305 Rectangle GetVisDocArea() const;
306
GetEditSelection()307 EditSelection& GetEditSelection() { return aEditSelection; }
308 void SetEditSelection( const EditSelection& rEditSelection );
HasSelection() const309 sal_Bool HasSelection() const { return aEditSelection.HasRange(); }
310
DrawSelection()311 void DrawSelection() { DrawSelection( aEditSelection ); }
312 void DrawSelection( EditSelection, Region* pRegion = NULL, OutputDevice* pTargetDevice = NULL );
313 Region* CalcSelectedRegion();
314
GetWindow() const315 Window* GetWindow() const { return pOutWin; }
316
GetSelectionMode() const317 EESelectionMode GetSelectionMode() const { return eSelectionMode; }
318 void SetSelectionMode( EESelectionMode eMode );
319
320 inline void SetPointer( const Pointer& rPointer );
321 inline const Pointer& GetPointer();
322
323 inline void SetCursor( const Cursor& rCursor );
324 inline Cursor* GetCursor();
325
326 void AddDragAndDropListeners();
327 void RemoveDragAndDropListeners();
328
329 sal_Bool IsBulletArea( const Point& rPos, sal_uInt16* pPara );
330
331 // Fuer die SelectionEngine...
332 void CreateAnchor();
333 void DeselectAll();
334 sal_Bool SetCursorAtPoint( const Point& rPointPixel );
335 sal_Bool IsSelectionAtPoint( const Point& rPosPixel );
336 sal_Bool IsInSelection( const EditPaM& rPaM );
337
338
339 void SetAnchorMode( EVAnchorMode eMode );
GetAnchorMode() const340 EVAnchorMode GetAnchorMode() const { return eAnchorMode; }
341 void CalcAnchorPoint();
342 void RecalcOutputArea();
343
344 void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sal_Bool test );
345 void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sal_uInt16 nShowCursorFlags = 0 );
346 Pair Scroll( long ndX, long ndY, sal_uInt8 nRangeCheck = RGCHK_NEG );
347
348 void SetInsertMode( sal_Bool bInsert );
IsInsertMode() const349 sal_Bool IsInsertMode() const { return ( ( nControl & EV_CNTRL_OVERWRITE ) == 0 ); }
350
EnablePaste(sal_Bool bEnable)351 void EnablePaste( sal_Bool bEnable ) { SetFlags( nControl, EV_CNTRL_ENABLEPASTE, bEnable ); }
IsPasteEnabled() const352 sal_Bool IsPasteEnabled() const { return ( ( nControl & EV_CNTRL_ENABLEPASTE ) != 0 ); }
353
DoSingleLinePaste() const354 sal_Bool DoSingleLinePaste() const { return ( ( nControl & EV_CNTRL_SINGLELINEPASTE ) != 0 ); }
DoAutoScroll() const355 sal_Bool DoAutoScroll() const { return ( ( nControl & EV_CNTRL_AUTOSCROLL ) != 0 ); }
DoBigScroll() const356 sal_Bool DoBigScroll() const { return ( ( nControl & EV_CNTRL_BIGSCROLL ) != 0 ); }
DoAutoSize() const357 sal_Bool DoAutoSize() const { return ( ( nControl & EV_CNTRL_AUTOSIZE ) != 0 ); }
DoAutoWidth() const358 sal_Bool DoAutoWidth() const { return ( ( nControl & EV_CNTRL_AUTOSIZEX) != 0 ); }
DoAutoHeight() const359 sal_Bool DoAutoHeight() const { return ( ( nControl & EV_CNTRL_AUTOSIZEY) != 0 ); }
DoInvalidateMore() const360 sal_Bool DoInvalidateMore() const { return ( ( nControl & EV_CNTRL_INVONEMORE ) != 0 ); }
361
362 void SetBackgroundColor( const Color& rColor );
GetBackgroundColor() const363 const Color& GetBackgroundColor() const {
364 return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); }
365
366 sal_Bool IsWrongSpelledWord( const EditPaM& rPaM, sal_Bool bMarkIfWrong );
367 String SpellIgnoreOrAddWord( sal_Bool bAdd );
368
369 const SvxFieldItem* GetField( const Point& rPos, sal_uInt16* pPara, sal_uInt16* pPos ) const;
370 void DeleteSelected();
371
372 // Ggf. mehr als OutputArea invalidieren, fuer den DrawingEngine-Textrahmen...
SetInvalidateMore(sal_uInt16 nPixel)373 void SetInvalidateMore( sal_uInt16 nPixel ) { nInvMore = nPixel; }
GetInvalidateMore() const374 sal_uInt16 GetInvalidateMore() const { return (sal_uInt16)nInvMore; }
375 };
376
377 // ----------------------------------------------------------------------
378 // ImpEditEngine
379 // ----------------------------------------------------------------------
380
381 typedef EditView* EditViewPtr;
382 SV_DECL_PTRARR( EditViews, EditViewPtr, 0, 1 )
383
384 class ImpEditEngine : public SfxListener
385 {
386 // Die Undos muessen direkt manipulieren ( private-Methoden ),
387 // damit keine neues Undos eingefuegt werden!
388 friend class EditUndoInsertChars;
389 friend class EditUndoRemoveChars;
390 friend class EditUndoDelContent;
391 friend class EditUndoConnectParas;
392 friend class EditUndoSplitPara;
393 friend class EditUndoInsertFeature;
394 friend class EditUndoMoveParagraphs;
395
396 friend class EditView;
397 friend class ImpEditView;
398 friend class EditEngine; // Fuer Zugriff auf Imp-Methoden
399 friend class EditRTFParser; // Fuer Zugriff auf Imp-Methoden
400 friend class EditHTMLParser; // Fuer Zugriff auf Imp-Methoden
401 friend class EdtAutoCorrDoc; // Fuer Zugriff auf Imp-Methoden
402 friend class EditDbg; // DebugRoutinen
403
404 private:
405
406 // ================================================================
407 // Daten...
408 // ================================================================
409
410 // Dokument-Spezifische Daten...
411 ParaPortionList aParaPortionList; // Formatierung
412 Size aPaperSize; // Layout
413 Size aMinAutoPaperSize; // Layout ?
414 Size aMaxAutoPaperSize; // Layout ?
415 EditDoc aEditDoc; // Dokumenteninhalt
416
417 // Engine-Spezifische Daten....
418 EditEngine* pEditEngine;
419 EditViews aEditViews;
420 EditView* pActiveView;
421 TextRanger* pTextRanger;
422
423 SfxStyleSheetPool* pStylePool;
424 SfxItemPool* pTextObjectPool;
425
426 VirtualDevice* pVirtDev;
427 OutputDevice* pRefDev;
428
429 svtools::ColorConfig* pColorConfig;
430 mutable SvtCTLOptions* pCTLOptions;
431
432 SfxItemSet* pEmptyItemSet;
433 EditUndoManager* pUndoManager;
434 ESelection* pUndoMarkSelection;
435
436 ImplIMEInfos* mpIMEInfos;
437
438 NotifyList aNotifyCache;
439
440 XubString aWordDelimiters;
441 XubString aGroupChars;
442
443 EditSelFunctionSet aSelFuncSet;
444 EditSelectionEngine aSelEngine;
445
446 Color maBackgroundColor;
447
448 sal_uInt32 nBlockNotifications;
449 sal_uInt16 nStretchX;
450 sal_uInt16 nStretchY;
451
452 sal_uInt16 nAsianCompressionMode;
453 sal_Bool bKernAsianPunctuation;
454 sal_Bool bAddExtLeading;
455
456 EEHorizontalTextDirection eDefaultHorizontalTextDirection;
457
458 sal_uInt16 nBigTextObjectStart;
459 ::com::sun::star::uno::Reference<
460 ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
461 ::com::sun::star::uno::Reference<
462 ::com::sun::star::linguistic2::XHyphenator > xHyphenator;
463 SpellInfo* pSpellInfo;
464 mutable ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > xBI;
465 mutable ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > xISC;
466
467 ConvInfo * pConvInfo;
468
469 XubString aAutoCompleteText;
470
471 InternalEditStatus aStatus;
472
473 LanguageType eDefLanguage;
474
475 OnDemandLocaleDataWrapper xLocaleDataWrapper;
476 OnDemandTransliterationWrapper xTransliterationWrapper;
477
478 sal_Bool bIsFormatting;
479 sal_Bool bFormatted;
480 sal_Bool bInSelection;
481 sal_Bool bIsInUndo;
482 sal_Bool bUpdate;
483 sal_Bool bUpdateForAcc;
484 sal_Bool bUndoEnabled;
485 sal_Bool bOwnerOfRefDev;
486 sal_Bool bDowning;
487 sal_Bool bUseAutoColor;
488 sal_Bool bForceAutoColor;
489 sal_Bool bCallParaInsertedOrDeleted;
490 sal_Bool bImpConvertFirstCall; // specifies if ImpConvert is called the very first time after Convert was called
491 sal_Bool bFirstWordCapitalization; // specifies if auto-correction should capitalize the first word or not
492
493 // Fuer Formatierung / Update....
494 DeletedNodesList aDeletedNodes;
495 Rectangle aInvalidRec;
496 sal_uInt32 nCurTextHeight;
497 sal_uInt16 nOnePixelInRef;
498
499 IdleFormattter aIdleFormatter;
500
501 Timer aOnlineSpellTimer;
502
503 // Wenn an einer Stelle erkannt wird, dass der StatusHdl gerufen werden
504 // muss, dies aber nicht sofort geschehen darf (kritischer Abschnitt):
505 Timer aStatusTimer;
506 Link aStatusHdlLink;
507 Link aNotifyHdl;
508 Link aImportHdl;
509 Link aBeginMovingParagraphsHdl;
510 Link aEndMovingParagraphsHdl;
511 Link aBeginPasteOrDropHdl;
512 Link aEndPasteOrDropHdl;
513 Link aModifyHdl;
514 Link maBeginDropHdl;
515 Link maEndDropHdl;
516
517 vos::ORef<SvxForbiddenCharactersTable> xForbiddenCharsTable;
518
519
520 // ================================================================
521 // Methoden...
522 // ================================================================
523
524 void CursorMoved( ContentNode* pPrevNode );
525 void ParaAttribsChanged( ContentNode* pNode );
526 void TextModified();
527 void CalcHeight( ParaPortion* pPortion );
528
529 // ggf. lieber inline, aber so einiges...
530 void InsertUndo( EditUndo* pUndo, sal_Bool bTryMerge = sal_False );
531 void ResetUndoManager();
HasUndoManager() const532 sal_Bool HasUndoManager() const { return pUndoManager ? sal_True : sal_False; }
533
534 EditUndoSetAttribs* CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet );
535
536 EditPaM GetPaM( Point aDocPos, sal_Bool bSmart = sal_True );
537 EditPaM GetPaM( ParaPortion* pPortion, Point aPos, sal_Bool bSmart = sal_True );
538 long GetXPos( ParaPortion* pParaPortion, EditLine* pLine, sal_uInt16 nIndex, sal_Bool bPreferPortionStart = sal_False );
539 long GetPortionXOffset( ParaPortion* pParaPortion, EditLine* pLine, sal_uInt16 nTextPortion );
540 sal_uInt16 GetChar( ParaPortion* pParaPortion, EditLine* pLine, long nX, sal_Bool bSmart = sal_True );
541 Range GetInvalidYOffsets( ParaPortion* pPortion );
542 Range GetLineXPosStartEnd( ParaPortion* pParaPortion, EditLine* pLine );
543
544 void SetParaAttrib( sal_uInt8 nFunc, EditSelection aSel, sal_uInt16 nValue );
545 sal_uInt16 GetParaAttrib( sal_uInt8 nFunc, EditSelection aSel );
546 void SetCharAttrib( EditSelection aSel, const SfxPoolItem& rItem );
547 void ParaAttribsToCharAttribs( ContentNode* pNode );
548 void GetCharAttribs( sal_uInt16 nPara, EECharAttribArray& rLst ) const;
549
550 EditTextObject* CreateBinTextObject( EditSelection aSelection, SfxItemPool*, sal_Bool bAllowBigObjects = sal_False, sal_uInt16 nBigObjStart = 0 ) const;
551 void StoreBinTextObject( SvStream& rOStream, BinTextObject& rTextObject );
552 EditSelection InsertBinTextObject( BinTextObject&, EditPaM aPaM );
553 EditSelection InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxDataObj, const String& rBaseURL, const EditPaM& rPaM, sal_Bool bUseSpecial );
554
555 EditPaM Clear();
556 EditPaM RemoveText();
557 EditPaM RemoveText( EditSelection aEditSelection );
558 sal_Bool CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY );
559 void CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uInt32 nStartPosY );
560 sal_Bool FinishCreateLines( ParaPortion* pParaPortion );
561 void CalcCharPositions( ParaPortion* pParaPortion );
562 void CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStartPos /*, sal_Bool bCreateBlockPortions */ );
563 void RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars );
564 sal_uInt16 SplitTextPortion( ParaPortion* pParaPortion, sal_uInt16 nPos, EditLine* pCurLine = 0 );
565 void SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0 );
566 void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont );
567 void CheckAutoPageSize();
568
569 void ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate );
570 void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace );
571 EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, sal_Bool bBackward = sal_False );
572 EditPaM ImpDeleteSelection( EditSelection aEditSelection);
573 EditPaM ImpInsertParaBreak( const EditPaM& rPaM, sal_Bool bKeepEndingAttribs = sal_True );
574 EditPaM ImpInsertParaBreak( const EditSelection& rEditSelection, sal_Bool bKeepEndingAttribs = sal_True );
575 EditPaM ImpInsertText( EditSelection aCurEditSelection, const String& rStr );
576 EditPaM ImpInsertFeature( EditSelection aEditSelection, const SfxPoolItem& rItem );
577 void ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, EditUndoRemoveChars* pCurUndo = 0 );
578 void ImpRemoveParagraph( sal_uInt16 nPara );
579 EditSelection ImpMoveParagraphs( Range aParagraphs, sal_uInt16 nNewPos );
580
581 EditPaM ImpFastInsertText( EditPaM aPaM, const String& rStr );
582 EditPaM ImpFastInsertParagraph( sal_uInt16 nPara );
583
584 sal_Bool ImpCheckRefMapMode();
585
586 sal_Bool ImplHasText() const;
587
588 void ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, SvUShorts& rArray );
589
590 void InsertContent( ContentNode* pNode, sal_uInt16 nPos );
591 EditPaM SplitContent( sal_uInt16 nNode, sal_uInt16 nSepPos );
592 EditPaM ConnectContents( sal_uInt16 nLeftNode, sal_Bool bBackward );
593
594 void ShowParagraph( sal_uInt16 nParagraph, sal_Bool bShow );
595 sal_Bool IsParagraphVisible( sal_uInt16 nParagraph );
596
597 EditPaM PageUp( const EditPaM& rPaM, EditView* pView);
598 EditPaM PageDown( const EditPaM& rPaM, EditView* pView);
599 EditPaM CursorUp( const EditPaM& rPaM, EditView* pEditView );
600 EditPaM CursorDown( const EditPaM& rPaM, EditView* pEditView );
601 EditPaM CursorLeft( const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode = ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
602 EditPaM CursorRight( const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode = ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
603 EditPaM CursorStartOfLine( const EditPaM& rPaM );
604 EditPaM CursorEndOfLine( const EditPaM& rPaM );
605 EditPaM CursorStartOfParagraph( const EditPaM& rPaM );
606 EditPaM CursorEndOfParagraph( const EditPaM& rPaM );
607 EditPaM CursorStartOfDoc();
608 EditPaM CursorEndOfDoc();
609 EditPaM WordLeft( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
610 EditPaM WordRight( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
611 EditPaM StartOfWord( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
612 EditPaM EndOfWord( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
613 EditSelection SelectWord( const EditSelection& rCurSelection, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_Bool bAcceptStartOfWord = sal_True );
614 EditSelection SelectSentence( const EditSelection& rCurSel );
615 EditPaM CursorVisualLeftRight( EditView* pEditView, const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode, sal_Bool bToLeft );
616 EditPaM CursorVisualStartEnd( EditView* pEditView, const EditPaM& rPaM, sal_Bool bStart );
617
618
619 void InitScriptTypes( sal_uInt16 nPara );
620 sal_uInt16 GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const;
621 sal_uInt16 GetScriptType( const EditSelection& rSel ) const;
622 sal_Bool IsScriptChange( const EditPaM& rPaM ) const;
623 sal_Bool HasScriptType( sal_uInt16 nPara, sal_uInt16 nType ) const;
624
625 sal_Bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_uInt16 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, sal_Bool bManipulateDXArray );
626 void ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, long nRemainingWidth );
627
628 void ImplInitLayoutMode( OutputDevice* pOutDev, sal_uInt16 nPara, sal_uInt16 nIndex );
629 void ImplInitDigitMode( OutputDevice* pOutDev, String* pString, xub_StrLen nStt, xub_StrLen nLen, LanguageType eLang );
630
631 EditPaM ReadText( SvStream& rInput, EditSelection aSel );
632 EditPaM ReadRTF( SvStream& rInput, EditSelection aSel );
633 EditPaM ReadXML( SvStream& rInput, EditSelection aSel );
634 EditPaM ReadHTML( SvStream& rInput, const String& rBaseURL, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs );
635 EditPaM ReadBin( SvStream& rInput, EditSelection aSel );
636 sal_uInt32 WriteText( SvStream& rOutput, EditSelection aSel );
637 sal_uInt32 WriteRTF( SvStream& rOutput, EditSelection aSel );
638 sal_uInt32 WriteXML( SvStream& rOutput, EditSelection aSel );
639 sal_uInt32 WriteHTML( SvStream& rOutput, EditSelection aSel );
640 sal_uInt32 WriteBin( SvStream& rOutput, EditSelection aSel, sal_Bool bStoreUnicode = sal_False ) const;
641
642 void WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos,
643 SvxFontTable& rFontTable, SvxColorList& rColorList );
644 sal_Bool WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos,
645 SvxFontTable& rFontTable, SvxColorList& rColorList );
646 long LogicToTwips( long n );
647
648 inline short GetXValue( short nXValue ) const;
649 inline sal_uInt16 GetXValue( sal_uInt16 nXValue ) const;
650 inline long GetXValue( long nXValue ) const;
651
652 inline short GetYValue( short nYValue ) const;
653 inline sal_uInt16 GetYValue( sal_uInt16 nYValue ) const;
654
655 ContentNode* GetPrevVisNode( ContentNode* pCurNode );
656 ContentNode* GetNextVisNode( ContentNode* pCurNode );
657
658 ParaPortion* GetPrevVisPortion( ParaPortion* pCurPortion );
659 ParaPortion* GetNextVisPortion( ParaPortion* pCurPortion );
660
SetBackgroundColor(const Color & rColor)661 void SetBackgroundColor( const Color& rColor ) { maBackgroundColor = rColor; }
GetBackgroundColor() const662 Color GetBackgroundColor() const { return maBackgroundColor; }
663
664 Color GetAutoColor() const;
EnableAutoColor(sal_Bool b)665 void EnableAutoColor( sal_Bool b ) { bUseAutoColor = b; }
IsAutoColorEnabled() const666 sal_Bool IsAutoColorEnabled() const { return bUseAutoColor; }
ForceAutoColor(sal_Bool b)667 void ForceAutoColor( sal_Bool b ) { bForceAutoColor = b; }
IsForceAutoColor() const668 sal_Bool IsForceAutoColor() const { return bForceAutoColor; }
669
670 inline VirtualDevice* GetVirtualDevice( const MapMode& rMapMode, sal_uLong nDrawMode );
671 inline void EraseVirtualDevice();
672
673 DECL_LINK( StatusTimerHdl, Timer * );
674 DECL_LINK( IdleFormatHdl, Timer * );
675 DECL_LINK( OnlineSpellHdl, Timer * );
676 DECL_LINK( DocModified, void* );
677
678 void CheckIdleFormatter();
679
680 inline ParaPortion* FindParaPortion( ContentNode* pNode ) const;
681
682 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > CreateTransferable( const EditSelection& rSelection ) const;
683
684 void SetValidPaperSize( const Size& rSz );
685
686 ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const;
687 ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker() const;
688
689 /** Decorate metafile output with verbose text comments
690
691 This method is used to wrap SvxFont::QuickDrawText, to
692 determine character-by-character wise, which logical text
693 units like characters, words and sentences are contained in
694 the output string at hand. This is necessary for slideshow
695 text effects.
696 */
697 void ImplFillTextMarkingVector(const ::com::sun::star::lang::Locale& rLocale, EEngineData::TextMarkingVector& rTextMarkingVector, const String& rTxt, const sal_uInt16 nIdx, const sal_uInt16 nLen) const;
698
699 SpellInfo * CreateSpellInfo( const EditSelection &rSel, bool bMultipleDocs );
700
701 protected:
702 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
703
704 public:
705 ImpEditEngine( EditEngine* pEditEngine, SfxItemPool* pPool );
706 ~ImpEditEngine();
707
708 void InitDoc( sal_Bool bKeepParaAttribs );
GetEditDoc()709 EditDoc& GetEditDoc() { return aEditDoc; }
GetEditDoc() const710 const EditDoc& GetEditDoc() const { return aEditDoc; }
711
712 inline EditUndoManager& GetUndoManager();
713 inline ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
714
715 void SetUpdateMode( sal_Bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False );
GetUpdateMode() const716 sal_Bool GetUpdateMode() const { return bUpdate; }
717 void SetUpdateModeForAcc( sal_Bool bUp);
718 sal_Bool GetUpdateModeForAcc();
719
GetParaPortions() const720 const ParaPortionList& GetParaPortions() const { return aParaPortionList; }
GetParaPortions()721 ParaPortionList& GetParaPortions() { return aParaPortionList; }
GetEditViews()722 EditViews& GetEditViews() { return aEditViews; }
723
GetPaperSize() const724 const Size& GetPaperSize() const { return aPaperSize; }
SetPaperSize(const Size & rSz)725 void SetPaperSize( const Size& rSz ) { aPaperSize = rSz; }
726
727 void SetVertical( sal_Bool bVertical );
IsVertical() const728 sal_Bool IsVertical() const { return GetEditDoc().IsVertical(); }
729
730 void SetFixedCellHeight( sal_Bool bUseFixedCellHeight );
IsFixedCellHeight() const731 sal_Bool IsFixedCellHeight() const { return GetEditDoc().IsFixedCellHeight(); }
732
SetDefaultHorizontalTextDirection(EEHorizontalTextDirection eHTextDir)733 void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir ) { eDefaultHorizontalTextDirection = eHTextDir; }
GetDefaultHorizontalTextDirection() const734 EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const { return eDefaultHorizontalTextDirection; }
735
736
737 void InitWritingDirections( sal_uInt16 nPara );
738 sal_Bool IsRightToLeft( sal_uInt16 nPara ) const;
739 sal_uInt8 GetRightToLeft( sal_uInt16 nPara, sal_uInt16 nChar, sal_uInt16* pStart = NULL, sal_uInt16* pEnd = NULL );
740 sal_Bool HasDifferentRTLLevels( const ContentNode* pNode );
741
742 void SetTextRanger( TextRanger* pRanger );
GetTextRanger() const743 TextRanger* GetTextRanger() const { return pTextRanger; }
744
GetMinAutoPaperSize() const745 const Size& GetMinAutoPaperSize() const { return aMinAutoPaperSize; }
SetMinAutoPaperSize(const Size & rSz)746 void SetMinAutoPaperSize( const Size& rSz ) { aMinAutoPaperSize = rSz; }
747
GetMaxAutoPaperSize() const748 const Size& GetMaxAutoPaperSize() const { return aMaxAutoPaperSize; }
SetMaxAutoPaperSize(const Size & rSz)749 void SetMaxAutoPaperSize( const Size& rSz ) { aMaxAutoPaperSize = rSz; }
750
751 void FormatDoc();
752 void FormatFullDoc();
753 void UpdateViews( EditView* pCurView = 0 );
754 void Paint( ImpEditView* pView, const Rectangle& rRect, OutputDevice* pTargetDevice = 0, sal_Bool bUseVirtDev = sal_False );
755 void Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly = sal_False, short nOrientation = 0 );
756
757 sal_Bool MouseButtonUp( const MouseEvent& rMouseEvent, EditView* pView );
758 sal_Bool MouseButtonDown( const MouseEvent& rMouseEvent, EditView* pView );
759 sal_Bool MouseMove( const MouseEvent& rMouseEvent, EditView* pView );
760 void Command( const CommandEvent& rCEvt, EditView* pView );
761
GetSelEngine()762 EditSelectionEngine& GetSelEngine() { return aSelEngine; }
763 XubString GetSelected( const EditSelection& rSel, const LineEnd eParaSep = LINEEND_LF ) const;
764
765 const SfxItemSet& GetEmptyItemSet();
766
767 void UpdateSelections();
768
769 void EnableUndo( sal_Bool bEnable );
IsUndoEnabled()770 sal_Bool IsUndoEnabled() { return bUndoEnabled; }
SetUndoMode(sal_Bool b)771 void SetUndoMode( sal_Bool b ) { bIsInUndo = b; }
IsInUndo()772 sal_Bool IsInUndo() { return bIsInUndo; }
773
SetCallParaInsertedOrDeleted(sal_Bool b)774 void SetCallParaInsertedOrDeleted( sal_Bool b ) { bCallParaInsertedOrDeleted = b; }
IsCallParaInsertedOrDeleted() const775 sal_Bool IsCallParaInsertedOrDeleted() const { return bCallParaInsertedOrDeleted; }
776
IsFormatted() const777 sal_Bool IsFormatted() const { return bFormatted; }
IsFormatting() const778 sal_Bool IsFormatting() const { return bIsFormatting; }
779
780 void SetText( const String& rText );
781 EditPaM DeleteSelected( EditSelection aEditSelection);
782 EditPaM InsertText( const EditSelection& rCurEditSelection, sal_Unicode c, sal_Bool bOverwrite, sal_Bool bIsUserInput = sal_False );
783 EditPaM InsertText( EditSelection aCurEditSelection, const String& rStr );
784 EditPaM AutoCorrect( const EditSelection& rCurEditSelection, sal_Unicode c, sal_Bool bOverwrite );
785 EditPaM DeleteLeftOrRight( const EditSelection& rEditSelection, sal_uInt8 nMode, sal_uInt8 nDelMode = DELMODE_SIMPLE );
786 EditPaM InsertParaBreak( EditSelection aEditSelection );
787 EditPaM InsertLineBreak( EditSelection aEditSelection );
788 EditPaM InsertTab( EditSelection aEditSelection );
789 EditPaM InsertField( EditSelection aEditSelection, const SvxFieldItem& rFld );
790 sal_Bool UpdateFields();
791
792 EditPaM Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
793 void Write( SvStream& rOutput, EETextFormat eFormat, EditSelection aSel );
794
795 EditTextObject* CreateTextObject();
796 EditTextObject* CreateTextObject( EditSelection aSel );
797 void SetText( const EditTextObject& rTextObject );
798 EditSelection InsertText( const EditTextObject& rTextObject, EditSelection aSel );
799
800 EditSelection MoveCursor( const KeyEvent& rKeyEvent, EditView* pEditView );
801
802 EditSelection MoveParagraphs( Range aParagraphs, sal_uInt16 nNewPos, EditView* pCurView );
803
804 sal_uInt32 CalcTextHeight();
805 sal_uInt32 GetTextHeight() const;
806 sal_uInt32 CalcTextWidth( sal_Bool bIgnoreExtraSpace );
807 sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, sal_Bool bIgnoreExtraSpace );
808 sal_uInt16 GetLineCount( sal_uInt16 nParagraph ) const;
809 sal_uInt16 GetLineLen( sal_uInt16 nParagraph, sal_uInt16 nLine ) const;
810 void GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const;
811 sal_uInt16 GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const;
812 sal_uInt16 GetLineHeight( sal_uInt16 nParagraph, sal_uInt16 nLine );
813 sal_uInt32 GetParaHeight( sal_uInt16 nParagraph );
814
815 SfxItemSet GetAttribs( sal_uInt16 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags = 0xFF ) const;
816 SfxItemSet GetAttribs( EditSelection aSel, sal_Bool bOnlyHardAttrib = sal_False );
817 void SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_uInt8 nSpecial = 0 );
818 void RemoveCharAttribs( EditSelection aSel, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich = 0 );
819 void RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich = 0, sal_Bool bRemoveFeatures = sal_False );
820 void SetFlatMode( sal_Bool bFlat );
821
822 void SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet );
823 const SfxItemSet& GetParaAttribs( sal_uInt16 nPara ) const;
824
825 sal_Bool HasParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const;
826 const SfxPoolItem& GetParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const;
827
828 Rectangle PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags = 0 );
829 Rectangle GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex, sal_uInt16 nFlags = 0 );
830
IsModified() const831 sal_Bool IsModified() const { return aEditDoc.IsModified(); }
SetModifyFlag(sal_Bool b)832 void SetModifyFlag( sal_Bool b ) { aEditDoc.SetModified( b ); }
SetModifyHdl(const Link & rLink)833 void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
GetModifyHdl() const834 Link GetModifyHdl() const { return aModifyHdl; }
835
836
IsInSelectionMode()837 sal_Bool IsInSelectionMode() { return bInSelection; }
838 void StopSelectionMode();
839
840 void IndentBlock( EditView* pView, sal_Bool bRight );
841
842 // Fuer Undo/Redo
843 sal_Bool Undo( EditView* pView );
844 sal_Bool Redo( EditView* pView );
845 sal_Bool Repeat( EditView* pView );
846
847 // OV-Special
848 void InvalidateFromParagraph( sal_uInt16 nFirstInvPara );
849 EditPaM InsertParagraph( sal_uInt16 nPara );
850 EditSelection* SelectParagraph( sal_uInt16 nPara );
851
SetStatusEventHdl(const Link & rLink)852 void SetStatusEventHdl( const Link& rLink ) { aStatusHdlLink = rLink; }
GetStatusEventHdl() const853 Link GetStatusEventHdl() const { return aStatusHdlLink; }
854
SetNotifyHdl(const Link & rLink)855 void SetNotifyHdl( const Link& rLink ) { aNotifyHdl = rLink; }
GetNotifyHdl() const856 Link GetNotifyHdl() const { return aNotifyHdl; }
857
858 void FormatAndUpdate( EditView* pCurView = 0 );
859 inline void IdleFormatAndUpdate( EditView* pCurView = 0 );
860
861 svtools::ColorConfig& GetColorConfig();
862 sal_Bool IsVisualCursorTravelingEnabled();
863 sal_Bool DoVisualCursorTraveling( const ContentNode* pNode );
864
865 EditSelection ConvertSelection( sal_uInt16 nStartPara, sal_uInt16 nStartPos, sal_uInt16 nEndPara, sal_uInt16 nEndPos ) const;
866 inline EPaM CreateEPaM( const EditPaM& rPaM );
867 inline EditPaM CreateEditPaM( const EPaM& rEPaM );
868 inline ESelection CreateESel( const EditSelection& rSel );
869 inline EditSelection CreateSel( const ESelection& rSel );
870
871
872 void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
GetStyleSheetPool() const873 SfxStyleSheetPool* GetStyleSheetPool() const { return pStylePool; }
874
875 void SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle );
876 void SetStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pStyle );
877 SfxStyleSheet* GetStyleSheet( sal_uInt16 nPara ) const;
878
879 void UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle );
880 void RemoveStyleFromParagraphs( SfxStyleSheet* pStyle );
881
GetRefDevice() const882 OutputDevice* GetRefDevice() const { return pRefDev; }
883 void SetRefDevice( OutputDevice* pRefDef );
884
GetRefMapMode()885 const MapMode& GetRefMapMode() { return pRefDev->GetMapMode(); }
886 void SetRefMapMode( const MapMode& rMapMode );
887
GetStatus()888 InternalEditStatus& GetStatus() { return aStatus; }
889 void CallStatusHdl();
DelayedCallStatusHdl()890 void DelayedCallStatusHdl() { aStatusTimer.Start(); }
891
892 void CallNotify( EENotify& rNotify );
893 void EnterBlockNotifications();
894 void LeaveBlockNotifications();
895
896
897 EditSelection MatchGroup( const EditSelection& rSel );
898
899 void UndoActionStart( sal_uInt16 nId );
900 void UndoActionStart( sal_uInt16 nId, const ESelection& rSel );
901 void UndoActionEnd( sal_uInt16 nId );
902
GetActiveView() const903 EditView* GetActiveView() const { return pActiveView; }
904 void SetActiveView( EditView* pView );
905
906 ::com::sun::star::uno::Reference<
907 ::com::sun::star::linguistic2::XSpellChecker1 >
908 GetSpeller();
SetSpeller(::com::sun::star::uno::Reference<::com::sun::star::linguistic2::XSpellChecker1> & xSpl)909 void SetSpeller( ::com::sun::star::uno::Reference<
910 ::com::sun::star::linguistic2::XSpellChecker1 > &xSpl )
911 { xSpeller = xSpl; }
912 ::com::sun::star::uno::Reference<
913 ::com::sun::star::linguistic2::XHyphenator >
GetHyphenator() const914 GetHyphenator() const { return xHyphenator; }
SetHyphenator(::com::sun::star::uno::Reference<::com::sun::star::linguistic2::XHyphenator> & xHyph)915 void SetHyphenator( ::com::sun::star::uno::Reference<
916 ::com::sun::star::linguistic2::XHyphenator > &xHyph )
917 { xHyphenator = xHyph; }
GetSpellInfo() const918 SpellInfo* GetSpellInfo() const { return pSpellInfo; }
919
SetDefaultLanguage(LanguageType eLang)920 void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; }
GetDefaultLanguage() const921 LanguageType GetDefaultLanguage() const { return eDefLanguage; }
922
923
924 LanguageType GetLanguage( const EditSelection rSelection ) const;
925 LanguageType GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const;
926 ::com::sun::star::lang::Locale GetLocale( const EditPaM& rPaM ) const;
927
928 void DoOnlineSpelling( ContentNode* pThisNodeOnly = 0, sal_Bool bSpellAtCursorPos = sal_False, sal_Bool bInteruptable = sal_True );
929 EESpellState Spell( EditView* pEditView, sal_Bool bMultipleDoc );
930 EESpellState HasSpellErrors();
931 EESpellState StartThesaurus( EditView* pEditView );
932 ::com::sun::star::uno::Reference<
933 ::com::sun::star::linguistic2::XSpellAlternatives >
934 ImpSpell( EditView* pEditView );
935
936 // text conversion functions
937 void Convert( EditView* pEditView, LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont, sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc );
938 void ImpConvert( rtl::OUString &rConvTxt, LanguageType &rConvTxtLang, EditView* pEditView, LanguageType nSrcLang, const ESelection &rConvRange,
939 sal_Bool bAllowImplicitChangesForNotConvertibleText, LanguageType nTargetLang, const Font *pTargetFont );
GetConvInfo() const940 ConvInfo * GetConvInfo() const { return pConvInfo; }
941 sal_Bool HasConvertibleTextPortion( LanguageType nLang );
942 void SetLanguageAndFont( const ESelection &rESel,
943 LanguageType nLang, sal_uInt16 nLangWhichId,
944 const Font *pFont, sal_uInt16 nFontWhichId );
945
946 // returns true if input sequence checking should be applied
947 sal_Bool IsInputSequenceCheckingRequired( sal_Unicode nChar, const EditSelection& rCurSel ) const;
948
949 //find the next error within the given selection - forward only!
950 ::com::sun::star::uno::Reference<
951 ::com::sun::star::linguistic2::XSpellAlternatives >
952 ImpFindNextError(EditSelection& rSelection);
953 //initialize sentence spelling
954 void StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc);
955 //spell and return a sentence
956 bool SpellSentence(EditView& rView, ::svx::SpellPortions& rToFill, bool bIsGrammarChecking );
957 //put spelling back to start of current sentence - needed after switch of grammar support
958 void PutSpellingToSentenceStart( EditView& rEditView );
959 //applies a changed sentence
960 void ApplyChangedSentence(EditView& rEditView, const ::svx::SpellPortions& rNewPortions, bool bRecheck );
961 //deinitialize sentence spelling
962 void EndSpelling();
963 //adds one or more portions of text to the SpellPortions depending on language changes
964 void AddPortionIterated(
965 EditView& rEditView,
966 const EditSelection rSel,
967 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
968 ::svx::SpellPortions& rToFill);
969 //adds one portion to the SpellPortions
970 void AddPortion(
971 const EditSelection rSel,
972 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
973 ::svx::SpellPortions& rToFill,
974 bool bIsField );
975
976 sal_Bool Search( const SvxSearchItem& rSearchItem, EditView* pView );
977 sal_Bool ImpSearch( const SvxSearchItem& rSearchItem, const EditSelection& rSearchSelection, const EditPaM& rStartPos, EditSelection& rFoundSel );
978 sal_uInt16 StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem );
979 sal_Bool HasText( const SvxSearchItem& rSearchItem );
980
SetEditTextObjectPool(SfxItemPool * pP)981 void SetEditTextObjectPool( SfxItemPool* pP ) { pTextObjectPool = pP; }
GetEditTextObjectPool() const982 SfxItemPool* GetEditTextObjectPool() const { return pTextObjectPool; }
983
984 const SvxNumberFormat * GetNumberFormat( const ContentNode* pNode ) const;
985 sal_Int32 GetSpaceBeforeAndMinLabelWidth( const ContentNode *pNode, sal_Int32 *pnSpaceBefore = 0, sal_Int32 *pnMinLabelWidth = 0 ) const;
986
987 const SvxLRSpaceItem& GetLRSpaceItem( ContentNode* pNode );
988 SvxAdjust GetJustification( sal_uInt16 nPara ) const;
989
990 void SetCharStretching( sal_uInt16 nX, sal_uInt16 nY );
991 inline void GetCharStretching( sal_uInt16& rX, sal_uInt16& rY );
992 void DoStretchChars( sal_uInt16 nX, sal_uInt16 nY );
993
SetBigTextObjectStart(sal_uInt16 nStartAtPortionCount)994 void SetBigTextObjectStart( sal_uInt16 nStartAtPortionCount ) { nBigTextObjectStart = nStartAtPortionCount; }
GetBigTextObjectStart() const995 sal_uInt16 GetBigTextObjectStart() const { return nBigTextObjectStart; }
996
GetEditEnginePtr() const997 inline EditEngine* GetEditEnginePtr() const { return pEditEngine; }
998
StartOnlineSpellTimer()999 void StartOnlineSpellTimer() { aOnlineSpellTimer.Start(); }
StopOnlineSpellTimer()1000 void StopOnlineSpellTimer() { aOnlineSpellTimer.Stop(); }
1001
GetAutoCompleteText() const1002 const XubString& GetAutoCompleteText() const { return aAutoCompleteText; }
1003 void SetAutoCompleteText( const String& rStr, sal_Bool bUpdateTipWindow );
1004
1005 EditSelection TransliterateText( const EditSelection& rSelection, sal_Int32 nTransliterationMode );
1006 short ReplaceTextOnly( ContentNode* pNode, sal_uInt16 nCurrentStart, xub_StrLen nLen, const String& rText, const ::com::sun::star::uno::Sequence< sal_Int32 >& rOffsets );
1007
1008
1009 void SetAsianCompressionMode( sal_uInt16 n );
GetAsianCompressionMode() const1010 sal_uInt16 GetAsianCompressionMode() const { return nAsianCompressionMode; }
1011
1012 void SetKernAsianPunctuation( sal_Bool b );
IsKernAsianPunctuation() const1013 sal_Bool IsKernAsianPunctuation() const { return bKernAsianPunctuation; }
1014
1015 void SetAddExtLeading( sal_Bool b );
IsAddExtLeading() const1016 sal_Bool IsAddExtLeading() const { return bAddExtLeading; }
1017
1018 vos::ORef<SvxForbiddenCharactersTable> GetForbiddenCharsTable( sal_Bool bGetInternal = sal_True ) const;
1019 void SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars );
1020
1021 sal_Bool mbLastTryMerge;
1022
1023 /** sets a link that is called at the beginning of a drag operation at an edit view */
SetBeginDropHdl(const Link & rLink)1024 void SetBeginDropHdl( const Link& rLink ) { maBeginDropHdl = rLink; }
GetBeginDropHdl() const1025 Link GetBeginDropHdl() const { return maBeginDropHdl; }
1026
1027 /** sets a link that is called at the end of a drag operation at an edit view */
SetEndDropHdl(const Link & rLink)1028 void SetEndDropHdl( const Link& rLink ) { maEndDropHdl = rLink; }
GetEndDropHdl() const1029 Link GetEndDropHdl() const { return maEndDropHdl; }
1030
1031 /// specifies if auto-correction should capitalize the first word or not (default is on)
SetFirstWordCapitalization(sal_Bool bCapitalize)1032 void SetFirstWordCapitalization( sal_Bool bCapitalize ) { bFirstWordCapitalization = bCapitalize; }
IsFirstWordCapitalization() const1033 sal_Bool IsFirstWordCapitalization() const { return bFirstWordCapitalization; }
1034 };
1035
CreateEPaM(const EditPaM & rPaM)1036 inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM )
1037 {
1038 ContentNode* pNode = rPaM.GetNode();
1039 return EPaM( aEditDoc.GetPos( pNode ), rPaM.GetIndex() );
1040 }
1041
CreateEditPaM(const EPaM & rEPaM)1042 inline EditPaM ImpEditEngine::CreateEditPaM( const EPaM& rEPaM )
1043 {
1044 DBG_ASSERT( rEPaM.nPara < aEditDoc.Count(), "CreateEditPaM: Ungueltiger Absatz" );
1045 DBG_ASSERT( aEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, "CreateEditPaM: Ungueltiger Index" );
1046 return EditPaM( aEditDoc[ rEPaM.nPara], rEPaM.nIndex );
1047 }
1048
CreateESel(const EditSelection & rSel)1049 inline ESelection ImpEditEngine::CreateESel( const EditSelection& rSel )
1050 {
1051 ContentNode* pStartNode = rSel.Min().GetNode();
1052 ContentNode* pEndNode = rSel.Max().GetNode();
1053 ESelection aESel;
1054 aESel.nStartPara = aEditDoc.GetPos( pStartNode );
1055 aESel.nStartPos = rSel.Min().GetIndex();
1056 aESel.nEndPara = aEditDoc.GetPos( pEndNode );
1057 aESel.nEndPos = rSel.Max().GetIndex();
1058 return aESel;
1059 }
1060
CreateSel(const ESelection & rSel)1061 inline EditSelection ImpEditEngine::CreateSel( const ESelection& rSel )
1062 {
1063 DBG_ASSERT( rSel.nStartPara < aEditDoc.Count(), "CreateSel: Ungueltiger Start-Absatz" );
1064 DBG_ASSERT( rSel.nEndPara < aEditDoc.Count(), "CreateSel: Ungueltiger End-Absatz" );
1065 EditSelection aSel;
1066 aSel.Min().SetNode( aEditDoc[ rSel.nStartPara ] );
1067 aSel.Min().SetIndex( rSel.nStartPos );
1068 aSel.Max().SetNode( aEditDoc[ rSel.nEndPara ] );
1069 aSel.Max().SetIndex( rSel.nEndPos );
1070 DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "CreateSel: Fehlerhafte Selektion!" );
1071 return aSel;
1072 }
1073
GetVirtualDevice(const MapMode & rMapMode,sal_uLong nDrawMode)1074 inline VirtualDevice* ImpEditEngine::GetVirtualDevice( const MapMode& rMapMode, sal_uLong nDrawMode )
1075 {
1076 if ( !pVirtDev )
1077 pVirtDev = new VirtualDevice;
1078
1079 if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) ||
1080 ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) ||
1081 ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) )
1082 {
1083 MapMode aMapMode( rMapMode );
1084 aMapMode.SetOrigin( Point( 0, 0 ) );
1085 pVirtDev->SetMapMode( aMapMode );
1086 }
1087
1088 pVirtDev->SetDrawMode( nDrawMode );
1089
1090 return pVirtDev;
1091 }
1092
EraseVirtualDevice()1093 inline void ImpEditEngine::EraseVirtualDevice()
1094 {
1095 delete pVirtDev;
1096 pVirtDev = 0;
1097 }
1098
IdleFormatAndUpdate(EditView * pCurView)1099 inline void ImpEditEngine::IdleFormatAndUpdate( EditView* pCurView )
1100 {
1101 aIdleFormatter.DoIdleFormat( pCurView );
1102 }
1103
GetUndoManager()1104 inline EditUndoManager& ImpEditEngine::GetUndoManager()
1105 {
1106 if ( !pUndoManager )
1107 {
1108 pUndoManager = new EditUndoManager();
1109 pUndoManager->SetImpEditEngine(this);
1110 }
1111 return *pUndoManager;
1112 }
1113
SetUndoManager(::svl::IUndoManager * pNew)1114 inline ::svl::IUndoManager* ImpEditEngine::SetUndoManager(::svl::IUndoManager* pNew)
1115 {
1116 ::svl::IUndoManager* pRetval = pUndoManager;
1117
1118 if(pUndoManager)
1119 {
1120 pUndoManager->SetImpEditEngine(0);
1121 }
1122
1123 pUndoManager = dynamic_cast< EditUndoManager* >(pNew);
1124
1125 if(pUndoManager)
1126 {
1127 pUndoManager->SetImpEditEngine(this);
1128 }
1129
1130 return pRetval;
1131 }
1132
FindParaPortion(ContentNode * pNode) const1133 inline ParaPortion* ImpEditEngine::FindParaPortion( ContentNode* pNode ) const
1134 {
1135 sal_uInt16 nPos = aEditDoc.GetPos( pNode );
1136 DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" );
1137 return GetParaPortions()[ nPos ];
1138 }
1139
GetCharStretching(sal_uInt16 & rX,sal_uInt16 & rY)1140 inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY )
1141 {
1142 rX = nStretchX;
1143 rY = nStretchY;
1144 }
1145
GetXValue(short nXValue) const1146 inline short ImpEditEngine::GetXValue( short nXValue ) const
1147 {
1148 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1149 return nXValue;
1150
1151 return (short) ((long)nXValue*nStretchX/100);
1152 }
1153
GetXValue(sal_uInt16 nXValue) const1154 inline sal_uInt16 ImpEditEngine::GetXValue( sal_uInt16 nXValue ) const
1155 {
1156 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1157 return nXValue;
1158
1159 return (sal_uInt16) ((long)nXValue*nStretchX/100);
1160 }
1161
GetXValue(long nXValue) const1162 inline long ImpEditEngine::GetXValue( long nXValue ) const
1163 {
1164 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1165 return nXValue;
1166
1167 return nXValue*nStretchX/100;
1168 }
1169
GetYValue(short nYValue) const1170 inline short ImpEditEngine::GetYValue( short nYValue ) const
1171 {
1172 if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
1173 return nYValue;
1174
1175 return (short) ((long)nYValue*nStretchY/100);
1176 }
1177
GetYValue(sal_uInt16 nYValue) const1178 inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const
1179 {
1180 if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
1181 return nYValue;
1182
1183 return (sal_uInt16) ((long)nYValue*nStretchY/100);
1184 }
1185
SetPointer(const Pointer & rPointer)1186 inline void ImpEditView::SetPointer( const Pointer& rPointer )
1187 {
1188 delete pPointer;
1189 pPointer = new Pointer( rPointer );
1190 }
1191
GetPointer()1192 inline const Pointer& ImpEditView::GetPointer()
1193 {
1194 if ( !pPointer )
1195 {
1196 pPointer = new Pointer( IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT );
1197 return *pPointer;
1198 }
1199
1200 if(POINTER_TEXT == pPointer->GetStyle() && IsVertical())
1201 {
1202 delete pPointer;
1203 pPointer = new Pointer(POINTER_TEXT_VERTICAL);
1204 }
1205 else if(POINTER_TEXT_VERTICAL == pPointer->GetStyle() && !IsVertical())
1206 {
1207 delete pPointer;
1208 pPointer = new Pointer(POINTER_TEXT);
1209 }
1210
1211 return *pPointer;
1212 }
1213
SetCursor(const Cursor & rCursor)1214 inline void ImpEditView::SetCursor( const Cursor& rCursor )
1215 {
1216 delete pCursor;
1217 pCursor = new Cursor( rCursor );
1218 }
1219
GetCursor()1220 inline Cursor* ImpEditView::GetCursor()
1221 {
1222 if ( !pCursor )
1223 pCursor = new Cursor;
1224 return pCursor;
1225 }
1226
1227 void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit );
1228 void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const MapUnit* pSourceUnit = NULL, const MapUnit* pDestUnit = NULL );
1229 sal_uInt8 GetCharTypeForCompression( xub_Unicode cChar );
1230 Point Rotate( const Point& rPoint, short nOrientation, const Point& rOrigin );
1231
1232 #endif // _IMPEDIT_HXX
1233
1234
1235