[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu May 26 08:44:40 UTC 2016
sw/qa/extras/rtfimport/data/tdf74795.rtf | 13 +++++
sw/qa/extras/rtfimport/rtfimport.cxx | 12 ++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 63 +++++++++++++++++++++++++
3 files changed, 88 insertions(+)
New commits:
commit 009c3917aa2df93c6476cbaa2b5117a60a113316
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed May 25 12:30:18 2016 +0200
tdf#74795 RTF import: handle row-level default cell margins
(cherry picked from commit db1a4f8d1d44351ca65742d3d94371a0c0536ff2)
Conflicts:
writerfilter/source/rtftok/rtfdispatchsymbol.cxx
writerfilter/source/rtftok/rtfdispatchvalue.cxx
Change-Id: I5bdd7b8624a9e2ac1aef963ccc5ed457ebda3f84
Reviewed-on: https://gerrit.libreoffice.org/25493
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/rtfimport/data/tdf74795.rtf b/sw/qa/extras/rtfimport/data/tdf74795.rtf
new file mode 100644
index 0000000..6db3008
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf74795.rtf
@@ -0,0 +1,13 @@
+{\rtf1\ansi\deff4\adeflang1025
+\trowd\trpaddfl3\trpaddl360\cellx4819\cellx9638
+\pard\plain\intbl
+{first cell}
+\cell\pard\plain\intbl
+{second cell}
+\cell\row\pard
+\trowd\cellx4819\cellx9638
+\pard\plain
+\cell\pard\plain
+\intbl
+\cell\row\pard\plain after.
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 2c9bc87..66b4c04 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2576,6 +2576,18 @@ DECLARE_RTFIMPORT_TEST(testTdf82073, "tdf82073.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xCell, "BackColor"));
}
+DECLARE_RTFIMPORT_TEST(testTdf74795, "tdf74795.rtf")
+{
+ uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ // This was 0, \trpaddl was ignored on import.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(635), getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
+
+ xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
+ // Make sure that the scope of the default is only one row.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
+}
+
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 cabc7f9..60c7ab4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2367,6 +2367,8 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
m_aTopLevelTableCellsSprms, m_aTopLevelTableCellsAttributes,
m_nTopLevelCells);
+ // The scope of the table cell defaults is one row.
+ m_aDefaultState.aTableCellSprms.clear();
m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
@@ -4804,6 +4806,67 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
}
break;
+ case RTF_TRPADDFB:
+ case RTF_TRPADDFL:
+ case RTF_TRPADDFR:
+ case RTF_TRPADDFT:
+ {
+ RTFSprms aAttributes;
+ switch (nParam)
+ {
+ case 3:
+ aAttributes.set(NS_ooxml::LN_CT_TblWidth_type, std::make_shared<RTFValue>(NS_ooxml::LN_Value_ST_TblWidth_dxa));
+ break;
+ }
+ switch (nKeyword)
+ {
+ case RTF_TRPADDFB:
+ nSprm = NS_ooxml::LN_CT_TcMar_bottom;
+ break;
+ case RTF_TRPADDFL:
+ nSprm = NS_ooxml::LN_CT_TcMar_left;
+ break;
+ case RTF_TRPADDFR:
+ nSprm = NS_ooxml::LN_CT_TcMar_right;
+ break;
+ case RTF_TRPADDFT:
+ nSprm = NS_ooxml::LN_CT_TcMar_top;
+ break;
+ default:
+ break;
+ }
+ lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ lcl_putNestedSprm(m_aDefaultState.aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ }
+ break;
+ case RTF_TRPADDB:
+ case RTF_TRPADDL:
+ case RTF_TRPADDR:
+ case RTF_TRPADDT:
+ {
+ RTFSprms aAttributes;
+ aAttributes.set(NS_ooxml::LN_CT_TblWidth_w, std::make_shared<RTFValue>(nParam));
+ switch (nKeyword)
+ {
+ case RTF_TRPADDB:
+ nSprm = NS_ooxml::LN_CT_TcMar_bottom;
+ break;
+ case RTF_TRPADDL:
+ nSprm = NS_ooxml::LN_CT_TcMar_left;
+ break;
+ case RTF_TRPADDR:
+ nSprm = NS_ooxml::LN_CT_TcMar_right;
+ break;
+ case RTF_TRPADDT:
+ nSprm = NS_ooxml::LN_CT_TcMar_top;
+ break;
+ default:
+ break;
+ }
+ lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ lcl_putNestedSprm(m_aDefaultState.aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ }
+ break;
case RTF_FI:
lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
break;
More information about the Libreoffice-commits
mailing list