sw/source/core/text/itrform2.cxx | 2 sw/source/core/text/porlay.cxx | 57 +++++++++++++++++++++++++-- writerfilter/source/dmapper/DomainMapper.cxx | 1 3 files changed, 55 insertions(+), 5 deletions(-)
New commits: commit 8f7a867609442a542dbeb1701e6a7dae4db359f1 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu Jun 13 14:49:16 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Wed Jul 24 21:46:57 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/+/170901 Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de> 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 221a23c5534a..d31d67f95089 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -892,7 +892,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 2ba2fcf75fb4..da043e507d73 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/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index b0ad1744dcde..d2fcefced9aa 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -145,6 +145,7 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon m_pImpl->SetDocumentSettingsProperty("NoNumberingShowFollowBy", uno::Any(true)); //paint backgound frames after header/footer when anchored in body m_pImpl->SetDocumentSettingsProperty("PaintHellOverHeaderFooter",uno::Any(true)); + m_pImpl->SetDocumentSettingsProperty(u"IgnoreTabsAndBlanksForLineCalculation"_ustr,uno::Any(true)); } // Initialize RDF metadata, to be able to add statements during the import.