diff options
-rw-r--r-- | oox/source/export/drawingml.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/crop-pixel.docx | bin | 0 -> 28063 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 |
3 files changed, 17 insertions, 1 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 4e1a0ceaa67b..f1ff69b6dfb1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1063,7 +1063,13 @@ void DrawingML::WritePattFill( Reference< XPropertySet > rXPropSet ) void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, const OUString& rURL ) { - Size aOriginalSize( GraphicObject::CreateGraphicObjectFromURL( rURL ).GetPrefSize() ); + GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(rURL); + Size aOriginalSize = aGraphicObject.GetPrefSize(); + const MapMode& rMapMode = aGraphicObject.GetPrefMapMode(); + + // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over. + if (rMapMode.GetMapUnit() == MAP_PIXEL) + aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MAP_100TH_MM)); if ( GetProperty( rXPropSet, "GraphicCrop" ) ) { diff --git a/sw/qa/extras/ooxmlexport/data/crop-pixel.docx b/sw/qa/extras/ooxmlexport/data/crop-pixel.docx Binary files differnew file mode 100644 index 000000000000..1ddb2efb93e4 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/crop-pixel.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 279be0030435..3c0a59200207 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -435,6 +435,16 @@ DECLARE_OOXMLEXPORT_TEST(testTextboxTable, "textbox-table.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount()); } +DECLARE_OOXMLEXPORT_TEST(testCropPixel, "crop-pixel.docx") +{ + // If map mode of the graphic is in pixels, then we used to handle original + // size of the graphic as mm100, but it was in pixels. + if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) + // This is 17667 in the original document (i.e. should be < 20000), but + // was 504666, so the image become invisible. + assertXPath(pXmlDoc, "//a:srcRect", "l", "19072"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |