diff options
author | Gary Houston <ghouston@arglist.com> | 2014-12-20 15:41:15 +1100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-03-31 07:24:37 +0000 |
commit | b8fdf370d8732d39d6739e320aa1450ead5a31b7 (patch) | |
tree | 5f4e123a04ec4ddddf5532c96a4e07ebe8b74ffa | |
parent | 7042961f4d3e383c04f792a60e96d909b7e44363 (diff) |
fdo#87488 Wrong text rotation inside a preset shape from docx
Preset shape text rotation values are read in a few places and stored in
moRotation. With these changes, moRotation is always read unchanged, but
multiplied by -1 when it's used.
Change-Id: I633d665c21daa69e15fa828a43300f10d2bf2054
Reviewed-on: https://gerrit.libreoffice.org/13561
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit 921cea89da8adbe714ea8f71169dd6afc42354c4)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/15083
-rw-r--r-- | oox/source/drawingml/shape.cxx | 5 | ||||
-rw-r--r-- | oox/source/drawingml/textbodypropertiescontext.cxx | 11 | ||||
-rw-r--r-- | oox/source/drawingml/transform2dcontext.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/fdo87488.docx | bin | 0 -> 26418 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 25 |
5 files changed, 35 insertions, 8 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index f8fdda6a6822..db36b56aae86 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1011,7 +1011,10 @@ Reference< XShape > Shape::createAndInsert( if( getTextBody() ) { sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) ); - mpCustomShapePropertiesPtr->setTextRotateAngle( nTextRotateAngle / 60000 ); + /* OOX measures text rotation clockwise in 1/60000th degrees, + relative to the containing shape. setTextRotateAngle wants + degrees anticlockwise. */ + mpCustomShapePropertiesPtr->setTextRotateAngle( -1 * nTextRotateAngle / 60000 ); } SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'"); diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index 89167b666eb4..cc274377c466 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -84,13 +84,16 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rPa // ST_TextVerticalType if( rAttribs.hasAttribute( XML_vert ) ) { mrTextBodyProp.moVert = rAttribs.getToken( XML_vert ); - bool bRtl = rAttribs.getBool( XML_rtl, false ); sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz ); - if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) - mrTextBodyProp.moRotation = -5400000*(tVert==XML_vert270?3:1); - else + if (tVert == XML_vert || tVert == XML_eaVert || tVert == XML_mongolianVert) + mrTextBodyProp.moRotation = 5400000; + else if (tVert == XML_vert270) + mrTextBodyProp.moRotation = 5400000 * 3; + else { + bool bRtl = rAttribs.getBool( XML_rtl, false ); mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWritingMode, ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB )); + } } // ST_TextAnchoringType diff --git a/oox/source/drawingml/transform2dcontext.cxx b/oox/source/drawingml/transform2dcontext.cxx index a6a39eb60b0a..10bd727ac902 100644 --- a/oox/source/drawingml/transform2dcontext.cxx +++ b/oox/source/drawingml/transform2dcontext.cxx @@ -48,7 +48,7 @@ Transform2DContext::Transform2DContext( ContextHandler2Helper& rParent, const At else { if( rAttribs.hasAttribute( XML_rot ) ) - mrShape.getTextBody()->getTextProperties().moRotation = -rAttribs.getInteger( XML_rot ).get(); + mrShape.getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot ).get(); } } diff --git a/sw/qa/extras/ooxmlimport/data/fdo87488.docx b/sw/qa/extras/ooxmlimport/data/fdo87488.docx Binary files differnew file mode 100644 index 000000000000..2bd51b65fd87 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/fdo87488.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 471095cb4c91..f71e03e71a54 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -76,13 +76,13 @@ public: virtual void preTest(const char* filename) SAL_OVERRIDE { - if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx") + if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" || OString(filename) == "fdo87488.docx") SvtFilterOptions::Get().SetSmartArt2Shape(true); } virtual void postTest(const char* filename) SAL_OVERRIDE { - if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx") + if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" || OString(filename) == "fdo87488.docx") SvtFilterOptions::Get().SetSmartArt2Shape(false); } }; @@ -2560,6 +2560,27 @@ DECLARE_OOXMLIMPORT_TEST(testChtOutlineNumberingOoxml, "chtoutline.docx") CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix); } +DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx") +{ + // The shape on the right (index 0, CustomShape within a + // GroupShape) is rotated 90 degrees clockwise and contains text + // rotated 90 degrees anticlockwise. Must be read with SmartArt + // enabled in preTest above, otherwise it gets converted to a + // StarView MetaFile. + uno::Reference<container::XIndexAccess> group(getShape(1), uno::UNO_QUERY); + { + uno::Reference<text::XTextRange> text(group->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("text2"), text->getString()); + } + { + uno::Reference<beans::XPropertySet> props(group->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(props->getPropertyValue("RotateAngle"), + uno::makeAny(270 * 100)); + comphelper::SequenceAsHashMap geom(props->getPropertyValue("CustomShapeGeometry")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(90), geom["TextPreRotateAngle"].get<sal_Int32>()); + } +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); |