Kaydet (Commit) 4f94e6c2 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Fix paste as link, and a test case to catch it in the future.

Change-Id: I55fd3fabb7594ee2c635cc0b02dbf506bd5ab3df
üst 77e7301a
......@@ -3171,6 +3171,44 @@ void Test::testCopyPaste()
m_pDoc->DeleteTab(0);
}
void Test::testCopyPasteAsLink()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
m_pDoc->SetValue(ScAddress(0,0,0), 1); // A1
m_pDoc->SetValue(ScAddress(0,1,0), 2); // A2
m_pDoc->SetValue(ScAddress(0,2,0), 3); // A3
ScRange aRange(0,0,0,0,2,0); // Copy A1:A3 to clip.
ScDocument aClipDoc(SCDOCMODE_CLIP);
copyToClip(m_pDoc, aRange, &aClipDoc);
aRange = ScRange(1,1,1,1,3,1); // Paste to B2:B4 on Sheet2.
ScMarkData aMark;
aMark.SetMarkArea(aRange);
// Paste range as link.
m_pDoc->CopyFromClip(aRange, aMark, IDF_CONTENTS, NULL, &aClipDoc, true, true);
// Check pasted content to make sure they reference the correct cells.
ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,1));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,1));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
pFC = m_pDoc->GetFormulaCell(ScAddress(1,3,1));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
CPPUNIT_ASSERT_EQUAL(3.0, pFC->GetValue());
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
void Test::testCopyPasteTranspose()
{
......
......@@ -220,6 +220,7 @@ public:
void testDataArea();
void testAutofilter();
void testCopyPaste();
void testCopyPasteAsLink();
void testCopyPasteTranspose();
void testMoveBlock();
void testCopyPasteRelativeFormula();
......@@ -362,8 +363,9 @@ public:
CPPUNIT_TEST(testToggleRefFlag);
CPPUNIT_TEST(testAutofilter);
CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testMoveBlock);
CPPUNIT_TEST(testCopyPasteAsLink);
CPPUNIT_TEST(testCopyPasteTranspose);
CPPUNIT_TEST(testMoveBlock);
CPPUNIT_TEST(testCopyPasteRelativeFormula);
CPPUNIT_TEST(testMergedCells);
CPPUNIT_TEST(testUpdateReference);
......
......@@ -690,7 +690,7 @@ class CopyCellsFromClipHandler
void insertRefCell(SCROW nSrcRow, SCROW nDestRow)
{
ScAddress aSrcPos(mnCol, nSrcRow, mnTab);
ScAddress aSrcPos(mnSrcCol, nSrcRow, mnSrcTab);
ScAddress aDestPos(mnCol, nDestRow, mnTab);
ScSingleRefData aRef;
aRef.InitAddress(aSrcPos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment