[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/qa writerfilter/source

Caolán McNamara caolanm at redhat.com
Thu Apr 28 07:36:04 UTC 2016


 sw/qa/extras/rtfimport/data/tdf99498.rtf       |    3 +++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   11 +++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   18 ++++++++++++++----
 3 files changed, 28 insertions(+), 4 deletions(-)

New commits:
commit b9dbeb401b1f8f9b89a1ab477a566cbf42967c8a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Apr 27 14:50:05 2016 +0100

    Resolves: tdf#99498 don't overwrite trwWidth value if set on a table
    
    Reviewed-on: https://gerrit.libreoffice.org/24430
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit b71f470e370c1819cba99abe5ef654d28bbf8749)
    
    Change-Id: Ia39da999a2de1ca2b8bec5fc7f35d2f9ffe2dd19
    Reviewed-on: https://gerrit.libreoffice.org/24434
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfimport/data/tdf99498.rtf b/sw/qa/extras/rtfimport/data/tdf99498.rtf
new file mode 100644
index 0000000..61a3066
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf99498.rtf
@@ -0,0 +1,3 @@
+{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\froman\fcharset0 Arial;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}{\stylesheet {\style\s0 \ql\fi0\li0\ri0\f1\fs24\cf0 Normal;}}
+{\*\generator iText 2.1.7 by 1T3XT}
+\par\par\trowd\trftsWidth3\trwWidth4000\trhdr\trqc\trgaph10\trpaddl0\trpaddr0\trpaddfl3\trpaddfr3\clvertalt\clcbpat1\clftsWidth3\clwWidth0\cellx0\clvertalt\clcbpat1\clftsWidth3\clwWidth0\cellx0\pard\plain\intbl\s0\fi0\li0\ri0\sl280\plain\f1\fs22\cf0 CELLCONTENTS \cell\pard\plain\intbl\s0\fi0\li0\ri0\sl280\plain\cell \row\pard}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 20f8755..5dfc751 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2497,6 +2497,17 @@ DECLARE_RTFIMPORT_TEST(testTdf96308Tabpos, "tdf96308-tabpos.rtf")
     CPPUNIT_ASSERT(!aTabStops.hasElements());
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf99498, "tdf99498.rtf")
+{
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+
+    // Table width was a tiny sub one char wide 145twips, it should now be a table wide
+    // enough to see all the text in the first column without breaking into multiple lines
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(7056), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
+}
+
+
 DECLARE_RTFIMPORT_TEST(testTdf87034, "tdf87034.rtf")
 {
     // This was A1BC34D, i.e. the first "super" text portion was mis-imported,
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index bb1991d..26e70ae 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1374,10 +1374,14 @@ void RTFDocumentImpl::prepareProperties(
     }
 
     // Table width.
-    auto pUnitValue = std::make_shared<RTFValue>(3);
-    lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
-    auto pWValue = std::make_shared<RTFValue>(nCurrentCellX);
-    lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
+    RTFValue::Pointer_t const pTableWidthProps = rState.aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblW);
+    if (!pTableWidthProps.get())
+    {
+        auto pUnitValue = std::make_shared<RTFValue>(3);
+        lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
+        auto pWValue = std::make_shared<RTFValue>(nCurrentCellX);
+        lcl_putNestedAttribute(rState.aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
+    }
 
     auto pRowValue = std::make_shared<RTFValue>(1);
     if (nCells > 0)
@@ -4810,6 +4814,12 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             lcl_putNestedSprm(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_right, std::make_shared<RTFValue>(aAttributes));
         }
         break;
+    case RTF_TRFTSWIDTH:
+        lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pIntValue);
+        break;
+    case RTF_TRWWIDTH:
+        lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pIntValue);
+        break;
     default:
     {
         SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");


More information about the Libreoffice-commits mailing list