sc/qa/unit/ucalc.cxx |   44 ++++++++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx |    2 ++
 2 files changed, 46 insertions(+)

New commits:
commit 8137bcb9c2915b179c541154cee050a11c54ba59
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Tue Mar 14 00:47:35 2017 +0100

    add test for tdf#106456
    
    Change-Id: Icf8a52db84536ef540c5dcffceabfbeb5c1deb02
    Reviewed-on: https://gerrit.libreoffice.org/35153
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4fda600..9a51d92 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 5d94547..076e5b0 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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to