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

Justin Luth justin_luth at sil.org
Wed Oct 11 17:43:01 UTC 2017


 sw/qa/extras/ww8export/data/tdf55528_relativeTableWidth.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx                       |   11 +++++++
 sw/source/filter/ww8/ww8par2.cxx                            |   18 ++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit e69473539a33da5450d3878999eba7f9bfb9e631
Author: Justin Luth <justin_luth at sil.org>
Date:   Thu Sep 28 18:22:08 2017 +0300

    tdf#55528 ww8import: import table width percent
    
    Change-Id: Ifab8fa2df13e16cbfbd70b62912ca2a6245e16cc
    Reviewed-on: https://gerrit.libreoffice.org/42918
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ww8export/data/tdf55528_relativeTableWidth.doc b/sw/qa/extras/ww8export/data/tdf55528_relativeTableWidth.doc
new file mode 100755
index 000000000000..367f7873d75f
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf55528_relativeTableWidth.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index cc6e3f14c5c6..191d4b940e10 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -52,6 +52,17 @@ DECLARE_WW8EXPORT_TEST(testTdf41542_borderlessPadding, "tdf41542_borderlessPaddi
     CPPUNIT_ASSERT_EQUAL( 3, getPages() );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf55528_relativeTableWidth, "tdf55528_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);
+
+if ( !mbExported )
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Table relative width percent", sal_Int16(98), getProperty<sal_Int16>(xTable, "RelativeWidth"));
+ }
+
 DECLARE_WW8EXPORT_TEST(testTdf37153, "tdf37153_considerWrapOnObjPos.doc")
 {
     CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index f30b6e9632c7..574db30c1200 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -169,6 +169,7 @@ class WW8TabDesc
     short m_nMaxRight;
     short m_nSwWidth;
     short m_nPreferredWidth;
+    short m_nPercentWidth;
 
     bool m_bOk;
     bool m_bClaimLineFormat;
@@ -1847,6 +1848,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
     m_nMaxRight(0),
     m_nSwWidth(0),
     m_nPreferredWidth(0),
+    m_nPercentWidth(0),
     m_bOk(true),
     m_bClaimLineFormat(false),
     m_eOri(text::HoriOrientation::NONE),
@@ -1922,6 +1924,15 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
                         const sal_uInt8 b2 = pParams[2];
                         if (b0 == 3) // Twips
                             m_nPreferredWidth = b2 * 0x100 + b1;
+                        else if (b0 == 2) // percent in fiftieths of a percent
+                        {
+                            m_nPercentWidth = (b2 * 0x100 + b1);
+                            // MS documentation: non-negative, and 600% max
+                            if ( m_nPercentWidth >= 0 && m_nPercentWidth <= 30000 )
+                                m_nPercentWidth *= .02;
+                            else
+                                m_nPercentWidth = 100;
+                        }
                         }
                         break;
                     case sprmTTextFlow:
@@ -2537,8 +2548,11 @@ void WW8TabDesc::CreateSwTable()
     // total width of table
     if( m_nMaxRight - m_nMinLeft > MINLAY * m_nDefaultSwCols )
     {
-        m_pTable->GetFrameFormat()->SetFormatAttr(SwFormatFrameSize(ATT_FIX_SIZE, m_nSwWidth));
-        m_aItemSet.Put(SwFormatFrameSize(ATT_FIX_SIZE, m_nSwWidth));
+        SwFormatFrameSize aFrameSize(ATT_FIX_SIZE, m_nSwWidth);
+        if( m_nPercentWidth )
+            aFrameSize.SetWidthPercent(m_nPercentWidth);
+        m_pTable->GetFrameFormat()->SetFormatAttr(aFrameSize);
+        m_aItemSet.Put(aFrameSize);
     }
 
     SvxFrameDirectionItem aDirection(


More information about the Libreoffice-commits mailing list