tdf#137085 writerfilter: RTF import: \trpaddfl and \trpaddl are row...
...properties, not cell properties.
What is supposed to happen here, afaict:
1. \trpaddfr3 either has an effect on the left margin too (despite being
defined for right), or \trpaddfl3 is the default, 0 is not the
default
2. \trgaph600 should be ignored if the \trpaddfl3 is in effect
3. \trpaddl0 should be in effect, overriding both the value from
\trgaph600 and the built-in default of #define DEF_BORDER_DIST 190
CellMarginHandler::lcl_sprm() needs to distinguish between \trpaddfl0
and \trpaddfl3 cases, but its not possible currently because a)
\trpaddfl is processed after \trgaph/\trpaddl, and b) both \trgaph and
\trpaddl produce the same srpm-id.
This fixes \trpaddl handling just enough to import the bugdoc properly,
for more fixing a new sprm-id for \trgaph would be needed at least.
At the other end, there is a line in DomainMapperTableHandler.cxx:
m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf )
... but nothing that would initialize the GAP_HALF there.
That this bugdoc looked right before commit
c2a5346b19c57f93f210b76c15cdba64f6871203 appears to be entirely
accidental.
Change-Id: I80dc34bdd5dadb7d7d7f5ec595907035d621a656
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104638
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit fc872146845e4d77ff404d0929f28abf2d3a1c51)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104604
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/rtfexport/data/tdf137085.rtf b/sw/qa/extras/rtfexport/data/tdf137085.rtf
new file mode 100644
index 0000000..6aed787
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf137085.rtf
@@ -0,0 +1,10 @@
{\rtf1\ansi
\trowd
\trgaph600\trpaddfr3\trpaddl0
\cellx3000
\cellx6000
<- no padding here\cell
<- no padding here\cell
\row
}
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 25c0bdb..e005ce6 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -1004,6 +1004,22 @@ DECLARE_RTFEXPORT_TEST(testTdf74795, "tdf74795.rtf")
getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
}
DECLARE_RTFEXPORT_TEST(testTdf137085, "tdf137085.rtf")
{
uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
// \trpaddl0 overrides \trgaph600 (-1058 mm100) and built-in default of 190
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xTable, "LeftMargin"));
// the \trpaddl0 is applied to all cells
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
}
DECLARE_RTFEXPORT_TEST(testTdf77349, "tdf77349.rtf")
{
uno::Reference<container::XNamed> xImage(getShape(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index d6b0fc7..b43e85a 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -624,6 +624,11 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword nKeyword, int nParam)
default:
break;
}
putNestedAttribute(m_aStates.top().getTableRowSprms(),
NS_ooxml::LN_CT_TblPrBase_tblCellMar, nSprm,
new RTFValue(aAttributes));
// tdf#74795 also set on current cell, and as default for table cells
// (why isn't this done by domainmapper?)
putNestedAttribute(m_aStates.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar,
nSprm, new RTFValue(aAttributes));
putNestedAttribute(m_aDefaultState.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar,
@@ -655,6 +660,10 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword nKeyword, int nParam)
default:
break;
}
putNestedSprm(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblCellMar,
nSprm, new RTFValue(aAttributes));
// tdf#74795 also set on current cell, and as default for table cells
// (why isn't this done by domainmapper?)
putNestedSprm(m_aStates.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar,
nSprm, new RTFValue(aAttributes));
putNestedSprm(m_aDefaultState.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar,
@@ -670,6 +679,7 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword nKeyword, int nParam)
aAttributes.set(NS_ooxml::LN_CT_TblWidth_type,
new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa));
aAttributes.set(NS_ooxml::LN_CT_TblWidth_w, pIntValue);
// FIXME: this is wrong, it is half-gap, needs to be distinguished from margin! depending on TRPADDFL/TRPADDFR
putNestedSprm(m_aStates.top().getTableRowSprms(),
NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_left,
new RTFValue(aAttributes));