sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods |binary sc/qa/unit/scshapetest.cxx | 24 +++++++++++++++++ sc/source/core/data/drwlayer.cxx | 2 - 3 files changed, 25 insertions(+), 1 deletion(-)
New commits: commit 199523b553957936dc31b8c3556ef2e47c6bc3a1 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Sun Mar 3 17:19:49 2024 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Mon Mar 4 14:30:21 2024 +0100 tdf#160003 use correct sheet in clipboard for test ..whether a page anchored object is contained in the to be copied area. Change-Id: I816e342770332e6d751b57a38e5ebabe33feb16a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164307 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods b/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods new file mode 100644 index 000000000000..565eb1bf6a26 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods differ diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index b5083544f114..5e4827005388 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -1207,6 +1207,30 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf154821_shape_in_group) CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aRectOrig, aRectReload, 1); } +CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160003_copy_page_anchored) +{ + // Load a document, which has a chart anchored to page on sheet2. Copy&paste to other document + // had lost the chart object. + createScDoc("ods/tdf160003_page_anchored_object.ods"); + + // copy range with chart + goToCell("$Sheet2.$A$1:$L$24"); + dispatchCommand(mxComponent, ".uno:Copy", {}); + + // close document and create new one + createScDoc(); + + // paste clipboard + goToCell("$Sheet1.$A$1"); + dispatchCommand(mxComponent, ".uno:Paste", {}); + + // Make sure the chart object exists. + ScDocument* pDoc = getScDoc(); + ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); + const SdrPage* pPage = pDrawLayer->GetPage(0); + CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index ed4f4ff4076c..4fac946caf1d 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -1996,7 +1996,7 @@ void ScDrawLayer::CopyFromClip(ScDrawLayer* pClipModel, SCTAB nSourceTab, } else // Object is anchored to page. { - aSrcObjStart = pClipDoc->GetRange(nClipTab, pOldObject->GetCurrentBoundRect()).aStart; + aSrcObjStart = pClipDoc->GetRange(nSourceTab, pOldObject->GetCurrentBoundRect()).aStart; } if (!rSourceRange.Contains(aSrcObjStart)) continue;