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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 3 08:22:24 PST 2014


 oox/source/drawingml/shape.cxx                    |   21 +++++++++++++--------
 oox/source/shape/WpgContext.cxx                   |    2 ++
 sw/qa/extras/ooxmlexport/data/relorientation.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx          |    8 ++++++++
 4 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit eb2b7d243dc75578c76b8e5801a63b9a93389bb7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 3 16:49:14 2014 +0100

    oox: fix handling of noop parent transformation from DOCX
    
    It seems that in Word, a zero parent transformation, like:
    
    <a:chOff x="0" y="0"/>
    <a:chExt cx="0" cy="0"/>
    
    means the child shapes will have an absolute position / size. We
    actually use this feature in the exporter, but so far the importer
    didn't handle this.
    
    Change-Id: I250784a3dddd23649e391b548fc128dfdf153614

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 46dedec..b42e27e 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -345,17 +345,22 @@ void Shape::addChildren(
 
     aChildTransformation.translate(-maChPosition.X, -maChPosition.Y);
     aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0));
-    aChildTransformation *= aTransformation;
+
+    // Child position and size is typically non-zero, but it's allowed to have
+    // it like that, and in that case Word ignores the parent transformation, it
+    // seems.
+    if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height)
+        aChildTransformation *= aTransformation;
 
     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n"
-             << aChildTransformation.get(0, 0)
-             << aChildTransformation.get(0, 1)
+             << aChildTransformation.get(0, 0) << " "
+             << aChildTransformation.get(0, 1) << " "
              << aChildTransformation.get(0, 2) << "\n"
-             << aChildTransformation.get(1, 0)
-             << aChildTransformation.get(1, 1)
-             << aChildTransformation.get(1, 2)
-             << aChildTransformation.get(2, 0)
-             << aChildTransformation.get(2, 1)
+             << aChildTransformation.get(1, 0) << " "
+             << aChildTransformation.get(1, 1) << " "
+             << aChildTransformation.get(1, 2) << "\n"
+             << aChildTransformation.get(2, 0) << " "
+             << aChildTransformation.get(2, 1) << " "
              << aChildTransformation.get(2, 2));
 
     std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx
index d66b518..8e6c8ea 100644
--- a/oox/source/shape/WpgContext.cxx
+++ b/oox/source/shape/WpgContext.cxx
@@ -22,6 +22,7 @@ WpgContext::WpgContext(ContextHandler2Helper& rParent)
     : ContextHandler2(rParent)
 {
     mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"));
+    mpShape->setWps(true);
 }
 
 WpgContext::~WpgContext()
@@ -56,6 +57,7 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken
     case XML_grpSp:
     {
         oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"));
+        pShape->setWps(true);
         return new oox::drawingml::ShapeGroupContext(*this, mpShape, pShape);
     }
     break;
diff --git a/sw/qa/extras/ooxmlexport/data/relorientation.docx b/sw/qa/extras/ooxmlexport/data/relorientation.docx
index d71148b..22a0453 100644
Binary files a/sw/qa/extras/ooxmlexport/data/relorientation.docx and b/sw/qa/extras/ooxmlexport/data/relorientation.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 23a8e6f..aab75ab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2175,6 +2175,14 @@ DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx")
     // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled.
     uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType());
+
+    // Right after import we get a rounding error: 8662 vs 8664.
+    if (m_bExported)
+    {
+        uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY);
+        // This was 2, due to incorrect handling of parent transformations inside DML groupshapes.
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width);
+    }
 }
 
 DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt")


More information about the Libreoffice-commits mailing list