From b71901da42a0429ff759b96bc9dd7cfd1bd189ac Mon Sep 17 00:00:00 2001 From: Ravindra_Vidhate Date: Fri, 15 May 2015 14:35:40 +0530 Subject: tdf#68868: better handle xlsx with samecell anchor image Problem Description : In the bugzill attached file, a image is anchored to the cell, it is shown as stretched image after opening in the LO. The image anchor attribute and are having the same value. It means , , , tag values of from and to are the same. So this image will have width and height as 1. Although, this is very rare case, where from and to has the same attribute values. Eventhough, we tried to create such kind of EXCEL file but failed to do so. Solution : When twocellAnchor attributes of from and to has the same value, then hide the shape. If we avoid to add the shape, then the original image file will be shown as stretched. If we don't add it into the shape, the original image will not be preserved. Change-Id: I48ea1cffcdfb013cec115ef8df5401e532fd2efd --- sc/source/filter/oox/drawingfragment.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sc/source/filter/oox/drawingfragment.cxx') diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx index 967b0ff24dd0..d1824eccf04e 100644 --- a/sc/source/filter/oox/drawingfragment.cxx +++ b/sc/source/filter/oox/drawingfragment.cxx @@ -256,6 +256,7 @@ void DrawingFragment::onEndElement() if ( getCurrentElement() == XDR_TOKEN( twoCellAnchor ) ) mxShape->setRotation(0); EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( getDrawPageSize() ); + const bool bIsShapeVisible = mxAnchor->isAnchorValid(); if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) ) { // TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle) @@ -270,6 +271,9 @@ void DrawingFragment::onEndElement() mxShape->setSize(Size(aShapeRectEmu.Width, aShapeRectEmu.Height)); basegfx::B2DHomMatrix aTransformation; + if ( !bIsShapeVisible) + mxShape->setHidden(true); + mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, aTransformation, mxShape->getFillProperties(), &aShapeRectEmu32 ); /* Collect all shape positions in the WorksheetHelper base -- cgit