summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-03-14 00:47:35 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-03-14 07:06:03 +0000
commit8137bcb9c2915b179c541154cee050a11c54ba59 (patch)
tree23aebbc75481df297dba152dd2358e82cc660947
parentb132445fc7b067b4a920a9648c180381332f05b0 (diff)
add test for tdf#106456
Change-Id: Icf8a52db84536ef540c5dcffceabfbeb5c1deb02 Reviewed-on: https://gerrit.libreoffice.org/35153 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/qa/unit/ucalc.cxx44
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4fda600077b1..9a51d92f7a96 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4909,6 +4909,50 @@ void Test::testCopyPasteFormulasExternalDoc()
xExtDocSh->DoClose();
}
+void Test::testCopyPasteReferencesExternalDoc()
+{
+ OUString aDocName("file:///source.fake");
+ SfxMedium* pMedium = new SfxMedium(aDocName, StreamMode::STD_READWRITE);
+ getDocShell().DoInitNew(pMedium);
+ m_pDoc = &getDocShell().GetDocument();
+
+ ScDocShellRef xExtDocSh = new ScDocShell;
+ xExtDocSh->SetIsInUcalc();
+ OUString aExtDocName("file:///extdata.fake");
+ OUString aExtSh1Name("ExtSheet1");
+ SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
+ xExtDocSh->DoInitNew(pMed);
+ CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
+ findLoadedDocShellByName(aExtDocName) != nullptr);
+
+ ScDocument& rExtDoc = xExtDocSh->GetDocument();
+ rExtDoc.InsertTab(0, aExtSh1Name);
+
+ m_pDoc->InsertTab(0, "Sheet1");
+
+ m_pDoc->SetString(0,5,0, "=SUM($Sheet1.A1:A5)");
+
+ ScRange aRange(0,2,0,0,5,0);
+ ScClipParam aClipParam(aRange, false);
+ ScMarkData aMark;
+ aMark.SetMarkArea(aRange);
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
+
+ InsertDeleteFlags nFlags = InsertDeleteFlags::ALL;
+ aRange = ScRange(0,0,0,0,3,0);
+ ScMarkData aMarkData2;
+ aMarkData2.SetMarkArea(aRange);
+ rExtDoc.CopyFromClip(aRange, aMarkData2, nFlags, nullptr, &aClipDoc);
+
+ OUString aFormula;
+ rExtDoc.GetFormula(0,3,0, aFormula);
+ //adjust absolute refs pointing to the copy area
+ CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=SUM('file:///source.fake'#$Sheet1.A#REF!:A3)"));
+
+ xExtDocSh->DoClose();
+}
+
void Test::testFindAreaPosVertical()
{
const char* aData[][3] = {
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 5d94547b2ceb..076e5b0e404a 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -422,6 +422,7 @@ public:
void testAutoFillSimple();
void testCopyPasteFormulas();
void testCopyPasteFormulasExternalDoc();
+ void testCopyPasteReferencesExternalDoc(); // tdf#106456
void testFindAreaPosVertical();
void testFindAreaPosColRight();
@@ -702,6 +703,7 @@ public:
CPPUNIT_TEST(testAutoFillSimple);
CPPUNIT_TEST(testCopyPasteFormulas);
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
+ CPPUNIT_TEST(testCopyPasteReferencesExternalDoc);
CPPUNIT_TEST(testFindAreaPosVertical);
CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST(testSort);