summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Arato (NISZ) <arato.daniel@nisz.hu>2020-09-08 16:56:58 +0200
committerLászló Németh <nemeth@numbertext.org>2020-09-14 12:51:21 +0200
commita354b7f7476513e5b1b4bbf1986b483cf122d47b (patch)
tree791f2fc4822fc54ad4b301b2df72baf32ce71edd
parent07a695ec1988ee8b02256cab2e07a1b429ead24b (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx18
1 files changed, 18 insertions, 0 deletions
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 ))
{