LibreOffice Module dtrans (master)  1
WinClipboard.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_DTRANS_SOURCE_WIN32_CLIPB_WINCLIPBOARD_HXX
21 #define INCLUDED_DTRANS_SOURCE_WIN32_CLIPB_WINCLIPBOARD_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <sal/types.h>
25 #include <cppuhelper/compbase.hxx>
26 #include <com/sun/star/datatransfer/XTransferable.hpp>
27 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
28 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
29 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
30 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <osl/conditn.hxx>
36 
37 #include <memory>
38 
39 // forward
40 class CWinClipbImpl;
41 
42 // implements the XClipboard[Ex] ... interfaces
43 // for the clipboard viewer mechanism we need a static callback function
44 // and a static member to reassociate from this static function to the
45 // class instance
46 // watch out: we are using only one static member variable and not a list
47 // because we assume to be instantiated only once
48 // this will be assured by a OneInstanceFactory of the service and not
49 // by this class!
50 
51 // helper class, so that the mutex is constructed
52 // before the constructor of WeakComponentImplHelper
53 // will be called and initialized with this mutex
55 {
56 protected:
57  osl::Mutex m_aMutex;
58  osl::Mutex m_aCbListenerMutex;
59 };
60 
62  public CWinClipboardDummy,
63  public cppu::WeakComponentImplHelper<
64  css::datatransfer::clipboard::XSystemClipboard,
65  css::datatransfer::clipboard::XFlushableClipboard,
66  css::lang::XServiceInfo >
67 {
68 public:
69  CWinClipboard( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
70  const OUString& aClipboardName );
71 
72  // XClipboard
73 
74  virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getContents( ) override;
75 
76  virtual void SAL_CALL setContents(
77  const css::uno::Reference< css::datatransfer::XTransferable >& xTransferable,
78  const css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ) override;
79 
80  virtual OUString SAL_CALL getName( ) override;
81 
82  // XFlushableClipboard
83 
84  virtual void SAL_CALL flushClipboard( ) override;
85 
86  // XClipboardEx
87 
88  virtual sal_Int8 SAL_CALL getRenderingCapabilities( ) override;
89 
90  // XClipboardNotifier
91 
92  virtual void SAL_CALL addClipboardListener(
93  const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener >& listener ) override;
94 
95  virtual void SAL_CALL removeClipboardListener(
96  const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener >& listener ) override;
97 
98  // overwrite base class method, which is called
99  // by base class dispose function
100 
101  virtual void SAL_CALL disposing() override;
102 
103  // XServiceInfo
104 
105  virtual OUString SAL_CALL getImplementationName( ) override;
106 
107  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
108 
109  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
110 
111 private:
113 
114 private:
115  std::unique_ptr< CWinClipbImpl > m_pImpl;
116  css::uno::Reference< css::uno::XComponentContext > m_xContext;
117 
118  friend class CWinClipbImpl;
119 };
120 
121 #endif
122 
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Mutex m_aCbListenerMutex
std::unique_ptr< CWinClipbImpl > m_pImpl
signed char sal_Int8
CWinClipboard(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &aClipboardName)
virtual void SAL_CALL flushClipboard() override
void notifyAllClipboardListener()
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getContents() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL disposing() override
unsigned char sal_Bool
virtual sal_Int8 SAL_CALL getRenderingCapabilities() override
virtual OUString SAL_CALL getName() override
virtual void SAL_CALL removeClipboardListener(const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > &listener) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL setContents(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, const css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner > &xClipboardOwner) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL addClipboardListener(const css::uno::Reference< css::datatransfer::clipboard::XClipboardListener > &listener) override