From 0e687595295e210e6275eda57a253ca66e8249ce Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 15 Feb 2018 15:41:50 +0100 Subject: tdf#115519: Handle rotation for WriterFlyFrames correctly Change-Id: I5f29b3640eaf24d63c64edfecd6732f336582640 Reviewed-on: https://gerrit.libreoffice.org/49826 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- xmloff/source/text/XMLTextFrameContext.cxx | 8 ++++++++ xmloff/source/text/txtparae.cxx | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 63ea2aa937f7..25b6b0441cf5 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1027,6 +1027,14 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( // to me mirrored using * -1.0, see conversion there) const double fRotate(aDecomposedTransform.getRotate() * (1800.0/M_PI)); nRotation = static_cast< sal_Int16 >(basegfx::fround(fRotate) % 3600); + + // tdf#115519 may be negative, with the above modulo maximal -3599, so + // no loop needed here. nRotation is used in setPropertyValue("GraphicRotation") + // and *has* to be in the range [0 .. 3600[ + if(nRotation < 0) + { + nRotation += 3600; + } } } } diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 70859d4c4779..16a57ed09d23 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3078,13 +3078,14 @@ void XMLTextParagraphExport::_exportTextGraphic( // we have a right-handed coordinate system, so need to correct this by mirroring // the rotation to get the correct transformation. See also case XML_TOK_TEXT_FRAME_TRANSFORM // in XMLTextFrameContext_Impl::XMLTextFrameContext_Impl and #i78696# - const double fRotate(static_cast< double >(-nRotation) * (M_PI/1800.0)); + const double fRotate(static_cast< double >(-nRotation) * (F_PI/1800.0)); // transform to rotation center which is the object's center aSdXMLImExTransform2D.AddTranslate(-aCenter); // add rotation itself - aSdXMLImExTransform2D.AddRotate(fRotate); + // tdf#115529 but correct value modulo 2PI to have it positive and in the range of [0.0 .. 2PI[ + aSdXMLImExTransform2D.AddRotate(basegfx::normalizeToRange(fRotate, F_2PI)); // back-transform after rotation aSdXMLImExTransform2D.AddTranslate(aCenter); -- cgit