diff options
author | László Németh <nemeth@numbertext.org> | 2023-01-02 13:36:42 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-01-03 09:54:27 +0000 |
commit | c9129bd97a9514e5679ed65bdf5879718f1b476d (patch) | |
tree | 883ae3f80512ff83faf8058487435a74280cea5d /sw | |
parent | 88ebc324a51f16df0248d6a0d53d2169b1995dda (diff) |
tdf#152245 sw change tracking: fix copy from Calc to Writer tables
Pasting Calc tables into Writer tables uses temporary table
deletion, which never occured if change tracking was enabled,
resulting freezing. Fix this by disabling change tracking
during temporarily, also add a limit for other potential cases,
where it's not possible to delete the table.
Regression from commit 05366b8e6683363688de8708a3d88cf144c7a2bf
"tdf#60382 sw offapi: add change tracking of table/row deletion".
Change-Id: I57874fa658652b30fc78b267ab49a52d7277a838
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144946
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/table/sheetToTable.py | 36 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 19 |
2 files changed, 54 insertions, 1 deletions
diff --git a/sw/qa/uitest/table/sheetToTable.py b/sw/qa/uitest/table/sheetToTable.py index 11b9fe89b490..4a40b6966935 100644 --- a/sw/qa/uitest/table/sheetToTable.py +++ b/sw/qa/uitest/table/sheetToTable.py @@ -114,4 +114,38 @@ class sheetToTable(UITestCase): self.assertEqual(table.getCellByName("A3").getString(), "Test 3") self.assertEqual(table.getCellByName("A4").getString(), "Test 4") -# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file + def test_tdf152245(self): + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Test 1") + enter_text_to_cell(gridwin, "A2", "Test 2") + enter_text_to_cell(gridwin, "A3", "Test 3") + enter_text_to_cell(gridwin, "A4", "Test 4") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + self.xUITest.executeCommand(".uno:Copy") + + + with self.ui_test.load_empty_file("writer") as writer_doc: + + self.xUITest.executeCommand(".uno:InsertTable?Columns:short=1&Rows:short=4") + + # redlining should be on + self.xUITest.executeCommand(".uno:TrackChanges") + + # This was freezing + self.xUITest.executeCommand(".uno:Paste") + + self.assertEqual(writer_doc.TextTables.getCount(), 1) + table = writer_doc.getTextTables()[0] + self.assertEqual(len(table.getRows()), 4) + self.assertEqual(table.getCellByName("A1").getString(), "Test 1") + self.assertEqual(table.getCellByName("A2").getString(), "Test 2") + self.assertEqual(table.getCellByName("A3").getString(), "Test 3") + self.assertEqual(table.getCellByName("A4").getString(), "Test 4") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 8c6d6bda92eb..d9a6db5c1bb5 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1519,16 +1519,35 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt { SfxDispatcher* pDispatch = rSh.GetView().GetViewFrame()->GetDispatcher(); sal_uInt32 nLevel = 0; + // within Writer table cells, inserting worksheets using HTML format results only plain text, not a native table, // so remove all outer nested tables temporary to get a working insertion point // (RTF format has no such problem, but that inserts the hidden rows of the original Calc worksheet, too) + + // For this, switch off change tracking temporarily, if needed + RedlineFlags eOld = rSh.GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags(); + if ( eOld & RedlineFlags::On ) + rSh.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eOld & ~RedlineFlags::On ); + + OUString sPreviousTableName; do { + // tdf#152245 add a limit to the loop, if it's not possible to delete the table + const SwTableNode* pNode = rSh.GetCursor()->GetPointNode().FindTableNode(); + const OUString sTableName = pNode->GetTable().GetFrameFormat()->GetName(); + if ( sTableName == sPreviousTableName ) + break; + sPreviousTableName = sTableName; // insert a random character to redo the place of the insertion at the end pDispatch->Execute(FN_INSERT_NNBSP, SfxCallMode::SYNCHRON); pDispatch->Execute(FN_TABLE_DELETE_TABLE, SfxCallMode::SYNCHRON); nLevel++; } while (SwDoc::IsInTable(rSh.GetCursor()->GetPointNode()) != nullptr); + + // restore change tracking settings + if ( eOld & RedlineFlags::On ) + rSh.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eOld ); + if ( SwTransferable::PasteData( rData, rSh, EXCHG_OUT_ACTION_INSERT_STRING, nActionFlags, SotClipboardFormatId::HTML, nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable) ) { |