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 $
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>
45 #include <pagefrm.hxx>
47 #include <rootfrm.hxx>
51 #include <swtable.hxx> // SwTxtFld
56 #include <txtinet.hxx>
57 #include <fmtinfmt.hxx>
58 #include <txttxmrk.hxx>
67 #include <flddat.hxx> // SwTxtFld
68 #include <cellatr.hxx>
70 #include <redline.hxx>
71 #include <fmtcntnt.hxx>
72 #include <fmthdft.hxx>
73 #include <pagedesc.hxx>
75 #include <charfmt.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() );
92 SwCallLink
aLk( *this ); // Crsr-Moves ueberwachen,
93 SwCrsrSaveState
aSaveState( *pCurCrsr
);
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() );
104 if( pFrm
->IsVertical() )
106 aPt
.X() = aCharRect
.Center().X();
107 aPt
.Y() = pFrm
->Frm().Top() + nUpDownX
;
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
);
118 UpdateCrsr(SwCrsrShell::UPDOWN
|
119 SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
120 SwCrsrShell::READONLY
);
127 BOOL
SwCrsrShell::GotoPrevNum()
129 BOOL bRet
= GetDoc()->GotoPrevNum( *pCurCrsr
->GetPoint() );
132 SwCallLink
aLk( *this ); // Crsr-Moves ueberwachen,
133 SwCrsrSaveState
aSaveState( *pCurCrsr
);
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() );
144 if( pFrm
->IsVertical() )
146 aPt
.X() = aCharRect
.Center().X();
147 aPt
.Y() = pFrm
->Frm().Top() + nUpDownX
;
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
);
158 UpdateCrsr(SwCrsrShell::UPDOWN
|
159 SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
160 SwCrsrShell::READONLY
);
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();
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
);
184 Point
aPt( pFrm
->Frm().Pos() + pFrm
->Prt().Pos() );
185 pFrm
->GetCrsrOfst( pTmpCrsr
->GetPoint(), aPt
);
186 if( !pTmpCrsr
->IsSelOvr() )
195 // springe aus dem Content zum Footer
197 BOOL
SwCrsrShell::GotoFooterTxt()
199 const SwPageFrm
* pFrm
= GetCurrFrm()->FindPageFrm();
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();
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
);
218 Point
aPt( pLower
->Frm().Pos() + pLower
->Prt().Pos() );
219 pLower
->GetCrsrOfst( pTmpCrsr
->GetPoint(), aPt
);
220 if( !pTmpCrsr
->IsSelOvr() )
233 BOOL
SwCrsrShell::SetCrsrInHdFt( USHORT nDescNo
, BOOL bInHeader
)
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();
245 for( USHORT i
= 0; i
< pMyDoc
->GetPageDescCnt(); ++i
)
246 if( pPage
->GetPageDesc() ==
247 &const_cast<const SwDoc
*>(pMyDoc
)->GetPageDesc( i
) )
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;
262 // gespiegelte Seiten??? erstmal nicht beachten
263 const SwFmtHeader
& rHd
= rDesc
.GetMaster().GetHeader();
264 if( rHd
.GetHeaderFmt() )
265 pCnt
= &rHd
.GetHeaderFmt()->GetCntnt();
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();
279 pCNd
= pMyDoc
->GetNodes().GoNext( &aIdx
);
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
);
292 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
294 rPos
.nContent
.Assign( pCNd
, 0 );
296 bRet
= !pCurCrsr
->IsSelOvr();
298 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
299 SwCrsrShell::READONLY
);
306 // springe zum naechsten Verzeichnis
308 BOOL
SwCrsrShell::GotoNextTOXBase( const String
* pName
)
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();
331 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
332 const SwCntntFrm
* pCFrm
;
334 pCNd
->EndOfSectionIndex() <= pSectNd
->EndOfSectionIndex() &&
335 0 != ( pCFrm
= pCNd
->GetFrm() ) &&
336 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
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();
350 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
355 // springe zum vorherigen Verzeichnis
358 BOOL
SwCrsrShell::GotoPrevTOXBase( const String
* pName
)
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();
381 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
382 const SwCntntFrm
* pCFrm
;
384 pCNd
->EndOfSectionIndex() <= pSectNd
->EndOfSectionIndex() &&
385 0 != ( pCFrm
= pCNd
->GetFrm() ) &&
386 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
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();
401 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
406 // springe zum Verzeichnis vom TOXMark
408 BOOL
SwCrsrShell::GotoTOXMarkBase()
413 USHORT nCnt
= GetDoc()->GetCurTOXMark( *pCurCrsr
->GetPoint(), aMarks
);
416 // dann nehme den 1. und hole den Verzeichnis-Typ.
417 // Suche in seiner Abhaengigkeitsliste nach dem eigentlichem
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();
434 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
435 const SwCntntFrm
* pCFrm
;
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();
448 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
457 // springe zur naechsten (vorherigen) Tabellenformel
458 // optional auch nur zu kaputten Formeln springen
459 BOOL
SwCrsrShell::GotoNxtPrvTblFormula( BOOL bNext
, BOOL bOnlyErrors
)
465 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
468 SwPosition
aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
471 _SetGetExpFld
aFndGEF( aFndPos
), aCurGEF( rPos
);
474 const SwNode
* pSttNd
= rPos
.nNode
.GetNode().FindTableBoxStartNode();
477 const SwTableBox
* pTBox
= pSttNd
->FindTableNode()->GetTable().
478 GetTblBox( pSttNd
->GetIndex() );
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() ) &&
499 pTBox
->GetSttNd()->GetNodes().IsDocNodes() &&
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
))
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();
533 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
534 SwCrsrShell::READONLY
);
539 // springe zum naechsten (vorherigen) Verzeichniseintrag
540 BOOL
SwCrsrShell::GotoNxtPrvTOXMark( BOOL bNext
)
546 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
549 SwPosition
aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
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
))
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();
597 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
598 SwCrsrShell::READONLY
);
603 /*--------------------------------------------------------------------
604 Beschreibung: Traveling zwischen Markierungen
605 --------------------------------------------------------------------*/
607 const SwTOXMark
& SwCrsrShell::GotoTOXMark( const SwTOXMark
& rStart
,
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() );
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
);
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
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
))
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
);
661 BOOL
SwCrsrShell::MoveFldType( const SwFieldType
* pFldType
, BOOL bNext
,
662 USHORT nSubType
, USHORT nResType
)
664 // sortierte Liste aller Felder
665 _SetGetExpFlds
aSrtLst( 64 );
669 if( RES_INPUTFLD
!= pFldType
->Which() && !pFldType
->GetDepends() )
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
);
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() )
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
,
718 BOOL bDelFld
= 0 == pTxtFld
;
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!
733 aSrch
.SetBodyPos( *pTNd
->GetFrm( &aPt
, &rPos
, FALSE
) );
736 BOOL bFound
= aSrtLst
.Seek_Entry( &aSrch
, &nPos
);
739 delete (SwFmtFld
*)&pTxtFld
->GetAttr();
743 if( bFound
) // stehe auf einem ?
747 if( ++nPos
>= aSrtLst
.Count() )
748 return FALSE
; // schon am Ende
751 return FALSE
; // weiter nach vorne geht nicht
753 else if( bNext
? nPos
>= aSrtLst
.Count() : !nPos
--)
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
);
767 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
772 BOOL
SwCrsrShell::GotoFld( const SwFmtFld
& rFld
)
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();
789 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
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
);
822 if( pDoc
->GotoOutline( *pCrsr
->GetPoint(), rName
) && !pCrsr
->IsSelOvr() )
824 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
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();
839 if( rNds
.GetOutLineNds().Seek_Entry( pNd
, &nPos
))
842 if( nPos
== rNds
.GetOutLineNds().Count() )
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();
855 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
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();
867 rNds
.GetOutLineNds().Seek_Entry( pNd
, &nPos
);
874 pNd
= rNds
.GetOutLineNds()[ nPos
];
875 if( pNd
->GetIndex() > pCrsr
->GetPoint()->nNode
.GetIndex() )
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();
886 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
892 // suche die "Outline-Position" vom vorherigen Outline-Node mit dem
894 USHORT
SwCrsrShell::GetOutlinePos( BYTE nLevel
)
896 SwPaM
* pCrsr
= getShellCrsr( true );
897 const SwNodes
& rNds
= GetDoc()->GetNodes();
899 SwNode
* pNd
= pCrsr
->GetNode();
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
913 return USHRT_MAX
; // davor keiner mehr also Ende
917 BOOL
SwCrsrShell::MakeOutlineSel( USHORT nSttPos
, USHORT nEndPos
,
920 const SwNodes
& rNds
= GetDoc()->GetNodes();
921 const SwOutlineNodes
& rOutlNds
= rNds
.GetOutLineNds();
922 if( !rOutlNds
.Count() ) // wie jetzt ???
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
;
936 SwNode
* pSttNd
= rOutlNds
[ nSttPos
];
937 SwNode
* pEndNd
= rOutlNds
[ nEndPos
];
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();
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 );
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();
973 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
978 // springe zu dieser Refmark
979 BOOL
SwCrsrShell::GotoRefMark( const String
& rRefMark
, USHORT nSubType
,
982 SET_CURR_SHELL( this );
983 SwCallLink
aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen
984 SwCrsrSaveState
aSaveState( *pCurCrsr
);
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
);
1003 BOOL
SwCrsrShell::IsPageAtPos( const Point
&rPt
) const
1006 return 0 != GetLayout()->GetPageAtPos( rPt
);
1010 BOOL
SwCrsrShell::GetContentAtPos( const Point
& rPt
,
1011 SwContentAtPos
& rCntntAtPos
,
1015 SET_CURR_SHELL( this );
1018 if( !IsTableMode() )
1021 SwPosition
aPos( *pCurCrsr
->GetPoint() );
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
) ?
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);
1046 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_OUTLINE
;
1047 rCntntAtPos
.sStr
= pONd
->GetExpandTxt( 0, STRING_LEN
, true );
1051 // --> FME 2005-05-13 #i43742# New function: SW_CONTENT_CHECK
1052 else if ( SwContentAtPos::SW_CONTENT_CHECK
& rCntntAtPos
.eCntntAtPos
&&
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
);
1087 nCurrent
= aTmpState
.pSpecialPos
->nCharOfst
;
1089 if ( pSubList
->InWrongWord( nCurrent
, nLen
) )
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
) )
1109 // rCntntAtPos.sStr = pTxtNd->GetExpandTxt(
1110 // *pTxtAttr->GetStart(),
1111 // *pTxtAttr->GetEnd() - *pTxtAttr->GetStart(),
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()
1132 if( SwContentAtPos::SW_CLICKFIELD
& rCntntAtPos
.eCntntAtPos
&&
1133 pFld
&& !pFld
->HasClickHdl() )
1138 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->GetFrm( &aPt
) ) )
1139 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
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() )
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() );
1171 rCntntAtPos
.aFnd
.pFld
= pFld
;
1172 rCntntAtPos
.pFndTxtAttr
= pTxtAttr
;
1173 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FIELD
;
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
;
1189 if( !bRet
&& SwContentAtPos::SW_FTN
& rCntntAtPos
.eCntntAtPos
)
1191 if( aTmpState
.bFtnNoInfo
)
1193 // stehe ueber dem Zeichen der Fussnote (??)
1197 *pCurCrsr
->GetPoint() = aPos
;
1198 if( !GotoFtnAnchor() )
1202 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FTN
;
1204 else if ( 0 != ( pTxtAttr
= pTxtNd
->GetTxtAttrForCharAt(
1205 aPos
.nContent
.GetIndex(), RES_TXTATR_FTN
)) )
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() );
1219 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, 0 );
1220 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1221 nsSwCursorSelOverFlags::SELOVER_TOGGLE
))
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
)
1247 if( SwContentAtPos::SW_TOXMARK
& rCntntAtPos
.eCntntAtPos
)
1248 pTxtAttr
= pTxtNd
->GetTxtAttr( aPos
.nContent
,
1249 RES_TXTATR_TOXMARK
);
1252 SwContentAtPos::SW_REFMARK
& rCntntAtPos
.eCntntAtPos
)
1253 pTxtAttr
= pTxtNd
->GetTxtAttr( aPos
.nContent
,
1254 RES_TXTATR_REFMARK
);
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
) )
1274 const xub_StrLen
* pEnd
= pTxtAttr
->GetEnd();
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() )
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
) )
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
);
1338 rCntntAtPos
.aFnd
.pRedl
= pRedl
;
1339 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_REDLINE
;
1340 rCntntAtPos
.pFndTxtAttr
= 0;
1343 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->GetFrm( &aPt
) ) )
1344 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1350 SwContentAtPos::SW_TABLEBOXFML
& rCntntAtPos
.eCntntAtPos
1352 || SwContentAtPos::SW_TABLEBOXVALUE
& rCntntAtPos
.eCntntAtPos
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() )) &&
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
))
1369 SFX_ITEM_SET
== pBox
->GetFrmFmt()->GetItemState(
1370 RES_BOXATR_FORMULA
, FALSE
, &pItem
)
1374 SwFrm
* pF
= pTxtNd
->GetFrm( &aPt
);
1377 // dann aber den CellFrame
1378 pFrm
= (SwCntntFrm
*)pF
;
1379 while( pF
&& !pF
->IsCellFrm() )
1380 pF
= pF
->GetUpper();
1384 if( aTmpState
.bPosCorr
)
1386 if( pF
&& !pF
->Frm().IsInside( aPt
))
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
;
1398 if( RES_BOXATR_VALUE
== pItem
->Which() )
1399 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_TABLEBOXVALUE
;
1402 ((SwTblBoxFormula
*)pItem
)->PtrToBoxNm( &pTblNd
->GetTable() );
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
) )
1421 *pFldRect
= pF
->Prt();
1422 *pFldRect
+= pF
->Frm().Pos();
1424 rCntntAtPos
.pFndTxtAttr
= 0;
1425 rCntntAtPos
.aFnd
.pAttr
= pItem
;
1432 if( !bRet
&& SwContentAtPos::SW_CURR_ATTRS
& rCntntAtPos
.eCntntAtPos
)
1434 xub_StrLen n
= aPos
.nContent
.GetIndex();
1435 SfxItemSet
aSet( GetDoc()->GetAttrPool(), POOLATTR_BEGIN
,
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
1446 if( 0 != pHt
->GetEnd() && (
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
);
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();
1486 SfxItemIter
aIter( aSet
);
1487 const SfxPoolItem
* pItem
= aIter
.FirstItem();
1490 if( !IsInvalidItem( pItem
))
1493 GetDoc()->GetAttrPool().GetPresentation( *pItem
,
1494 SFX_ITEM_PRESENTATION_COMPLETE
,
1495 SFX_MAPUNIT_CM
, aStr
);
1498 RTL_CONSTASCII_STRINGPARAM( ", " ));
1501 if( aIter
.IsAtEnd() )
1503 pItem
= aIter
.NextItem();
1507 if( rCntntAtPos
.sStr
.Len() )
1508 rCntntAtPos
.sStr
+= '\n';
1509 rCntntAtPos
.sStr
.AppendAscii(
1510 RTL_CONSTASCII_STRINGPARAM( "Attr: " ) )
1515 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_CURR_ATTRS
;
1523 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_NOTHING
;
1524 rCntntAtPos
.aFnd
.pFld
= 0;
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();
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
);
1554 // befindet sich der Node in einem geschuetzten Bereich?
1555 BOOL
SwContentAtPos::IsInProtectSect() const
1557 const SwTxtNode
* pNd
= 0;
1560 switch( eCntntAtPos
)
1564 pNd
= ((SwTxtFld
*)pFndTxtAttr
)->GetpTxtNode();
1568 pNd
= &((SwTxtFtn
*)pFndTxtAttr
)->GetTxtNode();
1572 pNd
= ((SwTxtINetFmt
*)pFndTxtAttr
)->GetpTxtNode();
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
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
);
1604 SwClientIter
aClientIter( * const_cast<SwTxtNode
*>(pNd
) );
1605 SwClient
* pLast
= aClientIter
.GoStart();
1608 if ( pLast
->ISA( SwTxtFrm
) )
1610 SwTxtFrm
* pTmpFrm
= static_cast<SwTxtFrm
*>( pLast
);
1611 if ( !pTmpFrm
->IsFollow())
1613 bRet
= pTmpFrm
->IsRightToLeft();
1617 pLast
= ++aClientIter
;
1623 BOOL
SwCrsrShell::SelectTxtAttr( USHORT nWhich
, BOOL bExpand
,
1624 const SwTxtAttr
* pTxtAttr
)
1626 SET_CURR_SHELL( this );
1629 if( !IsTableMode() )
1631 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
1634 SwTxtNode
* pTxtNd
= rPos
.nNode
.GetNode().GetTxtNode();
1635 pTxtAttr
= pTxtNd
? pTxtNd
->GetTxtAttr( rPos
.nContent
,
1636 nWhich
, bExpand
) : 0;
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() )
1661 BOOL
SwCrsrShell::GotoINetAttr( const SwTxtINetFmt
& rAttr
)
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();
1677 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
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 );
1695 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
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
;
1715 BOOL
SwCrsrShell::SetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
)
1717 SET_CURR_SHELL( this );
1720 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
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
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();
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() )
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
)
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
,
1794 SvxLRSpaceItem
aLR( (SvxLRSpaceItem
&)
1795 pCNd
->GetAttr( RES_LR_SPACE
) );
1796 aLR
.SetTxtLeft( aFPos
.nTabCnt
);
1797 aLR
.SetTxtFirstLineOfst( 0 );
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 );
1808 ASSERT( !this, "wo ist mein CntntNode?" );
1817 sInsert
.Fill( aFPos
.nTabCnt
, '\t' );
1818 if( aFPos
.nSpaceCnt
)
1821 sSpace
.Fill( aFPos
.nSpaceCnt
);
1826 GetDoc()->InsertString( *pCurCrsr
, sInsert
);
1829 // kein break - Ausrichtung muss noch gesetzt werden
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
);
1839 case text::HoriOrientation::RIGHT
:
1840 aAdj
.SetAdjust( SVX_ADJUST_RIGHT
);
1845 GetDoc()->InsertPoolItem( *pCurCrsr
, aAdj
, 0 );
1850 GetDoc()->EndUndo( nUndoId
, NULL
);
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
);
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
);
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
];
1904 *pCurCrsr
->GetPoint() = *pFnd
->Start();
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 );
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 );
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() );
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
);
1957 pCurCrsr
->DeleteMark();
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
;
1977 USHORT nArrSavPos
= nArrPos
;
1980 pTmp
= _GotoRedline( nArrPos
, TRUE
);
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();
2000 switch( ::ComparePosition( *pCStt
, *pCEnd
,
2003 case POS_INSIDE
: // Pos1 liegt vollstaendig in Pos2
2004 if( !pCur
->HasMark() )
2007 *pCur
->GetMark() = *pNStt
;
2014 case POS_OUTSIDE
: // Pos2 liegt vollstaendig in Pos1
2015 case POS_EQUAL
: // Pos1 ist genauso gross wie Pos2
2018 case POS_OVERLAP_BEFORE
: // Pos1 ueberlappt Pos2 am Anfang
2019 if( !pCur
->HasMark() )
2023 case POS_OVERLAP_BEHIND
: // Pos1 ueberlappt Pos2 am Ende
2024 if( !pCur
->HasMark() )
2027 *pCur
->GetMark() = *pNStt
;
2039 // den brauchen wir nicht mehr
2040 SwPaM
* pPrevPam
= (SwPaM
*)pNextPam
->GetPrev();
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
))) )
2057 // neuen Cursor erzeugen
2066 } while( nLoopCnt
);
2069 pFnd
= _GotoRedline( nArrPos
, bSelect
);
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();
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();
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
);
2110 if( pTxtNd
->GetIndex() < nBodySttNdIdx
&&
2111 0 != ( pFrm
= pTxtNd
->GetFrm( &aPt
)) )
2112 aPos
.SetBodyPos( *pFrm
);
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();
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
);
2142 GetBodyTxtNode( *GetDoc(), aTmpPos
, *pFly
->GetLower() ) )
2144 _SetGetExpFld
aPos( *pFmt
, &aTmpPos
);
2147 ? ( aPos
< aCmpPos
&& aCurPos
< aPos
)
2148 : ( aCmpPos
< aPos
&& aPos
< aCurPos
))
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 ?
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
);
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() );
2189 else // then is it a fly
2191 SwFlyFrm
* pFly
= pFndFmt
->GetFrm(&aPt
, FALSE
);
2194 ((SwFEShell
*)this)->SelectFlyFrm( *pFly
, TRUE
);