[Libreoffice-commits] core.git: sw/qa writerfilter/source
Attila Szűcs (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 15 10:33:46 UTC 2021
sw/qa/extras/ooxmlimport/data/tdf74367_MarginsZeroed.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 15 ++++++++++++++
writerfilter/source/dmapper/BorderHandler.hxx | 1
writerfilter/source/dmapper/PageBordersHandler.cxx | 5 +++-
4 files changed, 20 insertions(+), 1 deletion(-)
New commits:
commit b35f48d806f9e5ec689eda3828f1e4503644873b
Author: Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Wed Feb 3 16:50:30 2021 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Mon Feb 15 11:33:10 2021 +0100
tdf#74367 DOCX: fix page margins imported as border padding
Trying to import non-existing "none" borders of w:pgBorders
zeroed page margins, removing their values to border padding.
Note: according to OOXML standard 2.6.10. pgBorders (Page
Borders), "nil" should be treated the same.
Co-authored-by: Tibor Nagy (NISZ)
Change-Id: Ibbc9375b2f8b3daf7b4bdea84e078676ce588586
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110396
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf74367_MarginsZeroed.docx b/sw/qa/extras/ooxmlimport/data/tdf74367_MarginsZeroed.docx
new file mode 100644
index 000000000000..9b9eb1c43965
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf74367_MarginsZeroed.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index cf9781f00606..16351d9fcb35 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -459,6 +459,21 @@ DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
}
+DECLARE_OOXMLIMPORT_TEST(testTdf74367_MarginsZeroed, "tdf74367_MarginsZeroed.docx")
+{
+ // Do not import page borders with 'None' style, or else it will change the page margins.
+ uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ sal_Int32 nValue = 0;
+ xPropertySet->getPropertyValue("TopMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("RightMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("BottomMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+}
+
DECLARE_OOXMLIMPORT_TEST(testBnc773061, "bnc773061.docx")
{
uno::Reference< text::XTextRange > paragraph = getParagraph( 1 );
diff --git a/writerfilter/source/dmapper/BorderHandler.hxx b/writerfilter/source/dmapper/BorderHandler.hxx
index 9e8aa7a62a90..1261416760b3 100644
--- a/writerfilter/source/dmapper/BorderHandler.hxx
+++ b/writerfilter/source/dmapper/BorderHandler.hxx
@@ -69,6 +69,7 @@ public:
PropertyMapPtr getProperties();
css::table::BorderLine2 getBorderLine();
sal_Int32 getLineDistance() const { return m_nLineDistance;}
+ sal_Int32 getLineType() const { return m_nLineType;}
bool getShadow() const { return m_bShadow;}
void enableInteropGrabBag(const OUString& aName);
css::beans::PropertyValue getInteropGrabBag(const OUString& aName = OUString());
diff --git a/writerfilter/source/dmapper/PageBordersHandler.cxx b/writerfilter/source/dmapper/PageBordersHandler.cxx
index d6a0fdd1f502..89548eb351ee 100644
--- a/writerfilter/source/dmapper/PageBordersHandler.cxx
+++ b/writerfilter/source/dmapper/PageBordersHandler.cxx
@@ -119,7 +119,10 @@ void PageBordersHandler::lcl_sprm( Sprm& rSprm )
aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
aPgBorder.m_ePos = ePos;
aPgBorder.m_bShadow = pBorderHandler->getShadow();
- m_aBorders.push_back( aPgBorder );
+ if (pBorderHandler->getLineType() != NS_ooxml::LN_Value_ST_Border_none)
+ {
+ m_aBorders.push_back( aPgBorder );
+ }
}
}
break;
More information about the Libreoffice-commits
mailing list