summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/data/ods/tdf143619_validationCirclePos.odsbin0 -> 8367 bytes
-rw-r--r--sc/qa/unit/scshapetest.cxx34
-rw-r--r--sc/source/core/data/drwlayer.cxx7
3 files changed, 41 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/tdf143619_validationCirclePos.ods b/sc/qa/unit/data/ods/tdf143619_validationCirclePos.ods
new file mode 100644
index 000000000000..6470d6a1f430
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf143619_validationCirclePos.ods
Binary files differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index fad81ddd0e6b..c178c28578a6 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -46,6 +46,7 @@ public:
ScShapeTest();
void saveAndReload(css::uno::Reference<css::lang::XComponent>& xComponent,
const OUString& rFilter);
+ void testTdf143619_validation_circle_pos();
void testTdf140252_DragCreateFormControl();
void testTdf134355_DragCreateCustomShape();
void testTdf140252_LayerOfControl();
@@ -72,6 +73,7 @@ public:
void testCustomShapeCellAnchoredRotatedShape();
CPPUNIT_TEST_SUITE(ScShapeTest);
+ CPPUNIT_TEST(testTdf143619_validation_circle_pos);
CPPUNIT_TEST(testTdf140252_DragCreateFormControl);
CPPUNIT_TEST(testTdf134355_DragCreateCustomShape);
CPPUNIT_TEST(testTdf140252_LayerOfControl);
@@ -204,6 +206,38 @@ static SdrObject* lcl_getSdrObjectWithAssert(ScDocument& rDoc, sal_uInt16 nObjNu
return pObj;
}
+void ScShapeTest::testTdf143619_validation_circle_pos()
+{
+ // Load a document, which has validation circle around cell E6.
+
+ OUString aFileURL;
+ createFileURL(u"tdf143619_validationCirclePos.ods", aFileURL);
+ uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileURL);
+
+ // Get document
+ ScDocShell* pDocSh = lcl_getScDocShellWithAssert(xComponent);
+ ScDocument& rDoc = pDocSh->GetDocument();
+
+ // Get shape. That is the validation circle.
+ SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
+
+ // Error was, that deleting row and col before E6 does not move circle to D5, but to B3.
+ // Delete first row and first column.
+ uno::Sequence<beans::PropertyValue> aPropertyValues = {
+ comphelper::makePropertyValue("ToPoint", OUString("$A$1")),
+ };
+ dispatchCommand(xComponent, ".uno:GoToCell", aPropertyValues);
+ dispatchCommand(xComponent, ".uno:DeleteRows", {});
+ dispatchCommand(xComponent, ".uno:GoToCell", aPropertyValues);
+ dispatchCommand(xComponent, ".uno:DeleteColumns", {});
+
+ // Without fix in place the position was (2007, 833)
+ Point aPos = pObj->GetSnapRect().TopLeft();
+ lcl_AssertPointEqualWithTolerance("after row and col delete", Point(6523, 1736), aPos, 1);
+
+ pDocSh->DoClose();
+}
+
void ScShapeTest::testTdf140252_DragCreateFormControl()
{
// Error was, that drag-created form controls were initially not on layer 'controls' and thus
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 1174cb656019..79b52627e015 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1049,6 +1049,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
// Validation circle for detective.
rData.setShapeRect(GetDocument(), pObj->GetLogicRect());
+ // rData.maStart should contain the address of the be validated cell.
tools::Rectangle aRect = GetCellRect(*GetDocument(), rData.maStart, true);
aRect.AdjustLeft( -250 );
aRect.AdjustRight(250 );
@@ -1062,7 +1063,13 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
if (bRecording)
AddCalcUndo( std::make_unique<SdrUndoGeoObj>( *pObj ) );
rData.setShapeRect(GetDocument(), lcl_makeSafeRectangle(aRect));
+ // maStart has the meaning of "to be validated cell" in a validation circle. For usual
+ // drawing objects it has the meaning "left/top of logic/snap rect". Because the rectangle
+ // is expanded above, SetLogicRect() will set maStart to one cell left and one cell above
+ // of the to be validated cell. We need to backup the old value and restore it.
+ ScAddress aBackup(rData.maStart);
pObj->SetLogicRect(rData.getShapeRect());
+ rData.maStart = aBackup;
}
}
else if (rData.meType == ScDrawObjData::DetectiveArrow)