diff options
author | Tor Lillqvist <tml@collabora.com> | 2022-01-27 13:07:53 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2022-01-28 09:33:46 +0100 |
commit | 7517fc118a1a230ff59f6c629316a8e7e1282dff (patch) | |
tree | cb565c9856c1ac7e981558a7d6067307ab013c8b | |
parent | 00e28abcd33f7a52539cb0250b1cadcaf22f8f35 (diff) |
Enable pasting PDF into Impress
Just like when doing Insert>Image... of a PDF file, you get a bitmap
of the rendering of the first page of the PDF, not separately editable
shapes or text. The pasted PDF document is included when exporting to
.odp at least, just like for Insert>Image...
I don't know how common or easy it is on Windows or various Linux
desktops to have PDF format data on the clipboard, but at least on
macOS, if you select a rectangle of a PDF document viewed in the
Preview app, and do Edit>Copy, a PDF document is put on the
pasteboard. (Preview also puts a TIFF rendering of the selection on
the pasteboard, but for some reason that is of ridiculously low
resolution. That is what used to get pasted into Impress previously.)
Change-Id: Ic4b29deb12609dd839d8578779600156ff1ec48b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129049
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r-- | sd/source/ui/view/sdview3.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 5008c8d8ddd4..5b0fcc424313 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -40,7 +40,9 @@ #include <svx/unomodel.hxx> #include <svx/ImageMapInfo.hxx> #include <unotools/streamwrap.hxx> +#include <vcl/graph.hxx> #include <vcl/metaact.hxx> +#include <vcl/pdfread.hxx> #include <vcl/TypeSerializer.hxx> #include <svx/svxids.hrc> #include <toolkit/helper/vclunohelper.hxx> @@ -680,6 +682,29 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, } } + if(!bReturn && CHECK_FORMAT_TRANS( SotClipboardFormatId::PDF )) + { + ::tools::SvRef<SotTempStream> xStm; + if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::PDF, xStm ) ) + { + Point aInsertPos(rPos); + Graphic aGraphic; + if (vcl::ImportPDF(*xStm, aGraphic)) + { + std::unique_ptr<sal_uInt8[]> pGraphicContent; + + const sal_Int32 nGraphicContentSize(xStm->Tell()); + pGraphicContent.reset(new sal_uInt8[nGraphicContentSize]); + xStm->Seek(0); + xStm->ReadBytes(pGraphicContent.get(), nGraphicContentSize); + aGraphic.SetGfxLink(std::make_shared<GfxLink>(std::move(pGraphicContent), nGraphicContentSize, GfxLinkType::NativePdf)); + + InsertGraphic(aGraphic, mnAction, aInsertPos, nullptr, nullptr); + bReturn = true; + } + } + } + if(!bReturn && CHECK_FORMAT_TRANS( SotClipboardFormatId::DRAWING )) { ::tools::SvRef<SotTempStream> xStm; |