summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-07-30 21:22:23 +0200
committerAndras Timar <andras.timar@collabora.com>2018-09-12 09:43:35 +0200
commit43816e78744afdddd5116d8d598fcdd2f3e8767c (patch)
tree48c09b38813a3715fd9744e3d1e549ad4d1b3eab
parente299a443d67d16a41a82457a660afe28364b7c90 (diff)
tdf#37223 insert OLE tables in text tables as native text tables
to solve the long-standing problem of Calc/Writer integration, ie. now Calc table data are inserted cell by cell in Writer text tables instead of putting an unwanted second table over the original, as an OLE object. First insert the OLE table as a nested native table using paste special as RTF, and cut and paste that to get a native table insertion, removing also the temporary nested table. This fix has got correct undo, but unfortunately, also a small flash during insertion by the temporary nested table. I've tried to fix that by LockView and LockModify, but it seems, they don't help. Note: the planned solution mentioned in the original OOo issue (reported in 2004) suggested to use a hidden temporary document, but that has got poblems with clipboard usage. Change-Id: I49253239f1878bce5fc4c93494f997ed37101a1c Reviewed-on: https://gerrit.libreoffice.org/58346 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 80d3d1044a1ad921bff990e2c4bb4dbf7c0a35c6)
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx31
1 files changed, 28 insertions, 3 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index e82f6d95cb70..a89182f0f8ee 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1154,9 +1154,11 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
&nActionFlags );
}
+ bool bInsertOleTable = ( EXCHG_OUT_ACTION_INSERT_OLE == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) ||
+ rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) );
+
// content of 1-cell tables is inserted as simple text
- if( EXCHG_OUT_ACTION_INSERT_OLE == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) ||
- rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) )
+ if (bInsertOleTable)
{
OUString aExpand;
if( rData.GetString( SotClipboardFormatId::STRING, aExpand ))
@@ -1172,8 +1174,11 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
}
}
+ bool bInsertOleTableInTable = (bInsertOleTable && !bSingleCellTable &&
+ (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr));
+
// special case for tables from draw application or 1-cell tables
- if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable )
+ if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable || bInsertOleTableInTable )
{
if( rData.HasFormat( SotClipboardFormatId::RTF ) )
{
@@ -1187,6 +1192,26 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
}
}
+ // tdf#37223 insert OLE table in text tables as a native text table
+ // (first as an RTF nested table, and cut and paste that to get a
+ // native table insertion, removing also the temporary nested table)
+ // TODO set a working view lock to avoid of showing the temporary nested table for a moment
+ if (bInsertOleTableInTable && EXCHG_OUT_ACTION_INSERT_STRING == nAction)
+ {
+ bool bPasted = SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
+ nDestination, false, false, nullptr, 0, false, nAnchorType );
+ if (bPasted && rSh.DoesUndo())
+ {
+ SfxDispatcher* pDispatch = rSh.GetView().GetViewFrame()->GetDispatcher();
+ pDispatch->Execute(FN_PREV_TABLE, SfxCallMode::SYNCHRON);
+ pDispatch->Execute(FN_TABLE_SELECT_ALL, SfxCallMode::SYNCHRON);
+ pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON);
+ pDispatch->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
+ pDispatch->Execute(SID_PASTE, SfxCallMode::SYNCHRON);
+ }
+ return bPasted;
+ }
+
return EXCHG_INOUT_ACTION_NONE != nAction &&
SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
nDestination, false, false, nullptr, 0, false, nAnchorType );