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