[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Feb 17 14:49:43 CET 2014


 sw/qa/extras/ooxmlexport/data/dml-shape-relsize.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx             |   10 ++++++++
 sw/source/filter/ww8/docxsdrexport.cxx               |   23 +++++++++++++++++++
 3 files changed, 33 insertions(+)

New commits:
commit 2d93aee9bf614f8db176a34b04c20eb8ae3beb9e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Feb 17 14:31:12 2014 +0100

    DOCX export: handle relative size of drawinglayer shapes
    
    Change-Id: If4548f7b7a530402158ce5f84febe4fe5eaf2184

diff --git a/sw/qa/extras/ooxmlexport/data/dml-shape-relsize.docx b/sw/qa/extras/ooxmlexport/data/dml-shape-relsize.docx
new file mode 100644
index 0000000..80ae02e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/dml-shape-relsize.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 5cc672f..86b1d84 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -153,6 +153,7 @@ xmlNodeSetPtr Test::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape"));
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"));
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"));
+    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"));
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main"));
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture"));
     xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships"));
@@ -2298,6 +2299,15 @@ DECLARE_OOXMLEXPORT_TEST(testDmlZorder, "dml-zorder.odt")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor", "relativeHeight", "2");
 }
 
+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");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 2919806..1211ef3 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -486,6 +486,29 @@ void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwF
     pFS->endElementNS(XML_a, XML_graphicData);
     pFS->endElementNS(XML_a, XML_graphic);
 
+    // Relative size of the drawing.
+    if (pSdrObject->GetRelativeWidth())
+    {
+        // At the moment drawinglayer objects are always relative from page.
+        pFS->startElementNS(XML_wp14, XML_sizeRelH,
+                            XML_relativeFrom, "page",
+                            FSEND);
+        pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
+        pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT));
+        pFS->endElementNS(XML_wp14, XML_pctWidth);
+        pFS->endElementNS(XML_wp14, XML_sizeRelH);
+    }
+    if (pSdrObject->GetRelativeHeight())
+    {
+        pFS->startElementNS(XML_wp14, XML_sizeRelV,
+                            XML_relativeFrom, "page",
+                            FSEND);
+        pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+        pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT));
+        pFS->endElementNS(XML_wp14, XML_pctHeight);
+        pFS->endElementNS(XML_wp14, XML_sizeRelV);
+    }
+
     m_rSdrExport.endDMLAnchorInline(pFrmFmt);
 }
 


More information about the Libreoffice-commits mailing list