Kaydet (Commit) 09d381ad authored tarafından Pallavi Jadhav's avatar Pallavi Jadhav Kaydeden (comit) Miklos Vajna

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
üst 4837353e
......@@ -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();
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment