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