From 9b2a94321e3a05364064cb60dafc1d1b69eece56 Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Thu, 7 Nov 2019 15:25:21 +0100 Subject: tdf#128413 SetSnapRect of custom shapes expects logic rect SdrObjCustomShape has its own version of SetSnapRect. This expects a logic rectangle in its input parameter. That was not considered in method SetVerticalWriting(). The result was, that for rotated or sheared shapes, which has text, setting tb-rl writing mode changed size and position. Change-Id: Idefd75cf25fd9ff4b9088ee494c65d5e6c5d12c8 Reviewed-on: https://gerrit.libreoffice.org/82233 Tested-by: Jenkins Reviewed-by: Regina Henschel --- svx/qa/unit/customshapes.cxx | 29 +++++++++++++++++++++++++++++ svx/qa/unit/data/tdf128413_tbrl_OnOff.odp | Bin 0 -> 14170 bytes svx/source/svdraw/svdoashp.cxx | 5 +++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 svx/qa/unit/data/tdf128413_tbrl_OnOff.odp diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 25ddbc97df17..796fa4824809 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -602,6 +602,35 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_TextRotateAngle) CPPUNIT_ASSERT_EQUAL(OUString(), sErrors); } + +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf128413_tbrlOnOff) +{ + // The document contains a rotated shape with text. The error was, that switching + // tb-rl writing-mode on, changed the shape size and position. + + const OUString sFileName("tdf128413_tbrl_OnOff.odp"); + OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + sFileName; + mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + uno::Reference xShape(getShape(0)); + uno::Reference xShapeProps(xShape, uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is()); + awt::Rectangle aOrigRect; + xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT) >>= aOrigRect; + + SdrObjCustomShape& rSdrObjCustomShape( + static_cast(*GetSdrObjectFromXShape(xShape))); + rSdrObjCustomShape.SetVerticalWriting(true); + + awt::Rectangle aObservedRect; + xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT) >>= aObservedRect; + OUString sError; + if (aOrigRect.Width != aObservedRect.Width || aOrigRect.Height != aObservedRect.Height + || aOrigRect.X != aObservedRect.X || aOrigRect.Y != aObservedRect.Y) + { + sError = "Shape has wrong size or wrong position."; + } + CPPUNIT_ASSERT_EQUAL(OUString(), sError); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/qa/unit/data/tdf128413_tbrl_OnOff.odp b/svx/qa/unit/data/tdf128413_tbrl_OnOff.odp new file mode 100644 index 000000000000..f10f98bbeccf Binary files /dev/null and b/svx/qa/unit/data/tdf128413_tbrl_OnOff.odp differ diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 2fa14030b11a..7afb195499cd 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2208,8 +2208,9 @@ void SdrObjCustomShape::SetVerticalWriting( bool bVertical ) SdrTextHorzAdjust eHorz = rSet.Get(SDRATTR_TEXT_HORZADJUST).GetValue(); SdrTextVertAdjust eVert = rSet.Get(SDRATTR_TEXT_VERTADJUST).GetValue(); - // rescue object size - tools::Rectangle aObjectRect = GetSnapRect(); + // rescue object size, SetSnapRect below expects logic rect, + // not snap rect. + tools::Rectangle aObjectRect = GetLogicRect(); // prepare ItemSet to set exchanged width and height items SfxItemSet aNewSet(*rSet.GetPool(), -- cgit