[Libreoffice-commits] core.git: oox/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Thu Oct 9 04:21:30 PDT 2014
oox/source/export/drawingml.cxx | 8 +++++++-
sw/qa/extras/ooxmlexport/data/crop-pixel.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 ++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
New commits:
commit e16b01a9e4e111b1267c4eec1f5d168e5c2b8e53
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 9 11:09:48 2014 +0200
drawingML export: fix <a:srcRect> if graphic's map mode is pixels
Change-Id: Idbe399648c60e39c61e2be09a77b0648f57d3347
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 4e1a0ce..f1ff69b 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
new file mode 100644
index 0000000..1ddb2ef
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/crop-pixel.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 279be00..3c0a592 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: */
More information about the Libreoffice-commits
mailing list