sw/qa/extras/ooxmlexport/data/tdf134784.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 11 +++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-)
New commits: commit c04ee66c7cfeb725d637b0f9ec3e3b1f8776bfe9 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Sep 15 16:13:34 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Sep 16 09:31:10 2020 +0200 tdf#134784 DOCX import: fix shape paragraph margins based on bad style inheritance. Regression from commit dc0300eac3b755bc207cd1fe87217f4ebaeb9f58 (tdf#118521 DOCX import: fix paragraph margin from paragraph style), revealing the problematic m_sCurrentParaStyleName, see also commit 8920d865ee148518bf71f71ce1866b24cc17c07e for more information. Change-Id: Icc7f70452d946d56dc840d39545d850f74f97ebc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102774 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf134784.docx b/sw/qa/extras/ooxmlexport/data/tdf134784.docx new file mode 100644 index 000000000000..2099db66e0f6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf134784.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index cd00389f063c..e7b996562803 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -802,6 +802,17 @@ DECLARE_OOXMLEXPORT_TEST(testMarginsFromStyle, "margins_from_style.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(600), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin")); } +DECLARE_OOXMLEXPORT_TEST(testTdf134784, "tdf134784.docx") +{ + uno::Reference<text::XText> textbox(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(3, getParagraphs(textbox)); + uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, textbox); + CPPUNIT_ASSERT_EQUAL(sal_Int32(212), getProperty<sal_Int32>(xParagraph, "ParaBottomMargin")); + + // This wasn't zero (it was inherited from style of the previous paragraph in the main text) + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xParagraph, "ParaTopMargin")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf104348_contextMargin, "tdf104348_contextMargin.docx") { // tdf#104348 shows that ContextMargin belongs with Top/Bottom handling diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 25030cbff4b6..b0facd429e0e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -780,8 +780,13 @@ uno::Sequence< style::TabStop > DomainMapper_Impl::GetCurrentTabStopAndClear() OUString DomainMapper_Impl::GetCurrentParaStyleName() { + OUString sName; // use saved currParaStyleName as a fallback, in case no particular para style name applied. - OUString sName = m_sCurrentParaStyleName; + // tdf#134784 except in the case of first paragraph of shapes to avoid bad fallback. + // TODO fix this "highly inaccurate" m_sCurrentParaStyleName + if ( !m_bIsFirstParaInShape ) + sName = m_sCurrentParaStyleName; + PropertyMapPtr pParaContext = GetTopContextOfType(CONTEXT_PARAGRAPH); if ( pParaContext && pParaContext->isSet(PROP_PARA_STYLE_NAME) ) pParaContext->getProperty(PROP_PARA_STYLE_NAME)->second >>= sName; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits