diff options
-rw-r--r-- | oox/source/shape/WpsContext.cxx | 33 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf87924.docx | bin | 0 -> 15925 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 |
3 files changed, 38 insertions, 3 deletions
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index a22d6b82c1da..657071bf4a7a 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -13,6 +13,9 @@ #include <drawingml/shapestylecontext.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <basegfx/tuple/b2dtuple.hxx> +#include <svx/svdtrans.hxx> #include <boost/optional.hpp> @@ -76,9 +79,33 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken } else { - comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); - aCustomShapeGeometry["TextPreRotateAngle"] = uno::makeAny(sal_Int32(-270)); - xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); + // Get the existing rotation of the shape. + drawing::HomogenMatrix3 aMatrix; + xPropertySet->getPropertyValue("Transformation") >>= aMatrix; + basegfx::B2DHomMatrix aTransformation; + aTransformation.set(0, 0, aMatrix.Line1.Column1); + aTransformation.set(0, 1, aMatrix.Line1.Column2); + aTransformation.set(0, 2, aMatrix.Line1.Column3); + aTransformation.set(1, 0, aMatrix.Line1.Column1); + aTransformation.set(1, 1, aMatrix.Line2.Column2); + aTransformation.set(1, 2, aMatrix.Line3.Column3); + aTransformation.set(2, 0, aMatrix.Line1.Column1); + aTransformation.set(2, 1, aMatrix.Line2.Column2); + aTransformation.set(2, 2, aMatrix.Line3.Column3); + basegfx::B2DTuple aScale; + basegfx::B2DTuple aTranslate; + double fRotate = 0; + double fShearX = 0; + aTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + + // If the text is not rotated the way the shape wants it already, set the angle. + const sal_Int32 nRotation = -270; + if (basegfx::rad2deg(fRotate) != static_cast<double>(NormAngle360(nRotation * 100)) / 100) + { + comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); + aCustomShapeGeometry["TextPreRotateAngle"] = uno::makeAny(nRotation); + xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); + } } } diff --git a/sw/qa/extras/ooxmlimport/data/tdf87924.docx b/sw/qa/extras/ooxmlimport/data/tdf87924.docx Binary files differnew file mode 100644 index 000000000000..5265d6638a88 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf87924.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index c1ef511a73ff..20cb6fe74140 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2633,6 +2633,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf86374, "tdf86374.docx") CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType")); } +DECLARE_OOXMLIMPORT_TEST(testTdf87924, "tdf87924.docx") +{ + uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); + comphelper::SequenceAsHashMap aGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry")); + // This was -270, the text rotation angle was set when it should not be rotated. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aGeometry["TextPreRotateAngle"].get<sal_Int32>()); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); |