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>
106 for(
size_t n = 0;
n < rFrameFormatTable.
size(); ++
n )
112 ((RndStdIds::FLY_AS_CHAR == pAnchor->
GetAnchorId()) ||
113 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId()) ||
114 (RndStdIds::FLY_AT_FLY == pAnchor->
GetAnchorId()) ||
115 (RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId())) &&
116 nSttNd <= pAnchorNode->GetIndex() &&
126 nInsNd < pSNd->EndOfSectionIndex() )
130 if( lcl_ChkFlyFly( rDoc, pSNd->
GetIndex(),
145 == rStart.GetNodeIndex())
185 while( rLastIdx.
GetIndex() < nNewIdx );
190 while( rLastIdx.
GetIndex() > nNewIdx )
203 void lcl_SetCpyPos(
const SwPosition& rOrigPos,
245 std::vector< const ::sw::mark::IMark* > vMarksToCopy;
250 const ::sw::mark::IMark*
const pMark = *ppMark;
252 const SwPosition& rMarkStart = pMark->GetMarkStart();
253 const SwPosition& rMarkEnd = pMark->GetMarkEnd();
256 bool const isIncludeStart(
262 || rMarkStart != rStt);
263 bool const isIncludeEnd(
264 (rEnd.GetNode().IsTextNode()
265 && rEnd.GetContentIndex() == rEnd.GetNode().GetTextNode()->Len())
266 || rMarkEnd != rEnd);
267 const bool bIsNotOnBoundary =
269 ? (isIncludeStart || isIncludeEnd)
270 : (isIncludeStart && isIncludeEnd);
272 if ( rMarkStart >= rStt && rMarkEnd <= rEnd
273 && ( bIsNotOnBoundary
280 vMarksToCopy.push_back(pMark);
285 SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
288 SwPaM aTmpPam(*pCpyStt);
289 lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetMarkPos().GetNodeIndex(), nDelCount);
290 lcl_SetCpyPos( pMark->GetMarkPos(), rStt, *pCpyStt, *aTmpPam.
GetPoint(), nDelCount);
291 if(pMark->IsExpanded())
294 lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetOtherMarkPos().GetNodeIndex(), nDelCount);
295 lcl_SetCpyPos(pMark->GetOtherMarkPos(), rStt, *pCpyStt, *aTmpPam.
GetMark(), nDelCount);
305 if (pNewMark ==
nullptr)
316 const ::sw::mark::IBookmark*
const pOldBookmark =
318 if (pNewBookmark && pOldBookmark)
320 pNewBookmark->
SetKeyCode(pOldBookmark->GetKeyCode());
321 pNewBookmark->
SetShortName(pOldBookmark->GetShortName());
322 pNewBookmark->
Hide(pOldBookmark->IsHidden());
325 ::sw::mark::IFieldmark*
const pNewFieldmark =
326 dynamic_cast< ::sw::mark::IFieldmark*
const >(pNewMark);
327 const ::sw::mark::IFieldmark*
const pOldFieldmark =
328 dynamic_cast< const ::sw::mark::IFieldmark*
>(pMark);
329 if (pNewFieldmark && pOldFieldmark)
331 pNewFieldmark->SetFieldname(pOldFieldmark->GetFieldname());
332 pNewFieldmark->SetFieldHelptext(pOldFieldmark->GetFieldHelptext());
333 ::sw::mark::IFieldmark::parameter_map_t* pNewParams = pNewFieldmark->GetParameters();
334 const ::sw::mark::IFieldmark::parameter_map_t* pOldParams = pOldFieldmark->GetParameters();
335 for (
const auto& rEntry : *pOldParams )
337 pNewParams->insert( rEntry );
341 ::sfx2::Metadatable
const*
const pMetadatable(
342 dynamic_cast< ::sfx2::Metadatable const*
>(pMark));
343 ::sfx2::Metadatable *
const pNewMetadatable(
344 dynamic_cast< ::sfx2::Metadatable *
>(pNewMark));
345 if (pMetadatable && pNewMetadatable)
347 pNewMetadatable->RegisterAsCopyOf(*pMetadatable);
355 void lcl_DeleteRedlines(
const SwPaM& rPam,
SwPaM& rCpyPam )
364 std::unique_ptr<SwPaM> pDelPam;
365 auto [pStt, pEnd] = rPam.
StartEnd();
368 SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
372 for( ;
n < rTable.
size(); ++
n )
377 auto [pRStt, pREnd] = pRedl->
StartEnd();
395 pDelPam.reset(
new SwPaM( *pCpyStt, pDelPam.release() ));
398 lcl_NonCopyCount( rPam, aCorrIdx, pRStt->GetNodeIndex(), nDelCount );
399 lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
400 *pDelPam->GetPoint(), nDelCount );
405 *pDelPam->GetPoint() = *pCpyEnd;
408 lcl_NonCopyCount( rPam, aCorrIdx, pREnd->GetNodeIndex(), nDelCount );
409 lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
410 *pDelPam->GetPoint(), nDelCount );
413 if (pDelPam->GetNext() != pDelPam.get()
414 && *pDelPam->GetNext()->End() == *pDelPam->Start())
416 *pDelPam->GetNext()->End() = *pDelPam->End();
417 pDelPam.reset(pDelPam->GetNext());
434 if( !pDelPam->IsMultiSelection() )
436 delete pDelPam->GetNext();
449 lcl_DeleteRedlines( aRgTmp, aCpyTmp );
456 if ( !aSrc.GetNext() )
458 aSrc.SetNext( pDest );
462 if ( !aDest.GetPrev() )
464 aDest.SetPrev( pSrc );
470 bool lcl_ContainsOnlyParagraphsInList(
const SwPaM& rPam )
476 if ( pTextNd && pTextNd->
IsInList() &&
477 pEndTextNd && pEndTextNd->
IsInList() )
487 if ( !pTextNd || !pTextNd->
IsInList() )
492 }
while (pTextNd != pEndTextNd);
498 bool lcl_MarksWholeNode(
const SwPaM & rPam)
500 bool bResult =
false;
501 auto [pStt, pEnd] = rPam.
StartEnd();
503 if (
nullptr != pStt &&
nullptr != pEnd)
508 if (
nullptr != pSttNd &&
nullptr != pEndNd &&
509 pStt->GetContentIndex() == 0 &&
510 pEnd->GetContentIndex() == pEndNd->
Len())
523 void CalcBreaks(std::vector<std::pair<SwNodeOffset, sal_Int32>> & rBreaks,
524 SwPaM const & rPam,
bool const isOnlyFieldmarks)
531 std::stack<std::tuple<sw::mark::IFieldmark const*, bool, SwNodeOffset, sal_Int32>> startedFields;
535 SwNode *
const pNode(rNodes[
n]);
539 sal_Int32
const nStart(
n == nStartNode
542 sal_Int32
const nEnd(
n == nEndNode
545 for (sal_Int32
i = nStart;
i < nEnd; ++
i)
557 if (
n == nEndNode && !isOnlyFieldmarks)
560 if (pAttr && pAttr->
End() && (nEnd < *pAttr->
End()))
563 rBreaks.emplace_back(
n,
i);
570 if (pAttr && (nStart > pAttr->
GetStart()))
572 rBreaks.emplace_back(
n,
i);
581 startedFields.emplace(pFieldMark,
false, 0, 0);
586 if (startedFields.empty())
588 rBreaks.emplace_back(
n,
i);
592 assert(std::get<0>(startedFields.top())->IsCoveringPosition(
SwPosition(rTextNode,
i)));
593 std::get<1>(startedFields.top()) =
true;
594 std::get<2>(startedFields.top()) =
n;
595 std::get<3>(startedFields.top()) =
i;
601 if (startedFields.empty())
603 rBreaks.emplace_back(
n,
i);
627 while (!startedFields.empty())
629 SwPosition const& rStart(std::get<0>(startedFields.top())->GetMarkStart());
630 std::pair<SwNodeOffset, sal_Int32>
const pos(
632 auto it = std::lower_bound(rBreaks.begin(), rBreaks.end(),
pos);
633 assert(it == rBreaks.end() || *it !=
pos);
634 rBreaks.insert(it,
pos);
635 if (std::get<1>(startedFields.top()))
637 std::pair<SwNodeOffset, sal_Int32>
const posSep(
638 std::get<2>(startedFields.top()),
639 std::get<3>(startedFields.top()));
640 it = std::lower_bound(rBreaks.begin(), rBreaks.end(), posSep);
641 assert(it == rBreaks.end() || *it != posSep);
642 rBreaks.insert(it, posSep);
656 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
662 return (rDocumentContentOperations.*pFunc)(rPam, flags);
674 auto iter( Breaks.rbegin() );
677 SwPaM aPam( rSelectionEnd, rSelectionEnd );
681 while (iter != Breaks.rend())
683 rStart.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
686 bRet &= (rDocumentContentOperations.*pFunc)(aPam, flags);
687 nOffset = iter->first - rStart.GetNodeIndex();
689 rEnd.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
693 rStart = *rPam.
Start();
696 bRet &= (rDocumentContentOperations.*pFunc)(aPam, flags);
702 bool lcl_StrLenOverflow(
const SwPaM& rPam )
708 auto [pStt, pEnd] = rPam.
StartEnd();
710 if( (
nullptr != pEndNd) && pStt->GetNode().IsTextNode() )
712 const sal_uInt64 nSum = pStt->GetContentIndex() +
713 pEndNd->
GetText().getLength() - pEnd->GetContentIndex();
734 nStt = pStt->GetNodeIndex() - nSttIdx;
735 nSttCnt = pStt->GetContentIndex();
738 nEnd = pEnd->GetNodeIndex() - nSttIdx;
739 nEndCnt = pEnd->GetContentIndex();
753 nStt = pStt->GetNodeIndex() - nSttIdx;
754 nSttCnt = pStt->GetContentIndex();
759 nEnd = pEnd->GetNodeIndex() - nSttIdx;
760 nEndCnt = pEnd->GetContentIndex();
790 typedef std::vector< SaveRedline > SaveRedlines_t;
792 void lcl_SaveRedlines(
const SwPaM& aPam, SaveRedlines_t& rArr)
796 auto [pStart, pEnd] = aPam.
StartEnd();
801 if( nCurrentRedline > 0)
811 for( ; nCurrentRedline < rRedlineTable.
size(); nCurrentRedline++ )
826 rRedlineTable.
Remove( nCurrentRedline-- );
833 *pNewRedline->
End() = *pStart;
834 *pCurrent->
Start() = *pStart;
843 *pNewRedline->
Start() = *pEnd;
844 *pCurrent->
End() = *pEnd;
849 rArr.emplace_back( pCurrent, *pStart );
857 void lcl_RestoreRedlines(
SwDoc& rDoc,
const SwPosition& rPos, SaveRedlines_t& rArr)
862 for(SaveRedline & rSvRedLine : rArr)
864 rSvRedLine.SetPos( rPos );
871 void lcl_SaveRedlines(
const SwNodeRange& rRg, SaveRedlines_t& rArr)
889 auto [pRStt, pREnd] = pTmp->
StartEnd();
901 rArr.emplace_back(pNewRedl, rRg.
aStart);
903 pTmpPos = pTmp->
End();
914 rRedlTable.
Remove( nRedlPos-- );
916 ( pREnd->GetNode() == rRg.
aEnd.
GetNode() && !pREnd->GetContentIndex()) )
919 rArr.emplace_back( pTmp, rRg.
aStart );
928 rArr.emplace_back( pNewRedl, rRg.
aStart );
930 pTmpPos = pTmp->
Start();
942 void lcl_RestoreRedlines(
SwDoc& rDoc,
SwNodeOffset const nInsPos, SaveRedlines_t& rArr)
947 for(SaveRedline & rSvRedLine : rArr)
949 rSvRedLine.SetPos( nInsPos );
953 rSvRedLine.pRedl->GetType() == RedlineType::Delete )
962 bool lcl_SaveFootnote(
const SwNode& rSttNd,
const SwNode& rEndNd,
965 std::optional<sal_Int32> oSttCnt = std::nullopt, std::optional<sal_Int32> oEndCnt = std::nullopt )
967 bool bUpdateFootnote =
false;
971 const bool bSaveFootnote = !bDelFootnote &&
973 if( !rFootnoteArr.
empty() )
979 const SwNode* pFootnoteNd;
982 while( nPos < rFootnoteArr.
size() && ( pFootnoteNd =
983 &( pSrch = rFootnoteArr[ nPos ] )->GetTextNode())->GetIndex()
986 const sal_Int32 nFootnoteSttIdx = pSrch->
GetStart();
987 if( ( oEndCnt && oSttCnt )
988 ? (( &rSttNd == pFootnoteNd &&
989 *oSttCnt > nFootnoteSttIdx) ||
990 ( &rEndNd == pFootnoteNd &&
991 nFootnoteSttIdx >= *oEndCnt ))
992 : ( &rEndNd == pFootnoteNd ))
1008 rFootnoteArr.
erase( rFootnoteArr.
begin() + nPos );
1010 rSaveArr.
insert( pSrch );
1012 bUpdateFootnote =
true;
1016 while( nPos-- && ( pFootnoteNd = &( pSrch = rFootnoteArr[ nPos ] )->
1017 GetTextNode())->GetIndex() >= rSttNd.
GetIndex() )
1019 const sal_Int32 nFootnoteSttIdx = pSrch->
GetStart();
1020 if( !oEndCnt || !oSttCnt ||
1021 ! (( &rSttNd == pFootnoteNd &&
1022 *oSttCnt > nFootnoteSttIdx ) ||
1023 ( &rEndNd == pFootnoteNd &&
1024 nFootnoteSttIdx >= *oEndCnt )) )
1036 rFootnoteArr.
erase( rFootnoteArr.
begin() + nPos );
1038 rSaveArr.
insert( pSrch );
1040 bUpdateFootnote =
true;
1050 while( aIdx < rEndNd )
1052 SwNode* pNode = &aIdx.GetNode();
1058 bUpdateFootnote =
true;
1060 for(
size_t i = 0;
i <
nCount; ++
i )
1073 return bUpdateFootnote;
1076 bool lcl_MayOverwrite(
const SwTextNode *pNode,
const sal_Int32 nPos )
1098 if( !lcl_MayOverwrite( pNode, rStart ) )
1104 }
while (rStart < pNode->GetText().
getLength()
1105 && !lcl_MayOverwrite(pNode, rStart) );
1109 bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet,
bool bRegExpRplc )
1114 static const OUStringLiteral sPara(u
"\\n");
1117 nPos = rStr.indexOf( sPara, nPos );
1123 if( nPos &&
'\\' == rStr[nPos-1])
1126 if( nPos >= rStr.getLength() )
1133 rRet = rStr.copy( 0, nPos );
1134 rStr = rStr.copy( nPos + sPara.getLength() );
1148 bool lcl_ApplyOtherSet(
1157 assert(rOtherSet.
Count());
1168 pMerged = pTextFrame->GetMergedPara();
1172 if (rFirstSet.
Count())
1176 SwRegHistory aRegH(pMerged->pFirstNode, *pMerged->pFirstNode, pHistory);
1177 ret = pMerged->pFirstNode->SetAttr(rFirstSet);
1181 ret = pMerged->pFirstNode->SetAttr(rFirstSet);
1184 if (rPropsSet.
Count())
1188 SwRegHistory aRegH(pMerged->pParaPropsNode, *pMerged->pParaPropsNode, pHistory);
1189 ret = pMerged->pParaPropsNode->SetAttr(rPropsSet) || ret;
1193 ret = pMerged->pParaPropsNode->SetAttr(rPropsSet) || ret;
1198 *o_pIndex = *pMerged->pLastNode;
1212 ret = rNode.
SetAttr( rOtherSet );
1216 ret = rNode.
SetAttr( rOtherSet );
1222 #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
1225 void lcl_SetRedline(
1229 std::unique_ptr<SwRedlineExtraData_FormatColl> xExtra;
1239 pRStt = pTmp->
Start();
1240 pREnd = pTmp->
End();
1250 if (pFormattingChanges)
1287 aSet.ClearInvalidItems();
1302 void lcl_SetRedlines(
1308 while( aIdx <= aEndNd )
1313 const sal_Int32 nStart = aIdx == rRg.
Start()->
GetNode()
1316 const sal_Int32 nEnd = aIdx < aEndNd
1317 ? pNode->
GetText().getLength()
1323 sal_Int32 nRedEnd = nStart;
1324 for(
size_t i = 0;
i <
nCount; ++
i )
1339 if ( nRedEnd < pAttr->GetStart() )
1342 lcl_SetRedline(rDoc, aPam);
1346 sal_Int32 nRedStart = std::max(pAttr->
GetStart(), nStart);
1348 SwPaM aPam2( *pNode, nRedStart, *pNode, nRedEnd );
1349 lcl_SetRedline(rDoc, aPam2);
1353 if ( nRedEnd < nEnd )
1355 SwPaM aPam( *pNode, nRedEnd, *pNode, nEnd );
1356 lcl_SetRedline(rDoc, aPam);
1361 SwPaM aPam( *pNode, nStart, *pNode, nEnd );
1362 lcl_SetRedline(rDoc, aPam);
1384 bool bDelete =
false;
1385 bool bCharAttr =
false;
1386 bool bOtherAttr =
false;
1389 if ( 1 == rChgSet.
Count() )
1395 const sal_uInt16 nWhich = pItem->
Which();
1403 pCharSet = &rChgSet;
1414 pOtherSet = &rChgSet;
1423 if ( !bCharAttr && !bOtherAttr )
1437 pTmpCharItemSet->
Put( rChgSet );
1438 pTmpOtherItemSet->Put( rChgSet );
1440 pCharSet = pTmpCharItemSet;
1441 pOtherSet = pTmpOtherItemSet;
1459 auto nStartIndex = pNode->
GetIndex();
1460 auto nEndIndex = pEndNode->
GetIndex();
1462 while ( pCurrentNode !=
nullptr && nStartIndex <= pCurrentNode->GetIndex() )
1466 (nStartIndex < pCurrentNode->GetIndex() || pStt->
GetContentIndex() == 0) &&
1467 (pCurrentNode->
GetIndex() < nEndIndex || pEnd->GetContentIndex() == pEndNode->
Len()))
1488 OSL_FAIL(
"<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect." );
1501 SwNumFormat aNumFormat = pNumRule->
Get(o3tl::narrowing<sal_uInt16>(nLevel));
1519 if ( !bCharAttr && !bOtherAttr )
1523 aTextSet.Put( rChgSet );
1524 if( aTextSet.Count() )
1527 bRet = history.InsertItems(
1548 if ( !bCharAttr && !bOtherAttr )
1558 aTextSet.Put( rChgSet );
1559 if( aTextSet.Count() )
1562 const sal_Int32 nEnd = pStt->
GetNode() == pEnd->GetNode()
1563 ? pEnd->GetContentIndex()
1566 bRet = history.InsertItems( aTextSet, nInsCnt, nEnd, nFlags, ppNewTextAttr )
1575 SwPaM aPam( pStt->
GetNode(), bTextIns ? nInsCnt + 1 : nEnd,
1583 bTextIns ? RedlineType::Insert : RedlineType::Format, aPam ),
1593 if( pOtherSet && pOtherSet->
Count() )
1610 pTableNd = pCurTableNd;
1625 SwRegHistory aRegH( pFirstNode, *pFirstNode, pHistory );
1626 bRet = pFirstNode->SetAttr( aNew ) || bRet;
1637 if( !pOtherSet->
Count() )
1652 pTableNd = pCurTableNd;
1667 if( !pOtherSet->
Count() )
1676 sal_uInt16 nPoolId=0;
1687 if (pOtherSet && pOtherSet->
Count())
1689 firstSet.Put(*pOtherSet);
1695 if (pOtherSet && pOtherSet->
Count())
1697 propsSet.Put(*pOtherSet);
1712 const OUString& rStr = pTextNd->
GetText();
1717 if (pURLAttr && !pURLAttr->GetINetFormat().GetValue().isEmpty())
1719 nMkPos = pURLAttr->GetStart();
1720 nPtPos = *pURLAttr->End();
1728 WordType::ANY_WORD ,
1731 if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
1733 nMkPos = aBndry.startPos;
1734 nPtPos = aBndry.endPos;
1745 pTextNd->
HasHints() && !nMkPos && nPtPos == rStr.getLength())
1762 SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
1767 lcl_SetRedlines(rDoc, aPam);
1773 bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags,
nullptr )
1777 if( pOtherSet && pOtherSet->
Count() )
1785 bRet = lcl_ApplyOtherSet(*pNode, pHistory, aTempLocalCopy, firstSet, propsSet, pLayout) || bRet;
1797 lcl_SetRedlines(rDoc, rRg);
1805 SwContentIndex aCntEnd( pEnd->GetContentNode(), pEnd->GetContentIndex() );
1809 const sal_Int32 nLen = pNode->
Len();
1810 if( pStt->
GetNode() != pEnd->GetNode() )
1811 aCntEnd.Assign( pNode, nLen );
1819 bRet = history.InsertItems(*pCharSet,
1824 if( pOtherSet && pOtherSet->
Count() )
1826 bRet = lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout) || bRet;
1830 if( pStt->
GetNode() == pEnd->GetNode() )
1836 aSt.Assign( pStt->
GetNode(), +1 );
1840 aCntEnd.Assign(pEnd->GetContentNode(), pEnd->GetContentIndex());
1843 aSt.Assign( pStt->
GetNode(), +1 );
1850 if( pStt->
GetNode() < pEnd->GetNode() )
1855 if( aCntEnd.GetIndex() != pNode->
Len() )
1861 (void)history.InsertItems(*pCharSet,
1862 0, aCntEnd.GetIndex(), nFlags,
nullptr);
1865 if( pOtherSet && pOtherSet->
Count() )
1867 lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout);
1871 aEnd = pEnd->GetNode();
1874 aEnd.Assign( pEnd->GetNode(), +1 );
1877 aEnd = pEnd->GetNode();
1880 aEnd.Assign( pEnd->GetNode(), +1 );
1889 pStt, pEnd, pHistory, pCharSet, pLayout);
1893 bool bCreateSwpHints = pCharSet && (
1897 for (
SwNodeIndex current = aSt; current < aEnd; ++current)
1913 if (pCharSet && pCharSet->
Count())
1918 pSwpHints->Register( &aRegH );
1921 pTNd->
SetAttr(*pCharSet, 0, pTNd->
GetText().getLength(), nFlags);
1925 pSwpHints->DeRegister();
1930 if (pCharSet && pCharSet->
Count())
1931 pTNd->
SetAttr(*pCharSet, 0, pTNd->
GetText().getLength(), nFlags);
1936 if (pOtherSet && pOtherSet->
Count())
1938 for (; aSt < aEnd; ++aSt)
1944 lcl_ApplyOtherSet(*pNode, pHistory, *pOtherSet, firstSet, propsSet, pLayout, &aSt);
1950 return (nNodes != 0) || bRet;
1961 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
1963 return !Breaks.empty();
1989 return rEnd < rStart;
2012 nEnd = pEnd->GetNodeIndex(),
2013 nDiff = nEnd - nStt +1;
2027 lcl_ChkFlyFly( rDoc, nStt, nEnd, rPos.
GetNodeIndex() ) )
2033 SwPaM* pRedlineRange =
nullptr;
2036 pRedlineRange =
new SwPaM( rPos );
2046 else if( ! ( *pStt <= rPos && rPos < *pEnd &&
2047 ( pStt->
GetNode() != pEnd->GetNode() ||
2057 assert(!
"mst: this is assumed to be dead code");
2067 delete pRedlineRange;
2089 assert(pNode &&
"Didn't pass a Node.");
2102 SwPaM const range(aSttIdx, aEndIdx);
2113 SwPaM aPam(rPos, rPos);
2115 assert(aPam.
GetText().getLength() == 1 && aPam.
GetText()[0] == cDummy);
2154 SwPaM temp(rPam,
nullptr);
2175 bool bSavePageBreak =
false, bSavePageDesc =
false;
2192 bSavePageDesc =
true;
2199 bSavePageBreak =
true;
2209 else if( rPam.
GetPoint() == &rStt )
2214 bool bGoNext = (
nullptr == pTmpNode);
2234 pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
2250 SAL_WARN(
"sw.core",
"DelFullPara: no more Nodes");
2260 ::std::set<::sw::mark::IFieldmark*> fieldmarks;
2263 if (
SwTextNode *
const pTextNode =
i.GetNode().GetTextNode())
2265 for (sal_Int32 j = 0; j < pTextNode->GetText().
getLength(); ++j)
2267 switch (pTextNode->GetText()[j])
2280 for (
auto const pFieldMark : fieldmarks)
2304 ((RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()) ||
2305 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId())) &&
2327 if ( lcl_StrLenOverflow( rPam ) )
2344 if( !rPaM.
HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd))
2354 SaveRedlines_t aSaveRedl;
2357 lcl_SaveRedlines( rPaM, aSaveRedl );
2369 pEnd->GetContentIndex());
2372 bool bUpdateFootnote =
false;
2375 std::unique_ptr<SwUndoMove> pUndoMove;
2379 pUndoMove.reset(
new SwUndoMove( rPaM, rPos ));
2384 bUpdateFootnote = lcl_SaveFootnote( pStt->
GetNode(), pEnd->GetNode(), rPos.
GetNode(),
2389 bool bSplit =
false;
2390 SwPaM aSavePam( rPos, rPos );
2398 bool bCorrSavePam = pSrcNd && pStt->
GetNode() != pEnd->GetNode();
2423 if (!pContentStore->Empty())
2425 pContentStore->Restore(m_rDoc, pOrigNode->GetIndex()-SwNodeOffset(1), 0, true, false, eMode);
2475 std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
2481 pEnd->GetContentIndex());
2499 OSL_ENSURE( *aSavePam.
GetMark() == rPos ||
2501 "PaM was not moved. Aren't there ContentNodes at the beginning/end?" );
2507 bool bRemove =
true;
2530 for(
auto& rBkmk : aSaveBkmks)
2544 if( !aSaveRedl.empty() )
2546 lcl_RestoreRedlines(
m_rDoc, *aSavePam.
Start(), aSaveRedl );
2549 if( bUpdateFootnote )
2551 if( !aTmpFntIdx.
empty() )
2575 bool bUpdateFootnote =
false;
2578 std::unique_ptr<SwUndoMove> pUndo;
2589 SaveRedlines_t aSaveRedl;
2590 std::vector<SwRangeRedline*> aSavRedlInsPosArr;
2593 lcl_SaveRedlines( rRange, aSaveRedl );
2603 pRStt = pTmp->
Start();
2604 pREnd = pTmp->
End();
2607 aSavRedlInsPosArr.push_back( pTmp );
2616 std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
2627 std::optional<SwNodeIndex> oSaveInsPos;
2629 oSaveInsPos.emplace(rRange.
aStart, -1 );
2646 if( !aSaveFlyArr.empty() )
2653 for(
auto& rBkmk : aSaveBkmks)
2656 if( !aSavRedlInsPosArr.empty() )
2668 if( !aSaveRedl.empty() )
2673 pUndo->SetDestRange( aIdx.
GetNode(), rDestNd, *oSaveInsPos );
2677 oSaveInsPos.reset();
2679 if( bUpdateFootnote )
2681 if( !aTmpFntIdx.
empty() )
2702 if( !bRet || bOneNode )
2725 assert(rStr.getLength());
2729 if( 1 == rStr.getLength() )
2735 if (!pNode || rStr.getLength() > pNode->
GetSpaceLeft())
2749 sal_Int32 nStart = 0;
2754 for( sal_Int32 nCnt = 0; nCnt < rStr.getLength(); ++nCnt )
2758 if (nStart < pNode->GetText().
getLength())
2760 lcl_SkipAttr( pNode, rPt, nStart );
2765 bool bMerged(
false);
2780 std::make_unique<SwUndoOverwrite>(
m_rDoc, rPt, c) );
2786 if (nStart < pNode->GetText().
getLength())
2801 if( nOldAttrCnt != nNewAttrCnt )
2861 OUString
const ins(pNode->
InsertText(rStr, rPos, nInsertMode));
2865 std::make_unique<SwUndoInsert>(rPos.
GetNode(),
2879 if (pUndoInsert && pUndoInsert->
CanGrouping(rPos))
2881 pUndo = pUndoInsert;
2895 OUString
const ins(pNode->
InsertText(rStr, rPos, nInsertMode));
2897 for (sal_Int32
i = 0;
i < ins.getLength(); ++
i)
2944 std::unique_ptr<SwUndoTransliterate> pUndo;
2948 auto [pStt, pEnd] = rPaM.
StartEnd();
2950 nEndNd = pEnd->GetNodeIndex();
2952 sal_Int32 nEndCnt = pEnd->GetContentIndex();
2955 if( (pStt == pEnd) && pTNd )
2962 WordType::ANY_WORD ,
2965 if( aBndry.startPos < nSttCnt && nSttCnt < aBndry.endPos )
2968 if (rTrans.
getType() == TransliterationFlags::SENTENCE_CASE) {
2978 nSttCnt = aBndry.startPos;
2979 nEndCnt = aBndry.endPos;
2990 if ( bUseRedlining )
2993 const bool bIsTitleCase = rTrans.
getType() == TransliterationFlags::TITLE_CASE;
2997 for( ; aIdx.
GetIndex() <= nEndNd; ++aIdx )
3002 if( !pAffectedNode || pAffectedNode->
GetText().isEmpty() )
3010 nAffectedChars += pAffectedNode->
GetText().getLength();
3014 if( nAffectedNodes > nMaxRedlines ||
3017 ( bIsTitleCase && (nAffectedChars - nSttCnt)/6 > nMaxRedlines ) )
3019 bUseRedlining =
false;
3025 if( nSttNd != nEndNd )
3037 rTrans, nSttCnt, pTNd->
GetText().getLength(), pUndo.get(), bUseRedlining);
3041 for( ; aIdx.
GetIndex() < nEndNd; ++aIdx )
3047 rTrans, 0, pTNd->
GetText().getLength(), pUndo.get(), bUseRedlining);
3051 if( nEndCnt &&
nullptr != ( pTNd = pEnd->GetNode().
GetTextNode() ))
3056 else if( pTNd && nSttCnt < nEndCnt )
3058 pTNd->
TransliterateText( rTrans, nSttCnt, nEndCnt, pUndo.get(), bUseRedlining );
3060 if( pUndo && pUndo->HasData() )
3069 const OUString& rGrfName,
3070 const OUString& rFltName,
3080 rGrfName, rFltName, pGraphic,
3083 pFlyAttrSet, pGrfAttrSet, pFrameFormat );
3084 return pSwFlyFrameFormat;
3107 pFlyAttrSet,
nullptr,
3125 pFlyAttrSet, pGrfAttrSet,
3130 const OUString& rFltName,
const Graphic* pGraphic )
3148 pGrfNd->
ReRead( rGrfName, rFltName, pGraphic );
3166 const bool bIsAtContent = (RndStdIds::FLY_AT_PAGE != eAnchorId);
3169 if ( pAnchor ==
nullptr )
3173 else if ( bIsAtContent )
3180 if( pChkPos !=
nullptr
3185 eAnchorId = RndStdIds::FLY_AT_PAGE;
3188 else if( pAnchor ==
nullptr
3195 if ( eAnchorId == RndStdIds::FLY_AT_FLY )
3205 if ( eAnchorId == RndStdIds::FLY_AT_PAGE )
3207 eAnchorId =
dynamic_cast<const SdrUnoObj*
>( &rDrawObj) !=
nullptr ? RndStdIds::FLY_AS_CHAR : RndStdIds::FLY_AT_PARA;
3215 if ( eAnchorId == RndStdIds::FLY_AS_CHAR )
3217 bool bAnchorAtPageAsFallback =
true;
3223 if ( pAnchorTextNode !=
nullptr )
3227 pAnchorTextNode->
InsertItem( aFormat, nStt, nStt );
3228 bAnchorAtPageAsFallback =
false;
3232 if ( bAnchorAtPageAsFallback )
3234 OSL_ENSURE(
false,
"DocumentContentOperationsManager::InsertDrawObj(..) - missing content anchor for as-character anchored drawing object --> anchor at-page" );
3267 if(
nullptr == pNode)
3292 if( pTextNode &&
nPos &&
nPos != pTextNode->
Len() )
3307 nullptr != ( pTableNd =
m_rDoc.
GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
3373 if (!pContentStore->Empty())
3375 pContentStore->Restore(m_rDoc, rPos.GetNodeIndex()-SwNodeOffset(1), 0, true, bAtStart && (eMode & sw::mark::RestoreMode::Flys), eMode);
3386 aPam.Move( fnMoveBackward );
3387 if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn())
3389 m_rDoc.getIDocumentRedlineAccess().AppendRedline(
3390 new SwRangeRedline(RedlineType::Insert, aPam), true);
3394 m_rDoc.getIDocumentRedlineAccess().SplitRedline(aPam);
3405bool DocumentContentOperationsManager::AppendTextNode(
SwPosition& rPos )
3442bool DocumentContentOperationsManager::ReplaceRange(
SwPaM& rPam,
const OUString& rStr,
3443 const bool bRegExReplace )
3448 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
3460 while (!Breaks.empty()
3466 Breaks.erase(Breaks.begin());
3475 return ReplaceRangeImpl(rPam, rStr, bRegExReplace);
3485 auto iter( Breaks.rbegin() );
3488 OSL_ENSURE(aPam.
GetPoint() == aPam.
End(),
"wrong!");
3496 while (iter != Breaks.rend())
3498 rStart.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
3506 rEnd.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
3510 rStart = *rPam.
Start();
3511 assert(rStart < rEnd &&
"replace part empty!");
3514 bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace);
3522bool DocumentContentOperationsManager::InsertPoolItem(
3530 std::unique_ptr<SwUndoAttr> pUndoAttr;
3534 pUndoAttr.reset(
new SwUndoAttr( rRg, rHt, nFlags ));
3539 const bool bRet = lcl_InsAttr(
m_rDoc, rRg, aSet, nFlags, pUndoAttr.get(), pLayout, ppNewTextAttr);
3553void DocumentContentOperationsManager::InsertItemSet (
const SwPaM &rRg,
const SfxItemSet &rSet,
3557 std::unique_ptr<SwUndoAttr> pUndoAttr;
3564 bool bRet = lcl_InsAttr(
m_rDoc, rRg,
rSet, nFlags, pUndoAttr.get(), pLayout,
nullptr );
3575void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(
const SwPosition & rPos )
3581 const OUString& rText = pTNd->
GetText();
3583 while (nIdx < rText.getLength())
3586 if ((
'\t' != cCh) && (
' ' != cCh))
3599 DeleteRange( aPam );
3603void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(
SwPaM& rPaM )
3610 RemoveLeadingWhiteSpace(
SwPosition(rSel.GetBound().GetNodes(),
nPos));
3617void DocumentContentOperationsManager::CopyWithFlyInFly(
3620 const std::pair<const SwPaM&, const SwPosition&>* pCopiedPaM ,
3621 const bool bMakeNewFrames,
3622 const bool bDelRedlines,
3623 const bool bCopyFlyAtFly,
3626 assert(!pCopiedPaM || pCopiedPaM->first.End()->GetNode() == rRg.
aEnd.
GetNode());
3627 assert(!pCopiedPaM || pCopiedPaM->second.GetNode() <= rInsPos);
3634 bool bEndIsEqualEndPos = rInsPos == rRg.
aEnd.
GetNode();
3642 if (bEndIsEqualEndPos)
3656 if (pCopiedPaM && rRg.
aStart != pCopiedPaM->first.Start()->
GetNode())
3664 targetPos = pCopiedPaM->second;
3672 bool isRecreateEndNode(
false);
3683 if (pFrame->getRootFrame()->HasMergedParas())
3687 if (pNode ==
nullptr && pFrame->GetMergedPara()
3690 pNode = pFrame->GetMergedPara()->pFirstNode;
3695 if (pNode !=
nullptr)
3698 if (!frames.
empty())
3703 if (pFrame->getRootFrame()->HasMergedParas())
3705 auto const it = frames.
find(pFrame);
3706 if (it != frames.
end())
3712 if (!frames.
empty())
3715 isRecreateEndNode =
true;
3729 SwNodeOffset((!isRecreateEndNode || isAtStartOfSection)
3735#if OSL_DEBUG_LEVEL > 0
3743 if( pSSectNd == pESectNd &&
3751 "An insufficient number of nodes were copied!" );
3758 CopyFlyInFlyImpl(rRg, pCopiedPaM ? &pCopiedPaM->first :
nullptr,
3760 (pCopiedPaM && rRg.
aStart != pCopiedPaM->first.Start()->
GetNode())
3761 ? pCopiedPaM->second.GetNode()
3770 lcl_DeleteRedlines( rRg, aCpyRange );
3777void DocumentContentOperationsManager::CopyFlyInFlyImpl(
3779 SwPaM const*
const pCopiedPaM,
3781 const bool bCopyFlyAtFly,
3790 std::set< ZSortFly > aSet;
3796 for (
size_t n = 0;
n < nArrLen; ++
n )
3808 case RndStdIds::FLY_AT_FLY:
3814 case RndStdIds::FLY_AT_PARA:
3824 case RndStdIds::FLY_AT_CHAR:
3837 if (RndStdIds::FLY_AT_FLY == pAnchor->
GetAnchorId())
3839 if (nStart > nSkipAfter)
3861 aSet.insert(
ZSortFly( pFormat, pAnchor, nArrLen + aSet.size() ));
3868 std::vector< SwFrameFormat* > aVecSwFrameFormat;
3869 std::set< ZSortFly >::const_iterator it=aSet.begin();
3871 while (it != aSet.end())
3885 if ((aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
3886 (aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR) )
3891 bool bAnchorTextNdFound(
false );
3894 while ( !bAnchorTextNdFound && aIdx <= rRg.
aEnd )
3898 ++nAnchorTextNdNumInRange;
3905 if ( !bAnchorTextNdFound )
3909 OSL_FAIL(
"<SwDoc::_CopyFlyInFly(..)> - anchor text node in copied range not found" );
3910 nAnchorTextNdNumInRange = 1;
3917 const SwNode& aEndOfContentNd =
3919 while ( nAnchorTextNdNumInRange > 0 &&
3920 aIdx.
GetNode() != aEndOfContentNd )
3924 --nAnchorTextNdNumInRange;
3925 aAnchorNdIdx = aIdx;
3934 OSL_FAIL(
"<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" );
3935 aAnchorNdIdx = rStartIdx;
3942 newPos.
Assign( aAnchorNdIdx );
3947 newPos.
Assign( rStartIdx, nOffset );
3950 if ((RndStdIds::FLY_AT_CHAR == aAnchor.
GetAnchorId()) &&
3971 it = aSet.erase(it);
3980 it = aSet.erase(it);
3986 aAnchor,
false,
true ) );
3991 OSL_ENSURE( aSet.size() == aVecSwFrameFormat.size(),
"Missing new Flys" );
3992 if ( aSet.size() != aVecSwFrameFormat.size() )
3996 for (
const auto& rFlyN : aSet)
4001 for (
const auto& rFlyK : aSet)
4004 if ( rChain.
GetPrev() == pFormatK )
4006 ::lcl_ChainFormats(
static_cast< SwFlyFrameFormat*
>(aVecSwFrameFormat[k]),
4009 else if ( rChain.
GetNext() == pFormatK )
4031bool DocumentContentOperationsManager::lcl_RstTextAttr(
SwNode* pNd,
void* pArgs )
4043 sal_Int32 nEnd = pTextNode->
Len();
4069DocumentContentOperationsManager::~DocumentContentOperationsManager()
4074bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl(
SwPaM & rPam,
SwDeleteFlags const flags)
4085 std::vector<std::unique_ptr<SwRangeRedline>> redlines;
4087 auto pRedline(std::make_unique<SwRangeRedline>(RedlineType::Delete, rPam));
4088 if (pRedline->HasValidRange())
4090 redlines.push_back(std::move(pRedline));
4098 if (redlines.empty())
4109 std::vector<std::unique_ptr<SwUndo>> MarkUndos;
4110 for (
auto iter = rDMA.getAnnotationMarksBegin();
4111 iter != rDMA.getAnnotationMarksEnd(); )
4115 SwPosition const& rEndPos((**iter).GetMarkEnd());
4116 if (*rPam.
Start() < rEndPos && rEndPos <= *rPam.
End())
4120 MarkUndos.emplace_back(std::make_unique<SwUndoDeleteBookmark>(**iter));
4123 rDMA.deleteMark(&**iter);
4125 iter = rDMA.getAnnotationMarksBegin();
4129 if (*rPam.
End() < (**iter).GetMarkStart())
4141 std::vector<std::unique_ptr<SwUndoRedlineDelete>> undos;
4147 "sw.core",
"redlines will be moved in DeleteAndJoin");
4151 for (std::unique_ptr<SwRangeRedline> & pRedline : redlines)
4153 assert(pRedline->HasValidRange());
4154 undos.emplace_back(std::make_unique<SwUndoRedlineDelete>(
4157 const SwRewriter aRewriter = undos.front()->GetRewriter();
4159 if (MarkUndos.empty() && undos.size() == 1
4164 bool const bMerged = pUndoRedlineDel
4175 for (
auto& it : MarkUndos)
4179 for (
auto & it : undos)
4186 for (std::unique_ptr<SwRangeRedline> & pRedline : redlines)
4192 *pCursor->GetPoint() = *pRedline->GetPoint();
4218 bool bJoinText, bJoinPrev;
4221 bool const bSuccess( DeleteRangeImpl(rPam, flags) );
4249 bool const bSuccess( DeleteRangeImplImpl(aDelPam, flags) );
4260 auto [pStt, pEnd] = rPam.
StartEnd();
4284 for(
size_t n = pHts->
Count();
n; )
4287 if( nMkCntPos > pAttr->
GetStart() )
4290 const sal_Int32 *pEndIdx;
4291 if( nMkCntPos == pAttr->
GetStart() &&
4292 nullptr != (pEndIdx = pAttr->
End()) &&
4309 bool bMerged(
false);
4345 pEnd->GetContentIndex());
4354 if ( pStartTextNode )
4357 bool bOneNd = pStt->
GetNode() == pEnd->GetNode();
4358 const sal_Int32 nLen = ( bOneNd ? pEnd->GetContentIndex()
4365 pStartTextNode->
EraseText( *pStt, nLen );
4367 if( !pStartTextNode->
Len() )
4370 pStartTextNode->RemoveMetadataReference();
4394 if( pEnd->GetContentIndex() )
4397 pEndTextNode->
EraseText( aIdx, pEnd->GetContentIndex() );
4399 if( !pEndTextNode->
Len() )
4402 pEndTextNode->RemoveMetadataReference();
4410 pEnd->nContent.Assign(
nullptr, 0 );
4416 if( pCNd ==
nullptr )
4419 if( aSttIdx != nEnd )
4427 && aSttIdx <= pTmpNd->StartOfSectionNode()->GetIndex())
4458bool DocumentContentOperationsManager::ReplaceRangeImpl(
SwPaM& rPam,
const OUString& rStr,
4459 const bool bRegExReplace )
4464 bool bJoinText, bJoinPrev;
4474 auto [pStt, pEnd] = aDelPam.
StartEnd();
4475 bool bOneNode = pStt->
GetNode() == pEnd->GetNode();
4478 OUString sRepl( rStr );
4492 "sw.core",
"redlines will be moved in ReplaceRange");
4497 const ::sw::mark::IMark* pBkmk =
4500 ::sw::mark::InsertMode::New);
4505 *aDelPam.
GetPoint() = pBkmk->GetMarkPos();
4506 if(pBkmk->IsExpanded())
4507 *aDelPam.
GetMark() = pBkmk->GetOtherMarkPos();
4509 pStt = aDelPam.
Start();
4514 if( !sRepl.isEmpty() )
4538 while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
4540 InsertString( aDelPam, sIns );
4546 SplitNode( *aDelPam.
GetPoint(),
false );
4553 SplitNode( *aDelPam.
GetPoint(),
false );
4555 if( !sIns.isEmpty() )
4557 InsertString( aDelPam, sIns );
4568 InsertItemSet( aTmpRange, aSet );
4587 *pCursor->GetPoint() = *aDelPam.
GetPoint();
4599 const ::sw::mark::IMark* pBkmk =
4602 ::sw::mark::InsertMode::New);
4610 *rPam.
GetPoint() = pBkmk->GetMarkPos();
4611 *rPam.
GetMark() = pBkmk->IsExpanded() ? pBkmk->GetOtherMarkPos() : pBkmk->GetMarkPos();
4619 assert((pStt->
GetNode() == pEnd->GetNode() ||
4621 !pEnd->GetContentIndex() )) &&
4622 "invalid range: Point and Mark on different nodes" );
4631 pUndoRpl =
new SwUndoReplace(aDelPam, sRepl, bRegExReplace);
4644 nEnd = bOneNode ? pEnd->GetContentIndex()
4645 : pTextNd->
GetText().getLength();
4649 while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
4651 if (!bFirst || nStt == pTextNd->
GetText().getLength())
4653 InsertString( aDelPam, sIns );
4655 else if( nStt < nEnd || !sIns.isEmpty() )
4659 SplitNode( *pStt,
false);
4663 if( bFirst || !sIns.isEmpty() )
4665 if (!bFirst || nStt == pTextNd->
GetText().getLength())
4667 InsertString( aDelPam, sIns );
4669 else if( nStt < nEnd || !sIns.isEmpty() )
4685 else if (aDelPam.
GetPoint() == pStt)
4717 pFlyAttrSet, pFrameFormat );
4719 pNode->
SetAttr( *pGrfAttrSet );
4724#define NUMRULE_STATE \
4725 std::shared_ptr<SwNumRuleItem> aNumRuleItemHolderIfSet; \
4726 std::shared_ptr<SfxStringItem> aListIdItemHolderIfSet; \
4728#define PUSH_NUMRULE_STATE \
4729 lcl_PushNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd );
4731#define POP_NUMRULE_STATE \
4732 lcl_PopNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd, rPam );
4735 std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
4736 std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
4742 if (pAttrSet ==
nullptr)
4747 aNumRuleItemHolderIfSet.reset(pItem->
Clone());
4752 aListIdItemHolderIfSet.reset(pItem->
Clone());
4757 const std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
4758 const std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
4764 if ( lcl_MarksWholeNode(rPam) )
4767 if (aNumRuleItemHolderIfSet)
4769 pDestTextNd->
SetAttr(*aNumRuleItemHolderIfSet);
4776 if (aListIdItemHolderIfSet)
4778 pDestTextNd->
SetAttr(*aListIdItemHolderIfSet);
4788 SwPaM *
const pCopyRange)
const
4790 std::vector<std::pair<SwNodeOffset, sal_Int32>> Breaks;
4796 return CopyImplImpl(rPam, rPos, flags, pCopyRange);
4804 auto iter( Breaks.rbegin() );
4807 SwPaM aPam( rSelectionEnd, rSelectionEnd );
4810 SwPaM copyRange(rPos, rPos);
4812 while (iter != Breaks.rend())
4814 rStart.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1);
4831 rEnd.
Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second);
4835 rStart = *rPam.
Start();
4855 SwPaM *
const pCpyRange)
const
4860 auto [pStt, pEnd] = rPam.
StartEnd();
4866 ( &rDoc == &
m_rDoc && *pStt <= rPos && rPos < *pEnd ))
4871 const bool bEndEqualIns = &rDoc == &
m_rDoc && rPos == *pEnd;
4877 std::shared_ptr<SwUnoCursor>
const pCopyPam(rDoc.
CreateUnoCursor(rPos));
4880 std::optional<std::vector<SwFrameFormat*>> pFlys;
4881 std::vector<SwFrameFormat*>
const* pFlysAtInsPos;
4891 pFlysAtInsPos = pFlys ? &*pFlys :
nullptr;
4899 pCopyPam->SetMark();
4902 bool bAfterTable =
false;
4906 *(pCopyPam->GetPoint()) = rPos;
4908 bCanMoveBack =
false;
4914 assert(pCopyPam->GetPoint()->GetContentIndex() == 0);
4919 const bool bOneNode = pStt->
GetNode() == pEnd->GetNode();
4924 ( (pDestTextNd && !pDestTextNd->
GetText().getLength()) ||
4926 bool bCopyBookmarks =
true;
4927 bool bCopyPageSource =
false;
4941 OUString aListIdToPropagate;
4943 rDoc.
SearchNumRule( rPos,
false,
true,
false, 0, aListIdToPropagate,
nullptr,
true );
4944 if ( !pNumRuleToPropagate )
4946 pNumRuleToPropagate =
4947 rDoc.
SearchNumRule( rPos,
false,
false,
false, 0, aListIdToPropagate,
nullptr,
true );
4953 if ( pNumRuleToPropagate &&
4954 pDestTextNd && !pDestTextNd->
GetText().getLength() &&
4956 !lcl_ContainsOnlyParagraphsInList( rPam ) )
4958 pNumRuleToPropagate =
nullptr;
4970 bool bCopyOk =
false;
4981 aDestIdx.
Assign( pDestTextNd, 0 );
4982 bCopyCollFormat =
true;
4984 else if( !bOneNode || bColumnSel )
4986 const sal_Int32 nContentEnd = pEnd->GetContentIndex();
4992 if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
5001 pDestTextNd, pDestTextNd->
GetText().getLength());
5006 bool bChg = pEnd != rPam.
GetPoint();
5013 else if( rPos == *pEnd )
5017 pEnd->SetContent( nContentEnd );
5025 if( bCopyCollFormat && bOneNode )
5032 const sal_Int32 nCpyLen = ( bOneNode
5033 ? pEnd->GetContentIndex()
5034 : pSttTextNd->
GetText().getLength())
5036 pSttTextNd->
CopyText( pDestTextNd, aDestIdx, *pStt, nCpyLen );
5038 pEnd->AdjustContent( -nCpyLen );
5045 if (bCopyCollFormat)
5056 CopyFlyInFlyImpl(aRg, &rPam, *pDestTextNd,
false);