30#include <osl/diagnose.h>
88typedef std::vector<SwTextAttr*>
SwpHts;
110#define CHECK_SWPHINTS(pNd) { if( pNd->GetpSwpHints() && \
111 !pNd->GetDoc().IsInReading() ) \
112 pNd->GetpSwpHints()->Check(true); }
113#define CHECK_SWPHINTS_IF_FRM(pNd) { if( pNd->GetpSwpHints() && \
114 !pNd->GetDoc().IsInReading() ) \
115 pNd->GetpSwpHints()->Check(getLayoutFrame(nullptr, nullptr, nullptr) != nullptr); }
117#define CHECK_SWPHINTS(pNd)
118#define CHECK_SWPHINTS_IF_FRM(pNd)
124 OSL_ENSURE( pColl,
"Collection pointer is 0." );
133 !
GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() ||
148 static_cast<SwTableNode*
>(pNd)->MakeFramesForAdjacentContentNode(aIdx);
161 static_cast<SwSectionNode*
>(pNd)->MakeFramesForAdjacentContentNode(aIdx);
167 static_cast<SwContentNode*
>(pNd)->MakeFramesForAdjacentContentNode(*pNode);
194 if( &rWhere == &aTmp.
GetNode() )
205 m_bContainsHiddenChars(false),
206 m_bHiddenCharsHidePara(false),
207 m_bRecalcHiddenCharFlags(false),
208 m_bLastOutlineState( false ),
209 m_bNotifiable( true ),
210 mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ),
211 mbInSetOrResetAttr( false ),
248 std::unique_ptr<SwpHints> pTmpHints(std::move(
m_pSwpHints));
250 for(
size_t j = pTmpHints->Count(); j; )
259#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
261 assert(!
GetNodes().GetOutLineNds().Seek_Entry(
this, &
foo));
268#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
293 return m_Text.getLength();
308 for(
size_t j = pSwpHints->
Count(); j; )
320 OSL_ENSURE( pAttr->
GetStartNode(),
"FootnoteAtr without StartNode." );
325 GetNodes().GoNextSection( &aIdx,
true,
false );
334 "lcl_ChangeFootnoteRef: Layout double?" );
336 if( pFootnote && pFootnote->
GetAttr() == pAttr )
341 pFirstFootnoteOfNode = pFootnote;
344 pFootnote->
SetRef( pFrame );
346 static_cast<SwTextFrame*
>(pFrame)->SetFootnote(
true );
349#if OSL_DEBUG_LEVEL > 0
350 while(
nullptr != (pContent = aIter.
Next()) )
353 OSL_ENSURE( !pDbgFootnote || pDbgFootnote->
GetRef() == pFrame,
354 "lcl_ChangeFootnoteRef: Who's that guy?" );
361 if ( pFirstFootnoteOfNode )
404 std::vector<SwAnchoredObject*> objs;
405 objs.reserve(pObjs->size());
408 objs.push_back(pObj);
419 assert(!pFrame->GetDrawObjs() || !pObjs->Contains(*pObj));
437 const sal_Int32 nTextLen =
m_Text.getLength();
443 if (nSplitPos != 0) {
444 pNode->RegisterAsCopyOf(*
this,
true);
445 if (nSplitPos == nTextLen)
447 RemoveMetadataReference();
462 if ( HasWriterListeners() && !
m_Text.isEmpty() && (nTextLen / 2) < nSplitPos )
478 CutText( pNode, aIdx, nSplitPos );
530 const sal_Int32*
const pEnd = pHt->
GetEnd();
531 if (pEnd && pHt->
GetStart() == *pEnd )
543 if (pContentIndexRestore)
552 std::vector<SwTextFrame*> frames;
556 if (pFrame->getRootFrame()->HasMergedParas())
560 frames.push_back(pFrame);
564 pFrame->RegisterToNode( *pNode );
565 if (!pFrame->IsFollow() && pFrame->GetOffset())
580 if (pContentIndexRestore)
603 CutText( pNode, aIdx, nSplitPos );
611 const sal_Int32*
const pEnd = pHt->
GetEnd();
624 pNode->
SetWrong( pList->SplitList( nSplitPos ) );
643 if (pContentIndexRestore)
648 std::vector<SwTextFrame*> frames;
652 frames.push_back(pFrame);
653 if (pFrame->getRootFrame()->HasMergedParas())
658 bool bNonMerged(
false);
659 bool bRecreateThis(
false);
667 if (pFrame->GetMergedPara())
674 pFrame->RegisterToNode(*pNode);
682 if (!pFrame->GetMergedPara() ||
683 !pFrame->GetMergedPara()->listener.IsListeningTo(
this))
688 bRecreateThis =
true;
696 assert(!(bNonMerged && bRecreateThis));
697 if (!frames.empty() && bNonMerged)
703 else if (bRecreateThis)
705 assert(pNode->HasWriterListeners());
710 if (pContentIndexRestore)
734 const sal_Int32* pEnd = pHt->
GetEnd();
735 if (!pEnd || pHt->
GetStart() != *pEnd)
773 switch (eOldMergeFlag)
816 OSL_ENSURE(
m_pSwpHints,
"MoveTextAttr_To_AttrSet without SwpHints?" );
824 const sal_Int32* pHtEndIdx = pHt->
GetEnd();
850 std::vector<SwTextFrame*> frames;
854 if (pFrame->getRootFrame()->HasMergedParas())
856 frames.push_back(pFrame);
860 auto frames2(frames);
864 if (pFrame->getRootFrame()->HasMergedParas())
866 auto const it(std::find(frames2.begin(), frames2.end(), pFrame));
867 assert(it != frames2.end());
871 assert(frames2.empty());
875 pFrame->RegisterToNode(rNode,
true);
913 std::vector<SwTextFrame*> frames;
917 if (pFrame->getRootFrame()->HasMergedParas())
919 frames.push_back(pFrame);
925 SwTextNode & rFirstNode(pFrame->GetMergedPara()
926 ? *pFrame->GetMergedPara()->pFirstNode
930 *pFrame, rFirstNode,
eMode));
933 if (pFrame->GetMergedPara())
935 assert(pFrame->GetMergedPara()->listener.IsListeningTo(&rNode));
936 assert(rNode.
GetIndex() <= pFrame->GetMergedPara()->pLastNode->GetIndex());
951 if (
auto const pMergedPara = pFrame->GetMergedPara())
953 if (pMergedPara->pFirstNode == pMergedPara->pLastNode)
955 assert(pMergedPara->pFirstNode == &rNode);
960 else if (pFrame->getRootFrame()->HasMergedParas())
1012 sal_Int32 nOldLen =
m_Text.getLength();
1015 JoinMetadatable(*pTextNode, !
Len(), !pTextNode->
Len());
1020 pList->JoinList( pTextNode->
GetWrong(), nOldLen );
1028 pList->Move( 0, nOldLen );
1044 pList3->MoveGrammar( 0, nOldLen );
1052 pList2->JoinList( pTextNode->
GetSmartTags(), nOldLen );
1060 pList2->Move( 0, nOldLen );
1069 if( !pContentStore->Empty())
1070 pContentStore->Restore( rDoc,
GetIndex(), nOldLen );
1072 if( pTextNode->HasAnyIndex() )
1087 if (pFrame->GetMergedPara())
1113 OSL_FAIL(
"No TextNode." );
1129 const sal_Int32 nLen = pTextNode->
Len();
1131 std::unique_ptr<SwWrongList> pList = pTextNode->
ReleaseWrong();
1143 pList->Move( 0, nLen );
1160 pList3->MoveGrammar( 0, nLen );
1177 pList2->Move( 0, nLen );
1186 if( !pContentStore->Empty() )
1187 pContentStore->Restore( rDoc,
GetIndex() );
1189 if( pTextNode->HasAnyIndex() )
1212 OSL_FAIL(
"No TextNode." );
1219 OSL_ENSURE( !
mpAttrSet,
"AttrSet is set after all" );
1228 if ( pFormatColl != pAnyFormatColl )
1231 aNewAttrSet.
Put( aAnyFormatColl );
1232 aNewAttrSet.
Put( aFormatColl );
1253 const sal_Int32 nChangeLen,
1254 UpdateMode
const eMode)
1259 std::unique_ptr<SwpHts> pCollector;
1260 const sal_Int32 nChangePos = rPos.
GetIndex();
1264 if (
eMode & UpdateMode::Negative)
1266 std::vector<SwTextInputField*> aTextInputFields;
1268 const sal_Int32 nChangeEnd = nChangePos + nChangeLen;
1271 bool bTextAttrChanged =
false;
1272 bool bStartOfTextAttrChanged =
false;
1274 if ( pHint->
GetStart() > nChangePos )
1276 if ( pHint->
GetStart() > nChangeEnd )
1284 bStartOfTextAttrChanged =
true;
1287 const sal_Int32 *
const pEnd = pHint->
GetEnd();
1288 if (pEnd && *pEnd > nChangePos )
1290 if( *pEnd > nChangeEnd )
1292 pHint->
SetEnd(*pEnd - nChangeLen);
1296 pHint->
SetEnd(nChangePos);
1298 bTextAttrChanged = !bStartOfTextAttrChanged;
1301 if ( bTextAttrChanged
1305 if ( pTextInputField )
1306 aTextInputFields.push_back(pTextInputField);
1321 bool bNoExp =
false;
1322 bool bResort =
false;
1323 bool bMergePortionsNeeded =
false;
1325 std::vector<SwTextInputField*> aTextInputFields;
1327 bool aDontExp[ coArrSz ] = {};
1331 bool bTextAttrChanged =
false;
1333 const sal_Int32 *
const pEnd = pHint->
GetEnd();
1334 if ( pHint->
GetStart() >= nChangePos )
1339 pHint->
SetEnd(*pEnd + nChangeLen);
1342 else if ( pEnd && (*pEnd >= nChangePos) )
1346 pHint->
SetEnd(*pEnd + nChangeLen);
1347 bTextAttrChanged =
true;
1351 const sal_uInt16 nWhich = pHint->
Which();
1353 OSL_ENSURE(!
isCHRATR(nWhich),
"Update: char attr hint?");
1359 if( aDontExp[ nWhPos ] )
1369 bMergePortionsNeeded =
true;
1378 aDontExp[ nWhPos ] =
true;
1384 pCollector.reset(
new SwpHts );
1386 auto it = std::find_if(pCollector->begin(), pCollector->end(),
1387 [nWhich](
const SwTextAttr *pTmp) { return nWhich == pTmp->Which(); });
1388 if (it != pCollector->end())
1391 pCollector->erase( it );
1396 pHint->
GetAttr(), nChangePos, nChangePos + nChangeLen);
1397 pCollector->push_back( pTmp );
1401 pHint->
SetEnd(*pEnd + nChangeLen);
1402 bTextAttrChanged =
true;
1407 if ( bTextAttrChanged
1411 if ( pTextInputField )
1412 aTextInputFields.push_back(pTextInputField);
1423 if (bMergePortionsNeeded)
1434 bool bSortMarks =
false;
1435 SwContentNodeTmp aTmpIdxReg;
1436 if (!(
eMode & UpdateMode::Negative) && !(
eMode & UpdateMode::Delete))
1438 std::vector<SwRangeRedline*> vMyRedlines;
1441 while (pContentNodeIndex)
1445 vMyRedlines.push_back(pRedl);
1446 pContentNodeIndex = pContentNodeIndex->
GetNext();
1448 std::sort(vMyRedlines.begin(), vMyRedlines.end());
1449 vMyRedlines.erase( std::unique( vMyRedlines.begin(), vMyRedlines.end() ), vMyRedlines.end() );
1452 if ( pRedl->HasMark() )
1455 if ( *
this == pEnd->
GetNode() &&
1456 *pRedl->GetPoint() != *pRedl->GetMark() )
1465 else if (
this == &pRedl->GetPoint()->GetNode() )
1473 bool const isOneUsed(&pRedl->GetBound() == pRedl->GetPoint());
1474 assert(!pRedl->GetBound(!isOneUsed).GetNode().IsTextNode());
1475 assert(!pRedl->GetBound(!isOneUsed).GetContentNode()); (void)isOneUsed;
1482 if (!(
eMode & UpdateMode::Replace))
1484 bool bAtLeastOneBookmarkMoved =
false;
1485 bool bAtLeastOneExpandedBookmarkAtInsertionPosition =
false;
1489 for (
const SwContentIndex* pIndex = GetFirstIndex(); pIndex; pIndex = next )
1496 if (!aSeenMarks.
insert(pMark).second)
1500 if( *
this == pEnd->
GetNode() &&
1503 if (&rEndIdx == next)
1510 bAtLeastOneBookmarkMoved =
true;
1512 else if ( !bAtLeastOneExpandedBookmarkAtInsertionPosition )
1517 if (
this == &pStart->
GetNode()
1520 bAtLeastOneExpandedBookmarkAtInsertionPosition =
true;
1526 bSortMarks = bAtLeastOneBookmarkMoved && bAtLeastOneExpandedBookmarkAtInsertionPosition;
1533 for (
size_t i = 0;
i != rFlys.size(); ++
i)
1538 if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR && pAnchorNode)
1554 if (pDocShell->GetWrtShell())
1558 auto pWrtShell =
dynamic_cast<SwWrtShell*
>(&rShell);
1559 if (!pWrtShell || pWrtShell == pDocShell->GetWrtShell())
1578 SwContentIndexReg::Update(rPos, nChangeLen,
eMode);
1582 const size_t nCount = pCollector->size();
1585 m_pSwpHints->TryInsertHint( (*pCollector)[
i ], *
this );
1589 aTmpIdxReg.MoveTo( *
this );
1607 pSortedObjs = pPage->GetSortedObjs();
1618 pEditShell->ValidateParagraphSignatures(
this,
true);
1636 if (nChangePos <= pRedln->
Start()->GetContentIndex())
1657 if (
MAXLEVEL != nNewLevel && -1 != nNewLevel )
1682 bool bFormatToTextAttributes )
1684 if (bFormatToTextAttributes && nIdx ==
m_Text.getLength())
1697 const sal_Int32 *pEnd = pTmp->
GetEnd();
1700 assert( *pEnd <= nIdx );
1717 return ((nHintStart <=
nIndex) && (
nIndex < nHintEnd));
1721 return ((nHintStart <
nIndex) && (
nIndex <= nHintEnd));
1730 std::vector<SwTextAttr *> *
const pVector,
1733 sal_Int32
const nIndex, sal_uInt16
const nWhich,
1739 size_t const nSize = pSwpHints->
Count();
1740 sal_Int32 nPreviousIndex(0);
1741 bool (*pMatchFunc)(sal_Int32, sal_Int32, sal_Int32)=
nullptr;
1750 default: assert(
false);
1756 if (pHint->
Which() != nWhich)
1759 sal_Int32
const nHintStart = pHint->
GetStart();
1763 sal_Int32
const*
const pEndIdx = pHint->
GetEnd();
1768 bool const bContained( pEndIdx
1769 ? (*pMatchFunc)(
nIndex, nHintStart, *pEndIdx)
1770 : (nHintStart ==
nIndex) );
1775 if (nPreviousIndex < nHintStart)
1778 nPreviousIndex = nHintStart;
1780 pVector->push_back(pHint);
1784 *ppTextAttr = pHint;
1794std::vector<SwTextAttr *>
1798 std::vector<SwTextAttr *> ret;
1826 if ( pTextInputField ==
nullptr && rTextAttr.
End() != nullptr )
1831 return pTextInputField;
1850 const sal_Int32 nIndex,
1854 if ( pTextField ==
nullptr )
1858 if ( pTextField ==
nullptr )
1872 if( !rName.empty() )
1874 const size_t nArrLen = pCharFormats->
size();
1875 for(
size_t i = 1;
i < nArrLen;
i++ )
1878 if( pFormat->
GetName()==rName )
1886 const sal_uInt16 nWhich,
1889 SwDoc *
const pOtherDoc,
1892 assert(nWhich == pHt->
Which());
1906 if( pOtherDoc !=
nullptr )
1908 static_txtattr_cast<const SwTextField*>(pHt)->CopyTextField(
1909 static_txtattr_cast<SwTextField*>(pNewHt));
1933 if( pOtherDoc !=
nullptr )
1935 static_txtattr_cast<const SwTextField*>(pHt)->CopyTextField(
1936 static_txtattr_cast<SwTextField*>(pNewHt));
1946 static_txtattr_cast<SwTextTOXMark*>(pNewHt)->CopyTOXMark(*pOtherDoc);
1985 SwTextINetFormat *
const pINetHt = static_txtattr_cast<SwTextINetFormat*>(pNewHt);
1997 OSL_ENSURE( pNewHt,
"copying Meta should not fail!" );
2000 "missing CH_TXTATR?");
2010 const sal_Int32 nOldPos )
2015 &pDest->
GetDoc() :
nullptr;
2020 sal_Int32
const nAttrStartIdx = pHt->
GetStart();
2021 if ( nTextStartIdx < nAttrStartIdx )
2024 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2027 sal_uInt16
const nWhich = pHt->
Which();
2029 && ( *pEndIdx > nTextStartIdx
2030 || (*pEndIdx == nTextStartIdx
2031 && nAttrStartIdx == nTextStartIdx)))
2045 ?
GetDoc().IsCopyIsMove()
2071 const sal_Int32 nLen,
2072 const bool bForceCopyOfAllAttrs )
2075 CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs );
2082 const bool bForceCopyOfAllAttrs )
2084 CopyText( pDest, rDestStart, rStart.
nContent, nLen, bForceCopyOfAllAttrs );
2091 const bool bForceCopyOfAllAttrs )
2097 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2098 sal_Int32 nDestStart = rDestStart.
GetIndex();
2111 CopyAttr( pDest, nTextStartIdx, nDestStart );
2117 if ( !bForceCopyOfAllAttrs &&
2120 nLen != pDest->
GetText().getLength()))
2128 if( aCharSet.Count() )
2130 pDest->
SetAttr( aCharSet, nDestStart, nDestStart );
2142 const sal_Int32 oldLen = pDest->
m_Text.getLength();
2149 nLen = pDest->
m_Text.getLength() - oldLen;
2159 if ( !bForceCopyOfAllAttrs &&
2162 nLen != pDest->
GetText().getLength()))
2170 if( aCharSet.Count() )
2172 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2181 bool const bUndoNodes = !pOtherDoc
2187 const sal_Int32 nEnd = nTextStartIdx + nLen;
2201 std::vector<std::pair<sal_Int32, sal_Int32>> metaFieldRanges;
2202 sal_Int32 nDeletedDummyChars(0);
2203 for (
size_t n = 0;
n < nSize; ++
n)
2207 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2208 if ( nAttrStartIdx >= nEnd )
2211 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2212 const sal_uInt16 nWhich = pHt->
Which();
2236 assert(pEndIdx !=
nullptr &&
2237 "<SwTextNode::CopyText(..)> - RES_TXTATR_INPUTFIELD without EndIndex!" );
2238 if ( nAttrStartIdx < nTextStartIdx
2239 || ( pEndIdx !=
nullptr
2240 && *pEndIdx > nEnd ) )
2249 metaFieldRanges.emplace_back(nAttrStartIdx, pEndIdx ? *pEndIdx : nEnd);
2253 sal_Int32 nAttrStt = 0;
2254 sal_Int32 nAttrEnd = 0;
2256 if( nAttrStartIdx < nTextStartIdx )
2260 if ( pEndIdx && (*pEndIdx > nTextStartIdx) && !pHt->
HasDummyChar() )
2263 nAttrStt = nDestStart;
2264 nAttrEnd = (*pEndIdx > nEnd)
2266 : nDestStart + (*pEndIdx) - nTextStartIdx;
2276 nAttrStt = nDestStart + ( nAttrStartIdx - nTextStartIdx );
2279 nAttrEnd = *pEndIdx > nEnd
2281 : nDestStart + ( *pEndIdx - nTextStartIdx );
2285 nAttrEnd = nAttrStt;
2298 aArr.push_back( pNewHt );
2304 nAttrStt - nDeletedDummyChars,
2305 nAttrEnd - nDeletedDummyChars,
2316 ++nDeletedDummyChars;
2322 aRefMrkArr.push_back( pNewHt );
2328 if (!metaFieldRanges.empty())
2331 std::reverse(metaFieldRanges.begin(), metaFieldRanges.end());
2332 for (
const auto& pair : metaFieldRanges)
2335 pDest->
EraseText(aIdx, pair.second - pair.first);
2349 if( pNewHt->GetEnd() )
2376 assert(rIdx <=
m_Text.getLength());
2378 const sal_Int32 aPos = rIdx.
GetIndex();
2379 sal_Int32 nLen =
m_Text.getLength() - aPos;
2380 sal_Int32
const nOverflow(rStr.getLength() -
GetSpaceLeft());
2382 "SwTextNode::InsertText: node text with insertion > capacity.");
2383 OUString
const sInserted(
2384 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
2385 if (sInserted.isEmpty())
2389 if (aPos == 0 &&
m_Text.isEmpty())
2394 nLen =
m_Text.getLength() - aPos - nLen;
2403 Update(rIdx, nLen, UpdateMode::Default);
2410 if ( HasWriterListeners() )
2413 CallSwClientNotify(aInsHint);
2419 bool const bHadHints(!
m_pSwpHints->CanBeDeleted());
2420 bool bMergePortionsNeeded(
false);
2422 rIdx >=
m_pSwpHints->GetWithoutResorting(
i)->GetStart(); ++
i )
2425 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2429 if( rIdx == *pEndIdx )
2439 pHt->
SetEnd(*pEndIdx - nLen);
2446 bMergePortionsNeeded =
true;
2480 if (bMergePortionsNeeded)
2485 "SwTextNode::InsertText: unexpected loss of hints");
2501 CutImpl( pDest, aDestStt, rStart, nLen,
false );
2505 const SwContentIndex & rStart, sal_Int32 nLen,
const bool bUpdate )
2511 assert(pDest !=
this);
2523 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2524 sal_Int32 nDestStart = rDestStart.
GetIndex();
2525 const sal_Int32 nInitSize = pDest->
m_Text.getLength();
2533 m_Text.subView(nTextStartIdx, nLen));
2534 OUString
const newText =
m_Text.replaceAt(nTextStartIdx, nLen,
u"");
2535 nLen = pDest->
m_Text.getLength() - nInitSize;
2542 pDest->
Update(rDestStart, nLen, UpdateMode::Default);
2547 const sal_Int32 nEnd = rStart.
GetIndex() + nLen;
2548 bool const bUndoNodes =
2559 hasSwAttrSet =
false;
2582 hasSwAttrSet = (rParentItem != *pItem);
2596 if( nInitSize || hasSwAttrSet ||
2597 nLen != pDest->
GetText().getLength())
2605 if( aCharSet.Count() )
2606 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2616 if (aCharSet.Count())
2617 pDest->
SetAttr(aCharSet, nDestStart, nDestStart + nLen);
2626 const sw::MoveText aMoveHint(pDest, nDestStart, nTextStartIdx, nLen);
2627 CallSwClientNotify(aMoveHint);
2634 bool bMergePortionsNeeded(
false);
2635 size_t nAttrCnt = 0;
2639 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2640 if ( nAttrStartIdx >= nEnd )
2642 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2643 const sal_uInt16 nWhich = pHt->
Which();
2647 if(nAttrStartIdx < nTextStartIdx)
2651 || bUndoNodes ) && pEndIdx && *pEndIdx > nTextStartIdx)
2659 : *pEndIdx - nTextStartIdx ) );
2665 if (!pEndIdx || *pEndIdx < nEnd ||
2670 if (
GetDoc().GetDocShell())
2679 bMergePortionsNeeded =
true;
2681 pHt->
SetStart(nDestStart + (nAttrStartIdx - nTextStartIdx));
2684 pHt->
SetEnd( nDestStart + (
2687 : *pEndIdx - nTextStartIdx ) );
2692 if (
GetDoc().GetDocShell())
2702 nDestStart + (nAttrStartIdx - nTextStartIdx),
2703 nDestStart + (*pEndIdx > nEnd
2705 : *pEndIdx - nTextStartIdx));
2710 const bool bSuccess( pDest->
InsertHint( pNewHt,
2728 while (nAttrCnt < m_pSwpHints->
Count())
2733 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2734 if (pEndIdx && *pEndIdx == nEnd)
2736 aArr.push_back( pHt );
2744 Update(rStart, nLen, UpdateMode::Negative|UpdateMode::Delete);
2748 pHt->SetStart( rStart.
GetIndex() );
2755 Update(rStart, nLen, UpdateMode::Negative|UpdateMode::Delete);
2761 if (bMergePortionsNeeded)
2781 assert(rIdx <=
m_Text.getLength());
2783 const sal_Int32 nStartIdx = rIdx.
GetIndex();
2786 const sal_Int32 nEndIdx = nStartIdx + nCnt;
2787 if (nEndIdx <=
m_Text.getLength())
2797 const sal_Int32 nHintStart = pHt->
GetStart();
2799 if ( nHintStart < nStartIdx )
2802 if ( nHintStart > nEndIdx )
2805 const sal_Int32* pHtEndIdx = pHt->
GetEnd();
2806 const sal_uInt16 nWhich = pHt->
Which();
2812 if (
isTXTATR(nWhich) && (nHintStart < nEndIdx))
2821 assert(!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx)
2824 || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)));
2834 if ( (*pHtEndIdx < nEndIdx)
2835 || ( (*pHtEndIdx == nEndIdx) &&
2841 || ( (nHintStart < nEndIdx) &&
2851 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2855 Update(rIdx, nCnt, UpdateMode::Negative);
2860 CallSwClientNotify(aHint);
2863 CallSwClientNotify(aHint);
2866 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2880 bool bChanged =
false;
2881 sal_Int32 nMin =
m_Text.getLength();
2883 const bool bAll = nMin != 0;
2890 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2896 nMax = std::max( nMax, *pHt->
GetEnd() );
2926 bool bNoNumRule =
false;
2929 OUString sNumRuleName =
2931 if (!sNumRuleName.isEmpty())
2941 if ( pRet && pRet ==
GetDoc().GetOutlineNumRule() &&
2943 SfxItemState::SET !=
2950 if ( rDirectItem.
GetValue().isEmpty() )
2997 bool bResult =
false;
3013 std::optional<SwAttrSet> oNewAttrSet;
3015 bool bClearHardSetNumRuleWhenFormatCollChanges(
false );
3022 pTmpSet = &*oNewAttrSet;
3025 bool bRemoveFromCache =
false;
3026 std::vector<sal_uInt16> aClearWhichIds;
3028 bRemoveFromCache = ( 0 != oNewAttrSet->ClearItem(
RES_PAGEDESC ) );
3038 bRemoveFromCache =
true;
3043 oNewAttrSet->ClearItem(
RES_KEEP );
3045 aClearWhichIds.push_back(
RES_KEEP );
3046 bRemoveFromCache =
true;
3054 bRemoveFromCache =
true;
3069 bClearHardSetNumRuleWhenFormatCollChanges =
true;
3071 bRemoveFromCache =
true;
3075 if ( !aClearWhichIds.empty() )
3078 if( !bNext && bRemoveFromCache )
3089 oNewAttrSet.reset();
3108 if( bNext || !bChgFollow )
3114 if (pNextColl != pColl)
3117 if ( bClearHardSetNumRuleWhenFormatCollChanges )
3150 if( HasWriterListeners() )
3156 const sal_Int32 nIndex,
3157 const sal_uInt16 nWhich )
const
3165 const sal_Int32 nStartPos = pHint->
GetStart();
3166 if (
nIndex < nStartPos )
3205sal_uInt16 lcl_BoundListLevel(
const int nActualLevel)
3207 return o3tl::narrowing<sal_uInt16>( std::clamp( nActualLevel, 0,
MAXLEVEL-1 ) );
3215 bool bResult =
false;
3231 bool bResult =
false;
3248 const unsigned int _nRestrictToThisLevel,
3267 _bInclPrefixAndSuffixStrings,
3268 _nRestrictToThisLevel,
3316 : - leftMargin.
GetLeft(firstLine);
3321 if (indents & ::sw::ListLevelIndents::FirstLine)
3327 : leftMargin.
GetLeft(firstLine);
3379 SwTwips nAdditionalIndent = 0;
3392 nAdditionalIndent = nAdditionalIndent -
3403 indents & ::sw::ListLevelIndents::FirstLine
3410 nAdditionalIndent = rLeft.
GetLeft(rFirst);
3411 if (!(indents & ::sw::ListLevelIndents::FirstLine))
3426 return nAdditionalIndent;
3434 bool bLeftMarginForTabCalcSetToListLevelIndent(
false );
3444 bLeftMarginForTabCalcSetToListLevelIndent =
true;
3448 if ( !bLeftMarginForTabCalcSetToListLevelIndent )
3453 return nLeftMarginForTabCalc;
3458 OUStringBuffer & rText,
3459 sal_Int32 & rTextStt,
3466 for(
int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, cSrchChr =
CH_TXTATR_INWORD )
3468 sal_Int32
nPos = rText.indexOf(cSrchChr);
3469 while (-1 !=
nPos &&
nPos < nEndPos)
3475 switch( pAttr->
Which() )
3479 rText.remove(
nPos, 1);
3484 rText.remove(
nPos, 1);
3489 rText.remove(
nPos, 1);
3498 nPos = rText.indexOf(cSrchChr,
nPos);
3506 const sal_Int32 nIdx,
3507 const sal_Int32 nLen,
3508 const bool bWithNum,
3509 const bool bAddSpaceAfterListLabelStr,
3510 const bool bWithSpacesForLevel,
3521 const OUString aExpandText = aConversionMap.
getViewText();
3523 sal_Int32 nEnd = nLen == -1 ?
GetText().getLength() : nIdx + nLen;
3525 OUStringBuffer aText(aExpandText.subView(nExpandBegin, nExpandEnd-nExpandBegin));
3536 if ( bAddSpaceAfterListLabelStr )
3539 aText.insert(0, aSpace);
3545 if (bWithSpacesForLevel)
3550 aText.insert(0, aSpace);
3551 aText.insert(0, aSpace);
3555 return aText.makeStringAndClear();
3559 sal_Int32 nIdx, sal_Int32 nLen,
3561 bool bWithFootnote,
bool bReplaceTabsWithSpaces )
const
3563 if( &rDestNd ==
this )
3569 aDestIdx = *pDestIdx;
3570 const sal_Int32 nDestStt = aDestIdx.
GetIndex();
3573 OUStringBuffer buf(
GetText());
3574 if( bReplaceTabsWithSpaces )
3575 buf.replace(
'\t',
' ');
3581 buf.remove(0, nIdx);
3591 rDestNd.
InsertText(buf.makeStringAndClear(), aDestIdx);
3592 nLen = aDestIdx.
GetIndex() - nDestStt;
3597 sal_Int32 nInsPos = nDestStt - nIdx;
3601 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
3602 const sal_uInt16 nWhich = pHt->
Which();
3603 if (nIdx + nLen <= nAttrStartIdx)
3606 const sal_Int32 *pEndIdx = pHt->
End();
3607 if( pEndIdx && *pEndIdx > nIdx &&
3614 if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->
GetCharSet() )
3618 nInsPos + nAttrStartIdx, nInsPos + *pEndIdx );
3621 else if ( pHt->
HasDummyChar() && (nAttrStartIdx >= nIdx) )
3623 aDestIdx = nInsPos + nAttrStartIdx;
3629 OUString
const aExpand(
3630 static_txtattr_cast<SwTextField const*>(pHt)->GetFormatField().GetField()->ExpandField(
true, pLayout));
3631 if (!aExpand.isEmpty())
3636 SAL_INFO_IF(ins.getLength() != aExpand.getLength(),
3637 "sw.core",
"GetExpandText lossage");
3638 aDestIdx = nInsPos + nAttrStartIdx;
3639 nInsPos += ins.getLength();
3648 if ( bWithFootnote )
3663 if( !sExpand.isEmpty() )
3672 SAL_INFO_IF(ins.getLength() != sExpand.getLength(),
3673 "sw.core",
"GetExpandText lossage");
3674 aDestIdx = nInsPos + nAttrStartIdx;
3675 nInsPos += ins.getLength();
3693 aDestIdx = nDestStt;
3698 sal_Int32 nStartDelete(-1);
3699 while (aDestIdx < rDestNd.
GetText().getLength())
3708 if (-1 == nStartDelete)
3710 nStartDelete = aDestIdx.
GetIndex();
3713 if (aDestIdx < rDestNd.
GetText().getLength())
3720 if (-1 == nStartDelete)
3726 assert(-1 != nStartDelete);
3729 aDestIdx.
GetIndex() - nStartDelete);
3730 assert(aDestIdx.
GetIndex() == nStartDelete);
3739 std::vector<sal_Int32> aRedlArr;
3749 if( RedlineType::Delete == pTmp->
GetType() )
3754 if( pREnd->GetNodeIndex() > nNdIdx )
3757 else if( pREnd->GetNodeIndex() == nNdIdx )
3760 aRedlArr.push_back( 0 );
3761 aRedlArr.push_back( pREnd->GetContentIndex() );
3768 if( pREnd->GetNodeIndex() == nNdIdx )
3769 aRedlArr.push_back( pREnd->GetContentIndex() );
3782 OUStringBuffer aText(
GetText());
3784 sal_Int32 nTextStt = 0;
3785 sal_Int32 nIdxEnd = aText.getLength();
3786 for(
size_t n = 0;
n < aRedlArr.size();
n += 2 )
3788 sal_Int32 nStt = aRedlArr[
n ];
3789 sal_Int32 nEnd = aRedlArr[
n+1 ];
3790 if( ( 0 <= nStt && nStt <= nIdxEnd ) ||
3791 ( 0 <= nEnd && nEnd <= nIdxEnd ))
3793 if( nStt < 0 ) nStt = 0;
3794 if( nIdxEnd < nEnd ) nEnd = nIdxEnd;
3795 const sal_Int32 nDelCnt = nEnd - nStt;
3796 aText.remove(nStt - nTextStt, nDelCnt);
3797 Replace0xFF(*
this, aText, nTextStt, nStt - nTextStt);
3798 nTextStt += nDelCnt;
3800 else if( nStt >= nIdxEnd )
3803 Replace0xFF(*
this, aText, nTextStt, aText.getLength());
3805 return aText.makeStringAndClear();
3809 const OUString & rStr)
3815 sal_Int32
const nOverflow(rStr.getLength() - nDelLen -
GetSpaceLeft());
3817 "SwTextNode::ReplaceText: node text with insertion > node capacity.");
3818 OUString
const sInserted(
3819 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
3820 if (sInserted.isEmpty() && 0 == nDelLen)
3825 const sal_Int32 nStartPos = rStart.
GetIndex();
3826 sal_Int32 nEndPos = nStartPos + nDelLen;
3827 sal_Int32 nLen = nDelLen;
3828 for( sal_Int32
nPos = nStartPos;
nPos < nEndPos; ++
nPos )
3838 && (*pHint->
GetEnd() > nEndPos) ));
3850 if (nLen && sInserted.getLength())
3854 m_Text =
m_Text.replaceAt(nStartPos, 1, sInserted.subView(0, 1));
3858 Update(rStart, nLen - 1, UpdateMode::Negative);
3860 std::u16string_view aTmpText( sInserted.subView(1) );
3862 Update(rStart, aTmpText.size(), UpdateMode::Replace);
3867 Update(rStart, nLen, UpdateMode::Negative);
3870 Update(rStart, sInserted.getLength(), UpdateMode::Replace);
3875 CallSwClientNotify(aDelHint);
3877 if (sInserted.getLength())
3880 CallSwClientNotify(aInsHint);
3885 const OUString & rStr)
3891 void lcl_ResetParAttrs(
SwTextNode &rTextNode )
3897 SwPaM aPam( rTextNode );
3912 void HandleModifyAtTextNode(
SwTextNode& rTextNode,
3916 const sal_uInt16 nWhich = pOldValue ? pOldValue->
Which() :
3917 pNewValue ? pNewValue->
Which() : 0 ;
3918 bool bNumRuleSet =
false;
3919 bool bParagraphStyleChanged =
false;
3921 OUString sOldNumRule;
3926 bParagraphStyleChanged =
true;
3929 const SwNumRule* pFormerNumRuleAtTextNode =
3931 if ( pFormerNumRuleAtTextNode )
3933 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3938 if ( !rNumRuleItem.
GetValue().isEmpty() )
3944 if ( pNumRuleAtTextNode )
3947 sNumRule = pNumRuleAtTextNode->
GetName();
3954 const SwNumRule* pFormerNumRuleAtTextNode =
3956 if ( pFormerNumRuleAtTextNode )
3958 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3972 if ( pNumRuleAtTextNode )
3974 sNumRule = pNumRuleAtTextNode->
GetName();
3982 const SwNumRule* pFormerNumRuleAtTextNode =
3984 if ( pFormerNumRuleAtTextNode )
3986 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3998 if ( pNumRuleAtTextNode )
4000 sNumRule = pNumRuleAtTextNode->
GetName();
4006 if ( sNumRule != sOldNumRule )
4010 if (sNumRule.isEmpty())
4013 if ( bParagraphStyleChanged )
4015 lcl_ResetParAttrs(rTextNode);
4027 "<HandleModifyAtTextNode()> - text node with outline style, but its paragraph style is not assigned to outline style." );
4028 const int nNewListLevel =
4030 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
4041 if ( bParagraphStyleChanged )
4043 lcl_ResetParAttrs(rTextNode);
4052 else if (!sNumRule.isEmpty() && !rTextNode.
IsInList())
4062 OSL_ENSURE( pNewColl,
"ChgFormatColl: Collectionpointer has value 0." );
4063 assert(
dynamic_cast<const SwTextFormatColl *
>(pNewColl) &&
"ChgFormatColl: is not a Text Collection pointer." );
4066 if( pNewColl != pOldColl )
4071 "DEBUG OSL_ENSURE(ON - <SwTextNode::ChgFormatColl(..)> called during <Set/ResetAttr(..)>" );
4076 HandleModifyAtTextNode( *
this, &aTmp1, &aTmp2 );
4109 std::unique_ptr<SwNodeNum> pBackup2 = std::move(
mpNodeNumOrig);
4129 return pNum->GetNumberVector();
4140 bool bResult =
false;
4175 assert(0 <= nLevel && nLevel <=
MAXLEVEL);
4176 if ( 0 <= nLevel && nLevel <=
MAXLEVEL )
4179 o3tl::narrowing<sal_uInt16>(nLevel) ) );
4186 auto it = rGrabBagItem.
GetGrabBag().find(
"OutlineContentVisibleAttr");
4188 it->second >>= bOutlineContentVisibleAttr;
4220 if ( nLevel < 0 || nLevel >=
MAXLEVEL )
4227 static_cast<sal_Int16
>(nLevel) );
4239 int nAttrListLevel = 0;
4243 nAttrListLevel =
static_cast<int>(aListLevelItem.
GetValue());
4245 return nAttrListLevel;
4310 : nNumber != USHRT_MAX );
4315 if ( nNumber == USHRT_MAX )
4322 static_cast<sal_Int16
>(nNumber) );
4323 SetAttr( aNewListRestartValueItem );
4335 "<SwTextNode::GetAttrListRestartValue()> - only ask for list restart value, if attribute is set at text node." );
4359 nListRestartValue = pFormat->
GetStart();
4364 return nListRestartValue;
4389 SetAttr( aIsCountedInListItem );
4397 return aIsCountedInListItem.
GetValue();
4402 const OUString sListId = pNode->
GetListId();
4403 if (!sListId.isEmpty())
4406 SwList* pList = rIDLA.getListByName( sListId );
4407 if ( pList ==
nullptr )
4416 OSL_ENSURE( pList !=
nullptr,
4417 "<SwTextNode::AddToList()> - no list for given list id. Serious defect" );
4427 OSL_FAIL(
"<SwTextNode::AddToList()> - the text node is already added to a list. Serious defect" );
4432 if (!(pList &&
GetNodes().IsDocNodes()))
4444 if (!bRecordChanges ||
GetDoc().IsInXMLImport() ||
GetDoc().IsInWriterfilterImport() )
4462 else if ( bRecordChanges )
4469 if (pFrame->getRootFrame()->IsHideRedlines())
4471 if (pFrame->GetTextNodeForParaProps() ==
this)
4553 bool bResult =
false;
4566 if (rListIdItem.
GetValue() != rListId)
4568 if (rListId.isEmpty())
4584 const OUString& sListId {rListIdItem.
GetValue()};
4588 if (sListId.isEmpty())
4619 ret |= ::sw::ListLevelIndents::FirstLine;
4630 bool bAreListLevelIndentsApplicable(
true );
4635 bAreListLevelIndentsApplicable =
false;
4638 GetpSwAttrSet()->GetItemState(nWhich,
false) == SfxItemState::SET)
4641 bAreListLevelIndentsApplicable =
false;
4648 bAreListLevelIndentsApplicable =
true;
4662 bAreListLevelIndentsApplicable =
false;
4670 bAreListLevelIndentsApplicable =
true;
4676 "<SwTextNode::AreListLevelIndentsApplicable()> - something wrong in paragraph's style hierarchy. The applied list style is not found." );
4680 return bAreListLevelIndentsApplicable;
4693 bool bListTabStopPositionProvided(
false);
4702 bListTabStopPositionProvided =
true;
4722 return bListTabStopPositionProvided;
4742 sal_Int32 nStartPos;
4786 class HandleSetAttrAtTextNode
4789 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4791 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4793 ~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
4797 bool mbAddTextNodeToList;
4798 bool mbUpdateListLevel;
4799 bool mbUpdateListRestart;
4800 bool mbUpdateListCount;
4802 bool mbOutlineLevelSet;
4805 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4807 : mrTextNode( rTextNode ),
4808 mbAddTextNodeToList( false ),
4809 mbUpdateListLevel( false ),
4810 mbUpdateListRestart( false ),
4811 mbUpdateListCount( false ),
4813 mbOutlineLevelSet( false )
4815 switch ( pItem.Which() )
4820 mrTextNode.RemoveFromList();
4824 if ( !rNumRuleItem.
GetValue().isEmpty() )
4826 mbAddTextNodeToList =
true;
4829 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4839 OSL_ENSURE( rListIdItem.
GetValue().getLength() > 0,
4840 "<HandleSetAttrAtTextNode(..)> - empty list id attribute not expected. Serious defect." );
4841 const OUString sListIdOfTextNode = rTextNode.GetListId();
4842 if ( rListIdItem.
GetValue() != sListIdOfTextNode )
4844 mbAddTextNodeToList =
true;
4845 if ( mrTextNode.IsInList() )
4847 mrTextNode.RemoveFromList();
4858 if ( aListLevelItem.
GetValue() != mrTextNode.GetAttrListLevel() )
4860 mbUpdateListLevel =
true;
4870 if ( aListIsRestartItem.
GetValue() !=
4871 mrTextNode.IsListRestart() )
4873 mbUpdateListRestart =
true;
4883 if ( !mrTextNode.HasAttrListRestartValue() ||
4884 aListRestartValueItem.
GetValue() != mrTextNode.GetAttrListRestartValue() )
4886 mbUpdateListRestart =
true;
4896 if ( aIsCountedInListItem.
GetValue() !=
4897 mrTextNode.IsCountedInList() )
4899 mbUpdateListCount =
true;
4910 if ( aOutlineLevelItem.
GetValue() != mrTextNode.GetAttrOutlineLevel() )
4912 mbOutlineLevelSet =
true;
4920 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4922 : mrTextNode( rTextNode ),
4923 mbAddTextNodeToList( false ),
4924 mbUpdateListLevel( false ),
4925 mbUpdateListRestart( false ),
4926 mbUpdateListCount( false ),
4928 mbOutlineLevelSet( false )
4933 mrTextNode.RemoveFromList();
4935 if ( !pNumRuleItem->GetValue().isEmpty() )
4937 mbAddTextNodeToList =
true;
4939 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4946 const OUString sListIdOfTextNode = mrTextNode.GetListId();
4947 if ( pListIdItem->GetValue() != sListIdOfTextNode )
4949 mbAddTextNodeToList =
true;
4950 if ( mrTextNode.IsInList() )
4952 mrTextNode.RemoveFromList();
4960 if (pListLevelItem->GetValue() != mrTextNode.GetAttrListLevel())
4962 mbUpdateListLevel =
true;
4969 if (pListIsRestartItem->GetValue() != mrTextNode.IsListRestart())
4971 mbUpdateListRestart =
true;
4978 if ( !mrTextNode.HasAttrListRestartValue() ||
4979 pListRestartValueItem->GetValue() != mrTextNode.GetAttrListRestartValue() )
4981 mbUpdateListRestart =
true;
4988 if (pIsCountedInListItem->GetValue() != mrTextNode.IsCountedInList())
4990 mbUpdateListCount =
true;
4998 if (pOutlineLevelItem->GetValue() != mrTextNode.GetAttrOutlineLevel())
5000 mbOutlineLevelSet =
true;
5005 HandleSetAttrAtTextNode::~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
5007 if ( mbAddTextNodeToList )
5009 SwNumRule* pNumRuleAtTextNode = mrTextNode.GetNumRule();
5010 if ( pNumRuleAtTextNode )
5012 mrTextNode.AddToList();
5017 if ( mbUpdateListLevel && mrTextNode.IsInList() )
5019 auto const nLevel(mrTextNode.GetAttrListLevel());
5020 const SwDoc& rDoc(mrTextNode.GetDoc());
5025 if ( mbUpdateListRestart && mrTextNode.IsInList() )
5027 const SwDoc& rDoc(mrTextNode.GetDoc());
5039 const SwDoc& rDoc(mrTextNode.GetDoc());
5046 if (!mbOutlineLevelSet)
5049 mrTextNode.GetNodes().UpdateOutlineNode(mrTextNode);
5050 if (mrTextNode.GetAttrOutlineLevel() == 0)
5052 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5057 != SfxItemState::SET )
5059 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
5071 HandleSetAttrAtTextNode aHandleSetAttr( *
this, pItem );
5085 HandleSetAttrAtTextNode aHandleSetAttr( *
this,
rSet );
5116 class HandleResetAttrAtTextNode
5119 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5120 const sal_uInt16 nWhich1,
5121 sal_uInt16 nWhich2 );
5122 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5123 const std::vector<sal_uInt16>& rWhichArr );
5124 explicit HandleResetAttrAtTextNode(
SwTextNode& rTextNode );
5126 ~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
5130 bool mbListStyleOrIdReset;
5131 bool mbUpdateListLevel;
5132 bool mbUpdateListRestart;
5133 bool mbUpdateListCount;
5135 void init( sal_uInt16 nWhich,
bool& rbRemoveFromList );
5138 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5139 const sal_uInt16 nWhich1,
5140 sal_uInt16 nWhich2 )
5141 : mrTextNode( rTextNode ),
5142 mbListStyleOrIdReset( false ),
5143 mbUpdateListLevel( false ),
5144 mbUpdateListRestart( false ),
5145 mbUpdateListCount( false )
5147 if ( nWhich2 < nWhich1 )
5149 bool bRemoveFromList(
false );
5150 for ( sal_uInt16 nWhich = nWhich1; nWhich <= nWhich2; ++nWhich )
5151 init( nWhich, bRemoveFromList );
5152 if ( bRemoveFromList && mrTextNode.IsInList() )
5153 mrTextNode.RemoveFromList();
5156 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5157 const std::vector<sal_uInt16>& rWhichArr )
5158 : mrTextNode( rTextNode ),
5159 mbListStyleOrIdReset( false ),
5160 mbUpdateListLevel( false ),
5161 mbUpdateListRestart( false ),
5162 mbUpdateListCount( false )
5164 bool bRemoveFromList(
false );
5165 for ( sal_uInt16 nWhich : rWhichArr )
5166 init( nWhich, bRemoveFromList );
5167 if ( bRemoveFromList && mrTextNode.IsInList() )
5168 mrTextNode.RemoveFromList();
5171 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode )
5172 : mrTextNode( rTextNode ),
5173 mbListStyleOrIdReset( true ),
5174 mbUpdateListLevel( false ),
5175 mbUpdateListRestart( false ),
5176 mbUpdateListCount( false )
5183 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5186 void HandleResetAttrAtTextNode::init( sal_uInt16 rWhich,
bool& rbRemoveFromList )
5190 rbRemoveFromList = rbRemoveFromList ||
5191 mrTextNode.GetNumRule() !=
nullptr;
5192 mbListStyleOrIdReset =
true;
5196 rbRemoveFromList = rbRemoveFromList ||
5197 ( mrTextNode.GetpSwAttrSet() &&
5198 mrTextNode.GetpSwAttrSet()->GetItemState(
RES_PARATR_LIST_ID,
false ) == SfxItemState::SET );
5199 mbListStyleOrIdReset =
true;
5202 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5204 mrTextNode.ResetAttr( XATTR_FILL_FIRST, XATTR_FILL_LAST );
5206 if ( !rbRemoveFromList )
5209 mbUpdateListLevel = mbUpdateListLevel ||
5211 mrTextNode.HasAttrListLevel() );
5214 mbUpdateListRestart = mbUpdateListRestart ||
5216 mrTextNode.IsListRestart() ) ||
5218 mrTextNode.HasAttrListRestartValue() );
5221 mbUpdateListCount = mbUpdateListCount ||
5223 !mrTextNode.IsCountedInList() );
5227 HandleResetAttrAtTextNode::~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
5229 if ( mbListStyleOrIdReset && !mrTextNode.IsInList() )
5233 if (mrTextNode.GetNumRule() && !mrTextNode.GetListId().isEmpty())
5238 if ( !mrTextNode.HasAttrListLevel() &&
5240 mrTextNode.GetTextColl()->IsAssignedToListLevelOfOutlineStyle() )
5242 int nNewListLevel = mrTextNode.GetTextColl()->GetAssignedOutlineStyleLevel();
5243 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
5245 mrTextNode.SetAttrListLevel( nNewListLevel );
5248 mrTextNode.AddToList();
5254 if (mrTextNode.GetpSwAttrSet()
5257 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
5262 if ( !mrTextNode.IsInList() )
5265 if ( mbUpdateListLevel )
5267 auto const nLevel(mrTextNode.GetAttrListLevel());
5268 const SwDoc& rDoc(mrTextNode.GetDoc());
5273 if ( mbUpdateListRestart )
5275 const SwDoc& rDoc(mrTextNode.GetDoc());
5283 if ( mbUpdateListCount )
5285 const SwDoc& rDoc(mrTextNode.GetDoc());
5298 HandleResetAttrAtTextNode aHandleResetAttr( *
this, nWhich1, nWhich2 );
5312 HandleResetAttrAtTextNode aHandleResetAttr( *
this, rWhichArr );
5326 HandleResetAttrAtTextNode aHandleResetAttr( *
this );
5337 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextNode"));
5338 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
5339 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"), BAD_CAST(OString::number(sal_Int32(
GetIndex())).getStr()));
5342 for (
int i = 0;
i < 32; ++
i)
5343 sText = sText.replace(
i,
'*');
5344 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_Text"));
5345 (void)xmlTextWriterWriteString(pWriter, BAD_CAST(sText.toUtf8().getStr()));
5346 (void)xmlTextWriterEndElement(pWriter);
5350 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFormatColl"));
5351 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"name"), BAD_CAST(
GetFormatColl()->
GetName().toUtf8().getStr()));
5352 (void)xmlTextWriterEndElement(pWriter);
5357 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwAttrSet"));
5359 (void)xmlTextWriterEndElement(pWriter);
5364 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwpHints"));
5366 for (
size_t i = 0;
i < rHints.
Count(); ++
i)
5368 (void)xmlTextWriterEndElement(pWriter);
5371 (void)xmlTextWriterEndElement(pWriter);
5381 return pRsid->GetValue();
5397 return nThisRsid == nRsid;
5402 sal_uInt32 nThisRsid =
GetRsid( nStt1, nStt1 );
5403 sal_uInt32 nRsid = rTextNode.
GetRsid( nStt2, nStt2 );
5405 return nThisRsid == nRsid;