1*fbcf0fe9SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fbcf0fe9SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fbcf0fe9SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fbcf0fe9SAndrew Rist  * distributed with this work for additional information
6*fbcf0fe9SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fbcf0fe9SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fbcf0fe9SAndrew Rist  * "License"); you may not use this file except in compliance
9*fbcf0fe9SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fbcf0fe9SAndrew Rist  *
11*fbcf0fe9SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fbcf0fe9SAndrew Rist  *
13*fbcf0fe9SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fbcf0fe9SAndrew Rist  * software distributed under the License is distributed on an
15*fbcf0fe9SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fbcf0fe9SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fbcf0fe9SAndrew Rist  * specific language governing permissions and limitations
18*fbcf0fe9SAndrew Rist  * under the License.
19*fbcf0fe9SAndrew Rist  *
20*fbcf0fe9SAndrew Rist  *************************************************************/
21*fbcf0fe9SAndrew Rist 
22*fbcf0fe9SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _WINCLIPBOARD_HXX_
26cdf0e10cSrcweir #define _WINCLIPBOARD_HXX_
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir // includes
31cdf0e10cSrcweir //------------------------------------------------------------------------
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <rtl/ustring.hxx>
34cdf0e10cSrcweir #include <sal/types.h>
35cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
36cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
37cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
38cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
39cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
40cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
41cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
43cdf0e10cSrcweir #include <osl/conditn.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <memory>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // forward
48cdf0e10cSrcweir class CWinClipbImpl;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //------------------------------------------------------------------------
51cdf0e10cSrcweir // implements the XClipboard[Ex] ... interfaces
52cdf0e10cSrcweir // for the clipboard viewer mechanism we need a static callback function
53cdf0e10cSrcweir // and a static member to reasocciate from this static function to the
54cdf0e10cSrcweir // class instance
55cdf0e10cSrcweir // watch out: we are using only one static member variable and not a list
56cdf0e10cSrcweir // because we assume to be instanciated only once
57cdf0e10cSrcweir // this will be asured by an OneInstanceFactory of the service and not
58cdf0e10cSrcweir // by this class!
59cdf0e10cSrcweir //------------------------------------------------------------------------
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // helper class, so that the mutex is constructed
62cdf0e10cSrcweir // before the constructor of WeakComponentImplHelper
63cdf0e10cSrcweir // will be called and initialized with this mutex
64cdf0e10cSrcweir class CWinClipboardDummy
65cdf0e10cSrcweir {
66cdf0e10cSrcweir protected:
67cdf0e10cSrcweir 	osl::Mutex		m_aMutex;
68cdf0e10cSrcweir 	osl::Mutex		m_aCbListenerMutex;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir class CWinClipboard :
72cdf0e10cSrcweir 	public CWinClipboardDummy,
73cdf0e10cSrcweir 	public cppu::WeakComponentImplHelper4<
74cdf0e10cSrcweir 		::com::sun::star::datatransfer::clipboard::XClipboardEx, \
75cdf0e10cSrcweir 		::com::sun::star::datatransfer::clipboard::XFlushableClipboard,
76cdf0e10cSrcweir 		::com::sun::star::datatransfer::clipboard::XClipboardNotifier,
77cdf0e10cSrcweir 		::com::sun::star::lang::XServiceInfo >
78cdf0e10cSrcweir {
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir 	CWinClipboard( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
81cdf0e10cSrcweir 				   const ::rtl::OUString& aClipboardName );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	//------------------------------------------------
84cdf0e10cSrcweir 	// XClipboard
85cdf0e10cSrcweir 	//------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents(  )
88cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	virtual void SAL_CALL setContents(
91cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
92cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
93cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName(  )
96cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	//------------------------------------------------
99cdf0e10cSrcweir 	// XFlushableClipboard
100cdf0e10cSrcweir 	//------------------------------------------------
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	virtual void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	//------------------------------------------------
105cdf0e10cSrcweir 	// XClipboardEx
106cdf0e10cSrcweir 	//------------------------------------------------
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	virtual sal_Int8 SAL_CALL getRenderingCapabilities(  ) throw( ::com::sun::star::uno::RuntimeException );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	//------------------------------------------------
111cdf0e10cSrcweir 	// XClipboardNotifier
112cdf0e10cSrcweir 	//------------------------------------------------
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	virtual void SAL_CALL addClipboardListener(
115cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
116cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     virtual void SAL_CALL removeClipboardListener(
119cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
120cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	//------------------------------------------------
123cdf0e10cSrcweir 	// overwrite base class method, which is called
124cdf0e10cSrcweir 	// by base class dispose function
125cdf0e10cSrcweir 	//------------------------------------------------
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	//------------------------------------------------
130cdf0e10cSrcweir 	// XServiceInfo
131cdf0e10cSrcweir 	//------------------------------------------------
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
134cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
137cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
140cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir private:
143cdf0e10cSrcweir 	void SAL_CALL notifyAllClipboardListener( );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir private:
146cdf0e10cSrcweir 	::std::auto_ptr< CWinClipbImpl >												  m_pImpl;
147cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >  m_SrvMgr;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	friend class CWinClipbImpl;
150cdf0e10cSrcweir };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
153cdf0e10cSrcweir #endif
154