summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-07-20 11:22:09 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-07-27 14:17:28 -0400
commitbf940df64a8bd00db7ab44fcdef5af4edcbd75bf (patch)
treeb1735544a162efa4a2e9ae6a17eeb65210f5623d
parent3b2ff8bb3233af8d208508730c3c29aee04b8938 (diff)
clipboard: encourage paste to show up by having some dummy content.
Having an empty system clipboard is a hyper-unusual state, but this is quite common for new lok instances. If we populate some dummy state we can hide that. Allows context-menu paste into new documents. Change-Id: Ia180dd370c180d2d666cc57330db6c1385578a36
-rw-r--r--desktop/source/lib/lokclipboard.cxx15
-rw-r--r--desktop/source/lib/lokclipboard.hxx1
-rw-r--r--vcl/source/treelist/transfer.cxx2
3 files changed, 17 insertions, 1 deletions
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
index 18b728c2343a..c85ac029406c 100644
--- a/desktop/source/lib/lokclipboard.cxx
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -69,6 +69,9 @@ LOKClipboard::LOKClipboard()
: cppu::WeakComponentImplHelper<css::datatransfer::clipboard::XSystemClipboard,
css::lang::XServiceInfo>(m_aMutex)
{
+ // Encourage 'paste' menu items to always show up.
+ uno::Reference<datatransfer::XTransferable> xTransferable(new LOKTransferable());
+ setContents(xTransferable, uno::Reference<datatransfer::clipboard::XClipboardOwner>());
}
Sequence<OUString> 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<css::datatransfer::DataFlavor>(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)
diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx
index 90e41176fee4..6c0509265db4 100644
--- a/desktop/source/lib/lokclipboard.hxx
+++ b/desktop/source/lib/lokclipboard.hxx
@@ -77,6 +77,7 @@ class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransfer
static void initFlavourFromMime(css::datatransfer::DataFlavor& rFlavor, OUString sMimeType);
public:
+ LOKTransferable();
LOKTransferable(const size_t nInCount, const char** pInMimeTypes, const size_t* pInSizes,
const char** pInStreams);
LOKTransferable(const OUString& sMimeType, const css::uno::Sequence<sal_Int8>& aSequence);
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 10782592f5a2..5e41bde0378d 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -392,7 +392,7 @@ sal_Bool SAL_CALL TransferableHelper::isComplex()
{
// By default everything is complex, until proven otherwise
// in the respective document type transferable handler.
- return sal_True;
+ return true;
}
Sequence< DataFlavor > SAL_CALL TransferableHelper::getTransferDataFlavors()