27#include <osl/diagnose.h>
30 css::uno::Reference< css::container::XStringKeyMap >
const & xPropertyBag,
33:
maType(
std::move(aType)), mxPropertyBag(xPropertyBag), mnPos(
nPos), mnLen(nLen), mpSubList(nullptr)
40 css::uno::Reference< css::container::XStringKeyMap >
const & xPropertyBag,
46 if (pSubList !=
nullptr)
82 i.mpSubList =
i.mpSubList->Clone();
91 i.mpSubList =
nullptr;
108 const sal_Int32 nWrPos =
Pos(
nPos );
109 if ( nWrPos <= rChk )
112 if( nWrPos + rLn <= rChk )
135 sal_Int32 nWrPos =
Pos(
nPos );
136 sal_Int32 nEnd = nWrPos +
Len(
nPos );
146 if( nEnd > rChk && nWrPos < rLn )
171 if( nRet < nChk && nRet +
Len(
nPos ) <= nChk )
193 sal_uInt16 nMax =
Count();
204 return (rST.mnPos <= nValue && nValue < rST.mnPos + rST.mnLen)
205 || (rST.mnPos > nValue);
207 return o3tl::narrowing<sal_uInt16>(std::distance(
maList.begin(), aIter));
212 while( nMin <= nMax )
214 nMid = nMin + ( nMax - nMin ) / 2;
215 const sal_Int32 nTmp =
Pos( nMid );
272 const sal_Int32 nEnd =
nPos - nDiff;
275 while( nLst <
Count() &&
Pos( nLst ) < nEnd )
279 const sal_Int32 nWrPos =
Pos( nLst - 1 );
280 if ( nWrPos <=
nPos )
282 sal_Int32 nWrLen =
Len( nLst - 1 );
284 nWrLen = ( nEnd > nWrPos + nWrLen ) ?
289 maList[--nLst].mnLen = nWrLen;
310 const sal_Int32 nEnd =
nPos + nDiff;
322 const sal_Int32 nWrPos =
Pos(
i );
326 const sal_Int32 nWrLen =
Len(
i ) + nDiff;
357 sal_Int32 nLen, sal_uInt16 nIndex, sal_Int32 nCursorPos ) ->
FreshState
363 ? (nCursorPos >
nPos + nLen || nCursorPos <
nPos)
366 : FreshState::NOTHING;
368 sal_Int32 nWrPos = 0;
369 sal_Int32 nWrEnd = rEnd;
373 nWrPos =
Pos( nCnt );
374 if( nWrPos < nPos && rStart > nWrPos )
378 while( nCnt <
Count() )
380 nWrPos =
Pos( nCnt );
381 if ( nWrPos >=
nPos )
383 nWrEnd = nWrPos + Len( nCnt++ );
386 if( nCnt <
Count() && nWrPos ==
nPos && Len( nCnt ) == nLen )
389 eRet = FreshState::FRESH;
393 if (FreshState::FRESH == eRet)
397 nWrEnd =
nPos + nLen;
405 nWrPos =
Pos( nCnt );
406 if( nWrPos < nPos && rStart > nWrPos )
410 while( nCnt <
Count() )
412 nWrPos =
Pos( nCnt );
413 if ( nWrPos >=
nPos )
415 nWrEnd = nWrPos + Len( nCnt++ );
438 const sal_Int32 nFirst =
Pos( 0 );
448 std::unique_ptr<SwWrongList> pRet;
450 while( nLst <
Count() &&
Pos( nLst ) < nSplitPos )
454 sal_Int32 nWrPos =
Pos( nLst - 1 );
455 sal_Int32 nWrLen =
Len( nLst - 1 );
456 if ( nWrPos+nWrLen > nSplitPos )
458 nWrLen += nWrPos - nSplitPos;
459 maList[--nLst].mnPos = nSplitPos;
460 maList[nLst].mnLen = nWrLen;
471 pRet->Invalidate_( nSplitPos ? nSplitPos - 1 : nSplitPos, nSplitPos );
483 for (nLst = 0; nLst <
Count(); ++nLst )
485 maList[nLst].mnPos -= nSplitPos;
496 sal_uInt16 nCnt =
Count();
497 pNext->
Move( 0, nInsertPos );
501 if( nCnt &&
Count() > nCnt )
503 sal_Int32 nWrPos =
Pos( nCnt );
504 sal_Int32 nWrLen =
Len( nCnt );
507 nWrPos += nInsertPos;
508 nWrLen -= nInsertPos;
509 maList[nCnt].mnPos = nWrPos;
510 maList[nCnt].mnLen = nWrLen;
512 if( nWrPos ==
Pos( nCnt - 1 ) +
Len( nCnt - 1 ) )
514 nWrLen +=
Len( nCnt - 1 );
515 maList[nCnt - 1].mnLen = nWrLen;
520 Invalidate( nInsertPos ? nInsertPos - 1 : nInsertPos, nInsertPos + 1 );
529 std::vector<SwWrongArea>::iterator
i =
maList.begin();
530 if ( nWhere >=
maList.size() )
538void SwWrongList::Insert(sal_uInt16 nWhere, std::vector<SwWrongArea>::iterator startPos, std::vector<SwWrongArea>::iterator
const & endPos)
540 std::vector<SwWrongArea>::iterator
i =
maList.begin();
541 if ( nWhere >=
maList.size() )
545 maList.insert(
i, startPos, endPos);
549 while ( startPos != endPos )
551 (*startPos).mpSubList =
nullptr;
558 if ( nIdx >=
maList.size() )
return;
559 std::vector<SwWrongArea>::iterator i1 =
maList.begin();
562 std::vector<SwWrongArea>::iterator i2 = i1;
563 if ( nIdx + nLen >= o3tl::narrowing<sal_uInt16>(
maList.size()) )
568 std::vector<SwWrongArea>::iterator iLoop = i1;
569 while ( iLoop != i2 )
571 delete (*iLoop).mpSubList;
575#if OSL_DEBUG_LEVEL > 0
576 const int nOldSize =
Count();
581#if OSL_DEBUG_LEVEL > 0
582 OSL_ENSURE(
Count() + nLen == nOldSize,
"SwWrongList::Remove() trouble" );
587 std::vector<SwWrongArea>::const_iterator aEnd(
maList.end());
588 auto aDelIter = std::find_if(
maList.cbegin(), aEnd,
589 [nBegin](
const SwWrongArea& rST) { return rST.mnPos >= nBegin; });
590 auto aIter = aDelIter;
595 aIter = std::find_if(aDelIter, aEnd,
601 aIter = std::find_if(aDelIter, aEnd,
606 auto nDel = o3tl::narrowing<sal_uInt16>(std::distance(aDelIter, aIter));
609 auto nDelPos = o3tl::narrowing<sal_uInt16>(std::distance(
maList.cbegin(), aDelIter));
616 [nBegin](
const SwWrongArea& rST) { return rST.mnPos >= nBegin; });
617 return aIter !=
maList.end()
618 && nBegin == (*aIter).mnPos
619 && nEnd == (*aIter).mnPos + (*aIter).mnLen;
623 css::uno::Reference< css::container::XStringKeyMap >
const & xPropertyBag,
624 sal_Int32 nNewPos, sal_Int32 nNewLen )
627 [nNewPos](
const SwWrongArea& rST) { return nNewPos <= rST.mnPos; });
628 if ( aIter !=
maList.end() && nNewPos == (*aIter).mnPos )
630 const sal_Int32 nSTPos = (*aIter).mnPos;
632 aIter = std::find_if(aIter,
maList.end(),
633 [nSTPos, nNewLen](
const SwWrongArea& rST) { return rST.mnPos != nSTPos || nNewLen < rST.mnLen; });
643 : m_pGetWrongList(pGetWrongList)
644 , m_pMergedPara(rFrame.GetMergedPara())
647 , m_pWrongList(m_pMergedPara
649 : (rFrame.GetTextNodeFirst()->*pGetWrongList)())
654 : m_pGetWrongList(nullptr)
655 , m_pMergedPara(nullptr)
658 , m_pWrongList(&rWrongList)
682 while (m_CurrentExtent < m_pMergedPara->extents.size())
692 assert(0 < sal_Int32(rLen));
702 if (sal_Int32(rLen) < rExtent.
nEnd - nStart)
704 nLen = sal_Int32(rLen);
708 sal_Int32 nInLen(rLen);
709 nLen = rExtent.
nEnd - nStart;
721 if (nInLen <= rExtentEnd.
nEnd - rExtentEnd.
nStart)
727 nInLen -= rExtentEnd.
nEnd - rExtentEnd.
nStart;
730 if (pWrongList && pWrongList->
Check(nStart, nLen))
733 if (rExtent.
nStart <= nStart && nStart < rExtent.
nEnd)
736 sal_Int32
const nEnd(nStart + nLen);
739 if (nEnd <= rExtent.
nEnd)
751 || nEnd <= rExtentEnd.
nStart)
755 if (nEnd <= rExtentEnd.
nEnd)
763 assert(rLen <= nOrigLen); (void) nOrigLen;
775 sal_Int32 nStart(rStart);
776 sal_Int32 nLen(rLen);
795 while (m_CurrentExtent < m_pMergedPara->extents.size())
842 SwNode const* pNode(
nullptr);
843 sal_uInt16 InCurrentNode(0);
844 while (m_CurrentExtent < m_pMergedPara->extents.size())
847 if (rExtent.
pNode != pNode)
850 pNode = rExtent.
pNode;
853 for (; pWrongList && InCurrentNode < pWrongList->
Count(); ++InCurrentNode)
879std::optional<std::pair<TextFrameIndex, TextFrameIndex>>
886 SwNode const* pNode(
nullptr);
887 sal_uInt16 InCurrentNode(0);
888 while (m_CurrentExtent < m_pMergedPara->extents.size())
891 if (rExtent.
pNode != pNode)
894 pNode = rExtent.
pNode;
897 for (; pWrongList && InCurrentNode < pWrongList->
Count(); ++InCurrentNode)
910 return std::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
911 std::pair<TextFrameIndex, TextFrameIndex>(
923 return std::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
928 return std::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
929 std::pair<TextFrameIndex, TextFrameIndex>(
933 return std::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
Base class of the Writer document model elements.
Represents the visualization of a paragraph.
SwTextNode is a paragraph in the document model.
static Color getWrongAreaColor(WrongListType listType, css::uno::Reference< css::container::XStringKeyMap > const &xPropertyBag)
WrongAreaLineType mLineType
SwWrongArea(OUString aType, WrongListType listType, css::uno::Reference< css::container::XStringKeyMap > const &xPropertyBag, sal_Int32 nPos, sal_Int32 nLen)
static WrongAreaLineType getWrongAreaLineType(WrongListType listType, css::uno::Reference< css::container::XStringKeyMap > const &xPropertyBag)
sal_Int32 GetEndInv() const
void RemoveEntry(sal_Int32 nBegin, sal_Int32 nEnd)
std::unique_ptr< SwWrongList > SplitList(sal_Int32 nSplitPos)
WrongListType GetWrongListType() const
void JoinList(SwWrongList *pNext, sal_Int32 nInsertPos)
const SwWrongArea * GetElement(sal_uInt16 nIdx) const
bool Check(sal_Int32 &rChk, sal_Int32 &rLn) const
Calculate first incorrectly selected area.
virtual SwWrongList * Clone()
void Invalidate(sal_Int32 nBegin, sal_Int32 nEnd)
std::vector< SwWrongArea > maList
sal_Int32 Pos(sal_uInt16 nIdx) const
void InsertSubList(sal_Int32 nNewPos, sal_Int32 nNewLen, sal_uInt16 nWhere, SwWrongList *pSubList)
SwWrongList(const SwWrongList &rCpy)=delete
FreshState Fresh(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nPos, sal_Int32 nLen, sal_uInt16 nIndex, sal_Int32 nCursorPos)
Remove given range of entries.
virtual void CopyFrom(const SwWrongList &rCopy)
sal_uInt16 GetWrongPos(sal_Int32 nValue) const
Find the first position that is greater or equal to the given value.
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
void Invalidate_(sal_Int32 nBegin, sal_Int32 nEnd)
void Remove(sal_uInt16 nIdx, sal_uInt16 nLen)
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
static void ShiftLeft(sal_Int32 &rPos, sal_Int32 nStart, sal_Int32 nEnd)
void Move(sal_Int32 nPos, sal_Int32 nDiff)
Change all values after the given position.
void Insert(sal_uInt16 nWhere, std::vector< SwWrongArea >::iterator startPos, std::vector< SwWrongArea >::iterator const &endPos)
sal_Int32 GetBeginInv() const
bool LookForEntry(sal_Int32 nBegin, sal_Int32 nEnd)
sal_Int32 Len(sal_uInt16 nIdx) const
sal_Int32 NextWrong(sal_Int32 nChk) const
Find next incorrectly selected position.
sw::MergedPara const *const m_pMergedPara
SwWrongList const *(SwTextNode::*const m_pGetWrongList)() const
WrongListIteratorBase(SwTextFrame const &rFrame, SwWrongList const *(SwTextNode::*pGetWrongList)() const)
for the text frame
SwWrongList const *const m_pWrongList
TextFrameIndex m_CurrentIndex
sal_uInt16 GetElementCount()
std::optional< std::pair< TextFrameIndex, TextFrameIndex > > GetElementAt(sal_uInt16 nIndex)
WrongListIteratorCounter(SwTextFrame const &rFrame, SwWrongList const *(SwTextNode::*pGetWrongList)() const)
bool Check(TextFrameIndex &rStart, TextFrameIndex &rLen)
WrongListIterator(SwTextFrame const &rFrame, SwWrongList const *(SwTextNode::*pGetWrongList)() const)
for the text frame
const SwWrongArea * GetWrongElement(TextFrameIndex nStart)
Dialog to specify the properties of date form field.
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Describes a part of a single text node, which will be part of a text frame, even when redlines are hi...
std::vector< Extent > extents
constexpr sal_Int32 COMPLETE_STRING