sw/source/core/text/itrform2.cxx | 2 sw/source/core/text/porlay.cxx | 57 ++++++++++++++++++++++-- sw/source/writerfilter/dmapper/DomainMapper.cxx | 1 3 files changed, 55 insertions(+), 5 deletions(-)
New commits: commit f806fc136b3410ec9a1e09320d100c78b33c867b Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu Jun 13 14:49:16 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Jul 30 22:42:11 2024 +0200 tdf#137335 calculate paragraph height in RTF/DOCX TabStops and spaces are not included in height calculation of paragraphs in Word. With a compatibility option this is now also set in RTF import. But if spaces or/or tabstops are the only parts of a line their font size is taken into account. The fix 89e7341025b607491c90efdb74708e63d875c1e5%5E%21 from tdf#142404 has been removed because it broke formatting of follow lines. Change-Id: Id28488438462114bd54c4f8bd15e2ada606c4192 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168788 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 862a164a6dbc..3a884203b414 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -891,7 +891,7 @@ void SwTextFormatter::CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor ) { pPor->SetHangingBaseline( rInf.GetHangingBaseline() ); pPor->SetAscent( rInf.GetAscent() ); - pPor->Height( rInf.GetTextHeight() ); + pPor->Height(rInf.GetTextHeight()); bCalc = true; } else diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index bb33c11bf8b4..16dee7a087ae 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -400,6 +400,12 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) bool bHasBlankPortion = false; bool bHasOnlyBlankPortions = true; + bool bHasTabPortions = false; + bool bHasNonBlankPortions = false; + SwTwips nTabPortionAscent = 0; + SwTwips nTabPortionHeight = 0; + SwTwips nSpacePortionAscent = 0; + SwTwips nSpacePortionHeight = 0; bool bHasFlyPortion = false; if( mpNextPortion ) @@ -452,15 +458,40 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) AddPrtWidth( pPos->Width() ); // #i3952# - if (bIgnoreBlanksAndTabsForLineHeightCalculation && !rInf.GetLineStart()) + if (bIgnoreBlanksAndTabsForLineHeightCalculation) { + bHasTabPortions |= pPos->InTabGrp(); + bool isSpacePortion = false; if ( pPos->InTabGrp() || pPos->IsHolePortion() || ( pPos->IsTextPortion() && - lcl_HasOnlyBlanks( rInf.GetText(), nPorSttIdx, nPorSttIdx + pPos->GetLen() ) ) ) + (isSpacePortion = lcl_HasOnlyBlanks( rInf.GetText(), nPorSttIdx, nPorSttIdx + pPos->GetLen() ) ) ) ) { pLast = pPos; + if (pPos->InTabGrp()) + { + if (nTabPortionAscent < pPos->GetAscent()) + { + nTabPortionAscent = pPos->GetAscent(); + } + if (nTabPortionHeight < pPos->Height()) + { + nTabPortionHeight = pPos->Height(); + } + } + else if (isSpacePortion) + { + if (nSpacePortionAscent < pPos->GetAscent()) + { + nSpacePortionAscent = pPos->GetAscent(); + } + if (nSpacePortionHeight < pPos->Height()) + { + nSpacePortionHeight = pPos->Height(); + } + bHasBlankPortion = true; + } + bTmpDummy &= !pPos->InTabGrp(); pPos = pPos->GetNextPortion(); - bHasBlankPortion = true; continue; } } @@ -476,6 +507,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) } bHasOnlyBlankPortions = false; + bHasNonBlankPortions = true; // We had an attribute change: Sum up/build maxima of length and mass @@ -651,8 +683,25 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) } } + if (bIgnoreBlanksAndTabsForLineHeightCalculation && !bHasNonBlankPortions && + (bHasTabPortions || (bHasBlankPortion && (nSpacePortionAscent > 0 || nSpacePortionHeight > 0)))) + { + //Word increases line height if _only_ spaces and|or tabstops are in a line + if (bHasTabPortions) + { + mnAscent = nTabPortionAscent; + Height(nTabPortionHeight, true); + } + else if (bHasBlankPortion) + { + if( mnAscent < nSpacePortionAscent ) + mnAscent = nSpacePortionAscent; + if (!bHasTabPortions || Height() < nSpacePortionHeight) + Height(nSpacePortionHeight, true); + } + } // #i3952# Whitespace does not increase line height - if ( bHasBlankPortion && bHasOnlyBlankPortions ) + else if (bHasBlankPortion && bHasOnlyBlankPortions) { sal_uInt16 nTmpAscent = GetAscent(); sal_uInt16 nTmpHeight = Height(); diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 52e3eda73187..202a5343e510 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -150,6 +150,7 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon //paint background frames after header/footer when anchored in body m_pImpl->SetDocumentSettingsProperty(u"PaintHellOverHeaderFooter"_ustr,uno::Any(true)); m_pImpl->SetDocumentSettingsProperty(u"EmptyDbFieldHidesPara"_ustr,uno::Any(false)); + m_pImpl->SetDocumentSettingsProperty(u"IgnoreTabsAndBlanksForLineCalculation"_ustr,uno::Any(true)); } // Initialize RDF metadata, to be able to add statements during the import.