Blame SOURCES/0001-Resolves-tdf-99498-don-t-overwrite-trwWidth-value-if.patch

f325b2
From b5d3739516032e8863ee60e0c614dd1ec9e262a8 Mon Sep 17 00:00:00 2001
f325b2
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f325b2
Date: Wed, 27 Apr 2016 14:50:05 +0100
f325b2
Subject: [PATCH] Resolves: tdf#99498 don't overwrite trwWidth value if set on
f325b2
 a table
f325b2
f325b2
Change-Id: Ia39da999a2de1ca2b8bec5fc7f35d2f9ffe2dd19
f325b2
---
f325b2
 sw/qa/extras/rtfimport/rtfimport.cxx           | 10 ++++++++++
f325b2
 writerfilter/source/rtftok/rtfdocumentimpl.cxx | 18 ++++++++++++++----
f325b2
 2 files changed, 24 insertions(+), 4 deletions(-)
f325b2
f325b2
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
f325b2
index 4236a48..07dd0da 100644
f325b2
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
f325b2
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
f325b2
@@ -2388,6 +2388,16 @@ DECLARE_RTFIMPORT_TEST(testTdf96308Tabpos, "tdf96308-tabpos.rtf")
f325b2
     CPPUNIT_ASSERT(!aTabStops.hasElements());
f325b2
 }
f325b2
 
f325b2
+DECLARE_RTFIMPORT_TEST(testTdf99498, "tdf99498.rtf")
f325b2
+{
f325b2
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
f325b2
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
f325b2
+
f325b2
+    // Table width should be 7056
f325b2
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(7056), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
f325b2
+}
f325b2
+
f325b2
+
f325b2
 DECLARE_RTFIMPORT_TEST(testTdf87034, "tdf87034.rtf")
f325b2
 {
f325b2
     // This was A1BC34D, i.e. the first "super" text portion was mis-imported,
f325b2
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
f325b2
index 799186d..f292e9d 100644
f325b2
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
f325b2
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
f325b2
@@ -1368,10 +1368,14 @@ void RTFDocumentImpl::prepareProperties(
f325b2
     }
f325b2
 
f325b2
     // Table width.
f325b2
-    auto pUnitValue = std::make_shared<RTFValue>(3);
f325b2
-    lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
f325b2
-    auto pWValue = std::make_shared<RTFValue>(nCurrentCellX);
f325b2
-    lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
f325b2
+    RTFValue::Pointer_t const pTableWidthProps = rState.aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblW);
f325b2
+    if (!pTableWidthProps.get())
f325b2
+    {
f325b2
+        auto pUnitValue = std::make_shared<RTFValue>(3);
f325b2
+        lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
f325b2
+        auto pWValue = std::make_shared<RTFValue>(nCurrentCellX);
f325b2
+        lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
f325b2
+    }
f325b2
 
f325b2
     auto pRowValue = std::make_shared<RTFValue>(1);
f325b2
     if (nCells > 0)
f325b2
@@ -4783,6 +4787,12 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
f325b2
             lcl_putNestedSprm(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_right, std::make_shared<RTFValue>(aAttributes));
f325b2
         }
f325b2
         break;
f325b2
+    case RTF_TRFTSWIDTH:
f325b2
+        lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pIntValue);
f325b2
+        break;
f325b2
+    case RTF_TRWWIDTH:
f325b2
+        lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pIntValue);
f325b2
+        break;
f325b2
     default:
f325b2
     {
f325b2
         SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
f325b2
-- 
f325b2
2.7.3
f325b2