sw/qa/extras/ooxmlexport/data/fdo70838.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 57 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
New commits: commit 37aa85abd567363ec7ae699ff2b24403672ba874 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Fri Oct 25 09:56:26 2013 +0200 fdo#70838: Add unit test for docx export Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/6434 Change-Id: I631073180f973000c68533cd21b0b8447e5869e9 diff --git a/sw/qa/extras/ooxmlexport/data/fdo70838.docx b/sw/qa/extras/ooxmlexport/data/fdo70838.docx new file mode 100644 index 0000000..ede97f7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo70838.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 925da1b..30ed0f1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1647,6 +1647,63 @@ DECLARE_OOXML_TEST(testImageCrop, "ImageCrop.docx") CPPUNIT_ASSERT_EQUAL( sal_Int32( 2290 ), aGraphicCropStruct.Bottom ); } +DECLARE_OOXML_TEST(testFdo70838, "fdo70838.docx") +{ + // The problem was that VMLExport::Commit didn't save the correct width and height, + // and ImplEESdrWriter::ImplFlipBoundingBox made a mistake calculating the position + + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + + // get styles of the four shapes + OUString aStyles[4]; + aStyles[0] = getXPath( pXmlDocument, "/w:document/w:body/w:p/w:r/w:pict[1]/v:rect", "style"); + // original is: "position:absolute;margin-left:97.6pt;margin-top:165pt;width:283.4pt;height:141.7pt;rotation:285" + aStyles[1] = getXPath( pXmlDocument, "/w:document/w:body/w:p/w:r/w:pict[2]/v:rect", "style"); + // original is: "position:absolute;margin-left:97.6pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:255" + aStyles[2] = getXPath( pXmlDocument, "/w:document/w:body/w:p/w:r/w:pict[3]/v:rect", "style"); + // original is: "position:absolute;margin-left:97.5pt;margin-top:164.9pt;width:283.4pt;height:141.7pt;rotation:105" + aStyles[3] = getXPath( pXmlDocument, "/w:document/w:body/w:p/w:r/w:pict[4]/v:rect", "style"); + // original is: "position:absolute;margin-left:97.55pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:75" + + //check the size and position of each of the shapes + for( int i = 0; i < 4; ++i ) + { + CPPUNIT_ASSERT(!aStyles[i].isEmpty()); + + int nextTokenPos = 0; + do + { + OUString aStyleCommand = aStyles[i].getToken( 0, ';', nextTokenPos ); + CPPUNIT_ASSERT(!aStyleCommand.isEmpty()); + + OUString aStyleCommandName = aStyleCommand.getToken( 0, ':' ); + OUString aStyleCommandValue = aStyleCommand.getToken( 1, ':' ); + + if( aStyleCommandName.equals( "margin-left" ) ) + { + float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat(); + CPPUNIT_ASSERT_EQUAL(0, abs(97.6 - fValue)); + } + else if( aStyleCommandName.equals( "margin-top" ) ) + { + float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat(); + CPPUNIT_ASSERT_EQUAL(0, abs(165 - fValue)); + } + else if( aStyleCommandName.equals( "width" ) ) + { + float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat(); + CPPUNIT_ASSERT_EQUAL(0, abs(283.4 - fValue)); + } + else if( aStyleCommandName.equals( "height" ) ) + { + float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat(); + CPPUNIT_ASSERT_EQUAL(0, abs(141.7 - fValue)); + } + + } while( nextTokenPos != -1 ); + } +} + #endif CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits