tdf#116486 Consider upper margin in paragraph positioning with flys

The problem was the following:
There is a paragraph with an upper margin defined. Also, there
is a flyframe intersecting this upper margin. The desired behavior
is to reposition the parapgraph, such that it (including it's upper
margin) is located below the flyframe.

This patch increases the bounding rectangle of the paragraph by the
upper margin.

For compatibility, there is a compat-flag query. I re-used a related one.

Change-Id: I9dbc75e07e2ba0658fdbbfa9989be24a68660713
Reviewed-on: https://gerrit.libreoffice.org/52685
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Patrick Jaap
2018-04-16 09:14:56 +02:00
committed by Miklos Vajna
parent 266e58d246
commit d07fc485d4
3 changed files with 18 additions and 0 deletions
Binary file not shown.
+6
View File
@@ -1586,6 +1586,12 @@ DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
}
DECLARE_OOXMLIMPORT_TEST(testTdf116486, "tdf116486.docx")
{
OUString aTop = parseDump("/root/page/body/txt/Special", "nHeight");
CPPUNIT_ASSERT_EQUAL( OUString("4006"), aTop );
}
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
+12
View File
@@ -2278,12 +2278,24 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
SwRect aLine( rInf.X() + nLeftMin, nTop, rInf.RealWidth() - rInf.X()
+ nLeftMar - nLeftMin , nHeight );
// tdf#116486: consider also the upper margin from getFramePrintArea because intersections
// with this additional space should lead to repositioning of paragraphs
// For compatibility we grab a related compat flag:
if ( GetTextFrame()->GetTextNode()->getIDocumentSettingAccess()->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS) )
{
const long nUpper = m_pFrame->getFramePrintArea().Top();
// Increase the rectangle
if( nUpper > 0 && nTop >= nUpper )
aLine.SubTop( nUpper );
}
SwRect aLineVert( aLine );
if ( m_pFrame->IsRightToLeft() )
m_pFrame->SwitchLTRtoRTL( aLineVert );
if ( m_pFrame->IsVertical() )
m_pFrame->SwitchHorizontalToVertical( aLineVert );
// GetFrame(...) determines and returns the intersection rectangle
SwRect aInter( rTextFly.GetFrame( aLineVert ) );
if ( m_pFrame->IsRightToLeft() )