summaryrefslogtreecommitdiff
path: root/sw/source/uibase/dochdl/swdtflvr.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-12-09 20:38:40 +0100
committerLászló Németh <nemeth@numbertext.org>2020-12-10 10:16:50 +0100
commit7720f8cf22718415adb3db2304916581f864f884 (patch)
tree1d8e8ac8b156c81122a102f3446304fe2801fc1c /sw/source/uibase/dochdl/swdtflvr.cxx
parentb5f7658153d80e74d415a561f562808ea0255554 (diff)
tdf#138688 tdf#124646 sw: fix crash at pasting Calc data
.. in a table before a numbered paragraph. Dispatcher calls of the workaround for tdf#124646 missed the temporary table in this case, selecting + copying nothing and after that trying to paste the same non-native Calc data again, resulting infinite recursion. Replacing FN_CHAR_LEFT with FN_LINE_UP solved the problem (FN_CHAR_LEFT selected the numbers of the numbered list instead of the temporary table). Fixing the fragile dispatcher calls, now we check the selection of the temporary table to avoid similar crashes. Unit tests are added for the fix, also for the original problem of tdf#124646 (avoid copying hidden rows from Calc, e.g. copying only visible result of a filtering). Regression from commit 0c3ac02d8a3c7ea50ae262daf134c28df5c8b343 (tdf#124646 Don't paste hidden rows of Calc sheets into Writer tables). (Note: to check/show the fix of the crash manually, run the test with $ (cd sw && make -srj8 UITest_sw_table UITEST_TEST_NAME="sheetToTable.sheetToTable.test_tdf138688" SAL_USE_VCLPLUGIN=gen) adding import time time.sleep(5) to the called function of sheetToTable.py) Change-Id: I7b90af8219d6fd00b75d91f7c92fff5744373cc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107508 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/uibase/dochdl/swdtflvr.cxx')
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 940eca0bedc1..784683be6603 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1527,11 +1527,20 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
if ( SwTransferable::PasteData( rData, rSh, EXCHG_OUT_ACTION_INSERT_STRING, nActionFlags, SotClipboardFormatId::HTML,
nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable) )
{
- pDispatch->Execute(FN_CHAR_LEFT, SfxCallMode::SYNCHRON);
- pDispatch->Execute(FN_TABLE_SELECT_ALL, SfxCallMode::SYNCHRON);
- pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON);
+ bool bFoundTemporaryTable = false;
+ pDispatch->Execute(FN_LINE_UP, SfxCallMode::SYNCHRON);
+ if (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr)
+ {
+ bFoundTemporaryTable = true;
+ pDispatch->Execute(FN_TABLE_SELECT_ALL, SfxCallMode::SYNCHRON);
+ pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON);
+ }
for(sal_uInt32 a = 0; a < 1 + (nLevel * 2); a++)
pDispatch->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
+ // clipboard content hasn't changed (limit potential infinite
+ // recursion with the same non-native table, as was in tdf#138688)
+ if (!bFoundTemporaryTable)
+ return false;
if (ePasteTable == PasteTableType::PASTE_TABLE)
pDispatch->Execute(FN_PASTE_NESTED_TABLE, SfxCallMode::SYNCHRON);
else if (ePasteTable == PasteTableType::PASTE_ROW)