[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 27 09:32:02 UTC 2018


 sw/source/uibase/dochdl/swdtflvr.cxx |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 73bd150048d056fb6e00de3f8b91347b7f642e91
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Fri Jul 20 17:49:21 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Fri Jul 27 11:31:34 2018 +0200

    tdf#37223 Writer: insert 1-cell tables as text instead of OLE object
    
    to get a user-friendly solution to copy Calc cell content to a text
    document and to its native tables.
    
    NOTE: MSO does the same for copying 1-cell tables, while LibreOffice
    was able to do this only with paste special as RTF.
    
    Change-Id: I6156333055aa9bed4cf56ff12f913e89d3f5700c
    Reviewed-on: https://gerrit.libreoffice.org/57783
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Reviewed-on: https://gerrit.libreoffice.org/57814
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 4e69db27180e..2eac04a31e5d 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1128,6 +1128,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
     SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
     SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
     SotExchangeActionFlags nActionFlags = SotExchangeActionFlags::NONE;
+    bool bSingleCellTable = false;
 
     if( GetSwTransferable( rData ) )
     {
@@ -1153,8 +1154,26 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
                                     &nActionFlags );
     }
 
-    // special case for tables from draw application
-    if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction )
+    // 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 ) ) )
+    {
+        OUString aExpand;
+        if( rData.GetString( SotClipboardFormatId::STRING, aExpand ))
+        {
+            const sal_Int32 nNewlines{comphelper::string::getTokenCount(aExpand, '\n')};
+            const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0;
+            if ( nRows == 1 )
+            {
+                const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t');
+                if (nCols == 1)
+                    bSingleCellTable = true;
+            }
+        }
+    }
+
+    // special case for tables from draw application or 1-cell tables
+    if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable )
     {
         if( rData.HasFormat( SotClipboardFormatId::RTF ) )
         {


More information about the Libreoffice-commits mailing list