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