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 
240 bool CheckNodesRange( const SwNodeIndex& rStt,
241  const SwNodeIndex& rEnd, bool bChkSection )
242 {
243  const SwNodes& rNds = rStt.GetNodes();
244  sal_uLong nStt = rStt.GetIndex(), nEnd = rEnd.GetIndex();
245  CHKSECTION eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfContent() );
246  if( Chk_None != eSec )
247  return eSec == Chk_Both;
248 
249  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfAutotext() );
250  if( Chk_None != eSec )
251  return lcl_ChkOneRange( eSec, bChkSection,
252  rNds.GetEndOfAutotext(), nStt, nEnd );
253 
254  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfPostIts() );
255  if( Chk_None != eSec )
256  return lcl_ChkOneRange( eSec, bChkSection,
257  rNds.GetEndOfPostIts(), nStt, nEnd );
258 
259  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfInserts() );
260  if( Chk_None != eSec )
261  return lcl_ChkOneRange( eSec, bChkSection,
262  rNds.GetEndOfInserts(), nStt, nEnd );
263 
264  eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfRedlines() );
265  if( Chk_None != eSec )
266  return lcl_ChkOneRange( eSec, bChkSection,
267  rNds.GetEndOfRedlines(), nStt, nEnd );
268 
269  return false; // somewhere in between => error
270 }
271 
272 bool GoNext(SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
273 {
274  if( pNd->IsContentNode() )
275  return static_cast<SwContentNode*>(pNd)->GoNext( pIdx, nMode );
276  return false;
277 }
278 
279 bool GoPrevious( SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
280 {
281  if( pNd->IsContentNode() )
282  return static_cast<SwContentNode*>(pNd)->GoPrevious( pIdx, nMode );
283  return false;
284 }
285 
286 SwContentNode* GoNextNds( SwNodeIndex* pIdx, bool bChk )
287 {
288  SwNodeIndex aIdx( *pIdx );
289  SwContentNode* pNd = aIdx.GetNodes().GoNext( &aIdx );
290  if( pNd )
291  {
292  if( bChk && 1 != aIdx.GetIndex() - pIdx->GetIndex() &&
293  !CheckNodesRange( *pIdx, aIdx, true ) )
294  pNd = nullptr;
295  else
296  *pIdx = aIdx;
297  }
298  return pNd;
299 }
300 
302 {
303  SwNodeIndex aIdx( *pIdx );
304  SwContentNode* pNd = SwNodes::GoPrevious( &aIdx );
305  if( pNd )
306  {
307  if( bChk && 1 != pIdx->GetIndex() - aIdx.GetIndex() &&
308  !CheckNodesRange( *pIdx, aIdx, true ) )
309  pNd = nullptr;
310  else
311  *pIdx = aIdx;
312  }
313  return pNd;
314 }
315 
316 SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing )
317  : Ring( pRing )
318  , m_Bound1( rPos )
319  , m_Bound2( rPos.nNode.GetNode().GetNodes() ) // default initialize
320  , m_pPoint( &m_Bound1 )
321  , m_pMark( m_pPoint )
322  , m_bIsInFrontOfLabel( false )
323 {
324 }
325 
326 SwPaM::SwPaM( const SwPosition& rMark, const SwPosition& rPoint, SwPaM* pRing )
327  : Ring( pRing )
328  , m_Bound1( rMark )
329  , m_Bound2( rPoint )
330  , m_pPoint( &m_Bound2 )
331  , m_pMark( &m_Bound1 )
332  , m_bIsInFrontOfLabel( false )
333 {
334 }
335 
336 SwPaM::SwPaM( const SwNodeIndex& rMark, const SwNodeIndex& rPoint,
337  long nMarkOffset, long nPointOffset, 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  if ( nMarkOffset )
346  {
347  m_pMark->nNode += nMarkOffset;
348  }
349  if ( nPointOffset )
350  {
351  m_pPoint->nNode += nPointOffset;
352  }
355 }
356 
357 SwPaM::SwPaM( const SwNode& rMark, const SwNode& rPoint,
358  long nMarkOffset, long nPointOffset, SwPaM* pRing )
359  : Ring( pRing )
360  , m_Bound1( rMark )
361  , m_Bound2( rPoint )
362  , m_pPoint( &m_Bound2 )
363  , m_pMark( &m_Bound1 )
364  , m_bIsInFrontOfLabel( false )
365 {
366  if ( nMarkOffset )
367  {
368  m_pMark->nNode += nMarkOffset;
369  }
370  if ( nPointOffset )
371  {
372  m_pPoint->nNode += nPointOffset;
373  }
376 }
377 
378 SwPaM::SwPaM( const SwNodeIndex& rMark, sal_Int32 nMarkContent,
379  const SwNodeIndex& rPoint, sal_Int32 nPointContent, SwPaM* pRing )
380  : Ring( pRing )
381  , m_Bound1( rMark )
382  , m_Bound2( rPoint )
383  , m_pPoint( &m_Bound2 )
384  , m_pMark( &m_Bound1 )
385  , m_bIsInFrontOfLabel( false )
386 {
387  m_pPoint->nContent.Assign( rPoint.GetNode().GetContentNode(), nPointContent);
388  m_pMark ->nContent.Assign( rMark .GetNode().GetContentNode(), nMarkContent );
389 }
390 
391 SwPaM::SwPaM( const SwNode& rMark, sal_Int32 nMarkContent,
392  const SwNode& rPoint, sal_Int32 nPointContent, SwPaM* pRing )
393  : Ring( pRing )
394  , m_Bound1( rMark )
395  , m_Bound2( rPoint )
396  , m_pPoint( &m_Bound2 )
397  , m_pMark( &m_Bound1 )
398  , m_bIsInFrontOfLabel( false )
399 {
401  nPointContent);
402  m_pMark ->nContent.Assign( m_pMark ->nNode.GetNode().GetContentNode(),
403  nMarkContent );
404 }
405 
406 SwPaM::SwPaM( const SwNode& rNode, sal_Int32 nContent, SwPaM* pRing )
407  : Ring( pRing )
408  , m_Bound1( rNode )
409  , m_Bound2( m_Bound1.nNode.GetNode().GetNodes() ) // default initialize
410  , m_pPoint( &m_Bound1 )
411  , m_pMark( &m_Bound1 )
412  , m_bIsInFrontOfLabel( false )
413 {
415  nContent );
416 }
417 
418 SwPaM::SwPaM( const SwNodeIndex& rNodeIdx, sal_Int32 nContent, SwPaM* pRing )
419  : Ring( pRing )
420  , m_Bound1( rNodeIdx )
421  , m_Bound2( rNodeIdx.GetNode().GetNodes() ) // default initialize
422  , m_pPoint( &m_Bound1 )
423  , m_pMark( &m_Bound1 )
424  , m_bIsInFrontOfLabel( false )
425 {
426  m_pPoint->nContent.Assign( rNodeIdx.GetNode().GetContentNode(), nContent );
427 }
428 
430 
431 SwPaM::SwPaM(SwPaM const& rPam, SwPaM *const pRing)
432  : Ring(pRing)
433  , m_Bound1( *(rPam.m_pPoint) )
434  , m_Bound2( *(rPam.m_pMark) )
435  , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
436  , m_bIsInFrontOfLabel( false )
437 {
438 }
439 
440 // @@@ semantic: no copy assignment for super class Ring.
441 SwPaM &SwPaM::operator=( const SwPaM &rPam )
442 {
443  if(this == &rPam)
444  return *this;
445 
446  *m_pPoint = *( rPam.m_pPoint );
447  if ( rPam.HasMark() )
448  {
449  SetMark();
450  *m_pMark = *( rPam.m_pMark );
451  }
452  else
453  {
454  DeleteMark();
455  }
456  return *this;
457 }
458 
460 {
461  if (m_pPoint == &m_Bound1)
462  {
463  m_pMark = &m_Bound2;
464  }
465  else
466  {
467  m_pMark = &m_Bound1;
468  }
469  (*m_pMark) = *m_pPoint;
470 }
471 
472 #ifdef DBG_UTIL
474 {
475  if (m_pPoint != m_pMark)
476  {
477  SwPosition *pTmp = m_pPoint;
478  m_pPoint = m_pMark;
479  m_pMark = pTmp;
480  }
481 }
482 #endif
483 
485 bool SwPaM::Move( SwMoveFnCollection const & fnMove, SwGoInDoc fnGo )
486 {
487  const bool bRet = (*fnGo)( *this, fnMove );
488 
489  m_bIsInFrontOfLabel = false;
490  return bRet;
491 }
492 
493 namespace sw {
494 
505 std::unique_ptr<SwPaM> MakeRegion(SwMoveFnCollection const & fnMove,
506  const SwPaM & rOrigRg)
507 {
508  std::unique_ptr<SwPaM> pPam;
509  {
510  pPam.reset(new SwPaM(rOrigRg, const_cast<SwPaM*>(&rOrigRg))); // given search range
511  // make sure that SPoint is on the "real" start position
512  // FORWARD: SPoint always smaller than GetMark
513  // BACKWARD: SPoint always bigger than GetMark
514  if( (pPam->GetMark()->*fnMove.fnCmpOp)( *pPam->GetPoint() ) )
515  pPam->Exchange();
516  }
517  return pPam;
518 }
519 
520 } // namespace sw
521 
522 void SwPaM::Normalize(bool bPointFirst)
523 {
524  if (HasMark())
525  if ( ( bPointFirst && *m_pPoint > *m_pMark) ||
526  (!bPointFirst && *m_pPoint < *m_pMark) )
527  {
528  Exchange();
529  }
530 }
531 
533 sal_uInt16 SwPaM::GetPageNum( bool bAtPoint, const Point* pLayPos )
534 {
535  const SwContentFrame* pCFrame;
536  const SwPageFrame *pPg;
537  const SwContentNode *pNd ;
538  const SwPosition* pPos = bAtPoint ? m_pPoint : m_pMark;
539 
540  std::pair<Point, bool> tmp;
541  if (pLayPos)
542  {
543  tmp.first = *pLayPos;
544  tmp.second = false;
545  }
546  if( nullptr != ( pNd = pPos->nNode.GetNode().GetContentNode() ) &&
547  nullptr != (pCFrame = pNd->getLayoutFrame(pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), pPos, pLayPos ? &tmp : nullptr)) &&
548  nullptr != ( pPg = pCFrame->FindPageFrame() ))
549  return pPg->GetPhyPageNum();
550  return 0;
551 }
552 
553 // form view - see also SwCursorShell::IsCursorReadonly()
554 static const SwFrame* lcl_FindEditInReadonlyFrame( const SwFrame& rFrame )
555 {
556  const SwFrame* pRet = nullptr;
557 
558  const SwFlyFrame* pFly;
559  const SwSectionFrame* pSectionFrame;
560 
561  if( rFrame.IsInFly() &&
562  (pFly = rFrame.FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
563  pFly->Lower() &&
564  !pFly->Lower()->IsNoTextFrame() )
565  {
566  pRet = pFly;
567  }
568  else if ( rFrame.IsInSct() &&
569  nullptr != ( pSectionFrame = rFrame.FindSctFrame() )->GetSection() &&
570  pSectionFrame->GetSection()->IsEditInReadonlyFlag() )
571  {
572  pRet = pSectionFrame;
573  }
574 
575  return pRet;
576 }
577 
579 bool SwPaM::HasReadonlySel( bool bFormView ) const
580 {
581  bool bRet = false;
582 
583  const SwContentNode* pNd = GetPoint()->nNode.GetNode().GetContentNode();
584  const SwContentFrame *pFrame = nullptr;
585  if ( pNd != nullptr )
586  {
587  Point aTmpPt;
588  std::pair<Point, bool> const tmp(aTmpPt, false);
589  pFrame = pNd->getLayoutFrame(
591  GetPoint(), &tmp);
592  }
593 
594  // Will be set if point are inside edit-in-readonly environment
595  const SwFrame* pPointEditInReadonlyFrame = nullptr;
596  if ( pFrame != nullptr
597  && ( pFrame->IsProtected()
598  || ( bFormView
599  && nullptr == ( pPointEditInReadonlyFrame = lcl_FindEditInReadonlyFrame( *pFrame ) ) ) ) )
600  {
601  bRet = true;
602  }
603  else if( pNd != nullptr )
604  {
605  const SwSectionNode* pSNd = pNd->GetSectionNode();
606  if ( pSNd != nullptr
607  && ( pSNd->GetSection().IsProtectFlag()
608  || ( bFormView
609  && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
610  {
611  bRet = true;
612  }
613  else
614  {
615  const SwSectionNode* pParentSectionNd = pNd->FindSectionNode();
616  if ( pParentSectionNd != nullptr
617  && ( pParentSectionNd->GetSection().IsProtectFlag()
618  || ( bFormView && !pParentSectionNd->GetSection().IsEditInReadonlyFlag()) ) )
619  {
620  bRet = true;
621  }
622  }
623  }
624 
625  if ( !bRet
626  && HasMark()
627  && GetPoint()->nNode != GetMark()->nNode )
628  {
629  pNd = GetMark()->nNode.GetNode().GetContentNode();
630  pFrame = nullptr;
631  if ( pNd != nullptr )
632  {
633  Point aTmpPt;
634  std::pair<Point, bool> const tmp(aTmpPt, false);
635  pFrame = pNd->getLayoutFrame(
637  GetMark(), &tmp);
638  }
639 
640  const SwFrame* pMarkEditInReadonlyFrame = nullptr;
641  if ( pFrame != nullptr
642  && ( pFrame->IsProtected()
643  || ( bFormView
644  && nullptr == ( pMarkEditInReadonlyFrame = lcl_FindEditInReadonlyFrame( *pFrame ) ) ) ) )
645  {
646  bRet = true;
647  }
648  else if( pNd != nullptr )
649  {
650  const SwSectionNode* pSNd = pNd->GetSectionNode();
651  if ( pSNd != nullptr
652  && ( pSNd->GetSection().IsProtectFlag()
653  || ( bFormView
654  && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
655  {
656  bRet = true;
657  }
658  }
659 
660  if ( !bRet && bFormView )
661  {
662  // Check if start and end frame are inside the _same_
663  // edit-in-readonly-environment. Otherwise we better return 'true'
664  if ( pPointEditInReadonlyFrame != pMarkEditInReadonlyFrame )
665  bRet = true;
666  }
667 
668  // check for protected section inside the selection
669  if( !bRet )
670  {
671  sal_uLong nSttIdx = GetMark()->nNode.GetIndex(),
672  nEndIdx = GetPoint()->nNode.GetIndex();
673  if( nEndIdx <= nSttIdx )
674  {
675  sal_uLong nTmp = nSttIdx;
676  nSttIdx = nEndIdx;
677  nEndIdx = nTmp;
678  }
679 
680  // If a protected section should be between nodes, then the
681  // selection needs to contain already x nodes.
682  // (TextNd, SectNd, TextNd, EndNd, TextNd )
683  if( nSttIdx + 3 < nEndIdx )
684  {
685  const SwSectionFormats& rFormats = GetDoc()->GetSections();
686  for( SwSectionFormats::size_type n = rFormats.size(); n; )
687  {
688  const SwSectionFormat* pFormat = rFormats[ --n ];
689  if( pFormat->GetProtect().IsContentProtected() )
690  {
691  const SwFormatContent& rContent = pFormat->GetContent(false);
692  OSL_ENSURE( rContent.GetContentIdx(), "where is the SectionNode?" );
693  sal_uLong nIdx = rContent.GetContentIdx()->GetIndex();
694  if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
695  rContent.GetContentIdx()->GetNode().GetNodes().IsDocNodes() )
696  {
697  bRet = true;
698  break;
699  }
700  }
701  }
702  }
703  }
704  }
705 
706  const SwDoc *pDoc = GetDoc();
707  // Legacy text/combo/checkbox: never return read-only when inside these form fields.
708  const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
709  sw::mark::IFieldmark* pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : nullptr;
710  sw::mark::IFieldmark* pB = GetMark() ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
711  // prevent the user from accidentally deleting the field itself when modifying the text.
712  const bool bAtStartA = (pA != nullptr) && (pA->GetMarkStart() == *GetPoint());
713  const bool bAtStartB = (pB != nullptr) && (pB->GetMarkStart() == *GetMark());
714 
715  if (!bRet)
716  {
717  bool bUnhandledMark = pA && pA->GetFieldname( ) == ODF_UNHANDLED;
718  // Unhandled fieldmarks case shouldn't be edited manually to avoid breaking anything
719  if ( ( pA == pB ) && bUnhandledMark )
720  bRet = true;
721  else
722  {
723  if ((pA == pB) && (bAtStartA != bAtStartB))
724  bRet = true;
725  else if (pA != pB)
726  {
727  // If both points are either outside or at marks edges (i.e. selection either
728  // touches fields, or fully encloses it), then don't disable editing
729  bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
730  }
731  if( !bRet && pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM ) && (pA || pB) )
732  {
733  // Form protection case
734  bRet = ( pA == nullptr ) || ( pB == nullptr ) || bAtStartA || bAtStartB;
735  }
736  }
737  }
738  else
739  {
740  // Allow editing when the cursor/selection is fully inside of a legacy form field.
741  bRet = !( pA != nullptr && !bAtStartA && !bAtStartB && pA == pB );
742  }
743 
744  if (!bRet)
745  {
746  // Paragraph Signatures and Classification fields are read-only.
747  if (pDoc && pDoc->GetEditShell())
749  }
750 
751  return bRet;
752 }
753 
758 SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const & fnMove,
759  bool const bInReadOnly, SwRootFrame const*const i_pLayout)
760 {
761  SwRootFrame const*const pLayout(i_pLayout ? i_pLayout :
763  SwContentNode * pNd = nullptr;
764  if( ((*rPam.GetPoint()).*fnMove.fnCmpOp)( *rPam.GetMark() ) ||
765  ( *rPam.GetPoint() == *rPam.GetMark() && rbFirst ) )
766  {
767  if( rbFirst )
768  {
769  rbFirst = false;
770  pNd = rPam.GetContentNode();
771  if( pNd )
772  {
773  SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
774  if(
775  (
776  nullptr == pFrame ||
777  ( !bInReadOnly && pFrame->IsProtected() ) ||
778  (pFrame->IsTextFrame() && static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow())
779  ) ||
780  ( !bInReadOnly && pNd->FindSectionNode() &&
781  pNd->FindSectionNode()->GetSection().IsProtect()
782  )
783  )
784  {
785  pNd = nullptr;
786  }
787  }
788  }
789 
790  if( !pNd ) // is the cursor not on a ContentNode?
791  {
792  SwPosition aPos( *rPam.GetPoint() );
793  bool bSrchForward = &fnMove == &fnMoveForward;
794  SwNodes& rNodes = aPos.nNode.GetNodes();
795 
796  // go to next/previous ContentNode
797  while( true )
798  {
799  if (i_pLayout && aPos.nNode.GetNode().IsTextNode())
800  {
801  auto const fal(sw::GetFirstAndLastNode(*pLayout, aPos.nNode));
802  aPos.nNode = bSrchForward ? *fal.second : *fal.first;
803  }
804 
805  pNd = bSrchForward
806  ? rNodes.GoNextSection( &aPos.nNode, true, !bInReadOnly )
807  : SwNodes::GoPrevSection( &aPos.nNode, true, !bInReadOnly );
808  if( pNd )
809  {
810  aPos.nContent.Assign( pNd, ::GetSttOrEnd( bSrchForward,*pNd ));
811  // is the position still in the area
812  if( (aPos.*fnMove.fnCmpOp)( *rPam.GetMark() ) )
813  {
814  // only in AutoTextSection can be nodes that are hidden
815  SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
816  if (nullptr == pFrame ||
817  ( !bInReadOnly && pFrame->IsProtected() ) ||
818  ( pFrame->IsTextFrame() &&
819  static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow()))
820  {
821  pNd = nullptr;
822  continue;
823  }
824  *rPam.GetPoint() = aPos;
825  }
826  else
827  pNd = nullptr; // no valid node
828  break;
829  }
830  break;
831  }
832  }
833  }
834  return pNd;
835 }
836 
837 void GoStartDoc( SwPosition * pPos )
838 {
839  SwNodes& rNodes = pPos->nNode.GetNodes();
840  pPos->nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
841  // we always need to find a ContentNode!
842  SwContentNode* pCNd = rNodes.GoNext( &pPos->nNode );
843  if( pCNd )
844  pCNd->MakeStartIndex( &pPos->nContent );
845 }
846 
847 void GoEndDoc( SwPosition * pPos )
848 {
849  SwNodes& rNodes = pPos->nNode.GetNodes();
850  pPos->nNode = rNodes.GetEndOfContent();
851  SwContentNode* pCNd = GoPreviousNds( &pPos->nNode, true );
852  if( pCNd )
853  pCNd->MakeEndIndex( &pPos->nContent );
854 }
855 
857 {
858  // jump to section's beginning
859  SwNodes& rNodes = pPos->nNode.GetNodes();
860  sal_uInt16 nLevel = SwNodes::GetSectionLevel( pPos->nNode );
861  if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
862  nLevel--;
863  do { SwNodes::GoStartOfSection( &pPos->nNode ); } while( nLevel-- );
864 
865  // already on a ContentNode
866  pPos->nNode.GetNode().GetContentNode()->MakeStartIndex( &pPos->nContent );
867 }
868 
870 void GoEndSection( SwPosition * pPos )
871 {
872  // jump to section's beginning/end
873  SwNodes& rNodes = pPos->nNode.GetNodes();
874  sal_uInt16 nLevel = SwNodes::GetSectionLevel( pPos->nNode );
875  if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
876  nLevel--;
877  do { SwNodes::GoEndOfSection( &pPos->nNode ); } while( nLevel-- );
878 
879  // now on an EndNode, thus to the previous ContentNode
880  if( GoPreviousNds( &pPos->nNode, true ) )
881  pPos->nNode.GetNode().GetContentNode()->MakeEndIndex( &pPos->nContent );
882 }
883 
884 bool GoInDoc( SwPaM & rPam, SwMoveFnCollection const & fnMove )
885 {
886  (*fnMove.fnDoc)( rPam.GetPoint() );
887  return true;
888 }
889 
890 bool GoInSection( SwPaM & rPam, SwMoveFnCollection const & fnMove )
891 {
892  (*fnMove.fnSections)( rPam.GetPoint() );
893  return true;
894 }
895 
896 bool GoInNode( SwPaM & rPam, SwMoveFnCollection const & fnMove )
897 {
898  SwContentNode *pNd = (*fnMove.fnNds)( &rPam.GetPoint()->nNode, true );
899  if( pNd )
900  rPam.GetPoint()->nContent.Assign( pNd,
901  ::GetSttOrEnd( &fnMove == &fnMoveForward, *pNd ) );
902  return pNd;
903 }
904 
905 bool GoInContent( SwPaM & rPam, SwMoveFnCollection const & fnMove )
906 {
907  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
908  &rPam.GetPoint()->nContent, CRSR_SKIP_CHARS ))
909  return true;
910  return GoInNode( rPam, fnMove );
911 }
912 
913 bool GoInContentCells( SwPaM & rPam, SwMoveFnCollection const & fnMove )
914 {
915  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
916  &rPam.GetPoint()->nContent, CRSR_SKIP_CELLS ))
917  return true;
918  return GoInNode( rPam, fnMove );
919 }
920 
921 bool GoInContentSkipHidden( SwPaM & rPam, SwMoveFnCollection const & fnMove )
922 {
923  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
925  return true;
926  return GoInNode( rPam, fnMove );
927 }
928 
930 {
931  if( (*fnMove.fnNd)( &rPam.GetPoint()->nNode.GetNode(),
933  return true;
934  return GoInNode( rPam, fnMove );
935 }
936 
937 bool GoPrevPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
938 {
939  if( rPam.Move( fnMoveBackward, GoInNode ) )
940  {
941  // always on a ContentNode
942  SwPosition& rPos = *rPam.GetPoint();
943  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
944  rPos.nContent.Assign( pNd,
945  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ) );
946  return true;
947  }
948  return false;
949 }
950 
951 bool GoCurrPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
952 {
953  SwPosition& rPos = *rPam.GetPoint();
954  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
955  if( pNd )
956  {
957  const sal_Int32 nOld = rPos.nContent.GetIndex();
958  const sal_Int32 nNew = &aPosPara == &fnMoveForward ? 0 : pNd->Len();
959  // if already at beginning/end then to the next/previous
960  if( nOld != nNew )
961  {
962  rPos.nContent.Assign( pNd, nNew );
963  return true;
964  }
965  }
966  // move node to next/previous ContentNode
967  if( ( &aPosPara==&fnParaStart && nullptr != ( pNd =
968  GoPreviousNds( &rPos.nNode, true ))) ||
969  ( &aPosPara==&fnParaEnd && nullptr != ( pNd =
970  GoNextNds( &rPos.nNode, true ))) )
971  {
972  rPos.nContent.Assign( pNd,
973  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ));
974  return true;
975  }
976  return false;
977 }
978 
979 bool GoNextPara( SwPaM & rPam, SwMoveFnCollection const & aPosPara )
980 {
981  if( rPam.Move( fnMoveForward, GoInNode ) )
982  {
983  // always on a ContentNode
984  SwPosition& rPos = *rPam.GetPoint();
985  SwContentNode * pNd = rPos.nNode.GetNode().GetContentNode();
986  rPos.nContent.Assign( pNd,
987  ::GetSttOrEnd( &aPosPara == &fnMoveForward, *pNd ) );
988  return true;
989  }
990  return false;
991 }
992 
993 bool GoCurrSection( SwPaM & rPam, SwMoveFnCollection const & fnMove )
994 {
995  SwPosition& rPos = *rPam.GetPoint();
996  SwPosition aSavePos( rPos ); // position for comparison
997  (fnMove.fnSection)( &rPos.nNode );
998  SwContentNode *pNd;
999  if( nullptr == ( pNd = rPos.nNode.GetNode().GetContentNode()) &&
1000  nullptr == ( pNd = (*fnMove.fnNds)( &rPos.nNode, true )) )
1001  {
1002  rPos = aSavePos; // do not change cursor
1003  return false;
1004  }
1005 
1006  rPos.nContent.Assign( pNd,
1007  ::GetSttOrEnd( &fnMove == &fnMoveForward, *pNd ) );
1008  return aSavePos != rPos;
1009 }
1010 
1011 OUString SwPaM::GetText() const
1012 {
1013  OUStringBuffer aResult;
1014 
1015  SwNodeIndex aNodeIndex = Start()->nNode;
1016 
1017  // The first node can be already the end node.
1018  // Use a "forever" loop with an exit condition in the middle
1019  // of its body, in order to correctly handle all cases.
1020  bool bIsStartNode = true;
1021  for (;;)
1022  {
1023  const bool bIsEndNode = aNodeIndex == End()->nNode;
1024  SwTextNode * pTextNode = aNodeIndex.GetNode().GetTextNode();
1025 
1026  if (pTextNode != nullptr)
1027  {
1028  if (!bIsStartNode)
1029  {
1030  aResult.append(CH_TXTATR_NEWLINE); // use newline for para break
1031  }
1032  const OUString& aTmpStr = pTextNode->GetText();
1033 
1034  if (bIsStartNode || bIsEndNode)
1035  {
1036  // Handle corner cases of start/end node(s)
1037  const sal_Int32 nStart = bIsStartNode
1038  ? Start()->nContent.GetIndex()
1039  : 0;
1040  const sal_Int32 nEnd = bIsEndNode
1041  ? End()->nContent.GetIndex()
1042  : aTmpStr.getLength();
1043 
1044  aResult.append(std::u16string_view(aTmpStr).substr(nStart, nEnd-nStart));
1045  }
1046  else
1047  {
1048  aResult.append(aTmpStr);
1049  }
1050  }
1051 
1052  if (bIsEndNode)
1053  {
1054  break;
1055  }
1056 
1057  ++aNodeIndex;
1058  bIsStartNode = false;
1059  }
1060 
1061  return aResult.makeStringAndClear();
1062 }
1063 
1065 {
1066  const SwNode &_pNd = GetNode();
1067  const SwTextNode *_pTextNd = _pNd.GetTextNode();
1068  if (_pTextNd != nullptr)
1069  {
1070  // pretend that the PaM marks inserted text to recalc the portion...
1071  SwInsText aHint( Start()->nContent.GetIndex(),
1072  End()->nContent.GetIndex() - Start()->nContent.GetIndex() + 1 );
1073  SwModify *_pModify=const_cast<SwModify*>(static_cast<SwModify const *>(_pTextNd));
1074  _pModify->ModifyNotification( nullptr, &aHint);
1075  }
1076 }
1077 
1079 {
1080  xmlTextWriterStartElement(pWriter, BAD_CAST("SwPaM"));
1081 
1082  xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
1083  GetPoint()->dumpAsXml(pWriter);
1084  xmlTextWriterEndElement(pWriter);
1085 
1086  if (HasMark())
1087  {
1088  xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
1089  GetMark()->dumpAsXml(pWriter);
1090  xmlTextWriterEndElement(pWriter);
1091  }
1092 
1093  xmlTextWriterEndElement(pWriter);
1094 }
1095 
1096 std::ostream &operator <<(std::ostream& s, const SwPaM& pam)
1097 {
1098  if( pam.HasMark())
1099  return s << "SwPaM (point " << *pam.GetPoint() << ", mark " << *pam.GetMark() << ")";
1100  else
1101  return s << "SwPaM (point " << *pam.GetPoint() << ")";
1102 }
1103 
1104 
1105 /* 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:155
SwContentNode * GoNextNds(SwNodeIndex *pIdx, bool bChk)
Definition: pam.cxx:286
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:905
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:758
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:505
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:951
SwNodeIndex nNode
Definition: pam.hxx:37
static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex)
get section level at the given position
Definition: nodes.cxx:1239
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
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:1973
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:80
SwPosition * m_pPoint
points at either m_Bound1 or m_Bound2
Definition: pam.hxx:140
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1288
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:46
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1602
Dialog to specify the properties of date form field.
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:1078
SwPosition * m_pMark
points at either m_Bound1 or m_Bound2
Definition: pam.hxx:141
void InvalidatePaM()
Definition: pam.cxx:1064
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:890
bool operator==(const SwPosition &) const
Definition: pam.cxx:164
void GoStartDoc(SwPosition *pPos)
Definition: pam.cxx:837
void GoEndSection(SwPosition *pPos)
go to the end of the current base section
Definition: pam.cxx:870
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:847
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool IsStartNode() const
Definition: node.hxx:624
static void GoEndOfSection(SwNodeIndex *)
Definition: nodes.cxx:1265
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Definition: pam.cxx:240
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:522
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:937
bool IsContentNode() const
Definition: node.hxx:628
OUString GetText() const
Definition: pam.cxx:1011
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:485
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:272
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:896
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:913
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:1247
bool GoInContentCellsSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:929
void Exchange()
Definition: pam.cxx:473
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:993
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:884
virtual ~SwPaM() override
Definition: pam.cxx:429
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:921
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:979
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:579
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:441
void GoStartSection(SwPosition *pPos)
Definition: pam.cxx:856
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:1921
SwContentNode * GoPreviousNds(SwNodeIndex *pIdx, bool bChk)
Definition: pam.cxx:301
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:2334
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:459
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:159
const SwIndexReg * GetIdxReg() const
Definition: index.hxx:101
SwSectionFormats & GetSections()
Definition: doc.hxx:1328
bool GoPrevious(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
Definition: pam.cxx:279
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1271
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:533
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:363
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:1621
Base class of the Writer document model elements.
Definition: node.hxx:79
static const SwFrame * lcl_FindEditInReadonlyFrame(const SwFrame &rFrame)
Definition: pam.cxx:554