LibreOffice Module desktop (master)  1
lokclipboard.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
11 #define INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
12 
13 #include <vector>
14 
15 #include <rtl/ref.hxx>
16 #include <cppuhelper/implbase.hxx>
17 #include <cppuhelper/compbase.hxx>
18 #include <com/sun/star/lang/XServiceInfo.hpp>
19 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
20 #include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
21 
22 using namespace css::uno;
23 
25 class LOKClipboard final
26  : public cppu::WeakComponentImplHelper<css::datatransfer::clipboard::XSystemClipboard,
27  css::lang::XServiceInfo>
28 {
29  osl::Mutex m_aMutex;
30  css::uno::Reference<css::datatransfer::XTransferable> m_xTransferable;
31  css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner> m_aOwner;
32  std::vector<css::uno::Reference<css::datatransfer::clipboard::XClipboardListener>> m_aListeners;
33 
34 public:
35  LOKClipboard();
36 
38  css::uno::Reference<css::uno::XInterface> getXI()
39  {
40  return css::uno::Reference<css::uno::XInterface>(static_cast<cppu::OWeakObject*>(this));
41  }
42 
43  // XServiceInfo
44  OUString SAL_CALL getImplementationName() override;
45  sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
46  Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
47  static Sequence<OUString> getSupportedServiceNames_static();
48 
49  // XClipboard
50  css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getContents() override;
51  void SAL_CALL setContents(
52  const css::uno::Reference<css::datatransfer::XTransferable>& xTransferable,
53  const css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner>& xClipboardOwner)
54  override;
55  OUString SAL_CALL getName() override { return "CLIPBOARD"; }
56 
57  // XClipboardEx
58  sal_Int8 SAL_CALL getRenderingCapabilities() override { return 0; }
59 
60  // XClipboardNotifier
61  void SAL_CALL addClipboardListener(
62  const css::uno::Reference<css::datatransfer::clipboard::XClipboardListener>& listener)
63  override;
64  void SAL_CALL removeClipboardListener(
65  const css::uno::Reference<css::datatransfer::clipboard::XClipboardListener>& listener)
66  override;
67 };
68 
70 class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
71 {
72  css::uno::Sequence<css::datatransfer::DataFlavor> m_aFlavors;
73  std::vector<css::uno::Any> m_aContent;
74 
75  static void initFlavourFromMime(css::datatransfer::DataFlavor& rFlavor, OUString aMimeType);
76 
77 public:
79  LOKTransferable(size_t nInCount, const char** pInMimeTypes, const size_t* pInSizes,
80  const char** pInStreams);
81  LOKTransferable(const OUString& sMimeType, const css::uno::Sequence<sal_Int8>& aSequence);
82 
83  css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override;
84 
85  css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
86 
87  sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override;
88 };
89 
91 class LOKClipboardFactory : public ::cppu::WeakComponentImplHelper<css::lang::XSingleServiceFactory>
92 {
93  static osl::Mutex gMutex;
94 
95 public:
97  : cppu::WeakComponentImplHelper<css::lang::XSingleServiceFactory>(gMutex)
98  {
99  }
100 
101  css::uno::Reference<css::uno::XInterface> SAL_CALL createInstance() override
102  {
103  return createInstanceWithArguments(css::uno::Sequence<css::uno::Any>());
104  }
105  css::uno::Reference<css::uno::XInterface> SAL_CALL
106  createInstanceWithArguments(const css::uno::Sequence<css::uno::Any>& /* rArgs */) override;
107 
109  static rtl::Reference<LOKClipboard> getClipboardForCurView();
110 
112  static void releaseClipboardForView(int nViewId);
113 };
114 
115 #endif
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner > m_aOwner
css::uno::Reference< css::uno::XInterface > getXI()
get an XInterface easily.
signed char sal_Int8
OUString getImplementationName()
Definition: splash.cxx:640
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
osl::Mutex m_aMutex
css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override
css::uno::Sequence< OUString > getSupportedServiceNames()
Definition: splash.cxx:644
unsigned char sal_Bool
OUString SAL_CALL getName() override
css::uno::Sequence< css::datatransfer::DataFlavor > m_aFlavors
std::vector< css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners
Theoretically to hook into the (horrible) vcl dtranscomp.cxx code.
A clipboard implementation for LibreOfficeKit.
css::uno::Reference< css::datatransfer::XTransferable > m_xTransferable
std::vector< css::uno::Any > m_aContent
sal_Int8 SAL_CALL getRenderingCapabilities() override
static osl::Mutex gMutex
Represents the contents of LOKClipboard.