diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2016-10-25 02:44:16 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-10-25 07:41:00 +0000 |
commit | bc5c51e547e8ea971f90003657509848cc358724 (patch) | |
tree | 59552fa71e7b846daa4f684020d6c029bf2a734b /oox | |
parent | 55840d90c43d0ba6db4a9cda4af648df0776749b (diff) |
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.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@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 <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 15 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index dfa46d7d1699..bfbd078ce83e 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 e389fc6db416..83c555e70c48 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 { |