Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/2906 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/06/2906/1 fdo#62288 fix RTF import of table paragraph margins Regression from 4a507f732d82c188ad81b022cbe3037951e58ac3. The problem was that in some cases \pard can't reset all paragraph properties. The original commit just made this keyword a noop when it occurred between \cell and \row, but this is too much. At least margins do need resetting. Change-Id: I5cbb1df72bf1211f85ef69ab64d5b46cbce5c742 (cherry picked from commit 24d5261f5a122e22675210445056cdf67663237b) --- A sw/qa/extras/rtfimport/data/fdo62288.rtf M sw/qa/extras/rtfimport/rtfimport.cxx M writerfilter/source/rtftok/rtfdocumentimpl.cxx 3 files changed, 47 insertions(+), 0 deletions(-) diff --git a/sw/qa/extras/rtfimport/data/fdo62288.rtf b/sw/qa/extras/rtfimport/data/fdo62288.rtf new file mode 100644 index 0000000..f5ec592 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo62288.rtf @@ -0,0 +1,23 @@ +{\rtf1 +\paperw11907\paperh16840\margl567\margr567\margt567\margb567 +\sb113\sa113 +{\b\fs22\cf1\kerning1\cgrid0 Objectives} +{\fs24\kerning1\cgrid0 +\par } +\trowd \trgaph10\trleft-10 \clvertalt\cltxlrtb \cellx4808\clvertalt\cltxlrtb \cellx5375\clvertalt\cltxlrtb \cellx10194\clvertalt\cltxlrtb \cellx10762\pard \li567\nowidctlpar\intbl\adjustright +{\cf1\kerning1\cgrid0 One} +{\fs24\kerning1\cgrid0 \cell } +\pard \qc\nowidctlpar\intbl\adjustright +{\cf1\kerning1\cgrid0 [ ]} +{\fs24\kerning1\cgrid0 \cell } +\pard \li567\nowidctlpar\intbl\adjustright +{\cf1\kerning1\cgrid0 Two} +{ +\fs24\kerning1\cgrid0 \cell } +\pard \qc\nowidctlpar\intbl\adjustright +{\cf1\kerning1\cgrid0 [ ]} +{\fs24\kerning1\cgrid0 \cell } +\pard \widctlpar\intbl\adjustright +{\fs24\kerning1\cgrid0 \row } +\pard\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 07583fc..e54812f 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -142,6 +142,7 @@ void testFdo59638(); void testFdo60722(); void testFdo61909(); + void testFdo62288(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -234,6 +235,7 @@ {"fdo59638.rtf", &Test::testFdo59638}, {"fdo60722.rtf", &Test::testFdo60722}, {"fdo61909.rtf", &Test::testFdo61909}, + {"fdo62288.rtf", &Test::testFdo62288}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1142,6 +1144,19 @@ CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor")); } +void Test::testFdo62288() +{ + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + // Margins were inherited from the previous cell, even there was a \pard there. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaLeftMargin")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 34b779d..3f18695 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2172,11 +2172,20 @@ // \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table. if (m_aStates.top().nCells == 0) { + // Reset everything. m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms; m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes; if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) m_pCurrentBuffer = 0; } + else + { + // Reset only margins. + lcl_eraseNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_before); + lcl_eraseNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_after); + m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PDxaLeft); + m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PDxaRight); + } m_aStates.top().resetFrame(); break; case RTF_SECTD: -- To view, visit https://gerrit.libreoffice.org/2906 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5cbb1df72bf1211f85ef69ab64d5b46cbce5c742 Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: libreoffice-4-0 Gerrit-Owner: Miklos Vajna <vmik...@suse.cz> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice