LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/crsr - crstrvl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 1142 1.1 %
Date: 2012-12-27 Functions: 2 36 5.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <comphelper/string.hxx>
      22             : #include <svl/itemiter.hxx>
      23             : #include <editeng/lrspitem.hxx>
      24             : #include <editeng/adjitem.hxx>
      25             : #include <editeng/brkitem.hxx>
      26             : #include <svx/svdobj.hxx>
      27             : #include <crsrsh.hxx>
      28             : #include <doc.hxx>
      29             : #include <IDocumentUndoRedo.hxx>
      30             : #include <pagefrm.hxx>
      31             : #include <cntfrm.hxx>
      32             : #include <rootfrm.hxx>
      33             : #include <pam.hxx>
      34             : #include <ndtxt.hxx>
      35             : #include <fldbas.hxx>
      36             : #include <swtable.hxx>
      37             : #include <docary.hxx>
      38             : #include <txtfld.hxx>
      39             : #include <fmtfld.hxx>
      40             : #include <txtftn.hxx>
      41             : #include <txtinet.hxx>
      42             : #include <fmtinfmt.hxx>
      43             : #include <txttxmrk.hxx>
      44             : #include <frmfmt.hxx>
      45             : #include <flyfrm.hxx>
      46             : #include <viscrs.hxx>
      47             : #include <callnk.hxx>
      48             : #include <doctxm.hxx>
      49             : #include <docfld.hxx>
      50             : #include <expfld.hxx>
      51             : #include <reffld.hxx>
      52             : #include <flddat.hxx>
      53             : #include <cellatr.hxx>
      54             : #include <swundo.hxx>
      55             : #include <redline.hxx>
      56             : #include <fmtcntnt.hxx>
      57             : #include <fmthdft.hxx>
      58             : #include <pagedesc.hxx>
      59             : #include <fesh.hxx>
      60             : #include <charfmt.hxx>
      61             : #include <fmturl.hxx>
      62             : #include "txtfrm.hxx"
      63             : #include <wrong.hxx>
      64             : #include <switerator.hxx>
      65             : #include <vcl/window.hxx>
      66             : #include <docufld.hxx>
      67             : 
      68             : using namespace ::com::sun::star;
      69             : 
      70             : /// go to next/previous point on the same level
      71           0 : bool SwCrsrShell::GotoNextNum()
      72             : {
      73           0 :     bool bRet = GetDoc()->GotoNextNum( *pCurCrsr->GetPoint() );
      74           0 :     if( bRet )
      75             :     {
      76           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
      77           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
      78           0 :         if( !ActionPend() )
      79             :         {
      80           0 :             SET_CURR_SHELL( this );
      81             :             // try to set cursor onto this position, at half of the char-
      82             :             // SRectangle's height
      83           0 :             Point aPt( pCurCrsr->GetPtPos() );
      84           0 :             SwCntntFrm * pFrm = pCurCrsr->GetCntntNode()->getLayoutFrm( GetLayout(), &aPt,
      85           0 :                                                         pCurCrsr->GetPoint() );
      86           0 :             pFrm->GetCharRect( aCharRect, *pCurCrsr->GetPoint() );
      87           0 :             pFrm->Calc();
      88           0 :             if( pFrm->IsVertical() )
      89             :             {
      90           0 :                 aPt.X() = aCharRect.Center().X();
      91           0 :                 aPt.Y() = pFrm->Frm().Top() + nUpDownX;
      92             :             }
      93             :             else
      94             :             {
      95           0 :                 aPt.Y() = aCharRect.Center().Y();
      96           0 :                 aPt.X() = pFrm->Frm().Left() + nUpDownX;
      97             :             }
      98           0 :             pFrm->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
      99             :             bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
     100           0 :                                         nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
     101           0 :             if( bRet )
     102             :                 UpdateCrsr(SwCrsrShell::UPDOWN |
     103             :                         SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     104           0 :                         SwCrsrShell::READONLY );
     105           0 :         }
     106             :     }
     107           0 :     return bRet;
     108             : }
     109             : 
     110             : 
     111           0 : bool SwCrsrShell::GotoPrevNum()
     112             : {
     113           0 :     bool bRet = GetDoc()->GotoPrevNum( *pCurCrsr->GetPoint() );
     114           0 :     if( bRet )
     115             :     {
     116           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     117           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
     118           0 :         if( !ActionPend() )
     119             :         {
     120           0 :             SET_CURR_SHELL( this );
     121             :             // try to set cursor onto this position, at half of the char-
     122             :             // SRectangle's height
     123           0 :             Point aPt( pCurCrsr->GetPtPos() );
     124           0 :             SwCntntFrm * pFrm = pCurCrsr->GetCntntNode()->getLayoutFrm( GetLayout(), &aPt,
     125           0 :                                                         pCurCrsr->GetPoint() );
     126           0 :             pFrm->GetCharRect( aCharRect, *pCurCrsr->GetPoint() );
     127           0 :             pFrm->Calc();
     128           0 :             if( pFrm->IsVertical() )
     129             :             {
     130           0 :                 aPt.X() = aCharRect.Center().X();
     131           0 :                 aPt.Y() = pFrm->Frm().Top() + nUpDownX;
     132             :             }
     133             :             else
     134             :             {
     135           0 :                 aPt.Y() = aCharRect.Center().Y();
     136           0 :                 aPt.X() = pFrm->Frm().Left() + nUpDownX;
     137             :             }
     138           0 :             pFrm->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
     139             :             bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
     140           0 :                                         nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
     141           0 :             if( bRet )
     142             :                 UpdateCrsr(SwCrsrShell::UPDOWN |
     143             :                         SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     144           0 :                         SwCrsrShell::READONLY );
     145           0 :         }
     146             :     }
     147           0 :     return bRet;
     148             : }
     149             : 
     150             : /// jump from content to header
     151           0 : sal_Bool SwCrsrShell::GotoHeaderTxt()
     152             : {
     153           0 :     const SwFrm* pFrm = GetCurrFrm()->FindPageFrm();
     154           0 :     while( pFrm && !pFrm->IsHeaderFrm() )
     155           0 :         pFrm = pFrm->GetLower();
     156             :     // found header, search 1. content frame
     157           0 :     while( pFrm && !pFrm->IsCntntFrm() )
     158           0 :         pFrm = pFrm->GetLower();
     159           0 :     if( pFrm )
     160             :     {
     161           0 :         SET_CURR_SHELL( this );
     162             :         // get header frame
     163           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     164           0 :         SwCursor *pTmpCrsr = getShellCrsr( true );
     165           0 :         SwCrsrSaveState aSaveState( *pTmpCrsr );
     166           0 :         pFrm->Calc();
     167           0 :         Point aPt( pFrm->Frm().Pos() + pFrm->Prt().Pos() );
     168           0 :         pFrm->GetCrsrOfst( pTmpCrsr->GetPoint(), aPt );
     169           0 :         if( !pTmpCrsr->IsSelOvr() )
     170           0 :             UpdateCrsr();
     171             :         else
     172           0 :             pFrm = 0;
     173             :     }
     174           0 :     return 0 != pFrm;
     175             : }
     176             : 
     177             : /// jump from content to footer
     178           0 : sal_Bool SwCrsrShell::GotoFooterTxt()
     179             : {
     180           0 :     const SwPageFrm* pFrm = GetCurrFrm()->FindPageFrm();
     181           0 :     if( pFrm )
     182             :     {
     183           0 :         const SwFrm* pLower = pFrm->GetLastLower();
     184             : 
     185           0 :         while( pLower && !pLower->IsFooterFrm() )
     186           0 :             pLower = pLower->GetLower();
     187             :         // found footer, search 1. content frame
     188           0 :         while( pLower && !pLower->IsCntntFrm() )
     189           0 :             pLower = pLower->GetLower();
     190             : 
     191           0 :         if( pLower )
     192             :         {
     193           0 :             SwCursor *pTmpCrsr = getShellCrsr( true );
     194           0 :             SET_CURR_SHELL( this );
     195             :             // get position in footer
     196           0 :             SwCallLink aLk( *this ); // watch Crsr-Moves
     197           0 :             SwCrsrSaveState aSaveState( *pTmpCrsr );
     198           0 :             pLower->Calc();
     199           0 :             Point aPt( pLower->Frm().Pos() + pLower->Prt().Pos() );
     200           0 :             pLower->GetCrsrOfst( pTmpCrsr->GetPoint(), aPt );
     201           0 :             if( !pTmpCrsr->IsSelOvr() )
     202           0 :                 UpdateCrsr();
     203             :             else
     204           0 :                 pFrm = 0;
     205             :         }
     206             :         else
     207           0 :             pFrm = 0;
     208             :     }
     209             :     else
     210           0 :         pFrm = 0;
     211           0 :     return 0 != pFrm;
     212             : }
     213             : 
     214           0 : sal_Bool SwCrsrShell::SetCrsrInHdFt( sal_uInt16 nDescNo, sal_Bool bInHeader )
     215             : {
     216           0 :     sal_Bool bRet = sal_False;
     217           0 :     SwDoc *pMyDoc = GetDoc();
     218             : 
     219           0 :     SET_CURR_SHELL( this );
     220             : 
     221           0 :     if( USHRT_MAX == nDescNo )
     222             :     {
     223             :         // take the current one
     224           0 :         const SwPageFrm* pPage = GetCurrFrm()->FindPageFrm();
     225           0 :         if( pPage )
     226           0 :             for( sal_uInt16 i = 0; i < pMyDoc->GetPageDescCnt(); ++i )
     227           0 :                 if( pPage->GetPageDesc() == &pMyDoc->GetPageDesc( i ) )
     228             :                 {
     229           0 :                     nDescNo = i;
     230           0 :                     break;
     231             :                 }
     232             :     }
     233             : 
     234           0 :     if( USHRT_MAX != nDescNo && nDescNo < pMyDoc->GetPageDescCnt() )
     235             :     {
     236             :         // check if the attribute exists
     237             :         const SwPageDesc& rDesc = const_cast<const SwDoc *>(pMyDoc)
     238           0 :             ->GetPageDesc( nDescNo );
     239           0 :         const SwFmtCntnt* pCnt = 0;
     240           0 :         if( bInHeader )
     241             :         {
     242             :             // mirrored pages? ignore for now
     243           0 :             const SwFmtHeader& rHd = rDesc.GetMaster().GetHeader();
     244           0 :             if( rHd.GetHeaderFmt() )
     245           0 :                 pCnt = &rHd.GetHeaderFmt()->GetCntnt();
     246             :         }
     247             :         else
     248             :         {
     249           0 :             const SwFmtFooter& rFt = rDesc.GetMaster().GetFooter();
     250           0 :             if( rFt.GetFooterFmt() )
     251           0 :                 pCnt = &rFt.GetFooterFmt()->GetCntnt();
     252             :         }
     253             : 
     254           0 :         if( pCnt && pCnt->GetCntntIdx() )
     255             :         {
     256           0 :             SwNodeIndex aIdx( *pCnt->GetCntntIdx(), 1 );
     257           0 :             SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
     258           0 :             if( !pCNd )
     259           0 :                 pCNd = pMyDoc->GetNodes().GoNext( &aIdx );
     260             : 
     261             :             const SwFrm* pFrm;
     262           0 :             Point aPt( pCurCrsr->GetPtPos() );
     263             : 
     264           0 :             if( pCNd && 0 != ( pFrm = pCNd->getLayoutFrm( GetLayout(), &aPt, 0, sal_False ) ))
     265             :             {
     266             :                 // then we can set the cursor in here
     267           0 :                 SwCallLink aLk( *this ); // watch Crsr-Moves
     268           0 :                 SwCrsrSaveState aSaveState( *pCurCrsr );
     269             : 
     270           0 :                 ClearMark();
     271             : 
     272           0 :                 SwPosition& rPos = *pCurCrsr->GetPoint();
     273           0 :                 rPos.nNode = *pCNd;
     274           0 :                 rPos.nContent.Assign( pCNd, 0 );
     275             : 
     276           0 :                 bRet = !pCurCrsr->IsSelOvr();
     277           0 :                 if( bRet )
     278             :                     UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     279           0 :                                 SwCrsrShell::READONLY );
     280           0 :             }
     281             :         }
     282             :     }
     283           0 :     return bRet;
     284             : }
     285             : 
     286             : /// jump to the next index
     287           0 : sal_Bool SwCrsrShell::GotoNextTOXBase( const String* pName )
     288             : {
     289           0 :     sal_Bool bRet = sal_False;
     290             : 
     291           0 :     const SwSectionFmts& rFmts = GetDoc()->GetSections();
     292           0 :     SwCntntNode* pFnd = 0;
     293           0 :     for( sal_uInt16 n = rFmts.size(); n; )
     294             :     {
     295           0 :         const SwSection* pSect = rFmts[ --n ]->GetSection();
     296             :         const SwSectionNode* pSectNd;
     297           0 :         if( TOX_CONTENT_SECTION == pSect->GetType() &&
     298           0 :             0 != ( pSectNd = pSect->GetFmt()->GetSectionNode() ) &&
     299           0 :              pCurCrsr->GetPoint()->nNode < pSectNd->GetIndex() &&
     300           0 :             ( !pFnd || pFnd->GetIndex() > pSectNd->GetIndex() ) &&
     301           0 :             ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTOXName() )
     302             :             )
     303             :         {
     304           0 :             SwNodeIndex aIdx( *pSectNd, 1 );
     305           0 :             SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
     306           0 :             if( !pCNd )
     307           0 :                 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
     308             :             const SwCntntFrm* pCFrm;
     309           0 :             if( pCNd &&
     310           0 :                 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex() &&
     311           0 :                 0 != ( pCFrm = pCNd->getLayoutFrm( GetLayout() ) ) &&
     312           0 :                 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
     313             :             {
     314           0 :                 pFnd = pCNd;
     315           0 :             }
     316             :         }
     317             :     }
     318           0 :     if( pFnd )
     319             :     {
     320           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     321           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
     322           0 :         pCurCrsr->GetPoint()->nNode = *pFnd;
     323           0 :         pCurCrsr->GetPoint()->nContent.Assign( pFnd, 0 );
     324           0 :         bRet = !pCurCrsr->IsSelOvr();
     325           0 :         if( bRet )
     326           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     327             :     }
     328           0 :     return bRet;
     329             : }
     330             : 
     331             : /// jump to previous index
     332           0 : sal_Bool SwCrsrShell::GotoPrevTOXBase( const String* pName )
     333             : {
     334           0 :     sal_Bool bRet = sal_False;
     335             : 
     336           0 :     const SwSectionFmts& rFmts = GetDoc()->GetSections();
     337           0 :     SwCntntNode* pFnd = 0;
     338           0 :     for( sal_uInt16 n = rFmts.size(); n; )
     339             :     {
     340           0 :         const SwSection* pSect = rFmts[ --n ]->GetSection();
     341             :         const SwSectionNode* pSectNd;
     342           0 :         if( TOX_CONTENT_SECTION == pSect->GetType() &&
     343           0 :             0 != ( pSectNd = pSect->GetFmt()->GetSectionNode() ) &&
     344           0 :             pCurCrsr->GetPoint()->nNode > pSectNd->EndOfSectionIndex() &&
     345           0 :             ( !pFnd || pFnd->GetIndex() < pSectNd->GetIndex() ) &&
     346           0 :             ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTOXName() )
     347             :             )
     348             :         {
     349           0 :             SwNodeIndex aIdx( *pSectNd, 1 );
     350           0 :             SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
     351           0 :             if( !pCNd )
     352           0 :                 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
     353             :             const SwCntntFrm* pCFrm;
     354           0 :             if( pCNd &&
     355           0 :                 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex() &&
     356           0 :                 0 != ( pCFrm = pCNd->getLayoutFrm( GetLayout() ) ) &&
     357           0 :                 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
     358             :             {
     359           0 :                 pFnd = pCNd;
     360           0 :             }
     361             :         }
     362             :     }
     363             : 
     364           0 :     if( pFnd )
     365             :     {
     366           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     367           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
     368           0 :         pCurCrsr->GetPoint()->nNode = *pFnd;
     369           0 :         pCurCrsr->GetPoint()->nContent.Assign( pFnd, 0 );
     370           0 :         bRet = !pCurCrsr->IsSelOvr();
     371           0 :         if( bRet )
     372           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     373             :     }
     374           0 :     return bRet;
     375             : }
     376             : 
     377             : /// jump to index of TOXMark
     378           0 : sal_Bool SwCrsrShell::GotoTOXMarkBase()
     379             : {
     380           0 :     sal_Bool bRet = sal_False;
     381             : 
     382           0 :     SwTOXMarks aMarks;
     383           0 :     sal_uInt16 nCnt = GetDoc()->GetCurTOXMark( *pCurCrsr->GetPoint(), aMarks );
     384           0 :     if( nCnt )
     385             :     {
     386             :         // Take the 1. and get the index type. Search in its dependency list
     387             :         // for the actual index
     388           0 :         const SwTOXType* pType = aMarks[0]->GetTOXType();
     389           0 :         SwIterator<SwTOXBase,SwTOXType> aIter( *pType );
     390             :         const SwSectionNode* pSectNd;
     391             :         const SwSectionFmt* pSectFmt;
     392             : 
     393           0 :         for( SwTOXBase* pTOX = aIter.First(); pTOX; pTOX = aIter.Next() )
     394             :         {
     395           0 :             if( pTOX->ISA( SwTOXBaseSection ) &&
     396           0 :                 0 != ( pSectFmt = ((SwTOXBaseSection*)pTOX)->GetFmt() ) &&
     397             :                 0 != ( pSectNd = pSectFmt->GetSectionNode() ))
     398             :             {
     399           0 :                 SwNodeIndex aIdx( *pSectNd, 1 );
     400           0 :                 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
     401           0 :                 if( !pCNd )
     402           0 :                     pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
     403             :                 const SwCntntFrm* pCFrm;
     404           0 :                 if( pCNd &&
     405           0 :                     pCNd->EndOfSectionIndex() < pSectNd->EndOfSectionIndex() &&
     406           0 :                     0 != ( pCFrm = pCNd->getLayoutFrm( GetLayout() ) ) &&
     407           0 :                     ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
     408             :                 {
     409           0 :                     SwCallLink aLk( *this ); // watch Crsr-Moves
     410           0 :                     SwCrsrSaveState aSaveState( *pCurCrsr );
     411           0 :                     pCurCrsr->GetPoint()->nNode = *pCNd;
     412           0 :                     pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
     413           0 :                     bRet = !pCurCrsr->IsInProtectTable() &&
     414           0 :                             !pCurCrsr->IsSelOvr();
     415           0 :                     if( bRet )
     416           0 :                         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     417           0 :                     break;
     418           0 :                 }
     419             :             }
     420           0 :     }
     421             :     }
     422           0 :     return bRet;
     423             : }
     424             : 
     425             : /// Jump to next/previous table formula
     426             : /// Optionally it is possible to also jump to broken formulas
     427           0 : sal_Bool SwCrsrShell::GotoNxtPrvTblFormula( sal_Bool bNext, sal_Bool bOnlyErrors )
     428             : {
     429           0 :     if( IsTableMode() )
     430           0 :         return sal_False;
     431             : 
     432           0 :     sal_Bool bFnd = sal_False;
     433           0 :     SwPosition& rPos = *pCurCrsr->GetPoint();
     434             : 
     435           0 :     Point aPt;
     436           0 :     SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
     437           0 :     if( !bNext )
     438           0 :         aFndPos.nNode = 0;
     439           0 :     _SetGetExpFld aFndGEF( aFndPos ), aCurGEF( rPos );
     440             : 
     441             :     {
     442           0 :         const SwNode* pSttNd = rPos.nNode.GetNode().FindTableBoxStartNode();
     443           0 :         if( pSttNd )
     444             :         {
     445           0 :             const SwTableBox* pTBox = pSttNd->FindTableNode()->GetTable().
     446           0 :                                         GetTblBox( pSttNd->GetIndex() );
     447           0 :             if( pTBox )
     448           0 :                 aCurGEF = _SetGetExpFld( *pTBox );
     449             :         }
     450             :     }
     451             : 
     452           0 :     if( rPos.nNode < GetDoc()->GetNodes().GetEndOfExtras() )
     453             :         // also at collection use only the first frame
     454           0 :         aCurGEF.SetBodyPos( *rPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),
     455           0 :                                 &aPt, &rPos, sal_False ) );
     456             :     {
     457             :         const SfxPoolItem* pItem;
     458             :         const SwTableBox* pTBox;
     459           0 :         sal_uInt32 n, nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA );
     460             : 
     461           0 :         for( n = 0; n < nMaxItems; ++n )
     462           0 :             if( 0 != (pItem = GetDoc()->GetAttrPool().GetItem2(
     463           0 :                                         RES_BOXATR_FORMULA, n ) ) &&
     464             :                 0 != (pTBox = ((SwTblBoxFormula*)pItem)->GetTableBox() ) &&
     465           0 :                 pTBox->GetSttNd() &&
     466           0 :                 pTBox->GetSttNd()->GetNodes().IsDocNodes() &&
     467             :                 ( !bOnlyErrors ||
     468           0 :                   !((SwTblBoxFormula*)pItem)->HasValidBoxes() ) )
     469             :             {
     470             :                 const SwCntntFrm* pCFrm;
     471           0 :                 SwNodeIndex aIdx( *pTBox->GetSttNd() );
     472           0 :                 const SwCntntNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
     473           0 :                 if( pCNd && 0 != ( pCFrm = pCNd->getLayoutFrm( GetLayout(), &aPt, 0, sal_False ) ) &&
     474           0 :                     (IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
     475             :                 {
     476           0 :                     _SetGetExpFld aCmp( *pTBox );
     477           0 :                     aCmp.SetBodyPos( *pCFrm );
     478             : 
     479           0 :                     if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
     480           0 :                               : ( aCmp < aCurGEF && aFndGEF < aCmp ))
     481             :                     {
     482           0 :                         aFndGEF = aCmp;
     483           0 :                         bFnd = sal_True;
     484             :                     }
     485           0 :                 }
     486             :             }
     487             :     }
     488             : 
     489           0 :     if( bFnd )
     490             :     {
     491           0 :         SET_CURR_SHELL( this );
     492           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     493           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
     494             : 
     495           0 :         aFndGEF.GetPosOfContent( rPos );
     496           0 :         pCurCrsr->DeleteMark();
     497             : 
     498           0 :         bFnd = !pCurCrsr->IsSelOvr();
     499           0 :         if( bFnd )
     500             :             UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     501           0 :                         SwCrsrShell::READONLY );
     502             :     }
     503           0 :     return bFnd;
     504             : }
     505             : 
     506             : /// jump to next/previous index marker
     507           0 : sal_Bool SwCrsrShell::GotoNxtPrvTOXMark( sal_Bool bNext )
     508             : {
     509           0 :     if( IsTableMode() )
     510           0 :         return sal_False;
     511             : 
     512           0 :     sal_Bool bFnd = sal_False;
     513           0 :     SwPosition& rPos = *pCurCrsr->GetPoint();
     514             : 
     515           0 :     Point aPt;
     516           0 :     SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
     517           0 :     if( !bNext )
     518           0 :         aFndPos.nNode = 0;
     519           0 :     _SetGetExpFld aFndGEF( aFndPos ), aCurGEF( rPos );
     520             : 
     521           0 :     if( rPos.nNode.GetIndex() < GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
     522             :         // also at collection use only the first frame
     523           0 :         aCurGEF.SetBodyPos( *rPos.nNode.GetNode().
     524           0 :                         GetCntntNode()->getLayoutFrm( GetLayout(), &aPt, &rPos, sal_False ) );
     525             :     {
     526             :         const SfxPoolItem* pItem;
     527             :         const SwCntntFrm* pCFrm;
     528             :         const SwTxtNode* pTxtNd;
     529             :         const SwTxtTOXMark* pTxtTOX;
     530           0 :         sal_uInt32 n, nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK );
     531             : 
     532           0 :         for( n = 0; n < nMaxItems; ++n )
     533           0 :             if( 0 != (pItem = GetDoc()->GetAttrPool().GetItem2(
     534           0 :                                         RES_TXTATR_TOXMARK, n ) ) &&
     535             :                 0 != (pTxtTOX = ((SwTOXMark*)pItem)->GetTxtTOXMark() ) &&
     536           0 :                 ( pTxtNd = &pTxtTOX->GetTxtNode())->GetNodes().IsDocNodes() &&
     537           0 :                 0 != ( pCFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt, 0, sal_False )) &&
     538           0 :                 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
     539             :             {
     540           0 :                 SwNodeIndex aNdIndex( *pTxtNd ); // UNIX needs this object
     541           0 :                 _SetGetExpFld aCmp( aNdIndex, *pTxtTOX, 0 );
     542           0 :                 aCmp.SetBodyPos( *pCFrm );
     543             : 
     544           0 :                 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
     545           0 :                           : ( aCmp < aCurGEF && aFndGEF < aCmp ))
     546             :                 {
     547           0 :                     aFndGEF = aCmp;
     548           0 :                     bFnd = sal_True;
     549           0 :                 }
     550             :             }
     551             :     }
     552             : 
     553           0 :     if( bFnd )
     554             :     {
     555           0 :         SET_CURR_SHELL( this );
     556           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     557           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
     558             : 
     559           0 :         aFndGEF.GetPosOfContent( rPos );
     560             : 
     561           0 :         bFnd = !pCurCrsr->IsSelOvr();
     562           0 :         if( bFnd )
     563             :             UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     564           0 :                         SwCrsrShell::READONLY );
     565             :     }
     566           0 :     return bFnd;
     567             : }
     568             : 
     569             : /// traveling between marks
     570           0 : const SwTOXMark& SwCrsrShell::GotoTOXMark( const SwTOXMark& rStart,
     571             :                                             SwTOXSearch eDir )
     572             : {
     573           0 :     SET_CURR_SHELL( this );
     574           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     575           0 :     SwCrsrSaveState aSaveState( *pCurCrsr );
     576             : 
     577             :     const SwTOXMark& rNewMark = GetDoc()->GotoTOXMark( rStart, eDir,
     578           0 :                                                     IsReadOnlyAvailable() );
     579             :     // set position
     580           0 :     SwPosition& rPos = *GetCrsr()->GetPoint();
     581           0 :     rPos.nNode = rNewMark.GetTxtTOXMark()->GetTxtNode();
     582           0 :     rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
     583           0 :                          *rNewMark.GetTxtTOXMark()->GetStart() );
     584             : 
     585           0 :     if( !pCurCrsr->IsSelOvr() )
     586             :         UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
     587           0 :                     SwCrsrShell::READONLY );
     588             : 
     589           0 :     return rNewMark;
     590             : }
     591             : 
     592             : /// jump to next/previous field type
     593           0 : static void lcl_MakeFldLst( _SetGetExpFlds& rLst, const SwFieldType& rFldType,
     594             :                         sal_uInt16 nSubType, sal_Bool bInReadOnly,
     595             :                         sal_Bool bChkInpFlag = sal_False )
     596             : {
     597             :     // always search the 1. frame
     598           0 :     Point aPt;
     599             :     SwTxtFld* pTxtFld;
     600           0 :     SwIterator<SwFmtFld,SwFieldType> aIter(rFldType);
     601           0 :     bool bSubType = nSubType != USHRT_MAX;
     602           0 :     for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
     603           0 :         if( 0 != ( pTxtFld = pFmtFld->GetTxtFld() ) &&
     604           0 :             ( !bChkInpFlag || ((SwSetExpField*)pTxtFld->GetFld().GetFld())
     605           0 :                                 ->GetInputFlag() ) &&
     606           0 :             (!bSubType || (pFmtFld->GetFld()->GetSubType()
     607             :                                 & 0xff ) == nSubType ))
     608             :         {
     609             :             SwCntntFrm* pCFrm;
     610           0 :             const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
     611           0 :             if( 0 != ( pCFrm = rTxtNode.getLayoutFrm( rTxtNode.GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False )) &&
     612           0 :                 ( bInReadOnly || !pCFrm->IsProtected() ))
     613             :             {
     614             :                 _SetGetExpFld* pNew = new _SetGetExpFld(
     615           0 :                                 SwNodeIndex( rTxtNode ), pTxtFld );
     616           0 :                 pNew->SetBodyPos( *pCFrm );
     617           0 :                 rLst.insert( pNew );
     618             :             }
     619           0 :         }
     620           0 : }
     621             : 
     622             : 
     623           0 : sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext,
     624             :                                             sal_uInt16 nSubType, sal_uInt16 nResType )
     625             : {
     626             :     // sorted list of all fields
     627           0 :     _SetGetExpFlds aSrtLst;
     628             : 
     629           0 :     if (pFldType)
     630             :     {
     631           0 :         if( RES_INPUTFLD != pFldType->Which() && !pFldType->GetDepends() )
     632           0 :             return sal_False;
     633             : 
     634             :         // found Modify object, add all fields to array
     635           0 :         ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType, IsReadOnlyAvailable() );
     636             : 
     637           0 :         if( RES_INPUTFLD == pFldType->Which() )
     638             :         {
     639             :             // there are hidden input fields in the set exp. fields
     640           0 :             const SwFldTypes& rFldTypes = *pDoc->GetFldTypes();
     641           0 :             const sal_uInt16 nSize = rFldTypes.size();
     642             : 
     643             :             // iterate over all types
     644           0 :             for( sal_uInt16 i=0; i < nSize; ++i )
     645           0 :                 if( RES_SETEXPFLD == ( pFldType = rFldTypes[ i ] )->Which() )
     646             :                     ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType,
     647           0 :                                 IsReadOnlyAvailable(), sal_True );
     648             :         }
     649             :     }
     650             :     else
     651             :     {
     652           0 :         const SwFldTypes& rFldTypes = *pDoc->GetFldTypes();
     653           0 :         const sal_uInt16 nSize = rFldTypes.size();
     654             : 
     655             :         // iterate over all types
     656           0 :         for( sal_uInt16 i=0; i < nSize; ++i )
     657           0 :             if( nResType == ( pFldType = rFldTypes[ i ] )->Which() )
     658             :                 ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType,
     659           0 :                                 IsReadOnlyAvailable() );
     660             :     }
     661             : 
     662             :     // found no fields?
     663           0 :     if( aSrtLst.empty() )
     664           0 :         return sal_False;
     665             : 
     666           0 :     _SetGetExpFlds::const_iterator it;
     667           0 :     SwCursor* pCrsr = getShellCrsr( true );
     668             :     {
     669             :         // (1998): Always use field for search so that the right one is found as
     670             :         // well some are in frames that are anchored to a paragraph that has a
     671             :         // field
     672           0 :         const SwPosition& rPos = *pCrsr->GetPoint();
     673             : 
     674           0 :         SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
     675             :         OSL_ENSURE( pTNd, "No CntntNode" );
     676             : 
     677             :         SwTxtFld * pTxtFld = static_cast<SwTxtFld *>(
     678           0 :             pTNd->GetTxtAttrForCharAt(rPos.nContent.GetIndex(),
     679           0 :                 RES_TXTATR_FIELD));
     680           0 :         bool bDelFld = 0 == pTxtFld;
     681           0 :         if( bDelFld )
     682             :         {
     683             :             SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField(
     684           0 :                 (SwDateTimeFieldType*)pDoc->GetSysFldType( RES_DATETIMEFLD ) ) );
     685             : 
     686           0 :             pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex(),
     687           0 :                         pDoc->IsClipBoard() );
     688           0 :             pTxtFld->ChgTxtNode( pTNd );
     689             :         }
     690             : 
     691           0 :         _SetGetExpFld aSrch( rPos.nNode, pTxtFld, &rPos.nContent );
     692           0 :         if( rPos.nNode.GetIndex() < pDoc->GetNodes().GetEndOfExtras().GetIndex() )
     693             :         {
     694             :             // also at collection use only the first frame
     695           0 :             Point aPt;
     696           0 :             aSrch.SetBodyPos( *pTNd->getLayoutFrm( GetLayout(), &aPt, &rPos, sal_False ) );
     697             :         }
     698             : 
     699           0 :         it = aSrtLst.lower_bound( &aSrch );
     700           0 :         if( bDelFld )
     701             :         {
     702           0 :             delete (SwFmtFld*)&pTxtFld->GetAttr();
     703           0 :             delete pTxtFld;
     704             :         }
     705             : 
     706           0 :         if( it != aSrtLst.end() && **it == aSrch ) // found
     707             :         {
     708           0 :             if( bNext )
     709             :             {
     710           0 :                 if( ++it == aSrtLst.end() )
     711           0 :                     return sal_False; // already at the end
     712             :             }
     713             :             else
     714             :             {
     715           0 :                 if( it == aSrtLst.begin() )
     716           0 :                     return sal_False; // no more steps backward possible
     717           0 :                 --it;
     718             :             }
     719             :         }
     720             :         else // not found
     721             :         {
     722           0 :             if( bNext )
     723             :             {
     724           0 :                 if( it == aSrtLst.end() )
     725           0 :                     return sal_False;
     726             :             }
     727             :             else
     728             :             {
     729           0 :                 if( it == aSrtLst.begin() )
     730           0 :                     return sal_False; // no more steps backward possible
     731           0 :                 --it;
     732             :             }
     733             :         }
     734             :     }
     735           0 :     const _SetGetExpFld& rFnd = **it;
     736             : 
     737             : 
     738           0 :     SET_CURR_SHELL( this );
     739           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     740           0 :     SwCrsrSaveState aSaveState( *pCrsr );
     741             : 
     742           0 :     rFnd.GetPosOfContent( *pCrsr->GetPoint() );
     743             :     sal_Bool bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
     744           0 :                                      nsSwCursorSelOverFlags::SELOVER_TOGGLE );
     745           0 :     if( bRet )
     746           0 :         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     747           0 :     return bRet;
     748             : }
     749             : 
     750             : 
     751           0 : sal_Bool SwCrsrShell::GotoFld( const SwFmtFld& rFld )
     752             : {
     753           0 :     sal_Bool bRet = sal_False;
     754           0 :     if( rFld.GetTxtFld() )
     755             :     {
     756           0 :         SET_CURR_SHELL( this );
     757           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     758             : 
     759           0 :         SwCursor* pCrsr = getShellCrsr( true );
     760           0 :         SwCrsrSaveState aSaveState( *pCrsr );
     761             : 
     762           0 :         SwTxtNode* pTNd = (SwTxtNode*)rFld.GetTxtFld()->GetpTxtNode();
     763           0 :         pCrsr->GetPoint()->nNode = *pTNd;
     764           0 :         pCrsr->GetPoint()->nContent.Assign( pTNd, *rFld.GetTxtFld()->GetStart() );
     765             : 
     766           0 :         bRet = !pCrsr->IsSelOvr();
     767           0 :         if( bRet )
     768           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     769             :     }
     770           0 :     return bRet;
     771             : }
     772             : 
     773             : 
     774           0 : void SwCrsrShell::GotoOutline( sal_uInt16 nIdx )
     775             : {
     776           0 :     SwCursor* pCrsr = getShellCrsr( true );
     777             : 
     778           0 :     SET_CURR_SHELL( this );
     779           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     780           0 :     SwCrsrSaveState aSaveState( *pCrsr );
     781             : 
     782           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     783           0 :     SwTxtNode* pTxtNd = (SwTxtNode*)rNds.GetOutLineNds()[ nIdx ]->GetTxtNode();
     784           0 :     pCrsr->GetPoint()->nNode = *pTxtNd;
     785           0 :     pCrsr->GetPoint()->nContent.Assign( pTxtNd, 0 );
     786             : 
     787           0 :     if( !pCrsr->IsSelOvr() )
     788           0 :         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     789           0 : }
     790             : 
     791             : 
     792           0 : bool SwCrsrShell::GotoOutline( const String& rName )
     793             : {
     794           0 :     SwCursor* pCrsr = getShellCrsr( true );
     795             : 
     796           0 :     SET_CURR_SHELL( this );
     797           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     798           0 :     SwCrsrSaveState aSaveState( *pCrsr );
     799             : 
     800           0 :     bool bRet = false;
     801           0 :     if( pDoc->GotoOutline( *pCrsr->GetPoint(), rName ) && !pCrsr->IsSelOvr() )
     802             :     {
     803           0 :         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     804           0 :         bRet = true;
     805             :     }
     806           0 :     return bRet;
     807             : }
     808             : 
     809             : /// jump to next node with outline num.
     810           0 : sal_Bool SwCrsrShell::GotoNextOutline()
     811             : {
     812           0 :     SwCursor* pCrsr = getShellCrsr( true );
     813           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     814             : 
     815           0 :     SwNode* pNd = pCrsr->GetNode();
     816             :     sal_uInt16 nPos;
     817           0 :     if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
     818           0 :         ++nPos;
     819             : 
     820           0 :     if( nPos == rNds.GetOutLineNds().size() )
     821           0 :         return sal_False;
     822             : 
     823           0 :     pNd = rNds.GetOutLineNds()[ nPos ];
     824             : 
     825           0 :     SET_CURR_SHELL( this );
     826           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     827           0 :     SwCrsrSaveState aSaveState( *pCrsr );
     828           0 :     pCrsr->GetPoint()->nNode = *pNd;
     829           0 :     pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)pNd, 0 );
     830             : 
     831           0 :     sal_Bool bRet = !pCrsr->IsSelOvr();
     832           0 :     if( bRet )
     833           0 :         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     834           0 :     return bRet;
     835             : }
     836             : 
     837             : /// jump to previous node with outline num.
     838           0 : sal_Bool SwCrsrShell::GotoPrevOutline()
     839             : {
     840           0 :     SwCursor* pCrsr = getShellCrsr( true );
     841           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     842             : 
     843           0 :     SwNode* pNd = pCrsr->GetNode();
     844             :     sal_uInt16 nPos;
     845           0 :     rNds.GetOutLineNds().Seek_Entry( pNd, &nPos );
     846             : 
     847           0 :     sal_Bool bRet = sal_False;
     848           0 :     if( nPos )
     849             :     {
     850           0 :         --nPos; // before
     851             : 
     852           0 :         pNd = rNds.GetOutLineNds()[ nPos ];
     853           0 :         if( pNd->GetIndex() > pCrsr->GetPoint()->nNode.GetIndex() )
     854           0 :             return sal_False;
     855             : 
     856           0 :         SET_CURR_SHELL( this );
     857           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
     858           0 :         SwCrsrSaveState aSaveState( *pCrsr );
     859           0 :         pCrsr->GetPoint()->nNode = *pNd;
     860           0 :         pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)pNd, 0 );
     861             : 
     862           0 :         bRet = !pCrsr->IsSelOvr();
     863           0 :         if( bRet )
     864           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     865             :     }
     866           0 :     return bRet;
     867             : }
     868             : 
     869             : /// search "outline position" before previous outline node at given level
     870           0 : sal_uInt16 SwCrsrShell::GetOutlinePos( sal_uInt8 nLevel )
     871             : {
     872           0 :     SwPaM* pCrsr = getShellCrsr( true );
     873           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     874             : 
     875           0 :     SwNode* pNd = pCrsr->GetNode();
     876             :     sal_uInt16 nPos;
     877           0 :     if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
     878           0 :         nPos++; // is at correct position; take next for while
     879             : 
     880           0 :     while( nPos-- ) // check the one in front of the current
     881             :     {
     882           0 :         pNd = rNds.GetOutLineNds()[ nPos ];
     883             : 
     884           0 :         if( ((SwTxtNode*)pNd)->GetAttrOutlineLevel()-1 <= nLevel )
     885           0 :             return nPos;
     886             : 
     887             :     }
     888           0 :     return USHRT_MAX; // no more left
     889             : }
     890             : 
     891             : 
     892           0 : sal_Bool SwCrsrShell::MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos,
     893             :                                     sal_Bool bWithChildren )
     894             : {
     895           0 :     const SwNodes& rNds = GetDoc()->GetNodes();
     896           0 :     const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
     897           0 :     if( rOutlNds.empty() )
     898           0 :         return sal_False;
     899             : 
     900           0 :     SET_CURR_SHELL( this );
     901           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     902             : 
     903           0 :     if( nSttPos > nEndPos ) // parameters switched?
     904             :     {
     905             :         OSL_ENSURE( !this, "Start > End for array access" );
     906           0 :         sal_uInt16 nTmp = nSttPos;
     907           0 :         nSttPos = nEndPos;
     908           0 :         nEndPos = nTmp;
     909             :     }
     910             : 
     911           0 :     SwNode* pSttNd = rOutlNds[ nSttPos ];
     912           0 :     SwNode* pEndNd = rOutlNds[ nEndPos ];
     913             : 
     914           0 :     if( bWithChildren )
     915             :     {
     916           0 :         const int nLevel = pEndNd->GetTxtNode()->GetAttrOutlineLevel()-1;
     917           0 :         for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos )
     918             :         {
     919           0 :             pEndNd = rOutlNds[ nEndPos ];
     920           0 :             const int nNxtLevel = pEndNd->GetTxtNode()->GetAttrOutlineLevel()-1;
     921           0 :             if( nNxtLevel <= nLevel )
     922           0 :                 break; // EndPos is now on the next one
     923             :         }
     924             :     }
     925             :     // if without children then set onto next one
     926           0 :     else if( ++nEndPos < rOutlNds.size() )
     927           0 :         pEndNd = rOutlNds[ nEndPos ];
     928             : 
     929           0 :     if( nEndPos == rOutlNds.size() ) // no end found
     930           0 :         pEndNd = &rNds.GetEndOfContent();
     931             : 
     932           0 :     KillPams();
     933             : 
     934           0 :     SwCrsrSaveState aSaveState( *pCurCrsr );
     935             : 
     936             :     // set end to the end of the previous content node
     937           0 :     pCurCrsr->GetPoint()->nNode = *pSttNd;
     938           0 :     pCurCrsr->GetPoint()->nContent.Assign( pSttNd->GetCntntNode(), 0 );
     939           0 :     pCurCrsr->SetMark();
     940           0 :     pCurCrsr->GetPoint()->nNode = *pEndNd;
     941           0 :     pCurCrsr->Move( fnMoveBackward, fnGoNode ); // end of predecessor
     942             : 
     943             :     // and everything is already selected
     944           0 :     sal_Bool bRet = !pCurCrsr->IsSelOvr();
     945           0 :     if( bRet )
     946           0 :         UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     947           0 :     return bRet;
     948             : }
     949             : 
     950             : 
     951             : /// jump to reference marker
     952           0 : sal_Bool SwCrsrShell::GotoRefMark( const String& rRefMark, sal_uInt16 nSubType,
     953             :                                     sal_uInt16 nSeqNo )
     954             : {
     955           0 :     SET_CURR_SHELL( this );
     956           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
     957           0 :     SwCrsrSaveState aSaveState( *pCurCrsr );
     958             : 
     959             :     sal_uInt16 nPos;
     960             :     SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark,
     961           0 :                                                     nSubType, nSeqNo, &nPos );
     962           0 :     if( pTxtNd && pTxtNd->GetNodes().IsDocNodes() )
     963             :     {
     964           0 :         pCurCrsr->GetPoint()->nNode = *pTxtNd;
     965           0 :         pCurCrsr->GetPoint()->nContent.Assign( pTxtNd, nPos );
     966             : 
     967           0 :         if( !pCurCrsr->IsSelOvr() )
     968             :         {
     969           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
     970           0 :             return sal_True;
     971             :         }
     972             :     }
     973           0 :     return sal_False;
     974             : }
     975             : 
     976         144 : sal_Bool SwCrsrShell::IsPageAtPos( const Point &rPt ) const
     977             : {
     978         144 :     if( GetLayout() )
     979         144 :         return 0 != GetLayout()->GetPageAtPos( rPt );
     980           0 :     return sal_False;
     981             : }
     982             : 
     983           0 : sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt,
     984             :                                    SwContentAtPos& rCntntAtPos,
     985             :                                    sal_Bool bSetCrsr,
     986             :                                    SwRect* pFldRect )
     987             : {
     988           0 :     SET_CURR_SHELL( this );
     989           0 :     sal_Bool bRet = sal_False;
     990             : 
     991           0 :     if( !IsTableMode() )
     992             :     {
     993           0 :         Point aPt( rPt );
     994           0 :         SwPosition aPos( *pCurCrsr->GetPoint() );
     995             : 
     996             :         SwTxtNode* pTxtNd;
     997           0 :         SwCntntFrm *pFrm(0);
     998             :         SwTxtAttr* pTxtAttr;
     999           0 :         SwCrsrMoveState aTmpState;
    1000           0 :         aTmpState.bFieldInfo = sal_True;
    1001           0 :         aTmpState.bExactOnly = !( SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos );
    1002           0 :         aTmpState.bCntntCheck = (SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos) ?  sal_True : sal_False;
    1003           0 :         aTmpState.bSetInReadOnly = IsReadOnlyAvailable();
    1004             : 
    1005           0 :         SwSpecialPos aSpecialPos;
    1006             :         aTmpState.pSpecialPos = ( SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos ) ?
    1007           0 :                                 &aSpecialPos : 0;
    1008             : 
    1009           0 :         const sal_Bool bCrsrFoundExact = GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState );
    1010           0 :         pTxtNd = aPos.nNode.GetNode().GetTxtNode();
    1011             : 
    1012           0 :         const SwNodes& rNds = GetDoc()->GetNodes();
    1013           0 :         if( pTxtNd && SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos
    1014           0 :             && !rNds.GetOutLineNds().empty() )
    1015             :         {
    1016           0 :             const SwTxtNode* pONd = pTxtNd->FindOutlineNodeOfLevel( MAXLEVEL-1);
    1017           0 :             if( pONd )
    1018             :             {
    1019           0 :                 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_OUTLINE;
    1020           0 :                 rCntntAtPos.sStr = pONd->GetExpandTxt( 0, STRING_LEN, true, true );
    1021           0 :                 bRet = sal_True;
    1022             :             }
    1023             :         }
    1024             :         // #i43742# New function
    1025           0 :         else if ( SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos &&
    1026             :                   bCrsrFoundExact )
    1027             :         {
    1028           0 :             bRet = sal_True;
    1029             :         }
    1030             :         // #i23726#
    1031           0 :         else if( pTxtNd &&
    1032             :                  SwContentAtPos::SW_NUMLABEL & rCntntAtPos.eCntntAtPos)
    1033             :         {
    1034           0 :             bRet = aTmpState.bInNumPortion;
    1035           0 :             rCntntAtPos.aFnd.pNode = pTxtNd;
    1036             : 
    1037           0 :             Size aSizeLogic(aTmpState.nInNumPostionOffset, 0);
    1038           0 :             Size aSizePixel = GetWin()->LogicToPixel(aSizeLogic);
    1039           0 :             rCntntAtPos.nDist = aSizePixel.Width();
    1040             :         }
    1041           0 :         else if( bCrsrFoundExact && pTxtNd )
    1042             :         {
    1043           0 :             if( !aTmpState.bPosCorr )
    1044             :             {
    1045           0 :                 if( !bRet && SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos
    1046           0 :                     && !aTmpState.bFtnNoInfo )
    1047             :                 {
    1048           0 :                     const SwWrongList* pSmartTagList = pTxtNd->GetSmartTags();
    1049           0 :                     xub_StrLen nCurrent = aPos.nContent.GetIndex();
    1050           0 :                     xub_StrLen nBegin = nCurrent;
    1051           0 :                     xub_StrLen nLen = 1;
    1052             : 
    1053           0 :                     if ( pSmartTagList && pSmartTagList->InWrongWord( nCurrent, nLen ) && !pTxtNd->IsSymbol(nBegin) )
    1054             :                     {
    1055           0 :                         const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
    1056           0 :                         const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
    1057           0 :                         if ( pSubList )
    1058             :                         {
    1059           0 :                             nCurrent = aTmpState.pSpecialPos->nCharOfst;
    1060             : 
    1061           0 :                             if ( pSubList->InWrongWord( nCurrent, nLen ) )
    1062           0 :                                 bRet = sal_True;
    1063             :                         }
    1064             :                         else
    1065           0 :                             bRet = sal_True;
    1066             : 
    1067           0 :                         if( bRet && bSetCrsr )
    1068             :                         {
    1069           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1070           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1071           0 :                             pCurCrsr->DeleteMark();
    1072           0 :                             *pCurCrsr->GetPoint() = aPos;
    1073           0 :                             if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
    1074           0 :                                                     nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
    1075           0 :                                 bRet = sal_False;
    1076             :                             else
    1077           0 :                                 UpdateCrsr();
    1078             :                         }
    1079           0 :                         if( bRet )
    1080             :                         {
    1081           0 :                             rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_SMARTTAG;
    1082             : 
    1083           0 :                             if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1084           0 :                                 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1085             :                         }
    1086             :                     }
    1087             :                 }
    1088             : 
    1089           0 :                 if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD )
    1090           0 :                     & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo )
    1091             :                 {
    1092             :                     pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
    1093           0 :                             aPos.nContent.GetIndex(), RES_TXTATR_FIELD );
    1094             :                     const SwField* pFld = pTxtAttr
    1095           0 :                                             ? pTxtAttr->GetFld().GetFld()
    1096           0 :                                             : 0;
    1097           0 :                     if( SwContentAtPos::SW_CLICKFIELD & rCntntAtPos.eCntntAtPos &&
    1098           0 :                         pFld && !pFld->HasClickHdl() )
    1099           0 :                         pFld = 0;
    1100             : 
    1101           0 :                     if( pFld )
    1102             :                     {
    1103           0 :                         if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1104           0 :                             pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1105             : 
    1106           0 :                         if( bSetCrsr )
    1107             :                         {
    1108           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1109           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1110           0 :                             pCurCrsr->DeleteMark();
    1111           0 :                             *pCurCrsr->GetPoint() = aPos;
    1112           0 :                             if( pCurCrsr->IsSelOvr() )
    1113             :                             {
    1114             :                                 // allow click fields in protected sections
    1115             :                                 // only placeholder is not possible
    1116           0 :                                 if( SwContentAtPos::SW_FIELD & rCntntAtPos.eCntntAtPos
    1117           0 :                                      || RES_JUMPEDITFLD == pFld->Which() )
    1118           0 :                                     pFld = 0;
    1119             :                             }
    1120             :                             else
    1121           0 :                                 UpdateCrsr();
    1122             :                         }
    1123           0 :                         else if( RES_TABLEFLD == pFld->Which() &&
    1124           0 :                                 ((SwTblField*)pFld)->IsIntrnlName() )
    1125             :                         {
    1126             :                             // create from internal (for CORE) the external
    1127             :                             // (for UI) formula
    1128           0 :                             const SwTableNode* pTblNd = pTxtNd->FindTableNode();
    1129           0 :                             if( pTblNd )        // steht in einer Tabelle
    1130           0 :                                 ((SwTblField*)pFld)->PtrToBoxNm( &pTblNd->GetTable() );
    1131             :                         }
    1132             :                     }
    1133             : 
    1134           0 :                     if( pFld )
    1135             :                     {
    1136           0 :                         rCntntAtPos.aFnd.pFld = pFld;
    1137           0 :                         rCntntAtPos.pFndTxtAttr = pTxtAttr;
    1138           0 :                         rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FIELD;
    1139           0 :                         bRet = sal_True;
    1140             :                     }
    1141             :                 }
    1142             : 
    1143           0 :         if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos )
    1144             :         {
    1145           0 :             IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
    1146           0 :             sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos );
    1147           0 :             if( bCrsrFoundExact && pTxtNd && pFldBookmark) {
    1148           0 :                 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL;
    1149           0 :                 rCntntAtPos.aFnd.pFldmark = pFldBookmark;
    1150           0 :                 bRet=sal_True;
    1151             :             }
    1152             :         }
    1153             : 
    1154           0 :                 if( !bRet && SwContentAtPos::SW_FTN & rCntntAtPos.eCntntAtPos )
    1155             :                 {
    1156           0 :                     if( aTmpState.bFtnNoInfo )
    1157             :                     {
    1158             :                         // over the footnote's char
    1159           0 :                         bRet = sal_True;
    1160           0 :                         if( bSetCrsr )
    1161             :                         {
    1162           0 :                             *pCurCrsr->GetPoint() = aPos;
    1163           0 :                             if( !GotoFtnAnchor() )
    1164           0 :                                 bRet = sal_False;
    1165             :                         }
    1166           0 :                         if( bRet )
    1167           0 :                             rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN;
    1168             :                     }
    1169           0 :                     else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
    1170           0 :                                 aPos.nContent.GetIndex(), RES_TXTATR_FTN )) )
    1171             :                     {
    1172           0 :                         bRet = sal_True;
    1173           0 :                         if( bSetCrsr )
    1174             :                         {
    1175           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1176           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1177           0 :                             pCurCrsr->GetPoint()->nNode = *((SwTxtFtn*)pTxtAttr)->GetStartNode();
    1178           0 :                             SwCntntNode* pCNd = GetDoc()->GetNodes().GoNextSection(
    1179           0 :                                             &pCurCrsr->GetPoint()->nNode,
    1180           0 :                                             sal_True, !IsReadOnlyAvailable() );
    1181             : 
    1182           0 :                             if( pCNd )
    1183             :                             {
    1184           0 :                                 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
    1185           0 :                                 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
    1186           0 :                                                         nsSwCursorSelOverFlags::SELOVER_TOGGLE ))
    1187           0 :                                     bRet = sal_False;
    1188             :                                 else
    1189           0 :                                     UpdateCrsr();
    1190             :                             }
    1191             :                             else
    1192           0 :                                 bRet = sal_False;
    1193             :                         }
    1194             : 
    1195           0 :                         if( bRet )
    1196             :                         {
    1197           0 :                             rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN;
    1198           0 :                             rCntntAtPos.pFndTxtAttr = pTxtAttr;
    1199           0 :                             rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
    1200             : 
    1201           0 :                             if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1202           0 :                                 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1203             :                         }
    1204             :                     }
    1205             :                 }
    1206             : 
    1207           0 :                 if( !bRet && ( SwContentAtPos::SW_TOXMARK |
    1208             :                                SwContentAtPos::SW_REFMARK ) &
    1209           0 :                         rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo )
    1210             :                 {
    1211           0 :                     pTxtAttr = 0;
    1212           0 :                     if( SwContentAtPos::SW_TOXMARK & rCntntAtPos.eCntntAtPos )
    1213             :                     {
    1214             :                         ::std::vector<SwTxtAttr *> const marks(
    1215             :                             pTxtNd->GetTxtAttrsAt(
    1216           0 :                                aPos.nContent.GetIndex(), RES_TXTATR_TOXMARK));
    1217           0 :                         if (marks.size())
    1218             :                         {   // hmm... can only return 1 here
    1219           0 :                             pTxtAttr = *marks.begin();
    1220           0 :                         }
    1221             :                     }
    1222             : 
    1223           0 :                     if( !pTxtAttr &&
    1224             :                         SwContentAtPos::SW_REFMARK & rCntntAtPos.eCntntAtPos )
    1225             :                     {
    1226             :                         ::std::vector<SwTxtAttr *> const marks(
    1227             :                             pTxtNd->GetTxtAttrsAt(
    1228           0 :                                aPos.nContent.GetIndex(), RES_TXTATR_REFMARK));
    1229           0 :                         if (marks.size())
    1230             :                         {   // hmm... can only return 1 here
    1231           0 :                             pTxtAttr = *marks.begin();
    1232           0 :                         }
    1233             :                     }
    1234             : 
    1235           0 :                     if( pTxtAttr )
    1236             :                     {
    1237           0 :                         bRet = sal_True;
    1238           0 :                         if( bSetCrsr )
    1239             :                         {
    1240           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1241           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1242           0 :                             pCurCrsr->DeleteMark();
    1243           0 :                             *pCurCrsr->GetPoint() = aPos;
    1244           0 :                             if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
    1245           0 :                                                     nsSwCursorSelOverFlags::SELOVER_TOGGLE ) )
    1246           0 :                                 bRet = sal_False;
    1247             :                             else
    1248           0 :                                 UpdateCrsr();
    1249             :                         }
    1250             : 
    1251           0 :                         if( bRet )
    1252             :                         {
    1253           0 :                             const xub_StrLen* pEnd = pTxtAttr->GetEnd();
    1254           0 :                             if( pEnd )
    1255             :                                 rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
    1256           0 :                                             *pTxtAttr->GetStart(),
    1257           0 :                                             *pEnd - *pTxtAttr->GetStart() );
    1258           0 :                             else if( RES_TXTATR_TOXMARK == pTxtAttr->Which())
    1259           0 :                                 rCntntAtPos.sStr = pTxtAttr->GetTOXMark().
    1260           0 :                                                     GetAlternativeText();
    1261             : 
    1262             :                             rCntntAtPos.eCntntAtPos =
    1263           0 :                                 RES_TXTATR_TOXMARK == pTxtAttr->Which()
    1264             :                                             ? SwContentAtPos::SW_TOXMARK
    1265           0 :                                             : SwContentAtPos::SW_REFMARK;
    1266           0 :                             rCntntAtPos.pFndTxtAttr = pTxtAttr;
    1267           0 :                             rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
    1268             : 
    1269           0 :                             if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1270           0 :                                 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1271             :                         }
    1272             :                     }
    1273             :                 }
    1274             : 
    1275           0 :                 if( !bRet && SwContentAtPos::SW_INETATTR & rCntntAtPos.eCntntAtPos
    1276           0 :                     && !aTmpState.bFtnNoInfo )
    1277             :                 {
    1278             :                     pTxtAttr = pTxtNd->GetTxtAttrAt(
    1279           0 :                             aPos.nContent.GetIndex(), RES_TXTATR_INETFMT);
    1280             :                     // "detect" only INetAttrs with URLs
    1281           0 :                     if( pTxtAttr && pTxtAttr->GetINetFmt().GetValue().Len() )
    1282             :                     {
    1283           0 :                         bRet = sal_True;
    1284           0 :                         if( bSetCrsr )
    1285             :                         {
    1286           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1287           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1288           0 :                             pCurCrsr->DeleteMark();
    1289           0 :                             *pCurCrsr->GetPoint() = aPos;
    1290           0 :                             if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
    1291           0 :                                                     nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
    1292           0 :                                 bRet = sal_False;
    1293             :                             else
    1294           0 :                                 UpdateCrsr();
    1295             :                         }
    1296           0 :                         if( bRet )
    1297             :                         {
    1298             :                             rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
    1299           0 :                                         *pTxtAttr->GetStart(),
    1300           0 :                                         *pTxtAttr->GetEnd() - *pTxtAttr->GetStart() );
    1301             : 
    1302           0 :                             rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
    1303           0 :                             rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_INETATTR;
    1304           0 :                             rCntntAtPos.pFndTxtAttr = pTxtAttr;
    1305             : 
    1306           0 :                             if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1307           0 :                                 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1308             :                         }
    1309             :                     }
    1310             :                 }
    1311             : 
    1312           0 :                 if( !bRet && SwContentAtPos::SW_REDLINE & rCntntAtPos.eCntntAtPos )
    1313             :                 {
    1314           0 :                     const SwRedline* pRedl = GetDoc()->GetRedline(aPos, NULL);
    1315           0 :                     if( pRedl )
    1316             :                     {
    1317           0 :                         rCntntAtPos.aFnd.pRedl = pRedl;
    1318           0 :                         rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_REDLINE;
    1319           0 :                         rCntntAtPos.pFndTxtAttr = 0;
    1320           0 :                         bRet = sal_True;
    1321             : 
    1322           0 :                         if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) )
    1323           0 :                             pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
    1324             :                     }
    1325             :                 }
    1326             :             }
    1327             : 
    1328           0 :             if( !bRet && (
    1329             :                 SwContentAtPos::SW_TABLEBOXFML & rCntntAtPos.eCntntAtPos
    1330             : #ifdef DBG_UTIL
    1331             :                 || SwContentAtPos::SW_TABLEBOXVALUE & rCntntAtPos.eCntntAtPos
    1332             : #endif
    1333             :                 ))
    1334             :             {
    1335             :                 const SwTableNode* pTblNd;
    1336             :                 const SwTableBox* pBox;
    1337           0 :                 const SwStartNode* pSttNd = pTxtNd->FindTableBoxStartNode();
    1338             :                 const SfxPoolItem* pItem;
    1339           0 :                 if( pSttNd && 0 != ( pTblNd = pTxtNd->FindTableNode()) &&
    1340           0 :                     0 != ( pBox = pTblNd->GetTable().GetTblBox(
    1341           0 :                                     pSttNd->GetIndex() )) &&
    1342             : #ifdef DBG_UTIL
    1343             :                     ( SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
    1344             :                         RES_BOXATR_FORMULA, sal_False, &pItem ) ||
    1345             :                       SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
    1346             :                         RES_BOXATR_VALUE, sal_False, &pItem ))
    1347             : #else
    1348           0 :                     SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
    1349           0 :                         RES_BOXATR_FORMULA, sal_False, &pItem )
    1350             : #endif
    1351             :                     )
    1352             :                 {
    1353           0 :                     SwFrm* pF = pTxtNd->getLayoutFrm( GetLayout(), &aPt );
    1354           0 :                     if( pF )
    1355             :                     {
    1356             :                         // then the CellFrame
    1357           0 :                         pFrm = (SwCntntFrm*)pF;
    1358           0 :                         while( pF && !pF->IsCellFrm() )
    1359           0 :                             pF = pF->GetUpper();
    1360             :                     }
    1361             : 
    1362           0 :                     if( aTmpState.bPosCorr )
    1363             :                     {
    1364           0 :                         if( pF && !pF->Frm().IsInside( aPt ))
    1365           0 :                             pF = 0;
    1366             :                     }
    1367           0 :                     else if( !pF )
    1368           0 :                         pF = pFrm;
    1369             : 
    1370           0 :                     if( pF ) // only then it is valid
    1371             :                     {
    1372             :                         // create from internal (for CORE) the external
    1373             :                         // (for UI) formula
    1374           0 :                         rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_TABLEBOXFML;
    1375             : #ifdef DBG_UTIL
    1376             :                         if( RES_BOXATR_VALUE == pItem->Which() )
    1377             :                             rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_TABLEBOXVALUE;
    1378             :                         else
    1379             : #endif
    1380           0 :                         ((SwTblBoxFormula*)pItem)->PtrToBoxNm( &pTblNd->GetTable() );
    1381             : 
    1382           0 :                         bRet = sal_True;
    1383           0 :                         if( bSetCrsr )
    1384             :                         {
    1385           0 :                             SwCallLink aLk( *this ); // watch Crsr-Moves
    1386           0 :                             SwCrsrSaveState aSaveState( *pCurCrsr );
    1387           0 :                             *pCurCrsr->GetPoint() = aPos;
    1388           0 :                             if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
    1389           0 :                                                     nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
    1390           0 :                                 bRet = sal_False;
    1391             :                             else
    1392           0 :                                 UpdateCrsr();
    1393             :                         }
    1394             : 
    1395           0 :                         if( bRet )
    1396             :                         {
    1397           0 :                             if( pFldRect )
    1398             :                             {
    1399           0 :                                 *pFldRect = pF->Prt();
    1400           0 :                                 *pFldRect += pF->Frm().Pos();
    1401             :                             }
    1402           0 :                             rCntntAtPos.pFndTxtAttr = 0;
    1403           0 :                             rCntntAtPos.aFnd.pAttr = pItem;
    1404             :                         }
    1405             :                     }
    1406             :                 }
    1407             :             }
    1408             : 
    1409             : #ifdef DBG_UTIL
    1410             :             if( !bRet && SwContentAtPos::SW_CURR_ATTRS & rCntntAtPos.eCntntAtPos )
    1411             :             {
    1412             :                 xub_StrLen n = aPos.nContent.GetIndex();
    1413             :                 SfxItemSet aSet( GetDoc()->GetAttrPool(), POOLATTR_BEGIN,
    1414             :                                                           POOLATTR_END - 1 );
    1415             :                 if( pTxtNd->GetpSwpHints() )
    1416             :                 {
    1417             :                     for( sal_uInt16 i = 0; i < pTxtNd->GetSwpHints().Count(); ++i )
    1418             :                     {
    1419             :                         const SwTxtAttr* pHt = pTxtNd->GetSwpHints()[i];
    1420             :                         xub_StrLen nAttrStart = *pHt->GetStart();
    1421             :                         if( nAttrStart > n ) // over the section
    1422             :                             break;
    1423             : 
    1424             :                         if( 0 != pHt->GetEnd() && (
    1425             :                             ( nAttrStart < n &&
    1426             :                                 ( pHt->DontExpand() ? n < *pHt->GetEnd()
    1427             :                                                     : n <= *pHt->GetEnd() )) ||
    1428             :                             ( n == nAttrStart &&
    1429             :                                 ( nAttrStart == *pHt->GetEnd() || !n ))) )
    1430             :                         {
    1431             :                             aSet.Put( pHt->GetAttr() );
    1432             :                         }
    1433             :                     }
    1434             :                     if( pTxtNd->HasSwAttrSet() &&
    1435             :                         pTxtNd->GetpSwAttrSet()->Count() )
    1436             :                     {
    1437             :                         SfxItemSet aFmtSet( pTxtNd->GetSwAttrSet() );
    1438             :                         // remove all from format set that are also in TextSet
    1439             :                         aFmtSet.Differentiate( aSet );
    1440             :                         // now merge all together
    1441             :                         aSet.Put( aFmtSet );
    1442             :                     }
    1443             :                 }
    1444             :                 else
    1445             :                     pTxtNd->SwCntntNode::GetAttr( aSet );
    1446             : 
    1447             :                 rCntntAtPos.sStr.AssignAscii(
    1448             :                                     RTL_CONSTASCII_STRINGPARAM( "Pos: (" ));
    1449             :                 rCntntAtPos.sStr += String::CreateFromInt32( aPos.nNode.GetIndex());
    1450             :                 rCntntAtPos.sStr += ':';
    1451             :                 rCntntAtPos.sStr += String::CreateFromInt32( aPos.nContent.GetIndex());
    1452             :                 rCntntAtPos.sStr += ')';
    1453             :                 rCntntAtPos.sStr.AppendAscii(
    1454             :                                 RTL_CONSTASCII_STRINGPARAM( "\nAbs.Vorl.: " )); // translation *might be* "paragraph template"
    1455             :                 rCntntAtPos.sStr += pTxtNd->GetFmtColl()->GetName();
    1456             :                 if( pTxtNd->GetCondFmtColl() )
    1457             :                     rCntntAtPos.sStr.AppendAscii(
    1458             :                                 RTL_CONSTASCII_STRINGPARAM( "\nBed.Vorl.: " )) // translation *might be* "conditional template"
    1459             :                         += pTxtNd->GetCondFmtColl()->GetName();
    1460             : 
    1461             :                 if( aSet.Count() )
    1462             :                 {
    1463             :                     String sAttrs;
    1464             :                     SfxItemIter aIter( aSet );
    1465             :                     const SfxPoolItem* pItem = aIter.FirstItem();
    1466             :                     while( sal_True )
    1467             :                     {
    1468             :                         if( !IsInvalidItem( pItem ))
    1469             :                         {
    1470             :                             String aStr;
    1471             :                             GetDoc()->GetAttrPool().GetPresentation( *pItem,
    1472             :                                             SFX_ITEM_PRESENTATION_COMPLETE,
    1473             :                                             SFX_MAPUNIT_CM, aStr );
    1474             :                             if( sAttrs.Len() )
    1475             :                                 sAttrs.AppendAscii(
    1476             :                                         RTL_CONSTASCII_STRINGPARAM( ", " ));
    1477             :                             sAttrs += aStr;
    1478             :                         }
    1479             :                         if( aIter.IsAtEnd() )
    1480             :                             break;
    1481             :                         pItem = aIter.NextItem();
    1482             :                     }
    1483             :                     if( sAttrs.Len() )
    1484             :                     {
    1485             :                         if( rCntntAtPos.sStr.Len() )
    1486             :                             rCntntAtPos.sStr += '\n';
    1487             :                         rCntntAtPos.sStr.AppendAscii(
    1488             :                                 RTL_CONSTASCII_STRINGPARAM( "Attr: " ) )
    1489             :                                 += sAttrs;
    1490             :                     }
    1491             :                 }
    1492             :                 bRet = sal_True;
    1493             :                 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_CURR_ATTRS;
    1494             :             }
    1495             : #endif
    1496           0 :         }
    1497             :     }
    1498             : 
    1499           0 :     if( !bRet )
    1500             :     {
    1501           0 :         rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_NOTHING;
    1502           0 :         rCntntAtPos.aFnd.pFld = 0;
    1503             :     }
    1504           0 :     return bRet;
    1505             : }
    1506             : 
    1507             : // #i90516#
    1508         322 : const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const
    1509             : {
    1510         322 :     const SwPostItField* pPostItFld = 0;
    1511             : 
    1512         322 :     if ( !IsTableMode() )
    1513             :     {
    1514         322 :         const SwPosition* pCursorPos = _GetCrsr()->GetPoint();
    1515         322 :         const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode();
    1516         322 :         if ( pTxtNd )
    1517             :         {
    1518             :             SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
    1519         322 :                     pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD );
    1520         322 :             const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
    1521         322 :             if ( pFld && pFld->Which()== RES_POSTITFLD )
    1522             :             {
    1523           0 :                 pPostItFld = static_cast<const SwPostItField*>(pFld);
    1524             :             }
    1525             :         }
    1526             :     }
    1527             : 
    1528         322 :     return pPostItFld;
    1529             : }
    1530             : 
    1531             : /// is the node in a protected section?
    1532           0 : bool SwContentAtPos::IsInProtectSect() const
    1533             : {
    1534           0 :     const SwTxtNode* pNd = 0;
    1535           0 :     if( pFndTxtAttr )
    1536             :     {
    1537           0 :         switch( eCntntAtPos )
    1538             :         {
    1539             :         case SW_FIELD:
    1540             :         case SW_CLICKFIELD:
    1541           0 :             pNd = ((SwTxtFld*)pFndTxtAttr)->GetpTxtNode();
    1542           0 :             break;
    1543             : 
    1544             :         case SW_FTN:
    1545           0 :             pNd = &((SwTxtFtn*)pFndTxtAttr)->GetTxtNode();
    1546           0 :             break;
    1547             : 
    1548             :         case SW_INETATTR:
    1549           0 :             pNd = ((SwTxtINetFmt*)pFndTxtAttr)->GetpTxtNode();
    1550           0 :             break;
    1551             : 
    1552             :         default:
    1553           0 :             break;
    1554             :         }
    1555             :     }
    1556             : 
    1557             :     const SwCntntFrm* pFrm;
    1558           0 :     return pNd && ( pNd->IsInProtectSect() ||
    1559           0 :                     ( 0 != ( pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), 0,0,sal_False)) &&
    1560           0 :                         pFrm->IsProtected() ));
    1561             : }
    1562             : 
    1563           0 : bool SwContentAtPos::IsInRTLText()const
    1564             : {
    1565           0 :     bool bRet = false;
    1566           0 :     const SwTxtNode* pNd = 0;
    1567           0 :     if (pFndTxtAttr && (eCntntAtPos == SW_FTN))
    1568             :     {
    1569           0 :         const SwTxtFtn* pTxtFtn = static_cast<const SwTxtFtn*>(pFndTxtAttr);
    1570           0 :         if(pTxtFtn->GetStartNode())
    1571             :         {
    1572           0 :             SwStartNode* pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode();
    1573           0 :             SwPaM aTemp( *pSttNd );
    1574           0 :             aTemp.Move(fnMoveForward, fnGoNode);
    1575           0 :             SwCntntNode* pCntntNode = aTemp.GetCntntNode();
    1576           0 :             if(pCntntNode && pCntntNode->IsTxtNode())
    1577           0 :                 pNd = static_cast<SwTxtNode*>(pCntntNode);
    1578             :         }
    1579             :     }
    1580           0 :     if(pNd)
    1581             :     {
    1582           0 :         SwIterator<SwTxtFrm,SwTxtNode> aIter(*pNd);
    1583           0 :         SwTxtFrm* pTmpFrm = aIter.First();
    1584           0 :         while( pTmpFrm )
    1585             :         {
    1586           0 :                 if ( !pTmpFrm->IsFollow())
    1587             :                 {
    1588           0 :                     bRet = pTmpFrm->IsRightToLeft();
    1589           0 :                     break;
    1590             :                 }
    1591           0 :             pTmpFrm = aIter.Next();
    1592           0 :         }
    1593             :     }
    1594           0 :     return bRet;
    1595             : }
    1596             : 
    1597           0 : sal_Bool SwCrsrShell::SelectTxtAttr( sal_uInt16 nWhich, sal_Bool bExpand,
    1598             :                                     const SwTxtAttr* pTxtAttr )
    1599             : {
    1600           0 :     SET_CURR_SHELL( this );
    1601           0 :     sal_Bool bRet = sal_False;
    1602             : 
    1603           0 :     if( !IsTableMode() )
    1604             :     {
    1605           0 :         SwPosition& rPos = *pCurCrsr->GetPoint();
    1606           0 :         if( !pTxtAttr )
    1607             :         {
    1608           0 :             SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
    1609             :             pTxtAttr = (pTxtNd)
    1610           0 :                 ? pTxtNd->GetTxtAttrAt(rPos.nContent.GetIndex(),
    1611             :                         static_cast<RES_TXTATR>(nWhich),
    1612           0 :                         (bExpand) ? SwTxtNode::EXPAND : SwTxtNode::DEFAULT)
    1613           0 :                 : 0;
    1614             :         }
    1615             : 
    1616           0 :         if( pTxtAttr )
    1617             :         {
    1618           0 :             SwCallLink aLk( *this ); // watch Crsr-Moves
    1619           0 :             SwCrsrSaveState aSaveState( *pCurCrsr );
    1620             : 
    1621           0 :             pCurCrsr->DeleteMark();
    1622           0 :             rPos.nContent = *pTxtAttr->GetStart();
    1623           0 :             pCurCrsr->SetMark();
    1624           0 :             const xub_StrLen* pEnd = pTxtAttr->GetEnd();
    1625           0 :             rPos.nContent = pEnd ? *pEnd : *pTxtAttr->GetStart() + 1;
    1626             : 
    1627           0 :             if( !pCurCrsr->IsSelOvr() )
    1628             :             {
    1629           0 :                 UpdateCrsr();
    1630           0 :                 bRet = sal_True;
    1631           0 :             }
    1632             :         }
    1633             :     }
    1634           0 :     return bRet;
    1635             : }
    1636             : 
    1637             : 
    1638           0 : bool SwCrsrShell::GotoINetAttr( const SwTxtINetFmt& rAttr )
    1639             : {
    1640           0 :     bool bRet = false;
    1641           0 :     if( rAttr.GetpTxtNode() )
    1642             :     {
    1643           0 :         SwCursor* pCrsr = getShellCrsr( true );
    1644             : 
    1645           0 :         SET_CURR_SHELL( this );
    1646           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
    1647           0 :         SwCrsrSaveState aSaveState( *pCrsr );
    1648             : 
    1649           0 :         pCrsr->GetPoint()->nNode = *rAttr.GetpTxtNode();
    1650           0 :         pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)rAttr.GetpTxtNode(),
    1651           0 :                                             *rAttr.GetStart() );
    1652           0 :         bRet = !pCrsr->IsSelOvr();
    1653           0 :         if( bRet )
    1654           0 :             UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
    1655             :     }
    1656           0 :     return bRet;
    1657             : }
    1658             : 
    1659             : 
    1660           0 : const SwFmtINetFmt* SwCrsrShell::FindINetAttr( const String& rName ) const
    1661             : {
    1662           0 :     return pDoc->FindINetAttr( rName );
    1663             : }
    1664             : 
    1665           0 : sal_Bool SwCrsrShell::GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode,
    1666             :                                 SwRect& rRect, sal_Int16& rOrient )
    1667             : {
    1668             : 
    1669           0 :     SET_CURR_SHELL( this );
    1670           0 :     sal_Bool bRet = sal_False;
    1671             : 
    1672           0 :     if (!IsTableMode() && !HasSelection()
    1673           0 :         && GetDoc()->GetIDocumentUndoRedo().DoesUndo())
    1674             :     {
    1675           0 :         Point aPt( rPt );
    1676           0 :         SwPosition aPos( *pCurCrsr->GetPoint() );
    1677             : 
    1678           0 :         SwFillCrsrPos aFPos( eFillMode );
    1679           0 :         SwCrsrMoveState aTmpState( &aFPos );
    1680             : 
    1681           0 :         if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) &&
    1682           0 :             !aPos.nNode.GetNode().IsProtect())
    1683             :         {
    1684             :             // start position in protected section?
    1685           0 :             rRect = aFPos.aCrsr;
    1686           0 :             rOrient = aFPos.eOrient;
    1687           0 :             bRet = sal_True;
    1688           0 :         }
    1689             :     }
    1690           0 :     return bRet;
    1691             : }
    1692             : 
    1693           0 : sal_Bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
    1694             : {
    1695           0 :     SET_CURR_SHELL( this );
    1696           0 :     sal_Bool bRet = sal_False;
    1697             : 
    1698           0 :     if (!IsTableMode() && !HasSelection()
    1699           0 :         && GetDoc()->GetIDocumentUndoRedo().DoesUndo())
    1700             :     {
    1701           0 :         Point aPt( rPt );
    1702           0 :         SwPosition aPos( *pCurCrsr->GetPoint() );
    1703             : 
    1704           0 :         SwFillCrsrPos aFPos( eFillMode );
    1705           0 :         SwCrsrMoveState aTmpState( &aFPos );
    1706             : 
    1707           0 :         if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) )
    1708             :         {
    1709           0 :             SwCallLink aLk( *this ); // watch Crsr-Moves
    1710           0 :             StartAction();
    1711             : 
    1712           0 :             SwCntntNode* pCNd = aPos.nNode.GetNode().GetCntntNode();
    1713           0 :             SwUndoId nUndoId = UNDO_INS_FROM_SHADOWCRSR;
    1714             :             // If only the paragraph attributes "Adjust" or "LRSpace" are set,
    1715             :             // then the following should not delete those again.
    1716           0 :             if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
    1717             :                 ( FILL_INDENT == aFPos.eMode ||
    1718             :                   ( text::HoriOrientation::NONE != aFPos.eOrient &&
    1719             :                     0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
    1720           0 :                 pCNd && pCNd->Len() )
    1721           0 :                 nUndoId = UNDO_EMPTY;
    1722             : 
    1723           0 :             GetDoc()->GetIDocumentUndoRedo().StartUndo( nUndoId, NULL );
    1724             : 
    1725           0 :             SwTxtFmtColl* pNextFmt = 0;
    1726           0 :             SwTxtNode* pTNd = pCNd->GetTxtNode();
    1727           0 :             if( pTNd )
    1728           0 :                 pNextFmt = &pTNd->GetTxtColl()->GetNextTxtFmtColl();
    1729             : 
    1730           0 :             const SwSectionNode* pSectNd = pCNd->FindSectionNode();
    1731           0 :             if( pSectNd && aFPos.nParaCnt )
    1732             :             {
    1733           0 :                 SwNodeIndex aEnd( aPos.nNode, 1 );
    1734           0 :                 while( aEnd.GetNode().IsEndNode() &&
    1735           0 :                         (const SwNode*)&aEnd.GetNode() !=
    1736           0 :                         pSectNd->EndOfSectionNode() )
    1737           0 :                     ++aEnd;
    1738             : 
    1739           0 :                 if( aEnd.GetNode().IsEndNode() &&
    1740           0 :                     pCNd->Len() == aPos.nContent.GetIndex() )
    1741           0 :                     aPos.nNode = *pSectNd->EndOfSectionNode();
    1742             :             }
    1743             : 
    1744           0 :             for( sal_uInt16 n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
    1745             :             {
    1746           0 :                 GetDoc()->AppendTxtNode( aPos );
    1747           0 :                 if( !n && pNextFmt )
    1748             :                 {
    1749           0 :                     *pCurCrsr->GetPoint() = aPos;
    1750           0 :                     GetDoc()->SetTxtFmtColl( *pCurCrsr, pNextFmt, false );
    1751             :                 }
    1752           0 :                 if( n < aFPos.nColumnCnt )
    1753             :                 {
    1754           0 :                     *pCurCrsr->GetPoint() = aPos;
    1755           0 :                     GetDoc()->InsertPoolItem( *pCurCrsr,
    1756           0 :                             SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0);
    1757             :                 }
    1758             :             }
    1759             : 
    1760           0 :             *pCurCrsr->GetPoint() = aPos;
    1761           0 :             switch( aFPos.eMode )
    1762             :             {
    1763             :             case FILL_INDENT:
    1764           0 :                 if( 0 != (pCNd = aPos.nNode.GetNode().GetCntntNode() ))
    1765             :                 {
    1766           0 :                     SfxItemSet aSet( GetDoc()->GetAttrPool(),
    1767             :                                     RES_LR_SPACE, RES_LR_SPACE,
    1768             :                                     RES_PARATR_ADJUST, RES_PARATR_ADJUST,
    1769           0 :                                     0 );
    1770             :                     SvxLRSpaceItem aLR( (SvxLRSpaceItem&)
    1771           0 :                                         pCNd->GetAttr( RES_LR_SPACE ) );
    1772           0 :                     aLR.SetTxtLeft( aFPos.nTabCnt );
    1773           0 :                     aLR.SetTxtFirstLineOfst( 0 );
    1774           0 :                     aSet.Put( aLR );
    1775             : 
    1776             :                     const SvxAdjustItem& rAdj = (SvxAdjustItem&)pCNd->
    1777           0 :                                         GetAttr( RES_PARATR_ADJUST );
    1778           0 :                     if( SVX_ADJUST_LEFT != rAdj.GetAdjust() )
    1779           0 :                         aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) );
    1780             : 
    1781           0 :                     GetDoc()->InsertItemSet( *pCurCrsr, aSet, 0 );
    1782             :                 }
    1783             :                 else {
    1784             :                     OSL_ENSURE( !this, "No CntntNode" );
    1785             :                 }
    1786           0 :                 break;
    1787             : 
    1788             :             case FILL_TAB:
    1789             :             case FILL_SPACE:
    1790             :                 {
    1791           0 :                     rtl::OUStringBuffer sInsert;
    1792           0 :                     if (aFPos.nTabCnt)
    1793           0 :                         comphelper::string::padToLength(sInsert, aFPos.nTabCnt, '\t');
    1794           0 :                     if (aFPos.nSpaceCnt)
    1795           0 :                         comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
    1796           0 :                     if (sInsert.getLength())
    1797           0 :                         GetDoc()->InsertString( *pCurCrsr, sInsert.makeStringAndClear());
    1798             :                 }
    1799             :                 // no break - still need to set orientation
    1800             :             case FILL_MARGIN:
    1801           0 :                 if( text::HoriOrientation::NONE != aFPos.eOrient )
    1802             :                 {
    1803           0 :                     SvxAdjustItem aAdj( SVX_ADJUST_LEFT, RES_PARATR_ADJUST );
    1804           0 :                     switch( aFPos.eOrient )
    1805             :                     {
    1806             :                     case text::HoriOrientation::CENTER:
    1807           0 :                         aAdj.SetAdjust( SVX_ADJUST_CENTER );
    1808           0 :                         break;
    1809             :                     case text::HoriOrientation::RIGHT:
    1810           0 :                         aAdj.SetAdjust( SVX_ADJUST_RIGHT );
    1811           0 :                         break;
    1812             :                     default:
    1813           0 :                         break;
    1814             :                     }
    1815           0 :                     GetDoc()->InsertPoolItem( *pCurCrsr, aAdj, 0 );
    1816             :                 }
    1817           0 :                 break;
    1818             :             }
    1819             : 
    1820           0 :             GetDoc()->GetIDocumentUndoRedo().EndUndo( nUndoId, NULL );
    1821           0 :             EndAction();
    1822             : 
    1823           0 :             bRet = sal_True;
    1824           0 :         }
    1825             :     }
    1826           0 :     return bRet;
    1827             : }
    1828             : 
    1829           0 : const SwRedline* SwCrsrShell::SelNextRedline()
    1830             : {
    1831           0 :     const SwRedline* pFnd = 0;
    1832           0 :     if( !IsTableMode() )
    1833             :     {
    1834           0 :         SET_CURR_SHELL( this );
    1835           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
    1836           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
    1837             : 
    1838           0 :         pFnd = GetDoc()->SelNextRedline( *pCurCrsr );
    1839           0 :         if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
    1840           0 :             UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
    1841             :         else
    1842           0 :             pFnd = 0;
    1843             :     }
    1844           0 :     return pFnd;
    1845             : }
    1846             : 
    1847           0 : const SwRedline* SwCrsrShell::SelPrevRedline()
    1848             : {
    1849           0 :     const SwRedline* pFnd = 0;
    1850           0 :     if( !IsTableMode() )
    1851             :     {
    1852           0 :         SET_CURR_SHELL( this );
    1853           0 :         SwCallLink aLk( *this ); // watch Crsr-Moves
    1854           0 :         SwCrsrSaveState aSaveState( *pCurCrsr );
    1855             : 
    1856           0 :         pFnd = GetDoc()->SelPrevRedline( *pCurCrsr );
    1857           0 :         if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
    1858           0 :             UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
    1859             :         else
    1860           0 :             pFnd = 0;
    1861             :     }
    1862           0 :     return pFnd;
    1863             : }
    1864             : 
    1865           0 : const SwRedline* SwCrsrShell::_GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect )
    1866             : {
    1867           0 :     const SwRedline* pFnd = 0;
    1868           0 :     SwCallLink aLk( *this ); // watch Crsr-Moves
    1869           0 :     SwCrsrSaveState aSaveState( *pCurCrsr );
    1870             : 
    1871           0 :     pFnd = GetDoc()->GetRedlineTbl()[ nArrPos ];
    1872           0 :     if( pFnd )
    1873             :     {
    1874           0 :         *pCurCrsr->GetPoint() = *pFnd->Start();
    1875             : 
    1876             :         SwCntntNode* pCNd;
    1877           0 :         SwNodeIndex* pIdx = &pCurCrsr->GetPoint()->nNode;
    1878           0 :         if( !pIdx->GetNode().IsCntntNode() &&
    1879           0 :             0 != ( pCNd = GetDoc()->GetNodes().GoNextSection( pIdx,
    1880           0 :                                     sal_True, IsReadOnlyAvailable() )) )
    1881             :         {
    1882           0 :             if( *pIdx <= pFnd->End()->nNode )
    1883           0 :                 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
    1884             :             else
    1885           0 :                 pFnd = 0;
    1886             :         }
    1887             : 
    1888           0 :         if( pFnd && bSelect )
    1889             :         {
    1890           0 :             pCurCrsr->SetMark();
    1891           0 :             if( nsRedlineType_t::REDLINE_FMTCOLL == pFnd->GetType() )
    1892             :             {
    1893           0 :                 pCNd = pIdx->GetNode().GetCntntNode();
    1894           0 :                 pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
    1895           0 :                 pCurCrsr->GetMark()->nContent.Assign( pCNd, 0 );
    1896             :             }
    1897             :             else
    1898           0 :                 *pCurCrsr->GetPoint() = *pFnd->End();
    1899             : 
    1900           0 :             pIdx = &pCurCrsr->GetPoint()->nNode;
    1901           0 :             if( !pIdx->GetNode().IsCntntNode() &&
    1902           0 :                 0 != ( pCNd = GetDoc()->GetNodes().GoPrevSection( pIdx,
    1903           0 :                                             sal_True, IsReadOnlyAvailable() )) )
    1904             :             {
    1905           0 :                 if( *pIdx >= pCurCrsr->GetMark()->nNode )
    1906           0 :                     pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
    1907             :                 else
    1908           0 :                     pFnd = 0;
    1909             :             }
    1910             :         }
    1911             : 
    1912           0 :         if( !pFnd )
    1913             :         {
    1914           0 :             pCurCrsr->DeleteMark();
    1915           0 :             pCurCrsr->RestoreSavePos();
    1916             :         }
    1917           0 :         else if( bSelect && *pCurCrsr->GetMark() == *pCurCrsr->GetPoint() )
    1918           0 :             pCurCrsr->DeleteMark();
    1919             : 
    1920           0 :         if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
    1921             :             UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE
    1922           0 :                         | SwCrsrShell::READONLY );
    1923             :         else
    1924             :         {
    1925           0 :             pFnd = 0;
    1926           0 :             if( bSelect )
    1927           0 :                 pCurCrsr->DeleteMark();
    1928             :         }
    1929             :     }
    1930           0 :     return pFnd;
    1931             : }
    1932             : 
    1933           0 : const SwRedline* SwCrsrShell::GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect )
    1934             : {
    1935           0 :     const SwRedline* pFnd = 0;
    1936           0 :     if( !IsTableMode() )
    1937             :     {
    1938           0 :         SET_CURR_SHELL( this );
    1939             : 
    1940           0 :         const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
    1941           0 :         const SwRedline* pTmp = rTbl[ nArrPos ];
    1942           0 :         sal_uInt16 nSeqNo = pTmp->GetSeqNo();
    1943           0 :         if( nSeqNo && bSelect )
    1944             :         {
    1945           0 :             bool bCheck = false;
    1946           0 :             int nLoopCnt = 2;
    1947           0 :             sal_uInt16 nArrSavPos = nArrPos;
    1948             : 
    1949           0 :             do {
    1950           0 :                 pTmp = _GotoRedline( nArrPos, sal_True );
    1951             : 
    1952           0 :                 if( !pFnd )
    1953           0 :                     pFnd = pTmp;
    1954             : 
    1955           0 :                 if( pTmp && bCheck )
    1956             :                 {
    1957             :                     // Check for overlaps. These can happen when FmtColl-
    1958             :                     // Redlines were streched over a whole paragraph
    1959           0 :                     SwPaM* pCur = pCurCrsr;
    1960           0 :                     SwPaM* pNextPam = (SwPaM*)pCur->GetNext();
    1961           0 :                     SwPosition* pCStt = pCur->Start(), *pCEnd = pCur->End();
    1962           0 :                     while( pCur != pNextPam )
    1963             :                     {
    1964           0 :                         const SwPosition *pNStt = pNextPam->Start(),
    1965           0 :                                          *pNEnd = pNextPam->End();
    1966             : 
    1967           0 :                         bool bDel = true;
    1968           0 :                         switch( ::ComparePosition( *pCStt, *pCEnd,
    1969           0 :                                                    *pNStt, *pNEnd ))
    1970             :                         {
    1971             :                         case POS_INSIDE:         // Pos1 is completely in Pos2
    1972           0 :                             if( !pCur->HasMark() )
    1973             :                             {
    1974           0 :                                 pCur->SetMark();
    1975           0 :                                 *pCur->GetMark() = *pNStt;
    1976             :                             }
    1977             :                             else
    1978           0 :                                 *pCStt = *pNStt;
    1979           0 :                             *pCEnd = *pNEnd;
    1980           0 :                             break;
    1981             : 
    1982             :                         case POS_OUTSIDE:        // Pos2 is completely in Pos1
    1983             :                         case POS_EQUAL:          // Pos1 has same size as Pos2
    1984           0 :                             break;
    1985             : 
    1986             :                         case POS_OVERLAP_BEFORE: // Pos1 overlaps Pos2 at beginning
    1987           0 :                             if( !pCur->HasMark() )
    1988           0 :                                 pCur->SetMark();
    1989           0 :                             *pCEnd = *pNEnd;
    1990           0 :                             break;
    1991             :                         case POS_OVERLAP_BEHIND: // Pos1 overlaps Pos2 at end
    1992           0 :                             if( !pCur->HasMark() )
    1993             :                             {
    1994           0 :                                 pCur->SetMark();
    1995           0 :                                 *pCur->GetMark() = *pNStt;
    1996             :                             }
    1997             :                             else
    1998           0 :                                 *pCStt = *pNStt;
    1999           0 :                             break;
    2000             : 
    2001             :                         default:
    2002           0 :                             bDel = false;
    2003             :                         }
    2004             : 
    2005           0 :                         if( bDel )
    2006             :                         {
    2007             :                             // not needed anymore
    2008           0 :                             SwPaM* pPrevPam = (SwPaM*)pNextPam->GetPrev();
    2009           0 :                             delete pNextPam;
    2010           0 :                             pNextPam = pPrevPam;
    2011             :                         }
    2012           0 :                         pNextPam = (SwPaM*)pNextPam->GetNext();
    2013             :                     }
    2014             :                 }
    2015             : 
    2016             :                 sal_uInt16 nFndPos = 2 == nLoopCnt
    2017           0 :                                     ? rTbl.FindNextOfSeqNo( nArrPos )
    2018           0 :                                     : rTbl.FindPrevOfSeqNo( nArrPos );
    2019           0 :                 if( USHRT_MAX != nFndPos ||
    2020             :                     ( 0 != ( --nLoopCnt ) && USHRT_MAX != (
    2021           0 :                             nFndPos = rTbl.FindPrevOfSeqNo( nArrSavPos ))) )
    2022             :                 {
    2023           0 :                     if( pTmp )
    2024             :                     {
    2025             :                         // create new cursor
    2026           0 :                         CreateCrsr();
    2027           0 :                         bCheck = true;
    2028             :                     }
    2029           0 :                     nArrPos = nFndPos;
    2030             :                 }
    2031             :                 else
    2032           0 :                     nLoopCnt = 0;
    2033             : 
    2034           0 :             } while( nLoopCnt );
    2035             :         }
    2036             :         else
    2037           0 :             pFnd = _GotoRedline( nArrPos, bSelect );
    2038             :     }
    2039           0 :     return pFnd;
    2040             : }
    2041             : 
    2042             : 
    2043           0 : sal_Bool SwCrsrShell::SelectNxtPrvHyperlink( sal_Bool bNext )
    2044             : {
    2045           0 :     SwNodes& rNds = GetDoc()->GetNodes();
    2046           0 :     const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
    2047           0 :     const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
    2048           0 :     sal_uLong nBodySttNdIdx = pBodySttNd->GetIndex();
    2049           0 :     Point aPt;
    2050             : 
    2051           0 :     _SetGetExpFld aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
    2052           0 :     _SetGetExpFld aCurPos( bNext ? *pCurCrsr->End() : *pCurCrsr->Start() );
    2053           0 :     if( aCurPos.GetNode() < nBodySttNdIdx )
    2054             :     {
    2055           0 :         const SwCntntNode* pCNd = aCurPos.GetNodeFromCntnt()->GetCntntNode();
    2056             :         SwCntntFrm* pFrm;
    2057           0 :         if( pCNd && 0 != ( pFrm = pCNd->getLayoutFrm( GetLayout(), &aPt )) )
    2058           0 :             aCurPos.SetBodyPos( *pFrm );
    2059             :     }
    2060             : 
    2061             :     // check first all the hyperlink fields
    2062             :     {
    2063             :         const SwTxtNode* pTxtNd;
    2064           0 :         const SwCharFmts* pFmts = GetDoc()->GetCharFmts();
    2065           0 :         for( sal_uInt16 n = pFmts->size(); 1 < n; )
    2066             :         {
    2067           0 :             SwIterator<SwTxtINetFmt,SwCharFmt> aIter(*(*pFmts)[--n]);
    2068             : 
    2069           0 :             for( SwTxtINetFmt* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
    2070           0 :                 if( 0 != ( pTxtNd = pFnd->GetpTxtNode()) &&
    2071           0 :                     pTxtNd->GetNodes().IsDocNodes() )
    2072             :                 {
    2073           0 :                     SwTxtINetFmt& rAttr = *pFnd;
    2074           0 :                     SwPosition aTmpPos( *pTxtNd );
    2075           0 :                     _SetGetExpFld aPos( aTmpPos.nNode, rAttr );
    2076             :                     SwCntntFrm* pFrm;
    2077           0 :                     if( pTxtNd->GetIndex() < nBodySttNdIdx &&
    2078           0 :                         0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt )) )
    2079           0 :                         aPos.SetBodyPos( *pFrm );
    2080             : 
    2081           0 :                     if( bNext
    2082           0 :                         ? ( aPos < aCmpPos && aCurPos < aPos )
    2083           0 :                         : ( aCmpPos < aPos && aPos < aCurPos ))
    2084             :                     {
    2085           0 :                         String sTxt( pTxtNd->GetExpandTxt( *rAttr.GetStart(),
    2086           0 :                                         *rAttr.GetEnd() - *rAttr.GetStart() ) );
    2087             : 
    2088           0 :                         sTxt = comphelper::string::remove(sTxt, 0x0a);
    2089           0 :                         sTxt = comphelper::string::strip(sTxt, ' ');
    2090             : 
    2091           0 :                         if( sTxt.Len() )
    2092           0 :                             aCmpPos = aPos;
    2093           0 :                     }
    2094             :                 }
    2095           0 :         }
    2096             :     }
    2097             :     // then check all the Flys with a URL or imapge map
    2098             :     {
    2099           0 :         const SwFrmFmts* pFmts = GetDoc()->GetSpzFrmFmts();
    2100           0 :         for( sal_uInt16 n = 0, nEnd = pFmts->size(); n < nEnd; ++n )
    2101             :         {
    2102           0 :             SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)(*pFmts)[ n ];
    2103           0 :             const SwFmtURL& rURLItem = pFmt->GetURL();
    2104           0 :             if( rURLItem.GetMap() || rURLItem.GetURL().Len() )
    2105             :             {
    2106           0 :                 SwFlyFrm* pFly = pFmt->GetFrm( &aPt, sal_False );
    2107           0 :                 SwPosition aTmpPos( *pBodySttNd );
    2108           0 :                 if( pFly &&
    2109           0 :                     GetBodyTxtNode( *GetDoc(), aTmpPos, *pFly->GetLower() ) )
    2110             :                 {
    2111           0 :                     _SetGetExpFld aPos( *pFmt, &aTmpPos );
    2112             : 
    2113           0 :                     if( bNext
    2114           0 :                             ? ( aPos < aCmpPos && aCurPos < aPos )
    2115           0 :                             : ( aCmpPos < aPos && aPos < aCurPos ))
    2116           0 :                         aCmpPos = aPos;
    2117           0 :                 }
    2118             :             }
    2119             :         }
    2120             :     }
    2121             : 
    2122             :     // found any URL ?
    2123           0 :     sal_Bool bRet = sal_False;
    2124           0 :     const SwTxtINetFmt* pFndAttr = aCmpPos.GetINetFmt();
    2125           0 :     const SwFlyFrmFmt* pFndFmt = aCmpPos.GetFlyFmt();
    2126           0 :     if( pFndAttr || pFndFmt )
    2127             :     {
    2128           0 :         SET_CURR_SHELL( this );
    2129           0 :         SwCallLink aLk( *this );
    2130             : 
    2131             :         // found a text attribute ?
    2132           0 :         if( pFndAttr )
    2133             :         {
    2134           0 :             SwCrsrSaveState aSaveState( *pCurCrsr );
    2135             : 
    2136           0 :             aCmpPos.GetPosOfContent( *pCurCrsr->GetPoint() );
    2137           0 :             pCurCrsr->DeleteMark();
    2138           0 :             pCurCrsr->SetMark();
    2139           0 :             pCurCrsr->GetPoint()->nContent = *pFndAttr->SwTxtAttr::GetEnd();
    2140             : 
    2141           0 :             if( !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
    2142             :             {
    2143             :                 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|
    2144           0 :                                     SwCrsrShell::READONLY );
    2145           0 :                 bRet = sal_True;
    2146           0 :             }
    2147             :         }
    2148             :         // found a draw object ?
    2149           0 :         else if( RES_DRAWFRMFMT == pFndFmt->Which() )
    2150             :         {
    2151           0 :             const SdrObject* pSObj = pFndFmt->FindSdrObject();
    2152           0 :             ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
    2153           0 :             MakeSelVisible();
    2154           0 :             bRet = sal_True;
    2155             :         }
    2156             :         else // then is it a fly
    2157             :         {
    2158           0 :             SwFlyFrm* pFly = pFndFmt->GetFrm(&aPt, sal_False );
    2159           0 :             if( pFly )
    2160             :             {
    2161           0 :                 ((SwFEShell*)this)->SelectFlyFrm( *pFly, sal_True );
    2162           0 :                 MakeSelVisible();
    2163           0 :                 bRet = sal_True;
    2164             :             }
    2165           0 :         }
    2166             :     }
    2167           0 :     return bRet;
    2168             : }
    2169             : 
    2170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10