/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX #define INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX #include #include #include #include #include #include #include using namespace css::uno; /// A clipboard implementation for LibreOfficeKit. class LOKClipboard final : public cppu::WeakComponentImplHelper { osl::Mutex m_aMutex; css::uno::Reference m_xTransferable; css::uno::Reference m_aOwner; std::vector> m_aListeners; public: LOKClipboard(); /// get an XInterface easily. css::uno::Reference getXI() { return css::uno::Reference(static_cast(this)); } // XServiceInfo OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; Sequence SAL_CALL getSupportedServiceNames() override; static Sequence getSupportedServiceNames_static(); // XClipboard css::uno::Reference SAL_CALL getContents() override; void SAL_CALL setContents( const css::uno::Reference& xTransferable, const css::uno::Reference& xClipboardOwner) override; OUString SAL_CALL getName() override { return "CLIPBOARD"; } // XClipboardEx sal_Int8 SAL_CALL getRenderingCapabilities() override { return 0; } // XClipboardNotifier void SAL_CALL addClipboardListener( const css::uno::Reference& listener) override; void SAL_CALL removeClipboardListener( const css::uno::Reference& listener) override; }; /// Represents the contents of LOKClipboard. class LOKTransferable : public cppu::WeakImplHelper { css::uno::Sequence m_aFlavors; std::vector m_aContent; static void initFlavourFromMime(css::datatransfer::DataFlavor& rFlavor, OUString aMimeType); public: LOKTransferable(); LOKTransferable(size_t nInCount, const char** pInMimeTypes, const size_t* pInSizes, const char** pInStreams); LOKTransferable(const OUString& sMimeType, const css::uno::Sequence& aSequence); css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override; css::uno::Sequence SAL_CALL getTransferDataFlavors() override; sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override; }; /// Theoretically to hook into the (horrible) vcl dtranscomp.cxx code. class LOKClipboardFactory : public ::cppu::WeakComponentImplHelper { static osl::Mutex gMutex; public: LOKClipboardFactory() : cppu::WeakComponentImplHelper(gMutex) { } css::uno::Reference SAL_CALL createInstance() override { return createInstanceWithArguments(css::uno::Sequence()); } css::uno::Reference SAL_CALL createInstanceWithArguments(const css::uno::Sequence& /* rArgs */) override; /// Fetch clipboard from the global pool. static rtl::Reference getClipboardForCurView(); /// Release a clipboard before its document dies, nViewId of -1 clears all. static void releaseClipboardForView(int nViewId); }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */