summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2013-07-25 18:45:20 +0300
committerMiklos Vajna <vmiklos@suse.cz>2013-07-26 10:40:16 +0200
commit6be2b0fbf9da9963ac18d33f145e06d684136a26 (patch)
tree29a87ae26e771a4a18106a6483ae5044acba329e /sw/qa/extras/ooxmlexport
parent0154460b49d4c46cfca52e2c78dec134c7948b5a (diff)
fdo#65718 : fix for exporting of image distance from text
Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: Id33a9d491b2d89b05189b566641dadcef3176dc3
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo65718.docxbin0 -> 62876 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx25
2 files changed, 25 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65718.docx b/sw/qa/extras/ooxmlexport/data/fdo65718.docx
new file mode 100644
index 000000000000..0af4f9002573
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo65718.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 6fb397f96cf5..97015da69d1d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -41,6 +41,8 @@
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
+#define EMU_TO_MM100(EMU) (EMU / 360)
+
class Test : public SwModelTestBase
{
public:
@@ -101,6 +103,7 @@ public:
void testGrabBag();
void testFdo66781();
void testFdo60990();
+ void testFdo65718();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -180,6 +183,7 @@ void Test::run()
{"grabbag.docx", &Test::testGrabBag},
{"fdo66781.docx", &Test::testFdo66781},
{"fdo60990.odt", &Test::testFdo60990},
+ {"fdo65718.docx", &Test::testFdo65718},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -1063,6 +1067,27 @@ void Test::testFdo60990()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
}
+void Test::testFdo65718()
+{
+ // The problem was that the exporter always exported values of "0" for an images distance from text.
+ // the actual attributes where 'distT', 'distB', 'distL', 'distR'
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "TopMargin") );
+ CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "BottomMargin") );
+
+ // Going to do '+1' because the 'getProperty' return 318 (instead of 317.5)
+ // I think this is because it returns an integer, instead of a float.
+ // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360)
+ // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS)
+ // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318)
+ // So I had to add the hack of the '+1' to make the test-case pass
+ CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1 ), getProperty<sal_Int32>(xPropertySet, "LeftMargin") );
+ CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1), getProperty<sal_Int32>(xPropertySet, "RightMargin") );
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();