sc/qa/unit/data/ods/loadVerticalFlip.ods |binary sc/qa/unit/scshapetest.cxx | 30 ++++++++++++++++++++++++++++++ sc/source/core/data/drwlayer.cxx | 5 +++-- 3 files changed, 33 insertions(+), 2 deletions(-)
New commits: commit 122d1e391625ca21345c67c90720e971819aa4a6 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Tue Nov 10 23:37:20 2020 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Wed Nov 11 00:20:07 2020 +0100 Correction to improve 'resize with cell' Error: A vertical flipped shape lost flip on loading. The error slipped in, when I have implemented the suggestions from Jan-Marek. The object is vertical flipped, to have no flip for calculating the full sized logical rectangle. Therefore the second call to method lcl_NeedsMirrorYCorrection gives wrong result 'false'. I need to remember the result of the first call. Change-Id: Ia411fe7108be9fdcbbf748ee9de9f443e55d6ed0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105570 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/sc/qa/unit/data/ods/loadVerticalFlip.ods b/sc/qa/unit/data/ods/loadVerticalFlip.ods new file mode 100644 index 000000000000..e18809cef2ac Binary files /dev/null and b/sc/qa/unit/data/ods/loadVerticalFlip.ods differ diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index d2c8cc946296..279c9be43eda 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -33,6 +33,7 @@ public: ScShapeTest(); void saveAndReload(css::uno::Reference<css::lang::XComponent>& xComponent, const OUString& rFilter); + void testLoadVerticalFlip(); void testTdf117948_CollapseBeforeShape(); void testTdf137355_UndoHideRows(); void testTdf115655_HideDetail(); @@ -40,6 +41,7 @@ public: void testCustomShapeCellAnchoredRotatedShape(); CPPUNIT_TEST_SUITE(ScShapeTest); + CPPUNIT_TEST(testLoadVerticalFlip); CPPUNIT_TEST(testTdf117948_CollapseBeforeShape); CPPUNIT_TEST(testTdf137355_UndoHideRows); CPPUNIT_TEST(testTdf115655_HideDetail); @@ -97,6 +99,34 @@ static void lcl_AssertRectEqualWithTolerance(const OString& sInfo, labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); } +void ScShapeTest::testLoadVerticalFlip() +{ + // The document has a cell anchored custom shape with vertical flip. Error was, that the + // flip was lost on loading. + OUString aFileURL; + createFileURL("loadVerticalFlip.ods", aFileURL); + uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(xComponent.is()); + + // Get the document model + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell); + CPPUNIT_ASSERT(pDocSh); + + // Get the shape and check that it is flipped + ScDocument& rDoc = pDocSh->GetDocument(); + ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); + CPPUNIT_ASSERT(pDrawLayer); + const SdrPage* pPage = pDrawLayer->GetPage(0); + CPPUNIT_ASSERT(pPage); + SdrObjCustomShape* pObj = dynamic_cast<SdrObjCustomShape*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pObj); + CPPUNIT_ASSERT_MESSAGE("Load: Object should be vertically flipped", pObj->IsMirroredY()); + + pDocSh->DoClose(); +} + void ScShapeTest::testTdf117948_CollapseBeforeShape() { // The document contains a column group left from the image. The group is exanded. Collapse the diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index a9e177f01567..88335082c41f 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -673,7 +673,8 @@ void lcl_SetLogicRectFromAnchor(SdrObject* pObj, ScDrawObjData& rAnchor, ScDocum // set the logic rectangle, and apply flip again. You cannot simple use a 180deg-rotated // rectangle, because custom shape mirroring is internally applied after the other // transformations. - if (lcl_NeedsMirrorYCorrection(pObj)) + const bool bNeedsMirrorYCorrection = lcl_NeedsMirrorYCorrection(pObj); // remember state + if (bNeedsMirrorYCorrection) { const tools::Rectangle aRect(pObj->GetSnapRect()); const Point aLeft(aRect.Left(), (aRect.Top() + aRect.Bottom()) >> 1); @@ -703,7 +704,7 @@ void lcl_SetLogicRectFromAnchor(SdrObject* pObj, ScDrawObjData& rAnchor, ScDocum pObj->NbcSetLogicRect(lcl_makeSafeRectangle(aNewRectangle)); // The shape has the correct logical rectangle now. Reapply the above removed mirroring. - if (lcl_NeedsMirrorYCorrection(pObj)) + if (bNeedsMirrorYCorrection) { const tools::Rectangle aRect(pObj->GetSnapRect()); const Point aLeft(aRect.Left(), (aRect.Top() + aRect.Bottom()) >> 1); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits