11#include <unordered_map>
17#include <com/sun/star/uno/XComponentContext.hpp>
20using namespace css::uno;
29 osl::MutexGuard aGuard(
gMutex);
34 SAL_INFO(
"lok",
"Got clip: " << it->second.get() <<
" from " << nViewId);
39 SAL_INFO(
"lok",
"Created clip: " << xClip.get() <<
" for viewId " << nViewId);
45 osl::MutexGuard aGuard(
gMutex);
50 SAL_INFO(
"lok",
"Released all clipboards on doc destroy\n");
57 SAL_INFO(
"lok",
"Releasing clip: " << it->second.get() <<
" for destroyed " << nViewId);
70 :
cppu::WeakComponentImplHelper<css::datatransfer::clipboard::XSystemClipboard,
80 Sequence<OUString> aRet{
"com.sun.star.datatransfer.clipboard.LokClipboard" };
99 const Reference<css::datatransfer::XTransferable>& xTrans,
100 const Reference<css::datatransfer::clipboard::XClipboardOwner>& xClipboardOwner)
102 osl::ClearableMutexGuard aGuard(
m_aMutex);
103 Reference<datatransfer::clipboard::XClipboardOwner> xOldOwner(
m_aOwner);
109 datatransfer::clipboard::ClipboardEvent aEv;
115 if (xOldOwner.is() && xOldOwner != xClipboardOwner)
116 xOldOwner->lostOwnership(
this, xOldContents);
119 listener->changedContents(aEv);
124 const Reference<datatransfer::clipboard::XClipboardListener>& listener)
126 osl::ClearableMutexGuard aGuard(
m_aMutex);
131 const Reference<datatransfer::clipboard::XClipboardListener>& listener)
133 osl::ClearableMutexGuard aGuard(
m_aMutex);
138 const css::uno::Sequence<sal_Int8>& aSequence)
141 m_aFlavors = css::uno::Sequence<css::datatransfer::DataFlavor>(1);
147 auto pText =
reinterpret_cast<const char*
>(aSequence.getConstArray());
148 aContent <<= OUString(pText, aSequence.getLength(), RTL_TEXTENCODING_UTF8);
151 aContent <<= aSequence;
159 m_aFlavors = css::uno::Sequence<css::datatransfer::DataFlavor>(1);
162 aContent <<= OUString();
175 else if (
aMimeType ==
"application/x-libreoffice-tsvc")
180 rFlavor.HumanPresentableName =
aMimeType;
184 const size_t* pInSizes,
const char** pInStreams)
187 m_aFlavors = css::uno::Sequence<css::datatransfer::DataFlavor>(nInCount);
189 for (
size_t i = 0;
i < nInCount; ++
i)
195 aContent <<= OUString(pInStreams[
i], pInSizes[
i], RTL_TEXTENCODING_UTF8);
197 aContent <<= css::uno::Sequence<sal_Int8>(
198 reinterpret_cast<const sal_Int8*
>(pInStreams[
i]), pInSizes[
i]);
211 SAL_WARN(
"lok",
"Horror type mismatch!");
226 [&rFlavor](
const datatransfer::DataFlavor&
i) {
227 return i.MimeType == rFlavor.MimeType &&
i.DataType == rFlavor.DataType;
232extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
234 css::uno::Sequence<css::uno::Any>
const& )
static rtl::Reference< LOKClipboard > getClipboardForCurView()
Fetch clipboard from the global pool.
static void releaseClipboardForView(int nViewId)
Release a clipboard before its document dies, nViewId of -1 clears all.
css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const css::uno::Sequence< css::uno::Any > &) override
A clipboard implementation for LibreOfficeKit.
OUString SAL_CALL getImplementationName() override
static Sequence< OUString > getSupportedServiceNames_static()
void SAL_CALL setContents(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, const css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner > &xClipboardOwner) override
std::vector< css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners
void SAL_CALL addClipboardListener(const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > &listener) override
void SAL_CALL removeClipboardListener(const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > &listener) override
css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner > m_aOwner
css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getContents() override
Sequence< OUString > SAL_CALL getSupportedServiceNames() override
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::datatransfer::XTransferable > m_xTransferable
Represents the contents of LOKClipboard.
LOKTransferable()
Use to ensure we have some dummy content on the clipboard to allow a 1st 'paste'.
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &rFlavor) override
static void initFlavourFromMime(css::datatransfer::DataFlavor &rFlavor, OUString aMimeType)
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &rFlavor) override
css::uno::Sequence< css::datatransfer::DataFlavor > m_aFlavors
std::vector< css::uno::Any > m_aContent
static int getView(const SfxViewShell *pViewShell=nullptr)
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
css::uno::Type const & get()
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * desktop_LOKClipboard_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static vcl::DeleteOnDeinit< std::unordered_map< int, rtl::Reference< LOKClipboard > > > gClipboards
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const sal_Unicode *const aMimeType[]