summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-08-03 09:19:17 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-03 09:19:59 +0200
commitdbfed66eebde65f5844a0f1a2cfe548ad4eda962 (patch)
treeadd5cbf3d46150d940088c60b6fd182f19a38bde /oox
parent53e535821344549c2a1f5adf3d1bdbc2a0582492 (diff)
tdf#87924 DOCX import: rot=90 and vert=vert270 means no text rotation
If the shape is rotated 90 degrees clockwise and the text is further rotated 270 degrees clockwise that means we shouldn't do anything with the text and the result will be correct. Change-Id: I7c65319258136288520bd24fa2bf8e3c598b0878
Diffstat (limited to 'oox')
-rw-r--r--oox/source/shape/WpsContext.cxx33
1 files changed, 30 insertions, 3 deletions
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index a22d6b82c1da..9616e0b06776 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) != NormAngle360(nRotation * 100) / 100)
+ {
+ comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
+ aCustomShapeGeometry["TextPreRotateAngle"] = uno::makeAny(nRotation);
+ xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
+ }
}
}