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