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