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