tdf#107104 DOCX drawingML import: fix invisible arrow shape

This is the drawingML equivalent of commit
3d9ebded13 (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.

Change-Id: I9600424520d0a3deecc711b44622eccc041a59da
Reviewed-on: https://gerrit.libreoffice.org/36927
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2017-04-25 09:25:34 +02:00
parent d496eab538
commit e6e5a68f52
5 changed files with 18 additions and 3 deletions

Binary file not shown.

View File

@@ -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,

View File

@@ -457,6 +457,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106492, "tdf106492.docx")
assertXPath(pXmlDoc, "//w:sectPr", 3);
}
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: */

View File

@@ -1199,8 +1199,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);
}

View File

@@ -536,6 +536,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