diff options
author | Adam Co <rattles2013@gmail.com> | 2013-07-25 18:45:20 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-07-26 10:40:16 +0200 |
commit | 6be2b0fbf9da9963ac18d33f145e06d684136a26 (patch) | |
tree | 29a87ae26e771a4a18106a6483ae5044acba329e /sw | |
parent | 0154460b49d4c46cfca52e2c78dec134c7948b5a (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')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo65718.docx | bin | 0 -> 62876 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 25 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 20 |
3 files changed, 38 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65718.docx b/sw/qa/extras/ooxmlexport/data/fdo65718.docx Binary files differnew file mode 100644 index 000000000000..0af4f9002573 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo65718.docx 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(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index d79897daeda6..16fc3b0cc6f3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2295,17 +2295,20 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size if ( aRelId.isEmpty() ) return; - m_pSerializer->startElementNS( XML_w, XML_drawing, - FSEND ); + m_pSerializer->startElementNS( XML_w, XML_drawing, FSEND ); + + const SvxLRSpaceItem pLRSpaceItem = pFrmFmt->GetLRSpace(false); + const SvxULSpaceItem pULSpaceItem = pFrmFmt->GetULSpace(false); + bool isAnchor = pFrmFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR; if( isAnchor ) { ::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList(); attrList->add( XML_behindDoc, pFrmFmt->GetOpaque().GetValue() ? "0" : "1" ); - attrList->add( XML_distT, "0" ); - attrList->add( XML_distB, "0" ); - attrList->add( XML_distL, "0" ); - attrList->add( XML_distR, "0" ); + attrList->add( XML_distT, OString::valueOf( TwipsToEMU( pULSpaceItem.GetUpper() ) ).getStr( ) ); + attrList->add( XML_distB, OString::valueOf( TwipsToEMU( pULSpaceItem.GetLower() ) ).getStr( ) ); + attrList->add( XML_distL, OString::valueOf( TwipsToEMU( pLRSpaceItem.GetLeft() ) ).getStr( ) ); + attrList->add( XML_distR, OString::valueOf( TwipsToEMU( pLRSpaceItem.GetRight() ) ).getStr( ) ); attrList->add( XML_simplePos, "0" ); attrList->add( XML_locked, "0" ); attrList->add( XML_layoutInCell, "1" ); @@ -2428,7 +2431,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size else { m_pSerializer->startElementNS( XML_wp, XML_inline, - XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", + XML_distT, OString::valueOf( TwipsToEMU( pULSpaceItem.GetUpper() ) ).getStr( ), + XML_distB, OString::valueOf( TwipsToEMU( pULSpaceItem.GetLower() ) ).getStr( ), + XML_distL, OString::valueOf( TwipsToEMU( pLRSpaceItem.GetLeft() ) ).getStr( ), + XML_distR, OString::valueOf( TwipsToEMU( pLRSpaceItem.GetRight() ) ).getStr( ), FSEND ); } // now the common parts |