summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-04-25 09:25:34 +0200
committerMichael Stahl <mstahl@redhat.com>2017-04-27 21:06:36 +0200
commit7d3baea4a726d6c0cf6cb0d6a8b2c83cef4f580d (patch)
tree3fbb72f35177a3ee46cb69e1c4ae8bc97b77d479
parent0db4d993a1c9d9f52e50d8a8e638213e02ddd17c (diff)
tdf#107104 DOCX drawingML import: fix invisible arrow shape
This is the drawingML equivalent of commit 3d9ebded1358395ed81db7a63629b046aec2aeac (Misc improvements for docx VML import, 2010-10-06), which made sure that shapes are never invisible just because they have zero height or width. For this particular bugdoc the Word-produced WW8 equivalent width is 20 twips, but let's be consistent with the VML import and just round up to 1 mm100. Also fix two existing tests that wanted to test something else, but implicitly asserted that some shapes indeed have zero width/height. (cherry picked from commit e6e5a68f52f4e06b73f0ece3a3886f3bfc30f56d) Change-Id: I9600424520d0a3deecc711b44622eccc041a59da Reviewed-on: https://gerrit.libreoffice.org/36953 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf107104.docxbin0 -> 15648 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport6.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx4
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx6
5 files changed, 18 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf107104.docx b/sw/qa/extras/ooxmlexport/data/tdf107104.docx
new file mode 100644
index 000000000000..2f8c87d8d3d5
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf107104.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 80f28f09875a..2891b3ff162f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -909,7 +909,9 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx")
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent","cx","0");
+ sal_Int32 nX = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent", "cx").toInt32();
+ // This was negative.
+ CPPUNIT_ASSERT(nX >= 0);
}
// part of tdf#93676, word gives the frame in the exported .docx a huge height,
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 99695f570cc7..9e00e77da235 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -243,6 +243,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103931, "tdf103931.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTextSections->getCount());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf107104, "tdf107104.docx")
+{
+ CPPUNIT_ASSERT(getShape(1)->getSize().Width > 0);
+ // This failed: the second arrow was invisible because it had zero height.
+ CPPUNIT_ASSERT(getShape(2)->getSize().Width > 0);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 65ca9029923c..989d5fb34f34 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1215,8 +1215,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xShape.is());
awt::Size aActualSize(xShape->getSize());
- // This was 3493: the vertical line was horizontal.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aActualSize.Width);
+ // Width was 3493: the vertical line was horizontal.
+ CPPUNIT_ASSERT(aActualSize.Width < aActualSize.Height);
CPPUNIT_ASSERT(aActualSize.Height > 0);
}
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index f9458182505f..991b1461ed8d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -543,6 +543,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
case NS_ooxml::LN_CT_PositiveSize2D_cy:
{
sal_Int32 nDim = oox::drawingml::convertEmuToHmm(nIntValue);
+ // drawingML equivalent of oox::vml::ShapeType::getAbsRectangle():
+ // make sure a shape isn't hidden implicitly just because it has
+ // zero height or width.
+ if (nDim == 0)
+ nDim = 1;
+
if( nName == NS_ooxml::LN_CT_PositiveSize2D_cx )
m_pImpl->setXSize(nDim);
else