Debian Codegraph @

vcl/osx/clipboard.hxx

raw symbols SCIP
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 #pragma once
21
22 #include "DataFlavorMapping.hxx"
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/XMimeContentTypeFactory.hpp>
33 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <cppuhelper/basemutex.hxx>
36 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
37
38 #include <list>
39
40 #include <premac.h>
41 #import <Cocoa/Cocoa.h>
42 #include <postmac.h>
43
44 class AquaClipboard;
45
46 @interface EventListener : NSObject
47 {
48 AquaClipboard* pAquaClipboard;
49 }
50
51 // Init the pasteboard change listener with a reference to the OfficeClipboard
52 // instance
53 - (EventListener*)initWithAquaClipboard: (AquaClipboard*) pcb;
54
55 // Promise resolver function
56 - (void)pasteboard:(NSPasteboard*)sender provideDataForType:(const NSString *)type;
57
58 -(void)applicationDidBecomeActive:(NSNotification*)aNotification;
59
60 -(void)disposing;
61 @end
62
63 class AquaClipboard : public ::cppu::BaseMutex,
64 public ::cppu::WeakComponentImplHelper<css::datatransfer::clipboard::XSystemClipboard,
65 css::datatransfer::clipboard::XFlushableClipboard,
66 css::lang::XServiceInfo>
67 {
68 public:
69 /* Create a clipboard instance.
70
71 @param pasteboard
72 If not equal NULL the instance will be instantiated with the provided
73 pasteboard reference and 'bUseSystemClipboard' will be ignored
74
75 @param bUseSystemClipboard
76 If 'pasteboard' is NULL 'bUseSystemClipboard' determines whether the
77 system clipboard will be created (bUseSystemClipboard == true) or if
78 the DragPasteboard if bUseSystemClipboard == false
79 */
80 AquaClipboard(NSPasteboard* pasteboard,
81 bool bUseSystemClipboard);
82
83 virtual ~AquaClipboard() override;
84 AquaClipboard(const AquaClipboard&) = delete;
85 AquaClipboard& operator=(const AquaClipboard&) = delete;
86
87 // XClipboard
88
89 virtual css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getContents() override;
90
91 virtual void SAL_CALL setContents(css::uno::Reference<css::datatransfer::XTransferable> const & xTransferable,
92 css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner> const & xClipboardOwner) override;
93
94 virtual OUString SAL_CALL getName() override;
95
96 // XClipboardEx
97
98 virtual sal_Int8 SAL_CALL getRenderingCapabilities() override;
99
100 // XClipboardNotifier
101
102 virtual void SAL_CALL addClipboardListener(css::uno::Reference<css::datatransfer::clipboard::XClipboardListener> const & listener) override;
103 virtual void SAL_CALL removeClipboardListener(css::uno::Reference<css::datatransfer::clipboard::XClipboardListener> const & listener) override;
104
105 // XFlushableClipboard
106
107 virtual void SAL_CALL flushClipboard() override;
108
109 // XServiceInfo
110
111 virtual OUString SAL_CALL getImplementationName() override;
112 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
113 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
114
115 /* Get a reference to the used pastboard.
116 */
117 NSPasteboard* getPasteboard() const;
118
119 /* Notify the current clipboard owner that he is no longer the clipboard owner.
120 */
121 void fireLostClipboardOwnershipEvent(css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner> const & oldOwner,
122 css::uno::Reference<css::datatransfer::XTransferable> const & oldContent);
123
124 void pasteboardChangedOwner();
125
126 void provideDataForType(NSPasteboard* sender, const NSString* type);
127
128 void applicationDidBecomeActive(NSNotification* aNotification);
129
130 private:
131
132 /* Notify all registered XClipboardListener that the clipboard content
133 has changed.
134 */
135 void fireClipboardChangedEvent();
136
137 private:
138 css::uno::Reference<css::datatransfer::XMimeContentTypeFactory> mrXMimeCntFactory;
139 std::list<css::uno::Reference<css::datatransfer::clipboard::XClipboardListener>> mClipboardListeners;
140 css::uno::Reference<css::datatransfer::XTransferable> mXClipboardContent;
141 css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner> mXClipboardOwner;
142 DataFlavorMapperPtr_t mpDataFlavorMapper;
143 bool mIsSystemPasteboard;
144 NSPasteboard* mPasteboard;
145 int mPasteboardChangeCount;
146 EventListener* mEventListener;
147 };
148
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */