summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-03-22 11:08:12 +0100
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-22 15:53:30 +0000
commitcd8de6c4138d227a48d01b05212f5aaf53b67aab (patch)
treefd3329ece603a2b8fc992f8d9819697e6dca90e5
parent110253379015ec0cbb2bbaf99fde9e2c546f8d06 (diff)
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) Reviewed-on: https://gerrit.libreoffice.org/2906 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo62288.rtf23
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx15
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx9
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 000000000000..f5ec592fc1fc
--- /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 07583fc244ee..e54812f1c3cc 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -142,6 +142,7 @@ public:
void testFdo59638();
void testFdo60722();
void testFdo61909();
+ void testFdo62288();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -234,6 +235,7 @@ void Test::run()
{"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 @@ void Test::testFdo61909()
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 34b779d8ba6d..3f18695d7b39 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2172,11 +2172,20 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
// \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: