summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-05-08 09:06:26 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-05-11 09:59:50 +0200
commit9223a8766e5a055f77e9cc7bccbfa718e6122e28 (patch)
treeffa0abfd669ca7ec5d111de06b4d5910cac5cc9d /writerfilter
parent9b2ebcfe80900b2f6299851d3a271bdcaa85049a (diff)
tdf#117403 RTF import: fix lost cell border of merged cell
If two source cells have different border types, then Writer takes the second, Word takes the first. So mimic the MSO behavior explicitly in dmapper. (cherry picked from commit 42b32321381126ad70700424b8970dbc45a843f5) Change-Id: I25adc62e024a929216c7b05fec44e1f602f28285 Reviewed-on: https://gerrit.libreoffice.org/54089 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index e6f993e19387..1466787b8fb5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1030,21 +1030,48 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab
{
if (!aMerges.empty())
{
+ static const std::vector<OUStringLiteral> aBorderNames
+ = { "TopBorder", "LeftBorder", "BottomBorder", "RightBorder" };
+
// Perform horizontal merges in reverse order, so the fact that merging changes the position of cells won't cause a problem for us.
for (std::vector<HorizontallyMergedCell>::reverse_iterator it = aMerges.rbegin(); it != aMerges.rend(); ++it)
{
uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY_THROW);
- uno::Reference<beans::XPropertySet> xCell(xCellRange->getCellByPosition(it->m_nFirstCol, it->m_nFirstRow), uno::UNO_QUERY_THROW);
- OUString aFirst = xCell->getPropertyValue("CellName").get<OUString>();
+ uno::Reference<beans::XPropertySet> xFirstCell(
+ xCellRange->getCellByPosition(it->m_nFirstCol, it->m_nFirstRow),
+ uno::UNO_QUERY_THROW);
+ OUString aFirst
+ = xFirstCell->getPropertyValue("CellName").get<OUString>();
// tdf#105852: Only try to merge if m_nLastCol is set (i.e. there were some merge continuation cells)
if (it->m_nLastCol != -1)
{
- xCell.set(xCellRange->getCellByPosition(it->m_nLastCol, it->m_nLastRow), uno::UNO_QUERY_THROW);
- OUString aLast = xCell->getPropertyValue("CellName").get<OUString>();
+ // Save border properties of the first cell
+ // before merge.
+ table::BorderLine2 aBorderValues[4];
+ for (size_t i = 0; i < aBorderNames.size(); ++i)
+ xFirstCell->getPropertyValue(aBorderNames[i])
+ >>= aBorderValues[i];
+
+ uno::Reference<beans::XPropertySet> xLastCell(
+ xCellRange->getCellByPosition(it->m_nLastCol, it->m_nLastRow),
+ uno::UNO_QUERY_THROW);
+ OUString aLast
+ = xLastCell->getPropertyValue("CellName").get<OUString>();
uno::Reference<text::XTextTableCursor> xCursor = xTable->createCursorByCellName(aFirst);
xCursor->gotoCellByName(aLast, true);
+
xCursor->mergeRange();
+
+ // Handle conflicting properties: mergeRange()
+ // takes the last cell, Word takes the first
+ // cell.
+ for (size_t i = 0; i < aBorderNames.size(); ++i)
+ {
+ if (aBorderValues[i].LineStyle != table::BorderLineStyle::NONE)
+ xFirstCell->setPropertyValue(
+ aBorderNames[i], uno::makeAny(aBorderValues[i]));
+ }
}
}
}