Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_CRSRSH_HXX
29 : : #define SW_CRSRSH_HXX
30 : :
31 : : #include <com/sun/star/i18n/WordType.hpp>
32 : :
33 : : #include <tools/string.hxx>
34 : : #include <tools/link.hxx>
35 : : #include <tools/rtti.hxx>
36 : :
37 : : #include <IShellCursorSupplier.hxx>
38 : : #include "swdllapi.h"
39 : : #include <swtypes.hxx> // for SWPOSDOC
40 : : #include <viewsh.hxx> // for ViewShell
41 : : #include <calbck.hxx> // for SwClient
42 : : #include <cshtyp.hxx> // for CursorShell types
43 : : #include <crstate.hxx> // for CursorMove-States
44 : : #include <toxe.hxx> // SwTOXSearchDir
45 : : #include <tblsel.hxx> // SwTblSearchType
46 : : #include <viscrs.hxx>
47 : : #include <node.hxx>
48 : : #include <tblsel.hxx>
49 : : #include <IDocumentMarkAccess.hxx>
50 : :
51 : : class KeyCode;
52 : : class SfxItemSet;
53 : : class SfxPoolItem;
54 : : class SwCntntFrm;
55 : : class SwCrsrShell;
56 : : class SwCursor;
57 : : class SwField;
58 : : class SwFieldType;
59 : : class SwFmt;
60 : : class SwFmtFld;
61 : : class SwNodeIndex;
62 : : class SwPaM;
63 : : class SwShellCrsr;
64 : : class SwShellTableCrsr;
65 : : class SwTableNode;
66 : : class SwTxtFmtColl;
67 : : class SwVisCrsr;
68 : : class SwTxtINetFmt;
69 : : class SwFmtINetFmt;
70 : : class SwTxtAttr;
71 : : class SwTableBox;
72 : : class SwTOXMark;
73 : : class SwRedline;
74 : : class IBlockCursor;
75 : : class SwCntntNode;
76 : :
77 : : class SwPostItField;
78 : :
79 : : struct SwPosition;
80 : :
81 : : namespace com { namespace sun { namespace star { namespace util {
82 : : struct SearchOptions;
83 : : } } } }
84 : :
85 : : namespace com { namespace sun { namespace star { namespace text {
86 : : class XTextRange;
87 : : }}}}
88 : :
89 : : namespace com { namespace sun { namespace star { namespace container {
90 : : class XStringKeyMap;
91 : : }}}}
92 : :
93 : : // enum and struct to get informations via the Doc-Position
94 : :
95 : 0 : struct SwContentAtPos
96 : : {
97 : : enum IsAttrAtPos
98 : : {
99 : : SW_NOTHING = 0x0000,
100 : : SW_FIELD = 0x0001,
101 : : SW_CLICKFIELD = 0x0002,
102 : : SW_FTN = 0x0004,
103 : : SW_INETATTR = 0x0008,
104 : : SW_TABLEBOXFML = 0x0010,
105 : : SW_REDLINE = 0x0020,
106 : : SW_OUTLINE = 0x0040,
107 : : SW_TOXMARK = 0x0080,
108 : : SW_REFMARK = 0x0100,
109 : : SW_NUMLABEL = 0x0200,
110 : : SW_CONTENT_CHECK = 0x0400,
111 : : SW_SMARTTAG = 0x0800,
112 : : SW_FORMCTRL = 0x1000
113 : : #ifdef DBG_UTIL
114 : : ,SW_CURR_ATTRS = 0x4000 ///< only for debugging
115 : : ,SW_TABLEBOXVALUE = 0x8000 ///< only for debugging
116 : : #endif
117 : : } eCntntAtPos;
118 : :
119 : : union {
120 : : const SwField* pFld;
121 : : const SfxPoolItem* pAttr;
122 : : const SwRedline* pRedl;
123 : : SwCntntNode * pNode;
124 : : const sw::mark::IFieldmark* pFldmark;
125 : : } aFnd;
126 : :
127 : : int nDist;
128 : :
129 : : String sStr;
130 : : const SwTxtAttr* pFndTxtAttr;
131 : :
132 : 0 : SwContentAtPos( int eGetAtPos = 0xffff )
133 : 0 : : eCntntAtPos( (IsAttrAtPos)eGetAtPos )
134 : : {
135 : 0 : aFnd.pFld = 0;
136 : 0 : pFndTxtAttr = 0;
137 : 0 : nDist = 0; // #i23726#
138 : 0 : }
139 : :
140 : : sal_Bool IsInProtectSect() const;
141 : : bool IsInRTLText()const;
142 : : };
143 : :
144 : : // return values of SetCrsr (can be combined via ||)
145 : : const int CRSR_POSOLD = 0x01, // cursor stays at old position
146 : : CRSR_POSCHG = 0x02; // position changed by the layout
147 : :
148 : : /// Helperfunction to resolve backward references in regular expressions
149 : : String *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam );
150 : :
151 : : class SW_DLLPUBLIC SwCrsrShell
152 : : : public ViewShell
153 : : , public SwModify
154 : : , public ::sw::IShellCursorSupplier
155 : : {
156 : : friend class SwCallLink;
157 : : friend class SwVisCrsr;
158 : : friend class SwSelPaintRects;
159 : :
160 : : // requires the Crsr as InternalCrsr
161 : : friend sal_Bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& );
162 : :
163 : : public:
164 : :
165 : : /** for calling UpdateCrsr */
166 : : enum CrsrFlag {
167 : : UPDOWN = (1 << 0), ///< keep Up/Down on columns
168 : : SCROLLWIN = (1 << 1), ///< scroll window
169 : : CHKRANGE = (1 << 2), ///< check overlapping PaMs
170 : : NOCALRECT = (1 << 3), ///< don't recalculate CharRect
171 : : READONLY = (1 << 4) ///< make visible in spite of Readonly
172 : : };
173 : :
174 : : private:
175 : :
176 : : SwRect aCharRect; ///< Char-SRectangle on which the cursor is located
177 : : Point aCrsrHeight; ///< height & offset from visible Cursor
178 : : Point aOldRBPos; ///< Right/Bottom of last VisArea
179 : : // (used in Invalidate by Cursor)
180 : :
181 : : Link aFlyMacroLnk; /**< Link will be called, if the Crsr is set
182 : : into a fly. A macro can be then becalled */
183 : : Link aChgLnk; /**< link will be called by every attribut/
184 : : format changes at cursor position.*/
185 : : Link aGrfArrivedLnk; ///< Link calls to UI if a graphic is arrived
186 : :
187 : : SwShellCrsr* pCurCrsr; ///< current cursor
188 : : SwShellCrsr* pCrsrStk; ///< stack for the cursor
189 : : SwVisCrsr *pVisCrsr; ///< the visible cursor
190 : :
191 : : IBlockCursor *pBlockCrsr; ///< interface of cursor for block (=rectangular) selection
192 : :
193 : : SwShellTableCrsr* pTblCrsr; /**< table Crsr; only in tables when the
194 : : selection lays over 2 columns */
195 : :
196 : : SwNodeIndex* pBoxIdx; ///< for recognizing of the changed
197 : : SwTableBox* pBoxPtr; ///< table row
198 : :
199 : : long nUpDownX; /**< try to move the cursor on up/down always
200 : : in the same column */
201 : : long nLeftFrmPos;
202 : : sal_uLong nAktNode; // save CursorPos at Start-Action
203 : : xub_StrLen nAktCntnt;
204 : : sal_uInt16 nAktNdTyp;
205 : : bool bAktSelection;
206 : :
207 : : /*
208 : : * Via the Method SttCrsrMove and EndCrsrMove this counter gets
209 : : * incremented/decremented. As long as the counter is inequal to 0, the
210 : : * current Cursor gets no update. This way, "complicated" cursor movements
211 : : * (via Find()) can be realised.
212 : : */
213 : : sal_uInt16 nCrsrMove;
214 : : sal_uInt16 nBasicActionCnt; ///< Actions which are parenthesized by Basic
215 : : CrsrMoveState eMvState; ///< Status for Crsr-Travelling - GetCrsrOfst
216 : :
217 : : String sMarkedListId;
218 : : int nMarkedListLevel;
219 : :
220 : : sal_Bool bHasFocus : 1; ///< Shell is "active" in a window
221 : : sal_Bool bSVCrsrVis : 1; ///< SV-Cursor visible/invisible
222 : : sal_Bool bChgCallFlag : 1; ///< attribute change inside Start- and EndAction
223 : : sal_Bool bVisPortChgd : 1; ///< in VisPortChg-Call
224 : : // (used in Invalidate by the Cursor)
225 : :
226 : : sal_Bool bCallChgLnk : 1; ///< flag for derived classes
227 : : // TRUE -> call ChgLnk
228 : : // access only via SwChgLinkFlag
229 : : sal_Bool bAllProtect : 1; ///< Flag for areas
230 : : // TRUE -> everything protected / hidden
231 : : sal_Bool bInCMvVisportChgd : 1; ///< Flag for CrsrMoves
232 : : // TRUE -> view was moved
233 : : sal_Bool bGCAttr : 1; // TRUE -> non expanded attributes exist.
234 : : sal_Bool bIgnoreReadonly : 1; // TRUE -> make the cursor visible on next
235 : : // EndAction in spite of Readonly
236 : : sal_Bool bSelTblCells : 1; // TRUE -> select cells over the InputWin
237 : : sal_Bool bAutoUpdateCells : 1; // TRUE -> autoformat cells
238 : : sal_Bool bBasicHideCrsr : 1; // TRUE -> HideCrsr from Basic
239 : : sal_Bool bSetCrsrInReadOnly : 1;// TRUE -> Cursor is allowed in ReadOnly-Areas
240 : : sal_Bool bOverwriteCrsr : 1; // sal_True -> show Overwrite Crsr
241 : :
242 : : bool mbMacroExecAllowed : 1;
243 : :
244 : : SW_DLLPRIVATE void UpdateCrsr( sal_uInt16 eFlags
245 : : =SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE,
246 : : sal_Bool bIdleEnd = sal_False );
247 : :
248 : : SW_DLLPRIVATE void _ParkPams( SwPaM* pDelRg, SwShellCrsr** ppDelRing );
249 : :
250 : : /** Mark a certain list level of a certain list
251 : :
252 : : levels of a certain lists are marked now
253 : :
254 : : @param sListId list Id of the list whose level is marked
255 : : @param nLevel to be marked list level
256 : :
257 : : An empty sListId denotes that no level of a list is marked.
258 : : */
259 : : SW_DLLPRIVATE void MarkListLevel( const String& sListId,
260 : : const int nLevel );
261 : :
262 : : // private method(s) accessed from public inline method(s) must be exported.
263 : : sal_Bool LeftRight( sal_Bool, sal_uInt16, sal_uInt16, sal_Bool );
264 : : SW_DLLPRIVATE sal_Bool UpDown( sal_Bool, sal_uInt16 );
265 : : SW_DLLPRIVATE sal_Bool LRMargin( sal_Bool, sal_Bool bAPI = sal_False );
266 : : SW_DLLPRIVATE sal_Bool IsAtLRMargin( sal_Bool, sal_Bool bAPI = sal_False ) const;
267 : :
268 : : SW_DLLPRIVATE short GetTextDirection( const Point* pPt = 0 ) const;
269 : :
270 : : typedef sal_Bool (SwCursor:: *FNCrsr)();
271 : : SW_DLLPRIVATE sal_Bool CallCrsrFN( FNCrsr );
272 : :
273 : : SW_DLLPRIVATE const SwRedline* _GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect );
274 : :
275 : : protected:
276 : :
277 : : inline SwMoveFnCollection* MakeFindRange( sal_uInt16, sal_uInt16, SwPaM* ) const;
278 : :
279 : : /*
280 : : * Compare-Methode for the StackCursor and the current Cursor.
281 : : * The Methods return -1, 0, 1 for lower, equal, greater. The enum
282 : : * CrsrCompareType says which position is compared.
283 : : */
284 : : enum CrsrCompareType {
285 : : StackPtStackMk,
286 : : StackPtCurrPt,
287 : : StackPtCurrMk,
288 : : StackMkCurrPt,
289 : : StackMkCurrMk,
290 : : CurrPtCurrMk
291 : : };
292 : : int CompareCursor( CrsrCompareType eType ) const;
293 : :
294 : : // set all PaMs in OldNode to NewPos + Offset
295 : : void PaMCorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos,
296 : : const xub_StrLen nOffset = 0 );
297 : :
298 : : sal_Bool _SelTblRowOrCol( bool bRow, bool bRowSimple = false );
299 : :
300 : : bool SetInFrontOfLabel( sal_Bool bNew );
301 : :
302 : : void RefreshBlockCursor();
303 : :
304 : : /** Updates the marked list level according to the cursor.
305 : : */
306 : : SW_DLLPRIVATE void UpdateMarkedListLevel();
307 : :
308 : : protected:
309 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
310 : :
311 : : public:
312 : : TYPEINFO();
313 : : SwCrsrShell( SwDoc& rDoc, Window *pWin, const SwViewOption *pOpt = 0 );
314 : : // disguised copy constructor
315 : : SwCrsrShell( SwCrsrShell& rShell, Window *pWin );
316 : : virtual ~SwCrsrShell();
317 : :
318 : : // create new cursor and append the old one
319 : : virtual SwPaM & CreateNewShellCursor();
320 : : virtual SwPaM & GetCurrentShellCursor();
321 : :
322 : : SwPaM * CreateCrsr();
323 : : ///< delete the current cursor and make the following into the current
324 : : sal_Bool DestroyCrsr();
325 : : ///< transform TableCursor to normal cursor, nullify Tablemode
326 : : void TblCrsrToCursor();
327 : : ///< enter block mode, change normal cursor into block cursor
328 : : void CrsrToBlockCrsr();
329 : : ///< leave block mode, change block cursor into normal cursor
330 : : void BlockCrsrToCrsr();
331 : :
332 : : // SelAll() selects the document body content
333 : : // if ExtendedSelect() is called afterwards, the whole nodes array is selected
334 : : // only for usage in special cases allowed!
335 : : void ExtendedSelectAll();
336 : :
337 : : SwPaM* GetCrsr( sal_Bool bMakeTblCrsr = sal_True ) const;
338 : : inline SwCursor* GetSwCrsr( sal_Bool bMakeTblCrsr = sal_True ) const;
339 : : // return only the current cursor
340 : 4862 : SwShellCrsr* _GetCrsr() { return pCurCrsr; }
341 : 55505 : const SwShellCrsr* _GetCrsr() const { return pCurCrsr; }
342 : :
343 : : // show passed cursor - for UNO
344 : : void SetSelection(const SwPaM& rCrsr);
345 : :
346 : : // remove all cursors from ContentNodes and set to 0
347 : : void ParkCrsr( const SwNodeIndex &rIdx );
348 : :
349 : : // return the current cursor stack
350 : : // (required in EditShell when deleting contents)
351 : : inline SwPaM* GetStkCrsr() const;
352 : :
353 : : // start parenthesing, hide SV-Cursor and selected areas
354 : : void StartAction();
355 : : // end parenthesing, show SV-Cursor and selected areas
356 : : void EndAction( const sal_Bool bIdleEnd = sal_False );
357 : :
358 : : // basic cursor travelling
359 : 0 : long GetUpDownX() const { return nUpDownX; }
360 : :
361 : 12 : sal_Bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual = sal_False )
362 : 12 : { return LeftRight( sal_True, nCnt, nMode, bAllowVisual ); }
363 : 22 : sal_Bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual = sal_False )
364 : 22 : { return LeftRight( sal_False, nCnt, nMode, bAllowVisual ); }
365 : 0 : sal_Bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( sal_True, nCnt ); }
366 : 0 : sal_Bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( sal_False, nCnt ); }
367 : 0 : sal_Bool LeftMargin() { return LRMargin( sal_True ); }
368 : 0 : sal_Bool RightMargin(sal_Bool bAPI = sal_False) { return LRMargin( sal_False, bAPI ); }
369 : : sal_Bool SttEndDoc( sal_Bool bStt );
370 : :
371 : : sal_Bool MovePage( SwWhichPage, SwPosPage );
372 : : sal_Bool MovePara( SwWhichPara, SwPosPara );
373 : : sal_Bool MoveSection( SwWhichSection, SwPosSection );
374 : : sal_Bool MoveTable( SwWhichTable, SwPosTable );
375 : : sal_Bool MoveColumn( SwWhichColumn, SwPosColumn );
376 : : sal_Bool MoveRegion( SwWhichRegion, SwPosRegion );
377 : :
378 : : sal_uLong Find( const com::sun::star::util::SearchOptions& rSearchOpt,
379 : : sal_Bool bSearchInNotes,
380 : : SwDocPositions eStart, SwDocPositions eEnde,
381 : : sal_Bool& bCancel,
382 : : FindRanges eRng, int bReplace = sal_False );
383 : :
384 : : sal_uLong Find( const SwTxtFmtColl& rFmtColl,
385 : : SwDocPositions eStart, SwDocPositions eEnde,
386 : : sal_Bool& bCancel,
387 : : FindRanges eRng, const SwTxtFmtColl* pReplFmt = 0 );
388 : :
389 : : sal_uLong Find( const SfxItemSet& rSet, sal_Bool bNoCollections,
390 : : SwDocPositions eStart, SwDocPositions eEnde,
391 : : sal_Bool& bCancel,
392 : : FindRanges eRng,
393 : : const com::sun::star::util::SearchOptions* pSearchOpt = 0,
394 : : const SfxItemSet* rReplSet = 0 );
395 : :
396 : : // Position the Cursor
397 : : // return values:
398 : : // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
399 : : // CRSR_POSOLD: when the cursor was not changed
400 : : int SetCrsr( const Point &rPt, sal_Bool bOnlyText = sal_False, bool bBlock = true );
401 : :
402 : : /*
403 : : * Notification that the visible area was changed. aVisArea is reset, then
404 : : * scrolling is done. The passed Rectangle lays on pixel borders to avoid
405 : : * pixel errors.
406 : : */
407 : : virtual void VisPortChgd( const SwRect & );
408 : :
409 : : /*
410 : : * virtual paint method to make selection visible again after Paint
411 : : */
412 : : void Paint( const Rectangle & rRect );
413 : :
414 : : // Areas
415 : : inline void SetMark();
416 : : inline sal_Bool HasMark();
417 : :
418 : : void ClearMark();
419 : :
420 : : /**
421 : : Ensure point and mark of the current PaM are in a specific order.
422 : :
423 : : @param bPointFirst TRUE: If the point is behind the mark then
424 : : swap the PaM. FALSE: If the mark is behind the point then swap
425 : : the PaM.
426 : : */
427 : : void NormalizePam(sal_Bool bPointFirst = sal_True);
428 : :
429 : : void SwapPam();
430 : : sal_Bool ChgCurrPam( const Point & rPt,
431 : : sal_Bool bTstOnly = sal_True, // test only, don't set
432 : : sal_Bool bTstHit = sal_False ); // only exact matches
433 : : void KillPams();
434 : :
435 : : // story a copy of the cursor in the stack
436 : : void Push();
437 : : /*
438 : : * Delete a cursor (controlled by bOldCrsr)
439 : : * - from stack or (bOldCrsr = TRUE)
440 : : * - delete the current one and replace it with the cursor from the
441 : : * stack
442 : : * Return: whether there was one left one the stack
443 : : */
444 : : sal_Bool Pop( sal_Bool bOldCrsr = sal_True );
445 : : /*
446 : : * Combine 2 Cursors.
447 : : * Delete the topmost from the stack and move its Mark into the current.
448 : : */
449 : : void Combine();
450 : :
451 : : #ifdef DBG_UTIL
452 : : void SttCrsrMove();
453 : : void EndCrsrMove( const sal_Bool bIdleEnd = sal_False );
454 : : #else
455 : 58 : void SttCrsrMove() { ++nCrsrMove; StartAction(); }
456 : 58 : void EndCrsrMove( const sal_Bool bIdleEnd = sal_False )
457 : 58 : { EndAction( bIdleEnd ); --nCrsrMove; }
458 : : #endif
459 : :
460 : : /*
461 : : * When the focus is lost the selected ranges are not displayed anymore.
462 : : * On the other hand, on receiving the focus all selected ranges are displayed again
463 : : * (ranges must be recalculated!).
464 : : */
465 : 0 : sal_Bool HasShFcs() const { return bHasFocus; }
466 : : void ShLooseFcs();
467 : : void ShGetFcs( sal_Bool bUpdate = sal_True );
468 : :
469 : : // Methods for displaying or hiding the visible text cursor.
470 : : void ShowCrsr();
471 : : void HideCrsr();
472 : : // Methods for displaying or hiding the selected ranges with visible cursor.
473 : : void ShowCrsrs( sal_Bool bCrsrVis );
474 : : void HideCrsrs();
475 : :
476 : 141275 : sal_Bool IsOverwriteCrsr() const { return bOverwriteCrsr; }
477 : 0 : void SetOverwriteCrsr( sal_Bool bFlag ) { bOverwriteCrsr = bFlag; }
478 : :
479 : : // Return current frame in which the cursor is placed.
480 : : SwCntntFrm *GetCurrFrm( const sal_Bool bCalcFrm = sal_True ) const;
481 : :
482 : : //TRUE if cursor is hidden because of readonly.
483 : : //FALSE if it is working despite readonly.
484 : : sal_Bool IsCrsrReadonly() const;
485 : :
486 : : // Cursor is placed in something that is protected or selection contains
487 : : // something that is protected.
488 : : sal_Bool HasReadonlySel() const;
489 : :
490 : : // Can the cursor be set to read only ranges?
491 : 162531 : sal_Bool IsReadOnlyAvailable() const { return bSetCrsrInReadOnly; }
492 : : void SetReadOnlyAvailable( sal_Bool bFlag );
493 : : sal_Bool IsOverReadOnlyPos( const Point& rPt ) const;
494 : :
495 : : /// Is the rPt point in the header or footer area?
496 : : sal_Bool IsOverHeaderFooterPos( const Point& rPt ) const;
497 : :
498 : : // Methods for aFlyMacroLnk.
499 : 1318 : void SetFlyMacroLnk( const Link& rLnk ) { aFlyMacroLnk = rLnk; }
500 : 0 : const Link& GetFlyMacroLnk() const { return aFlyMacroLnk; }
501 : :
502 : : // Methods returning/altering link for changes of attributes/formates.
503 : 1318 : void SetChgLnk( const Link &rLnk ) { aChgLnk = rLnk; }
504 : 31 : const Link& GetChgLnk() const { return aChgLnk; }
505 : :
506 : : // Methods returning/altering ling for "graphic completely loaded".
507 : 3886 : void SetGrfArrivedLnk( const Link &rLnk ) { aGrfArrivedLnk = rLnk; }
508 : 2489 : const Link& GetGrfArrivedLnk() const { return aGrfArrivedLnk; }
509 : :
510 : : //Call ChgLink. When within an action calling will be delayed.
511 : : void CallChgLnk();
512 : :
513 : : // Check if the current cursor contains a selection, i.e.
514 : : // if Mark is set and SPoint and Mark are different.
515 : : sal_Bool HasSelection() const;
516 : :
517 : : // Check if a selection exists, i.e. if the current cursor comprises a selection.
518 : : inline sal_Bool IsSelection() const;
519 : : // returns if multiple cursors are available
520 : : inline sal_Bool IsMultiSelection() const;
521 : :
522 : : // Check if a complete paragraph was selected.
523 : : sal_Bool IsSelFullPara() const;
524 : :
525 : : // Check if selection is within one paragraph.
526 : :
527 : : //Should WaitPtr be activated for Clipboard.
528 : : sal_Bool ShouldWait() const;
529 : :
530 : : // Check if selection is within one paragraph.
531 : : inline sal_Bool IsSelOnePara() const;
532 : :
533 : : /*
534 : : * Returns SRectangle, at which the cursor is located.
535 : : */
536 : 12620 : const SwRect &GetCharRect() const { return aCharRect; }
537 : : /*
538 : : * Returns if cursor is wholly or partly within visible range.
539 : : */
540 : 1365 : sal_Bool IsCrsrVisible() const { return VisArea().IsOver( GetCharRect() ); }
541 : :
542 : : // Return current page number:
543 : : // TRUE: in which cursor is located.
544 : : // FALSE: which is visible at the upper margin.
545 : : void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
546 : : sal_Bool bAtCrsrPos = sal_True, const sal_Bool bCalcFrm = sal_True );
547 : : // Determine how "empty pages" are handled
548 : : // (used in PhyPage).
549 : : sal_uInt16 GetNextPrevPageNum( sal_Bool bNext = sal_True );
550 : :
551 : : // Move cursor at the bginning of page "nPage".
552 : : sal_Bool GotoPage( sal_uInt16 nPage );
553 : :
554 : : sal_uInt16 GetPageCnt();
555 : :
556 : : sal_Bool GoNextCrsr();
557 : :
558 : : sal_Bool GoPrevCrsr();
559 : :
560 : : // at CurCrsr.SPoint
561 : : ::sw::mark::IMark* SetBookmark(
562 : : const KeyCode&,
563 : : const ::rtl::OUString& rName,
564 : : const ::rtl::OUString& rShortName,
565 : : IDocumentMarkAccess::MarkType eMark = IDocumentMarkAccess::BOOKMARK);
566 : : bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurCrsr.SPoint
567 : : bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
568 : : bool GoNextBookmark(); // true, if there was one
569 : : bool GoPrevBookmark();
570 : :
571 : : bool IsFormProtected();
572 : : ::sw::mark::IFieldmark* GetCurrentFieldmark();
573 : : ::sw::mark::IFieldmark* GetFieldmarkAfter();
574 : : ::sw::mark::IFieldmark* GetFieldmarkBefore();
575 : : bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark );
576 : :
577 : : // update Cursr, i.e. reset it into content should only be called when the
578 : : // cursor was set to a random position e.g. when deleting frames
579 : : void UpdateCrsrPos();
580 : :
581 : : // get the selected text at the current cursor. it will be filled with
582 : : // fields etc.
583 : : String GetSelTxt() const;
584 : : // return only the text starting from the current cursor position (to the
585 : : // end of the node)
586 : : String GetText() const;
587 : :
588 : : // Check of SPoint or Mark of current cursor are placed within a table.
589 : : inline const SwTableNode* IsCrsrInTbl( sal_Bool bIsPtInTbl = sal_True ) const;
590 : :
591 : : inline Point& GetCrsrDocPos( sal_Bool bPoint = sal_True ) const;
592 : : inline sal_Bool IsCrsrPtAtEnd() const;
593 : :
594 : : inline const SwPaM* GetTblCrs() const;
595 : : inline SwPaM* GetTblCrs();
596 : :
597 : : sal_Bool IsTblComplex() const;
598 : : sal_Bool IsTblComplexForChart();
599 : : // get current table selection as text
600 : : String GetBoxNms() const;
601 : :
602 : : // set Crsr to the next/previous cell
603 : : sal_Bool GoNextCell( sal_Bool bAppendLine = sal_True );
604 : : sal_Bool GoPrevCell();
605 : : // go to this box (if available and inside of table)
606 : : sal_Bool GotoTable( const String& rName );
607 : :
608 : : // select a table row, column or box (based on the current cursor)
609 : 0 : sal_Bool SelTblRow() { return _SelTblRowOrCol( true ); }
610 : 0 : sal_Bool SelTblCol() { return _SelTblRowOrCol( false ); }
611 : : sal_Bool SelTblBox();
612 : :
613 : : sal_Bool SelTbl();
614 : :
615 : : sal_Bool GotoNextNum();
616 : : sal_Bool GotoPrevNum();
617 : :
618 : : sal_Bool GotoOutline( const String& rName );
619 : : // to the next/previous or the given OutlineNode
620 : : void GotoOutline( sal_uInt16 nIdx );
621 : : // find the "outline position" in the nodes array of the current chapter
622 : : sal_uInt16 GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX );
623 : : // select the given range of OutlineNodes. Optionally including the children
624 : : // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
625 : : sal_Bool MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos,
626 : : sal_Bool bWithChildren = sal_False );
627 : :
628 : : sal_Bool GotoNextOutline();
629 : : sal_Bool GotoPrevOutline();
630 : :
631 : : /** Delivers the current shell cursor
632 : :
633 : : Some operations have to run on the current cursor ring,
634 : : some on the pTblCrsr (if exist) or the current cursor ring and
635 : : some on the pTblCrsr or pBlockCrsr or the current cursor ring.
636 : : This small function checks the existence and delivers the wished cursor.
637 : :
638 : : @param bBlock [bool]
639 : : if the block cursor is of interest or not
640 : :
641 : : @return pTblCrsr if exist,
642 : : pBlockCrsr if exist and of interest (param bBlock)
643 : : otherwise pCurCrsr
644 : : */
645 : : SwShellCrsr* getShellCrsr( bool bBlock );
646 : 43244 : const SwShellCrsr* getShellCrsr( bool bBlock ) const
647 : 43244 : { return (const_cast<SwCrsrShell*>(this))->getShellCrsr( bBlock ); }
648 : :
649 : 0 : bool IsBlockMode() const { return 0 != pBlockCrsr; }
650 : : const IBlockCursor* GetBlockCrsr() const { return pBlockCrsr; }
651 : : IBlockCursor* GetBlockCrsr() { return pBlockCrsr; }
652 : :
653 : : // is the Crsr in a table and is the selection over 2 columns
654 : 229544 : sal_Bool IsTableMode() const { return 0 != pTblCrsr; }
655 : :
656 : 76 : const SwShellTableCrsr* GetTableCrsr() const { return pTblCrsr; }
657 : 2 : SwShellTableCrsr* GetTableCrsr() { return pTblCrsr; }
658 : : sal_uInt16 UpdateTblSelBoxes();
659 : :
660 : : sal_Bool GotoFtnTxt(); ///< jump from content to footnote
661 : : sal_Bool GotoFtnAnchor(); ///< jump from footnote to anchor
662 : : sal_Bool GotoPrevFtnAnchor();
663 : : sal_Bool GotoNextFtnAnchor();
664 : :
665 : : sal_Bool GotoFlyAnchor(); ///< jump from the frame to the anchor
666 : : sal_Bool GotoHeaderTxt(); ///< jump from the content to the header
667 : : sal_Bool GotoFooterTxt(); ///< jump from the content to the footer
668 : : // jump to the header/footer of the given or current PageDesc
669 : : sal_Bool SetCrsrInHdFt( sal_uInt16 nDescNo = USHRT_MAX,
670 : : sal_Bool bInHeader = sal_True );
671 : : // is point of cursor in header/footer. pbInHeader return sal_True if it is
672 : : // in a headerframe otherwise in a footerframe
673 : : bool IsInHeaderFooter( sal_Bool* pbInHeader = 0 ) const;
674 : :
675 : : sal_Bool GotoNextTOXBase( const String* = 0 );
676 : : sal_Bool GotoPrevTOXBase( const String* = 0 );
677 : : sal_Bool GotoTOXMarkBase();
678 : : // jump to the next or previous index entry
679 : : sal_Bool GotoNxtPrvTOXMark( sal_Bool bNext = sal_True );
680 : : // jump to the next/previous index mark of this type
681 : : const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir );
682 : :
683 : : // jump to the next or previous table formula
684 : : // optionally only to broken formulas
685 : : sal_Bool GotoNxtPrvTblFormula( sal_Bool bNext = sal_True,
686 : : sal_Bool bOnlyErrors = sal_False );
687 : : // jump to the next / previous hyperlink - inside text and also
688 : : // on graphics
689 : : sal_Bool SelectNxtPrvHyperlink( sal_Bool bNext = sal_True );
690 : :
691 : : sal_Bool GotoRefMark( const String& rRefMark, sal_uInt16 nSubType = 0,
692 : : sal_uInt16 nSeqNo = 0 );
693 : :
694 : : // get the nth character from the start or end of the current selection
695 : : sal_Unicode GetChar( sal_Bool bEnd = sal_True, long nOffset = 0 );
696 : : sal_Bool ExtendSelection( sal_Bool bEnd = sal_True, xub_StrLen nCount = 1 );
697 : :
698 : : // Place only the visible cursor at the given position in the document.
699 : : // Return FALSE if SPoint was corrected by layout.
700 : : // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
701 : : sal_Bool SetVisCrsr( const Point &rPt );
702 : : inline void UnSetVisCrsr();
703 : :
704 : : // jump to the next or previous field of the corresponding type
705 : : sal_Bool MoveFldType( const SwFieldType* pFldType, sal_Bool bNext,
706 : : sal_uInt16 nSubType = USHRT_MAX,
707 : : sal_uInt16 nResType = USHRT_MAX );
708 : : sal_Bool GotoFld( const SwFmtFld& rFld );
709 : :
710 : : // Return number of cursors in ring (The flag indicates whether
711 : : // only cursors containing selections are requested).
712 : : sal_uInt16 GetCrsrCnt( sal_Bool bAll = sal_True ) const;
713 : :
714 : : // Char Travelling - methods (in crstrvl1.cxx)
715 : : sal_Bool GoStartWord();
716 : : sal_Bool GoEndWord();
717 : : sal_Bool GoNextWord();
718 : : sal_Bool GoPrevWord();
719 : : sal_Bool GoNextSentence();
720 : : sal_Bool GoStartSentence();
721 : : sal_Bool GoEndSentence();
722 : : sal_Bool SelectWord( const Point* pPt = 0 );
723 : : sal_Bool ExpandToSentenceBorders();
724 : :
725 : : // get position from current cursor
726 : : sal_Bool IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const;
727 : : sal_Bool IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
728 : : sal_Bool IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
729 : : sal_Bool IsStartSentence() const;
730 : : sal_Bool IsEndSentence() const;
731 : : sal_Bool IsSttPara() const;
732 : : sal_Bool IsEndPara() const;
733 : : sal_Bool IsStartOfDoc() const;
734 : : sal_Bool IsEndOfDoc() const;
735 : : sal_Bool IsInFrontOfLabel() const;
736 : 0 : sal_Bool IsAtLeftMargin() const { return IsAtLRMargin( sal_True ); }
737 : 0 : sal_Bool IsAtRightMargin(sal_Bool bAPI = sal_False) const { return IsAtLRMargin( sal_False, bAPI ); }
738 : :
739 : : // delete all created cursors, set the table cursor and the last cursor to
740 : : // its TextNode (or StartNode?)
741 : : // They all get created on the next ::GetCrsr again
742 : : // Used for Drag&Drop/Clipboard-Paste in tables
743 : : sal_Bool ParkTblCrsr();
744 : :
745 : : // Non expanded attributes?
746 : 89 : sal_Bool IsGCAttr() const { return bGCAttr; }
747 : 0 : void ClearGCAttr() { bGCAttr = sal_False; }
748 : 0 : void UpdateAttr() { bGCAttr = sal_True; }
749 : :
750 : : // is the whole document protected/hidden (for UI...)
751 : 10 : sal_Bool IsAllProtect() const { return bAllProtect; }
752 : :
753 : : #ifdef SW_CRSR_TIMER
754 : : // Set flag at VisCrsr. Is it triggered by Timer (TRUE) or directly (FALSE).
755 : : // Default is triggert by Timer.
756 : : sal_Bool ChgCrsrTimerFlag( sal_Bool bTimerOn = sal_True );
757 : : #endif
758 : :
759 : 64291 : sal_Bool BasicActionPend() const { return nBasicActionCnt != nStartAction; }
760 : :
761 : : sal_Bool GotoRegion( const String& rName );
762 : :
763 : : // show the current selection
764 : : virtual void MakeSelVisible();
765 : :
766 : : // set the cursor to a NOT protected/hidden node
767 : : sal_Bool FindValidCntntNode( sal_Bool bOnlyText = sal_False );
768 : :
769 : : sal_Bool GetContentAtPos( const Point& rPt,
770 : : SwContentAtPos& rCntntAtPos,
771 : : sal_Bool bSetCrsr = sal_False,
772 : : SwRect* pFldRect = 0 );
773 : :
774 : : const SwPostItField* GetPostItFieldAtCursor() const;
775 : :
776 : : // get smart tags at point position
777 : : void GetSmartTagTerm( const Point& rPt,
778 : : SwRect& rSelectRect,
779 : : ::com::sun::star::uno::Sequence< rtl::OUString >& rSmartTagTypes,
780 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
781 : : ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange );
782 : :
783 : : // get smart tags at current cursor position
784 : : void GetSmartTagTerm( ::com::sun::star::uno::Sequence< rtl::OUString >& rSmartTagTypes,
785 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
786 : : ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange ) const;
787 : :
788 : : sal_Bool IsPageAtPos( const Point &rPt ) const;
789 : :
790 : : sal_Bool SelectTxtAttr( sal_uInt16 nWhich, sal_Bool bExpand, const SwTxtAttr* pAttr = 0 );
791 : : sal_Bool GotoINetAttr( const SwTxtINetFmt& rAttr );
792 : : const SwFmtINetFmt* FindINetAttr( const String& rName ) const;
793 : :
794 : : sal_Bool CheckTblBoxCntnt( const SwPosition* pPos = 0 );
795 : : void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
796 : : void ClearTblBoxCntnt();
797 : : sal_Bool EndAllTblBoxEdit();
798 : :
799 : 0 : void SetSelTblCells( sal_Bool bFlag ) { bSelTblCells = bFlag; }
800 : 30 : sal_Bool IsSelTblCells() const { return bSelTblCells; }
801 : :
802 : 20 : sal_Bool IsAutoUpdateCells() const { return bAutoUpdateCells; }
803 : 0 : void SetAutoUpdateCells( sal_Bool bFlag ) { bAutoUpdateCells = bFlag; }
804 : :
805 : : sal_Bool GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode,
806 : : SwRect& rRect, short& rOrient );
807 : : sal_Bool SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode );
808 : :
809 : : const SwRedline* SelNextRedline();
810 : : const SwRedline* SelPrevRedline();
811 : : const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False );
812 : :
813 : : // is cursor or the point in/over a vertical formatted text?
814 : : sal_Bool IsInVerticalText( const Point* pPt = 0 ) const;
815 : : // is cursor or the point in/over a right to left formatted text?
816 : : sal_Bool IsInRightToLeftText( const Point* pPt = 0 ) const;
817 : :
818 : : // If the current cursor position is inside a hidden range, the hidden range
819 : : // is selected and true is returned:
820 : : bool SelectHiddenRange();
821 : :
822 : : // remove all invalid cursors
823 : : void ClearUpCrsrs();
824 : :
825 : 2122 : inline void SetMacroExecAllowed( const bool _bMacroExecAllowed )
826 : : {
827 : 2122 : mbMacroExecAllowed = _bMacroExecAllowed;
828 : 2122 : }
829 : 1061 : inline bool IsMacroExecAllowed()
830 : : {
831 : 1061 : return mbMacroExecAllowed;
832 : : }
833 : :
834 : : /**
835 : : Returns textual description of the current selection.
836 : :
837 : : - If the current selection is a multi-selection the result is
838 : : STR_MULTISEL.
839 : : - Else the result is the text of the selection.
840 : :
841 : : @return the textual description of the current selection
842 : : */
843 : : String GetCrsrDescr() const;
844 : :
845 : : SwRect GetRectOfCurrentChar();
846 : : };
847 : :
848 : : // Cursor Inlines:
849 : 0 : inline SwMoveFnCollection* SwCrsrShell::MakeFindRange(
850 : : sal_uInt16 nStt, sal_uInt16 nEnd, SwPaM* pPam ) const
851 : : {
852 : 0 : return pCurCrsr->MakeFindRange( (SwDocPositions)nStt, (SwDocPositions)nEnd, pPam );
853 : : }
854 : :
855 : 16 : inline SwCursor* SwCrsrShell::GetSwCrsr( sal_Bool bMakeTblCrsr ) const
856 : : {
857 : 16 : return (SwCursor*)GetCrsr( bMakeTblCrsr );
858 : : }
859 : :
860 [ + + ]: 2428 : inline SwPaM* SwCrsrShell::GetStkCrsr() const { return pCrsrStk; }
861 : :
862 : 84 : inline void SwCrsrShell::SetMark() { pCurCrsr->SetMark(); }
863 : :
864 : 20 : inline sal_Bool SwCrsrShell::HasMark() { return( pCurCrsr->HasMark() ); }
865 : :
866 : 35939 : inline sal_Bool SwCrsrShell::IsSelection() const
867 : : {
868 : 71860 : return IsTableMode() || pCurCrsr->HasMark() ||
869 [ + - ][ - + ]: 71860 : pCurCrsr->GetNext() != pCurCrsr;
[ + + + + ]
870 : : }
871 : 9425 : inline sal_Bool SwCrsrShell::IsMultiSelection() const
872 : : {
873 [ + - ]: 9425 : return pCurCrsr->GetNext() != pCurCrsr;
874 : : }
875 : :
876 : 2 : inline sal_Bool SwCrsrShell::IsSelOnePara() const
877 : : {
878 : 2 : return pCurCrsr == pCurCrsr->GetNext() &&
879 [ + - ][ + - ]: 4 : pCurCrsr->GetPoint()->nNode == pCurCrsr->GetMark()->nNode;
[ - + ]
880 : : }
881 : :
882 : 50723 : inline const SwTableNode* SwCrsrShell::IsCrsrInTbl( sal_Bool bIsPtInTbl ) const
883 : : {
884 : 50723 : return pCurCrsr->GetNode( bIsPtInTbl )->FindTableNode();
885 : : }
886 : :
887 : 0 : inline sal_Bool SwCrsrShell::IsCrsrPtAtEnd() const
888 : : {
889 : 0 : return pCurCrsr->End() == pCurCrsr->GetPoint();
890 : : }
891 : :
892 : 0 : inline Point& SwCrsrShell::GetCrsrDocPos( sal_Bool bPoint ) const
893 : : {
894 [ # # ]: 0 : return bPoint ? pCurCrsr->GetPtPos() : pCurCrsr->GetMkPos();
895 : : }
896 : :
897 : : inline const SwPaM* SwCrsrShell::GetTblCrs() const
898 : : {
899 : : return pTblCrsr;
900 : : }
901 : :
902 : 58 : inline SwPaM* SwCrsrShell::GetTblCrs()
903 : : {
904 [ + + ]: 58 : return pTblCrsr;
905 : : }
906 : :
907 : 0 : inline void SwCrsrShell::UnSetVisCrsr()
908 : : {
909 : 0 : pVisCrsr->Hide();
910 : 0 : pVisCrsr->SetDragCrsr( sal_False );
911 : 0 : }
912 : :
913 : : #endif // _CRSRSH_HXX
914 : :
915 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|