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

Justin Luth justin_luth at sil.org
Fri May 19 07:16:55 UTC 2017


 sw/qa/extras/ww8export/data/testTdf107931_KERN_DocEnabled_disabledDefStyle.doc |binary
 sw/qa/extras/ww8export/data/testTdf107931_KERN_enabledDefStyle.doc             |binary
 sw/qa/extras/ww8export/ww8export2.cxx                                          |   28 ++++++++++
 sw/source/filter/ww8/ww8par6.cxx                                               |   11 ++-
 4 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit 8a01fc2f505acc6ed9af5ba18049131225baad30
Author: Justin Luth <justin_luth at sil.org>
Date:   Thu May 18 16:59:09 2017 +0300

    tdf#107931 ww8import: kern marker MAY indicate disabled kerning.
    
    The simple presence of a FontKern SPRM was assumed to mean
    that kerning was enabled instead of reading the value
    passed by the parameter. However, if the style's default
    is to enable kerning, then SPRMs must indicate zero
    in order to disable it in non-default formatting.
    
    This commit will be food for reporting false regressions.
    Just because text no longer fits in the space that it used
    to doesn’t make this a regression. Don’t blame this commit
    UNLESS the character or style’s “Position” “Pair Kerning”
    setting is incorrect. In MSWord this is a “Font” “Advanced”
    Kerning setting. This kern bug will have hidden lots of other
    spacing related problems that are unrelated to this commit.
    
    Related to tdf#105454 which did something similar for .docx.
    
    Change-Id: Ie27b5a342ffc1431e1c5ee0a7b057fdb11e4e4e3
    Reviewed-on: https://gerrit.libreoffice.org/37781
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ww8export/data/testTdf107931_KERN_DocEnabled_disabledDefStyle.doc b/sw/qa/extras/ww8export/data/testTdf107931_KERN_DocEnabled_disabledDefStyle.doc
new file mode 100644
index 000000000000..101b02a0b679
Binary files /dev/null and b/sw/qa/extras/ww8export/data/testTdf107931_KERN_DocEnabled_disabledDefStyle.doc differ
diff --git a/sw/qa/extras/ww8export/data/testTdf107931_KERN_enabledDefStyle.doc b/sw/qa/extras/ww8export/data/testTdf107931_KERN_enabledDefStyle.doc
new file mode 100644
index 000000000000..35f6371fbc54
Binary files /dev/null and b/sw/qa/extras/ww8export/data/testTdf107931_KERN_enabledDefStyle.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index bb70ccff0be0..98116014f8d4 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -47,6 +47,34 @@ DECLARE_WW8EXPORT_TEST(testTdf49102_mergedCellNumbering, "tdf49102_mergedCellNum
     CPPUNIT_ASSERT_EQUAL( OUString("2."), parseDump("/root/page/body/tab/row[4]/cell/txt/Special[@nType='POR_NUMBER']", "rText") );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf107931_KERN_DocEnabled_disabledDefStyle, "testTdf107931_KERN_DocEnabled_disabledDefStyle.doc")
+{
+    // Paragraph 3: the default style has kerning disabled
+    CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(3), 1), "CharAutoKerning"));
+    // Paragraph 4: style with kerning disabled
+    CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(4), 1), "CharAutoKerning"));
+    // Paragraph 5: style with kerning enabled
+    CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(5), 1), "CharAutoKerning"));
+    // Paragraph 6: directly applied character properties: kerning disabled
+    CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(6), 1), "CharAutoKerning"));
+    // Paragraph 7: directly applied character properties: kerning enabled
+    CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(7), 1), "CharAutoKerning"));
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf107931_KERN_enabledDefStyle, "testTdf107931_KERN_enabledDefStyle.doc")
+{
+    // Paragraph 3: the default style has kerning enabled
+    CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(3), 1), "CharAutoKerning"));
+    // Paragraph 4: style with kerning disabled
+    CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(4), 1), "CharAutoKerning"));
+    // Paragraph 5: style with kerning enabled
+    CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(5), 1), "CharAutoKerning"));
+    // Paragraph 6: directly applied character properties: kerning disabled
+    CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(6), 1), "CharAutoKerning"));
+    // Paragraph 7: directly applied character properties: kerning enabled
+    CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(7), 1), "CharAutoKerning"));
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.doc")
 {
     // the paragraph style should set table's text-flow break-before-page
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index e62807df07ad..e0af6f6d076b 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3915,12 +3915,15 @@ void SwWW8ImplReader::Read_Kern( sal_uInt16, const sal_uInt8* pData, short nLen
     NewAttr( SvxKerningItem( nKern, RES_CHRATR_KERNING ) );
 }
 
-void SwWW8ImplReader::Read_FontKern( sal_uInt16, const sal_uInt8* , short nLen )
+void SwWW8ImplReader::Read_FontKern( sal_uInt16, const sal_uInt8* pData, short nLen )
 {
-    if (nLen < 0) // end of attribute
+    if (nLen < 2) // end of attribute
+    {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_AUTOKERN );
-    else
-        NewAttr(SvxAutoKernItem(true, RES_CHRATR_AUTOKERN));
+        return;
+    }
+    sal_Int16 nAutoKern = SVBT16ToShort( pData );    // Kerning in Twips
+    NewAttr(SvxAutoKernItem((bool)nAutoKern, RES_CHRATR_AUTOKERN));
 }
 
 void SwWW8ImplReader::Read_CharShadow(  sal_uInt16, const sal_uInt8* pData, short nLen )


More information about the Libreoffice-commits mailing list