diff options
author | Henry Castro <hcastro@collabora.com> | 2019-04-18 18:10:13 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2019-04-26 15:28:11 +0200 |
commit | 2ead533d2383083925537832b473e3264811d454 (patch) | |
tree | 60792f8db8b1990adcc87000a0e415c36146d260 /desktop/source | |
parent | Access2Base - Error handling extended (diff) | |
download | core-2ead533d2383083925537832b473e3264811d454.tar.gz core-2ead533d2383083925537832b473e3264811d454.zip |
lok: allow paste content to popup dialog
Change-Id: I1893d52df505bc43428c37a624ca05c569ba1bc0
Reviewed-on: https://gerrit.libreoffice.org/70958
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/lib/init.cxx | 37 | ||||
-rw-r--r-- | desktop/source/lib/lokclipboard.cxx | 10 | ||||
-rw-r--r-- | desktop/source/lib/lokclipboard.hxx | 3 |
3 files changed, 45 insertions, 5 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index c4a36e9e182e..937331376024 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -358,6 +358,15 @@ std::vector<beans::PropertyValue> desktop::jsonToPropertyValuesVector(const char aValue.Value <<= static_cast<sal_Int16>(OString(rValue.c_str()).toInt32()); else if (rType == "unsigned short") aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); + else if (rType == "[]byte") + { + aNodeValue = rPair.second.get_child("value", aNodeNull); + if (aNodeValue != aNodeNull && aNodeValue.size() == 0) + { + uno::Sequence< sal_Int8 > aSeqByte(reinterpret_cast<const sal_Int8*>(rValue.c_str()), rValue.size()); + aValue.Value <<= aSeqByte; + } + } else if (rType == "[]any") { aNodeValue = rPair.second.get_child("value", aNodeNull); @@ -806,7 +815,7 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindo const int nWidth, const int nHeight, const double fDPIScale); -static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction); +static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction, const char* pData); static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart); @@ -4146,7 +4155,7 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW #endif } -static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction) +static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction, const char* pData) { comphelper::ProfileZone aZone("doc_postWindow"); @@ -4168,6 +4177,30 @@ static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindo else if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow.get())) pFloatWin->EndPopupMode(FloatWinPopupEndFlags::Cancel | FloatWinPopupEndFlags::CloseAll); } + else if (nAction == LOK_WINDOW_PASTE) + { + OUString aMimeType; + css::uno::Sequence<sal_Int8> aData; + std::vector<beans::PropertyValue> aArgs(jsonToPropertyValuesVector(pData)); + { + aArgs.size() == 2 && + aArgs[0].Name == "MimeType" && (aArgs[0].Value >>= aMimeType) && + aArgs[1].Name == "Data" && (aArgs[1].Value >>= aData); + } + + if (!aMimeType.isEmpty() && aData.getLength() > 0) + { + uno::Reference<datatransfer::XTransferable> xTransferable(new LOKTransferable(aMimeType, aData)); + uno::Reference<datatransfer::clipboard::XClipboard> xClipboard(new LOKClipboard); + xClipboard->setContents(xTransferable, uno::Reference<datatransfer::clipboard::XClipboardOwner>()); + pWindow->SetClipboard(xClipboard); + + KeyEvent aEvent(0, KEY_PASTE, 0); + Application::PostKeyEvent(VclEventId::WindowKeyInput, pWindow, &aEvent); + } + else + gImpl->maLastExceptionMsg = "Window command 'paste': wrong parameters."; + } } // CERTIFICATE AND DOCUMENT SIGNING diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx index 091bd47d35db..b02dc3ca172b 100644 --- a/desktop/source/lib/lokclipboard.cxx +++ b/desktop/source/lib/lokclipboard.cxx @@ -29,11 +29,17 @@ OUString SAL_CALL LOKClipboard::getName() } LOKTransferable::LOKTransferable(const char* pMimeType, const char* pData, std::size_t nSize) - : m_aMimeType(pMimeType), + : m_aMimeType(OUString::fromUtf8(pMimeType)), m_aSequence(reinterpret_cast<const sal_Int8*>(pData), nSize) { } +LOKTransferable::LOKTransferable(const OUString& sMimeType, const css::uno::Sequence<sal_Int8>& aSequence) + : m_aMimeType(sMimeType), + m_aSequence(aSequence) +{ +} + uno::Any SAL_CALL LOKTransferable::getTransferData(const datatransfer::DataFlavor& rFlavor) { uno::Any aRet; @@ -51,7 +57,7 @@ std::vector<datatransfer::DataFlavor> LOKTransferable::getTransferDataFlavorsAsV { std::vector<datatransfer::DataFlavor> aRet; datatransfer::DataFlavor aFlavor; - aFlavor.MimeType = OUString::fromUtf8(m_aMimeType.getStr()); + aFlavor.MimeType = m_aMimeType; aFlavor.DataType = cppu::UnoType< uno::Sequence<sal_Int8> >::get(); sal_Int32 nIndex(0); diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx index 11c676500043..ae83eb6dd2e6 100644 --- a/desktop/source/lib/lokclipboard.hxx +++ b/desktop/source/lib/lokclipboard.hxx @@ -32,7 +32,7 @@ public: /// Represents the contents of LOKClipboard. class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable> { - OString m_aMimeType; + OUString m_aMimeType; css::uno::Sequence<sal_Int8> m_aSequence; /// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported(). @@ -40,6 +40,7 @@ class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransfer public: LOKTransferable(const char* pMimeType, const char* pData, std::size_t nSize); + LOKTransferable(const OUString& sMimeType, const css::uno::Sequence<sal_Int8>& aSequence); css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override; |