LibreOffice Module sw (master) 1
crstrvl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <memory>
21#include <utility>
22#include <hintids.hxx>
23#include <comphelper/string.hxx>
24#include <svl/itemiter.hxx>
25#include <editeng/lrspitem.hxx>
28#include <svx/svdobj.hxx>
29#include <osl/diagnose.h>
30#include <crsrsh.hxx>
31#include <doc.hxx>
32#include <IDocumentUndoRedo.hxx>
36#include <pagefrm.hxx>
37#include <cntfrm.hxx>
38#include <rootfrm.hxx>
39#include <pam.hxx>
40#include <ndtxt.hxx>
41#include <fldbas.hxx>
42#include <swtable.hxx>
43#include <docary.hxx>
44#include <txtfld.hxx>
45#include <fmtfld.hxx>
46#include <txtftn.hxx>
47#include <txtinet.hxx>
48#include <fmtinfmt.hxx>
49#include <txttxmrk.hxx>
50#include <frmfmt.hxx>
51#include <flyfrm.hxx>
52#include <viscrs.hxx>
53#include "callnk.hxx"
54#include <doctxm.hxx>
55#include <docfld.hxx>
56#include <expfld.hxx>
57#include <reffld.hxx>
58#include <flddat.hxx>
59#include <cellatr.hxx>
60#include <swundo.hxx>
61#include <redline.hxx>
62#include <fmtcntnt.hxx>
63#include <fmthdft.hxx>
64#include <pagedesc.hxx>
65#include <fesh.hxx>
66#include <charfmt.hxx>
67#include <fmturl.hxx>
68#include <txtfrm.hxx>
69#include <wrong.hxx>
70#include <calbck.hxx>
72#include <docufld.hxx>
73#include <svx/srchdlg.hxx>
74#include <frameformats.hxx>
75#include <docsh.hxx>
76#include <wrtsh.hxx>
78
79using namespace ::com::sun::star;
80
82{
83 SwCallLink aLk( *this ); // watch Cursor-Moves
85 if( ActionPend() )
86 return;
87 CurrShell aCurr( this );
88 // try to set cursor onto this position, at half of the char-
89 // SRectangle's height
91 std::pair<Point, bool> const tmp(aPt, true);
95 pFrame->Calc(GetOut());
96 if( pFrame->IsVertical() )
97 {
98 aPt.setX(m_aCharRect.Center().getX());
99 aPt.setY(pFrame->getFrameArea().Top() + GetUpDownX());
100 }
101 else
102 {
103 aPt.setY(m_aCharRect.Center().getY());
104 aPt.setX(pFrame->getFrameArea().Left() + GetUpDownX());
105 }
109 {
113 }
114}
115
118{
120 return;
122}
123
125{
127 return;
129}
130
133{
134 const SwFrame* pFrame = GetCurrFrame()->FindPageFrame();
135 while( pFrame && !pFrame->IsHeaderFrame() )
136 pFrame = pFrame->GetLower();
137 // found header, search 1. content frame
138 while( pFrame && !pFrame->IsContentFrame() )
139 pFrame = pFrame->GetLower();
140
141 if( !pFrame )
142 return false;
143
144 CurrShell aCurr( this );
145 // get header frame
146 SwCallLink aLk( *this ); // watch Cursor-Moves
147 SwCursor *pTmpCursor = getShellCursor( true );
148 SwCursorSaveState aSaveState( *pTmpCursor );
149 pFrame->Calc(GetOut());
150 Point aPt( pFrame->getFrameArea().Pos() + pFrame->getFramePrintArea().Pos() );
151 pFrame->GetModelPositionForViewPoint( pTmpCursor->GetPoint(), aPt );
152 if( !pTmpCursor->IsSelOvr() )
153 UpdateCursor();
154 else
155 pFrame = nullptr;
156 return nullptr != pFrame;
157}
158
161{
162 const SwPageFrame* pFrame = GetCurrFrame()->FindPageFrame();
163 if( !pFrame )
164 return false;
165
166 const SwFrame* pLower = pFrame->GetLastLower();
167
168 while( pLower && !pLower->IsFooterFrame() )
169 pLower = pLower->GetLower();
170 // found footer, search 1. content frame
171 while( pLower && !pLower->IsContentFrame() )
172 pLower = pLower->GetLower();
173
174 if( !pLower )
175 return false;
176
177 SwCursor *pTmpCursor = getShellCursor( true );
178 CurrShell aCurr( this );
179 // get position in footer
180 SwCallLink aLk( *this ); // watch Cursor-Moves
181 SwCursorSaveState aSaveState( *pTmpCursor );
182 pLower->Calc(GetOut());
183 Point aPt( pLower->getFrameArea().Pos() + pLower->getFramePrintArea().Pos() );
184 pLower->GetModelPositionForViewPoint( pTmpCursor->GetPoint(), aPt );
185 if( !pTmpCursor->IsSelOvr() )
186 UpdateCursor();
187 else
188 pFrame = nullptr;
189 return nullptr != pFrame;
190}
191
192bool SwCursorShell::SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven, bool bFirst)
193{
194 SwDoc *pMyDoc = GetDoc();
195 const SwPageDesc* pDesc = nullptr;
196
197 CurrShell aCurr( this );
198
199 if( SIZE_MAX == nDescNo )
200 {
201 // take the current one
202 const SwContentFrame *pCurrFrame = GetCurrFrame();
203 const SwPageFrame* pPage = (pCurrFrame == nullptr) ? nullptr : pCurrFrame->FindPageFrame();
204 if( pPage && pMyDoc->ContainsPageDesc(
205 pPage->GetPageDesc(), &nDescNo) )
206 pDesc = pPage->GetPageDesc();
207 }
208 else
209 if (nDescNo < pMyDoc->GetPageDescCnt())
210 pDesc = &pMyDoc->GetPageDesc( nDescNo );
211
212 if( !pDesc )
213 return false;
214
215 // check if the attribute exists
216 const SwFormatContent* pCnt = nullptr;
217 if( bInHeader )
218 {
219 const SwFormatHeader& rHd
220 = bEven ? bFirst ? pDesc->GetFirstLeft().GetHeader() : pDesc->GetLeft().GetHeader()
221 : bFirst ? pDesc->GetFirstMaster().GetHeader() : pDesc->GetMaster().GetHeader();
222 if( rHd.GetHeaderFormat() )
223 pCnt = &rHd.GetHeaderFormat()->GetContent();
224 }
225 else
226 {
227 const SwFormatFooter& rFt
228 = bEven ? bFirst ? pDesc->GetFirstLeft().GetFooter() : pDesc->GetLeft().GetFooter()
229 : bFirst ? pDesc->GetFirstMaster().GetFooter() : pDesc->GetMaster().GetFooter();
230 if( rFt.GetFooterFormat() )
231 pCnt = &rFt.GetFooterFormat()->GetContent();
232 }
233
234 if( !pCnt || !pCnt->GetContentIdx() )
235 return false;
236
237 SwNodeIndex aIdx( *pCnt->GetContentIdx(), 1 );
238 SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
239 if( !pCNd )
240 pCNd = pMyDoc->GetNodes().GoNext( &aIdx );
241
243
244 std::pair<Point, bool> const tmp(aPt, false);
245 if (!pCNd || nullptr == pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp))
246 return false;
247
248 // then we can set the cursor in here
249 SwCallLink aLk( *this ); // watch Cursor-Moves
250 SwCursorSaveState aSaveState( *m_pCurrentCursor );
251
252 ClearMark();
253
255 rPos.Assign( *pCNd );
256
258 return false;
259
262 return true;
263}
264
266bool SwCursorShell::GotoNextTOXBase( const OUString* pName )
267{
268 const SwSectionFormats& rFormats = GetDoc()->GetSections();
269 SwContentNode* pFnd = nullptr;
270 for( SwSectionFormats::size_type n = rFormats.size(); n; )
271 {
272 const SwSection* pSect = rFormats[ --n ]->GetSection();
273 if (SectionType::ToxContent == pSect->GetType())
274 {
275 SwSectionNode const*const pSectNd(
276 pSect->GetFormat()->GetSectionNode());
277 if ( pSectNd
278 && m_pCurrentCursor->GetPoint()->GetNode() < *pSectNd
279 && (!pFnd || pFnd->GetIndex() > pSectNd->GetIndex())
280 && (!pName || *pName ==
281 static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()))
282 {
283 SwNodeIndex aIdx(*pSectNd, 1);
284 SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
285 if (!pCNd)
286 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
287 if (pCNd &&
288 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex())
289 {
290 SwContentFrame const*const pCFrame(
291 pCNd->getLayoutFrame(GetLayout()));
292 if (pCFrame &&
293 (IsReadOnlyAvailable() || !pCFrame->IsProtected()))
294 {
295 pFnd = pCNd;
296 }
297 }
298 }
299 }
300 }
301 if( !pFnd )
302 return false;
303 SwCallLink aLk( *this ); // watch Cursor-Moves
304 SwCursorSaveState aSaveState( *m_pCurrentCursor );
305 m_pCurrentCursor->GetPoint()->Assign( *pFnd );
306 bool bRet = !m_pCurrentCursor->IsSelOvr();
307 if( bRet )
309 return bRet;
310}
311
313bool SwCursorShell::GotoPrevTOXBase( const OUString* pName )
314{
315 const SwSectionFormats& rFormats = GetDoc()->GetSections();
316 SwContentNode* pFnd = nullptr;
317 for( SwSectionFormats::size_type n = rFormats.size(); n; )
318 {
319 const SwSection* pSect = rFormats[ --n ]->GetSection();
320 if (SectionType::ToxContent == pSect->GetType())
321 {
322 SwSectionNode const*const pSectNd(
323 pSect->GetFormat()->GetSectionNode());
324 if ( pSectNd
326 && (!pFnd || *pFnd < *pSectNd)
327 && (!pName || *pName ==
328 static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()))
329 {
330 SwNodeIndex aIdx(*pSectNd, 1);
331 SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
332 if (!pCNd)
333 pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
334 if (pCNd &&
335 pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex())
336 {
337 SwContentFrame const*const pCFrame(
338 pCNd->getLayoutFrame(GetLayout()));
339 if (pCFrame &&
340 (IsReadOnlyAvailable() || !pCFrame->IsProtected()))
341 {
342 pFnd = pCNd;
343 }
344 }
345 }
346 }
347 }
348
349 if( !pFnd )
350 return false;
351
352 SwCallLink aLk( *this ); // watch Cursor-Moves
353 SwCursorSaveState aSaveState( *m_pCurrentCursor );
355 bool bRet = !m_pCurrentCursor->IsSelOvr();
356 if( bRet )
358 return bRet;
359}
360
363{
364 SwTOXMarks aMarks;
365 sal_uInt16 nCnt = SwDoc::GetCurTOXMark(*m_pCurrentCursor->GetPoint(), aMarks);
366 if(!nCnt)
367 return;
368 // Take the 1. and get the index type. Ask it for the actual index.
369 const SwTOXType* pType = aMarks[0]->GetTOXType();
370 auto pContentFrame = pType->FindContentFrame(*GetDoc(), *GetLayout());
371 SwCallLink aLk(*this); // watch Cursor-Moves
373 assert(pContentFrame->IsTextFrame());
374 *m_pCurrentCursor->GetPoint() = static_cast<SwTextFrame const*>(pContentFrame)->MapViewToModelPos(TextFrameIndex(0));
377}
378
381bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors )
382{
383 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
384
385 if( IsTableMode() )
386 return false;
387
388 bool bFnd = false;
391
392 Point aPt;
393 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
394 if( !bNext )
395 aFndPos.Assign(SwNodeOffset(0));
396 SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
397
398 {
399 const SwNode* pSttNd = rPos.GetNode().FindTableBoxStartNode();
400 if( pSttNd )
401 {
402 const SwTableBox* pTBox = pSttNd->FindTableNode()->GetTable().
403 GetTableBox( pSttNd->GetIndex() );
404 if( pTBox )
405 aCurGEF = SetGetExpField( *pTBox );
406 }
407 }
408
409 if( rPos.GetNode() < GetDoc()->GetNodes().GetEndOfExtras() )
410 {
411 // also at collection use only the first frame
412 std::pair<Point, bool> const tmp(aPt, false);
414 &rPos, &tmp) );
415 }
416
417 sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA );
418 if( nMaxItems > 0 )
419 {
420 sal_uInt8 nMaxDo = 2;
421 do {
422 for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA))
423 {
424 const SwTableBox* pTBox;
425 auto pFormulaItem = dynamic_cast<const SwTableBoxFormula*>(pItem);
426 if( !pFormulaItem )
427 continue;
428 pTBox = pFormulaItem->GetTableBox();
429 if( pTBox &&
430 pTBox->GetSttNd() &&
431 pTBox->GetSttNd()->GetNodes().IsDocNodes() &&
432 ( !bOnlyErrors ||
433 !pFormulaItem->HasValidBoxes() ) )
434 {
435 SwNodeIndex aIdx( *pTBox->GetSttNd() );
436 const SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
437 std::pair<Point, bool> const tmp(aPt, false);
438 if (pCNd)
439 {
440 const SwContentFrame* pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
441 if (pCFrame && (IsReadOnlyAvailable() || !pCFrame->IsProtected() ))
442 {
443 SetGetExpField aCmp( *pTBox );
444 aCmp.SetBodyPos( *pCFrame );
445
446 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
447 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
448 {
449 aFndGEF = aCmp;
450 bFnd = true;
451 }
452 }
453 }
454 }
455 }
456 if( !bFnd )
457 {
458 if( bNext )
459 {
460 rPos.Assign(SwNodeOffset(0), 0);
461 aCurGEF = SetGetExpField( rPos );
462 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
463 }
464 else
465 {
466 aCurGEF = SetGetExpField( SwPosition( GetDoc()->GetNodes().GetEndOfContent() ) );
467 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
468 }
469 }
470 } while( !bFnd && --nMaxDo );
471 }
472
473 if( !bFnd )
474 {
475 rPos = aOldPos;
476 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
477 return false;
478 }
479
480 CurrShell aCurr( this );
481 SwCallLink aLk( *this ); // watch Cursor-Moves
482 SwCursorSaveState aSaveState( *m_pCurrentCursor );
483
484 aFndGEF.GetPosOfContent( rPos );
486
487 bFnd = !m_pCurrentCursor->IsSelOvr();
488 if( bFnd )
491
492 return bFnd;
493}
494
497{
498 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
499
500 if( IsTableMode() )
501 return false;
502
503 bool bFnd = false;
505
506 Point aPt;
507 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
508 if( !bNext )
509 aFndPos.Assign(SwNodeOffset(0));
510 SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
511
512 if( rPos.GetNodeIndex() < GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
513 {
514 // also at collection use only the first frame
515 std::pair<Point, bool> const tmp(aPt, false);
516 aCurGEF.SetBodyPos( *rPos.GetNode().
517 GetContentNode()->getLayoutFrame(GetLayout(), &rPos, &tmp));
518 }
519
520 const SwTextNode* pTextNd;
521 const SwTextTOXMark* pTextTOX;
522 sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK );
523 if( nMaxItems == 0 )
524 {
525 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
526 return false;
527 }
528
529 do {
530 for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_TXTATR_TOXMARK))
531 {
532 auto pToxMarkItem = dynamic_cast<const SwTOXMark*>(pItem);
533 if( !pToxMarkItem )
534 continue;
535 pTextTOX = pToxMarkItem->GetTextTOXMark();
536 if( !pTextTOX )
537 continue;
538 pTextNd = &pTextTOX->GetTextNode();
539 if( !pTextNd->GetNodes().IsDocNodes() )
540 continue;
541 std::pair<Point, bool> const tmp(aPt, false);
542 const SwContentFrame* pCFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
543 if( pCFrame && ( IsReadOnlyAvailable() || !pCFrame->IsProtected() ))
544 {
545 SetGetExpField aCmp( *pTextNd, *pTextTOX );
546 aCmp.SetBodyPos( *pCFrame );
547
548 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
549 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
550 {
551 aFndGEF = aCmp;
552 bFnd = true;
553 }
554 }
555 }
556 if( !bFnd )
557 {
558 if ( bNext )
559 {
560 rPos.Assign(SwNodeOffset(0), 0);
561 aCurGEF = SetGetExpField( rPos );
562 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
563 }
564 else
565 {
566 aCurGEF = SetGetExpField( SwPosition( GetDoc()->GetNodes().GetEndOfContent() ) );
567 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
568 }
569 }
570 } while ( !bFnd );
571
572 CurrShell aCurr( this );
573 SwCallLink aLk( *this ); // watch Cursor-Moves
574 SwCursorSaveState aSaveState( *m_pCurrentCursor );
575
576 aFndGEF.GetPosOfContent( rPos );
577
578 bFnd = !m_pCurrentCursor->IsSelOvr();
579 if( bFnd )
582 return bFnd;
583}
584
587 SwTOXSearch eDir )
588{
589 CurrShell aCurr( this );
590 SwCallLink aLk( *this ); // watch Cursor-Moves
591 SwCursorSaveState aSaveState( *m_pCurrentCursor );
592
593 const SwTOXMark& rNewMark = GetDoc()->GotoTOXMark( rStart, eDir,
595 // set position
596 SwPosition& rPos = *GetCursor()->GetPoint();
597 rPos.Assign(rNewMark.GetTextTOXMark()->GetTextNode(),
598 rNewMark.GetTextTOXMark()->GetStart() );
599
600 if( !m_pCurrentCursor->IsSelOvr() )
603
604 return rNewMark;
605}
606
609 SetGetExpFields& rLst,
610 const SwFieldType& rFieldType,
611 const bool bInReadOnly,
612 const bool bChkInpFlag = false )
613{
614 // always search the 1. frame
615 Point aPt;
616 std::vector<SwFormatField*> vFields;
617 rFieldType.GatherFields(vFields, false);
618 for(SwFormatField* pFormatField: vFields)
619 {
620 SwTextField* pTextField = pFormatField->GetTextField();
621 if ( pTextField != nullptr
622 && ( !bChkInpFlag
623 || static_cast<const SwSetExpField*>(pTextField->GetFormatField().GetField())->GetInputFlag() ) )
624 {
625 const SwTextNode& rTextNode = pTextField->GetTextNode();
626 std::pair<Point, bool> const tmp(aPt, false);
627 const SwContentFrame* pCFrame =
628 rTextNode.getLayoutFrame(
630 nullptr, &tmp);
631 if ( pCFrame != nullptr
632 && ( bInReadOnly || !pCFrame->IsProtected() ) )
633 {
634 std::unique_ptr<SetGetExpField> pNew(new SetGetExpField( rTextNode, pTextField ));
635 pNew->SetBodyPos( *pCFrame );
636 rLst.insert( std::move(pNew) );
637 }
638 }
639 }
640}
641
643lcl_FindField(bool & o_rFound, SetGetExpFields const& rSrtLst,
644 SwRootFrame const *const pLayout, SwTextNode *const pTextNode,
645 SwTextField const *const pTextField, SwPosition const& rPos,
646 sal_Int32 const nContentOffset)
647{
648 std::optional<SetGetExpField> oSrch;
649 if (-1 == nContentOffset)
650 {
651 oSrch.emplace(rPos.GetNode(), pTextField, rPos.GetContentIndex());
652 }
653 else
654 {
655 oSrch.emplace(rPos.GetNode(), pTextField, nContentOffset);
656 }
657
658 if (rPos.GetNodeIndex() < pTextNode->GetNodes().GetEndOfExtras().GetIndex())
659 {
660 // also at collection use only the first frame
661 Point aPt;
662 std::pair<Point, bool> const tmp(aPt, false);
663 oSrch->SetBodyPos(*pTextNode->getLayoutFrame(pLayout, &rPos, &tmp));
664 }
665
666 SetGetExpFields::const_iterator it = rSrtLst.lower_bound(&*oSrch);
667
668 o_rFound = (it != rSrtLst.end()) && (**it == *oSrch);
669 return it;
670}
671
673 const SwFieldType* pFieldType,
674 const bool bNext,
675 const SwFieldIds nResType,
676 const bool bAddSetExpressionFieldsToInputFields )
677{
678 // sorted list of all fields
679 SetGetExpFields aSrtLst;
680
681 if ( pFieldType )
682 {
683 if( SwFieldIds::Input != pFieldType->Which() && !pFieldType->HasWriterListeners() )
684 {
685 return false;
686 }
687
688 // found Modify object, add all fields to array
689 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable() );
690
691 if( SwFieldIds::Input == pFieldType->Which() && bAddSetExpressionFieldsToInputFields )
692 {
693 // there are hidden input fields in the set exp. fields
694 const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
695 const size_t nSize = rFieldTypes.size();
696 for( size_t i=0; i < nSize; ++i )
697 {
698 pFieldType = rFieldTypes[ i ].get();
699 if ( SwFieldIds::SetExp == pFieldType->Which() )
700 {
701 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable(), true );
702 }
703 }
704 }
705 }
706 else
707 {
708 const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
709 const size_t nSize = rFieldTypes.size();
710 const bool bAllFieldTypes = nResType == SwFieldIds::Unknown;
711 for( size_t i=0; i < nSize; ++i )
712 {
713 pFieldType = rFieldTypes[ i ].get();
714 if (bAllFieldTypes || nResType == pFieldType->Which())
715 {
716 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable() );
717 }
718 }
719 }
720
721 // found no fields?
722 if( aSrtLst.empty() )
723 return false;
724
726 SwCursor* pCursor = getShellCursor( true );
727 {
728 // (1998): Always use field for search so that the right one is found as
729 // well some are in frames that are anchored to a paragraph that has a
730 // field
731 const SwPosition& rPos = *pCursor->GetPoint();
732
733 SwTextNode* pTNd = rPos.GetNode().GetTextNode();
734 OSL_ENSURE( pTNd, "No ContentNode" );
735
737 const bool bDelField = ( pTextField == nullptr );
738 sal_Int32 nContentOffset = -1;
739
740 if( bDelField )
741 {
742 // create dummy for the search
743 SwFormatField* pFormatField = new SwFormatField( SwDateTimeField(
744 static_cast<SwDateTimeFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DateTime ) ) ) );
745
746 pTextField = new SwTextField( *pFormatField, rPos.GetContentIndex(),
747 mxDoc->IsClipBoard() );
748 pTextField->ChgTextNode( pTNd );
749 }
750 else
751 {
752 // the cursor might be anywhere inside the input field,
753 // but we will be searching for the field start
754 if (pTextField->Which() == RES_TXTATR_INPUTFIELD
755 && rPos.GetContentIndex() != pTextField->GetStart())
756 nContentOffset = pTextField->GetStart();
757 }
758 bool isSrch;
759 it = lcl_FindField(isSrch, aSrtLst,
760 GetLayout(), pTNd, pTextField, rPos, nContentOffset);
761
762 if( bDelField )
763 {
764 auto const pFormat(static_cast<SwFormatField*>(&pTextField->GetAttr()));
765 delete pTextField;
766 delete pFormat;
767 }
768
769 if( it != aSrtLst.end() && isSrch ) // found
770 {
771 if( bNext )
772 {
773 if( ++it == aSrtLst.end() )
774 return false; // already at the end
775 }
776 else
777 {
778 if( it == aSrtLst.begin() )
779 return false; // no more steps backward possible
780 --it;
781 }
782 }
783 else // not found
784 {
785 if( bNext )
786 {
787 if( it == aSrtLst.end() )
788 return false;
789 }
790 else
791 {
792 if( it == aSrtLst.begin() )
793 return false; // no more steps backward possible
794 --it;
795 }
796 }
797 }
798 const SetGetExpField& rFnd = **it;
799
800 CurrShell aCurr( this );
801 SwCallLink aLk( *this ); // watch Cursor-Moves
802 SwCursorSaveState aSaveState( *pCursor );
803
804 rFnd.GetPosOfContent( *pCursor->GetPoint() );
807 if( bRet )
809 return bRet;
810}
811
813{
814 if (SwWrtShell* pWrtSh = dynamic_cast<SwWrtShell*>(this))
815 pWrtSh->addCurrentPosition();
817 bool bRet = false;
818 SwCursor* pCursor = getShellCursor(true);
819
820 CurrShell aCurr(this);
821 SwCallLink aLk(*this); // watch Cursor-Moves
822 SwCursorSaveState aSaveState(*pCursor);
823
824 pCursor->GetPoint()->Assign(rTextFootnote.GetTextNode(),
825 rTextFootnote.GetStart());
826 bRet = !pCursor->IsSelOvr();
827 if (bRet)
829 return bRet;
830}
831
833{
834 std::shared_ptr<SwContentControl> pContentControl = rContentControl.GetContentControl();
835 const SwTextContentControl* pTextContentControl = pContentControl->GetTextAttr();
836 if (!pTextContentControl)
837 return false;
838
839 CurrShell aCurr(this);
840 SwCallLink aLink(*this);
841
842 SwCursor* pCursor = getShellCursor(true);
843 SwCursorSaveState aSaveState(*pCursor);
844
845 SwTextNode* pTextNode = pContentControl->GetTextNode();
846 // Don't select the text attribute itself at the start.
847 sal_Int32 nStart = pTextContentControl->GetStart() + 1;
848 pCursor->GetPoint()->Assign(*pTextNode, nStart);
850 bool bRet = true;
851 // select contents for certain controls or conditions
852 if (pContentControl->GetShowingPlaceHolder() || pContentControl->GetCheckbox()
853 || pContentControl->GetSelectedListItem() || pContentControl->GetSelectedDate())
854 {
855 pCursor->SetMark();
856 // Don't select the CH_TXTATR_BREAKWORD itself at the end.
857 sal_Int32 nEnd = *pTextContentControl->End() - 1;
858 pCursor->GetMark()->Assign(*pTextNode, nEnd);
859 bRet = !pCursor->IsSelOvr();
860 }
861 else
862 ClearMark();
863
864 if (bRet)
865 {
868 }
869
870 return bRet;
871}
872
878{
879 // (note: this only applies to modern content controls and legacy fieldmarks,
880 // since activeX richText controls aren't exposed to SW keystrokes)
881
882 struct FormControlSort
883 {
884 bool operator()(std::pair<const SwPosition&, sal_uInt32> rLHS,
885 std::pair<const SwPosition&, sal_uInt32> rRHS) const
886 {
887 assert(rLHS.second && rRHS.second && "tabIndex zero must be changed to SAL_MAX_UINT32");
888 //first compare tabIndexes where 1 has the priority.
889 if (rLHS.second < rRHS.second)
890 return true;
891 if (rLHS.second > rRHS.second)
892 return false;
893
894 // when tabIndexes are equal (and they usually are) then sort by paragraph position
895 return rLHS.first < rRHS.first;
896 }
897 };
898 std::map<std::pair<SwPosition, sal_uInt32>,
899 std::pair<SwTextContentControl*, sw::mark::IFieldmark*>, FormControlSort> aFormMap;
900
901 // add all of the eligible modern Content Controls into a sorted map
903 for (size_t i = 0; i < rManager.GetCount(); ++i)
904 {
905 SwTextContentControl* pTCC = rManager.UnsortedGet(i);
906 if (!pTCC || !pTCC->GetTextNode())
907 continue;
908 auto pCC = pTCC->GetContentControl().GetContentControl();
909
910 // -1 indicates the control should not participate in keyboard tab navigation
911 if (pCC && pCC->GetTabIndex() == SAL_MAX_UINT32)
912 continue;
913
914 const SwPosition nPos(*pTCC->GetTextNode(), pTCC->GetStart());
915
916 // since 0 is the lowest priority (1 is the highest), and -1 has already been excluded,
917 // use SAL_MAX_UINT32 as zero's tabIndex so that automatic sorting is correct.
918 sal_uInt32 nTabIndex = pCC && pCC->GetTabIndex() ? pCC->GetTabIndex() : SAL_MAX_UINT32;
919
920 const std::pair<SwTextContentControl*, sw::mark::IFieldmark*> pFormControl(pTCC, nullptr);
921 aFormMap[std::make_pair(nPos, nTabIndex)] = pFormControl;
922 }
923
924 if (aFormMap.begin() == aFormMap.end())
925 {
926 // only legacy fields exist. Avoid reprocessing everything and use legacy code path.
927 GotoFieldmark(bNext ? GetFieldmarkAfter(/*Loop=*/true) : GetFieldmarkBefore(/*Loop=*/true));
928 return;
929 }
930
931 // add all of the legacy form field controls into the sorted map
933 for (auto it = pMarkAccess->getFieldmarksBegin(); it != pMarkAccess->getFieldmarksEnd(); ++it)
934 {
935 auto pFieldMark = dynamic_cast<sw::mark::IFieldmark*>(*it);
936 assert(pFieldMark);
937 std::pair<SwTextContentControl*, sw::mark::IFieldmark*> pFormControl(nullptr, pFieldMark);
938 // legacy form fields do not have (functional) tabIndexes - use lowest priority for them
939 aFormMap[std::make_pair((*it)->GetMarkStart(), SAL_MAX_UINT32)] = pFormControl;
940 }
941
942 if (aFormMap.begin() == aFormMap.end())
943 return;
944
945 // Identify the current location in the document, and the current tab index priority
946
947 // A content control could contain a Fieldmark, so check for legacy fieldmarks first
948 sw::mark::IFieldmark* pFieldMark = GetCurrentFieldmark();
949 SwTextContentControl* pTCC = !pFieldMark ? CursorInsideContentControl() : nullptr;
950
951 auto pCC = pTCC ? pTCC->GetContentControl().GetContentControl() : nullptr;
952 const sal_Int32 nCurTabIndex = pCC && pCC->GetTabIndex() ? pCC->GetTabIndex() : SAL_MAX_UINT32;
953
954 SwPosition nCurPos(*GetCursor()->GetPoint());
955 if (pFieldMark)
956 nCurPos = pFieldMark->GetMarkStart();
957 else if (pTCC && pTCC->GetTextNode())
958 nCurPos = SwPosition(*pTCC->GetTextNode(), pTCC->GetStart());
959
960 // Find the previous (or next) tab control and navigate to it
961 const std::pair<SwPosition, sal_uInt32> nOldPos(nCurPos, nCurTabIndex);
962
963 // lower_bound acts like find, and returns a pointer to nFindPos if it exists,
964 // otherwise it will point to the previous entry.
965 auto aNewPos = aFormMap.lower_bound(nOldPos);
966 if (bNext && aNewPos != aFormMap.end())
967 ++aNewPos;
968 else if (!bNext && aNewPos != aFormMap.end() && aNewPos->first == nOldPos)
969 {
970 // Found the current position - need to return previous
971 if (aNewPos == aFormMap.begin())
972 aNewPos = aFormMap.end(); // prepare to loop around
973 else
974 --aNewPos;
975 }
976
977 if (aNewPos == aFormMap.end())
978 {
979 // Loop around to the other side
980 if (bNext)
981 aNewPos = aFormMap.begin();
982 else
983 --aNewPos;
984 }
985
986 // the entry contains a pointer to either a Content Control (first) or Fieldmark (second)
987 if (aNewPos->second.first)
988 {
989 auto& rFCC = static_cast<SwFormatContentControl&>(aNewPos->second.first->GetAttr());
991 }
992 else
993 {
994 assert(aNewPos->second.second);
995 GotoFieldmark(aNewPos->second.second);
996 }
997}
998
1000{
1001 SwTextField const*const pTextField(rField.GetTextField());
1002 if (!pTextField
1003 || (GetLayout()->IsHideRedlines()
1005 GetDoc()->getIDocumentRedlineAccess(), *pTextField)))
1006 return false;
1007
1008 CurrShell aCurr( this );
1009 SwCallLink aLk( *this ); // watch Cursor-Moves
1010
1011 SwCursor* pCursor = getShellCursor( true );
1012 SwCursorSaveState aSaveState( *pCursor );
1013
1014 SwTextNode* pTNd = pTextField->GetpTextNode();
1015 pCursor->GetPoint()->Assign(*pTNd, pTextField->GetStart() );
1016
1017 bool bRet = !pCursor->IsSelOvr();
1018 if( bRet )
1020 return bRet;
1021}
1022
1024 const SwPosition* pPos,
1025 ::sw::GetTextAttrMode const eMode)
1026{
1027 SwTextField* pTextField = nullptr;
1028
1029 SwTextNode * const pNode = pPos->GetNode().GetTextNode();
1030 if ( pNode != nullptr )
1031 {
1032 pTextField = pNode->GetFieldTextAttrAt(pPos->GetContentIndex(), eMode);
1033 }
1034
1035 return pTextField;
1036}
1037
1039 const SwPaM* pCursor,
1040 ::sw::GetTextAttrMode const eMode)
1041{
1042 SwTextField* pTextField = GetTextFieldAtPos(pCursor->Start(), eMode);
1043 if ( !pTextField
1044 || pCursor->Start()->GetNode() != pCursor->End()->GetNode() )
1045 return nullptr;
1046
1047 SwTextField* pFieldAtCursor = nullptr;
1048 const sal_Int32 nTextFieldLength =
1049 pTextField->End() != nullptr
1050 ? *(pTextField->End()) - pTextField->GetStart()
1051 : 1;
1052 if ( ( pCursor->End()->GetContentIndex() - pCursor->Start()->GetContentIndex() ) <= nTextFieldLength )
1053 {
1054 pFieldAtCursor = pTextField;
1055 }
1056
1057 return pFieldAtCursor;
1058}
1059
1061 const SwPaM *const pCursor,
1062 const bool bIncludeInputFieldAtStart)
1063{
1064 SwTextField *const pField(GetTextFieldAtCursor(pCursor,
1065 bIncludeInputFieldAtStart ? ::sw::GetTextAttrMode::Default : ::sw::GetTextAttrMode::Expand));
1066 return pField
1067 ? const_cast<SwField*>(pField->GetFormatField().GetField())
1068 : nullptr;
1069}
1070
1071SwField* SwCursorShell::GetCurField( const bool bIncludeInputFieldAtStart ) const
1072{
1073 SwPaM* pCursor = GetCursor();
1074 if ( pCursor->IsMultiSelection() )
1075 {
1076 // multi selection not handled.
1077 return nullptr;
1078 }
1079
1080 SwField* pCurField = GetFieldAtCursor( pCursor, bIncludeInputFieldAtStart );
1081 if ( pCurField != nullptr
1082 && SwFieldIds::Table == pCurField->GetTyp()->Which() )
1083 {
1084 // table formula? convert internal name into external
1085 const SwTableNode* pTableNd = IsCursorInTable();
1086 static_cast<SwTableField*>(pCurField)->PtrToBoxNm( pTableNd ? &pTableNd->GetTable() : nullptr );
1087 }
1088
1089 return pCurField;
1090}
1091
1093{
1094 for(SwPaM& rCursor : GetCursor()->GetRingContainer())
1095 {
1096 if (dynamic_cast<const SwTextInputField*>(GetTextFieldAtCursor(&rCursor, ::sw::GetTextAttrMode::Parent)))
1097 return true;
1098 }
1099 return false;
1100}
1101
1103{
1104 for (SwPaM& rCursor : GetCursor()->GetRingContainer())
1105 {
1106 const SwPosition* pStart = rCursor.Start();
1107 SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
1108 if (!pTextNode)
1109 {
1110 continue;
1111 }
1112
1113 sal_Int32 nIndex = pStart->GetContentIndex();
1115 {
1116 return static_txtattr_cast<SwTextContentControl*>(pAttr);
1117 }
1118 }
1119
1120 return nullptr;
1121}
1122
1124{
1125 return dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Parent)) != nullptr;
1126}
1127
1128bool SwCursorShell::DocPtInsideInputField( const Point& rDocPt ) const
1129{
1130 SwPosition aPos( *(GetCursor()->Start()) );
1131 Point aDocPt( rDocPt );
1132 if ( GetLayout()->GetModelPositionForViewPoint( &aPos, aDocPt ) )
1133 {
1134 return PosInsideInputField( aPos );
1135 }
1136 return false;
1137}
1138
1140{
1141 const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Default));
1142 assert(pTextInputField != nullptr
1143 && "<SwEditShell::StartOfInputFieldAtPos(..)> - no Input Field at given position");
1144 return pTextInputField->GetStart();
1145}
1146
1148{
1149 const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Default));
1150 assert(pTextInputField != nullptr
1151 && "<SwEditShell::EndOfInputFieldAtPos(..)> - no Input Field at given position");
1152 return *(pTextInputField->End());
1153}
1154
1156{
1157 SwCursor* pCursor = getShellCursor( true );
1158
1159 CurrShell aCurr( this );
1160 SwCallLink aLk( *this ); // watch Cursor-Moves
1161 SwCursorSaveState aSaveState( *pCursor );
1162
1163 const SwNodes& rNds = GetDoc()->GetNodes();
1164 SwTextNode* pTextNd = rNds.GetOutLineNds()[ nIdx ]->GetTextNode();
1165 pCursor->GetPoint()->Assign(*pTextNd);
1166
1167 if( !pCursor->IsSelOvr() )
1169}
1170
1171bool SwCursorShell::GotoOutline( const OUString& rName )
1172{
1173 SwCursor* pCursor = getShellCursor( true );
1174
1175 CurrShell aCurr( this );
1176 SwCallLink aLk( *this ); // watch Cursor-Moves
1177 SwCursorSaveState aSaveState( *pCursor );
1178
1179 bool bRet = false;
1180 if (mxDoc->GotoOutline(*pCursor->GetPoint(), rName, GetLayout())
1181 && !pCursor->IsSelOvr())
1182 {
1184 bRet = true;
1185 }
1186 return bRet;
1187}
1188
1191{
1192 const SwNodes& rNds = GetDoc()->GetNodes();
1193
1194 if ( rNds.GetOutLineNds().empty() )
1195 {
1196 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1197 return false;
1198 }
1199
1200 SwCursor* pCursor = getShellCursor( true );
1201 SwNode* pNd = &(pCursor->GetPointNode());
1203 bool bUseFirst = !rNds.GetOutLineNds().Seek_Entry( pNd, &nPos );
1204 SwOutlineNodes::size_type const nStartPos(nPos);
1205
1206 do
1207 {
1208 if (!bUseFirst)
1209 {
1210 ++nPos;
1211 }
1212 if (rNds.GetOutLineNds().size() <= nPos)
1213 {
1214 nPos = 0;
1215 }
1216
1217 if (bUseFirst)
1218 {
1219 bUseFirst = false;
1220 }
1221 else
1222 {
1223 if (nPos == nStartPos)
1224 {
1225 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1226 return false;
1227 }
1228 }
1229
1230 pNd = rNds.GetOutLineNds()[ nPos ];
1231 }
1232 while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
1233
1234 if (nPos < nStartPos)
1235 {
1236 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
1237 }
1238 else
1239 {
1240 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1241 }
1242
1243 CurrShell aCurr( this );
1244 SwCallLink aLk( *this ); // watch Cursor-Moves
1245 SwCursorSaveState aSaveState( *pCursor );
1246 pCursor->GetPoint()->Assign(*pNd);
1247
1248 bool bRet = !pCursor->IsSelOvr();
1249 if( bRet )
1251 return bRet;
1252}
1253
1256{
1257 const SwNodes& rNds = GetDoc()->GetNodes();
1258
1259 if ( rNds.GetOutLineNds().empty() )
1260 {
1261 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1262 return false;
1263 }
1264
1265 SwCursor* pCursor = getShellCursor( true );
1266 SwNode* pNd = &(pCursor->GetPointNode());
1268 (void)rNds.GetOutLineNds().Seek_Entry(pNd, &nPos);
1269 SwOutlineNodes::size_type const nStartPos(nPos);
1270
1271 do
1272 {
1273 if (nPos == 0)
1274 {
1275 nPos = rNds.GetOutLineNds().size() - 1;
1276 }
1277 else
1278 {
1279 --nPos; // before
1280 }
1281 if (nPos == nStartPos)
1282 {
1283 pNd = nullptr;
1284 break;
1285 }
1286
1287 pNd = rNds.GetOutLineNds()[ nPos ];
1288 }
1289 while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
1290
1291 if (!pNd)
1292 {
1293 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1294 return false;
1295 }
1296
1297 if (nStartPos < nPos)
1298 {
1299 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
1300 }
1301 else
1302 {
1303 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1304 }
1305 CurrShell aCurr( this );
1306 SwCallLink aLk( *this ); // watch Cursor-Moves
1307 SwCursorSaveState aSaveState( *pCursor );
1308 pCursor->GetPoint()->Assign(*pNd);
1309
1310 bool bRet = !pCursor->IsSelOvr();
1311 if( bRet )
1313 return bRet;
1314}
1315
1318{
1319 SwPaM* pCursor = pPaM ? pPaM : getShellCursor(true);
1320 const SwNodes& rNds = GetDoc()->GetNodes();
1321
1322 SwNode* pNd = &(pCursor->GetPointNode());
1324 if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
1325 nPos++; // is at correct position; take next for while
1326
1327 while( nPos-- ) // check the one in front of the current
1328 {
1329 pNd = rNds.GetOutLineNds()[ nPos ];
1330
1332 && pNd->GetTextNode()->GetAttrOutlineLevel()-1 <= nLevel)
1333 {
1334 if (pNd->GetIndex() < rNds.GetEndOfExtras().GetIndex()
1335 && pCursor->GetPointNode().GetIndex() > rNds.GetEndOfExtras().GetIndex())
1336 {
1337 // node found in extras but cursor position is not in extras
1338 return SwOutlineNodes::npos;
1339 }
1340 return nPos;
1341 }
1342 }
1343 return SwOutlineNodes::npos; // no more left
1344}
1345
1347 bool bWithChildren , bool bKillPams)
1348{
1349 const SwNodes& rNds = GetDoc()->GetNodes();
1350 const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
1351 if( rOutlNds.empty() )
1352 return;
1353
1354 CurrShell aCurr( this );
1355 SwCallLink aLk( *this ); // watch Cursor-Moves
1356
1357 if( nSttPos > nEndPos ) // parameters switched?
1358 {
1359 OSL_ENSURE( false, "Start > End for array access" );
1360 std::swap(nSttPos, nEndPos);
1361 }
1362
1363 SwNode* pSttNd = rOutlNds[ nSttPos ];
1364 SwNode* pEndNd = rOutlNds[ nEndPos ];
1365
1366 if( bWithChildren )
1367 {
1368 const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
1369 for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos )
1370 {
1371 pEndNd = rOutlNds[ nEndPos ];
1372 const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
1373 if( nNxtLevel <= nLevel )
1374 break; // EndPos is now on the next one
1375 }
1376 }
1377 // if without children then set onto next one
1378 else if( ++nEndPos < rOutlNds.size() )
1379 pEndNd = rOutlNds[ nEndPos ];
1380
1381 if( nEndPos == rOutlNds.size() ) // no end found
1382 pEndNd = &rNds.GetEndOfContent();
1383
1384 if( bKillPams )
1385 KillPams();
1386
1387 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1388
1389 // set end to the end of the previous content node
1390 m_pCurrentCursor->GetPoint()->Assign(*pSttNd);
1392 m_pCurrentCursor->GetPoint()->Assign(*pEndNd);
1393 m_pCurrentCursor->Move( fnMoveBackward, GoInNode ); // end of predecessor
1394
1395 // and everything is already selected
1396 bool bRet = !m_pCurrentCursor->IsSelOvr();
1397 if( bRet )
1399}
1400
1402bool SwCursorShell::GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
1403 sal_uInt16 nSeqNo )
1404{
1405 CurrShell aCurr( this );
1406 SwCallLink aLk( *this ); // watch Cursor-Moves
1407 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1408
1409 sal_Int32 nPos = -1;
1410 SwTextNode* pTextNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark,
1411 nSubType, nSeqNo, &nPos, nullptr, GetLayout());
1412 if( !pTextNd || !pTextNd->GetNodes().IsDocNodes() )
1413 return false;
1414
1415 m_pCurrentCursor->GetPoint()->Assign(*pTextNd, nPos );
1416
1417 if( m_pCurrentCursor->IsSelOvr() )
1418 return false;
1419
1421 return true;
1422}
1423
1424bool SwCursorShell::IsPageAtPos( const Point &rPt ) const
1425{
1426 if( GetLayout() )
1427 return nullptr != GetLayout()->GetPageAtPos( rPt );
1428 return false;
1429}
1430
1431bool SwCursorShell::GetContentAtPos( const Point& rPt,
1432 SwContentAtPos& rContentAtPos,
1433 bool bSetCursor,
1434 SwRect* pFieldRect )
1435{
1436 CurrShell aCurr( this );
1437 bool bRet = false;
1438
1439 if( IsTableMode() )
1440 {
1441 rContentAtPos.eContentAtPos = IsAttrAtPos::NONE;
1442 rContentAtPos.aFnd.pField = nullptr;
1443 return false;
1444 }
1445
1446 Point aPt( rPt );
1448
1449 SwTextNode* pTextNd;
1450 SwCursorMoveState aTmpState;
1451 aTmpState.m_bFieldInfo = true;
1452 aTmpState.m_bExactOnly = !( IsAttrAtPos::Outline & rContentAtPos.eContentAtPos );
1453 aTmpState.m_bContentCheck = bool(IsAttrAtPos::ContentCheck & rContentAtPos.eContentAtPos);
1455
1456 SwSpecialPos aSpecialPos;
1457 aTmpState.m_pSpecialPos = ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos ) ?
1458 &aSpecialPos : nullptr;
1459
1460 const bool bCursorFoundExact = GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState );
1461 pTextNd = aPos.GetNode().GetTextNode();
1462
1463 const SwNodes& rNds = GetDoc()->GetNodes();
1464 if( pTextNd
1465 && IsAttrAtPos::Outline & rContentAtPos.eContentAtPos
1466 && !rNds.GetOutLineNds().empty() )
1467 {
1468 // only for nodes in outline nodes
1470 if(rNds.GetOutLineNds().Seek_Entry(pTextNd, &nPos))
1471 {
1472 rContentAtPos.eContentAtPos = IsAttrAtPos::Outline;
1473 rContentAtPos.sStr = sw::GetExpandTextMerged(GetLayout(), *pTextNd, true, false, ExpandMode::ExpandFootnote);
1474 rContentAtPos.aFnd.pNode = pTextNd;
1475 bRet = true;
1476 }
1477 }
1478 else if ( IsAttrAtPos::ContentCheck & rContentAtPos.eContentAtPos
1479 && bCursorFoundExact )
1480 {
1481 bRet = true;
1482 }
1483 else if( pTextNd
1484 && IsAttrAtPos::NumLabel & rContentAtPos.eContentAtPos)
1485 {
1486 bRet = aTmpState.m_bInNumPortion;
1487 rContentAtPos.aFnd.pNode = sw::GetParaPropsNode(*GetLayout(), aPos.GetNode());
1488
1489 Size aSizeLogic(aTmpState.m_nInNumPortionOffset, 0);
1490 Size aSizePixel = GetWin()->LogicToPixel(aSizeLogic);
1491 rContentAtPos.nDist = aSizePixel.Width();
1492 }
1493 else if( bCursorFoundExact && pTextNd )
1494 {
1495 SwContentFrame *pFrame(nullptr);
1496 if( !aTmpState.m_bPosCorr )
1497 {
1498 SwTextAttr* pTextAttr;
1499 if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
1500 && !aTmpState.m_bFootnoteNoInfo )
1501 {
1502 const SwWrongList* pSmartTagList = pTextNd->GetSmartTags();
1503 sal_Int32 nCurrent = aPos.GetContentIndex();
1504 const sal_Int32 nBegin = nCurrent;
1505 sal_Int32 nLen = 1;
1506
1507 if (pSmartTagList && pSmartTagList->InWrongWord(nCurrent, nLen) && !pTextNd->IsSymbolAt(nBegin))
1508 {
1509 const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
1510 const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
1511 if ( pSubList )
1512 {
1513 nCurrent = aTmpState.m_pSpecialPos->nCharOfst;
1514
1515 if ( pSubList->InWrongWord( nCurrent, nLen ) )
1516 bRet = true;
1517 }
1518 else
1519 bRet = true;
1520
1521 if( bRet && bSetCursor )
1522 {
1523 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1524 SwCallLink aLk( *this ); // watch Cursor-Moves
1526 *m_pCurrentCursor->GetPoint() = aPos;
1528 bRet = false;
1529 else
1530 UpdateCursor();
1531 }
1532 if( bRet )
1533 {
1534 rContentAtPos.eContentAtPos = IsAttrAtPos::SmartTag;
1535
1536 std::pair<Point, bool> tmp(aPt, true);
1537 if (pFieldRect)
1538 {
1539 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1540 if (pFrame)
1541 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1542 }
1543 }
1544 }
1545 }
1546
1547 if ( !bRet
1549 && !aTmpState.m_bFootnoteNoInfo )
1550 {
1551 pTextAttr = pTextNd->GetFieldTextAttrAt( aPos.GetContentIndex() );
1552 const SwField* pField = pTextAttr != nullptr
1553 ? pTextAttr->GetFormatField().GetField()
1554 : nullptr;
1555 if ( IsAttrAtPos::ClickField & rContentAtPos.eContentAtPos
1556 && pField && !pField->HasClickHdl() )
1557 {
1558 pField = nullptr;
1559 }
1560
1561 if ( pField )
1562 {
1563 if (pFieldRect)
1564 {
1565 std::pair<Point, bool> tmp(aPt, true);
1566 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1567 if (pFrame)
1568 {
1569 //tdf#116397 now that we looking for the bounds of the field drop the SmartTag
1570 //index within field setting so we don't the bounds of the char within the field
1571 SwSpecialPos* pSpecialPos = aTmpState.m_pSpecialPos;
1572 aTmpState.m_pSpecialPos = nullptr;
1573 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1574 aTmpState.m_pSpecialPos = pSpecialPos;
1575 }
1576 }
1577
1578 if( bSetCursor )
1579 {
1580 SwCallLink aLk( *this ); // watch Cursor-Moves
1581 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1583 *m_pCurrentCursor->GetPoint() = aPos;
1584 if( m_pCurrentCursor->IsSelOvr() )
1585 {
1586 // allow click fields in protected sections
1587 // only placeholder is not possible
1588 if( IsAttrAtPos::Field & rContentAtPos.eContentAtPos
1589 || SwFieldIds::JumpEdit == pField->Which() )
1590 pField = nullptr;
1591 }
1592 else
1593 UpdateCursor();
1594 }
1595 else if( SwFieldIds::Table == pField->Which() &&
1596 static_cast<const SwTableField*>(pField)->IsIntrnlName() )
1597 {
1598 // create from internal (for CORE) the external
1599 // (for UI) formula
1600 const SwTableNode* pTableNd = pTextNd->FindTableNode();
1601 if( pTableNd ) // is in a table
1602 const_cast<SwTableField*>(static_cast<const SwTableField*>(pField))->PtrToBoxNm( &pTableNd->GetTable() );
1603 }
1604 }
1605
1606 if( pField )
1607 {
1608 rContentAtPos.aFnd.pField = pField;
1609 rContentAtPos.pFndTextAttr = pTextAttr;
1610 rContentAtPos.eContentAtPos = IsAttrAtPos::Field;
1611 bRet = true;
1612 }
1613 }
1614
1615 if( !bRet && IsAttrAtPos::FormControl & rContentAtPos.eContentAtPos )
1616 {
1618 sw::mark::IFieldmark* pFieldBookmark = pMarksAccess->getInnerFieldmarkFor(aPos);
1619 if (bCursorFoundExact && pFieldBookmark)
1620 {
1622 rContentAtPos.aFnd.pFieldmark = pFieldBookmark;
1623 bRet=true;
1624 }
1625 }
1626
1627 if (!bRet && rContentAtPos.eContentAtPos & IsAttrAtPos::ContentControl)
1628 {
1629 SwTextAttr* pAttr = pTextNd->GetTextAttrAt(
1631 if (pAttr)
1632 {
1634 rContentAtPos.pFndTextAttr = pAttr;
1635 bRet = true;
1636 }
1637 }
1638
1639 if( !bRet && IsAttrAtPos::Ftn & rContentAtPos.eContentAtPos )
1640 {
1641 if( aTmpState.m_bFootnoteNoInfo )
1642 {
1643 // over the footnote's char
1644 bRet = true;
1645 if( bSetCursor )
1646 {
1647 *m_pCurrentCursor->GetPoint() = aPos;
1648 if( !GotoFootnoteAnchor() )
1649 bRet = false;
1650 }
1651 if( bRet )
1652 rContentAtPos.eContentAtPos = IsAttrAtPos::Ftn;
1653 }
1654 else if ( nullptr != ( pTextAttr = pTextNd->GetTextAttrForCharAt(
1655 aPos.GetContentIndex(), RES_TXTATR_FTN )) )
1656 {
1657 bRet = true;
1658 if( bSetCursor )
1659 {
1660 if (SwWrtShell* pWrtSh = dynamic_cast<SwWrtShell*>(this))
1661 pWrtSh->addCurrentPosition();
1662
1663 SwCallLink aLk( *this ); // watch Cursor-Moves
1664 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1665 m_pCurrentCursor->GetPoint()->Assign( *static_cast<SwTextFootnote*>(pTextAttr)->GetStartNode() );
1668 true, !IsReadOnlyAvailable() );
1669
1670 if( pCNd )
1671 {
1674 bRet = false;
1675 else
1676 UpdateCursor();
1677 }
1678 else
1679 bRet = false;
1680 }
1681
1682 if( bRet )
1683 {
1684 rContentAtPos.eContentAtPos = IsAttrAtPos::Ftn;
1685 rContentAtPos.pFndTextAttr = pTextAttr;
1686 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1687
1688 if (pFieldRect)
1689 {
1690 std::pair<Point, bool> tmp(aPt, true);
1691 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1692 if (pFrame)
1693 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1694 }
1695 }
1696 }
1697 }
1698
1699 if( !bRet
1701 && !aTmpState.m_bFootnoteNoInfo )
1702 {
1703 pTextAttr = nullptr;
1704 if( IsAttrAtPos::ToxMark & rContentAtPos.eContentAtPos )
1705 {
1706 std::vector<SwTextAttr *> const marks(
1707 pTextNd->GetTextAttrsAt(
1709 if (!marks.empty())
1710 { // hmm... can only return 1 here
1711 pTextAttr = *marks.begin();
1712 }
1713 }
1714
1715 if( !pTextAttr &&
1716 IsAttrAtPos::RefMark & rContentAtPos.eContentAtPos )
1717 {
1718 std::vector<SwTextAttr *> const marks(
1719 pTextNd->GetTextAttrsAt(
1721 if (!marks.empty())
1722 { // hmm... can only return 1 here
1723 pTextAttr = *marks.begin();
1724 }
1725 }
1726
1727 if( pTextAttr )
1728 {
1729 bRet = true;
1730 if( bSetCursor )
1731 {
1732 SwCallLink aLk( *this ); // watch Cursor-Moves
1733 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1735 *m_pCurrentCursor->GetPoint() = aPos;
1737 bRet = false;
1738 else
1739 UpdateCursor();
1740 }
1741
1742 if( bRet )
1743 {
1744 const sal_Int32* pEnd = pTextAttr->GetEnd();
1745 if( pEnd )
1746 rContentAtPos.sStr =
1747 pTextNd->GetExpandText(GetLayout(), pTextAttr->GetStart(), *pEnd - pTextAttr->GetStart());
1748 else if( RES_TXTATR_TOXMARK == pTextAttr->Which())
1749 rContentAtPos.sStr =
1750 pTextAttr->GetTOXMark().GetAlternativeText();
1751
1752 rContentAtPos.eContentAtPos =
1753 RES_TXTATR_TOXMARK == pTextAttr->Which()
1756 rContentAtPos.pFndTextAttr = pTextAttr;
1757 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1758
1759 std::pair<Point, bool> tmp(aPt, true);
1760 if (pFieldRect)
1761 {
1762 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1763 if (pFrame)
1764 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1765 }
1766 }
1767 }
1768 }
1769
1770 if ( !bRet
1771 && IsAttrAtPos::InetAttr & rContentAtPos.eContentAtPos
1772 && !aTmpState.m_bFootnoteNoInfo )
1773 {
1774 sal_Int32 index = aPos.GetContentIndex();
1775 pTextAttr = pTextNd->GetTextAttrAt(index, RES_TXTATR_INETFMT);
1776
1777 if(!pTextAttr && index > 0)
1778 pTextAttr = pTextNd->GetTextAttrAt(index - 1, RES_TXTATR_INETFMT);
1779 // "detect" only INetAttrs with URLs
1780 if( pTextAttr && !pTextAttr->GetINetFormat().GetValue().isEmpty() )
1781 {
1782 bRet = true;
1783 if( bSetCursor )
1784 {
1785 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1786 SwCallLink aLk( *this ); // watch Cursor-Moves
1788 *m_pCurrentCursor->GetPoint() = aPos;
1791 bRet = false;
1792 else
1793 UpdateCursor();
1794 }
1795 if( bRet )
1796 {
1797 const sal_Int32 nSt = pTextAttr->GetStart();
1798 const sal_Int32 nEnd = *pTextAttr->End();
1799
1800 rContentAtPos.sStr = pTextNd->GetExpandText(GetLayout(), nSt, nEnd-nSt);
1801
1802 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1803 rContentAtPos.eContentAtPos = IsAttrAtPos::InetAttr;
1804 rContentAtPos.pFndTextAttr = pTextAttr;
1805
1806 if (pFieldRect)
1807 {
1808 std::pair<Point, bool> tmp(aPt, true);
1809 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1810 if (pFrame)
1811 {
1812 //get bounding box of range
1813 SwRect aStart;
1814 SwPosition aStartPos(*pTextNd, nSt);
1815 pFrame->GetCharRect(aStart, aStartPos, &aTmpState);
1816 SwRect aEnd;
1817 SwPosition aEndPos(*pTextNd, nEnd);
1818 pFrame->GetCharRect(aEnd, aEndPos, &aTmpState);
1819 if (aStart.Top() != aEnd.Top() || aStart.Bottom() != aEnd.Bottom())
1820 {
1821 aStart.Left(pFrame->getFrameArea().Left());
1822 aEnd.Right(pFrame->getFrameArea().Right());
1823 }
1824 *pFieldRect = aStart.Union(aEnd);
1825 }
1826 }
1827 }
1828 }
1829 }
1830
1831 if( !bRet && IsAttrAtPos::Redline & rContentAtPos.eContentAtPos )
1832 {
1833 const SwRangeRedline* pRedl = GetDoc()->getIDocumentRedlineAccess().GetRedline(aPos, nullptr);
1834
1835 if( pRedl )
1836 {
1837 rContentAtPos.aFnd.pRedl = pRedl;
1838 rContentAtPos.eContentAtPos = IsAttrAtPos::Redline;
1839 rContentAtPos.pFndTextAttr = nullptr;
1840 bRet = true;
1841
1842 if (pFieldRect)
1843 {
1844 std::pair<Point, bool> tmp(aPt, true);
1845 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1846 if( pFrame )
1847 {
1848 // not sure if this should be limited to one
1849 // paragraph, or mark the entire redline; let's
1850 // leave it limited to one for now...
1851 sal_Int32 nStart;
1852 sal_Int32 nEnd;
1853 pRedl->CalcStartEnd(pTextNd->GetIndex(), nStart, nEnd);
1854 if (nStart == COMPLETE_STRING)
1855 {
1856 // consistency: found pRedl, so there must be
1857 // something in pTextNd
1858 assert(nEnd != COMPLETE_STRING);
1859 nStart = 0;
1860 }
1861 if (nEnd == COMPLETE_STRING)
1862 {
1863 nEnd = pTextNd->Len();
1864 }
1865 //get bounding box of range
1866 SwRect aStart;
1867 pFrame->GetCharRect(aStart, SwPosition(*pTextNd, nStart), &aTmpState);
1868 SwRect aEnd;
1869 pFrame->GetCharRect(aEnd, SwPosition(*pTextNd, nEnd), &aTmpState);
1870 if (aStart.Top() != aEnd.Top() || aStart.Bottom() != aEnd.Bottom())
1871 {
1872 aStart.Left(pFrame->getFrameArea().Left());
1873 aEnd.Right(pFrame->getFrameArea().Right());
1874 }
1875 *pFieldRect = aStart.Union(aEnd);
1876 }
1877 }
1878 }
1879 }
1880 }
1881
1882 if( !bRet && ( ( IsAttrAtPos::TableRedline & rContentAtPos.eContentAtPos ) ||
1883 ( IsAttrAtPos::TableColRedline & rContentAtPos.eContentAtPos ) ) )
1884 {
1885 const SwTableNode* pTableNd;
1886 const SwTableBox* pBox;
1887 const SwTableLine* pTableLine;
1888 const SwStartNode* pSttNd = pTextNd->FindTableBoxStartNode();
1889 if( pSttNd && nullptr != ( pTableNd = pTextNd->FindTableNode()) &&
1890 nullptr != ( pBox = pTableNd->GetTable().GetTableBox(
1891 pSttNd->GetIndex() )) &&
1892 nullptr != ( pTableLine = pBox->GetUpper() ) &&
1893 ( RedlineType::None != pBox->GetRedlineType() ||
1894 RedlineType::None != pTableLine->GetRedlineType() ) )
1895 {
1896 const SwRedlineTable& aRedlineTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
1897 if ( RedlineType::None != pTableLine->GetRedlineType() )
1898 {
1900 nPos = pTableLine->UpdateTextChangesOnly(nPos);
1901 if ( nPos != SwRedlineTable::npos )
1902 {
1903 rContentAtPos.aFnd.pRedl = aRedlineTable[nPos];
1905 bRet = true;
1906 }
1907 }
1908 else
1909 {
1911 SwNodeIndex aIdx( *pSttNd, 1 );
1912 const SwPosition aBoxStart(aIdx);
1913 const SwRangeRedline* pFnd = aRedlineTable.FindAtPosition( aBoxStart, n, /*next=*/true );
1914 if( pFnd && RedlineType::Delete == pFnd->GetType() )
1915 {
1916 rContentAtPos.aFnd.pRedl = aRedlineTable[n];
1918 bRet = true;
1919 }
1920 }
1921 }
1922 }
1923
1924 if( !bRet
1925 && ( IsAttrAtPos::TableBoxFml & rContentAtPos.eContentAtPos
1926#ifdef DBG_UTIL
1927 || IsAttrAtPos::TableBoxValue & rContentAtPos.eContentAtPos
1928#endif
1929 ) )
1930 {
1931 const SwTableNode* pTableNd;
1932 const SwTableBox* pBox;
1933 const SwStartNode* pSttNd = pTextNd->FindTableBoxStartNode();
1934 const SwTableBoxFormula* pItem;
1935#ifdef DBG_UTIL
1936 const SwTableBoxValue* pItem2 = nullptr;
1937#endif
1938 if( pSttNd && nullptr != ( pTableNd = pTextNd->FindTableNode()) &&
1939 nullptr != ( pBox = pTableNd->GetTable().GetTableBox(
1940 pSttNd->GetIndex() )) &&
1941#ifdef DBG_UTIL
1942 ( (pItem = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_FORMULA, false )) ||
1943 (pItem2 = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_VALUE, false )) )
1944#else
1945 (pItem = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_FORMULA, false ))
1946#endif
1947 )
1948 {
1949 std::pair<Point, bool> tmp(aPt, true);
1950 SwFrame* pF = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1951 if( pF )
1952 {
1953 // then the CellFrame
1954 pFrame = static_cast<SwContentFrame*>(pF);
1955 while( pF && !pF->IsCellFrame() )
1956 pF = pF->GetUpper();
1957 }
1958
1959 if( aTmpState.m_bPosCorr )
1960 {
1961 if( pF && !pF->getFrameArea().Contains( aPt ))
1962 pF = nullptr;
1963 }
1964 else if( !pF )
1965 pF = pFrame;
1966
1967 if( pF ) // only then it is valid
1968 {
1969 // create from internal (for CORE) the external
1970 // (for UI) formula
1972#ifdef DBG_UTIL
1973 if( pItem2 )
1975 else
1976#endif
1977 const_cast<SwTableBoxFormula&>(*pItem).PtrToBoxNm( &pTableNd->GetTable() );
1978
1979 bRet = true;
1980 if( bSetCursor )
1981 {
1982 SwCallLink aLk( *this ); // watch Cursor-Moves
1983 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1984 *m_pCurrentCursor->GetPoint() = aPos;
1987 bRet = false;
1988 else
1989 UpdateCursor();
1990 }
1991
1992 if( bRet )
1993 {
1994 if( pFieldRect )
1995 {
1996 *pFieldRect = pF->getFramePrintArea();
1997 *pFieldRect += pF->getFrameArea().Pos();
1998 }
1999 rContentAtPos.pFndTextAttr = nullptr;
2000 rContentAtPos.aFnd.pAttr = pItem;
2001 }
2002 }
2003 }
2004 }
2005
2006#ifdef DBG_UTIL
2007 if( !bRet && IsAttrAtPos::CurrAttrs & rContentAtPos.eContentAtPos )
2008 {
2009 const sal_Int32 n = aPos.GetContentIndex();
2011 if( pTextNd->GetpSwpHints() )
2012 {
2013 for( size_t i = 0; i < pTextNd->GetSwpHints().Count(); ++i )
2014 {
2015 const SwTextAttr* pHt = pTextNd->GetSwpHints().Get(i);
2016 const sal_Int32 nAttrStart = pHt->GetStart();
2017 if( nAttrStart > n ) // over the section
2018 break;
2019
2020 if( nullptr != pHt->End() && (
2021 ( nAttrStart < n &&
2022 ( pHt->DontExpand() ? n < *pHt->End()
2023 : n <= *pHt->End() )) ||
2024 ( n == nAttrStart &&
2025 ( nAttrStart == *pHt->End() || !n ))) )
2026 {
2027 aSet.Put( pHt->GetAttr() );
2028 }
2029 }
2030 if( pTextNd->HasSwAttrSet() &&
2031 pTextNd->GetpSwAttrSet()->Count() )
2032 {
2033 SfxItemSet aFormatSet( pTextNd->GetSwAttrSet() );
2034 // remove all from format set that are also in TextSet
2035 aFormatSet.Differentiate( aSet );
2036 // now merge all together
2037 aSet.Put( aFormatSet );
2038 }
2039 }
2040 else
2041 pTextNd->SwContentNode::GetAttr( aSet );
2042
2043 rContentAtPos.sStr = "Pos: (";
2044 rContentAtPos.sStr += OUString::number( sal_Int32(aPos.GetNodeIndex()));
2045 rContentAtPos.sStr += ":";
2046 rContentAtPos.sStr += OUString::number( aPos.GetContentIndex());
2047 rContentAtPos.sStr += ")";
2048 rContentAtPos.sStr += "\nParagraph Style: ";
2049 rContentAtPos.sStr += pTextNd->GetFormatColl()->GetName();
2050 if( pTextNd->GetCondFormatColl() )
2051 {
2052 rContentAtPos.sStr += "\nConditional Style: " + pTextNd->GetCondFormatColl()->GetName();
2053 }
2054
2055 if( aSet.Count() )
2056 {
2057 OUStringBuffer sAttrs;
2058 SfxItemIter aIter( aSet );
2059 const SfxPoolItem* pItem = aIter.GetCurItem();
2060 const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
2061 do
2062 {
2063 if( !IsInvalidItem( pItem ))
2064 {
2065 OUString aStr;
2067 MapUnit::MapCM, aStr, aInt);
2068 if (!sAttrs.isEmpty())
2069 sAttrs.append(", ");
2070 sAttrs.append(aStr);
2071 }
2072 pItem = aIter.NextItem();
2073 } while (pItem);
2074 if (!sAttrs.isEmpty())
2075 {
2076 if( !rContentAtPos.sStr.isEmpty() )
2077 rContentAtPos.sStr += "\n";
2078 rContentAtPos.sStr += "Attr: " + sAttrs;
2079 }
2080 }
2081 bRet = true;
2082 rContentAtPos.eContentAtPos = IsAttrAtPos::CurrAttrs;
2083 }
2084#endif
2085 }
2086
2087 if( !bRet )
2088 {
2089 rContentAtPos.eContentAtPos = IsAttrAtPos::NONE;
2090 rContentAtPos.aFnd.pField = nullptr;
2091 }
2092 return bRet;
2093}
2094
2095// #i90516#
2097{
2098 if ( IsTableMode() )
2099 return nullptr;
2100
2101 const SwPosition* pCursorPos = GetCursor_()->GetPoint();
2102 const SwTextNode* pTextNd = pCursorPos->GetNode().GetTextNode();
2103 if ( !pTextNd )
2104 return nullptr;
2105
2106 const SwPostItField* pPostItField = nullptr;
2107 SwTextAttr* pTextAttr = pTextNd->GetFieldTextAttrAt( pCursorPos->GetContentIndex() );
2108 const SwField* pField = pTextAttr != nullptr ? pTextAttr->GetFormatField().GetField() : nullptr;
2109 if ( pField && pField->Which()== SwFieldIds::Postit )
2110 {
2111 pPostItField = static_cast<const SwPostItField*>(pField);
2112 }
2113
2114 return pPostItField;
2115}
2116
2119{
2120 const SwTextNode* pNd = nullptr;
2121 if( pFndTextAttr )
2122 {
2123 switch( eContentAtPos )
2124 {
2125 case IsAttrAtPos::Field:
2127 pNd = static_txtattr_cast<SwTextField const*>(pFndTextAttr)->GetpTextNode();
2128 break;
2129
2130 case IsAttrAtPos::Ftn:
2131 pNd = &static_cast<const SwTextFootnote*>(pFndTextAttr)->GetTextNode();
2132 break;
2133
2135 pNd = static_txtattr_cast<SwTextINetFormat const*>(pFndTextAttr)->GetpTextNode();
2136 break;
2137
2138 default:
2139 break;
2140 }
2141 }
2142
2143 if( !pNd )
2144 return false;
2145 if( pNd->IsInProtectSect() )
2146 return true;
2147
2148 const SwContentFrame* pFrame = pNd->getLayoutFrame(pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr);
2149 return pFrame && pFrame->IsProtected() ;
2150}
2151
2153{
2154 const SwTextNode* pNd = nullptr;
2156 return false;
2157
2158 const SwTextFootnote* pTextFootnote = static_cast<const SwTextFootnote*>(pFndTextAttr);
2159 if(!pTextFootnote->GetStartNode())
2160 return false;
2161
2162 SwStartNode* pSttNd = pTextFootnote->GetStartNode()->GetNode().GetStartNode();
2163 SwPaM aTemp( *pSttNd );
2164 aTemp.Move(fnMoveForward, GoInNode);
2165 SwContentNode* pContentNode = aTemp.GetPointContentNode();
2166 if(pContentNode && pContentNode->IsTextNode())
2167 pNd = pContentNode->GetTextNode();
2168 if(!pNd)
2169 return false;
2170
2171 bool bRet = false;
2173 SwTextFrame* pTmpFrame = aIter.First();
2174 while( pTmpFrame )
2175 {
2176 if ( !pTmpFrame->IsFollow())
2177 {
2178 bRet = pTmpFrame->IsRightToLeft();
2179 break;
2180 }
2181 pTmpFrame = aIter.Next();
2182 }
2183 return bRet;
2184}
2185
2186bool SwCursorShell::SelectTextModel( const sal_Int32 nStart,
2187 const sal_Int32 nEnd )
2188{
2189 CurrShell aCurr( this );
2190 bool bRet = false;
2191
2192 SwCallLink aLk( *this );
2193 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2194
2197 rPos.SetContent(nStart);
2199 rPos.SetContent(nEnd);
2200
2201 if( !m_pCurrentCursor->IsSelOvr() )
2202 {
2203 UpdateCursor();
2204 bRet = true;
2205 }
2206
2207 return bRet;
2208}
2209
2210TextFrameIndex SwCursorShell::GetCursorPointAsViewIndex() const
2211{
2212 SwPosition const*const pPos(GetCursor()->GetPoint());
2213 SwTextNode const*const pTextNode(pPos->GetNode().GetTextNode());
2214 assert(pTextNode);
2215 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(pTextNode->getLayoutFrame(GetLayout())));
2216 assert(pFrame);
2217 return pFrame->MapModelToViewPos(*pPos);
2218}
2219
2220bool SwCursorShell::SelectTextView(TextFrameIndex const nStart,
2221 TextFrameIndex const nEnd)
2222{
2223 CurrShell aCurr( this );
2224 bool bRet = false;
2225
2226 SwCallLink aLk( *this );
2227 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2228
2231 // indexes must correspond to cursor point!
2232 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(m_pCurrentCursor->GetPoint()->GetNode().GetTextNode()->getLayoutFrame(GetLayout())));
2233 assert(pFrame);
2234 rPos = pFrame->MapViewToModelPos(nStart);
2236 rPos = pFrame->MapViewToModelPos(nEnd);
2237
2238 if (!m_pCurrentCursor->IsSelOvr())
2239 {
2240 UpdateCursor();
2241 bRet = true;
2242 }
2243
2244 return bRet;
2245}
2246
2247bool SwCursorShell::SelectTextAttr( sal_uInt16 nWhich,
2248 bool bExpand,
2249 const SwTextAttr* pTextAttr )
2250{
2251 CurrShell aCurr( this );
2252
2253 if( IsTableMode() )
2254 return false;
2255
2256 if( !pTextAttr )
2257 {
2259 SwTextNode* pTextNd = rPos.GetNode().GetTextNode();
2260 pTextAttr = pTextNd
2261 ? pTextNd->GetTextAttrAt(rPos.GetContentIndex(),
2262 nWhich,
2264 : nullptr;
2265 }
2266 if( !pTextAttr )
2267 return false;
2268
2269 const sal_Int32* pEnd = pTextAttr->End();
2270 bool bRet = SelectTextModel(pTextAttr->GetStart(), (pEnd ? *pEnd : pTextAttr->GetStart() + 1));
2271 return bRet;
2272}
2273
2275{
2276 if( !rAttr.GetpTextNode() )
2277 return false;
2278 SwCursor* pCursor = getShellCursor( true );
2279
2280 CurrShell aCurr( this );
2281 SwCallLink aLk( *this ); // watch Cursor-Moves
2282 SwCursorSaveState aSaveState( *pCursor );
2283
2284 pCursor->GetPoint()->Assign(*rAttr.GetpTextNode(), rAttr.GetStart() );
2285 bool bRet = !pCursor->IsSelOvr();
2286 if( bRet )
2288 return bRet;
2289}
2290
2291const SwFormatINetFormat* SwCursorShell::FindINetAttr( std::u16string_view rName ) const
2292{
2293 return mxDoc->FindINetAttr( rName );
2294}
2295
2296bool SwCursorShell::GetShadowCursorPos( const Point& rPt, SwFillMode eFillMode,
2297 SwRect& rRect, sal_Int16& rOrient )
2298{
2299
2300 CurrShell aCurr( this );
2301
2302 if (IsTableMode() || HasSelection()
2303 || !GetDoc()->GetIDocumentUndoRedo().DoesUndo())
2304 return false;
2305
2306 Point aPt( rPt );
2308
2309 SwFillCursorPos aFPos( eFillMode );
2310 SwCursorMoveState aTmpState( &aFPos );
2311
2312 bool bRet = false;
2313 if( GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState ) &&
2314 !aPos.GetNode().IsProtect())
2315 {
2316 // start position in protected section?
2317 rRect = aFPos.aCursor;
2318 rOrient = aFPos.eOrient;
2319 bRet = true;
2320 }
2321 return bRet;
2322}
2323
2324bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
2325{
2326 CurrShell aCurr( this );
2327
2328 if (IsTableMode() || HasSelection()
2329 || !GetDoc()->GetIDocumentUndoRedo().DoesUndo())
2330 return false;
2331
2332 Point aPt( rPt );
2334
2335 SwFillCursorPos aFPos( eFillMode );
2336 SwCursorMoveState aTmpState( &aFPos );
2337
2338 if( !GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState ) )
2339 return false;
2340
2341 SwCallLink aLk( *this ); // watch Cursor-Moves
2342 StartAction();
2343
2344 SwContentNode* pCNd = aPos.GetNode().GetContentNode();
2346 // If only the paragraph attributes "Adjust" or "LRSpace" are set,
2347 // then the following should not delete those again.
2348 if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
2349 ( SwFillMode::Indent == aFPos.eMode ||
2351 0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
2352 pCNd && pCNd->Len() )
2353 nUndoId = SwUndoId::EMPTY;
2354
2355 GetDoc()->GetIDocumentUndoRedo().StartUndo( nUndoId, nullptr );
2356
2357 SwTextFormatColl* pNextFormat = nullptr;
2358 SwTextNode* pTNd = pCNd ? pCNd->GetTextNode() : nullptr;
2359 if( pTNd )
2360 pNextFormat = &pTNd->GetTextColl()->GetNextTextFormatColl();
2361
2362 const SwSectionNode* pSectNd = pCNd ? pCNd->FindSectionNode() : nullptr;
2363 if( pSectNd && aFPos.nParaCnt )
2364 {
2365 SwNodeIndex aEnd( aPos.GetNode(), 1 );
2366 while( aEnd.GetNode().IsEndNode() &&
2367 &aEnd.GetNode() !=
2368 pSectNd->EndOfSectionNode() )
2369 ++aEnd;
2370
2371 if( aEnd.GetNode().IsEndNode() &&
2372 pCNd->Len() == aPos.GetContentIndex() )
2373 aPos.Assign( *pSectNd->EndOfSectionNode() );
2374 }
2375
2376 for( sal_uInt16 n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
2377 {
2379 if( !n && pNextFormat )
2380 {
2381 *m_pCurrentCursor->GetPoint() = aPos;
2382 GetDoc()->SetTextFormatColl( *m_pCurrentCursor, pNextFormat, false );
2383 }
2384 if( n < aFPos.nColumnCnt )
2385 {
2386 *m_pCurrentCursor->GetPoint() = aPos;
2388 SvxFormatBreakItem( SvxBreak::ColumnBefore, RES_BREAK ) );
2389 }
2390 }
2391
2392 *m_pCurrentCursor->GetPoint() = aPos;
2393 switch( aFPos.eMode )
2394 {
2395 case SwFillMode::Indent:
2396 if( nullptr != (pCNd = aPos.GetNode().GetContentNode() ))
2397 {
2398 assert(pCNd->IsTextNode()); // ???
2404 firstLine.SetTextFirstLineOffset(0);
2405 leftMargin.SetTextLeft(aFPos.nTabCnt);
2406 aSet.Put(firstLine);
2407 aSet.Put(leftMargin);
2408
2409 const SvxAdjustItem& rAdj = pCNd->GetAttr(RES_PARATR_ADJUST);
2410 if( SvxAdjust::Left != rAdj.GetAdjust() )
2411 aSet.Put( SvxAdjustItem( SvxAdjust::Left, RES_PARATR_ADJUST ) );
2412
2414 }
2415 else {
2416 OSL_ENSURE( false, "No ContentNode" );
2417 }
2418 break;
2419
2420 case SwFillMode::Tab:
2422 case SwFillMode::Space:
2423 {
2424 OUStringBuffer sInsert;
2425 if (aFPos.eMode == SwFillMode::Space)
2426 {
2427 comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceOnlyCnt, ' ');
2428 }
2429 else
2430 {
2431 if (aFPos.nTabCnt)
2432 comphelper::string::padToLength(sInsert, aFPos.nTabCnt, '\t');
2433 if (aFPos.nSpaceCnt)
2434 comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
2435 }
2436 if (!sInsert.isEmpty())
2437 GetDoc()->getIDocumentContentOperations().InsertString( *m_pCurrentCursor, sInsert.makeStringAndClear());
2438 }
2439 [[fallthrough]]; // still need to set orientation
2440 case SwFillMode::Margin:
2442 {
2443 SvxAdjustItem aAdj( SvxAdjust::Left, RES_PARATR_ADJUST );
2444 switch( aFPos.eOrient )
2445 {
2446 case text::HoriOrientation::CENTER:
2447 aAdj.SetAdjust( SvxAdjust::Center );
2448 break;
2449 case text::HoriOrientation::RIGHT:
2450 aAdj.SetAdjust( SvxAdjust::Right );
2451 break;
2452 default:
2453 break;
2454 }
2456 }
2457 break;
2458 }
2459
2460 GetDoc()->GetIDocumentUndoRedo().EndUndo( nUndoId, nullptr );
2461 EndAction();
2462
2463 return true;
2464}
2465
2467{
2468 if( IsTableMode() )
2469 return nullptr;
2470
2471 CurrShell aCurr( this );
2472 SwCallLink aLk( *this ); // watch Cursor-Moves
2473 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2474
2475 // ensure point is at the end so alternating SelNext/SelPrev works
2476 NormalizePam(false);
2478
2479 // at the end of the document, go to the start of the document, and try again
2480 if ( !pFnd )
2481 {
2484 }
2485
2488 else
2489 pFnd = nullptr;
2490 return pFnd;
2491}
2492
2494{
2495 if( IsTableMode() )
2496 return nullptr;
2497
2498 CurrShell aCurr( this );
2499 SwCallLink aLk( *this ); // watch Cursor-Moves
2500 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2501
2502 // ensure point is at the start so alternating SelNext/SelPrev works
2503 NormalizePam(true);
2505
2506 // at the start of the document, go to the end of the document, and try again
2507 if ( !pFnd )
2508 {
2511 }
2512
2515 else
2516 pFnd = nullptr;
2517 return pFnd;
2518}
2519
2521{
2522 const SwRangeRedline* pFnd = nullptr;
2523 SwCallLink aLk( *this ); // watch Cursor-Moves
2524 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2525
2526 pFnd = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nArrPos ];
2527 if( !pFnd )
2528 return nullptr;
2529
2530 *m_pCurrentCursor->GetPoint() = *pFnd->Start();
2531
2533 if( !pPtPos->GetNode().IsContentNode() )
2534 {
2535 SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( pPtPos,
2536 true, IsReadOnlyAvailable() );
2537 if( pCNd )
2538 {
2539 if( pPtPos->GetNode() <= pFnd->End()->GetNode() )
2540 pPtPos->SetContent( 0 );
2541 else
2542 pFnd = nullptr;
2543 }
2544 }
2545
2546 if( pFnd && bSelect )
2547 {
2549 if( RedlineType::FmtColl == pFnd->GetType() )
2550 {
2551 SwContentNode* pCNd = pPtPos->GetNode().GetContentNode();
2552 m_pCurrentCursor->GetPoint()->SetContent( pCNd->Len() );
2553 m_pCurrentCursor->GetMark()->Assign( *pCNd, 0 );
2554 }
2555 else
2556 *m_pCurrentCursor->GetPoint() = *pFnd->End();
2557
2558 pPtPos = m_pCurrentCursor->GetPoint();
2559 if( !pPtPos->GetNode().IsContentNode() )
2560 {
2561 SwContentNode* pCNd = SwNodes::GoPrevSection( pPtPos,
2562 true, IsReadOnlyAvailable() );
2563 if( pCNd )
2564 {
2565 if( pPtPos->GetNode() >= m_pCurrentCursor->GetMark()->GetNode() )
2566 pPtPos->SetContent( pCNd->Len() );
2567 else
2568 pFnd = nullptr;
2569 }
2570 }
2571 }
2572
2573 if( !pFnd )
2574 {
2577 }
2578 else if( bSelect && *m_pCurrentCursor->GetMark() == *m_pCurrentCursor->GetPoint() )
2580
2584 else
2585 {
2586 pFnd = nullptr;
2587 if( bSelect )
2589 }
2590 return pFnd;
2591}
2592
2594{
2595 const SwRangeRedline* pFnd = nullptr;
2596 if( IsTableMode() )
2597 return nullptr;
2598
2599 CurrShell aCurr( this );
2600
2602 const SwRangeRedline* pTmp = rTable[ nArrPos ];
2603 sal_uInt16 nSeqNo = pTmp->GetSeqNo();
2604 if( !nSeqNo || !bSelect )
2605 {
2606 pFnd = GotoRedline_( nArrPos, bSelect );
2607 return pFnd;
2608 }
2609
2610 bool bCheck = false;
2611 int nLoopCnt = 2;
2612 SwRedlineTable::size_type nArrSavPos = nArrPos;
2613
2614 do {
2615 pTmp = GotoRedline_( nArrPos, true );
2616
2617 if( !pFnd )
2618 pFnd = pTmp;
2619
2620 if( pTmp && bCheck )
2621 {
2622 // Check for overlaps. These can happen when FormatColl-
2623 // Redlines were stretched over a whole paragraph
2624 SwPaM* pCur = m_pCurrentCursor;
2625 SwPaM* pNextPam = pCur->GetNext();
2626 auto [pCStt, pCEnd] = pCur->StartEnd(); // SwPosition*
2627 while( pCur != pNextPam )
2628 {
2629 auto [pNStt, pNEnd] = pNextPam->StartEnd(); // SwPosition*
2630
2631 bool bDel = true;
2632 switch( ::ComparePosition( *pCStt, *pCEnd,
2633 *pNStt, *pNEnd ))
2634 {
2635 case SwComparePosition::Inside: // Pos1 is completely in Pos2
2636 if( !pCur->HasMark() )
2637 {
2638 pCur->SetMark();
2639 *pCur->GetMark() = *pNStt;
2640 }
2641 else
2642 *pCStt = *pNStt;
2643 *pCEnd = *pNEnd;
2644 break;
2645
2646 case SwComparePosition::Outside: // Pos2 is completely in Pos1
2647 case SwComparePosition::Equal: // Pos1 has same size as Pos2
2648 break;
2649
2650 case SwComparePosition::OverlapBefore: // Pos1 overlaps Pos2 at beginning
2651 if( !pCur->HasMark() )
2652 pCur->SetMark();
2653 *pCEnd = *pNEnd;
2654 break;
2655 case SwComparePosition::OverlapBehind: // Pos1 overlaps Pos2 at end
2656 if( !pCur->HasMark() )
2657 {
2658 pCur->SetMark();
2659 *pCur->GetMark() = *pNStt;
2660 }
2661 else
2662 *pCStt = *pNStt;
2663 break;
2664
2665 default:
2666 bDel = false;
2667 }
2668
2669 if( bDel )
2670 {
2671 // not needed anymore
2672 SwPaM* pPrevPam = pNextPam->GetPrev();
2673 delete pNextPam;
2674 pNextPam = pPrevPam;
2675 }
2676 pNextPam = pNextPam->GetNext();
2677 }
2678 }
2679
2680 SwRedlineTable::size_type nFndPos = 2 == nLoopCnt
2681 ? rTable.FindNextOfSeqNo( nArrPos )
2682 : rTable.FindPrevOfSeqNo( nArrPos );
2683 if( SwRedlineTable::npos != nFndPos ||
2684 ( 0 != ( --nLoopCnt ) && SwRedlineTable::npos != (
2685 nFndPos = rTable.FindPrevOfSeqNo( nArrSavPos ))) )
2686 {
2687 if( pTmp )
2688 {
2689 // create new cursor
2690 CreateCursor();
2691 bCheck = true;
2692 }
2693 nArrPos = nFndPos;
2694 }
2695 else
2696 nLoopCnt = 0;
2697
2698 } while( nLoopCnt );
2699 return pFnd;
2700}
2701
2703{
2704 SwNodes& rNds = GetDoc()->GetNodes();
2705 const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
2706 const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
2707 SwNodeOffset nBodySttNdIdx = pBodySttNd->GetIndex();
2708 Point aPt;
2709
2710 SetGetExpField aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
2711 SetGetExpField aCurPos( bNext ? *m_pCurrentCursor->End() : *m_pCurrentCursor->Start() );
2712 if( aCurPos.GetNode() < nBodySttNdIdx )
2713 {
2714 const SwContentNode* pCNd = aCurPos.GetNodeFromContent()->GetContentNode();
2715 std::pair<Point, bool> tmp(aPt, true);
2716 if (pCNd)
2717 {
2718 SwContentFrame* pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
2719 if( pFrame )
2720 aCurPos.SetBodyPos( *pFrame );
2721 }
2722 }
2723
2724 // check first all the hyperlink fields
2725 {
2726 const SwTextNode* pTextNd;
2727 const SwCharFormats* pFormats = GetDoc()->GetCharFormats();
2728 for( SwCharFormats::size_type n = pFormats->size(); 1 < n; )
2729 {
2730 SwIterator<SwTextINetFormat,SwCharFormat> aIter(*(*pFormats)[--n]);
2731
2732 for( SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
2733 {
2734 pTextNd = pFnd->GetpTextNode();
2735 if( pTextNd && pTextNd->GetNodes().IsDocNodes() )
2736 {
2737 SwTextINetFormat& rAttr = *pFnd;
2738 SetGetExpField aPos( *pTextNd, rAttr );
2739 if (pTextNd->GetIndex() < nBodySttNdIdx)
2740 {
2741 std::pair<Point, bool> tmp(aPt, true);
2742 SwContentFrame* pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
2743 if (pFrame)
2744 {
2745 aPos.SetBodyPos( *pFrame );
2746 }
2747 }
2748
2749 if( bNext
2750 ? ( aPos < aCmpPos && aCurPos < aPos )
2751 : ( aCmpPos < aPos && aPos < aCurPos ))
2752 {
2753 OUString sText(pTextNd->GetExpandText(GetLayout(),
2754 rAttr.GetStart(),
2755 *rAttr.GetEnd() - rAttr.GetStart() ) );
2756
2757 sText = sText.replaceAll("\x0a", "");
2758 sText = comphelper::string::strip(sText, ' ');
2759
2760 if( !sText.isEmpty() )
2761 aCmpPos = aPos;
2762 }
2763 }
2764 }
2765 }
2766 }
2767
2768 // then check all the Flys with a URL or image map
2769 {
2770 for(sw::SpzFrameFormat* pSpz: *GetDoc()->GetSpzFrameFormats())
2771 {
2772 auto pFormat = static_cast<SwFlyFrameFormat*>(pSpz);
2773 const SwFormatURL& rURLItem = pFormat->GetURL();
2774 if( rURLItem.GetMap() || !rURLItem.GetURL().isEmpty() )
2775 {
2776 SwFlyFrame* pFly = pFormat->GetFrame( &aPt );
2777 SwPosition aTmpPos( *pBodySttNd );
2778 if( pFly &&
2779 GetBodyTextNode( *GetDoc(), aTmpPos, *pFly->GetLower() ) )
2780 {
2781 SetGetExpField aPos( *pFormat, &aTmpPos );
2782
2783 if( bNext
2784 ? ( aPos < aCmpPos && aCurPos < aPos )
2785 : ( aCmpPos < aPos && aPos < aCurPos ))
2786 aCmpPos = aPos;
2787 }
2788 }
2789 }
2790 }
2791
2792 // found any URL ?
2793 const SwTextINetFormat* pFndAttr = aCmpPos.GetINetFormat();
2794 const SwFlyFrameFormat* pFndFormat = aCmpPos.GetFlyFormat();
2795 if( !pFndAttr && !pFndFormat )
2796 return false;
2797
2798 CurrShell aCurr( this );
2799 SwCallLink aLk( *this );
2800
2801 bool bRet = false;
2802 // found a text attribute ?
2803 if( pFndAttr )
2804 {
2805 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2806
2810 m_pCurrentCursor->GetPoint()->SetContent( *pFndAttr->End() );
2811
2813 {
2816 bRet = true;
2817 }
2818 }
2819 // found a draw object ?
2820 else if( RES_DRAWFRMFMT == pFndFormat->Which() )
2821 {
2822 const SdrObject* pSObj = pFndFormat->FindSdrObject();
2823 if (pSObj)
2824 {
2825 static_cast<SwFEShell*>(this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
2827 bRet = true;
2828 }
2829 }
2830 else // then is it a fly
2831 {
2832 SwFlyFrame* pFly = pFndFormat->GetFrame(&aPt);
2833 if( pFly )
2834 {
2835 static_cast<SwFEShell*>(this)->SelectFlyFrame( *pFly );
2837 bRet = true;
2838 }
2839 }
2840 return bRet;
2841}
2842
2843/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
const char * pName
virtual bool AppendTextNode(SwPosition &rPos)=0
virtual void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr)=0
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, SwTextAttr **ppNewTextAttr=nullptr)=0
Insert an attribute.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
virtual const_iterator_t getFieldmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of fieldmarks.
virtual sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
virtual const SwRangeRedline * SelNextRedline(SwPaM &rPam) const =0
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
virtual const SwRangeRedline * SelPrevRedline(SwPaM &rPam) const =0
virtual const tools::Rectangle & GetCurrentBoundRect() const
const SwTextINetFormat * GetINetFormat() const
Definition: docfld.hxx:100
const SwNode * GetNodeFromContent() const
Definition: docfld.cxx:294
void SetBodyPos(const SwContentFrame &rFrame)
Definition: docfld.cxx:204
void GetPosOfContent(SwPosition &rPos) const
Definition: docfld.cxx:188
SwNodeOffset GetNode() const
Definition: docfld.hxx:105
const SwFlyFrameFormat * GetFlyFormat() const
Definition: docfld.hxx:102
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const
sal_uInt16 Count() const
void Differentiate(const SfxItemSet &rSet)
constexpr tools::Long Width() const
SvxAdjust GetAdjust() const
void SetAdjust(const SvxAdjust eType)
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
static void SetSearchLabel(const SearchLabel &rSL)
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
size_t size() const
Definition: charformats.hxx:71
SwCharFormatsBase::size_type size_type
Definition: charformats.hxx:63
Knows all the text content controls in the document.
SwTextContentControl * UnsortedGet(size_t nIndex)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
SwFormatColl * GetFormatColl() const
Definition: node.hxx:497
bool HasSwAttrSet() const
Definition: node.hxx:494
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
SS for PoolItems: hard attributation.
Definition: node.hxx:770
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:765
virtual sal_Int32 Len() const
Definition: node.cxx:1256
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
SwFormatColl * GetCondFormatColl() const
Definition: node.hxx:753
A helper class to save cursor state (position).
Definition: swcrsr.hxx:233
SAL_DLLPRIVATE void UpdateCursor(sal_uInt16 eFlags=SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE, bool bIdleEnd=false)
Definition: crsrsh.cxx:1844
tools::Long GetUpDownX() const
Definition: crsrsh.hxx:361
bool GotoRefMark(const OUString &rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo)
jump to reference marker
Definition: crstrvl.cxx:1402
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1023
void GotoFormControl(bool bNext)
Go to the next (or previous) form control, based first on tabIndex and then paragraph position,...
Definition: crstrvl.cxx:877
bool GetShadowCursorPos(const Point &rPt, SwFillMode eFillMode, SwRect &rRect, sal_Int16 &rOrient)
Definition: crstrvl.cxx:2296
bool GotoNextOutline()
jump to next node with outline num.
Definition: crstrvl.cxx:1190
bool GotoPrevOutline()
jump to previous node with outline num.
Definition: crstrvl.cxx:1255
void GotoTOXMarkBase()
jump to index of TOXMark
Definition: crstrvl.cxx:362
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:493
SAL_DLLPRIVATE void MoveCursorToNum()
Definition: crstrvl.cxx:81
void StartAction()
Definition: crsrsh.cxx:226
const SwTableNode * IsCursorInTable() const
Check if Point of current cursor is placed within a table.
Definition: crsrsh.cxx:600
bool GotoHeaderText()
jump from the content to the header
Definition: crstrvl.cxx:132
bool GotoPrevTOXBase(const OUString *=nullptr)
jump to previous index
Definition: crstrvl.cxx:313
bool SelectNxtPrvHyperlink(bool bNext)
Definition: crstrvl.cxx:2702
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:342
const SwPostItField * GetPostItFieldAtCursor() const
Definition: crstrvl.cxx:2096
const SwTOXMark & GotoTOXMark(const SwTOXMark &rStart, SwTOXSearch eDir)
traveling between marks
Definition: crstrvl.cxx:586
const SwFormatINetFormat * FindINetAttr(std::u16string_view rName) const
Definition: crstrvl.cxx:2291
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2806
bool GotoFieldmark(const ::sw::mark::IFieldmark *const pMark)
Definition: crbm.cxx:305
void NormalizePam(bool bPointFirst=true)
Ensure point and mark of the current PaM are in a specific order.
Definition: crsrsh.cxx:1224
bool GotoFootnoteAnchor()
jump from footnote to anchor
Definition: trvlfnfl.cxx:167
bool SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven=false, bool bFirst=false)
Definition: crstrvl.cxx:192
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
bool SelectTextModel(sal_Int32 nStart, sal_Int32 nEnd)
Definition: crstrvl.cxx:2186
bool GotoNxtPrvTOXMark(bool bNext=true)
jump to next/previous index marker
Definition: crstrvl.cxx:496
bool SelectTextAttr(sal_uInt16 nWhich, bool bExpand, const SwTextAttr *pAttr=nullptr)
Definition: crstrvl.cxx:2247
bool CursorInsideInputField() const
Definition: crstrvl.cxx:1092
void GotoPrevNum()
Definition: crstrvl.cxx:124
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1071
SwPaM * CreateCursor()
delete the current cursor and make the following into the current
Definition: crsrsh.cxx:123
bool SetShadowCursorPos(const Point &rPt, SwFillMode eFillMode)
Definition: crstrvl.cxx:2324
void MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren, bool bKillPams=true)
Definition: crstrvl.cxx:1346
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
bool IsPageAtPos(const Point &rPt) const
Definition: crstrvl.cxx:1424
void GotoNextNum()
go to next/previous point on the same level
Definition: crstrvl.cxx:117
bool GotoNextTOXBase(const OUString *=nullptr)
jump to the next index
Definition: crstrvl.cxx:266
static sal_Int32 StartOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1139
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2739
static SwTextField * GetTextFieldAtCursor(const SwPaM *pCursor, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1038
const SwRangeRedline * GotoRedline(SwRedlineTable::size_type nArrPos, bool bSelect)
Definition: crstrvl.cxx:2593
static SwField * GetFieldAtCursor(const SwPaM *pCursor, const bool bIncludeInputFieldAtStart)
Definition: crstrvl.cxx:1060
const SwRangeRedline * SelNextRedline()
Definition: crstrvl.cxx:2466
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3360
bool DocPtInsideInputField(const Point &rDocPt) const
Definition: crstrvl.cxx:1128
SAL_DLLPRIVATE const SwRangeRedline * GotoRedline_(SwRedlineTable::size_type nArrPos, bool bSelect)
Definition: crstrvl.cxx:2520
void ClearMark()
Definition: crsrsh.cxx:1193
sw::mark::IFieldmark * GetFieldmarkBefore(bool bLoop)
Definition: crbm.cxx:299
bool GotoOutline(const OUString &rName)
Definition: crstrvl.cxx:1171
SwTextContentControl * CursorInsideContentControl() const
Definition: crstrvl.cxx:1102
const SwRangeRedline * SelPrevRedline()
Definition: crstrvl.cxx:2493
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3324
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:174
static sal_Int32 EndOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1147
@ READONLY
make visible in spite of Readonly
Definition: crsrsh.hxx:165
@ CHKRANGE
check overlapping PaMs
Definition: crsrsh.hxx:164
@ SCROLLWIN
scroll window
Definition: crsrsh.hxx:163
@ UPDOWN
keep Up/Down on columns
Definition: crsrsh.hxx:162
static bool PosInsideInputField(const SwPosition &rPos)
Definition: crstrvl.cxx:1123
::sw::mark::IFieldmark * GetCurrentFieldmark()
Definition: crbm.cxx:286
void KillPams()
Definition: crsrsh.cxx:1276
SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel=UCHAR_MAX, SwPaM *pPaM=nullptr)
search "outline position" before previous outline node at given level
Definition: crstrvl.cxx:1317
sw::mark::IFieldmark * GetFieldmarkAfter(bool bLoop)
Definition: crbm.cxx:293
SwShellCursor * m_pCurrentCursor
current cursor
Definition: crsrsh.hxx:185
bool GotoNxtPrvTableFormula(bool bNext=true, bool bOnlyErrors=false)
Jump to next/previous table formula Optionally it is possible to also jump to broken formulas.
Definition: crstrvl.cxx:381
bool GotoFormatField(const SwFormatField &rField)
Definition: crstrvl.cxx:999
bool GetContentAtPos(const Point &rPt, SwContentAtPos &rContentAtPos, bool bSetCursor=false, SwRect *pFieldRect=nullptr)
Definition: crstrvl.cxx:1431
bool GotoINetAttr(const SwTextINetFormat &rAttr)
Definition: crstrvl.cxx:2274
bool IsTableMode() const
Definition: crsrsh.hxx:667
bool GotoFormatContentControl(const SwFormatContentControl &rContentControl)
Definition: crstrvl.cxx:832
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:672
bool GotoFooterText()
jump from the content to the footer
Definition: crstrvl.cxx:160
void RestoreSavePos()
Restore cursor state to the one saved by SwCursorSaveState.
Definition: swcrsr.cxx:2341
virtual bool IsSelOvr(SwCursorSelOverFlags eFlags=SwCursorSelOverFlags::CheckNodeSection|SwCursorSelOverFlags::Toggle|SwCursorSelOverFlags::ChangePos)
Definition: swcrsr.cxx:222
bool IsInProtectTable(bool bMove=false, bool bChgCursor=true)
Definition: swcrsr.cxx:557
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:225
Definition: doc.hxx:197
bool ContainsPageDesc(const SwPageDesc *pDesc, size_t *pPos) const
Definition: docdesc.cxx:952
SwSectionFormats & GetSections()
Definition: doc.hxx:1353
static sal_uInt16 GetCurTOXMark(const SwPosition &rPos, SwTOXMarks &)
Get current table of contents Mark.
Definition: doctxm.cxx:117
static bool GotoPrevNum(SwPosition &, SwRootFrame const *pLayout, bool bOverUpper=true)
Definition: docnum.cxx:1700
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:753
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:329
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:349
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1890
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1334
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter <bResetListAttrs>.
Definition: docfmt.cxx:1088
SwDocShell * GetDocShell()
Definition: doc.hxx:1367
static bool GotoNextNum(SwPosition &, SwRootFrame const *pLayout, bool bOverUpper=true, sal_uInt8 *pUpper=nullptr, sal_uInt8 *pLower=nullptr)
Definition: docnum.cxx:1614
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:894
::SwContentControlManager & GetContentControlManager()
Definition: doc.cxx:142
const SwTOXMark & GotoTOXMark(const SwTOXMark &rCurTOXMark, SwTOXSearch eDir, bool bInReadOnly)
Definition: doctxm.cxx:229
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
SwFieldIds Which() const
Definition: fldbas.hxx:276
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:205
Base class of all fields.
Definition: fldbas.hxx:296
bool HasClickHdl() const
Does the field possess an action on its ClickHandler? (e.g. INetFields, ...).
Definition: fldbas.cxx:425
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
SwFieldIds Which() const
ResId.
Definition: fldbas.cxx:263
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3140
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
SfxPoolItem subclass that wraps an SwContentControl.
const std::shared_ptr< SwContentControl > & GetContentControl() const
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:32
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
const SwField * GetField() const
Definition: fmtfld.hxx:131
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:149
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:65
const SwFrameFormat * GetFooterFormat() const
Definition: fmthdft.hxx:85
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:34
const SwFrameFormat * GetHeaderFormat() const
Definition: fmthdft.hxx:54
const OUString & GetValue() const
Definition: fmtinfmt.hxx:75
SfxPoolItem subclass that wraps a URL.
Definition: fmturl.hxx:33
const ImageMap * GetMap() const
Definition: fmturl.hxx:67
const OUString & GetURL() const
Definition: fmturl.hxx:65
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const OUString & GetName() const
Definition: format.hxx:131
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Templatized version of GetItemState() to directly return the correct type.
Definition: format.hxx:111
const SwRect & getFrameArea() const
Definition: frame.hxx:179
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:153
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsCellFrame() const
Definition: frame.hxx:1232
bool IsHeaderFrame() const
Definition: frame.hxx:1196
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1799
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1639
SwFrame * GetLower()
Definition: findfrm.cxx:196
bool IsRightToLeft() const
Definition: frame.hxx:993
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
bool IsFooterFrame() const
Definition: frame.hxx:1200
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
bool IsVertical() const
Definition: frame.hxx:979
bool IsContentFrame() const
Definition: frame.hxx:1236
SwPageFrame * FindPageFrame()
Definition: frame.hxx:686
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
static SwTextNode * FindAnchor(SwDoc *pDoc, const OUString &rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_Int32 *pStt, sal_Int32 *pEnd=nullptr, SwRootFrame const *pLayout=nullptr)
Definition: reffld.cxx:1169
TElementType * Next()
Definition: calbck.hxx:380
TElementType * First()
Definition: calbck.hxx:372
const SwFrame * GetLastLower() const
Definition: findfrm.cxx:1917
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:123
Base class of the Writer document model elements.
Definition: node.hxx:98
SwStartNode * GetStartNode()
Definition: node.hxx:642
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:218
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ... including anchor in case of fra...
Definition: node.cxx:449
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:744
bool IsInProtectSect() const
Is node in a protected area?
Definition: node.cxx:439
bool IsContentNode() const
Definition: node.hxx:679
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsEndNode() const
Definition: node.hxx:683
bool IsTextNode() const
Definition: node.hxx:687
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:968
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
SwContentNode * GetContentNode()
Definition: node.hxx:666
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:733
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:236
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:165
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2538
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1299
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!...
Definition: nodes.cxx:1948
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
Definition: nodes.cxx:2064
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:32
static constexpr auto npos
Definition: ndarr.hxx:81
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
const SwPosition * GetMark() const
Definition: pam.hxx:255
SwNode & GetPointNode() const
Definition: pam.hxx:275
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:643
SwPaM * GetPrev()
Definition: pam.hxx:318
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
Definition: pam.hxx:269
bool IsMultiSelection() const
Definition: pam.hxx:322
SwContentNode * GetPointContentNode() const
Definition: pam.hxx:279
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:657
const SwPosition * End() const
Definition: pam.hxx:263
SwPaM * GetNext()
Definition: pam.hxx:314
void DeleteMark()
Definition: pam.hxx:232
const SwPosition * GetPoint() const
Definition: pam.hxx:253
const SwPosition * Start() const
Definition: pam.hxx:258
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:251
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
SwFrameFormat & GetFirstLeft()
Definition: pagedesc.hxx:241
SwFrameFormat & GetFirstMaster()
Definition: pagedesc.hxx:240
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:239
A page of the document layout.
Definition: pagefrm.hxx:59
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:144
void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32 &rStart, sal_Int32 &rEnd) const
Calculates the intersection with text node number nNdIdx.
Definition: docredln.cxx:1470
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1975
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:237
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:35
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
Point Center() const
Definition: swrect.hxx:338
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
size_type FindPrevOfSeqNo(size_type nSttPos) const
Definition: docredln.cxx:713
size_type FindNextOfSeqNo(size_type nSttPos) const
Definition: docredln.cxx:706
static constexpr size_type npos
Definition: docary.hxx:224
vector_type::size_type size_type
Definition: docary.hxx:223
const SwRangeRedline * FindAtPosition(const SwPosition &startPosition, size_type &tableIndex, bool next=true) const
Find the redline at the given position.
Definition: docredln.cxx:765
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
Definition: findfrm.cxx:658
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
SwSectionNode * GetSectionNode()
Definition: section.cxx:923
Array of Undo-history.
Definition: docary.hxx:193
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
SwSectionFormat * GetFormat()
Definition: section.hxx:341
SectionType GetType() const
Definition: section.hxx:173
bool GetInputFlag() const
Definition: expfld.hxx:269
const Point & GetPtPos() const
Definition: viscrs.hxx:165
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:939
Starts a section of nodes in the document model.
Definition: node.hxx:348
const OUString & GetTOXName() const
Definition: tox.hxx:481
const SwTextTOXMark * GetTextTOXMark() const
Definition: tox.hxx:160
const OUString & GetAlternativeText() const
Definition: tox.hxx:570
SwContentFrame * FindContentFrame(const SwDoc &rDoc, const SwRootFrame &rLayout) const
Definition: tox.hxx:186
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
SwTableLine * GetUpper()
Definition: swtable.hxx:477
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:481
RedlineType GetRedlineType() const
Definition: swtable.cxx:3020
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:495
bool IsIntrnlName() const
Definition: cellfml.hxx:131
void PtrToBoxNm(const SwTable *pTable)
create from the internal formula (for CORE) the external formula (for UI)
Definition: cellfml.cxx:580
SwTableLine is one table row in the document model.
Definition: swtable.hxx:376
SwRedlineTable::size_type UpdateTextChangesOnly(SwRedlineTable::size_type &rRedlinePos, bool bUpdateProperty=true) const
Definition: swtable.cxx:1751
RedlineType GetRedlineType() const
Definition: swtable.cxx:1954
const SwTable & GetTable() const
Definition: node.hxx:542
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1344
virtual const sal_Int32 * GetEnd() const override
end position
Definition: txatbase.cxx:77
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:167
virtual const sal_Int32 * GetEnd() const
end position
Definition: txatbase.cxx:48
const sal_Int32 * End() const
Definition: txatbase.hxx:156
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const SwFormatINetFormat & GetINetFormat() const
Definition: txatbase.hxx:244
bool DontExpand() const
Definition: txatbase.hxx:98
const SwFormatContentControl & GetContentControl() const
Definition: txatbase.hxx:220
sal_uInt16 Which() const
Definition: txatbase.hxx:116
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:199
const SwTOXMark & GetTOXMark() const
Definition: txatbase.hxx:232
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
SwTextNode * GetTextNode() const
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
void ChgTextNode(SwTextNode *pNew)
Definition: txtfld.hxx:58
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
const SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:43
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:72
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:106
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
Definition: txtinet.hxx:30
const SwTextNode * GetpTextNode() const
Definition: txtinet.hxx:46
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
Definition: ndtxt.cxx:3503
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:291
SwWrongList * GetSmartTags()
Definition: txtedt.cxx:2325
SwTextField * GetFieldTextAttrAt(const sal_Int32 nIndex, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Expand) const
Definition: ndtxt.cxx:1847
SwpHints & GetSwpHints()
getters for SwpHints
Definition: ndtxt.hxx:867
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
Definition: itratr.cxx:859
int GetAttrOutlineLevel() const
Returns outline level of this text node.
Definition: ndtxt.cxx:4166
std::vector< SwTextAttr * > GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) const
get the innermost text attributes covering position nIndex.
Definition: ndtxt.cxx:1793
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
Definition: ndtxt.cxx:1802
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:252
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3153
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:895
const SwTextNode & GetTextNode() const
Definition: txttxmrk.hxx:49
std::vector< SwSectionFormat * >::size_type size_type
Definition: docary.hxx:67
size_t size() const
Definition: docary.hxx:88
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:364
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2167
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:198
bool ActionPend() const
Definition: viewsh.hxx:224
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2149
vcl::Window * GetWin() const
Definition: viewsh.hxx:363
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2819
SwDoc * GetDoc() const
Definition: viewsh.hxx:307
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: viewsh.cxx:2809
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:649
sal_uInt16 GetWrongPos(sal_Int32 nValue) const
Find the first position that is greater or equal to the given value.
Definition: wrong.cxx:191
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
Definition: wrong.cxx:103
SwWrongList * SubList(sal_uInt16 nIdx) const
Definition: wrong.hxx:342
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
bool EndOfSection(bool bSelect=false)
Definition: move.cxx:352
bool StartOfSection(bool bSelect=false)
Definition: move.cxx:346
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
const_iterator begin() const
bool empty() const
const_iterator end() const
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
const_iterator lower_bound(const Value &x) const
ring_container GetRingContainer()
Definition: ring.hxx:240
constexpr Point Center() const
Point LogicToPixel(const Point &rLogicPt) const
@ CurrAttrs
only for debugging
@ TableBoxValue
only for debugging
SwFillMode
Definition: crstate.hxx:29
@ Indent
by left paragraph indentation
@ Tab
default, fill with tabs
@ Margin
only align left, center, right
@ Space
fill with spaces
@ TabSpace
fill with spaces and tabs
static SetGetExpFields::const_iterator lcl_FindField(bool &o_rFound, SetGetExpFields const &rSrtLst, SwRootFrame const *const pLayout, SwTextNode *const pTextNode, SwTextField const *const pTextField, SwPosition const &rPos, sal_Int32 const nContentOffset)
Definition: crstrvl.cxx:643
static void lcl_MakeFieldLst(SetGetExpFields &rLst, const SwFieldType &rFieldType, const bool bInReadOnly, const bool bChkInpFlag=false)
jump to next/previous field type
Definition: crstrvl.cxx:608
static SwNode * GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
Definition: expfld.cxx:163
SwFieldIds
Definition: fldbas.hxx:49
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
Definition: fltshell.cxx:54
constexpr sal_uInt16 POOLATTR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(158)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(157)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
sal_Int32 nIndex
Mode eMode
sal_Int64 n
sal_uInt16 nPos
aStr
OString strip(const OString &rIn, char c)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
int i
index
Count
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
Definition: txtfrm.cxx:313
OUString GetExpandTextMerged(SwRootFrame const *const pLayout, SwTextNode const &rNode, bool const bWithNumber, bool const bWithSpacesForLevel, ExpandMode const i_mode)
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNode const &rNode)
Definition: txtfrm.cxx:330
GetTextAttrMode
Definition: swtypes.hxx:163
@ Parent
EXPAND : (Start < nIndex <= End)
@ Expand
DEFAULT: (Start <= nIndex < End)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1194
SwComparePosition ComparePosition(const T &rStt1, const T &rEnd1, const T &rStt2, const T &rEnd2)
Definition: pam.hxx:123
@ OverlapBehind
Pos1 overlaps Pos2 at the end.
@ OverlapBefore
Pos1 overlaps Pos2 at the beginning.
@ Outside
Pos2 completely contained in Pos1.
@ Inside
Pos1 completely contained in Pos2.
@ Equal
Pos1 is as large as Pos2.
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
bool IsInvalidItem(const SfxPoolItem *pItem)
union SwContentAtPos::@21 aFnd
const SwRangeRedline * pRedl
Definition: crsrsh.hxx:107
SwContentNode * pNode
Definition: crsrsh.hxx:108
bool IsInProtectSect() const
is the node in a protected section?
Definition: crstrvl.cxx:2118
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:106
bool IsInRTLText() const
Definition: crstrvl.cxx:2152
OUString sStr
Definition: crsrsh.hxx:113
const SwField * pField
Definition: crsrsh.hxx:105
const SwTextAttr * pFndTextAttr
Definition: crsrsh.hxx:114
IsAttrAtPos eContentAtPos
Definition: crsrsh.hxx:111
const sw::mark::IFieldmark * pFieldmark
Definition: crsrsh.hxx:109
bool m_bPosCorr
Point had to be corrected.
Definition: crstate.hxx:143
bool m_bInNumPortion
point is in number portion #i23726#
Definition: crstate.hxx:163
bool m_bFootnoteNoInfo
recognized footnote numbering
Definition: crstate.hxx:144
int m_nInNumPortionOffset
distance from number portion's start
Definition: crstate.hxx:164
SwSpecialPos * m_pSpecialPos
for positions inside fields
Definition: crstate.hxx:136
bool m_bFieldInfo
should be fields recognized?
Definition: crstate.hxx:142
bool m_bExactOnly
let GetModelPositionForViewPoint look for exact matches only, i.e.
Definition: crstate.hxx:145
bool m_bSetInReadOnly
ReadOnly areas may be entered.
Definition: crstate.hxx:148
sal_uInt16 nColumnCnt
number of necessary column breaks
Definition: crstate.hxx:44
SwFillMode eMode
desired fill-up rule
Definition: crstate.hxx:46
sal_Int16 eOrient
paragraph alignment
Definition: crstate.hxx:45
sal_uInt16 nSpaceOnlyCnt
number of spaces to insert ("only spaces, no tabs" mode)
Definition: crstate.hxx:43
SwRect aCursor
position and size of the ShadowCursor
Definition: crstate.hxx:39
sal_uInt16 nSpaceCnt
number of spaces to insert
Definition: crstate.hxx:42
sal_uInt16 nTabCnt
number of tabs respectively size of indentation
Definition: crstate.hxx:41
sal_uInt16 nParaCnt
number of paragraphs to insert
Definition: crstate.hxx:40
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:231
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:267
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:78
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
sal_Int32 nCharOfst
Definition: crstate.hxx:110
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
SwUndoId
Definition: swundo.hxx:30
@ INS_FROM_SHADOWCRSR
std::vector< SwTOXMark * > SwTOXMarks
Definition: tox.hxx:46
SwTOXSearch
Definition: toxe.hxx:23
unsigned char sal_uInt8
#define SAL_MAX_UINT32