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
->GetTxtAttr( aPos
.nContent
.GetIndex(),
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
->GetTxtAttr(
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
=
1541 pTxtNd
->GetTxtAttr( pCursorPos
->nContent
.GetIndex(),
1543 const SwField
* pFld
= pTxtAttr
? pTxtAttr
->GetFld().GetFld() : 0;
1544 if ( pFld
&& pFld
->Which()== RES_POSTITFLD
)
1546 pPostItFld
= static_cast<const SwPostItField
*>(pFld
);
1555 // befindet sich der Node in einem geschuetzten Bereich?
1556 BOOL
SwContentAtPos::IsInProtectSect() const
1558 const SwTxtNode
* pNd
= 0;
1561 switch( eCntntAtPos
)
1565 pNd
= ((SwTxtFld
*)pFndTxtAttr
)->GetpTxtNode();
1569 pNd
= &((SwTxtFtn
*)pFndTxtAttr
)->GetTxtNode();
1573 pNd
= ((SwTxtINetFmt
*)pFndTxtAttr
)->GetpTxtNode();
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
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
);
1605 SwClientIter
aClientIter( * const_cast<SwTxtNode
*>(pNd
) );
1606 SwClient
* pLast
= aClientIter
.GoStart();
1609 if ( pLast
->ISA( SwTxtFrm
) )
1611 SwTxtFrm
* pTmpFrm
= static_cast<SwTxtFrm
*>( pLast
);
1612 if ( !pTmpFrm
->IsFollow())
1614 bRet
= pTmpFrm
->IsRightToLeft();
1618 pLast
= ++aClientIter
;
1624 BOOL
SwCrsrShell::SelectTxtAttr( USHORT nWhich
, BOOL bExpand
,
1625 const SwTxtAttr
* pTxtAttr
)
1627 SET_CURR_SHELL( this );
1630 if( !IsTableMode() )
1632 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
1635 SwTxtNode
* pTxtNd
= rPos
.nNode
.GetNode().GetTxtNode();
1636 pTxtAttr
= pTxtNd
? pTxtNd
->GetTxtAttr( rPos
.nContent
,
1637 nWhich
, bExpand
) : 0;
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() )
1662 BOOL
SwCrsrShell::GotoINetAttr( const SwTxtINetFmt
& rAttr
)
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();
1678 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
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 );
1696 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
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
;
1716 BOOL
SwCrsrShell::SetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
)
1718 SET_CURR_SHELL( this );
1721 if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() )
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
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();
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() )
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
)
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
,
1795 SvxLRSpaceItem
aLR( (SvxLRSpaceItem
&)
1796 pCNd
->GetAttr( RES_LR_SPACE
) );
1797 aLR
.SetTxtLeft( aFPos
.nTabCnt
);
1798 aLR
.SetTxtFirstLineOfst( 0 );
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 );
1809 ASSERT( !this, "wo ist mein CntntNode?" );
1818 sInsert
.Fill( aFPos
.nTabCnt
, '\t' );
1819 if( aFPos
.nSpaceCnt
)
1822 sSpace
.Fill( aFPos
.nSpaceCnt
);
1826 GetDoc()->Insert( *pCurCrsr
, sInsert
, true );
1828 // kein break - Ausrichtung muss noch gesetzt werden
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
);
1838 case text::HoriOrientation::RIGHT
:
1839 aAdj
.SetAdjust( SVX_ADJUST_RIGHT
);
1844 GetDoc()->Insert( *pCurCrsr
, aAdj
, 0 );
1849 GetDoc()->EndUndo( nUndoId
, NULL
);
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
);
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
);
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
];
1903 *pCurCrsr
->GetPoint() = *pFnd
->Start();
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 );
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 );
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() );
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
);
1956 pCurCrsr
->DeleteMark();
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
;
1976 USHORT nArrSavPos
= nArrPos
;
1979 pTmp
= _GotoRedline( nArrPos
, TRUE
);
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();
1999 switch( ::ComparePosition( *pCStt
, *pCEnd
,
2002 case POS_INSIDE
: // Pos1 liegt vollstaendig in Pos2
2003 if( !pCur
->HasMark() )
2006 *pCur
->GetMark() = *pNStt
;
2013 case POS_OUTSIDE
: // Pos2 liegt vollstaendig in Pos1
2014 case POS_EQUAL
: // Pos1 ist genauso gross wie Pos2
2017 case POS_OVERLAP_BEFORE
: // Pos1 ueberlappt Pos2 am Anfang
2018 if( !pCur
->HasMark() )
2022 case POS_OVERLAP_BEHIND
: // Pos1 ueberlappt Pos2 am Ende
2023 if( !pCur
->HasMark() )
2026 *pCur
->GetMark() = *pNStt
;
2038 // den brauchen wir nicht mehr
2039 SwPaM
* pPrevPam
= (SwPaM
*)pNextPam
->GetPrev();
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
))) )
2056 // neuen Cursor erzeugen
2065 } while( nLoopCnt
);
2068 pFnd
= _GotoRedline( nArrPos
, bSelect
);
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();
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();
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
);
2109 if( pTxtNd
->GetIndex() < nBodySttNdIdx
&&
2110 0 != ( pFrm
= pTxtNd
->GetFrm( &aPt
)) )
2111 aPos
.SetBodyPos( *pFrm
);
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();
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
);
2141 GetBodyTxtNode( *GetDoc(), aTmpPos
, *pFly
->GetLower() ) )
2143 _SetGetExpFld
aPos( *pFmt
, &aTmpPos
);
2146 ? ( aPos
< aCmpPos
&& aCurPos
< aPos
)
2147 : ( aCmpPos
< aPos
&& aPos
< aCurPos
))
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 ?
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
);
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() );
2188 else // then is it a fly
2190 SwFlyFrm
* pFly
= pFndFmt
->GetFrm(&aPt
, FALSE
);
2193 ((SwFEShell
*)this)->SelectFlyFrm( *pFly
, TRUE
);