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

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 29 10:58:24 UTC 2017


 sw/qa/extras/rtfexport/data/tdf104937.rtf        |   42 +++++++++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx             |   14 +++++++
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx |    7 +++
 3 files changed, 62 insertions(+), 1 deletion(-)

New commits:
commit b5d67cdd697c1b094b7e0622a2f4a06c3499f3d0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 29 09:04:49 2017 +0200

    tdf#104937 RTF import: \trwWidthA is an absolute value
    
    Not a relative one, so similar to \cellx need to convert these before
    sending the value to dmapper (which expects an OOXML value, which is
    always relative).
    
    The result of the correct type is that the relative width of the last
    cell in the table row is smaller, so other cells are wider -> they now
    reach the expected width.
    
    (cherry picked from commit e6ec0794858df1444f43659b568119bf126a90e6)
    
    Change-Id: If282eb9a5ec644b38e552b5a66fc64a93538f216
    Reviewed-on: https://gerrit.libreoffice.org/41676
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfexport/data/tdf104937.rtf b/sw/qa/extras/rtfexport/data/tdf104937.rtf
new file mode 100644
index 000000000000..d2d0c2c94903
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf104937.rtf
@@ -0,0 +1,42 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\fonttbl
+{\f0\fbidi \froman\fcharset0\fprq2 Times New Roman;}
+{\f2\fbidi \fmodern\fcharset0\fprq1 Courier New;}
+}
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;
+\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red255\green255\blue255;}
+\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect \widowctrl\ftnbj\aenddoc\trackmoves0\trackformatting1\donotembedsysfont0\relyonvml0\donotembedlingdata1\grfdocevents0\validatexml0\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\rsidroot3872472 \fet0\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\sectdefaultcl\sftnbj
+\ltrrow\pard\plain \ltrpar\ql \li0\ri0\sa100\widctlpar\intbl\wrapdefault\faauto\rin0\lin0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
+\fs22\lang1033\langfe1033\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \ab\af2\afs20 \ltrch\fcs0 \b\f2\fs20\insrsid11621749 \hich\af2\dbch\af31505\loch\f2
+30.06.2011\cell }
+\pard \ltrpar\ql \li0\ri0\sa200\sl276\slmult1
+\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0
+{\rtlch\fcs1 \af2\afs20 \ltrch\fcs0 \f2\fs20\insrsid11621749 \trowd\cellx16330\row
+\ltrrow}
+\trowd \irow2\irowband2\ltrrow\ts11\trleft0\trftsWidth3\trwWidth16330\trftsWidthB3\trftsWidthA3\trwWidthA8460\tblrsid3872472\tblind0\tblindtype3
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth70\clshdrawnil \cellx70
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth180\clshdrawnil \cellx250
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth1260\clshdrawnil \cellx1510
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth960\clshdrawnil \cellx2470
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth1920\clshdrawnil \cellx4390
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth1320\clshdrawnil \cellx5710
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth1320\clshdrawnil \cellx7030
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth840\clshdrawnil \cellx7870
+\pard \ltrpar\ql \li0\ri0\sb100\sa100\widctlpar\intbl\wrapdefault\faauto\rin0\lin0 {\rtlch\fcs1 \af2\afs20 \ltrch\fcs0 \f2\fs20\insrsid3872472 \cell }
+\pard \ltrpar\ql \li60\ri0\sb100\sa100\widctlpar\intbl\wrapdefault\faauto\rin0\lin60 \cbpat2 \cell
+\pard \ltrpar\ql \li0\ri0\sb100\sa100\widctlpar\intbl\wrapdefault\faauto\rin0\lin0 \cbpat2 {\b\f2\fs20\cf8\insrsid3872472 \hich\af2\dbch\af31505\loch\f2 Datum\cell }
+\pard \ltrpar\ql \li60\ri0\sb100\sa100\widctlpar\intbl\wrapdefault\faauto\rin0\lin60 \cbpat2 {\b\f2\fs20\cf8\insrsid3872472 \hich\af2\dbch\af31505\loch\f2 Stunden\cell
+\hich\af2\dbch\af31505\loch\f2 PSP-Element\cell
+\hich\af2\dbch\af31505\loch\f2 Genehmiger\cell
+\hich\af2\dbch\af31505\loch\f2 GenDatum\cell
+\hich\af2\dbch\af31505\loch\f2 LstArt\cell }
+\pard \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0
+{\rtlch\fcs1 \af2\afs20 \ltrch\fcs0 \f2\fs20\insrsid3872472 \trowd \irow2\irowband2\ltrrow\ts11\trleft0\trftsWidth3\trwWidth16330\trftsWidthB3\trftsWidthA3\trwWidthA8460\tblrsid3872472\tblind0\tblindtype3
+\clvertalt\cltxlrtb\clftsWidth3\clwWidth70\clshdrawnil \cellx70\clvertalt\cltxlrtb\clftsWidth3\clwWidth180\clshdrawnil \cellx250\clvertalt
+\cltxlrtb\clftsWidth3\clwWidth1260\clshdrawnil \cellx1510\clvertalt\cltxlrtb\clftsWidth3\clwWidth960\clshdrawnil \cellx2470\clvertalt\cltxlrtb\clftsWidth3\clwWidth1920\clshdrawnil \cellx4390\clvertalt\cltxlrtb\clftsWidth3\clwWidth1320\clshdrawnil \cellx5710\clvertalt\cltxlrtb\clftsWidth3\clwWidth1320\clshdrawnil \cellx7030\clvertalt\cltxlrtb\clftsWidth3\clwWidth840\clshdrawnil \cellx7870
+\row \ltrrow}
+\pard \ltrpar
+\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11621749 \par }
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index b31a66a30f6e..db9ea695bb1d 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1211,6 +1211,20 @@ DECLARE_RTFEXPORT_TEST(testTdf107620, "tdf107620.docx")
     CPPUNIT_ASSERT(!bAddParaTableSpacing);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf104937, "tdf104937.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);
+    uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+    auto aSeparators = getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators");
+    // First table's second row had 9 cells (so 8 separators).
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), aSeparators.getLength());
+    // This was 3174, i.e. last cell was wider than expected, while others were
+    // narrower.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4651), aSeparators[7].Position);
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
 {
     // These were 176 (100 twips), as \htmautsp was parsed too late.
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index 09b9b6c9c5ed..e7b09b7a5f92 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -236,9 +236,14 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
         m_bAfterCellBeforeRow = false;
         if (m_aStates.top().nTableRowWidthAfter > 0)
         {
+            // nTableRowWidthAfter is an absolute value, gridCol wants a
+            // relative value, so count the delta from the last cellx.
+            int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES == m_aStates.top().eDestination) ? m_nNestedCurrentCellX : m_nTopLevelCurrentCellX);
+            int nCellX = m_aStates.top().nTableRowWidthAfter - rCurrentCellX;
+
             // Add fake cellx / cell, RTF equivalent of
             // OOXMLFastContextHandlerTextTableRow::handleGridAfter().
-            auto pXValue = std::make_shared<RTFValue>(m_aStates.top().nTableRowWidthAfter);
+            auto pXValue = std::make_shared<RTFValue>(nCellX);
             m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND);
             dispatchSymbol(RTF_CELL);
             m_aStates.top().nTableRowWidthAfter = 0;


More information about the Libreoffice-commits mailing list