summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-26 18:34:15 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-26 19:06:50 +0200
commit7f9b242331327c5c1b137b91861a6bb57bfb0ecc (patch)
tree14a2f24b8cc08a5d22054a84cd6c1b655aa9de5c
parentef58e10844dff60cd218306b059ec81d8421f961 (diff)
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
-rw-r--r--oox/source/drawingml/shape.cxx11
-rw-r--r--oox/source/export/drawingml.cxx6
-rw-r--r--sw/qa/extras/ooxmlexport/data/rot180-flipv.docxbin0 -> 15903 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx11
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx10
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx14
7 files changed, 39 insertions, 15 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 1276c9743a33..534317298501 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 0ca30540dc0e..066049858a4b 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 000000000000..2a8bb196759d
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/rot180-flipv.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 43ea66977dc1..c8e2470a18c4 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 fcb5c8a9a770..78fbb7ece004 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 4eeccd816c30..dae2b598cdfb 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 0c914afea90b..ce2b764785ea 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);