1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _WINCLIPBOARD_HXX_
30 #define _WINCLIPBOARD_HXX_
31 
32 
33 //------------------------------------------------------------------------
34 // includes
35 //------------------------------------------------------------------------
36 
37 #include <rtl/ustring.hxx>
38 #include <sal/types.h>
39 #include <cppuhelper/compbase4.hxx>
40 #include <com/sun/star/datatransfer/XTransferable.hpp>
41 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
42 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
43 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
44 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
45 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <osl/conditn.hxx>
48 
49 #include <memory>
50 
51 // forward
52 class CWinClipbImpl;
53 
54 //------------------------------------------------------------------------
55 // implements the XClipboard[Ex] ... interfaces
56 // for the clipboard viewer mechanism we need a static callback function
57 // and a static member to reasocciate from this static function to the
58 // class instance
59 // watch out: we are using only one static member variable and not a list
60 // because we assume to be instanciated only once
61 // this will be asured by an OneInstanceFactory of the service and not
62 // by this class!
63 //------------------------------------------------------------------------
64 
65 // helper class, so that the mutex is constructed
66 // before the constructor of WeakComponentImplHelper
67 // will be called and initialized with this mutex
68 class CWinClipboardDummy
69 {
70 protected:
71 	osl::Mutex		m_aMutex;
72 	osl::Mutex		m_aCbListenerMutex;
73 };
74 
75 class CWinClipboard :
76 	public CWinClipboardDummy,
77 	public cppu::WeakComponentImplHelper4<
78 		::com::sun::star::datatransfer::clipboard::XClipboardEx, \
79 		::com::sun::star::datatransfer::clipboard::XFlushableClipboard,
80 		::com::sun::star::datatransfer::clipboard::XClipboardNotifier,
81 		::com::sun::star::lang::XServiceInfo >
82 {
83 public:
84 	CWinClipboard( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
85 				   const ::rtl::OUString& aClipboardName );
86 
87 	//------------------------------------------------
88 	// XClipboard
89 	//------------------------------------------------
90 
91 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents(  )
92 		throw( ::com::sun::star::uno::RuntimeException );
93 
94 	virtual void SAL_CALL setContents(
95 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
96 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
97 		throw( ::com::sun::star::uno::RuntimeException );
98 
99     virtual ::rtl::OUString SAL_CALL getName(  )
100 		throw( ::com::sun::star::uno::RuntimeException );
101 
102 	//------------------------------------------------
103 	// XFlushableClipboard
104 	//------------------------------------------------
105 
106 	virtual void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException );
107 
108 	//------------------------------------------------
109 	// XClipboardEx
110 	//------------------------------------------------
111 
112 	virtual sal_Int8 SAL_CALL getRenderingCapabilities(  ) throw( ::com::sun::star::uno::RuntimeException );
113 
114 	//------------------------------------------------
115 	// XClipboardNotifier
116 	//------------------------------------------------
117 
118 	virtual void SAL_CALL addClipboardListener(
119 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
120 		throw( ::com::sun::star::uno::RuntimeException );
121 
122     virtual void SAL_CALL removeClipboardListener(
123 		const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
124 		throw( ::com::sun::star::uno::RuntimeException );
125 
126 	//------------------------------------------------
127 	// overwrite base class method, which is called
128 	// by base class dispose function
129 	//------------------------------------------------
130 
131 	virtual void SAL_CALL disposing();
132 
133 	//------------------------------------------------
134 	// XServiceInfo
135 	//------------------------------------------------
136 
137 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
138 		throw(::com::sun::star::uno::RuntimeException);
139 
140 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
141 		throw(::com::sun::star::uno::RuntimeException);
142 
143 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
144 		throw(::com::sun::star::uno::RuntimeException);
145 
146 private:
147 	void SAL_CALL notifyAllClipboardListener( );
148 
149 private:
150 	::std::auto_ptr< CWinClipbImpl >												  m_pImpl;
151 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >  m_SrvMgr;
152 
153 	friend class CWinClipbImpl;
154 };
155 
156 
157 #endif
158