sc: add a regression test for a grouped-sheet copy of a named table
A grouped-sheet copy applies the same area to each selected sheet, so only the tables on the copied sheet are carried into the clipboard, not a same-area table living on another selected sheet. The paste side therefore never receives tables from several sheets that it would then place onto a single destination sheet. The engine already behaves this way. This test guards against a regression that would carry a table from another sheet into the clipboard. Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Change-Id: Icb6b5c0db0df4819ae2c2b45d3d81e173e586993 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5096 Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com> Reviewed-by: Balázs Varga <balazs.varga@collabora.com> (cherry picked from commit a9ab487333670a2cbfd03c2382af87f2cc1bb387) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207945 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
499ca3e23e
commit
4c787b42eb
@@ -10226,6 +10226,41 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyToClipMultiRangeGapTable)
|
||||
m_pDoc->DeleteTab(0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyToClipMultiSheetForeignTable)
|
||||
{
|
||||
// A grouped-sheet copy carries only the tables on the sheet whose cells are
|
||||
// copied, not a same-area table living on another selected sheet. So the
|
||||
// paste side never receives tables from several sheets that would all be
|
||||
// placed onto a single destination sheet.
|
||||
m_pDoc->InsertTab(0, u"Sheet1"_ustr);
|
||||
m_pDoc->InsertTab(1, u"Sheet2"_ustr);
|
||||
|
||||
auto pTab0 = std::make_unique<ScDBData>(u"Table0"_ustr, 0, 0, 0, 1, 1, true, true);
|
||||
CPPUNIT_ASSERT(m_pDoc->GetDBCollection()->getNamedDBs().insert(std::move(pTab0)));
|
||||
auto pTab1 = std::make_unique<ScDBData>(u"Table1"_ustr, 1, 0, 0, 1, 1, true, true);
|
||||
CPPUNIT_ASSERT(m_pDoc->GetDBCollection()->getNamedDBs().insert(std::move(pTab1)));
|
||||
|
||||
// Copy A1:B2 with both sheets grouped. The copied ranges live on sheet 0.
|
||||
ScMarkData aMark(m_pDoc->GetSheetLimits());
|
||||
aMark.SelectTable(0, true);
|
||||
aMark.SelectTable(1, true);
|
||||
ScRange aClipRange(0, 0, 0, 1, 1, 0); // A1:B2 on sheet 0
|
||||
aMark.SetMarkArea(aClipRange);
|
||||
ScClipParam aClipParam(aClipRange, false);
|
||||
|
||||
ScDocument aClipDoc(SCDOCMODE_CLIP);
|
||||
m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
|
||||
|
||||
ScDBCollection::NamedDBs& rClipDBs = aClipDoc.GetDBCollection()->getNamedDBs();
|
||||
CPPUNIT_ASSERT_MESSAGE("the copied sheet's table is carried",
|
||||
rClipDBs.findByUpperName(u"TABLE0"_ustr));
|
||||
CPPUNIT_ASSERT_MESSAGE("a table on another sheet is not carried",
|
||||
!rClipDBs.findByUpperName(u"TABLE1"_ustr));
|
||||
|
||||
m_pDoc->DeleteTab(1);
|
||||
m_pDoc->DeleteTab(0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteFormulasExternalDoc)
|
||||
{
|
||||
SfxMedium* pMedium = new SfxMedium(u"file:///source.fake"_ustr, StreamMode::STD_READWRITE);
|
||||
|
||||
Reference in New Issue
Block a user