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 );
1606 pSortedObjs = pFrame->FindPageFrame()->GetSortedObjs();
1616 pEditShell->ValidateParagraphSignatures(
this,
true);
1634 if (nChangePos <= pRedln->
Start()->GetContentIndex())
1655 if (
MAXLEVEL != nNewLevel && -1 != nNewLevel )
1680 bool bFormatToTextAttributes )
1682 if (bFormatToTextAttributes && nIdx ==
m_Text.getLength())
1695 const sal_Int32 *pEnd = pTmp->
GetEnd();
1698 assert( *pEnd <= nIdx );
1715 return ((nHintStart <=
nIndex) && (
nIndex < nHintEnd));
1719 return ((nHintStart <
nIndex) && (
nIndex <= nHintEnd));
1728 std::vector<SwTextAttr *> *
const pVector,
1731 sal_Int32
const nIndex, sal_uInt16
const nWhich,
1737 size_t const nSize = pSwpHints->
Count();
1738 sal_Int32 nPreviousIndex(0);
1739 bool (*pMatchFunc)(sal_Int32, sal_Int32, sal_Int32)=
nullptr;
1748 default: assert(
false);
1754 if (pHint->
Which() != nWhich)
1757 sal_Int32
const nHintStart = pHint->
GetStart();
1761 sal_Int32
const*
const pEndIdx = pHint->
GetEnd();
1766 bool const bContained( pEndIdx
1767 ? (*pMatchFunc)(
nIndex, nHintStart, *pEndIdx)
1768 : (nHintStart ==
nIndex) );
1773 if (nPreviousIndex < nHintStart)
1776 nPreviousIndex = nHintStart;
1778 pVector->push_back(pHint);
1782 *ppTextAttr = pHint;
1792std::vector<SwTextAttr *>
1796 std::vector<SwTextAttr *> ret;
1824 if ( pTextInputField ==
nullptr && rTextAttr.
End() != nullptr )
1829 return pTextInputField;
1848 const sal_Int32 nIndex,
1852 if ( pTextField ==
nullptr )
1856 if ( pTextField ==
nullptr )
1870 if( !rName.empty() )
1872 const size_t nArrLen = pCharFormats->
size();
1873 for(
size_t i = 1;
i < nArrLen;
i++ )
1876 if( pFormat->
GetName()==rName )
1884 const sal_uInt16 nWhich,
1887 SwDoc *
const pOtherDoc,
1890 assert(nWhich == pHt->
Which());
1904 if( pOtherDoc !=
nullptr )
1906 static_txtattr_cast<const SwTextField*>(pHt)->CopyTextField(
1907 static_txtattr_cast<SwTextField*>(pNewHt));
1931 if( pOtherDoc !=
nullptr )
1933 static_txtattr_cast<const SwTextField*>(pHt)->CopyTextField(
1934 static_txtattr_cast<SwTextField*>(pNewHt));
1944 static_txtattr_cast<SwTextTOXMark*>(pNewHt)->CopyTOXMark(*pOtherDoc);
1983 SwTextINetFormat *
const pINetHt = static_txtattr_cast<SwTextINetFormat*>(pNewHt);
1995 OSL_ENSURE( pNewHt,
"copying Meta should not fail!" );
1998 "missing CH_TXTATR?");
2008 const sal_Int32 nOldPos )
2013 &pDest->
GetDoc() :
nullptr;
2018 sal_Int32
const nAttrStartIdx = pHt->
GetStart();
2019 if ( nTextStartIdx < nAttrStartIdx )
2022 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2025 sal_uInt16
const nWhich = pHt->
Which();
2027 && ( *pEndIdx > nTextStartIdx
2028 || (*pEndIdx == nTextStartIdx
2029 && nAttrStartIdx == nTextStartIdx)))
2043 ?
GetDoc().IsCopyIsMove()
2069 const sal_Int32 nLen,
2070 const bool bForceCopyOfAllAttrs )
2073 CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs );
2080 const bool bForceCopyOfAllAttrs )
2082 CopyText( pDest, rDestStart, rStart.
nContent, nLen, bForceCopyOfAllAttrs );
2089 const bool bForceCopyOfAllAttrs )
2095 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2096 sal_Int32 nDestStart = rDestStart.
GetIndex();
2109 CopyAttr( pDest, nTextStartIdx, nDestStart );
2115 if ( !bForceCopyOfAllAttrs &&
2118 nLen != pDest->
GetText().getLength()))
2126 if( aCharSet.Count() )
2128 pDest->
SetAttr( aCharSet, nDestStart, nDestStart );
2140 const sal_Int32 oldLen = pDest->
m_Text.getLength();
2147 nLen = pDest->
m_Text.getLength() - oldLen;
2157 if ( !bForceCopyOfAllAttrs &&
2160 nLen != pDest->
GetText().getLength()))
2168 if( aCharSet.Count() )
2170 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2179 bool const bUndoNodes = !pOtherDoc
2185 const sal_Int32 nEnd = nTextStartIdx + nLen;
2199 std::vector<std::pair<sal_Int32, sal_Int32>> metaFieldRanges;
2200 sal_Int32 nDeletedDummyChars(0);
2201 for (
size_t n = 0;
n < nSize; ++
n)
2205 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2206 if ( nAttrStartIdx >= nEnd )
2209 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2210 const sal_uInt16 nWhich = pHt->
Which();
2234 assert(pEndIdx !=
nullptr &&
2235 "<SwTextNode::CopyText(..)> - RES_TXTATR_INPUTFIELD without EndIndex!" );
2236 if ( nAttrStartIdx < nTextStartIdx
2237 || ( pEndIdx !=
nullptr
2238 && *pEndIdx > nEnd ) )
2247 metaFieldRanges.emplace_back(nAttrStartIdx, pEndIdx ? *pEndIdx : nEnd);
2251 sal_Int32 nAttrStt = 0;
2252 sal_Int32 nAttrEnd = 0;
2254 if( nAttrStartIdx < nTextStartIdx )
2258 if ( pEndIdx && (*pEndIdx > nTextStartIdx) && !pHt->
HasDummyChar() )
2261 nAttrStt = nDestStart;
2262 nAttrEnd = (*pEndIdx > nEnd)
2264 : nDestStart + (*pEndIdx) - nTextStartIdx;
2274 nAttrStt = nDestStart + ( nAttrStartIdx - nTextStartIdx );
2277 nAttrEnd = *pEndIdx > nEnd
2279 : nDestStart + ( *pEndIdx - nTextStartIdx );
2283 nAttrEnd = nAttrStt;
2296 aArr.push_back( pNewHt );
2302 nAttrStt - nDeletedDummyChars,
2303 nAttrEnd - nDeletedDummyChars,
2314 ++nDeletedDummyChars;
2320 aRefMrkArr.push_back( pNewHt );
2326 if (!metaFieldRanges.empty())
2329 std::reverse(metaFieldRanges.begin(), metaFieldRanges.end());
2330 for (
const auto& pair : metaFieldRanges)
2333 pDest->
EraseText(aIdx, pair.second - pair.first);
2347 if( pNewHt->GetEnd() )
2374 assert(rIdx <=
m_Text.getLength());
2376 const sal_Int32 aPos = rIdx.
GetIndex();
2377 sal_Int32 nLen =
m_Text.getLength() - aPos;
2378 sal_Int32
const nOverflow(rStr.getLength() -
GetSpaceLeft());
2380 "SwTextNode::InsertText: node text with insertion > capacity.");
2381 OUString
const sInserted(
2382 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
2383 if (sInserted.isEmpty())
2387 if (aPos == 0 &&
m_Text.isEmpty())
2392 nLen =
m_Text.getLength() - aPos - nLen;
2401 Update(rIdx, nLen, UpdateMode::Default);
2408 if ( HasWriterListeners() )
2411 CallSwClientNotify(aInsHint);
2417 bool const bHadHints(!
m_pSwpHints->CanBeDeleted());
2418 bool bMergePortionsNeeded(
false);
2420 rIdx >=
m_pSwpHints->GetWithoutResorting(
i)->GetStart(); ++
i )
2423 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2427 if( rIdx == *pEndIdx )
2437 pHt->
SetEnd(*pEndIdx - nLen);
2444 bMergePortionsNeeded =
true;
2478 if (bMergePortionsNeeded)
2483 "SwTextNode::InsertText: unexpected loss of hints");
2499 CutImpl( pDest, aDestStt, rStart, nLen,
false );
2503 const SwContentIndex & rStart, sal_Int32 nLen,
const bool bUpdate )
2509 assert(pDest !=
this);
2521 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2522 sal_Int32 nDestStart = rDestStart.
GetIndex();
2523 const sal_Int32 nInitSize = pDest->
m_Text.getLength();
2531 m_Text.subView(nTextStartIdx, nLen));
2532 OUString
const newText =
m_Text.replaceAt(nTextStartIdx, nLen,
u"");
2533 nLen = pDest->
m_Text.getLength() - nInitSize;
2540 pDest->
Update(rDestStart, nLen, UpdateMode::Default);
2545 const sal_Int32 nEnd = rStart.
GetIndex() + nLen;
2546 bool const bUndoNodes =
2557 hasSwAttrSet =
false;
2580 hasSwAttrSet = (rParentItem != *pItem);
2594 if( nInitSize || hasSwAttrSet ||
2595 nLen != pDest->
GetText().getLength())
2603 if( aCharSet.Count() )
2604 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2614 if (aCharSet.Count())
2615 pDest->
SetAttr(aCharSet, nDestStart, nDestStart + nLen);
2624 const sw::MoveText aMoveHint(pDest, nDestStart, nTextStartIdx, nLen);
2625 CallSwClientNotify(aMoveHint);
2632 bool bMergePortionsNeeded(
false);
2633 size_t nAttrCnt = 0;
2637 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2638 if ( nAttrStartIdx >= nEnd )
2640 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2641 const sal_uInt16 nWhich = pHt->
Which();
2645 if(nAttrStartIdx < nTextStartIdx)
2649 || bUndoNodes ) && pEndIdx && *pEndIdx > nTextStartIdx)
2657 : *pEndIdx - nTextStartIdx ) );
2663 if (!pEndIdx || *pEndIdx < nEnd ||
2668 if (
GetDoc().GetDocShell())
2677 bMergePortionsNeeded =
true;
2679 pHt->
SetStart(nDestStart + (nAttrStartIdx - nTextStartIdx));
2682 pHt->
SetEnd( nDestStart + (
2685 : *pEndIdx - nTextStartIdx ) );
2690 if (
GetDoc().GetDocShell())
2700 nDestStart + (nAttrStartIdx - nTextStartIdx),
2701 nDestStart + (*pEndIdx > nEnd
2703 : *pEndIdx - nTextStartIdx));
2708 const bool bSuccess( pDest->
InsertHint( pNewHt,
2726 while (nAttrCnt < m_pSwpHints->
Count())
2731 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2732 if (pEndIdx && *pEndIdx == nEnd)
2734 aArr.push_back( pHt );
2742 Update(rStart, nLen, UpdateMode::Negative|UpdateMode::Delete);
2746 pHt->SetStart( rStart.
GetIndex() );
2753 Update(rStart, nLen, UpdateMode::Negative|UpdateMode::Delete);
2759 if (bMergePortionsNeeded)
2779 assert(rIdx <=
m_Text.getLength());
2781 const sal_Int32 nStartIdx = rIdx.
GetIndex();
2784 const sal_Int32 nEndIdx = nStartIdx + nCnt;
2785 if (nEndIdx <=
m_Text.getLength())
2795 const sal_Int32 nHintStart = pHt->
GetStart();
2797 if ( nHintStart < nStartIdx )
2800 if ( nHintStart > nEndIdx )
2803 const sal_Int32* pHtEndIdx = pHt->
GetEnd();
2804 const sal_uInt16 nWhich = pHt->
Which();
2810 if (
isTXTATR(nWhich) && (nHintStart < nEndIdx))
2819 assert(!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx)
2822 || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)));
2832 if ( (*pHtEndIdx < nEndIdx)
2833 || ( (*pHtEndIdx == nEndIdx) &&
2839 || ( (nHintStart < nEndIdx) &&
2849 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2853 Update(rIdx, nCnt, UpdateMode::Negative);
2858 CallSwClientNotify(aHint);
2861 CallSwClientNotify(aHint);
2864 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2878 bool bChanged =
false;
2879 sal_Int32 nMin =
m_Text.getLength();
2881 const bool bAll = nMin != 0;
2888 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2894 nMax = std::max( nMax, *pHt->
GetEnd() );
2924 bool bNoNumRule =
false;
2927 OUString sNumRuleName =
2929 if (!sNumRuleName.isEmpty())
2939 if ( pRet && pRet ==
GetDoc().GetOutlineNumRule() &&
2941 SfxItemState::SET !=
2948 if ( rDirectItem.
GetValue().isEmpty() )
2995 bool bResult =
false;
3011 std::optional<SwAttrSet> oNewAttrSet;
3013 bool bClearHardSetNumRuleWhenFormatCollChanges(
false );
3020 pTmpSet = &*oNewAttrSet;
3023 bool bRemoveFromCache =
false;
3024 std::vector<sal_uInt16> aClearWhichIds;
3026 bRemoveFromCache = ( 0 != oNewAttrSet->ClearItem(
RES_PAGEDESC ) );
3036 bRemoveFromCache =
true;
3041 oNewAttrSet->ClearItem(
RES_KEEP );
3043 aClearWhichIds.push_back(
RES_KEEP );
3044 bRemoveFromCache =
true;
3052 bRemoveFromCache =
true;
3067 bClearHardSetNumRuleWhenFormatCollChanges =
true;
3069 bRemoveFromCache =
true;
3073 if ( !aClearWhichIds.empty() )
3076 if( !bNext && bRemoveFromCache )
3087 oNewAttrSet.reset();
3106 if( bNext || !bChgFollow )
3112 if (pNextColl != pColl)
3115 if ( bClearHardSetNumRuleWhenFormatCollChanges )
3148 if( HasWriterListeners() )
3154 const sal_Int32 nIndex,
3155 const sal_uInt16 nWhich )
const
3163 const sal_Int32 nStartPos = pHint->
GetStart();
3164 if (
nIndex < nStartPos )
3203sal_uInt16 lcl_BoundListLevel(
const int nActualLevel)
3205 return o3tl::narrowing<sal_uInt16>( std::clamp( nActualLevel, 0,
MAXLEVEL-1 ) );
3213 bool bResult =
false;
3229 bool bResult =
false;
3246 const unsigned int _nRestrictToThisLevel,
3265 _bInclPrefixAndSuffixStrings,
3266 _nRestrictToThisLevel,
3363 SwTwips nAdditionalIndent = 0;
3375 nAdditionalIndent = nAdditionalIndent -
3390 nAdditionalIndent = nAdditionalIndent -
3401 return nAdditionalIndent;
3415 o_rLRSpaceItem = std::make_shared<SvxLRSpaceItem>(
RES_LR_SPACE);
3426 bool bLeftMarginForTabCalcSetToListLevelIndent(
false );
3436 bLeftMarginForTabCalcSetToListLevelIndent =
true;
3440 if ( !bLeftMarginForTabCalcSetToListLevelIndent )
3445 return nLeftMarginForTabCalc;
3450 OUStringBuffer & rText,
3451 sal_Int32 & rTextStt,
3458 for(
int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, cSrchChr =
CH_TXTATR_INWORD )
3460 sal_Int32
nPos = rText.indexOf(cSrchChr);
3461 while (-1 !=
nPos &&
nPos < nEndPos)
3467 switch( pAttr->
Which() )
3471 rText.remove(
nPos, 1);
3476 rText.remove(
nPos, 1);
3481 rText.remove(
nPos, 1);
3490 nPos = rText.indexOf(cSrchChr,
nPos);
3498 const sal_Int32 nIdx,
3499 const sal_Int32 nLen,
3500 const bool bWithNum,
3501 const bool bAddSpaceAfterListLabelStr,
3502 const bool bWithSpacesForLevel,
3513 const OUString aExpandText = aConversionMap.
getViewText();
3515 sal_Int32 nEnd = nLen == -1 ?
GetText().getLength() : nIdx + nLen;
3517 OUStringBuffer aText(aExpandText.subView(nExpandBegin, nExpandEnd-nExpandBegin));
3528 if ( bAddSpaceAfterListLabelStr )
3531 aText.insert(0, aSpace);
3537 if (bWithSpacesForLevel)
3542 aText.insert(0, aSpace);
3543 aText.insert(0, aSpace);
3547 return aText.makeStringAndClear();
3551 sal_Int32 nIdx, sal_Int32 nLen,
3553 bool bWithFootnote,
bool bReplaceTabsWithSpaces )
const
3555 if( &rDestNd ==
this )
3561 aDestIdx = *pDestIdx;
3562 const sal_Int32 nDestStt = aDestIdx.
GetIndex();
3565 OUStringBuffer buf(
GetText());
3566 if( bReplaceTabsWithSpaces )
3567 buf.replace(
'\t',
' ');
3573 buf.remove(0, nIdx);
3583 rDestNd.
InsertText(buf.makeStringAndClear(), aDestIdx);
3584 nLen = aDestIdx.
GetIndex() - nDestStt;
3589 sal_Int32 nInsPos = nDestStt - nIdx;
3593 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
3594 const sal_uInt16 nWhich = pHt->
Which();
3595 if (nIdx + nLen <= nAttrStartIdx)
3598 const sal_Int32 *pEndIdx = pHt->
End();
3599 if( pEndIdx && *pEndIdx > nIdx &&
3606 if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->
GetCharSet() )
3610 nInsPos + nAttrStartIdx, nInsPos + *pEndIdx );
3613 else if ( pHt->
HasDummyChar() && (nAttrStartIdx >= nIdx) )
3615 aDestIdx = nInsPos + nAttrStartIdx;
3621 OUString
const aExpand(
3622 static_txtattr_cast<SwTextField const*>(pHt)->GetFormatField().GetField()->ExpandField(
true, pLayout));
3623 if (!aExpand.isEmpty())
3628 SAL_INFO_IF(ins.getLength() != aExpand.getLength(),
3629 "sw.core",
"GetExpandText lossage");
3630 aDestIdx = nInsPos + nAttrStartIdx;
3631 nInsPos += ins.getLength();
3640 if ( bWithFootnote )
3655 if( !sExpand.isEmpty() )
3664 SAL_INFO_IF(ins.getLength() != sExpand.getLength(),
3665 "sw.core",
"GetExpandText lossage");
3666 aDestIdx = nInsPos + nAttrStartIdx;
3667 nInsPos += ins.getLength();
3685 aDestIdx = nDestStt;
3690 sal_Int32 nStartDelete(-1);
3691 while (aDestIdx < rDestNd.
GetText().getLength())
3700 if (-1 == nStartDelete)
3702 nStartDelete = aDestIdx.
GetIndex();
3705 if (aDestIdx < rDestNd.
GetText().getLength())
3712 if (-1 == nStartDelete)
3718 assert(-1 != nStartDelete);
3721 aDestIdx.
GetIndex() - nStartDelete);
3722 assert(aDestIdx.
GetIndex() == nStartDelete);
3731 std::vector<sal_Int32> aRedlArr;
3741 if( RedlineType::Delete == pTmp->
GetType() )
3746 if( pREnd->GetNodeIndex() > nNdIdx )
3749 else if( pREnd->GetNodeIndex() == nNdIdx )
3752 aRedlArr.push_back( 0 );
3753 aRedlArr.push_back( pREnd->GetContentIndex() );
3760 if( pREnd->GetNodeIndex() == nNdIdx )
3761 aRedlArr.push_back( pREnd->GetContentIndex() );
3774 OUStringBuffer aText(
GetText());
3776 sal_Int32 nTextStt = 0;
3777 sal_Int32 nIdxEnd = aText.getLength();
3778 for(
size_t n = 0;
n < aRedlArr.size();
n += 2 )
3780 sal_Int32 nStt = aRedlArr[
n ];
3781 sal_Int32 nEnd = aRedlArr[
n+1 ];
3782 if( ( 0 <= nStt && nStt <= nIdxEnd ) ||
3783 ( 0 <= nEnd && nEnd <= nIdxEnd ))
3785 if( nStt < 0 ) nStt = 0;
3786 if( nIdxEnd < nEnd ) nEnd = nIdxEnd;
3787 const sal_Int32 nDelCnt = nEnd - nStt;
3788 aText.remove(nStt - nTextStt, nDelCnt);
3789 Replace0xFF(*
this, aText, nTextStt, nStt - nTextStt);
3790 nTextStt += nDelCnt;
3792 else if( nStt >= nIdxEnd )
3795 Replace0xFF(*
this, aText, nTextStt, aText.getLength());
3797 return aText.makeStringAndClear();
3801 const OUString & rStr)
3807 sal_Int32
const nOverflow(rStr.getLength() - nDelLen -
GetSpaceLeft());
3809 "SwTextNode::ReplaceText: node text with insertion > node capacity.");
3810 OUString
const sInserted(
3811 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
3812 if (sInserted.isEmpty() && 0 == nDelLen)
3817 const sal_Int32 nStartPos = rStart.
GetIndex();
3818 sal_Int32 nEndPos = nStartPos + nDelLen;
3819 sal_Int32 nLen = nDelLen;
3820 for( sal_Int32
nPos = nStartPos;
nPos < nEndPos; ++
nPos )
3830 && (*pHint->
GetEnd() > nEndPos) ));
3842 if (nLen && sInserted.getLength())
3846 m_Text =
m_Text.replaceAt(nStartPos, 1, sInserted.subView(0, 1));
3850 Update(rStart, nLen - 1, UpdateMode::Negative);
3852 std::u16string_view aTmpText( sInserted.subView(1) );
3854 Update(rStart, aTmpText.size(), UpdateMode::Replace);
3859 Update(rStart, nLen, UpdateMode::Negative);
3862 Update(rStart, sInserted.getLength(), UpdateMode::Replace);
3867 CallSwClientNotify(aDelHint);
3869 if (sInserted.getLength())
3872 CallSwClientNotify(aInsHint);
3877 const OUString & rStr)
3883 void lcl_ResetParAttrs(
SwTextNode &rTextNode )
3889 SwPaM aPam( rTextNode );
3904 void HandleModifyAtTextNode(
SwTextNode& rTextNode,
3908 const sal_uInt16 nWhich = pOldValue ? pOldValue->
Which() :
3909 pNewValue ? pNewValue->
Which() : 0 ;
3910 bool bNumRuleSet =
false;
3911 bool bParagraphStyleChanged =
false;
3913 OUString sOldNumRule;
3918 bParagraphStyleChanged =
true;
3921 const SwNumRule* pFormerNumRuleAtTextNode =
3923 if ( pFormerNumRuleAtTextNode )
3925 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3930 if ( !rNumRuleItem.
GetValue().isEmpty() )
3936 if ( pNumRuleAtTextNode )
3939 sNumRule = pNumRuleAtTextNode->
GetName();
3946 const SwNumRule* pFormerNumRuleAtTextNode =
3948 if ( pFormerNumRuleAtTextNode )
3950 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3964 if ( pNumRuleAtTextNode )
3966 sNumRule = pNumRuleAtTextNode->
GetName();
3974 const SwNumRule* pFormerNumRuleAtTextNode =
3976 if ( pFormerNumRuleAtTextNode )
3978 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3990 if ( pNumRuleAtTextNode )
3992 sNumRule = pNumRuleAtTextNode->
GetName();
3998 if ( sNumRule != sOldNumRule )
4002 if (sNumRule.isEmpty())
4005 if ( bParagraphStyleChanged )
4007 lcl_ResetParAttrs(rTextNode);
4019 "<HandleModifyAtTextNode()> - text node with outline style, but its paragraph style is not assigned to outline style." );
4020 const int nNewListLevel =
4022 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
4033 if ( bParagraphStyleChanged )
4035 lcl_ResetParAttrs(rTextNode);
4044 else if (!sNumRule.isEmpty() && !rTextNode.
IsInList())
4054 OSL_ENSURE( pNewColl,
"ChgFormatColl: Collectionpointer has value 0." );
4055 assert(
dynamic_cast<const SwTextFormatColl *
>(pNewColl) &&
"ChgFormatColl: is not a Text Collection pointer." );
4058 if( pNewColl != pOldColl )
4063 "DEBUG OSL_ENSURE(ON - <SwTextNode::ChgFormatColl(..)> called during <Set/ResetAttr(..)>" );
4068 HandleModifyAtTextNode( *
this, &aTmp1, &aTmp2 );
4101 std::unique_ptr<SwNodeNum> pBackup2 = std::move(
mpNodeNumOrig);
4121 return pNum->GetNumberVector();
4132 bool bResult =
false;
4167 assert(0 <= nLevel && nLevel <=
MAXLEVEL);
4168 if ( 0 <= nLevel && nLevel <=
MAXLEVEL )
4171 o3tl::narrowing<sal_uInt16>(nLevel) ) );
4178 auto it = rGrabBagItem.
GetGrabBag().find(
"OutlineContentVisibleAttr");
4180 it->second >>= bOutlineContentVisibleAttr;
4212 if ( nLevel < 0 || nLevel >=
MAXLEVEL )
4219 static_cast<sal_Int16
>(nLevel) );
4231 int nAttrListLevel = 0;
4235 nAttrListLevel =
static_cast<int>(aListLevelItem.
GetValue());
4237 return nAttrListLevel;
4302 : nNumber != USHRT_MAX );
4307 if ( nNumber == USHRT_MAX )
4314 static_cast<sal_Int16
>(nNumber) );
4315 SetAttr( aNewListRestartValueItem );
4327 "<SwTextNode::GetAttrListRestartValue()> - only ask for list restart value, if attribute is set at text node." );
4351 nListRestartValue = pFormat->
GetStart();
4356 return nListRestartValue;
4381 SetAttr( aIsCountedInListItem );
4389 return aIsCountedInListItem.
GetValue();
4394 const OUString sListId = pNode->
GetListId();
4395 if (!sListId.isEmpty())
4398 SwList* pList = rIDLA.getListByName( sListId );
4399 if ( pList ==
nullptr )
4408 OSL_ENSURE( pList !=
nullptr,
4409 "<SwTextNode::AddToList()> - no list for given list id. Serious defect" );
4419 OSL_FAIL(
"<SwTextNode::AddToList()> - the text node is already added to a list. Serious defect" );
4424 if (!(pList &&
GetNodes().IsDocNodes()))
4436 if (!bRecordChanges ||
GetDoc().IsInXMLImport() ||
GetDoc().IsInWriterfilterImport() )
4454 else if ( bRecordChanges )
4461 if (pFrame->getRootFrame()->IsHideRedlines())
4463 if (pFrame->GetTextNodeForParaProps() ==
this)
4545 bool bResult =
false;
4558 if (rListIdItem.
GetValue() != rListId)
4560 if (rListId.isEmpty())
4576 const OUString& sListId {rListIdItem.
GetValue()};
4580 if (sListId.isEmpty())
4608 bool bAreListLevelIndentsApplicable(
true );
4613 bAreListLevelIndentsApplicable =
false;
4619 bAreListLevelIndentsApplicable =
false;
4626 bAreListLevelIndentsApplicable =
true;
4640 bAreListLevelIndentsApplicable =
false;
4648 bAreListLevelIndentsApplicable =
true;
4654 "<SwTextNode::AreListLevelIndentsApplicable()> - something wrong in paragraph's style hierarchy. The applied list style is not found." );
4658 return bAreListLevelIndentsApplicable;
4671 bool bListTabStopPositionProvided(
false);
4680 bListTabStopPositionProvided =
true;
4700 return bListTabStopPositionProvided;
4720 sal_Int32 nStartPos;
4764 class HandleSetAttrAtTextNode
4767 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4769 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4771 ~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
4775 bool mbAddTextNodeToList;
4776 bool mbUpdateListLevel;
4777 bool mbUpdateListRestart;
4778 bool mbUpdateListCount;
4780 bool mbOutlineLevelSet;
4783 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4785 : mrTextNode( rTextNode ),
4786 mbAddTextNodeToList( false ),
4787 mbUpdateListLevel( false ),
4788 mbUpdateListRestart( false ),
4789 mbUpdateListCount( false ),
4791 mbOutlineLevelSet( false )
4793 switch ( pItem.Which() )
4798 mrTextNode.RemoveFromList();
4802 if ( !rNumRuleItem.
GetValue().isEmpty() )
4804 mbAddTextNodeToList =
true;
4807 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4817 OSL_ENSURE( rListIdItem.
GetValue().getLength() > 0,
4818 "<HandleSetAttrAtTextNode(..)> - empty list id attribute not expected. Serious defect." );
4819 const OUString sListIdOfTextNode = rTextNode.GetListId();
4820 if ( rListIdItem.
GetValue() != sListIdOfTextNode )
4822 mbAddTextNodeToList =
true;
4823 if ( mrTextNode.IsInList() )
4825 mrTextNode.RemoveFromList();
4836 if ( aListLevelItem.
GetValue() != mrTextNode.GetAttrListLevel() )
4838 mbUpdateListLevel =
true;
4848 if ( aListIsRestartItem.
GetValue() !=
4849 mrTextNode.IsListRestart() )
4851 mbUpdateListRestart =
true;
4861 if ( !mrTextNode.HasAttrListRestartValue() ||
4862 aListRestartValueItem.
GetValue() != mrTextNode.GetAttrListRestartValue() )
4864 mbUpdateListRestart =
true;
4874 if ( aIsCountedInListItem.
GetValue() !=
4875 mrTextNode.IsCountedInList() )
4877 mbUpdateListCount =
true;
4888 if ( aOutlineLevelItem.
GetValue() != mrTextNode.GetAttrOutlineLevel() )
4890 mbOutlineLevelSet =
true;
4898 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4900 : mrTextNode( rTextNode ),
4901 mbAddTextNodeToList( false ),
4902 mbUpdateListLevel( false ),
4903 mbUpdateListRestart( false ),
4904 mbUpdateListCount( false ),
4906 mbOutlineLevelSet( false )
4911 mrTextNode.RemoveFromList();
4913 if ( !pNumRuleItem->GetValue().isEmpty() )
4915 mbAddTextNodeToList =
true;
4917 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4924 const OUString sListIdOfTextNode = mrTextNode.GetListId();
4925 if ( pListIdItem->GetValue() != sListIdOfTextNode )
4927 mbAddTextNodeToList =
true;
4928 if ( mrTextNode.IsInList() )
4930 mrTextNode.RemoveFromList();
4938 if (pListLevelItem->GetValue() != mrTextNode.GetAttrListLevel())
4940 mbUpdateListLevel =
true;
4947 if (pListIsRestartItem->GetValue() != mrTextNode.IsListRestart())
4949 mbUpdateListRestart =
true;
4956 if ( !mrTextNode.HasAttrListRestartValue() ||
4957 pListRestartValueItem->GetValue() != mrTextNode.GetAttrListRestartValue() )
4959 mbUpdateListRestart =
true;
4966 if (pIsCountedInListItem->GetValue() != mrTextNode.IsCountedInList())
4968 mbUpdateListCount =
true;
4976 if (pOutlineLevelItem->GetValue() != mrTextNode.GetAttrOutlineLevel())
4978 mbOutlineLevelSet =
true;
4983 HandleSetAttrAtTextNode::~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
4985 if ( mbAddTextNodeToList )
4987 SwNumRule* pNumRuleAtTextNode = mrTextNode.GetNumRule();
4988 if ( pNumRuleAtTextNode )
4990 mrTextNode.AddToList();
4995 if ( mbUpdateListLevel && mrTextNode.IsInList() )
4997 auto const nLevel(mrTextNode.GetAttrListLevel());
4998 const SwDoc& rDoc(mrTextNode.GetDoc());
5003 if ( mbUpdateListRestart && mrTextNode.IsInList() )
5005 const SwDoc& rDoc(mrTextNode.GetDoc());
5017 const SwDoc& rDoc(mrTextNode.GetDoc());
5024 if (!mbOutlineLevelSet)
5027 mrTextNode.GetNodes().UpdateOutlineNode(mrTextNode);
5028 if (mrTextNode.GetAttrOutlineLevel() == 0)
5030 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5035 != SfxItemState::SET )
5037 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
5049 HandleSetAttrAtTextNode aHandleSetAttr( *
this, pItem );
5063 HandleSetAttrAtTextNode aHandleSetAttr( *
this,
rSet );
5094 class HandleResetAttrAtTextNode
5097 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5098 const sal_uInt16 nWhich1,
5099 sal_uInt16 nWhich2 );
5100 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5101 const std::vector<sal_uInt16>& rWhichArr );
5102 explicit HandleResetAttrAtTextNode(
SwTextNode& rTextNode );
5104 ~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
5108 bool mbListStyleOrIdReset;
5109 bool mbUpdateListLevel;
5110 bool mbUpdateListRestart;
5111 bool mbUpdateListCount;
5113 void init( sal_uInt16 nWhich,
bool& rbRemoveFromList );
5116 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5117 const sal_uInt16 nWhich1,
5118 sal_uInt16 nWhich2 )
5119 : mrTextNode( rTextNode ),
5120 mbListStyleOrIdReset( false ),
5121 mbUpdateListLevel( false ),
5122 mbUpdateListRestart( false ),
5123 mbUpdateListCount( false )
5125 if ( nWhich2 < nWhich1 )
5127 bool bRemoveFromList(
false );
5128 for ( sal_uInt16 nWhich = nWhich1; nWhich <= nWhich2; ++nWhich )
5129 init( nWhich, bRemoveFromList );
5130 if ( bRemoveFromList && mrTextNode.IsInList() )
5131 mrTextNode.RemoveFromList();
5134 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
5135 const std::vector<sal_uInt16>& rWhichArr )
5136 : mrTextNode( rTextNode ),
5137 mbListStyleOrIdReset( false ),
5138 mbUpdateListLevel( false ),
5139 mbUpdateListRestart( false ),
5140 mbUpdateListCount( false )
5142 bool bRemoveFromList(
false );
5143 for ( sal_uInt16 nWhich : rWhichArr )
5144 init( nWhich, bRemoveFromList );
5145 if ( bRemoveFromList && mrTextNode.IsInList() )
5146 mrTextNode.RemoveFromList();
5149 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode )
5150 : mrTextNode( rTextNode ),
5151 mbListStyleOrIdReset( true ),
5152 mbUpdateListLevel( false ),
5153 mbUpdateListRestart( false ),
5154 mbUpdateListCount( false )
5161 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5164 void HandleResetAttrAtTextNode::init( sal_uInt16 rWhich,
bool& rbRemoveFromList )
5168 rbRemoveFromList = rbRemoveFromList ||
5169 mrTextNode.GetNumRule() !=
nullptr;
5170 mbListStyleOrIdReset =
true;
5174 rbRemoveFromList = rbRemoveFromList ||
5175 ( mrTextNode.GetpSwAttrSet() &&
5176 mrTextNode.GetpSwAttrSet()->GetItemState(
RES_PARATR_LIST_ID,
false ) == SfxItemState::SET );
5177 mbListStyleOrIdReset =
true;
5180 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5182 mrTextNode.ResetAttr( XATTR_FILL_FIRST, XATTR_FILL_LAST );
5184 if ( !rbRemoveFromList )
5187 mbUpdateListLevel = mbUpdateListLevel ||
5189 mrTextNode.HasAttrListLevel() );
5192 mbUpdateListRestart = mbUpdateListRestart ||
5194 mrTextNode.IsListRestart() ) ||
5196 mrTextNode.HasAttrListRestartValue() );
5199 mbUpdateListCount = mbUpdateListCount ||
5201 !mrTextNode.IsCountedInList() );
5205 HandleResetAttrAtTextNode::~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
5207 if ( mbListStyleOrIdReset && !mrTextNode.IsInList() )
5211 if (mrTextNode.GetNumRule() && !mrTextNode.GetListId().isEmpty())
5216 if ( !mrTextNode.HasAttrListLevel() &&
5218 mrTextNode.GetTextColl()->IsAssignedToListLevelOfOutlineStyle() )
5220 int nNewListLevel = mrTextNode.GetTextColl()->GetAssignedOutlineStyleLevel();
5221 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
5223 mrTextNode.SetAttrListLevel( nNewListLevel );
5226 mrTextNode.AddToList();
5232 if (mrTextNode.GetpSwAttrSet()
5235 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
5240 if ( !mrTextNode.IsInList() )
5243 if ( mbUpdateListLevel )
5245 auto const nLevel(mrTextNode.GetAttrListLevel());
5246 const SwDoc& rDoc(mrTextNode.GetDoc());
5251 if ( mbUpdateListRestart )
5253 const SwDoc& rDoc(mrTextNode.GetDoc());
5261 if ( mbUpdateListCount )
5263 const SwDoc& rDoc(mrTextNode.GetDoc());
5276 HandleResetAttrAtTextNode aHandleResetAttr( *
this, nWhich1, nWhich2 );
5290 HandleResetAttrAtTextNode aHandleResetAttr( *
this, rWhichArr );
5304 HandleResetAttrAtTextNode aHandleResetAttr( *
this );
5315 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextNode"));
5316 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
5317 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"), BAD_CAST(OString::number(sal_Int32(
GetIndex())).getStr()));
5320 for (
int i = 0;
i < 32; ++
i)
5321 sText = sText.replace(
i,
'*');
5322 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_Text"));
5323 (void)xmlTextWriterWriteString(pWriter, BAD_CAST(sText.toUtf8().getStr()));
5324 (void)xmlTextWriterEndElement(pWriter);
5328 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFormatColl"));
5329 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"name"), BAD_CAST(
GetFormatColl()->
GetName().toUtf8().getStr()));
5330 (void)xmlTextWriterEndElement(pWriter);
5335 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwAttrSet"));
5337 (void)xmlTextWriterEndElement(pWriter);
5342 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwpHints"));
5344 for (
size_t i = 0;
i < rHints.
Count(); ++
i)
5346 (void)xmlTextWriterEndElement(pWriter);
5349 (void)xmlTextWriterEndElement(pWriter);
5359 return pRsid->GetValue();
5375 return nThisRsid == nRsid;
5380 sal_uInt32 nThisRsid =
GetRsid( nStt1, nStt1 );
5381 sal_uInt32 nRsid = rTextNode.
GetRsid( nStt2, nStt2 );
5383 return nThisRsid == nRsid;
5411 CallSwClientNotify(rHint);
5423 const auto pOldValue = rHint.
m_pOld;
5424 const auto pNewValue = rHint.
m_pNew;
5434 && GetRegisteredIn() ==
static_cast<const SwFormatChg*
>(pNewValue)->pChangedFormat