include/oox/export/drawingml.hxx | 2 +- oox/source/export/drawingml.cxx | 15 ++++++++------- oox/source/export/shapes.cxx | 4 +++- 3 files changed, 12 insertions(+), 9 deletions(-)
New commits: commit b1ec4d7377ccc4facd46743ee63815fc5745afa2 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Tue Oct 25 01:51:25 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) Change-Id: Ie7a4e2b8a18bfddaeeb81425ae5f1de04140d43f diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 9305c01..765e137 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -187,7 +187,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( css::uno::Reference<css::drawing::XShape> rXShape ); + bool WriteCustomGeometry( css::uno::Reference<css::drawing::XShape> rXShape ); void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon ); void WriteFill( css::uno::Reference< css::beans::XPropertySet > xPropSet ); void WriteShapeStyle( css::uno::Reference< css::beans::XPropertySet > rXPropSet ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 319b791..b320eed 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2216,23 +2216,23 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b mpFS->endElementNS( XML_a, XML_prstGeom ); } -void DrawingML::WriteCustomGeometry( Reference< XShape > rXShape ) +bool DrawingML::WriteCustomGeometry( 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; } @@ -2264,7 +2264,7 @@ void DrawingML::WriteCustomGeometry( Reference< XShape > rXShape ) } if ( !aPairs.hasElements() ) - return; + return false; if ( !aSegments.hasElements() ) { @@ -2288,7 +2288,7 @@ void DrawingML::WriteCustomGeometry( 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 ); @@ -2450,10 +2450,11 @@ void DrawingML::WriteCustomGeometry( 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 9934bfa..087f15d 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -749,7 +749,9 @@ ShapeExport& ShapeExport::WriteCustomShape( 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 {
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits