[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 1 11:36:32 UTC 2018


 sw/source/uibase/dochdl/swdtflvr.cxx |   31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

New commits:
commit 80d3d1044a1ad921bff990e2c4bb4dbf7c0a35c6
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Jul 30 21:22:23 2018 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Aug 1 13:36:10 2018 +0200

    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 at numbertext.org>

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 );


More information about the Libreoffice-commits mailing list