From ff17478e069cc82681df62514876c06365dd5cd6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 25 Apr 2019 21:05:43 +0200 Subject: sw btlr writing mode: implement DOCX shape import for tbrl Now that the btlr writing mode works reasonably well in table cells, the next context is shape text. But turns out that DOCX shape text lacked support in the easier tbrl case, so add that first. Also remove the char-level text rotation code in oox, that is effectively dead code since we import drawingML shapes as shape + Writer TextBox. Change-Id: I30c7793221cc3aceedfcfd9e4e1725634ebb3309 Reviewed-on: https://gerrit.libreoffice.org/71329 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- oox/source/shape/WpsContext.cxx | 84 +++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) (limited to 'oox') diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index 19b413f5c329..0f39a850b0ee 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -59,61 +59,39 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken { uno::Reference xServiceInfo(mxShape, uno::UNO_QUERY); uno::Reference xPropertySet(mxShape, uno::UNO_QUERY); - OptValue oVert = rAttribs.getString(XML_vert); - if (oVert.has() && oVert.get() == "vert270") + sal_Int32 nVert = rAttribs.getToken(XML_vert, XML_horz); + if (nVert != XML_horz) { - if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) - { - // No support for this in core, work around by char rotation, as we do so for table cells already. - uno::Reference xText(mxShape, uno::UNO_QUERY); - uno::Reference xTextCursor = xText->createTextCursor(); - xTextCursor->gotoStart(false); - xTextCursor->gotoEnd(true); - uno::Reference xPropertyState(xTextCursor, - uno::UNO_QUERY); - beans::PropertyState aState - = xPropertyState->getPropertyState("CharRotation"); - if (aState == beans::PropertyState_DEFAULT_VALUE) - { - uno::Reference xTextCursorPropertySet( - xTextCursor, uno::UNO_QUERY); - xTextCursorPropertySet->setPropertyValue("CharRotation", - uno::makeAny(sal_Int16(900))); - } - } - else - { - // 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); + // 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 (static_cast(basegfx::rad2deg(fRotate)) - != NormAngle36000(static_cast(nRotation) * 100) / 100) - { - comphelper::SequenceAsHashMap aCustomShapeGeometry( - xPropertySet->getPropertyValue("CustomShapeGeometry")); - aCustomShapeGeometry["TextPreRotateAngle"] <<= nRotation; - xPropertySet->setPropertyValue( - "CustomShapeGeometry", - uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); - } + // If the text is not rotated the way the shape wants it already, set the angle. + const sal_Int32 nRotation = nVert == XML_vert270 ? -270 : -90; + if (static_cast(basegfx::rad2deg(fRotate)) + != NormAngle36000(static_cast(nRotation) * 100) / 100) + { + comphelper::SequenceAsHashMap aCustomShapeGeometry( + xPropertySet->getPropertyValue("CustomShapeGeometry")); + aCustomShapeGeometry["TextPreRotateAngle"] <<= nRotation; + xPropertySet->setPropertyValue( + "CustomShapeGeometry", + uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList())); } } -- cgit