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

Guillaume Smaha gsmaha at linagora.com
Tue Apr 12 08:53:43 UTC 2016


 sw/qa/extras/rtfimport/data/tdf97035.rtf       |  140 +++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   11 +
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   10 +
 writerfilter/source/rtftok/rtfsprm.cxx         |   14 ++
 writerfilter/source/rtftok/rtfsprm.hxx         |    2 
 5 files changed, 175 insertions(+), 2 deletions(-)

New commits:
commit b297456515ba198913e49121cfcbc1afc8d195a7
Author: Guillaume Smaha <gsmaha at linagora.com>
Date:   Fri Apr 8 18:22:58 2016 +0200

    Fix tdf#97035 - Import: RTF wrong cell width
    
    Change-Id: Ifd31ab1672261644a00a32f3a8632dd0dcb33825
    Reviewed-on: https://gerrit.libreoffice.org/23687
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfimport/data/tdf97035.rtf b/sw/qa/extras/rtfimport/data/tdf97035.rtf
new file mode 100644
index 0000000..a8f1d8a
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf97035.rtf
@@ -0,0 +1,140 @@
+{\rtf1 \ansi 
+{\colortbl;
+\red0\green0\blue0;
+\red255\green255\blue255;
+\red255\green0\blue0;
+\red0\green255\blue0;
+\red0\green0\blue255;
+\red0\green255\blue255;
+\red255\green0\blue255;
+\red255\green255\blue0;
+\red0\green0\blue128;
+\red0\green128\blue128;
+\red0\green128\blue0;
+\red128\green0\blue128;
+\red128\green0\blue0;
+\red128\green128\blue0;
+\red128\green128\blue128;
+\red192\green192\blue192;
+\red204\green204\blue204;
+}
+{\fonttbl {
+\f0 Arial;}{
+\f1 Symbol;}{
+\f2 Times New Roman;}{
+\f3 Times Roman;}{
+\f4 sans-serif;}
+}
+\paperw16837 \paperh11905 \landscape \margt396 \margb453 \margl737 \margr680 \headery566 \footery396 \itap0 
+\sectd {
+{\trowd \itap0 \trleft0 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrl \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx1927 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx3060 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx4023 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx4816 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx5836 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx6573 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx7253 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx8160 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx9407 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx10200 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx11107 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx12014 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx12921 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx13828 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx14394 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrb \brdrw4 \brdrcf1 \brdrs \clbrdrr \brdrw4 \brdrcf1 \brdrs \trql \clvertalc \cellx15527 
+\intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \fs16 \cf1 \i0 
+}
+}\f3 \li0 \strike0 \ul0 \b0 \ql \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs16 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs16 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \fs16 \cf1 \i0 
+123
+}
+}\f3 \li0 \strike0 \ul0 \b0 \ql \fs16 \ri0 \cf1 \i0 \intbl \cell \row }}{
+{\trowd \itap0 \trleft0 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \clbrdrl \trql \clvertalc \cellx3571 
+\clpadt60 \clpadft3 \clpadr60 \clpadfr3 \trql \clvertalc \cellx15418 
+\intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs20 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs20 \cf1 \i0 
+Nombre de page(s) : 1
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs20 \ri0 \cf1 \i0 \intbl \cell \intbl 
+{\li0 \f3 \b0 \ql \ri0 \fs20 \cf1 \i0 
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs20 \cf1 \i0 
+Nombre d\rquote article(s) : 1
+}
+}\f3 \li0 \strike0 \ul0 \b0 \sa0 \ql \sb0 \fs20 \ri0 \cf1 \i0 \intbl \cell \row }}}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 1525c4a..20f8755 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2512,6 +2512,17 @@ DECLARE_RTFIMPORT_TEST(testTdf65642, "tdf65642.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(getParagraph(2), "PageNumberOffset"));
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf97035, "tdf97035.rtf")
+{
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+
+    // First cell width of the second row should be 2299
+    uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2299), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c3013f4..cc01274 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2294,10 +2294,16 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
             bRestored = true;
         }
 
-        // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): add a fake cell.
+        // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): resize the last cell
         const int MINLAY = 23; // sw/inc/swtypes.hxx, minimal possible size of frames.
         if ((m_nCellxMax - m_nTopLevelCurrentCellX) >= MINLAY)
-            dispatchValue(RTF_CELLX, m_nCellxMax);
+        {
+            auto pXValueLast = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblGridBase_gridCol, false);
+            auto pXValue = std::make_shared<RTFValue>(pXValueLast->getInt() + m_nCellxMax - m_nTopLevelCurrentCellX);
+            m_aStates.top().aTableRowSprms.eraseLast(NS_ooxml::LN_CT_TblGridBase_gridCol);
+            m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND);
+            m_nTopLevelCurrentCellX = m_nCellxMax;
+        }
 
         if (m_nTopLevelCells)
         {
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 3af3000..4abb812 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -127,6 +127,20 @@ bool RTFSprms::erase(Id nKeyword)
     return false;
 }
 
+bool RTFSprms::eraseLast(Id nKeyword)
+{
+    ensureCopyBeforeWrite();
+    for (RTFSprms::ReverseIterator_t i = m_pSprms->rbegin(); i != m_pSprms->rend(); ++i)
+    {
+        if (i->first == nKeyword)
+        {
+            m_pSprms->erase(std::next(i).base());
+            return true;
+        }
+    }
+    return false;
+}
+
 static RTFValue::Pointer_t getDefaultSPRM(Id const id)
 {
     switch (id)
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index 05b39cb..4f397e6 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -59,6 +59,7 @@ public:
     typedef ::std::shared_ptr<RTFSprms> Pointer_t;
     typedef std::pair<Id, RTFValue::Pointer_t> Entry_t;
     typedef std::vector<Entry_t>::iterator Iterator_t;
+    typedef std::vector<Entry_t>::reverse_iterator ReverseIterator_t;
     RTFSprms();
     RTFSprms(const RTFSprms& rSprms);
     ~RTFSprms();
@@ -67,6 +68,7 @@ public:
     /// Does the same as ->push_back(), except that it can overwrite or ignore existing entries.
     void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = RTFOverwrite::YES);
     bool erase(Id nKeyword);
+    bool eraseLast(Id nKeyword);
     /// Removes elements which are already in the reference set.
     /// Also insert default values to override attributes of style
     /// (yes, really; that's what Word does).


More information about the Libreoffice-commits mailing list