summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Trojahn <paul.trojahn@gmail.com>2017-07-23 22:59:25 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-08-10 17:50:47 +0200
commit5fc980154a968d8f48803289f0042d105dfc102a (patch)
treec48b9afe0767d7ff548a1fc0759bf7c4e6d449ae
parentc3f8727fe88e3073272f573516d5662ddcbbaa13 (diff)
tdf#109187 Fix OOXML import of flipped shapes with gradients
The rotation of the gradient instead of the shape needs to be flipped because OOXML flips shapes before rotating them. Change-Id: I332412078ae0f8d555bd462964c7b20037147e02 Reviewed-on: https://gerrit.libreoffice.org/40136 Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--oox/source/drawingml/fillproperties.cxx14
-rw-r--r--sd/qa/unit/data/pptx/tdf109187.pptxbin0 -> 34647 bytes
-rw-r--r--sd/qa/unit/data/xml/n762695_0.xml2
-rw-r--r--sd/qa/unit/import-tests.cxx17
4 files changed, 25 insertions, 8 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 81ab8c66396a..925db22fb5f9 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -356,12 +356,6 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
}
- // Adjust for flips
- if ( bFlipH )
- nShapeRotation = 180*60000 - nShapeRotation;
- if ( bFlipV )
- nShapeRotation = -nShapeRotation;
-
// "rotate with shape" set to false -> do not rotate
if ( !maGradientProps.moRotateWithShape.get( true ) )
nShapeRotation = 0;
@@ -533,7 +527,13 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// Now we have a potential border and a largest segment. Use those.
aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
- sal_Int32 nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) + nShapeRotation;
+ sal_Int32 nShadeAngle = maGradientProps.moShadeAngle.get( 0 );
+ // Adjust for flips
+ if ( bFlipH )
+ nShadeAngle = 180*60000 - nShadeAngle;
+ if ( bFlipV )
+ nShadeAngle = -nShadeAngle;
+ sal_Int32 nDmlAngle = nShadeAngle + nShapeRotation;
// convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
aGradient.Angle = static_cast< sal_Int16 >( (8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
Color aStartColor, aEndColor;
diff --git a/sd/qa/unit/data/pptx/tdf109187.pptx b/sd/qa/unit/data/pptx/tdf109187.pptx
new file mode 100644
index 000000000000..0fd03c81e6a5
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf109187.pptx
Binary files differ
diff --git a/sd/qa/unit/data/xml/n762695_0.xml b/sd/qa/unit/data/xml/n762695_0.xml
index 0b216210097d..26255f7f8dfb 100644
--- a/sd/qa/unit/data/xml/n762695_0.xml
+++ b/sd/qa/unit/data/xml/n762695_0.xml
@@ -164,7 +164,7 @@
</XShape>
<XShape positionX="17594" positionY="7175" sizeX="1418" sizeY="1450" type="com.sun.star.drawing.CustomShape" name="Left Arrow 13" fontHeight="24.000000" fontColor="ffffffff" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="CENTER" textLeftDistance="250" textRightDistance="250" textUpperDistance="125" textLowerDistance="125" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="GRADIENT" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName="">
<FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
- <FillGradient style="LINEAR" startColor="b29dde" endColor="ffffff" angle="3150" border="0" xOffset="0" yOffset="0" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillGradient style="LINEAR" startColor="b29dde" endColor="ffffff" angle="2250" border="0" xOffset="0" yOffset="0" startIntensity="100" endIntensity="100" stepCount="0"/>
<FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
<FillBitmap width="32" height="32"/>
<LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 7cf536eb3bb1..392369234d0a 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -167,6 +167,7 @@ public:
void testSmartArtChildren();
void testTdf109223();
void testActiveXCheckbox();
+ void testTdf109187();
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
@@ -241,6 +242,7 @@ public:
CPPUNIT_TEST(testSmartArtChildren);
CPPUNIT_TEST(testTdf109223);
CPPUNIT_TEST(testActiveXCheckbox);
+ CPPUNIT_TEST(testTdf109187);
CPPUNIT_TEST_SUITE_END();
};
@@ -2365,6 +2367,21 @@ void SdImportTest::testActiveXCheckbox()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf109187()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf109187.pptx"), PPTX);
+ uno::Reference< beans::XPropertySet > xArrow1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
+ awt::Gradient aGradient1;
+ CPPUNIT_ASSERT(xArrow1->getPropertyValue("FillGradient") >>= aGradient1);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2250), aGradient1.Angle);
+ uno::Reference< beans::XPropertySet > xArrow2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
+ awt::Gradient aGradient2;
+ CPPUNIT_ASSERT(xArrow2->getPropertyValue("FillGradient") >>= aGradient2);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(1350), aGradient2.Angle);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();