61 #include <section.hxx>
88 typedef std::vector<SwTextAttr*>
SwpHts;
93 #define CHECK_SWPHINTS(pNd) { if( pNd->GetpSwpHints() && \
94 !pNd->GetDoc().IsInReading() ) \
95 pNd->GetpSwpHints()->Check(true); }
96 #define CHECK_SWPHINTS_IF_FRM(pNd) { if( pNd->GetpSwpHints() && \
97 !pNd->GetDoc().IsInReading() ) \
98 pNd->GetpSwpHints()->Check(getLayoutFrame(nullptr, nullptr, nullptr) != nullptr); }
100 #define CHECK_SWPHINTS(pNd)
101 #define CHECK_SWPHINTS_IF_FRM(pNd)
107 OSL_ENSURE( pColl,
"Collection pointer is 0." );
116 !
GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() ||
131 static_cast<SwTableNode*
>(pNd)->MakeFramesForAdjacentContentNode(aIdx);
135 if( static_cast<SwSectionNode*>(pNd)->GetSection().IsHidden() ||
145 static_cast<SwSectionNode*
>(pNd)->MakeFramesForAdjacentContentNode(aIdx);
151 static_cast<SwContentNode*
>(pNd)->MakeFramesForAdjacentContentNode(*pNode);
190 m_pParaIdleData_Impl(nullptr),
191 m_bContainsHiddenChars(false),
192 m_bHiddenCharsHidePara(false),
193 m_bRecalcHiddenCharFlags(false),
194 m_bLastOutlineState( false ),
195 m_bNotifiable( false ),
196 mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ),
197 mbInSetOrResetAttr( false ),
236 std::unique_ptr<SwpHints> pTmpHints(std::move(
m_pSwpHints));
238 for(
size_t j = pTmpHints->Count(); j; )
247 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
277 return m_Text.getLength();
292 for(
size_t j = pSwpHints->
Count(); j; )
304 OSL_ENSURE( pAttr->
GetStartNode(),
"FootnoteAtr without StartNode." );
309 GetNodes().GoNextSection( &aIdx,
true,
false );
318 "lcl_ChangeFootnoteRef: Layout double?" );
320 if( pFootnote && pFootnote->GetAttr() == pAttr )
322 while( pFootnote->GetMaster() )
325 pFirstFootnoteOfNode = pFootnote;
328 pFootnote->
SetRef( pFrame );
329 pFootnote = pFootnote->GetFollow();
330 static_cast<SwTextFrame*
>(pFrame)->SetFootnote(
true );
333 #if OSL_DEBUG_LEVEL > 0
334 while(
nullptr != (pContent = aIter.
Next()) )
337 OSL_ENSURE( !pDbgFootnote || pDbgFootnote->
GetRef() == pFrame,
338 "lcl_ChangeFootnoteRef: Who's that guy?" );
345 if ( pFirstFootnoteOfNode )
370 if (pTmp->IsCreateFrameWhenHidingRedlines() || pTmp->IsEndNode())
374 else if (pTmp->IsStartNode())
376 nIndex = pTmp->EndOfSectionIndex();
379 && pTmp->IsTextNode())
388 std::vector<SwAnchoredObject*> objs;
389 objs.reserve(pObjs->size());
392 objs.push_back(pObj);
398 if (rFirstNode.
GetIndex() < rAnchor.GetContentAnchor()->nNode.GetIndex())
403 assert(!pFrame->GetDrawObjs() || !pObjs->Contains(*pObj));
421 const sal_Int32 nTextLen =
m_Text.getLength();
427 if (nSplitPos != 0) {
429 if (nSplitPos == nTextLen)
462 CutText( pNode, aIdx, nSplitPos );
511 const sal_Int32*
const pEnd = pHt->
GetEnd();
512 if (pEnd && pHt->
GetStart() == *pEnd )
524 if (pContentIndexRestore)
533 std::vector<SwTextFrame*> frames;
537 if (pFrame->getRootFrame()->HasMergedParas())
541 frames.push_back(pFrame);
545 pFrame->RegisterToNode( *pNode );
546 if (!pFrame->IsFollow() && pFrame->GetOffset())
561 if (pContentIndexRestore)
587 CutText( pNode, aIdx, nSplitPos );
595 const sal_Int32*
const pEnd = pHt->
GetEnd();
624 if (pContentIndexRestore)
629 std::vector<SwTextFrame*> frames;
633 frames.push_back(pFrame);
634 if (pFrame->getRootFrame()->HasMergedParas())
639 bool bNonMerged(
false);
640 bool bRecreateThis(
false);
648 if (pFrame->GetMergedPara())
655 pFrame->RegisterToNode(*pNode);
656 if (pFrame->GetText().isEmpty())
663 if (!pFrame->GetMergedPara() ||
664 !pFrame->GetMergedPara()->listener.IsListeningTo(
this))
669 bRecreateThis =
true;
677 assert(!(bNonMerged && bRecreateThis));
678 if (!frames.empty() && bNonMerged)
684 else if (bRecreateThis)
691 if (pContentIndexRestore)
723 switch (eOldMergeFlag)
766 OSL_ENSURE(
m_pSwpHints,
"MoveTextAttr_To_AttrSet without SwpHints?" );
774 const sal_Int32* pHtEndIdx = pHt->
GetEnd();
800 std::vector<SwTextFrame*> frames;
804 if (pFrame->getRootFrame()->HasMergedParas())
806 frames.push_back(pFrame);
810 auto frames2(frames);
814 if (pFrame->getRootFrame()->HasMergedParas())
816 auto const it(std::find(frames2.begin(), frames2.end(), pFrame));
817 assert(it != frames2.end());
825 pFrame->RegisterToNode(rNode,
true);
851 assert(!pNode->IsStartNode());
852 if (pNode->IsEndNode())
854 i = pNode->StartOfSectionIndex();
856 else if (pNode->IsTextNode())
863 std::vector<SwTextFrame*> frames;
867 if (pFrame->getRootFrame()->HasMergedParas())
869 frames.push_back(pFrame);
875 SwTextNode & rFirstNode(pFrame->GetMergedPara()
876 ? *pFrame->GetMergedPara()->pFirstNode
880 *pFrame, rFirstNode,
eMode));
881 assert(pFrame->GetMergedPara());
882 assert(pFrame->GetMergedPara()->listener.IsListeningTo(&rNode));
883 assert(rNode.
GetIndex() <= pFrame->GetMergedPara()->pLastNode->GetIndex());
892 if (
auto const pMergedPara = pFrame->GetMergedPara())
894 if (pMergedPara->pFirstNode == pMergedPara->pLastNode)
896 assert(pMergedPara->pFirstNode == &rNode);
901 else if (pFrame->getRootFrame()->HasMergedParas())
953 sal_Int32 nOldLen =
m_Text.getLength();
961 pList->JoinList( pTextNode->
GetWrong(), nOldLen );
970 pList->
Move( 0, nOldLen );
972 pTextNode->
SetWrong(
nullptr,
false );
1006 pList2->
Move( 0, nOldLen );
1016 if( !pContentStore->Empty())
1017 pContentStore->Restore( rDoc,
GetIndex(), nOldLen );
1044 OSL_FAIL(
"No TextNode." );
1060 const sal_Int32 nLen = pTextNode->
Len();
1067 pTextNode->
SetWrong(
nullptr,
false );
1075 pList->
Move( 0, nLen );
1113 pList2->
Move( 0, nLen );
1123 if( !pContentStore->Empty() )
1124 pContentStore->Restore( rDoc,
GetIndex() );
1148 OSL_FAIL(
"No TextNode." );
1155 OSL_ENSURE( !
mpAttrSet,
"AttrSet is set after all" );
1164 if ( pFormatColl != pAnyFormatColl )
1167 aNewAttrSet.
Put( aAnyFormatColl );
1168 aNewAttrSet.
Put( aFormatColl );
1177 const sal_Int32 nChangeLen,
1178 const bool bNegative,
1179 const bool bDelete )
1183 std::unique_ptr<SwpHts> pCollector;
1184 const sal_Int32 nChangePos = rPos.
GetIndex();
1190 std::vector<SwTextInputField*> aTextInputFields;
1192 const sal_Int32 nChangeEnd = nChangePos + nChangeLen;
1195 bool bTextAttrChanged =
false;
1196 bool bStartOfTextAttrChanged =
false;
1198 if ( pHint->
GetStart() > nChangePos )
1200 if ( pHint->
GetStart() > nChangeEnd )
1208 bStartOfTextAttrChanged =
true;
1211 const sal_Int32 *
const pEnd = pHint->
GetEnd();
1212 if (pEnd && *pEnd > nChangePos )
1214 if( *pEnd > nChangeEnd )
1216 pHint->
SetEnd(*pEnd - nChangeLen);
1220 pHint->
SetEnd(nChangePos);
1222 bTextAttrChanged = !bStartOfTextAttrChanged;
1225 if ( bTextAttrChanged
1229 if ( pTextInputField )
1230 aTextInputFields.push_back(pTextInputField);
1245 bool bNoExp =
false;
1246 bool bResort =
false;
1247 bool bMergePortionsNeeded =
false;
1249 std::vector<SwTextInputField*> aTextInputFields;
1251 bool aDontExp[ coArrSz ] = {};
1255 bool bTextAttrChanged =
false;
1257 const sal_Int32 *
const pEnd = pHint->
GetEnd();
1258 if ( pHint->
GetStart() >= nChangePos )
1263 pHint->
SetEnd(*pEnd + nChangeLen);
1266 else if ( pEnd && (*pEnd >= nChangePos) )
1270 pHint->
SetEnd(*pEnd + nChangeLen);
1271 bTextAttrChanged =
true;
1275 const sal_uInt16 nWhich = pHint->
Which();
1277 OSL_ENSURE(!
isCHRATR(nWhich),
"Update: char attr hint?");
1283 if( aDontExp[ nWhPos ] )
1293 bMergePortionsNeeded =
true;
1302 aDontExp[ nWhPos ] =
true;
1308 pCollector.reset(
new SwpHts );
1310 auto it = std::find_if(pCollector->begin(), pCollector->end(),
1311 [nWhich](
const SwTextAttr *pTmp) {
return nWhich == pTmp->Which(); });
1312 if (it != pCollector->end())
1315 pCollector->erase( it );
1320 pHint->
GetAttr(), nChangePos, nChangePos + nChangeLen);
1321 pCollector->push_back( pTmp );
1325 pHint->
SetEnd(*pEnd + nChangeLen);
1326 bTextAttrChanged =
true;
1331 if ( bTextAttrChanged
1335 if ( pTextInputField )
1336 aTextInputFields.push_back(pTextInputField);
1347 if (bMergePortionsNeeded)
1358 bool bSortMarks =
false;
1360 if ( !bNegative && !bDelete )
1365 if ( pRedl->HasMark() )
1369 *pRedl->GetPoint() != *pRedl->GetMark() )
1378 else if (
this == &pRedl->GetPoint()->nNode.GetNode() )
1380 SwIndex & rIdx = pRedl->GetPoint()->nContent;
1386 bool const isOneUsed(&pRedl->GetBound() == pRedl->GetPoint());
1387 assert(!pRedl->GetBound(!isOneUsed).nNode.GetNode().IsTextNode());
1388 assert(!pRedl->GetBound(!isOneUsed).nContent.GetIdxReg()); (
void)isOneUsed;
1396 bool bAtLeastOneBookmarkMoved =
false;
1397 bool bAtLeastOneExpandedBookmarkAtInsertionPosition =
false;
1408 if (!aSeenMarks.
insert(pMark).second)
1415 if (&rEndIdx == next)
1422 bAtLeastOneBookmarkMoved =
true;
1424 else if ( !bAtLeastOneExpandedBookmarkAtInsertionPosition )
1432 bAtLeastOneExpandedBookmarkAtInsertionPosition =
true;
1438 bSortMarks = bAtLeastOneBookmarkMoved && bAtLeastOneExpandedBookmarkAtInsertionPosition;
1442 #if OSL_DEBUG_LEVEL > 0
1443 std::vector<SwFrameFormat*> checkFormats;
1445 for (
auto& rpFormat : rFormats)
1449 if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR && pContentAnchor)
1459 checkFormats.push_back( rpFormat );
1465 for (
size_t i = 0; pFlys &&
i != pFlys->size(); ++
i)
1470 if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR && pContentAnchor)
1478 #if OSL_DEBUG_LEVEL > 0
1479 auto checkPos = std::find( checkFormats.begin(), checkFormats.end(), pFormat );
1480 assert( checkPos != checkFormats.end());
1481 checkFormats.erase( checkPos );
1486 #if OSL_DEBUG_LEVEL > 0
1487 assert( checkFormats.empty());
1493 if (pDocShell->GetWrtShell())
1497 auto pWrtShell =
dynamic_cast<SwWrtShell*
>(&rShell);
1498 if (!pWrtShell || pWrtShell == pDocShell->GetWrtShell())
1521 const size_t nCount = pCollector->size();
1522 for (
size_t i = 0;
i < nCount; ++
i )
1524 m_pSwpHints->TryInsertHint( (*pCollector)[
i ], *
this );
1528 aTmpIdxReg.
MoveTo( *
this );
1544 pEditShell->ValidateParagraphSignatures(
this,
true);
1562 if (nChangePos <= pRedln->
Start()->nContent.GetIndex())
1583 if (
MAXLEVEL != nNewLevel && -1 != nNewLevel )
1610 bool bFormatToTextAttributes )
1612 const sal_Int32 nIdx = rIdx.
GetIndex();
1613 if (bFormatToTextAttributes && nIdx ==
m_Text.getLength())
1623 for ( ; nPos >= 0; --nPos)
1626 const sal_Int32 *pEnd = pTmp->
GetEnd();
1646 return ((nHintStart <= nIndex) && (nIndex < nHintEnd));
1650 return ((nHintStart < nIndex) && (nIndex <= nHintEnd));
1654 return ((nHintStart < nIndex) && (nIndex < nHintEnd));
1659 std::vector<SwTextAttr *> *
const pVector,
1662 sal_Int32
const nIndex, sal_uInt16
const nWhich,
1668 size_t const nSize = pSwpHints->
Count();
1669 sal_Int32 nPreviousIndex(0);
1670 bool (*pMatchFunc)(sal_Int32, sal_Int32, sal_Int32)=
nullptr;
1682 if (pHint->
Which() != nWhich)
1685 sal_Int32
const nHintStart = pHint->
GetStart();
1686 if (nIndex < nHintStart)
1689 sal_Int32
const*
const pEndIdx = pHint->
GetEnd();
1694 bool const bContained( pEndIdx
1695 ? (*pMatchFunc)(nIndex, nHintStart, *pEndIdx)
1696 : (nHintStart == nIndex) );
1701 if (nPreviousIndex < nHintStart)
1704 nPreviousIndex = nHintStart;
1706 pVector->push_back(pHint);
1710 *ppTextAttr = pHint;
1720 std::vector<SwTextAttr *>
1724 std::vector<SwTextAttr *> ret;
1751 if ( pTextInputField ==
nullptr && rTextAttr.
End() != nullptr )
1756 return pTextInputField;
1775 const sal_Int32 nIndex,
1776 const bool bIncludeInputFieldAtStart )
const
1779 if ( pTextField ==
nullptr )
1783 if ( pTextField ==
nullptr )
1797 if( !rName.empty() )
1799 const size_t nArrLen = pCharFormats->
size();
1800 for(
size_t i = 1;
i < nArrLen;
i++ )
1803 if( pFormat->
GetName()==rName )
1811 const sal_uInt16 nWhich,
1814 SwDoc *
const pOtherDoc,
1823 static_cast<const SwTextFootnote*
>(pHt)->CopyFootnote( *static_cast<SwTextFootnote*>(pNewHt), *pDest);
1831 if( pOtherDoc !=
nullptr )
1834 static_txtattr_cast<SwTextField*>(pNewHt));
1858 if( pOtherDoc !=
nullptr )
1861 static_txtattr_cast<SwTextField*>(pNewHt));
1922 OSL_ENSURE( pNewHt,
"copying Meta should not fail!" );
1925 "missing CH_TXTATR?");
1935 const sal_Int32 nOldPos )
1940 &pDest->
GetDoc() :
nullptr;
1945 sal_Int32
const nAttrStartIdx = pHt->
GetStart();
1946 if ( nTextStartIdx < nAttrStartIdx )
1949 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
1952 sal_uInt16
const nWhich = pHt->
Which();
1954 && ( *pEndIdx > nTextStartIdx
1955 || (*pEndIdx == nTextStartIdx
1956 && nAttrStartIdx == nTextStartIdx)))
1970 ?
GetDoc().IsCopyIsMove()
1996 const sal_Int32 nLen,
1997 const bool bForceCopyOfAllAttrs )
2000 CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs );
2007 const bool bForceCopyOfAllAttrs )
2011 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2012 sal_Int32 nDestStart = rDestStart.
GetIndex();
2025 CopyAttr( pDest, nTextStartIdx, nDestStart );
2031 if ( !bForceCopyOfAllAttrs &&
2034 nLen != pDest->
GetText().getLength()))
2043 if( aCharSet.Count() )
2045 pDest->
SetAttr( aCharSet, nDestStart, nDestStart );
2057 const sal_Int32 oldLen = pDest->
m_Text.getLength();
2064 nLen = pDest->
m_Text.getLength() - oldLen;
2074 if ( !bForceCopyOfAllAttrs &&
2077 nLen != pDest->
GetText().getLength()))
2086 if( aCharSet.Count() )
2088 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2097 bool const bUndoNodes = !pOtherDoc
2103 const sal_Int32 nEnd = nTextStartIdx + nLen;
2117 std::vector<std::pair<sal_Int32, sal_Int32>> metaFieldRanges;
2118 sal_Int32 nDeletedDummyChars(0);
2119 for (
size_t n = 0;
n < nSize; ++
n)
2123 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2124 if ( nAttrStartIdx >= nEnd )
2127 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2128 const sal_uInt16 nWhich = pHt->
Which();
2152 assert(pEndIdx !=
nullptr &&
2153 "<SwTextNode::CopyText(..)> - RES_TXTATR_INPUTFIELD without EndIndex!" );
2154 if ( nAttrStartIdx < nTextStartIdx
2155 || ( pEndIdx !=
nullptr
2156 && *pEndIdx > nEnd ) )
2165 metaFieldRanges.emplace_back(nAttrStartIdx, pEndIdx ? *pEndIdx : nEnd);
2169 sal_Int32 nAttrStt = 0;
2170 sal_Int32 nAttrEnd = 0;
2172 if( nAttrStartIdx < nTextStartIdx )
2176 if ( pEndIdx && (*pEndIdx > nTextStartIdx) && !pHt->
HasDummyChar() )
2179 nAttrStt = nDestStart;
2180 nAttrEnd = (*pEndIdx > nEnd)
2182 : nDestStart + (*pEndIdx) - nTextStartIdx;
2192 nAttrStt = nDestStart + ( nAttrStartIdx - nTextStartIdx );
2195 nAttrEnd = *pEndIdx > nEnd
2197 : nDestStart + ( *pEndIdx - nTextStartIdx );
2201 nAttrEnd = nAttrStt;
2214 aArr.push_back( pNewHt );
2220 nAttrStt - nDeletedDummyChars,
2221 nAttrEnd - nDeletedDummyChars,
2232 ++nDeletedDummyChars;
2238 aRefMrkArr.push_back( pNewHt );
2244 if (!metaFieldRanges.empty())
2247 std::reverse(metaFieldRanges.begin(), metaFieldRanges.end());
2248 for (
const auto& pair : metaFieldRanges)
2250 const SwIndex aIdx(pDest, pair.first);
2251 pDest->
EraseText(aIdx, pair.second - pair.first);
2265 if( pNewHt->GetEnd() )
2272 const SwIndex aIdx( pDest, pNewHt->GetStart() );
2287 const sal_Int32 aPos = rIdx.
GetIndex();
2288 sal_Int32 nLen =
m_Text.getLength() - aPos;
2289 sal_Int32
const nOverflow(rStr.getLength() -
GetSpaceLeft());
2291 "SwTextNode::InsertText: node text with insertion > capacity.");
2292 OUString
const sInserted(
2293 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
2294 if (sInserted.isEmpty())
2300 nLen =
m_Text.getLength() - aPos - nLen;
2311 if (nMode & SwInsertFlags::FORCEHINTEXPAND)
2325 bool const bHadHints(!
m_pSwpHints->CanBeDeleted());
2326 bool bMergePortionsNeeded(
false);
2328 rIdx >=
m_pSwpHints->GetWithoutResorting(
i)->GetStart(); ++
i )
2331 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2335 if( rIdx == *pEndIdx )
2338 (!(nMode & SwInsertFlags::FORCEHINTEXPAND)
2345 pHt->
SetEnd(*pEndIdx - nLen);
2352 bMergePortionsNeeded =
true;
2386 if (bMergePortionsNeeded)
2390 SAL_WARN_IF(bHadHints &&
m_pSwpHints->CanBeDeleted(),
"sw.core",
2391 "SwTextNode::InsertText: unexpected loss of hints");
2403 const SwIndex & rStart,
const sal_Int32 nLen )
2407 CutImpl( pDest, aDestStt, rStart, nLen,
false );
2411 const SwIndex & rStart, sal_Int32 nLen,
const bool bUpdate )
2426 sal_Int32 nTextStartIdx = rStart.
GetIndex();
2427 sal_Int32 nDestStart = rDestStart.
GetIndex();
2428 const sal_Int32 nInitSize = pDest->
m_Text.getLength();
2436 m_Text.copy(nTextStartIdx, nLen));
2437 OUString
const newText =
m_Text.replaceAt(nTextStartIdx, nLen,
"");
2438 nLen = pDest->
m_Text.getLength() - nInitSize;
2445 pDest->
Update( rDestStart, nLen,
false,
false);
2450 const sal_Int32 nEnd = rStart.
GetIndex() + nLen;
2451 bool const bUndoNodes =
2462 hasSwAttrSet =
false;
2485 hasSwAttrSet = (rParentItem != *pItem);
2493 pItem = aIter.NextItem();
2499 if( nInitSize || hasSwAttrSet ||
2500 nLen != pDest->
GetText().getLength())
2509 if( aCharSet.Count() )
2510 pDest->
SetAttr( aCharSet, nDestStart, nDestStart + nLen );
2522 const sw::MoveText aMoveHint(pDest, nDestStart, nTextStartIdx, nLen);
2524 const SwDelText aDelHint(nTextStartIdx, nLen);
2530 bool bMergePortionsNeeded(
false);
2531 size_t nAttrCnt = 0;
2535 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
2536 if ( nAttrStartIdx >= nEnd )
2538 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2539 const sal_uInt16 nWhich = pHt->
Which();
2543 if(nAttrStartIdx < nTextStartIdx)
2547 || bUndoNodes ) && pEndIdx && *pEndIdx > nTextStartIdx)
2555 : *pEndIdx - nTextStartIdx ) );
2561 if (!pEndIdx || *pEndIdx < nEnd ||
2575 bMergePortionsNeeded =
true;
2577 pHt->
SetStart(nDestStart + (nAttrStartIdx - nTextStartIdx));
2580 pHt->
SetEnd( nDestStart + (
2583 : *pEndIdx - nTextStartIdx ) );
2588 if (
GetDoc().GetDocShell())
2598 nDestStart + (nAttrStartIdx - nTextStartIdx),
2599 nDestStart + (*pEndIdx > nEnd
2601 : *pEndIdx - nTextStartIdx));
2606 const bool bSuccess( pDest->
InsertHint( pNewHt,
2624 while (nAttrCnt < m_pSwpHints->
Count())
2629 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2630 if (pEndIdx && *pEndIdx == nEnd)
2632 aArr.push_back( pHt );
2640 Update( rStart, nLen,
true,
true );
2644 pHt->SetStart( rStart.
GetIndex() );
2651 Update( rStart, nLen,
true,
true );
2657 if (bMergePortionsNeeded)
2672 const sal_Int32 nStartIdx = rIdx.
GetIndex();
2674 ?
m_Text.getLength() - nStartIdx : nCount;
2675 const sal_Int32 nEndIdx = nStartIdx + nCnt;
2676 if (nEndIdx <=
m_Text.getLength())
2686 const sal_Int32 nHintStart = pHt->
GetStart();
2688 if ( nHintStart < nStartIdx )
2691 if ( nHintStart > nEndIdx )
2694 const sal_Int32* pHtEndIdx = pHt->
GetEnd();
2695 const sal_uInt16 nWhich = pHt->
Which();
2701 if (
isTXTATR(nWhich) && (nHintStart < nEndIdx))
2710 assert(!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx)
2713 || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)));
2723 if ( (*pHtEndIdx < nEndIdx)
2724 || ( (*pHtEndIdx == nEndIdx) &&
2730 || ( (nHintStart < nEndIdx) &&
2740 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2744 Update( rIdx, nCnt,
true );
2757 OSL_ENSURE(rIdx.
GetIndex() == nStartIdx,
"huh? start index has changed?");
2771 bool bChanged =
false;
2772 sal_Int32 nMin =
m_Text.getLength();
2774 const bool bAll = nMin != 0;
2781 const sal_Int32 *
const pEndIdx = pHt->
GetEnd();
2786 nMin = std::min( nMin, pHt->
GetStart() );
2787 nMax = std::max( nMax, *pHt->
GetEnd() );
2817 bool bNoNumRule =
false;
2820 OUString sNumRuleName =
2822 if (!sNumRuleName.isEmpty())
2832 if ( pRet && pRet ==
GetDoc().GetOutlineNumRule() &&
2834 SfxItemState::SET !=
2841 if ( rDirectItem.
GetValue().isEmpty() )
2888 bool bResult =
false;
2904 std::unique_ptr<SwAttrSet> pNewAttrSet;
2906 bool bClearHardSetNumRuleWhenFormatCollChanges(
false );
2913 pTmpSet = pNewAttrSet.get();
2916 bool bRemoveFromCache =
false;
2917 std::vector<sal_uInt16> aClearWhichIds;
2919 bRemoveFromCache = ( 0 != pNewAttrSet->ClearItem(
RES_PAGEDESC ) );
2929 bRemoveFromCache =
true;
2934 pNewAttrSet->ClearItem(
RES_KEEP );
2936 aClearWhichIds.push_back(
RES_KEEP );
2937 bRemoveFromCache =
true;
2945 bRemoveFromCache =
true;
2960 bClearHardSetNumRuleWhenFormatCollChanges =
true;
2962 bRemoveFromCache =
true;
2966 if ( !aClearWhichIds.empty() )
2969 if( !bNext && bRemoveFromCache )
2980 pNewAttrSet.reset();
2999 if( bNext || !bChgFollow )
3005 if (pNextColl != pColl)
3008 if ( bClearHardSetNumRuleWhenFormatCollChanges )
3010 std::vector<sal_uInt16> aClearWhichIds;
3050 const sal_Int32 nIndex,
3051 const sal_uInt16 nWhich )
const
3059 const sal_Int32 nStartPos = pHint->
GetStart();
3060 if ( nIndex < nStartPos )
3077 sal_uInt16 lcl_BoundListLevel(
const int nActualLevel)
3079 return static_cast<sal_uInt16
>( std::clamp( nActualLevel, 0,
MAXLEVEL-1 ) );
3087 bool bResult =
false;
3104 bool bResult =
false;
3121 const unsigned int _nRestrictToThisLevel,
3135 if (rNumberType.IsTextFormat() ||
3137 (style::NumberingType::NUMBER_NONE == rNumberType.GetNumberingType()))
3140 _bInclPrefixAndSuffixStrings,
3142 _nRestrictToThisLevel,
3239 SwTwips nAdditionalIndent = 0;
3251 nAdditionalIndent = nAdditionalIndent -
3266 nAdditionalIndent = nAdditionalIndent -
3277 return nAdditionalIndent;
3291 o_rLRSpaceItem = std::make_shared<SvxLRSpaceItem>(
RES_LR_SPACE);
3302 bool bLeftMarginForTabCalcSetToListLevelIndent(
false );
3312 bLeftMarginForTabCalcSetToListLevelIndent =
true;
3316 if ( !bLeftMarginForTabCalcSetToListLevelIndent )
3321 return nLeftMarginForTabCalc;
3326 OUStringBuffer & rText,
3327 sal_Int32 & rTextStt,
3334 for(
int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, cSrchChr =
CH_TXTATR_INWORD )
3336 sal_Int32
nPos = rText.indexOf(cSrchChr);
3337 while (-1 != nPos && nPos < nEndPos)
3343 switch( pAttr->
Which() )
3347 rText.remove(nPos, 1);
3352 rText.remove(nPos, 1);
3357 rText.remove(nPos, 1);
3366 nPos = rText.indexOf(cSrchChr, nPos);
3374 const sal_Int32 nIdx,
3375 const sal_Int32 nLen,
3376 const bool bWithNum,
3377 const bool bAddSpaceAfterListLabelStr,
3378 const bool bWithSpacesForLevel,
3389 const OUString aExpandText = aConversionMap.
getViewText();
3391 sal_Int32 nEnd = nLen == -1 ?
GetText().getLength() : nIdx + nLen;
3393 OUStringBuffer aText(aExpandText.subView(nExpandBegin, nExpandEnd-nExpandBegin));
3403 if ( bAddSpaceAfterListLabelStr )
3406 aText.insert(0, aSpace);
3412 if (bWithSpacesForLevel)
3417 aText.insert(0, aSpace);
3418 aText.insert(0, aSpace);
3422 return aText.makeStringAndClear();
3426 sal_Int32 nIdx, sal_Int32 nLen,
3428 bool bWithFootnote,
bool bReplaceTabsWithSpaces )
const
3430 if( &rDestNd ==
this )
3435 aDestIdx = *pDestIdx;
3436 const sal_Int32 nDestStt = aDestIdx.
GetIndex();
3439 OUStringBuffer buf(
GetText());
3440 if( bReplaceTabsWithSpaces )
3441 buf.replace(
'\t',
' ');
3447 buf.remove(0, nIdx);
3457 rDestNd.
InsertText(buf.makeStringAndClear(), aDestIdx);
3458 nLen = aDestIdx.GetIndex() - nDestStt;
3463 sal_Int32 nInsPos = nDestStt - nIdx;
3467 const sal_Int32 nAttrStartIdx = pHt->
GetStart();
3468 const sal_uInt16 nWhich = pHt->
Which();
3469 if (nIdx + nLen <= nAttrStartIdx)
3472 const sal_Int32 *pEndIdx = pHt->
End();
3473 if( pEndIdx && *pEndIdx > nIdx &&
3480 if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->
GetCharSet() )
3483 rDestNd.
InsertItem( *const_cast<SvxFontItem*>(pFont),
3484 nInsPos + nAttrStartIdx, nInsPos + *pEndIdx );
3487 else if ( pHt->
HasDummyChar() && (nAttrStartIdx >= nIdx) )
3489 aDestIdx = nInsPos + nAttrStartIdx;
3495 OUString
const aExpand(
3496 static_txtattr_cast<SwTextField const*>(pHt)->GetFormatField().GetField()->ExpandField(
true, pLayout));
3497 if (!aExpand.isEmpty())
3502 SAL_INFO_IF(ins.getLength() != aExpand.getLength(),
3503 "sw.core",
"GetExpandText lossage");
3504 aDestIdx = nInsPos + nAttrStartIdx;
3505 nInsPos += ins.getLength();
3514 if ( bWithFootnote )
3529 if( !sExpand.isEmpty() )
3535 aDestIdx.GetIndex(),
3536 aDestIdx.GetIndex() );
3538 SAL_INFO_IF(ins.getLength() != sExpand.getLength(),
3539 "sw.core",
"GetExpandText lossage");
3540 aDestIdx = nInsPos + nAttrStartIdx;
3541 nInsPos += ins.getLength();
3559 aDestIdx = nDestStt;
3564 sal_Int32 nStartDelete(-1);
3565 while (aDestIdx < rDestNd.
GetText().getLength())
3574 if (-1 == nStartDelete)
3576 nStartDelete = aDestIdx.GetIndex();
3579 if (aDestIdx < rDestNd.
GetText().getLength())
3586 if (-1 == nStartDelete)
3592 assert(-1 != nStartDelete);
3594 SwIndex(&rDestNd, nStartDelete),
3595 aDestIdx.GetIndex() - nStartDelete);
3596 assert(aDestIdx.GetIndex() == nStartDelete);
3605 std::vector<sal_Int32> aRedlArr;
3615 if( RedlineType::Delete == pTmp->
GetType() )
3618 if( pRStt->
nNode < nNdIdx )
3620 if( pREnd->nNode > nNdIdx )
3623 else if( pREnd->nNode == nNdIdx )
3626 aRedlArr.push_back( 0 );
3627 aRedlArr.push_back( pREnd->nContent.GetIndex() );
3630 else if( pRStt->
nNode == nNdIdx )
3634 if( pREnd->nNode == nNdIdx )
3635 aRedlArr.push_back( pREnd->nContent.GetIndex() );
3648 OUStringBuffer aText(
GetText());
3650 sal_Int32 nTextStt = 0;
3651 sal_Int32 nIdxEnd = aText.getLength();
3652 for(
size_t n = 0;
n < aRedlArr.size();
n += 2 )
3654 sal_Int32 nStt = aRedlArr[
n ];
3655 sal_Int32 nEnd = aRedlArr[
n+1 ];
3656 if( ( 0 <= nStt && nStt <= nIdxEnd ) ||
3657 ( 0 <= nEnd && nEnd <= nIdxEnd ))
3659 if( nStt < 0 ) nStt = 0;
3660 if( nIdxEnd < nEnd ) nEnd = nIdxEnd;
3661 const sal_Int32 nDelCnt = nEnd - nStt;
3662 aText.remove(nStt - nTextStt, nDelCnt);
3663 Replace0xFF(*
this, aText, nTextStt, nStt - nTextStt);
3664 nTextStt += nDelCnt;
3666 else if( nStt >= nIdxEnd )
3669 Replace0xFF(*
this, aText, nTextStt, aText.getLength());
3671 return aText.makeStringAndClear();
3675 const OUString & rStr)
3680 sal_Int32
const nOverflow(rStr.getLength() - nDelLen -
GetSpaceLeft());
3682 "SwTextNode::ReplaceText: node text with insertion > node capacity.");
3683 OUString
const sInserted(
3684 (nOverflow > 0) ? rStr.copy(0, rStr.getLength() - nOverflow) : rStr);
3685 if (sInserted.isEmpty() && 0 == nDelLen)
3690 const sal_Int32 nStartPos = rStart.
GetIndex();
3691 sal_Int32 nEndPos = nStartPos + nDelLen;
3692 sal_Int32 nLen = nDelLen;
3693 for( sal_Int32
nPos = nStartPos;
nPos < nEndPos; ++
nPos )
3703 && (*pHint->
GetEnd() > nEndPos) ));
3715 if (nLen && sInserted.getLength())
3719 m_Text =
m_Text.replaceAt(nStartPos, 1, sInserted.copy(0, 1));
3721 ++
const_cast<SwIndex&
>(rStart);
3723 Update( rStart, nLen - 1,
true );
3725 OUString aTmpText( sInserted.copy(1) );
3727 Update( rStart, aTmpText.getLength() );
3732 Update( rStart, nLen,
true );
3735 Update( rStart, sInserted.getLength() );
3739 SwDelText aDelHint( nStartPos, nDelLen );
3742 if (sInserted.getLength())
3744 SwInsText aHint( nStartPos, sInserted.getLength() );
3750 void lcl_ResetParAttrs(
SwTextNode &rTextNode )
3756 SwPaM aPam( rTextNode );
3771 void HandleModifyAtTextNode(
SwTextNode& rTextNode,
3775 const sal_uInt16 nWhich = pOldValue ? pOldValue->
Which() :
3776 pNewValue ? pNewValue->
Which() : 0 ;
3777 bool bNumRuleSet =
false;
3778 bool bParagraphStyleChanged =
false;
3780 OUString sOldNumRule;
3785 bParagraphStyleChanged =
true;
3788 const SwNumRule* pFormerNumRuleAtTextNode =
3790 if ( pFormerNumRuleAtTextNode )
3792 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3797 if ( !rNumRuleItem.
GetValue().isEmpty() )
3803 if ( pNumRuleAtTextNode )
3806 sNumRule = pNumRuleAtTextNode->
GetName();
3814 const SwNumRule* pFormerNumRuleAtTextNode =
3816 if ( pFormerNumRuleAtTextNode )
3818 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3832 if ( pNumRuleAtTextNode )
3834 sNumRule = pNumRuleAtTextNode->
GetName();
3842 const SwNumRule* pFormerNumRuleAtTextNode =
3844 if ( pFormerNumRuleAtTextNode )
3846 sOldNumRule = pFormerNumRuleAtTextNode->
GetName();
3858 if ( pNumRuleAtTextNode )
3860 sNumRule = pNumRuleAtTextNode->
GetName();
3866 if ( sNumRule != sOldNumRule )
3870 if (sNumRule.isEmpty())
3873 if ( bParagraphStyleChanged )
3875 lcl_ResetParAttrs(rTextNode);
3887 "<HandleModifyAtTextNode()> - text node with outline style, but its paragraph style is not assigned to outline style." );
3888 const int nNewListLevel =
3890 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
3901 if ( bParagraphStyleChanged )
3903 lcl_ResetParAttrs(rTextNode);
3912 else if (!sNumRule.isEmpty() && !rTextNode.
IsInList())
3922 OSL_ENSURE( pNewColl,
"ChgFormatColl: Collectionpointer has value 0." );
3923 OSL_ENSURE( dynamic_cast<const SwTextFormatColl *>(pNewColl) !=
nullptr,
3924 "ChgFormatColl: is not a Text Collection pointer." );
3927 if( pNewColl != pOldColl )
3932 "DEBUG OSL_ENSURE(ON - <SwTextNode::ChgFormatColl(..)> called during <Set/ResetAttr(..)>" );
3937 HandleModifyAtTextNode( *
this, &aTmp1, &aTmp2 );
3982 return pNum->GetNumberVector();
3993 bool bResult =
false;
4029 if ( 0 <= nLevel && nLevel <=
MAXLEVEL )
4032 static_cast<sal_uInt16>(nLevel) ) );
4039 auto it = aGrabBagItem.
GetGrabBag().find(
"OutlineContentVisibleAttr");
4042 it->second >>= bOutlineContentVisibleAttr;
4051 aGrabBagItem.
GetGrabBag()[
"OutlineContentVisibleAttr"] <<= bVisible;
4077 if ( nLevel < 0 || nLevel >=
MAXLEVEL )
4084 static_cast<sal_Int16>(nLevel) );
4096 int nAttrListLevel = 0;
4100 nAttrListLevel =
static_cast<int>(aListLevelItem.
GetValue());
4102 return nAttrListLevel;
4172 static_cast<sal_Int16>(nNumber) );
4173 SetAttr( aNewListRestartValueItem );
4185 "<SwTextNode::GetAttrListRestartValue()> - only ask for list restart value, if attribute is set at text node." );
4209 nListRestartValue = pFormat->
GetStart();
4214 return nListRestartValue;
4239 SetAttr( aIsCountedInListItem );
4248 return aIsCountedInListItem.
GetValue();
4253 const OUString sListId = pNode->
GetListId();
4254 if (!sListId.isEmpty())
4257 SwList* pList = rIDLA.getListByName( sListId );
4258 if ( pList ==
nullptr )
4267 OSL_ENSURE( pList !=
nullptr,
4268 "<SwTextNode::AddToList()> - no list for given list id. Serious defect" );
4278 OSL_FAIL(
"<SwTextNode::AddToList()> - the text node is already added to a list. Serious defect" );
4283 if (!(pList &&
GetNodes().IsDocNodes()))
4293 if (pFrame->getRootFrame()->IsHideRedlines())
4295 if (pFrame->GetTextNodeForParaProps() ==
this)
4309 OSL_FAIL(
"<SwTextNode::AddToListRLHidden()> - the text node is already added to a list. Serious defect" );
4354 bool bResult =
false;
4367 if (rListIdItem.
GetValue() != rListId)
4369 if (rListId.isEmpty())
4385 const OUString& sListId {rListIdItem.
GetValue()};
4389 if (sListId.isEmpty())
4417 bool bAreListLevelIndentsApplicable(
true );
4422 bAreListLevelIndentsApplicable =
false;
4428 bAreListLevelIndentsApplicable =
false;
4435 bAreListLevelIndentsApplicable =
true;
4449 bAreListLevelIndentsApplicable =
false;
4457 bAreListLevelIndentsApplicable =
true;
4463 "<SwTextNode::AreListLevelIndentsApplicable()> - something wrong in paragraph's style hierarchy. The applied list style is not found." );
4467 return bAreListLevelIndentsApplicable;
4480 bool bListTabStopPositionProvided(
false);
4489 bListTabStopPositionProvided =
true;
4509 return bListTabStopPositionProvided;
4544 OSL_FAIL(
"<SwTextNode::GetLabelFollowedBy()> - unknown SvxNumberFormat::GetLabelFollowedBy() return value" );
4555 sal_Int32 nStartPos;
4599 class HandleSetAttrAtTextNode
4602 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4604 HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4606 ~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
4610 bool mbAddTextNodeToList;
4611 bool mbUpdateListLevel;
4612 bool mbUpdateListRestart;
4613 bool mbUpdateListCount;
4615 bool mbOutlineLevelSet;
4618 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4620 : mrTextNode( rTextNode ),
4621 mbAddTextNodeToList( false ),
4622 mbUpdateListLevel( false ),
4623 mbUpdateListRestart( false ),
4624 mbUpdateListCount( false ),
4626 mbOutlineLevelSet( false )
4628 switch ( pItem.
Which() )
4633 mrTextNode.RemoveFromList();
4637 if ( !rNumRuleItem.
GetValue().isEmpty() )
4639 mbAddTextNodeToList =
true;
4642 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4652 OSL_ENSURE( rListIdItem.
GetValue().getLength() > 0,
4653 "<HandleSetAttrAtTextNode(..)> - empty list id attribute not expected. Serious defect." );
4654 const OUString sListIdOfTextNode = rTextNode.GetListId();
4655 if ( rListIdItem.
GetValue() != sListIdOfTextNode )
4657 mbAddTextNodeToList =
true;
4658 if ( mrTextNode.IsInList() )
4660 mrTextNode.RemoveFromList();
4671 if ( aListLevelItem.
GetValue() != mrTextNode.GetAttrListLevel() )
4673 mbUpdateListLevel =
true;
4683 if ( aListIsRestartItem.
GetValue() !=
4684 mrTextNode.IsListRestart() )
4686 mbUpdateListRestart =
true;
4696 if ( !mrTextNode.HasAttrListRestartValue() ||
4697 aListRestartValueItem.
GetValue() != mrTextNode.GetAttrListRestartValue() )
4699 mbUpdateListRestart =
true;
4709 if ( aIsCountedInListItem.
GetValue() !=
4710 mrTextNode.IsCountedInList() )
4712 mbUpdateListCount =
true;
4723 if ( aOutlineLevelItem.
GetValue() != mrTextNode.GetAttrOutlineLevel() )
4725 mbOutlineLevelSet =
true;
4733 HandleSetAttrAtTextNode::HandleSetAttrAtTextNode(
SwTextNode& rTextNode,
4735 : mrTextNode( rTextNode ),
4736 mbAddTextNodeToList( false ),
4737 mbUpdateListLevel( false ),
4738 mbUpdateListRestart( false ),
4739 mbUpdateListCount( false ),
4741 mbOutlineLevelSet( false )
4747 mrTextNode.RemoveFromList();
4752 if ( !pNumRuleItem->
GetValue().isEmpty() )
4754 mbAddTextNodeToList =
true;
4756 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4765 const OUString sListIdOfTextNode = mrTextNode.GetListId();
4767 pListIdItem->
GetValue() != sListIdOfTextNode )
4769 mbAddTextNodeToList =
true;
4770 if ( mrTextNode.IsInList() )
4772 mrTextNode.RemoveFromList();
4782 if (pListLevelItem && pListLevelItem->
GetValue() != mrTextNode.GetAttrListLevel())
4784 mbUpdateListLevel =
true;
4793 if (pListIsRestartItem && pListIsRestartItem->
GetValue() != mrTextNode.IsListRestart())
4795 mbUpdateListRestart =
true;
4804 if ( !mrTextNode.HasAttrListRestartValue() || (pListRestartValueItem &&
4805 pListRestartValueItem->
GetValue() != mrTextNode.GetAttrListRestartValue()) )
4807 mbUpdateListRestart =
true;
4816 if (pIsCountedInListItem && pIsCountedInListItem->
GetValue() !=
4817 mrTextNode.IsCountedInList())
4819 mbUpdateListCount =
true;
4829 if (pOutlineLevelItem && pOutlineLevelItem->
GetValue() !=
4830 mrTextNode.GetAttrOutlineLevel())
4832 mbOutlineLevelSet =
true;
4837 HandleSetAttrAtTextNode::~HandleSetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
4839 if ( mbAddTextNodeToList )
4841 SwNumRule* pNumRuleAtTextNode = mrTextNode.GetNumRule();
4842 if ( pNumRuleAtTextNode )
4844 mrTextNode.AddToList();
4849 if ( mbUpdateListLevel && mrTextNode.IsInList() )
4851 auto const nLevel(mrTextNode.GetAttrListLevel());
4856 if ( mbUpdateListRestart && mrTextNode.IsInList() )
4875 if (!mbOutlineLevelSet)
4878 mrTextNode.GetNodes().UpdateOutlineNode(mrTextNode);
4879 if (mrTextNode.GetAttrOutlineLevel() == 0)
4881 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
4888 != SfxItemState::SET )
4890 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
4902 HandleSetAttrAtTextNode aHandleSetAttr( *
this, pItem );
4916 HandleSetAttrAtTextNode aHandleSetAttr( *
this, rSet );
4942 class HandleResetAttrAtTextNode
4945 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
4946 const sal_uInt16 nWhich1,
4947 sal_uInt16 nWhich2 );
4948 HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
4949 const std::vector<sal_uInt16>& rWhichArr );
4950 explicit HandleResetAttrAtTextNode(
SwTextNode& rTextNode );
4952 ~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE;
4956 bool mbListStyleOrIdReset;
4957 bool mbUpdateListLevel;
4958 bool mbUpdateListRestart;
4959 bool mbUpdateListCount;
4961 void init( const
std::vector<sal_uInt16>& rWhichArr );
4964 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
4965 const sal_uInt16 nWhich1,
4966 sal_uInt16 nWhich2 )
4967 : mrTextNode( rTextNode ),
4968 mbListStyleOrIdReset( false ),
4969 mbUpdateListLevel( false ),
4970 mbUpdateListRestart( false ),
4971 mbUpdateListCount( false )
4973 if ( nWhich2 < nWhich1 )
4975 std::vector<sal_uInt16> rWhichArr;
4976 for ( sal_uInt16 nWhich = nWhich1; nWhich <= nWhich2; ++nWhich )
4977 rWhichArr.push_back( nWhich );
4982 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode,
4983 const std::vector<sal_uInt16>& rWhichArr )
4984 : mrTextNode( rTextNode ),
4985 mbListStyleOrIdReset( false ),
4986 mbUpdateListLevel( false ),
4987 mbUpdateListRestart( false ),
4988 mbUpdateListCount( false )
4993 HandleResetAttrAtTextNode::HandleResetAttrAtTextNode(
SwTextNode& rTextNode )
4994 : mrTextNode( rTextNode ),
4995 mbListStyleOrIdReset( true ),
4996 mbUpdateListLevel( false ),
4997 mbUpdateListRestart( false ),
4998 mbUpdateListCount( false )
5005 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5008 void HandleResetAttrAtTextNode::init(
const std::vector<sal_uInt16>& rWhichArr )
5010 bool bRemoveFromList(
false );
5012 for (
const auto& rWhich : rWhichArr)
5016 bRemoveFromList = bRemoveFromList ||
5017 mrTextNode.GetNumRule() !=
nullptr;
5018 mbListStyleOrIdReset =
true;
5022 bRemoveFromList = bRemoveFromList ||
5023 ( mrTextNode.GetpSwAttrSet() &&
5024 mrTextNode.GetpSwAttrSet()->GetItemState(
RES_PARATR_LIST_ID,
false ) == SfxItemState::SET );
5025 mbListStyleOrIdReset =
true;
5028 mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
5030 mrTextNode.ResetAttr( XATTR_FILL_FIRST, XATTR_FILL_LAST );
5032 if ( !bRemoveFromList )
5035 mbUpdateListLevel = mbUpdateListLevel ||
5037 mrTextNode.HasAttrListLevel() );
5040 mbUpdateListRestart = mbUpdateListRestart ||
5042 mrTextNode.IsListRestart() ) ||
5044 mrTextNode.HasAttrListRestartValue() );
5047 mbUpdateListCount = mbUpdateListCount ||
5049 !mrTextNode.IsCountedInList() );
5054 if ( bRemoveFromList && mrTextNode.IsInList() )
5056 mrTextNode.RemoveFromList();
5060 HandleResetAttrAtTextNode::~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
5062 if ( mbListStyleOrIdReset && !mrTextNode.IsInList() )
5066 if (mrTextNode.GetNumRule() && !mrTextNode.GetListId().isEmpty())
5071 if ( !mrTextNode.HasAttrListLevel() &&
5073 mrTextNode.GetTextColl()->IsAssignedToListLevelOfOutlineStyle() )
5075 int nNewListLevel = mrTextNode.GetTextColl()->GetAssignedOutlineStyleLevel();
5076 if ( 0 <= nNewListLevel && nNewListLevel <
MAXLEVEL )
5078 mrTextNode.SetAttrListLevel( nNewListLevel );
5081 mrTextNode.AddToList();
5087 assert(!mrTextNode.GetpSwAttrSet()
5090 if (mrTextNode.GetpSwAttrSet()
5094 mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
5099 if ( !mrTextNode.IsInList() )
5102 if ( mbUpdateListLevel )
5104 auto const nLevel(mrTextNode.GetAttrListLevel());
5109 if ( mbUpdateListRestart )
5118 if ( mbUpdateListCount )
5132 HandleResetAttrAtTextNode aHandleResetAttr( *
this, nWhich1, nWhich2 );
5146 HandleResetAttrAtTextNode aHandleResetAttr( *
this, rWhichArr );
5160 HandleResetAttrAtTextNode aHandleResetAttr( *
this );
5171 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextNode"));
5172 xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
5173 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"), BAD_CAST(OString::number(
GetIndex()).getStr()));
5176 for (
int i = 0;
i < 32; ++
i)
5177 sText = sText.replace(
i,
'*');
5178 xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_Text"));
5179 xmlTextWriterWriteString(pWriter, BAD_CAST(sText.toUtf8().getStr()));
5180 xmlTextWriterEndElement(pWriter);
5184 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFormatColl"));
5185 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"name"), BAD_CAST(
GetFormatColl()->GetName().toUtf8().getStr()));
5186 xmlTextWriterEndElement(pWriter);
5191 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwAttrSet"));
5193 xmlTextWriterEndElement(pWriter);
5198 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwpHints"));
5200 for (
size_t i = 0;
i < rHints.
Count(); ++
i)
5202 xmlTextWriterEndElement(pWriter);
5208 xmlTextWriterEndElement(pWriter);
5218 return pRsid->GetValue();
5234 return nThisRsid == nRsid;
5239 sal_uInt32 nThisRsid =
GetRsid( nStt1, nStt1 );
5240 sal_uInt32 nRsid = rTextNode.
GetRsid( nStt2, nStt2 );
5242 return nThisRsid == nRsid;
5268 const auto pOldValue = rHint.
m_pOld;
5269 const auto pNewValue = rHint.
m_pNew;
5282 assert(dynamic_cast<SwTextFormatColl const*>(static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat));
5283 assert(dynamic_cast<SwTextFormatColl const*>(static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat));
5285 static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat),
5286 static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat) );
5292 const sal_uInt16 nWhich = pNewValue->
Which();
5297 SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pNewValue)->GetChgSet());
5313 HandleModifyAtTextNode( *
this, pOldValue, pNewValue );
5329 SetXParagraph(css::uno::Reference<css::text::XTextContent>(
nullptr));
5335 if (
auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
5339 else if (dynamic_cast<const SwAttrHint*>(&rHint))
5346 uno::Reference< rdf::XMetadatable >
5349 const uno::Reference<rdf::XMetadatable> xMeta(
static void RemoveListItem(SwNodeNum &rNodeNum)
void SetWordCountDirty(bool bNew) const
const SwAttrSet * GetChgSet() const
What has changed.
void CheckResetRedlineMergeFlag(SwTextNode &rNode, Recreate eRecreateMerged)
if first node is First, its frames may need to be moved, never deleted.
SwSectionNode * FindSectionNode()
Search section node, in which it is.
SvxNumType GetNumberingType() const
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
virtual std::shared_ptr< SfxItemSet > getAutomaticStyle(const SfxItemSet &rSet, SwAutoStyleFamily eFamily, const OUString *pParentName=nullptr)=0
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
const SvxLRSpaceItem & GetLRSpace(bool=true) const
void SetListRestart(bool bRestart)
sal_uLong GetIndex() const
bool IsFormatIgnoreEnd() const
int GetAssignedOutlineStyleLevel() const
void SetDontExpand(bool bDontExpand)
SwCharFormat * GetCharFormat()
const SwSortedObjs * GetDrawObjs() const
bool HasBullet() const
Returns if this text node has a bullet.
Represents the style of a paragraph.
Marks a position in the document model.
void dumpAsXml(xmlTextWriterPtr pWriter) const
void MoveDeletedPrevFrames(const SwTextNode &rDeletedPrev, SwTextNode &rNode)
if first node is deleted & second survives, then the first node's frame will be deleted too; prevent this...
bool IsSectionNode() const
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr) const
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
OUString GetLabelFollowedBy() const
Retrieves the character following the list label, if the paragraph's list level defines one...
The inserted item is a copy – intended for use in ndtxt.cxx.
bool isCHRATR(const sal_uInt16 nWhich)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
const OUString & GetText() const
bool IsOutline() const
Returns if this text node is an outline.
virtual sal_uInt16 ResetAllAttr() override
SwDocShell * GetDocShell()
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
SwpHints * GetpSwpHints()
bool isTXTATR_WITHEND(const sal_uInt16 nWhich)
bool isTXTATR(const sal_uInt16 nWhich)
static void lcl_ChangeFootnoteRef(SwTextNode &rNode)
void Move(sal_Int32 nPos, sal_Int32 nDiff)
Change all values after the given position.
sal_uInt16 const aTextNodeSetRange[]
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
for hanging TextFormatCollections somewhere else (Outline-Numbering!)
const SwNumFormat * GetNumFormat(sal_uInt16 i) const
void DelFrames_TextNodePart()
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
SwDoc & GetDoc()
Which Doc contains the nodes-array?
sal_Int32 GetSpaceLeft() const
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
bool GetFirstLineOfsWithNum(short &rFirstOffset) const
Returns the combined first line indent of this text node and its numbering.
virtual const sal_Int32 * GetEnd() const
end position
virtual sal_Int32 Len() const override
void SetLevelInListTree(const int nLevel)
set level of this node
#define SAL_INFO_IF(condition, area, stream)
tools::Long GetLeftMarginForTabCalculation() const
return left margin for tab stop position calculation
static css::uno::Reference< css::text::XTextContent > CreateXParagraph(SwDoc &rDoc, SwTextNode *pTextNode, css::uno::Reference< css::text::XText > const &xParentText=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)