1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DTRANS_X11_CLIPBOARD_HXX_
25 #define _DTRANS_X11_CLIPBOARD_HXX_
26 
27 #include <X11_selection.hxx>
28 
29 #ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDEX_HPP_
30 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
31 #endif
32 
33 #ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDNOTIFIER_HPP_
34 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
35 #endif
36 #include <cppuhelper/compbase4.hxx>
37 
38 // ------------------------------------------------------------------------
39 
40 #define X11_CLIPBOARD_IMPLEMENTATION_NAME "com.sun.star.datatransfer.X11ClipboardSupport"
41 
42 namespace x11 {
43 
44 	class X11Clipboard :
45 		public ::cppu::WeakComponentImplHelper4 <
46         ::com::sun::star::datatransfer::clipboard::XClipboardEx,
47     	::com::sun::star::datatransfer::clipboard::XClipboardNotifier,
48         ::com::sun::star::lang::XServiceInfo,
49         ::com::sun::star::lang::XInitialization
50 		>,
51 		public SelectionAdaptor
52 	{
53 		com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > m_aContents;
54 		com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
55 
56 		SelectionManager&										m_rSelectionManager;
57 		com::sun::star::uno::Reference< ::com::sun::star::lang::XInitialization >	m_xSelectionManager;
58         ::std::list< com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener > > m_aListeners;
59 		Atom													m_aSelection;
60 
61 	protected:
62 
63 
64 		friend class SelectionManager;
65 		friend class X11_Transferable;
66 
67 		void fireChangedContentsEvent();
68 		void clearContents();
69 
70 	public:
71 
72 		X11Clipboard( SelectionManager& rManager, Atom aSelection );
73 		virtual ~X11Clipboard();
74 
75 		static X11Clipboard* get( const ::rtl::OUString& rDisplayName, Atom aSelection );
76 
77 		/*
78 		 *	XInitialization
79 		 */
80 		virtual void SAL_CALL initialize( const Sequence< Any >& arguments ) throw(  ::com::sun::star::uno::Exception );
81 
82 		/*
83 		 * XServiceInfo
84 		 */
85 
86 		virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
87 			throw(RuntimeException);
88 
89 		virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
90 			throw(RuntimeException);
91 
92 		virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
93 			throw(RuntimeException);
94 
95 		/*
96 		 * XClipboard
97 		 */
98 
99 		virtual com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
100 			throw(RuntimeException);
101 
102 		virtual void SAL_CALL setContents(
103 			const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans,
104 			const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
105 			throw(RuntimeException);
106 
107 		virtual ::rtl::OUString SAL_CALL getName()
108 			throw(RuntimeException);
109 
110 		/*
111 		 * XClipboardEx
112 		 */
113 
114 		virtual sal_Int8 SAL_CALL getRenderingCapabilities()
115 			throw(RuntimeException);
116 
117 		/*
118 		 * XClipboardNotifier
119 		 */
120 		virtual void SAL_CALL addClipboardListener(
121 			const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
122 			throw(RuntimeException);
123 
124 		virtual void SAL_CALL removeClipboardListener(
125 			const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
126 			throw(RuntimeException);
127 
128 		/*
129 		 *	SelectionAdaptor
130 		 */
131 		virtual com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable();
132 		virtual void clearTransferable();
133         virtual void fireContentsChanged();
134         virtual com::sun::star::uno::Reference< XInterface > getReference() throw();
135 	};
136 
137 // ------------------------------------------------------------------------
138 
139 	Sequence< ::rtl::OUString > SAL_CALL X11Clipboard_getSupportedServiceNames();
140 	com::sun::star::uno::Reference< XInterface > SAL_CALL X11Clipboard_createInstance(
141 		const com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
142 
143 // ------------------------------------------------------------------------
144 
145 } // namepspace
146 
147 #endif
148