update dev300-m58
[ooovba.git] / sw / source / core / crsr / crstrvl.cxx
blob9ff996a8c71805af71197dd3e47845e4548a4fb2
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->GetTxtAttr( aPos.nContent.GetIndex(),
1128 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->GetTxtAttr(
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 =
1541 pTxtNd->GetTxtAttr( pCursorPos->nContent.GetIndex(),
1542 RES_TXTATR_FIELD );
1543 const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
1544 if ( pFld && pFld->Which()== RES_POSTITFLD )
1546 pPostItFld = static_cast<const SwPostItField*>(pFld);
1551 return pPostItFld;
1553 // <--
1555 // befindet sich der Node in einem geschuetzten Bereich?
1556 BOOL SwContentAtPos::IsInProtectSect() const
1558 const SwTxtNode* pNd = 0;
1559 if( pFndTxtAttr )
1561 switch( eCntntAtPos )
1563 case SW_FIELD:
1564 case SW_CLICKFIELD:
1565 pNd = ((SwTxtFld*)pFndTxtAttr)->GetpTxtNode();
1566 break;
1568 case SW_FTN:
1569 pNd = &((SwTxtFtn*)pFndTxtAttr)->GetTxtNode();
1570 break;
1572 case SW_INETATTR:
1573 pNd = ((SwTxtINetFmt*)pFndTxtAttr)->GetpTxtNode();
1574 break;
1576 default:
1577 break;
1581 const SwCntntFrm* pFrm;
1582 return pNd && ( pNd->IsInProtectSect() ||
1583 ( 0 != ( pFrm = pNd->GetFrm(0,0,FALSE)) &&
1584 pFrm->IsProtected() ));
1586 bool SwContentAtPos::IsInRTLText()const
1588 bool bRet = false;
1589 const SwTxtNode* pNd = 0;
1590 if (pFndTxtAttr && (eCntntAtPos == SW_FTN))
1592 const SwTxtFtn* pTxtFtn = static_cast<const SwTxtFtn*>(pFndTxtAttr);
1593 if(pTxtFtn->GetStartNode())
1595 SwStartNode* pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode();
1596 SwPaM aTemp( *pSttNd );
1597 aTemp.Move(fnMoveForward, fnGoNode);
1598 SwCntntNode* pCntntNode = aTemp.GetCntntNode();
1599 if(pCntntNode && pCntntNode->IsTxtNode())
1600 pNd = static_cast<SwTxtNode*>(pCntntNode);
1603 if(pNd)
1605 SwClientIter aClientIter( * const_cast<SwTxtNode*>(pNd) );
1606 SwClient* pLast = aClientIter.GoStart();
1607 while( pLast )
1609 if ( pLast->ISA( SwTxtFrm ) )
1611 SwTxtFrm* pTmpFrm = static_cast<SwTxtFrm*>( pLast );
1612 if ( !pTmpFrm->IsFollow())
1614 bRet = pTmpFrm->IsRightToLeft();
1615 break;
1618 pLast = ++aClientIter;
1621 return bRet;
1624 BOOL SwCrsrShell::SelectTxtAttr( USHORT nWhich, BOOL bExpand,
1625 const SwTxtAttr* pTxtAttr )
1627 SET_CURR_SHELL( this );
1628 BOOL bRet = FALSE;
1630 if( !IsTableMode() )
1632 SwPosition& rPos = *pCurCrsr->GetPoint();
1633 if( !pTxtAttr )
1635 SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
1636 pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( rPos.nContent,
1637 nWhich, bExpand ) : 0;
1640 if( pTxtAttr )
1642 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen,
1643 SwCrsrSaveState aSaveState( *pCurCrsr );
1645 pCurCrsr->DeleteMark();
1646 rPos.nContent = *pTxtAttr->GetStart();
1647 pCurCrsr->SetMark();
1648 const xub_StrLen* pEnd = pTxtAttr->GetEnd();
1649 rPos.nContent = pEnd ? *pEnd : *pTxtAttr->GetStart() + 1;
1651 if( !pCurCrsr->IsSelOvr() )
1653 UpdateCrsr();
1654 bRet = TRUE;
1658 return bRet;
1662 BOOL SwCrsrShell::GotoINetAttr( const SwTxtINetFmt& rAttr )
1664 BOOL bRet = FALSE;
1665 if( rAttr.GetpTxtNode() )
1667 SwCursor* pCrsr = getShellCrsr( true );
1669 SET_CURR_SHELL( this );
1670 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1671 SwCrsrSaveState aSaveState( *pCrsr );
1673 pCrsr->GetPoint()->nNode = *rAttr.GetpTxtNode();
1674 pCrsr->GetPoint()->nContent.Assign( (SwTxtNode*)rAttr.GetpTxtNode(),
1675 *rAttr.GetStart() );
1676 bRet = !pCrsr->IsSelOvr();
1677 if( bRet )
1678 UpdateCrsr(SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1680 return bRet;
1684 const SwFmtINetFmt* SwCrsrShell::FindINetAttr( const String& rName ) const
1686 return pDoc->FindINetAttr( rName );
1689 BOOL SwCrsrShell::GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode,
1690 SwRect& rRect, sal_Int16& rOrient )
1693 SET_CURR_SHELL( this );
1694 BOOL bRet = FALSE;
1696 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
1698 Point aPt( rPt );
1699 SwPosition aPos( *pCurCrsr->GetPoint() );
1701 SwFillCrsrPos aFPos( eFillMode );
1702 SwCrsrMoveState aTmpState( &aFPos );
1704 if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) &&
1705 !aPos.nNode.GetNode().IsProtect())
1707 // Start-Position im geschuetzten Bereich?
1708 rRect = aFPos.aCrsr;
1709 rOrient = aFPos.eOrient;
1710 bRet = TRUE;
1713 return bRet;
1716 BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
1718 SET_CURR_SHELL( this );
1719 BOOL bRet = FALSE;
1721 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
1723 Point aPt( rPt );
1724 SwPosition aPos( *pCurCrsr->GetPoint() );
1726 SwFillCrsrPos aFPos( eFillMode );
1727 SwCrsrMoveState aTmpState( &aFPos );
1729 if( GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState ) )
1731 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen
1732 StartAction();
1734 SwCntntNode* pCNd = aPos.nNode.GetNode().GetCntntNode();
1735 SwUndoId nUndoId = UNDO_INS_FROM_SHADOWCRSR;
1736 // Werden nur die Absatzattribute Adjust oder LRSpace gesetzt,
1737 // dann sollte der naechste Aufruf die NICHT wieder entfernen.
1738 if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
1739 ( FILL_INDENT == aFPos.eMode ||
1740 ( text::HoriOrientation::NONE != aFPos.eOrient &&
1741 0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
1742 pCNd && pCNd->Len() )
1743 nUndoId = UNDO_EMPTY;
1745 GetDoc()->StartUndo( nUndoId, NULL );
1747 SwTxtFmtColl* pNextFmt = 0;
1748 SwTxtNode* pTNd = pCNd->GetTxtNode();
1749 if( pTNd )
1750 pNextFmt = &pTNd->GetTxtColl()->GetNextTxtFmtColl();
1752 const SwSectionNode* pSectNd = pCNd->FindSectionNode();
1753 if( pSectNd && aFPos.nParaCnt )
1755 SwNodeIndex aEnd( aPos.nNode, 1 );
1756 while( aEnd.GetNode().IsEndNode() &&
1757 (const SwNode*)&aEnd.GetNode() !=
1758 pSectNd->EndOfSectionNode() )
1759 aEnd++;
1761 if( aEnd.GetNode().IsEndNode() &&
1762 pCNd->Len() == aPos.nContent.GetIndex() )
1763 aPos.nNode = *pSectNd->EndOfSectionNode();
1766 for( USHORT n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
1768 GetDoc()->AppendTxtNode( aPos );
1769 if( !n && pNextFmt )
1771 *pCurCrsr->GetPoint() = aPos;
1772 GetDoc()->SetTxtFmtColl( *pCurCrsr, pNextFmt, false );
1773 //JP 04.11.97: erstmal keine Folgevorlage der
1774 // Folgevorlage beachten
1775 // pNextFmt = pNextFmt->GetNextTxtFmtColl();
1777 if( n < aFPos.nColumnCnt )
1779 *pCurCrsr->GetPoint() = aPos;
1780 GetDoc()->Insert( *pCurCrsr,
1781 SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0);
1785 *pCurCrsr->GetPoint() = aPos;
1786 switch( aFPos.eMode )
1788 case FILL_INDENT:
1789 if( 0 != (pCNd = aPos.nNode.GetNode().GetCntntNode() ))
1791 SfxItemSet aSet( GetDoc()->GetAttrPool(),
1792 RES_LR_SPACE, RES_LR_SPACE,
1793 RES_PARATR_ADJUST, RES_PARATR_ADJUST,
1794 0 );
1795 SvxLRSpaceItem aLR( (SvxLRSpaceItem&)
1796 pCNd->GetAttr( RES_LR_SPACE ) );
1797 aLR.SetTxtLeft( aFPos.nTabCnt );
1798 aLR.SetTxtFirstLineOfst( 0 );
1799 aSet.Put( aLR );
1801 const SvxAdjustItem& rAdj = (SvxAdjustItem&)pCNd->
1802 GetAttr( RES_PARATR_ADJUST );
1803 if( SVX_ADJUST_LEFT != rAdj.GetAdjust() )
1804 aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) );
1806 GetDoc()->Insert( *pCurCrsr, aSet, 0 );
1808 else {
1809 ASSERT( !this, "wo ist mein CntntNode?" );
1811 break;
1813 case FILL_TAB:
1814 case FILL_SPACE:
1816 String sInsert;
1817 if( aFPos.nTabCnt )
1818 sInsert.Fill( aFPos.nTabCnt, '\t' );
1819 if( aFPos.nSpaceCnt )
1821 String sSpace;
1822 sSpace.Fill( aFPos.nSpaceCnt );
1823 sInsert += sSpace;
1825 if( sInsert.Len() )
1826 GetDoc()->Insert( *pCurCrsr, sInsert, true );
1828 // kein break - Ausrichtung muss noch gesetzt werden
1829 case FILL_MARGIN:
1830 if( text::HoriOrientation::NONE != aFPos.eOrient )
1832 SvxAdjustItem aAdj( SVX_ADJUST_LEFT, RES_PARATR_ADJUST );
1833 switch( aFPos.eOrient )
1835 case text::HoriOrientation::CENTER:
1836 aAdj.SetAdjust( SVX_ADJUST_CENTER );
1837 break;
1838 case text::HoriOrientation::RIGHT:
1839 aAdj.SetAdjust( SVX_ADJUST_RIGHT );
1840 break;
1841 default:
1842 break;
1844 GetDoc()->Insert( *pCurCrsr, aAdj, 0 );
1846 break;
1849 GetDoc()->EndUndo( nUndoId, NULL );
1850 EndAction();
1852 bRet = TRUE;
1855 return bRet;
1858 const SwRedline* SwCrsrShell::SelNextRedline()
1860 const SwRedline* pFnd = 0;
1861 if( !IsTableMode() )
1863 SET_CURR_SHELL( this );
1864 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1865 SwCrsrSaveState aSaveState( *pCurCrsr );
1867 pFnd = GetDoc()->SelNextRedline( *pCurCrsr );
1868 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1869 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1870 else
1871 pFnd = 0;
1873 return pFnd;
1876 const SwRedline* SwCrsrShell::SelPrevRedline()
1878 const SwRedline* pFnd = 0;
1879 if( !IsTableMode() )
1881 SET_CURR_SHELL( this );
1882 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1883 SwCrsrSaveState aSaveState( *pCurCrsr );
1885 pFnd = GetDoc()->SelPrevRedline( *pCurCrsr );
1886 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1887 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
1888 else
1889 pFnd = 0;
1891 return pFnd;
1894 const SwRedline* SwCrsrShell::_GotoRedline( USHORT nArrPos, BOOL bSelect )
1896 const SwRedline* pFnd = 0;
1897 SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
1898 SwCrsrSaveState aSaveState( *pCurCrsr );
1900 pFnd = GetDoc()->GetRedlineTbl()[ nArrPos ];
1901 if( pFnd )
1903 *pCurCrsr->GetPoint() = *pFnd->Start();
1905 SwCntntNode* pCNd;
1906 SwNodeIndex* pIdx = &pCurCrsr->GetPoint()->nNode;
1907 if( !pIdx->GetNode().IsCntntNode() &&
1908 0 != ( pCNd = GetDoc()->GetNodes().GoNextSection( pIdx,
1909 TRUE, IsReadOnlyAvailable() )) )
1911 if( *pIdx <= pFnd->End()->nNode )
1912 pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
1913 else
1914 pFnd = 0;
1917 if( pFnd && bSelect )
1919 pCurCrsr->SetMark();
1920 if( nsRedlineType_t::REDLINE_FMTCOLL == pFnd->GetType() )
1922 pCNd = pIdx->GetNode().GetCntntNode();
1923 pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1924 pCurCrsr->GetMark()->nContent.Assign( pCNd, 0 );
1926 else
1927 *pCurCrsr->GetPoint() = *pFnd->End();
1929 pIdx = &pCurCrsr->GetPoint()->nNode;
1930 if( !pIdx->GetNode().IsCntntNode() &&
1931 0 != ( pCNd = GetDoc()->GetNodes().GoPrevSection( pIdx,
1932 TRUE, IsReadOnlyAvailable() )) )
1934 if( *pIdx >= pCurCrsr->GetMark()->nNode )
1935 pCurCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1936 else
1937 pFnd = 0;
1941 if( !pFnd )
1943 pCurCrsr->DeleteMark();
1944 pCurCrsr->RestoreSavePos();
1946 else if( bSelect && *pCurCrsr->GetMark() == *pCurCrsr->GetPoint() )
1947 pCurCrsr->DeleteMark();
1949 if( pFnd && !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
1950 UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE
1951 | SwCrsrShell::READONLY );
1952 else
1954 pFnd = 0;
1955 if( bSelect )
1956 pCurCrsr->DeleteMark();
1959 return pFnd;
1962 const SwRedline* SwCrsrShell::GotoRedline( USHORT nArrPos, BOOL bSelect )
1964 const SwRedline* pFnd = 0;
1965 if( !IsTableMode() )
1967 SET_CURR_SHELL( this );
1969 const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
1970 const SwRedline* pTmp = rTbl[ nArrPos ];
1971 USHORT nSeqNo = pTmp->GetSeqNo();
1972 if( nSeqNo && bSelect )
1974 BOOL bCheck = FALSE;
1975 int nLoopCnt = 2;
1976 USHORT nArrSavPos = nArrPos;
1978 do {
1979 pTmp = _GotoRedline( nArrPos, TRUE );
1981 if( !pFnd )
1982 pFnd = pTmp;
1984 if( pTmp && bCheck )
1986 // checke auf Ueberlappungen. Das kann durch
1987 // FmtColl-Redlines kommen, die auf den gesamten Absatz
1988 // aus gedehnt werden.
1990 SwPaM* pCur = pCurCrsr;
1991 SwPaM* pNextPam = (SwPaM*)pCur->GetNext();
1992 SwPosition* pCStt = pCur->Start(), *pCEnd = pCur->End();
1993 while( pCur != pNextPam )
1995 const SwPosition *pNStt = pNextPam->Start(),
1996 *pNEnd = pNextPam->End();
1998 BOOL bDel = TRUE;
1999 switch( ::ComparePosition( *pCStt, *pCEnd,
2000 *pNStt, *pNEnd ))
2002 case POS_INSIDE: // Pos1 liegt vollstaendig in Pos2
2003 if( !pCur->HasMark() )
2005 pCur->SetMark();
2006 *pCur->GetMark() = *pNStt;
2008 else
2009 *pCStt = *pNStt;
2010 *pCEnd = *pNEnd;
2011 break;
2013 case POS_OUTSIDE: // Pos2 liegt vollstaendig in Pos1
2014 case POS_EQUAL: // Pos1 ist genauso gross wie Pos2
2015 break;
2017 case POS_OVERLAP_BEFORE: // Pos1 ueberlappt Pos2 am Anfang
2018 if( !pCur->HasMark() )
2019 pCur->SetMark();
2020 *pCEnd = *pNEnd;
2021 break;
2022 case POS_OVERLAP_BEHIND: // Pos1 ueberlappt Pos2 am Ende
2023 if( !pCur->HasMark() )
2025 pCur->SetMark();
2026 *pCur->GetMark() = *pNStt;
2028 else
2029 *pCStt = *pNStt;
2030 break;
2032 default:
2033 bDel = FALSE;
2036 if( bDel )
2038 // den brauchen wir nicht mehr
2039 SwPaM* pPrevPam = (SwPaM*)pNextPam->GetPrev();
2040 delete pNextPam;
2041 pNextPam = pPrevPam;
2043 pNextPam = (SwPaM*)pNextPam->GetNext();
2047 USHORT nFndPos = 2 == nLoopCnt
2048 ? rTbl.FindNextOfSeqNo( nArrPos )
2049 : rTbl.FindPrevOfSeqNo( nArrPos );
2050 if( USHRT_MAX != nFndPos ||
2051 ( 0 != ( --nLoopCnt ) && USHRT_MAX != (
2052 nFndPos = rTbl.FindPrevOfSeqNo( nArrSavPos ))) )
2054 if( pTmp )
2056 // neuen Cursor erzeugen
2057 CreateCrsr();
2058 bCheck = TRUE;
2060 nArrPos = nFndPos;
2062 else
2063 nLoopCnt = 0;
2065 } while( nLoopCnt );
2067 else
2068 pFnd = _GotoRedline( nArrPos, bSelect );
2070 return pFnd;
2074 BOOL SwCrsrShell::SelectNxtPrvHyperlink( BOOL bNext )
2076 SwNodes& rNds = GetDoc()->GetNodes();
2077 const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
2078 const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
2079 ULONG nBodySttNdIdx = pBodySttNd->GetIndex();
2080 Point aPt;
2082 _SetGetExpFld aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
2083 _SetGetExpFld aCurPos( bNext ? *pCurCrsr->End() : *pCurCrsr->Start() );
2084 if( aCurPos.GetNode() < nBodySttNdIdx )
2086 const SwCntntNode* pCNd = aCurPos.GetNodeFromCntnt()->GetCntntNode();
2087 SwCntntFrm* pFrm;
2088 if( pCNd && 0 != ( pFrm = pCNd->GetFrm( &aPt )) )
2089 aCurPos.SetBodyPos( *pFrm );
2092 // check first all the hyperlink fields
2094 const SwTxtNode* pTxtNd;
2095 const SwCharFmts* pFmts = GetDoc()->GetCharFmts();
2096 for( USHORT n = pFmts->Count(); 1 < n; )
2098 SwClientIter aIter( *(*pFmts)[ --n ] );
2100 for( SwClient* pFnd = aIter.First(TYPE( SwTxtINetFmt ));
2101 pFnd; pFnd = aIter.Next() )
2102 if( 0 != ( pTxtNd = ((SwTxtINetFmt*)pFnd)->GetpTxtNode()) &&
2103 pTxtNd->GetNodes().IsDocNodes() )
2105 SwTxtINetFmt& rAttr = *(SwTxtINetFmt*)pFnd;
2106 SwPosition aTmpPos( *pTxtNd );
2107 _SetGetExpFld aPos( aTmpPos.nNode, rAttr );
2108 SwCntntFrm* pFrm;
2109 if( pTxtNd->GetIndex() < nBodySttNdIdx &&
2110 0 != ( pFrm = pTxtNd->GetFrm( &aPt )) )
2111 aPos.SetBodyPos( *pFrm );
2113 if( bNext
2114 ? ( aPos < aCmpPos && aCurPos < aPos )
2115 : ( aCmpPos < aPos && aPos < aCurPos ))
2117 String sTxt( pTxtNd->GetExpandTxt( *rAttr.GetStart(),
2118 *rAttr.GetEnd() - *rAttr.GetStart() ) );
2120 sTxt.EraseAllChars( 0x0a );
2121 sTxt.EraseLeadingChars().EraseTrailingChars();
2123 if( sTxt.Len() )
2124 aCmpPos = aPos;
2129 // then check all the Flys with a URL or imapge map
2131 const SwSpzFrmFmts* pFmts = GetDoc()->GetSpzFrmFmts();
2132 for( USHORT n = 0, nEnd = pFmts->Count(); n < nEnd; ++n )
2134 SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)(*pFmts)[ n ];
2135 const SwFmtURL& rURLItem = pFmt->GetURL();
2136 if( rURLItem.GetMap() || rURLItem.GetURL().Len() )
2138 SwFlyFrm* pFly = pFmt->GetFrm( &aPt, FALSE );
2139 SwPosition aTmpPos( *pBodySttNd );
2140 if( pFly &&
2141 GetBodyTxtNode( *GetDoc(), aTmpPos, *pFly->GetLower() ) )
2143 _SetGetExpFld aPos( *pFmt, &aTmpPos );
2145 if( bNext
2146 ? ( aPos < aCmpPos && aCurPos < aPos )
2147 : ( aCmpPos < aPos && aPos < aCurPos ))
2148 aCmpPos = aPos;
2154 // found any URL ?
2155 BOOL bRet = FALSE;
2156 const SwTxtINetFmt* pFndAttr = aCmpPos.GetINetFmt();
2157 const SwFlyFrmFmt* pFndFmt = aCmpPos.GetFlyFmt();
2158 if( pFndAttr || pFndFmt )
2160 SET_CURR_SHELL( this );
2161 SwCallLink aLk( *this );
2163 // find a text attribute ?
2164 if( pFndAttr )
2166 SwCrsrSaveState aSaveState( *pCurCrsr );
2168 aCmpPos.GetPosOfContent( *pCurCrsr->GetPoint() );
2169 pCurCrsr->DeleteMark();
2170 pCurCrsr->SetMark();
2171 pCurCrsr->GetPoint()->nContent = *pFndAttr->SwTxtAttr::GetEnd();
2173 if( !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() )
2175 UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|
2176 SwCrsrShell::READONLY );
2177 bRet = TRUE;
2180 // find a draw object ?
2181 else if( RES_DRAWFRMFMT == pFndFmt->Which() )
2183 const SdrObject* pSObj = pFndFmt->FindSdrObject();
2184 ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
2185 MakeSelVisible();
2186 bRet = TRUE;
2188 else // then is it a fly
2190 SwFlyFrm* pFly = pFndFmt->GetFrm(&aPt, FALSE );
2191 if( pFly )
2193 ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE );
2194 MakeSelVisible();
2195 bRet = TRUE;
2199 return bRet;