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