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