LCOV - code coverage report
Current view: top level - sw/source/core/crsr - swcrsr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 648 1235 52.5 %
Date: 2012-08-25 Functions: 51 78 65.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 685 2160 31.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <hintids.hxx>
      30                 :            : #include <editeng/protitem.hxx>
      31                 :            : #include <com/sun/star/i18n/WordType.hpp>
      32                 :            : #include <com/sun/star/i18n/CharType.hpp>
      33                 :            : #include <unotools/charclass.hxx>
      34                 :            : #include <svl/ctloptions.hxx>
      35                 :            : #include <swmodule.hxx>
      36                 :            : #include <fmtcntnt.hxx>
      37                 :            : #include <swtblfmt.hxx>
      38                 :            : #include <swcrsr.hxx>
      39                 :            : #include <unocrsr.hxx>
      40                 :            : #include <doc.hxx>
      41                 :            : #include <IDocumentUndoRedo.hxx>
      42                 :            : #include <docary.hxx>
      43                 :            : #include <ndtxt.hxx>
      44                 :            : #include <section.hxx>
      45                 :            : #include <swtable.hxx>
      46                 :            : #include <cntfrm.hxx>
      47                 :            : #include <rootfrm.hxx>
      48                 :            : #include <txtfrm.hxx>
      49                 :            : #include <scriptinfo.hxx>
      50                 :            : #include <crstate.hxx>
      51                 :            : #include <docsh.hxx>
      52                 :            : #include <viewsh.hxx>
      53                 :            : #include <frmatr.hxx>
      54                 :            : #include <breakit.hxx>
      55                 :            : #include <crsskip.hxx>
      56                 :            : #include <vcl/msgbox.hxx>
      57                 :            : #include <mdiexp.hxx>
      58                 :            : #include <statstr.hrc>
      59                 :            : #include <redline.hxx>
      60                 :            : #include <xmloff/odffields.hxx>
      61                 :            : 
      62                 :            : using namespace ::com::sun::star::i18n;
      63                 :            : 
      64                 :            : 
      65                 :            : static const sal_uInt16 coSrchRplcThreshold = 60000;
      66                 :            : 
      67                 :            : struct _PercentHdl
      68                 :            : {
      69                 :            :     SwDocShell* pDSh;
      70                 :            :     sal_uLong nActPos;
      71                 :            :     sal_Bool bBack, bNodeIdx;
      72                 :            : 
      73                 :          0 :     _PercentHdl( sal_uLong nStt, sal_uLong nEnd, SwDocShell* pSh )
      74                 :          0 :         : pDSh( pSh )
      75                 :            :     {
      76                 :          0 :         nActPos = nStt;
      77         [ #  # ]:          0 :         if( 0 != ( bBack = (nStt > nEnd )) )
      78                 :            :         {
      79                 :          0 :             sal_uLong n = nStt; nStt = nEnd; nEnd = n;
      80                 :            :         }
      81                 :          0 :         ::StartProgress( STR_STATSTR_SEARCH, nStt, nEnd, 0 );
      82                 :          0 :     }
      83                 :            : 
      84                 :          0 :     _PercentHdl( const SwPaM& rPam )
      85                 :          0 :         : pDSh( (SwDocShell*)rPam.GetDoc()->GetDocShell() )
      86                 :            :     {
      87                 :            :         sal_uLong nStt, nEnd;
      88         [ #  # ]:          0 :         if( rPam.GetPoint()->nNode == rPam.GetMark()->nNode )
      89                 :            :         {
      90                 :          0 :             bNodeIdx = sal_False;
      91                 :          0 :             nStt = rPam.GetMark()->nContent.GetIndex();
      92                 :          0 :             nEnd = rPam.GetPoint()->nContent.GetIndex();
      93                 :            :         }
      94                 :            :         else
      95                 :            :         {
      96                 :          0 :             bNodeIdx = sal_True;
      97                 :          0 :             nStt = rPam.GetMark()->nNode.GetIndex();
      98                 :          0 :             nEnd = rPam.GetPoint()->nNode.GetIndex();
      99                 :            :         }
     100                 :          0 :         nActPos = nStt;
     101         [ #  # ]:          0 :         if( 0 != ( bBack = (nStt > nEnd )) )
     102                 :            :         {
     103                 :          0 :             sal_uLong n = nStt; nStt = nEnd; nEnd = n;
     104                 :            :         }
     105                 :          0 :         ::StartProgress( STR_STATSTR_SEARCH, nStt, nEnd, pDSh );
     106                 :          0 :     }
     107                 :            : 
     108                 :          0 :     ~_PercentHdl()                      { ::EndProgress( pDSh ); }
     109                 :            : 
     110                 :          0 :     void NextPos( sal_uLong nPos ) const
     111         [ #  # ]:          0 :         { ::SetProgressState( bBack ? nActPos - nPos : nPos, pDSh ); }
     112                 :            : 
     113                 :          0 :     void NextPos( SwPosition& rPos ) const
     114                 :            :         {
     115                 :            :             sal_uLong nPos;
     116         [ #  # ]:          0 :             if( bNodeIdx )
     117                 :          0 :                 nPos = rPos.nNode.GetIndex();
     118                 :            :             else
     119                 :          0 :                 nPos = rPos.nContent.GetIndex();
     120         [ #  # ]:          0 :             ::SetProgressState( bBack ? nActPos - nPos : nPos, pDSh );
     121                 :          0 :         }
     122                 :            : };
     123                 :            : 
     124                 :      90511 : SwCursor::SwCursor( const SwPosition &rPos, SwPaM* pRing, bool bColumnSel )
     125                 :            :     : SwPaM( rPos, pRing ), pSavePos( 0 ), mnRowSpanOffset( 0 ), nCursorBidiLevel( 0 ),
     126                 :      90511 :     mbColumnSelection( bColumnSel )
     127                 :            : {
     128                 :      90511 : }
     129                 :            : 
     130                 :            : // @@@ semantic: no copy ctor.
     131                 :          0 : SwCursor::SwCursor( SwCursor& rCpy )
     132                 :            :     : SwPaM( rCpy ), pSavePos( 0 ), mnRowSpanOffset( rCpy.mnRowSpanOffset ),
     133                 :          0 :     nCursorBidiLevel( rCpy.nCursorBidiLevel ), mbColumnSelection( rCpy.mbColumnSelection )
     134                 :            : {
     135                 :          0 : }
     136                 :            : 
     137                 :      90424 : SwCursor::~SwCursor()
     138                 :            : {
     139         [ -  + ]:      90424 :     while( pSavePos )
     140                 :            :     {
     141                 :          0 :         _SwCursor_SavePos* pNxt = pSavePos->pNext;
     142 [ #  # ][ #  # ]:          0 :         delete pSavePos;
     143                 :          0 :         pSavePos = pNxt;
     144                 :            :     }
     145         [ -  + ]:      90796 : }
     146                 :            : 
     147                 :        372 : SwCursor* SwCursor::Create( SwPaM* pRing ) const
     148                 :            : {
     149         [ +  - ]:        372 :     return new SwCursor( *GetPoint(), pRing, false );
     150                 :            : }
     151                 :            : 
     152                 :         28 : bool SwCursor::IsReadOnlyAvailable() const
     153                 :            : {
     154                 :         28 :     return false;
     155                 :            : }
     156                 :            : 
     157                 :        163 : sal_Bool SwCursor::IsSkipOverHiddenSections() const
     158                 :            : {
     159                 :        163 :     return sal_True;
     160                 :            : }
     161                 :            : 
     162                 :        163 : sal_Bool SwCursor::IsSkipOverProtectSections() const
     163                 :            : {
     164                 :        163 :     return !IsReadOnlyAvailable();
     165                 :            : }
     166                 :            : 
     167                 :            : // CreateNewSavePos is virtual so that derived classes of cursor can implement
     168                 :            : // own SaveObjects if needed and validate them in the virtual check routines.
     169                 :      18042 : void SwCursor::SaveState()
     170                 :            : {
     171                 :      18042 :     _SwCursor_SavePos* pNew = CreateNewSavePos();
     172                 :      18042 :     pNew->pNext = pSavePos;
     173                 :      18042 :     pSavePos = pNew;
     174                 :      18042 : }
     175                 :            : 
     176                 :      18042 : void SwCursor::RestoreState()
     177                 :            : {
     178         [ +  - ]:      18042 :     if( pSavePos ) // Robust
     179                 :            :     {
     180                 :      18042 :         _SwCursor_SavePos* pDel = pSavePos;
     181                 :      18042 :         pSavePos = pSavePos->pNext;
     182         [ +  - ]:      18042 :         delete pDel;
     183                 :            :     }
     184                 :      18042 : }
     185                 :            : 
     186                 :      18042 : _SwCursor_SavePos* SwCursor::CreateNewSavePos() const
     187                 :            : {
     188                 :      18042 :     return new _SwCursor_SavePos( *this );
     189                 :            : }
     190                 :            : 
     191                 :            : /// determine if point is outside of the node-array's content area
     192                 :         12 : sal_Bool SwCursor::IsNoCntnt() const
     193                 :            : {
     194                 :         12 :     return GetPoint()->nNode.GetIndex() <
     195                 :         12 :             GetDoc()->GetNodes().GetEndOfExtras().GetIndex();
     196                 :            : }
     197                 :            : 
     198                 :      13200 : bool SwCursor::IsSelOvrCheck(int)
     199                 :            : {
     200                 :      13200 :     return false;
     201                 :            : }
     202                 :            : 
     203                 :            : // extracted from IsSelOvr()
     204                 :         34 : bool SwTableCursor::IsSelOvrCheck(int eFlags)
     205                 :            : {
     206                 :         34 :     SwNodes& rNds = GetDoc()->GetNodes();
     207                 :            :     // check sections of nodes array
     208         [ +  + ]:         62 :     if( (nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION & eFlags)
           [ +  +  +  + ]
     209                 :         28 :         && HasMark() )
     210                 :            :     {
     211         [ +  - ]:         10 :         SwNodeIndex aOldPos( rNds, GetSavePos()->nNode );
     212 [ +  - ][ -  + ]:         10 :         if( !CheckNodesRange( aOldPos, GetPoint()->nNode, sal_True ))
     213                 :            :         {
     214         [ #  # ]:          0 :             GetPoint()->nNode = aOldPos;
     215 [ #  # ][ #  # ]:          0 :             GetPoint()->nContent.Assign( GetCntntNode(), GetSavePos()->nCntnt );
     216                 :         10 :             return true;
     217 [ +  - ][ +  - ]:         10 :         }
     218                 :            :     }
     219                 :         34 :     return SwCursor::IsSelOvrCheck(eFlags);
     220                 :            : }
     221                 :            : 
     222                 :      13200 : sal_Bool SwCursor::IsSelOvr( int eFlags )
     223                 :            : {
     224                 :      13200 :     SwDoc* pDoc = GetDoc();
     225                 :      13200 :     SwNodes& rNds = pDoc->GetNodes();
     226                 :            : 
     227                 :      13200 :     sal_Bool bSkipOverHiddenSections = IsSkipOverHiddenSections();
     228                 :      13200 :     sal_Bool bSkipOverProtectSections = IsSkipOverProtectSections();
     229                 :            : 
     230         [ -  + ]:      13200 :     if ( IsSelOvrCheck( eFlags ) )
     231                 :            :     {
     232                 :          0 :         return sal_True;
     233                 :            :     }
     234                 :            : 
     235   [ +  +  +  -  :      19046 :     if( pSavePos->nNode != GetPoint()->nNode.GetIndex() &&
           +  - ][ +  + ]
     236                 :            :         // (1997) in UI-ReadOnly everything is allowed
     237                 :       5846 :         ( !pDoc->GetDocShell() || !pDoc->GetDocShell()->IsReadOnlyUI() ))
     238                 :            :     {
     239                 :            :         // check new sections
     240                 :       2923 :         SwNodeIndex& rPtIdx = GetPoint()->nNode;
     241                 :       2923 :         const SwSectionNode* pSectNd = rPtIdx.GetNode().FindSectionNode();
     242   [ -  +  #  # ]:       2923 :         if( pSectNd &&
           [ -  +  #  # ]
         [ -  + ][ +  + ]
     243                 :          0 :             ((bSkipOverHiddenSections && pSectNd->GetSection().IsHiddenFlag() ) ||
     244                 :          0 :              (bSkipOverProtectSections && pSectNd->GetSection().IsProtectFlag() )))
     245                 :            :         {
     246         [ #  # ]:          0 :             if( 0 == ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) )
     247                 :            :             {
     248                 :            :                 // then we're already done
     249         [ #  # ]:          0 :                 RestoreSavePos();
     250                 :          0 :                 return sal_True;
     251                 :            :             }
     252                 :            : 
     253                 :            :             // set cursor to new position:
     254         [ #  # ]:          0 :             SwNodeIndex aIdx( rPtIdx );
     255                 :          0 :             xub_StrLen nCntntPos = pSavePos->nCntnt;
     256                 :          0 :             int bGoNxt = pSavePos->nNode < rPtIdx.GetIndex();
     257                 :            :             SwCntntNode* pCNd = bGoNxt
     258                 :          0 :                     ? rNds.GoNextSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections)
     259 [ #  # ][ #  # ]:          0 :                     : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections);
                 [ #  # ]
     260 [ #  # ][ #  # ]:          0 :             if( !pCNd && ( nsSwCursorSelOverFlags::SELOVER_ENABLEREVDIREKTION & eFlags ))
     261                 :            :             {
     262                 :          0 :                 bGoNxt = !bGoNxt;
     263                 :          0 :                 pCNd = bGoNxt ? rNds.GoNextSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections)
     264 [ #  # ][ #  # ]:          0 :                               : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections);
                 [ #  # ]
     265                 :            :             }
     266                 :            : 
     267                 :          0 :             int bIsValidPos = 0 != pCNd;
     268                 :            :             sal_Bool bValidNodesRange = bIsValidPos &&
     269 [ #  # ][ #  # ]:          0 :                                     ::CheckNodesRange( rPtIdx, aIdx, sal_True );
                 [ #  # ]
     270         [ #  # ]:          0 :             if( !bValidNodesRange )
     271                 :            :             {
     272         [ #  # ]:          0 :                 rPtIdx = pSavePos->nNode;
     273         [ #  # ]:          0 :                 if( 0 == ( pCNd = rPtIdx.GetNode().GetCntntNode() ) )
     274                 :            :                 {
     275                 :          0 :                     bIsValidPos = sal_False;
     276                 :          0 :                     nCntntPos = 0;
     277         [ #  # ]:          0 :                     rPtIdx = aIdx;
     278         [ #  # ]:          0 :                     if( 0 == ( pCNd = rPtIdx.GetNode().GetCntntNode() ) )
     279                 :            :                     {
     280                 :            :                         // then to the beginning of the document
     281         [ #  # ]:          0 :                         rPtIdx = rNds.GetEndOfExtras();
     282         [ #  # ]:          0 :                         pCNd = rNds.GoNext( &rPtIdx );
     283                 :            :                     }
     284                 :            :                 }
     285                 :            :             }
     286                 :            : 
     287                 :            :             // register ContentIndex:
     288 [ #  # ][ #  # ]:          0 :             xub_StrLen nTmpPos = bIsValidPos ? (bGoNxt ? 0 : pCNd->Len()) : nCntntPos;
                 [ #  # ]
     289 [ #  # ][ #  # ]:          0 :             GetPoint()->nContent.Assign( pCNd, nTmpPos );
     290 [ #  # ][ #  # ]:          0 :             if( !bIsValidPos || !bValidNodesRange ||
         [ #  # ][ #  # ]
     291         [ #  # ]:          0 :                 IsInProtectTable( sal_True ) )
     292 [ #  # ][ #  # ]:          0 :                 return sal_True;
     293                 :            :         }
     294                 :            : 
     295                 :            :         // is there a protected section in the section?
     296 [ +  + ][ -  + ]:       2923 :         if( HasMark() && bSkipOverProtectSections)
                 [ -  + ]
     297                 :            :         {
     298                 :          0 :             sal_uLong nSttIdx = GetMark()->nNode.GetIndex(),
     299                 :          0 :                   nEndIdx = GetPoint()->nNode.GetIndex();
     300         [ #  # ]:          0 :             if( nEndIdx <= nSttIdx )
     301                 :            :             {
     302                 :          0 :                 sal_uLong nTmp = nSttIdx;
     303                 :          0 :                 nSttIdx = nEndIdx;
     304                 :          0 :                 nEndIdx = nTmp;
     305                 :            :             }
     306                 :            : 
     307                 :          0 :             const SwSectionFmts& rFmts = pDoc->GetSections();
     308         [ #  # ]:          0 :             for( sal_uInt16 n = 0; n < rFmts.size(); ++n )
     309                 :            :             {
     310                 :          0 :                 const SwSectionFmt* pFmt = rFmts[n];
     311                 :          0 :                 const SvxProtectItem& rProtect = pFmt->GetProtect();
     312         [ #  # ]:          0 :                 if( rProtect.IsCntntProtected() )
     313                 :            :                 {
     314                 :          0 :                     const SwFmtCntnt& rCntnt = pFmt->GetCntnt(sal_False);
     315                 :            :                     OSL_ENSURE( rCntnt.GetCntntIdx(), "No SectionNode?" );
     316                 :          0 :                     sal_uLong nIdx = rCntnt.GetCntntIdx()->GetIndex();
     317 [ #  # ][ #  # ]:          0 :                     if( nSttIdx <= nIdx && nEndIdx >= nIdx )
     318                 :            :                     {
     319                 :            :                         // if it is no linked section then we cannot select it
     320                 :          0 :                         const SwSection& rSect = *pFmt->GetSection();
     321         [ #  # ]:          0 :                         if( CONTENT_SECTION == rSect.GetType() )
     322                 :            :                         {
     323                 :          0 :                             RestoreSavePos();
     324                 :          0 :                             return sal_True;
     325                 :            :                         }
     326                 :            :                     }
     327                 :            :                 }
     328                 :            :             }
     329                 :            :         }
     330                 :            : 
     331                 :            :     }
     332                 :            : 
     333                 :      13200 :     const SwNode* pNd = &GetPoint()->nNode.GetNode();
     334 [ +  - ][ +  + ]:      13200 :     if( pNd->IsCntntNode() && !dynamic_cast<SwUnoCrsr*>(this) )
         [ +  + ][ +  - ]
     335                 :            :     {
     336         [ +  - ]:        163 :         const SwCntntFrm* pFrm = ((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() );
     337 [ +  + ][ -  + ]:        163 :         if( pFrm && pFrm->IsValid() && 0 == pFrm->Frm().Height() &&
         [ #  # ][ -  + ]
                 [ +  - ]
     338                 :            :             0 != ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) )
     339                 :            :         {
     340                 :            :             // skip to the next/prev valid paragraph with a layout
     341                 :          0 :             SwNodeIndex& rPtIdx = GetPoint()->nNode;
     342                 :          0 :             int bGoNxt = pSavePos->nNode < rPtIdx.GetIndex();
     343         [ #  # ]:          0 :             while( 0 != ( pFrm = ( bGoNxt ? pFrm->GetNextCntntFrm()
           [ #  #  #  # ]
                 [ #  # ]
     344                 :            :                                           : pFrm->GetPrevCntntFrm() )) &&
     345                 :          0 :                     0 == pFrm->Frm().Height() )
     346                 :            :                 ;
     347                 :            : 
     348                 :            :             // #i72394# skip to prev/next valid paragraph with a layout in case
     349                 :            :             // the first search did not succeed:
     350         [ #  # ]:          0 :             if( !pFrm )
     351                 :            :             {
     352                 :          0 :                 bGoNxt = !bGoNxt;
     353         [ #  # ]:          0 :                 pFrm = ((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() );
     354 [ #  # ][ #  # ]:          0 :                 while ( pFrm && 0 == pFrm->Frm().Height() )
                 [ #  # ]
     355                 :            :                 {
     356                 :            :                     pFrm = bGoNxt ? pFrm->GetNextCntntFrm()
     357         [ #  # ]:          0 :                         :   pFrm->GetPrevCntntFrm();
     358                 :            :                 }
     359                 :            :             }
     360                 :            : 
     361                 :            :             SwCntntNode* pCNd;
     362 [ #  # ][ #  # ]:          0 :             if( pFrm && 0 != (pCNd = (SwCntntNode*)pFrm->GetNode()) )
                 [ #  # ]
     363                 :            :             {
     364                 :            :                 // set this CntntNode as new position
     365                 :          0 :                 rPtIdx = *pCNd;
     366         [ #  # ]:          0 :                 pNd = pCNd;
     367                 :            : 
     368                 :            :                 // register ContentIndex:
     369         [ #  # ]:          0 :                 xub_StrLen nTmpPos = bGoNxt ? 0 : pCNd->Len();
     370         [ #  # ]:          0 :                 GetPoint()->nContent.Assign( pCNd, nTmpPos );
     371                 :            : 
     372         [ #  # ]:          0 :                 if( IsInProtectTable( sal_True ) )
     373                 :          0 :                     pFrm = 0;
     374                 :            :             }
     375                 :            :         }
     376                 :            : 
     377         [ -  + ]:        163 :         if( !pFrm )
     378                 :            :         {
     379                 :          0 :             DeleteMark();
     380                 :          0 :             RestoreSavePos();
     381                 :          0 :             return sal_True; // we need a frame
     382                 :            :         }
     383                 :            :     }
     384                 :            : 
     385                 :            :     // is the cursor allowed to be in a protected node?
     386 [ +  + ][ -  + ]:      13200 :     if( 0 == ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) && !IsAtValidPos() )
                 [ -  + ]
     387                 :            :     {
     388                 :          0 :         DeleteMark();
     389                 :          0 :         RestoreSavePos();
     390                 :          0 :         return sal_True;
     391                 :            :     }
     392                 :            : 
     393         [ +  + ]:      13200 :     if( !HasMark() )
     394                 :       2733 :         return sal_False;
     395                 :            : 
     396                 :            :     // check for invalid sections
     397         [ -  + ]:      10467 :     if( !::CheckNodesRange( GetMark()->nNode, GetPoint()->nNode, sal_True ))
     398                 :            :     {
     399                 :          0 :         DeleteMark();
     400                 :          0 :         RestoreSavePos();
     401                 :          0 :         return sal_True; // we need a frame
     402                 :            :     }
     403                 :            : 
     404                 :      10467 :     const SwTableNode* pPtNd = pNd->FindTableNode();
     405                 :            : 
     406 [ +  - ][ -  + ]:      23153 :     if( (pNd = &GetMark()->nNode.GetNode())->IsCntntNode() &&
           [ +  -  +  + ]
     407 [ +  - ][ -  + ]:      12686 :         !((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() ) && !dynamic_cast<SwUnoCrsr*>(this) )
     408                 :            :     {
     409                 :          0 :         DeleteMark();
     410                 :          0 :         RestoreSavePos();
     411                 :          0 :         return sal_True; // we need a frame
     412                 :            :     }
     413                 :            : 
     414                 :      10467 :     const SwTableNode* pMrkNd = pNd->FindTableNode();
     415                 :            : 
     416                 :            :     // both in no or in same table node
     417 [ -  + ][ +  - ]:      10467 :     if( ( !pMrkNd && !pPtNd ) || pPtNd == pMrkNd )
                 [ +  + ]
     418                 :      10467 :         return sal_False;
     419                 :            : 
     420                 :            :     // in different tables or only mark in table
     421 [ #  # ][ #  # ]:          0 :     if( ( pPtNd && pMrkNd ) || pMrkNd )
                 [ #  # ]
     422                 :            :     {
     423                 :            :         // not allowed, so go back to old position
     424                 :          0 :         RestoreSavePos();
     425                 :            :         // Crsr stays at old position
     426                 :          0 :         return sal_True;
     427                 :            :     }
     428                 :            : 
     429                 :            :     // Note: this cannot happen in TableMode
     430         [ #  # ]:          0 :     if( pPtNd )     // if only Point in Table then go behind/in front of table
     431                 :            :     {
     432         [ #  # ]:          0 :         if( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags )
     433                 :            :         {
     434                 :          0 :             sal_Bool bSelTop = GetPoint()->nNode.GetIndex() <
     435                 :            :                     (( nsSwCursorSelOverFlags::SELOVER_TOGGLE & eFlags ) ? pSavePos->nNode
     436         [ #  # ]:          0 :                                                  : GetMark()->nNode.GetIndex());
     437                 :            : 
     438                 :          0 :             do { // loop for table after table
     439                 :          0 :                 sal_uLong nSEIdx = pPtNd->EndOfSectionIndex();
     440                 :          0 :                 sal_uLong nSttEndTbl = nSEIdx + 1;
     441                 :            : 
     442         [ #  # ]:          0 :                 if( bSelTop )
     443                 :          0 :                     nSttEndTbl = rNds[ nSEIdx ]->StartOfSectionIndex() - 1;
     444                 :            : 
     445                 :          0 :                 GetPoint()->nNode = nSttEndTbl;
     446                 :          0 :                 const SwNode* pMyNd = GetNode();
     447                 :            : 
     448   [ #  #  #  # ]:          0 :                 if( pMyNd->IsSectionNode() || ( pMyNd->IsEndNode() &&
         [ #  # ][ #  # ]
     449                 :          0 :                     pMyNd->StartOfSectionNode()->IsSectionNode() ) )
     450                 :            :                 {
     451                 :            :                     pMyNd = bSelTop
     452                 :          0 :                         ? rNds.GoPrevSection( &GetPoint()->nNode,sal_True,sal_False )
     453 [ #  # ][ #  # ]:          0 :                         : rNds.GoNextSection( &GetPoint()->nNode,sal_True,sal_False );
     454                 :            : 
     455                 :            :                     /* #i12312# Handle failure of Go{Prev|Next}Section */
     456         [ #  # ]:          0 :                     if ( 0 == pMyNd)
     457                 :          0 :                         break;
     458                 :            : 
     459         [ #  # ]:          0 :                     if( 0 != ( pPtNd = pMyNd->FindTableNode() ))
     460                 :          0 :                         continue;
     461                 :            :                 }
     462                 :            : 
     463                 :            :                 // we permit these
     464   [ #  #  #  # ]:          0 :                 if( pMyNd->IsCntntNode() &&
                 [ #  # ]
     465                 :          0 :                     ::CheckNodesRange( GetMark()->nNode,
     466                 :          0 :                                        GetPoint()->nNode, sal_True ))
     467                 :            :                 {
     468                 :            :                     // table in table
     469                 :          0 :                     const SwTableNode* pOuterTableNd = pMyNd->FindTableNode();
     470         [ #  # ]:          0 :                     if ( pOuterTableNd )
     471                 :          0 :                         pMyNd = pOuterTableNd;
     472                 :            :                     else
     473                 :            :                     {
     474         [ #  # ]:          0 :                         SwCntntNode* pCNd = (SwCntntNode*)pMyNd;
     475         [ #  # ]:          0 :                         xub_StrLen nTmpPos = bSelTop ? pCNd->Len() : 0;
     476         [ #  # ]:          0 :                         GetPoint()->nContent.Assign( pCNd, nTmpPos );
     477                 :          0 :                         return sal_False;
     478                 :            :                     }
     479                 :            :                 }
     480   [ #  #  #  # ]:          0 :                 if( bSelTop
         [ #  # ][ #  # ]
     481                 :          0 :                     ? ( !pMyNd->IsEndNode() || 0 == ( pPtNd = pMyNd->FindTableNode() ))
     482                 :            :                     : 0 == ( pPtNd = pMyNd->GetTableNode() ))
     483                 :          0 :                     break;
     484                 :            :             } while( sal_True );
     485                 :            :         }
     486                 :            : 
     487                 :            :         // stay on old position
     488                 :          0 :         RestoreSavePos();
     489                 :          0 :         return sal_True;
     490                 :            :     }
     491                 :      13200 :     return sal_False;
     492                 :            : }
     493                 :            : 
     494                 :            : #if defined( UNX )
     495                 :            : #define IDX     (*pCellStt)
     496                 :            : #else
     497                 :            : #define IDX     aCellStt
     498                 :            : #endif
     499                 :            : 
     500                 :            : 
     501                 :      13392 : sal_Bool SwCursor::IsInProtectTable( sal_Bool bMove, sal_Bool bChgCrsr )
     502                 :            : {
     503                 :      13392 :     SwCntntNode* pCNd = GetCntntNode();
     504         [ -  + ]:      13392 :     if( !pCNd )
     505                 :          0 :         return sal_False;
     506                 :            : 
     507                 :            :     // No table, no protected cell:
     508                 :      13392 :     const SwTableNode* pTableNode = pCNd->FindTableNode();
     509         [ +  + ]:      13392 :     if ( !pTableNode )
     510                 :      12947 :         return sal_False;
     511                 :            : 
     512                 :            :     // Current position == last save position?
     513         [ +  + ]:        445 :     if ( pSavePos->nNode == GetPoint()->nNode.GetIndex() )
     514                 :        343 :         return sal_False;
     515                 :            : 
     516                 :            :     // Check for convered cell:
     517                 :        102 :     bool bInCoveredCell = false;
     518                 :        102 :     const SwStartNode* pTmpSttNode = pCNd->FindTableBoxStartNode();
     519                 :            :     OSL_ENSURE( pTmpSttNode, "In table, therefore I expect to get a SwTableBoxStartNode" );
     520         [ +  - ]:        102 :     const SwTableBox* pBox = pTmpSttNode ? pTableNode->GetTable().GetTblBox( pTmpSttNode->GetIndex() ) : 0; //Robust #151355
     521 [ +  - ][ -  + ]:        102 :     if ( pBox && pBox->getRowSpan() < 1 ) // Robust #151270
                 [ -  + ]
     522                 :          0 :         bInCoveredCell = true;
     523                 :            : 
     524                 :            :     // Positions of covered cells are not acceptable:
     525         [ +  - ]:        102 :     if ( !bInCoveredCell )
     526                 :            :     {
     527                 :            :         // Position not protected?
     528         [ +  - ]:        102 :         if ( !pCNd->IsProtect() )
     529                 :        102 :             return sal_False;
     530                 :            : 
     531                 :            :         // Cursor in protected cells allowed?
     532         [ #  # ]:          0 :         if ( IsReadOnlyAvailable() )
     533                 :          0 :             return sal_False;
     534                 :            :     }
     535                 :            : 
     536                 :            :     // If we reach this point, we are in a protected or covered table cell!
     537                 :            : 
     538         [ #  # ]:          0 :     if( !bMove )
     539                 :            :     {
     540         [ #  # ]:          0 :         if( bChgCrsr )
     541                 :            :             // restore the last save position
     542                 :          0 :             RestoreSavePos();
     543                 :          0 :         return sal_True; // Crsr stays at old position
     544                 :            :     }
     545                 :            : 
     546                 :            :     // We are in a protected table cell. Traverse top to bottom?
     547         [ #  # ]:          0 :     if( pSavePos->nNode < GetPoint()->nNode.GetIndex() )
     548                 :            :     {
     549                 :            :         // search next valid box
     550                 :            :         // if there is another StartNode after the EndNode of a cell then
     551                 :            :         // there is another cell
     552                 :            : #if defined( UNX )
     553                 :            :         SwNodeIndex* pCellStt = new SwNodeIndex( *GetNode()->
     554         [ #  # ]:          0 :                         FindTableBoxStartNode()->EndOfSectionNode(), 1 );
     555                 :            : #else
     556                 :            :         SwNodeIndex aCellStt( *GetNode()->FindTableBoxStartNode()->EndOfSectionNode(), 1 );
     557                 :            : #endif
     558                 :          0 :         sal_Bool bProt = sal_True;
     559                 :            : GoNextCell:
     560         [ #  # ]:          0 :         do {
     561         [ #  # ]:          0 :             if( !IDX.GetNode().IsStartNode() )
     562                 :          0 :                 break;
     563                 :          0 :             IDX++;
     564         [ #  # ]:          0 :             if( 0 == ( pCNd = IDX.GetNode().GetCntntNode() ))
     565                 :          0 :                 pCNd = IDX.GetNodes().GoNext( &IDX );
     566         [ #  # ]:          0 :             if( 0 == ( bProt = pCNd->IsProtect() ))
     567                 :          0 :                 break;
     568                 :          0 :             IDX.Assign( *pCNd->FindTableBoxStartNode()->EndOfSectionNode(), 1 );
     569                 :            :         } while( bProt );
     570                 :            : 
     571                 :            : SetNextCrsr:
     572         [ #  # ]:          0 :         if( !bProt ) // found free cell
     573                 :            :         {
     574                 :          0 :             GetPoint()->nNode = IDX;
     575                 :            : #if defined( UNX )
     576         [ #  # ]:          0 :             delete pCellStt;
     577                 :            : #endif
     578                 :          0 :             SwCntntNode* pTmpCNd = GetCntntNode();
     579         [ #  # ]:          0 :             if( pTmpCNd )
     580                 :            :             {
     581         [ #  # ]:          0 :                 GetPoint()->nContent.Assign( pTmpCNd, 0 );
     582                 :          0 :                 return sal_False;
     583                 :            :             }
     584                 :            :             return IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
     585                 :          0 :                              nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
     586                 :            :         }
     587                 :            :         // end of table, so go to next node
     588                 :          0 :         IDX++;
     589                 :            :         SwNode* pNd;
     590 [ #  # ][ #  # ]:          0 :         if( ( pNd = &IDX.GetNode())->IsEndNode() || HasMark())
                 [ #  # ]
     591                 :            :         {
     592                 :            :             // if only table in FlyFrame or SSelection then stay on old position
     593         [ #  # ]:          0 :             if( bChgCrsr )
     594                 :          0 :                 RestoreSavePos();
     595                 :            : #if defined( UNX )
     596         [ #  # ]:          0 :             delete pCellStt;
     597                 :            : #endif
     598                 :          0 :             return sal_True;
     599                 :            :         }
     600 [ #  # ][ #  # ]:          0 :         else if( pNd->IsTableNode() && IDX++ )
                 [ #  # ]
     601                 :          0 :             goto GoNextCell;
     602                 :            : 
     603                 :          0 :         bProt = sal_False; // index is now on a content node
     604                 :          0 :         goto SetNextCrsr;
     605                 :            :     }
     606                 :            : 
     607                 :            :     // search for the previous valid box
     608                 :            :     {
     609                 :            :         // if there is another EndNode in front of the StartNode than there
     610                 :            :         // exists a previous cell
     611                 :            : #if defined( UNX )
     612                 :            :         SwNodeIndex* pCellStt = new SwNodeIndex(
     613         [ #  # ]:          0 :                     *GetNode()->FindTableBoxStartNode(), -1 );
     614                 :            : #else
     615                 :            :         SwNodeIndex aCellStt( *GetNode()->FindTableBoxStartNode(), -1 );
     616                 :            : #endif
     617                 :            :         SwNode* pNd;
     618                 :          0 :         sal_Bool bProt = sal_True;
     619                 :            : GoPrevCell:
     620         [ #  # ]:          0 :         do {
     621         [ #  # ]:          0 :             if( !( pNd = &IDX.GetNode())->IsEndNode() )
     622                 :          0 :                 break;
     623                 :          0 :             IDX.Assign( *pNd->StartOfSectionNode(), +1 );
     624         [ #  # ]:          0 :             if( 0 == ( pCNd = IDX.GetNode().GetCntntNode() ))
     625                 :          0 :                 pCNd = pNd->GetNodes().GoNext( &IDX );
     626         [ #  # ]:          0 :             if( 0 == ( bProt = pCNd->IsProtect() ))
     627                 :          0 :                 break;
     628                 :          0 :             IDX.Assign( *pNd->FindTableBoxStartNode(), -1 );
     629                 :            :         } while( bProt );
     630                 :            : 
     631                 :            : SetPrevCrsr:
     632         [ #  # ]:          0 :         if( !bProt ) // found free cell
     633                 :            :         {
     634                 :          0 :             GetPoint()->nNode = IDX;
     635                 :            : #if defined( UNX )
     636         [ #  # ]:          0 :             delete pCellStt;
     637                 :            : #endif
     638                 :          0 :             SwCntntNode* pTmpCNd = GetCntntNode();
     639         [ #  # ]:          0 :             if( pTmpCNd )
     640                 :            :             {
     641         [ #  # ]:          0 :                 GetPoint()->nContent.Assign( pTmpCNd, 0 );
     642                 :          0 :                 return sal_False;
     643                 :            :             }
     644                 :            :             return IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
     645                 :          0 :                              nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
     646                 :            :         }
     647                 :            :         // at the beginning of a table, so go to next node
     648                 :          0 :         IDX--;
     649 [ #  # ][ #  # ]:          0 :         if( ( pNd = &IDX.GetNode())->IsStartNode() || HasMark() )
                 [ #  # ]
     650                 :            :         {
     651                 :            :             // if only table in FlyFrame or SSelection then stay on old position
     652         [ #  # ]:          0 :             if( bChgCrsr )
     653                 :          0 :                 RestoreSavePos();
     654                 :            : #if defined( UNX )
     655         [ #  # ]:          0 :             delete pCellStt;
     656                 :            : #endif
     657                 :          0 :             return sal_True;
     658                 :            :         }
     659 [ #  # ][ #  # ]:          0 :         else if( pNd->StartOfSectionNode()->IsTableNode() && IDX-- )
                 [ #  # ]
     660                 :          0 :             goto GoPrevCell;
     661                 :            : 
     662                 :          0 :         bProt = sal_False; // index is now on a content node
     663                 :      13392 :         goto SetPrevCrsr;
     664                 :            :     }
     665                 :            : }
     666                 :            : 
     667                 :            : /// Return <true> if cursor can be set to this position
     668                 :         40 : sal_Bool SwCursor::IsAtValidPos( sal_Bool bPoint ) const
     669                 :            : {
     670                 :         40 :     const SwDoc* pDoc = GetDoc();
     671         [ +  - ]:         40 :     const SwPosition* pPos = bPoint ? GetPoint() : GetMark();
     672                 :         40 :     const SwNode* pNd = &pPos->nNode.GetNode();
     673                 :            : 
     674 [ +  - ][ -  + ]:         40 :     if( pNd->IsCntntNode() && !((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() ) &&
         [ #  # ][ -  + ]
                 [ +  - ]
     675         [ #  # ]:          0 :         !dynamic_cast<const SwUnoCrsr*>(this) )
     676                 :            :     {
     677                 :          0 :         return sal_False;
     678                 :            :     }
     679                 :            : 
     680                 :            :     // #i45129# - in UI-ReadOnly everything is allowed
     681 [ +  - ][ +  - ]:         40 :     if( !pDoc->GetDocShell() || !pDoc->GetDocShell()->IsReadOnlyUI() )
                 [ +  - ]
     682                 :         40 :         return sal_True;
     683                 :            : 
     684                 :          0 :     sal_Bool bCrsrInReadOnly = IsReadOnlyAvailable();
     685 [ #  # ][ #  # ]:          0 :     if( !bCrsrInReadOnly && pNd->IsProtect() )
                 [ #  # ]
     686                 :          0 :         return sal_False;
     687                 :            : 
     688                 :          0 :     const SwSectionNode* pSectNd = pNd->FindSectionNode();
     689         [ #  # ]:          0 :     if( pSectNd && (pSectNd->GetSection().IsHiddenFlag() ||
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     690                 :          0 :                     ( !bCrsrInReadOnly && pSectNd->GetSection().IsProtectFlag() )))
     691                 :          0 :         return sal_False;
     692                 :            : 
     693                 :         40 :     return sal_True;
     694                 :            : }
     695                 :            : 
     696                 :         88 : void SwCursor::SaveTblBoxCntnt( const SwPosition* ) {}
     697                 :            : 
     698                 :            : /// set range for search in document
     699                 :         18 : SwMoveFnCollection* SwCursor::MakeFindRange( SwDocPositions nStart,
     700                 :            :                                 SwDocPositions nEnd, SwPaM* pRange ) const
     701                 :            : {
     702                 :         18 :     pRange->SetMark();
     703                 :         18 :     FillFindPos( nStart, *pRange->GetMark() );
     704                 :         18 :     FillFindPos( nEnd, *pRange->GetPoint() );
     705                 :            : 
     706                 :            :     // determine direction of search
     707                 :            :     return ( DOCPOS_START == nStart || DOCPOS_OTHERSTART == nStart ||
     708                 :            :               (DOCPOS_CURR == nStart &&
     709                 :            :                 (DOCPOS_END == nEnd || DOCPOS_OTHEREND == nEnd ) ))
     710 [ +  - ][ +  - ]:         18 :                 ? fnMoveForward : fnMoveBackward;
         [ -  + ][ #  # ]
                 [ +  + ]
     711                 :            : }
     712                 :            : 
     713                 :            : 
     714                 :         10 : sal_uLong lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr,
     715                 :            :                         SwMoveFn fnMove, SwCursor*& pFndRing,
     716                 :            :                         SwPaM& aRegion, FindRanges eFndRngs,
     717                 :            :                         sal_Bool bInReadOnly, sal_Bool& bCancel )
     718                 :            : {
     719                 :         10 :     SwDoc* pDoc = pCurCrsr->GetDoc();
     720                 :         10 :     bool const bDoesUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
     721                 :         10 :     int nFndRet = 0;
     722                 :         10 :     sal_uLong nFound = 0;
     723                 :         10 :     int bSrchBkwrd = fnMove == fnMoveBackward, bEnde = sal_False;
     724                 :         10 :     SwPaM *pTmpCrsr = pCurCrsr, *pSaveCrsr = pCurCrsr;
     725                 :            : 
     726                 :            :     // only create progress bar for ShellCrsr
     727 [ +  - ][ +  - ]:         10 :     bool bIsUnoCrsr = 0 != dynamic_cast<SwUnoCrsr*>(pCurCrsr);
     728                 :         10 :     _PercentHdl* pPHdl = 0;
     729                 :         10 :     sal_uInt16 nCrsrCnt = 0;
     730         [ -  + ]:         10 :     if( FND_IN_SEL & eFndRngs )
     731                 :            :     {
     732         [ #  # ]:          0 :         while( pCurCrsr != ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ))
     733                 :          0 :             ++nCrsrCnt;
     734 [ #  # ][ #  # ]:          0 :         if( nCrsrCnt && !bIsUnoCrsr )
     735         [ #  # ]:          0 :             pPHdl = new _PercentHdl( 0, nCrsrCnt, pDoc->GetDocShell() );
     736                 :            :     }
     737                 :            :     else
     738                 :         10 :         pSaveCrsr = (SwPaM*)pSaveCrsr->GetPrev();
     739                 :            : 
     740         [ -  + ]:          8 :     do {
     741                 :         10 :         aRegion.SetMark();
     742                 :            :         // independent from search direction: SPoint is always bigger than mark
     743                 :            :         // if the search area is valid
     744                 :         10 :         SwPosition *pSttPos = aRegion.GetMark(),
     745                 :         10 :                         *pEndPos = aRegion.GetPoint();
     746                 :         10 :         *pSttPos = *pTmpCrsr->Start();
     747                 :         10 :         *pEndPos = *pTmpCrsr->End();
     748         [ -  + ]:         10 :         if( bSrchBkwrd )
     749                 :          0 :             aRegion.Exchange();
     750                 :            : 
     751 [ +  - ][ +  - ]:         10 :         if( !nCrsrCnt && !pPHdl && !bIsUnoCrsr )
                 [ -  + ]
     752         [ #  # ]:          0 :             pPHdl = new _PercentHdl( aRegion );
     753                 :            : 
     754                 :            :         // as long as found and not at same position
     755 [ +  - ][ +  + ]:        242 :         while(  *pSttPos <= *pEndPos &&
           [ +  +  -  +  
           #  # ][ +  + ]
     756                 :            :                 0 != ( nFndRet = rParas.Find( pCurCrsr, fnMove,
     757                 :        172 :                                             &aRegion, bInReadOnly )) &&
     758                 :        162 :                 ( !pFndRing ||
     759                 :         70 :                     *pFndRing->GetPoint() != *pCurCrsr->GetPoint() ||
     760                 :          0 :                     *pFndRing->GetMark() != *pCurCrsr->GetMark() ))
     761                 :            :         {
     762         [ +  + ]:        162 :             if( !( FIND_NO_RING & nFndRet ))
     763                 :            :             {
     764                 :            :                 // #i24084# - create ring similar to the one in CreateCrsr
     765                 :         74 :                 SwCursor* pNew = pCurCrsr->Create( pFndRing );
     766         [ +  + ]:         74 :                 if( !pFndRing )
     767                 :          4 :                     pFndRing = pNew;
     768                 :            : 
     769                 :         74 :                 pNew->SetMark();
     770                 :         74 :                 *pNew->GetMark() = *pCurCrsr->GetMark();
     771                 :            :             }
     772                 :            : 
     773                 :        162 :             ++nFound;
     774                 :            : 
     775         [ -  + ]:        162 :             if( !( eFndRngs & FND_IN_SELALL) )
     776                 :            :             {
     777                 :          0 :                 bEnde = sal_True;
     778                 :          0 :                 break;
     779                 :            :             }
     780                 :            : 
     781   [ -  +  #  #  :        162 :             if ((coSrchRplcThreshold == nFound)
           #  # ][ -  + ]
     782                 :          0 :                 && pDoc->GetIDocumentUndoRedo().DoesUndo()
     783                 :          0 :                 && rParas.IsReplaceMode())
     784                 :            :             {
     785                 :          0 :                 short nRet = pCurCrsr->MaxReplaceArived();
     786         [ #  # ]:          0 :                 if( RET_YES == nRet )
     787                 :            :                 {
     788                 :          0 :                     pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
     789                 :          0 :                     pDoc->GetIDocumentUndoRedo().DoUndo(false);
     790                 :            :                 }
     791                 :            :                 else
     792                 :            :                 {
     793                 :          0 :                     bEnde = sal_True;
     794         [ #  # ]:          0 :                     if(RET_CANCEL == nRet)
     795                 :            :                     {
     796                 :          0 :                         bCancel = sal_True;
     797                 :            :                     }
     798                 :          0 :                     break;
     799                 :            :                 }
     800                 :            :             }
     801                 :            : 
     802         [ -  + ]:        162 :             if( bSrchBkwrd )
     803                 :            :                 // move pEndPos in front of the found area
     804                 :          0 :                 *pEndPos = *pCurCrsr->Start();
     805                 :            :             else
     806                 :            :                 // move pSttPos behind the found area
     807                 :        162 :                 *pSttPos = *pCurCrsr->End();
     808                 :            : 
     809         [ -  + ]:        162 :             if( *pSttPos == *pEndPos )
     810                 :            :                 // in area but at the end => done
     811                 :          0 :                 break;
     812                 :            : 
     813 [ +  - ][ -  + ]:        162 :             if( !nCrsrCnt && pPHdl )
     814                 :            :             {
     815                 :          0 :                 pPHdl->NextPos( *aRegion.GetMark() );
     816                 :            :             }
     817                 :            :         }
     818                 :            : 
     819 [ +  - ][ +  + ]:         10 :         if( bEnde || !( eFndRngs & ( FND_IN_SELALL | FND_IN_SEL )) )
     820                 :          2 :             break;
     821                 :            : 
     822                 :          8 :         pTmpCrsr = ((SwPaM*)pTmpCrsr->GetNext());
     823 [ #  # ][ -  + ]:          8 :         if( nCrsrCnt && pPHdl )
     824                 :            :         {
     825                 :          0 :             pPHdl->NextPos( ++pPHdl->nActPos );
     826                 :            :         }
     827                 :            : 
     828                 :            :     } while( pTmpCrsr != pSaveCrsr );
     829                 :            : 
     830 [ +  + ][ +  + ]:         10 :     if( nFound && !pFndRing ) // if no ring should be created
     831                 :          4 :         pFndRing = pCurCrsr->Create();
     832                 :            : 
     833         [ -  + ]:         10 :     delete pPHdl;
     834                 :         10 :     pDoc->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
     835                 :         10 :     return nFound;
     836                 :            : }
     837                 :            : 
     838                 :            : 
     839                 :         10 : int lcl_MakeSelFwrd( const SwNode& rSttNd, const SwNode& rEndNd,
     840                 :            :                         SwPaM& rPam, int bFirst )
     841                 :            : {
     842         [ -  + ]:         10 :     if( rSttNd.GetIndex() + 1 == rEndNd.GetIndex() )
     843                 :          0 :         return sal_False;
     844                 :            : 
     845                 :         10 :     SwNodes& rNds = rPam.GetDoc()->GetNodes();
     846                 :         10 :     rPam.DeleteMark();
     847                 :            :     SwCntntNode* pCNd;
     848         [ +  - ]:         10 :     if( !bFirst )
     849                 :            :     {
     850                 :         10 :         rPam.GetPoint()->nNode = rSttNd;
     851                 :         10 :         pCNd = rNds.GoNext( &rPam.GetPoint()->nNode );
     852         [ -  + ]:         10 :         if( !pCNd )
     853                 :          0 :             return sal_False;
     854                 :         10 :         pCNd->MakeStartIndex( &rPam.GetPoint()->nContent );
     855                 :            :     }
     856   [ #  #  #  # ]:          0 :     else if( rSttNd.GetIndex() > rPam.GetPoint()->nNode.GetIndex() ||
                 [ #  # ]
     857                 :          0 :              rPam.GetPoint()->nNode.GetIndex() >= rEndNd.GetIndex() )
     858                 :            :         // not in this section
     859                 :          0 :         return sal_False;
     860                 :            : 
     861                 :         10 :     rPam.SetMark();
     862                 :         10 :     rPam.GetPoint()->nNode = rEndNd;
     863                 :         10 :     pCNd = rNds.GoPrevious( &rPam.GetPoint()->nNode );
     864         [ -  + ]:         10 :     if( !pCNd )
     865                 :          0 :         return sal_False;
     866                 :         10 :     pCNd->MakeEndIndex( &rPam.GetPoint()->nContent );
     867                 :            : 
     868                 :         10 :     return *rPam.GetMark() < *rPam.GetPoint();
     869                 :            : }
     870                 :            : 
     871                 :            : 
     872                 :          0 : int lcl_MakeSelBkwrd( const SwNode& rSttNd, const SwNode& rEndNd,
     873                 :            :                         SwPaM& rPam, int bFirst )
     874                 :            : {
     875         [ #  # ]:          0 :     if( rEndNd.GetIndex() + 1 == rSttNd.GetIndex() )
     876                 :          0 :         return sal_False;
     877                 :            : 
     878                 :          0 :     SwNodes& rNds = rPam.GetDoc()->GetNodes();
     879                 :          0 :     rPam.DeleteMark();
     880                 :            :     SwCntntNode* pCNd;
     881         [ #  # ]:          0 :     if( !bFirst )
     882                 :            :     {
     883                 :          0 :         rPam.GetPoint()->nNode = rSttNd;
     884                 :          0 :         pCNd = rNds.GoPrevious( &rPam.GetPoint()->nNode );
     885         [ #  # ]:          0 :         if( !pCNd )
     886                 :          0 :             return sal_False;
     887                 :          0 :         pCNd->MakeEndIndex( &rPam.GetPoint()->nContent );
     888                 :            :     }
     889   [ #  #  #  # ]:          0 :     else if( rEndNd.GetIndex() > rPam.GetPoint()->nNode.GetIndex() ||
                 [ #  # ]
     890                 :          0 :              rPam.GetPoint()->nNode.GetIndex() >= rSttNd.GetIndex() )
     891                 :          0 :         return sal_False;       // not in this section
     892                 :            : 
     893                 :          0 :     rPam.SetMark();
     894                 :          0 :     rPam.GetPoint()->nNode = rEndNd;
     895                 :          0 :     pCNd = rNds.GoNext( &rPam.GetPoint()->nNode );
     896         [ #  # ]:          0 :     if( !pCNd )
     897                 :          0 :         return sal_False;
     898                 :          0 :     pCNd->MakeStartIndex( &rPam.GetPoint()->nContent );
     899                 :            : 
     900                 :          0 :     return *rPam.GetPoint() < *rPam.GetMark();
     901                 :            : }
     902                 :            : 
     903                 :            : // this method "searches" for all use cases because in SwFindParas is always the
     904                 :            : // correct parameters and respective search method
     905                 :         18 : sal_uLong SwCursor::FindAll( SwFindParas& rParas,
     906                 :            :                             SwDocPositions nStart, SwDocPositions nEnde,
     907                 :            :                             FindRanges eFndRngs, sal_Bool& bCancel )
     908                 :            : {
     909                 :         18 :     bCancel = sal_False;
     910         [ +  - ]:         18 :     SwCrsrSaveState aSaveState( *this );
     911                 :            : 
     912                 :            :     // create region without adding it to the ring
     913         [ +  - ]:         18 :     SwPaM aRegion( *GetPoint() );
     914         [ +  - ]:         18 :     SwMoveFn fnMove = MakeFindRange( nStart, nEnde, &aRegion );
     915                 :            : 
     916                 :         18 :     sal_uLong nFound = 0;
     917                 :         18 :     int bMvBkwrd = fnMove == fnMoveBackward;
     918         [ +  - ]:         18 :     sal_Bool bInReadOnly = IsReadOnlyAvailable();
     919                 :            : 
     920                 :         18 :     SwCursor* pFndRing = 0;
     921         [ +  - ]:         18 :     SwNodes& rNds = GetDoc()->GetNodes();
     922                 :            : 
     923                 :            :     // search in sections?
     924         [ -  + ]:         18 :     if( FND_IN_SEL & eFndRngs )
     925                 :            :     {
     926                 :            :         // if string was not found in region then get all sections (cursors
     927                 :            :         // stays unchanged)
     928 [ #  # ][ #  # ]:          0 :         if( 0 == ( nFound = lcl_FindSelection( rParas, this, fnMove,
     929                 :            :                                                 pFndRing, aRegion, eFndRngs,
     930                 :          0 :                                                 bInReadOnly, bCancel ) ))
     931                 :          0 :             return nFound;
     932                 :            : 
     933                 :            :         // found string at least once; it's all in new Crsr ring thus delete old one
     934         [ #  # ]:          0 :         while( GetNext() != this )
     935 [ #  # ][ #  # ]:          0 :             delete GetNext();
     936                 :            : 
     937         [ #  # ]:          0 :         *GetPoint() = *pFndRing->GetPoint();
     938         [ #  # ]:          0 :         SetMark();
     939         [ #  # ]:          0 :         *GetMark() = *pFndRing->GetMark();
     940         [ #  # ]:          0 :         pFndRing->MoveRingTo( this );
     941 [ #  # ][ #  # ]:          0 :         delete pFndRing;
     942                 :            :     }
     943         [ +  + ]:         18 :     else if( FND_IN_OTHER & eFndRngs )
     944                 :            :     {
     945                 :            :         // put cursor as copy of current into ring
     946                 :            :         // chaining points always to first created, so forward
     947                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     948         [ +  - ]:          2 :         std::auto_ptr< SwCursor > pSav( Create( this ) ); // save the current cursor
     949                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
     950                 :            : 
     951                 :            :         // if already outside of body text search from this position or start at
     952                 :            :         // 1. base section
     953         [ +  - ]:          2 :         if( bMvBkwrd
     954                 :          0 :             ? lcl_MakeSelBkwrd( rNds.GetEndOfExtras(),
     955                 :          0 :                     *rNds.GetEndOfPostIts().StartOfSectionNode(),
     956                 :          0 :                      *this, rNds.GetEndOfExtras().GetIndex() >=
     957         [ #  # ]:          0 :                     GetPoint()->nNode.GetIndex() )
     958                 :          2 :             : lcl_MakeSelFwrd( *rNds.GetEndOfPostIts().StartOfSectionNode(),
     959                 :          2 :                     rNds.GetEndOfExtras(), *this,
     960                 :          2 :                     rNds.GetEndOfExtras().GetIndex() >=
     961 [ +  - ][ -  + ]:          6 :                     GetPoint()->nNode.GetIndex() ))
     962                 :            :         {
     963                 :            :             nFound = lcl_FindSelection( rParas, this, fnMove, pFndRing,
     964         [ +  - ]:          2 :                                         aRegion, eFndRngs, bInReadOnly, bCancel );
     965                 :            :         }
     966                 :            : 
     967         [ +  - ]:          2 :         if( !nFound )
     968                 :            :         {
     969                 :            :             // put back the old one
     970         [ +  - ]:          2 :             *GetPoint() = *pSav->GetPoint();
     971         [ -  + ]:          2 :             if( pSav->HasMark() )
     972                 :            :             {
     973         [ #  # ]:          0 :                 SetMark();
     974         [ #  # ]:          0 :                 *GetMark() = *pSav->GetMark();
     975                 :            :             }
     976                 :            :             else
     977         [ +  - ]:          2 :                 DeleteMark();
     978                 :          2 :             return 0;
     979                 :            :         }
     980                 :          0 :         pSav.release();
     981                 :            : 
     982         [ #  # ]:          0 :         if( !( FND_IN_SELALL & eFndRngs ))
     983                 :            :         {
     984                 :            :             // there should only be a single one, thus add it
     985                 :            :             // independent from search direction: SPoint is always bigger than
     986                 :            :             // mark if the search area is valid
     987         [ #  # ]:          0 :             *GetPoint() = *pFndRing->GetPoint();
     988         [ #  # ]:          0 :             SetMark();
     989         [ #  # ]:          0 :             *GetMark() = *pFndRing->GetMark();
     990                 :            :         }
     991                 :            :         else
     992                 :            :         {
     993                 :            :             // found string at least once; it's all in new Crsr ring thus delete old one
     994         [ #  # ]:          0 :             while( GetNext() != this )
     995 [ #  # ][ #  # ]:          0 :                 delete GetNext();
     996                 :            : 
     997         [ #  # ]:          0 :             *GetPoint() = *pFndRing->GetPoint();
     998         [ #  # ]:          0 :             SetMark();
     999         [ #  # ]:          0 :             *GetMark() = *pFndRing->GetMark();
    1000         [ #  # ]:          0 :             pFndRing->MoveRingTo( this );
    1001                 :            :         }
    1002 [ #  # ][ #  # ]:          2 :         delete pFndRing;
         [ +  - ][ -  + ]
    1003                 :            :     }
    1004         [ +  + ]:         16 :     else if( FND_IN_SELALL & eFndRngs )
    1005                 :            :     {
    1006                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1007         [ +  - ]:          8 :         ::std::auto_ptr< SwCursor> pSav( Create( this ) );  // save the current cursor
    1008                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1009                 :            : 
    1010                 :            :         const SwNode* pSttNd = ( FND_IN_BODYONLY & eFndRngs )
    1011                 :          0 :                             ? rNds.GetEndOfContent().StartOfSectionNode()
    1012         [ -  + ]:          8 :                             : rNds.GetEndOfPostIts().StartOfSectionNode();
    1013                 :            : 
    1014         [ +  - ]:          8 :         if( bMvBkwrd
    1015         [ #  # ]:          0 :             ? lcl_MakeSelBkwrd( rNds.GetEndOfContent(), *pSttNd,*this, sal_False )
    1016 [ -  + ][ +  - ]:          8 :             : lcl_MakeSelFwrd( *pSttNd, rNds.GetEndOfContent(), *this, sal_False ))
    1017                 :            :         {
    1018                 :            :             nFound = lcl_FindSelection( rParas, this, fnMove, pFndRing,
    1019         [ +  - ]:          8 :                                         aRegion, eFndRngs, bInReadOnly, bCancel );
    1020                 :            :         }
    1021                 :            : 
    1022         [ -  + ]:          8 :         if( !nFound )
    1023                 :            :         {
    1024                 :            :             // put back the old one
    1025         [ #  # ]:          0 :             *GetPoint() = *pSav->GetPoint();
    1026         [ #  # ]:          0 :             if( pSav->HasMark() )
    1027                 :            :             {
    1028         [ #  # ]:          0 :                 SetMark();
    1029         [ #  # ]:          0 :                 *GetMark() = *pSav->GetMark();
    1030                 :            :             }
    1031                 :            :             else
    1032         [ #  # ]:          0 :                 DeleteMark();
    1033                 :          0 :             return 0;
    1034                 :            :         }
    1035                 :          8 :         pSav.release();
    1036         [ +  + ]:         16 :         while( GetNext() != this )
    1037 [ +  - ][ +  - ]:          8 :             delete GetNext();
    1038                 :            : 
    1039         [ +  - ]:          8 :         *GetPoint() = *pFndRing->GetPoint();
    1040         [ +  - ]:          8 :         SetMark();
    1041         [ +  - ]:          8 :         *GetMark() = *pFndRing->GetMark();
    1042         [ +  - ]:          8 :         pFndRing->MoveRingTo( this );
    1043 [ +  - ][ +  - ]:          8 :         delete pFndRing;
         [ +  - ][ +  - ]
    1044                 :            :     }
    1045                 :            :     else
    1046                 :            :     {
    1047                 :            :         // if a GetMark is set then keep the GetMark of the found object
    1048                 :            :         // This allows spanning an area with this search.
    1049         [ +  - ]:          8 :         SwPosition aMarkPos( *GetMark() );
    1050 [ -  + ][ #  # ]:          8 :         int bMarkPos = HasMark() && !eFndRngs;
    1051                 :            : 
    1052 [ +  + ][ +  + ]:          8 :         if( 0 != (nFound = rParas.Find( this, fnMove,
         [ -  + ][ -  + ]
    1053         [ +  - ]:          8 :                                         &aRegion, bInReadOnly ) ? 1 : 0)
    1054                 :            :             && bMarkPos )
    1055 [ #  # ][ +  - ]:          8 :             *GetMark() = aMarkPos;
    1056                 :            :     }
    1057                 :            : 
    1058 [ +  + ][ +  - ]:         16 :     if( nFound && SwCursor::IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE ) )
         [ -  + ][ -  + ]
    1059                 :          0 :         nFound = 0;
    1060 [ +  - ][ +  - ]:         18 :     return nFound;
    1061                 :            : }
    1062                 :            : 
    1063                 :            : 
    1064                 :         36 : void SwCursor::FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const
    1065                 :            : {
    1066                 :         36 :     sal_Bool bIsStart = sal_True;
    1067                 :         36 :     SwCntntNode* pCNd = 0;
    1068                 :         36 :     SwNodes& rNds = GetDoc()->GetNodes();
    1069                 :            : 
    1070   [ +  +  -  -  :         36 :     switch( ePos )
                      + ]
    1071                 :            :     {
    1072                 :            :     case DOCPOS_START:
    1073                 :          8 :         rPos.nNode = *rNds.GetEndOfContent().StartOfSectionNode();
    1074                 :          8 :         pCNd = rNds.GoNext( &rPos.nNode );
    1075                 :          8 :         break;
    1076                 :            : 
    1077                 :            :     case DOCPOS_END:
    1078                 :         18 :         rPos.nNode = rNds.GetEndOfContent();
    1079                 :         18 :         pCNd = rNds.GoPrevious( &rPos.nNode );
    1080                 :         18 :         bIsStart = sal_False;
    1081                 :         18 :         break;
    1082                 :            : 
    1083                 :            :     case DOCPOS_OTHERSTART:
    1084                 :          0 :         rPos.nNode = *rNds[ sal_uLong(0) ];
    1085                 :          0 :         pCNd = rNds.GoNext( &rPos.nNode );
    1086                 :          0 :         break;
    1087                 :            : 
    1088                 :            :     case DOCPOS_OTHEREND:
    1089                 :          0 :         rPos.nNode = *rNds.GetEndOfContent().StartOfSectionNode();
    1090                 :          0 :         pCNd = rNds.GoPrevious( &rPos.nNode );
    1091                 :          0 :         bIsStart = sal_False;
    1092                 :          0 :         break;
    1093                 :            :     default:
    1094                 :         10 :         rPos = *GetPoint();
    1095                 :            :     }
    1096                 :            : 
    1097         [ +  + ]:         36 :     if( pCNd )
    1098                 :            :     {
    1099                 :         26 :         xub_StrLen nCPos = 0;
    1100         [ +  + ]:         26 :         if( !bIsStart )
    1101                 :         18 :             nCPos = pCNd->Len();
    1102         [ +  - ]:         26 :         rPos.nContent.Assign( pCNd, nCPos );
    1103                 :            :     }
    1104                 :         36 : }
    1105                 :            : 
    1106                 :          0 : short SwCursor::MaxReplaceArived()
    1107                 :            : {
    1108                 :          0 :     return RET_YES;
    1109                 :            : }
    1110                 :            : 
    1111                 :            : 
    1112                 :         10 : sal_Bool SwCursor::IsStartWord( sal_Int16 nWordType ) const
    1113                 :            : {
    1114                 :         10 :     return IsStartWordWT( nWordType );
    1115                 :            : }
    1116                 :            : 
    1117                 :          0 : sal_Bool SwCursor::IsEndWord( sal_Int16 nWordType ) const
    1118                 :            : {
    1119                 :          0 :     return IsEndWordWT( nWordType );
    1120                 :            : }
    1121                 :            : 
    1122                 :          0 : sal_Bool SwCursor::IsInWord( sal_Int16 nWordType ) const
    1123                 :            : {
    1124                 :          0 :     return IsInWordWT( nWordType );
    1125                 :            : }
    1126                 :            : 
    1127                 :          0 : sal_Bool SwCursor::GoStartWord()
    1128                 :            : {
    1129                 :          0 :     return GoStartWordWT( WordType::ANYWORD_IGNOREWHITESPACES );
    1130                 :            : }
    1131                 :            : 
    1132                 :          0 : sal_Bool SwCursor::GoEndWord()
    1133                 :            : {
    1134                 :          0 :     return GoEndWordWT( WordType::ANYWORD_IGNOREWHITESPACES );
    1135                 :            : }
    1136                 :            : 
    1137                 :          6 : sal_Bool SwCursor::GoNextWord()
    1138                 :            : {
    1139                 :          6 :     return GoNextWordWT( WordType::ANYWORD_IGNOREWHITESPACES );
    1140                 :            : }
    1141                 :            : 
    1142                 :          0 : sal_Bool SwCursor::GoPrevWord()
    1143                 :            : {
    1144                 :          0 :     return GoPrevWordWT( WordType::ANYWORD_IGNOREWHITESPACES );
    1145                 :            : }
    1146                 :            : 
    1147                 :          0 : sal_Bool SwCursor::SelectWord( ViewShell* pViewShell, const Point* pPt )
    1148                 :            : {
    1149                 :          0 :     return SelectWordWT( pViewShell, WordType::ANYWORD_IGNOREWHITESPACES, pPt );
    1150                 :            : }
    1151                 :            : 
    1152                 :         36 : sal_Bool SwCursor::IsStartWordWT( sal_Int16 nWordType ) const
    1153                 :            : {
    1154                 :         36 :     sal_Bool bRet = sal_False;
    1155                 :         36 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1156 [ +  - ][ +  - ]:         36 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1157                 :            :     {
    1158                 :         36 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1159         [ +  - ]:         72 :         bRet = pBreakIt->GetBreakIter()->isBeginWord(
    1160                 :         36 :                             pTxtNd->GetTxt(), nPtPos,
    1161 [ +  - ][ +  - ]:         36 :                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos )),
    1162 [ +  - ][ +  - ]:         36 :                             nWordType );
    1163                 :            :     }
    1164                 :         36 :     return bRet;
    1165                 :            : }
    1166                 :            : 
    1167                 :         50 : sal_Bool SwCursor::IsEndWordWT( sal_Int16 nWordType ) const
    1168                 :            : {
    1169                 :         50 :     sal_Bool bRet = sal_False;
    1170                 :         50 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1171 [ +  - ][ +  - ]:         50 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1172                 :            :     {
    1173                 :         50 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1174         [ +  - ]:        100 :         bRet = pBreakIt->GetBreakIter()->isEndWord(
    1175                 :         50 :                             pTxtNd->GetTxt(), nPtPos,
    1176 [ +  - ][ +  - ]:         50 :                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
    1177 [ +  - ][ +  - ]:         50 :                             nWordType );
    1178                 :            : 
    1179                 :            :     }
    1180                 :         50 :     return bRet;
    1181                 :            : }
    1182                 :            : 
    1183                 :          0 : sal_Bool SwCursor::IsInWordWT( sal_Int16 nWordType ) const
    1184                 :            : {
    1185                 :          0 :     sal_Bool bRet = sal_False;
    1186                 :          0 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1187 [ #  # ][ #  # ]:          0 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1188                 :            :     {
    1189                 :          0 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1190 [ #  # ][ #  # ]:          0 :         Boundary aBoundary = pBreakIt->GetBreakIter()->getWordBoundary(
    1191                 :          0 :                             pTxtNd->GetTxt(), nPtPos,
    1192 [ #  # ][ #  # ]:          0 :                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
    1193                 :            :                             nWordType,
    1194 [ #  # ][ #  # ]:          0 :                             sal_True );
    1195                 :            : 
    1196                 :            :         bRet = aBoundary.startPos != aBoundary.endPos &&
    1197                 :            :                 aBoundary.startPos <= nPtPos &&
    1198 [ #  # ][ #  # ]:          0 :                     nPtPos <= aBoundary.endPos;
                 [ #  # ]
    1199         [ #  # ]:          0 :         if(bRet)
    1200                 :            :         {
    1201         [ #  # ]:          0 :             const CharClass& rCC = GetAppCharClass();
    1202         [ #  # ]:          0 :             bRet = rCC.isLetterNumeric( pTxtNd->GetTxt(), static_cast<xub_StrLen>(aBoundary.startPos) );
    1203                 :            :         }
    1204                 :            :     }
    1205                 :          0 :     return bRet;
    1206                 :            : }
    1207                 :            : 
    1208                 :          0 : sal_Bool SwCursor::IsStartEndSentence( bool bEnd ) const
    1209                 :            : {
    1210                 :            :     sal_Bool bRet = bEnd ?
    1211                 :          0 :                     GetCntntNode() && GetPoint()->nContent == GetCntntNode()->Len() :
    1212   [ #  #  #  #  :          0 :                     GetPoint()->nContent.GetIndex() == 0;
                   #  # ]
    1213                 :            : 
    1214         [ #  # ]:          0 :     if( !bRet )
    1215                 :            :     {
    1216         [ #  # ]:          0 :         SwCursor aCrsr(*GetPoint(), 0, false);
    1217         [ #  # ]:          0 :         SwPosition aOrigPos = *aCrsr.GetPoint();
    1218 [ #  # ][ #  # ]:          0 :         aCrsr.GoSentence( bEnd ? SwCursor::END_SENT : SwCursor::START_SENT );
    1219 [ #  # ][ #  # ]:          0 :         bRet = aOrigPos == *aCrsr.GetPoint();
                 [ #  # ]
    1220                 :            :     }
    1221                 :            : 
    1222                 :          0 :     return bRet;
    1223                 :            : }
    1224                 :            : 
    1225                 :         10 : sal_Bool SwCursor::GoStartWordWT( sal_Int16 nWordType )
    1226                 :            : {
    1227                 :         10 :     sal_Bool bRet = sal_False;
    1228                 :         10 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1229 [ +  - ][ +  - ]:         10 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1230                 :            :     {
    1231         [ +  - ]:         10 :         SwCrsrSaveState aSave( *this );
    1232                 :         10 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1233 [ +  - ][ +  - ]:         20 :         nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary(
    1234                 :         10 :                             pTxtNd->GetTxt(), nPtPos,
    1235 [ +  - ][ +  - ]:         10 :                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
    1236                 :            :                             nWordType,
    1237 [ +  - ][ +  - ]:         10 :                             sal_False ).startPos;
    1238                 :            : 
    1239         [ +  - ]:         10 :         if( nPtPos < pTxtNd->GetTxt().Len() )
    1240                 :            :         {
    1241         [ +  - ]:         10 :             GetPoint()->nContent = nPtPos;
    1242 [ +  - ][ +  - ]:         10 :             if( !IsSelOvr() )
    1243                 :         10 :                 bRet = sal_True;
    1244         [ +  - ]:         10 :         }
    1245                 :            :     }
    1246                 :         10 :     return bRet;
    1247                 :            : }
    1248                 :            : 
    1249                 :         24 : sal_Bool SwCursor::GoEndWordWT( sal_Int16 nWordType )
    1250                 :            : {
    1251                 :         24 :     sal_Bool bRet = sal_False;
    1252                 :         24 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1253 [ +  - ][ +  - ]:         24 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1254                 :            :     {
    1255         [ +  - ]:         24 :         SwCrsrSaveState aSave( *this );
    1256                 :         24 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1257 [ +  - ][ +  - ]:         48 :         nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary(
    1258                 :         24 :                             pTxtNd->GetTxt(), nPtPos,
    1259 [ +  - ][ +  - ]:         24 :                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
    1260                 :            :                             nWordType,
    1261 [ +  - ][ +  - ]:         24 :                             sal_True ).endPos;
    1262                 :            : 
    1263         [ +  - ]:         48 :         if( nPtPos <= pTxtNd->GetTxt().Len() &&
           [ +  -  +  - ]
    1264                 :         24 :             GetPoint()->nContent.GetIndex() != nPtPos )
    1265                 :            :         {
    1266         [ +  - ]:         24 :             GetPoint()->nContent = nPtPos;
    1267 [ +  - ][ +  - ]:         24 :             if( !IsSelOvr() )
    1268                 :         24 :                 bRet = sal_True;
    1269         [ +  - ]:         24 :         }
    1270                 :            :     }
    1271                 :         24 :     return bRet;
    1272                 :            : }
    1273                 :            : 
    1274                 :         14 : sal_Bool SwCursor::GoNextWordWT( sal_Int16 nWordType )
    1275                 :            : {
    1276                 :         14 :     sal_Bool bRet = sal_False;
    1277                 :         14 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1278 [ +  - ][ +  - ]:         14 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1279                 :            :     {
    1280         [ +  - ]:         14 :         SwCrsrSaveState aSave( *this );
    1281                 :         14 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1282                 :            : 
    1283 [ +  - ][ +  - ]:         28 :         nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextWord(
    1284                 :         14 :                                 pTxtNd->GetTxt(), nPtPos,
    1285 [ +  - ][ +  - ]:         14 :             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ),
    1286 [ +  - ][ +  - ]:         14 :                     nWordType ).startPos;
    1287                 :            : 
    1288         [ +  + ]:         14 :         if( nPtPos < pTxtNd->GetTxt().Len() )
    1289                 :            :         {
    1290         [ +  - ]:          8 :             GetPoint()->nContent = nPtPos;
    1291 [ +  - ][ +  - ]:          8 :             if( !IsSelOvr() )
    1292                 :          8 :                 bRet = sal_True;
    1293         [ +  - ]:         14 :         }
    1294                 :            :     }
    1295                 :         14 :     return bRet;
    1296                 :            : }
    1297                 :            : 
    1298                 :         10 : sal_Bool SwCursor::GoPrevWordWT( sal_Int16 nWordType )
    1299                 :            : {
    1300                 :         10 :     sal_Bool bRet = sal_False;
    1301                 :         10 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1302 [ +  - ][ +  - ]:         10 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1303                 :            :     {
    1304         [ +  - ]:         10 :         SwCrsrSaveState aSave( *this );
    1305                 :         10 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1306                 :         10 :         const xub_StrLen nPtStart = nPtPos;
    1307                 :            : 
    1308         [ +  - ]:         10 :         if( nPtPos )
    1309                 :         10 :             --nPtPos;
    1310 [ +  - ][ +  - ]:         20 :         nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousWord(
    1311                 :         10 :                                 pTxtNd->GetTxt(), nPtStart,
    1312 [ +  - ][ +  - ]:         10 :             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ),
    1313 [ +  - ][ +  - ]:         10 :                     nWordType ).startPos;
    1314                 :            : 
    1315         [ +  - ]:         10 :         if( nPtPos < pTxtNd->GetTxt().Len() )
    1316                 :            :         {
    1317         [ +  - ]:         10 :             GetPoint()->nContent = nPtPos;
    1318 [ +  - ][ +  - ]:         10 :             if( !IsSelOvr() )
    1319                 :         10 :                 bRet = sal_True;
    1320         [ +  - ]:         10 :         }
    1321                 :            :     }
    1322                 :         10 :     return bRet;
    1323                 :            : }
    1324                 :            : 
    1325                 :          0 : sal_Bool SwCursor::SelectWordWT( ViewShell* pViewShell, sal_Int16 nWordType, const Point* pPt )
    1326                 :            : {
    1327         [ #  # ]:          0 :     SwCrsrSaveState aSave( *this );
    1328                 :            : 
    1329                 :          0 :     sal_Bool bRet = sal_False;
    1330                 :          0 :     sal_Bool bForward = sal_True;
    1331         [ #  # ]:          0 :     DeleteMark();
    1332         [ #  # ]:          0 :     const SwRootFrm* pLayout = pViewShell->GetLayout();
    1333 [ #  # ][ #  # ]:          0 :     if( pPt && 0 != pLayout )
    1334                 :            :     {
    1335                 :            :         // set the cursor to the layout position
    1336                 :          0 :         Point aPt( *pPt );
    1337         [ #  # ]:          0 :         pLayout->GetCrsrOfst( GetPoint(), aPt );
    1338                 :            :     }   //swmod 071107 //swmod 071225
    1339                 :            : 
    1340                 :          0 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1341 [ #  # ][ #  # ]:          0 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1342                 :            :     {
    1343                 :            :         // Should we select the whole fieldmark?
    1344         [ #  # ]:          0 :         const IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
    1345 [ #  # ][ #  # ]:          0 :         sw::mark::IFieldmark* pMark = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : NULL;
    1346 [ #  # ][ #  # ]:          0 :         if ( pMark && pMark->GetFieldname() != ODF_COMMENTRANGE )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1347                 :            :         {
    1348 [ #  # ][ #  # ]:          0 :             const SwPosition rStart = pMark->GetMarkStart();
    1349         [ #  # ]:          0 :             GetPoint()->nNode = rStart.nNode;
    1350         [ #  # ]:          0 :             GetPoint()->nContent = rStart.nContent;
    1351         [ #  # ]:          0 :             GetPoint()->nContent++; // Don't select the start delimiter
    1352                 :            : 
    1353 [ #  # ][ #  # ]:          0 :             const SwPosition rEnd = pMark->GetMarkEnd();
    1354                 :            : 
    1355 [ #  # ][ #  # ]:          0 :             if ( rStart != rEnd )
    1356                 :            :             {
    1357         [ #  # ]:          0 :                 SetMark();
    1358         [ #  # ]:          0 :                 GetMark()->nNode = rEnd.nNode;
    1359         [ #  # ]:          0 :                 GetMark()->nContent = rEnd.nContent;
    1360         [ #  # ]:          0 :                 GetMark()->nContent--; //Don't select the end delimiter
    1361                 :            :             }
    1362 [ #  # ][ #  # ]:          0 :             bRet = sal_True;
    1363                 :            :         }
    1364                 :            :         else
    1365                 :            :         {
    1366                 :          0 :             xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1367 [ #  # ][ #  # ]:          0 :             Boundary aBndry( pBreakIt->GetBreakIter()->getWordBoundary(
    1368                 :          0 :                                 pTxtNd->GetTxt(), nPtPos,
    1369 [ #  # ][ #  # ]:          0 :                                 pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
    1370                 :            :                                 nWordType,
    1371 [ #  # ][ #  # ]:          0 :                                 bForward ));
    1372                 :            : 
    1373         [ #  # ]:          0 :             if( aBndry.startPos != aBndry.endPos )
    1374                 :            :             {
    1375         [ #  # ]:          0 :                 GetPoint()->nContent = (xub_StrLen)aBndry.endPos;
    1376 [ #  # ][ #  # ]:          0 :                 if( !IsSelOvr() )
    1377                 :            :                 {
    1378         [ #  # ]:          0 :                     SetMark();
    1379         [ #  # ]:          0 :                     GetMark()->nContent = (xub_StrLen)aBndry.startPos;
    1380 [ #  # ][ #  # ]:          0 :                     if( !IsSelOvr() )
    1381                 :          0 :                         bRet = sal_True;
    1382                 :            :                 }
    1383                 :            :             }
    1384                 :            :         }
    1385                 :            :     }
    1386                 :            : 
    1387         [ #  # ]:          0 :     if( !bRet )
    1388                 :            :     {
    1389         [ #  # ]:          0 :         DeleteMark();
    1390         [ #  # ]:          0 :         RestoreSavePos();
    1391                 :            :     }
    1392         [ #  # ]:          0 :     return bRet;
    1393                 :            : }
    1394                 :            : 
    1395                 :            : 
    1396                 :         44 : static String lcl_MaskDeletedRedlines( const SwTxtNode* pTxtNd )
    1397                 :            : {
    1398                 :         44 :     String aRes;
    1399         [ +  - ]:         44 :     if (pTxtNd)
    1400                 :            :     {
    1401                 :            :         //mask deleted redlines
    1402         [ +  - ]:         44 :         String sNodeText(pTxtNd->GetTxt());
    1403                 :         44 :         const SwDoc& rDoc = *pTxtNd->GetDoc();
    1404         [ +  - ]:         44 :         const bool nShowChg = IDocumentRedlineAccess::IsShowChanges( rDoc.GetRedlineMode() );
    1405         [ +  - ]:         44 :         if ( nShowChg )
    1406                 :            :         {
    1407         [ +  - ]:         44 :             sal_uInt16 nAct = rDoc.GetRedlinePos( *pTxtNd, USHRT_MAX );
    1408 [ +  - ][ -  + ]:         44 :             for ( ; nAct < rDoc.GetRedlineTbl().size(); nAct++ )
    1409                 :            :             {
    1410 [ #  # ][ #  # ]:          0 :                 const SwRedline* pRed = rDoc.GetRedlineTbl()[ nAct ];
    1411 [ #  # ][ #  # ]:          0 :                 if ( pRed->Start()->nNode > pTxtNd->GetIndex() )
    1412                 :          0 :                     break;
    1413                 :            : 
    1414 [ #  # ][ #  # ]:          0 :                 if( nsRedlineType_t::REDLINE_DELETE == pRed->GetType() )
    1415                 :            :                 {
    1416                 :            :                     xub_StrLen nStart, nEnd;
    1417         [ #  # ]:          0 :                     pRed->CalcStartEnd( pTxtNd->GetIndex(), nStart, nEnd );
    1418                 :            : 
    1419 [ #  # ][ #  # ]:          0 :                     while ( nStart < nEnd && nStart < sNodeText.Len() )
                 [ #  # ]
    1420         [ #  # ]:          0 :                         sNodeText.SetChar( nStart++, CH_TXTATR_INWORD );
    1421                 :            :                 }
    1422                 :            :             }
    1423                 :            :         }
    1424 [ +  - ][ +  - ]:         44 :         aRes = sNodeText;
    1425                 :            :     }
    1426                 :         44 :     return aRes;
    1427                 :            : }
    1428                 :            : 
    1429                 :         44 : sal_Bool SwCursor::GoSentence( SentenceMoveType eMoveType )
    1430                 :            : {
    1431                 :         44 :     sal_Bool bRet = sal_False;
    1432                 :         44 :     const SwTxtNode* pTxtNd = GetNode()->GetTxtNode();
    1433 [ +  - ][ +  - ]:         44 :     if( pTxtNd && pBreakIt->GetBreakIter().is() )
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1434                 :            :     {
    1435         [ +  - ]:         44 :         String sNodeText( lcl_MaskDeletedRedlines( pTxtNd ) );
    1436                 :            : 
    1437         [ +  - ]:         44 :         SwCrsrSaveState aSave( *this );
    1438                 :         44 :         xub_StrLen nPtPos = GetPoint()->nContent.GetIndex();
    1439   [ +  +  +  +  :         44 :         switch ( eMoveType )
                      - ]
    1440                 :            :         {
    1441                 :            :         case START_SENT: /* when modifying: see also ExpandToSentenceBorders below! */
    1442 [ +  - ][ +  - ]:         16 :             nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence(
    1443                 :            :                                     sNodeText,
    1444                 :            :                                     nPtPos, pBreakIt->GetLocale(
    1445 [ +  - ][ +  - ]:          8 :                                             pTxtNd->GetLang( nPtPos ) ));
         [ +  - ][ +  - ]
    1446                 :          8 :             break;
    1447                 :            :         case END_SENT: /* when modifying: see also ExpandToSentenceBorders below! */
    1448 [ +  - ][ +  - ]:         28 :             nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence(
    1449                 :            :                                     sNodeText,
    1450                 :            :                                     nPtPos, pBreakIt->GetLocale(
    1451 [ +  - ][ +  - ]:         14 :                                                 pTxtNd->GetLang( nPtPos ) ));
         [ +  - ][ +  - ]
    1452                 :         14 :             break;
    1453                 :            :         case NEXT_SENT:
    1454                 :            :             {
    1455 [ +  - ][ +  - ]:         20 :                 nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence(
    1456                 :            :                                         sNodeText,
    1457                 :            :                                         nPtPos, pBreakIt->GetLocale(
    1458 [ +  - ][ +  - ]:         10 :                                                     pTxtNd->GetLang( nPtPos ) ));
         [ +  - ][ +  - ]
    1459         [ +  - ]:         14 :                 while (nPtPos != (sal_uInt16) -1 && ++nPtPos < sNodeText.Len()
           [ +  +  -  + ]
                 [ -  + ]
    1460                 :          4 :                        && sNodeText.GetChar(nPtPos)== ' ' /*isWhiteSpace( aTxt.GetChar(nPtPos)*/ )
    1461                 :            :                     ;
    1462                 :         10 :                 break;
    1463                 :            :             }
    1464                 :            :         case PREV_SENT:
    1465 [ +  - ][ +  - ]:         24 :             nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence(
    1466                 :            :                                     sNodeText,
    1467                 :            :                                     nPtPos, pBreakIt->GetLocale(
    1468 [ +  - ][ +  - ]:         12 :                                                 pTxtNd->GetLang( nPtPos ) ));
         [ +  - ][ +  - ]
    1469         [ +  + ]:         12 :             if (nPtPos == 0)
    1470                 :          2 :                 return sal_False;   // the previous sentence is not in this paragraph
    1471         [ +  - ]:         10 :             if (nPtPos > 0)
    1472 [ +  - ][ +  - ]:         20 :                 nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence(
    1473                 :            :                                     sNodeText,
    1474                 :            :                                     nPtPos - 1, pBreakIt->GetLocale(
    1475 [ +  - ][ +  - ]:         10 :                                                 pTxtNd->GetLang( nPtPos ) ));
         [ +  - ][ +  - ]
    1476                 :         10 :             break;
    1477                 :            :         }
    1478                 :            : 
    1479                 :            :         // it is allowed to place the PaM just behind the last
    1480                 :            :         // character in the text thus <= ...Len
    1481         [ +  - ]:         42 :         if( nPtPos <= pTxtNd->GetTxt().Len() )
    1482                 :            :         {
    1483         [ +  - ]:         42 :             GetPoint()->nContent = nPtPos;
    1484 [ +  - ][ +  - ]:         42 :             if( !IsSelOvr() )
    1485                 :         42 :                 bRet = sal_True;
    1486 [ +  - ][ +  + ]:         44 :         }
         [ +  - ][ +  + ]
    1487                 :            :     }
    1488                 :         44 :     return bRet;
    1489                 :            : }
    1490                 :            : 
    1491                 :            : 
    1492                 :          0 : sal_Bool SwCursor::ExpandToSentenceBorders()
    1493                 :            : {
    1494                 :          0 :     sal_Bool bRes = sal_False;
    1495                 :          0 :     const SwTxtNode* pStartNd = Start()->nNode.GetNode().GetTxtNode();
    1496                 :          0 :     const SwTxtNode* pEndNd   = End()->nNode.GetNode().GetTxtNode();
    1497 [ #  # ][ #  # ]:          0 :     if (pStartNd && pEndNd && pBreakIt->GetBreakIter().is())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1498                 :            :     {
    1499         [ #  # ]:          0 :         if (!HasMark())
    1500         [ #  # ]:          0 :             SetMark();
    1501                 :            : 
    1502         [ #  # ]:          0 :         String sStartText( lcl_MaskDeletedRedlines( pStartNd ) );
    1503 [ #  # ][ #  # ]:          0 :         String sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) );
                 [ #  # ]
    1504                 :            : 
    1505         [ #  # ]:          0 :         SwCrsrSaveState aSave( *this );
    1506         [ #  # ]:          0 :         xub_StrLen nStartPos = Start()->nContent.GetIndex();
    1507         [ #  # ]:          0 :         xub_StrLen nEndPos   = End()->nContent.GetIndex();
    1508                 :            : 
    1509 [ #  # ][ #  # ]:          0 :         nStartPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence(
    1510                 :            :                                 sStartText, nStartPos,
    1511 [ #  # ][ #  # ]:          0 :                                 pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) );
         [ #  # ][ #  # ]
    1512 [ #  # ][ #  # ]:          0 :         nEndPos   = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence(
    1513                 :            :                                 sEndText, nEndPos,
    1514 [ #  # ][ #  # ]:          0 :                                 pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) );
         [ #  # ][ #  # ]
    1515                 :            : 
    1516                 :            :         // it is allowed to place the PaM just behind the last
    1517                 :            :         // character in the text thus <= ...Len
    1518                 :          0 :         bool bChanged = false;
    1519         [ #  # ]:          0 :         if (nStartPos <= pStartNd->GetTxt().Len())
    1520                 :            :         {
    1521         [ #  # ]:          0 :             GetMark()->nContent = nStartPos;
    1522                 :          0 :             bChanged = true;
    1523                 :            :         }
    1524         [ #  # ]:          0 :         if (nEndPos <= pEndNd->GetTxt().Len())
    1525                 :            :         {
    1526         [ #  # ]:          0 :             GetPoint()->nContent = nEndPos;
    1527                 :          0 :             bChanged = true;
    1528                 :            :         }
    1529 [ #  # ][ #  # ]:          0 :         if (bChanged && !IsSelOvr())
         [ #  # ][ #  # ]
    1530 [ #  # ][ #  # ]:          0 :             bRes = sal_True;
                 [ #  # ]
    1531                 :            :     }
    1532                 :          0 :     return bRes;
    1533                 :            : }
    1534                 :            : 
    1535                 :            : 
    1536                 :          8 : sal_Bool SwTableCursor::LeftRight( sal_Bool bLeft, sal_uInt16 nCnt, sal_uInt16 /*nMode*/,
    1537                 :            :     sal_Bool /*bVisualAllowed*/, sal_Bool /*bSkipHidden*/, sal_Bool /*bInsertCrsr*/ )
    1538                 :            : {
    1539                 :          4 :     return bLeft ? GoPrevCell( nCnt )
    1540         [ +  + ]:          8 :                  : GoNextCell( nCnt );
    1541                 :            : }
    1542                 :            : 
    1543                 :            : 
    1544                 :            : // calculate cursor bidi level: extracted from LeftRight()
    1545                 :            : const SwCntntFrm*
    1546                 :         72 : SwCursor::DoSetBidiLevelLeftRight(
    1547                 :            :     sal_Bool & io_rbLeft, sal_Bool bVisualAllowed, sal_Bool bInsertCrsr)
    1548                 :            : {
    1549                 :            :     // calculate cursor bidi level
    1550                 :         72 :     const SwCntntFrm* pSttFrm = NULL;
    1551                 :         72 :     SwNode& rNode = GetPoint()->nNode.GetNode();
    1552                 :            : 
    1553         [ +  - ]:         72 :     if( rNode.IsTxtNode() )
    1554                 :            :     {
    1555                 :         72 :         const SwTxtNode& rTNd = *rNode.GetTxtNode();
    1556                 :         72 :         SwIndex& rIdx = GetPoint()->nContent;
    1557                 :         72 :         xub_StrLen nPos = rIdx.GetIndex();
    1558                 :            : 
    1559 [ +  - ][ +  - ]:         72 :         const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
    1560 [ -  + ][ #  # ]:         72 :         if ( bVisualAllowed && rCTLOptions.IsCTLFontEnabled() &&
         [ #  # ][ #  # ]
                 [ -  + ]
    1561                 :            :              SvtCTLOptions::MOVEMENT_VISUAL ==
    1562         [ #  # ]:          0 :              rCTLOptions.GetCTLCursorMovement() )
    1563                 :            :         {
    1564                 :            :             // for visual cursor travelling (used in bidi layout)
    1565                 :            :             // we first have to convert the logic to a visual position
    1566                 :          0 :             Point aPt;
    1567 [ #  # ][ #  # ]:          0 :             pSttFrm = rTNd.getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1568         [ #  # ]:          0 :             if( pSttFrm )
    1569                 :            :             {
    1570                 :          0 :                 sal_uInt8 nCrsrLevel = GetCrsrBidiLevel();
    1571                 :          0 :                 sal_Bool bForward = ! io_rbLeft;
    1572                 :            :                 ((SwTxtFrm*)pSttFrm)->PrepareVisualMove( nPos, nCrsrLevel,
    1573         [ #  # ]:          0 :                                                          bForward, bInsertCrsr );
    1574         [ #  # ]:          0 :                 rIdx = nPos;
    1575                 :          0 :                 SetCrsrBidiLevel( nCrsrLevel );
    1576                 :          0 :                 io_rbLeft = ! bForward;
    1577                 :            :             }
    1578                 :            :         }
    1579                 :            :         else
    1580                 :            :         {
    1581         [ +  - ]:         72 :             const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( rTNd );
    1582         [ +  + ]:         72 :             if ( pSI )
    1583                 :            :             {
    1584                 :            :                 const xub_StrLen nMoveOverPos = io_rbLeft ?
    1585                 :            :                                                ( nPos ? nPos - 1 : 0 ) :
    1586 [ +  + ][ +  + ]:         34 :                                                 nPos;
    1587         [ +  - ]:         72 :                 SetCrsrBidiLevel( pSI->DirType( nMoveOverPos ) );
    1588                 :            :             }
    1589                 :            :         }
    1590                 :            :     }
    1591                 :         72 :     return pSttFrm;
    1592                 :            : }
    1593                 :            : 
    1594                 :      13406 : sal_Bool SwCursor::LeftRight( sal_Bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
    1595                 :            :                           sal_Bool bVisualAllowed,sal_Bool bSkipHidden, sal_Bool bInsertCrsr )
    1596                 :            : {
    1597                 :            :     // calculate cursor bidi level
    1598                 :      13406 :     SwNode& rNode = GetPoint()->nNode.GetNode();
    1599                 :            :     const SwCntntFrm* pSttFrm = // may side-effect bLeft!
    1600         [ +  - ]:      13406 :         DoSetBidiLevelLeftRight(bLeft, bVisualAllowed, bInsertCrsr);
    1601                 :            : 
    1602                 :            :     // can the cursor be moved n times?
    1603         [ +  - ]:      13406 :     SwCrsrSaveState aSave( *this );
    1604         [ +  + ]:      13406 :     SwMoveFn fnMove = bLeft ? fnMoveBackward : fnMoveForward;
    1605                 :            : 
    1606                 :            :     SwGoInDoc fnGo;
    1607         [ +  + ]:      13406 :     if ( bSkipHidden )
    1608         [ -  + ]:         34 :         fnGo = CRSR_SKIP_CELLS == nMode ? fnGoCntntCellsSkipHidden : fnGoCntntSkipHidden;
    1609                 :            :     else
    1610         [ -  + ]:      13372 :         fnGo = CRSR_SKIP_CELLS == nMode ? fnGoCntntCells : fnGoCntnt;
    1611                 :            : 
    1612         [ +  + ]:     177355 :     while( nCnt )
    1613                 :            :     {
    1614         [ +  - ]:     165434 :         SwNodeIndex aOldNodeIdx( GetPoint()->nNode );
    1615                 :            : 
    1616         [ +  - ]:     165434 :         bool bSuccess = Move( fnMove, fnGo );
    1617         [ +  + ]:     165434 :         if ( !bSuccess )
    1618                 :            :             break;
    1619                 :            : 
    1620                 :            :         // If we were located inside a covered cell but our position has been
    1621                 :            :         // corrected, we check if the last move has moved the cursor to a
    1622                 :            :         // different table cell. In this case we set the cursor to the stored
    1623                 :            :         // covered position and redo the move:
    1624         [ -  + ]:     163949 :         if ( mnRowSpanOffset )
    1625                 :            :         {
    1626         [ #  # ]:          0 :             const SwNode* pOldTabBoxSttNode = aOldNodeIdx.GetNode().FindTableBoxStartNode();
    1627 [ #  # ][ #  # ]:          0 :             const SwTableNode* pOldTabSttNode = pOldTabBoxSttNode ? pOldTabBoxSttNode->FindTableNode() : 0;
    1628         [ #  # ]:          0 :             const SwNode* pNewTabBoxSttNode = GetPoint()->nNode.GetNode().FindTableBoxStartNode();
    1629 [ #  # ][ #  # ]:          0 :             const SwTableNode* pNewTabSttNode = pNewTabBoxSttNode ? pNewTabBoxSttNode->FindTableNode() : 0;
    1630                 :            : 
    1631                 :            :             const bool bCellChanged = pOldTabSttNode && pNewTabSttNode &&
    1632                 :            :                                       pOldTabSttNode == pNewTabSttNode &&
    1633                 :            :                                       pOldTabBoxSttNode && pNewTabBoxSttNode &&
    1634 [ #  # ][ #  # ]:          0 :                                       pOldTabBoxSttNode != pNewTabBoxSttNode;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1635                 :            : 
    1636         [ #  # ]:          0 :             if ( bCellChanged )
    1637                 :            :             {
    1638                 :            :                 // Set cursor to start/end of covered cell:
    1639         [ #  # ]:          0 :                 SwTableBox* pTableBox = pOldTabBoxSttNode->GetTblBox();
    1640 [ #  # ][ #  # ]:          0 :                 if ( pTableBox && pTableBox->getRowSpan() > 1 )
         [ #  # ][ #  # ]
    1641                 :            :                 {
    1642 [ #  # ][ #  # ]:          0 :                     pTableBox = & pTableBox->FindEndOfRowSpan( pOldTabSttNode->GetTable(), (sal_uInt16)(pTableBox->getRowSpan() + mnRowSpanOffset ) );
    1643                 :          0 :                     SwNodeIndex& rPtIdx = GetPoint()->nNode;
    1644         [ #  # ]:          0 :                     SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
    1645         [ #  # ]:          0 :                     rPtIdx = aNewIdx;
    1646                 :            : 
    1647 [ #  # ][ #  # ]:          0 :                     GetDoc()->GetNodes().GoNextSection( &rPtIdx, sal_False, sal_False );
    1648                 :          0 :                     SwCntntNode* pCntntNode = GetCntntNode();
    1649         [ #  # ]:          0 :                     if ( pCntntNode )
    1650                 :            :                     {
    1651 [ #  # ][ #  # ]:          0 :                         const xub_StrLen nTmpPos = bLeft ? pCntntNode->Len() : 0;
    1652 [ #  # ][ #  # ]:          0 :                         GetPoint()->nContent.Assign( pCntntNode, nTmpPos );
    1653                 :            : 
    1654                 :            :                         // Redo the move:
    1655         [ #  # ]:          0 :                         bSuccess = Move( fnMove, fnGo );
    1656         [ #  # ]:          0 :                         if ( !bSuccess )
    1657                 :            :                             break;
    1658 [ #  # ][ #  # ]:          0 :                     }
    1659                 :            :                 }
    1660                 :            : 
    1661                 :          0 :                 mnRowSpanOffset = 0;
    1662                 :            :             }
    1663                 :            :         }
    1664                 :            : 
    1665                 :            :         // Check if I'm inside a covered cell. Correct cursor if necessary and
    1666                 :            :         // store covered cell:
    1667         [ +  - ]:     163949 :         const SwNode* pTableBoxStartNode = GetPoint()->nNode.GetNode().FindTableBoxStartNode();
    1668         [ +  + ]:     163949 :         if ( pTableBoxStartNode )
    1669                 :            :         {
    1670         [ +  - ]:        283 :             const SwTableBox* pTableBox = pTableBoxStartNode->GetTblBox();
    1671 [ +  - ][ +  - ]:        283 :             if ( pTableBox && pTableBox->getRowSpan() < 1 )
         [ -  + ][ -  + ]
    1672                 :            :             {
    1673                 :            :                 // Store the row span offset:
    1674         [ #  # ]:          0 :                 mnRowSpanOffset = pTableBox->getRowSpan();
    1675                 :            : 
    1676                 :            :                 // Move cursor to non-covered cell:
    1677         [ #  # ]:          0 :                 const SwTableNode* pTblNd = pTableBoxStartNode->FindTableNode();
    1678         [ #  # ]:          0 :                 pTableBox = & pTableBox->FindStartOfRowSpan( pTblNd->GetTable(), USHRT_MAX );
    1679                 :          0 :                  SwNodeIndex& rPtIdx = GetPoint()->nNode;
    1680         [ #  # ]:          0 :                 SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
    1681         [ #  # ]:          0 :                 rPtIdx = aNewIdx;
    1682                 :            : 
    1683 [ #  # ][ #  # ]:          0 :                 GetDoc()->GetNodes().GoNextSection( &rPtIdx, sal_False, sal_False );
    1684                 :          0 :                 SwCntntNode* pCntntNode = GetCntntNode();
    1685         [ #  # ]:          0 :                 if ( pCntntNode )
    1686                 :            :                 {
    1687 [ #  # ][ #  # ]:          0 :                     const xub_StrLen nTmpPos = bLeft ? pCntntNode->Len() : 0;
    1688 [ #  # ][ #  # ]:          0 :                        GetPoint()->nContent.Assign( pCntntNode, nTmpPos );
    1689         [ #  # ]:          0 :                 }
    1690                 :            :             }
    1691                 :            :         }
    1692                 :            : 
    1693         [ +  + ]:     329383 :         --nCnt;
    1694         [ +  - ]:     165434 :     }
    1695                 :            : 
    1696                 :            :     // here come some special rules for visual cursor travelling
    1697         [ -  + ]:      13406 :     if ( pSttFrm )
    1698                 :            :     {
    1699                 :          0 :         SwNode& rTmpNode = GetPoint()->nNode.GetNode();
    1700 [ #  # ][ #  # ]:          0 :         if ( &rTmpNode != &rNode && rTmpNode.IsTxtNode() )
                 [ #  # ]
    1701                 :            :         {
    1702                 :          0 :             Point aPt;
    1703 [ #  # ][ #  # ]:          0 :             const SwCntntFrm* pEndFrm = ((SwTxtNode&)rTmpNode).getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1704         [ #  # ]:          0 :             if ( pEndFrm )
    1705                 :            :             {
    1706 [ #  # ][ #  # ]:          0 :                 if ( ! pEndFrm->IsRightToLeft() != ! pSttFrm->IsRightToLeft() )
                 [ #  # ]
    1707                 :            :                 {
    1708         [ #  # ]:          0 :                     if ( ! bLeft )
    1709         [ #  # ]:          0 :                         pEndFrm->RightMargin( this );
    1710                 :            :                     else
    1711         [ #  # ]:          0 :                         pEndFrm->LeftMargin( this );
    1712                 :            :                 }
    1713                 :            :             }
    1714                 :            :         }
    1715                 :            :     }
    1716                 :            : 
    1717         [ +  - ]:      11921 :     return 0 == nCnt && !IsInProtectTable( sal_True ) &&
    1718                 :            :             !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
    1719 [ +  + ][ +  - ]:      25327 :                        nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
         [ +  - ][ +  + ]
                 [ +  - ]
    1720                 :            : }
    1721                 :            : 
    1722                 :            : // calculate cursor bidi level: extracted from UpDown()
    1723                 :          0 : void SwCursor::DoSetBidiLevelUpDown()
    1724                 :            : {
    1725                 :          0 :     SwNode& rNode = GetPoint()->nNode.GetNode();
    1726         [ #  # ]:          0 :     if ( rNode.IsTxtNode() )
    1727                 :            :     {
    1728                 :            :         const SwScriptInfo* pSI =
    1729                 :          0 :             SwScriptInfo::GetScriptInfo( (SwTxtNode&)rNode );
    1730         [ #  # ]:          0 :         if ( pSI )
    1731                 :            :         {
    1732                 :          0 :             SwIndex& rIdx = GetPoint()->nContent;
    1733                 :          0 :             xub_StrLen nPos = rIdx.GetIndex();
    1734                 :            : 
    1735 [ #  # ][ #  # ]:          0 :             if( nPos && nPos < ((SwTxtNode&)rNode).GetTxt().Len() )
                 [ #  # ]
    1736                 :            :             {
    1737                 :          0 :                 const sal_uInt8 nCurrLevel = pSI->DirType( nPos );
    1738                 :          0 :                 const sal_uInt8 nPrevLevel = pSI->DirType( nPos - 1 );
    1739                 :            : 
    1740         [ #  # ]:          0 :                 if ( nCurrLevel % 2 != nPrevLevel % 2 )
    1741                 :            :                 {
    1742                 :            :                     // set cursor level to the lower of the two levels
    1743                 :          0 :                     SetCrsrBidiLevel( Min( nCurrLevel, nPrevLevel ) );
    1744                 :            :                 }
    1745                 :            :                 else
    1746                 :          0 :                     SetCrsrBidiLevel( nCurrLevel );
    1747                 :            :             }
    1748                 :            :         }
    1749                 :            :     }
    1750                 :          0 : }
    1751                 :            : 
    1752                 :          6 : sal_Bool SwCursor::UpDown( sal_Bool bUp, sal_uInt16 nCnt,
    1753                 :            :                             Point* pPt, long nUpDownX )
    1754                 :            : {
    1755         [ -  + ]:          6 :     SwTableCursor* pTblCrsr = dynamic_cast<SwTableCursor*>(this);
    1756                 :          6 :     sal_Bool bAdjustTableCrsr = sal_False;
    1757                 :            : 
    1758                 :            :     // If the point/mark of the table cursor in the same box then set cursor to
    1759                 :            :     // beginning of the box
    1760 [ +  - ][ +  - ]:         12 :     if( pTblCrsr && GetNode( sal_True )->StartOfSectionNode() ==
                 [ +  - ]
    1761                 :          6 :                     GetNode( sal_False )->StartOfSectionNode() )
    1762                 :            :     {
    1763 [ +  - ][ -  + ]:          6 :         if ( End() != GetPoint() )
    1764                 :          0 :             Exchange();
    1765                 :          6 :         bAdjustTableCrsr = sal_True;
    1766                 :            :     }
    1767                 :            : 
    1768                 :          6 :     sal_Bool bRet = sal_False;
    1769                 :          6 :     Point aPt;
    1770         [ -  + ]:          6 :     if( pPt )
    1771                 :          0 :         aPt = *pPt;
    1772 [ +  - ][ +  - ]:          6 :     SwCntntFrm* pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1773                 :            : 
    1774         [ +  - ]:          6 :     if( pFrm )
    1775                 :            :     {
    1776         [ +  - ]:          6 :         SwCrsrSaveState aSave( *this );
    1777                 :            : 
    1778         [ +  - ]:          6 :         if( !pPt )
    1779                 :            :         {
    1780                 :          6 :             SwRect aTmpRect;
    1781         [ +  - ]:          6 :             pFrm->GetCharRect( aTmpRect, *GetPoint() );
    1782                 :          6 :             aPt = aTmpRect.Pos();
    1783                 :            : 
    1784         [ +  - ]:          6 :             nUpDownX = pFrm->IsVertical() ?
    1785                 :          0 :                 aPt.Y() - pFrm->Frm().Top() :
    1786         [ -  + ]:          6 :                 aPt.X() - pFrm->Frm().Left();
    1787                 :            :         }
    1788                 :            : 
    1789                 :            :         // It is allowed to move footnotes in other footnotes but not sections
    1790         [ +  - ]:          6 :         const sal_Bool bChkRange = pFrm->IsInFtn() && !HasMark()
    1791   [ -  +  #  # ]:          6 :                                     ? sal_False : sal_True;
    1792         [ +  - ]:          6 :         const SwPosition aOldPos( *GetPoint() );
    1793         [ +  - ]:          6 :         sal_Bool bInReadOnly = IsReadOnlyAvailable();
    1794                 :            : 
    1795 [ +  - ][ +  + ]:          6 :         if ( bAdjustTableCrsr && !bUp )
    1796                 :            :         {
    1797                 :            :             // Special case: We have a table cursor but the start box has more
    1798                 :            :             // than one paragraph. If we want to go down, we have to set the
    1799                 :            :             // point to the last frame in the table box. This is only necessary
    1800                 :            :             // if we do not already have a table selection
    1801         [ +  - ]:          2 :             const SwStartNode* pTblNd = GetNode( sal_True )->FindTableBoxStartNode();
    1802                 :            :             OSL_ENSURE( pTblNd, "pTblCrsr without SwTableNode?" );
    1803                 :            : 
    1804         [ +  - ]:          2 :             if ( pTblNd ) // safety first
    1805                 :            :             {
    1806                 :          2 :                 const SwNode* pEndNd = pTblNd->EndOfSectionNode();
    1807         [ +  - ]:          2 :                 GetPoint()->nNode = *pEndNd;
    1808         [ +  - ]:          2 :                 pTblCrsr->Move( fnMoveBackward, fnGoNode );
    1809 [ +  - ][ +  - ]:          2 :                    pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1810                 :            :             }
    1811                 :            :         }
    1812                 :            : 
    1813 [ +  + ][ +  + ]:         22 :         while( nCnt &&
         [ +  - ][ +  - ]
                 [ +  + ]
    1814         [ +  - ]:          4 :                (bUp ? pFrm->UnitUp( this, nUpDownX, bInReadOnly )
    1815 [ +  - ][ +  - ]:          2 :                     : pFrm->UnitDown( this, nUpDownX, bInReadOnly ) ) &&
    1816         [ +  - ]:          6 :                 CheckNodesRange( aOldPos.nNode, GetPoint()->nNode, bChkRange ))
    1817                 :            :         {
    1818 [ +  - ][ +  - ]:          6 :                pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1819                 :          6 :             --nCnt;
    1820                 :            :         }
    1821                 :            : 
    1822                 :            :         // iterate over whole number of items?
    1823 [ +  - ][ +  - ]:         12 :         if( !nCnt && !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
                 [ +  - ]
    1824         [ +  - ]:          6 :                                 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ) )
    1825                 :            :         {
    1826         [ -  + ]:          6 :             if( !pTblCrsr )
    1827                 :            :             {
    1828                 :            :                 // try to position the cursor at half of the char-rect's height
    1829 [ #  # ][ #  # ]:          0 :                 pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1830                 :          0 :                 SwCrsrMoveState eTmpState( MV_UPDOWN );
    1831                 :          0 :                 eTmpState.bSetInReadOnly = bInReadOnly;
    1832                 :          0 :                 SwRect aTmpRect;
    1833         [ #  # ]:          0 :                 pFrm->GetCharRect( aTmpRect, *GetPoint(), &eTmpState );
    1834 [ #  # ][ #  # ]:          0 :                 if ( pFrm->IsVertical() )
    1835                 :            :                 {
    1836         [ #  # ]:          0 :                     aPt.X() = aTmpRect.Center().X();
    1837         [ #  # ]:          0 :                     pFrm->Calc();
    1838                 :          0 :                     aPt.Y() = pFrm->Frm().Top() + nUpDownX;
    1839                 :            :                 }
    1840                 :            :                 else
    1841                 :            :                 {
    1842         [ #  # ]:          0 :                     aPt.Y() = aTmpRect.Center().Y();
    1843         [ #  # ]:          0 :                     pFrm->Calc();
    1844                 :          0 :                     aPt.X() = pFrm->Frm().Left() + nUpDownX;
    1845                 :            :                 }
    1846         [ #  # ]:          0 :                 pFrm->GetCrsrOfst( GetPoint(), aPt, &eTmpState );
    1847                 :            :             }
    1848                 :          6 :             bRet = sal_True;
    1849                 :            :         }
    1850                 :            :         else
    1851         [ #  # ]:          0 :             *GetPoint() = aOldPos;
    1852                 :            : 
    1853 [ +  - ][ +  - ]:          6 :         DoSetBidiLevelUpDown(); // calculate cursor bidi level
                 [ +  - ]
    1854                 :            :     }
    1855                 :            : 
    1856                 :          6 :     return bRet;
    1857                 :            : }
    1858                 :            : 
    1859                 :          0 : sal_Bool SwCursor::LeftRightMargin( sal_Bool bLeft, sal_Bool bAPI )
    1860                 :            : {
    1861                 :          0 :     Point aPt;
    1862 [ #  # ][ #  # ]:          0 :     SwCntntFrm * pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1863                 :            : 
    1864                 :            :     // calculate cursor bidi level
    1865         [ #  # ]:          0 :     if ( pFrm )
    1866 [ #  # ][ #  # ]:          0 :         SetCrsrBidiLevel( pFrm->IsRightToLeft() ? 1 : 0 );
    1867                 :            : 
    1868         [ #  # ]:          0 :     return pFrm && (bLeft ? pFrm->LeftMargin( this ) :
    1869 [ #  # ][ #  # ]:          0 :                             pFrm->RightMargin( this, bAPI ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1870                 :            : }
    1871                 :            : 
    1872                 :          0 : sal_Bool SwCursor::IsAtLeftRightMargin( sal_Bool bLeft, sal_Bool bAPI ) const
    1873                 :            : {
    1874                 :          0 :     sal_Bool bRet = sal_False;
    1875                 :          0 :     Point aPt;
    1876 [ #  # ][ #  # ]:          0 :     SwCntntFrm * pFrm = GetCntntNode()->getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, GetPoint() );
    1877         [ #  # ]:          0 :     if( pFrm )
    1878                 :            :     {
    1879         [ #  # ]:          0 :         SwPaM aPam( *GetPoint() );
    1880 [ #  # ][ #  # ]:          0 :         if( !bLeft && aPam.GetPoint()->nContent.GetIndex() )
                 [ #  # ]
    1881         [ #  # ]:          0 :             aPam.GetPoint()->nContent--;
    1882         [ #  # ]:          0 :         bRet = (bLeft ? pFrm->LeftMargin( &aPam )
    1883         [ #  # ]:          0 :                       : pFrm->RightMargin( &aPam, bAPI ))
    1884 [ #  # ][ #  # ]:          0 :                 && *aPam.GetPoint() == *GetPoint();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1885                 :            :     }
    1886                 :          0 :     return bRet;
    1887                 :            : }
    1888                 :            : 
    1889                 :         49 : sal_Bool SwCursor::SttEndDoc( sal_Bool bStt )
    1890                 :            : {
    1891         [ +  - ]:         49 :     SwCrsrSaveState aSave( *this );
    1892                 :            :     // Never jump over section boundaries during selection!
    1893                 :            :     // Can the cursor still moved on?
    1894         [ +  + ]:         49 :     SwMoveFn fnMove = bStt ? fnMoveBackward : fnMoveForward;
    1895         [ +  - ]:         61 :     sal_Bool bRet = (!HasMark() || !IsNoCntnt() ) &&
    1896         [ +  - ]:         49 :                     Move( fnMove, fnGoDoc ) &&
    1897         [ +  - ]:         49 :                     !IsInProtectTable( sal_True ) &&
    1898                 :            :                     !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
    1899                 :            :                                nsSwCursorSelOverFlags::SELOVER_CHANGEPOS |
    1900 [ +  - ][ +  - ]:        159 :                                nsSwCursorSelOverFlags::SELOVER_ENABLEREVDIREKTION );
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    1901                 :            : 
    1902         [ +  - ]:         49 :     return bRet;
    1903                 :            : }
    1904                 :            : 
    1905                 :          8 : sal_Bool SwCursor::GoPrevNextCell( sal_Bool bNext, sal_uInt16 nCnt )
    1906                 :            : {
    1907         [ +  - ]:          8 :     const SwTableNode* pTblNd = GetPoint()->nNode.GetNode().FindTableNode();
    1908         [ -  + ]:          8 :     if( !pTblNd )
    1909                 :          0 :         return sal_False;
    1910                 :            : 
    1911                 :            :     // If there is another EndNode in front of the cell's StartNode then there
    1912                 :            :     // exists a previous cell
    1913         [ +  - ]:          8 :     SwCrsrSaveState aSave( *this );
    1914                 :          8 :     SwNodeIndex& rPtIdx = GetPoint()->nNode;
    1915                 :            : 
    1916         [ +  + ]:         16 :     while( nCnt-- )
    1917                 :            :     {
    1918         [ +  - ]:          8 :         const SwNode* pTableBoxStartNode = rPtIdx.GetNode().FindTableBoxStartNode();
    1919         [ +  - ]:          8 :         const SwTableBox* pTableBox = pTableBoxStartNode->GetTblBox();
    1920                 :            : 
    1921                 :            :         // Check if we have to move the cursor to a covered cell before
    1922                 :            :         // proceeding:
    1923         [ -  + ]:          8 :         if ( mnRowSpanOffset )
    1924                 :            :         {
    1925 [ #  # ][ #  # ]:          0 :             if ( pTableBox && pTableBox->getRowSpan() > 1 )
         [ #  # ][ #  # ]
    1926                 :            :             {
    1927 [ #  # ][ #  # ]:          0 :                 pTableBox = & pTableBox->FindEndOfRowSpan( pTblNd->GetTable(), (sal_uInt16)(pTableBox->getRowSpan() + mnRowSpanOffset) );
    1928         [ #  # ]:          0 :                 SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
    1929         [ #  # ]:          0 :                 rPtIdx = aNewIdx;
    1930 [ #  # ][ #  # ]:          0 :                 pTableBoxStartNode = rPtIdx.GetNode().FindTableBoxStartNode();
    1931                 :            :             }
    1932                 :          0 :             mnRowSpanOffset = 0;
    1933                 :            :         }
    1934                 :            : 
    1935                 :            :         const SwNode* pTmpNode = bNext ?
    1936                 :            :                                  pTableBoxStartNode->EndOfSectionNode() :
    1937         [ +  + ]:          8 :                                  pTableBoxStartNode;
    1938                 :            : 
    1939 [ +  + ][ +  - ]:          8 :         SwNodeIndex aCellIdx( *pTmpNode, bNext ? 1 : -1 );
    1940 [ +  + ][ +  - ]:         12 :         if(  (bNext && !aCellIdx.GetNode().IsStartNode()) ||
           [ +  +  -  + ]
                 [ -  + ]
    1941                 :          4 :             (!bNext && !aCellIdx.GetNode().IsEndNode()) )
    1942                 :          0 :             return sal_False;
    1943                 :            : 
    1944 [ +  + ][ +  - ]:          8 :         rPtIdx = bNext ? aCellIdx : SwNodeIndex(*aCellIdx.GetNode().StartOfSectionNode());
         [ +  - ][ +  - ]
                 [ +  - ]
    1945                 :            : 
    1946         [ +  - ]:          8 :         pTableBoxStartNode = rPtIdx.GetNode().FindTableBoxStartNode();
    1947         [ +  - ]:          8 :         pTableBox = pTableBoxStartNode->GetTblBox();
    1948 [ +  - ][ +  - ]:          8 :         if ( pTableBox && pTableBox->getRowSpan() < 1 )
         [ -  + ][ -  + ]
    1949                 :            :         {
    1950         [ #  # ]:          0 :             mnRowSpanOffset = pTableBox->getRowSpan();
    1951                 :            :             // move cursor to non-covered cell:
    1952         [ #  # ]:          0 :             pTableBox = & pTableBox->FindStartOfRowSpan( pTblNd->GetTable(), USHRT_MAX );
    1953         [ #  # ]:          0 :             SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
    1954 [ #  # ][ #  # ]:          8 :             rPtIdx = aNewIdx;
    1955                 :            :         }
    1956 [ +  - ][ +  - ]:          8 :     }
    1957                 :            : 
    1958         [ +  - ]:          8 :     rPtIdx++;
    1959         [ -  + ]:          8 :     if( !rPtIdx.GetNode().IsCntntNode() )
    1960 [ #  # ][ #  # ]:          0 :         GetDoc()->GetNodes().GoNextSection( &rPtIdx, sal_True, sal_False );
    1961 [ +  - ][ +  - ]:          8 :     GetPoint()->nContent.Assign( GetCntntNode(), 0 );
    1962                 :            : 
    1963 [ +  - ][ +  - ]:          8 :     return !IsInProtectTable( sal_True );
    1964                 :            : }
    1965                 :            : 
    1966                 :          0 : sal_Bool SwTableCursor::GotoTable( const String& )
    1967                 :            : {
    1968                 :          0 :     return sal_False; // invalid action
    1969                 :            : }
    1970                 :            : 
    1971                 :          2 : sal_Bool SwCursor::GotoTable( const String& rName )
    1972                 :            : {
    1973                 :          2 :     sal_Bool bRet = sal_False;
    1974         [ +  - ]:          2 :     if ( !HasMark() )
    1975                 :            :     {
    1976                 :          2 :         SwTable* pTmpTbl = SwTable::FindTable( GetDoc()->FindTblFmtByName( rName ) );
    1977         [ +  - ]:          2 :         if( pTmpTbl )
    1978                 :            :         {
    1979                 :            :             // a table in a normal nodes array
    1980         [ +  - ]:          2 :             SwCrsrSaveState aSave( *this );
    1981         [ +  - ]:          4 :             GetPoint()->nNode = *pTmpTbl->GetTabSortBoxes()[ 0 ]->
    1982   [ +  -  +  - ]:          4 :                                 GetSttNd()->FindTableNode();
    1983         [ +  - ]:          2 :             Move( fnMoveForward, fnGoCntnt );
    1984 [ +  - ][ +  - ]:          2 :             bRet = !IsSelOvr();
    1985                 :            :         }
    1986                 :            :     }
    1987                 :          2 :     return bRet;
    1988                 :            : }
    1989                 :            : 
    1990                 :          2 : sal_Bool SwCursor::GotoTblBox( const String& rName )
    1991                 :            : {
    1992                 :          2 :     sal_Bool bRet = sal_False;
    1993                 :          2 :     const SwTableNode* pTblNd = GetPoint()->nNode.GetNode().FindTableNode();
    1994         [ +  - ]:          2 :     if( pTblNd )
    1995                 :            :     {
    1996                 :            :         // retrieve box by name
    1997                 :          2 :         const SwTableBox* pTblBox = pTblNd->GetTable().GetTblBox( rName );
    1998   [ +  -  -  +  :          4 :         if( pTblBox && pTblBox->GetSttNd() &&
           #  # ][ +  - ]
                 [ +  - ]
    1999                 :          2 :             ( !pTblBox->GetFrmFmt()->GetProtect().IsCntntProtected() ||
    2000                 :          0 :               IsReadOnlyAvailable() ) )
    2001                 :            :         {
    2002         [ +  - ]:          2 :             SwCrsrSaveState aSave( *this );
    2003         [ +  - ]:          2 :             GetPoint()->nNode = *pTblBox->GetSttNd();
    2004         [ +  - ]:          2 :             Move( fnMoveForward, fnGoCntnt );
    2005 [ +  - ][ +  - ]:          2 :             bRet = !IsSelOvr();
    2006                 :            :         }
    2007                 :            :     }
    2008                 :          2 :     return bRet;
    2009                 :            : }
    2010                 :            : 
    2011                 :       7822 : sal_Bool SwCursor::MovePara(SwWhichPara fnWhichPara, SwPosPara fnPosPara )
    2012                 :            : {
    2013                 :            :     // for optimization test something before
    2014                 :       7822 :     const SwNode* pNd = &GetPoint()->nNode.GetNode();
    2015                 :       7822 :     bool bShortCut = false;
    2016         [ +  + ]:       7822 :     if ( fnWhichPara == fnParaCurr )
    2017                 :            :     {
    2018                 :            :         // #i41048#
    2019                 :            :         // If fnWhichPara == fnParaCurr then (*fnWhichPara)( *this, fnPosPara )
    2020                 :            :         // can already move the cursor to a different text node. In this case
    2021                 :            :         // we better check if IsSelOvr().
    2022                 :       4844 :         const SwCntntNode* pCntntNd = pNd->GetCntntNode();
    2023         [ +  - ]:       4844 :         if ( pCntntNd )
    2024                 :            :         {
    2025 [ +  + ][ +  - ]:       4844 :             const xub_StrLen nSttEnd = fnPosPara == fnMoveForward ? 0 : pCntntNd->Len();
    2026         [ +  + ]:       4844 :             if ( GetPoint()->nContent.GetIndex() != nSttEnd )
    2027                 :       2878 :                 bShortCut = true;
    2028                 :            :         }
    2029                 :            :     }
    2030                 :            :     else
    2031                 :            :     {
    2032   [ +  -  +  + ]:       5956 :         if ( pNd->IsTxtNode() &&
                 [ +  + ]
    2033                 :       5956 :              pNd->GetNodes()[ pNd->GetIndex() +
    2034 [ +  - ][ +  + ]:       5956 :                     (fnWhichPara == fnParaNext ? 1 : -1 ) ]->IsTxtNode() )
    2035                 :       1558 :             bShortCut = true;
    2036                 :            :     }
    2037                 :            : 
    2038         [ +  + ]:       7822 :     if ( bShortCut )
    2039         [ +  - ]:       4436 :         return (*fnWhichPara)( *this, fnPosPara );
    2040                 :            : 
    2041                 :            :     // else we must use the SaveStructure, because the next/prev is not
    2042                 :            :     // a same node type.
    2043         [ +  - ]:       3386 :     SwCrsrSaveState aSave( *this );
    2044         [ +  - ]:       3386 :     return (*fnWhichPara)( *this, fnPosPara ) &&
    2045         [ +  - ]:        814 :             !IsInProtectTable( sal_True ) &&
    2046                 :            :             !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
    2047 [ +  + ][ +  - ]:       8636 :                        nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
         [ +  - ][ +  + ]
                 [ +  - ]
    2048                 :            : }
    2049                 :            : 
    2050                 :            : 
    2051                 :        971 : sal_Bool SwCursor::MoveSection( SwWhichSection fnWhichSect,
    2052                 :            :                                 SwPosSection fnPosSect)
    2053                 :            : {
    2054         [ +  - ]:        971 :     SwCrsrSaveState aSave( *this );
    2055         [ +  - ]:        971 :     return (*fnWhichSect)( *this, fnPosSect ) &&
    2056         [ +  - ]:        589 :             !IsInProtectTable( sal_True ) &&
    2057                 :            :             !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
    2058 [ +  + ][ +  - ]:       1560 :                        nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
         [ +  - ][ +  - ]
                 [ +  - ]
    2059                 :            : }
    2060                 :            : 
    2061                 :          0 : void SwCursor::RestoreSavePos()
    2062                 :            : {
    2063                 :            :     // This method is not supposed to be used in cases when nodes may be
    2064                 :            :     // deleted; detect such cases, but do not crash (example: fdo#40831).
    2065                 :          0 :     sal_uLong uNodeCount = GetPoint()->nNode.GetNodes().Count();
    2066                 :            :     OSL_ENSURE(!pSavePos || pSavePos->nNode < uNodeCount,
    2067                 :            :         "SwCursor::RestoreSavePos: invalid node: "
    2068                 :            :         "probably something was deleted; consider using SwUnoCrsr instead");
    2069 [ #  # ][ #  # ]:          0 :     if( pSavePos && pSavePos->nNode < uNodeCount )
    2070                 :            :     {
    2071                 :          0 :         GetPoint()->nNode = pSavePos->nNode;
    2072                 :            : 
    2073                 :          0 :         xub_StrLen nIdx = 0;
    2074         [ #  # ]:          0 :         if ( GetCntntNode() )
    2075                 :            :         {
    2076         [ #  # ]:          0 :             if ( pSavePos->nCntnt <= GetCntntNode()->Len() )
    2077                 :          0 :                 nIdx = pSavePos->nCntnt;
    2078                 :            :             else
    2079                 :            :             {
    2080                 :          0 :                 nIdx = GetCntntNode()->Len();
    2081                 :            :                 OSL_FAIL("SwCursor::RestoreSavePos: invalid content index");
    2082                 :            :             }
    2083                 :            :         }
    2084         [ #  # ]:          0 :         GetPoint()->nContent.Assign( GetCntntNode(), nIdx );
    2085                 :            :     }
    2086                 :          0 : }
    2087                 :            : 
    2088                 :            : 
    2089                 :            : 
    2090                 :         55 : SwTableCursor::SwTableCursor( const SwPosition &rPos, SwPaM* pRing )
    2091 [ #  # ][ +  - ]:         55 :     : SwCursor( rPos, pRing, false )
    2092                 :            : {
    2093                 :         55 :     bParked = sal_False;
    2094                 :         55 :     bChg = sal_False;
    2095                 :         55 :     nTblPtNd = 0, nTblMkNd = 0;
    2096                 :         55 :     nTblPtCnt = 0, nTblMkCnt = 0;
    2097                 :         55 : }
    2098                 :            : 
    2099 [ #  # ][ #  # ]:         55 : SwTableCursor::~SwTableCursor() {}
         [ -  + ][ -  + ]
    2100                 :            : 
    2101                 :            : 
    2102                 :         34 : sal_Bool lcl_SeekEntry( const SwSelBoxes& rTmp, const SwStartNode* pSrch, sal_uInt16& rFndPos )
    2103                 :            : {
    2104                 :         34 :     sal_uLong nIdx = pSrch->GetIndex();
    2105                 :            : 
    2106                 :         34 :     sal_uInt16 nO = rTmp.size();
    2107         [ +  + ]:         34 :     if( nO > 0 )
    2108                 :            :     {
    2109                 :         22 :         nO--;
    2110                 :         22 :         sal_uInt16 nU = 0;
    2111         [ +  + ]:         30 :         while( nU <= nO )
    2112                 :            :         {
    2113                 :         28 :             sal_uInt16 nM = nU + ( nO - nU ) / 2;
    2114         [ +  + ]:         28 :             if( rTmp[ nM ]->GetSttNd() == pSrch )
    2115                 :            :             {
    2116                 :         10 :                 rFndPos = nM;
    2117                 :         10 :                 return sal_True;
    2118                 :            :             }
    2119         [ +  + ]:         18 :             else if( rTmp[ nM ]->GetSttIdx() < nIdx )
    2120                 :          8 :                 nU = nM + 1;
    2121         [ +  - ]:         10 :             else if( nM == 0 )
    2122                 :         10 :                 return sal_False;
    2123                 :            :             else
    2124                 :          0 :                 nO = nM - 1;
    2125                 :            :         }
    2126                 :            :     }
    2127                 :         34 :     return sal_False;
    2128                 :            : }
    2129                 :            : 
    2130                 :            : 
    2131                 :         73 : SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr )
    2132                 :            : {
    2133         [ +  - ]:         73 :     if( bChg )
    2134                 :            :     {
    2135         [ -  + ]:         73 :         if( bParked )
    2136                 :            :         {
    2137                 :            :             // move back into content
    2138                 :          0 :             Exchange();
    2139         [ #  # ]:          0 :             Move( fnMoveForward );
    2140                 :          0 :             Exchange();
    2141         [ #  # ]:          0 :             Move( fnMoveForward );
    2142                 :          0 :             bParked = sal_False;
    2143                 :            :         }
    2144                 :            : 
    2145                 :         73 :         bChg = sal_False;
    2146                 :            : 
    2147                 :            :         // create temporary copies so that all boxes that
    2148                 :            :         // have already cursors can be removed
    2149         [ +  - ]:         73 :         SwSelBoxes aTmp( aSelBoxes );
    2150                 :            : 
    2151                 :            :         // compare old and new ones
    2152         [ +  - ]:         73 :         SwNodes& rNds = pAktCrsr->GetDoc()->GetNodes();
    2153                 :            :         sal_uInt16 nPos;
    2154                 :            :         const SwStartNode* pSttNd;
    2155                 :         73 :         SwPaM* pCur = pAktCrsr;
    2156         [ +  + ]:         95 :         do {
    2157                 :         95 :             sal_Bool bDel = sal_False;
    2158         [ +  - ]:         95 :             pSttNd = pCur->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
    2159 [ +  + ][ +  + ]:        129 :             if( !pCur->HasMark() || !pSttNd ||
         [ -  + ][ +  + ]
    2160         [ +  - ]:         34 :                 pSttNd != pCur->GetMark()->nNode.GetNode().FindTableBoxStartNode() )
    2161                 :         61 :                 bDel = sal_True;
    2162                 :            : 
    2163 [ +  - ][ +  + ]:         34 :             else if( lcl_SeekEntry( aTmp, pSttNd, nPos ))
    2164                 :            :             {
    2165         [ +  - ]:         10 :                 SwNodeIndex aIdx( *pSttNd, 1 );
    2166                 :         10 :                 const SwNode* pNd = &aIdx.GetNode();
    2167         [ -  + ]:         10 :                 if( !pNd->IsCntntNode() )
    2168 [ #  # ][ #  # ]:          0 :                     pNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
    2169                 :            : 
    2170                 :         10 :                 SwPosition* pPos = pCur->GetMark();
    2171         [ -  + ]:         10 :                 if( pNd != &pPos->nNode.GetNode() )
    2172         [ #  # ]:          0 :                     pPos->nNode = *pNd;
    2173 [ +  - ][ +  - ]:         10 :                 pPos->nContent.Assign( (SwCntntNode*)pNd, 0 );
         [ +  - ][ +  - ]
    2174                 :            : 
    2175         [ +  - ]:         10 :                 aIdx.Assign( *pSttNd->EndOfSectionNode(), - 1 );
    2176         [ -  + ]:         10 :                 if( !( pNd = &aIdx.GetNode())->IsCntntNode() )
    2177 [ #  # ][ #  # ]:          0 :                     pNd = rNds.GoPrevSection( &aIdx, sal_True, sal_False );
    2178                 :            : 
    2179                 :         10 :                 pPos = pCur->GetPoint();
    2180         [ -  + ]:         10 :                 if( pNd != &pPos->nNode.GetNode() )
    2181         [ #  # ]:          0 :                     pPos->nNode = *pNd;
    2182 [ +  - ][ +  - ]:         10 :                 pPos->nContent.Assign( (SwCntntNode*)pNd, ((SwCntntNode*)pNd)->Len() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2183                 :            : 
    2184 [ +  - ][ +  - ]:         10 :                 aTmp.erase( aTmp.begin() + nPos );
                 [ +  - ]
    2185                 :            :             }
    2186                 :            :             else
    2187                 :         24 :                 bDel = sal_True;
    2188                 :            : 
    2189                 :         95 :             pCur = (SwPaM*)pCur->GetNext();
    2190         [ +  + ]:         95 :             if( bDel )
    2191                 :            :             {
    2192                 :         85 :                 SwPaM* pDel = (SwPaM*)pCur->GetPrev();
    2193                 :            : 
    2194         [ +  + ]:         85 :                 if( pDel == pAktCrsr )
    2195         [ +  - ]:         65 :                     pAktCrsr->DeleteMark();
    2196                 :            :                 else
    2197 [ +  - ][ +  - ]:         20 :                     delete pDel;
    2198                 :            :             }
    2199                 :            :         } while ( pAktCrsr != pCur );
    2200                 :            : 
    2201         [ +  + ]:        444 :         for( nPos = 0; nPos < aTmp.size(); ++nPos )
    2202                 :            :         {
    2203         [ +  - ]:        371 :             pSttNd = aTmp[ nPos ]->GetSttNd();
    2204                 :            : 
    2205         [ +  - ]:        371 :             SwNodeIndex aIdx( *pSttNd, 1 );
    2206         [ -  + ]:        371 :             if( &aIdx.GetNodes() != &rNds )
    2207                 :            :                 break;
    2208                 :        371 :             const SwNode* pNd = &aIdx.GetNode();
    2209         [ -  + ]:        371 :             if( !pNd->IsCntntNode() )
    2210 [ #  # ][ #  # ]:          0 :                 pNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
    2211                 :            : 
    2212                 :            :             SwPaM* pNew;
    2213 [ +  + ][ +  + ]:        371 :             if( pAktCrsr->GetNext() == pAktCrsr && !pAktCrsr->HasMark() )
                 [ +  + ]
    2214                 :            :             {
    2215                 :         63 :                 pNew = pAktCrsr;
    2216         [ +  - ]:         63 :                 pNew->GetPoint()->nNode = *pNd;
    2217 [ +  - ][ +  - ]:         63 :                 pNew->GetPoint()->nContent.Assign( (SwCntntNode*)pNd, 0 );
         [ +  - ][ +  - ]
    2218                 :            :             }
    2219                 :            :             else
    2220                 :            :             {
    2221         [ +  - ]:        308 :                 pNew = pAktCrsr->Create( pAktCrsr );
    2222         [ +  - ]:        308 :                 pNew->GetPoint()->nNode = *pNd;
    2223 [ +  - ][ +  - ]:        308 :                 pNew->GetPoint()->nContent.Assign( (SwCntntNode*)pNd, 0 );
         [ +  - ][ +  - ]
    2224                 :            :             }
    2225         [ +  - ]:        371 :             pNew->SetMark();
    2226                 :            : 
    2227                 :        371 :             SwPosition* pPos = pNew->GetPoint();
    2228         [ +  - ]:        371 :             pPos->nNode.Assign( *pSttNd->EndOfSectionNode(), - 1 );
    2229         [ -  + ]:        371 :             if( !( pNd = &pPos->nNode.GetNode())->IsCntntNode() )
    2230 [ #  # ][ #  # ]:          0 :                 pNd = rNds.GoPrevSection( &pPos->nNode, sal_True, sal_False );
    2231                 :            : 
    2232 [ +  - ][ +  - ]:        742 :             pPos->nContent.Assign( (SwCntntNode*)pNd, ((SwCntntNode*)pNd)->Len() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    2233         [ +  - ]:        444 :         }
    2234                 :            :     }
    2235                 :         73 :     return pAktCrsr;
    2236                 :            : }
    2237                 :            : 
    2238                 :            : 
    2239                 :        373 : void SwTableCursor::InsertBox( const SwTableBox& rTblBox )
    2240                 :            : {
    2241                 :        373 :     SwTableBox* pBox = (SwTableBox*)&rTblBox;
    2242         [ +  - ]:        373 :     aSelBoxes.insert( pBox );
    2243                 :        373 :     bChg = sal_True;
    2244                 :        373 : }
    2245                 :            : 
    2246                 :        675 : bool SwTableCursor::NewTableSelection()
    2247                 :            : {
    2248                 :        675 :     bool bRet = false;
    2249                 :        675 :     const SwNode *pStart = GetCntntNode()->FindTableBoxStartNode();
    2250                 :        675 :     const SwNode *pEnd = GetCntntNode(sal_False)->FindTableBoxStartNode();
    2251 [ +  - ][ +  - ]:        675 :     if( pStart && pEnd )
    2252                 :            :     {
    2253                 :        675 :         const SwTableNode *pTableNode = pStart->FindTableNode();
    2254         [ +  - ]:       1350 :         if( pTableNode == pEnd->FindTableNode() &&
           [ +  -  +  - ]
    2255                 :        675 :             pTableNode->GetTable().IsNewModel() )
    2256                 :            :         {
    2257                 :        675 :             bRet = true;
    2258         [ +  - ]:        675 :             SwSelBoxes aNew( aSelBoxes );
    2259                 :        675 :             pTableNode->GetTable().CreateSelection( pStart, pEnd, aNew,
    2260         [ +  - ]:        675 :                 SwTable::SEARCH_NONE, false );
    2261         [ +  - ]:        675 :             ActualizeSelection( aNew );
    2262                 :            :         }
    2263                 :            :     }
    2264                 :        675 :     return bRet;
    2265                 :            : }
    2266                 :            : 
    2267                 :        675 : void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew )
    2268                 :            : {
    2269                 :        675 :     sal_uInt16 nOld = 0, nNew = 0;
    2270 [ +  + ][ +  + ]:       3701 :     while ( nOld < aSelBoxes.size() && nNew < rNew.size() )
                 [ +  + ]
    2271                 :            :     {
    2272                 :       3026 :         const SwTableBox* pPOld = aSelBoxes[ nOld ];
    2273                 :       3026 :         const SwTableBox* pPNew = rNew[ nNew ];
    2274         [ +  + ]:       3026 :         if( pPOld == pPNew )
    2275                 :            :         {   // this box will stay
    2276                 :       3006 :             ++nOld;
    2277                 :       3006 :             ++nNew;
    2278                 :            :         }
    2279         [ +  + ]:         20 :         else if( pPOld->GetSttIdx() < pPNew->GetSttIdx() )
    2280                 :         10 :             DeleteBox( nOld ); // this box has to go
    2281                 :            :         else
    2282                 :            :         {
    2283                 :         10 :             InsertBox( *pPNew ); // this is a new one
    2284                 :         10 :             ++nOld;
    2285                 :         10 :             ++nNew;
    2286                 :            :         }
    2287                 :            :     }
    2288                 :            : 
    2289         [ +  + ]:        689 :     while( nOld < aSelBoxes.size() )
    2290                 :         14 :         DeleteBox( nOld ); // some more to delete
    2291                 :            : 
    2292         [ +  + ]:       1038 :     for( ; nNew < rNew.size(); ++nNew ) // some more to insert
    2293                 :        363 :         InsertBox( *rNew[ nNew ] );
    2294                 :        675 : }
    2295                 :            : 
    2296                 :        226 : sal_Bool SwTableCursor::IsCrsrMovedUpdt()
    2297                 :            : {
    2298         [ +  + ]:        226 :     if( !IsCrsrMoved() )
    2299                 :        214 :         return sal_False;
    2300                 :            : 
    2301                 :         12 :     nTblMkNd = GetMark()->nNode.GetIndex();
    2302                 :         12 :     nTblPtNd = GetPoint()->nNode.GetIndex();
    2303                 :         12 :     nTblMkCnt = GetMark()->nContent.GetIndex();
    2304                 :         12 :     nTblPtCnt = GetPoint()->nContent.GetIndex();
    2305                 :        226 :     return sal_True;
    2306                 :            : }
    2307                 :            : 
    2308                 :            : /// park table cursor on the boxes' start node
    2309                 :          0 : void SwTableCursor::ParkCrsr()
    2310                 :            : {
    2311                 :            :     // de-register index from text node
    2312                 :          0 :     SwNode* pNd = &GetPoint()->nNode.GetNode();
    2313         [ #  # ]:          0 :     if( !pNd->IsStartNode() )
    2314                 :          0 :         pNd = pNd->StartOfSectionNode();
    2315                 :          0 :     GetPoint()->nNode = *pNd;
    2316                 :          0 :     GetPoint()->nContent.Assign( 0, 0 );
    2317                 :            : 
    2318                 :          0 :     pNd = &GetMark()->nNode.GetNode();
    2319         [ #  # ]:          0 :     if( !pNd->IsStartNode() )
    2320                 :          0 :         pNd = pNd->StartOfSectionNode();
    2321                 :          0 :     GetMark()->nNode = *pNd;
    2322                 :          0 :     GetMark()->nContent.Assign( 0, 0 );
    2323                 :            : 
    2324                 :          0 :     bChg = sal_True;
    2325                 :          0 :     bParked = sal_True;
    2326                 :          0 : }
    2327                 :            : 
    2328                 :            : 
    2329                 :         28 : sal_Bool SwTableCursor::HasReadOnlyBoxSel() const
    2330                 :            : {
    2331                 :         28 :     sal_Bool bRet = sal_False;
    2332         [ +  + ]:        116 :     for( sal_uInt16 n = aSelBoxes.size(); n;  )
    2333         [ -  + ]:         88 :         if( aSelBoxes[ --n ]->GetFrmFmt()->GetProtect().IsCntntProtected() )
    2334                 :            :         {
    2335                 :          0 :             bRet = sal_True;
    2336                 :          0 :             break;
    2337                 :            :         }
    2338                 :         28 :     return bRet;
    2339                 :            : }
    2340                 :            : 
    2341                 :            : 
    2342                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10