Kaydet (Commit) ab296726 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

tdf#91999 export/drawingml: shape rotate 180 is not special

This commit reverts the first (LO 4.3ish) regression commit
60635557 and most of the two commits
that tried to fix that: commit 9ae1e094
and commit ee45d881 in LO6.0/6.2.

The ooxmlexport6 unit test shows that there is nothing special
about 180degrees. So, all transformations need to be avoided in
docx format - not just 180 degree ones.

I removed IsInGroupShape() since it is no longer being used - as
per standard procedures.

Change-Id: Id2bba5bc542875a10ac21fbb67f29b2d59705493
Reviewed-on: https://gerrit.libreoffice.org/58434
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 3cc5149a
......@@ -252,8 +252,7 @@ public:
void WriteShape3DEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
bool IsInGroupShape() const;
bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape, bool bOrChildShape = false ) const;
bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape ) const;
sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName);
static void ResetCounters();
......
......@@ -1345,17 +1345,11 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
bFlipH = bFlipH && !bFlippedBeforeRotation;
bFlipV = bFlipV && !bFlippedBeforeRotation;
bool bPositiveY = true;
bool bPositiveX = true;
if (GetDocumentType() == DOCUMENT_DOCX && m_xParent.is())
{
awt::Point aParentPos = m_xParent->getPosition();
aPos.X -= aParentPos.X;
aPos.Y -= aParentPos.Y;
bPositiveX = aParentPos.X >= 0;
bPositiveY = aParentPos.Y >= 0;
}
if ( aSize.Width < 0 )
......@@ -1366,24 +1360,13 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
{
SdrObject* pShape = GetSdrObjectFromXShape( rXShape );
nRotation = pShape ? pShape->GetRotateAngle() : 0;
if (nRotation != 0 && nRotation != 18000)
if ( nRotation != 0 && GetDocumentType() != DOCUMENT_DOCX )
{
int faccos=bFlipV ? -1 : 1;
int facsin=bFlipH ? -1 : 1;
aPos.X-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Width/2-facsin*sin(nRotation*F_PI18000)*aSize.Height/2;
aPos.Y-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Height/2+facsin*sin(nRotation*F_PI18000)*aSize.Width/2;
}
else if ( nRotation == 18000 && IsGroupShape( rXShape, /*bOrChildShape=*/true ) )
{
if (!bFlipV && bPositiveX)
{
aPos.X -= aSize.Width;
}
if (!bFlipH && bPositiveY)
{
aPos.Y -= aSize.Height;
}
}
// The RotateAngle property's value is independent from any flipping, and that's exactly what we need here.
uno::Reference<beans::XPropertySet> xPropertySet(rXShape, uno::UNO_QUERY);
......@@ -2080,21 +2063,10 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
}
}
bool DrawingML::IsInGroupShape () const
{
bool bRet = m_xParent.is();
if ( bRet )
{
uno::Reference<lang::XServiceInfo> xServiceInfo(m_xParent, uno::UNO_QUERY_THROW);
bRet = xServiceInfo->supportsService("com.sun.star.drawing.GroupShape");
}
return bRet;
}
bool DrawingML::IsGroupShape( const Reference< XShape >& rXShape, bool bOrChildShape ) const
bool DrawingML::IsGroupShape( const Reference< XShape >& rXShape ) const
{
bool bRet = bOrChildShape && IsInGroupShape();
if ( !bRet && rXShape.is() )
bool bRet = false;
if ( rXShape.is() )
{
uno::Reference<lang::XServiceInfo> xServiceInfo(rXShape, uno::UNO_QUERY_THROW);
bRet = xServiceInfo->supportsService("com.sun.star.drawing.GroupShape");
......
......@@ -123,6 +123,7 @@ public:
void testGroupRotation();
void testTdf104788();
void testSmartartRotation2();
void testTdf91999_rotateShape();
void testTdf114845_rotateShape();
void testGroupsPosition();
void testGroupsRotatedPosition();
......@@ -198,6 +199,7 @@ public:
CPPUNIT_TEST(testGroupRotation);
CPPUNIT_TEST(testTdf104788);
CPPUNIT_TEST(testSmartartRotation2);
CPPUNIT_TEST(testTdf91999_rotateShape);
CPPUNIT_TEST(testTdf114845_rotateShape);
CPPUNIT_TEST(testGroupsPosition);
CPPUNIT_TEST(testGroupsRotatedPosition);
......@@ -1312,7 +1314,20 @@ void SdOOXMLExportTest2::testSmartartRotation2()
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:p/a:r/a:t", "Text");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "2276280");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "3158280");
}
void SdOOXMLExportTest2::testTdf91999_rotateShape()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf91999_rotateShape.pptx"), PPTX);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
xDocShRef->DoClose();
xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:nvSpPr/p:cNvPr", "name", "CustomShape 2");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm", "rot", "10800000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:off", "x", "2960640");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:off", "y", "1449000");
}
void SdOOXMLExportTest2::testTdf114845_rotateShape()
......
......@@ -114,6 +114,23 @@ DECLARE_OOXMLEXPORT_TEST(testDmlTextshape, "dml-textshape.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(-4727), xShape->getPosition().Y);
}
DECLARE_OOXMLEXPORT_TEST(testDmlTextshapeB, "dml-textshapeB.docx")
{
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
xmlDocPtr pXmlDocument = parseExport("word/document.xml");
if (!pXmlDocument)
return;
uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(3), uno::UNO_QUERY);
// Connector was incorrectly shifted towards the top left corner, X was 192, Y was -5743.
CPPUNIT_ASSERT_EQUAL(sal_Int32(3778), xShape->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-5064), xShape->getPosition().Y);
xShape.set(xGroup->getByIndex(5), uno::UNO_QUERY);
// This was incorrectly shifted towards the top of the page, Y was -5011.
CPPUNIT_ASSERT_EQUAL(sal_Int32(-4713), xShape->getPosition().Y);
}
DECLARE_OOXMLEXPORT_TEST(testDMLSolidfillAlpha, "dml-solidfill-alpha.docx")
{
// Problem was that the transparency was not exported (a:alpha).
......
......@@ -1050,7 +1050,8 @@ DECLARE_OOXMLEXPORT_TEST(testFdo66474, "fdo66474.docx")
DECLARE_OOXMLEXPORT_TEST(testGroupshapeRotation, "groupshape-rotation.docx")
{
// Rotation on groupshapes wasn't handled at all by the VML importer.
CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
// Note: the shapes are still shifting on the page, so the rotation drifts after multiple round-trips.
CPPUNIT_ASSERT_DOUBLES_EQUAL(31500.0, getProperty<double>(getShape(1), "RotateAngle"), 100);
}
DECLARE_OOXMLEXPORT_TEST(testBnc780044Spacing, "bnc780044_spacing.docx")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment