summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-04-04 16:24:27 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-04-05 07:59:28 +0200
commit6a2e5833f97890ad3b980955626d53622d57377d (patch)
tree860006c22082ece4543fe709d890f88e42ae8f2a /sc
parentfe28b80dfc315dfa7f190b808f144cef6c664a29 (diff)
tdf#116510 Unit test for copying graphics from individual cells
Change-Id: I2471650a50a980129672f3a5f0439753b25eebd6 Reviewed-on: https://gerrit.libreoffice.org/52391 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/extras/anchor.cxx62
1 files changed, 43 insertions, 19 deletions
diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx
index a457a2854391..e1130b792b39 100644
--- a/sc/qa/extras/anchor.cxx
+++ b/sc/qa/extras/anchor.cxx
@@ -261,25 +261,49 @@ void ScAnchorTest::testCopyColumnWithImages()
ScDocument aClipDoc(SCDOCMODE_CLIP);
- // 1. Copy source range
- ScRange aSrcRange;
- aSrcRange.Parse("A1:A11", pDoc, pDoc->GetAddressConvention());
- pViewShell->GetViewData().GetMarkData().SetMarkArea(aSrcRange);
- pViewShell->GetViewData().GetView()->CopyToClip(&aClipDoc, false, false, true, false);
-
- // 2. Paste to target range
- ScRange aDstRange;
- aDstRange.Parse("D1:D11", pDoc, pDoc->GetAddressConvention());
- pViewShell->GetViewData().GetMarkData().SetMarkArea(aDstRange);
- pViewShell->GetViewData().GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-
- // 3. Make sure the images have been copied too
- std::map<SCROW, std::vector<SdrObject*>> aRowObjects
- = pDrawLayer->GetObjectsAnchoredToRange(0, 3, 0, 11);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be an image anchored to D:3", 1,
- static_cast<int>(aRowObjects[2].size()));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be an image anchored to D:11", 1,
- static_cast<int>(aRowObjects[10].size()));
+ // Copy whole column
+ {
+ // 1. Copy source range
+ ScRange aSrcRange;
+ aSrcRange.Parse("A1:A11", pDoc, pDoc->GetAddressConvention());
+ pViewShell->GetViewData().GetMarkData().SetMarkArea(aSrcRange);
+ pViewShell->GetViewData().GetView()->CopyToClip(&aClipDoc, false, false, true, false);
+
+ // 2. Paste to target range
+ ScRange aDstRange;
+ aDstRange.Parse("D1:D11", pDoc, pDoc->GetAddressConvention());
+ pViewShell->GetViewData().GetMarkData().SetMarkArea(aDstRange);
+ pViewShell->GetViewData().GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
+
+ // 3. Make sure the images have been copied too
+ std::map<SCROW, std::vector<SdrObject*>> aRowObjects
+ = pDrawLayer->GetObjectsAnchoredToRange(0, 3, 0, 11);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be an image anchored to D3", 1,
+ static_cast<int>(aRowObjects[2].size()));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be an image anchored to D11", 1,
+ static_cast<int>(aRowObjects[10].size()));
+ }
+
+ // Copy individual cells
+ {
+ // 1. Copy source cells
+ ScRange aSrcRange;
+ aSrcRange.Parse("A3:B3", pDoc, pDoc->GetAddressConvention());
+ pViewShell->GetViewData().GetMarkData().SetMarkArea(aSrcRange);
+ pViewShell->GetViewData().GetView()->CopyToClip(&aClipDoc, false, false, true, false);
+
+ // 2. Paste to target cells
+ ScRange aDstRange;
+ aDstRange.Parse("G3:H3", pDoc, pDoc->GetAddressConvention());
+ pViewShell->GetViewData().GetMarkData().SetMarkArea(aDstRange);
+ pViewShell->GetViewData().GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
+
+ // 3. Make sure the image has been copied too
+ std::map<SCROW, std::vector<SdrObject*>> aRowObjects
+ = pDrawLayer->GetObjectsAnchoredToRange(0, 6, 2, 2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be an image anchored to G3", 1,
+ static_cast<int>(aRowObjects[2].size()));
+ }
pDocSh->DoClose();
}