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 _OS2CLIPBOARD_HXX_
25 #define _OS2CLIPBOARD_HXX_
26 
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
29 #include <cppuhelper/compbase4.hxx>
30 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
33 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
37 #include "Os2Transferable.hxx"
38 
39 // the service names
40 #define OS2_CLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard"
41 
42 // the implementation names
43 #define OS2_CLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32"
44 
45 // the registry key names
46 #define OS2_CLIPBOARD_REGKEY_NAME "/com.sun.star.datatransfer.clipboard.Os2Clipboard/UNO/SERVICES/com.sun.star.datatransfer.clipboard.SystemClipboard"
47 
48 namespace os2 {
49 
50 class Os2Clipboard :
51 	//public cppu::WeakComponentImplHelper3< ::com::sun::star::datatransfer::clipboard::XClipboardEx, ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, ::com::sun::star::lang::XServiceInfo >
52     public ::cppu::WeakComponentImplHelper4 < \
53     ::com::sun::star::datatransfer::clipboard::XClipboardEx, \
54     ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, \
55     ::com::sun::star::lang::XServiceInfo, \
56     ::com::sun::star::lang::XInitialization >
57 {
58 
59 public:
60 	Os2Clipboard();
61 	~Os2Clipboard();
62 
63 	/*
64 	 * XInitialization
65 	 */
66 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
67 		throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
68 
69 	/*
70 	 * XServiceInfo
71 	 */
72 	virtual ::rtl::OUString SAL_CALL getImplementationName()
73 		throw(::com::sun::star::uno::RuntimeException);
74 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
75 		throw(::com::sun::star::uno::RuntimeException);
76 
77 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
78 		throw(::com::sun::star::uno::RuntimeException);
79 
80 	/*
81 	 * XClipboard
82 	 */
83 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
84 		throw( ::com::sun::star::uno::RuntimeException );
85 	virtual void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
86 		throw( ::com::sun::star::uno::RuntimeException );
87 	virtual ::rtl::OUString SAL_CALL getName()
88 		throw( ::com::sun::star::uno::RuntimeException );
89 
90 	/*
91 	 * XClipboardEx
92 	 */
93 	virtual sal_Int8 SAL_CALL getRenderingCapabilities()
94 		throw( ::com::sun::star::uno::RuntimeException );
95 
96 	/*
97 	 * XClipboardNotifier
98 	 */
99 	virtual void SAL_CALL addClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
100 		throw( ::com::sun::star::uno::RuntimeException );
101 	virtual void SAL_CALL removeClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
102 		throw( ::com::sun::star::uno::RuntimeException );
103 	void SAL_CALL notifyAllClipboardListener( );
104 
105 public:
106 	sal_Bool m_bInSetClipboardData;
107 
108 private:
109 	HAB	hAB;
110 	HWND	hObjWnd;
111 	ULONG	hText, hBitmap;	// handles to previous clipboard data
112 
113 	::osl::Mutex m_aMutex;
114 	::rtl::OUString m_aName;
115 
116 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > m_aContents;
117 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
118 
119 	sal_Bool m_bInitialized;
120 
121 };
122 
123 } // namespace Os2
124 
125 // ------------------------------------------------------------------------
126 
127 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Os2Clipboard_getSupportedServiceNames();
128 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Os2Clipboard_createInstance(
129 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
130 
131 #endif
132 
133