summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde PĂ©rez <jaragunde@igalia.com>2013-10-25 09:56:26 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-14 12:29:30 +0100
commit37aa85abd567363ec7ae699ff2b24403672ba874 (patch)
treeef9b601d4a03f7e1670c5b318bd511c2b1345388
parentcca8c8cf79e0d9bcfb8798de3948aa446317b08e (diff)
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
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo70838.docxbin0 -> 4103 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx57
2 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo70838.docx b/sw/qa/extras/ooxmlexport/data/fdo70838.docx
new file mode 100644
index 000000000000..ede97f7eac05
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo70838.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 925da1b93fc2..30ed0f17af57 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();