28#include <UndoManager.hxx>
66#include <bookmark.hxx>
87#include <com/sun/star/i18n/Boundary.hpp>
88#include <com/sun/star/i18n/WordType.hpp>
89#include <com/sun/star/i18n/XBreakIterator.hpp>
90#include <com/sun/star/embed/XEmbeddedObject.hpp>
110 ((RndStdIds::FLY_AS_CHAR == pAnchor->
GetAnchorId()) ||
111 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId()) ||
112 (RndStdIds::FLY_AT_FLY == pAnchor->
GetAnchorId()) ||
113 (RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId())) &&
114 nSttNd <= pAnchorNode->GetIndex() &&
124 nInsNd < pSNd->EndOfSectionIndex() )
128 if( lcl_ChkFlyFly( rDoc, pSNd->
GetIndex(),
143 == rStart.GetNodeIndex())
183 while( rLastIdx.
GetIndex() < nNewIdx );
188 while( rLastIdx.
GetIndex() > nNewIdx )
201 void lcl_SetCpyPos(
const SwPosition& rOrigPos,
243 std::vector< const ::sw::mark::IMark* > vMarksToCopy;
248 const ::sw::mark::IMark*
const pMark = *ppMark;
250 const SwPosition& rMarkStart = pMark->GetMarkStart();
251 const SwPosition& rMarkEnd = pMark->GetMarkEnd();
254 bool const isIncludeStart(
260 || rMarkStart != rStt);
261 bool const isIncludeEnd(
262 (rEnd.GetNode().IsTextNode()
263 && rEnd.GetContentIndex() == rEnd.GetNode().GetTextNode()->Len())
264 || rMarkEnd != rEnd);
265 const bool bIsNotOnBoundary =
267 ? (isIncludeStart || isIncludeEnd)
268 : (isIncludeStart && isIncludeEnd);
270 if ( rMarkStart >= rStt && rMarkEnd <= rEnd
271 && ( bIsNotOnBoundary
278 vMarksToCopy.push_back(pMark);
283 SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
286 SwPaM aTmpPam(*pCpyStt);
287 lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetMarkPos().GetNodeIndex(), nDelCount);
288 lcl_SetCpyPos( pMark->GetMarkPos(), rStt, *pCpyStt, *aTmpPam.
GetPoint(), nDelCount);
289 if(pMark->IsExpanded())
292 lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetOtherMarkPos().GetNodeIndex(), nDelCount);
293 lcl_SetCpyPos(pMark->GetOtherMarkPos(), rStt, *pCpyStt, *aTmpPam.
GetMark(), nDelCount);
296 OUString sRequestedName = pMark->GetName();
299 assert(&rSrcDoc == &rDestDoc);
303 sRequestedName +
"COPY_IS_MOVE");
313 if (pNewMark ==
nullptr)
324 const ::sw::mark::IBookmark*
const pOldBookmark =
326 if (pNewBookmark && pOldBookmark)
328 pNewBookmark->
SetKeyCode(pOldBookmark->GetKeyCode());
329 pNewBookmark->
SetShortName(pOldBookmark->GetShortName());
330 pNewBookmark->
Hide(pOldBookmark->IsHidden());
333 ::sw::mark::IFieldmark*
const pNewFieldmark =
334 dynamic_cast< ::sw::mark::IFieldmark*
const >(pNewMark);
335 const ::sw::mark::IFieldmark*
const pOldFieldmark =
336 dynamic_cast< const ::sw::mark::IFieldmark*
>(pMark);
337 if (pNewFieldmark && pOldFieldmark)
339 pNewFieldmark->SetFieldname(pOldFieldmark->GetFieldname());
340 pNewFieldmark->SetFieldHelptext(pOldFieldmark->GetFieldHelptext());
341 ::sw::mark::IFieldmark::parameter_map_t* pNewParams = pNewFieldmark->GetParameters();
342 const ::sw::mark::IFieldmark::parameter_map_t* pOldParams = pOldFieldmark->GetParameters();
343 for (
const auto& rEntry : *pOldParams )
345 pNewParams->insert( rEntry );
349 ::sfx2::Metadatable
const*
const pMetadatable(
350 dynamic_cast< ::sfx2::Metadatable const*
>(pMark));
351 ::sfx2::Metadatable *
const pNewMetadatable(
352 dynamic_cast< ::sfx2::Metadatable *
>(pNewMark));
353 if (pMetadatable && pNewMetadatable)
355 pNewMetadatable->RegisterAsCopyOf(*pMetadatable);
363 void lcl_DeleteRedlines(
const SwPaM& rPam,
SwPaM& rCpyPam )
372 std::unique_ptr<SwPaM> pDelPam;
373 auto [pStt, pEnd] = rPam.
StartEnd();
376 SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
380 for( ;
n < rTable.
size(); ++
n )
385 auto [pRStt, pREnd] = pRedl->
StartEnd();
403 pDelPam.reset(
new SwPaM( *pCpyStt, pDelPam.release() ));
406 lcl_NonCopyCount( rPam, aCorrIdx, pRStt->GetNodeIndex(), nDelCount );
407 lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
408 *pDelPam->GetPoint(), nDelCount );
413 *pDelPam->GetPoint() = *pCpyEnd;
416 lcl_NonCopyCount( rPam, aCorrIdx, pREnd->GetNodeIndex(), nDelCount );
417 lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
418 *pDelPam->GetPoint(), nDelCount );
421 if (pDelPam->GetNext() != pDelPam.get()
422 && *pDelPam->GetNext()->End() == *pDelPam->Start())
424 *pDelPam->GetNext()->End() = *pDelPam->End();
425 pDelPam.reset(pDelPam->GetNext());
442 if( !pDelPam->IsMultiSelection() )
444 delete pDelPam->GetNext();
457 lcl_DeleteRedlines( aRgTmp, aCpyTmp );
464 if ( !aSrc.GetNext() )
466 aSrc.SetNext( pDest );
470 if ( !aDest.GetPrev() )
472 aDest.SetPrev( pSrc );
478 bool lcl_ContainsOnlyParagraphsInList(
const SwPaM& rPam )
484 if ( pTextNd && pTextNd->
IsInList() &&
485 pEndTextNd && pEndTextNd->
IsInList() )
495 if ( !pTextNd || !pTextNd->
IsInList() )
500 }
while (pTextNd != pEndTextNd);
506 bool lcl_MarksWholeNode(
const SwPaM & rPam)
508 bool bResult =
false;
509 auto [pStt, pEnd] = rPam.
StartEnd();
511 if (
nullptr != pStt &&
nullptr != pEnd)
516 if (
nullptr != pSttNd &&
nullptr != pEndNd &&
517 pStt->GetContentIndex() == 0 &&
518 pEnd->GetContentIndex() == pEndNd->
Len())
531 void CalcBreaks(std::vector<std::pair<SwNodeOffset, sal_Int32>> & rBreaks,
532 SwPaM const & rPam,
bool const isOnlyFieldmarks)
539 std::stack<std::tuple<sw::mark::IFieldmark const*, bool, SwNodeOffset, sal_Int32>> startedFields;
543 SwNode *
const pNode(rNodes[
n]);
547 sal_Int32
const nStart(
n == nStartNode
550 sal_Int32
const nEnd(
n == nEndNode
553 for (sal_Int32
i = nStart;
i < nEnd; ++
i)
565 if (
n == nEndNode && !isOnlyFieldmarks)
568 if (pAttr && pAttr->
End() && (nEnd < *pAttr->
End()))
571 rBreaks.emplace_back(
n,
i);
578 if (pAttr && (nStart > pAttr->
GetStart()))
580 rBreaks.emplace_back(
n,
i);
589 startedFields.emplace(pFieldMark,
false, 0, 0);
594 if (startedFields.empty())
596 rBreaks.emplace_back(
n,
i);
600 assert(std::get<0>(startedFields.top())->IsCoveringPosition(
SwPosition(rTextNode,
i)));
601 std::get<1>(startedFields.top()) =
true;
602 std::get<2>(startedFields.top()) =
n;
603 std::get<3>(startedFields.top()) =
i;
609 if (startedFields.empty())
611 rBreaks.emplace_back(
n,
i);
635 while (!startedFields.empty())
637 if (
const sw::mark::IFieldmark* pMark = std::get<0>(startedFields.top()))
639 SwPosition const& rStart(pMark->GetMarkStart());
640 std::pair<SwNodeOffset, sal_Int32>
const pos(
642 auto it = std::lower_bound(rBreaks.begin(), rBreaks.end(),
pos);
643 assert(it == rBreaks.end() || *it !=
pos);
644 rBreaks.insert(it,
pos);
646 if (std::get<1>(startedFields.top()))
648 std::pair<SwNodeOffset, sal_Int32>
const posSep(
649 std::get<2>(startedFields.top()),
650 std::get<3>(startedFields.top()));
651 auto it = std::lower_bound(rBreaks.begin(), rBreaks.end(), posSep);
652 assert(it == rBreaks.end() || *it != posSep);
653 rBreaks.insert(it, posSep);
667 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
673 return (rDocumentContentOperations.*pFunc)(rPam, flags);
685 auto iter( Breaks.rbegin() );
688 SwPaM aPam( rSelectionEnd, rSelectionEnd );
692 while (iter != Breaks.rend())
694 rStart.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
697 bRet &= (rDocumentContentOperations.*pFunc)(aPam, flags);
698 nOffset = iter->first - rStart.GetNodeIndex();
700 rEnd.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
704 rStart = *rPam.
Start();
707 bRet &= (rDocumentContentOperations.*pFunc)(aPam, flags);
713 bool lcl_StrLenOverflow(
const SwPaM& rPam )
719 auto [pStt, pEnd] = rPam.
StartEnd();
721 if( (
nullptr != pEndNd) && pStt->GetNode().IsTextNode() )
723 const sal_uInt64 nSum = pStt->GetContentIndex() +
724 pEndNd->
GetText().getLength() - pEnd->GetContentIndex();
745 nStt = pStt->GetNodeIndex() - nSttIdx;
746 nSttCnt = pStt->GetContentIndex();
749 nEnd = pEnd->GetNodeIndex() - nSttIdx;
750 nEndCnt = pEnd->GetContentIndex();
764 nStt = pStt->GetNodeIndex() - nSttIdx;
765 nSttCnt = pStt->GetContentIndex();
770 nEnd = pEnd->GetNodeIndex() - nSttIdx;
771 nEndCnt = pEnd->GetContentIndex();
801 typedef std::vector< SaveRedline > SaveRedlines_t;
803 void lcl_SaveRedlines(
const SwPaM& aPam, SaveRedlines_t& rArr)
807 auto [pStart, pEnd] = aPam.
StartEnd();
812 if( nCurrentRedline > 0)
822 for( ; nCurrentRedline < rRedlineTable.
size(); nCurrentRedline++ )
837 rRedlineTable.
Remove( nCurrentRedline-- );
844 *pNewRedline->
End() = *pStart;
845 *pCurrent->
Start() = *pStart;
854 *pNewRedline->
Start() = *pEnd;
855 *pCurrent->
End() = *pEnd;
860 rArr.emplace_back( pCurrent, *pStart );
868 void lcl_RestoreRedlines(
SwDoc& rDoc,
const SwPosition& rPos, SaveRedlines_t& rArr)
873 for(SaveRedline & rSvRedLine : rArr)
875 rSvRedLine.SetPos( rPos );
882 void lcl_SaveRedlines(
const SwNodeRange& rRg, SaveRedlines_t& rArr)
900 auto [pRStt, pREnd] = pTmp->
StartEnd();
912 rArr.emplace_back(pNewRedl, rRg.
aStart);
914 pTmpPos = pTmp->
End();
925 rRedlTable.
Remove( nRedlPos-- );
927 ( pREnd->GetNode() == rRg.
aEnd.
GetNode() && !pREnd->GetContentIndex()) )
930 rArr.emplace_back( pTmp, rRg.
aStart );
939 rArr.emplace_back( pNewRedl, rRg.
aStart );
941 pTmpPos = pTmp->
Start();
953 void lcl_RestoreRedlines(
SwDoc& rDoc,
SwNodeOffset const nInsPos, SaveRedlines_t& rArr)
958 for(SaveRedline & rSvRedLine : rArr)
960 rSvRedLine.SetPos( nInsPos );
964 rSvRedLine.pRedl->GetType() == RedlineType::Delete )
973 bool lcl_SaveFootnote(
const SwNode& rSttNd,
const SwNode& rEndNd,
976 std::optional<sal_Int32> oSttCnt = std::nullopt, std::optional<sal_Int32> oEndCnt = std::nullopt )
978 bool bUpdateFootnote =
false;
982 const bool bSaveFootnote = !bDelFootnote &&
984 if( !rFootnoteArr.
empty() )
990 const SwNode* pFootnoteNd;
993 while( nPos < rFootnoteArr.
size() && ( pFootnoteNd =
994 &( pSrch = rFootnoteArr[ nPos ] )->GetTextNode())->GetIndex()
997 const sal_Int32 nFootnoteSttIdx = pSrch->
GetStart();
998 if( ( oEndCnt && oSttCnt )
999 ? (( &rSttNd == pFootnoteNd &&
1000 *oSttCnt > nFootnoteSttIdx) ||
1001 ( &rEndNd == pFootnoteNd &&
1002 nFootnoteSttIdx >= *oEndCnt ))
1003 : ( &rEndNd == pFootnoteNd ))
1019 rFootnoteArr.
erase( rFootnoteArr.
begin() + nPos );
1021 rSaveArr.
insert( pSrch );
1023 bUpdateFootnote =
true;
1027 while( nPos-- && ( pFootnoteNd = &( pSrch = rFootnoteArr[ nPos ] )->
1028 GetTextNode())->GetIndex() >= rSttNd.
GetIndex() )
1030 const sal_Int32 nFootnoteSttIdx = pSrch->
GetStart();
1031 if( !oEndCnt || !oSttCnt ||
1032 ! (( &rSttNd == pFootnoteNd &&
1033 *oSttCnt > nFootnoteSttIdx ) ||
1034 ( &rEndNd == pFootnoteNd &&
1035 nFootnoteSttIdx >= *oEndCnt )) )
1047 rFootnoteArr.
erase( rFootnoteArr.
begin() + nPos );
1049 rSaveArr.
insert( pSrch );
1051 bUpdateFootnote =
true;
1061 while( aIdx < rEndNd )
1063 SwNode* pNode = &aIdx.GetNode();
1069 bUpdateFootnote =
true;
1071 for(
size_t i = 0;
i <
nCount; ++
i )
1084 return bUpdateFootnote;
1087 bool lcl_MayOverwrite(
const SwTextNode *pNode,
const sal_Int32 nPos )
1109 if( !lcl_MayOverwrite( pNode, rStart ) )
1115 }
while (rStart < pNode->GetText().
getLength()
1116 && !lcl_MayOverwrite(pNode, rStart) );
1120 bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet,
bool bRegExpRplc )
1125 static constexpr OUStringLiteral sPara(u
"\\n");
1128 nPos = rStr.indexOf( sPara, nPos );
1134 if( nPos &&
'\\' == rStr[nPos-1])
1137 if( nPos >= rStr.getLength() )
1144 rRet = rStr.copy( 0, nPos );
1145 rStr = rStr.copy( nPos + sPara.getLength() );
1159 bool lcl_ApplyOtherSet(
1168 assert(rOtherSet.
Count());
1179 pMerged = pTextFrame->GetMergedPara();
1183 if (rFirstSet.
Count())
1187 SwRegHistory aRegH(pMerged->pFirstNode, *pMerged->pFirstNode, pHistory);
1188 ret = pMerged->pFirstNode->SetAttr(rFirstSet);
1192 ret = pMerged->pFirstNode->SetAttr(rFirstSet);
1195 if (rPropsSet.
Count())
1199 SwRegHistory aRegH(pMerged->pParaPropsNode, *pMerged->pParaPropsNode, pHistory);
1200 ret = pMerged->pParaPropsNode->SetAttr(rPropsSet) || ret;
1204 ret = pMerged->pParaPropsNode->SetAttr(rPropsSet) || ret;
1209 *o_pIndex = *pMerged->pLastNode;
1223 ret = rNode.
SetAttr( rOtherSet );
1227 ret = rNode.
SetAttr( rOtherSet );
1233 #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
1236 void lcl_SetRedline(
1240 std::unique_ptr<SwRedlineExtraData_FormatColl> xExtra;
1250 pRStt = pTmp->
Start();
1251 pREnd = pTmp->
End();
1261 if (pFormattingChanges)
1298 aSet.ClearInvalidItems();
1313 void lcl_SetRedlines(
1319 while( aIdx <= aEndNd )
1324 const sal_Int32 nStart = aIdx == rRg.
Start()->
GetNode()
1327 const sal_Int32 nEnd = aIdx < aEndNd
1328 ? pNode->
GetText().getLength()
1334 sal_Int32 nRedEnd = nStart;
1335 for(
size_t i = 0;
i <
nCount; ++
i )
1350 if ( nRedEnd < pAttr->GetStart() )
1353 lcl_SetRedline(rDoc, aPam);
1357 sal_Int32 nRedStart = std::max(pAttr->
GetStart(), nStart);
1359 SwPaM aPam2( *pNode, nRedStart, *pNode, nRedEnd );
1360 lcl_SetRedline(rDoc, aPam2);
1364 if ( nRedEnd < nEnd )
1366 SwPaM aPam( *pNode, nRedEnd, *pNode, nEnd );
1367 lcl_SetRedline(rDoc, aPam);
1372 SwPaM aPam( *pNode, nStart, *pNode, nEnd );
1373 lcl_SetRedline(rDoc, aPam);
1395 bool bDelete =
false;
1396 bool bCharAttr =
false;
1397 bool bOtherAttr =
false;
1400 if ( 1 == rChgSet.
Count() )
1406 const sal_uInt16 nWhich = pItem->
Which();
1414 pCharSet = &rChgSet;
1425 pOtherSet = &rChgSet;
1434 if ( !bCharAttr && !bOtherAttr )
1448 pTmpCharItemSet->
Put( rChgSet );
1449 pTmpOtherItemSet->Put( rChgSet );
1451 pCharSet = pTmpCharItemSet;
1452 pOtherSet = pTmpOtherItemSet;
1470 auto nStartIndex = pNode->
GetIndex();
1471 auto nEndIndex = pEndNode->
GetIndex();
1473 while ( pCurrentNode !=
nullptr && nStartIndex <= pCurrentNode->GetIndex() )
1477 (nStartIndex < pCurrentNode->GetIndex() || pStt->
GetContentIndex() == 0) &&
1478 (pCurrentNode->
GetIndex() < nEndIndex || pEnd->GetContentIndex() == pEndNode->
Len()))
1499 OSL_FAIL(
"<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect." );
1512 SwNumFormat aNumFormat = pNumRule->
Get(o3tl::narrowing<sal_uInt16>(nLevel));
1530 if ( !bCharAttr && !bOtherAttr )
1534 aTextSet.Put( rChgSet );
1535 if( aTextSet.Count() )
1538 bRet = history.InsertItems(
1559 if ( !bCharAttr && !bOtherAttr )
1569 aTextSet.Put( rChgSet );
1570 if( aTextSet.Count() )
1573 const sal_Int32 nEnd = pStt->
GetNode() == pEnd->GetNode()
1574 ? pEnd->GetContentIndex()
1577 bRet = history.InsertItems( aTextSet, nInsCnt, nEnd, nFlags, ppNewTextAttr )
1586 SwPaM aPam( pStt->
GetNode(), bTextIns ? nInsCnt + 1 : nEnd,
1594 bTextIns ? RedlineType::Insert : RedlineType::Format, aPam ),
1604 if( pOtherSet && pOtherSet->
Count() )
1621 pTableNd = pCurTableNd;
1636 SwRegHistory aRegH( pFirstNode, *pFirstNode, pHistory );
1637 bRet = pFirstNode->SetAttr( aNew ) || bRet;
1648 if( !pOtherSet->
Count() )
1663 pTableNd = pCurTableNd;
1678 if( !pOtherSet->
Count() )
1687 sal_uInt16 nPoolId=0;
1698 if (pOtherSet && pOtherSet->
Count())
1700 firstSet.Put(*pOtherSet);
1706 if (pOtherSet && pOtherSet->
Count())
1708 propsSet.Put(*pOtherSet);
1723 const OUString& rStr = pTextNd->
GetText();
1728 if (pURLAttr && !pURLAttr->GetINetFormat().GetValue().isEmpty())
1730 nMkPos = pURLAttr->GetStart();
1731 nPtPos = *pURLAttr->End();
1739 WordType::ANY_WORD ,
1742 if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
1744 nMkPos = aBndry.startPos;
1745 nPtPos = aBndry.endPos;
1756 pTextNd->
HasHints() && !nMkPos && nPtPos == rStr.getLength())
1773 SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
1778 lcl_SetRedlines(rDoc, aPam);
1784 bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags,
nullptr )
1788 if( pOtherSet && pOtherSet->
Count() )
1796 bRet = lcl_ApplyOtherSet(*pNode, pHistory, aTempLocalCopy, firstSet, propsSet, pLayout) || bRet;
1808 lcl_SetRedlines(rDoc, rRg);
1816 SwContentIndex aCntEnd( pEnd->GetContentNode(), pEnd->GetContentIndex() );
1820 const sal_Int32 nLen = pNode->
Len();
1821 if( pStt->
GetNode() != pEnd->GetNode() )
1822 aCntEnd.Assign( pNode, nLen );
1830 bRet = history.InsertItems(*pCharSet,
1835 if( pOtherSet && pOtherSet->
Count() )
1837 bRet = lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout) || bRet;
1841 if( pStt->
GetNode() == pEnd->GetNode() )
1847 aSt.Assign( pStt->
GetNode(), +1 );
1851 aCntEnd.Assign(pEnd->GetContentNode(), pEnd->GetContentIndex());
1854 aSt.Assign( pStt->
GetNode(), +1 );
1861 if( pStt->
GetNode() < pEnd->GetNode() )
1866 if( aCntEnd.GetIndex() != pNode->
Len() )
1872 (void)history.InsertItems(*pCharSet,
1873 0, aCntEnd.GetIndex(), nFlags,
nullptr);
1876 if( pOtherSet && pOtherSet->
Count() )
1878 lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout);
1882 aEnd = pEnd->GetNode();
1885 aEnd.Assign( pEnd->GetNode(), +1 );
1888 aEnd = pEnd->GetNode();
1891 aEnd.Assign( pEnd->GetNode(), +1 );
1900 pStt, pEnd, pHistory, pCharSet, pLayout);
1904 bool bCreateSwpHints = pCharSet && (
1908 for (
SwNodeIndex current = aSt; current < aEnd; ++current)
1924 if (pCharSet && pCharSet->
Count())
1929 pSwpHints->Register( &aRegH );
1932 pTNd->
SetAttr(*pCharSet, 0, pTNd->
GetText().getLength(), nFlags);
1936 pSwpHints->DeRegister();
1941 if (pCharSet && pCharSet->
Count())
1942 pTNd->
SetAttr(*pCharSet, 0, pTNd->
GetText().getLength(), nFlags);
1947 if (pOtherSet && pOtherSet->
Count())
1949 for (; aSt < aEnd; ++aSt)
1955 lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout, &aSt);
1961 return (nNodes != 0) || bRet;
1972 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
1974 return !Breaks.empty();
2000 return rEnd < rStart;
2023 nEnd = pEnd->GetNodeIndex(),
2024 nDiff = nEnd - nStt +1;
2038 lcl_ChkFlyFly( rDoc, nStt, nEnd, rPos.
GetNodeIndex() ) )
2044 SwPaM* pRedlineRange =
nullptr;
2047 pRedlineRange =
new SwPaM( rPos );
2057 else if( ! ( *pStt <= rPos && rPos < *pEnd &&
2058 ( pStt->
GetNode() != pEnd->GetNode() ||
2068 assert(!
"mst: this is assumed to be dead code");
2078 delete pRedlineRange;
2100 assert(pNode &&
"Didn't pass a Node.");
2113 SwPaM const range(aSttIdx, aEndIdx);
2124 SwPaM aPam(rPos, rPos);
2126 assert(aPam.
GetText().getLength() == 1 && aPam.
GetText()[0] == cDummy);
2165 SwPaM temp(rPam,
nullptr);
2186 bool bSavePageBreak =
false, bSavePageDesc =
false;
2203 bSavePageDesc =
true;
2210 bSavePageBreak =
true;
2220 else if( rPam.
GetPoint() == &rStt )
2225 bool bGoNext = (
nullptr == pTmpNode);
2245 pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
2261 SAL_WARN(
"sw.core",
"DelFullPara: no more Nodes");
2271 ::std::set<::sw::mark::IFieldmark*> fieldmarks;
2274 if (
SwTextNode *
const pTextNode =
i.GetNode().GetTextNode())
2276 for (sal_Int32 j = 0; j < pTextNode->GetText().
getLength(); ++j)
2278 switch (pTextNode->GetText()[j])
2291 for (
auto const pFieldMark : fieldmarks)
2315 ((RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()) ||
2316 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId())) &&
2345 if ( lcl_StrLenOverflow( rPam ) )
2362 if( !rPaM.
HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd))
2372 SaveRedlines_t aSaveRedl;
2375 lcl_SaveRedlines( rPaM, aSaveRedl );
2387 pEnd->GetContentIndex());
2390 bool bUpdateFootnote =
false;
2393 std::unique_ptr<SwUndoMove> pUndoMove;
2397 pUndoMove.reset(
new SwUndoMove( rPaM, rPos ));
2402 bUpdateFootnote = lcl_SaveFootnote( pStt->
GetNode(), pEnd->GetNode(), rPos.
GetNode(),
2407 bool bSplit =
false;
2408 SwPaM aSavePam( rPos, rPos );
2416 bool bCorrSavePam = pSrcNd && pStt->
GetNode() != pEnd->GetNode();
2441 if (!pContentStore->Empty())
2443 pContentStore->Restore(m_rDoc, pOrigNode->GetIndex()-SwNodeOffset(1), 0, true, false, eMode);
2493 std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
2499 pEnd->GetContentIndex());
2517 OSL_ENSURE( *aSavePam.
GetMark() == rPos ||
2519 "PaM was not moved. Aren't there ContentNodes at the beginning/end?" );
2525 bool bRemove =
true;
2548 for(
auto& rBkmk : aSaveBkmks)
2562 if( !aSaveRedl.empty() )
2564 lcl_RestoreRedlines(
m_rDoc, *aSavePam.
Start(), aSaveRedl );
2567 if( bUpdateFootnote )
2569 if( !aTmpFntIdx.
empty() )
2593 bool bUpdateFootnote =
false;
2596 std::unique_ptr<SwUndoMove> pUndo;
2607 SaveRedlines_t aSaveRedl;
2608 std::vector<SwRangeRedline*> aSavRedlInsPosArr;
2611 lcl_SaveRedlines( rRange, aSaveRedl );
2621 pRStt = pTmp->
Start();
2622 pREnd = pTmp->
End();
2625 aSavRedlInsPosArr.push_back( pTmp );
2634 std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
2645 std::optional<SwNodeIndex> oSaveInsPos;
2647 oSaveInsPos.emplace(rRange.
aStart, -1 );
2664 if( !aSaveFlyArr.empty() )
2671 for(
auto& rBkmk : aSaveBkmks)
2674 if( !aSavRedlInsPosArr.empty() )
2686 if( !aSaveRedl.empty() )
2691 pUndo->SetDestRange( aIdx.
GetNode(), rDestNd, *oSaveInsPos );
2695 oSaveInsPos.reset();
2697 if( bUpdateFootnote )
2699 if( !aTmpFntIdx.
empty() )
2720 if( !bRet || bOneNode )
2743 assert(rStr.getLength());
2747 if( 1 == rStr.getLength() )
2753 if (!pNode || rStr.getLength() > pNode->
GetSpaceLeft())
2767 sal_Int32 nStart = 0;
2772 for( sal_Int32 nCnt = 0; nCnt < rStr.getLength(); ++nCnt )
2776 if (nStart < pNode->GetText().
getLength())
2778 lcl_SkipAttr( pNode, rPt, nStart );
2783 bool bMerged(
false);
2798 std::make_unique<SwUndoOverwrite>(
m_rDoc, rPt, c) );
2804 if (nStart < pNode->GetText().
getLength())
2819 if( nOldAttrCnt != nNewAttrCnt )
2879 OUString
const ins(pNode->
InsertText(rStr, rPos, nInsertMode));
2883 std::make_unique<SwUndoInsert>(rPos.
GetNode(),
2897 if (pUndoInsert && pUndoInsert->
CanGrouping(rPos))
2899 pUndo = pUndoInsert;
2913 OUString
const ins(pNode->
InsertText(rStr, rPos, nInsertMode));
2915 for (sal_Int32
i = 0;
i < ins.getLength(); ++
i)
2962 std::unique_ptr<SwUndoTransliterate> pUndo;
2966 auto [pStt, pEnd] = rPaM.
StartEnd();
2968 nEndNd = pEnd->GetNodeIndex();
2970 sal_Int32 nEndCnt = pEnd->GetContentIndex();
2973 if( (pStt == pEnd) && pTNd )
2980 WordType::ANY_WORD ,
2983 if( aBndry.startPos < nSttCnt && nSttCnt < aBndry.endPos )
2986 if (rTrans.
getType() == TransliterationFlags::SENTENCE_CASE) {
2996 nSttCnt = aBndry.startPos;
2997 nEndCnt = aBndry.endPos;
3008 if ( bUseRedlining )
3011 const bool bIsTitleCase = rTrans.
getType() == TransliterationFlags::TITLE_CASE;
3015 for( ; aIdx.
GetIndex() <= nEndNd; ++aIdx )
3020 if( !pAffectedNode || pAffectedNode->
GetText().isEmpty() )
3028 nAffectedChars += pAffectedNode->
GetText().getLength();
3032 if( nAffectedNodes > nMaxRedlines ||
3035 ( bIsTitleCase && (nAffectedChars - nSttCnt)/6 > nMaxRedlines ) )
3037 bUseRedlining =
false;
3043 if( nSttNd != nEndNd )
3055 rTrans, nSttCnt, pTNd->
GetText().getLength(), pUndo.get(), bUseRedlining);
3059 for( ; aIdx.
GetIndex() < nEndNd; ++aIdx )
3065 rTrans, 0, pTNd->
GetText().getLength(), pUndo.get(), bUseRedlining);
3069 if( nEndCnt &&
nullptr != ( pTNd = pEnd->GetNode().
GetTextNode() ))
3074 else if( pTNd && nSttCnt < nEndCnt )
3076 pTNd->
TransliterateText( rTrans, nSttCnt, nEndCnt, pUndo.get(), bUseRedlining );
3078 if( pUndo && pUndo->HasData() )
3087 const OUString& rGrfName,
3088 const OUString& rFltName,
3098 rGrfName, rFltName, pGraphic,
3101 pFlyAttrSet, pGrfAttrSet, pFrameFormat );
3102 return pSwFlyFrameFormat;
3125 pFlyAttrSet,
nullptr,
3143 pFlyAttrSet, pGrfAttrSet,
3148 const OUString& rFltName,
const Graphic* pGraphic )
3166 pGrfNd->
ReRead( rGrfName, rFltName, pGraphic );
3184 const bool bIsAtContent = (RndStdIds::FLY_AT_PAGE != eAnchorId);
3187 if ( pAnchor ==
nullptr )
3191 else if ( bIsAtContent )
3198 if( pChkPos !=
nullptr
3203 eAnchorId = RndStdIds::FLY_AT_PAGE;
3206 else if( pAnchor ==
nullptr
3213 if ( eAnchorId == RndStdIds::FLY_AT_FLY )
3223 if ( eAnchorId == RndStdIds::FLY_AT_PAGE )
3225 eAnchorId =
dynamic_cast<const SdrUnoObj*
>( &rDrawObj) !=
nullptr ? RndStdIds::FLY_AS_CHAR : RndStdIds::FLY_AT_PARA;
3233 if ( eAnchorId == RndStdIds::FLY_AS_CHAR )
3235 bool bAnchorAtPageAsFallback =
true;
3241 if ( pAnchorTextNode !=
nullptr )
3245 pAnchorTextNode->
InsertItem( aFormat, nStt, nStt );
3246 bAnchorAtPageAsFallback =
false;
3250 if ( bAnchorAtPageAsFallback )
3252 OSL_ENSURE(
false,
"DocumentContentOperationsManager::InsertDrawObj(..) - missing content anchor for as-character anchored drawing object --> anchor at-page" );
3285 if(
nullptr == pNode)
3310 if( pTextNode &&
nPos &&
nPos != pTextNode->
Len() )
3325 nullptr != ( pTableNd =
m_rDoc.
GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
3391 if (!pContentStore->Empty())
3393 pContentStore->Restore(m_rDoc, rPos.GetNodeIndex()-SwNodeOffset(1), 0, true, bAtStart && (eMode & sw::mark::RestoreMode::Flys), eMode);
3404 aPam.Move( fnMoveBackward );
3405 if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn())
3407 m_rDoc.getIDocumentRedlineAccess().AppendRedline(
3408 new SwRangeRedline(RedlineType::Insert, aPam), true);
3412 m_rDoc.getIDocumentRedlineAccess().SplitRedline(aPam);
3423bool DocumentContentOperationsManager::AppendTextNode(
SwPosition& rPos )
3460bool DocumentContentOperationsManager::ReplaceRange(
SwPaM& rPam,
const OUString& rStr,
3461 const bool bRegExReplace )
3466 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
3478 while (!Breaks.empty()
3484 Breaks.erase(Breaks.begin());
3493 return ReplaceRangeImpl(rPam, rStr, bRegExReplace);
3503 auto iter( Breaks.rbegin() );
3506 OSL_ENSURE(aPam.
GetPoint() == aPam.
End(),
"wrong!");
3514 while (iter != Breaks.rend())
3516 rStart.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
3524 rEnd.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
3528 rStart = *rPam.
Start();
3529 assert(rStart < rEnd &&
"replace part empty!");
3532 bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace);
3540bool DocumentContentOperationsManager::InsertPoolItem(
3548 std::unique_ptr<SwUndoAttr> pUndoAttr;
3552 pUndoAttr.reset(
new SwUndoAttr( rRg, rHt, nFlags ));
3557 const bool bRet = lcl_InsAttr(
m_rDoc, rRg, aSet, nFlags, pUndoAttr.get(), pLayout, ppNewTextAttr);
3571void DocumentContentOperationsManager::InsertItemSet (
const SwPaM &rRg,
const SfxItemSet &rSet,
3575 std::unique_ptr<SwUndoAttr> pUndoAttr;
3582 bool bRet = lcl_InsAttr(
m_rDoc, rRg,
rSet, nFlags, pUndoAttr.get(), pLayout,
nullptr );
3593void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(
const SwPosition & rPos )
3599 const OUString& rText = pTNd->
GetText();
3601 while (nIdx < rText.getLength())
3604 if ((
'\t' != cCh) && (
' ' != cCh))
3617 DeleteRange( aPam );
3621void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(
SwPaM& rPaM )
3628 RemoveLeadingWhiteSpace(
SwPosition(rSel.GetBound().GetNodes(),
nPos));
3635void DocumentContentOperationsManager::CopyWithFlyInFly(
3638 const std::pair<const SwPaM&, const SwPosition&>* pCopiedPaM ,
3639 const bool bMakeNewFrames,
3640 const bool bDelRedlines,
3641 const bool bCopyFlyAtFly,
3644 assert(!pCopiedPaM || pCopiedPaM->first.End()->GetNode() == rRg.
aEnd.
GetNode());
3645 assert(!pCopiedPaM || pCopiedPaM->second.GetNode() <= rInsPos);
3652 bool bEndIsEqualEndPos = rInsPos == rRg.
aEnd.
GetNode();
3660 if (bEndIsEqualEndPos)
3674 if (pCopiedPaM && rRg.
aStart != pCopiedPaM->first.Start()->
GetNode())
3682 targetPos = pCopiedPaM->second;
3690 bool isRecreateEndNode(
false);
3701 if (pFrame->getRootFrame()->HasMergedParas())
3705 if (pNode ==
nullptr && pFrame->GetMergedPara()
3708 pNode = pFrame->GetMergedPara()->pFirstNode;
3713 if (pNode !=
nullptr)
3716 if (!frames.
empty())
3721 if (pFrame->getRootFrame()->HasMergedParas())
3723 auto const it = frames.
find(pFrame);
3724 if (it != frames.
end())
3730 if (!frames.
empty())
3733 isRecreateEndNode =
true;
3747 SwNodeOffset((!isRecreateEndNode || isAtStartOfSection)
3753#if OSL_DEBUG_LEVEL > 0
3761 if( pSSectNd == pESectNd &&
3769 "An insufficient number of nodes were copied!" );
3776 CopyFlyInFlyImpl(rRg, pCopiedPaM ? &pCopiedPaM->first :
nullptr,
3778 (pCopiedPaM && rRg.
aStart != pCopiedPaM->first.Start()->
GetNode())
3779 ? pCopiedPaM->second.GetNode()
3788 lcl_DeleteRedlines( rRg, aCpyRange );
3795void DocumentContentOperationsManager::CopyFlyInFlyImpl(
3797 SwPaM const*
const pCopiedPaM,
3799 const bool bCopyFlyAtFly,
3808 std::set< ZSortFly > aSet;
3814 for (
size_t n = 0;
n < nArrLen; ++
n )
3826 case RndStdIds::FLY_AT_FLY:
3832 case RndStdIds::FLY_AT_PARA:
3842 case RndStdIds::FLY_AT_CHAR:
3855 if (RndStdIds::FLY_AT_FLY == pAnchor->
GetAnchorId())
3857 if (nStart > nSkipAfter)
3879 aSet.insert(
ZSortFly( pFormat, pAnchor, nArrLen + aSet.size() ));
3886 std::vector< SwFrameFormat* > aVecSwFrameFormat;
3887 std::set< ZSortFly >::const_iterator it=aSet.begin();
3889 while (it != aSet.end())
3903 if ((aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
3904 (aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR) )
3909 bool bAnchorTextNdFound(
false );
3912 while ( !bAnchorTextNdFound && aIdx <= rRg.
aEnd )
3916 ++nAnchorTextNdNumInRange;
3923 if ( !bAnchorTextNdFound )
3927 OSL_FAIL(
"<SwDoc::_CopyFlyInFly(..)> - anchor text node in copied range not found" );
3928 nAnchorTextNdNumInRange = 1;
3935 const SwNode& aEndOfContentNd =
3937 while ( nAnchorTextNdNumInRange > 0 &&
3938 aIdx.
GetNode() != aEndOfContentNd )
3942 --nAnchorTextNdNumInRange;
3943 aAnchorNdIdx = aIdx;
3952 OSL_FAIL(
"<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" );
3953 aAnchorNdIdx = rStartIdx;
3960 newPos.
Assign( aAnchorNdIdx );
3965 newPos.
Assign( rStartIdx, nOffset );
3968 if ((RndStdIds::FLY_AT_CHAR == aAnchor.
GetAnchorId()) &&
3989 it = aSet.erase(it);
3998 it = aSet.erase(it);
4004 aAnchor,
false,
true ) );
4009 OSL_ENSURE( aSet.size() == aVecSwFrameFormat.size(),
"Missing new Flys" );
4010 if ( aSet.size() != aVecSwFrameFormat.size() )
4014 for (
const auto& rFlyN : aSet)
4019 for (
const auto& rFlyK : aSet)
4022 if ( rChain.
GetPrev() == pFormatK )
4024 ::lcl_ChainFormats(
static_cast< SwFlyFrameFormat*
>(aVecSwFrameFormat[k]),
4027 else if ( rChain.
GetNext() == pFormatK )
4049bool DocumentContentOperationsManager::lcl_RstTextAttr(
SwNode* pNd,
void* pArgs )
4061 sal_Int32 nEnd = pTextNode->
Len();
4087DocumentContentOperationsManager::~DocumentContentOperationsManager()
4092bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl(
SwPaM & rPam,
SwDeleteFlags const flags)
4103 std::vector<std::unique_ptr<SwRangeRedline>> redlines;
4105 auto pRedline(std::make_unique<SwRangeRedline>(RedlineType::Delete, rPam));
4106 if (pRedline->HasValidRange())
4108 redlines.push_back(std::move(pRedline));
4116 if (redlines.empty())
4127 std::vector<std::unique_ptr<SwUndo>> MarkUndos;
4128 for (
auto iter = rDMA.getAnnotationMarksBegin();
4129 iter != rDMA.getAnnotationMarksEnd(); )
4133 SwPosition const& rEndPos((**iter).GetMarkEnd());
4134 if (*rPam.
Start() < rEndPos && rEndPos <= *rPam.
End())
4138 MarkUndos.emplace_back(std::make_unique<SwUndoDeleteBookmark>(**iter));
4141 rDMA.deleteMark(&**iter);
4143 iter = rDMA.getAnnotationMarksBegin();
4147 if (*rPam.
End() < (**iter).GetMarkStart())
4159 std::vector<std::unique_ptr<SwUndoRedlineDelete>> undos;
4165 "sw.core",
"redlines will be moved in DeleteAndJoin");
4169 for (std::unique_ptr<SwRangeRedline> & pRedline : redlines)
4171 assert(pRedline->HasValidRange());
4172 undos.emplace_back(std::make_unique<SwUndoRedlineDelete>(
4175 const SwRewriter aRewriter = undos.front()->GetRewriter();
4177 if (MarkUndos.empty() && undos.size() == 1
4182 bool const bMerged = pUndoRedlineDel
4193 for (
auto& it : MarkUndos)
4197 for (
auto & it : undos)
4204 for (std::unique_ptr<SwRangeRedline> & pRedline : redlines)
4210 *pCursor->GetPoint() = *pRedline->GetPoint();
4236 bool bJoinText, bJoinPrev;
4239 bool const bSuccess( DeleteRangeImpl(rPam, flags) );
4267 bool const bSuccess( DeleteRangeImplImpl(aDelPam, flags) );
4278 auto [pStt, pEnd] = rPam.
StartEnd();
4302 for(
size_t n = pHts->
Count();
n; )
4305 if( nMkCntPos > pAttr->
GetStart() )
4308 const sal_Int32 *pEndIdx;
4309 if( nMkCntPos == pAttr->
GetStart() &&
4310 nullptr != (pEndIdx = pAttr->
End()) &&
4327 bool bMerged(
false);
4363 pEnd->GetContentIndex());
4372 if ( pStartTextNode )
4375 bool bOneNd = pStt->
GetNode() == pEnd->GetNode();
4376 const sal_Int32 nLen = ( bOneNd ? pEnd->GetContentIndex()
4383 pStartTextNode->
EraseText( *pStt, nLen );
4385 if( !pStartTextNode->
Len() )
4388 pStartTextNode->RemoveMetadataReference();
4412 if( pEnd->GetContentIndex() )
4415 pEndTextNode->
EraseText( aIdx, pEnd->GetContentIndex() );
4417 if( !pEndTextNode->
Len() )
4420 pEndTextNode->RemoveMetadataReference();
4428 pEnd->nContent.Assign(
nullptr, 0 );
4434 if( pCNd ==
nullptr )
4437 if( aSttIdx != nEnd )
4445 && aSttIdx <= pTmpNd->StartOfSectionNode()->GetIndex())
4476bool DocumentContentOperationsManager::ReplaceRangeImpl(
SwPaM& rPam,
const OUString& rStr,
4477 const bool bRegExReplace )
4482 bool bJoinText, bJoinPrev;
4492 auto [pStt, pEnd] = aDelPam.
StartEnd();
4493 bool bOneNode = pStt->
GetNode() == pEnd->GetNode();
4496 OUString sRepl( rStr );
4510 "sw.core",
"redlines will be moved in ReplaceRange");
4515 const ::sw::mark::IMark* pBkmk =
4518 ::sw::mark::InsertMode::New);
4523 *aDelPam.
GetPoint() = pBkmk->GetMarkPos();
4524 if(pBkmk->IsExpanded())
4525 *aDelPam.
GetMark() = pBkmk->GetOtherMarkPos();
4527 pStt = aDelPam.
Start();
4532 if( !sRepl.isEmpty() )
4556 while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
4558 InsertString( aDelPam, sIns );
4564 SplitNode( *aDelPam.
GetPoint(),
false );
4571 SplitNode( *aDelPam.
GetPoint(),
false );
4573 if( !sIns.isEmpty() )
4575 InsertString( aDelPam, sIns );
4586 InsertItemSet( aTmpRange, aSet );
4605 *pCursor->GetPoint() = *aDelPam.
GetPoint();
4617 const ::sw::mark::IMark* pBkmk =
4620 ::sw::mark::InsertMode::New);
4628 *rPam.
GetPoint() = pBkmk->GetMarkPos();
4629 *rPam.
GetMark() = pBkmk->IsExpanded() ? pBkmk->GetOtherMarkPos() : pBkmk->GetMarkPos();
4637 assert((pStt->
GetNode() == pEnd->GetNode() ||
4639 !pEnd->GetContentIndex() )) &&
4640 "invalid range: Point and Mark on different nodes" );
4649 pUndoRpl =
new SwUndoReplace(aDelPam, sRepl, bRegExReplace);
4662 nEnd = bOneNode ? pEnd->GetContentIndex()
4663 : pTextNd->
GetText().getLength();
4667 while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
4669 if (!bFirst || nStt == pTextNd->
GetText().getLength())
4671 InsertString( aDelPam, sIns );
4673 else if( nStt < nEnd || !sIns.isEmpty() )
4677 SplitNode( *pStt,
false);
4681 if( bFirst || !sIns.isEmpty() )
4683 if (!bFirst || nStt == pTextNd->
GetText().getLength())
4685 InsertString( aDelPam, sIns );
4687 else if( nStt < nEnd || !sIns.isEmpty() )
4703 else if (aDelPam.
GetPoint() == pStt)
4735 pFlyAttrSet, pFrameFormat );
4737 pNode->
SetAttr( *pGrfAttrSet );
4742#define NUMRULE_STATE \
4743 std::shared_ptr<SwNumRuleItem> aNumRuleItemHolderIfSet; \
4744 std::shared_ptr<SfxStringItem> aListIdItemHolderIfSet; \
4746#define PUSH_NUMRULE_STATE \
4747 lcl_PushNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd );
4749#define POP_NUMRULE_STATE \
4750 lcl_PopNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd, rPam );
4753 std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
4754 std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
4760 if (pAttrSet ==
nullptr)
4765 aNumRuleItemHolderIfSet.reset(pItem->
Clone());
4770 aListIdItemHolderIfSet.reset(pItem->
Clone());
4775 const std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
4776 const std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
4782 if ( lcl_MarksWholeNode(rPam) )
4785 if (aNumRuleItemHolderIfSet)
4787 pDestTextNd->
SetAttr(*aNumRuleItemHolderIfSet);
4794 if (aListIdItemHolderIfSet)
4796 pDestTextNd->
SetAttr(*aListIdItemHolderIfSet);
4806 SwPaM *
const pCopyRange)
const
4808 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
4814 return CopyImplImpl(rPam, rPos, flags, pCopyRange);
4822 auto iter( Breaks.rbegin() );
4825 SwPaM aPam( rSelectionEnd, rSelectionEnd );
4828 SwPaM copyRange(rPos, rPos);
4830 while (iter != Breaks.rend())
4832 rStart.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
4849 rEnd.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
4853 rStart = *rPam.
Start();
4873 SwPaM *
const pCpyRange)
const
4878 auto [pStt, pEnd] = rPam.
StartEnd();
4884 ( &rDoc == &
m_rDoc && *pStt <= rPos && rPos < *pEnd ))
4889 const bool bEndEqualIns = &rDoc == &
m_rDoc && rPos == *pEnd;
4895 std::shared_ptr<SwUnoCursor>
const pCopyPam(rDoc.
CreateUnoCursor(rPos));
4898 std::optional<std::vector<SwFrameFormat*>> pFlys;
4899 std::vector<SwFrameFormat*>
const* pFlysAtInsPos;
4909 pFlysAtInsPos = pFlys ? &*pFlys :
nullptr;
4917 pCopyPam->SetMark();
4920 bool bAfterTable =
false;
4924 *(pCopyPam->GetPoint()) = rPos;
4926 bCanMoveBack =
false;
4932 assert(pCopyPam->GetPoint()->GetContentIndex() == 0);
4937 const bool bOneNode = pStt->
GetNode() == pEnd->GetNode();
4942 ( (pDestTextNd && !pDestTextNd->
GetText().getLength()) ||
4944 bool bCopyBookmarks =
true;
4945 bool bCopyPageSource =
false;
4959 OUString aListIdToPropagate;
4961 rDoc.
SearchNumRule( rPos,
false,
true,
false, 0, aListIdToPropagate,
nullptr,
true );
4962 if ( !pNumRuleToPropagate )
4964 pNumRuleToPropagate =
4965 rDoc.
SearchNumRule( rPos,
false,
false,
false, 0, aListIdToPropagate,
nullptr,
true );
4973 if ( pNumRuleToPropagate &&
4974 ((pDestTextNd && !pDestTextNd->
GetText().getLength() &&
4976 !lcl_ContainsOnlyParagraphsInList(rPam)) ||
4979 pNumRuleToPropagate =
nullptr;
4991 bool bCopyOk =
false;
5002 aDestIdx.
Assign( pDestTextNd, 0 );
5003 bCopyCollFormat =
true;
5005 else if( !bOneNode || bColumnSel )
5007 const sal_Int32 nContentEnd = pEnd->GetContentIndex();
5013 if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
5022 pDestTextNd, pDestTextNd->
GetText().getLength());
5027 bool bChg = pEnd != rPam.
GetPoint();
5034 else if( rPos == *pEnd )
5038 pEnd->SetContent( nContentEnd );
5046 if( bCopyCollFormat && bOneNode )
5053 const sal_Int32 nCpyLen = ( bOneNode
5054 ? pEnd->GetContentIndex()
5055 : pSttTextNd->
GetText().getLength())