oox/source/drawingml/shape.cxx                  |   11 ++++++++---
 oox/source/export/drawingml.cxx                 |    6 ++++++
 sw/qa/extras/ooxmlexport/data/rot180-flipv.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |   11 +++++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx       |    2 +-
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx     |   10 +++++-----
 writerfilter/source/dmapper/GraphicImport.cxx   |   14 ++++++++------
 7 files changed, 39 insertions(+), 15 deletions(-)

New commits:
commit 7f9b242331327c5c1b137b91861a6bb57bfb0ecc
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Sep 26 18:34:15 2014 +0200

    DOCX drawingML import: fix remaining rotation / flip combinations
    
    With this, each rotation = 0 / 90 / 180 / 270 and flip = none /
    horizontal / vertical / horizontal+vertical combination (16 cases) are
    imported perfectly.
    
    Also adjust a few testcases -- now that in many cases we only set the
    position in oox, some rounding errors went away.
    
    Change-Id: I5567a7d6964775f2caf10a0e539f3eb84d10461e

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 1276c97..5343172 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -418,7 +418,9 @@ Reference< XShape > Shape::createAndInsert(
                             aServiceName == 
"com.sun.star.drawing.ConnectorShape" );
     bool bUseRotationTransform = ( !mbWps ||
             aServiceName == "com.sun.star.drawing.LineShape" ||
-            aServiceName == "com.sun.star.drawing.GroupShape" );
+            aServiceName == "com.sun.star.drawing.GroupShape" ||
+            mbFlipH ||
+            mbFlipV );
 
     basegfx::B2DHomMatrix aTransformation;
 
@@ -458,7 +460,10 @@ Reference< XShape > Shape::createAndInsert(
     if( maPosition.X != 0 || maPosition.Y != 0)
     {
         // if global position is used, add it to transformation
-        aTransformation.translate( maPosition.X, maPosition.Y );
+        if (mbWps && aParentTransformation.isIdentity())
+            aTransformation.translate( maPosition.X * 360, maPosition.Y * 360);
+        else
+            aTransformation.translate( maPosition.X, maPosition.Y );
     }
 
     aTransformation = aParentTransformation*aTransformation;
@@ -986,7 +991,7 @@ Reference< XShape > Shape::createAndInsert(
         // These can have a custom geometry, so position should be set here,
         // after creation but before custom shape handling, using the position
         // we got from the caller.
-        if (mbWps && aServiceName != "com.sun.star.text.TextFrame")
+        if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
             mxShape->setPosition(maPosition);
 
         if( bIsCustomShape )
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0ca3054..0660498 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1169,7 +1169,13 @@ void DrawingML::WriteShapeTransformation( Reference< 
XShape > rXShape, sal_Int32
     }
     if (!bSuppressRotation)
     {
+        // See SdrObjCustomShape::NbcRotate().
+        int nSwap = 0;
+        if (bFlipH)
+            nSwap ^= 1;
         if (bFlipV)
+            nSwap ^= 1;
+        if (nSwap)
         {
             nRotation=(nRotation+18000)%36000;
         }
diff --git a/sw/qa/extras/ooxmlexport/data/rot180-flipv.docx 
b/sw/qa/extras/ooxmlexport/data/rot180-flipv.docx
new file mode 100644
index 0000000..2a8bb19
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/rot180-flipv.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 43ea669..c8e2470 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -315,6 +315,17 @@ DECLARE_OOXMLEXPORT_TEST(testRot90Fliph, 
"rot90-fliph.docx")
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testRot180Flipv, "rot180-flipv.docx")
+{
+    // 180° rotation got lost after roundtrip.
+    if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+    {
+        assertXPath(pXmlDoc, "//a:xfrm", "flipV", "1");
+        // This attribute was completely missing.
+        assertXPath(pXmlDoc, "//a:xfrm", "rot", "10800000");
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index fcb5c8a..78fbb7e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -1048,7 +1048,7 @@ DECLARE_OOXMLEXPORT_TEST(testTableFloating, 
"table-floating.docx")
         // After import, table is inside a TextFrame.
         uno::Reference<beans::XPropertySet> xShape(getShape(1), 
uno::UNO_QUERY);
         // This was 0, should be the the opposite of (left margin + half of 
the border width).
-        CPPUNIT_ASSERT_EQUAL(sal_Int32(-198), getProperty<sal_Int32>(xShape, 
"HoriOrientPosition"));
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xShape, 
"HoriOrientPosition"));
         // Was 0 as well, should be the right margin.
         CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xShape, 
"RightMargin"));
     }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 4eeccd8..dae2b59 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -319,17 +319,17 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, 
"dml-groupshape-childpo
 
     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
     uno::Reference<drawing::XShape> xChildGroup(xGroup->getByIndex(1), 
uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2121), 
xChildGroup->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11338 : 11335), 
xChildGroup->getPosition().Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2122), 
xChildGroup->getPosition().X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), 
xChildGroup->getPosition().Y);
 
     xGroup.set(xChildGroup, uno::UNO_QUERY);
     xChildGroup.set(xGroup->getByIndex(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -1856 : -1858), 
xChildGroup->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11338 : 11335), 
xChildGroup->getPosition().Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), 
xChildGroup->getPosition().Y);
 
     xChildGroup.set(xGroup->getByIndex(1), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2121), 
xChildGroup->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 14028 : 14025), 
xChildGroup->getPosition().Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2122), 
xChildGroup->getPosition().X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 14026 : 14023), 
xChildGroup->getPosition().Y);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme, 
"dml-gradientfill-theme.docx")
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index 0c914af..ce2b764 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -363,17 +363,19 @@ public:
                 uno::makeAny(nVertOrient));
     }
 
-    void applyRelativePosition(uno::Reference< beans::XPropertySet > 
xGraphicObjectProperties) const
+    void applyRelativePosition(uno::Reference< beans::XPropertySet > 
xGraphicObjectProperties, bool bRelativeOnly = false) const
     {
         PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
-        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_POSITION),
-                uno::makeAny(nLeftPosition));
+        if (!bRelativeOnly)
+            
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_POSITION),
+                                                       
uno::makeAny(nLeftPosition));
         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_RELATION ),
                 uno::makeAny(nHoriRelation));
         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_PAGE_TOGGLE ),
                 uno::makeAny(bPageToggle));
-        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_POSITION),
-                uno::makeAny(nTopPosition));
+        if (!bRelativeOnly)
+            
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_POSITION),
+                                                       
uno::makeAny(nTopPosition));
         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_RELATION ),
                 uno::makeAny(nVertRelation));
     }
@@ -805,7 +807,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                             if (nRotation)
                                 xShapeProps->setPropertyValue("RotateAngle", 
uno::makeAny(nRotation));
                         }
-                        m_pImpl->applyRelativePosition(xShapeProps);
+                        m_pImpl->applyRelativePosition(xShapeProps, 
/*bRelativeOnly=*/true);
 
                         xShapeProps->setPropertyValue("SurroundContour", 
uno::makeAny(m_pImpl->bContour));
                         m_pImpl->applyMargins(xShapeProps);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to