summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-11-10 23:37:20 +0100
committerRegina Henschel <rb.henschel@t-online.de>2020-11-11 00:20:07 +0100
commit122d1e391625ca21345c67c90720e971819aa4a6 (patch)
tree629c836562f2f5bbb0e6bf0a250a032e55f98959
parent6dae6c6fdcf410cb0258e04ed018c82d70e8cc3e (diff)
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.henschel@t-online.de>
-rw-r--r--sc/qa/unit/data/ods/loadVerticalFlip.odsbin0 -> 10112 bytes
-rw-r--r--sc/qa/unit/scshapetest.cxx30
-rw-r--r--sc/source/core/data/drwlayer.cxx5
3 files changed, 33 insertions, 2 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/ods/loadVerticalFlip.ods
Binary files 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);