oox/source/drawingml/customshapeproperties.cxx | 6 ++-- oox/source/drawingml/shape.cxx | 19 +++++++++++-- sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 35 +++++++++++++++++++------ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 29 ++++++++++++++++++++ sw/source/filter/ww8/docxsdrexport.cxx | 8 ++--- 5 files changed, 79 insertions(+), 18 deletions(-)
New commits: commit 1393ba60b1eb43b55820f74c393da04308221d97 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Apr 14 18:53:34 2014 +0200 fdo#70838: fix rotation transformation in DML exporter This patch fixes an error in commit c6ff03f37a6898f50a5ca07152168fb4fe911e05. And now that fdo#75722 is fixed, I completed the existing unit test for this bug with absolute position checks. Change-Id: I76b4fa046db9b946fd23194e91686ffa4fcb5362 diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 5f5ecf9..674b496 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -503,16 +503,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70838, "fdo70838.docx") aYPos[2] = getXPathContent(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32(); aYPos[3] = getXPathContent(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32(); - // TODO: compare values with a reference value extracted from the original document - // depends on fdo#75722 // certain degree of error is tolerated due to rounding in unit conversions - CPPUNIT_ASSERT(abs(aXPos[0] - aXPos[1]) < 1000); - CPPUNIT_ASSERT(abs(aXPos[1] - aXPos[2]) < 1000); - CPPUNIT_ASSERT(abs(aXPos[2] - aXPos[3]) < 1000); + CPPUNIT_ASSERT(abs(1239520 - aXPos[0]) < 1000); + CPPUNIT_ASSERT(abs(1239520 - aXPos[1]) < 1000); + CPPUNIT_ASSERT(abs(1238250 - aXPos[2]) < 1000); + CPPUNIT_ASSERT(abs(1238885 - aXPos[3]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[0] - aYPos[1]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[1] - aYPos[2]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[2] - aYPos[3]) < 1000); + CPPUNIT_ASSERT(abs(2095500 - aYPos[0]) < 1000); + CPPUNIT_ASSERT(abs(2094865 - aYPos[1]) < 1000); + CPPUNIT_ASSERT(abs(2094230 - aYPos[2]) < 1000); + CPPUNIT_ASSERT(abs(2094865 - aYPos[3]) < 1000); sal_Int32 aHSize[4], aVSize[4]; aHSize[0] = getXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32(); @@ -586,6 +586,25 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70838, "fdo70838.docx") } while( nextTokenPos != -1 ); } + + // Check shape objects + + awt::Point aPos[4]; + aPos[0] = getShape(1)->getPosition(); + aPos[1] = getShape(2)->getPosition(); + aPos[2] = getShape(3)->getPosition(); + aPos[3] = getShape(4)->getPosition(); + + // certain degree of error is tolerated due to rounding in unit conversions + CPPUNIT_ASSERT(abs(4734 - aPos[0].X) < 10); + CPPUNIT_ASSERT(abs(4734 - aPos[1].X) < 10); + CPPUNIT_ASSERT(abs(4731 - aPos[2].X) < 10); + CPPUNIT_ASSERT(abs(4733 - aPos[3].X) < 10); + + CPPUNIT_ASSERT(abs(2845 - aPos[0].Y) < 10); + CPPUNIT_ASSERT(abs(2843 - aPos[1].Y) < 10); + CPPUNIT_ASSERT(abs(2842 - aPos[2].Y) < 10); + CPPUNIT_ASSERT(abs(2843 - aPos[3].Y) < 10); } DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx") diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index c80cce0..a2cb109 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -85,7 +85,7 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) return aResult; } -void lclMovePositionWithRotation(awt::Point& aPos, sal_Int64 nRotation) +void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, sal_Int64 nRotation) { // code from ImplEESdrWriter::ImplFlipBoundingBox (filter/source/msfilter/eschesdo.cxx) // TODO: refactor @@ -104,8 +104,8 @@ void lclMovePositionWithRotation(awt::Point& aPos, sal_Int64 nRotation) double fCos = cos(fVal); double fSin = sin(fVal); - double nWidthHalf = (double) aPos.X / 2; - double nHeightHalf = (double) aPos.Y / 2; + double nWidthHalf = (double) rSize.Width() / 2; + double nHeightHalf = (double) rSize.Height() / 2; double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf; double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf; @@ -303,7 +303,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS // SdrObjects know their layer, consider that instead of the frame format. bOpaque = pObj->GetLayer() != pFrmFmt->GetDoc()->GetHellId() && pObj->GetLayer() != pFrmFmt->GetDoc()->GetInvisibleHellId(); - lclMovePositionWithRotation(aPos, pObj->GetRotateAngle()); + lclMovePositionWithRotation(aPos, rSize, pObj->GetRotateAngle()); } attrList->add(XML_behindDoc, bOpaque ? "0" : "1"); attrList->add(XML_distT, OString::number(TwipsToEMU(pULSpaceItem.GetUpper())).getStr()); commit b65de36ecb839ec4d7a8f40f9ffe67956e9bc79d Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Apr 14 17:27:35 2014 +0200 fdo#75722: fix incorrect import of rotated DML shapes The DML importer used a tranformation matrix to rotate the shape, but I replaced it with the same code that's being used in the VML importer in which the position is correctly set. I've noticed that I cannot use that code in all cases thanks to the existing unit tests; that's why I added the bUseRotationTransform. In case it is set to true the existing transformation matrix rotation is used. Finally I added a unit test for this case. Change-Id: I260c14b42d169def786e15484e4ecb1d8e8584e4 diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 36cbc0c..c1d00f6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -63,6 +63,7 @@ #include <com/sun/star/document/XActionLockable.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <svl/outstrm.hxx> +#include <svx/svdtrans.hxx> #include <unotools/streamwrap.hxx> #include <unotools/fltrcfg.hxx> #include <vcl/graph.hxx> @@ -410,6 +411,9 @@ Reference< XShape > Shape::createAndInsert( } bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || aServiceName == "com.sun.star.drawing.ConnectorShape" ); + bool bUseRotationTransform = ( !mbWps || + aServiceName == "com.sun.star.drawing.LineShape" || + aServiceName == "com.sun.star.drawing.GroupShape" ); basegfx::B2DHomMatrix aTransformation; @@ -436,7 +440,7 @@ Reference< XShape > Shape::createAndInsert( aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 ); } - if( mnRotation != 0 ) + if( bUseRotationTransform && mnRotation != 0 ) { // rotate around object's center aTransformation.rotate( F_PI180 * ( (double)mnRotation / 60000.0 ) ); @@ -896,6 +900,15 @@ Reference< XShape > Shape::createAndInsert( else if( getTextBody() ) getTextBody()->getTextProperties().pushVertSimulation(); + if ( !bUseRotationTransform && mnRotation != 0 ) + { + // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx) + PropertySet aPropertySet( mxShape ); + aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) ); + aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) ); + aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) ); + } + // in some cases, we don't have any text body. if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) ) { diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 103a3db..8961eed 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2019,6 +2019,35 @@ DECLARE_OOXMLIMPORT_TEST(testFdo74401, "fdo74401.docx") CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShape->getShapeType()); } +DECLARE_OOXMLIMPORT_TEST(testFdo75722vml, "fdo75722-vml.docx") +{ + uno::Reference<drawing::XShape> xShape = getShape(1); + awt::Point aPos = xShape->getPosition(); + awt::Size aSize = xShape->getSize(); + sal_Int64 nRot = getProperty<sal_Int64>(xShape, "RotateAngle"); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(3720), aPos.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-392), aPos.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5457), aSize.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3447), aSize.Height); + CPPUNIT_ASSERT_EQUAL(sal_Int64(3100), nRot); +} + +DECLARE_OOXMLIMPORT_TEST(testFdo75722dml, "fdo75722-dml.docx") +{ + uno::Reference<drawing::XShape> xShape = getShape(1); + awt::Point aPos = xShape->getPosition(); + awt::Size aSize = xShape->getSize(); + sal_Int64 nRot = getProperty<sal_Int64>(xShape, "RotateAngle"); + + // a slight difference regarding vml file is tolerated due to rounding errors + CPPUNIT_ASSERT_EQUAL(sal_Int32(3720), aPos.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-397), aPos.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5457), aSize.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3447), aSize.Height); + CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); commit 944a195600868c49dbf6f7725b8be3886c9a84e1 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Thu Apr 10 19:05:09 2014 +0200 sal_Bool -> bool Change-Id: I92fe7e3d3be4bf64b57dacb2ae8386775b02c80a diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index ea02fef..4886912 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -146,10 +146,10 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi #endif } - aPropertyMap.setProperty( PROP_MirroredX, (sal_Bool) mbMirroredX ); - aPropertyMap.setProperty( PROP_MirroredY, (sal_Bool) mbMirroredY ); + aPropertyMap.setProperty( PROP_MirroredX, mbMirroredX ); + aPropertyMap.setProperty( PROP_MirroredY, mbMirroredY ); aPropertyMap.setProperty( PROP_TextPreRotateAngle, mnTextRotateAngle ); - aPropertyMap.setProperty( PROP_IsPostRotateAngle, (sal_Bool)true); // For OpenXML Imports + aPropertyMap.setProperty( PROP_IsPostRotateAngle, true); // For OpenXML Imports Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq ); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 2b9220a..36cbc0c 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -408,8 +408,8 @@ Reference< XShape > Shape::createAndInsert( { aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm ); } - sal_Bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || - aServiceName == "com.sun.star.drawing.ConnectorShape" ); + bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || + aServiceName == "com.sun.star.drawing.ConnectorShape" ); basegfx::B2DHomMatrix aTransformation;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits