24#include <officecfg/Office/Common.hxx>
48#include <osl/diagnose.h>
51#include <rtl/ustrbuf.hxx>
59 return bCondition ? 0 : rNd.
Len();
63 : nNode( rNodeIndex ), nContent( rContent )
66 &&
"parameters point to different nodes");
70 : nNode( rNode ), nContent( rContent )
73 &&
"parameters point to different nodes");
77 : nNode( rNodeIndex ), nContent( pContentNode, nContentOffset )
79 assert((!pContentNode || pContentNode == &rNodeIndex.
GetNode()) &&
80 "parameters point to different nodes");
84 : nNode( rNode ), nContent( pContentNode, nContentOffset )
86 assert((!pContentNode || pContentNode == &rNode) &&
87 "parameters point to different nodes");
91 : nNode( rNodeIndex, nDiff ), nContent( pContentNode, nContentOffset )
93 assert((!pContentNode || pContentNode == &rNodeIndex.
GetNode()) &&
94 "parameters point to different nodes");
113 : nNode( rNode ), nContent( &rNode, nContentOffset )
118 : nNode( *rContentIndex.
GetContentNode() ), nContent( rContentIndex, nDiff )
131 if (pThisReg && pOtherReg)
137 return pOtherReg !=
nullptr;
152 if (pThisReg && pOtherReg)
158 return pThisReg !=
nullptr;
173 if (pThisReg && pOtherReg)
179 return pThisReg ==
nullptr;
194 if (pThisReg && pOtherReg)
200 return pOtherReg ==
nullptr;
225 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPosition"));
226 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nNode"), BAD_CAST(OString::number(sal_Int32(
GetNodeIndex())).getStr()));
227 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nContent"), BAD_CAST(OString::number(
GetContentIndex()).getStr()));
228 (void)xmlTextWriterEndElement(pWriter);
286 return s <<
"SwPosition (node " <<
position.GetNodeIndex() <<
", offset " <<
position.GetContentIndex() <<
")";
291enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
298 CHKSECTION eSec = nStt < nSttIdx && nEnd >= nSttIdx ? Chk_One : Chk_None;
299 if( nStt < nEndIdx && nEnd >= nEndIdx )
300 return( eSec == Chk_One ? Chk_Both : Chk_One );
307 if( eSec != Chk_Both )
315 const SwNode *pTmp, *pNd = rNds[ nStt ];
319 if( pNd == rNds[ nEnd ]->StartOfSectionNode() )
335 return nSttIdx <= nStt && nStt <= nEndIdx &&
336 nSttIdx <= nEnd && nEnd <= nEndIdx;
350 const SwNode& rEnd,
bool bChkSection )
355 if( Chk_None != eSec )
356 return eSec == Chk_Both;
359 if( Chk_None != eSec )
364 if( Chk_None != eSec )
369 if( Chk_None != eSec )
374 if( Chk_None != eSec )
458 , m_Bound2( rPos.
GetNode().GetNodes() )
459 , m_pPoint( &m_Bound1 )
460 , m_pMark( m_pPoint )
461 , m_bIsInFrontOfLabel( false )
469 , m_pPoint( &m_Bound2 )
470 , m_pMark( &m_Bound1 )
471 , m_bIsInFrontOfLabel( false )
480 , m_pPoint( &m_Bound2 )
481 , m_pMark( &m_Bound1 )
482 , m_bIsInFrontOfLabel( false )
501 , m_pPoint( &m_Bound2 )
502 , m_pMark( &m_Bound1 )
503 , m_bIsInFrontOfLabel( false )
522 , m_pPoint( &m_Bound2 )
523 , m_pMark( &m_Bound1 )
524 , m_bIsInFrontOfLabel( false )
531 const SwNode& rPoint, sal_Int32 nPointContent,
SwPaM* pRing )
535 , m_pPoint( &m_Bound2 )
536 , m_pMark( &m_Bound1 )
537 , m_bIsInFrontOfLabel( false )
550 , m_pPoint( &m_Bound2 )
551 , m_pMark( &m_Bound1 )
552 , m_bIsInFrontOfLabel( false )
571 , m_Bound2( m_Bound1.
GetNode().GetNodes() )
572 , m_pPoint( &m_Bound1 )
573 , m_pMark( &m_Bound1 )
574 , m_bIsInFrontOfLabel( false )
582 , m_Bound1( rNode, nNdOffset )
583 , m_Bound2( m_Bound1.
GetNode().GetNodes() )
584 , m_pPoint( &m_Bound1 )
585 , m_pMark( &m_Bound1 )
586 , m_bIsInFrontOfLabel( false )
594 , m_Bound1( rNodeIdx )
595 , m_Bound2( rNodeIdx.
GetNode().GetNodes() )
596 , m_pPoint( &m_Bound1 )
597 , m_pMark( &m_Bound1 )
598 , m_bIsInFrontOfLabel( false )
605 , m_Bound1( rNodes, nNdOffset )
607 , m_pPoint( &m_Bound1 )
608 , m_pMark( &m_Bound1 )
609 , m_bIsInFrontOfLabel( false )
617 , m_Bound1( *(rPam.m_pPoint) )
618 , m_Bound2( *(rPam.m_pMark) )
619 , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
620 , m_bIsInFrontOfLabel( false )
659 const bool bRet = (*fnGo)( *
this, fnMove );
677 const SwPaM & rOrigRg, std::optional<SwPaM>& rPam)
679 rPam.emplace(rOrigRg,
const_cast<SwPaM*
>(&rOrigRg));
683 if( (rPam->GetMark()->*fnMove.
fnCmpOp)( *rPam->GetPoint() ) )
707 std::pair<Point, bool> tmp;
710 tmp.first = *pLayPos;
729 (pFly = rFrame.
FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
736 nullptr != ( pSectionFrame = rFrame.
FindSctFrame() )->GetSection() &&
739 pRet = pSectionFrame;
752 if ( pNd !=
nullptr )
755 std::pair<Point, bool>
const tmp(aTmpPt,
false);
762 const SwFrame* pPointEditInReadonlyFrame =
nullptr;
763 if ( pFrame !=
nullptr
770 else if( pNd !=
nullptr )
783 if ( pParentSectionNd !=
nullptr
798 if ( pNd !=
nullptr )
801 std::pair<Point, bool>
const tmp(aTmpPt,
false);
807 const SwFrame* pMarkEditInReadonlyFrame =
nullptr;
808 if ( pFrame !=
nullptr
815 else if( pNd !=
nullptr )
827 if ( !bRet && bFormView )
831 if ( pPointEditInReadonlyFrame != pMarkEditInReadonlyFrame )
840 if( nEndIdx < nSttIdx )
841 std::swap( nSttIdx, nEndIdx );
855 OSL_ENSURE( rContent.
GetContentIdx(),
"where is the SectionNode?" );
857 if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
875 const bool bAtStartA = (pA !=
nullptr) && (pA->GetMarkStart() == *
GetPoint());
876 const bool bAtStartB = (pB !=
nullptr) && (pB->GetMarkStart() == *
GetMark());
884 bool bUnhandledMark = pA && pA->GetFieldname( ) ==
ODF_UNHANDLED;
886 if ( ( pA == pB ) && bUnhandledMark )
890 if ((pA == pB) && (bAtStartA != bAtStartB))
896 bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
901 bRet = ( pA == nullptr ) || ( pB ==
nullptr ) || bAtStartA || bAtStartB;
908 bRet = !( pA !=
nullptr && !bAtStartA && !bAtStartB && pA == pB );
915 bRet = !pEditShell->CursorInsideContentControl();
923 bRet = pEditShell->IsCursorInParagraphMetadataField();
941 if (
SwTextNode const*
const pNode =
n.GetNode().GetTextNode())
943 if (
SwpHints const*
const pHints = pNode->GetpSwpHints())
945 for (
size_t i = 0;
i < pHints->Count(); ++
i)
978 auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
979 if (pTextContentControl)
983 std::shared_ptr<SwContentControl> pContentControl
985 if (pContentControl && !pContentControl->GetReadWrite())
987 switch (pContentControl->GetType())
1023 OSL_ENSURE(rContent.
GetContentIdx(),
"where is the SectionNode?");
1025 if (nSttIdx <= nIdx && nEndIdx >= nIdx
1044 bool const bInReadOnly,
SwRootFrame const*
const i_pLayout)
1046 SwRootFrame const*
const pLayout(i_pLayout ? i_pLayout :
1061 nullptr == pFrame ||
1087 aPos.
Assign( bSrchForward ? *fal.second : *fal.first );
1102 if (
nullptr == pFrame ||
1264 if( ( &aPosPara==&
fnParaStart &&
nullptr != ( pNd =
1266 ( &aPosPara==&
fnParaEnd &&
nullptr != ( pNd =
1295 nullptr == ( pNd = (*fnMove.
fnPos)( &rPos,
true )) )
1302 return aSavePos != rPos;
1307 OUStringBuffer aResult;
1314 bool bIsStartNode =
true;
1317 const bool bIsEndNode = aNodeIndex ==
End()->
nNode;
1320 if (pTextNode !=
nullptr)
1326 const OUString& aTmpStr = pTextNode->
GetText();
1328 if (bIsStartNode || bIsEndNode)
1331 const sal_Int32 nStart = bIsStartNode
1334 const sal_Int32 nEnd = bIsEndNode
1336 : aTmpStr.getLength();
1338 aResult.append(aTmpStr.subView(nStart, nEnd-nStart));
1342 aResult.append(aTmpStr);
1352 bIsStartNode =
false;
1355 return aResult.makeStringAndClear();
1365 sal_Int32
const nStart(
1371 ?
End()->GetContentIndex() - nStart
1372 : pTextNode->Len() - nStart,
1382 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPaM"));
1384 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"point"));
1386 (void)xmlTextWriterEndElement(pWriter);
1390 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"mark"));
1392 (void)xmlTextWriterEndElement(pWriter);
1395 (void)xmlTextWriterEndElement(pWriter);
1401 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
", mark " << *pam.
GetMark() <<
")";
1403 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
")";
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
virtual bool isBookmarkDeleted(SwPaM const &rPaM, bool isReplace) const =0
check if the selection would delete a BOOKMARK
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
bool IsContentProtected() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Marks a character position inside a document model content node (SwContentNode)
const SwContentNode * GetContentNode() const
SwContentIndex & Assign(const SwContentNode *, sal_Int32)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
virtual sal_Int32 Len() const
SwSectionFormats & GetSections()
SwEditShell const * GetEditShell() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
IDocumentMarkAccess * getIDocumentMarkAccess()
::sw::DocumentSettingManager & GetDocumentSettingManager()
SwFieldType * GetTyp() const
general base class for all free-flowing frames
SfxPoolItem subclass that wraps an SwContentControl.
const std::shared_ptr< SwContentControl > & GetContentControl() const
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
Base class of the Writer layout elements.
SwFlyFrame * FindFlyFrame()
SwSectionFrame * FindSctFrame()
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
bool IsNoTextFrame() const
SwPageFrame * FindPageFrame()
const SwFrame * Lower() const
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset nIdx)
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwSectionNode * GetSectionNode()
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
bool IsContentNode() const
SwNodeOffset StartOfSectionIndex() const
SwSectionNode * FindSectionNode()
Search section node, in which it is.
const SwStartNode * StartOfSectionNode() const
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
const SwEndNode * EndOfSectionNode() const
static sal_uInt16 GetSectionLevel(const SwNode &rIndex)
get section level at the given position
static void GoEndOfSection(SwNodeIndex *)
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
static SwContentNode * GoPrevious(SwNodeIndex *)
static void GoStartOfSection(SwNodeIndex *)
SwNode & GetEndOfRedlines() const
Section for all Redlines.
SwContentNode * GoNext(SwNodeIndex *) const
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!...
SwNode & GetEndOfInserts() const
Section for all footnotes.
SwNode & GetEndOfPostIts() const
A still empty section.
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
SwPaM & operator=(const SwPaM &)
@@ semantic: no copy assignment for super class Ring.
void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
SwPosition * m_pMark
points at either m_Bound1 or m_Bound2
virtual ~SwPaM() override
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
SwPosition * m_pPoint
points at either m_Bound1 or m_Bound2
SwContentNode * GetPointContentNode() const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * End() const
SwPaM(SwPaM const &rPaM)=delete
sal_uInt16 GetPageNum(bool bAtPoint=true, const Point *pLayPos=nullptr)
Get number of page which contains cursor.
bool HasReadonlySel(bool bFormView, bool isReplace) const
Is in something protected (readonly) or selection contains something protected.
const SwPosition * GetPoint() const
bool HasHiddenSections() const
Is there hidden sections in the selected area.
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
A page of the document layout.
sal_uInt16 GetPhyPageNum() const
The root element of a Writer document layout.
A section node represents the start of a section on the UI, i.e.
const SwSection & GetSection() const
bool IsProtectFlag() const
bool IsEditInReadonlyFlag() const
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
sal_Int32 GetStart() const
const SwFormatField & GetFormatField() const
Represents the visualization of a paragraph.
bool IsHiddenNow() const
Hidden.
SwTextNode is a paragraph in the document model.
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
const OUString & GetText() const
std::vector< SwSectionFormat * >::size_type size_type
An SwTextAttr container, stores all directly formatted text portions for a text node.
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
struct _xmlTextWriter * xmlTextWriterPtr
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
#define CH_TXTATR_NEWLINE
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Dialog to specify the properties of date form field.
void MakeRegion(SwMoveFnCollection const &fnMove, const SwPaM &rOrigRg, std::optional< SwPaM > &rPam)
make a new region
std::pair< SwTextNode *, SwTextNode * > GetFirstAndLastNode(SwRootFrame const &rLayout, SwNode const &rPos)
@ Parent
EXPAND : (Start < nIndex <= End)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
constexpr OUStringLiteral ODF_UNHANDLED
void GoEndOfSection(SwPosition *pPos)
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
SwContentNode * GoNextNds(SwNodeIndex *pIdx, bool bChk)
bool GoInContentSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
SwContentNode * GoPreviousPos(SwPosition *pIdx, bool bChk)
void GoStartSection(SwPosition *pPos)
bool GoInContentCells(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
std::ostream & operator<<(std::ostream &s, const SwPosition &position)
void GoStartDoc(SwPosition *pPos)
bool GoNext(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
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.
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
void GoStartOfSection(SwPosition *pPos)
bool GoInContentCellsSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
static CHKSECTION lcl_TstIdx(SwNodeOffset nSttIdx, SwNodeOffset nEndIdx, const SwNode &rEndNd)
bool CheckNodesRange(const SwNode &rStt, const SwNode &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
static const SwFrame * lcl_FindEditInReadonlyFrame(const SwFrame &rFrame)
SwContentNode * GoPreviousNds(SwNodeIndex *pIdx, bool bChk)
bool GoPrevious(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
void GoEndDoc(SwPosition *pPos)
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
bool GoInSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
void GoEndSection(SwPosition *pPos)
go to the end of the current base section
static bool lcl_ChkOneRange(CHKSECTION eSec, bool bChkSections, const SwNode &rBaseEnd, SwNodeOffset nStt, SwNodeOffset nEnd)
static sal_Int32 GetSttOrEnd(bool bCondition, const SwContentNode &rNd)
SwContentNode * GoNextPos(SwPosition *pIdx, bool bChk)
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
auto(*)(SwPaM &rPam, SwMoveFnCollection const &fnMove) -> bool SwGoInDoc
SwMoveFnCollection const & fnParaStart
SwMoveFnCollection const & fnParaEnd
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Marks a position in the document model.
void Adjust(SwNodeOffset nDelta)
Adjust node position, and resets content position to zero.
bool operator<(const SwPosition &) const
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
void AssignEndIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the end of rNd.
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
void dumpAsXml(xmlTextWriterPtr pWriter) const
bool operator>(const SwPosition &) const
bool operator>=(const SwPosition &) const
const SwContentNode * GetContentNode() const
SwNodeOffset GetNodeIndex() const
bool operator<=(const SwPosition &) const
const SwNodes & GetNodes() const
void AssignStartIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the beginning of rNd.
sal_Int32 GetContentIndex() const
SwPosition(const SwNodeIndex &rNode, const SwContentIndex &rContent)
bool operator==(const SwPosition &) const
void AdjustContent(sal_Int32 nDelta)
Adjust content index, only valid to call this if the position points to a SwContentNode subclass.
SwDoc & GetDoc() const
Returns the document this position is in.
bool operator!=(const SwPosition &) const