LCOV - code coverage report
Current view: top level - sw/inc - crsrsh.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 65 83 78.3 %
Date: 2015-06-13 12:38:46 Functions: 45 58 77.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11