sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 4 ++-- sw/qa/extras/ooxmlimport/data/tdf108350.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 10 ++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-)
New commits: commit 5471a5585cba925bb0dcb2dc41e03ad563998166 Author: Mike Kaganski <mike.kagan...@collabora.com> Date: Mon Jun 5 23:47:13 2017 +0300 tdf#108350: Use Carlito for DOCX import by default In OOXML (i.e. Word since 2007), the default document font is Calibri 11 pt. If a document doesn't contain font information, we should assume our metric-compatible equivalent Carlito to provide best layout match. A unit test included. An existing unit test (testN766487) was corrected to match the font size that Word uses (11; was 12 which doesn't match Word's size). Change-Id: I3040f235696282dc7a124cd83fb34a6d95a29a17 Reviewed-on: https://gerrit.libreoffice.org/38421 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 7fc5d19b2db3..ac7ba7838132 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -350,7 +350,7 @@ DECLARE_OOXMLEXPORT_TEST(testN766487, "n766487.docx") * oPara = oParas.nextElement * oRuns = oPara.createEnumeration * oRun = oRuns.nextElement - * xray oRun.CharHeight ' 12, was larger + * xray oRun.CharHeight ' 11, was larger * oPara = oParas.nextElement * xray oPara.ParaFirstLineIndent ' -635, was 0 */ @@ -363,7 +363,7 @@ DECLARE_OOXMLEXPORT_TEST(testN766487, "n766487.docx") uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); float fValue = 0; xPropertySet->getPropertyValue("CharHeight") >>= fValue; - CPPUNIT_ASSERT_EQUAL(12.f, fValue); + CPPUNIT_ASSERT_EQUAL(11.f, fValue); xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY); sal_Int32 nValue = 0; diff --git a/sw/qa/extras/ooxmlimport/data/tdf108350.docx b/sw/qa/extras/ooxmlimport/data/tdf108350.docx new file mode 100644 index 000000000000..b62b3e127838 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108350.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 15aebdab076b..60d74ea7572a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1287,6 +1287,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf76446, "tdf76446.docx") CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot); } +DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx") +{ + // For OOXML without explicit font information, font needs to be Carlito 11 pt, + // our bundled metrically compatible substitute for Calibri. + uno::Reference<text::XTextRange> xPara(getParagraph(1)); + uno::Reference<beans::XPropertySet> xRun(getRun(xPara, 1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Carlito"), getProperty<OUString>(xRun, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(double(11), getProperty<double>(xRun, "CharHeight")); +} + // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 5928fa4315c4..3abdb8d2b6f9 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -134,6 +134,24 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon SAL_WARN("writerfilter", "DomainMapper::DomainMapper: failed to initialize RDF metadata: " << rException.Message); } + if (eDocumentType == SourceDocumentType::OOXML) { + // tdf#108350 + // In OOXML (i.e. Word since 2007), the default document font is Calibri 11 pt. + // If a document doesn't contain font information, we should assume our + // metric-compatible equivalent Carlito to provide best layout match. + try + { + uno::Reference< beans::XPropertySet > xDefProps(GetTextFactory()->createInstance("com.sun.star.text.Defaults"), + uno::UNO_QUERY_THROW); + xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), css::uno::Any(OUString("Carlito"))); + xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), css::uno::Any(double(11))); + } + catch (const uno::Exception& rException) + { + SAL_WARN("writerfilter", "DomainMapper::DomainMapper: failed to initialize default font: " << rException.Message); + } + } + //import document properties try { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits