diff options
author | scito <info@scito.ch> | 2021-05-21 13:11:51 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-05-21 17:01:24 +0200 |
commit | de4c23fb38a7848e1030075b9c15cbb5c558694c (patch) | |
tree | 0c787bc7e8613159920da304b89b5bfbe2387103 /sc/qa/unit | |
parent | 2eb95408912f2292e2c7e8634c628a29f6c241b7 (diff) |
tdf#68976 cut paste transposed: fix wrong position in clipdoc
The transposed cells were written always in A1 of the transposed clip.
This is no problem for copy paste transposed. However, this is an issue for
cut paste transposed as references of formulas pointing to cut cells are
adjusted according to position changes.
The solution is to write the transposed cells in the same top left
corner of the transposed clipdoc as in the original non-transposed clipdoc.
There are still issues with cut paste transposed: Formula references are
not updated correctly in some cases (tdf#142065, tdf#142201).
Comprehensive unit tests will follow with fixes for tdf#142065 and
tdf#142201.
Change-Id: Id691fabf89d7f25e05182b20bd379299fc18fbb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115535
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/ucalc_copypaste.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index 0bbd326eb128..35c1bb72f276 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -114,6 +114,7 @@ public: void testCopyPasteFormulas(); void testCopyPasteFormulasExternalDoc(); void testCopyPasteReferencesExternalDoc(); // tdf#106456 + void testTdf68976(); void testTdf71058(); CPPUNIT_TEST_SUITE(TestCopyPaste); @@ -189,6 +190,7 @@ public: CPPUNIT_TEST(testCopyPasteFormulasExternalDoc); CPPUNIT_TEST(testCopyPasteReferencesExternalDoc); + CPPUNIT_TEST(testTdf68976); CPPUNIT_TEST(testTdf71058); CPPUNIT_TEST_SUITE_END(); @@ -6820,6 +6822,48 @@ void TestCopyPaste::testCopyPasteReferencesExternalDoc() xExtDocSh->DoClose(); } +void TestCopyPaste::testTdf68976() +{ + const SCTAB nTab = 0; + m_pDoc->InsertTab(nTab, "Test"); + + m_pDoc->SetValue(0, 0, nTab, 1.0); // A1 + m_pDoc->SetString(0, 1, nTab, "=$A$1"); // A2 + m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3 + + // Cut A3 to the clip document. + ScDocument aClipDoc(SCDOCMODE_CLIP); + ScRange aSrcRange(0, 2, nTab, 0, 2, nTab); + cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false); // A3 + + ScRange aDestRange(1, 3, nTab, 1, 3, nTab); // B4 + ScMarkData aDestMark(m_pDoc->GetSheetLimits()); + + // Transpose + ScDocument* pOrigClipDoc = &aClipDoc; + ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP)); + aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true); + aDestMark.SetMarkArea(aDestRange); + // Paste + m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), + true, false, true, false); + m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr); + pTransClip.reset(); + + // Check results + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, nTab)); // A1 + // Without the fix in place, this would have failed with + // - Expected: =$A$1 + // - Actual : =$B$4 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, nTab), "$A$1", "Wrong formula"); + // Without the fix in place, this would have failed with + // - Expected: 1 + // - Actual : 1000 + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 1, nTab)); // A2 + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 2, nTab)); // A3 + CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(1, 3, nTab)); // B4 +} + void TestCopyPaste::testTdf71058() { const SCTAB nTab = 0; |