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

Mark Hung marklh9 at gmail.com
Mon Apr 17 09:27:12 UTC 2017


 sw/qa/extras/uiwriter/data/tdf107025.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx       |   24 ++++++++++++++++++++++++
 sw/source/core/txtnode/fntcache.cxx      |    4 +++-
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit bdaf1708abeb1924f0cca21ec305638f4e0beb6c
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sun Apr 16 00:01:15 2017 +0800

    tdf#107025 advance only if grid is wider than font.
    
    EvalGridWidthAdd decide distance to advance by
    subtracting the grid width and the height of the CJK font
    of default style. Text cluttered if the value is negative
    on Windows or break into multiple lines if it overflow
    on Linux.
    
    Change-Id: I085d420ef168238cde2eac3fb129020d5e5608da
    Reviewed-on: https://gerrit.libreoffice.org/36568
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/qa/extras/uiwriter/data/tdf107025.odt b/sw/qa/extras/uiwriter/data/tdf107025.odt
new file mode 100755
index 000000000000..e5422aed33a5
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf107025.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 802fc179822f..e9513d1bbf06 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -229,6 +229,7 @@ public:
     void testTdf35021_tabOverMarginDemo();
     void testTdf106701_tabOverMarginAutotab();
     void testTdf104492();
+    void testTdf107025();
     void testTdf105417();
     void testTdf105625();
     void testTdf106736();
@@ -353,6 +354,7 @@ public:
     CPPUNIT_TEST(testTdf35021_tabOverMarginDemo);
     CPPUNIT_TEST(testTdf106701_tabOverMarginAutotab);
     CPPUNIT_TEST(testTdf104492);
+    CPPUNIT_TEST(testTdf107025);
     CPPUNIT_TEST(testTdf105417);
     CPPUNIT_TEST(testTdf105625);
     CPPUNIT_TEST(testTdf106736);
@@ -4434,6 +4436,28 @@ void SwUiWriterTest::testTdf104492()
     assertXPath(pXmlDoc, "//page", 3);
 }
 
+void SwUiWriterTest::testTdf107025()
+{
+    // Tdf107025 - characters advance with wrong distance, so that
+    // they are cluttered because of negative value or
+    // break into multiple lines because of overflow.
+    createDoc("tdf107025.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    // Verify the number of characters in each line.
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(1), getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[1]", "nLength").toInt32());
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(9), getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[2]", "nLength").toInt32());
+
+
+    CPPUNIT_ASSERT(!parseDump("(//Text[@nType='POR_TXT'])[1]", "nWidth").isEmpty());
+    CPPUNIT_ASSERT(!parseDump("(//Text[@nType='POR_TXT'])[2]", "nWidth").isEmpty());
+    // Width of the second line is expected to be 9 times of the first.
+    sal_Int32 nWidth1 = getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[1]", "nWidth").toInt32();
+    sal_Int32 nWidth2 = getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[2]", "nWidth").toInt32();
+
+    CPPUNIT_ASSERT( nWidth1 != 0 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(9), nWidth2 / nWidth1 );
+}
+
 void SwUiWriterTest::testTdf105417()
 {
     SwDoc* pDoc = createDoc("tdf105417.odt");
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index f31db54e71b2..db095f14aa49 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -87,7 +87,9 @@ long EvalGridWidthAdd( const SwTextGridItem *const pGrid, const SwDrawTextInfo &
     const SvxFontHeightItem &aDefaultFontItem = static_cast<const SvxFontHeightItem&>(aTmpSet.Get(RES_CHRATR_CJK_FONTSIZE));
 
     const SwDoc* pDoc = rInf.GetShell()->GetDoc();
-    const long nGridWidthAdd = GetGridWidth(*pGrid, *pDoc) - aDefaultFontItem.GetHeight();
+    const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, *pDoc);
+    const sal_uInt32 nFontHeight = aDefaultFontItem.GetHeight();
+    const long nGridWidthAdd = nGridWidth > nFontHeight ? nGridWidth - nFontHeight : 0;
     if( SwFontScript::Latin == rInf.GetFont()->GetActual() )
         return nGridWidthAdd / 2;
 


More information about the Libreoffice-commits mailing list