1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <hintids.hxx>
21 #include <comphelper/string.hxx>
22 #include <svl/itemiter.hxx>
23 #include <editeng/lrspitem.hxx>
24 #include <editeng/adjitem.hxx>
25 #include <editeng/brkitem.hxx>
26 #include <svx/svdobj.hxx>
29 #include <IDocumentUndoRedo.hxx>
30 #include <pagefrm.hxx>
32 #include <rootfrm.hxx>
36 #include <swtable.hxx>
41 #include <txtinet.hxx>
42 #include <fmtinfmt.hxx>
43 #include <txttxmrk.hxx>
53 #include <cellatr.hxx>
55 #include <redline.hxx>
56 #include <fmtcntnt.hxx>
57 #include <fmthdft.hxx>
58 #include <pagedesc.hxx>
60 #include <charfmt.hxx>
64 #include <switerator.hxx>
65 #include <vcl/window.hxx>
66 #include <docufld.hxx>
68 using namespace ::com::sun::star
;
70 /// go to next/previous point on the same level
71 bool SwCrsrShell::GotoNextNum()
73 bool bRet
= GetDoc()->GotoNextNum( *pCurCrsr
->GetPoint() );
76 SwCallLink
aLk( *this ); // watch Crsr-Moves
77 SwCrsrSaveState
aSaveState( *pCurCrsr
);
80 SET_CURR_SHELL( this );
81 // try to set cursor onto this position, at half of the char-
82 // SRectangle's height
83 Point
aPt( pCurCrsr
->GetPtPos() );
84 SwCntntFrm
* pFrm
= pCurCrsr
->GetCntntNode()->getLayoutFrm( GetLayout(), &aPt
,
85 pCurCrsr
->GetPoint() );
86 pFrm
->GetCharRect( aCharRect
, *pCurCrsr
->GetPoint() );
88 if( pFrm
->IsVertical() )
90 aPt
.X() = aCharRect
.Center().X();
91 aPt
.Y() = pFrm
->Frm().Top() + nUpDownX
;
95 aPt
.Y() = aCharRect
.Center().Y();
96 aPt
.X() = pFrm
->Frm().Left() + nUpDownX
;
98 pFrm
->GetCrsrOfst( pCurCrsr
->GetPoint(), aPt
);
99 bRet
= !pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE
|
100 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS
);
102 UpdateCrsr(SwCrsrShell::UPDOWN
|
103 SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
104 SwCrsrShell::READONLY
);
111 bool SwCrsrShell::GotoPrevNum()
113 bool bRet
= GetDoc()->GotoPrevNum( *pCurCrsr
->GetPoint() );
116 SwCallLink
aLk( *this ); // watch Crsr-Moves
117 SwCrsrSaveState
aSaveState( *pCurCrsr
);
120 SET_CURR_SHELL( this );
121 // try to set cursor onto this position, at half of the char-
122 // SRectangle's height
123 Point
aPt( pCurCrsr
->GetPtPos() );
124 SwCntntFrm
* pFrm
= pCurCrsr
->GetCntntNode()->getLayoutFrm( GetLayout(), &aPt
,
125 pCurCrsr
->GetPoint() );
126 pFrm
->GetCharRect( aCharRect
, *pCurCrsr
->GetPoint() );
128 if( pFrm
->IsVertical() )
130 aPt
.X() = aCharRect
.Center().X();
131 aPt
.Y() = pFrm
->Frm().Top() + nUpDownX
;
135 aPt
.Y() = aCharRect
.Center().Y();
136 aPt
.X() = pFrm
->Frm().Left() + nUpDownX
;
138 pFrm
->GetCrsrOfst( pCurCrsr
->GetPoint(), aPt
);
139 bRet
= !pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE
|
140 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS
);
142 UpdateCrsr(SwCrsrShell::UPDOWN
|
143 SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
144 SwCrsrShell::READONLY
);
150 /// jump from content to header
151 sal_Bool
SwCrsrShell::GotoHeaderTxt()
153 const SwFrm
* pFrm
= GetCurrFrm()->FindPageFrm();
154 while( pFrm
&& !pFrm
->IsHeaderFrm() )
155 pFrm
= pFrm
->GetLower();
156 // found header, search 1. content frame
157 while( pFrm
&& !pFrm
->IsCntntFrm() )
158 pFrm
= pFrm
->GetLower();
161 SET_CURR_SHELL( this );
163 SwCallLink
aLk( *this ); // watch Crsr-Moves
164 SwCursor
*pTmpCrsr
= getShellCrsr( true );
165 SwCrsrSaveState
aSaveState( *pTmpCrsr
);
167 Point
aPt( pFrm
->Frm().Pos() + pFrm
->Prt().Pos() );
168 pFrm
->GetCrsrOfst( pTmpCrsr
->GetPoint(), aPt
);
169 if( !pTmpCrsr
->IsSelOvr() )
177 /// jump from content to footer
178 sal_Bool
SwCrsrShell::GotoFooterTxt()
180 const SwPageFrm
* pFrm
= GetCurrFrm()->FindPageFrm();
183 const SwFrm
* pLower
= pFrm
->GetLastLower();
185 while( pLower
&& !pLower
->IsFooterFrm() )
186 pLower
= pLower
->GetLower();
187 // found footer, search 1. content frame
188 while( pLower
&& !pLower
->IsCntntFrm() )
189 pLower
= pLower
->GetLower();
193 SwCursor
*pTmpCrsr
= getShellCrsr( true );
194 SET_CURR_SHELL( this );
195 // get position in footer
196 SwCallLink
aLk( *this ); // watch Crsr-Moves
197 SwCrsrSaveState
aSaveState( *pTmpCrsr
);
199 Point
aPt( pLower
->Frm().Pos() + pLower
->Prt().Pos() );
200 pLower
->GetCrsrOfst( pTmpCrsr
->GetPoint(), aPt
);
201 if( !pTmpCrsr
->IsSelOvr() )
214 sal_Bool
SwCrsrShell::SetCrsrInHdFt( sal_uInt16 nDescNo
, sal_Bool bInHeader
)
216 sal_Bool bRet
= sal_False
;
217 SwDoc
*pMyDoc
= GetDoc();
219 SET_CURR_SHELL( this );
221 if( USHRT_MAX
== nDescNo
)
223 // take the current one
224 const SwPageFrm
* pPage
= GetCurrFrm()->FindPageFrm();
226 for( sal_uInt16 i
= 0; i
< pMyDoc
->GetPageDescCnt(); ++i
)
227 if( pPage
->GetPageDesc() == &pMyDoc
->GetPageDesc( i
) )
234 if( USHRT_MAX
!= nDescNo
&& nDescNo
< pMyDoc
->GetPageDescCnt() )
236 // check if the attribute exists
237 const SwPageDesc
& rDesc
= const_cast<const SwDoc
*>(pMyDoc
)
238 ->GetPageDesc( nDescNo
);
239 const SwFmtCntnt
* pCnt
= 0;
242 // mirrored pages? ignore for now
243 const SwFmtHeader
& rHd
= rDesc
.GetMaster().GetHeader();
244 if( rHd
.GetHeaderFmt() )
245 pCnt
= &rHd
.GetHeaderFmt()->GetCntnt();
249 const SwFmtFooter
& rFt
= rDesc
.GetMaster().GetFooter();
250 if( rFt
.GetFooterFmt() )
251 pCnt
= &rFt
.GetFooterFmt()->GetCntnt();
254 if( pCnt
&& pCnt
->GetCntntIdx() )
256 SwNodeIndex
aIdx( *pCnt
->GetCntntIdx(), 1 );
257 SwCntntNode
* pCNd
= aIdx
.GetNode().GetCntntNode();
259 pCNd
= pMyDoc
->GetNodes().GoNext( &aIdx
);
262 Point
aPt( pCurCrsr
->GetPtPos() );
264 if( pCNd
&& 0 != ( pFrm
= pCNd
->getLayoutFrm( GetLayout(), &aPt
, 0, sal_False
) ))
266 // then we can set the cursor in here
267 SwCallLink
aLk( *this ); // watch Crsr-Moves
268 SwCrsrSaveState
aSaveState( *pCurCrsr
);
272 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
274 rPos
.nContent
.Assign( pCNd
, 0 );
276 bRet
= !pCurCrsr
->IsSelOvr();
278 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
279 SwCrsrShell::READONLY
);
286 /// jump to the next index
287 sal_Bool
SwCrsrShell::GotoNextTOXBase( const String
* pName
)
289 sal_Bool bRet
= sal_False
;
291 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
292 SwCntntNode
* pFnd
= 0;
293 for( sal_uInt16 n
= rFmts
.size(); n
; )
295 const SwSection
* pSect
= rFmts
[ --n
]->GetSection();
296 const SwSectionNode
* pSectNd
;
297 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
298 0 != ( pSectNd
= pSect
->GetFmt()->GetSectionNode() ) &&
299 pCurCrsr
->GetPoint()->nNode
< pSectNd
->GetIndex() &&
300 ( !pFnd
|| pFnd
->GetIndex() > pSectNd
->GetIndex() ) &&
301 ( !pName
|| *pName
== ((SwTOXBaseSection
*)pSect
)->GetTOXName() )
304 SwNodeIndex
aIdx( *pSectNd
, 1 );
305 SwCntntNode
* pCNd
= aIdx
.GetNode().GetCntntNode();
307 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
308 const SwCntntFrm
* pCFrm
;
310 pCNd
->EndOfSectionIndex() <= pSectNd
->EndOfSectionIndex() &&
311 0 != ( pCFrm
= pCNd
->getLayoutFrm( GetLayout() ) ) &&
312 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
320 SwCallLink
aLk( *this ); // watch Crsr-Moves
321 SwCrsrSaveState
aSaveState( *pCurCrsr
);
322 pCurCrsr
->GetPoint()->nNode
= *pFnd
;
323 pCurCrsr
->GetPoint()->nContent
.Assign( pFnd
, 0 );
324 bRet
= !pCurCrsr
->IsSelOvr();
326 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
331 /// jump to previous index
332 sal_Bool
SwCrsrShell::GotoPrevTOXBase( const String
* pName
)
334 sal_Bool bRet
= sal_False
;
336 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
337 SwCntntNode
* pFnd
= 0;
338 for( sal_uInt16 n
= rFmts
.size(); n
; )
340 const SwSection
* pSect
= rFmts
[ --n
]->GetSection();
341 const SwSectionNode
* pSectNd
;
342 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
343 0 != ( pSectNd
= pSect
->GetFmt()->GetSectionNode() ) &&
344 pCurCrsr
->GetPoint()->nNode
> pSectNd
->EndOfSectionIndex() &&
345 ( !pFnd
|| pFnd
->GetIndex() < pSectNd
->GetIndex() ) &&
346 ( !pName
|| *pName
== ((SwTOXBaseSection
*)pSect
)->GetTOXName() )
349 SwNodeIndex
aIdx( *pSectNd
, 1 );
350 SwCntntNode
* pCNd
= aIdx
.GetNode().GetCntntNode();
352 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
353 const SwCntntFrm
* pCFrm
;
355 pCNd
->EndOfSectionIndex() <= pSectNd
->EndOfSectionIndex() &&
356 0 != ( pCFrm
= pCNd
->getLayoutFrm( GetLayout() ) ) &&
357 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
366 SwCallLink
aLk( *this ); // watch Crsr-Moves
367 SwCrsrSaveState
aSaveState( *pCurCrsr
);
368 pCurCrsr
->GetPoint()->nNode
= *pFnd
;
369 pCurCrsr
->GetPoint()->nContent
.Assign( pFnd
, 0 );
370 bRet
= !pCurCrsr
->IsSelOvr();
372 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
377 /// jump to index of TOXMark
378 sal_Bool
SwCrsrShell::GotoTOXMarkBase()
380 sal_Bool bRet
= sal_False
;
383 sal_uInt16 nCnt
= GetDoc()->GetCurTOXMark( *pCurCrsr
->GetPoint(), aMarks
);
386 // Take the 1. and get the index type. Search in its dependency list
387 // for the actual index
388 const SwTOXType
* pType
= aMarks
[0]->GetTOXType();
389 SwIterator
<SwTOXBase
,SwTOXType
> aIter( *pType
);
390 const SwSectionNode
* pSectNd
;
391 const SwSectionFmt
* pSectFmt
;
393 for( SwTOXBase
* pTOX
= aIter
.First(); pTOX
; pTOX
= aIter
.Next() )
395 if( pTOX
->ISA( SwTOXBaseSection
) &&
396 0 != ( pSectFmt
= ((SwTOXBaseSection
*)pTOX
)->GetFmt() ) &&
397 0 != ( pSectNd
= pSectFmt
->GetSectionNode() ))
399 SwNodeIndex
aIdx( *pSectNd
, 1 );
400 SwCntntNode
* pCNd
= aIdx
.GetNode().GetCntntNode();
402 pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
403 const SwCntntFrm
* pCFrm
;
405 pCNd
->EndOfSectionIndex() < pSectNd
->EndOfSectionIndex() &&
406 0 != ( pCFrm
= pCNd
->getLayoutFrm( GetLayout() ) ) &&
407 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
409 SwCallLink
aLk( *this ); // watch Crsr-Moves
410 SwCrsrSaveState
aSaveState( *pCurCrsr
);
411 pCurCrsr
->GetPoint()->nNode
= *pCNd
;
412 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, 0 );
413 bRet
= !pCurCrsr
->IsInProtectTable() &&
414 !pCurCrsr
->IsSelOvr();
416 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
425 /// Jump to next/previous table formula
426 /// Optionally it is possible to also jump to broken formulas
427 sal_Bool
SwCrsrShell::GotoNxtPrvTblFormula( sal_Bool bNext
, sal_Bool bOnlyErrors
)
432 sal_Bool bFnd
= sal_False
;
433 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
436 SwPosition
aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
439 _SetGetExpFld
aFndGEF( aFndPos
), aCurGEF( rPos
);
442 const SwNode
* pSttNd
= rPos
.nNode
.GetNode().FindTableBoxStartNode();
445 const SwTableBox
* pTBox
= pSttNd
->FindTableNode()->GetTable().
446 GetTblBox( pSttNd
->GetIndex() );
448 aCurGEF
= _SetGetExpFld( *pTBox
);
452 if( rPos
.nNode
< GetDoc()->GetNodes().GetEndOfExtras() )
453 // also at collection use only the first frame
454 aCurGEF
.SetBodyPos( *rPos
.nNode
.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),
455 &aPt
, &rPos
, sal_False
) );
457 const SfxPoolItem
* pItem
;
458 const SwTableBox
* pTBox
;
459 sal_uInt32 n
, nMaxItems
= GetDoc()->GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA
);
461 for( n
= 0; n
< nMaxItems
; ++n
)
462 if( 0 != (pItem
= GetDoc()->GetAttrPool().GetItem2(
463 RES_BOXATR_FORMULA
, n
) ) &&
464 0 != (pTBox
= ((SwTblBoxFormula
*)pItem
)->GetTableBox() ) &&
466 pTBox
->GetSttNd()->GetNodes().IsDocNodes() &&
468 !((SwTblBoxFormula
*)pItem
)->HasValidBoxes() ) )
470 const SwCntntFrm
* pCFrm
;
471 SwNodeIndex
aIdx( *pTBox
->GetSttNd() );
472 const SwCntntNode
* pCNd
= GetDoc()->GetNodes().GoNext( &aIdx
);
473 if( pCNd
&& 0 != ( pCFrm
= pCNd
->getLayoutFrm( GetLayout(), &aPt
, 0, sal_False
) ) &&
474 (IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
476 _SetGetExpFld
aCmp( *pTBox
);
477 aCmp
.SetBodyPos( *pCFrm
);
479 if( bNext
? ( aCurGEF
< aCmp
&& aCmp
< aFndGEF
)
480 : ( aCmp
< aCurGEF
&& aFndGEF
< aCmp
))
491 SET_CURR_SHELL( this );
492 SwCallLink
aLk( *this ); // watch Crsr-Moves
493 SwCrsrSaveState
aSaveState( *pCurCrsr
);
495 aFndGEF
.GetPosOfContent( rPos
);
496 pCurCrsr
->DeleteMark();
498 bFnd
= !pCurCrsr
->IsSelOvr();
500 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
501 SwCrsrShell::READONLY
);
506 /// jump to next/previous index marker
507 sal_Bool
SwCrsrShell::GotoNxtPrvTOXMark( sal_Bool bNext
)
512 sal_Bool bFnd
= sal_False
;
513 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
516 SwPosition
aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
519 _SetGetExpFld
aFndGEF( aFndPos
), aCurGEF( rPos
);
521 if( rPos
.nNode
.GetIndex() < GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
522 // also at collection use only the first frame
523 aCurGEF
.SetBodyPos( *rPos
.nNode
.GetNode().
524 GetCntntNode()->getLayoutFrm( GetLayout(), &aPt
, &rPos
, sal_False
) );
526 const SfxPoolItem
* pItem
;
527 const SwCntntFrm
* pCFrm
;
528 const SwTxtNode
* pTxtNd
;
529 const SwTxtTOXMark
* pTxtTOX
;
530 sal_uInt32 n
, nMaxItems
= GetDoc()->GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK
);
532 for( n
= 0; n
< nMaxItems
; ++n
)
533 if( 0 != (pItem
= GetDoc()->GetAttrPool().GetItem2(
534 RES_TXTATR_TOXMARK
, n
) ) &&
535 0 != (pTxtTOX
= ((SwTOXMark
*)pItem
)->GetTxtTOXMark() ) &&
536 ( pTxtNd
= &pTxtTOX
->GetTxtNode())->GetNodes().IsDocNodes() &&
537 0 != ( pCFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
, 0, sal_False
)) &&
538 ( IsReadOnlyAvailable() || !pCFrm
->IsProtected() ))
540 SwNodeIndex
aNdIndex( *pTxtNd
); // UNIX needs this object
541 _SetGetExpFld
aCmp( aNdIndex
, *pTxtTOX
, 0 );
542 aCmp
.SetBodyPos( *pCFrm
);
544 if( bNext
? ( aCurGEF
< aCmp
&& aCmp
< aFndGEF
)
545 : ( aCmp
< aCurGEF
&& aFndGEF
< aCmp
))
555 SET_CURR_SHELL( this );
556 SwCallLink
aLk( *this ); // watch Crsr-Moves
557 SwCrsrSaveState
aSaveState( *pCurCrsr
);
559 aFndGEF
.GetPosOfContent( rPos
);
561 bFnd
= !pCurCrsr
->IsSelOvr();
563 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
564 SwCrsrShell::READONLY
);
569 /// traveling between marks
570 const SwTOXMark
& SwCrsrShell::GotoTOXMark( const SwTOXMark
& rStart
,
573 SET_CURR_SHELL( this );
574 SwCallLink
aLk( *this ); // watch Crsr-Moves
575 SwCrsrSaveState
aSaveState( *pCurCrsr
);
577 const SwTOXMark
& rNewMark
= GetDoc()->GotoTOXMark( rStart
, eDir
,
578 IsReadOnlyAvailable() );
580 SwPosition
& rPos
= *GetCrsr()->GetPoint();
581 rPos
.nNode
= rNewMark
.GetTxtTOXMark()->GetTxtNode();
582 rPos
.nContent
.Assign( rPos
.nNode
.GetNode().GetCntntNode(),
583 *rNewMark
.GetTxtTOXMark()->GetStart() );
585 if( !pCurCrsr
->IsSelOvr() )
586 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
|
587 SwCrsrShell::READONLY
);
592 /// jump to next/previous field type
593 static void lcl_MakeFldLst( _SetGetExpFlds
& rLst
, const SwFieldType
& rFldType
,
594 sal_uInt16 nSubType
, sal_Bool bInReadOnly
,
595 sal_Bool bChkInpFlag
= sal_False
)
597 // always search the 1. frame
600 SwIterator
<SwFmtFld
,SwFieldType
> aIter(rFldType
);
601 bool bSubType
= nSubType
!= USHRT_MAX
;
602 for( SwFmtFld
* pFmtFld
= aIter
.First(); pFmtFld
; pFmtFld
= aIter
.Next() )
603 if( 0 != ( pTxtFld
= pFmtFld
->GetTxtFld() ) &&
604 ( !bChkInpFlag
|| ((SwSetExpField
*)pTxtFld
->GetFld().GetFld())
605 ->GetInputFlag() ) &&
606 (!bSubType
|| (pFmtFld
->GetFld()->GetSubType()
607 & 0xff ) == nSubType
))
610 const SwTxtNode
& rTxtNode
= pTxtFld
->GetTxtNode();
611 if( 0 != ( pCFrm
= rTxtNode
.getLayoutFrm( rTxtNode
.GetDoc()->GetCurrentLayout(), &aPt
, 0, sal_False
)) &&
612 ( bInReadOnly
|| !pCFrm
->IsProtected() ))
614 _SetGetExpFld
* pNew
= new _SetGetExpFld(
615 SwNodeIndex( rTxtNode
), pTxtFld
);
616 pNew
->SetBodyPos( *pCFrm
);
623 sal_Bool
SwCrsrShell::MoveFldType( const SwFieldType
* pFldType
, sal_Bool bNext
,
624 sal_uInt16 nSubType
, sal_uInt16 nResType
)
626 // sorted list of all fields
627 _SetGetExpFlds aSrtLst
;
631 if( RES_INPUTFLD
!= pFldType
->Which() && !pFldType
->GetDepends() )
634 // found Modify object, add all fields to array
635 ::lcl_MakeFldLst( aSrtLst
, *pFldType
, nSubType
, IsReadOnlyAvailable() );
637 if( RES_INPUTFLD
== pFldType
->Which() )
639 // there are hidden input fields in the set exp. fields
640 const SwFldTypes
& rFldTypes
= *pDoc
->GetFldTypes();
641 const sal_uInt16 nSize
= rFldTypes
.size();
643 // iterate over all types
644 for( sal_uInt16 i
=0; i
< nSize
; ++i
)
645 if( RES_SETEXPFLD
== ( pFldType
= rFldTypes
[ i
] )->Which() )
646 ::lcl_MakeFldLst( aSrtLst
, *pFldType
, nSubType
,
647 IsReadOnlyAvailable(), sal_True
);
652 const SwFldTypes
& rFldTypes
= *pDoc
->GetFldTypes();
653 const sal_uInt16 nSize
= rFldTypes
.size();
655 // iterate over all types
656 for( sal_uInt16 i
=0; i
< nSize
; ++i
)
657 if( nResType
== ( pFldType
= rFldTypes
[ i
] )->Which() )
658 ::lcl_MakeFldLst( aSrtLst
, *pFldType
, nSubType
,
659 IsReadOnlyAvailable() );
663 if( aSrtLst
.empty() )
666 _SetGetExpFlds::const_iterator it
;
667 SwCursor
* pCrsr
= getShellCrsr( true );
669 // (1998): Always use field for search so that the right one is found as
670 // well some are in frames that are anchored to a paragraph that has a
672 const SwPosition
& rPos
= *pCrsr
->GetPoint();
674 SwTxtNode
* pTNd
= rPos
.nNode
.GetNode().GetTxtNode();
675 OSL_ENSURE( pTNd
, "No CntntNode" );
677 SwTxtFld
* pTxtFld
= static_cast<SwTxtFld
*>(
678 pTNd
->GetTxtAttrForCharAt(rPos
.nContent
.GetIndex(),
680 bool bDelFld
= 0 == pTxtFld
;
683 SwFmtFld
* pFmtFld
= new SwFmtFld( SwDateTimeField(
684 (SwDateTimeFieldType
*)pDoc
->GetSysFldType( RES_DATETIMEFLD
) ) );
686 pTxtFld
= new SwTxtFld( *pFmtFld
, rPos
.nContent
.GetIndex(),
687 pDoc
->IsClipBoard() );
688 pTxtFld
->ChgTxtNode( pTNd
);
691 _SetGetExpFld
aSrch( rPos
.nNode
, pTxtFld
, &rPos
.nContent
);
692 if( rPos
.nNode
.GetIndex() < pDoc
->GetNodes().GetEndOfExtras().GetIndex() )
694 // also at collection use only the first frame
696 aSrch
.SetBodyPos( *pTNd
->getLayoutFrm( GetLayout(), &aPt
, &rPos
, sal_False
) );
699 it
= aSrtLst
.lower_bound( &aSrch
);
702 delete (SwFmtFld
*)&pTxtFld
->GetAttr();
706 if( it
!= aSrtLst
.end() && **it
== aSrch
) // found
710 if( ++it
== aSrtLst
.end() )
711 return sal_False
; // already at the end
715 if( it
== aSrtLst
.begin() )
716 return sal_False
; // no more steps backward possible
724 if( it
== aSrtLst
.end() )
729 if( it
== aSrtLst
.begin() )
730 return sal_False
; // no more steps backward possible
735 const _SetGetExpFld
& rFnd
= **it
;
738 SET_CURR_SHELL( this );
739 SwCallLink
aLk( *this ); // watch Crsr-Moves
740 SwCrsrSaveState
aSaveState( *pCrsr
);
742 rFnd
.GetPosOfContent( *pCrsr
->GetPoint() );
743 sal_Bool bRet
= !pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
744 nsSwCursorSelOverFlags::SELOVER_TOGGLE
);
746 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
751 sal_Bool
SwCrsrShell::GotoFld( const SwFmtFld
& rFld
)
753 sal_Bool bRet
= sal_False
;
754 if( rFld
.GetTxtFld() )
756 SET_CURR_SHELL( this );
757 SwCallLink
aLk( *this ); // watch Crsr-Moves
759 SwCursor
* pCrsr
= getShellCrsr( true );
760 SwCrsrSaveState
aSaveState( *pCrsr
);
762 SwTxtNode
* pTNd
= (SwTxtNode
*)rFld
.GetTxtFld()->GetpTxtNode();
763 pCrsr
->GetPoint()->nNode
= *pTNd
;
764 pCrsr
->GetPoint()->nContent
.Assign( pTNd
, *rFld
.GetTxtFld()->GetStart() );
766 bRet
= !pCrsr
->IsSelOvr();
768 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
774 void SwCrsrShell::GotoOutline( sal_uInt16 nIdx
)
776 SwCursor
* pCrsr
= getShellCrsr( true );
778 SET_CURR_SHELL( this );
779 SwCallLink
aLk( *this ); // watch Crsr-Moves
780 SwCrsrSaveState
aSaveState( *pCrsr
);
782 const SwNodes
& rNds
= GetDoc()->GetNodes();
783 SwTxtNode
* pTxtNd
= (SwTxtNode
*)rNds
.GetOutLineNds()[ nIdx
]->GetTxtNode();
784 pCrsr
->GetPoint()->nNode
= *pTxtNd
;
785 pCrsr
->GetPoint()->nContent
.Assign( pTxtNd
, 0 );
787 if( !pCrsr
->IsSelOvr() )
788 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
792 bool SwCrsrShell::GotoOutline( const String
& rName
)
794 SwCursor
* pCrsr
= getShellCrsr( true );
796 SET_CURR_SHELL( this );
797 SwCallLink
aLk( *this ); // watch Crsr-Moves
798 SwCrsrSaveState
aSaveState( *pCrsr
);
801 if( pDoc
->GotoOutline( *pCrsr
->GetPoint(), rName
) && !pCrsr
->IsSelOvr() )
803 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
809 /// jump to next node with outline num.
810 sal_Bool
SwCrsrShell::GotoNextOutline()
812 SwCursor
* pCrsr
= getShellCrsr( true );
813 const SwNodes
& rNds
= GetDoc()->GetNodes();
815 SwNode
* pNd
= pCrsr
->GetNode();
817 if( rNds
.GetOutLineNds().Seek_Entry( pNd
, &nPos
))
820 if( nPos
== rNds
.GetOutLineNds().size() )
823 pNd
= rNds
.GetOutLineNds()[ nPos
];
825 SET_CURR_SHELL( this );
826 SwCallLink
aLk( *this ); // watch Crsr-Moves
827 SwCrsrSaveState
aSaveState( *pCrsr
);
828 pCrsr
->GetPoint()->nNode
= *pNd
;
829 pCrsr
->GetPoint()->nContent
.Assign( (SwTxtNode
*)pNd
, 0 );
831 sal_Bool bRet
= !pCrsr
->IsSelOvr();
833 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
837 /// jump to previous node with outline num.
838 sal_Bool
SwCrsrShell::GotoPrevOutline()
840 SwCursor
* pCrsr
= getShellCrsr( true );
841 const SwNodes
& rNds
= GetDoc()->GetNodes();
843 SwNode
* pNd
= pCrsr
->GetNode();
845 rNds
.GetOutLineNds().Seek_Entry( pNd
, &nPos
);
847 sal_Bool bRet
= sal_False
;
852 pNd
= rNds
.GetOutLineNds()[ nPos
];
853 if( pNd
->GetIndex() > pCrsr
->GetPoint()->nNode
.GetIndex() )
856 SET_CURR_SHELL( this );
857 SwCallLink
aLk( *this ); // watch Crsr-Moves
858 SwCrsrSaveState
aSaveState( *pCrsr
);
859 pCrsr
->GetPoint()->nNode
= *pNd
;
860 pCrsr
->GetPoint()->nContent
.Assign( (SwTxtNode
*)pNd
, 0 );
862 bRet
= !pCrsr
->IsSelOvr();
864 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
869 /// search "outline position" before previous outline node at given level
870 sal_uInt16
SwCrsrShell::GetOutlinePos( sal_uInt8 nLevel
)
872 SwPaM
* pCrsr
= getShellCrsr( true );
873 const SwNodes
& rNds
= GetDoc()->GetNodes();
875 SwNode
* pNd
= pCrsr
->GetNode();
877 if( rNds
.GetOutLineNds().Seek_Entry( pNd
, &nPos
))
878 nPos
++; // is at correct position; take next for while
880 while( nPos
-- ) // check the one in front of the current
882 pNd
= rNds
.GetOutLineNds()[ nPos
];
884 if( ((SwTxtNode
*)pNd
)->GetAttrOutlineLevel()-1 <= nLevel
)
888 return USHRT_MAX
; // no more left
892 sal_Bool
SwCrsrShell::MakeOutlineSel( sal_uInt16 nSttPos
, sal_uInt16 nEndPos
,
893 sal_Bool bWithChildren
)
895 const SwNodes
& rNds
= GetDoc()->GetNodes();
896 const SwOutlineNodes
& rOutlNds
= rNds
.GetOutLineNds();
897 if( rOutlNds
.empty() )
900 SET_CURR_SHELL( this );
901 SwCallLink
aLk( *this ); // watch Crsr-Moves
903 if( nSttPos
> nEndPos
) // parameters switched?
905 OSL_ENSURE( !this, "Start > End for array access" );
906 sal_uInt16 nTmp
= nSttPos
;
911 SwNode
* pSttNd
= rOutlNds
[ nSttPos
];
912 SwNode
* pEndNd
= rOutlNds
[ nEndPos
];
916 const int nLevel
= pEndNd
->GetTxtNode()->GetAttrOutlineLevel()-1;
917 for( ++nEndPos
; nEndPos
< rOutlNds
.size(); ++nEndPos
)
919 pEndNd
= rOutlNds
[ nEndPos
];
920 const int nNxtLevel
= pEndNd
->GetTxtNode()->GetAttrOutlineLevel()-1;
921 if( nNxtLevel
<= nLevel
)
922 break; // EndPos is now on the next one
925 // if without children then set onto next one
926 else if( ++nEndPos
< rOutlNds
.size() )
927 pEndNd
= rOutlNds
[ nEndPos
];
929 if( nEndPos
== rOutlNds
.size() ) // no end found
930 pEndNd
= &rNds
.GetEndOfContent();
934 SwCrsrSaveState
aSaveState( *pCurCrsr
);
936 // set end to the end of the previous content node
937 pCurCrsr
->GetPoint()->nNode
= *pSttNd
;
938 pCurCrsr
->GetPoint()->nContent
.Assign( pSttNd
->GetCntntNode(), 0 );
940 pCurCrsr
->GetPoint()->nNode
= *pEndNd
;
941 pCurCrsr
->Move( fnMoveBackward
, fnGoNode
); // end of predecessor
943 // and everything is already selected
944 sal_Bool bRet
= !pCurCrsr
->IsSelOvr();
946 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
951 /// jump to reference marker
952 sal_Bool
SwCrsrShell::GotoRefMark( const String
& rRefMark
, sal_uInt16 nSubType
,
955 SET_CURR_SHELL( this );
956 SwCallLink
aLk( *this ); // watch Crsr-Moves
957 SwCrsrSaveState
aSaveState( *pCurCrsr
);
960 SwTxtNode
* pTxtNd
= SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark
,
961 nSubType
, nSeqNo
, &nPos
);
962 if( pTxtNd
&& pTxtNd
->GetNodes().IsDocNodes() )
964 pCurCrsr
->GetPoint()->nNode
= *pTxtNd
;
965 pCurCrsr
->GetPoint()->nContent
.Assign( pTxtNd
, nPos
);
967 if( !pCurCrsr
->IsSelOvr() )
969 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
976 sal_Bool
SwCrsrShell::IsPageAtPos( const Point
&rPt
) const
979 return 0 != GetLayout()->GetPageAtPos( rPt
);
983 sal_Bool
SwCrsrShell::GetContentAtPos( const Point
& rPt
,
984 SwContentAtPos
& rCntntAtPos
,
988 SET_CURR_SHELL( this );
989 sal_Bool bRet
= sal_False
;
994 SwPosition
aPos( *pCurCrsr
->GetPoint() );
999 SwCrsrMoveState aTmpState
;
1000 aTmpState
.bFieldInfo
= sal_True
;
1001 aTmpState
.bExactOnly
= !( SwContentAtPos::SW_OUTLINE
& rCntntAtPos
.eCntntAtPos
);
1002 aTmpState
.bCntntCheck
= (SwContentAtPos::SW_CONTENT_CHECK
& rCntntAtPos
.eCntntAtPos
) ? sal_True
: sal_False
;
1003 aTmpState
.bSetInReadOnly
= IsReadOnlyAvailable();
1005 SwSpecialPos aSpecialPos
;
1006 aTmpState
.pSpecialPos
= ( SwContentAtPos::SW_SMARTTAG
& rCntntAtPos
.eCntntAtPos
) ?
1009 const sal_Bool bCrsrFoundExact
= GetLayout()->GetCrsrOfst( &aPos
, aPt
, &aTmpState
);
1010 pTxtNd
= aPos
.nNode
.GetNode().GetTxtNode();
1012 const SwNodes
& rNds
= GetDoc()->GetNodes();
1013 if( pTxtNd
&& SwContentAtPos::SW_OUTLINE
& rCntntAtPos
.eCntntAtPos
1014 && !rNds
.GetOutLineNds().empty() )
1016 const SwTxtNode
* pONd
= pTxtNd
->FindOutlineNodeOfLevel( MAXLEVEL
-1);
1019 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_OUTLINE
;
1020 rCntntAtPos
.sStr
= pONd
->GetExpandTxt( 0, STRING_LEN
, true, true );
1024 // #i43742# New function
1025 else if ( SwContentAtPos::SW_CONTENT_CHECK
& rCntntAtPos
.eCntntAtPos
&&
1032 SwContentAtPos::SW_NUMLABEL
& rCntntAtPos
.eCntntAtPos
)
1034 bRet
= aTmpState
.bInNumPortion
;
1035 rCntntAtPos
.aFnd
.pNode
= pTxtNd
;
1037 Size
aSizeLogic(aTmpState
.nInNumPostionOffset
, 0);
1038 Size aSizePixel
= GetWin()->LogicToPixel(aSizeLogic
);
1039 rCntntAtPos
.nDist
= aSizePixel
.Width();
1041 else if( bCrsrFoundExact
&& pTxtNd
)
1043 if( !aTmpState
.bPosCorr
)
1045 if( !bRet
&& SwContentAtPos::SW_SMARTTAG
& rCntntAtPos
.eCntntAtPos
1046 && !aTmpState
.bFtnNoInfo
)
1048 const SwWrongList
* pSmartTagList
= pTxtNd
->GetSmartTags();
1049 xub_StrLen nCurrent
= aPos
.nContent
.GetIndex();
1050 xub_StrLen nBegin
= nCurrent
;
1051 xub_StrLen nLen
= 1;
1053 if ( pSmartTagList
&& pSmartTagList
->InWrongWord( nCurrent
, nLen
) && !pTxtNd
->IsSymbol(nBegin
) )
1055 const sal_uInt16 nIndex
= pSmartTagList
->GetWrongPos( nBegin
);
1056 const SwWrongList
* pSubList
= pSmartTagList
->SubList( nIndex
);
1059 nCurrent
= aTmpState
.pSpecialPos
->nCharOfst
;
1061 if ( pSubList
->InWrongWord( nCurrent
, nLen
) )
1067 if( bRet
&& bSetCrsr
)
1069 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1070 SwCallLink
aLk( *this ); // watch Crsr-Moves
1071 pCurCrsr
->DeleteMark();
1072 *pCurCrsr
->GetPoint() = aPos
;
1073 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1074 nsSwCursorSelOverFlags::SELOVER_TOGGLE
) )
1081 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_SMARTTAG
;
1083 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1084 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1089 if( !bRet
&& ( SwContentAtPos::SW_FIELD
| SwContentAtPos::SW_CLICKFIELD
)
1090 & rCntntAtPos
.eCntntAtPos
&& !aTmpState
.bFtnNoInfo
)
1092 pTxtAttr
= pTxtNd
->GetTxtAttrForCharAt(
1093 aPos
.nContent
.GetIndex(), RES_TXTATR_FIELD
);
1094 const SwField
* pFld
= pTxtAttr
1095 ? pTxtAttr
->GetFld().GetFld()
1097 if( SwContentAtPos::SW_CLICKFIELD
& rCntntAtPos
.eCntntAtPos
&&
1098 pFld
&& !pFld
->HasClickHdl() )
1103 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1104 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1108 SwCallLink
aLk( *this ); // watch Crsr-Moves
1109 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1110 pCurCrsr
->DeleteMark();
1111 *pCurCrsr
->GetPoint() = aPos
;
1112 if( pCurCrsr
->IsSelOvr() )
1114 // allow click fields in protected sections
1115 // only placeholder is not possible
1116 if( SwContentAtPos::SW_FIELD
& rCntntAtPos
.eCntntAtPos
1117 || RES_JUMPEDITFLD
== pFld
->Which() )
1123 else if( RES_TABLEFLD
== pFld
->Which() &&
1124 ((SwTblField
*)pFld
)->IsIntrnlName() )
1126 // create from internal (for CORE) the external
1128 const SwTableNode
* pTblNd
= pTxtNd
->FindTableNode();
1129 if( pTblNd
) // steht in einer Tabelle
1130 ((SwTblField
*)pFld
)->PtrToBoxNm( &pTblNd
->GetTable() );
1136 rCntntAtPos
.aFnd
.pFld
= pFld
;
1137 rCntntAtPos
.pFndTxtAttr
= pTxtAttr
;
1138 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FIELD
;
1143 if( !bRet
&& SwContentAtPos::SW_FORMCTRL
& rCntntAtPos
.eCntntAtPos
)
1145 IDocumentMarkAccess
* pMarksAccess
= GetDoc()->getIDocumentMarkAccess( );
1146 sw::mark::IFieldmark
* pFldBookmark
= pMarksAccess
->getFieldmarkFor( aPos
);
1147 if( bCrsrFoundExact
&& pTxtNd
&& pFldBookmark
) {
1148 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FORMCTRL
;
1149 rCntntAtPos
.aFnd
.pFldmark
= pFldBookmark
;
1154 if( !bRet
&& SwContentAtPos::SW_FTN
& rCntntAtPos
.eCntntAtPos
)
1156 if( aTmpState
.bFtnNoInfo
)
1158 // over the footnote's char
1162 *pCurCrsr
->GetPoint() = aPos
;
1163 if( !GotoFtnAnchor() )
1167 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FTN
;
1169 else if ( 0 != ( pTxtAttr
= pTxtNd
->GetTxtAttrForCharAt(
1170 aPos
.nContent
.GetIndex(), RES_TXTATR_FTN
)) )
1175 SwCallLink
aLk( *this ); // watch Crsr-Moves
1176 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1177 pCurCrsr
->GetPoint()->nNode
= *((SwTxtFtn
*)pTxtAttr
)->GetStartNode();
1178 SwCntntNode
* pCNd
= GetDoc()->GetNodes().GoNextSection(
1179 &pCurCrsr
->GetPoint()->nNode
,
1180 sal_True
, !IsReadOnlyAvailable() );
1184 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, 0 );
1185 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1186 nsSwCursorSelOverFlags::SELOVER_TOGGLE
))
1197 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_FTN
;
1198 rCntntAtPos
.pFndTxtAttr
= pTxtAttr
;
1199 rCntntAtPos
.aFnd
.pAttr
= &pTxtAttr
->GetAttr();
1201 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1202 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1207 if( !bRet
&& ( SwContentAtPos::SW_TOXMARK
|
1208 SwContentAtPos::SW_REFMARK
) &
1209 rCntntAtPos
.eCntntAtPos
&& !aTmpState
.bFtnNoInfo
)
1212 if( SwContentAtPos::SW_TOXMARK
& rCntntAtPos
.eCntntAtPos
)
1214 ::std::vector
<SwTxtAttr
*> const marks(
1215 pTxtNd
->GetTxtAttrsAt(
1216 aPos
.nContent
.GetIndex(), RES_TXTATR_TOXMARK
));
1218 { // hmm... can only return 1 here
1219 pTxtAttr
= *marks
.begin();
1224 SwContentAtPos::SW_REFMARK
& rCntntAtPos
.eCntntAtPos
)
1226 ::std::vector
<SwTxtAttr
*> const marks(
1227 pTxtNd
->GetTxtAttrsAt(
1228 aPos
.nContent
.GetIndex(), RES_TXTATR_REFMARK
));
1230 { // hmm... can only return 1 here
1231 pTxtAttr
= *marks
.begin();
1240 SwCallLink
aLk( *this ); // watch Crsr-Moves
1241 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1242 pCurCrsr
->DeleteMark();
1243 *pCurCrsr
->GetPoint() = aPos
;
1244 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1245 nsSwCursorSelOverFlags::SELOVER_TOGGLE
) )
1253 const xub_StrLen
* pEnd
= pTxtAttr
->GetEnd();
1255 rCntntAtPos
.sStr
= pTxtNd
->GetExpandTxt(
1256 *pTxtAttr
->GetStart(),
1257 *pEnd
- *pTxtAttr
->GetStart() );
1258 else if( RES_TXTATR_TOXMARK
== pTxtAttr
->Which())
1259 rCntntAtPos
.sStr
= pTxtAttr
->GetTOXMark().
1260 GetAlternativeText();
1262 rCntntAtPos
.eCntntAtPos
=
1263 RES_TXTATR_TOXMARK
== pTxtAttr
->Which()
1264 ? SwContentAtPos::SW_TOXMARK
1265 : SwContentAtPos::SW_REFMARK
;
1266 rCntntAtPos
.pFndTxtAttr
= pTxtAttr
;
1267 rCntntAtPos
.aFnd
.pAttr
= &pTxtAttr
->GetAttr();
1269 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1270 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1275 if( !bRet
&& SwContentAtPos::SW_INETATTR
& rCntntAtPos
.eCntntAtPos
1276 && !aTmpState
.bFtnNoInfo
)
1278 pTxtAttr
= pTxtNd
->GetTxtAttrAt(
1279 aPos
.nContent
.GetIndex(), RES_TXTATR_INETFMT
);
1280 // "detect" only INetAttrs with URLs
1281 if( pTxtAttr
&& pTxtAttr
->GetINetFmt().GetValue().Len() )
1286 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1287 SwCallLink
aLk( *this ); // watch Crsr-Moves
1288 pCurCrsr
->DeleteMark();
1289 *pCurCrsr
->GetPoint() = aPos
;
1290 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1291 nsSwCursorSelOverFlags::SELOVER_TOGGLE
) )
1298 rCntntAtPos
.sStr
= pTxtNd
->GetExpandTxt(
1299 *pTxtAttr
->GetStart(),
1300 *pTxtAttr
->GetEnd() - *pTxtAttr
->GetStart() );
1302 rCntntAtPos
.aFnd
.pAttr
= &pTxtAttr
->GetAttr();
1303 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_INETATTR
;
1304 rCntntAtPos
.pFndTxtAttr
= pTxtAttr
;
1306 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1307 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1312 if( !bRet
&& SwContentAtPos::SW_REDLINE
& rCntntAtPos
.eCntntAtPos
)
1314 const SwRedline
* pRedl
= GetDoc()->GetRedline(aPos
, NULL
);
1317 rCntntAtPos
.aFnd
.pRedl
= pRedl
;
1318 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_REDLINE
;
1319 rCntntAtPos
.pFndTxtAttr
= 0;
1322 if( pFldRect
&& 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
) ) )
1323 pFrm
->GetCharRect( *pFldRect
, aPos
, &aTmpState
);
1329 SwContentAtPos::SW_TABLEBOXFML
& rCntntAtPos
.eCntntAtPos
1331 || SwContentAtPos::SW_TABLEBOXVALUE
& rCntntAtPos
.eCntntAtPos
1335 const SwTableNode
* pTblNd
;
1336 const SwTableBox
* pBox
;
1337 const SwStartNode
* pSttNd
= pTxtNd
->FindTableBoxStartNode();
1338 const SfxPoolItem
* pItem
;
1339 if( pSttNd
&& 0 != ( pTblNd
= pTxtNd
->FindTableNode()) &&
1340 0 != ( pBox
= pTblNd
->GetTable().GetTblBox(
1341 pSttNd
->GetIndex() )) &&
1343 ( SFX_ITEM_SET
== pBox
->GetFrmFmt()->GetItemState(
1344 RES_BOXATR_FORMULA
, sal_False
, &pItem
) ||
1345 SFX_ITEM_SET
== pBox
->GetFrmFmt()->GetItemState(
1346 RES_BOXATR_VALUE
, sal_False
, &pItem
))
1348 SFX_ITEM_SET
== pBox
->GetFrmFmt()->GetItemState(
1349 RES_BOXATR_FORMULA
, sal_False
, &pItem
)
1353 SwFrm
* pF
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
);
1356 // then the CellFrame
1357 pFrm
= (SwCntntFrm
*)pF
;
1358 while( pF
&& !pF
->IsCellFrm() )
1359 pF
= pF
->GetUpper();
1362 if( aTmpState
.bPosCorr
)
1364 if( pF
&& !pF
->Frm().IsInside( aPt
))
1370 if( pF
) // only then it is valid
1372 // create from internal (for CORE) the external
1374 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_TABLEBOXFML
;
1376 if( RES_BOXATR_VALUE
== pItem
->Which() )
1377 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_TABLEBOXVALUE
;
1380 ((SwTblBoxFormula
*)pItem
)->PtrToBoxNm( &pTblNd
->GetTable() );
1385 SwCallLink
aLk( *this ); // watch Crsr-Moves
1386 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1387 *pCurCrsr
->GetPoint() = aPos
;
1388 if( pCurCrsr
->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION
|
1389 nsSwCursorSelOverFlags::SELOVER_TOGGLE
) )
1399 *pFldRect
= pF
->Prt();
1400 *pFldRect
+= pF
->Frm().Pos();
1402 rCntntAtPos
.pFndTxtAttr
= 0;
1403 rCntntAtPos
.aFnd
.pAttr
= pItem
;
1410 if( !bRet
&& SwContentAtPos::SW_CURR_ATTRS
& rCntntAtPos
.eCntntAtPos
)
1412 xub_StrLen n
= aPos
.nContent
.GetIndex();
1413 SfxItemSet
aSet( GetDoc()->GetAttrPool(), POOLATTR_BEGIN
,
1415 if( pTxtNd
->GetpSwpHints() )
1417 for( sal_uInt16 i
= 0; i
< pTxtNd
->GetSwpHints().Count(); ++i
)
1419 const SwTxtAttr
* pHt
= pTxtNd
->GetSwpHints()[i
];
1420 xub_StrLen nAttrStart
= *pHt
->GetStart();
1421 if( nAttrStart
> n
) // over the section
1424 if( 0 != pHt
->GetEnd() && (
1426 ( pHt
->DontExpand() ? n
< *pHt
->GetEnd()
1427 : n
<= *pHt
->GetEnd() )) ||
1428 ( n
== nAttrStart
&&
1429 ( nAttrStart
== *pHt
->GetEnd() || !n
))) )
1431 aSet
.Put( pHt
->GetAttr() );
1434 if( pTxtNd
->HasSwAttrSet() &&
1435 pTxtNd
->GetpSwAttrSet()->Count() )
1437 SfxItemSet
aFmtSet( pTxtNd
->GetSwAttrSet() );
1438 // remove all from format set that are also in TextSet
1439 aFmtSet
.Differentiate( aSet
);
1440 // now merge all together
1441 aSet
.Put( aFmtSet
);
1445 pTxtNd
->SwCntntNode::GetAttr( aSet
);
1447 rCntntAtPos
.sStr
.AssignAscii(
1448 RTL_CONSTASCII_STRINGPARAM( "Pos: (" ));
1449 rCntntAtPos
.sStr
+= String::CreateFromInt32( aPos
.nNode
.GetIndex());
1450 rCntntAtPos
.sStr
+= ':';
1451 rCntntAtPos
.sStr
+= String::CreateFromInt32( aPos
.nContent
.GetIndex());
1452 rCntntAtPos
.sStr
+= ')';
1453 rCntntAtPos
.sStr
.AppendAscii(
1454 RTL_CONSTASCII_STRINGPARAM( "\nAbs.Vorl.: " )); // translation *might be* "paragraph template"
1455 rCntntAtPos
.sStr
+= pTxtNd
->GetFmtColl()->GetName();
1456 if( pTxtNd
->GetCondFmtColl() )
1457 rCntntAtPos
.sStr
.AppendAscii(
1458 RTL_CONSTASCII_STRINGPARAM( "\nBed.Vorl.: " )) // translation *might be* "conditional template"
1459 += pTxtNd
->GetCondFmtColl()->GetName();
1464 SfxItemIter
aIter( aSet
);
1465 const SfxPoolItem
* pItem
= aIter
.FirstItem();
1468 if( !IsInvalidItem( pItem
))
1471 GetDoc()->GetAttrPool().GetPresentation( *pItem
,
1472 SFX_ITEM_PRESENTATION_COMPLETE
,
1473 SFX_MAPUNIT_CM
, aStr
);
1476 RTL_CONSTASCII_STRINGPARAM( ", " ));
1479 if( aIter
.IsAtEnd() )
1481 pItem
= aIter
.NextItem();
1485 if( rCntntAtPos
.sStr
.Len() )
1486 rCntntAtPos
.sStr
+= '\n';
1487 rCntntAtPos
.sStr
.AppendAscii(
1488 RTL_CONSTASCII_STRINGPARAM( "Attr: " ) )
1493 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_CURR_ATTRS
;
1501 rCntntAtPos
.eCntntAtPos
= SwContentAtPos::SW_NOTHING
;
1502 rCntntAtPos
.aFnd
.pFld
= 0;
1508 const SwPostItField
* SwCrsrShell::GetPostItFieldAtCursor() const
1510 const SwPostItField
* pPostItFld
= 0;
1512 if ( !IsTableMode() )
1514 const SwPosition
* pCursorPos
= _GetCrsr()->GetPoint();
1515 const SwTxtNode
* pTxtNd
= pCursorPos
->nNode
.GetNode().GetTxtNode();
1518 SwTxtAttr
* pTxtAttr
= pTxtNd
->GetTxtAttrForCharAt(
1519 pCursorPos
->nContent
.GetIndex(), RES_TXTATR_FIELD
);
1520 const SwField
* pFld
= pTxtAttr
? pTxtAttr
->GetFld().GetFld() : 0;
1521 if ( pFld
&& pFld
->Which()== RES_POSTITFLD
)
1523 pPostItFld
= static_cast<const SwPostItField
*>(pFld
);
1531 /// is the node in a protected section?
1532 bool SwContentAtPos::IsInProtectSect() const
1534 const SwTxtNode
* pNd
= 0;
1537 switch( eCntntAtPos
)
1541 pNd
= ((SwTxtFld
*)pFndTxtAttr
)->GetpTxtNode();
1545 pNd
= &((SwTxtFtn
*)pFndTxtAttr
)->GetTxtNode();
1549 pNd
= ((SwTxtINetFmt
*)pFndTxtAttr
)->GetpTxtNode();
1557 const SwCntntFrm
* pFrm
;
1558 return pNd
&& ( pNd
->IsInProtectSect() ||
1559 ( 0 != ( pFrm
= pNd
->getLayoutFrm( pNd
->GetDoc()->GetCurrentLayout(), 0,0,sal_False
)) &&
1560 pFrm
->IsProtected() ));
1563 bool SwContentAtPos::IsInRTLText()const
1566 const SwTxtNode
* pNd
= 0;
1567 if (pFndTxtAttr
&& (eCntntAtPos
== SW_FTN
))
1569 const SwTxtFtn
* pTxtFtn
= static_cast<const SwTxtFtn
*>(pFndTxtAttr
);
1570 if(pTxtFtn
->GetStartNode())
1572 SwStartNode
* pSttNd
= pTxtFtn
->GetStartNode()->GetNode().GetStartNode();
1573 SwPaM
aTemp( *pSttNd
);
1574 aTemp
.Move(fnMoveForward
, fnGoNode
);
1575 SwCntntNode
* pCntntNode
= aTemp
.GetCntntNode();
1576 if(pCntntNode
&& pCntntNode
->IsTxtNode())
1577 pNd
= static_cast<SwTxtNode
*>(pCntntNode
);
1582 SwIterator
<SwTxtFrm
,SwTxtNode
> aIter(*pNd
);
1583 SwTxtFrm
* pTmpFrm
= aIter
.First();
1586 if ( !pTmpFrm
->IsFollow())
1588 bRet
= pTmpFrm
->IsRightToLeft();
1591 pTmpFrm
= aIter
.Next();
1597 sal_Bool
SwCrsrShell::SelectTxtAttr( sal_uInt16 nWhich
, sal_Bool bExpand
,
1598 const SwTxtAttr
* pTxtAttr
)
1600 SET_CURR_SHELL( this );
1601 sal_Bool bRet
= sal_False
;
1603 if( !IsTableMode() )
1605 SwPosition
& rPos
= *pCurCrsr
->GetPoint();
1608 SwTxtNode
* pTxtNd
= rPos
.nNode
.GetNode().GetTxtNode();
1610 ? pTxtNd
->GetTxtAttrAt(rPos
.nContent
.GetIndex(),
1611 static_cast<RES_TXTATR
>(nWhich
),
1612 (bExpand
) ? SwTxtNode::EXPAND
: SwTxtNode::DEFAULT
)
1618 SwCallLink
aLk( *this ); // watch Crsr-Moves
1619 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1621 pCurCrsr
->DeleteMark();
1622 rPos
.nContent
= *pTxtAttr
->GetStart();
1623 pCurCrsr
->SetMark();
1624 const xub_StrLen
* pEnd
= pTxtAttr
->GetEnd();
1625 rPos
.nContent
= pEnd
? *pEnd
: *pTxtAttr
->GetStart() + 1;
1627 if( !pCurCrsr
->IsSelOvr() )
1638 bool SwCrsrShell::GotoINetAttr( const SwTxtINetFmt
& rAttr
)
1641 if( rAttr
.GetpTxtNode() )
1643 SwCursor
* pCrsr
= getShellCrsr( true );
1645 SET_CURR_SHELL( this );
1646 SwCallLink
aLk( *this ); // watch Crsr-Moves
1647 SwCrsrSaveState
aSaveState( *pCrsr
);
1649 pCrsr
->GetPoint()->nNode
= *rAttr
.GetpTxtNode();
1650 pCrsr
->GetPoint()->nContent
.Assign( (SwTxtNode
*)rAttr
.GetpTxtNode(),
1651 *rAttr
.GetStart() );
1652 bRet
= !pCrsr
->IsSelOvr();
1654 UpdateCrsr(SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
1660 const SwFmtINetFmt
* SwCrsrShell::FindINetAttr( const String
& rName
) const
1662 return pDoc
->FindINetAttr( rName
);
1665 sal_Bool
SwCrsrShell::GetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
,
1666 SwRect
& rRect
, sal_Int16
& rOrient
)
1669 SET_CURR_SHELL( this );
1670 sal_Bool bRet
= sal_False
;
1672 if (!IsTableMode() && !HasSelection()
1673 && GetDoc()->GetIDocumentUndoRedo().DoesUndo())
1676 SwPosition
aPos( *pCurCrsr
->GetPoint() );
1678 SwFillCrsrPos
aFPos( eFillMode
);
1679 SwCrsrMoveState
aTmpState( &aFPos
);
1681 if( GetLayout()->GetCrsrOfst( &aPos
, aPt
, &aTmpState
) &&
1682 !aPos
.nNode
.GetNode().IsProtect())
1684 // start position in protected section?
1685 rRect
= aFPos
.aCrsr
;
1686 rOrient
= aFPos
.eOrient
;
1693 sal_Bool
SwCrsrShell::SetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
)
1695 SET_CURR_SHELL( this );
1696 sal_Bool bRet
= sal_False
;
1698 if (!IsTableMode() && !HasSelection()
1699 && GetDoc()->GetIDocumentUndoRedo().DoesUndo())
1702 SwPosition
aPos( *pCurCrsr
->GetPoint() );
1704 SwFillCrsrPos
aFPos( eFillMode
);
1705 SwCrsrMoveState
aTmpState( &aFPos
);
1707 if( GetLayout()->GetCrsrOfst( &aPos
, aPt
, &aTmpState
) )
1709 SwCallLink
aLk( *this ); // watch Crsr-Moves
1712 SwCntntNode
* pCNd
= aPos
.nNode
.GetNode().GetCntntNode();
1713 SwUndoId nUndoId
= UNDO_INS_FROM_SHADOWCRSR
;
1714 // If only the paragraph attributes "Adjust" or "LRSpace" are set,
1715 // then the following should not delete those again.
1716 if( 0 == aFPos
.nParaCnt
+ aFPos
.nColumnCnt
&&
1717 ( FILL_INDENT
== aFPos
.eMode
||
1718 ( text::HoriOrientation::NONE
!= aFPos
.eOrient
&&
1719 0 == aFPos
.nTabCnt
+ aFPos
.nSpaceCnt
)) &&
1720 pCNd
&& pCNd
->Len() )
1721 nUndoId
= UNDO_EMPTY
;
1723 GetDoc()->GetIDocumentUndoRedo().StartUndo( nUndoId
, NULL
);
1725 SwTxtFmtColl
* pNextFmt
= 0;
1726 SwTxtNode
* pTNd
= pCNd
->GetTxtNode();
1728 pNextFmt
= &pTNd
->GetTxtColl()->GetNextTxtFmtColl();
1730 const SwSectionNode
* pSectNd
= pCNd
->FindSectionNode();
1731 if( pSectNd
&& aFPos
.nParaCnt
)
1733 SwNodeIndex
aEnd( aPos
.nNode
, 1 );
1734 while( aEnd
.GetNode().IsEndNode() &&
1735 (const SwNode
*)&aEnd
.GetNode() !=
1736 pSectNd
->EndOfSectionNode() )
1739 if( aEnd
.GetNode().IsEndNode() &&
1740 pCNd
->Len() == aPos
.nContent
.GetIndex() )
1741 aPos
.nNode
= *pSectNd
->EndOfSectionNode();
1744 for( sal_uInt16 n
= 0; n
< aFPos
.nParaCnt
+ aFPos
.nColumnCnt
; ++n
)
1746 GetDoc()->AppendTxtNode( aPos
);
1747 if( !n
&& pNextFmt
)
1749 *pCurCrsr
->GetPoint() = aPos
;
1750 GetDoc()->SetTxtFmtColl( *pCurCrsr
, pNextFmt
, false );
1752 if( n
< aFPos
.nColumnCnt
)
1754 *pCurCrsr
->GetPoint() = aPos
;
1755 GetDoc()->InsertPoolItem( *pCurCrsr
,
1756 SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE
, RES_BREAK
), 0);
1760 *pCurCrsr
->GetPoint() = aPos
;
1761 switch( aFPos
.eMode
)
1764 if( 0 != (pCNd
= aPos
.nNode
.GetNode().GetCntntNode() ))
1766 SfxItemSet
aSet( GetDoc()->GetAttrPool(),
1767 RES_LR_SPACE
, RES_LR_SPACE
,
1768 RES_PARATR_ADJUST
, RES_PARATR_ADJUST
,
1770 SvxLRSpaceItem
aLR( (SvxLRSpaceItem
&)
1771 pCNd
->GetAttr( RES_LR_SPACE
) );
1772 aLR
.SetTxtLeft( aFPos
.nTabCnt
);
1773 aLR
.SetTxtFirstLineOfst( 0 );
1776 const SvxAdjustItem
& rAdj
= (SvxAdjustItem
&)pCNd
->
1777 GetAttr( RES_PARATR_ADJUST
);
1778 if( SVX_ADJUST_LEFT
!= rAdj
.GetAdjust() )
1779 aSet
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, RES_PARATR_ADJUST
) );
1781 GetDoc()->InsertItemSet( *pCurCrsr
, aSet
, 0 );
1784 OSL_ENSURE( !this, "No CntntNode" );
1791 rtl::OUStringBuffer sInsert
;
1793 comphelper::string::padToLength(sInsert
, aFPos
.nTabCnt
, '\t');
1794 if (aFPos
.nSpaceCnt
)
1795 comphelper::string::padToLength(sInsert
, sInsert
.getLength() + aFPos
.nSpaceCnt
, ' ');
1796 if (sInsert
.getLength())
1797 GetDoc()->InsertString( *pCurCrsr
, sInsert
.makeStringAndClear());
1799 // no break - still need to set orientation
1801 if( text::HoriOrientation::NONE
!= aFPos
.eOrient
)
1803 SvxAdjustItem
aAdj( SVX_ADJUST_LEFT
, RES_PARATR_ADJUST
);
1804 switch( aFPos
.eOrient
)
1806 case text::HoriOrientation::CENTER
:
1807 aAdj
.SetAdjust( SVX_ADJUST_CENTER
);
1809 case text::HoriOrientation::RIGHT
:
1810 aAdj
.SetAdjust( SVX_ADJUST_RIGHT
);
1815 GetDoc()->InsertPoolItem( *pCurCrsr
, aAdj
, 0 );
1820 GetDoc()->GetIDocumentUndoRedo().EndUndo( nUndoId
, NULL
);
1829 const SwRedline
* SwCrsrShell::SelNextRedline()
1831 const SwRedline
* pFnd
= 0;
1832 if( !IsTableMode() )
1834 SET_CURR_SHELL( this );
1835 SwCallLink
aLk( *this ); // watch Crsr-Moves
1836 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1838 pFnd
= GetDoc()->SelNextRedline( *pCurCrsr
);
1839 if( pFnd
&& !pCurCrsr
->IsInProtectTable() && !pCurCrsr
->IsSelOvr() )
1840 UpdateCrsr( SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
1847 const SwRedline
* SwCrsrShell::SelPrevRedline()
1849 const SwRedline
* pFnd
= 0;
1850 if( !IsTableMode() )
1852 SET_CURR_SHELL( this );
1853 SwCallLink
aLk( *this ); // watch Crsr-Moves
1854 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1856 pFnd
= GetDoc()->SelPrevRedline( *pCurCrsr
);
1857 if( pFnd
&& !pCurCrsr
->IsInProtectTable() && !pCurCrsr
->IsSelOvr() )
1858 UpdateCrsr( SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|SwCrsrShell::READONLY
);
1865 const SwRedline
* SwCrsrShell::_GotoRedline( sal_uInt16 nArrPos
, sal_Bool bSelect
)
1867 const SwRedline
* pFnd
= 0;
1868 SwCallLink
aLk( *this ); // watch Crsr-Moves
1869 SwCrsrSaveState
aSaveState( *pCurCrsr
);
1871 pFnd
= GetDoc()->GetRedlineTbl()[ nArrPos
];
1874 *pCurCrsr
->GetPoint() = *pFnd
->Start();
1877 SwNodeIndex
* pIdx
= &pCurCrsr
->GetPoint()->nNode
;
1878 if( !pIdx
->GetNode().IsCntntNode() &&
1879 0 != ( pCNd
= GetDoc()->GetNodes().GoNextSection( pIdx
,
1880 sal_True
, IsReadOnlyAvailable() )) )
1882 if( *pIdx
<= pFnd
->End()->nNode
)
1883 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, 0 );
1888 if( pFnd
&& bSelect
)
1890 pCurCrsr
->SetMark();
1891 if( nsRedlineType_t::REDLINE_FMTCOLL
== pFnd
->GetType() )
1893 pCNd
= pIdx
->GetNode().GetCntntNode();
1894 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, pCNd
->Len() );
1895 pCurCrsr
->GetMark()->nContent
.Assign( pCNd
, 0 );
1898 *pCurCrsr
->GetPoint() = *pFnd
->End();
1900 pIdx
= &pCurCrsr
->GetPoint()->nNode
;
1901 if( !pIdx
->GetNode().IsCntntNode() &&
1902 0 != ( pCNd
= GetDoc()->GetNodes().GoPrevSection( pIdx
,
1903 sal_True
, IsReadOnlyAvailable() )) )
1905 if( *pIdx
>= pCurCrsr
->GetMark()->nNode
)
1906 pCurCrsr
->GetPoint()->nContent
.Assign( pCNd
, pCNd
->Len() );
1914 pCurCrsr
->DeleteMark();
1915 pCurCrsr
->RestoreSavePos();
1917 else if( bSelect
&& *pCurCrsr
->GetMark() == *pCurCrsr
->GetPoint() )
1918 pCurCrsr
->DeleteMark();
1920 if( pFnd
&& !pCurCrsr
->IsInProtectTable() && !pCurCrsr
->IsSelOvr() )
1921 UpdateCrsr( SwCrsrShell::SCROLLWIN
| SwCrsrShell::CHKRANGE
1922 | SwCrsrShell::READONLY
);
1927 pCurCrsr
->DeleteMark();
1933 const SwRedline
* SwCrsrShell::GotoRedline( sal_uInt16 nArrPos
, sal_Bool bSelect
)
1935 const SwRedline
* pFnd
= 0;
1936 if( !IsTableMode() )
1938 SET_CURR_SHELL( this );
1940 const SwRedlineTbl
& rTbl
= GetDoc()->GetRedlineTbl();
1941 const SwRedline
* pTmp
= rTbl
[ nArrPos
];
1942 sal_uInt16 nSeqNo
= pTmp
->GetSeqNo();
1943 if( nSeqNo
&& bSelect
)
1945 bool bCheck
= false;
1947 sal_uInt16 nArrSavPos
= nArrPos
;
1950 pTmp
= _GotoRedline( nArrPos
, sal_True
);
1955 if( pTmp
&& bCheck
)
1957 // Check for overlaps. These can happen when FmtColl-
1958 // Redlines were streched over a whole paragraph
1959 SwPaM
* pCur
= pCurCrsr
;
1960 SwPaM
* pNextPam
= (SwPaM
*)pCur
->GetNext();
1961 SwPosition
* pCStt
= pCur
->Start(), *pCEnd
= pCur
->End();
1962 while( pCur
!= pNextPam
)
1964 const SwPosition
*pNStt
= pNextPam
->Start(),
1965 *pNEnd
= pNextPam
->End();
1968 switch( ::ComparePosition( *pCStt
, *pCEnd
,
1971 case POS_INSIDE
: // Pos1 is completely in Pos2
1972 if( !pCur
->HasMark() )
1975 *pCur
->GetMark() = *pNStt
;
1982 case POS_OUTSIDE
: // Pos2 is completely in Pos1
1983 case POS_EQUAL
: // Pos1 has same size as Pos2
1986 case POS_OVERLAP_BEFORE
: // Pos1 overlaps Pos2 at beginning
1987 if( !pCur
->HasMark() )
1991 case POS_OVERLAP_BEHIND
: // Pos1 overlaps Pos2 at end
1992 if( !pCur
->HasMark() )
1995 *pCur
->GetMark() = *pNStt
;
2007 // not needed anymore
2008 SwPaM
* pPrevPam
= (SwPaM
*)pNextPam
->GetPrev();
2010 pNextPam
= pPrevPam
;
2012 pNextPam
= (SwPaM
*)pNextPam
->GetNext();
2016 sal_uInt16 nFndPos
= 2 == nLoopCnt
2017 ? rTbl
.FindNextOfSeqNo( nArrPos
)
2018 : rTbl
.FindPrevOfSeqNo( nArrPos
);
2019 if( USHRT_MAX
!= nFndPos
||
2020 ( 0 != ( --nLoopCnt
) && USHRT_MAX
!= (
2021 nFndPos
= rTbl
.FindPrevOfSeqNo( nArrSavPos
))) )
2025 // create new cursor
2034 } while( nLoopCnt
);
2037 pFnd
= _GotoRedline( nArrPos
, bSelect
);
2043 sal_Bool
SwCrsrShell::SelectNxtPrvHyperlink( sal_Bool bNext
)
2045 SwNodes
& rNds
= GetDoc()->GetNodes();
2046 const SwNode
* pBodyEndNd
= &rNds
.GetEndOfContent();
2047 const SwNode
* pBodySttNd
= pBodyEndNd
->StartOfSectionNode();
2048 sal_uLong nBodySttNdIdx
= pBodySttNd
->GetIndex();
2051 _SetGetExpFld
aCmpPos( SwPosition( bNext
? *pBodyEndNd
: *pBodySttNd
) );
2052 _SetGetExpFld
aCurPos( bNext
? *pCurCrsr
->End() : *pCurCrsr
->Start() );
2053 if( aCurPos
.GetNode() < nBodySttNdIdx
)
2055 const SwCntntNode
* pCNd
= aCurPos
.GetNodeFromCntnt()->GetCntntNode();
2057 if( pCNd
&& 0 != ( pFrm
= pCNd
->getLayoutFrm( GetLayout(), &aPt
)) )
2058 aCurPos
.SetBodyPos( *pFrm
);
2061 // check first all the hyperlink fields
2063 const SwTxtNode
* pTxtNd
;
2064 const SwCharFmts
* pFmts
= GetDoc()->GetCharFmts();
2065 for( sal_uInt16 n
= pFmts
->size(); 1 < n
; )
2067 SwIterator
<SwTxtINetFmt
,SwCharFmt
> aIter(*(*pFmts
)[--n
]);
2069 for( SwTxtINetFmt
* pFnd
= aIter
.First(); pFnd
; pFnd
= aIter
.Next() )
2070 if( 0 != ( pTxtNd
= pFnd
->GetpTxtNode()) &&
2071 pTxtNd
->GetNodes().IsDocNodes() )
2073 SwTxtINetFmt
& rAttr
= *pFnd
;
2074 SwPosition
aTmpPos( *pTxtNd
);
2075 _SetGetExpFld
aPos( aTmpPos
.nNode
, rAttr
);
2077 if( pTxtNd
->GetIndex() < nBodySttNdIdx
&&
2078 0 != ( pFrm
= pTxtNd
->getLayoutFrm( GetLayout(), &aPt
)) )
2079 aPos
.SetBodyPos( *pFrm
);
2082 ? ( aPos
< aCmpPos
&& aCurPos
< aPos
)
2083 : ( aCmpPos
< aPos
&& aPos
< aCurPos
))
2085 String
sTxt( pTxtNd
->GetExpandTxt( *rAttr
.GetStart(),
2086 *rAttr
.GetEnd() - *rAttr
.GetStart() ) );
2088 sTxt
= comphelper::string::remove(sTxt
, 0x0a);
2089 sTxt
= comphelper::string::strip(sTxt
, ' ');
2097 // then check all the Flys with a URL or imapge map
2099 const SwFrmFmts
* pFmts
= GetDoc()->GetSpzFrmFmts();
2100 for( sal_uInt16 n
= 0, nEnd
= pFmts
->size(); n
< nEnd
; ++n
)
2102 SwFlyFrmFmt
* pFmt
= (SwFlyFrmFmt
*)(*pFmts
)[ n
];
2103 const SwFmtURL
& rURLItem
= pFmt
->GetURL();
2104 if( rURLItem
.GetMap() || rURLItem
.GetURL().Len() )
2106 SwFlyFrm
* pFly
= pFmt
->GetFrm( &aPt
, sal_False
);
2107 SwPosition
aTmpPos( *pBodySttNd
);
2109 GetBodyTxtNode( *GetDoc(), aTmpPos
, *pFly
->GetLower() ) )
2111 _SetGetExpFld
aPos( *pFmt
, &aTmpPos
);
2114 ? ( aPos
< aCmpPos
&& aCurPos
< aPos
)
2115 : ( aCmpPos
< aPos
&& aPos
< aCurPos
))
2123 sal_Bool bRet
= sal_False
;
2124 const SwTxtINetFmt
* pFndAttr
= aCmpPos
.GetINetFmt();
2125 const SwFlyFrmFmt
* pFndFmt
= aCmpPos
.GetFlyFmt();
2126 if( pFndAttr
|| pFndFmt
)
2128 SET_CURR_SHELL( this );
2129 SwCallLink
aLk( *this );
2131 // found a text attribute ?
2134 SwCrsrSaveState
aSaveState( *pCurCrsr
);
2136 aCmpPos
.GetPosOfContent( *pCurCrsr
->GetPoint() );
2137 pCurCrsr
->DeleteMark();
2138 pCurCrsr
->SetMark();
2139 pCurCrsr
->GetPoint()->nContent
= *pFndAttr
->SwTxtAttr::GetEnd();
2141 if( !pCurCrsr
->IsInProtectTable() && !pCurCrsr
->IsSelOvr() )
2143 UpdateCrsr( SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
|
2144 SwCrsrShell::READONLY
);
2148 // found a draw object ?
2149 else if( RES_DRAWFRMFMT
== pFndFmt
->Which() )
2151 const SdrObject
* pSObj
= pFndFmt
->FindSdrObject();
2152 ((SwFEShell
*)this)->SelectObj( pSObj
->GetCurrentBoundRect().Center() );
2156 else // then is it a fly
2158 SwFlyFrm
* pFly
= pFndFmt
->GetFrm(&aPt
, sal_False
);
2161 ((SwFEShell
*)this)->SelectFlyFrm( *pFly
, sal_True
);
2170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */