[Libreoffice-commits] core.git: oox/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jan 21 06:02:38 PST 2014
oox/source/export/drawingml.cxx | 10 +++++++++-
sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 15 +++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
New commits:
commit 3aef7b3b3dba2d898f3a278e916166e7c3d87321
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 21 12:08:00 2014 +0100
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
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 2cddbf5..f81cd91 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -714,7 +714,15 @@ void DrawingML::WriteTransformation( const Rectangle& rRect,
XML_rot, (nRotation % 21600000) ? I32S( nRotation ) : NULL,
FSEND );
- mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( MM100toEMU( rRect.Left() ) ), XML_y, IS( MM100toEMU( rRect.Top() ) ), FSEND );
+ sal_Int32 nLeft = rRect.Left();
+ sal_Int32 nTop = rRect.Top();
+ if (GetDocumentType() == DOCUMENT_DOCX && !m_xParent.is())
+ {
+ nLeft = 0;
+ nTop = 0;
+ }
+
+ mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( MM100toEMU( nLeft ) ), XML_y, IS( MM100toEMU( nTop ) ), FSEND );
mpFS->singleElementNS( XML_a, XML_ext, XML_cx, IS( MM100toEMU( rRect.GetWidth() ) ), XML_cy, IS( MM100toEMU( rRect.GetHeight() ) ), FSEND );
mpFS->endElementNS( nXmlNamespace, XML_xfrm );
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 0000000..bb18ab3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/drawinglayer-pic-pos.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ae4ab8c..8bfc251 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");
More information about the Libreoffice-commits
mailing list