sw/qa/extras/ooxmlexport/data/test_GIF_ImageCrop.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 18 ++++++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 10 ++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-)
New commits: commit 09d381adbfba893331a07918c9ec9b3c58939dfb Author: Pallavi Jadhav <pallavi.jad...@synerzip.com> Date: Fri Nov 15 13:10:30 2013 +0530 Save Image-Crop information for GIF in docx Issue:- 1] When MS Office docx file containing cropped image is round tripped with LibreOffice 4.2, image looses its cropping effect. Implementation:- 1] Converted MAP unit, MAP_PIXEL to MAP_100TH_MM using PixelToLogic function. As for calculating EMU values for XML, we need Original Height and Width of an image in 100thMM(HMM) format. 2] Written Export Unit Test (GIF) to verify cropping parameters. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/6595 Change-Id: I54d7b08c96608a0cfca3c2f8833684c09848351c diff --git a/sw/qa/extras/ooxmlexport/data/test_GIF_ImageCrop.docx b/sw/qa/extras/ooxmlexport/data/test_GIF_ImageCrop.docx new file mode 100644 index 0000000..8fe7ff2 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/test_GIF_ImageCrop.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 23fe7cd..b7bdaef 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -94,6 +94,7 @@ protected: "math-escape.docx", "math-mso2k7.docx", "ImageCrop.docx", + "test_GIF_ImageCrop.docx" }; std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); @@ -1839,6 +1840,23 @@ DECLARE_OOXML_TEST(testParaAutoSpacing, "para-auto-spacing.docx") CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "beforeAutospacing").match("1")); CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "afterAutospacing").match("1")); } + +DECLARE_OOXML_TEST(testGIFImageCrop, "test_GIF_ImageCrop.docx") +{ + uno::Reference<drawing::XShape> image = getShape(1); + uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + + imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; + + // FIXME import test is disabled (we only check after import-export-import) + // The reason is that after import this is 1171 -- why? + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1265 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 4256 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1109 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1448 ), aGraphicCropStruct.Bottom ); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 70361fa..80c17e3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2689,8 +2689,7 @@ OString lcl_ConvertTransparency(const Color& rColor) } /* Writes <a:srcRect> tag back to document.xml if a file conatins a cropped image. - NOTE : It works only for images of type JPEG,EMF/WMF and BMP. - It does not work for images of type PNG and GIF. +* NOTE : Tested on images of type JPEG,EMF/WMF,BMP, PNG and GIF. */ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj ) { @@ -2704,6 +2703,13 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj ) ::com::sun::star::text::GraphicCrop aGraphicCropStruct; xPropSet->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; + const MapMode aMap100mm( MAP_100TH_MM ); + const MapMode& mapMode = GraphicObject::CreateGraphicObjectFromURL( sUrl ).GetPrefMapMode(); + if( mapMode.GetMapUnit() == MAP_PIXEL ) + { + aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, aMap100mm ); + } + if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) ) { double widthMultiplier = 100000.0/aOriginalSize.Width(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits