Kaydet (Commit) 061d98cc authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Norbert Thiebaud

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.

Change-Id: Ifcf4a348e975df53410933aab3684d17f68b688c
Reviewed-on: https://gerrit.libreoffice.org/19586Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst d671a70f
...@@ -568,7 +568,7 @@ DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx") ...@@ -568,7 +568,7 @@ DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
sal_Int32 nValue = 0; sal_Int32 nValue = 0;
xPropertySet->getPropertyValue("LeftMargin") >>= nValue; 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. // No assert for the 3rd problem: see the comment in the test doc.
......
...@@ -675,18 +675,18 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet ...@@ -675,18 +675,18 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet
PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth ) PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth )
{ {
sal_Int32 nDist = nDistance; sal_Int32 nDist = nDistance;
if( nOffsetFrom == 1 ) if( nOffsetFrom == 1 ) // From page
{ {
const OUString sMarginName = getPropertyName( eMarginId ); const OUString sMarginName = getPropertyName( eMarginId );
uno::Any aMargin = xStyle->getPropertyValue( sMarginName ); uno::Any aMargin = xStyle->getPropertyValue( sMarginName );
sal_Int32 nMargin = 0; sal_Int32 nMargin = 0;
aMargin >>= nMargin; aMargin >>= nMargin;
// Change the margins with the ( border distance - line width ) // Change the margins with the border distance
xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance - nLineWidth ) ); xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance ) );
// Set the distance to ( Margin - distance ) // Set the distance to ( Margin - distance - nLineWidth )
nDist = nMargin - nDistance; nDist = nMargin - nDistance - nLineWidth;
} }
const OUString sBorderDistanceName = getPropertyName( eDistId ); const OUString sBorderDistanceName = getPropertyName( eDistId );
if (xStyle.is()) 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