dev/null |binary sw/qa/extras/inc/swmodeltestbase.hxx | 9 ++++++++ sw/qa/extras/ooxmlexport/data/pagerelsize.docx |binary sw/qa/extras/ooxmlexport/data/rel-size-round.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 20 +++++++++++++++++++ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 19 ------------------ sw/source/filter/ww8/docxsdrexport.cxx | 23 ++++++++++++++++++++++ 7 files changed, 52 insertions(+), 19 deletions(-)
New commits: commit 62b63d9f4b99713d10021c068005f74694299302 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 6 17:54:01 2014 +0100 DOCX export: write wp14:sizeRelH and wp14:sizeRelV for Writer TextFrames Change-Id: I16ee2682b6fa8c7b194e442d6dbe1437e7743c60 diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index d6f7134..7a6f951 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -408,6 +408,15 @@ protected: return xShape; } + /// Get TextFrame by name + uno::Reference<drawing::XShape> getTextFrameByName(OUString aName) + { + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xNameAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(xNameAccess->getByName(aName), uno::UNO_QUERY); + return xShape; + } + void header() { std::cout << "File tested,Execution Time (ms)" << std::endl; diff --git a/sw/qa/extras/ooxmlimport/data/pagerelsize.docx b/sw/qa/extras/ooxmlexport/data/pagerelsize.docx similarity index 100% rename from sw/qa/extras/ooxmlimport/data/pagerelsize.docx rename to sw/qa/extras/ooxmlexport/data/pagerelsize.docx diff --git a/sw/qa/extras/ooxmlimport/data/rel-size-round.docx b/sw/qa/extras/ooxmlexport/data/rel-size-round.docx similarity index 100% rename from sw/qa/extras/ooxmlimport/data/rel-size-round.docx rename to sw/qa/extras/ooxmlexport/data/rel-size-round.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index a1cfd4c..3c1d9d8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2524,6 +2524,26 @@ DECLARE_OOXMLEXPORT_TEST(testDrawinglayerPicPos, "drawinglayer-pic-pos.docx") // This was 1828800. assertXPath(pXmlDocument, aXPath, "y", "0"); } + +DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx") +{ + // First textframe: width is relative from page, but not height. + uno::Reference<drawing::XShape> xTextFrame = getTextFrameByName("Frame1"); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation")); + + // Second textframe: height is relative from page, but not height. + xTextFrame = getTextFrameByName("Text Box 2"); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation")); +} + +DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx") +{ + // This was 9: 9.8 was imported as 9 instead of being rounded to 10. + CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight")); +} + DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.docx") { xmlDocPtr pXmlDocument = parseExport("word/document.xml"); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 3fbf9ee..91c5ede 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1756,25 +1756,6 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx") CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString()); } -DECLARE_OOXMLIMPORT_TEST(testPageRelSize, "pagerelsize.docx") -{ - // First textframe: width is relative from page, but not height. - uno::Reference<drawing::XShape> xTextFrame = getShape(1); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation")); - - // Second textframe: height is relative from page, but not height. - xTextFrame = getShape(2); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation")); -} - -DECLARE_OOXMLIMPORT_TEST(testRelSizeRound, "rel-size-round.docx") -{ - // This was 9: 9.8 was imported as 9 instead of being rounded to 10. - CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight")); -} - DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capitalization.docx") { // Capitalization inside a group shape was not imported diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index d0deeb5..cd2bd55 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -907,6 +907,29 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId) pFS->endElementNS(XML_wps, XML_wsp); pFS->endElementNS(XML_a, XML_graphicData); pFS->endElementNS(XML_a, XML_graphic); + + // Relative size of the Text Frame. + if (rSize.GetWidthPercent()) + { + pFS->startElementNS(XML_wp14, XML_sizeRelH, + XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"), + FSEND); + pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND); + pFS->writeEscaped(OUString::number(rSize.GetWidthPercent() * oox::drawingml::PER_PERCENT)); + pFS->endElementNS(XML_wp14, XML_pctWidth); + pFS->endElementNS(XML_wp14, XML_sizeRelH); + } + if (rSize.GetHeightPercent()) + { + pFS->startElementNS(XML_wp14, XML_sizeRelV, + XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"), + FSEND); + pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND); + pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT)); + pFS->endElementNS(XML_wp14, XML_pctHeight); + pFS->endElementNS(XML_wp14, XML_sizeRelV); + } + endDMLAnchorInline(&rFrmFmt); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits