[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed May 25 14:45:47 UTC 2016
sw/qa/extras/rtfimport/data/tdf74795.rtf | 13 ++++
sw/qa/extras/rtfimport/rtfimport.cxx | 12 ++++
writerfilter/source/rtftok/rtfdispatchsymbol.cxx | 2
writerfilter/source/rtftok/rtfdispatchvalue.cxx | 61 +++++++++++++++++++++++
4 files changed, 88 insertions(+)
New commits:
commit db1a4f8d1d44351ca65742d3d94371a0c0536ff2
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
Change-Id: I5bdd7b8624a9e2ac1aef963ccc5ed457ebda3f84
Reviewed-on: https://gerrit.libreoffice.org/25443
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
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 309f79a..2af36e6 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2607,6 +2607,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/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index 98aa43d..218810b 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -283,6 +283,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;
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 46c77bb..b231ef4 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1284,6 +1284,67 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
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;
+ }
+ putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ 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;
+ }
+ putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ putNestedSprm(m_aDefaultState.aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, std::make_shared<RTFValue>(aAttributes));
+ }
+ break;
case RTF_FI:
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