diff options
| author | Oliver Specht <oliver.specht@cib.de> | 2024-06-13 14:49:16 +0200 |
|---|---|---|
| committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2024-07-24 21:46:57 +0200 |
| commit | 8f7a867609442a542dbeb1701e6a7dae4db359f1 (patch) | |
| tree | 13806f5d435b69b9113cdb4ef16d82c11007660a | |
| parent | fa713aa172772e5328726d236fdb733c83435284 (diff) | |
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.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
| -rw-r--r-- | sw/source/core/text/itrform2.cxx | 2 | ||||
| -rw-r--r-- | sw/source/core/text/porlay.cxx | 57 | ||||
| -rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 1 |
3 files changed, 55 insertions, 5 deletions
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. |
