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