24#include <officecfg/Office/Common.hxx>
47#include <osl/diagnose.h>
50#include <rtl/ustrbuf.hxx>
58 return bCondition ? 0 : rNd.
Len();
62 : nNode( rNodeIndex ), nContent( rContent )
65 &&
"parameters point to different nodes");
69 : nNode( rNode ), nContent( rContent )
72 &&
"parameters point to different nodes");
76 : nNode( rNodeIndex ), nContent( pContentNode, nContentOffset )
78 assert((!pContentNode || pContentNode == &rNodeIndex.
GetNode()) &&
79 "parameters point to different nodes");
83 : nNode( rNode ), nContent( pContentNode, nContentOffset )
85 assert((!pContentNode || pContentNode == &rNode) &&
86 "parameters point to different nodes");
90 : nNode( rNodeIndex, nDiff ), nContent( pContentNode, nContentOffset )
92 assert((!pContentNode || pContentNode == &rNodeIndex.
GetNode()) &&
93 "parameters point to different nodes");
112 : nNode( rNode ), nContent( &rNode, nContentOffset )
117 : nNode( *rContentIndex.
GetContentNode() ), nContent( rContentIndex, nDiff )
130 if (pThisReg && pOtherReg)
136 return pOtherReg !=
nullptr;
151 if (pThisReg && pOtherReg)
157 return pThisReg !=
nullptr;
172 if (pThisReg && pOtherReg)
178 return pThisReg ==
nullptr;
193 if (pThisReg && pOtherReg)
199 return pOtherReg ==
nullptr;
224 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPosition"));
225 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nNode"), BAD_CAST(OString::number(sal_Int32(
GetNodeIndex())).getStr()));
226 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nContent"), BAD_CAST(OString::number(
GetContentIndex()).getStr()));
227 (void)xmlTextWriterEndElement(pWriter);
285 return s <<
"SwPosition (node " <<
position.GetNodeIndex() <<
", offset " <<
position.GetContentIndex() <<
")";
290enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
297 CHKSECTION eSec = nStt < nSttIdx && nEnd >= nSttIdx ? Chk_One : Chk_None;
298 if( nStt < nEndIdx && nEnd >= nEndIdx )
299 return( eSec == Chk_One ? Chk_Both : Chk_One );
306 if( eSec != Chk_Both )
314 const SwNode *pTmp, *pNd = rNds[ nStt ];
318 if( pNd == rNds[ nEnd ]->StartOfSectionNode() )
334 return nSttIdx <= nStt && nStt <= nEndIdx &&
335 nSttIdx <= nEnd && nEnd <= nEndIdx;
349 const SwNode& rEnd,
bool bChkSection )
354 if( Chk_None != eSec )
355 return eSec == Chk_Both;
358 if( Chk_None != eSec )
363 if( Chk_None != eSec )
368 if( Chk_None != eSec )
373 if( Chk_None != eSec )
457 , m_Bound2( rPos.
GetNode().GetNodes() )
458 , m_pPoint( &m_Bound1 )
459 , m_pMark( m_pPoint )
460 , m_bIsInFrontOfLabel( false )
468 , m_pPoint( &m_Bound2 )
469 , m_pMark( &m_Bound1 )
470 , m_bIsInFrontOfLabel( false )
479 , m_pPoint( &m_Bound2 )
480 , m_pMark( &m_Bound1 )
481 , m_bIsInFrontOfLabel( false )
500 , m_pPoint( &m_Bound2 )
501 , m_pMark( &m_Bound1 )
502 , m_bIsInFrontOfLabel( false )
521 , m_pPoint( &m_Bound2 )
522 , m_pMark( &m_Bound1 )
523 , m_bIsInFrontOfLabel( false )
530 const SwNode& rPoint, sal_Int32 nPointContent,
SwPaM* pRing )
534 , m_pPoint( &m_Bound2 )
535 , m_pMark( &m_Bound1 )
536 , m_bIsInFrontOfLabel( false )
549 , m_pPoint( &m_Bound2 )
550 , m_pMark( &m_Bound1 )
551 , m_bIsInFrontOfLabel( false )
570 , m_Bound2( m_Bound1.
GetNode().GetNodes() )
571 , m_pPoint( &m_Bound1 )
572 , m_pMark( &m_Bound1 )
573 , m_bIsInFrontOfLabel( false )
581 , m_Bound1( rNode, nNdOffset )
582 , m_Bound2( m_Bound1.
GetNode().GetNodes() )
583 , m_pPoint( &m_Bound1 )
584 , m_pMark( &m_Bound1 )
585 , m_bIsInFrontOfLabel( false )
593 , m_Bound1( rNodeIdx )
594 , m_Bound2( rNodeIdx.
GetNode().GetNodes() )
595 , m_pPoint( &m_Bound1 )
596 , m_pMark( &m_Bound1 )
597 , m_bIsInFrontOfLabel( false )
604 , m_Bound1( rNodes, nNdOffset )
606 , m_pPoint( &m_Bound1 )
607 , m_pMark( &m_Bound1 )
608 , m_bIsInFrontOfLabel( false )
616 , m_Bound1( *(rPam.m_pPoint) )
617 , m_Bound2( *(rPam.m_pMark) )
618 , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
619 , m_bIsInFrontOfLabel( false )
670 const bool bRet = (*fnGo)( *
this, fnMove );
688 const SwPaM & rOrigRg, std::optional<SwPaM>& rPam)
690 rPam.emplace(rOrigRg,
const_cast<SwPaM*
>(&rOrigRg));
694 if( (rPam->GetMark()->*fnMove.
fnCmpOp)( *rPam->GetPoint() ) )
718 std::pair<Point, bool> tmp;
721 tmp.first = *pLayPos;
740 (pFly = rFrame.
FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
747 nullptr != ( pSectionFrame = rFrame.
FindSctFrame() )->GetSection() &&
750 pRet = pSectionFrame;
763 if ( pNd !=
nullptr )
766 std::pair<Point, bool>
const tmp(aTmpPt,
false);
773 const SwFrame* pPointEditInReadonlyFrame =
nullptr;
774 if ( pFrame !=
nullptr
781 else if( pNd !=
nullptr )
794 if ( pParentSectionNd !=
nullptr
809 if ( pNd !=
nullptr )
812 std::pair<Point, bool>
const tmp(aTmpPt,
false);
818 const SwFrame* pMarkEditInReadonlyFrame =
nullptr;
819 if ( pFrame !=
nullptr
826 else if( pNd !=
nullptr )
838 if ( !bRet && bFormView )
842 if ( pPointEditInReadonlyFrame != pMarkEditInReadonlyFrame )
851 if( nEndIdx < nSttIdx )
852 std::swap( nSttIdx, nEndIdx );
866 OSL_ENSURE( rContent.
GetContentIdx(),
"where is the SectionNode?" );
868 if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
886 const bool bAtStartA = (pA !=
nullptr) && (pA->GetMarkStart() == *
GetPoint());
887 const bool bAtStartB = (pB !=
nullptr) && (pB->GetMarkStart() == *
GetMark());
895 bool bUnhandledMark = pA && pA->GetFieldname( ) ==
ODF_UNHANDLED;
897 if ( ( pA == pB ) && bUnhandledMark )
901 if ((pA == pB) && (bAtStartA != bAtStartB))
907 bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
912 bRet = ( pA == nullptr ) || ( pB ==
nullptr ) || bAtStartA || bAtStartB;
919 bRet = !( pA !=
nullptr && !bAtStartA && !bAtStartB && pA == pB );
926 bRet = !pEditShell->CursorInsideContentControl();
934 bRet = pEditShell->IsCursorInParagraphMetadataField();
952 if (
SwTextNode const*
const pNode =
n.GetNode().GetTextNode())
954 if (
SwpHints const*
const pHints = pNode->GetpSwpHints())
956 for (
size_t i = 0;
i < pHints->Count(); ++
i)
989 auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
990 if (pTextContentControl)
994 std::shared_ptr<SwContentControl> pContentControl
996 if (pContentControl && !pContentControl->GetReadWrite())
998 switch (pContentControl->GetType())
1021 bool const bInReadOnly,
SwRootFrame const*
const i_pLayout)
1023 SwRootFrame const*
const pLayout(i_pLayout ? i_pLayout :
1038 nullptr == pFrame ||
1064 aPos.
Assign( bSrchForward ? *fal.second : *fal.first );
1079 if (
nullptr == pFrame ||
1241 if( ( &aPosPara==&
fnParaStart &&
nullptr != ( pNd =
1243 ( &aPosPara==&
fnParaEnd &&
nullptr != ( pNd =
1272 nullptr == ( pNd = (*fnMove.
fnPos)( &rPos,
true )) )
1279 return aSavePos != rPos;
1284 OUStringBuffer aResult;
1291 bool bIsStartNode =
true;
1294 const bool bIsEndNode = aNodeIndex ==
End()->
nNode;
1297 if (pTextNode !=
nullptr)
1303 const OUString& aTmpStr = pTextNode->
GetText();
1305 if (bIsStartNode || bIsEndNode)
1308 const sal_Int32 nStart = bIsStartNode
1311 const sal_Int32 nEnd = bIsEndNode
1313 : aTmpStr.getLength();
1315 aResult.append(aTmpStr.subView(nStart, nEnd-nStart));
1319 aResult.append(aTmpStr);
1329 bIsStartNode =
false;
1332 return aResult.makeStringAndClear();
1342 sal_Int32
const nStart(
1348 ?
End()->GetContentIndex() - nStart
1349 : pTextNode->Len() - nStart,
1359 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPaM"));
1361 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"point"));
1363 (void)xmlTextWriterEndElement(pWriter);
1367 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"mark"));
1369 (void)xmlTextWriterEndElement(pWriter);
1372 (void)xmlTextWriterEndElement(pWriter);
1378 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
", mark " << *pam.
GetMark() <<
")";
1380 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
")";
struct _xmlTextWriter * xmlTextWriterPtr
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual ::sw::mark::IFieldmark * getFieldmarkFor(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.
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset)
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
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
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.
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