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 namespace os2 {
46 
47 class Os2Clipboard :
48 	//public cppu::WeakComponentImplHelper3< ::com::sun::star::datatransfer::clipboard::XClipboardEx, ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, ::com::sun::star::lang::XServiceInfo >
49     public ::cppu::WeakComponentImplHelper4 < \
50     ::com::sun::star::datatransfer::clipboard::XClipboardEx, \
51     ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, \
52     ::com::sun::star::lang::XServiceInfo, \
53     ::com::sun::star::lang::XInitialization >
54 {
55 
56 public:
57 	Os2Clipboard();
58 	~Os2Clipboard();
59 
60 	/*
61 	 * XInitialization
62 	 */
63 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
64 		throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
65 
66 	/*
67 	 * XServiceInfo
68 	 */
69 	virtual ::rtl::OUString SAL_CALL getImplementationName()
70 		throw(::com::sun::star::uno::RuntimeException);
71 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
72 		throw(::com::sun::star::uno::RuntimeException);
73 
74 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
75 		throw(::com::sun::star::uno::RuntimeException);
76 
77 	/*
78 	 * XClipboard
79 	 */
80 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
81 		throw( ::com::sun::star::uno::RuntimeException );
82 	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 )
83 		throw( ::com::sun::star::uno::RuntimeException );
84 	virtual ::rtl::OUString SAL_CALL getName()
85 		throw( ::com::sun::star::uno::RuntimeException );
86 
87 	/*
88 	 * XClipboardEx
89 	 */
90 	virtual sal_Int8 SAL_CALL getRenderingCapabilities()
91 		throw( ::com::sun::star::uno::RuntimeException );
92 
93 	/*
94 	 * XClipboardNotifier
95 	 */
96 	virtual void SAL_CALL addClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
97 		throw( ::com::sun::star::uno::RuntimeException );
98 	virtual void SAL_CALL removeClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
99 		throw( ::com::sun::star::uno::RuntimeException );
100 	void SAL_CALL notifyAllClipboardListener( );
101 
102 public:
103 	sal_Bool m_bInSetClipboardData;
104 
105 private:
106 	HAB	hAB;
107 	HWND	hObjWnd;
108 	ULONG	hText, hBitmap;	// handles to previous clipboard data
109 
110 	::osl::Mutex m_aMutex;
111 	::rtl::OUString m_aName;
112 
113 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > m_aContents;
114 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
115 
116 	sal_Bool m_bInitialized;
117 
118 };
119 
120 } // namespace Os2
121 
122 // ------------------------------------------------------------------------
123 
124 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Os2Clipboard_getSupportedServiceNames();
125 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Os2Clipboard_createInstance(
126 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
127 
128 #endif
129 
130