diff options
author | Aron Budea <aron.budea@collabora.com> | 2017-02-28 07:28:30 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-01 07:43:36 +0000 |
commit | a3a0eac099831de6fd7c53b66f85b964e41a5a13 (patch) | |
tree | 44587564948ff8b43b461bdc4f067587ce7f18a8 | |
parent | 4c09fc48e9fa9114f32f2973090cbe75177cdd37 (diff) |
tdf#106001: Clamp CharScaleWidth outliers when exporting to DOCX
Atribute is of type ST_TextScale, which has to be
between 1 and 600.
Change-Id: I9b9cddc47d194f1364d91675c9b825752b2f5e06
Reviewed-on: https://gerrit.libreoffice.org/34713
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf106001-2.odt | bin | 0 -> 8159 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf106001-2.odt b/sw/qa/extras/ooxmlexport/data/tdf106001-2.odt Binary files differnew file mode 100644 index 000000000000..36d2650f4c18 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf106001-2.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index a97ee2f645f5..3ab81d2b5b97 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -231,6 +231,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106001, "tdf106001.docx") CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>( 100 ), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharScaleWidth" )); } +DECLARE_OOXMLEXPORT_TEST(testTdf106001_2, "tdf106001-2.odt") +{ + // In test ODT CharScaleWidth = 900, this was not changed upon OOXML export to stay in [1..600], now it's clamped to 600 + // Note: we disregard what's set in pPr / rPr and only care about r / rPr + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:w","val","600"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf103931, "tdf103931.docx") { uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a66ab0b35472..e5ce36a58bb8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6566,8 +6566,11 @@ void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines ) void DocxAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) { + // Clamp CharScaleWidth to OOXML limits ([1..600]) + const sal_Int16 nScaleWidth( std::max<sal_Int16>( 1, + std::min<sal_Int16>( rScaleWidth.GetValue(), 600 ) ) ); m_pSerializer->singleElementNS( XML_w, XML_w, - FSNS( XML_w, XML_val ), OString::number( rScaleWidth.GetValue() ).getStr(), FSEND ); + FSNS( XML_w, XML_val ), OString::number( nScaleWidth ).getStr(), FSEND ); } void DocxAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief ) |