include/oox/export/drawingml.hxx | 2 +- oox/source/export/drawingml.cxx | 15 ++++++++------- oox/source/export/shapes.cxx | 4 +++- sw/qa/extras/ooxmlexport/data/tdf103389.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 11 +++++++++++ 5 files changed, 23 insertions(+), 9 deletions(-)
New commits: commit bc5c51e547e8ea971f90003657509848cc358724 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Tue Oct 25 02:44:16 2016 +0000 tdf#103389: Resaving a DOCX document with two canvases leads to a broken file. Make custom shape export more robust. In case of the test document, WriteCustomGeometry is called, but this call does not export anything, and so we get a shape without any geometry in the DOCX file, which causes problem to MS Word. Reviewed-on: https://gerrit.libreoffice.org/30241 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit f7c61b08d526c79ecd1522dff79386059b6125e0) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport9.cxx Change-Id: Ie7a4e2b8a18bfddaeeb81425ae5f1de04140d43f Reviewed-on: https://gerrit.libreoffice.org/30242 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 10b5e95..dc1c06d 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -203,7 +203,7 @@ public: void WritePresetShape( const char* pShape ); void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const css::beans::PropertyValue& rProp ); - void WriteCustomGeometry( const css::uno::Reference<css::drawing::XShape>& rXShape ); + bool WriteCustomGeometry( const css::uno::Reference<css::drawing::XShape>& rXShape ); void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon ); void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index dfa46d7..bfbd078 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2278,23 +2278,23 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b mpFS->endElementNS( XML_a, XML_prstGeom ); } -void DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape ) +bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape ) { uno::Reference< beans::XPropertySet > aXPropSet; uno::Any aAny( rXShape->queryInterface(cppu::UnoType<beans::XPropertySet>::get())); if ( ! (aAny >>= aXPropSet) ) - return; + return false; try { aAny = aXPropSet->getPropertyValue( "CustomShapeGeometry" ); if ( !aAny.hasValue() ) - return; + return false; } catch( const ::uno::Exception& ) { - return; + return false; } @@ -2326,7 +2326,7 @@ void DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape ) } if ( !aPairs.hasElements() ) - return; + return false; if ( !aSegments.hasElements() ) { @@ -2350,7 +2350,7 @@ void DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape ) if ( nExpectedPairCount > aPairs.getLength() ) { SAL_WARN("oox", "Segments need " << nExpectedPairCount << " coordinates, but Coordinates have only " << aPairs.getLength() << " pairs."); - return; + return false; } mpFS->startElementNS( XML_a, XML_custGeom, FSEND ); @@ -2512,10 +2512,11 @@ void DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape ) mpFS->endElementNS( XML_a, XML_path ); mpFS->endElementNS( XML_a, XML_pathLst ); mpFS->endElementNS( XML_a, XML_custGeom ); + return true; } } } - + return false; } void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon ) diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index e389fc6..83c555e 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -744,7 +744,9 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) else if (bCustGeom) { WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV ); - WriteCustomGeometry( xShape ); + bool bSuccess = WriteCustomGeometry( xShape ); + if (!bSuccess) + WritePresetShape( sPresetShape ); } else // preset geometry { diff --git a/sw/qa/extras/ooxmlexport/data/tdf103389.docx b/sw/qa/extras/ooxmlexport/data/tdf103389.docx new file mode 100644 index 0000000..0ef80e6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103389.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index a7ad465..42f6474 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1126,6 +1126,17 @@ DECLARE_OOXMLEXPORT_TEST(testFlipAndRotateCustomShape, "flip_and_rotate.odt") #endif } +DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // No geometry was exported for the second canvas + // Check both canvases' geometry + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp/wps:spPr/a:prstGeom", "prst", "rect"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp/wps:spPr/a:prstGeom", "prst", "rect"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits