diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-08 11:23:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-02 12:26:19 +0000 |
commit | cb64c29389939048666141eb4dddcfae4dd70ee5 (patch) | |
tree | 9b5c5c1b02f4bf0b6a8c4a6a93a30880e86806d2 | |
parent | acfc9935a41d45619d09d05abe6d933c3cd9fcc7 (diff) |
tdf#96308 RTF import: fix tab stop inheritance inside table cells
The tab stop list is a paragraph property, and RTF requires to repeat it
after \s as direct formatting, otherwise the parser should be assumed
that the tab stop list is cleared as a direct formatting.
Non-buffered text handles that in getDefaultSPRM(), handle it directly
in the RTF_PARD code for buffered text.
(cherry picked from commit 1ec88cdb82a28851c4b97d7f043d8bcec3c675e8)
Conflicts:
sw/qa/extras/rtfimport/rtfimport.cxx
Change-Id: I16b09bc4c177df5a74d16653b829b198aa1a800f
Reviewed-on: https://gerrit.libreoffice.org/21996
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/qa/extras/rtfimport/data/tdf96308-tabpos.rtf | 12 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 |
3 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/tdf96308-tabpos.rtf b/sw/qa/extras/rtfimport/data/tdf96308-tabpos.rtf new file mode 100644 index 000000000000..59fdb8fbffc4 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf96308-tabpos.rtf @@ -0,0 +1,12 @@ +{\rtf1 +{\stylesheet +{\s30\tx2552 Body Text 3;} +} +\deftab284 +\pard\plain\par +\trowd\cellx2694\cellx4678 \pard\intbl\tx284 A1\cell +\pard\intbl\tx2694 before\par +\pard\plain\s30\intbl 7.\tab Champion\par +\pard\plain\intbl after\cell\row +\pard\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index b718572c46e9..0544b1e829fd 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2350,6 +2350,22 @@ DECLARE_RTFIMPORT_TEST(testTdf59454, "tdf59454.rtf") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_RTFIMPORT_TEST(testTdf96308Tabpos, "tdf96308-tabpos.rtf") +{ + // Get the tab stops of the second para in the B1 cell of the first table in the document. + 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(); + xParaEnum->nextElement(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + auto aTabStops = getProperty< uno::Sequence<style::TabStop> >(xPara, "ParaTabStops"); + // This failed: tab stops were not deleted as direct formatting on the paragraph. + CPPUNIT_ASSERT(!aTabStops.hasElements()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 6dd24056837c..be5a966d3ec6 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2981,6 +2981,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) { // We are still in a table. m_aStates.top().aParagraphSprms.set(NS_ooxml::LN_inTbl, std::make_shared<RTFValue>(1)); + // Ideally getDefaultSPRM() would take care of this, but it would not when we're buffering. + m_aStates.top().aParagraphSprms.set(NS_ooxml::LN_CT_PPrBase_tabs, std::make_shared<RTFValue>()); } m_aStates.top().resetFrame(); |