From 34116936e5a90400d1fff678719a081d69b484d7 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 20 Jul 2019 11:22:09 +0100 Subject: clipboard: encourage paste to show up by having some dummy content. Having an empty system clipboard is a hyper-unusual state, but quite common for lok instances - so hide that with the dummy state. Allows context-menu paste into new documents. Change-Id: I9ce04cb8a0abfa054a67cb94922d7ac5992d1b29 --- desktop/source/lib/lokclipboard.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'desktop/source/lib/lokclipboard.cxx') diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx index f53202903761..17a9c5c54e4f 100644 --- a/desktop/source/lib/lokclipboard.cxx +++ b/desktop/source/lib/lokclipboard.cxx @@ -69,6 +69,9 @@ LOKClipboard::LOKClipboard() : cppu::WeakComponentImplHelper(m_aMutex) { + // Encourage 'paste' menu items to always show up. + uno::Reference xTransferable(new LOKTransferable()); + setContents(xTransferable, uno::Reference()); } Sequence LOKClipboard::getSupportedServiceNames_static() @@ -150,6 +153,18 @@ LOKTransferable::LOKTransferable(const OUString& sMimeType, aContent <<= aSequence; m_aContent.push_back(aContent); } + +/// Use to ensure we have some dummy content on the clipboard to allow a 1st 'paste' +LOKTransferable::LOKTransferable() +{ + m_aContent.reserve(1); + m_aFlavors = css::uno::Sequence(1); + initFlavourFromMime(m_aFlavors[0], "text/plain"); + uno::Any aContent; + aContent <<= OUString(); + m_aContent.push_back(aContent); +} + // cf. sot/source/base/exchange.cxx for these two exceptional types. void LOKTransferable::initFlavourFromMime(css::datatransfer::DataFlavor& rFlavor, OUString aMimeType) -- cgit v1.2.3