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