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 if(!pContentFrame)
372 return;
373 SwCallLink aLk(*this); // watch Cursor-Moves
375 assert(pContentFrame->IsTextFrame());
376 *m_pCurrentCursor->GetPoint() = static_cast<SwTextFrame const*>(pContentFrame)->MapViewToModelPos(TextFrameIndex(0));
379}
380
383bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors )
384{
385 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
386
387 if( IsTableMode() )
388 return false;
389
390 bool bFnd = false;
393
394 Point aPt;
395 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
396 if( !bNext )
397 aFndPos.Assign(SwNodeOffset(0));
398 SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
399
400 {
401 const SwNode* pSttNd = rPos.GetNode().FindTableBoxStartNode();
402 if( pSttNd )
403 {
404 const SwTableBox* pTBox = pSttNd->FindTableNode()->GetTable().
405 GetTableBox( pSttNd->GetIndex() );
406 if( pTBox )
407 aCurGEF = SetGetExpField( *pTBox );
408 }
409 }
410
411 if( rPos.GetNode() < GetDoc()->GetNodes().GetEndOfExtras() )
412 {
413 // also at collection use only the first frame
414 std::pair<Point, bool> const tmp(aPt, false);
416 &rPos, &tmp) );
417 }
418
419 sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA );
420 if( nMaxItems > 0 )
421 {
422 sal_uInt8 nMaxDo = 2;
423 do {
424 for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA))
425 {
426 const SwTableBox* pTBox;
427 auto pFormulaItem = dynamic_cast<const SwTableBoxFormula*>(pItem);
428 if( !pFormulaItem )
429 continue;
430 pTBox = pFormulaItem->GetTableBox();
431 if( pTBox &&
432 pTBox->GetSttNd() &&
433 pTBox->GetSttNd()->GetNodes().IsDocNodes() &&
434 ( !bOnlyErrors ||
435 !pFormulaItem->HasValidBoxes() ) )
436 {
437 SwNodeIndex aIdx( *pTBox->GetSttNd() );
438 const SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
439 std::pair<Point, bool> const tmp(aPt, false);
440 if (pCNd)
441 {
442 const SwContentFrame* pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
443 if (pCFrame && (IsReadOnlyAvailable() || !pCFrame->IsProtected() ))
444 {
445 SetGetExpField aCmp( *pTBox );
446 aCmp.SetBodyPos( *pCFrame );
447
448 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
449 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
450 {
451 aFndGEF = aCmp;
452 bFnd = true;
453 }
454 }
455 }
456 }
457 }
458 if( !bFnd )
459 {
460 if( bNext )
461 {
462 rPos.Assign(SwNodeOffset(0), 0);
463 aCurGEF = SetGetExpField( rPos );
464 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
465 }
466 else
467 {
468 aCurGEF = SetGetExpField( SwPosition( GetDoc()->GetNodes().GetEndOfContent() ) );
469 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
470 }
471 }
472 } while( !bFnd && --nMaxDo );
473 }
474
475 if( !bFnd )
476 {
477 rPos = aOldPos;
478 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
479 return false;
480 }
481
482 CurrShell aCurr( this );
483 SwCallLink aLk( *this ); // watch Cursor-Moves
484 SwCursorSaveState aSaveState( *m_pCurrentCursor );
485
486 aFndGEF.GetPosOfContent( rPos );
488
489 bFnd = !m_pCurrentCursor->IsSelOvr();
490 if( bFnd )
493
494 return bFnd;
495}
496
499{
500 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
501
502 if( IsTableMode() )
503 return false;
504
505 bool bFnd = false;
507
508 Point aPt;
509 SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
510 if( !bNext )
511 aFndPos.Assign(SwNodeOffset(0));
512 SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
513
514 if( rPos.GetNodeIndex() < GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
515 {
516 // also at collection use only the first frame
517 std::pair<Point, bool> const tmp(aPt, false);
518 aCurGEF.SetBodyPos( *rPos.GetNode().
519 GetContentNode()->getLayoutFrame(GetLayout(), &rPos, &tmp));
520 }
521
522 const SwTextNode* pTextNd;
523 const SwTextTOXMark* pTextTOX;
524 sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK );
525 if( nMaxItems == 0 )
526 {
527 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
528 return false;
529 }
530
531 do {
532 for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_TXTATR_TOXMARK))
533 {
534 auto pToxMarkItem = dynamic_cast<const SwTOXMark*>(pItem);
535 if( !pToxMarkItem )
536 continue;
537 pTextTOX = pToxMarkItem->GetTextTOXMark();
538 if( !pTextTOX )
539 continue;
540 pTextNd = &pTextTOX->GetTextNode();
541 if( !pTextNd->GetNodes().IsDocNodes() )
542 continue;
543 std::pair<Point, bool> const tmp(aPt, false);
544 const SwContentFrame* pCFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
545 if( pCFrame && ( IsReadOnlyAvailable() || !pCFrame->IsProtected() ))
546 {
547 SetGetExpField aCmp( *pTextNd, *pTextTOX );
548 aCmp.SetBodyPos( *pCFrame );
549
550 if( bNext ? ( aCurGEF < aCmp && aCmp < aFndGEF )
551 : ( aCmp < aCurGEF && aFndGEF < aCmp ))
552 {
553 aFndGEF = aCmp;
554 bFnd = true;
555 }
556 }
557 }
558 if( !bFnd )
559 {
560 if ( bNext )
561 {
562 rPos.Assign(SwNodeOffset(0), 0);
563 aCurGEF = SetGetExpField( rPos );
564 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
565 }
566 else
567 {
568 aCurGEF = SetGetExpField( SwPosition( GetDoc()->GetNodes().GetEndOfContent() ) );
569 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
570 }
571 }
572 } while ( !bFnd );
573
574 CurrShell aCurr( this );
575 SwCallLink aLk( *this ); // watch Cursor-Moves
576 SwCursorSaveState aSaveState( *m_pCurrentCursor );
577
578 aFndGEF.GetPosOfContent( rPos );
579
580 bFnd = !m_pCurrentCursor->IsSelOvr();
581 if( bFnd )
584 return bFnd;
585}
586
589 SwTOXSearch eDir )
590{
591 CurrShell aCurr( this );
592 SwCallLink aLk( *this ); // watch Cursor-Moves
593 SwCursorSaveState aSaveState( *m_pCurrentCursor );
594
595 const SwTOXMark& rNewMark = GetDoc()->GotoTOXMark( rStart, eDir,
597 // set position
598 SwPosition& rPos = *GetCursor()->GetPoint();
599 rPos.Assign(rNewMark.GetTextTOXMark()->GetTextNode(),
600 rNewMark.GetTextTOXMark()->GetStart() );
601
602 if( !m_pCurrentCursor->IsSelOvr() )
605
606 return rNewMark;
607}
608
611 SetGetExpFields& rLst,
612 const SwFieldType& rFieldType,
613 const bool bInReadOnly,
614 const bool bChkInpFlag = false )
615{
616 // always search the 1. frame
617 Point aPt;
618 std::vector<SwFormatField*> vFields;
619 rFieldType.GatherFields(vFields, false);
620 for(SwFormatField* pFormatField: vFields)
621 {
622 SwTextField* pTextField = pFormatField->GetTextField();
623 if ( pTextField != nullptr
624 && ( !bChkInpFlag
625 || static_cast<const SwSetExpField*>(pTextField->GetFormatField().GetField())->GetInputFlag() ) )
626 {
627 const SwTextNode& rTextNode = pTextField->GetTextNode();
628 std::pair<Point, bool> const tmp(aPt, false);
629 const SwContentFrame* pCFrame =
630 rTextNode.getLayoutFrame(
632 nullptr, &tmp);
633 if ( pCFrame != nullptr
634 && ( bInReadOnly || !pCFrame->IsProtected() ) )
635 {
636 std::unique_ptr<SetGetExpField> pNew(new SetGetExpField( rTextNode, pTextField ));
637 pNew->SetBodyPos( *pCFrame );
638 rLst.insert( std::move(pNew) );
639 }
640 }
641 }
642}
643
645lcl_FindField(bool & o_rFound, SetGetExpFields const& rSrtLst,
646 SwRootFrame const *const pLayout, SwTextNode *const pTextNode,
647 SwTextField const *const pTextField, SwPosition const& rPos,
648 sal_Int32 const nContentOffset)
649{
650 std::optional<SetGetExpField> oSrch;
651 if (-1 == nContentOffset)
652 {
653 oSrch.emplace(rPos.GetNode(), pTextField, rPos.GetContentIndex());
654 }
655 else
656 {
657 oSrch.emplace(rPos.GetNode(), pTextField, nContentOffset);
658 }
659
660 if (rPos.GetNodeIndex() < pTextNode->GetNodes().GetEndOfExtras().GetIndex())
661 {
662 // also at collection use only the first frame
663 Point aPt;
664 std::pair<Point, bool> const tmp(aPt, false);
665 oSrch->SetBodyPos(*pTextNode->getLayoutFrame(pLayout, &rPos, &tmp));
666 }
667
668 SetGetExpFields::const_iterator it = rSrtLst.lower_bound(&*oSrch);
669
670 o_rFound = (it != rSrtLst.end()) && (**it == *oSrch);
671 return it;
672}
673
675 const SwFieldType* pFieldType,
676 const bool bNext,
677 const SwFieldIds nResType,
678 const bool bAddSetExpressionFieldsToInputFields )
679{
680 // sorted list of all fields
681 SetGetExpFields aSrtLst;
682
683 if ( pFieldType )
684 {
685 if( SwFieldIds::Input != pFieldType->Which() && !pFieldType->HasWriterListeners() )
686 {
687 return false;
688 }
689
690 // found Modify object, add all fields to array
691 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable() );
692
693 if( SwFieldIds::Input == pFieldType->Which() && bAddSetExpressionFieldsToInputFields )
694 {
695 // there are hidden input fields in the set exp. fields
696 const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
697 const size_t nSize = rFieldTypes.size();
698 for( size_t i=0; i < nSize; ++i )
699 {
700 pFieldType = rFieldTypes[ i ].get();
701 if ( SwFieldIds::SetExp == pFieldType->Which() )
702 {
703 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable(), true );
704 }
705 }
706 }
707 }
708 else
709 {
710 const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
711 const size_t nSize = rFieldTypes.size();
712 const bool bAllFieldTypes = nResType == SwFieldIds::Unknown;
713 for( size_t i=0; i < nSize; ++i )
714 {
715 pFieldType = rFieldTypes[ i ].get();
716 if (bAllFieldTypes || nResType == pFieldType->Which())
717 {
718 ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable() );
719 }
720 }
721 }
722
723 // found no fields?
724 if( aSrtLst.empty() )
725 return false;
726
728 SwCursor* pCursor = getShellCursor( true );
729 {
730 // (1998): Always use field for search so that the right one is found as
731 // well some are in frames that are anchored to a paragraph that has a
732 // field
733 const SwPosition& rPos = *pCursor->GetPoint();
734
735 SwTextNode* pTNd = rPos.GetNode().GetTextNode();
736 OSL_ENSURE( pTNd, "No ContentNode" );
737
739 const bool bDelField = ( pTextField == nullptr );
740 sal_Int32 nContentOffset = -1;
741
742 if( bDelField )
743 {
744 // create dummy for the search
745 SwFormatField* pFormatField = new SwFormatField( SwDateTimeField(
746 static_cast<SwDateTimeFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DateTime ) ) ) );
747
748 pTextField = new SwTextField( *pFormatField, rPos.GetContentIndex(),
749 mxDoc->IsClipBoard() );
750 pTextField->ChgTextNode( pTNd );
751 }
752 else
753 {
754 // the cursor might be anywhere inside the input field,
755 // but we will be searching for the field start
756 if (pTextField->Which() == RES_TXTATR_INPUTFIELD
757 && rPos.GetContentIndex() != pTextField->GetStart())
758 nContentOffset = pTextField->GetStart();
759 }
760 bool isSrch;
761 it = lcl_FindField(isSrch, aSrtLst,
762 GetLayout(), pTNd, pTextField, rPos, nContentOffset);
763
764 if( bDelField )
765 {
766 auto const pFormat(static_cast<SwFormatField*>(&pTextField->GetAttr()));
767 delete pTextField;
768 delete pFormat;
769 }
770
771 if( it != aSrtLst.end() && isSrch ) // found
772 {
773 if( bNext )
774 {
775 if( ++it == aSrtLst.end() )
776 return false; // already at the end
777 }
778 else
779 {
780 if( it == aSrtLst.begin() )
781 return false; // no more steps backward possible
782 --it;
783 }
784 }
785 else // not found
786 {
787 if( bNext )
788 {
789 if( it == aSrtLst.end() )
790 return false;
791 }
792 else
793 {
794 if( it == aSrtLst.begin() )
795 return false; // no more steps backward possible
796 --it;
797 }
798 }
799 }
800 const SetGetExpField& rFnd = **it;
801
802 CurrShell aCurr( this );
803 SwCallLink aLk( *this ); // watch Cursor-Moves
804 SwCursorSaveState aSaveState( *pCursor );
805
806 rFnd.GetPosOfContent( *pCursor->GetPoint() );
809 if( bRet )
811 return bRet;
812}
813
815{
816 if (SwWrtShell* pWrtSh = dynamic_cast<SwWrtShell*>(this))
817 pWrtSh->addCurrentPosition();
818
819 bool bRet = false;
820 SwCursor* pCursor = getShellCursor(true);
821
822 CurrShell aCurr(this);
823 SwCallLink aLk(*this); // watch Cursor-Moves
824 SwCursorSaveState aSaveState(*pCursor);
825
826 pCursor->GetPoint()->Assign(rTextFootnote.GetTextNode(),
827 rTextFootnote.GetStart());
828 bRet = !pCursor->IsSelOvr();
829 if (bRet)
831 return bRet;
832}
833
835{
836 std::shared_ptr<SwContentControl> pContentControl = rContentControl.GetContentControl();
837 const SwTextContentControl* pTextContentControl = pContentControl->GetTextAttr();
838 if (!pTextContentControl)
839 return false;
840
841 CurrShell aCurr(this);
842 SwCallLink aLink(*this);
843
844 SwCursor* pCursor = getShellCursor(true);
845 SwCursorSaveState aSaveState(*pCursor);
846
847 SwTextNode* pTextNode = pContentControl->GetTextNode();
848 // Don't select the text attribute itself at the start.
849 sal_Int32 nStart = pTextContentControl->GetStart() + 1;
850 pCursor->GetPoint()->Assign(*pTextNode, nStart);
851
852 bool bRet = true;
853 // select contents for certain controls or conditions
854 if (pContentControl->GetShowingPlaceHolder() || pContentControl->GetCheckbox()
855 || pContentControl->GetSelectedListItem() || pContentControl->GetSelectedDate())
856 {
857 pCursor->SetMark();
858 // Don't select the CH_TXTATR_BREAKWORD itself at the end.
859 sal_Int32 nEnd = *pTextContentControl->End() - 1;
860 pCursor->GetMark()->Assign(*pTextNode, nEnd);
861 bRet = !pCursor->IsSelOvr();
862 }
863 else
864 ClearMark();
865
866 if (bRet)
867 {
870 }
871
872 return bRet;
873}
874
880{
881 // (note: this only applies to modern content controls and legacy fieldmarks,
882 // since activeX richText controls aren't exposed to SW keystrokes)
883
884 struct FormControlSort
885 {
886 bool operator()(std::pair<const SwPosition&, sal_uInt32> rLHS,
887 std::pair<const SwPosition&, sal_uInt32> rRHS) const
888 {
889 assert(rLHS.second && rRHS.second && "tabIndex zero must be changed to SAL_MAX_UINT32");
890 //first compare tabIndexes where 1 has the priority.
891 if (rLHS.second < rRHS.second)
892 return true;
893 if (rLHS.second > rRHS.second)
894 return false;
895
896 // when tabIndexes are equal (and they usually are) then sort by paragraph position
897 return rLHS.first < rRHS.first;
898 }
899 };
900 std::map<std::pair<SwPosition, sal_uInt32>,
901 std::pair<SwTextContentControl*, sw::mark::IFieldmark*>, FormControlSort> aFormMap;
902
903 // add all of the eligible modern Content Controls into a sorted map
905 for (size_t i = 0; i < rManager.GetCount(); ++i)
906 {
907 SwTextContentControl* pTCC = rManager.UnsortedGet(i);
908 if (!pTCC || !pTCC->GetTextNode())
909 continue;
910 auto pCC = pTCC->GetContentControl().GetContentControl();
911
912 // -1 indicates the control should not participate in keyboard tab navigation
913 if (pCC && pCC->GetTabIndex() == SAL_MAX_UINT32)
914 continue;
915
916 const SwPosition nPos(*pTCC->GetTextNode(), pTCC->GetStart());
917
918 // since 0 is the lowest priority (1 is the highest), and -1 has already been excluded,
919 // use SAL_MAX_UINT32 as zero's tabIndex so that automatic sorting is correct.
920 sal_uInt32 nTabIndex = pCC && pCC->GetTabIndex() ? pCC->GetTabIndex() : SAL_MAX_UINT32;
921
922 const std::pair<SwTextContentControl*, sw::mark::IFieldmark*> pFormControl(pTCC, nullptr);
923 aFormMap[std::make_pair(nPos, nTabIndex)] = pFormControl;
924 }
925
926 if (aFormMap.begin() == aFormMap.end())
927 {
928 // only legacy fields exist. Avoid reprocessing everything and use legacy code path.
929 GotoFieldmark(bNext ? GetFieldmarkAfter(/*Loop=*/true) : GetFieldmarkBefore(/*Loop=*/true));
930 return;
931 }
932
933 // add all of the legacy form field controls into the sorted map
935 for (auto it = pMarkAccess->getFieldmarksBegin(); it != pMarkAccess->getFieldmarksEnd(); ++it)
936 {
937 auto pFieldMark = dynamic_cast<sw::mark::IFieldmark*>(*it);
938 assert(pFieldMark);
939 std::pair<SwTextContentControl*, sw::mark::IFieldmark*> pFormControl(nullptr, pFieldMark);
940 // legacy form fields do not have (functional) tabIndexes - use lowest priority for them
941 aFormMap[std::make_pair((*it)->GetMarkStart(), SAL_MAX_UINT32)] = pFormControl;
942 }
943
944 if (aFormMap.begin() == aFormMap.end())
945 return;
946
947 // Identify the current location in the document, and the current tab index priority
948
949 // A content control could contain a Fieldmark, so check for legacy fieldmarks first
950 sw::mark::IFieldmark* pFieldMark = GetCurrentFieldmark();
951 SwTextContentControl* pTCC = !pFieldMark ? CursorInsideContentControl() : nullptr;
952
953 auto pCC = pTCC ? pTCC->GetContentControl().GetContentControl() : nullptr;
954 const sal_Int32 nCurTabIndex = pCC && pCC->GetTabIndex() ? pCC->GetTabIndex() : SAL_MAX_UINT32;
955
956 SwPosition nCurPos(*GetCursor()->GetPoint());
957 if (pFieldMark)
958 nCurPos = pFieldMark->GetMarkStart();
959 else if (pTCC && pTCC->GetTextNode())
960 nCurPos = SwPosition(*pTCC->GetTextNode(), pTCC->GetStart());
961
962 // Find the previous (or next) tab control and navigate to it
963 const std::pair<SwPosition, sal_uInt32> nOldPos(nCurPos, nCurTabIndex);
964
965 // lower_bound acts like find, and returns a pointer to nFindPos if it exists,
966 // otherwise it will point to the previous entry.
967 auto aNewPos = aFormMap.lower_bound(nOldPos);
968 if (bNext && aNewPos != aFormMap.end())
969 ++aNewPos;
970 else if (!bNext && aNewPos != aFormMap.end() && aNewPos->first == nOldPos)
971 {
972 // Found the current position - need to return previous
973 if (aNewPos == aFormMap.begin())
974 aNewPos = aFormMap.end(); // prepare to loop around
975 else
976 --aNewPos;
977 }
978
979 if (aNewPos == aFormMap.end())
980 {
981 // Loop around to the other side
982 if (bNext)
983 aNewPos = aFormMap.begin();
984 else
985 --aNewPos;
986 }
987
988 // the entry contains a pointer to either a Content Control (first) or Fieldmark (second)
989 if (aNewPos->second.first)
990 {
991 auto& rFCC = static_cast<SwFormatContentControl&>(aNewPos->second.first->GetAttr());
993 }
994 else
995 {
996 assert(aNewPos->second.second);
997 GotoFieldmark(aNewPos->second.second);
998 }
999}
1000
1002{
1003 SwTextField const*const pTextField(rField.GetTextField());
1004 if (!pTextField
1005 || (GetLayout()->IsHideRedlines()
1007 GetDoc()->getIDocumentRedlineAccess(), *pTextField)))
1008 return false;
1009
1010 CurrShell aCurr( this );
1011 SwCallLink aLk( *this ); // watch Cursor-Moves
1012
1013 SwCursor* pCursor = getShellCursor( true );
1014 SwCursorSaveState aSaveState( *pCursor );
1015
1016 SwTextNode* pTNd = pTextField->GetpTextNode();
1017 pCursor->GetPoint()->Assign(*pTNd, pTextField->GetStart() );
1018
1019 bool bRet = !pCursor->IsSelOvr();
1020 if( bRet )
1022 return bRet;
1023}
1024
1026 const SwPosition* pPos,
1027 ::sw::GetTextAttrMode const eMode)
1028{
1029 SwTextField* pTextField = nullptr;
1030
1031 SwTextNode * const pNode = pPos->GetNode().GetTextNode();
1032 if ( pNode != nullptr )
1033 {
1034 pTextField = pNode->GetFieldTextAttrAt(pPos->GetContentIndex(), eMode);
1035 }
1036
1037 return pTextField;
1038}
1039
1041 const SwPaM* pCursor,
1042 ::sw::GetTextAttrMode const eMode)
1043{
1044 SwTextField* pTextField = GetTextFieldAtPos(pCursor->Start(), eMode);
1045 if ( !pTextField
1046 || pCursor->Start()->GetNode() != pCursor->End()->GetNode() )
1047 return nullptr;
1048
1049 SwTextField* pFieldAtCursor = nullptr;
1050 const sal_Int32 nTextFieldLength =
1051 pTextField->End() != nullptr
1052 ? *(pTextField->End()) - pTextField->GetStart()
1053 : 1;
1054 if ( ( pCursor->End()->GetContentIndex() - pCursor->Start()->GetContentIndex() ) <= nTextFieldLength )
1055 {
1056 pFieldAtCursor = pTextField;
1057 }
1058
1059 return pFieldAtCursor;
1060}
1061
1063 const SwPaM *const pCursor,
1064 const bool bIncludeInputFieldAtStart)
1065{
1066 SwTextField *const pField(GetTextFieldAtCursor(pCursor,
1067 bIncludeInputFieldAtStart ? ::sw::GetTextAttrMode::Default : ::sw::GetTextAttrMode::Expand));
1068 return pField
1069 ? const_cast<SwField*>(pField->GetFormatField().GetField())
1070 : nullptr;
1071}
1072
1073SwField* SwCursorShell::GetCurField( const bool bIncludeInputFieldAtStart ) const
1074{
1075 SwPaM* pCursor = GetCursor();
1076 if ( pCursor->IsMultiSelection() )
1077 {
1078 // multi selection not handled.
1079 return nullptr;
1080 }
1081
1082 SwField* pCurField = GetFieldAtCursor( pCursor, bIncludeInputFieldAtStart );
1083 if ( pCurField != nullptr
1084 && SwFieldIds::Table == pCurField->GetTyp()->Which() )
1085 {
1086 // table formula? convert internal name into external
1087 const SwTableNode* pTableNd = IsCursorInTable();
1088 static_cast<SwTableField*>(pCurField)->PtrToBoxNm( pTableNd ? &pTableNd->GetTable() : nullptr );
1089 }
1090
1091 return pCurField;
1092}
1093
1095{
1096 for(SwPaM& rCursor : GetCursor()->GetRingContainer())
1097 {
1098 if (dynamic_cast<const SwTextInputField*>(GetTextFieldAtCursor(&rCursor, ::sw::GetTextAttrMode::Parent)))
1099 return true;
1100 }
1101 return false;
1102}
1103
1105{
1106 for (SwPaM& rCursor : GetCursor()->GetRingContainer())
1107 {
1108 const SwPosition* pStart = rCursor.Start();
1109 SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
1110 if (!pTextNode)
1111 {
1112 continue;
1113 }
1114
1115 sal_Int32 nIndex = pStart->GetContentIndex();
1117 {
1118 return static_txtattr_cast<SwTextContentControl*>(pAttr);
1119 }
1120 }
1121
1122 return nullptr;
1123}
1124
1126{
1127 return dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Parent)) != nullptr;
1128}
1129
1131{
1132 SwPosition aPos( *(GetCursor()->Start()) );
1133 Point aDocPt( rDocPt );
1134 if ( GetLayout()->GetModelPositionForViewPoint( &aPos, aDocPt ) )
1135 {
1136 return PosInsideInputField( aPos );
1137 }
1138 return false;
1139}
1140
1142{
1143 const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Default));
1144 assert(pTextInputField != nullptr
1145 && "<SwEditShell::StartOfInputFieldAtPos(..)> - no Input Field at given position");
1146 return pTextInputField->GetStart();
1147}
1148
1150{
1151 const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos(&rPos, ::sw::GetTextAttrMode::Default));
1152 assert(pTextInputField != nullptr
1153 && "<SwEditShell::EndOfInputFieldAtPos(..)> - no Input Field at given position");
1154 return *(pTextInputField->End());
1155}
1156
1158{
1159 SwCursor* pCursor = getShellCursor( true );
1160
1161 CurrShell aCurr( this );
1162 SwCallLink aLk( *this ); // watch Cursor-Moves
1163 SwCursorSaveState aSaveState( *pCursor );
1164
1165 const SwNodes& rNds = GetDoc()->GetNodes();
1166 SwTextNode* pTextNd = rNds.GetOutLineNds()[ nIdx ]->GetTextNode();
1167 pCursor->GetPoint()->Assign(*pTextNd);
1168
1169 if( !pCursor->IsSelOvr() )
1171}
1172
1173bool SwCursorShell::GotoOutline( const OUString& rName )
1174{
1175 SwCursor* pCursor = getShellCursor( true );
1176
1177 CurrShell aCurr( this );
1178 SwCallLink aLk( *this ); // watch Cursor-Moves
1179 SwCursorSaveState aSaveState( *pCursor );
1180
1181 bool bRet = false;
1182 if (mxDoc->GotoOutline(*pCursor->GetPoint(), rName, GetLayout())
1183 && !pCursor->IsSelOvr())
1184 {
1186 bRet = true;
1187 }
1188 return bRet;
1189}
1190
1193{
1194 const SwNodes& rNds = GetDoc()->GetNodes();
1195
1196 if ( rNds.GetOutLineNds().empty() )
1197 {
1198 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1199 return false;
1200 }
1201
1202 SwCursor* pCursor = getShellCursor( true );
1203 SwNode* pNd = &(pCursor->GetPointNode());
1205 bool bUseFirst = !rNds.GetOutLineNds().Seek_Entry( pNd, &nPos );
1206 SwOutlineNodes::size_type const nStartPos(nPos);
1207
1208 do
1209 {
1210 if (!bUseFirst)
1211 {
1212 ++nPos;
1213 }
1214 if (rNds.GetOutLineNds().size() <= nPos)
1215 {
1216 nPos = 0;
1217 }
1218
1219 if (bUseFirst)
1220 {
1221 bUseFirst = false;
1222 }
1223 else
1224 {
1225 if (nPos == nStartPos)
1226 {
1227 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1228 return false;
1229 }
1230 }
1231
1232 pNd = rNds.GetOutLineNds()[ nPos ];
1233 }
1234 while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
1235
1236 if (nPos < nStartPos)
1237 {
1238 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
1239 }
1240 else
1241 {
1242 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1243 }
1244
1245 CurrShell aCurr( this );
1246 SwCallLink aLk( *this ); // watch Cursor-Moves
1247 SwCursorSaveState aSaveState( *pCursor );
1248 pCursor->GetPoint()->Assign(*pNd);
1249
1250 bool bRet = !pCursor->IsSelOvr();
1251 if( bRet )
1253 return bRet;
1254}
1255
1258{
1259 const SwNodes& rNds = GetDoc()->GetNodes();
1260
1261 if ( rNds.GetOutLineNds().empty() )
1262 {
1263 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1264 return false;
1265 }
1266
1267 SwCursor* pCursor = getShellCursor( true );
1268 SwNode* pNd = &(pCursor->GetPointNode());
1270 (void)rNds.GetOutLineNds().Seek_Entry(pNd, &nPos);
1271 SwOutlineNodes::size_type const nStartPos(nPos);
1272
1273 do
1274 {
1275 if (nPos == 0)
1276 {
1277 nPos = rNds.GetOutLineNds().size() - 1;
1278 }
1279 else
1280 {
1281 --nPos; // before
1282 }
1283 if (nPos == nStartPos)
1284 {
1285 pNd = nullptr;
1286 break;
1287 }
1288
1289 pNd = rNds.GetOutLineNds()[ nPos ];
1290 }
1291 while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
1292
1293 if (!pNd)
1294 {
1295 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1296 return false;
1297 }
1298
1299 if (nStartPos < nPos)
1300 {
1301 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
1302 }
1303 else
1304 {
1305 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1306 }
1307 CurrShell aCurr( this );
1308 SwCallLink aLk( *this ); // watch Cursor-Moves
1309 SwCursorSaveState aSaveState( *pCursor );
1310 pCursor->GetPoint()->Assign(*pNd);
1311
1312 bool bRet = !pCursor->IsSelOvr();
1313 if( bRet )
1315 return bRet;
1316}
1317
1320{
1321 SwPaM* pCursor = pPaM ? pPaM : getShellCursor(true);
1322 const SwNodes& rNds = GetDoc()->GetNodes();
1323
1324 SwNode* pNd = &(pCursor->GetPointNode());
1326 if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
1327 nPos++; // is at correct position; take next for while
1328
1329 while( nPos-- ) // check the one in front of the current
1330 {
1331 pNd = rNds.GetOutLineNds()[ nPos ];
1332
1334 && pNd->GetTextNode()->GetAttrOutlineLevel()-1 <= nLevel)
1335 {
1336 if (pNd->GetIndex() < rNds.GetEndOfExtras().GetIndex()
1337 && pCursor->GetPointNode().GetIndex() > rNds.GetEndOfExtras().GetIndex())
1338 {
1339 // node found in extras but cursor position is not in extras
1340 return SwOutlineNodes::npos;
1341 }
1342 return nPos;
1343 }
1344 }
1345 return SwOutlineNodes::npos; // no more left
1346}
1347
1349 bool bWithChildren , bool bKillPams)
1350{
1351 const SwNodes& rNds = GetDoc()->GetNodes();
1352 const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
1353 if( rOutlNds.empty() )
1354 return;
1355
1356 CurrShell aCurr( this );
1357 SwCallLink aLk( *this ); // watch Cursor-Moves
1358
1359 if( nSttPos > nEndPos ) // parameters switched?
1360 {
1361 OSL_ENSURE( false, "Start > End for array access" );
1362 std::swap(nSttPos, nEndPos);
1363 }
1364
1365 SwNode* pSttNd = rOutlNds[ nSttPos ];
1366 SwNode* pEndNd = rOutlNds[ nEndPos ];
1367
1368 if( bWithChildren )
1369 {
1370 const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
1371 for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos )
1372 {
1373 pEndNd = rOutlNds[ nEndPos ];
1374 const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
1375 if( nNxtLevel <= nLevel )
1376 break; // EndPos is now on the next one
1377 }
1378 }
1379 // if without children then set onto next one
1380 else if( ++nEndPos < rOutlNds.size() )
1381 pEndNd = rOutlNds[ nEndPos ];
1382
1383 if( nEndPos == rOutlNds.size() ) // no end found
1384 pEndNd = &rNds.GetEndOfContent();
1385
1386 if( bKillPams )
1387 KillPams();
1388
1389 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1390
1391 // set end to the end of the previous content node
1392 m_pCurrentCursor->GetPoint()->Assign(*pSttNd);
1394 m_pCurrentCursor->GetPoint()->Assign(*pEndNd);
1395 m_pCurrentCursor->Move( fnMoveBackward, GoInNode ); // end of predecessor
1396
1397 // and everything is already selected
1398 bool bRet = !m_pCurrentCursor->IsSelOvr();
1399 if( bRet )
1401}
1402
1404bool SwCursorShell::GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
1405 sal_uInt16 nSeqNo )
1406{
1407 CurrShell aCurr( this );
1408 SwCallLink aLk( *this ); // watch Cursor-Moves
1409 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1410
1411 sal_Int32 nPos = -1;
1412 SwTextNode* pTextNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark,
1413 nSubType, nSeqNo, &nPos, nullptr, GetLayout());
1414 if( !pTextNd || !pTextNd->GetNodes().IsDocNodes() )
1415 return false;
1416
1417 m_pCurrentCursor->GetPoint()->Assign(*pTextNd, nPos );
1418
1419 if( m_pCurrentCursor->IsSelOvr() )
1420 return false;
1421
1423 return true;
1424}
1425
1426bool SwCursorShell::IsPageAtPos( const Point &rPt ) const
1427{
1428 if( GetLayout() )
1429 return nullptr != GetLayout()->GetPageAtPos( rPt );
1430 return false;
1431}
1432
1434 SwContentAtPos& rContentAtPos,
1435 bool bSetCursor,
1436 SwRect* pFieldRect )
1437{
1438 CurrShell aCurr( this );
1439 bool bRet = false;
1440
1441 if( IsTableMode() )
1442 {
1443 rContentAtPos.eContentAtPos = IsAttrAtPos::NONE;
1444 rContentAtPos.aFnd.pField = nullptr;
1445 return false;
1446 }
1447
1448 Point aPt( rPt );
1450
1451 SwTextNode* pTextNd;
1452 SwCursorMoveState aTmpState;
1453 aTmpState.m_bFieldInfo = true;
1454 aTmpState.m_bExactOnly = !( IsAttrAtPos::Outline & rContentAtPos.eContentAtPos );
1455 aTmpState.m_bContentCheck = bool(IsAttrAtPos::ContentCheck & rContentAtPos.eContentAtPos);
1457
1458 SwSpecialPos aSpecialPos;
1459 aTmpState.m_pSpecialPos = ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos ) ?
1460 &aSpecialPos : nullptr;
1461
1462 const bool bCursorFoundExact = GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState );
1463 pTextNd = aPos.GetNode().GetTextNode();
1464
1465 const SwNodes& rNds = GetDoc()->GetNodes();
1466 if( pTextNd
1467 && IsAttrAtPos::Outline & rContentAtPos.eContentAtPos
1468 && !rNds.GetOutLineNds().empty() )
1469 {
1470 // only for nodes in outline nodes
1472 bool bFoundOutline = rNds.GetOutLineNds().Seek_Entry(pTextNd, &nPos);
1473 if (!bFoundOutline && nPos && (IsAttrAtPos::AllowContaining & rContentAtPos.eContentAtPos))
1474 {
1475 // nPos points to the first found outline node not before pTextNd, or to end();
1476 // when bFoundOutline is false, and nPos is not 0, it means that there were
1477 // outline nodes before pTextNd, and nPos-1 points to the last of those.
1478 pTextNd = rNds.GetOutLineNds()[nPos - 1]->GetTextNode();
1479 bFoundOutline = true;
1480 }
1481 if (bFoundOutline)
1482 {
1483 rContentAtPos.eContentAtPos = IsAttrAtPos::Outline;
1484 rContentAtPos.sStr = sw::GetExpandTextMerged(GetLayout(), *pTextNd, true, false, ExpandMode::ExpandFootnote);
1485 rContentAtPos.aFnd.pNode = pTextNd;
1486 bRet = true;
1487 }
1488 }
1489 else if ( IsAttrAtPos::ContentCheck & rContentAtPos.eContentAtPos
1490 && bCursorFoundExact )
1491 {
1492 bRet = true;
1493 }
1494 else if( pTextNd
1495 && IsAttrAtPos::NumLabel & rContentAtPos.eContentAtPos)
1496 {
1497 bRet = aTmpState.m_bInNumPortion;
1498 rContentAtPos.aFnd.pNode = sw::GetParaPropsNode(*GetLayout(), aPos.GetNode());
1499
1500 Size aSizeLogic(aTmpState.m_nInNumPortionOffset, 0);
1501 Size aSizePixel = GetWin()->LogicToPixel(aSizeLogic);
1502 rContentAtPos.nDist = aSizePixel.Width();
1503 }
1504 else if( bCursorFoundExact && pTextNd )
1505 {
1506 SwContentFrame *pFrame(nullptr);
1507 if( !aTmpState.m_bPosCorr )
1508 {
1509 SwTextAttr* pTextAttr;
1510 if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
1511 && !aTmpState.m_bFootnoteNoInfo )
1512 {
1513 const SwWrongList* pSmartTagList = pTextNd->GetSmartTags();
1514 sal_Int32 nCurrent = aPos.GetContentIndex();
1515 const sal_Int32 nBegin = nCurrent;
1516 sal_Int32 nLen = 1;
1517
1518 if (pSmartTagList && pSmartTagList->InWrongWord(nCurrent, nLen) && !pTextNd->IsSymbolAt(nBegin))
1519 {
1520 const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
1521 const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
1522 if ( pSubList )
1523 {
1524 nCurrent = aTmpState.m_pSpecialPos->nCharOfst;
1525
1526 if ( pSubList->InWrongWord( nCurrent, nLen ) )
1527 bRet = true;
1528 }
1529 else
1530 bRet = true;
1531
1532 if( bRet && bSetCursor )
1533 {
1534 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1535 SwCallLink aLk( *this ); // watch Cursor-Moves
1537 *m_pCurrentCursor->GetPoint() = aPos;
1539 bRet = false;
1540 else
1541 UpdateCursor();
1542 }
1543 if( bRet )
1544 {
1545 rContentAtPos.eContentAtPos = IsAttrAtPos::SmartTag;
1546
1547 std::pair<Point, bool> tmp(aPt, true);
1548 if (pFieldRect)
1549 {
1550 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1551 if (pFrame)
1552 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1553 }
1554 }
1555 }
1556 }
1557
1558 if ( !bRet
1560 && !aTmpState.m_bFootnoteNoInfo )
1561 {
1562 pTextAttr = pTextNd->GetFieldTextAttrAt( aPos.GetContentIndex() );
1563 const SwField* pField = pTextAttr != nullptr
1564 ? pTextAttr->GetFormatField().GetField()
1565 : nullptr;
1566 if ( IsAttrAtPos::ClickField & rContentAtPos.eContentAtPos
1567 && pField && !pField->HasClickHdl() )
1568 {
1569 pField = nullptr;
1570 }
1571
1572 if ( pField )
1573 {
1574 if (pFieldRect)
1575 {
1576 std::pair<Point, bool> tmp(aPt, true);
1577 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1578 if (pFrame)
1579 {
1580 //tdf#116397 now that we looking for the bounds of the field drop the SmartTag
1581 //index within field setting so we don't the bounds of the char within the field
1582 SwSpecialPos* pSpecialPos = aTmpState.m_pSpecialPos;
1583 aTmpState.m_pSpecialPos = nullptr;
1584 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1585 aTmpState.m_pSpecialPos = pSpecialPos;
1586 }
1587 }
1588
1589 if( bSetCursor )
1590 {
1591 SwCallLink aLk( *this ); // watch Cursor-Moves
1592 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1594 *m_pCurrentCursor->GetPoint() = aPos;
1595 if( m_pCurrentCursor->IsSelOvr() )
1596 {
1597 // allow click fields in protected sections
1598 // only placeholder is not possible
1599 if( IsAttrAtPos::Field & rContentAtPos.eContentAtPos
1600 || SwFieldIds::JumpEdit == pField->Which() )
1601 pField = nullptr;
1602 }
1603 else
1604 UpdateCursor();
1605 }
1606 else if( SwFieldIds::Table == pField->Which() &&
1607 static_cast<const SwTableField*>(pField)->IsIntrnlName() )
1608 {
1609 // create from internal (for CORE) the external
1610 // (for UI) formula
1611 const SwTableNode* pTableNd = pTextNd->FindTableNode();
1612 if( pTableNd ) // is in a table
1613 const_cast<SwTableField*>(static_cast<const SwTableField*>(pField))->PtrToBoxNm( &pTableNd->GetTable() );
1614 }
1615 }
1616
1617 if( pField )
1618 {
1619 rContentAtPos.aFnd.pField = pField;
1620 rContentAtPos.pFndTextAttr = pTextAttr;
1621 rContentAtPos.eContentAtPos = IsAttrAtPos::Field;
1622 bRet = true;
1623 }
1624 }
1625
1626 if( !bRet && IsAttrAtPos::FormControl & rContentAtPos.eContentAtPos )
1627 {
1629 sw::mark::IFieldmark* pFieldBookmark = pMarksAccess->getInnerFieldmarkFor(aPos);
1630 if (bCursorFoundExact && pFieldBookmark)
1631 {
1633 rContentAtPos.aFnd.pFieldmark = pFieldBookmark;
1634 bRet=true;
1635 }
1636 }
1637
1638 if (!bRet && rContentAtPos.eContentAtPos & IsAttrAtPos::ContentControl)
1639 {
1640 SwTextAttr* pAttr = pTextNd->GetTextAttrAt(
1642 if (pAttr)
1643 {
1645 rContentAtPos.pFndTextAttr = pAttr;
1646 bRet = true;
1647 }
1648 }
1649
1650 if( !bRet && IsAttrAtPos::Ftn & rContentAtPos.eContentAtPos )
1651 {
1652 if( aTmpState.m_bFootnoteNoInfo )
1653 {
1654 // over the footnote's char
1655 bRet = true;
1656 if( bSetCursor )
1657 {
1658 *m_pCurrentCursor->GetPoint() = aPos;
1659 if( !GotoFootnoteAnchor() )
1660 bRet = false;
1661 }
1662 if( bRet )
1663 rContentAtPos.eContentAtPos = IsAttrAtPos::Ftn;
1664 }
1665 else if ( nullptr != ( pTextAttr = pTextNd->GetTextAttrForCharAt(
1666 aPos.GetContentIndex(), RES_TXTATR_FTN )) )
1667 {
1668 bRet = true;
1669 if( bSetCursor )
1670 {
1671 if (SwWrtShell* pWrtSh = dynamic_cast<SwWrtShell*>(this))
1672 pWrtSh->addCurrentPosition();
1673
1674 SwCallLink aLk( *this ); // watch Cursor-Moves
1675 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1676 m_pCurrentCursor->GetPoint()->Assign( *static_cast<SwTextFootnote*>(pTextAttr)->GetStartNode() );
1679 true, !IsReadOnlyAvailable() );
1680
1681 if( pCNd )
1682 {
1685 bRet = false;
1686 else
1687 UpdateCursor();
1688 }
1689 else
1690 bRet = false;
1691 }
1692
1693 if( bRet )
1694 {
1695 rContentAtPos.eContentAtPos = IsAttrAtPos::Ftn;
1696 rContentAtPos.pFndTextAttr = pTextAttr;
1697 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1698
1699 if (pFieldRect)
1700 {
1701 std::pair<Point, bool> tmp(aPt, true);
1702 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1703 if (pFrame)
1704 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1705 }
1706 }
1707 }
1708 }
1709
1710 if( !bRet
1712 && !aTmpState.m_bFootnoteNoInfo )
1713 {
1714 pTextAttr = nullptr;
1715 if( IsAttrAtPos::ToxMark & rContentAtPos.eContentAtPos )
1716 {
1717 std::vector<SwTextAttr *> const marks(
1718 pTextNd->GetTextAttrsAt(
1720 if (!marks.empty())
1721 { // hmm... can only return 1 here
1722 pTextAttr = *marks.begin();
1723 }
1724 }
1725
1726 if( !pTextAttr &&
1727 IsAttrAtPos::RefMark & rContentAtPos.eContentAtPos )
1728 {
1729 std::vector<SwTextAttr *> const marks(
1730 pTextNd->GetTextAttrsAt(
1732 if (!marks.empty())
1733 { // hmm... can only return 1 here
1734 pTextAttr = *marks.begin();
1735 }
1736 }
1737
1738 if( pTextAttr )
1739 {
1740 bRet = true;
1741 if( bSetCursor )
1742 {
1743 SwCallLink aLk( *this ); // watch Cursor-Moves
1744 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1746 *m_pCurrentCursor->GetPoint() = aPos;
1748 bRet = false;
1749 else
1750 UpdateCursor();
1751 }
1752
1753 if( bRet )
1754 {
1755 const sal_Int32* pEnd = pTextAttr->GetEnd();
1756 if( pEnd )
1757 rContentAtPos.sStr =
1758 pTextNd->GetExpandText(GetLayout(), pTextAttr->GetStart(), *pEnd - pTextAttr->GetStart());
1759 else if( RES_TXTATR_TOXMARK == pTextAttr->Which())
1760 rContentAtPos.sStr =
1761 pTextAttr->GetTOXMark().GetAlternativeText();
1762
1763 rContentAtPos.eContentAtPos =
1764 RES_TXTATR_TOXMARK == pTextAttr->Which()
1767 rContentAtPos.pFndTextAttr = pTextAttr;
1768 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1769
1770 std::pair<Point, bool> tmp(aPt, true);
1771 if (pFieldRect)
1772 {
1773 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1774 if (pFrame)
1775 pFrame->GetCharRect( *pFieldRect, aPos, &aTmpState );
1776 }
1777 }
1778 }
1779 }
1780
1781 if ( !bRet
1782 && IsAttrAtPos::InetAttr & rContentAtPos.eContentAtPos
1783 && !aTmpState.m_bFootnoteNoInfo )
1784 {
1785 sal_Int32 index = aPos.GetContentIndex();
1786 pTextAttr = pTextNd->GetTextAttrAt(index, RES_TXTATR_INETFMT);
1787
1788 if(!pTextAttr && index > 0)
1789 pTextAttr = pTextNd->GetTextAttrAt(index - 1, RES_TXTATR_INETFMT);
1790 // "detect" only INetAttrs with URLs
1791 if( pTextAttr && !pTextAttr->GetINetFormat().GetValue().isEmpty() )
1792 {
1793 bRet = true;
1794 if( bSetCursor )
1795 {
1796 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1797 SwCallLink aLk( *this ); // watch Cursor-Moves
1799 *m_pCurrentCursor->GetPoint() = aPos;
1802 bRet = false;
1803 else
1804 UpdateCursor();
1805 }
1806 if( bRet )
1807 {
1808 const sal_Int32 nSt = pTextAttr->GetStart();
1809 const sal_Int32 nEnd = *pTextAttr->End();
1810
1811 rContentAtPos.sStr = pTextNd->GetExpandText(GetLayout(), nSt, nEnd-nSt);
1812
1813 rContentAtPos.aFnd.pAttr = &pTextAttr->GetAttr();
1814 rContentAtPos.eContentAtPos = IsAttrAtPos::InetAttr;
1815 rContentAtPos.pFndTextAttr = pTextAttr;
1816
1817 if (pFieldRect)
1818 {
1819 std::pair<Point, bool> tmp(aPt, true);
1820 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1821 if (pFrame)
1822 {
1823 //get bounding box of range
1824 SwRect aStart;
1825 SwPosition aStartPos(*pTextNd, nSt);
1826 pFrame->GetCharRect(aStart, aStartPos, &aTmpState);
1827 SwRect aEnd;
1828 SwPosition aEndPos(*pTextNd, nEnd);
1829 pFrame->GetCharRect(aEnd, aEndPos, &aTmpState);
1830 if (aStart.Top() != aEnd.Top() || aStart.Bottom() != aEnd.Bottom())
1831 {
1832 aStart.Left(pFrame->getFrameArea().Left());
1833 aEnd.Right(pFrame->getFrameArea().Right());
1834 }
1835 *pFieldRect = aStart.Union(aEnd);
1836 }
1837 }
1838 }
1839 }
1840 }
1841
1842 if( !bRet && IsAttrAtPos::Redline & rContentAtPos.eContentAtPos )
1843 {
1844 const SwRangeRedline* pRedl = GetDoc()->getIDocumentRedlineAccess().GetRedline(aPos, nullptr);
1845
1846 if( pRedl )
1847 {
1848 rContentAtPos.aFnd.pRedl = pRedl;
1849 rContentAtPos.eContentAtPos = IsAttrAtPos::Redline;
1850 rContentAtPos.pFndTextAttr = nullptr;
1851 bRet = true;
1852
1853 if (pFieldRect)
1854 {
1855 std::pair<Point, bool> tmp(aPt, true);
1856 pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1857 if( pFrame )
1858 {
1859 // not sure if this should be limited to one
1860 // paragraph, or mark the entire redline; let's
1861 // leave it limited to one for now...
1862 sal_Int32 nStart;
1863 sal_Int32 nEnd;
1864 pRedl->CalcStartEnd(pTextNd->GetIndex(), nStart, nEnd);
1865 if (nStart == COMPLETE_STRING)
1866 {
1867 // consistency: found pRedl, so there must be
1868 // something in pTextNd
1869 assert(nEnd != COMPLETE_STRING);
1870 nStart = 0;
1871 }
1872 if (nEnd == COMPLETE_STRING)
1873 {
1874 nEnd = pTextNd->Len();
1875 }
1876 //get bounding box of range
1877 SwRect aStart;
1878 pFrame->GetCharRect(aStart, SwPosition(*pTextNd, nStart), &aTmpState);
1879 SwRect aEnd;
1880 pFrame->GetCharRect(aEnd, SwPosition(*pTextNd, nEnd), &aTmpState);
1881 if (aStart.Top() != aEnd.Top() || aStart.Bottom() != aEnd.Bottom())
1882 {
1883 aStart.Left(pFrame->getFrameArea().Left());
1884 aEnd.Right(pFrame->getFrameArea().Right());
1885 }
1886 *pFieldRect = aStart.Union(aEnd);
1887 }
1888 }
1889 }
1890 }
1891 }
1892
1893 if( !bRet && ( ( IsAttrAtPos::TableRedline & rContentAtPos.eContentAtPos ) ||
1894 ( IsAttrAtPos::TableColRedline & rContentAtPos.eContentAtPos ) ) )
1895 {
1896 const SwTableNode* pTableNd;
1897 const SwTableBox* pBox;
1898 const SwTableLine* pTableLine;
1899 const SwStartNode* pSttNd = pTextNd->FindTableBoxStartNode();
1900 if( pSttNd && nullptr != ( pTableNd = pTextNd->FindTableNode()) &&
1901 nullptr != ( pBox = pTableNd->GetTable().GetTableBox(
1902 pSttNd->GetIndex() )) &&
1903 nullptr != ( pTableLine = pBox->GetUpper() ) &&
1904 ( RedlineType::None != pBox->GetRedlineType() ||
1905 RedlineType::None != pTableLine->GetRedlineType() ) )
1906 {
1907 const SwRedlineTable& aRedlineTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
1908 if ( RedlineType::None != pTableLine->GetRedlineType() )
1909 {
1911 nPos = pTableLine->UpdateTextChangesOnly(nPos);
1912 if ( nPos != SwRedlineTable::npos )
1913 {
1914 rContentAtPos.aFnd.pRedl = aRedlineTable[nPos];
1916 bRet = true;
1917 }
1918 }
1919 else
1920 {
1922 SwNodeIndex aIdx( *pSttNd, 1 );
1923 const SwPosition aBoxStart(aIdx);
1924 const SwRangeRedline* pFnd = aRedlineTable.FindAtPosition( aBoxStart, n, /*next=*/true );
1925 if( pFnd && RedlineType::Delete == pFnd->GetType() )
1926 {
1927 rContentAtPos.aFnd.pRedl = aRedlineTable[n];
1929 bRet = true;
1930 }
1931 }
1932 }
1933 }
1934
1935 if( !bRet
1936 && ( IsAttrAtPos::TableBoxFml & rContentAtPos.eContentAtPos
1937#ifdef DBG_UTIL
1938 || IsAttrAtPos::TableBoxValue & rContentAtPos.eContentAtPos
1939#endif
1940 ) )
1941 {
1942 const SwTableNode* pTableNd;
1943 const SwTableBox* pBox;
1944 const SwStartNode* pSttNd = pTextNd->FindTableBoxStartNode();
1945 const SwTableBoxFormula* pItem;
1946#ifdef DBG_UTIL
1947 const SwTableBoxValue* pItem2 = nullptr;
1948#endif
1949 if( pSttNd && nullptr != ( pTableNd = pTextNd->FindTableNode()) &&
1950 nullptr != ( pBox = pTableNd->GetTable().GetTableBox(
1951 pSttNd->GetIndex() )) &&
1952#ifdef DBG_UTIL
1953 ( (pItem = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_FORMULA, false )) ||
1954 (pItem2 = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_VALUE, false )) )
1955#else
1956 (pItem = pBox->GetFrameFormat()->GetItemIfSet( RES_BOXATR_FORMULA, false ))
1957#endif
1958 )
1959 {
1960 std::pair<Point, bool> tmp(aPt, true);
1961 SwFrame* pF = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
1962 if( pF )
1963 {
1964 // then the CellFrame
1965 pFrame = static_cast<SwContentFrame*>(pF);
1966 while( pF && !pF->IsCellFrame() )
1967 pF = pF->GetUpper();
1968 }
1969
1970 if( aTmpState.m_bPosCorr )
1971 {
1972 if( pF && !pF->getFrameArea().Contains( aPt ))
1973 pF = nullptr;
1974 }
1975 else if( !pF )
1976 pF = pFrame;
1977
1978 if( pF ) // only then it is valid
1979 {
1980 // create from internal (for CORE) the external
1981 // (for UI) formula
1983#ifdef DBG_UTIL
1984 if( pItem2 )
1986 else
1987#endif
1988 const_cast<SwTableBoxFormula&>(*pItem).PtrToBoxNm( &pTableNd->GetTable() );
1989
1990 bRet = true;
1991 if( bSetCursor )
1992 {
1993 SwCallLink aLk( *this ); // watch Cursor-Moves
1994 SwCursorSaveState aSaveState( *m_pCurrentCursor );
1995 *m_pCurrentCursor->GetPoint() = aPos;
1998 bRet = false;
1999 else
2000 UpdateCursor();
2001 }
2002
2003 if( bRet )
2004 {
2005 if( pFieldRect )
2006 {
2007 *pFieldRect = pF->getFramePrintArea();
2008 *pFieldRect += pF->getFrameArea().Pos();
2009 }
2010 rContentAtPos.pFndTextAttr = nullptr;
2011 rContentAtPos.aFnd.pAttr = pItem;
2012 }
2013 }
2014 }
2015 }
2016
2017#ifdef DBG_UTIL
2018 if( !bRet && IsAttrAtPos::CurrAttrs & rContentAtPos.eContentAtPos )
2019 {
2020 const sal_Int32 n = aPos.GetContentIndex();
2022 if( pTextNd->GetpSwpHints() )
2023 {
2024 for( size_t i = 0; i < pTextNd->GetSwpHints().Count(); ++i )
2025 {
2026 const SwTextAttr* pHt = pTextNd->GetSwpHints().Get(i);
2027 const sal_Int32 nAttrStart = pHt->GetStart();
2028 if( nAttrStart > n ) // over the section
2029 break;
2030
2031 if( nullptr != pHt->End() && (
2032 ( nAttrStart < n &&
2033 ( pHt->DontExpand() ? n < *pHt->End()
2034 : n <= *pHt->End() )) ||
2035 ( n == nAttrStart &&
2036 ( nAttrStart == *pHt->End() || !n ))) )
2037 {
2038 aSet.Put( pHt->GetAttr() );
2039 }
2040 }
2041 if( pTextNd->HasSwAttrSet() &&
2042 pTextNd->GetpSwAttrSet()->Count() )
2043 {
2044 SfxItemSet aFormatSet( pTextNd->GetSwAttrSet() );
2045 // remove all from format set that are also in TextSet
2046 aFormatSet.Differentiate( aSet );
2047 // now merge all together
2048 aSet.Put( aFormatSet );
2049 }
2050 }
2051 else
2052 pTextNd->SwContentNode::GetAttr( aSet );
2053
2054 rContentAtPos.sStr = "Pos: (";
2055 rContentAtPos.sStr += OUString::number( sal_Int32(aPos.GetNodeIndex()));
2056 rContentAtPos.sStr += ":";
2057 rContentAtPos.sStr += OUString::number( aPos.GetContentIndex());
2058 rContentAtPos.sStr += ")";
2059 rContentAtPos.sStr += "\nParagraph Style: ";
2060 rContentAtPos.sStr += pTextNd->GetFormatColl()->GetName();
2061 if( pTextNd->GetCondFormatColl() )
2062 {
2063 rContentAtPos.sStr += "\nConditional Style: " + pTextNd->GetCondFormatColl()->GetName();
2064 }
2065
2066 if( aSet.Count() )
2067 {
2068 OUStringBuffer sAttrs;
2069 SfxItemIter aIter( aSet );
2070 const SfxPoolItem* pItem = aIter.GetCurItem();
2071 const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
2072 do
2073 {
2074 if( !IsInvalidItem( pItem ))
2075 {
2076 OUString aStr;
2078 MapUnit::MapCM, aStr, aInt);
2079 if (!sAttrs.isEmpty())
2080 sAttrs.append(", ");
2081 sAttrs.append(aStr);
2082 }
2083 pItem = aIter.NextItem();
2084 } while (pItem);
2085 if (!sAttrs.isEmpty())
2086 {
2087 if( !rContentAtPos.sStr.isEmpty() )
2088 rContentAtPos.sStr += "\n";
2089 rContentAtPos.sStr += "Attr: " + sAttrs;
2090 }
2091 }
2092 bRet = true;
2093 rContentAtPos.eContentAtPos = IsAttrAtPos::CurrAttrs;
2094 }
2095#endif
2096 }
2097
2098 if( !bRet )
2099 {
2100 rContentAtPos.eContentAtPos = IsAttrAtPos::NONE;
2101 rContentAtPos.aFnd.pField = nullptr;
2102 }
2103 return bRet;
2104}
2105
2106// #i90516#
2108{
2109 if ( IsTableMode() )
2110 return nullptr;
2111
2112 const SwPosition* pCursorPos = GetCursor_()->GetPoint();
2113 const SwTextNode* pTextNd = pCursorPos->GetNode().GetTextNode();
2114 if ( !pTextNd )
2115 return nullptr;
2116
2117 const SwPostItField* pPostItField = nullptr;
2118 SwTextAttr* pTextAttr = pTextNd->GetFieldTextAttrAt( pCursorPos->GetContentIndex() );
2119 const SwField* pField = pTextAttr != nullptr ? pTextAttr->GetFormatField().GetField() : nullptr;
2120 if ( pField && pField->Which()== SwFieldIds::Postit )
2121 {
2122 pPostItField = static_cast<const SwPostItField*>(pField);
2123 }
2124
2125 return pPostItField;
2126}
2127
2130{
2131 const SwTextNode* pNd = nullptr;
2132 if( pFndTextAttr )
2133 {
2134 switch( eContentAtPos )
2135 {
2136 case IsAttrAtPos::Field:
2138 pNd = static_txtattr_cast<SwTextField const*>(pFndTextAttr)->GetpTextNode();
2139 break;
2140
2141 case IsAttrAtPos::Ftn:
2142 pNd = &static_cast<const SwTextFootnote*>(pFndTextAttr)->GetTextNode();
2143 break;
2144
2146 pNd = static_txtattr_cast<SwTextINetFormat const*>(pFndTextAttr)->GetpTextNode();
2147 break;
2148
2149 default:
2150 break;
2151 }
2152 }
2153
2154 if( !pNd )
2155 return false;
2156 if( pNd->IsInProtectSect() )
2157 return true;
2158
2159 const SwContentFrame* pFrame = pNd->getLayoutFrame(pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr);
2160 return pFrame && pFrame->IsProtected() ;
2161}
2162
2164{
2165 const SwTextNode* pNd = nullptr;
2167 return false;
2168
2169 const SwTextFootnote* pTextFootnote = static_cast<const SwTextFootnote*>(pFndTextAttr);
2170 if(!pTextFootnote->GetStartNode())
2171 return false;
2172
2173 SwStartNode* pSttNd = pTextFootnote->GetStartNode()->GetNode().GetStartNode();
2174 SwPaM aTemp( *pSttNd );
2175 aTemp.Move(fnMoveForward, GoInNode);
2176 SwContentNode* pContentNode = aTemp.GetPointContentNode();
2177 if(pContentNode && pContentNode->IsTextNode())
2178 pNd = pContentNode->GetTextNode();
2179 if(!pNd)
2180 return false;
2181
2182 bool bRet = false;
2184 SwTextFrame* pTmpFrame = aIter.First();
2185 while( pTmpFrame )
2186 {
2187 if ( !pTmpFrame->IsFollow())
2188 {
2189 bRet = pTmpFrame->IsRightToLeft();
2190 break;
2191 }
2192 pTmpFrame = aIter.Next();
2193 }
2194 return bRet;
2195}
2196
2197bool SwCursorShell::SelectTextModel( const sal_Int32 nStart,
2198 const sal_Int32 nEnd )
2199{
2200 CurrShell aCurr( this );
2201 bool bRet = false;
2202
2203 SwCallLink aLk( *this );
2204 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2205
2208 rPos.SetContent(nStart);
2210 rPos.SetContent(nEnd);
2211
2212 if( !m_pCurrentCursor->IsSelOvr() )
2213 {
2214 UpdateCursor();
2215 bRet = true;
2216 }
2217
2218 return bRet;
2219}
2220
2221TextFrameIndex SwCursorShell::GetCursorPointAsViewIndex() const
2222{
2223 SwPosition const*const pPos(GetCursor()->GetPoint());
2224 SwTextNode const*const pTextNode(pPos->GetNode().GetTextNode());
2225 assert(pTextNode);
2226 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(pTextNode->getLayoutFrame(GetLayout())));
2227 assert(pFrame);
2228 return pFrame->MapModelToViewPos(*pPos);
2229}
2230
2231bool SwCursorShell::SelectTextView(TextFrameIndex const nStart,
2232 TextFrameIndex const nEnd)
2233{
2234 CurrShell aCurr( this );
2235 bool bRet = false;
2236
2237 SwCallLink aLk( *this );
2238 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2239
2242 // indexes must correspond to cursor point!
2243 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(m_pCurrentCursor->GetPoint()->GetNode().GetTextNode()->getLayoutFrame(GetLayout())));
2244 assert(pFrame);
2245 rPos = pFrame->MapViewToModelPos(nStart);
2247 rPos = pFrame->MapViewToModelPos(nEnd);
2248
2249 if (!m_pCurrentCursor->IsSelOvr())
2250 {
2251 UpdateCursor();
2252 bRet = true;
2253 }
2254
2255 return bRet;
2256}
2257
2258bool SwCursorShell::SelectTextAttr( sal_uInt16 nWhich,
2259 bool bExpand,
2260 const SwTextAttr* pTextAttr )
2261{
2262 CurrShell aCurr( this );
2263
2264 if( IsTableMode() )
2265 return false;
2266
2267 if( !pTextAttr )
2268 {
2270 SwTextNode* pTextNd = rPos.GetNode().GetTextNode();
2271 pTextAttr = pTextNd
2272 ? pTextNd->GetTextAttrAt(rPos.GetContentIndex(),
2273 nWhich,
2275 : nullptr;
2276 }
2277 if( !pTextAttr )
2278 return false;
2279
2280 const sal_Int32* pEnd = pTextAttr->End();
2281 bool bRet = SelectTextModel(pTextAttr->GetStart(), (pEnd ? *pEnd : pTextAttr->GetStart() + 1));
2282 return bRet;
2283}
2284
2286{
2287 if( !rAttr.GetpTextNode() )
2288 return false;
2289 SwCursor* pCursor = getShellCursor( true );
2290
2291 CurrShell aCurr( this );
2292 SwCallLink aLk( *this ); // watch Cursor-Moves
2293 SwCursorSaveState aSaveState( *pCursor );
2294
2295 pCursor->GetPoint()->Assign(*rAttr.GetpTextNode(), rAttr.GetStart() );
2296 bool bRet = !pCursor->IsSelOvr();
2297 if( bRet )
2299 return bRet;
2300}
2301
2302const SwFormatINetFormat* SwCursorShell::FindINetAttr( std::u16string_view rName ) const
2303{
2304 return mxDoc->FindINetAttr( rName );
2305}
2306
2308 SwRect& rRect, sal_Int16& rOrient )
2309{
2310
2311 CurrShell aCurr( this );
2312
2313 if (IsTableMode() || HasSelection()
2314 || !GetDoc()->GetIDocumentUndoRedo().DoesUndo())
2315 return false;
2316
2317 Point aPt( rPt );
2319
2320 SwFillCursorPos aFPos( eFillMode );
2321 SwCursorMoveState aTmpState( &aFPos );
2322
2323 bool bRet = false;
2324 if( GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState ) &&
2325 !aPos.GetNode().IsProtect())
2326 {
2327 // start position in protected section?
2328 rRect = aFPos.aCursor;
2329 rOrient = aFPos.eOrient;
2330 bRet = true;
2331 }
2332 return bRet;
2333}
2334
2336{
2337 CurrShell aCurr( this );
2338
2339 if (IsTableMode() || HasSelection()
2340 || !GetDoc()->GetIDocumentUndoRedo().DoesUndo())
2341 return false;
2342
2343 Point aPt( rPt );
2345
2346 SwFillCursorPos aFPos( eFillMode );
2347 SwCursorMoveState aTmpState( &aFPos );
2348
2349 if( !GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState ) )
2350 return false;
2351
2352 SwCallLink aLk( *this ); // watch Cursor-Moves
2353 StartAction();
2354
2355 SwContentNode* pCNd = aPos.GetNode().GetContentNode();
2357 // If only the paragraph attributes "Adjust" or "LRSpace" are set,
2358 // then the following should not delete those again.
2359 if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
2360 ( SwFillMode::Indent == aFPos.eMode ||
2362 0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
2363 pCNd && pCNd->Len() )
2364 nUndoId = SwUndoId::EMPTY;
2365
2366 GetDoc()->GetIDocumentUndoRedo().StartUndo( nUndoId, nullptr );
2367
2368 SwTextFormatColl* pNextFormat = nullptr;
2369 SwTextNode* pTNd = pCNd ? pCNd->GetTextNode() : nullptr;
2370 if( pTNd )
2371 pNextFormat = &pTNd->GetTextColl()->GetNextTextFormatColl();
2372
2373 const SwSectionNode* pSectNd = pCNd ? pCNd->FindSectionNode() : nullptr;
2374 if( pSectNd && aFPos.nParaCnt )
2375 {
2376 SwNodeIndex aEnd( aPos.GetNode(), 1 );
2377 while( aEnd.GetNode().IsEndNode() &&
2378 &aEnd.GetNode() !=
2379 pSectNd->EndOfSectionNode() )
2380 ++aEnd;
2381
2382 if( aEnd.GetNode().IsEndNode() &&
2383 pCNd->Len() == aPos.GetContentIndex() )
2384 aPos.Assign( *pSectNd->EndOfSectionNode() );
2385 }
2386
2387 for( sal_uInt16 n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
2388 {
2390 if( !n && pNextFormat )
2391 {
2392 *m_pCurrentCursor->GetPoint() = aPos;
2393 GetDoc()->SetTextFormatColl( *m_pCurrentCursor, pNextFormat, false );
2394 }
2395 if( n < aFPos.nColumnCnt )
2396 {
2397 *m_pCurrentCursor->GetPoint() = aPos;
2399 SvxFormatBreakItem( SvxBreak::ColumnBefore, RES_BREAK ) );
2400 }
2401 }
2402
2403 *m_pCurrentCursor->GetPoint() = aPos;
2404 switch( aFPos.eMode )
2405 {
2406 case SwFillMode::Indent:
2407 if( nullptr != (pCNd = aPos.GetNode().GetContentNode() ))
2408 {
2409 assert(pCNd->IsTextNode()); // ???
2415 firstLine.SetTextFirstLineOffset(0);
2416 leftMargin.SetTextLeft(aFPos.nTabCnt);
2417 aSet.Put(firstLine);
2418 aSet.Put(leftMargin);
2419
2420 const SvxAdjustItem& rAdj = pCNd->GetAttr(RES_PARATR_ADJUST);
2421 if( SvxAdjust::Left != rAdj.GetAdjust() )
2422 aSet.Put( SvxAdjustItem( SvxAdjust::Left, RES_PARATR_ADJUST ) );
2423
2425 }
2426 else {
2427 OSL_ENSURE( false, "No ContentNode" );
2428 }
2429 break;
2430
2431 case SwFillMode::Tab:
2433 case SwFillMode::Space:
2434 {
2435 OUStringBuffer sInsert;
2436 if (aFPos.eMode == SwFillMode::Space)
2437 {
2438 comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceOnlyCnt, ' ');
2439 }
2440 else
2441 {
2442 if (aFPos.nTabCnt)
2443 comphelper::string::padToLength(sInsert, aFPos.nTabCnt, '\t');
2444 if (aFPos.nSpaceCnt)
2445 comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
2446 }
2447 if (!sInsert.isEmpty())
2448 GetDoc()->getIDocumentContentOperations().InsertString( *m_pCurrentCursor, sInsert.makeStringAndClear());
2449 }
2450 [[fallthrough]]; // still need to set orientation
2451 case SwFillMode::Margin:
2453 {
2454 SvxAdjustItem aAdj( SvxAdjust::Left, RES_PARATR_ADJUST );
2455 switch( aFPos.eOrient )
2456 {
2457 case text::HoriOrientation::CENTER:
2458 aAdj.SetAdjust( SvxAdjust::Center );
2459 break;
2460 case text::HoriOrientation::RIGHT:
2461 aAdj.SetAdjust( SvxAdjust::Right );
2462 break;
2463 default:
2464 break;
2465 }
2467 }
2468 break;
2469 }
2470
2471 GetDoc()->GetIDocumentUndoRedo().EndUndo( nUndoId, nullptr );
2472 EndAction();
2473
2474 return true;
2475}
2476
2478{
2479 if( IsTableMode() )
2480 return nullptr;
2481
2482 CurrShell aCurr( this );
2483 SwCallLink aLk( *this ); // watch Cursor-Moves
2484 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2485
2486 // ensure point is at the end so alternating SelNext/SelPrev works
2487 NormalizePam(false);
2489
2490 // at the end of the document, go to the start of the document, and try again
2491 if ( !pFnd )
2492 {
2495 }
2496
2499 else
2500 pFnd = nullptr;
2501 return pFnd;
2502}
2503
2505{
2506 if( IsTableMode() )
2507 return nullptr;
2508
2509 CurrShell aCurr( this );
2510 SwCallLink aLk( *this ); // watch Cursor-Moves
2511 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2512
2513 // ensure point is at the start so alternating SelNext/SelPrev works
2514 NormalizePam(true);
2516
2517 // at the start of the document, go to the end of the document, and try again
2518 if ( !pFnd )
2519 {
2522 }
2523
2526 else
2527 pFnd = nullptr;
2528 return pFnd;
2529}
2530
2532{
2533 const SwRangeRedline* pFnd = nullptr;
2534 SwCallLink aLk( *this ); // watch Cursor-Moves
2535 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2536
2537 pFnd = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nArrPos ];
2538 if( !pFnd )
2539 return nullptr;
2540
2541 *m_pCurrentCursor->GetPoint() = *pFnd->Start();
2542
2544 if( !pPtPos->GetNode().IsContentNode() )
2545 {
2546 SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( pPtPos,
2547 true, IsReadOnlyAvailable() );
2548 if( pCNd )
2549 {
2550 if( pPtPos->GetNode() <= pFnd->End()->GetNode() )
2551 pPtPos->SetContent( 0 );
2552 else
2553 pFnd = nullptr;
2554 }
2555 }
2556
2557 if( pFnd && bSelect )
2558 {
2560 if( RedlineType::FmtColl == pFnd->GetType() )
2561 {
2562 SwContentNode* pCNd = pPtPos->GetNode().GetContentNode();
2563 m_pCurrentCursor->GetPoint()->SetContent( pCNd->Len() );
2564 m_pCurrentCursor->GetMark()->Assign( *pCNd, 0 );
2565 }
2566 else
2567 *m_pCurrentCursor->GetPoint() = *pFnd->End();
2568
2569 pPtPos = m_pCurrentCursor->GetPoint();
2570 if( !pPtPos->GetNode().IsContentNode() )
2571 {
2572 SwContentNode* pCNd = SwNodes::GoPrevSection( pPtPos,
2573 true, IsReadOnlyAvailable() );
2574 if( pCNd )
2575 {
2576 if( pPtPos->GetNode() >= m_pCurrentCursor->GetMark()->GetNode() )
2577 pPtPos->SetContent( pCNd->Len() );
2578 else
2579 pFnd = nullptr;
2580 }
2581 }
2582 }
2583
2584 if( !pFnd )
2585 {
2588 }
2589 else if( bSelect && *m_pCurrentCursor->GetMark() == *m_pCurrentCursor->GetPoint() )
2591
2595 else
2596 {
2597 pFnd = nullptr;
2598 if( bSelect )
2600 }
2601 return pFnd;
2602}
2603
2605{
2606 const SwRangeRedline* pFnd = nullptr;
2607 if( IsTableMode() )
2608 return nullptr;
2609
2610 CurrShell aCurr( this );
2611
2613 const SwRangeRedline* pTmp = rTable[ nArrPos ];
2614 sal_uInt16 nSeqNo = pTmp->GetSeqNo();
2615 if( !nSeqNo || !bSelect )
2616 {
2617 pFnd = GotoRedline_( nArrPos, bSelect );
2618 return pFnd;
2619 }
2620
2621 bool bCheck = false;
2622 int nLoopCnt = 2;
2623 SwRedlineTable::size_type nArrSavPos = nArrPos;
2624
2625 do {
2626 pTmp = GotoRedline_( nArrPos, true );
2627
2628 if( !pFnd )
2629 pFnd = pTmp;
2630
2631 if( pTmp && bCheck )
2632 {
2633 // Check for overlaps. These can happen when FormatColl-
2634 // Redlines were stretched over a whole paragraph
2635 SwPaM* pCur = m_pCurrentCursor;
2636 SwPaM* pNextPam = pCur->GetNext();
2637 auto [pCStt, pCEnd] = pCur->StartEnd(); // SwPosition*
2638 while( pCur != pNextPam )
2639 {
2640 auto [pNStt, pNEnd] = pNextPam->StartEnd(); // SwPosition*
2641
2642 bool bDel = true;
2643 switch( ::ComparePosition( *pCStt, *pCEnd,
2644 *pNStt, *pNEnd ))
2645 {
2646 case SwComparePosition::Inside: // Pos1 is completely in Pos2
2647 if( !pCur->HasMark() )
2648 {
2649 pCur->SetMark();
2650 *pCur->GetMark() = *pNStt;
2651 }
2652 else
2653 *pCStt = *pNStt;
2654 *pCEnd = *pNEnd;
2655 break;
2656
2657 case SwComparePosition::Outside: // Pos2 is completely in Pos1
2658 case SwComparePosition::Equal: // Pos1 has same size as Pos2
2659 break;
2660
2661 case SwComparePosition::OverlapBefore: // Pos1 overlaps Pos2 at beginning
2662 if( !pCur->HasMark() )
2663 pCur->SetMark();
2664 *pCEnd = *pNEnd;
2665 break;
2666 case SwComparePosition::OverlapBehind: // Pos1 overlaps Pos2 at end
2667 if( !pCur->HasMark() )
2668 {
2669 pCur->SetMark();
2670 *pCur->GetMark() = *pNStt;
2671 }
2672 else
2673 *pCStt = *pNStt;
2674 break;
2675
2676 default:
2677 bDel = false;
2678 }
2679
2680 if( bDel )
2681 {
2682 // not needed anymore
2683 SwPaM* pPrevPam = pNextPam->GetPrev();
2684 delete pNextPam;
2685 pNextPam = pPrevPam;
2686 }
2687 pNextPam = pNextPam->GetNext();
2688 }
2689 }
2690
2691 SwRedlineTable::size_type nFndPos = 2 == nLoopCnt
2692 ? rTable.FindNextOfSeqNo( nArrPos )
2693 : rTable.FindPrevOfSeqNo( nArrPos );
2694 if( SwRedlineTable::npos != nFndPos ||
2695 ( 0 != ( --nLoopCnt ) && SwRedlineTable::npos != (
2696 nFndPos = rTable.FindPrevOfSeqNo( nArrSavPos ))) )
2697 {
2698 if( pTmp )
2699 {
2700 // create new cursor
2701 CreateCursor();
2702 bCheck = true;
2703 }
2704 nArrPos = nFndPos;
2705 }
2706 else
2707 nLoopCnt = 0;
2708
2709 } while( nLoopCnt );
2710 return pFnd;
2711}
2712
2714{
2715 SwNodes& rNds = GetDoc()->GetNodes();
2716 const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
2717 const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
2718 SwNodeOffset nBodySttNdIdx = pBodySttNd->GetIndex();
2719 Point aPt;
2720
2721 SetGetExpField aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
2722 SetGetExpField aCurPos( bNext ? *m_pCurrentCursor->End() : *m_pCurrentCursor->Start() );
2723 if( aCurPos.GetNode() < nBodySttNdIdx )
2724 {
2725 const SwContentNode* pCNd = aCurPos.GetNodeFromContent()->GetContentNode();
2726 std::pair<Point, bool> tmp(aPt, true);
2727 if (pCNd)
2728 {
2729 SwContentFrame* pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
2730 if( pFrame )
2731 aCurPos.SetBodyPos( *pFrame );
2732 }
2733 }
2734
2735 // check first all the hyperlink fields
2736 {
2737 const SwTextNode* pTextNd;
2738 const SwCharFormats* pFormats = GetDoc()->GetCharFormats();
2739 for( SwCharFormats::size_type n = pFormats->size(); 1 < n; )
2740 {
2741 SwIterator<SwTextINetFormat,SwCharFormat> aIter(*(*pFormats)[--n]);
2742
2743 for( SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
2744 {
2745 pTextNd = pFnd->GetpTextNode();
2746 if( pTextNd && pTextNd->GetNodes().IsDocNodes() )
2747 {
2748 SwTextINetFormat& rAttr = *pFnd;
2749 SetGetExpField aPos( *pTextNd, rAttr );
2750 if (pTextNd->GetIndex() < nBodySttNdIdx)
2751 {
2752 std::pair<Point, bool> tmp(aPt, true);
2753 SwContentFrame* pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
2754 if (pFrame)
2755 {
2756 aPos.SetBodyPos( *pFrame );
2757 }
2758 }
2759
2760 if( bNext
2761 ? ( aPos < aCmpPos && aCurPos < aPos )
2762 : ( aCmpPos < aPos && aPos < aCurPos ))
2763 {
2764 OUString sText(pTextNd->GetExpandText(GetLayout(),
2765 rAttr.GetStart(),
2766 *rAttr.GetEnd() - rAttr.GetStart() ) );
2767
2768 sText = sText.replaceAll("\x0a", "");
2769 sText = comphelper::string::strip(sText, ' ');
2770
2771 if( !sText.isEmpty() )
2772 aCmpPos = aPos;
2773 }
2774 }
2775 }
2776 }
2777 }
2778
2779 // then check all the Flys with a URL or image map
2780 {
2781 for(sw::SpzFrameFormat* pSpz: *GetDoc()->GetSpzFrameFormats())
2782 {
2783 auto pFormat = static_cast<SwFlyFrameFormat*>(pSpz);
2784 const SwFormatURL& rURLItem = pFormat->GetURL();
2785 if( rURLItem.GetMap() || !rURLItem.GetURL().isEmpty() )
2786 {
2787 SwFlyFrame* pFly = pFormat->GetFrame( &aPt );
2788 SwPosition aTmpPos( *pBodySttNd );
2789 if( pFly &&
2790 GetBodyTextNode( *GetDoc(), aTmpPos, *pFly->GetLower() ) )
2791 {
2792 SetGetExpField aPos( *pFormat, &aTmpPos );
2793
2794 if( bNext
2795 ? ( aPos < aCmpPos && aCurPos < aPos )
2796 : ( aCmpPos < aPos && aPos < aCurPos ))
2797 aCmpPos = aPos;
2798 }
2799 }
2800 }
2801 }
2802
2803 // found any URL ?
2804 const SwTextINetFormat* pFndAttr = aCmpPos.GetINetFormat();
2805 const SwFlyFrameFormat* pFndFormat = aCmpPos.GetFlyFormat();
2806 if( !pFndAttr && !pFndFormat )
2807 return false;
2808
2809 CurrShell aCurr( this );
2810 SwCallLink aLk( *this );
2811
2812 bool bRet = false;
2813 // found a text attribute ?
2814 if( pFndAttr )
2815 {
2816 SwCursorSaveState aSaveState( *m_pCurrentCursor );
2817
2821 m_pCurrentCursor->GetPoint()->SetContent( *pFndAttr->End() );
2822
2824 {
2827 bRet = true;
2828 }
2829 }
2830 // found a draw object ?
2831 else if( RES_DRAWFRMFMT == pFndFormat->Which() )
2832 {
2833 const SdrObject* pSObj = pFndFormat->FindSdrObject();
2834 if (pSObj)
2835 {
2836 static_cast<SwFEShell*>(this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
2838 bRet = true;
2839 }
2840 }
2841 else // then is it a fly
2842 {
2843 SwFlyFrame* pFly = pFndFormat->GetFrame(&aPt);
2844 if( pFly )
2845 {
2846 static_cast<SwFEShell*>(this)->SelectFlyFrame( *pFly );
2848 bRet = true;
2849 }
2850 }
2851 return bRet;
2852}
2853
2854/* 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
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long getX() const
constexpr tools::Long getY() const
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:732
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:727
virtual sal_Int32 Len() const
Definition: node.cxx:1256
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
SwFormatColl * GetCondFormatColl() const
Definition: node.hxx:715
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:1876
tools::Long GetUpDownX() const
Definition: crsrsh.hxx:362
bool GotoRefMark(const OUString &rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo)
jump to reference marker
Definition: crstrvl.cxx:1404
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1025
void GotoFormControl(bool bNext)
Go to the next (or previous) form control, based first on tabIndex and then paragraph position,...
Definition: crstrvl.cxx:879
bool GetShadowCursorPos(const Point &rPt, SwFillMode eFillMode, SwRect &rRect, sal_Int16 &rOrient)
Definition: crstrvl.cxx:2307
bool GotoNextOutline()
jump to next node with outline num.
Definition: crstrvl.cxx:1192
bool GotoPrevOutline()
jump to previous node with outline num.
Definition: crstrvl.cxx:1257
void GotoTOXMarkBase()
jump to index of TOXMark
Definition: crstrvl.cxx:362
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:494
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:2713
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:343
const SwPostItField * GetPostItFieldAtCursor() const
Definition: crstrvl.cxx:2107
const SwTOXMark & GotoTOXMark(const SwTOXMark &rStart, SwTOXSearch eDir)
traveling between marks
Definition: crstrvl.cxx:588
const SwFormatINetFormat * FindINetAttr(std::u16string_view rName) const
Definition: crstrvl.cxx:2302
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2838
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:1256
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:2197
bool GotoNxtPrvTOXMark(bool bNext=true)
jump to next/previous index marker
Definition: crstrvl.cxx:498
bool SelectTextAttr(sal_uInt16 nWhich, bool bExpand, const SwTextAttr *pAttr=nullptr)
Definition: crstrvl.cxx:2258
bool CursorInsideInputField() const
Definition: crstrvl.cxx:1094
void GotoPrevNum()
Definition: crstrvl.cxx:124
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1073
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:2335
void MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren, bool bKillPams=true)
Definition: crstrvl.cxx:1348
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
bool IsPageAtPos(const Point &rPt) const
Definition: crstrvl.cxx:1426
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:1141
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2771
static SwTextField * GetTextFieldAtCursor(const SwPaM *pCursor, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1040
const SwRangeRedline * GotoRedline(SwRedlineTable::size_type nArrPos, bool bSelect)
Definition: crstrvl.cxx:2604
static SwField * GetFieldAtCursor(const SwPaM *pCursor, const bool bIncludeInputFieldAtStart)
Definition: crstrvl.cxx:1062
const SwRangeRedline * SelNextRedline()
Definition: crstrvl.cxx:2477
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3392
bool DocPtInsideInputField(const Point &rDocPt) const
Definition: crstrvl.cxx:1130
SAL_DLLPRIVATE const SwRangeRedline * GotoRedline_(SwRedlineTable::size_type nArrPos, bool bSelect)
Definition: crstrvl.cxx:2531
void ClearMark()
Definition: crsrsh.cxx:1225
sw::mark::IFieldmark * GetFieldmarkBefore(bool bLoop)
Definition: crbm.cxx:299
bool GotoOutline(const OUString &rName)
Definition: crstrvl.cxx:1173
SwTextContentControl * CursorInsideContentControl() const
Definition: crstrvl.cxx:1104
const SwRangeRedline * SelPrevRedline()
Definition: crstrvl.cxx:2504
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3356
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:175
static sal_Int32 EndOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1149
@ READONLY
make visible in spite of Readonly
Definition: crsrsh.hxx:166
@ CHKRANGE
check overlapping PaMs
Definition: crsrsh.hxx:165
@ SCROLLWIN
scroll window
Definition: crsrsh.hxx:164
@ UPDOWN
keep Up/Down on columns
Definition: crsrsh.hxx:163
static bool PosInsideInputField(const SwPosition &rPos)
Definition: crstrvl.cxx:1125
::sw::mark::IFieldmark * GetCurrentFieldmark()
Definition: crbm.cxx:286
void KillPams()
Definition: crsrsh.cxx:1308
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:1319
sw::mark::IFieldmark * GetFieldmarkAfter(bool bLoop)
Definition: crbm.cxx:293
SwShellCursor * m_pCurrentCursor
current cursor
Definition: crsrsh.hxx:186
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:383
bool GotoFormatField(const SwFormatField &rField)
Definition: crstrvl.cxx:1001
bool GetContentAtPos(const Point &rPt, SwContentAtPos &rContentAtPos, bool bSetCursor=false, SwRect *pFieldRect=nullptr)
Definition: crstrvl.cxx:1433
bool GotoINetAttr(const SwTextINetFormat &rAttr)
Definition: crstrvl.cxx:2285
bool IsTableMode() const
Definition: crsrsh.hxx:668
bool GotoFormatContentControl(const SwFormatContentControl &rContentControl)
Definition: crstrvl.cxx:834
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:674
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:2339
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:1356
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:755
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:1337
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:1100
SwDocShell * GetDocShell()
Definition: doc.hxx:1370
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:896
::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:706
bool IsInProtectSect() const
Is node in a protected area?
Definition: node.cxx:439
bool IsContentNode() const
Definition: node.hxx:188
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsEndNode() const
Definition: node.hxx:189
bool IsTextNode() const
Definition: node.hxx:190
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:691
SwContentNode * GetContentNode()
Definition: node.hxx:666
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:695
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:2555
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:60
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:147
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:3025
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:3505
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:1849
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:4168
std::vector< SwTextAttr * > GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) const
get the innermost text attributes covering position nIndex.
Definition: ndtxt.cxx:1795
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:1804
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:3155
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:365
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2181
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:199
bool ActionPend() const
Definition: viewsh.hxx:225
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2163
vcl::Window * GetWin() const
Definition: viewsh.hxx:364
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2835
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: viewsh.cxx:2825
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:648
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:645
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:610
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
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:108
SwContentNode * pNode
Definition: crsrsh.hxx:109
bool IsInProtectSect() const
is the node in a protected section?
Definition: crstrvl.cxx:2129
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:107
bool IsInRTLText() const
Definition: crstrvl.cxx:2163
OUString sStr
Definition: crsrsh.hxx:114
const SwField * pField
Definition: crsrsh.hxx:106
const SwTextAttr * pFndTextAttr
Definition: crsrsh.hxx:115
IsAttrAtPos eContentAtPos
Definition: crsrsh.hxx:112
const sw::mark::IFieldmark * pFieldmark
Definition: crsrsh.hxx:110
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
Count