Update ooo320-m1
[ooovba.git] / svx / source / editeng / impedit.hxx
blobe3773fa32df70718343f6f3bc83047b3dab96b51
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: impedit.hxx,v $
10 * $Revision: 1.89.40.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _IMPEDIT_HXX
31 #define _IMPEDIT_HXX
33 #include <editdoc.hxx>
34 #include <editsel.hxx>
35 #include <editundo.hxx>
36 #include <editobj2.hxx>
37 #include <editstt2.hxx>
38 #include <svx/editdata.hxx>
39 #include <svx/svxacorr.hxx>
40 #include <vcl/virdev.hxx>
41 #include <vcl/gdimtf.hxx>
42 #include <vcl/cursor.hxx>
44 #include <vcl/dndhelp.hxx>
45 #include <svtools/ondemand.hxx>
46 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
47 #include <com/sun/star/linguistic2/SpellFailure.hpp>
48 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
49 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
50 #include <com/sun/star/linguistic2/XHyphenator.hpp>
51 #include <com/sun/star/lang/Locale.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/i18n/XBreakIterator.hpp>
54 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
56 #ifndef _COM_SUN_STAR_TEXT_WORDTYPE_HPP_
57 #include <com/sun/star/i18n/WordType.hpp>
58 #endif
60 #ifndef _COM_SUN_STAR_I18N_XEXTENDEDINPUTSEQUENCECHECKER_HDL_
61 #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
62 #endif
64 #include <i18npool/lang.h>
66 #include <vos/ref.hxx>
68 DBG_NAMEEX( EditView )
69 DBG_NAMEEX( EditEngine )
71 #define PIMPEE pImpEditView->pEditEngine->pImpEditEngine
73 #define DEL_LEFT 1
74 #define DEL_RIGHT 2
75 #define TRAVEL_X_DONTKNOW 0xFFFFFFFF
76 #define CURSOR_BIDILEVEL_DONTKNOW 0xFFFF
77 #define MAXCHARSINPARA 0x3FFF-CHARPOSGROW // Max 16K, because WYSIWYG array
79 #define ATTRSPECIAL_WHOLEWORD 1
80 #define ATTRSPECIAL_EDGE 2
82 #define GETCRSR_TXTONLY 0x0001
83 #define GETCRSR_STARTOFLINE 0x0002
84 #define GETCRSR_ENDOFLINE 0x0004
85 #define GETCRSR_PREFERPORTIONSTART 0x0008
87 #define LINE_SEP 0x0A
89 typedef EENotify* EENotifyPtr;
90 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
93 class EditView;
94 class EditEngine;
95 class SvxFontTable;
96 class SvxColorList;
98 class SvxSearchItem;
99 class SvxLRSpaceItem;
100 class TextRanger;
101 class SvKeyValueIterator;
102 class SvxForbiddenCharactersTable;
103 class SvtCTLOptions;
104 class Window;
106 #include <svx/SpellPortions.hxx>
108 #include <svx/eedata.hxx>
110 class SvUShorts;
111 class SvxNumberFormat;
114 namespace com {
115 namespace sun {
116 namespace star {
117 namespace datatransfer {
118 namespace clipboard {
119 class XClipboard;
120 }}}}}
122 namespace svtools {
123 class ColorConfig;
126 struct DragAndDropInfo
128 Rectangle aCurCursor;
129 Rectangle aCurSavedCursor;
130 sal_uInt16 nSensibleRange;
131 sal_uInt16 nCursorWidth;
132 ESelection aBeginDragSel;
133 EditPaM aDropDest;
134 USHORT nOutlinerDropDest;
135 ESelection aDropSel;
136 VirtualDevice* pBackground;
137 const SvxFieldItem* pField;
138 sal_Bool bVisCursor : 1;
139 sal_Bool bDroppedInMe : 1;
140 sal_Bool bStarterOfDD : 1;
141 sal_Bool bHasValidData : 1;
142 sal_Bool bUndoAction : 1;
143 sal_Bool bOutlinerMode : 1;
144 sal_Bool bDragAccepted : 1;
146 DragAndDropInfo()
148 pBackground = NULL; bVisCursor = sal_False; bDroppedInMe = sal_False; bStarterOfDD = sal_False;
149 bHasValidData = sal_False; bUndoAction = sal_False; bOutlinerMode = sal_False;
150 nSensibleRange = 0; nCursorWidth = 0; pField = 0; nOutlinerDropDest = 0; bDragAccepted = sal_False;
154 struct ImplIMEInfos
156 String aOldTextAfterStartPos;
157 sal_uInt16* pAttribs;
158 EditPaM aPos;
159 sal_uInt16 nLen;
160 sal_Bool bCursor;
161 sal_Bool bWasCursorOverwrite;
163 ImplIMEInfos( const EditPaM& rPos, const String& rOldTextAfterStartPos );
164 ~ImplIMEInfos();
166 void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL );
167 void DestroyAttribs();
170 // #i18881# to be able to identify the postions of changed words
171 // the positions of each portion need to be saved
172 typedef std::vector<EditSelection> SpellContentSelections;
174 struct SpellInfo
176 EESpellState eState;
177 EPaM aSpellStart;
178 EPaM aSpellTo;
179 sal_Bool bSpellToEnd;
180 sal_Bool bMultipleDoc;
181 ::svx::SpellPortions aLastSpellPortions;
182 SpellContentSelections aLastSpellContentSelections;
183 SpellInfo()
184 { bSpellToEnd = sal_True; eState = EE_SPELL_OK; bMultipleDoc = sal_False; }
187 // used for text conversion
188 struct ConvInfo
190 EPaM aConvStart;
191 EPaM aConvTo;
192 EPaM aConvContinue; // position to start search for next text portion (word) with
193 sal_Bool bConvToEnd;
194 sal_Bool bMultipleDoc;
196 ConvInfo() { bConvToEnd = sal_True; bMultipleDoc = sal_False; }
199 struct FormatterFontMetric
201 sal_uInt16 nMaxAscent;
202 sal_uInt16 nMaxDescent;
204 FormatterFontMetric() { nMaxAscent = 0; nMaxDescent = 0; /* nMinLeading = 0xFFFF; */ }
205 sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; }
208 class IdleFormattter : public Timer
210 private:
211 EditView* pView;
212 int nRestarts;
214 public:
215 IdleFormattter();
216 ~IdleFormattter();
218 void DoIdleFormat( EditView* pV );
219 void ForceTimeout();
220 void ResetRestarts() { nRestarts = 0; }
221 EditView* GetView() { return pView; }
224 \f// ----------------------------------------------------------------------
225 // class ImpEditView
226 // ----------------------------------------------------------------------
227 class ImpEditView : public vcl::unohelper::DragAndDropClient
229 friend class EditView;
230 friend class EditEngine;
231 friend class ImpEditEngine;
232 using vcl::unohelper::DragAndDropClient::dragEnter;
233 using vcl::unohelper::DragAndDropClient::dragExit;
234 using vcl::unohelper::DragAndDropClient::dragOver;
236 private:
237 EditView* pEditView;
238 Cursor* pCursor;
239 Color* pBackgroundColor;
240 EditEngine* pEditEngine;
241 Window* pOutWin;
242 Pointer* pPointer;
243 DragAndDropInfo* pDragAndDropInfo;
245 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener > mxDnDListener;
248 long nInvMore;
249 ULONG nControl;
250 sal_uInt32 nTravelXPos;
251 sal_uInt16 nExtraCursorFlags;
252 sal_uInt16 nCursorBidiLevel;
253 sal_uInt16 nScrollDiffX;
254 sal_Bool bReadOnly;
255 sal_Bool bClickedInSelection;
256 sal_Bool bActiveDragAndDropListener;
258 Point aAnchorPoint;
259 Rectangle aOutArea;
260 Point aVisDocStartPos;
261 EESelectionMode eSelectionMode;
262 EditSelection aEditSelection;
263 EVAnchorMode eAnchorMode;
265 protected:
267 // DragAndDropClient
268 void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException);
269 void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException);
270 void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
271 void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException);
272 void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException);
273 void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
275 void ShowDDCursor( const Rectangle& rRect );
276 void HideDDCursor();
278 void ImplDrawHighlightRect( Window* pOutWin, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, PolyPolygon* pPolyPoly );
280 public:
281 ImpEditView( EditView* pView, EditEngine* pEng, Window* pWindow );
282 ~ImpEditView();
284 EditView* GetEditViewPtr() { return pEditView; }
286 sal_uInt16 GetScrollDiffX() const { return nScrollDiffX; }
287 void SetScrollDiffX( sal_uInt16 n ) { nScrollDiffX = n; }
289 sal_uInt16 GetCursorBidiLevel() const { return nCursorBidiLevel; }
290 void SetCursorBidiLevel( sal_uInt16 n ) { nCursorBidiLevel = n; }
292 Point GetDocPos( const Point& rWindowPos ) const;
293 Point GetWindowPos( const Point& rDocPos ) const;
294 Rectangle GetWindowPos( const Rectangle& rDocPos ) const;
296 void SetOutputArea( const Rectangle& rRec );
297 void ResetOutputArea( const Rectangle& rRec );
298 const Rectangle& GetOutputArea() const { return aOutArea; }
300 BOOL IsVertical() const;
302 BOOL PostKeyEvent( const KeyEvent& rKeyEvent, Window* pFrameWin = NULL );
304 BOOL MouseButtonUp( const MouseEvent& rMouseEvent );
305 BOOL MouseButtonDown( const MouseEvent& rMouseEvent );
306 BOOL MouseMove( const MouseEvent& rMouseEvent );
307 void Command( const CommandEvent& rCEvt );
309 void CutCopy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bCut );
310 void Paste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bUseSpecial = sal_False );
312 void SetVisDocStartPos( const Point& rPos ) { aVisDocStartPos = rPos; }
313 const Point& GetVisDocStartPos() const { return aVisDocStartPos; }
315 long GetVisDocLeft() const { return aVisDocStartPos.X(); }
316 long GetVisDocTop() const { return aVisDocStartPos.Y(); }
317 long GetVisDocRight() const { return aVisDocStartPos.X() + ( !IsVertical() ? aOutArea.GetWidth() : aOutArea.GetHeight() ); }
318 long GetVisDocBottom() const { return aVisDocStartPos.Y() + ( !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth() ); }
319 Rectangle GetVisDocArea() const;
321 EditSelection& GetEditSelection() { return aEditSelection; }
322 void SetEditSelection( const EditSelection& rEditSelection );
323 sal_Bool HasSelection() const { return aEditSelection.HasRange(); }
325 void DrawSelection() { DrawSelection( aEditSelection ); }
326 void DrawSelection( EditSelection, Region* pRegion = NULL );
327 Region* CalcSelectedRegion();
329 Window* GetWindow() const { return pOutWin; }
331 EESelectionMode GetSelectionMode() const { return eSelectionMode; }
332 void SetSelectionMode( EESelectionMode eMode );
334 inline void SetPointer( const Pointer& rPointer );
335 inline const Pointer& GetPointer();
337 inline void SetCursor( const Cursor& rCursor );
338 inline Cursor* GetCursor();
340 void AddDragAndDropListeners();
341 void RemoveDragAndDropListeners();
343 BOOL IsBulletArea( const Point& rPos, sal_uInt16* pPara );
345 // Fuer die SelectionEngine...
346 void CreateAnchor();
347 void DeselectAll();
348 sal_Bool SetCursorAtPoint( const Point& rPointPixel );
349 sal_Bool IsSelectionAtPoint( const Point& rPosPixel );
350 sal_Bool IsInSelection( const EditPaM& rPaM );
353 void SetAnchorMode( EVAnchorMode eMode );
354 EVAnchorMode GetAnchorMode() const { return eAnchorMode; }
355 void CalcAnchorPoint();
356 void RecalcOutputArea();
358 void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, BOOL test );
359 void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, USHORT nShowCursorFlags = 0 );
360 Pair Scroll( long ndX, long ndY, BYTE nRangeCheck = RGCHK_NEG );
362 void SetInsertMode( sal_Bool bInsert );
363 sal_Bool IsInsertMode() const { return ( ( nControl & EV_CNTRL_OVERWRITE ) == 0 ); }
365 void EnablePaste( sal_Bool bEnable ) { SetFlags( nControl, EV_CNTRL_ENABLEPASTE, bEnable ); }
366 sal_Bool IsPasteEnabled() const { return ( ( nControl & EV_CNTRL_ENABLEPASTE ) != 0 ); }
368 sal_Bool DoSingleLinePaste() const { return ( ( nControl & EV_CNTRL_SINGLELINEPASTE ) != 0 ); }
369 sal_Bool DoAutoScroll() const { return ( ( nControl & EV_CNTRL_AUTOSCROLL ) != 0 ); }
370 sal_Bool DoBigScroll() const { return ( ( nControl & EV_CNTRL_BIGSCROLL ) != 0 ); }
371 sal_Bool DoAutoSize() const { return ( ( nControl & EV_CNTRL_AUTOSIZE ) != 0 ); }
372 sal_Bool DoAutoWidth() const { return ( ( nControl & EV_CNTRL_AUTOSIZEX) != 0 ); }
373 sal_Bool DoAutoHeight() const { return ( ( nControl & EV_CNTRL_AUTOSIZEY) != 0 ); }
374 sal_Bool DoInvalidateMore() const { return ( ( nControl & EV_CNTRL_INVONEMORE ) != 0 ); }
376 void SetBackgroundColor( const Color& rColor );
377 const Color& GetBackgroundColor() const {
378 return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); }
380 sal_Bool IsWrongSpelledWord( const EditPaM& rPaM, sal_Bool bMarkIfWrong );
381 String SpellIgnoreOrAddWord( sal_Bool bAdd );
383 const SvxFieldItem* GetField( const Point& rPos, sal_uInt16* pPara, sal_uInt16* pPos ) const;
384 void DeleteSelected();
386 // Ggf. mehr als OutputArea invalidieren, fuer den DrawingEngine-Textrahmen...
387 void SetInvalidateMore( sal_uInt16 nPixel ) { nInvMore = nPixel; }
388 sal_uInt16 GetInvalidateMore() const { return (sal_uInt16)nInvMore; }
391 // ----------------------------------------------------------------------
392 // ImpEditEngine
393 // ----------------------------------------------------------------------
395 typedef EditView* EditViewPtr;
396 SV_DECL_PTRARR( EditViews, EditViewPtr, 0, 1 )
398 class ImpEditEngine : public SfxListener
400 // Die Undos muessen direkt manipulieren ( private-Methoden ),
401 // damit keine neues Undos eingefuegt werden!
402 friend class EditUndoInsertChars;
403 friend class EditUndoRemoveChars;
404 friend class EditUndoDelContent;
405 friend class EditUndoConnectParas;
406 friend class EditUndoSplitPara;
407 friend class EditUndoInsertFeature;
408 friend class EditUndoMoveParagraphs;
410 friend class EditView;
411 friend class ImpEditView;
412 friend class EditEngine; // Fuer Zugriff auf Imp-Methoden
413 friend class EditRTFParser; // Fuer Zugriff auf Imp-Methoden
414 friend class EditHTMLParser; // Fuer Zugriff auf Imp-Methoden
415 friend class EdtAutoCorrDoc; // Fuer Zugriff auf Imp-Methoden
416 friend class EditDbg; // DebugRoutinen
418 private:
420 // ================================================================
421 // Daten...
422 // ================================================================
424 // Dokument-Spezifische Daten...
425 ParaPortionList aParaPortionList; // Formatierung
426 Size aPaperSize; // Layout
427 Size aMinAutoPaperSize; // Layout ?
428 Size aMaxAutoPaperSize; // Layout ?
429 EditDoc aEditDoc; // Dokumenteninhalt
431 // Engine-Spezifische Daten....
432 EditEngine* pEditEngine;
433 EditViews aEditViews;
434 EditView* pActiveView;
435 TextRanger* pTextRanger;
437 SfxStyleSheetPool* pStylePool;
438 SfxItemPool* pTextObjectPool;
440 VirtualDevice* pVirtDev;
441 OutputDevice* pRefDev;
443 svtools::ColorConfig* pColorConfig;
444 mutable SvtCTLOptions* pCTLOptions;
446 SfxItemSet* pEmptyItemSet;
447 EditUndoManager* pUndoManager;
448 ESelection* pUndoMarkSelection;
450 ImplIMEInfos* mpIMEInfos;
452 NotifyList aNotifyCache;
454 XubString aWordDelimiters;
455 XubString aGroupChars;
457 EditSelFunctionSet aSelFuncSet;
458 EditSelectionEngine aSelEngine;
460 Color maBackgroundColor;
462 sal_uInt32 nBlockNotifications;
463 sal_uInt16 nStretchX;
464 sal_uInt16 nStretchY;
466 USHORT nAsianCompressionMode;
467 BOOL bKernAsianPunctuation;
468 BOOL bAddExtLeading;
470 EEHorizontalTextDirection eDefaultHorizontalTextDirection;
472 sal_uInt16 nBigTextObjectStart;
473 ::com::sun::star::uno::Reference<
474 ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
475 ::com::sun::star::uno::Reference<
476 ::com::sun::star::linguistic2::XHyphenator > xHyphenator;
477 SpellInfo* pSpellInfo;
478 mutable ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > xBI;
479 mutable ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > xISC;
481 ConvInfo * pConvInfo;
483 XubString aAutoCompleteText;
485 InternalEditStatus aStatus;
487 LanguageType eDefLanguage;
489 OnDemandLocaleDataWrapper xLocaleDataWrapper;
490 OnDemandTransliterationWrapper xTransliterationWrapper;
492 sal_Bool bIsFormatting;
493 sal_Bool bFormatted;
494 sal_Bool bInSelection;
495 sal_Bool bIsInUndo;
496 sal_Bool bUpdate;
497 sal_Bool bUndoEnabled;
498 sal_Bool bOwnerOfRefDev;
499 sal_Bool bDowning;
500 sal_Bool bUseAutoColor;
501 sal_Bool bForceAutoColor;
502 sal_Bool bCallParaInsertedOrDeleted;
503 sal_Bool bImpConvertFirstCall; // specifies if ImpConvert is called the very first time after Convert was called
504 sal_Bool bFirstWordCapitalization; // specifies if auto-correction should capitalize the first word or not
506 // Fuer Formatierung / Update....
507 DeletedNodesList aDeletedNodes;
508 Rectangle aInvalidRec;
509 sal_uInt32 nCurTextHeight;
510 sal_uInt16 nOnePixelInRef;
512 IdleFormattter aIdleFormatter;
514 Timer aOnlineSpellTimer;
516 // Wenn an einer Stelle erkannt wird, dass der StatusHdl gerufen werden
517 // muss, dies aber nicht sofort geschehen darf (kritischer Abschnitt):
518 Timer aStatusTimer;
519 Link aStatusHdlLink;
520 Link aNotifyHdl;
521 Link aImportHdl;
522 Link aBeginMovingParagraphsHdl;
523 Link aEndMovingParagraphsHdl;
524 Link aBeginPasteOrDropHdl;
525 Link aEndPasteOrDropHdl;
526 Link aModifyHdl;
527 Link maBeginDropHdl;
528 Link maEndDropHdl;
530 vos::ORef<SvxForbiddenCharactersTable> xForbiddenCharsTable;
533 // ================================================================
534 // Methoden...
535 // ================================================================
537 void CursorMoved( ContentNode* pPrevNode );
538 void ParaAttribsChanged( ContentNode* pNode );
539 void TextModified();
540 void CalcHeight( ParaPortion* pPortion );
542 // ggf. lieber inline, aber so einiges...
543 void InsertUndo( EditUndo* pUndo, sal_Bool bTryMerge = sal_False );
544 void ResetUndoManager();
545 sal_Bool HasUndoManager() const { return pUndoManager ? sal_True : sal_False; }
547 EditUndoSetAttribs* CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet );
549 EditPaM GetPaM( Point aDocPos, sal_Bool bSmart = sal_True );
550 EditPaM GetPaM( ParaPortion* pPortion, Point aPos, sal_Bool bSmart = sal_True );
551 long GetXPos( ParaPortion* pParaPortion, EditLine* pLine, USHORT nIndex, BOOL bPreferPortionStart = FALSE );
552 long GetPortionXOffset( ParaPortion* pParaPortion, EditLine* pLine, USHORT nTextPortion );
553 USHORT GetChar( ParaPortion* pParaPortion, EditLine* pLine, long nX, BOOL bSmart = TRUE );
554 Range GetInvalidYOffsets( ParaPortion* pPortion );
555 Range GetLineXPosStartEnd( ParaPortion* pParaPortion, EditLine* pLine );
557 void SetParaAttrib( BYTE nFunc, EditSelection aSel, sal_uInt16 nValue );
558 sal_uInt16 GetParaAttrib( BYTE nFunc, EditSelection aSel );
559 void SetCharAttrib( EditSelection aSel, const SfxPoolItem& rItem );
560 void ParaAttribsToCharAttribs( ContentNode* pNode );
561 void GetCharAttribs( sal_uInt16 nPara, EECharAttribArray& rLst ) const;
563 EditTextObject* CreateBinTextObject( EditSelection aSelection, SfxItemPool*, sal_Bool bAllowBigObjects = sal_False, sal_uInt16 nBigObjStart = 0 ) const;
564 void StoreBinTextObject( SvStream& rOStream, BinTextObject& rTextObject );
565 EditSelection InsertBinTextObject( BinTextObject&, EditPaM aPaM );
566 EditSelection InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxDataObj, const String& rBaseURL, const EditPaM& rPaM, BOOL bUseSpecial );
568 EditPaM Clear();
569 EditPaM RemoveText();
570 EditPaM RemoveText( EditSelection aEditSelection );
571 sal_Bool CreateLines( USHORT nPara, sal_uInt32 nStartPosY );
572 void CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uInt32 nStartPosY );
573 sal_Bool FinishCreateLines( ParaPortion* pParaPortion );
574 void CalcCharPositions( ParaPortion* pParaPortion );
575 void CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStartPos /*, sal_Bool bCreateBlockPortions */ );
576 void RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars );
577 sal_uInt16 SplitTextPortion( ParaPortion* pParaPortion, sal_uInt16 nPos, EditLine* pCurLine = 0 );
578 void SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0 );
579 void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont );
580 void CheckAutoPageSize();
582 void ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate );
583 void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace );
584 EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, sal_Bool bBackward = sal_False );
585 EditPaM ImpDeleteSelection( EditSelection aEditSelection);
586 EditPaM ImpInsertParaBreak( const EditPaM& rPaM, sal_Bool bKeepEndingAttribs = sal_True );
587 EditPaM ImpInsertParaBreak( const EditSelection& rEditSelection, sal_Bool bKeepEndingAttribs = sal_True );
588 EditPaM ImpInsertText( EditSelection aCurEditSelection, const String& rStr );
589 EditPaM ImpInsertFeature( EditSelection aEditSelection, const SfxPoolItem& rItem );
590 void ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, EditUndoRemoveChars* pCurUndo = 0 );
591 void ImpRemoveParagraph( sal_uInt16 nPara );
592 EditSelection ImpMoveParagraphs( Range aParagraphs, sal_uInt16 nNewPos );
594 EditPaM ImpFastInsertText( EditPaM aPaM, const String& rStr );
595 EditPaM ImpFastInsertParagraph( sal_uInt16 nPara );
597 sal_Bool ImpCheckRefMapMode();
599 BOOL ImplHasText() const;
601 void ImpFindKashidas( ContentNode* pNode, USHORT nStart, USHORT nEnd, SvUShorts& rArray );
603 void InsertContent( ContentNode* pNode, sal_uInt16 nPos );
604 EditPaM SplitContent( sal_uInt16 nNode, sal_uInt16 nSepPos );
605 EditPaM ConnectContents( sal_uInt16 nLeftNode, sal_Bool bBackward );
607 void ShowParagraph( sal_uInt16 nParagraph, sal_Bool bShow );
608 sal_Bool IsParagraphVisible( sal_uInt16 nParagraph );
610 EditPaM PageUp( const EditPaM& rPaM, EditView* pView);
611 EditPaM PageDown( const EditPaM& rPaM, EditView* pView);
612 EditPaM CursorUp( const EditPaM& rPaM, EditView* pEditView );
613 EditPaM CursorDown( const EditPaM& rPaM, EditView* pEditView );
614 EditPaM CursorLeft( const EditPaM& rPaM, USHORT nCharacterIteratorMode = ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
615 EditPaM CursorRight( const EditPaM& rPaM, USHORT nCharacterIteratorMode = ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
616 EditPaM CursorStartOfLine( const EditPaM& rPaM );
617 EditPaM CursorEndOfLine( const EditPaM& rPaM );
618 EditPaM CursorStartOfParagraph( const EditPaM& rPaM );
619 EditPaM CursorEndOfParagraph( const EditPaM& rPaM );
620 EditPaM CursorStartOfDoc();
621 EditPaM CursorEndOfDoc();
622 EditPaM WordLeft( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
623 EditPaM WordRight( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
624 EditPaM StartOfWord( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
625 EditPaM EndOfWord( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
626 EditSelection SelectWord( const EditSelection& rCurSelection, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, BOOL bAcceptStartOfWord = TRUE );
627 EditSelection SelectSentence( const EditSelection& rCurSel );
628 EditPaM CursorVisualLeftRight( EditView* pEditView, const EditPaM& rPaM, USHORT nCharacterIteratorMode, BOOL bToLeft );
629 EditPaM CursorVisualStartEnd( EditView* pEditView, const EditPaM& rPaM, BOOL bStart );
632 void InitScriptTypes( USHORT nPara );
633 USHORT GetScriptType( const EditPaM& rPaM, USHORT* pEndPos = NULL ) const;
634 USHORT GetScriptType( const EditSelection& rSel ) const;
635 BOOL IsScriptChange( const EditPaM& rPaM ) const;
636 BOOL HasScriptType( USHORT nPara, USHORT nType ) const;
638 BOOL ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, USHORT nStartPos, sal_Int32* pDXArray, USHORT n100thPercentFromMax, BOOL bManipulateDXArray );
639 void ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, long nRemainingWidth );
641 void ImplInitLayoutMode( OutputDevice* pOutDev, USHORT nPara, USHORT nIndex );
642 void ImplInitDigitMode( OutputDevice* pOutDev, String* pString, xub_StrLen nStt, xub_StrLen nLen, LanguageType eLang );
644 EditPaM ReadText( SvStream& rInput, EditSelection aSel );
645 EditPaM ReadRTF( SvStream& rInput, EditSelection aSel );
646 EditPaM ReadXML( SvStream& rInput, EditSelection aSel );
647 EditPaM ReadHTML( SvStream& rInput, const String& rBaseURL, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs );
648 EditPaM ReadBin( SvStream& rInput, EditSelection aSel );
649 sal_uInt32 WriteText( SvStream& rOutput, EditSelection aSel );
650 sal_uInt32 WriteRTF( SvStream& rOutput, EditSelection aSel );
651 sal_uInt32 WriteXML( SvStream& rOutput, EditSelection aSel );
652 sal_uInt32 WriteHTML( SvStream& rOutput, EditSelection aSel );
653 sal_uInt32 WriteBin( SvStream& rOutput, EditSelection aSel, BOOL bStoreUnicode = FALSE ) const;
655 void WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos,
656 SvxFontTable& rFontTable, SvxColorList& rColorList );
657 sal_Bool WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos,
658 SvxFontTable& rFontTable, SvxColorList& rColorList );
659 long LogicToTwips( long n );
661 inline short GetXValue( short nXValue ) const;
662 inline sal_uInt16 GetXValue( sal_uInt16 nXValue ) const;
663 inline long GetXValue( long nXValue ) const;
665 inline short GetYValue( short nYValue ) const;
666 inline sal_uInt16 GetYValue( sal_uInt16 nYValue ) const;
668 ContentNode* GetPrevVisNode( ContentNode* pCurNode );
669 ContentNode* GetNextVisNode( ContentNode* pCurNode );
671 ParaPortion* GetPrevVisPortion( ParaPortion* pCurPortion );
672 ParaPortion* GetNextVisPortion( ParaPortion* pCurPortion );
674 void SetBackgroundColor( const Color& rColor ) { maBackgroundColor = rColor; }
675 Color GetBackgroundColor() const { return maBackgroundColor; }
677 Color GetAutoColor() const;
678 void EnableAutoColor( BOOL b ) { bUseAutoColor = b; }
679 BOOL IsAutoColorEnabled() const { return bUseAutoColor; }
680 void ForceAutoColor( BOOL b ) { bForceAutoColor = b; }
681 BOOL IsForceAutoColor() const { return bForceAutoColor; }
683 inline VirtualDevice* GetVirtualDevice( const MapMode& rMapMode, ULONG nDrawMode );
684 inline void EraseVirtualDevice();
686 DECL_LINK( StatusTimerHdl, Timer * );
687 DECL_LINK( IdleFormatHdl, Timer * );
688 DECL_LINK( OnlineSpellHdl, Timer * );
689 DECL_LINK( DocModified, void* );
691 void CheckIdleFormatter();
693 inline ParaPortion* FindParaPortion( ContentNode* pNode ) const;
695 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > CreateTransferable( const EditSelection& rSelection ) const;
697 void SetValidPaperSize( const Size& rSz );
699 ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const;
700 ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker() const;
702 /** Decorate metafile output with verbose text comments
704 This method is used to wrap SvxFont::QuickDrawText, to
705 determine character-by-character wise, which logical text
706 units like characters, words and sentences are contained in
707 the output string at hand. This is necessary for slideshow
708 text effects.
710 void ImplFillTextMarkingVector(const ::com::sun::star::lang::Locale& rLocale, EEngineData::TextMarkingVector& rTextMarkingVector, const String& rTxt, const USHORT nIdx, const USHORT nLen) const;
712 protected:
713 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
715 public:
716 ImpEditEngine( EditEngine* pEditEngine, SfxItemPool* pPool );
717 ~ImpEditEngine();
719 void InitDoc( BOOL bKeepParaAttribs );
720 EditDoc& GetEditDoc() { return aEditDoc; }
721 const EditDoc& GetEditDoc() const { return aEditDoc; }
723 inline EditUndoManager& GetUndoManager();
725 void SetUpdateMode( sal_Bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False );
726 sal_Bool GetUpdateMode() const { return bUpdate; }
728 const ParaPortionList& GetParaPortions() const { return aParaPortionList; }
729 ParaPortionList& GetParaPortions() { return aParaPortionList; }
730 EditViews& GetEditViews() { return aEditViews; }
732 const Size& GetPaperSize() const { return aPaperSize; }
733 void SetPaperSize( const Size& rSz ) { aPaperSize = rSz; }
735 void SetVertical( BOOL bVertical );
736 BOOL IsVertical() const { return GetEditDoc().IsVertical(); }
738 void SetFixedCellHeight( BOOL bUseFixedCellHeight );
739 BOOL IsFixedCellHeight() const { return GetEditDoc().IsFixedCellHeight(); }
741 void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir ) { eDefaultHorizontalTextDirection = eHTextDir; }
742 EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const { return eDefaultHorizontalTextDirection; }
745 void InitWritingDirections( USHORT nPara );
746 BOOL IsRightToLeft( USHORT nPara ) const;
747 BYTE GetRightToLeft( USHORT nPara, USHORT nChar, USHORT* pStart = NULL, USHORT* pEnd = NULL );
748 BOOL HasDifferentRTLLevels( const ContentNode* pNode );
750 void SetTextRanger( TextRanger* pRanger );
751 TextRanger* GetTextRanger() const { return pTextRanger; }
753 const Size& GetMinAutoPaperSize() const { return aMinAutoPaperSize; }
754 void SetMinAutoPaperSize( const Size& rSz ) { aMinAutoPaperSize = rSz; }
756 const Size& GetMaxAutoPaperSize() const { return aMaxAutoPaperSize; }
757 void SetMaxAutoPaperSize( const Size& rSz ) { aMaxAutoPaperSize = rSz; }
759 void FormatDoc();
760 void FormatFullDoc();
761 void UpdateViews( EditView* pCurView = 0 );
762 void Paint( ImpEditView* pView, const Rectangle& rRect, sal_Bool bUseVirtDev = sal_False );
763 void Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly = sal_False, short nOrientation = 0 );
765 sal_Bool MouseButtonUp( const MouseEvent& rMouseEvent, EditView* pView );
766 sal_Bool MouseButtonDown( const MouseEvent& rMouseEvent, EditView* pView );
767 sal_Bool MouseMove( const MouseEvent& rMouseEvent, EditView* pView );
768 void Command( const CommandEvent& rCEvt, EditView* pView );
770 EditSelectionEngine& GetSelEngine() { return aSelEngine; }
771 XubString GetSelected( const EditSelection& rSel, const LineEnd eParaSep = LINEEND_LF ) const;
773 const SfxItemSet& GetEmptyItemSet();
775 void UpdateSelections();
777 void EnableUndo( sal_Bool bEnable );
778 sal_Bool IsUndoEnabled() { return bUndoEnabled; }
779 void SetUndoMode( sal_Bool b ) { bIsInUndo = b; }
780 sal_Bool IsInUndo() { return bIsInUndo; }
782 void SetCallParaInsertedOrDeleted( sal_Bool b ) { bCallParaInsertedOrDeleted = b; }
783 sal_Bool IsCallParaInsertedOrDeleted() const { return bCallParaInsertedOrDeleted; }
785 sal_Bool IsFormatted() const { return bFormatted; }
786 sal_Bool IsFormatting() const { return bIsFormatting; }
788 void SetText( const String& rText );
789 EditPaM DeleteSelected( EditSelection aEditSelection);
790 EditPaM InsertText( const EditSelection& rCurEditSelection, sal_Unicode c, sal_Bool bOverwrite, sal_Bool bIsUserInput = sal_False );
791 EditPaM InsertText( EditSelection aCurEditSelection, const String& rStr );
792 EditPaM AutoCorrect( const EditSelection& rCurEditSelection, sal_Unicode c, bool bOverwrite, Window* pFrameWin = NULL );
793 EditPaM DeleteLeftOrRight( const EditSelection& rEditSelection, BYTE nMode, BYTE nDelMode = DELMODE_SIMPLE );
794 EditPaM InsertParaBreak( EditSelection aEditSelection );
795 EditPaM InsertLineBreak( EditSelection aEditSelection );
796 EditPaM InsertTab( EditSelection aEditSelection );
797 EditPaM InsertField( EditSelection aEditSelection, const SvxFieldItem& rFld );
798 sal_Bool UpdateFields();
800 EditPaM Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
801 void Write( SvStream& rOutput, EETextFormat eFormat, EditSelection aSel );
803 EditTextObject* CreateTextObject();
804 EditTextObject* CreateTextObject( EditSelection aSel );
805 void SetText( const EditTextObject& rTextObject );
806 EditSelection InsertText( const EditTextObject& rTextObject, EditSelection aSel );
808 EditSelection MoveCursor( const KeyEvent& rKeyEvent, EditView* pEditView );
810 EditSelection MoveParagraphs( Range aParagraphs, sal_uInt16 nNewPos, EditView* pCurView );
812 sal_uInt32 CalcTextHeight();
813 sal_uInt32 GetTextHeight() const;
814 sal_uInt32 CalcTextWidth( BOOL bIgnoreExtraSpace );
815 sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, BOOL bIgnoreExtraSpace );
816 sal_uInt16 GetLineCount( sal_uInt16 nParagraph ) const;
817 sal_uInt16 GetLineLen( sal_uInt16 nParagraph, sal_uInt16 nLine ) const;
818 void GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nParagraph, USHORT nLine ) const;
819 USHORT GetLineNumberAtIndex( USHORT nPara, USHORT nIndex ) const;
820 sal_uInt16 GetLineHeight( sal_uInt16 nParagraph, sal_uInt16 nLine );
821 sal_uInt32 GetParaHeight( sal_uInt16 nParagraph );
823 SfxItemSet GetAttribs( USHORT nPara, USHORT nStart, USHORT nEnd, sal_uInt8 nFlags = 0xFF ) const;
824 SfxItemSet GetAttribs( EditSelection aSel, BOOL bOnlyHardAttrib = FALSE );
825 void SetAttribs( EditSelection aSel, const SfxItemSet& rSet, BYTE nSpecial = 0 );
826 void RemoveCharAttribs( EditSelection aSel, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich = 0 );
827 void RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich = 0, sal_Bool bRemoveFeatures = sal_False );
828 void SetFlatMode( sal_Bool bFlat );
830 void SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet );
831 const SfxItemSet& GetParaAttribs( sal_uInt16 nPara ) const;
833 sal_Bool HasParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const;
834 const SfxPoolItem& GetParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const;
836 Rectangle PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags = 0 );
837 Rectangle GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex, sal_uInt16 nFlags = 0 );
839 sal_Bool IsModified() const { return aEditDoc.IsModified(); }
840 void SetModifyFlag( sal_Bool b ) { aEditDoc.SetModified( b ); }
841 void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
842 Link GetModifyHdl() const { return aModifyHdl; }
845 sal_Bool IsInSelectionMode() { return bInSelection; }
846 void StopSelectionMode();
848 void IndentBlock( EditView* pView, sal_Bool bRight );
850 // Fuer Undo/Redo
851 sal_Bool Undo( EditView* pView );
852 sal_Bool Redo( EditView* pView );
853 sal_Bool Repeat( EditView* pView );
855 // OV-Special
856 void InvalidateFromParagraph( sal_uInt16 nFirstInvPara );
857 EditPaM InsertParagraph( sal_uInt16 nPara );
858 EditSelection* SelectParagraph( sal_uInt16 nPara );
860 void SetStatusEventHdl( const Link& rLink ) { aStatusHdlLink = rLink; }
861 Link GetStatusEventHdl() const { return aStatusHdlLink; }
863 void SetNotifyHdl( const Link& rLink ) { aNotifyHdl = rLink; }
864 Link GetNotifyHdl() const { return aNotifyHdl; }
866 void FormatAndUpdate( EditView* pCurView = 0 );
867 inline void IdleFormatAndUpdate( EditView* pCurView = 0 );
869 svtools::ColorConfig& GetColorConfig();
870 BOOL IsVisualCursorTravelingEnabled();
871 BOOL DoVisualCursorTraveling( const ContentNode* pNode );
873 EditSelection ConvertSelection( sal_uInt16 nStartPara, sal_uInt16 nStartPos, sal_uInt16 nEndPara, sal_uInt16 nEndPos ) const;
874 inline EPaM CreateEPaM( const EditPaM& rPaM );
875 inline EditPaM CreateEditPaM( const EPaM& rEPaM );
876 inline ESelection CreateESel( const EditSelection& rSel );
877 inline EditSelection CreateSel( const ESelection& rSel );
880 void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
881 SfxStyleSheetPool* GetStyleSheetPool() const { return pStylePool; }
883 void SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle );
884 void SetStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pStyle );
885 SfxStyleSheet* GetStyleSheet( sal_uInt16 nPara ) const;
887 void UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle );
888 void RemoveStyleFromParagraphs( SfxStyleSheet* pStyle );
890 OutputDevice* GetRefDevice() const { return pRefDev; }
891 void SetRefDevice( OutputDevice* pRefDef );
893 const MapMode& GetRefMapMode() { return pRefDev->GetMapMode(); }
894 void SetRefMapMode( const MapMode& rMapMode );
896 InternalEditStatus& GetStatus() { return aStatus; }
897 void CallStatusHdl();
898 void DelayedCallStatusHdl() { aStatusTimer.Start(); }
900 void CallNotify( EENotify& rNotify );
901 void EnterBlockNotifications();
902 void LeaveBlockNotifications();
905 EditSelection MatchGroup( const EditSelection& rSel );
907 void UndoActionStart( sal_uInt16 nId );
908 void UndoActionStart( sal_uInt16 nId, const ESelection& rSel );
909 void UndoActionEnd( sal_uInt16 nId );
911 EditView* GetActiveView() const { return pActiveView; }
912 void SetActiveView( EditView* pView );
914 ::com::sun::star::uno::Reference<
915 ::com::sun::star::linguistic2::XSpellChecker1 >
916 GetSpeller();
917 void SetSpeller( ::com::sun::star::uno::Reference<
918 ::com::sun::star::linguistic2::XSpellChecker1 > &xSpl )
919 { xSpeller = xSpl; }
920 ::com::sun::star::uno::Reference<
921 ::com::sun::star::linguistic2::XHyphenator >
922 GetHyphenator() const { return xHyphenator; }
923 void SetHyphenator( ::com::sun::star::uno::Reference<
924 ::com::sun::star::linguistic2::XHyphenator > &xHyph )
925 { xHyphenator = xHyph; }
926 SpellInfo* GetSpellInfo() const { return pSpellInfo; }
928 void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; }
929 LanguageType GetDefaultLanguage() const { return eDefLanguage; }
932 LanguageType GetLanguage( const EditSelection rSelection ) const;
933 LanguageType GetLanguage( const EditPaM& rPaM, USHORT* pEndPos = NULL ) const;
934 ::com::sun::star::lang::Locale GetLocale( const EditPaM& rPaM ) const;
936 void DoOnlineSpelling( ContentNode* pThisNodeOnly = 0, sal_Bool bSpellAtCursorPos = sal_False, sal_Bool bInteruptable = sal_True );
937 EESpellState Spell( EditView* pEditView, sal_Bool bMultipleDoc );
938 EESpellState HasSpellErrors();
939 EESpellState StartThesaurus( EditView* pEditView );
940 ::com::sun::star::uno::Reference<
941 ::com::sun::star::linguistic2::XSpellAlternatives >
942 ImpSpell( EditView* pEditView );
944 // text conversion functions
945 void Convert( EditView* pEditView, LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont, INT32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc );
946 void ImpConvert( rtl::OUString &rConvTxt, LanguageType &rConvTxtLang, EditView* pEditView, LanguageType nSrcLang, const ESelection &rConvRange,
947 sal_Bool bAllowImplicitChangesForNotConvertibleText, LanguageType nTargetLang, const Font *pTargetFont );
948 ConvInfo * GetConvInfo() const { return pConvInfo; }
949 sal_Bool HasConvertibleTextPortion( LanguageType nLang );
950 void SetLanguageAndFont( const ESelection &rESel,
951 LanguageType nLang, USHORT nLangWhichId,
952 const Font *pFont, USHORT nFontWhichId );
954 // returns true if input sequence checking should be applied
955 sal_Bool IsInputSequenceCheckingRequired( sal_Unicode nChar, const EditSelection& rCurSel ) const;
957 //find the next error within the given selection - forward only!
958 ::com::sun::star::uno::Reference<
959 ::com::sun::star::linguistic2::XSpellAlternatives >
960 ImpFindNextError(EditSelection& rSelection);
961 //initialize sentence spelling
962 void StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc);
963 //spell and return a sentence
964 bool SpellSentence(EditView& rView, ::svx::SpellPortions& rToFill, bool bIsGrammarChecking );
965 //put spelling back to start of current sentence - needed after switch of grammar support
966 void PutSpellingToSentenceStart( EditView& rEditView );
967 //applies a changed sentence
968 void ApplyChangedSentence(EditView& rEditView, const ::svx::SpellPortions& rNewPortions, bool bIsGrammarChecking );
969 //deinitialize sentence spelling
970 void EndSpelling();
971 //adds one or more portions of text to the SpellPortions depending on language changes
972 void AddPortionIterated(
973 EditView& rEditView,
974 const EditSelection rSel,
975 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
976 ::svx::SpellPortions& rToFill);
977 //adds one portion to the SpellPortions
978 void AddPortion(
979 const EditSelection rSel,
980 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
981 ::svx::SpellPortions& rToFill,
982 bool bIsField );
984 sal_Bool Search( const SvxSearchItem& rSearchItem, EditView* pView );
985 sal_Bool ImpSearch( const SvxSearchItem& rSearchItem, const EditSelection& rSearchSelection, const EditPaM& rStartPos, EditSelection& rFoundSel );
986 sal_uInt16 StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem );
987 sal_Bool HasText( const SvxSearchItem& rSearchItem );
989 void SetEditTextObjectPool( SfxItemPool* pP ) { pTextObjectPool = pP; }
990 SfxItemPool* GetEditTextObjectPool() const { return pTextObjectPool; }
992 const SvxNumberFormat * GetNumberFormat( const ContentNode* pNode ) const;
993 sal_Int32 GetSpaceBeforeAndMinLabelWidth( const ContentNode *pNode, sal_Int32 *pnSpaceBefore = 0, sal_Int32 *pnMinLabelWidth = 0 ) const;
995 const SvxLRSpaceItem& GetLRSpaceItem( ContentNode* pNode );
996 SvxAdjust GetJustification( USHORT nPara ) const;
998 void SetCharStretching( sal_uInt16 nX, sal_uInt16 nY );
999 inline void GetCharStretching( sal_uInt16& rX, sal_uInt16& rY );
1000 void DoStretchChars( sal_uInt16 nX, sal_uInt16 nY );
1002 void SetBigTextObjectStart( sal_uInt16 nStartAtPortionCount ) { nBigTextObjectStart = nStartAtPortionCount; }
1003 sal_uInt16 GetBigTextObjectStart() const { return nBigTextObjectStart; }
1005 inline EditEngine* GetEditEnginePtr() const { return pEditEngine; }
1007 void StartOnlineSpellTimer() { aOnlineSpellTimer.Start(); }
1008 void StopOnlineSpellTimer() { aOnlineSpellTimer.Stop(); }
1010 const XubString& GetAutoCompleteText() const { return aAutoCompleteText; }
1011 void SetAutoCompleteText( const String& rStr, sal_Bool bUpdateTipWindow );
1013 EditSelection TransliterateText( const EditSelection& rSelection, sal_Int32 nTransliterationMode );
1015 void SetAsianCompressionMode( USHORT n );
1016 USHORT GetAsianCompressionMode() const { return nAsianCompressionMode; }
1018 void SetKernAsianPunctuation( BOOL b );
1019 BOOL IsKernAsianPunctuation() const { return bKernAsianPunctuation; }
1021 void SetAddExtLeading( BOOL b );
1022 BOOL IsAddExtLeading() const { return bAddExtLeading; }
1024 vos::ORef<SvxForbiddenCharactersTable> GetForbiddenCharsTable( BOOL bGetInternal = TRUE ) const;
1025 void SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars );
1027 BOOL mbLastTryMerge;
1029 /** sets a link that is called at the beginning of a drag operation at an edit view */
1030 void SetBeginDropHdl( const Link& rLink ) { maBeginDropHdl = rLink; }
1031 Link GetBeginDropHdl() const { return maBeginDropHdl; }
1033 /** sets a link that is called at the end of a drag operation at an edit view */
1034 void SetEndDropHdl( const Link& rLink ) { maEndDropHdl = rLink; }
1035 Link GetEndDropHdl() const { return maEndDropHdl; }
1037 /// specifies if auto-correction should capitalize the first word or not (default is on)
1038 void SetFirstWordCapitalization( BOOL bCapitalize ) { bFirstWordCapitalization = bCapitalize; }
1039 BOOL IsFirstWordCapitalization() const { return bFirstWordCapitalization; }
1042 inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM )
1044 ContentNode* pNode = rPaM.GetNode();
1045 return EPaM( aEditDoc.GetPos( pNode ), rPaM.GetIndex() );
1048 inline EditPaM ImpEditEngine::CreateEditPaM( const EPaM& rEPaM )
1050 DBG_ASSERT( rEPaM.nPara < aEditDoc.Count(), "CreateEditPaM: Ungueltiger Absatz" );
1051 DBG_ASSERT( aEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, "CreateEditPaM: Ungueltiger Index" );
1052 return EditPaM( aEditDoc[ rEPaM.nPara], rEPaM.nIndex );
1055 inline ESelection ImpEditEngine::CreateESel( const EditSelection& rSel )
1057 ContentNode* pStartNode = rSel.Min().GetNode();
1058 ContentNode* pEndNode = rSel.Max().GetNode();
1059 ESelection aESel;
1060 aESel.nStartPara = aEditDoc.GetPos( pStartNode );
1061 aESel.nStartPos = rSel.Min().GetIndex();
1062 aESel.nEndPara = aEditDoc.GetPos( pEndNode );
1063 aESel.nEndPos = rSel.Max().GetIndex();
1064 return aESel;
1067 inline EditSelection ImpEditEngine::CreateSel( const ESelection& rSel )
1069 DBG_ASSERT( rSel.nStartPara < aEditDoc.Count(), "CreateSel: Ungueltiger Start-Absatz" );
1070 DBG_ASSERT( rSel.nEndPara < aEditDoc.Count(), "CreateSel: Ungueltiger End-Absatz" );
1071 EditSelection aSel;
1072 aSel.Min().SetNode( aEditDoc[ rSel.nStartPara ] );
1073 aSel.Min().SetIndex( rSel.nStartPos );
1074 aSel.Max().SetNode( aEditDoc[ rSel.nEndPara ] );
1075 aSel.Max().SetIndex( rSel.nEndPos );
1076 DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "CreateSel: Fehlerhafte Selektion!" );
1077 return aSel;
1080 inline VirtualDevice* ImpEditEngine::GetVirtualDevice( const MapMode& rMapMode, ULONG nDrawMode )
1082 if ( !pVirtDev )
1083 pVirtDev = new VirtualDevice;
1085 if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) ||
1086 ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) ||
1087 ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) )
1089 MapMode aMapMode( rMapMode );
1090 aMapMode.SetOrigin( Point( 0, 0 ) );
1091 pVirtDev->SetMapMode( aMapMode );
1094 pVirtDev->SetDrawMode( nDrawMode );
1096 return pVirtDev;
1099 inline void ImpEditEngine::EraseVirtualDevice()
1101 delete pVirtDev;
1102 pVirtDev = 0;
1105 inline void ImpEditEngine::IdleFormatAndUpdate( EditView* pCurView )
1107 aIdleFormatter.DoIdleFormat( pCurView );
1110 #ifndef SVX_LIGHT
1111 inline EditUndoManager& ImpEditEngine::GetUndoManager()
1113 if ( !pUndoManager )
1114 pUndoManager = new EditUndoManager( this );
1115 return *pUndoManager;
1117 #endif
1119 inline ParaPortion* ImpEditEngine::FindParaPortion( ContentNode* pNode ) const
1121 sal_uInt16 nPos = aEditDoc.GetPos( pNode );
1122 DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" );
1123 return GetParaPortions()[ nPos ];
1126 inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY )
1128 rX = nStretchX;
1129 rY = nStretchY;
1132 inline short ImpEditEngine::GetXValue( short nXValue ) const
1134 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1135 return nXValue;
1137 return (short) ((long)nXValue*nStretchX/100);
1140 inline sal_uInt16 ImpEditEngine::GetXValue( sal_uInt16 nXValue ) const
1142 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1143 return nXValue;
1145 return (sal_uInt16) ((long)nXValue*nStretchX/100);
1148 inline long ImpEditEngine::GetXValue( long nXValue ) const
1150 if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
1151 return nXValue;
1153 return nXValue*nStretchX/100;
1156 inline short ImpEditEngine::GetYValue( short nYValue ) const
1158 if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
1159 return nYValue;
1161 return (short) ((long)nYValue*nStretchY/100);
1164 inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const
1166 if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
1167 return nYValue;
1169 return (sal_uInt16) ((long)nYValue*nStretchY/100);
1172 inline void ImpEditView::SetPointer( const Pointer& rPointer )
1174 delete pPointer;
1175 pPointer = new Pointer( rPointer );
1178 inline const Pointer& ImpEditView::GetPointer()
1180 if ( !pPointer )
1182 pPointer = new Pointer( IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT );
1183 return *pPointer;
1186 if(POINTER_TEXT == pPointer->GetStyle() && IsVertical())
1188 delete pPointer;
1189 pPointer = new Pointer(POINTER_TEXT_VERTICAL);
1191 else if(POINTER_TEXT_VERTICAL == pPointer->GetStyle() && !IsVertical())
1193 delete pPointer;
1194 pPointer = new Pointer(POINTER_TEXT);
1197 return *pPointer;
1200 inline void ImpEditView::SetCursor( const Cursor& rCursor )
1202 delete pCursor;
1203 pCursor = new Cursor( rCursor );
1206 inline Cursor* ImpEditView::GetCursor()
1208 if ( !pCursor )
1209 pCursor = new Cursor;
1210 return pCursor;
1213 void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit );
1214 void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const MapUnit* pSourceUnit = NULL, const MapUnit* pDestUnit = NULL );
1215 BYTE GetCharTypeForCompression( xub_Unicode cChar );
1216 Point Rotate( const Point& rPoint, short nOrientation, const Point& rOrigin );
1218 #endif // _IMPEDIT_HXX