diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc_copypaste.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/data/documen3.cxx | 9 |
2 files changed, 25 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index bad57d8646a7..575cfb90f9f7 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -10752,6 +10752,23 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, testUndoBackgroundColor) m_pDoc->DeleteTab(0); } +CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMergedHyperlink) +{ + m_pDoc->InsertTab(0, "Table1"); + m_pDoc->InitDrawLayer(m_xDocShell.get()); + + ScFieldEditEngine& pEE = m_pDoc->GetEditEngine(); + pEE.SetTextCurrentDefaults("https://libreoffice.org/"); + m_pDoc->SetEditText(ScAddress(1, 0, 0), pEE.CreateTextObject()); // B1 + + m_pDoc->DoMergeContents(0, 0, 1, 0, 0); // A1:B1 + + CPPUNIT_ASSERT_EQUAL(CELLTYPE_EDIT, m_pDoc->GetCellType(ScAddress(0, 0, 0))); // A1 + const EditTextObject* pEditObj = m_pDoc->GetEditText(ScAddress(0, 0, 0)); // A1 + CPPUNIT_ASSERT(pEditObj); + CPPUNIT_ASSERT_EQUAL(OUString("https://libreoffice.org/"), pEditObj->GetText(0)); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 73cf516c4d49..b52deed7d85b 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -2030,6 +2030,7 @@ void ScDocument::DoMergeContents( SCCOL nStartCol, SCROW nStartRow, OUString aCellStr; SCCOL nCol; SCROW nRow; + ScCellValue aCell; for (nRow=nStartRow; nRow<=nEndRow; nRow++) for (nCol=nStartCol; nCol<=nEndCol; nCol++) { @@ -2039,12 +2040,18 @@ void ScDocument::DoMergeContents( SCCOL nStartCol, SCROW nStartRow, if (!aTotal.isEmpty()) aTotal.append(' '); aTotal.append(aCellStr); + ScAddress aPos(nCol, nRow, nTab); + if ((GetCellType(aPos) == CELLTYPE_EDIT) && aCell.isEmpty()) + aCell = ScRefCellValue(*this, aPos); } if (nCol != nStartCol || nRow != nStartRow) SetString(nCol,nRow,nTab,""); } - SetString(nStartCol,nStartRow,nTab,aTotal.makeStringAndClear()); + if (aCell.isEmpty() || !GetString(nStartCol, nStartRow, nTab).isEmpty()) + SetString(nStartCol, nStartRow, nTab, aTotal.makeStringAndClear()); + else + aCell.release(*this, ScAddress(nStartCol, nStartRow, nTab)); } void ScDocument::DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow, |