sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 6 +++--- sw/source/filter/ww8/docxsdrexport.cxx | 4 ++-- writerfilter/source/dmapper/GraphicImport.cxx | 26 ++++++++++++++------------ 3 files changed, 19 insertions(+), 17 deletions(-)
New commits: commit c2485b4c38a574416dc3948fec85b0232109eb61 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 20 16:32:23 2014 +0100 DOCX export: handle wp14:sizeRelH/V relativeFrom=margin for shapes Change-Id: I913fe328376a246bf410512c4cfb018fc573094b diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1a83cf7..dc434a3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2303,8 +2303,8 @@ DECLARE_OOXMLEXPORT_TEST(testDmlShapeRelsize, "dml-shape-relsize.docx") xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) return; - // Relative size wasn't exported at all. - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "page"); + // Relative size wasn't exported all, then relativeFrom was "page", not "margin". + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin"); } DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeRelsize, "dml-groupshape-relsize.docx") @@ -2313,7 +2313,7 @@ DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeRelsize, "dml-groupshape-relsize.docx" if (!pXmlDoc) return; // Relative size wasn't imported. - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "page"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin"); } DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeParaspacing, "dml-groupshape-paraspacing.docx") diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 1211ef3..170be93 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -491,7 +491,7 @@ void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwF { // At the moment drawinglayer objects are always relative from page. pFS->startElementNS(XML_wp14, XML_sizeRelH, - XML_relativeFrom, "page", + XML_relativeFrom, (pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? "margin" : "page"), FSEND); pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND); pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT)); @@ -501,7 +501,7 @@ void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwF if (pSdrObject->GetRelativeHeight()) { pFS->startElementNS(XML_wp14, XML_sizeRelV, - XML_relativeFrom, "page", + XML_relativeFrom, (pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? "margin" : "page"), FSEND); pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND); pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT)); commit 418800e2e8d6b2c1b2723a7b066aca27abe8f5f8 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 20 15:36:57 2014 +0100 DOCX import: handle wp14:sizeRelH/V relativeFrom=margin No explicit code for this was necessary in case for TextFrames, but for drawinglayer shapes the default is relativeFrom=page. To keep things simpler, just always set these, regardless what the LO default is. Change-Id: I9f651d7cce4a12ce7f545e42656b92d078a74327 diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 2009bf5..3bccb1c 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -754,16 +754,17 @@ void GraphicImport::lcl_attribute(Id nName, Value & val) switch (nIntValue) { case NS_ooxml::LN_ST_SizeRelFromH_margin: + if (m_xShape.is()) + { + uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::FRAME)); + } break; case NS_ooxml::LN_ST_SizeRelFromH_page: if (m_xShape.is()) { - uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW); - if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) - { - uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); - xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME)); - } + uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME)); } break; default: @@ -777,16 +778,17 @@ void GraphicImport::lcl_attribute(Id nName, Value & val) switch (nIntValue) { case NS_ooxml::LN_ST_SizeRelFromV_margin: + if (m_xShape.is()) + { + uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::FRAME)); + } break; case NS_ooxml::LN_ST_SizeRelFromV_page: if (m_xShape.is()) { - uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW); - if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) - { - uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); - xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME)); - } + uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME)); } break; default: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits