[Libreoffice-commits] core.git: sw/qa writerfilter/source

Guillaume Smaha guillaume.smaha at gmail.com
Thu Jan 14 23:34:58 PST 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 6f2ce5c31708e5914d6d17d69b45f15a4429f8e3
Author: Guillaume Smaha <guillaume.smaha at gmail.com>
Date:   Tue Jan 12 17:00:39 2016 +0100

    Fix tdf#97035 - FILEOPEN: RTF wrong cell width
    
    Change-Id: Ifd31ab1672261644a00a32f3a8632dd0dcb33825
    Reviewed-on: https://gerrit.libreoffice.org/21382
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>
    Tested-by: jan iversen <jani at documentfoundation.org>

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 c3edad9..1cb27c6b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2473,6 +2473,17 @@ DECLARE_RTFIMPORT_TEST(testLandscape, "landscape.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape"));
 }
 
+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 938e92a..9bd58a7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2273,10 +2273,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 4e8768b..e19d27e 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -124,6 +124,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 e05ef78..79b6b38 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -56,6 +56,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();
@@ -64,6 +65,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