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