24#include <officecfg/Office/Common.hxx>
47#include <osl/diagnose.h>
49#include <rtl/ustrbuf.hxx>
57 return bCondition ? 0 : rNd.
Len();
61 : nNode( rNodeIndex ), nContent( rContent )
76 : nNode( rNode ), nContent( &rNode, nOffset )
90 if (pThisReg && pOtherReg)
96 return pOtherReg !=
nullptr;
112 if (pThisReg && pOtherReg)
118 return pThisReg !=
nullptr;
134 if (pThisReg && pOtherReg)
140 return pThisReg ==
nullptr;
156 if (pThisReg && pOtherReg)
162 return pOtherReg ==
nullptr;
187 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPosition"));
188 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nNode"), BAD_CAST(OString::number(sal_Int32(
nNode.
GetIndex())).getStr()));
189 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"nContent"), BAD_CAST(OString::number(
nContent.
GetIndex()).getStr()));
190 (void)xmlTextWriterEndElement(pWriter);
195 return s <<
"SwPosition (node " <<
position.nNode.GetIndex() <<
", offset " <<
position.nContent.GetIndex() <<
")";
200enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
207 CHKSECTION eSec = nStt < nSttIdx && nEnd >= nSttIdx ? Chk_One : Chk_None;
208 if( nStt < nEndIdx && nEnd >= nEndIdx )
209 return( eSec == Chk_One ? Chk_Both : Chk_One );
216 if( eSec != Chk_Both )
224 const SwNode *pTmp, *pNd = rNds[ nStt ];
228 if( pNd == rNds[ nEnd ]->StartOfSectionNode() )
244 return nSttIdx <= nStt && nStt <= nEndIdx &&
245 nSttIdx <= nEnd && nEnd <= nEndIdx;
264 if( Chk_None != eSec )
265 return eSec == Chk_Both;
268 if( Chk_None != eSec )
273 if( Chk_None != eSec )
278 if( Chk_None != eSec )
283 if( Chk_None != eSec )
337 , m_Bound2( rPos.nNode.
GetNode().GetNodes() )
338 , m_pPoint( &m_Bound1 )
339 , m_pMark( m_pPoint )
340 , m_bIsInFrontOfLabel( false )
348 , m_pPoint( &m_Bound2 )
349 , m_pMark( &m_Bound1 )
350 , m_bIsInFrontOfLabel( false )
359 , m_pPoint( &m_Bound2 )
360 , m_pMark( &m_Bound1 )
361 , m_bIsInFrontOfLabel( false )
380 , m_pPoint( &m_Bound2 )
381 , m_pMark( &m_Bound1 )
382 , m_bIsInFrontOfLabel( false )
401 , m_pPoint( &m_Bound2 )
402 , m_pMark( &m_Bound1 )
403 , m_bIsInFrontOfLabel( false )
410 const SwNode& rPoint, sal_Int32 nPointContent,
SwPaM* pRing )
414 , m_pPoint( &m_Bound2 )
415 , m_pMark( &m_Bound1 )
416 , m_bIsInFrontOfLabel( false )
427 , m_Bound2( m_Bound1.nNode.
GetNode().GetNodes() )
428 , m_pPoint( &m_Bound1 )
429 , m_pMark( &m_Bound1 )
430 , m_bIsInFrontOfLabel( false )
438 , m_Bound1( rNodeIdx )
439 , m_Bound2( rNodeIdx.
GetNode().GetNodes() )
440 , m_pPoint( &m_Bound1 )
441 , m_pMark( &m_Bound1 )
442 , m_bIsInFrontOfLabel( false )
451 , m_Bound1( *(rPam.m_pPoint) )
452 , m_Bound2( *(rPam.m_pMark) )
453 , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
454 , m_bIsInFrontOfLabel( false )
505 const bool bRet = (*fnGo)( *
this, fnMove );
524 const SwPaM & rOrigRg)
526 std::unique_ptr<SwPaM> pPam;
528 pPam.reset(
new SwPaM(rOrigRg,
const_cast<SwPaM*
>(&rOrigRg)));
532 if( (pPam->GetMark()->*fnMove.
fnCmpOp)( *pPam->GetPoint() ) )
558 std::pair<Point, bool> tmp;
561 tmp.first = *pLayPos;
580 (pFly = rFrame.
FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
587 nullptr != ( pSectionFrame = rFrame.
FindSctFrame() )->GetSection() &&
590 pRet = pSectionFrame;
603 if ( pNd !=
nullptr )
606 std::pair<Point, bool>
const tmp(aTmpPt,
false);
613 const SwFrame* pPointEditInReadonlyFrame =
nullptr;
614 if ( pFrame !=
nullptr
621 else if( pNd !=
nullptr )
634 if ( pParentSectionNd !=
nullptr
649 if ( pNd !=
nullptr )
652 std::pair<Point, bool>
const tmp(aTmpPt,
false);
658 const SwFrame* pMarkEditInReadonlyFrame =
nullptr;
659 if ( pFrame !=
nullptr
666 else if( pNd !=
nullptr )
678 if ( !bRet && bFormView )
682 if ( pPointEditInReadonlyFrame != pMarkEditInReadonlyFrame )
691 if( nEndIdx <= nSttIdx )
710 OSL_ENSURE( rContent.
GetContentIdx(),
"where is the SectionNode?" );
712 if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
741 if ( ( pA == pB ) && bUnhandledMark )
745 if ((pA == pB) && (bAtStartA != bAtStartB))
751 bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
756 bRet = ( pA == nullptr ) || ( pB ==
nullptr ) || bAtStartA || bAtStartB;
763 bRet = !( pA !=
nullptr && !bAtStartA && !bAtStartB && pA == pB );
788 if (
SwTextNode const*
const pNode =
n.GetNode().GetTextNode())
790 if (
SwpHints const*
const pHints = pNode->GetpSwpHints())
792 for (
size_t i = 0;
i < pHints->Count(); ++
i)
825 auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
826 if (pTextContentControl)
830 std::shared_ptr<SwContentControl> pContentControl
832 if (pContentControl && !pContentControl->GetReadWrite())
834 bRet = pContentControl->GetCheckbox() || pContentControl->GetPicture();
848 bool const bInReadOnly,
SwRootFrame const*
const i_pLayout)
850 SwRootFrame const*
const pLayout(i_pLayout ? i_pLayout :
891 aPos.
nNode = bSrchForward ? *fal.second : *fal.first;
905 if (
nullptr == pFrame ||
1056 if( ( &aPosPara==&
fnParaStart &&
nullptr != ( pNd =
1058 ( &aPosPara==&
fnParaEnd &&
nullptr != ( pNd =
1089 nullptr == ( pNd = (*fnMove.
fnNds)( &rPos.
nNode,
true )) )
1097 return aSavePos != rPos;
1102 OUStringBuffer aResult;
1109 bool bIsStartNode =
true;
1112 const bool bIsEndNode = aNodeIndex ==
End()->
nNode;
1115 if (pTextNode !=
nullptr)
1121 const OUString& aTmpStr = pTextNode->
GetText();
1123 if (bIsStartNode || bIsEndNode)
1126 const sal_Int32 nStart = bIsStartNode
1129 const sal_Int32 nEnd = bIsEndNode
1131 : aTmpStr.getLength();
1133 aResult.append(aTmpStr.subView(nStart, nEnd-nStart));
1137 aResult.append(aTmpStr);
1147 bIsStartNode =
false;
1150 return aResult.makeStringAndClear();
1160 sal_Int32
const nStart(
1166 ?
End()->nContent.GetIndex() - nStart
1167 : pTextNode->Len() - nStart,
1177 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwPaM"));
1179 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"point"));
1181 (void)xmlTextWriterEndElement(pWriter);
1185 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"mark"));
1187 (void)xmlTextWriterEndElement(pWriter);
1190 (void)xmlTextWriterEndElement(pWriter);
1196 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
", mark " << *pam.
GetMark() <<
")";
1198 return s <<
"SwPaM (point " << *pam.
GetPoint() <<
")";
struct _xmlTextWriter * xmlTextWriterPtr
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual bool isBookmarkDeleted(SwPaM const &rPaM) const =0
check if the selection would delete a BOOKMARK
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
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...
void MakeStartIndex(SwIndex *pIdx)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
void MakeEndIndex(SwIndex *pIdx)
virtual sal_Int32 Len() const
SwSectionFormats & GetSections()
SwEditShell const * GetEditShell() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
IDocumentMarkAccess * getIDocumentMarkAccess()
::sw::DocumentSettingManager & GetDocumentSettingManager()
bool IsCursorInParagraphMetadataField() const
Returns true iff the cursor is within a paragraph metadata field.
SwFieldType * GetTyp() const
general base class for all free-flowing frames
SfxPoolItem subclass that wraps an SwContentControl.
std::shared_ptr< SwContentControl > GetContentControl()
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()
Marks a character position inside a document model node.
const SwIndexReg * GetIdxReg() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
sal_Int32 GetIndex() const
const SwFrame * Lower() const
Marks a node in the document model.
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 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.
static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex)
get section level at the given position
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.
SwContentNode * GetContentNode(bool bPoint=true) const
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
SwNode & GetNode(bool bPoint=true) const
virtual ~SwPaM() override
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
SwPosition * m_pPoint
points at either m_Bound1 or m_Bound2
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) 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.
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, enum GetTextAttrMode const eMode=DEFAULT) const
get the innermost text attribute covering position nIndex.
const OUString & GetText() const
@ PARENT
EXPAND : (Start < nIndex <= End)
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.
virtual OUString GetFieldname() const =0
virtual const SwPosition & GetMarkStart() const =0
static SwContentNode * GetContentNode(SwDoc &rDoc, SwNodeIndex &rIdx, 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.
std::unique_ptr< SwPaM > MakeRegion(SwMoveFnCollection const &fnMove, const SwPaM &rOrigRg)
make a new region
std::pair< SwTextNode *, SwTextNode * > GetFirstAndLastNode(SwRootFrame const &rLayout, SwNodeIndex const &rPos)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
constexpr OUStringLiteral ODF_UNHANDLED
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
bool GoPrevious(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
SwContentNode * GoNextNds(SwNodeIndex *pIdx, bool bChk)
bool GoInContentSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
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)
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)
bool GoInContentCellsSkipHidden(SwPaM &rPam, SwMoveFnCollection const &fnMove)
static CHKSECTION lcl_TstIdx(SwNodeOffset nSttIdx, SwNodeOffset nEndIdx, const SwNode &rEndNd)
static const SwFrame * lcl_FindEditInReadonlyFrame(const SwFrame &rFrame)
SwContentNode * GoPreviousNds(SwNodeIndex *pIdx, bool bChk)
void GoEndDoc(SwPosition *pPos)
bool GoNext(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
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)
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
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.
bool operator<(const SwPosition &) const
void dumpAsXml(xmlTextWriterPtr pWriter) const
bool operator>(const SwPosition &) const
bool operator>=(const SwPosition &) const
SwPosition(const SwNodeIndex &rNode, const SwIndex &rContent)
bool operator<=(const SwPosition &) const
bool operator==(const SwPosition &) const
SwDoc & GetDoc() const
Returns the document this position is in.
bool operator!=(const SwPosition &) const
const sal_uInt16 CRSR_SKIP_CELLS
const sal_uInt16 CRSR_SKIP_CHARS
const sal_uInt16 CRSR_SKIP_HIDDEN