summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-04-08 18:38:04 +0200
committerRegina Henschel <rb.henschel@t-online.de>2023-05-07 10:57:04 +0200
commitdfb0d118f6b23730bc632885eb4703a37eeaec16 (patch)
treee5208dfd5dcbd1f237fa2fa2d03117e518efd891 /sc/qa/unit
parenta2066028ff6b1d0470968bfc064d54cb9d8cbd6b (diff)
tdf#139083 Only resize if 'resize with cell' is set
The copy&paste of ranges with shapes had the following further bugs: * For cell anchored shapes the position was taken from the source rectangle instead of the anchor. * Resizing was calculated from source and destination rectangle, but should only depend on size of object range. * tdf#125938 Shapes were moved without adapting the anchor. * tdf#155091 Source with filtered rows produced doubled objects in paste. * The CopyToClip method has a useless NbcMove(size(0,0)). NbcMove is a move 'by', not a move 'to'. * tdf#155093 Pasted object has same name as source object and thus is not accessible via Navigator. * tdf#155094 Transposed pasted objects have wrong position * tdf#155095 Objects over collapsed group are incorrectly resized * tdf#141437, tdf#141436 transposed objects have wrong size Only objects, which can really resize, are now resized. In case of transposing no objects are resized. Transposing would need to transpose the object geometry, but that is missing. The offset inside the start anchor cell is adapted to the size of the destination cell to keep the anchor in this cell. Object resizing considers that filtered rows are removed whereas collapsed or hidden rows are shown in pasted area. Object resizing does no longer use global factors but calculate the desired snap rectangle and fits the object into it. Change-Id: I42924b28a2d652d8b70cb8e1a1d7ca4324b09cf6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150161 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/tdf139083_copy_without_resize.odsbin0 -> 10457 bytes
-rw-r--r--sc/qa/unit/data/ods/tdf155093_double_names.odsbin0 -> 13978 bytes
-rw-r--r--sc/qa/unit/scshapetest.cxx47
3 files changed, 47 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/tdf139083_copy_without_resize.ods b/sc/qa/unit/data/ods/tdf139083_copy_without_resize.ods
new file mode 100644
index 000000000000..ea3b8908ede2
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf139083_copy_without_resize.ods
Binary files differ
diff --git a/sc/qa/unit/data/ods/tdf155093_double_names.ods b/sc/qa/unit/data/ods/tdf155093_double_names.ods
new file mode 100644
index 000000000000..6dd7a69554c4
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf155093_double_names.ods
Binary files differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 814384effe83..6f9a39c8eafa 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -999,6 +999,53 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, testLargeAnchorOffset)
CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(aOldPos, aNewPos, 1);
}
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf139083_copy_without_resize)
+{
+ // Load a document, which has a shape anchored to cell B2, but without 'resize with cell'.
+ // When the range B2:B3 is copied and pasted to D5, then the copied shape should keep its size.
+ createScDoc("ods/tdf139083_copy_without_resize.ods");
+
+ // Get document
+ ScDocument* pDoc = getScDoc();
+
+ // Copy cells B2:B3. They have row height 2cm and column width 3cm.
+ goToCell("$B$2:$B$3");
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ // Paste to D5. There are row height 0.5cm and column width 1cm.
+ goToCell("$D$5");
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ // Make sure original and pasted shape have the same size.
+ // Size of original shape is 2001x3002, without fix size of pasted shape was 668x750.
+ SdrObject* pObjOrig = lcl_getSdrObjectWithAssert(*pDoc, 0); // original shape
+ SdrObject* pObjPasted = lcl_getSdrObjectWithAssert(*pDoc, 1); // pasted shape
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2001, pObjOrig->GetSnapRect().GetWidth(), 1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3002, pObjOrig->GetSnapRect().GetHeight(), 1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2001, pObjPasted->GetSnapRect().GetWidth(), 1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3002, pObjPasted->GetSnapRect().GetHeight(), 1);
+}
+
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf155093_double_names)
+{
+ // Load a document, which has a shape in range B6:C14 with name "myArrow". When the range was
+ // copied and pasted, then the copied shape got the same name and thus was not accessible with
+ // Navigator.
+ createScDoc("ods/tdf155093_double_names.ods");
+ ScDocument* pDoc = getScDoc();
+
+ // Copy and paste
+ goToCell("$B$6:$C$14");
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+ goToCell("$D$16");
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ // Make sure original and pasted shape have different names.
+ SdrObject* pObjOrig = lcl_getSdrObjectWithAssert(*pDoc, 0); // original shape
+ SdrObject* pObjPasted = lcl_getSdrObjectWithAssert(*pDoc, 1); // pasted shape
+ CPPUNIT_ASSERT(pObjOrig->GetName() != pObjPasted->GetName());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */