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

Justin Luth justin_luth at sil.org
Wed Sep 13 02:17:04 UTC 2017


 sw/qa/extras/ww8export/data/tdf75539_relativeWidth.doc |binary
 sw/qa/extras/ww8export/ww8export.cxx                   |   11 +++++++++++
 sw/source/filter/ww8/ww8graf2.cxx                      |    2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit ffc3358515799057e72379b76a1165c6ea5a9bd1
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue Sep 5 13:06:27 2017 -0400

    tdf#75539 ww8import: fix horizontalLine percentage
    
    The formula previously divided by 1000, which was a common
    dxaGoal width from MSO2003 (based on round-trip testing).
    But for the bug document, that formuala didn't work.
    
    An "assert (false)" with "make check" indicates that only
    unit test n757118.doc contains a percentage-derived width,
    and that test also has dxaGoal == 1000. So, my pool of
    test documents is pretty small, but it seems logical that
    this is a better formula since it fixes an obviously
    bad example, and explains why it "worked before".
    
    Change-Id: I7bf666e88e7e59e06bbfa3c0961fa8eabbc80310
    Reviewed-on: https://gerrit.libreoffice.org/41957
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Tested-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ww8export/data/tdf75539_relativeWidth.doc b/sw/qa/extras/ww8export/data/tdf75539_relativeWidth.doc
new file mode 100644
index 000000000000..ac811a8f3599
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf75539_relativeWidth.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 131c8e85b329..38f41d83bf49 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -261,6 +261,17 @@ xray ThisComponent.DrawPage.getByIndex(0).BoundRect
     CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf75539_relativeWidth, "tdf75539_relativeWidth.doc")
+{
+    //divide everything by 10 to give a margin of error for rounding etc.
+    sal_Int32 pageWidth = parseDump("/root/page[1]/body/infos/bounds", "width").toInt32()/10;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Page width", sal_Int32(9354/10), pageWidth);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("100% width line", pageWidth,   parseDump("/root/page[1]/body/txt[2]/Special", "nWidth").toInt32()/10);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("50% width line", pageWidth/2,  parseDump("/root/page[1]/body/txt[4]/Special", "nWidth").toInt32()/10);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("25% width line", pageWidth/4,  parseDump("/root/page[1]/body/txt[6]/Special", "nWidth").toInt32()/10);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("10% width line", pageWidth/10, parseDump("/root/page[1]/body/txt[8]/Special", "nWidth").toInt32()/10);
+}
+
 DECLARE_WW8EXPORT_TEST(testN757905, "n757905.doc")
 {
     // The problem was that the paragraph had only a single fly
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index df199a69f87a..0ab278d9dbb4 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -580,7 +580,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
                         aPic.mx = msword_cast<sal_uInt16>(
                             m_aSectionManager.GetPageWidth() -
                             m_aSectionManager.GetPageRight() -
-                            m_aSectionManager.GetPageLeft()) * relativeWidth / 1000;
+                            m_aSectionManager.GetPageLeft()) * relativeWidth / aPic.dxaGoal;
                         aPD = WW8PicDesc( aPic );
                         // This SetSnapRect() call adjusts the size of the
                         // object itself, no idea why it's this call (or even


More information about the Libreoffice-commits mailing list