27#include <com/sun/star/i18n/ScriptType.hpp>
40#include <bookmark.hxx>
66 bool const m_isHideRedlines;
68 bool const m_isHideParagraphBreaks;
73 std::pair<sw::mark::IFieldmark const*, std::optional<SwPosition>> m_Fieldmark;
74 std::optional<SwPosition> m_oNextFieldmarkHide;
76 std::optional<std::pair<SwPosition, SwPosition>> m_oParagraphBreak;
82 SwPosition const* GetStartPos()
const {
return m_pStartPos; }
83 SwPosition const* GetEndPos()
const {
return m_pEndPos; }
88 : m_rIDRA(rTextNode.getIDocumentRedlineAccess())
89 , m_rIDMA(*rTextNode.getIDocumentMarkAccess())
90 , m_isHideRedlines(isHideRedlines)
91 , m_eFieldmarkMode(
eMode)
93 , m_Start(rTextNode, 0)
95 , m_pStartPos(nullptr)
108 if (m_isHideRedlines)
118 if (pRed->
GetType() != RedlineType::Delete)
121 auto [pStart, pEnd] = pRed->
StartEnd();
122 if (*pStart == *pEnd)
127 if (pStart->GetNode().IsTableNode())
129 assert(pEnd->GetNode() == m_Start.
GetNode() && pEnd->GetContentIndex() == 0);
132 if (*m_pEndPos <= *pStart)
134 pNextRedlineHide = pStart;
141 m_oNextFieldmarkHide.reset();
148 sal_Int32
const nPos = pTextNode ? pTextNode->
GetText().indexOf(
152 m_oNextFieldmarkHide.emplace(*pTextNode, nPos);
153 sw::mark::IFieldmark
const*
const pFieldmark(
158 m_Fieldmark.first = pFieldmark;
165 m_Fieldmark.second.emplace(
167 m_Fieldmark.second->AdjustContent(+1);
168 m_oNextFieldmarkHide->AdjustContent(+1);
172 m_Fieldmark.second.emplace(pFieldmark->GetMarkEnd());
173 m_Fieldmark.second->AdjustContent(-1);
180 assert(!pNextRedlineHide || !m_oNextFieldmarkHide
181 || *pNextRedlineHide != *m_oNextFieldmarkHide
182 || *m_rIDRA.
GetRedlineTable()[m_RedlineIndex]->End() < *m_Fieldmark.second);
184 && (!m_oNextFieldmarkHide || *pNextRedlineHide < *m_oNextFieldmarkHide))
187 m_pStartPos = pRed->
Start();
188 m_pEndPos = pRed->
End();
192 else if (m_oNextFieldmarkHide)
194 assert(!pNextRedlineHide || *m_oNextFieldmarkHide <= *pNextRedlineHide);
195 m_pStartPos = &*m_oNextFieldmarkHide;
196 m_pEndPos = &*m_Fieldmark.second;
201 assert(!pNextRedlineHide && !m_oNextFieldmarkHide);
202 auto const hasHiddenItem = [](
auto const& rNode) {
206 auto const hasBreakBefore = [](
SwTextNode const& rNode) {
211 switch (rNode.GetAttr(
RES_BREAK).GetBreak())
213 case SvxBreak::ColumnBefore:
214 case SvxBreak::ColumnBoth:
215 case SvxBreak::PageBefore:
216 case SvxBreak::PageBoth:
223 auto const hasBreakAfter = [](
SwTextNode const& rNode) {
224 switch (rNode.GetAttr(
RES_BREAK).GetBreak())
226 case SvxBreak::ColumnAfter:
227 case SvxBreak::ColumnBoth:
228 case SvxBreak::PageAfter:
229 case SvxBreak::PageBoth:
236 if (m_isHideParagraphBreaks
246 m_oParagraphBreak.emplace(
249 m_pStartPos = &m_oParagraphBreak->first;
250 m_pEndPos = &m_oParagraphBreak->second;
255 m_pStartPos =
nullptr;
267std::unique_ptr<sw::MergedPara>
275 bool bHaveRedlines(
false);
276 std::vector<SwTextNode *> nodes{ &rTextNode };
277 std::vector<SwTableNode *> tables;
278 std::vector<SwSectionNode *> sections;
279 std::vector<sw::Extent> extents;
280 OUStringBuffer mergedText;
283 sal_Int32 nLastEnd(0);
284 for (
auto iter = HideIterator(rTextNode,
290 SwPosition const*
const pStart(iter.GetStartPos());
291 SwPosition const*
const pEnd(iter.GetEndPos());
292 bHaveRedlines =
true;
293 assert(pNode != &rTextNode || &pStart->
GetNode() == &rTextNode);
301 if (pNode == &rTextNode)
340 pNode = nodes.back();
342 if (pNode != &rTextNode)
346 nLastEnd = pNode->
Len();
351 nodes.push_back(pNode);
361 if (pNode == &rTextNode)
415 if (nLastEnd != pNode->
Len())
417 extents.emplace_back(pNode, nLastEnd, pNode->
Len());
418 mergedText.append(pNode->
GetText().subView(nLastEnd, pNode->
Len() - nLastEnd));
422 assert(mergedText.isEmpty());
423 pParaPropsNode = pNode;
427 assert(!mergedText.isEmpty());
428 pParaPropsNode = extents.begin()->pNode;
436 for (
auto const pTextNode : nodes)
438 if (pTextNode != pParaPropsNode)
452 auto itExtent(extents.begin());
453 for (
auto const pTextNode : nodes)
456 std::vector<std::pair<sal_Int32, sal_Int32>>
hidden;
457 for ( ; itExtent != extents.end(); ++itExtent)
459 if (itExtent->pNode != pTextNode)
463 if (itExtent->nStart != 0)
465 assert(itExtent->nStart != nLast);
466 hidden.emplace_back(nLast, itExtent->nStart);
468 nLast = itExtent->nEnd;
470 if (nLast != pTextNode->
Len())
472 hidden.emplace_back(nLast, pTextNode->
Len());
478 auto const end(--nodes.rend());
479 for (
auto iter = nodes.rbegin(); iter !=
end; ++iter)
484 for (
auto const pTableNode : tables)
488 for (
auto const pSectionNode : sections)
490 pSectionNode->GetSection().GetFormat()->DelFrames();
493 auto pRet(std::make_unique<sw::MergedPara>(rFrame, std::move(extents),
494 mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode,
498 pRet->listener.StartListening(pTmp);
509 std::u16string_view aText,
510 bool const*
const pbVertLayout,
511 bool const*
const pbVertLayoutLRBT)
530 bool bVertLayoutLRBT =
false;
531 if (pbVertLayoutLRBT)
532 bVertLayoutLRBT = *pbVertLayoutLRBT;
564 case i18n::ScriptType::ASIAN :
567 case i18n::ScriptType::COMPLEX :
592 bool bVertLayout =
false;
593 bool bVertLayoutLRBT =
false;
603 bVertLayoutLRBT =
true;
635 if (rExtent.pNode != pNode)
637 pNode = rExtent.pNode;
655 if (rExtent.pNode != pNode)
657 pNode = rExtent.pNode;
673 const std::vector<ExtTextInputAttr> *pArr =
nullptr;
686 pArr, pExtInp ? pExtInp->
Start() :
nullptr));
707 const std::vector<ExtTextInputAttr> *pArr,
709 :
m_rDoc( rTextNd.GetDoc() )
710 , m_rAttrHandler( rAH )
711 , m_nNdIdx( rTextNd.GetIndex() )
721 assert(pExtInputStart);
740 SwNodeOffset const nNode, sal_Int32
const nNew, sal_Int32
const nOld)
816 ( SfxItemState::SET == aIter.
GetItemState(
true, &pItem ) ) )
854 if (pRedline->
GetType() == RedlineType::Delete
855 && (nNode < pStart->GetNodeIndex()
857 && nNew <= pStart->GetContentIndex())))
873 case RedlineType::Insert:
876 case RedlineType::Delete:
879 case RedlineType::Format:
880 case RedlineType::FmtColl:
890 OSL_ENSURE(
IsOn(),
"SwRedlineItr::ChangeTextAttr: Off?" );
904 OSL_ENSURE( !
m_pExt || !
m_pExt->IsOn(),
"Pop of attribute during opened extension" );
911 OSL_ENSURE(
m_bOn,
"SwRedlineItr::Clear: Off?" );
913 for (
auto const& hint :
m_Hints)
928std::pair<sal_Int32, std::pair<SwRangeRedline const*, size_t>>
936 return std::make_pair(nNext, std::make_pair(
nullptr, 0));
949 || pRedline->
GetType() == RedlineType::Delete)
958 return std::make_pair(nNext, std::make_pair(
nullptr, 0));
965 else if (nStart <= nNext)
976 assert(pRedline->
GetType() == RedlineType::Delete);
977 if (pRedline->
GetType() == RedlineType::Delete)
981 while (rAct + nSkipped <
986 if (*pRedline->
End() < *pNext->
Start())
990 else if (*pNext->
Start() == *pRedline->
End() &&
991 pNext->
GetType() == RedlineType::Delete)
998 return std::make_pair(nNext, std::make_pair(pRedline, nSkipped));
1002 return std::make_pair(nNext, std::make_pair(
nullptr, 0));
1012 const sal_uInt16 nWhich = pHint->Which();
1021 SwNodeOffset const nStartNode, sal_Int32
const nChkStart,
1022 SwNodeOffset const nEndNode, sal_Int32 nChkEnd, OUString& rRedlineText,
1023 bool& bRedlineEnd,
RedlineType& eRedlineEnd,
size_t* pAuthorAtPos)
1029 if( nChkEnd == nChkStart && pAuthorAtPos ==
nullptr )
1032 sal_Int32 nOldEnd =
m_nEnd;
1034 bool bRet = bRedlineEnd =
false;
1035 eRedlineEnd = RedlineType::None;
1040 bool isBreak(
false);
1046 bool isExtendText(
false);
1057 eRedlineEnd = pRedline->
GetType();
1069 if (rRedlineText.isEmpty() && !pRedline->
IsVisible())
1071 rRedlineText =
const_cast<SwRangeRedline*
>(pRedline)->GetDescr(
true);
1072 pPrevRedline = pRedline;
1073 isExtendText =
true;
1077 else if (pPrevRedline && !pRedline->
IsVisible() &&
1078 *pRedline->
Start() == *pPrevRedline->
Start() && *pRedline->
End() == *pPrevRedline->
End() )
1080 OUString sExtendText(
const_cast<SwRangeRedline*
>(pRedline)->GetDescr(
true));
1081 if (!sExtendText.isEmpty())
1083 if (rRedlineText.getLength() < 12)
1087 rRedlineText = rRedlineText +
1088 const_cast<SwRangeRedline*
>(pRedline)->GetDescr(
true).subView(1);
1091 rRedlineText = OUString::Concat(rRedlineText.subView(0, rRedlineText.getLength() - 3)) +
"...";
1093 isExtendText =
true;
1100 if (isBreak && !isExtendText)
1114 if ( nAttr & ExtTextInputAttr::Underline )
1116 else if ( nAttr & ExtTextInputAttr::DoubleUnderline )
1118 else if ( nAttr & ExtTextInputAttr::BoldUnderline )
1120 else if ( nAttr & ExtTextInputAttr::DottedUnderline )
1122 else if ( nAttr & ExtTextInputAttr::DashDotUnderline )
1125 if ( nAttr & ExtTextInputAttr::RedText )
1128 if ( nAttr & ExtTextInputAttr::Highlight )
1134 if ( nAttr & ExtTextInputAttr::GrayWaveline )
1140 OSL_ENSURE( !
m_pFont,
"SwExtend: Enter with Font" );
1143 OSL_ENSURE( !
Inside(),
"SwExtend: Enter without Leave" );
1156 OSL_ENSURE(nNode ==
m_nNode &&
Inside(),
"SwExtend: Leave without Enter");
1164 if( nOldAttr != nAttr )
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...
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual ::sw::mark::IFieldmark * getFieldmarkAt(const SwPosition &rPos) const =0
get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
virtual sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
static bool IsShowChanges(const RedlineFlags eM)
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
Used by Attribute Iterators to organize attributes on stacks to find the valid attribute in each cate...
void Init(const SwAttrSet &rAttrSet, const IDocumentSettingAccess &rIDocumentSettingAccess)
void PushAndChg(const SwTextAttr &rAttr, SwFont &rFnt)
void Pop(const SwTextAttr &rAttr)
Only used during redlining.
void PopAndChg(const SwTextAttr &rAttr, SwFont &rFnt)
bool IsVertLayout() const
size_t m_nStartIndex
current iteration index in HintStarts
sal_Int32 m_nPosition
current iteration index in text node
size_t m_nEndIndex
current iteration index in HintEnds
o3tl::enumarray< SwFontScript, sal_uInt16 > m_aFontIdx
o3tl::enumarray< SwFontScript, const void * > m_aFontCacheIds
short m_nChgCnt
count currently open hints, redlines, ext-input
std::unique_ptr< SwRedlineItr, o3tl::default_delete< SwRedlineItr > > m_pRedline
void CtorInitAttrIter(SwTextNode &rTextNode, SwScriptInfo &rScrInf, SwTextFrame const *pFrame=nullptr)
SwAttrHandler m_aAttrHandler
sw::MergedPara const * m_pMergedPara
SwScriptInfo * m_pScriptInfo
SwViewShell * m_pViewShell
bool Seek(TextFrameIndex nPos)
Enables the attributes used at char pos nPos in the logical font.
void InitFontAndAttrHandler(SwTextNode const &rPropsNode, SwTextNode const &rTextNode, std::u16string_view aText, bool const *pbVertLayout, bool const *pbVertLayoutLRBT)
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const SwAttrSet * GetpSwAttrSet() const
SwFormatColl & GetAnyFormatColl() const
SwExtTextInput * GetExtTextInput(const SwNode &rNd, sal_Int32 nContentPos=-1) const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
const std::vector< ExtTextInputAttr > & GetAttrs() const
sal_Int32 Next(SwNodeOffset nNode, sal_Int32 nNext)
const std::vector< ExtTextInputAttr > & m_rArr
short Enter(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew)
std::unique_ptr< SwFont > m_pFont
SwNodeOffset const m_nNode
position of start of SwExtTextInput
bool Leave_(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew)
sal_Int32 m_nPos
current position (inside)
sal_Int32 const m_nEnd
position of end of SwExtTextInput (in same node as start)
static void ActualizeFont(SwFont &rFnt, ExtTextInputAttr nAttr)
const SfxPoolItem ** GetDefault()
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
void SetGreyWave(const bool bNew)
void SetVertical(Degree10 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
Degree10 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)
void SetBackColor(std::optional< Color > xNewColor)
void CheckFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
void SetColor(const Color &rColor)
void SetUnderline(const FontLineStyle eUnderline)
void SetActual(SwFontScript nNew)
bool IsRightToLeft() const
SwRootFrame * getRootFrame()
Base class of the Writer document model elements.
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwSectionNode * GetSectionNode()
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
void SetRedlineMergeFlag(Merge const eMerge)
bool IsSectionNode() const
Merge GetRedlineMergeFlag() const
SwNodeOffset EndOfSectionIndex() const
bool IsCreateFrameWhenHidingRedlines() const
SwTableNode * GetTableNode()
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
const IDocumentSettingAccess * getIDocumentSettingAccess() const
Provides access to the document setting interface.
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
const SwPosition * End() const
const SwPosition * Start() const
sal_uInt16 GetStackCount() const
std::size_t GetAuthor(sal_uInt16 nPos=0) const
void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32 &rStart, sal_Int32 &rEnd) const
Calculates the intersection with text node number nNdIdx.
RedlineType GetType(sal_uInt16 nPos=0) const
std::unique_ptr< SfxItemSet > m_pSet
void Clear_(SwFont *pFnt)
void ChangeTextAttr(SwFont *pFnt, SwTextAttr const &rHt, bool bChg)
std::pair< sal_Int32, std::pair< SwRangeRedline const *, size_t > > GetNextRedln(sal_Int32 nNext, SwTextNode const *pNode, SwRedlineTable::size_type &rAct)
Ignore mode: does nothing.
sal_Int32 NextExtend(SwNodeOffset const nNode, sal_Int32 const nNext)
bool CheckLine(SwNodeOffset nStartNode, sal_Int32 nChkStart, SwNodeOffset nEndNode, sal_Int32 nChkEnd, OUString &rRedlineText, bool &bRedlineEnd, RedlineType &eRedlineEnd, size_t *pAuthorAtPos=nullptr)
SwNodeOffset const m_nNdIdx
short EnterExtend(SwFont &rFnt, SwNodeOffset const nNode, sal_Int32 const nNew)
SwRedlineTable::size_type m_nAct
bool ChkSpecialUnderline_() const
SwRedlineItr(const SwTextNode &rTextNd, SwFont &rFnt, SwAttrHandler &rAH, sal_Int32 nRedlPos, Mode mode, const std::vector< ExtTextInputAttr > *pArr=nullptr, SwPosition const *pExtInputStart=nullptr)
short Seek(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew, sal_Int32 nOld)
SwAttrHandler & m_rAttrHandler
std::unique_ptr< SwExtend > m_pExt
std::deque< SwTextAttr * > m_Hints
SwRedlineTable::size_type const m_nFirst
void FillHints(std::size_t nAuthor, RedlineType eType)
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
static constexpr size_type npos
vector_type::size_type size_type
The root element of a Writer document layout.
SwViewShell * GetCurrShell() const
bool HasMergedParas() const
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
sw::FieldmarkMode GetFieldmarkMode() const
sw::ParagraphBreakMode GetParagraphBreakMode() const
SwFontScript WhichFont(TextFrameIndex nIdx) const
size_t CountScriptChg() const
TextFrameIndex GetInvalidityA() const
TextFrameIndex GetScriptChg(const size_t nCnt) const
sal_uInt8 GetScriptType(const size_t nCnt) const
void InitScriptInfo(const SwTextNode &rNode, sw::MergedPara const *pMerged, bool bRTL)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
static void Destroy(SwTextAttr *pToDestroy, SfxItemPool &rPool)
destroy instance
void SetPriorityAttr(bool bFlag)
Represents the visualization of a paragraph.
sw::MergedPara * GetMergedPara()
SwTextNode is a paragraph in the document model.
virtual sal_Int32 Len() const override
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
const OUString & GetText() const
void RemoveFromListRLHidden()
constexpr ::Color COL_GREEN(0x00, 0x80, 0x00)
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
#define CH_TXT_ATR_FIELDSEP
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxCharHiddenItem > RES_CHRATR_HIDDEN(37)
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SwFormatAutoFormat > RES_PARATR_LIST_AUTOFMT(87)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
#define CH_TXT_ATR_FIELDSTART
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
SwPosition FindFieldSep(IFieldmark const &rMark)
return position of the CH_TXT_ATR_FIELDSEP for rMark
Dialog to specify the properties of date form field.
void RemoveFootnotesForNode(SwRootFrame const &rLayout, SwTextNode const &rTextNode, std::vector< std::pair< sal_Int32, sal_Int32 > > const *const pExtents)
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
SwComparePosition ComparePosition(const T &rStt1, const T &rEnd1, const T &rStt2, const T &rEnd2)
@ OverlapBehind
Pos1 overlaps Pos2 at the end.
@ CollideEnd
Pos1 end touches at Pos2 start.
@ Behind
Pos1 behind Pos2.
@ OverlapBefore
Pos1 overlaps Pos2 at the beginning.
@ Outside
Pos2 completely contained in Pos1.
@ Before
Pos1 before Pos2.
@ Inside
Pos1 completely contained in Pos2.
@ CollideStart
Pos1 start touches at Pos2 end.
@ Equal
Pos1 is as large as Pos2.
Marks a position in the document model.
SwNodeOffset GetNodeIndex() const
const SwNodes & GetNodes() const
sal_Int32 GetContentIndex() const
OUString mergedText
note: cannot be const currently to avoid UB because SwTextGuess::Guess const_casts it and modifies it...
SwTextNode * pParaPropsNode
most paragraph properties are taken from the first non-empty node
std::vector< Extent > extents
constexpr sal_Int32 COMPLETE_STRING
SwTextAttr * MakeRedlineTextAttr(SwDoc &rDoc, SfxPoolItem const &rAttr)
create redline dummy text hint that must not be inserted into hints array