sw/source/core/text/txtfrm.cxx | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-)
New commits: commit ffc368fc83724240119aaf1dedaefddd288e7591 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Nov 5 14:59:21 2024 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Nov 5 21:18:50 2024 +0100 tdf#162268 sw: layout: hidden formatting is ignored on cell end marker ... in Word, so ignore it in Writer on the last paragraph in a cell. (regression from commit 7b8cec8322b60673e686660caf875bc71117bbd0) Word also uses hidden character formatting on the row end marker to determine if a row should be hidden; this isn't possible yet. Change-Id: I7ceaea0d807193155631083616a93cdd058e20d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176092 Tested-by: allotropia jenkins <jenk...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index bbf18f79ef66..793a03b98903 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1475,6 +1475,19 @@ void SwTextFrame::ResetPreps() } } +static auto FindCellFrame(SwFrame const* pLower) -> SwLayoutFrame const* +{ + while (pLower) + { + if (pLower->IsCellFrame()) + { + return static_cast<SwLayoutFrame const*>(pLower); + } + pLower = pLower->GetUpper(); + } + return nullptr; +} + bool SwTextFrame::IsHiddenNow() const { SwFrameSwapper aSwapper( this, true ); @@ -1549,12 +1562,27 @@ bool SwTextFrame::IsHiddenNow() const SwTextNode const*const pNode{ m_pMergedPara ? m_pMergedPara->pLastNode : static_cast<SwTextNode const*>(SwFrame::GetDep()) }; - SwFormatAutoFormat const& rListAutoFormat{pNode->GetAttr(RES_PARATR_LIST_AUTOFMT)}; - std::shared_ptr<SfxItemSet> const pSet{rListAutoFormat.GetStyleHandle()}; - SvxCharHiddenItem const*const pItem{pSet ? pSet->GetItemIfSet(RES_CHRATR_HIDDEN) : nullptr}; - if (!pItem || !pItem->GetValue()) + // Word ignores hidden formatting on the cell end marker + bool isLastInCell{false}; + if (SwLayoutFrame const*const pCellFrame{FindCellFrame(this)}) { - bHiddenCharsHidePara = false; + SwContentFrame const* pNext{GetNextContentFrame()}; + // skip frame in hidden section ("this" is *not* in hidden section!) + while (pNext && pNext->SwContentFrame::IsHiddenNow()) + { + pNext = pNext->GetNextContentFrame(); + } + isLastInCell = pNext == nullptr || !pCellFrame->IsAnLower(pNext); + } + if (!isLastInCell) + { + SwFormatAutoFormat const& rListAutoFormat{pNode->GetAttr(RES_PARATR_LIST_AUTOFMT)}; + std::shared_ptr<SfxItemSet> const pSet{rListAutoFormat.GetStyleHandle()}; + SvxCharHiddenItem const*const pItem{pSet ? pSet->GetItemIfSet(RES_CHRATR_HIDDEN) : nullptr}; + if (!pItem || !pItem->GetValue()) + { + bHiddenCharsHidePara = false; + } } } const SwViewShell* pVsh = getRootFrame()->GetCurrShell();