summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-07-30 21:22:23 +0200
committerLászló Németh <nemeth@numbertext.org>2018-08-01 13:36:10 +0200
commit80d3d1044a1ad921bff990e2c4bb4dbf7c0a35c6 (patch)
treeadfd3f89bfe0e5f1cd426f3a6816c46ca99f4a2b
parent64b18c37c55dcac472e0344f7ac61a12d81e51c5 (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>
-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 d69c680a0424..a9a5fa476219 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 );