sw/qa/extras/ww8export/data/tdf128700_relativeTableWidth.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx                        |   11 +++++++++++
 sw/source/filter/ww8/ww8par2.cxx                             |    3 ++-
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit cd77ab93b0f8e629c12d1b46d1be86e67dc93f0f
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Nov 13 21:34:27 2019 +0300
Commit:     Xisco FaulĂ­ <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 18 10:27:17 2019 +0100

    tdf#128700 ww8import: no relative width table if made into a fly
    
    This is a partial revert for LO 6.0's tdf#55528 commit
    e69473539a33da5450d3878999eba7f9bfb9e631
    
    Apparently Word tables can float without a frame, but in LO they
    need to wrapped in a frame? The relative size is supposed to be
    relative to the container they are in - so floated tables must
    not be assigned a relative value - otherwise the tablesize becomes
    relative to the custom frame that was created to float it.
    
    The fix was easy to make, but then trying to figure out whether
    to test using InLocalApo(), or just m_xSFlyPara took a lot of time.
    The documentation is sparse and unclear. In the end I settled on
    ignoring relative width if pFlyFormat exists, since certain
    conditions can cancel (bNoFly) a FloatingTableConversion.
    
    I tested what happens if a real frame is created and then a
    relatively sized table is dropped inside. I confirmed that relative
    SHOULD be relative to the frame. That case still works fine
    since it isn't considered an x_sFlyPara - I think because it actually
    is a textbox that the table is anchored onto. LO round-trips
    frame/table as textbox/table.
    
    Conclusion: tables inside of frames/textboxes MAY be relative,
    but if the table itself is floating (a WORD-ONLY feature)
    then it should not be relatively sized.
    
    Change-Id: I2b0bd525051a33b5606b79d2b26665d3edeb5357
    Reviewed-on: https://gerrit.libreoffice.org/82647
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit b58b78f5275aedbc8904b8dd5cf2f54919da7c8a)
    Reviewed-on: https://gerrit.libreoffice.org/82762
    (cherry picked from commit e13cebf480373f17c9161f17ebaed0286a72ca1f)
    Reviewed-on: https://gerrit.libreoffice.org/82818
    Reviewed-by: Xisco FaulĂ­ <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ww8export/data/tdf128700_relativeTableWidth.doc 
b/sw/qa/extras/ww8export/data/tdf128700_relativeTableWidth.doc
new file mode 100644
index 000000000000..9fa798ea32c7
Binary files /dev/null and 
b/sw/qa/extras/ww8export/data/tdf128700_relativeTableWidth.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index 1900d0569a03..e89d8c1c3063 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -65,6 +65,17 @@ DECLARE_WW8EXPORT_TEST(testTdf55528_relativeTableWidth, 
"tdf55528_relativeTableW
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Table relative width percent", 
sal_Int16(98), getProperty<sal_Int16>(xTable, "RelativeWidth"));
  }
 
+DECLARE_WW8EXPORT_TEST(testTdf128700_relativeTableWidth, 
"tdf128700_relativeTableWidth.doc")
+{
+    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);
+
+    // Since the table has been converted into a floating frame, the relative 
width either needed to be transferred
+    // onto the frame, or else just thrown out. Otherwise it becomes relative 
to the size of the frame.
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Floated table can't use relative width", 
sal_Int16(0), getProperty<sal_Int16>(xTable, "RelativeWidth"));
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf116436_tableBackground, 
"tdf116436_tableBackground.odt")
 {
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 15ba8ae2d95c..97369efb39bc 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -2481,7 +2481,8 @@ void WW8TabDesc::CreateSwTable()
     if( m_nMaxRight - m_nMinLeft > MINLAY * m_nDefaultSwCols )
     {
         SwFormatFrameSize aFrameSize(ATT_FIX_SIZE, m_nSwWidth);
-        if( m_nPercentWidth )
+        // Don't set relative width if the table has been converted into a 
floating frame
+        if ( m_nPercentWidth && (!m_pIo->m_xSFlyPara || 
!m_pIo->m_xSFlyPara->pFlyFormat) )
             aFrameSize.SetWidthPercent(m_nPercentWidth);
         m_pTable->GetFrameFormat()->SetFormatAttr(aFrameSize);
         m_aItemSet.Put(aFrameSize);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to