summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2017-05-15 09:28:59 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-16 14:52:51 +0200
commitc7e31f492140a064d9c152583bda3d111c8bee83 (patch)
tree9650bdd393b76445c42c352bcc195a3a10aba769 /sw
parentb53c84af0a34aa9193b0e35363ca2ebe00c3e32c (diff)
tdf#107801 docx export: support w:kern
Writer only enables or disables pair kerning (autokern). Word uses a minimum font size to determine which characters to kern. Since these documents are round-tripping through Writer, and every size is kerned by Writer, the minimum size is forced to 1pt and the original minimum font size is lost. This is a followup to commit 38b0c24fa5cbb4246e03d77ac022dfdc9fdede03 for related tdf#105454 DOCX import: fix unwanted enabled-by-default kerning. Tested in Word 2003, 2007, 2013. Change-Id: I7678a544f455fd06bec5e7d864b5c27ab26bf6d3 Reviewed-on: https://gerrit.libreoffice.org/37574 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/kern.docx (renamed from sw/qa/extras/ooxmlimport/data/kern.docx)bin12832 -> 12832 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx18
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx7
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx7
4 files changed, 23 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/kern.docx b/sw/qa/extras/ooxmlexport/data/kern.docx
index b66130d38d03..b66130d38d03 100644
--- a/sw/qa/extras/ooxmlimport/data/kern.docx
+++ b/sw/qa/extras/ooxmlexport/data/kern.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 7370fe83da3d..73077b4fe40a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -91,10 +91,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106970, "tdf106970.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(4), "ParaBottomMargin"));
}
+DECLARE_OOXMLEXPORT_TEST(testKern, "kern.docx")
+{
+ CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(1), 1), "CharAutoKerning"));
+ // This failed: kerning was also enabled for the second paragraph.
+ CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(2), 1), "CharAutoKerning"));
+
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Default Style"), uno::UNO_QUERY);
+ //tdf107801: kerning normally isn't enabled by default for .docx
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be false", false, getProperty<bool>(xStyle, "CharAutoKerning"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.docx")
{
// the paragraph style should set table's text-flow break-before-page
CPPUNIT_ASSERT_EQUAL( 3, getPages() );
+
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Default Style"), uno::UNO_QUERY);
+ //tdf107801: kerning info wasn't exported previously.
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be true", true, getProperty<bool>(xStyle, "CharAutoKerning"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf104420, "tdf104420_lostParagraph.docx")
@@ -358,6 +373,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103651, "tdf103651.docx")
xTextField->getPropertyValue("Content") >>= sContent;
// Comment in the first paragraph should not have smiley ( 0xf04a ).
CPPUNIT_ASSERT_EQUAL( sal_Int32( -1 ) , sContent.indexOf( u'\xf04a' ));
+
+ // this document has a w:kern setting in the DocDefault character properties. Ensure it applies.
+ CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(1), 1), "CharAutoKerning"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf99227, "tdf99227.docx")
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a314b212b81a..87ccce61d9b5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -669,13 +669,6 @@ DECLARE_OOXMLIMPORT_TEST(testN820504, "n820504.docx")
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
}
-DECLARE_OOXMLIMPORT_TEST(testKern, "kern.docx")
-{
- CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(1), 1), "CharAutoKerning"));
- // This failed: kerning was also enabled for the second paragraph.
- CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(2), 1), "CharAutoKerning"));
-}
-
DECLARE_OOXMLIMPORT_TEST(testFdo43641, "fdo43641.docx")
{
uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 83dfe43b5372..f82667c6ed2c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6483,9 +6483,12 @@ void DocxAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
m_pSerializer->singleElementNS( XML_w, XML_b, FSNS( XML_w, XML_val ), "false", FSEND );
}
-void DocxAttributeOutput::CharAutoKern( const SvxAutoKernItem& )
+void DocxAttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern )
{
- SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::CharAutoKern()" );
+ // auto kerning is bound to a minimum font size in Word - but is just a boolean in Writer :-(
+ // kerning is based on half-point sizes, so 2 enables kerning for fontsize 1pt or higher. (1 is treated as size 12, and 0 is treated as disabled.)
+ const OString sFontSize = OString::number( (sal_uInt32) rAutoKern.GetValue() * 2 );
+ m_pSerializer->singleElementNS(XML_w, XML_kern, FSNS( XML_w, XML_val ), sFontSize.getStr(), FSEND );
}
void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )