43#include <unofield.hxx>
62#include <com/sun/star/container/XEnumeration.hpp>
72typedef std::pair< TextRangeList_t * const, SwTextAttr const * const >
PortionList_t;
77 uno::Reference< text::XText >
const& i_xParentText,
80 const sal_Int32 i_nStartPos,
const sal_Int32 i_nEndPos,
bool bOnlyTextFields );
88 struct SwXBookmarkPortion_Impl
90 Reference<XTextContent> xBookmark;
94 SwXBookmarkPortion_Impl(uno::Reference<text::XTextContent> xMark,
96 : xBookmark (
std::move( xMark ))
98 , aPosition (
std::move( _aPosition ))
101 sal_Int32 getIndex ()
const
106 typedef std::shared_ptr < SwXBookmarkPortion_Impl > SwXBookmarkPortion_ImplSharedPtr;
107 struct BookmarkCompareStruct
109 bool operator () (
const SwXBookmarkPortion_ImplSharedPtr &r1,
110 const SwXBookmarkPortion_ImplSharedPtr &r2 )
const
125 return r1->aPosition < r2->aPosition;
128 typedef std::multiset < SwXBookmarkPortion_ImplSharedPtr, BookmarkCompareStruct > SwXBookmarkPortion_ImplList;
131 void lcl_FillBookmark(
sw::mark::IMark*
const pBkmk,
const SwNode& rOwnNode,
SwDoc& rDoc, SwXBookmarkPortion_ImplList& rBkmArr)
136 if(rStartPos.
GetNode() == rOwnNode)
140 BkmType
const nType = (hasOther || pCrossRefMark)
141 ? BkmType::Start : BkmType::StartEnd;
142 rBkmArr.insert(std::make_shared<SwXBookmarkPortion_Impl>(
148 if(rEndPos.
GetNode() != rOwnNode)
151 std::optional<SwPosition> oCrossRefEndPos;
158 else if (pCrossRefMark)
162 oCrossRefEndPos.emplace(rEndNd, rEndNd.
Len());
163 pEndPos = &*oCrossRefEndPos;
167 rBkmArr.insert(std::make_shared<SwXBookmarkPortion_Impl>(
169 BkmType::End, *pEndPos));
173 void lcl_FillBookmarkArray(
SwDoc& rDoc,
SwUnoCursor& rUnoCursor, SwXBookmarkPortion_ImplList& rBkmArr)
183 for (
const SwContentIndex* pIndex = pTextNode->GetFirstIndex(); pIndex; pIndex = pIndex->GetNext())
195 if (!aSeenMarks.
insert(pBkmk).second)
197 lcl_FillBookmark(pBkmk, *pTextNode, rDoc, rBkmArr);
201 struct SwAnnotationStartPortion_Impl
204 uno::Reference< text::XTextField > mxAnnotationField;
207 SwAnnotationStartPortion_Impl(
208 uno::Reference< text::XTextField > xAnnotationField,
210 : mxAnnotationField (
std::move( xAnnotationField ))
215 sal_Int32 getIndex ()
const
220 typedef std::shared_ptr < SwAnnotationStartPortion_Impl > SwAnnotationStartPortion_ImplSharedPtr;
221 struct AnnotationStartCompareStruct
223 bool operator () (
const SwAnnotationStartPortion_ImplSharedPtr &r1,
224 const SwAnnotationStartPortion_ImplSharedPtr &r2 )
227 return r1->maPosition < r2->maPosition;
230 typedef std::multiset < SwAnnotationStartPortion_ImplSharedPtr, AnnotationStartCompareStruct > SwAnnotationStartPortion_ImplList;
232 void lcl_FillAnnotationStartArray(
235 SwAnnotationStartPortion_ImplList& rAnnotationStartArr )
252 ppMark != pCandidatesEnd;
258 if (!pAnnotationMark)
262 if (rStartPos.
GetNode() != rOwnNode)
266 if (!pAnnotationFormatField)
268 SAL_WARN(
"sw.core",
"missing annotation format field");
272 rAnnotationStartArr.insert(
273 std::make_shared<SwAnnotationStartPortion_Impl>(
275 pAnnotationFormatField),
283 return "SwXTextPortionEnumeration";
294 return {
"com.sun.star.text.TextPortionEnumeration" };
299 uno::Reference< XText >
const & xParentText,
300 const sal_Int32 nStart,
301 const sal_Int32 nEnd,
302 bool bOnlyTextFields)
306 OSL_ENSURE(nEnd == -1 || (nStart <= nEnd &&
308 "start or end value invalid!");
319 : m_Portions(
std::move(rPortions) )
346 throw container::NoSuchElementException();
356 const sal_Int32 i_nStartPos)
360 if (!pTextNode)
return;
364 sal_Int32
pos = std::max(
static_cast<sal_Int32
>(0), i_nStartPos);
365 while ((
pos = ::comphelper::string::indexOfAny(pTextNode->
GetText(), fld,
pos)) != -1)
367 rFieldMarks.push_back(
pos);
372static uno::Reference<text::XTextRange>
374 uno::Reference< text::XText >
const & i_xParentText,
378 uno::Reference<text::XTextRange> xRef;
383 "hmm --- why is this different");
385 pUnoCursor->
Right(1);
388 OSL_FAIL(
"cannot move cursor?");
395 ::sw::mark::IFieldmark* pFieldmark =
nullptr;
397 getFieldmarkAt(*pUnoCursor->
GetMark());
403 pPortion->SetBookmark(
415 ::sw::mark::IFieldmark* pFieldmark =
nullptr;
417 getFieldmarkAt(*pUnoCursor->
GetMark());
423 pPortion->SetBookmark(
429 ::sw::mark::IFieldmark* pFieldmark =
436 pPortion->SetBookmark(
442 OSL_FAIL(
"no fieldmark found?");
447static Reference<XTextRange>
449 Reference<XText>
const& xParent,
456 Reference<XTextContent> xContent;
466 pPortion->SetRefMark(xContent);
467 pPortion->SetCollapsed(rAttr.
End() ==
nullptr);
472 pPortion->SetRefMark(xContent);
480 Reference<XText>
const& xParent,
485 static_txtattr_cast<const SwTextRuby&>(rAttr), xParent, bEnd);
486 rPortions.emplace_back(pPortion);
487 pPortion->SetCollapsed(rAttr.
End() ==
nullptr);
490static Reference<XTextRange>
492 Reference<XText>
const& xParent,
499 const Reference<XTextContent> xContent =
506 pPortion->SetTOXMark(xContent);
507 pPortion->SetCollapsed(rAttr.
GetEnd() ==
nullptr);
512 pPortion->SetTOXMark(xContent);
517static uno::Reference<text::XTextRange>
519 uno::Reference<text::XText>
const& xParent,
521 SwTextAttr & rAttr, std::unique_ptr<TextRangeList_t const> && pPortions)
525 xParent, std::move(pPortions)));
529 const uno::Reference<text::XTextContent> xContent(xMeta,
532 pPortion->SetMeta(xContent);
536 const uno::Reference<text::XTextField> xField(xMeta, uno::UNO_QUERY);
538 pPortion->SetTextField(xField);
544static uno::Reference<text::XTextRange>
547 std::unique_ptr<const TextRangeList_t>&& pPortions)
551 std::move(pPortions));
554 pPortion->SetContentControl(xContentControl);
574 Reference<XText>
const& xParent,
576 SwXBookmarkPortion_ImplList& rBkmArr,
577 const sal_Int32 nIndex,
579 bool bOnlyFrameStarts)
581 for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end(); aIter != aEnd; )
583 const SwXBookmarkPortion_ImplSharedPtr& pPtr = *aIter;
584 if (
nIndex > pPtr->getIndex() )
586 if (bOnlyFrameStarts)
589 aIter = rBkmArr.erase(aIter);
592 if ( nIndex < pPtr->getIndex() )
595 if ((BkmType::Start == pPtr->nBkmType && bOnlyFrameStarts) ||
596 (BkmType::StartEnd == pPtr->nBkmType))
598 bool bFrameStart = rFramePositions.
find(
nIndex) != rFramePositions.
end();
599 bool bEnd = pPtr->nBkmType == BkmType::StartEnd && bFrameStart && !bOnlyFrameStarts;
600 if (pPtr->nBkmType == BkmType::Start || bFrameStart || !bOnlyFrameStarts)
611 rPortions.emplace_back(pPortion);
612 pPortion->SetBookmark(pPtr->xBookmark);
613 pPortion->SetCollapsed( BkmType::StartEnd == pPtr->nBkmType && !bFrameStart );
616 else if (BkmType::End == pPtr->nBkmType && !bOnlyFrameStarts)
620 rPortions.emplace_back(pPortion);
621 pPortion->SetBookmark(pPtr->xBookmark);
625 if (bOnlyFrameStarts)
628 aIter = rBkmArr.erase(aIter);
634 Reference<XText>
const& xParent,
637 const sal_Int32 nIndex)
639 for (
auto aIter = rBreakArr.
begin(); aIter != rBreakArr.
end(); )
643 aIter = rBreakArr.
erase(aIter);
651 aIter = rBreakArr.
erase(aIter);
657struct SwXRedlinePortion_Impl
662 SwXRedlinePortion_Impl (
const SwRangeRedline* pRed,
const bool bIsStart )
668 sal_Int32 getRealIndex ()
const
677typedef std::shared_ptr < SwXRedlinePortion_Impl >
682struct RedlineCompareStruct
686 return *(r->m_bStart ? r->m_pRedline->Start() : r->m_pRedline->End());
692 return getPosition ( r1 ) < getPosition ( r2 );
698typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct >
701static Reference<XTextRange>
704 const Reference<XText> & xParent,
707 const sal_Int32 i_nStartPos,
708 const sal_Int32 i_nEndPos,
709 const sal_Int32 nCurrentIndex,
710 const bool bRightMoveForbidden,
711 bool & o_rbCursorMoved,
712 sal_Int32 & o_rNextAttrPosition)
716 Reference<XTextRange> xRef;
719 size_t nEndIndex = 0;
720 const auto nHintsCount = pHints->
Count();
723 if (nEndIndex >= nHintsCount)
726 const sal_Int32* pAttrEnd = pAttr->
GetEnd();
727 sal_Int32 nNextEnd = 0;
729 nCurrentIndex < (nNextEnd = (*pAttrEnd)))
733 if (nNextEnd == nCurrentIndex)
735 const sal_uInt16 nWhich( pAttr->
Which() );
741 xParent, pUnoCursor, *pAttr,
true);
742 rPortionStack.top().first->push_back(xTmp);
748 xParent, pUnoCursor, *pAttr,
true);
749 rPortionStack.top().first->push_back(xTmp);
757 xParent, pUnoCursor, *pAttr,
false);
760 xParent, pUnoCursor, *pAttr,
true);
767 if ((i_nStartPos > 0) &&
775 if (pAttr->
GetStart() + 1 == i_nStartPos)
777 nEndIndex = pHints->
Count() - 1;
782 if (
Top.second != pAttr)
784 OSL_FAIL(
"ExportHints: stack error" );
788 std::unique_ptr<const TextRangeList_t>
789 pCurrentPortions(
Top.first);
791 const uno::Reference<text::XTextRange> xPortion(
793 *pAttr, std::move(pCurrentPortions)));
794 rPortionStack.top().first->push_back(xPortion);
802 SAL_WARN(
"sw.core",
"lcl_ExportHints: empty content control");
804 if ((i_nStartPos > 0) && (pAttr->
GetStart() < i_nStartPos))
808 if (pAttr->
GetStart() + 1 == i_nStartPos)
810 nEndIndex = pHints->
Count() - 1;
815 if (
Top.second != pAttr)
817 SAL_WARN(
"sw.core",
"lcl_ExportHints: content control is not at the "
818 "top of the portion stack");
822 std::unique_ptr<const TextRangeList_t> pCurrentPortions(
Top.first);
824 uno::Reference<text::XTextRange> xPortion(
826 std::move(pCurrentPortions)));
827 rPortionStack.top().first->push_back(xPortion);
838 size_t nStartIndex = 0;
839 sal_Int32 nNextStart = 0;
840 while(nStartIndex < nHintsCount &&
841 nCurrentIndex >= (nNextStart = pHints->
Get(nStartIndex)->
GetStart()))
844 sal_uInt16 nAttrWhich = pAttr->
Which();
845 if (nNextStart == nCurrentIndex)
850 if(!bRightMoveForbidden)
852 pUnoCursor->
Right(1);
859 Reference<XTextField>
const xField =
862 pPortion->SetTextField(xField);
867 if(!bRightMoveForbidden)
869 pUnoCursor->
Right(1);
875 if ( pAnnotationMark !=
nullptr )
879 rDoc, pAnnotationMark));
885 Reference<XTextField> xField =
888 pPortion->SetTextField(xField);
895 if(!bRightMoveForbidden)
905 Reference<XTextField> xField =
908 pPortion->SetTextField(xField);
913 if(!bRightMoveForbidden)
915 pUnoCursor->
Right(1);
930 if(!bRightMoveForbidden)
932 pUnoCursor->
Right(1);
938 Reference<XFootnote> xContent =
940 pPortion->SetFootnote(xContent);
948 bool bIsPoint = !(pAttr->
GetEnd());
949 if (!bRightMoveForbidden || !bIsPoint)
953 pUnoCursor->
Right(1);
955 Reference<XTextRange> xTmp =
958 xParent, pUnoCursor, *pAttr,
false)
960 xParent, pUnoCursor, *pAttr,
false);
969 rPortionStack.top().first->push_back(xTmp);
979 xParent, pUnoCursor, *pAttr,
false);
987 if (!bRightMoveForbidden)
989 pUnoCursor->
Right(1);
990 o_rbCursorMoved =
true;
992 if ((i_nEndPos < 0) ||
993 (*pAttr->
GetEnd() <= i_nEndPos))
995 rPortionStack.push( std::make_pair(
1002 if (!bRightMoveForbidden)
1004 pUnoCursor->
Right(1);
1010 uno::Reference<text::XTextContent> xLineBreak
1013 pPortion->SetLineBreak(xLineBreak);
1021 OSL_FAIL(
"unknown attribute");
1030 o_rbCursorMoved =
true;
1032 if (!o_rbCursorMoved)
1039 while(nStartIndex < pHints->
Count() &&
1040 nCurrentIndex >= (nNextStart = pHints->
Get(nStartIndex)->
GetStart()))
1044 sal_Int32 nNextEnd = 0;
1045 while(nEndIndex < pHints->
Count() &&
1049 sal_Int32 nNextPos =
1050 ((nNextStart > nCurrentIndex) && (nNextStart < nNextEnd))
1051 ? nNextStart : nNextEnd;
1052 if (nNextPos > nCurrentIndex)
1054 o_rNextAttrPosition = nNextPos;
1061 const sal_Int32 nCurrentIndex,
1062 const sal_Int32 nNextFrameIndex,
1063 const sal_Int32 nNextPortionIndex,
1064 const sal_Int32 nNextAttrIndex,
1065 const sal_Int32 nNextMarkIndex,
1066 const sal_Int32 nEndPos )
1070 if ((nEndPos >= 0) && (nEndPos < nMovePos))
1075 if ((nNextFrameIndex >= 0) && (nNextFrameIndex < nMovePos))
1077 nMovePos = nNextFrameIndex;
1080 if ((nNextPortionIndex >= 0) && (nNextPortionIndex < nMovePos))
1082 nMovePos = nNextPortionIndex;
1085 if ((nNextAttrIndex >= 0) && (nNextAttrIndex < nMovePos))
1087 nMovePos = nNextAttrIndex;
1090 if ((nNextMarkIndex >= 0) && (nNextMarkIndex < nMovePos))
1092 nMovePos = nNextMarkIndex;
1095 if (nMovePos > nCurrentIndex)
1107 const size_t nRedTableCount = rRedTable.
size();
1109 if ( nRedTableCount <= 0 )
1116 for(; nRed < nRedTableCount; ++nRed)
1119 auto [pRedStart, pRedEnd]= pRedline->
StartEnd();
1120 if ( rOwnNode == pRedStart->GetNode() )
1121 rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
1123 if( pRedline->
HasMark() && pRedEnd->GetNode() == rOwnNode )
1124 rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
1125 pRedline,
false ) );
1141 Reference<XText>
const& xParent,
1144 const sal_Int32 nIndex)
1149 for ( SwXRedlinePortion_ImplList::iterator aIter = rRedlineArr.begin(), aEnd = rRedlineArr.end();
1153 sal_Int32 nRealIndex = pPtr->getRealIndex();
1155 if (
nIndex > nRealIndex )
1156 aIter = rRedlineArr.erase(aIter);
1158 else if (
nIndex == nRealIndex )
1161 *pPtr->m_pRedline, pUnoCursor, xParent, pPtr->m_bStart));
1162 aIter = rRedlineArr.erase(aIter);
1172 Reference<XText>
const & xParent,
1174 SwXBookmarkPortion_ImplList& rBkmArr,
1177 const sal_Int32 nIndex,
1179 bool bOnlyFrameBookmarkStarts)
1181 if (!rBkmArr.empty())
1183 bOnlyFrameBookmarkStarts);
1185 if (bOnlyFrameBookmarkStarts)
1190 if (!rRedlineArr.empty())
1193 if (!rBreakArr.
empty())
1210 Reference<XText>
const & xParent,
1212 SwAnnotationStartPortion_ImplList& rAnnotationStartArr,
1213 const sal_Int32 nIndex,
1217 for ( SwAnnotationStartPortion_ImplList::iterator aIter = rAnnotationStartArr.begin(), aEnd = rAnnotationStartArr.end();
1220 SwAnnotationStartPortion_ImplSharedPtr pPtr = *aIter;
1221 if (
nIndex > pPtr->getIndex() )
1223 aIter = rAnnotationStartArr.erase(aIter);
1226 if ( pPtr->getIndex() >
nIndex )
1231 bool bFrameStart = rFramePositions.
find(
nIndex) != rFramePositions.
end();
1232 if (bFrameStart || !bOnlyFrame)
1236 pPortion->SetTextField( pPtr->mxAnnotationField );
1237 rPortions.emplace_back(pPortion);
1239 aIter = rAnnotationStartArr.erase(aIter);
1250 for (
const auto& rFrame : rFrames)
1252 if (rFrame.nIndex < nCurrentIndex)
1255 if (rFrame.nIndex > nCurrentIndex)
1258 const auto pFrame =
static_cast<const SwFrameFormat*
>(rFrame.pFrameClient->GetRegisteredIn());
1279 Reference<XText>
const & i_xParent,
1282 sal_Int32
const i_nCurrentIndex)
1286 while (!i_rFrames.empty() && i_rFrames.front().nIndex < i_nCurrentIndex)
1287 i_rFrames.pop_front();
1290 while (!i_rFrames.empty() && (i_rFrames.front().nIndex == i_nCurrentIndex))
1293 auto pFrame =
static_cast<SwFrameFormat*
>(i_rFrames.front().pFrameClient->GetRegisteredIn());
1297 rPortions.emplace_back(pPortion);
1299 i_rFrames.pop_front();
1302 return !i_rFrames.empty() ? i_rFrames.front().nIndex : -1;
1306 SwXBookmarkPortion_ImplList
const & rBkmArr,
1310 sal_Int32 nRet = -1;
1311 if(!rBkmArr.empty())
1313 SwXBookmarkPortion_ImplSharedPtr pPtr = *rBkmArr.begin();
1314 nRet = pPtr->getIndex();
1316 if(!rRedlineArr.empty())
1319 sal_Int32 nTmp = pPtr->getRealIndex();
1320 if(nRet < 0 || nTmp < nRet)
1323 if(!rBreakArr.
empty())
1325 if(nRet < 0 || *rBreakArr.
begin() < nRet)
1326 nRet = *rBreakArr.
begin();
1333 uno::Reference< text::XText >
const & i_xParentText,
1336 const sal_Int32 i_nStartPos,
1337 const sal_Int32 i_nEndPos,
1338 bool bOnlyTextFields )
1344 if ((i_nStartPos > 0) &&
1349 (i_nStartPos <= pUnoCursor->
Start()->
GetNode().GetTextNode()->
1350 GetText().
getLength()),
"Incorrect start position" );
1352 pUnoCursor->
Right(i_nStartPos);
1357 std::deque<sal_Int32> FieldMarks;
1358 if (!bOnlyTextFields)
1361 SwXBookmarkPortion_ImplList Bookmarks;
1362 if (!bOnlyTextFields)
1363 lcl_FillBookmarkArray(rDoc, *pUnoCursor, Bookmarks);
1366 if (!bOnlyTextFields)
1370 if (!bOnlyTextFields)
1373 SwAnnotationStartPortion_ImplList AnnotationStarts;
1374 if (!bOnlyTextFields)
1375 lcl_FillAnnotationStartArray( rDoc, *pUnoCursor, AnnotationStarts );
1380 bool bAtEnd(
false );
1392 OSL_FAIL(
"lcl_CreatePortions: no TextNode - what now ?");
1397 const sal_Int32 nCurrentIndex =
1401 uno::Reference< XTextRange > xRef;
1412 pUnoCursor, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex, aFramePositions,
true );
1415 *PortionStack.top().first,
1423 const sal_Int32 nFirstFrameIndex =
1425 i_xParentText, pUnoCursor, i_rFrames, nCurrentIndex);
1430 pUnoCursor, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex, aFramePositions,
false );
1433 *PortionStack.top().first,
1441 bool bCursorMoved(
false );
1442 sal_Int32 nNextAttrIndex = -1;
1445 bAtEnd = ((i_nEndPos >= 0) && (nCurrentIndex >= i_nEndPos))
1446 || (nCurrentIndex >= pTextNode->
Len());
1451 pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd,
1452 bCursorMoved, nNextAttrIndex);
1453 if (PortionStack.empty())
1455 OSL_FAIL(
"CreatePortions: stack underflow");
1460 if (!xRef.is() && !bCursorMoved)
1463 !FieldMarks.empty() && (FieldMarks.front() == nCurrentIndex))
1467 FieldMarks.pop_front();
1472 OSL_ENSURE(FieldMarks.empty() ||
1473 (FieldMarks.front() != nCurrentIndex),
1474 "fieldmark and hint with CH_TXTATR at same pos?");
1477 if (!bAtEnd && !xRef.is() && !bCursorMoved)
1479 const sal_Int32 nNextPortionIndex =
1482 sal_Int32 nNextMarkIndex = ( !FieldMarks.empty() ? FieldMarks.front() : -1 );
1483 if ( !AnnotationStarts.empty()
1484 && ( nNextMarkIndex == -1
1485 || (*AnnotationStarts.begin())->getIndex() < nNextMarkIndex ) )
1487 nNextMarkIndex = (*AnnotationStarts.begin())->getIndex();
1501 else if (bAtEnd && !xRef.is() && !pTextNode->
Len())
1507 else if (bAtEnd && !xRef.is() && pHints)
1511 for (
size_t i = 0;
i < pHints->
Count(); ++
i)
1530 PortionStack.top().first->push_back(xRef);
1534 OSL_ENSURE((PortionStack.size() == 1) && !PortionStack.top().second,
1535 "CreatePortions: stack error" );
geometry::RealPoint2D maPosition
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides access to the marks of a document.
virtual const_iterator_t getAnnotationMarksBegin() const =0
virtual ::sw::mark::IFieldmark * getFieldmarkAt(const SwPosition &rPos) const =0
get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
virtual sal_Int32 getAnnotationMarksCount() const =0
virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition &rPos) const =0
Finds the first mark that is starting after.
@ CROSSREF_NUMITEM_BOOKMARK
@ CROSSREF_HEADING_BOOKMARK
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
virtual sal_Int32 getBookmarksCount() const =0
returns the number of IBookmarks.
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
virtual const SwRedlineTable & GetRedlineTable() const =0
Marks a character position inside a document model content node (SwContentNode)
virtual sal_Int32 Len() const
bool Right(sal_uInt16 nCnt)
void cleanupUnoCursorTable() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentMarkAccess * getIDocumentMarkAccess()
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
SfxPoolItem subclass that wraps an SwContentControl.
const std::shared_ptr< SwContentControl > & GetContentControl() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwContentNode * GetContentNode()
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
SwNode & GetPointNode() const
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
SwContentNode * GetPointContentNode() const
const SwPosition * End() const
const SwPosition * GetPoint() const
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
vector_type::size_type size_type
::sw::mark::IMark * GetAnnotationMark() const
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SfxPoolItem & GetAttr() const
sal_Int32 GetAnyEnd() const
end (if available), else start
virtual const sal_Int32 * GetEnd() const
end position
const sal_Int32 * End() const
const SwFormatFlyCnt & GetFlyCnt() const
const SwFormatLineBreak & GetLineBreak() const
const SwFormatFootnote & GetFootnote() const
sal_Int32 GetStart() const
const SwFormatField & GetFormatField() const
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
SwTextNode is a paragraph in the document model.
virtual sal_Int32 Len() const override
void fillSoftPageBreakList(SwSoftPageBreakList &rBreak) const
SwpHints * GetpSwpHints()
const OUString & GetText() const
static rtl::Reference< SwXBookmark > CreateXBookmark(SwDoc &rDoc, ::sw::mark::IMark *pBookmark)
static rtl::Reference< SwXContentControl > CreateXContentControl(SwContentControl &rContentControl, const css::uno::Reference< css::text::XText > &xParentText=nullptr, std::unique_ptr< const TextRangeList_t > &&pPortions=std::unique_ptr< const TextRangeList_t >())
static rtl::Reference< SwXDocumentIndexMark > CreateXDocumentIndexMark(SwDoc &rDoc, SwTOXMark *pMark, TOXTypes eType=TOX_INDEX)
static rtl::Reference< SwXBookmark > CreateXFieldmark(SwDoc &rDoc, ::sw::mark::IMark *pMark, bool isReplacementObject=false)
static rtl::Reference< SwXLineBreak > CreateXLineBreak(SwFormatLineBreak *pLineBreakFormat)
static rtl::Reference< SwXReferenceMark > CreateXReferenceMark(SwDoc &rDoc, SwFormatRefMark *pMarkFormat)
static rtl::Reference< SwXTextField > CreateXTextField(SwDoc *pDoc, SwFormatField const *pFormat, SwServiceType nServiceId=SwServiceType::Invalid)
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL nextElement() override
SwXTextPortionEnumeration(SwPaM &rParaCursor, css::uno::Reference< css::text::XText > const &xParent, const sal_Int32 nStart, const sal_Int32 nEnd, bool bOnlyTextFields=false)
TextRangeList_t m_Portions
virtual sal_Bool SAL_CALL hasMoreElements() override
virtual ~SwXTextPortionEnumeration() override
sw::UnoCursorPointer m_pUnoCursor
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
An SwTextAttr container, stores all directly formatted text portions for a text node.
SwTextAttr * Get(size_t nPos) const
SwTextAttr * GetSortedByEnd(size_t nPos) const
const_iterator begin() const
const_iterator find(const Value &x) const
size_type erase(const Value &x)
const_iterator end() const
std::pair< const_iterator, bool > insert(Value &&x)
void reset(std::shared_ptr< SwUnoCursor > pNew)
const SwFormatField * GetAnnotationFormatField() const
virtual bool IsExpanded() const =0
virtual const SwPosition & GetMarkEnd() const =0
virtual const SwPosition & GetMarkStart() const =0
SwPosition & GetMarkStart() const override
#define CH_TXT_ATR_FIELDSEP
#define CH_TXT_ATR_FORMELEMENT
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SwFormatLineBreak > RES_TXTATR_LINEBREAK(61)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
#define CH_TXT_ATR_FIELDEND
#define CH_TXT_ATR_FIELDSTART
#define SAL_WARN(area, stream)
void SelectPam(SwPaM &rPam, const bool bExpand)
double getLength(const B2DPolygon &rCandidate)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
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.
Marks a position in the document model.
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
sal_Int32 GetContentIndex() const
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t
std::deque< FrameClientSortListEntry > FrameClientSortList_t
void CollectFrameAtNode(const SwNode &rNd, FrameClientSortList_t &rFrames, const bool bAtCharAnchoredObjs)
@ PORTION_CONTENT_CONTROL
@ PORTION_FIELD_START_END
static void lcl_FillSoftPageBreakArray(SwUnoCursor const &rUnoCursor, SwSoftPageBreakList &rBreakArr)
static void lcl_MoveCursor(SwUnoCursor *const pUnoCursor, const sal_Int32 nCurrentIndex, const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, const sal_Int32 nNextAttrIndex, const sal_Int32 nNextMarkIndex, const sal_Int32 nEndPos)
std::multiset< SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList
static void lcl_FillRedlineArray(SwDoc const &rDoc, SwUnoCursor const &rUnoCursor, SwXRedlinePortion_ImplList &rRedArr)
static Reference< XTextRange > lcl_CreateTOXMarkPortion(Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwTextAttr &rAttr, const bool bEnd)
static uno::Reference< text::XTextRange > lcl_CreateContentControlPortion(const uno::Reference< text::XText > &xParent, const SwUnoCursor *pUnoCursor, SwTextAttr &rAttr, std::unique_ptr< const TextRangeList_t > &&pPortions)
Creates a text portion that has a non-empty ContentControl property.
static void lcl_ExtractFramePositions(FrameClientSortList_t &rFrames, sal_Int32 nCurrentIndex, o3tl::sorted_vector< sal_Int32 > &rFramePositions)
Fills character positions from rFrames into rFramePositions.
static void lcl_FillFieldMarkArray(std::deque< sal_Int32 > &rFieldMarks, SwUnoCursor const &rUnoCursor, const sal_Int32 i_nStartPos)
static uno::Reference< text::XTextRange > lcl_ExportFieldMark(uno::Reference< text::XText > const &i_xParentText, SwUnoCursor *const pUnoCursor, const SwTextNode *const pTextNode)
std::pair< TextRangeList_t *const, SwTextAttr const *const > PortionList_t
static void lcl_ExportAnnotationStarts(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwAnnotationStartPortion_ImplList &rAnnotationStartArr, const sal_Int32 nIndex, const o3tl::sorted_vector< sal_Int32 > &rFramePositions, bool bOnlyFrame)
Exports all start annotation marks from rAnnotationStartArr into rPortions that have the same start p...
static Reference< XTextRange > lcl_CreateRefMarkPortion(Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, const SwTextAttr &rAttr, const bool bEnd)
static Reference< XTextRange > lcl_ExportHints(PortionStack_t &rPortionStack, const Reference< XText > &xParent, SwUnoCursor *const pUnoCursor, SwpHints const *const pHints, const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos, const sal_Int32 nCurrentIndex, const bool bRightMoveForbidden, bool &o_rbCursorMoved, sal_Int32 &o_rNextAttrPosition)
static void lcl_ExportRedline(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwXRedlinePortion_ImplList &rRedlineArr, const sal_Int32 nIndex)
static void lcl_ExportSoftPageBreak(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwSoftPageBreakList &rBreakArr, const sal_Int32 nIndex)
static void lcl_ExportBookmark(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwXBookmarkPortion_ImplList &rBkmArr, const sal_Int32 nIndex, const o3tl::sorted_vector< sal_Int32 > &rFramePositions, bool bOnlyFrameStarts)
Exports all bookmarks from rBkmArr into rPortions that have the same start or end position as nIndex.
static sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList const &rBkmArr, SwXRedlinePortion_ImplList const &rRedlineArr, SwSoftPageBreakList const &rBreakArr)
static void lcl_InsertRubyPortion(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, const SwTextAttr &rAttr, const bool bEnd)
std::shared_ptr< SwXRedlinePortion_Impl > SwXRedlinePortion_ImplSharedPtr
static uno::Reference< text::XTextRange > lcl_CreateMetaPortion(uno::Reference< text::XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwTextAttr &rAttr, std::unique_ptr< TextRangeList_t const > &&pPortions)
std::stack< PortionList_t > PortionStack_t
static void lcl_ExportBkmAndRedline(TextRangeList_t &rPortions, Reference< XText > const &xParent, const SwUnoCursor *const pUnoCursor, SwXBookmarkPortion_ImplList &rBkmArr, SwXRedlinePortion_ImplList &rRedlineArr, SwSoftPageBreakList &rBreakArr, const sal_Int32 nIndex, const o3tl::sorted_vector< sal_Int32 > &rFramePositions, bool bOnlyFrameBookmarkStarts)
static sal_Int32 lcl_ExportFrames(TextRangeList_t &rPortions, Reference< XText > const &i_xParent, SwUnoCursor const *const i_pUnoCursor, FrameClientSortList_t &i_rFrames, sal_Int32 const i_nCurrentIndex)
Exports at-char anchored frames.
static void lcl_CreatePortions(TextRangeList_t &i_rPortions, uno::Reference< text::XText > const &i_xParentText, SwUnoCursor *pUnoCursor, FrameClientSortList_t &i_rFrames, const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos, bool bOnlyTextFields)