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.behrens@allotropia.de>
This commit is contained in:
committed by
Thorsten Behrens
parent
3b8aad9781
commit
f806fc136b
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user