Update ooo320-m1
[ooovba.git] / sw / source / core / crsr / crstrvl.cxx
blobb194a5000b1e0a7281819daf61c8323457c310c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: crstrvl.cxx,v $
10 * $Revision: 1.28 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
36 #include <svtools/itemiter.hxx>
37 #include <svx/lrspitem.hxx>
38 #include <svx/adjitem.hxx>
39 #include <svx/brkitem.hxx>
40 #ifndef _SVX_SVDOBJ_HXX
41 #include <svx/svdobj.hxx>
42 #endif
43 #include <crsrsh.hxx>
44 #include <doc.hxx>
45 #include <pagefrm.hxx>
46 #include <cntfrm.hxx>
47 #include <rootfrm.hxx>
48 #include <pam.hxx>
49 #include <ndtxt.hxx>
50 #include <fldbas.hxx>
51 #include <swtable.hxx> // SwTxtFld
52 #include <docary.hxx>
53 #include <txtfld.hxx>
54 #include <fmtfld.hxx>
55 #include <txtftn.hxx>
56 #include <txtinet.hxx>
57 #include <fmtinfmt.hxx>
58 #include <txttxmrk.hxx>
59 #include <frmfmt.hxx>
60 #include <flyfrm.hxx>
61 #include <viscrs.hxx>
62 #include <callnk.hxx>
63 #include <doctxm.hxx>
64 #include <docfld.hxx>
65 #include <expfld.hxx>
66 #include <reffld.hxx>
67 #include <flddat.hxx> // SwTxtFld
68 #include <cellatr.hxx>
69 #include <swundo.hxx>
70 #include <redline.hxx>
71 #include <fmtcntnt.hxx>
72 #include <fmthdft.hxx>
73 #include <pagedesc.hxx>
74 #include <fesh.hxx>
75 #include <charfmt.hxx>
76 #include <fmturl.hxx>
77 #include "txtfrm.hxx"
78 #include <wrong.hxx>
80 #include <vcl/window.hxx>
81 #include <docufld.hxx> // OD 2008-06-19 #i90516#
83 using namespace ::com::sun::star;
86 // zum naechsten/vorhergehenden Punkt auf gleicher Ebene
87 BOOL SwCrsrShell::GotoNextNum()
89 BOOL bRet = GetDoc()->GotoNextNum( *pCurCrsr->GetPoint() );
90 if( bRet )
92 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
93 SwCrsrSaveState aSaveState( *pCurCrsr );
94 if( !ActionPend() )
96 SET_CURR_SHELL( this );
97 // dann versuche den Cursor auf die Position zu setzen,
98 // auf halber Heohe vom Char-SRectangle
99 Point aPt( pCurCrsr->GetPtPos() );
100 SwCntntFrm * pFrm = pCurCrsr->GetCntntNode()->GetFrm( &aPt,
101 pCurCrsr->GetPoint() );
102 pFrm->GetCharRect( aCharRect, *pCurCrsr->GetPoint() );
103 pFrm->Calc();
104 if( pFrm->IsVertical() )
106 aPt.X() = aCharRect.Center().X();
107 aPt.Y() = pFrm->Frm().Top() + nUpDownX;
109 else
111 aPt.Y() = aCharRect.Center().Y();
112 aPt.X() = pFrm->Frm().Left() + nUpDownX;
114 pFrm->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
115 bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
116 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
117 if( bRet )
118 UpdateCrsr(SwCrsrShell::UPDOWN |
119 SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
120 SwCrsrShell::READONLY );
123 return bRet;
127 BOOL SwCrsrShell::GotoPrevNum()
129 BOOL bRet = GetDoc()->GotoPrevNum( *pCurCrsr->GetPoint() );
130 if( bRet )
132 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
133 SwCrsrSaveState aSaveState( *pCurCrsr );
134 if( !ActionPend() )
136 SET_CURR_SHELL( this );
137 // dann versuche den Cursor auf die Position zu setzen,
138 // auf halber Heohe vom Char-SRectangle
139 Point aPt( pCurCrsr->GetPtPos() );
140 SwCntntFrm * pFrm = pCurCrsr->GetCntntNode()->GetFrm( &aPt,
141 pCurCrsr->GetPoint() );
142 pFrm->GetCharRect( aCharRect, *pCurCrsr->GetPoint() );
143 pFrm->Calc();
144 if( pFrm->IsVertical() )
146 aPt.X() = aCharRect.Center().X();
147 aPt.Y() = pFrm->Frm().Top() + nUpDownX;
149 else
151 aPt.Y() = aCharRect.Center().Y();
152 aPt.X() = pFrm->Frm().Left() + nUpDownX;
154 pFrm->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
155 bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
156 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS );
157 if( bRet )
158 UpdateCrsr(SwCrsrShell::UPDOWN |
159 SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
160 SwCrsrShell::READONLY );
163 return bRet;
166 // springe aus dem Content zum Header
168 BOOL SwCrsrShell::GotoHeaderTxt()
170 const SwFrm* pFrm = GetCurrFrm()->FindPageFrm();
171 while( pFrm && !pFrm->IsHeaderFrm() )
172 pFrm = pFrm->GetLower();
173 // Header gefunden, dann suche den 1.Cntnt-Frame
174 while( pFrm && !pFrm->IsCntntFrm() )
175 pFrm = pFrm->GetLower();
176 if( pFrm )
178 SET_CURR_SHELL( this );
179 // hole den Header-Frame
180 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
181 SwCursor *pTmpCrsr = getShellCrsr( true );
182 SwCrsrSaveState aSaveState( *pTmpCrsr );
183 pFrm->Calc();
184 Point aPt( pFrm->Frm().Pos() + pFrm->Prt().Pos() );
185 pFrm->GetCrsrOfst( pTmpCrsr->GetPoint(), aPt );
186 if( !pTmpCrsr->IsSelOvr() )
187 UpdateCrsr();
188 else
189 pFrm = 0;
191 return 0 != pFrm;
195 // springe aus dem Content zum Footer
197 BOOL SwCrsrShell::GotoFooterTxt()
199 const SwPageFrm* pFrm = GetCurrFrm()->FindPageFrm();
200 if( pFrm )
202 const SwFrm* pLower = pFrm->GetLastLower();
204 while( pLower && !pLower->IsFooterFrm() )
205 pLower = pLower->GetLower();
206 // Header gefunden, dann suche den 1.Cntnt-Frame
207 while( pLower && !pLower->IsCntntFrm() )
208 pLower = pLower->GetLower();
210 if( pLower )
212 SwCursor *pTmpCrsr = getShellCrsr( true );
213 SET_CURR_SHELL( this );
214 // hole eine Position im Footer
215 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
216 SwCrsrSaveState aSaveState( *pTmpCrsr );
217 pLower->Calc();
218 Point aPt( pLower->Frm().Pos() + pLower->Prt().Pos() );
219 pLower->GetCrsrOfst( pTmpCrsr->GetPoint(), aPt );
220 if( !pTmpCrsr->IsSelOvr() )
221 UpdateCrsr();
222 else
223 pFrm = 0;
225 else
226 pFrm = 0;
228 else
229 pFrm = 0;
230 return 0 != pFrm;
233 BOOL SwCrsrShell::SetCrsrInHdFt( USHORT nDescNo, BOOL bInHeader )
235 BOOL bRet = FALSE;
236 SwDoc *pMyDoc = GetDoc();
238 SET_CURR_SHELL( this );
240 if( USHRT_MAX == nDescNo )
242 // dann den akt. nehmen
243 const SwPageFrm* pPage = GetCurrFrm()->FindPageFrm();
244 if( pPage )
245 for( USHORT i = 0; i < pMyDoc->GetPageDescCnt(); ++i )
246 if( pPage->GetPageDesc() ==
247 &const_cast<const SwDoc *>(pMyDoc)->GetPageDesc( i ) )
249 nDescNo = i;
250 break;
254 if( USHRT_MAX != nDescNo && nDescNo < pMyDoc->GetPageDescCnt() )
256 //dann teste mal, ob ueberhaupt das Attribut vorhanden ist.
257 const SwPageDesc& rDesc = const_cast<const SwDoc *>(pMyDoc)
258 ->GetPageDesc( nDescNo );
259 const SwFmtCntnt* pCnt = 0;
260 if( bInHeader )
262 // gespiegelte Seiten??? erstmal nicht beachten
263 const SwFmtHeader& rHd = rDesc.GetMaster().GetHeader();
264 if( rHd.GetHeaderFmt() )
265 pCnt = &rHd.GetHeaderFmt()->GetCntnt();
267 else
269 const SwFmtFooter& rFt = rDesc.GetMaster().GetFooter();
270 if( rFt.GetFooterFmt() )
271 pCnt = &rFt.GetFooterFmt()->GetCntnt();
274 if( pCnt && pCnt->GetCntntIdx() )
276 SwNodeIndex aIdx( *pCnt->GetCntntIdx(), 1 );
277 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
278 if( !pCNd )
279 pCNd = pMyDoc->GetNodes().GoNext( &aIdx );
281 const SwFrm* pFrm;
282 Point aPt( pCurCrsr->GetPtPos() );
284 if( pCNd && 0 != ( pFrm = pCNd->GetFrm( &aPt, 0, FALSE ) ))
286 // dann kann der Cursor ja auch hinein gesetzt werden
287 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
288 SwCrsrSaveState aSaveState( *pCurCrsr );
290 ClearMark();
292 SwPosition& rPos = *pCurCrsr->GetPoint();
293 rPos.nNode = *pCNd;
294 rPos.nContent.Assign( pCNd, 0 );
296 bRet = !pCurCrsr->IsSelOvr();
297 if( bRet )
298 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
299 SwCrsrShell::READONLY );
303 return bRet;
306 // springe zum naechsten Verzeichnis
308 BOOL SwCrsrShell::GotoNextTOXBase( const String* pName )
310 BOOL bRet = FALSE;
312 const SwSectionFmts& rFmts = GetDoc()->GetSections();
313 SwCntntNode* pFnd = 0;
314 for( USHORT n = rFmts.Count(); n; )
316 const SwSection* pSect = rFmts[ --n ]->GetSection();
317 const SwSectionNode* pSectNd;
318 if( TOX_CONTENT_SECTION == pSect->GetType() &&
319 0 != ( pSectNd = pSect->GetFmt()->GetSectionNode() ) &&
320 pCurCrsr->GetPoint()->nNode < pSectNd->GetIndex() &&
321 ( !pFnd || pFnd->GetIndex() > pSectNd->GetIndex() ) &&
322 // JP 10.12.96: solange wir nur 3 Typen kennen und UI-seitig keine anderen
323 // einstellbar sind, muss ueber den Titel gesucht werden!
324 // ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTypeName() ) &&
325 ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTOXName() )
328 SwNodeIndex aIdx( *pSectNd, 1 );
329 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
330 if( !pCNd )
331 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
332 const SwCntntFrm* pCFrm;
333 if( pCNd &&
334 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex() &&
335 0 != ( pCFrm = pCNd->GetFrm() ) &&
336 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
338 pFnd = pCNd;
342 if( pFnd )
344 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
345 SwCrsrSaveState aSaveState( *pCurCrsr );
346 pCurCrsr->GetPoint()->nNode = *pFnd;
347 pCurCrsr->GetPoint()->nContent.Assign( pFnd, 0 );
348 bRet = !pCurCrsr->IsSelOvr();
349 if( bRet )
350 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
352 return bRet;
355 // springe zum vorherigen Verzeichnis
358 BOOL SwCrsrShell::GotoPrevTOXBase( const String* pName )
360 BOOL bRet = FALSE;
362 const SwSectionFmts& rFmts = GetDoc()->GetSections();
363 SwCntntNode* pFnd = 0;
364 for( USHORT n = rFmts.Count(); n; )
366 const SwSection* pSect = rFmts[ --n ]->GetSection();
367 const SwSectionNode* pSectNd;
368 if( TOX_CONTENT_SECTION == pSect->GetType() &&
369 0 != ( pSectNd = pSect->GetFmt()->GetSectionNode() ) &&
370 pCurCrsr->GetPoint()->nNode > pSectNd->EndOfSectionIndex() &&
371 ( !pFnd || pFnd->GetIndex() < pSectNd->GetIndex() ) &&
372 // JP 10.12.96: solange wir nur 3 Typen kennen und UI-seitig keine anderen
373 // einstellbar sind, muss ueber den Titel gesucht werden!
374 // ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTypeName() ) &&
375 ( !pName || *pName == ((SwTOXBaseSection*)pSect)->GetTOXName() )
378 SwNodeIndex aIdx( *pSectNd, 1 );
379 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
380 if( !pCNd )
381 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
382 const SwCntntFrm* pCFrm;
383 if( pCNd &&
384 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex() &&
385 0 != ( pCFrm = pCNd->GetFrm() ) &&
386 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
388 pFnd = pCNd;
393 if( pFnd )
395 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
396 SwCrsrSaveState aSaveState( *pCurCrsr );
397 pCurCrsr->GetPoint()->nNode = *pFnd;
398 pCurCrsr->GetPoint()->nContent.Assign( pFnd, 0 );
399 bRet = !pCurCrsr->IsSelOvr();
400 if( bRet )
401 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
403 return bRet;
406 // springe zum Verzeichnis vom TOXMark
408 BOOL SwCrsrShell::GotoTOXMarkBase()
410 BOOL bRet = FALSE;
412 SwTOXMarks aMarks;
413 USHORT nCnt = GetDoc()->GetCurTOXMark( *pCurCrsr->GetPoint(), aMarks );
414 if( nCnt )
416 // dann nehme den 1. und hole den Verzeichnis-Typ.
417 // Suche in seiner Abhaengigkeitsliste nach dem eigentlichem
418 // Verzeichnis
419 SwModify* pType = (SwModify*)aMarks[0]->GetRegisteredIn();
420 SwClientIter aIter( *pType );
421 const SwSectionNode* pSectNd;
422 const SwSectionFmt* pSectFmt;
424 for( SwTOXBase* pTOX =
425 (SwTOXBase*)aIter.First( TYPE( SwTOXBase ));
426 pTOX; pTOX = (SwTOXBase*)aIter.Next() )
427 if( pTOX->ISA( SwTOXBaseSection ) &&
428 0 != ( pSectFmt = ((SwTOXBaseSection*)pTOX)->GetFmt() ) &&
429 0 != ( pSectNd = pSectFmt->GetSectionNode() ))
431 SwNodeIndex aIdx( *pSectNd, 1 );
432 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
433 if( !pCNd )
434 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
435 const SwCntntFrm* pCFrm;
436 if( pCNd &&
437 pCNd->EndOfSectionIndex() < pSectNd->EndOfSectionIndex() &&
438 0 != ( pCFrm = pCNd->GetFrm() ) &&
439 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
441 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
442 SwCrsrSaveState aSaveState( *pCurCrsr );
443 pCurCrsr->GetPoint()->nNode = *pCNd;
444 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
445 bRet = !pCurCrsr->IsInProtectTable() &&
446 !pCurCrsr->IsSelOvr();
447 if( bRet )
448 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
449 break;
453 return bRet;
457 // springe zur naechsten (vorherigen) Tabellenformel
458 // optional auch nur zu kaputten Formeln springen
459 BOOL SwCrsrShell::GotoNxtPrvTblFormula( BOOL bNext, BOOL bOnlyErrors )
461 if( IsTableMode() )
462 return FALSE;
464 BOOL bFnd = FALSE;
465 SwPosition& rPos = *pCurCrsr->GetPoint();
467 Point aPt;
468 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
469 if( !bNext )
470 aFndPos.nNode = 0;
471 _SetGetExpFld aFndGEF( aFndPos ), aCurGEF( rPos );
474 const SwNode* pSttNd = rPos.nNode.GetNode().FindTableBoxStartNode();
475 if( pSttNd )
477 const SwTableBox* pTBox = pSttNd->FindTableNode()->GetTable().
478 GetTblBox( pSttNd->GetIndex() );
479 if( pTBox )
480 aCurGEF = _SetGetExpFld( *pTBox );
484 if( rPos.nNode < GetDoc()->GetNodes().GetEndOfExtras() )
485 // auch beim Einsammeln wird nur der erste Frame benutzt!
486 aCurGEF.SetBodyPos( *rPos.nNode.GetNode().GetCntntNode()->GetFrm(
487 &aPt, &rPos, FALSE ) );
490 const SfxPoolItem* pItem;
491 const SwTableBox* pTBox;
492 USHORT n, nMaxItems = GetDoc()->GetAttrPool().GetItemCount( RES_BOXATR_FORMULA );
494 for( n = 0; n < nMaxItems; ++n )
495 if( 0 != (pItem = GetDoc()->GetAttrPool().GetItem(
496 RES_BOXATR_FORMULA, n ) ) &&
497 0 != (pTBox = ((SwTblBoxFormula*)pItem)->GetTableBox() ) &&
498 pTBox->GetSttNd() &&
499 pTBox->GetSttNd()->GetNodes().IsDocNodes() &&
500 ( !bOnlyErrors ||
501 !((SwTblBoxFormula*)pItem)->HasValidBoxes() ) )
503 const SwCntntFrm* pCFrm;
504 SwNodeIndex aIdx( *pTBox->GetSttNd() );
505 const SwCntntNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
506 if( pCNd && 0 != ( pCFrm = pCNd->GetFrm( &aPt, 0, FALSE ) ) &&
507 (IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
509 _SetGetExpFld aCmp( *pTBox );
510 aCmp.SetBodyPos( *pCFrm );
512 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
513 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
515 aFndGEF = aCmp;
516 bFnd = TRUE;
522 if( bFnd )
524 SET_CURR_SHELL( this );
525 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
526 SwCrsrSaveState aSaveState( *pCurCrsr );
528 aFndGEF.GetPosOfContent( rPos );
529 pCurCrsr->DeleteMark();
531 bFnd = !pCurCrsr->IsSelOvr();
532 if( bFnd )
533 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
534 SwCrsrShell::READONLY );
536 return bFnd;
539 // springe zum naechsten (vorherigen) Verzeichniseintrag
540 BOOL SwCrsrShell::GotoNxtPrvTOXMark( BOOL bNext )
542 if( IsTableMode() )
543 return FALSE;
545 BOOL bFnd = FALSE;
546 SwPosition& rPos = *pCurCrsr->GetPoint();
548 Point aPt;
549 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
550 if( !bNext )
551 aFndPos.nNode = 0;
552 _SetGetExpFld aFndGEF( aFndPos ), aCurGEF( rPos );
554 if( rPos.nNode.GetIndex() < GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
555 // auch beim Einsammeln wird nur der erste Frame benutzt!
556 aCurGEF.SetBodyPos( *rPos.nNode.GetNode().
557 GetCntntNode()->GetFrm( &aPt, &rPos, FALSE ) );
560 const SfxPoolItem* pItem;
561 const SwCntntFrm* pCFrm;
562 const SwTxtNode* pTxtNd;
563 const SwTxtTOXMark* pTxtTOX;
564 USHORT n, nMaxItems = GetDoc()->GetAttrPool().GetItemCount( RES_TXTATR_TOXMARK );
566 for( n = 0; n < nMaxItems; ++n )
567 if( 0 != (pItem = GetDoc()->GetAttrPool().GetItem(
568 RES_TXTATR_TOXMARK, n ) ) &&
569 0 != (pTxtTOX = ((SwTOXMark*)pItem)->GetTxtTOXMark() ) &&
570 ( pTxtNd = &pTxtTOX->GetTxtNode())->GetNodes().IsDocNodes() &&
571 0 != ( pCFrm = pTxtNd->GetFrm( &aPt, 0, FALSE )) &&
572 ( IsReadOnlyAvailable() || !pCFrm->IsProtected() ))
574 SwNodeIndex aNdIndex( *pTxtNd ); // UNIX benoetigt dieses Obj.
575 _SetGetExpFld aCmp( aNdIndex, *pTxtTOX, 0 );
576 aCmp.SetBodyPos( *pCFrm );
578 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
579 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
581 aFndGEF = aCmp;
582 bFnd = TRUE;
587 if( bFnd )
589 SET_CURR_SHELL( this );
590 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
591 SwCrsrSaveState aSaveState( *pCurCrsr );
593 aFndGEF.GetPosOfContent( rPos );
595 bFnd = !pCurCrsr->IsSelOvr();
596 if( bFnd )
597 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
598 SwCrsrShell::READONLY );
600 return bFnd;
603 /*--------------------------------------------------------------------
604 Beschreibung: Traveling zwischen Markierungen
605 --------------------------------------------------------------------*/
607 const SwTOXMark& SwCrsrShell::GotoTOXMark( const SwTOXMark& rStart,
608 SwTOXSearch eDir )
610 SET_CURR_SHELL( this );
611 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
612 SwCrsrSaveState aSaveState( *pCurCrsr );
614 const SwTOXMark& rNewMark = GetDoc()->GotoTOXMark( rStart, eDir,
615 IsReadOnlyAvailable() );
616 // Position setzen
617 SwPosition& rPos = *GetCrsr()->GetPoint();
618 rPos.nNode = rNewMark.GetTxtTOXMark()->GetTxtNode();
619 rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
620 *rNewMark.GetTxtTOXMark()->GetStart() );
622 if( !pCurCrsr->IsSelOvr() )
623 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
624 SwCrsrShell::READONLY );
626 return rNewMark;
629 // springe zum naechsten / vorherigen FeldTypen
631 void lcl_MakeFldLst( _SetGetExpFlds& rLst, const SwFieldType& rFldType,
632 USHORT nSubType, BOOL bInReadOnly,
633 BOOL bChkInpFlag = FALSE )
635 // es muss immer der 1. Frame gesucht werden
636 Point aPt;
637 SwTxtFld* pTxtFld;
638 SwClientIter aIter( (SwFieldType&)rFldType );
639 BOOL bSubType = nSubType != USHRT_MAX;
640 for( SwClient* pLast = aIter.First( TYPE( SwFmtFld )); pLast; pLast = aIter.Next() )
641 if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) &&
642 ( !bChkInpFlag || ((SwSetExpField*)pTxtFld->GetFld().GetFld())
643 ->GetInputFlag() ) &&
644 (!bSubType || (((SwFmtFld*)pLast)->GetFld()->GetSubType()
645 & 0xff ) == nSubType ))
647 SwCntntFrm* pCFrm;
648 const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
649 if( 0 != ( pCFrm = rTxtNode.GetFrm( &aPt, 0, FALSE )) &&
650 ( bInReadOnly || !pCFrm->IsProtected() ))
652 _SetGetExpFld* pNew = new _SetGetExpFld(
653 SwNodeIndex( rTxtNode ), pTxtFld );
654 pNew->SetBodyPos( *pCFrm );
655 rLst.Insert( pNew );
661 BOOL SwCrsrShell::MoveFldType( const SwFieldType* pFldType, BOOL bNext,
662 USHORT nSubType, USHORT nResType )
664 // sortierte Liste aller Felder
665 _SetGetExpFlds aSrtLst( 64 );
667 if (pFldType)
669 if( RES_INPUTFLD != pFldType->Which() && !pFldType->GetDepends() )
670 return FALSE;
672 // Modify-Object gefunden, trage alle Felder ins Array ein
673 ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType, IsReadOnlyAvailable() );
675 if( RES_INPUTFLD == pFldType->Which() )
677 // es gibt noch versteckte InputFelder in den SetExp. Feldern
678 const SwFldTypes& rFldTypes = *pDoc->GetFldTypes();
679 const USHORT nSize = rFldTypes.Count();
681 // Alle Typen abklappern
682 for( USHORT i=0; i < nSize; ++i )
683 if( RES_SETEXPFLD == ( pFldType = rFldTypes[ i ] )->Which() )
684 ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType,
685 IsReadOnlyAvailable(), TRUE );
688 else
690 const SwFldTypes& rFldTypes = *pDoc->GetFldTypes();
691 const USHORT nSize = rFldTypes.Count();
693 // Alle Typen abklappern
694 for( USHORT i=0; i < nSize; ++i )
695 if( nResType == ( pFldType = rFldTypes[ i ] )->Which() )
696 ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType,
697 IsReadOnlyAvailable() );
700 // keine Felder gefunden?
701 if( !aSrtLst.Count() )
702 return FALSE;
704 USHORT nPos;
705 SwCursor* pCrsr = getShellCrsr( true );
707 // JP 19.08.98: es muss immer ueber das Feld gesucht werden, damit
708 // auch immer das richtige gefunden wird, wenn welche in
709 // Rahmen stehen, die in einem Absatz verankert sind,
710 // in dem ein Feld steht - siehe auch Bug 55247
711 const SwPosition& rPos = *pCrsr->GetPoint();
713 SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
714 ASSERT( pTNd, "Wo ist mein CntntNode?" );
716 SwTxtFld* pTxtFld = (SwTxtFld*)pTNd->GetTxtAttr( rPos.nContent,
717 RES_TXTATR_FIELD );
718 BOOL bDelFld = 0 == pTxtFld;
719 if( bDelFld )
721 SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField(
722 (SwDateTimeFieldType*)pDoc->GetSysFldType( RES_DATETIMEFLD ) ) );
724 pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex() );
725 pTxtFld->ChgTxtNode( pTNd );
728 _SetGetExpFld aSrch( rPos.nNode, pTxtFld, &rPos.nContent );
729 if( rPos.nNode.GetIndex() < pDoc->GetNodes().GetEndOfExtras().GetIndex() )
731 // auch beim Einsammeln wird nur der erste Frame benutzt!
732 Point aPt;
733 aSrch.SetBodyPos( *pTNd->GetFrm( &aPt, &rPos, FALSE ) );
736 BOOL bFound = aSrtLst.Seek_Entry( &aSrch, &nPos );
737 if( bDelFld )
739 delete (SwFmtFld*)&pTxtFld->GetAttr();
740 delete pTxtFld;
743 if( bFound ) // stehe auf einem ?
745 if( bNext )
747 if( ++nPos >= aSrtLst.Count() )
748 return FALSE; // schon am Ende
750 else if( !nPos-- )
751 return FALSE; // weiter nach vorne geht nicht
753 else if( bNext ? nPos >= aSrtLst.Count() : !nPos--)
754 return FALSE;
756 const _SetGetExpFld& rFnd = **( aSrtLst.GetData() + nPos );
759 SET_CURR_SHELL( this );
760 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
761 SwCrsrSaveState aSaveState( *pCrsr );
763 rFnd.GetPosOfContent( *pCrsr->GetPoint() );
764 BOOL bRet = !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
765 nsSwCursorSelOverFlags::SELOVER_TOGGLE );
766 if( bRet )
767 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
768 return bRet;
772 BOOL SwCrsrShell::GotoFld( const SwFmtFld& rFld )
774 BOOL bRet = FALSE;
775 if( rFld.GetTxtFld() )
777 SET_CURR_SHELL( this );
778 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
780 SwCursor* pCrsr = getShellCrsr( true );
781 SwCrsrSaveState aSaveState( *pCrsr );
783 SwTxtNode* pTNd = (SwTxtNode*)rFld.GetTxtFld()->GetpTxtNode();
784 pCrsr->GetPoint()->nNode = *pTNd;
785 pCrsr->GetPoint()->nContent.Assign( pTNd, *rFld.GetTxtFld()->GetStart() );
787 bRet = !pCrsr->IsSelOvr();
788 if( bRet )
789 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
791 return bRet;
795 void SwCrsrShell::GotoOutline( USHORT nIdx )
797 SwCursor* pCrsr = getShellCrsr( true );
799 SET_CURR_SHELL( this );
800 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
801 SwCrsrSaveState aSaveState( *pCrsr );
803 const SwNodes& rNds = GetDoc()->GetNodes();
804 SwTxtNode* pTxtNd = (SwTxtNode*)rNds.GetOutLineNds()[ nIdx ]->GetTxtNode();
805 pCrsr->GetPoint()->nNode = *pTxtNd;
806 pCrsr->GetPoint()->nContent.Assign( pTxtNd, 0 );
808 if( !pCrsr->IsSelOvr() )
809 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
813 BOOL SwCrsrShell::GotoOutline( const String& rName )
815 SwCursor* pCrsr = getShellCrsr( true );
817 SET_CURR_SHELL( this );
818 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
819 SwCrsrSaveState aSaveState( *pCrsr );
821 BOOL bRet = FALSE;
822 if( pDoc->GotoOutline( *pCrsr->GetPoint(), rName ) && !pCrsr->IsSelOvr() )
824 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
825 bRet = TRUE;
827 return bRet;
832 BOOL SwCrsrShell::GotoNextOutline() // naechster Node mit Outline-Num.
834 SwCursor* pCrsr = getShellCrsr( true );
835 const SwNodes& rNds = GetDoc()->GetNodes();
837 SwNode* pNd = pCrsr->GetNode();
838 USHORT nPos;
839 if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
840 ++nPos;
842 if( nPos == rNds.GetOutLineNds().Count() )
843 return FALSE;
845 pNd = rNds.GetOutLineNds()[ nPos ];
847 SET_CURR_SHELL( this );
848 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
849 SwCrsrSaveState aSaveState( *pCrsr );
850 pCrsr->GetPoint()->nNode = *pNd;
851 pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)pNd, 0 );
853 BOOL bRet = !pCrsr->IsSelOvr();
854 if( bRet )
855 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
856 return bRet;
860 BOOL SwCrsrShell::GotoPrevOutline() // vorheriger Node mit Outline-Num.
862 SwCursor* pCrsr = getShellCrsr( true );
863 const SwNodes& rNds = GetDoc()->GetNodes();
865 SwNode* pNd = pCrsr->GetNode();
866 USHORT nPos;
867 rNds.GetOutLineNds().Seek_Entry( pNd, &nPos );
869 BOOL bRet = FALSE;
870 if( nPos )
872 --nPos; // davor
874 pNd = rNds.GetOutLineNds()[ nPos ];
875 if( pNd->GetIndex() > pCrsr->GetPoint()->nNode.GetIndex() )
876 return FALSE;
878 SET_CURR_SHELL( this );
879 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
880 SwCrsrSaveState aSaveState( *pCrsr );
881 pCrsr->GetPoint()->nNode = *pNd;
882 pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)pNd, 0 );
884 bRet = !pCrsr->IsSelOvr();
885 if( bRet )
886 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
888 return bRet;
892 // suche die "Outline-Position" vom vorherigen Outline-Node mit dem
893 // Level.
894 USHORT SwCrsrShell::GetOutlinePos( BYTE nLevel )
896 SwPaM* pCrsr = getShellCrsr( true );
897 const SwNodes& rNds = GetDoc()->GetNodes();
899 SwNode* pNd = pCrsr->GetNode();
900 USHORT nPos;
901 if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
902 nPos++; // steht auf der Position, fuers while zum Naechsten
904 while( nPos-- ) // immer den davor testen !
906 pNd = rNds.GetOutLineNds()[ nPos ];
908 //if( ((SwTxtNode*)pNd)->GetTxtColl()->GetOutlineLevel() <= nLevel )//#outline level,zhaojianwei
909 if( ((SwTxtNode*)pNd)->GetAttrOutlineLevel()-1 <= nLevel )//<-end,zhaojianwei
910 return nPos;
913 return USHRT_MAX; // davor keiner mehr also Ende
917 BOOL SwCrsrShell::MakeOutlineSel( USHORT nSttPos, USHORT nEndPos,
918 BOOL bWithChilds )
920 const SwNodes& rNds = GetDoc()->GetNodes();
921 const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
922 if( !rOutlNds.Count() ) // wie jetzt ???
923 return FALSE;
925 SET_CURR_SHELL( this );
926 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
928 if( nSttPos > nEndPos ) // sollte jemand das vertauscht haben?
930 ASSERT( !this, "Start- > Ende-Position im Array" );
931 USHORT nTmp = nSttPos;
932 nSttPos = nEndPos;
933 nEndPos = nTmp;
936 SwNode* pSttNd = rOutlNds[ nSttPos ];
937 SwNode* pEndNd = rOutlNds[ nEndPos ];
939 if( bWithChilds )
941 //BYTE nLevel = pEndNd->GetTxtNode()->GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
942 const int nLevel = pEndNd->GetTxtNode()->GetAttrOutlineLevel()-1;//<-end.zhaojianwei
943 for( ++nEndPos; nEndPos < rOutlNds.Count(); ++nEndPos )
945 pEndNd = rOutlNds[ nEndPos ];
946 //BYTE nNxtLevel = pEndNd->GetTxtNode()->GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
947 const int nNxtLevel = pEndNd->GetTxtNode()->GetAttrOutlineLevel()-1;//<-end,zhaojianwei
948 if( nNxtLevel <= nLevel )
949 break; // EndPos steht jetzt auf dem naechsten
952 // ohne Childs, dann aber zumindest auf den naechsten
953 else if( ++nEndPos < rOutlNds.Count() )
954 pEndNd = rOutlNds[ nEndPos ];
956 if( nEndPos == rOutlNds.Count() ) // kein Ende gefunden
957 pEndNd = &rNds.GetEndOfContent();
959 KillPams();
961 SwCrsrSaveState aSaveState( *pCurCrsr );
963 // Jetzt das Ende ans Ende vom voherigen ContentNode setzen
964 pCurCrsr->GetPoint()->nNode = *pSttNd;
965 pCurCrsr->GetPoint()->nContent.Assign( pSttNd->GetCntntNode(), 0 );
966 pCurCrsr->SetMark();
967 pCurCrsr->GetPoint()->nNode = *pEndNd;
968 pCurCrsr->Move( fnMoveBackward, fnGoNode ); // ans Ende vom Vorgaenger
970 // und schon ist alles selektiert
971 BOOL bRet = !pCurCrsr->IsSelOvr();
972 if( bRet )
973 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
974 return bRet;
978 // springe zu dieser Refmark
979 BOOL SwCrsrShell::GotoRefMark( const String& rRefMark, USHORT nSubType,
980 USHORT nSeqNo )
982 SET_CURR_SHELL( this );
983 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
984 SwCrsrSaveState aSaveState( *pCurCrsr );
986 USHORT nPos;
987 SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark,
988 nSubType, nSeqNo, &nPos );
989 if( pTxtNd && pTxtNd->GetNodes().IsDocNodes() )
991 pCurCrsr->GetPoint()->nNode = *pTxtNd;
992 pCurCrsr->GetPoint()->nContent.Assign( pTxtNd, nPos );
994 if( !pCurCrsr->IsSelOvr() )
996 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
997 return TRUE;
1000 return FALSE;
1003 BOOL SwCrsrShell::IsPageAtPos( const Point &rPt ) const
1005 if( GetLayout() )
1006 return 0 != GetLayout()->GetPageAtPos( rPt );
1007 return FALSE;
1010 BOOL SwCrsrShell::GetContentAtPos( const Point& rPt,
1011 SwContentAtPos& rCntntAtPos,
1012 BOOL bSetCrsr,
1013 SwRect* pFldRect )
1015 SET_CURR_SHELL( this );
1016 BOOL bRet = FALSE;
1018 if( !IsTableMode() )
1020 Point aPt( rPt );
1021 SwPosition aPos( *pCurCrsr->GetPoint() );
1023 SwTxtNode* pTxtNd;
1024 SwCntntFrm *pFrm(0);
1025 SwTxtAttr* pTxtAttr;
1026 SwCrsrMoveState aTmpState;
1027 aTmpState.bFieldInfo = TRUE;
1028 aTmpState.bExactOnly = !( SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos );
1029 aTmpState.bCntntCheck = (SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos) ? TRUE : FALSE;
1030 aTmpState.bSetInReadOnly = IsReadOnlyAvailable();
1032 SwSpecialPos aSpecialPos;
1033 aTmpState.pSpecialPos = ( SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos ) ?
1034 &aSpecialPos : 0;
1036 const BOOL bCrsrFoundExact = GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState );
1037 pTxtNd = aPos.nNode.GetNode().GetTxtNode();
1039 const SwNodes& rNds = GetDoc()->GetNodes();
1040 if( pTxtNd && SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos
1041 && rNds.GetOutLineNds().Count() )
1043 const SwTxtNode* pONd = pTxtNd->FindOutlineNodeOfLevel( MAXLEVEL-1);
1044 if( pONd )
1046 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_OUTLINE;
1047 rCntntAtPos.sStr = pONd->GetExpandTxt( 0, STRING_LEN, true );
1048 bRet = TRUE;
1051 // --> FME 2005-05-13 #i43742# New function: SW_CONTENT_CHECK
1052 else if ( SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos &&
1053 bCrsrFoundExact )
1055 bRet = TRUE;
1057 // <--
1058 // #i23726#
1059 else if( pTxtNd &&
1060 SwContentAtPos::SW_NUMLABEL & rCntntAtPos.eCntntAtPos)
1062 bRet = aTmpState.bInNumPortion;
1063 rCntntAtPos.aFnd.pNode = pTxtNd;
1065 Size aSizeLogic(aTmpState.nInNumPostionOffset, 0);
1066 Size aSizePixel = GetWin()->LogicToPixel(aSizeLogic);
1067 rCntntAtPos.nDist = aSizePixel.Width();
1069 else if( bCrsrFoundExact && pTxtNd )
1071 if( !aTmpState.bPosCorr )
1073 if( !bRet && SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos
1074 && !aTmpState.bFtnNoInfo )
1076 const SwWrongList* pSmartTagList = pTxtNd->GetSmartTags();
1077 xub_StrLen nCurrent = aPos.nContent.GetIndex();
1078 xub_StrLen nBegin = nCurrent;
1079 xub_StrLen nLen = 1;
1081 if ( pSmartTagList && pSmartTagList->InWrongWord( nCurrent, nLen ) && !pTxtNd->IsSymbol(nBegin) )
1083 const USHORT nIndex = pSmartTagList->GetWrongPos( nBegin );
1084 const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
1085 if ( pSubList )
1087 nCurrent = aTmpState.pSpecialPos->nCharOfst;
1089 if ( pSubList->InWrongWord( nCurrent, nLen ) )
1090 bRet = TRUE;
1092 else
1093 bRet = TRUE;
1095 if( bRet && bSetCrsr )
1097 SwCrsrSaveState aSaveState( *pCurCrsr );
1098 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1099 pCurCrsr->DeleteMark();
1100 *pCurCrsr->GetPoint() = aPos;
1101 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
1102 nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
1103 bRet = FALSE;
1104 else
1105 UpdateCrsr();
1107 if( bRet )
1109 // rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
1110 // *pTxtAttr->GetStart(),
1111 // *pTxtAttr->GetEnd() - *pTxtAttr->GetStart(),
1112 // FALSE );
1114 // rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
1115 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_SMARTTAG;
1116 // rCntntAtPos.pFndTxtAttr = pTxtAttr;
1118 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1119 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1124 if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD )
1125 & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo )
1127 pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
1128 aPos.nContent.GetIndex(), RES_TXTATR_FIELD );
1129 const SwField* pFld = pTxtAttr
1130 ? pTxtAttr->GetFld().GetFld()
1131 : 0;
1132 if( SwContentAtPos::SW_CLICKFIELD & rCntntAtPos.eCntntAtPos &&
1133 pFld && !pFld->HasClickHdl() )
1134 pFld = 0;
1136 if( pFld )
1138 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1139 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1141 if( bSetCrsr )
1143 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1144 SwCrsrSaveState aSaveState( *pCurCrsr );
1145 pCurCrsr->DeleteMark();
1146 *pCurCrsr->GetPoint() = aPos;
1147 if( pCurCrsr->IsSelOvr() )
1149 // Click-Felder in geschuetzten Bereichen zulassen
1150 // Nur Platzhalter geht nicht!
1151 if( SwContentAtPos::SW_FIELD & rCntntAtPos.eCntntAtPos
1152 || RES_JUMPEDITFLD == pFld->Which() )
1153 pFld = 0;
1155 else
1156 UpdateCrsr();
1158 else if( RES_TABLEFLD == pFld->Which() &&
1159 ((SwTblField*)pFld)->IsIntrnlName() )
1161 // erzeuge aus der internen (fuer CORE)
1162 // die externe (fuer UI) Formel
1163 const SwTableNode* pTblNd = pTxtNd->FindTableNode();
1164 if( pTblNd ) // steht in einer Tabelle
1165 ((SwTblField*)pFld)->PtrToBoxNm( &pTblNd->GetTable() );
1169 if( pFld )
1171 rCntntAtPos.aFnd.pFld = pFld;
1172 rCntntAtPos.pFndTxtAttr = pTxtAttr;
1173 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FIELD;
1174 bRet = TRUE;
1178 if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos )
1180 IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
1181 sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos );
1182 if( bCrsrFoundExact && pTxtNd && pFldBookmark) {
1183 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL;
1184 rCntntAtPos.aFnd.pFldmark = pFldBookmark;
1185 bRet=TRUE;
1189 if( !bRet && SwContentAtPos::SW_FTN & rCntntAtPos.eCntntAtPos )
1191 if( aTmpState.bFtnNoInfo )
1193 // stehe ueber dem Zeichen der Fussnote (??)
1194 bRet = TRUE;
1195 if( bSetCrsr )
1197 *pCurCrsr->GetPoint() = aPos;
1198 if( !GotoFtnAnchor() )
1199 bRet = FALSE;
1201 if( bRet )
1202 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN;
1204 else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
1205 aPos.nContent.GetIndex(), RES_TXTATR_FTN )) )
1207 bRet = TRUE;
1208 if( bSetCrsr )
1210 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
1211 SwCrsrSaveState aSaveState( *pCurCrsr );
1212 pCurCrsr->GetPoint()->nNode = *((SwTxtFtn*)pTxtAttr)->GetStartNode();
1213 SwCntntNode* pCNd = GetDoc()->GetNodes().GoNextSection(
1214 &pCurCrsr->GetPoint()->nNode,
1215 TRUE, !IsReadOnlyAvailable() );
1217 if( pCNd )
1219 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
1220 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
1221 nsSwCursorSelOverFlags::SELOVER_TOGGLE ))
1222 bRet = FALSE;
1223 else
1224 UpdateCrsr();
1226 else
1227 bRet = FALSE;
1230 if( bRet )
1232 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN;
1233 rCntntAtPos.pFndTxtAttr = pTxtAttr;
1234 rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
1236 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1237 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1242 if( !bRet && ( SwContentAtPos::SW_TOXMARK |
1243 SwContentAtPos::SW_REFMARK ) &
1244 rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo )
1246 pTxtAttr = 0;
1247 if( SwContentAtPos::SW_TOXMARK & rCntntAtPos.eCntntAtPos )
1248 pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent,
1249 RES_TXTATR_TOXMARK );
1251 if( !pTxtAttr &&
1252 SwContentAtPos::SW_REFMARK & rCntntAtPos.eCntntAtPos )
1253 pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent,
1254 RES_TXTATR_REFMARK );
1256 if( pTxtAttr )
1258 bRet = TRUE;
1259 if( bSetCrsr )
1261 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
1262 SwCrsrSaveState aSaveState( *pCurCrsr );
1263 pCurCrsr->DeleteMark();
1264 *pCurCrsr->GetPoint() = aPos;
1265 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
1266 nsSwCursorSelOverFlags::SELOVER_TOGGLE ) )
1267 bRet = FALSE;
1268 else
1269 UpdateCrsr();
1272 if( bRet )
1274 const xub_StrLen* pEnd = pTxtAttr->GetEnd();
1275 if( pEnd )
1276 rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
1277 *pTxtAttr->GetStart(),
1278 *pEnd - *pTxtAttr->GetStart() );
1279 else if( RES_TXTATR_TOXMARK == pTxtAttr->Which())
1280 rCntntAtPos.sStr = pTxtAttr->GetTOXMark().
1281 GetAlternativeText();
1283 rCntntAtPos.eCntntAtPos =
1284 RES_TXTATR_TOXMARK == pTxtAttr->Which()
1285 ? SwContentAtPos::SW_TOXMARK
1286 : SwContentAtPos::SW_REFMARK;
1287 rCntntAtPos.pFndTxtAttr = pTxtAttr;
1288 rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
1290 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1291 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1296 if( !bRet && SwContentAtPos::SW_INETATTR & rCntntAtPos.eCntntAtPos
1297 && !aTmpState.bFtnNoInfo )
1299 pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent,
1300 RES_TXTATR_INETFMT );
1301 // nur INetAttrs mit URLs "erkennen"
1302 if( pTxtAttr && pTxtAttr->GetINetFmt().GetValue().Len() )
1304 bRet = TRUE;
1305 if( bSetCrsr )
1307 SwCrsrSaveState aSaveState( *pCurCrsr );
1308 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1309 pCurCrsr->DeleteMark();
1310 *pCurCrsr->GetPoint() = aPos;
1311 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
1312 nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
1313 bRet = FALSE;
1314 else
1315 UpdateCrsr();
1317 if( bRet )
1319 rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
1320 *pTxtAttr->GetStart(),
1321 *pTxtAttr->GetEnd() - *pTxtAttr->GetStart() );
1323 rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr();
1324 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_INETATTR;
1325 rCntntAtPos.pFndTxtAttr = pTxtAttr;
1327 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1328 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1333 if( !bRet && SwContentAtPos::SW_REDLINE & rCntntAtPos.eCntntAtPos )
1335 const SwRedline* pRedl = GetDoc()->GetRedline(aPos, NULL);
1336 if( pRedl )
1338 rCntntAtPos.aFnd.pRedl = pRedl;
1339 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_REDLINE;
1340 rCntntAtPos.pFndTxtAttr = 0;
1341 bRet = TRUE;
1343 if( pFldRect && 0 != ( pFrm = pTxtNd->GetFrm( &aPt ) ) )
1344 pFrm->GetCharRect( *pFldRect, aPos, &aTmpState );
1349 if( !bRet && (
1350 SwContentAtPos::SW_TABLEBOXFML & rCntntAtPos.eCntntAtPos
1351 #ifndef PRODUCT
1352 || SwContentAtPos::SW_TABLEBOXVALUE & rCntntAtPos.eCntntAtPos
1353 #endif
1356 const SwTableNode* pTblNd;
1357 const SwTableBox* pBox;
1358 const SwStartNode* pSttNd = pTxtNd->FindTableBoxStartNode();
1359 const SfxPoolItem* pItem;
1360 if( pSttNd && 0 != ( pTblNd = pTxtNd->FindTableNode()) &&
1361 0 != ( pBox = pTblNd->GetTable().GetTblBox(
1362 pSttNd->GetIndex() )) &&
1363 #ifndef PRODUCT
1364 ( SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
1365 RES_BOXATR_FORMULA, FALSE, &pItem ) ||
1366 SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
1367 RES_BOXATR_VALUE, FALSE, &pItem ))
1368 #else
1369 SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState(
1370 RES_BOXATR_FORMULA, FALSE, &pItem )
1371 #endif
1374 SwFrm* pF = pTxtNd->GetFrm( &aPt );
1375 if( pF )
1377 // dann aber den CellFrame
1378 pFrm = (SwCntntFrm*)pF;
1379 while( pF && !pF->IsCellFrm() )
1380 pF = pF->GetUpper();
1383 // es wurde ein
1384 if( aTmpState.bPosCorr )
1386 if( pF && !pF->Frm().IsInside( aPt ))
1387 pF = 0;
1389 else if( !pF )
1390 pF = pFrm;
1392 if( pF ) // nur dann ist es gueltig!!
1394 // erzeuge aus der internen (fuer CORE)
1395 // die externe (fuer UI) Formel
1396 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_TABLEBOXFML;
1397 #ifndef PRODUCT
1398 if( RES_BOXATR_VALUE == pItem->Which() )
1399 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_TABLEBOXVALUE;
1400 else
1401 #endif
1402 ((SwTblBoxFormula*)pItem)->PtrToBoxNm( &pTblNd->GetTable() );
1404 bRet = TRUE;
1405 if( bSetCrsr )
1407 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
1408 SwCrsrSaveState aSaveState( *pCurCrsr );
1409 *pCurCrsr->GetPoint() = aPos;
1410 if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
1411 nsSwCursorSelOverFlags::SELOVER_TOGGLE) )
1412 bRet = FALSE;
1413 else
1414 UpdateCrsr();
1417 if( bRet )
1419 if( pFldRect )
1421 *pFldRect = pF->Prt();
1422 *pFldRect += pF->Frm().Pos();
1424 rCntntAtPos.pFndTxtAttr = 0;
1425 rCntntAtPos.aFnd.pAttr = pItem;
1431 #ifndef PRODUCT
1432 if( !bRet && SwContentAtPos::SW_CURR_ATTRS & rCntntAtPos.eCntntAtPos )
1434 xub_StrLen n = aPos.nContent.GetIndex();
1435 SfxItemSet aSet( GetDoc()->GetAttrPool(), POOLATTR_BEGIN,
1436 POOLATTR_END - 1 );
1437 if( pTxtNd->GetpSwpHints() )
1439 for( USHORT i = 0; i < pTxtNd->GetSwpHints().Count(); ++i )
1441 const SwTxtAttr* pHt = pTxtNd->GetSwpHints()[i];
1442 xub_StrLen nAttrStart = *pHt->GetStart();
1443 if( nAttrStart > n ) // ueber den Bereich hinaus
1444 break;
1446 if( 0 != pHt->GetEnd() && (
1447 ( nAttrStart < n &&
1448 ( pHt->DontExpand() ? n < *pHt->GetEnd()
1449 : n <= *pHt->GetEnd() )) ||
1450 ( n == nAttrStart &&
1451 ( nAttrStart == *pHt->GetEnd() || !n ))) )
1453 aSet.Put( pHt->GetAttr() );
1456 if( pTxtNd->HasSwAttrSet() &&
1457 pTxtNd->GetpSwAttrSet()->Count() )
1459 SfxItemSet aFmtSet( pTxtNd->GetSwAttrSet() );
1460 // aus dem Format-Set alle entfernen, die im TextSet auch gesetzt sind
1461 aFmtSet.Differentiate( aSet );
1462 // jetzt alle zusammen "mergen"
1463 aSet.Put( aFmtSet );
1466 else
1467 pTxtNd->SwCntntNode::GetAttr( aSet );
1469 rCntntAtPos.sStr.AssignAscii(
1470 RTL_CONSTASCII_STRINGPARAM( "Pos: (" ));
1471 rCntntAtPos.sStr += String::CreateFromInt32( aPos.nNode.GetIndex());
1472 rCntntAtPos.sStr += ':';
1473 rCntntAtPos.sStr += String::CreateFromInt32( aPos.nContent.GetIndex());
1474 rCntntAtPos.sStr += ')';
1475 rCntntAtPos.sStr.AppendAscii(
1476 RTL_CONSTASCII_STRINGPARAM( "\nAbs.Vorl.: " ));
1477 rCntntAtPos.sStr += pTxtNd->GetFmtColl()->GetName();
1478 if( pTxtNd->GetCondFmtColl() )
1479 rCntntAtPos.sStr.AppendAscii(
1480 RTL_CONSTASCII_STRINGPARAM( "\nBed.Vorl.: " ))
1481 += pTxtNd->GetCondFmtColl()->GetName();
1483 if( aSet.Count() )
1485 String sAttrs;
1486 SfxItemIter aIter( aSet );
1487 const SfxPoolItem* pItem = aIter.FirstItem();
1488 while( TRUE )
1490 if( !IsInvalidItem( pItem ))
1492 String aStr;
1493 GetDoc()->GetAttrPool().GetPresentation( *pItem,
1494 SFX_ITEM_PRESENTATION_COMPLETE,
1495 SFX_MAPUNIT_CM, aStr );
1496 if( sAttrs.Len() )
1497 sAttrs.AppendAscii(
1498 RTL_CONSTASCII_STRINGPARAM( ", " ));
1499 sAttrs += aStr;
1501 if( aIter.IsAtEnd() )
1502 break;
1503 pItem = aIter.NextItem();
1505 if( sAttrs.Len() )
1507 if( rCntntAtPos.sStr.Len() )
1508 rCntntAtPos.sStr += '\n';
1509 rCntntAtPos.sStr.AppendAscii(
1510 RTL_CONSTASCII_STRINGPARAM( "Attr: " ) )
1511 += sAttrs;
1514 bRet = TRUE;
1515 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_CURR_ATTRS;
1517 #endif
1521 if( !bRet )
1523 rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_NOTHING;
1524 rCntntAtPos.aFnd.pFld = 0;
1526 return bRet;
1529 // --> OD 2008-06-19 #i90516#
1530 const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const
1532 const SwPostItField* pPostItFld = 0;
1534 if ( !IsTableMode() )
1536 const SwPosition* pCursorPos = _GetCrsr()->GetPoint();
1537 const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode();
1538 if ( pTxtNd )
1540 SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
1541 pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD );
1542 const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
1543 if ( pFld && pFld->Which()== RES_POSTITFLD )
1545 pPostItFld = static_cast<const SwPostItField*>(pFld);
1550 return pPostItFld;
1552 // <--
1554 // befindet sich der Node in einem geschuetzten Bereich?
1555 BOOL SwContentAtPos::IsInProtectSect() const
1557 const SwTxtNode* pNd = 0;
1558 if( pFndTxtAttr )
1560 switch( eCntntAtPos )
1562 case SW_FIELD:
1563 case SW_CLICKFIELD:
1564 pNd = ((SwTxtFld*)pFndTxtAttr)->GetpTxtNode();
1565 break;
1567 case SW_FTN:
1568 pNd = &((SwTxtFtn*)pFndTxtAttr)->GetTxtNode();
1569 break;
1571 case SW_INETATTR:
1572 pNd = ((SwTxtINetFmt*)pFndTxtAttr)->GetpTxtNode();
1573 break;
1575 default:
1576 break;
1580 const SwCntntFrm* pFrm;
1581 return pNd && ( pNd->IsInProtectSect() ||
1582 ( 0 != ( pFrm = pNd->GetFrm(0,0,FALSE)) &&
1583 pFrm->IsProtected() ));
1585 bool SwContentAtPos::IsInRTLText()const
1587 bool bRet = false;
1588 const SwTxtNode* pNd = 0;
1589 if (pFndTxtAttr && (eCntntAtPos == SW_FTN))
1591 const SwTxtFtn* pTxtFtn = static_cast<const SwTxtFtn*>(pFndTxtAttr);
1592 if(pTxtFtn->GetStartNode())
1594 SwStartNode* pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode();
1595 SwPaM aTemp( *pSttNd );
1596 aTemp.Move(fnMoveForward, fnGoNode);
1597 SwCntntNode* pCntntNode = aTemp.GetCntntNode();
1598 if(pCntntNode && pCntntNode->IsTxtNode())
1599 pNd = static_cast<SwTxtNode*>(pCntntNode);
1602 if(pNd)
1604 SwClientIter aClientIter( * const_cast<SwTxtNode*>(pNd) );
1605 SwClient* pLast = aClientIter.GoStart();
1606 while( pLast )
1608 if ( pLast->ISA( SwTxtFrm ) )
1610 SwTxtFrm* pTmpFrm = static_cast<SwTxtFrm*>( pLast );
1611 if ( !pTmpFrm->IsFollow())
1613 bRet = pTmpFrm->IsRightToLeft();
1614 break;
1617 pLast = ++aClientIter;
1620 return bRet;
1623 BOOL SwCrsrShell::SelectTxtAttr( USHORT nWhich, BOOL bExpand,
1624 const SwTxtAttr* pTxtAttr )
1626 SET_CURR_SHELL( this );
1627 BOOL bRet = FALSE;
1629 if( !IsTableMode() )
1631 SwPosition& rPos = *pCurCrsr->GetPoint();
1632 if( !pTxtAttr )
1634 SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
1635 pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( rPos.nContent,
1636 nWhich, bExpand ) : 0;
1639 if( pTxtAttr )
1641 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
1642 SwCrsrSaveState aSaveState( *pCurCrsr );
1644 pCurCrsr->DeleteMark();
1645 rPos.nContent = *pTxtAttr->GetStart();
1646 pCurCrsr->SetMark();
1647 const xub_StrLen* pEnd = pTxtAttr->GetEnd();
1648 rPos.nContent = pEnd ? *pEnd : *pTxtAttr->GetStart() + 1;
1650 if( !pCurCrsr->IsSelOvr() )
1652 UpdateCrsr();
1653 bRet = TRUE;
1657 return bRet;
1661 BOOL SwCrsrShell::GotoINetAttr( const SwTxtINetFmt& rAttr )
1663 BOOL bRet = FALSE;
1664 if( rAttr.GetpTxtNode() )
1666 SwCursor* pCrsr = getShellCrsr( true );
1668 SET_CURR_SHELL( this );
1669 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1670 SwCrsrSaveState aSaveState( *pCrsr );
1672 pCrsr->GetPoint()->nNode = *rAttr.GetpTxtNode();
1673 pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)rAttr.GetpTxtNode(),
1674 *rAttr.GetStart() );
1675 bRet = !pCrsr->IsSelOvr();
1676 if( bRet )
1677 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1679 return bRet;
1683 const SwFmtINetFmt* SwCrsrShell::FindINetAttr( const String& rName ) const
1685 return pDoc->FindINetAttr( rName );
1688 BOOL SwCrsrShell::GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode,
1689 SwRect& rRect, sal_Int16& rOrient )
1692 SET_CURR_SHELL( this );
1693 BOOL bRet = FALSE;
1695 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
1697 Point aPt( rPt );
1698 SwPosition aPos( *pCurCrsr->GetPoint() );
1700 SwFillCrsrPos aFPos( eFillMode );
1701 SwCrsrMoveState aTmpState( &aFPos );
1703 if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) &&
1704 !aPos.nNode.GetNode().IsProtect())
1706 // Start-Position im geschuetzten Bereich?
1707 rRect = aFPos.aCrsr;
1708 rOrient = aFPos.eOrient;
1709 bRet = TRUE;
1712 return bRet;
1715 BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
1717 SET_CURR_SHELL( this );
1718 BOOL bRet = FALSE;
1720 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
1722 Point aPt( rPt );
1723 SwPosition aPos( *pCurCrsr->GetPoint() );
1725 SwFillCrsrPos aFPos( eFillMode );
1726 SwCrsrMoveState aTmpState( &aFPos );
1728 if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) )
1730 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen
1731 StartAction();
1733 SwCntntNode* pCNd = aPos.nNode.GetNode().GetCntntNode();
1734 SwUndoId nUndoId = UNDO_INS_FROM_SHADOWCRSR;
1735 // Werden nur die Absatzattribute Adjust oder LRSpace gesetzt,
1736 // dann sollte der naechste Aufruf die NICHT wieder entfernen.
1737 if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
1738 ( FILL_INDENT == aFPos.eMode ||
1739 ( text::HoriOrientation::NONE != aFPos.eOrient &&
1740 0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
1741 pCNd && pCNd->Len() )
1742 nUndoId = UNDO_EMPTY;
1744 GetDoc()->StartUndo( nUndoId, NULL );
1746 SwTxtFmtColl* pNextFmt = 0;
1747 SwTxtNode* pTNd = pCNd->GetTxtNode();
1748 if( pTNd )
1749 pNextFmt = &pTNd->GetTxtColl()->GetNextTxtFmtColl();
1751 const SwSectionNode* pSectNd = pCNd->FindSectionNode();
1752 if( pSectNd && aFPos.nParaCnt )
1754 SwNodeIndex aEnd( aPos.nNode, 1 );
1755 while( aEnd.GetNode().IsEndNode() &&
1756 (const SwNode*)&aEnd.GetNode() !=
1757 pSectNd->EndOfSectionNode() )
1758 aEnd++;
1760 if( aEnd.GetNode().IsEndNode() &&
1761 pCNd->Len() == aPos.nContent.GetIndex() )
1762 aPos.nNode = *pSectNd->EndOfSectionNode();
1765 for( USHORT n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
1767 GetDoc()->AppendTxtNode( aPos );
1768 if( !n && pNextFmt )
1770 *pCurCrsr->GetPoint() = aPos;
1771 GetDoc()->SetTxtFmtColl( *pCurCrsr, pNextFmt, false );
1772 //JP 04.11.97: erstmal keine Folgevorlage der
1773 // Folgevorlage beachten
1774 // pNextFmt = pNextFmt->GetNextTxtFmtColl();
1776 if( n < aFPos.nColumnCnt )
1778 *pCurCrsr->GetPoint() = aPos;
1779 GetDoc()->InsertPoolItem( *pCurCrsr,
1780 SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0);
1784 *pCurCrsr->GetPoint() = aPos;
1785 switch( aFPos.eMode )
1787 case FILL_INDENT:
1788 if( 0 != (pCNd = aPos.nNode.GetNode().GetCntntNode() ))
1790 SfxItemSet aSet( GetDoc()->GetAttrPool(),
1791 RES_LR_SPACE, RES_LR_SPACE,
1792 RES_PARATR_ADJUST, RES_PARATR_ADJUST,
1793 0 );
1794 SvxLRSpaceItem aLR( (SvxLRSpaceItem&)
1795 pCNd->GetAttr( RES_LR_SPACE ) );
1796 aLR.SetTxtLeft( aFPos.nTabCnt );
1797 aLR.SetTxtFirstLineOfst( 0 );
1798 aSet.Put( aLR );
1800 const SvxAdjustItem& rAdj = (SvxAdjustItem&)pCNd->
1801 GetAttr( RES_PARATR_ADJUST );
1802 if( SVX_ADJUST_LEFT != rAdj.GetAdjust() )
1803 aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) );
1805 GetDoc()->InsertItemSet( *pCurCrsr, aSet, 0 );
1807 else {
1808 ASSERT( !this, "wo ist mein CntntNode?" );
1810 break;
1812 case FILL_TAB:
1813 case FILL_SPACE:
1815 String sInsert;
1816 if( aFPos.nTabCnt )
1817 sInsert.Fill( aFPos.nTabCnt, '\t' );
1818 if( aFPos.nSpaceCnt )
1820 String sSpace;
1821 sSpace.Fill( aFPos.nSpaceCnt );
1822 sInsert += sSpace;
1824 if( sInsert.Len() )
1826 GetDoc()->InsertString( *pCurCrsr, sInsert );
1829 // kein break - Ausrichtung muss noch gesetzt werden
1830 case FILL_MARGIN:
1831 if( text::HoriOrientation::NONE != aFPos.eOrient )
1833 SvxAdjustItem aAdj( SVX_ADJUST_LEFT, RES_PARATR_ADJUST );
1834 switch( aFPos.eOrient )
1836 case text::HoriOrientation::CENTER:
1837 aAdj.SetAdjust( SVX_ADJUST_CENTER );
1838 break;
1839 case text::HoriOrientation::RIGHT:
1840 aAdj.SetAdjust( SVX_ADJUST_RIGHT );
1841 break;
1842 default:
1843 break;
1845 GetDoc()->InsertPoolItem( *pCurCrsr, aAdj, 0 );
1847 break;
1850 GetDoc()->EndUndo( nUndoId, NULL );
1851 EndAction();
1853 bRet = TRUE;
1856 return bRet;
1859 const SwRedline* SwCrsrShell::SelNextRedline()
1861 const SwRedline* pFnd = 0;
1862 if( !IsTableMode() )
1864 SET_CURR_SHELL( this );
1865 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1866 SwCrsrSaveState aSaveState( *pCurCrsr );
1868 pFnd = GetDoc()->SelNextRedline( *pCurCrsr );
1869 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1870 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1871 else
1872 pFnd = 0;
1874 return pFnd;
1877 const SwRedline* SwCrsrShell::SelPrevRedline()
1879 const SwRedline* pFnd = 0;
1880 if( !IsTableMode() )
1882 SET_CURR_SHELL( this );
1883 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1884 SwCrsrSaveState aSaveState( *pCurCrsr );
1886 pFnd = GetDoc()->SelPrevRedline( *pCurCrsr );
1887 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1888 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1889 else
1890 pFnd = 0;
1892 return pFnd;
1895 const SwRedline* SwCrsrShell::_GotoRedline( USHORT nArrPos, BOOL bSelect )
1897 const SwRedline* pFnd = 0;
1898 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1899 SwCrsrSaveState aSaveState( *pCurCrsr );
1901 pFnd = GetDoc()->GetRedlineTbl()[ nArrPos ];
1902 if( pFnd )
1904 *pCurCrsr->GetPoint() = *pFnd->Start();
1906 SwCntntNode* pCNd;
1907 SwNodeIndex* pIdx = &pCurCrsr->GetPoint()->nNode;
1908 if( !pIdx->GetNode().IsCntntNode() &&
1909 0 != ( pCNd = GetDoc()->GetNodes().GoNextSection( pIdx,
1910 TRUE, IsReadOnlyAvailable() )) )
1912 if( *pIdx <= pFnd->End()->nNode )
1913 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
1914 else
1915 pFnd = 0;
1918 if( pFnd && bSelect )
1920 pCurCrsr->SetMark();
1921 if( nsRedlineType_t::REDLINE_FMTCOLL == pFnd->GetType() )
1923 pCNd = pIdx->GetNode().GetCntntNode();
1924 pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1925 pCurCrsr->GetMark()->nContent.Assign( pCNd, 0 );
1927 else
1928 *pCurCrsr->GetPoint() = *pFnd->End();
1930 pIdx = &pCurCrsr->GetPoint()->nNode;
1931 if( !pIdx->GetNode().IsCntntNode() &&
1932 0 != ( pCNd = GetDoc()->GetNodes().GoPrevSection( pIdx,
1933 TRUE, IsReadOnlyAvailable() )) )
1935 if( *pIdx >= pCurCrsr->GetMark()->nNode )
1936 pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1937 else
1938 pFnd = 0;
1942 if( !pFnd )
1944 pCurCrsr->DeleteMark();
1945 pCurCrsr->RestoreSavePos();
1947 else if( bSelect && *pCurCrsr->GetMark() == *pCurCrsr->GetPoint() )
1948 pCurCrsr->DeleteMark();
1950 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1951 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE
1952 | SwCrsrShell::READONLY );
1953 else
1955 pFnd = 0;
1956 if( bSelect )
1957 pCurCrsr->DeleteMark();
1960 return pFnd;
1963 const SwRedline* SwCrsrShell::GotoRedline( USHORT nArrPos, BOOL bSelect )
1965 const SwRedline* pFnd = 0;
1966 if( !IsTableMode() )
1968 SET_CURR_SHELL( this );
1970 const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
1971 const SwRedline* pTmp = rTbl[ nArrPos ];
1972 USHORT nSeqNo = pTmp->GetSeqNo();
1973 if( nSeqNo && bSelect )
1975 BOOL bCheck = FALSE;
1976 int nLoopCnt = 2;
1977 USHORT nArrSavPos = nArrPos;
1979 do {
1980 pTmp = _GotoRedline( nArrPos, TRUE );
1982 if( !pFnd )
1983 pFnd = pTmp;
1985 if( pTmp && bCheck )
1987 // checke auf Ueberlappungen. Das kann durch
1988 // FmtColl-Redlines kommen, die auf den gesamten Absatz
1989 // aus gedehnt werden.
1991 SwPaM* pCur = pCurCrsr;
1992 SwPaM* pNextPam = (SwPaM*)pCur->GetNext();
1993 SwPosition* pCStt = pCur->Start(), *pCEnd = pCur->End();
1994 while( pCur != pNextPam )
1996 const SwPosition *pNStt = pNextPam->Start(),
1997 *pNEnd = pNextPam->End();
1999 BOOL bDel = TRUE;
2000 switch( ::ComparePosition( *pCStt, *pCEnd,
2001 *pNStt, *pNEnd ))
2003 case POS_INSIDE: // Pos1 liegt vollstaendig in Pos2
2004 if( !pCur->HasMark() )
2006 pCur->SetMark();
2007 *pCur->GetMark() = *pNStt;
2009 else
2010 *pCStt = *pNStt;
2011 *pCEnd = *pNEnd;
2012 break;
2014 case POS_OUTSIDE: // Pos2 liegt vollstaendig in Pos1
2015 case POS_EQUAL: // Pos1 ist genauso gross wie Pos2
2016 break;
2018 case POS_OVERLAP_BEFORE: // Pos1 ueberlappt Pos2 am Anfang
2019 if( !pCur->HasMark() )
2020 pCur->SetMark();
2021 *pCEnd = *pNEnd;
2022 break;
2023 case POS_OVERLAP_BEHIND: // Pos1 ueberlappt Pos2 am Ende
2024 if( !pCur->HasMark() )
2026 pCur->SetMark();
2027 *pCur->GetMark() = *pNStt;
2029 else
2030 *pCStt = *pNStt;
2031 break;
2033 default:
2034 bDel = FALSE;
2037 if( bDel )
2039 // den brauchen wir nicht mehr
2040 SwPaM* pPrevPam = (SwPaM*)pNextPam->GetPrev();
2041 delete pNextPam;
2042 pNextPam = pPrevPam;
2044 pNextPam = (SwPaM*)pNextPam->GetNext();
2048 USHORT nFndPos = 2 == nLoopCnt
2049 ? rTbl.FindNextOfSeqNo( nArrPos )
2050 : rTbl.FindPrevOfSeqNo( nArrPos );
2051 if( USHRT_MAX != nFndPos ||
2052 ( 0 != ( --nLoopCnt ) && USHRT_MAX != (
2053 nFndPos = rTbl.FindPrevOfSeqNo( nArrSavPos ))) )
2055 if( pTmp )
2057 // neuen Cursor erzeugen
2058 CreateCrsr();
2059 bCheck = TRUE;
2061 nArrPos = nFndPos;
2063 else
2064 nLoopCnt = 0;
2066 } while( nLoopCnt );
2068 else
2069 pFnd = _GotoRedline( nArrPos, bSelect );
2071 return pFnd;
2075 BOOL SwCrsrShell::SelectNxtPrvHyperlink( BOOL bNext )
2077 SwNodes& rNds = GetDoc()->GetNodes();
2078 const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
2079 const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
2080 ULONG nBodySttNdIdx = pBodySttNd->GetIndex();
2081 Point aPt;
2083 _SetGetExpFld aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
2084 _SetGetExpFld aCurPos( bNext ? *pCurCrsr->End() : *pCurCrsr->Start() );
2085 if( aCurPos.GetNode() < nBodySttNdIdx )
2087 const SwCntntNode* pCNd = aCurPos.GetNodeFromCntnt()->GetCntntNode();
2088 SwCntntFrm* pFrm;
2089 if( pCNd && 0 != ( pFrm = pCNd->GetFrm( &aPt )) )
2090 aCurPos.SetBodyPos( *pFrm );
2093 // check first all the hyperlink fields
2095 const SwTxtNode* pTxtNd;
2096 const SwCharFmts* pFmts = GetDoc()->GetCharFmts();
2097 for( USHORT n = pFmts->Count(); 1 < n; )
2099 SwClientIter aIter( *(*pFmts)[ --n ] );
2101 for( SwClient* pFnd = aIter.First(TYPE( SwTxtINetFmt ));
2102 pFnd; pFnd = aIter.Next() )
2103 if( 0 != ( pTxtNd = ((SwTxtINetFmt*)pFnd)->GetpTxtNode()) &&
2104 pTxtNd->GetNodes().IsDocNodes() )
2106 SwTxtINetFmt& rAttr = *(SwTxtINetFmt*)pFnd;
2107 SwPosition aTmpPos( *pTxtNd );
2108 _SetGetExpFld aPos( aTmpPos.nNode, rAttr );
2109 SwCntntFrm* pFrm;
2110 if( pTxtNd->GetIndex() < nBodySttNdIdx &&
2111 0 != ( pFrm = pTxtNd->GetFrm( &aPt )) )
2112 aPos.SetBodyPos( *pFrm );
2114 if( bNext
2115 ? ( aPos < aCmpPos && aCurPos < aPos )
2116 : ( aCmpPos < aPos && aPos < aCurPos ))
2118 String sTxt( pTxtNd->GetExpandTxt( *rAttr.GetStart(),
2119 *rAttr.GetEnd() - *rAttr.GetStart() ) );
2121 sTxt.EraseAllChars( 0x0a );
2122 sTxt.EraseLeadingChars().EraseTrailingChars();
2124 if( sTxt.Len() )
2125 aCmpPos = aPos;
2130 // then check all the Flys with a URL or imapge map
2132 const SwSpzFrmFmts* pFmts = GetDoc()->GetSpzFrmFmts();
2133 for( USHORT n = 0, nEnd = pFmts->Count(); n < nEnd; ++n )
2135 SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)(*pFmts)[ n ];
2136 const SwFmtURL& rURLItem = pFmt->GetURL();
2137 if( rURLItem.GetMap() || rURLItem.GetURL().Len() )
2139 SwFlyFrm* pFly = pFmt->GetFrm( &aPt, FALSE );
2140 SwPosition aTmpPos( *pBodySttNd );
2141 if( pFly &&
2142 GetBodyTxtNode( *GetDoc(), aTmpPos, *pFly->GetLower() ) )
2144 _SetGetExpFld aPos( *pFmt, &aTmpPos );
2146 if( bNext
2147 ? ( aPos < aCmpPos && aCurPos < aPos )
2148 : ( aCmpPos < aPos && aPos < aCurPos ))
2149 aCmpPos = aPos;
2155 // found any URL ?
2156 BOOL bRet = FALSE;
2157 const SwTxtINetFmt* pFndAttr = aCmpPos.GetINetFmt();
2158 const SwFlyFrmFmt* pFndFmt = aCmpPos.GetFlyFmt();
2159 if( pFndAttr || pFndFmt )
2161 SET_CURR_SHELL( this );
2162 SwCallLink aLk( *this );
2164 // find a text attribute ?
2165 if( pFndAttr )
2167 SwCrsrSaveState aSaveState( *pCurCrsr );
2169 aCmpPos.GetPosOfContent( *pCurCrsr->GetPoint() );
2170 pCurCrsr->DeleteMark();
2171 pCurCrsr->SetMark();
2172 pCurCrsr->GetPoint()->nContent = *pFndAttr->SwTxtAttr::GetEnd();
2174 if( !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
2176 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|
2177 SwCrsrShell::READONLY );
2178 bRet = TRUE;
2181 // find a draw object ?
2182 else if( RES_DRAWFRMFMT == pFndFmt->Which() )
2184 const SdrObject* pSObj = pFndFmt->FindSdrObject();
2185 ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
2186 MakeSelVisible();
2187 bRet = TRUE;
2189 else // then is it a fly
2191 SwFlyFrm* pFly = pFndFmt->GetFrm(&aPt, FALSE );
2192 if( pFly )
2194 ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE );
2195 MakeSelVisible();
2196 bRet = TRUE;
2200 return bRet;