summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-09-15 16:13:34 +0200
committerLászló Németh <nemeth@numbertext.org>2020-09-16 09:31:10 +0200
commitc04ee66c7cfeb725d637b0f9ec3e3b1f8776bfe9 (patch)
tree6082fa482a1ea2bc574887a1cede6251d86c58de
parentf19381e46930bb496e7331754843920933fb4be2 (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf134784.docxbin0 -> 28416 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx7
3 files changed, 17 insertions, 1 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf134784.docx
Binary files 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;