sw/source/uibase/dochdl/swdtflvr.cxx |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit a354b7f7476513e5b1b4bbf1986b483cf122d47b
Author:     Daniel Arato (NISZ) <arato.dan...@nisz.hu>
AuthorDate: Tue Sep 8 16:56:58 2020 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Sep 14 12:51:21 2020 +0200

    tdf#135669 sw: drag and drop other files as OLE
    
    from file managers.
    
    Native text, PDF and image file formats were supported,
    but now spreadsheet and DOCX documents, too. The same
    feature was already implemented in e.g. Impress.
    
    Note: DOCX files inserted as OLE objects yet, and not
    linked files in sections, as ODTs (but it's possible saving
    and printing them via Save As option of the local menu
    of the OLE object).
    
    Change-Id: Ia2fafe4a0b79dc0c66eaec5ad073c994f98e1345
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102263
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 52c6b47d469f..745731327a09 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2246,6 +2246,19 @@ bool SwTransferable::PasteOLE( TransferableDataHelper& 
rData, SwWrtShell& rSh,
                     }
                 }
             }
+            else if (rData.HasFormat(SotClipboardFormatId::SIMPLE_FILE))
+            {
+                OUString sFile;
+                if (rData.GetString(nFormat, sFile) && !sFile.isEmpty())
+                {
+                    // Copied from sd::View::DropInsertFileHdl
+                    uno::Sequence< beans::PropertyValue > aMedium(1);
+                    aMedium[0].Name = "URL";
+                    aMedium[0].Value <<= sFile;
+                    SwDocShell* pDocSh = rSh.GetDoc()->GetDocShell();
+                    xObj = 
pDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject(aMedium, aName);
+                }
+            }
         }
 
         if ( xStrm.is() && !xObj.is() )
@@ -3023,6 +3036,11 @@ bool SwTransferable::PasteFileName( 
TransferableDataHelper& rData,
                     rSh.StartInsertRegionDialog( aSect ); // starts dialog 
asynchronously
                     bRet = true;
                 }
+                else if (SwPasteSdr::Insert == nAction && 
rData.HasFormat(SotClipboardFormatId::SIMPLE_FILE))
+                {
+                    // insert file as OLE
+                    PasteOLE(rData, rSh, nFormat, nActionFlags, nullptr == 
pPt);
+                }
                 else if( SwPasteSdr::SetAttr == nAction ||
                         ( bIsURLFile && SwPasteSdr::Insert == nAction ))
                 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to