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