LibreOffice Module sw (master)  1
pam.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 <sal/config.h>
21 
22 #include <string_view>
23 
24 #include <tools/gen.hxx>
25 #include <editeng/protitem.hxx>
26 #include <cntfrm.hxx>
27 #include <pagefrm.hxx>
28 #include <doc.hxx>
30 #include <docary.hxx>
31 #include <pam.hxx>
32 #include <pamtyp.hxx>
33 #include <txtfrm.hxx>
34 #include <fmtcntnt.hxx>
35 #include <frmatr.hxx>
36 #include <flyfrm.hxx>
37 #include <fmteiro.hxx>
38 #include <section.hxx>
39 #include <sectfrm.hxx>
40 #include <ndtxt.hxx>
41 #include <swcrsr.hxx>
42 
43 #include <IMark.hxx>
45 #include <hints.hxx>
46 #include <txatbase.hxx>
47 #include <xmloff/odffields.hxx>
48 
49 #include <editsh.hxx>
50 
51 // for the dump "MSC-" compiler
52 static sal_Int32 GetSttOrEnd( bool bCondition, const SwContentNode& rNd )
53 {
54  return bCondition ? 0 : rNd.Len();
55 }
56 
57 SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, const SwIndex & rContent )
58  : nNode( rNodeIndex ), nContent( rContent )
59 {
60 }
61 
62 SwPosition::SwPosition( const SwNodeIndex & rNodeIndex )
63  : nNode( rNodeIndex ), nContent( nNode.GetNode().GetContentNode() )
64 {
65 }
66 
68  : nNode( rNode ), nContent( nNode.GetNode().GetContentNode() )
69 {
70 }
71 
72 SwPosition::SwPosition( SwContentNode & rNode, const sal_Int32 nOffset )
73  : nNode( rNode ), nContent( &rNode, nOffset )
74 {
75 }
76 
77 bool SwPosition::operator<(const SwPosition &rPos) const
78 {
79  if( nNode < rPos.nNode )
80  return true;
81  if( nNode == rPos.nNode )
82  {
83  // note that positions with text node but no SwIndex registered are
84  // created for text frames anchored at para (see SwXFrame::getAnchor())
85  SwIndexReg const*const pThisReg(nContent.GetIdxReg());
86  SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
87  if (pThisReg && pOtherReg)
88  {
89  return (nContent < rPos.nContent);
90  }
91  else // by convention position with no index is smaller
92  {
93  return pOtherReg != nullptr;
94  }
95  }
96  return false;
97 }
98 
99 bool SwPosition::operator>(const SwPosition &rPos) const
100 {
101  if(nNode > rPos.nNode )
102  return true;
103  if( nNode == rPos.nNode )
104  {
105  // note that positions with text node but no SwIndex registered are
106  // created for text frames anchored at para (see SwXFrame::getAnchor())
107  SwIndexReg const*const pThisReg(nContent.GetIdxReg());
108  SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
109  if (pThisReg && pOtherReg)
110  {
111  return (nContent > rPos.nContent);
112  }
113  else // by convention position with no index is smaller
114  {
115  return pThisReg != nullptr;
116  }
117  }
118  return false;
119 }
120 
121 bool SwPosition::operator<=(const SwPosition &rPos) const
122 {
123  if(nNode < rPos.nNode )
124  return true;
125  if( nNode == rPos.nNode )
126  {
127  // note that positions with text node but no SwIndex registered are
128  // created for text frames anchored at para (see SwXFrame::getAnchor())
129  SwIndexReg const*const pThisReg(nContent.GetIdxReg());
130  SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
131  if (pThisReg && pOtherReg)
132  {
133  return (nContent <= rPos.nContent);
134  }
135  else // by convention position with no index is smaller
136  {
137  return pThisReg == nullptr;
138  }
139  }
140  return false;
141 }
142 
143 bool SwPosition::operator>=(const SwPosition &rPos) const
144 {
145  if(nNode > rPos.nNode )
146  return true;
147  if( nNode == rPos.nNode )
148  {
149  // note that positions with text node but no SwIndex registered are
150  // created for text frames anchored at para (see SwXFrame::getAnchor())
151  SwIndexReg const*const pThisReg(nContent.GetIdxReg());
152  SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
153  if (pThisReg && pOtherReg)
154  {
155  return (nContent >= rPos.nContent);
156  }
157  else // by convention position with no index is smaller
158  {
159  return pOtherReg == nullptr;
160  }
161  }
162  return false;
163 }
164 
165 bool SwPosition::operator==(const SwPosition &rPos) const
166 {
167  return (nNode == rPos.nNode)
168  && (nContent == rPos.nContent);
169 }
170 
171 bool SwPosition::operator!=(const SwPosition &rPos) const
172 {
173  return (nNode != rPos.nNode)
174  || (nContent != rPos.nContent);
175 }
176 
178 {
179  return nNode.GetNode().GetDoc();
180 }
181 
183 {
184  xmlTextWriterStartElement(pWriter, BAD_CAST("SwPosition"));
185  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nNode"), BAD_CAST(OString::number(nNode.GetIndex()).getStr()));
186  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nContent"), BAD_CAST(OString::number(nContent.GetIndex()).getStr()));
187  xmlTextWriterEndElement(pWriter);
188 }
189 
190 std::ostream &operator <<(std::ostream& s, const SwPosition& position)
191 {
192  return s << "SwPosition (node " << position.nNode.GetIndex() << ", offset " << position.nContent.GetIndex() << ")";
193 }
194 
195 namespace {
196 
197 enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
198 
199 }
200 
201 static CHKSECTION lcl_TstIdx( sal_uLong nSttIdx, sal_uLong nEndIdx, const SwNode& rEndNd )
202 {
203  sal_uLong nStt = rEndNd.StartOfSectionIndex(), nEnd = rEndNd.GetIndex();
204  CHKSECTION eSec = nStt < nSttIdx && nEnd >= nSttIdx ? Chk_One : Chk_None;
205  if( nStt < nEndIdx && nEnd >= nEndIdx )
206  return( eSec == Chk_One ? Chk_Both : Chk_One );
207  return eSec;
208 }
209 
210 static bool lcl_ChkOneRange( CHKSECTION eSec, bool bChkSections,
211  const SwNode& rBaseEnd, sal_uLong nStt, sal_uLong nEnd )
212 {
213  if( eSec != Chk_Both )
214  return false;
215 
216  if( !bChkSections )
217  return true;
218 
219  // search the surrounding section
220  const SwNodes& rNds = rBaseEnd.GetNodes();
221  const SwNode *pTmp, *pNd = rNds[ nStt ];
222  if( !pNd->IsStartNode() )
223  pNd = pNd->StartOfSectionNode();
224 
225  if( pNd == rNds[ nEnd ]->StartOfSectionNode() )
226  return true; // same StartNode, same section
227 
228  // already on a base node => error
229  if( !pNd->StartOfSectionIndex() )
230  return false;
231 
232  while( ( pTmp = pNd->StartOfSectionNode())->EndOfSectionNode() !=
233  &rBaseEnd )
234  pNd = pTmp;
235 
236  sal_uLong nSttIdx = pNd->GetIndex(), nEndIdx = pNd->EndOfSectionIndex();
237  return nSttIdx <= nStt && nStt <= nEndIdx &&
238  nSttIdx <= nEnd && nEnd <= nEndIdx;
239 }
240 
251 bool CheckNodesRange( const SwNodeIndex& rStt,
252  const SwNodeIndex& rEnd, bool bChkSection )
253 {
254  const SwNodes& rNds = rStt.GetNodes();
255  sal_uLong nStt = rStt.GetIndex(), nEnd = rEnd.GetIndex();
256  CHKSECTION eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfContent() );
257  if( Chk_None != eSec )
258  return eSec == Chk_Both;
259 
260  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfAutotext() );
261  if( Chk_None != eSec )
262  return lcl_ChkOneRange( eSec, bChkSection,
263  rNds.GetEndOfAutotext(), nStt, nEnd );
264 
265  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfPostIts() );
266  if( Chk_None != eSec )
267  return lcl_ChkOneRange( eSec, bChkSection,
268  rNds.GetEndOfPostIts(), nStt, nEnd );
269 
270  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfInserts() );
271  if( Chk_None != eSec )
272  return lcl_ChkOneRange( eSec, bChkSection,
273  rNds.GetEndOfInserts(), nStt, nEnd );
274 
275  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfRedlines() );
276  if( Chk_None != eSec )
277  return lcl_ChkOneRange( eSec, bChkSection,
278  rNds.GetEndOfRedlines(), nStt, nEnd );
279 
280  return false; // somewhere in between => error
281 }
282 
283 bool GoNext(SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
284 {
285  if( pNd->IsContentNode() )
286  return static_cast<SwContentNode*>(pNd)->GoNext( pIdx, nMode );
287  return false;
288 }
289 
290 bool GoPrevious( SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
291 {
292  if( pNd->IsContentNode() )
293  return static_cast<SwContentNode*>(pNd)->GoPrevious( pIdx, nMode );
294  return false;
295 }
296 
297 SwContentNode* GoNextNds( SwNodeIndex* pIdx, bool bChk )
298 {
299  SwNodeIndex aIdx( *pIdx );
300  SwContentNode* pNd = aIdx.GetNodes().GoNext( &aIdx );
301  if( pNd )
302  {
303  if( bChk && 1 != aIdx.GetIndex() - pIdx->GetIndex() &&
304  !CheckNodesRange( *pIdx, aIdx, true ) )
305  pNd = nullptr;
306  else
307  *pIdx = aIdx;
308  }
309  return pNd;
310 }
311 
313 {
314  SwNodeIndex aIdx( *pIdx );
315  SwContentNode* pNd = SwNodes::GoPrevious( &aIdx );
316  if( pNd )
317  {
318  if( bChk && 1 != pIdx->GetIndex() - aIdx.GetIndex() &&
319  !CheckNodesRange( *pIdx, aIdx, true ) )
320  pNd = nullptr;
321  else
322  *pIdx = aIdx;
323  }
324  return pNd;
325 }
326 
327 SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing )
328  : Ring( pRing )
329  , m_Bound1( rPos )
330  , m_Bound2( rPos.nNode.GetNode().GetNodes() ) // default initialize
331  , m_pPoint( &m_Bound1 )
332  , m_pMark( m_pPoint )
333  , m_bIsInFrontOfLabel( false )
334 {
335 }
336 
337 SwPaM::SwPaM( const SwPosition& rMark, const SwPosition& rPoint, SwPaM* pRing )
338  : Ring( pRing )
339  , m_Bound1( rMark )
340  , m_Bound2( rPoint )
341  , m_pPoint( &m_Bound2 )
342  , m_pMark( &m_Bound1 )
343  , m_bIsInFrontOfLabel( false )
344 {
345 }
346 
347 SwPaM::SwPaM( const SwNodeIndex& rMark, const SwNodeIndex& rPoint,
348  long nMarkOffset, long nPointOffset, SwPaM* pRing )
349  : Ring( pRing )
350  , m_Bound1( rMark )
351  , m_Bound2( rPoint )
352  , m_pPoint( &m_Bound2 )
353  , m_pMark( &m_Bound1 )
354  , m_bIsInFrontOfLabel( false )
355 {
356  if ( nMarkOffset )
357  {
358  m_pMark->nNode += nMarkOffset;
359  }
360  if ( nPointOffset )
361  {
362  m_pPoint->nNode += nPointOffset;
363  }
366 }
367 
368 SwPaM::SwPaM( const SwNode& rMark, const SwNode& rPoint,
369  long nMarkOffset, long nPointOffset, SwPaM* pRing )
370  : Ring( pRing )
371  , m_Bound1( rMark )
372  , m_Bound2( rPoint )
373  , m_pPoint( &m_Bound2 )
374  , m_pMark( &m_Bound1 )
375  , m_bIsInFrontOfLabel( false )
376 {
377  if ( nMarkOffset )
378  {
379  m_pMark->nNode += nMarkOffset;
380  }
381  if ( nPointOffset )
382  {
383  m_pPoint->nNode += nPointOffset;
384  }
387 }
388 
389 SwPaM::SwPaM( const SwNodeIndex& rMark, sal_Int32 nMarkContent,
390  const SwNodeIndex& rPoint, sal_Int32 nPointContent, SwPaM* pRing )
391  : Ring( pRing )
392  , m_Bound1( rMark )
393  , m_Bound2( rPoint )
394  , m_pPoint( &m_Bound2 )
395  , m_pMark( &m_Bound1 )
396  , m_bIsInFrontOfLabel( false )
397 {
398  m_pPoint->nContent.Assign( rPoint.GetNode().GetContentNode(), nPointContent);
399  m_pMark ->nContent.Assign( rMark .GetNode().GetContentNode(), nMarkContent );
400 }
401 
402 SwPaM::SwPaM( const SwNode& rMark, sal_Int32 nMarkContent,
403  const SwNode& rPoint, sal_Int32 nPointContent, SwPaM* pRing )
404  : Ring( pRing )
405  , m_Bound1( rMark )
406  , m_Bound2( rPoint )
407  , m_pPoint( &m_Bound2 )
408  , m_pMark( &m_Bound1 )
409  , m_bIsInFrontOfLabel( false )
410 {
412  nPointContent);
413  m_pMark ->nContent.Assign( m_pMark ->nNode.GetNode().GetContentNode(),
414  nMarkContent );
415 }
416 
417 SwPaM::SwPaM( const SwNode& rNode, sal_Int32 nContent, SwPaM* pRing )
418  : Ring( pRing )
419  , m_Bound1( rNode )
420  , m_Bound2( m_Bound1.nNode.GetNode().GetNodes() ) // default initialize
421  , m_pPoint( &m_Bound1 )
422  , m_pMark( &m_Bound1 )
423  , m_bIsInFrontOfLabel( false )
424 {
426  nContent );
427 }
428 
429 SwPaM::SwPaM( const SwNodeIndex& rNodeIdx, sal_Int32 nContent, SwPaM* pRing )
430  : Ring( pRing )
431  , m_Bound1( rNodeIdx )
432  , m_Bound2( rNodeIdx.GetNode().GetNodes() ) // default initialize
433  , m_pPoint( &m_Bound1 )
434  , m_pMark( &m_Bound1 )
435  , m_bIsInFrontOfLabel( false )
436 {
437  m_pPoint->nContent.Assign( rNodeIdx.GetNode().GetContentNode(), nContent );
438 }
439 
441 
442 SwPaM::SwPaM(SwPaM const& rPam, SwPaM *const pRing)
443  : Ring(pRing)
444  , m_Bound1( *(rPam.m_pPoint) )
445  , m_Bound2( *(rPam.m_pMark) )
446  , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
447  , m_bIsInFrontOfLabel( false )
448 {
449 }
450 
451 // @@@ semantic: no copy assignment for super class Ring.
452 SwPaM &SwPaM::operator=( const SwPaM &rPam )
453 {
454  if(this == &rPam)
455  return *this;
456 
457  *m_pPoint = *( rPam.m_pPoint );
458  if ( rPam.HasMark() )
459  {
460  SetMark();
461  *m_pMark = *( rPam.m_pMark );
462  }
463  else
464  {
465  DeleteMark();
466  }
467  return *this;
468 }
469 
471 {
472  if (m_pPoint == &m_Bound1)
473  {
474  m_pMark = &m_Bound2;
475  }
476  else
477  {
478  m_pMark = &m_Bound1;
479  }
480  (*m_pMark) = *m_pPoint;
481 }
482 
483 #ifdef DBG_UTIL
485 {
486  if (m_pPoint != m_pMark)
487  {
488  SwPosition *pTmp = m_pPoint;
489  m_pPoint = m_pMark;
490  m_pMark = pTmp;
491  }
492 }
493 #endif
494 
496 bool SwPaM::Move( SwMoveFnCollection const & fnMove, SwGoInDoc fnGo )
497 {
498  const bool bRet = (*fnGo)( *this, fnMove );
499 
500  m_bIsInFrontOfLabel = false;
501  return bRet;
502 }
503 
504 namespace sw {
505 
516 std::unique_ptr<SwPaM> MakeRegion(SwMoveFnCollection const & fnMove,
517  const SwPaM & rOrigRg)
518 {
519  std::unique_ptr<SwPaM> pPam;
520  {
521  pPam.reset(new SwPaM(rOrigRg, const_cast<SwPaM*>(&rOrigRg))); // given search range
522  // make sure that SPoint is on the "real" start position
523  // FORWARD: SPoint always smaller than GetMark
524  // BACKWARD: SPoint always bigger than GetMark
525  if( (pPam->GetMark()->*fnMove.fnCmpOp)( *pPam->GetPoint() ) )
526  pPam->Exchange();
527  }
528  return pPam;
529 }
530 
531 } // namespace sw
532 
533 void SwPaM::Normalize(bool bPointFirst)
534 {
535  if (HasMark())
536  if ( ( bPointFirst && *m_pPoint > *m_pMark) ||
537  (!bPointFirst && *m_pPoint < *m_pMark) )
538  {
539  Exchange();
540  }
541 }
542 
544 sal_uInt16 SwPaM::GetPageNum( bool bAtPoint, const Point* pLayPos )
545 {
546  const SwContentFrame* pCFrame;
547  const SwPageFrame *pPg;
548  const SwContentNode *pNd ;
549  const SwPosition* pPos = bAtPoint ? m_pPoint : m_pMark;
550 
551  std::pair<Point, bool> tmp;
552  if (pLayPos)
553  {
554  tmp.first = *pLayPos;
555  tmp.second = false;
556  }
557  if( nullptr != ( pNd = pPos->nNode.GetNode().GetContentNode() ) &&
558  nullptr != (pCFrame = pNd->getLayoutFrame(pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), pPos, pLayPos ? &tmp : nullptr)) &&
559  nullptr != ( pPg = pCFrame->FindPageFrame() ))
560  return pPg->GetPhyPageNum();
561  return 0;
562 }
563 
564 // form view - see also SwCursorShell::IsCursorReadonly()
565 static const SwFrame* lcl_FindEditInReadonlyFrame( const SwFrame& rFrame )
566 {
567  const SwFrame* pRet = nullptr;
568 
569  const SwFlyFrame* pFly;
570  const SwSectionFrame* pSectionFrame;
571 
572  if( rFrame.IsInFly() &&
573  (pFly = rFrame.FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
574  pFly->Lower() &&
575  !pFly->Lower()->IsNoTextFrame() )
576  {
577  pRet = pFly;
578  }
579  else if ( rFrame.IsInSct() &&
580  nullptr != ( pSectionFrame = rFrame.FindSctFrame() )->GetSection() &&
581  pSectionFrame->GetSection()->IsEditInReadonlyFlag() )
582  {
583  pRet = pSectionFrame;
584  }
585 
586  return pRet;
587 }
588 
590 bool SwPaM::HasReadonlySel( bool bFormView ) const
591 {
592  bool bRet = false;
593 
594  const SwContentNode* pNd = GetPoint()->nNode.GetNode().GetContentNode();
595  const SwContentFrame *pFrame = nullptr;
596  if ( pNd != nullptr )
597  {
598  Point aTmpPt;
599  std::pair<Point, bool> const tmp(aTmpPt, false);
600  pFrame = pNd->getLayoutFrame(
602  GetPoint(), &tmp);
603  }
604 
605  // Will be set if point are inside edit-in-readonly environment
606  const SwFrame* pPointEditInReadonlyFrame = nullptr;
607  if ( pFrame != nullptr
608  && ( pFrame->IsProtected()
609  || ( bFormView
610  && nullptr == ( pPointEditInReadonlyFrame = lcl_FindEditInReadonlyFrame( *pFrame ) ) ) ) )
611  {
612  bRet = true;
613  }
614  else if( pNd != nullptr )
615  {
616  const SwSectionNode* pSNd = pNd->GetSectionNode();
617  if ( pSNd != nullptr
618  && ( pSNd->GetSection().IsProtectFlag()
619  || ( bFormView
620  && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
621  {
622  bRet = true;
623  }
624  else
625  {
626  const SwSectionNode* pParentSectionNd = pNd->FindSectionNode();
627  if ( pParentSectionNd != nullptr
628  && ( pParentSectionNd->GetSection().IsProtectFlag()
629  || ( bFormView && !pParentSectionNd->GetSection().IsEditInReadonlyFlag()) ) )
630  {
631  bRet = true;
632  }
633  }
634  }
635 
636  if ( !bRet
637  && HasMark()
638  && GetPoint()->nNode != GetMark()->nNode )
639  {
640  pNd = GetMark()->nNode.GetNode().GetContentNode();
641  pFrame = nullptr;
642  if ( pNd != nullptr )
643  {
644  Point aTmpPt;
645  std::pair<Point, bool> const tmp(aTmpPt, false);
646  pFrame = pNd->getLayoutFrame(
648  GetMark(), &tmp);
649  }
650 
651  const SwFrame* pMarkEditInReadonlyFrame = nullptr;
652  if ( pFrame != nullptr
653  && ( pFrame->IsProtected()
654  || ( bFormView
655  && nullptr == ( pMarkEditInReadonlyFrame = lcl_FindEditInReadonlyFrame( *pFrame ) ) ) ) )
656  {
657  bRet = true;
658  }
659  else if( pNd != nullptr )
660  {
661  const SwSectionNode* pSNd = pNd->GetSectionNode();
662  if ( pSNd != nullptr
663  && ( pSNd->GetSection().IsProtectFlag()
664  || ( bFormView
665  && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
666  {
667  bRet = true;
668  }
669  }
670 
671  if ( !bRet && bFormView )
672  {
673  // Check if start and end frame are inside the _same_
674  // edit-in-readonly-environment. Otherwise we better return 'true'
675  if ( pPointEditInReadonlyFrame != pMarkEditInReadonlyFrame )
676  bRet = true;
677  }
678 
679  // check for protected section inside the selection
680  if( !bRet )
681  {
682  sal_uLong nSttIdx = GetMark()->nNode.GetIndex(),
683  nEndIdx = GetPoint()->nNode.GetIndex();
684  if( nEndIdx <= nSttIdx )
685  {
686  sal_uLong nTmp = nSttIdx;
687  nSttIdx = nEndIdx;
688  nEndIdx = nTmp;
689  }
690 
691  // If a protected section should be between nodes, then the
692  // selection needs to contain already x nodes.
693  // (TextNd, SectNd, TextNd, EndNd, TextNd )
694  if( nSttIdx + 3 < nEndIdx )
695  {
696  const SwSectionFormats& rFormats = GetDoc()->GetSections();
697  for( SwSectionFormats::size_type n = rFormats.size(); n; )
698  {
699  const SwSectionFormat* pFormat = rFormats[ --n ];
700  if( pFormat->GetProtect().IsContentProtected() )
701  {
702  const SwFormatContent& rContent = pFormat->GetContent(false);
703  OSL_ENSURE( rContent.GetContentIdx(), "where is the SectionNode?" );
704  sal_uLong nIdx = rContent.GetContentIdx()->GetIndex();
705  if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
706  rContent.GetContentIdx()->GetNode().GetNodes().IsDocNodes() )
707  {
708  bRet = true;
709  break;
710  }
711  }
712  }
713  }
714  }
715  }
716 
717  const SwDoc *pDoc = GetDoc();
718  // Legacy text/combo/checkbox: never return read-only when inside these form fields.
719  const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
720  sw::mark::IFieldmark* pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : nullptr;
721  sw::mark::IFieldmark* pB = GetMark() ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
722  // prevent the user from accidentally deleting the field itself when modifying the text.
723  const bool bAtStartA = (pA != nullptr) && (pA->GetMarkStart() == *GetPoint());
724  const bool bAtStartB = (pB != nullptr) && (pB->GetMarkStart() == *GetMark());
725 
726  if (!bRet)
727  {
728  bool bUnhandledMark = pA && pA->GetFieldname( ) == ODF_UNHANDLED;
729  // Unhandled fieldmarks case shouldn't be edited manually to avoid breaking anything
730  if ( ( pA == pB ) && bUnhandledMark )
731  bRet = true;
732  else
733  {
734  if ((pA == pB) && (bAtStartA != bAtStartB))
735  bRet = true;
736  else if (pA != pB)
737  {
738  // If both points are either outside or at marks edges (i.e. selection either
739  // touches fields, or fully encloses it), then don't disable editing
740  bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
741  }
742  if( !bRet && pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM ) && (pA || pB) )
743  {
744  // Form protection case
745  bRet = ( pA == nullptr ) || ( pB == nullptr ) || bAtStartA || bAtStartB;
746  }
747  }
748  }
749  else
750  {
751  // Allow editing when the cursor/selection is fully inside of a legacy form field.
752  bRet = !( pA != nullptr && !bAtStartA && !bAtStartB && pA == pB );
753  }
754 
755  if (!bRet)
756  {
757  // Paragraph Signatures and Classification fields are read-only.
758  if (pDoc && pDoc->GetEditShell())
760  }
761 
762  if (!bRet &&
764  {
765  if (pDoc->getIDocumentMarkAccess()->isBookmarkDeleted(*this))
766  {
767  return true;
768  }
769  }
770  if (!bRet &&
772  {
773  SwPosition const& rStart(*Start());
774  SwPosition const& rEnd(*End());
775  for (SwNodeIndex n = rStart.nNode; n <= rEnd.nNode; ++n)
776  {
777  if (SwTextNode const*const pNode = n.GetNode().GetTextNode())
778  {
779  if (SwpHints const*const pHints = pNode->GetpSwpHints())
780  {
781  for (size_t i = 0; i < pHints->Count(); ++i)
782  {
783  SwTextAttr const*const pHint(pHints->Get(i));
784  if (n == rStart.nNode && pHint->GetStart() < rStart.nContent.GetIndex())
785  {
786  continue; // before selection
787  }
788  if (n == rEnd.nNode && rEnd.nContent.GetIndex() <= pHint->GetStart())
789  {
790  break; // after selection
791  }
792  if (pHint->Which() == RES_TXTATR_FIELD
793  // placeholders don't work if you can't delete them
794  && pHint->GetFormatField().GetField()->GetTyp()->Which() != SwFieldIds::JumpEdit)
795  {
796  return true;
797  }
798  }
799  }
800  }
801  }
802  }
803 
804  return bRet;
805 }
806 
811 SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const & fnMove,
812  bool const bInReadOnly, SwRootFrame const*const i_pLayout)
813 {
814  SwRootFrame const*const pLayout(i_pLayout ? i_pLayout :
816  SwContentNode * pNd = nullptr;
817  if( ((*rPam.GetPoint()).*fnMove.fnCmpOp)( *rPam.GetMark() ) ||
818  ( *rPam.GetPoint() == *rPam.GetMark() && rbFirst ) )
819  {
820  if( rbFirst )
821  {
822  rbFirst = false;
823  pNd = rPam.GetContentNode();
824  if( pNd )
825  {
826  SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
827  if(
828  (
829  nullptr == pFrame ||
830  ( !bInReadOnly && pFrame->IsProtected() ) ||
831  (pFrame->IsTextFrame() && static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow())
832  ) ||
833  ( !bInReadOnly && pNd->FindSectionNode() &&
834  pNd->FindSectionNode()->GetSection().IsProtect()
835  )
836  )
837  {
838  pNd = nullptr;
839  }
840  }
841  }
842 
843  if( !pNd ) // is the cursor not on a ContentNode?
844  {
845  SwPosition aPos( *rPam.GetPoint() );
846  bool bSrchForward = &fnMove == &fnMoveForward;
847  SwNodes& rNodes = aPos.nNode.GetNodes();
848 
849  // go to next/previous ContentNode
850  while( true )
851  {
852  if (i_pLayout && aPos.nNode.GetNode().IsTextNode())
853  {
854  auto const fal(sw::GetFirstAndLastNode(*pLayout, aPos.nNode));
855  aPos.nNode = bSrchForward ? *fal.second : *fal.first;
856  }
857 
858  pNd = bSrchForward
859  ? rNodes.GoNextSection( &aPos.nNode, true, !bInReadOnly )
860  : SwNodes::GoPrevSection( &aPos.nNode, true, !bInReadOnly );
861  if( pNd )
862  {
863  aPos.nContent.Assign( pNd, ::GetSttOrEnd( bSrchForward,*pNd ));
864  // is the position still in the area
865  if( (aPos.*fnMove.fnCmpOp)( *rPam.GetMark() ) )
866  {
867  // only in AutoTextSection can be nodes that are hidden
868  SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
869  if (nullptr == pFrame ||
870  ( !bInReadOnly && pFrame->IsProtected() ) ||
871  ( pFrame->IsTextFrame() &&
872  static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow()))
873  {
874  pNd = nullptr;
875  continue;
876  }
877  *rPam.GetPoint() = aPos;
878  }
879  else
880  pNd = nullptr; // no valid node
881  break;
882  }
883  break;
884  }
885  }
886  }
887  return pNd;
888 }
889 
890 void GoStartDoc( SwPosition * pPos )
891 {
892  SwNodes& rNodes = pPos->nNode.GetNodes();
893  pPos->nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
894  // we always need to find a ContentNode!
895  SwContentNode* pCNd = rNodes.GoNext( &pPos->nNode );
896  if( pCNd )
897  pCNd->MakeStartIndex( &pPos->nContent );
898 }
899 
900 void GoEndDoc( SwPosition * pPos )
901 {
902  SwNodes& rNodes = pPos->nNode.GetNodes();
903  pPos->nNode = rNodes.GetEndOfContent();
904  SwContentNode* pCNd = GoPreviousNds( &pPos->nNode, true );
905  if( pCNd )
906  pCNd->MakeEndIndex( &pPos->nContent );
907 }
908 
910 {
911  // jump to section's beginning
912  SwNodes& rNodes = pPos->nNode.GetNodes();
913  sal_uInt16 nLevel = SwNodes::GetSectionLevel( pPos->nNode );
914  if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
915  nLevel--;
916  do { SwNodes::GoStartOfSection( &pPos->nNode ); } while( nLevel-- );
917 
918  // already on a ContentNode
919  pPos->nNode.GetNode().GetContentNode()->MakeStartIndex( &pPos->nContent );
920 }
921 
923 void GoEndSection( SwPosition * pPos )
924 {
925  // jump to section's beginning/end
926  SwNodes& rNodes = pPos->nNode.GetNodes();
927  sal_uInt16 nLevel = SwNodes::GetSectionLevel( pPos->nNode );
928  if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
929  nLevel--;
930  do { SwNodes::GoEndOfSection( &pPos->nNode ); } while( nLevel-- );
931 
932  // now on an EndNode, thus to the previous ContentNode
933  if( GoPreviousNds( &pPos->nNode, true ) )
934  pPos->nNode.GetNode().GetContentNode()->MakeEndIndex( &pPos->nContent );
935 }
936 
937 bool GoInDoc( SwPaM & rPam, SwMoveFnCollection const & fnMove )
938 {
939  (*fnMove.fnDoc)( rPam.GetPoint() );
940  return true;
941 }
942 
943 bool GoInSection( SwPaM & rPam, SwMoveFnCollection const & fnMove )
944 {
945  (*fnMove.fnSections)( rPam.GetPoint() );
946  return true;
947 }
948 
949 bool GoInNode( SwPaM & rPam, SwMoveFnCollection const & fnMove )
950 {
951  SwContentNode *pNd = (*fnMove.fnNds)( &rPam.GetPoint()->nNode, true );
952  if( pNd )
953  rPam.GetPoint()->nContent.Assign( pNd,
954  ::GetSttOrEnd( &fnMove == &fnMoveForward, *pNd ) );
955  return pNd;
956 }
957 
958 bool GoInContent( SwPaM & rPam, SwMoveFnCollection const & fnMove )
959 {
960  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
961  &rPam.GetPoint()->nContent, CRSR_SKIP_CHARS ))
962  return true;
963  return GoInNode( rPam, fnMove );
964 }
965 
966 bool GoInContentCells( SwPaM & rPam, SwMoveFnCollection const & fnMove )
967 {
968  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
969  &rPam.GetPoint()->nContent, CRSR_SKIP_CELLS ))
970  return true;
971  return GoInNode( rPam, fnMove );
972 }
973 
974 bool GoInContentSkipHidden( SwPaM & rPam, SwMoveFnCollection const & fnMove )
975 {
976  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
978  return true;
979  return GoInNode( rPam, fnMove );
980 }
981 
983 {
984  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
986  return true;
987  return GoInNode( rPam, fnMove );
988 }
989 
990 bool GoPrevPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
991 {
992  if( rPam.Move( fnMoveBackward, GoInNode ) )
993  {
994  // always on a ContentNode
995  SwPosition& rPos = *rPam.GetPoint();
996  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
997  rPos.nContent.Assign( pNd,
998  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ) );
999  return true;
1000  }
1001  return false;
1002 }
1003 
1004 bool GoCurrPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
1005 {
1006  SwPosition& rPos = *rPam.GetPoint();
1007  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
1008  if( pNd )
1009  {
1010  const sal_Int32 nOld = rPos.nContent.GetIndex();
1011  const sal_Int32 nNew = &aPosPara == &fnMoveForward ? 0 : pNd->Len();
1012  // if already at beginning/end then to the next/previous
1013  if( nOld != nNew )
1014  {
1015  rPos.nContent.Assign( pNd, nNew );
1016  return true;
1017  }
1018  }
1019  // move node to next/previous ContentNode
1020  if( ( &aPosPara==&fnParaStart && nullptr != ( pNd =
1021  GoPreviousNds( &rPos.nNode, true ))) ||
1022  ( &aPosPara==&fnParaEnd && nullptr != ( pNd =
1023  GoNextNds( &rPos.nNode, true ))) )
1024  {
1025  rPos.nContent.Assign( pNd,
1026  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ));
1027  return true;
1028  }
1029  return false;
1030 }
1031 
1032 bool GoNextPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
1033 {
1034  if( rPam.Move( fnMoveForward, GoInNode ) )
1035  {
1036  // always on a ContentNode
1037  SwPosition& rPos = *rPam.GetPoint();
1038  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
1039  rPos.nContent.Assign( pNd,
1040  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ) );
1041  return true;
1042  }
1043  return false;
1044 }
1045 
1046 bool GoCurrSection( SwPaM & rPam, SwMoveFnCollection const & fnMove )
1047 {
1048  SwPosition& rPos = *rPam.GetPoint();
1049  SwPosition aSavePos( rPos ); // position for comparison
1050  (fnMove.fnSection)( &rPos.nNode );
1051  SwContentNode *pNd;
1052  if( nullptr == ( pNd = rPos.nNode.GetNode().GetContentNode()) &&
1053  nullptr == ( pNd = (*fnMove.fnNds)( &rPos.nNode, true )) )
1054  {
1055  rPos = aSavePos; // do not change cursor
1056  return false;
1057  }
1058 
1059  rPos.nContent.Assign( pNd,
1060  ::GetSttOrEnd( &fnMove == &fnMoveForward, *pNd ) );
1061  return aSavePos != rPos;
1062 }
1063 
1064 OUString SwPaM::GetText() const
1065 {
1066  OUStringBuffer aResult;
1067 
1068  SwNodeIndex aNodeIndex = Start()->nNode;
1069 
1070  // The first node can be already the end node.
1071  // Use a "forever" loop with an exit condition in the middle
1072  // of its body, in order to correctly handle all cases.
1073  bool bIsStartNode = true;
1074  for (;;)
1075  {
1076  const bool bIsEndNode = aNodeIndex == End()->nNode;
1077  SwTextNode * pTextNode = aNodeIndex.GetNode().GetTextNode();
1078 
1079  if (pTextNode != nullptr)
1080  {
1081  if (!bIsStartNode)
1082  {
1083  aResult.append(CH_TXTATR_NEWLINE); // use newline for para break
1084  }
1085  const OUString& aTmpStr = pTextNode->GetText();
1086 
1087  if (bIsStartNode || bIsEndNode)
1088  {
1089  // Handle corner cases of start/end node(s)
1090  const sal_Int32 nStart = bIsStartNode
1091  ? Start()->nContent.GetIndex()
1092  : 0;
1093  const sal_Int32 nEnd = bIsEndNode
1094  ? End()->nContent.GetIndex()
1095  : aTmpStr.getLength();
1096 
1097  aResult.append(std::u16string_view(aTmpStr).substr(nStart, nEnd-nStart));
1098  }
1099  else
1100  {
1101  aResult.append(aTmpStr);
1102  }
1103  }
1104 
1105  if (bIsEndNode)
1106  {
1107  break;
1108  }
1109 
1110  ++aNodeIndex;
1111  bIsStartNode = false;
1112  }
1113 
1114  return aResult.makeStringAndClear();
1115 }
1116 
1118 {
1119  const SwNode &_pNd = GetNode();
1120  const SwTextNode *_pTextNd = _pNd.GetTextNode();
1121  if (_pTextNd != nullptr)
1122  {
1123  // pretend that the PaM marks inserted text to recalc the portion...
1124  SwInsText aHint( Start()->nContent.GetIndex(),
1125  End()->nContent.GetIndex() - Start()->nContent.GetIndex() + 1 );
1126  SwModify *_pModify=const_cast<SwModify*>(static_cast<SwModify const *>(_pTextNd));
1127  _pModify->ModifyNotification( nullptr, &aHint);
1128  }
1129 }
1130 
1132 {
1133  xmlTextWriterStartElement(pWriter, BAD_CAST("SwPaM"));
1134 
1135  xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
1136  GetPoint()->dumpAsXml(pWriter);
1137  xmlTextWriterEndElement(pWriter);
1138 
1139  if (HasMark())
1140  {
1141  xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
1142  GetMark()->dumpAsXml(pWriter);
1143  xmlTextWriterEndElement(pWriter);
1144  }
1145 
1146  xmlTextWriterEndElement(pWriter);
1147 }
1148 
1149 std::ostream &operator <<(std::ostream& s, const SwPaM& pam)
1150 {
1151  if( pam.HasMark())
1152  return s << "SwPaM (point " << *pam.GetPoint() << ", mark " << *pam.GetMark() << ")";
1153  else
1154  return s << "SwPaM (point " << *pam.GetPoint() << ")";
1155 }
1156 
1157 
1158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:955
SwPosition m_Bound1
Definition: pam.hxx:138
Base class of the Writer layout elements.
Definition: frame.hxx:297
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual sal_Int32 Len() const
Definition: node.cxx:1181
void DeleteMark()
Definition: pam.hxx:177
SwNode & GetEndOfInserts() const
Section for all footnotes.
Definition: ndarr.hxx:154
SwContentNode * GoNextNds(SwNodeIndex *pIdx, bool bChk)
Definition: pam.cxx:297
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
sal_uLong GetIndex() const
Definition: node.hxx:282
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:156
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:958
Marks a position in the document model.
Definition: pam.hxx:35
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:811
bool IsInFly() const
Definition: frame.hxx:939
bool IsInSct() const
Definition: frame.hxx:945
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:673
const OUString & GetText() const
Definition: ndtxt.hxx:211
virtual const SwRootFrame * GetCurrentLayout() const =0
std::unique_ptr< SwPaM > MakeRegion(SwMoveFnCollection const &fnMove, const SwPaM &rOrigRg)
make a new region
Definition: pam.cxx:516
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1004
SwNodeIndex nNode
Definition: pam.hxx:37
static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex)
get section level at the given position
Definition: nodes.cxx:1245
GoSection fnSections
Definition: pamtyp.hxx:74
sal_uIntPtr sal_uLong
bool IsEditInReadonlyFlag() const
Definition: section.hxx:190
const SwPosition * GetMark() const
Definition: pam.hxx:209
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
sal_Int64 n
Provides access to the marks of a document.
Definition: doc.hxx:186
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
Definition: nodes.cxx:1952
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
static CHKSECTION lcl_TstIdx(sal_uLong nSttIdx, sal_uLong nEndIdx, const SwNode &rEndNd)
Definition: pam.cxx:201
static SwContentNode * GetContentNode(SwDoc *pDoc, SwNodeIndex &rIdx, bool bNext)
Definition: fltshell.cxx:54
SwPosition * m_pPoint
points at either m_Bound1 or m_Bound2
Definition: pam.hxx:140
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1294
SwNode & GetNode() const
Definition: ndindex.hxx:119
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
#define CH_TXTATR_NEWLINE
Definition: hintids.hxx:139
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1683
Dialog to specify the properties of date form field.
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:152
CHKSECTION
Definition: pam.cxx:197
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1131
SwPosition * m_pMark
points at either m_Bound1 or m_Bound2
Definition: pam.hxx:141
void InvalidatePaM()
Definition: pam.cxx:1117
Array of Undo-history.
Definition: docary.hxx:197
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:190
const SwSection & GetSection() const
Definition: node.hxx:541
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
bool GoInSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:943
bool operator==(const SwPosition &) const
Definition: pam.cxx:165
void GoStartDoc(SwPosition *pPos)
Definition: pam.cxx:890
void GoEndSection(SwPosition *pPos)
go to the end of the current base section
Definition: pam.cxx:923
SwIndex nContent
Definition: pam.hxx:38
SwDoc * GetDoc() const
Returns the document this position is in.
Definition: pam.cxx:177
auto(*)(SwPaM &rPam, SwMoveFnCollection const &fnMove) -> bool SwGoInDoc
Definition: pam.hxx:126
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
bool m_bIsInFrontOfLabel
Definition: pam.hxx:142
void GoEndDoc(SwPosition *pPos)
Definition: pam.cxx:900
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool IsStartNode() const
Definition: node.hxx:624
static void GoEndOfSection(SwNodeIndex *)
Definition: nodes.cxx:1271
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
Definition: pam.cxx:251
bool IsProtectFlag() const
Definition: section.hxx:189
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1089
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:533
MvSection fnSection
Definition: pamtyp.hxx:78
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:990
bool IsContentNode() const
Definition: node.hxx:628
OUString GetText() const
Definition: pam.cxx:1064
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
struct _xmlTextWriter * xmlTextWriterPtr
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:496
SwPaM(SwPaM const &rPaM)=delete
bool operator!=(const SwPosition &) const
Definition: pam.cxx:171
bool GoNext(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
Definition: pam.cxx:283
int i
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:949
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const SwPosition * GetPoint() const
Definition: pam.hxx:207
std::vector< SwSectionFormat * >::size_type size_type
Definition: docary.hxx:63
bool GoInContentCells(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:966
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:317
SwPageFrame * FindPageFrame()
Definition: frame.hxx:660
bool operator>=(const SwPosition &) const
Definition: pam.cxx:143
static void GoStartOfSection(SwNodeIndex *)
Definition: nodes.cxx:1253
bool GoInContentCellsSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:982
void Exchange()
Definition: pam.cxx:484
SwPosition(const SwNodeIndex &rNode, const SwIndex &rContent)
Definition: pam.cxx:57
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentNode * GetContentNode()
Definition: node.hxx:615
SwSection * GetSection()
Definition: sectfrm.hxx:84
SwPosition m_Bound2
Definition: pam.hxx:139
void MakeStartIndex(SwIndex *pIdx)
Definition: node.hxx:391
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
const sal_uInt16 CRSR_SKIP_HIDDEN
Definition: swcrsr.hxx:65
SwDoc * GetDoc()
Definition: node.hxx:702
SwDoc * GetDoc() const
Definition: pam.hxx:243
Marks a character position inside a document model node.
Definition: index.hxx:37
size_t size() const
Definition: docary.hxx:84
bool IsContentProtected() const
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1046
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:937
virtual ~SwPaM() override
Definition: pam.cxx:440
A page of the document layout.
Definition: pagefrm.hxx:40
bool operator>(const SwPosition &) const
Definition: pam.cxx:99
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
virtual bool isBookmarkDeleted(SwPaM const &rPaM) const =0
check if the selection would delete a BOOKMARK
const SwPosition * Start() const
Definition: pam.hxx:212
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1093
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
bool GoInContentSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:974
const sal_uInt16 CRSR_SKIP_CELLS
Definition: swcrsr.hxx:64
#define ODF_UNHANDLED
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
#define RES_TXTATR_FIELD
Definition: hintids.hxx:244
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsNoTextFrame() const
Definition: frame.hxx:1216
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:175
std::ostream & operator<<(std::ostream &s, const SwPosition &position)
Definition: pam.cxx:190
const SwPosition * End() const
Definition: pam.hxx:217
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:185
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1032
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:182
bool HasReadonlySel(bool bFormView) const
Is in something protected (readonly) or selection contains something protected.
Definition: pam.cxx:590
bool operator<=(const SwPosition &) const
Definition: pam.cxx:121
static bool lcl_ChkOneRange(CHKSECTION eSec, bool bChkSections, const SwNode &rBaseEnd, sal_uLong nStt, sal_uLong nEnd)
Definition: pam.cxx:210
SwPaM & operator=(const SwPaM &)
@@ semantic: no copy assignment for super class Ring.
Definition: pam.cxx:452
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
void GoStartSection(SwPosition *pPos)
Definition: pam.cxx:909
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
bool operator<(const SwPosition &) const
Definition: pam.cxx:77
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
virtual OUString GetFieldname() const =0
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:1900
SwContentNode * GoPreviousNds(SwNodeIndex *pIdx, bool bChk)
Definition: pam.cxx:312
bool IsCursorInParagraphMetadataField() const
Returns true iff the cursor is within a paragraph metadata field.
Definition: edfcol.cxx:2033
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2313
const SvxProtectItem & GetProtect(bool=true) const
Definition: frmatr.hxx:82
SwSectionNode * GetSectionNode()
Definition: node.hxx:607
virtual const SwPosition & GetMarkStart() const =0
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:470
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:158
const SwIndexReg * GetIdxReg() const
Definition: index.hxx:101
SwSectionFormats & GetSections()
Definition: doc.hxx:1336
bool GoPrevious(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
Definition: pam.cxx:290
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
void MakeEndIndex(SwIndex *pIdx)
Definition: node.hxx:392
sal_uInt16 GetPageNum(bool bAtPoint=true, const Point *pLayPos=nullptr)
Get number of page which contains cursor.
Definition: pam.cxx:544
static sal_Int32 GetSttOrEnd(bool bCondition, const SwContentNode &rNd)
Definition: pam.cxx:52
std::pair< SwTextNode *, SwTextNode * > GetFirstAndLastNode(SwRootFrame const &rLayout, SwNodeIndex const &rPos)
Definition: txtfrm.cxx:351
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1625
Base class of the Writer document model elements.
Definition: node.hxx:79
static const SwFrame * lcl_FindEditInReadonlyFrame(const SwFrame &rFrame)
Definition: pam.cxx:565