Kaydet (Commit) 78f90a6d authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Adolfo Jayme Barrientos

tdf#95071: fix spacing calculations for border with page offset

With commit ebf767ee, some previously
hidden bugs manifested themselves, this is one of them.
The margin size calculated incorrectly when border offset was from
page. The border is drawn from the margin inwards, so the margin
should be equal to OOXML w:space attribute, and border distance
should be OOXML page margin - border distance - border width.

Incorrect calculation gave negative margin, with IllegalArgumentException
thrown in SfxItemPropertySet::setPropertyValue.

Reviewed-on: https://gerrit.libreoffice.org/19586Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>

Cherry-picked from 061d98cc

Change-Id: Ifcf4a348e975df53410933aab3684d17f68b688c
Reviewed-on: https://gerrit.libreoffice.org/19940Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mikekaganski@hotmail.com>
Reviewed-by: 's avatarAdolfo Jayme Barrientos <fitojb@ubuntu.com>
üst 11d0bacd
......@@ -567,7 +567,7 @@ DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
sal_Int32 nValue = 0;
xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(794), nValue);
CPPUNIT_ASSERT_EQUAL(sal_Int32(847), nValue);
// No assert for the 3rd problem: see the comment in the test doc.
......
......@@ -700,18 +700,18 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
sal_Int32 nDist = nDistance;
if( nOffsetFrom == 1 )
if( nOffsetFrom == 1 ) // From page
{
const OUString sMarginName = rPropNameSupplier.GetName( eMarginId );
uno::Any aMargin = xStyle->getPropertyValue( sMarginName );
sal_Int32 nMargin = 0;
aMargin >>= nMargin;
// Change the margins with the ( border distance - line width )
xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance - nLineWidth ) );
// Change the margins with the border distance
xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance ) );
// Set the distance to ( Margin - distance )
nDist = nMargin - nDistance;
// Set the distance to ( Margin - distance - nLineWidth )
nDist = nMargin - nDistance - nLineWidth;
}
const OUString sBorderDistanceName = rPropNameSupplier.GetName( eDistId );
if (xStyle.is())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment