summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-03-07 14:44:10 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-07 15:10:26 +0100
commit37cc7e7471ba3b11cefcb0218c27e2c745886a6d (patch)
tree95c10ba8670d79130fa682f05eab08fde1b1cc50
parentd5d7c7d3b281e1a9060d60bc4ac7738ae616f167 (diff)
DOCX import: handle points in ST_TwipsMeasure and ST_SignedTwipsMeasure
This fixes page size and margins in case of strict DOCX. Change-Id: I65894eeef191a0f4bd92d1fa69a17e820aae3a43
-rw-r--r--sw/qa/extras/ooxmlimport/data/strict.docxbin0 -> 11408 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx5
-rw-r--r--writerfilter/source/ooxml/model.xml2
4 files changed, 17 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/strict.docx b/sw/qa/extras/ooxmlimport/data/strict.docx
new file mode 100644
index 000000000000..41953981766e
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/strict.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4f384d8ea13b..2503c81509c8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1903,6 +1903,18 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.doc
CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex"));
CPPUNIT_ASSERT_EQUAL(OUString("MS Mincho"), getProperty<OUString>(xRun, "CharFontNameAsian"));
}
+
+DECLARE_OOXMLIMPORT_TEST(testStrict, "strict.docx")
+{
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+ // This was only 127, pt suffix was ignored, so this got parsed as twips instead of points.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(72 * 20)), getProperty<sal_Int32>(xPageStyle, "TopMargin"));
+ // This was only 1397, same issue
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(792 * 20)), getProperty<sal_Int32>(xPageStyle, "Height"));
+ // Text was missing, due to not handling the strict namespaces.
+ getParagraph(1, "Hello world!");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
index cb7f1b79c1de..6d227af1c7e0 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
@@ -670,7 +670,10 @@ OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(sal_uInt32 nValue)
OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const OUString& rValue)
{
- mnValue = rValue.toInt32();
+ if (rValue.endsWith("pt"))
+ mnValue = rValue.copy(0, rValue.getLength() - 2).toInt32() * 20;
+ else
+ mnValue = rValue.toInt32();
}
OOXMLUniversalMeasureValue::~OOXMLUniversalMeasureValue()
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 406609a11acc..0a84d4faf460 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -22996,7 +22996,7 @@
<attribute name="val" tokenid="ooxml:CT_TwipsMeasure_val" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/>
</resource>
- <resource name="ST_SignedTwipsMeasure" resource="Integer"/>
+ <resource name="ST_SignedTwipsMeasure" resource="UniversalMeasure"/>
<resource name="CT_SignedTwipsMeasure" resource="Value" tag="attribute">
<attribute name="val" tokenid="ooxml:CT_SignedTwipsMeasure_val" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/>