summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-21 12:08:00 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-21 15:02:11 +0100
commit3aef7b3b3dba2d898f3a278e916166e7c3d87321 (patch)
tree13d8ec6c33a5d4e14db5623f4e755f7980f93505 /sw
parentcdfebf30946307998eb3965ad30bbcd34ce82b02 (diff)
drawingML export: fix position of wrapped shapes in DOCX
In case of DOCX, the DOCX wrapper around the drawingML fragment already contains the real position of the shape (which talks about paragraphs and other concepts which are unavailable in a spreadsheet / presentation), and the inner position should be 0, otherwise the shape is shifted towards the bottom right corner. Note that this only affects drawinglayer shapes in DOCX, Writer pictures are handled in sw, and those always had a 0,0 position in the inner drawingML fragment. Change-Id: I582b1ae64387b50ffb051e1f5017eab0e5d5ab34
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docxbin0 -> 17617 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx15
2 files changed, 15 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docx b/sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docx
new file mode 100644
index 000000000000..bb18ab38b3c0
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ae4ab8cd6f70..8bfc251cdfc1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -147,6 +147,7 @@ xmlNodeSetPtr Test::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
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("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main"));
+ xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture"));
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
return pXmlXpathObj->nodesetval;
}
@@ -2493,6 +2494,20 @@ DECLARE_OOXMLEXPORT_TEST(testDmlTextshape, "dml-textshape.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(1256), xShape->getPosition().Y);
}
+DECLARE_OOXMLEXPORT_TEST(testDrawinglayerPicPos, "drawinglayer-pic-pos.docx")
+{
+ // The problem was that the position of the picture was incorrect, it was shifted towards the bottom right corner.
+ xmlDocPtr pXmlDocument = parseExport("word/document.xml");
+ if (!pXmlDocument)
+ return;
+
+ OString aXPath("/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:xfrm/a:off");
+ // This was 720.
+ assertXPath(pXmlDocument, aXPath, "x", "0");
+ // This was 1828800.
+ assertXPath(pXmlDocument, aXPath, "y", "0");
+}
+
DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.docx")
{
xmlDocPtr pXmlDocument = parseExport("word/document.xml");