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