xref: /AOO41X/main/dtrans/source/win32/clipb/WinClipbImpl.hxx (revision fbcf0fe955ab8df0a2f1d76ae10cf7d5c87503b1)
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 
25 #ifndef _WINCLIPBIMPL_HXX_
26 #define _WINCLIPBIMPL_HXX_
27 
28 //------------------------------------------------------------------------
29 // includes
30 //------------------------------------------------------------------------
31 
32 #include <sal/types.h>
33 #include <rtl/ustring.hxx>
34 #include <com/sun/star/datatransfer/XTransferable.hpp>
35 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
36 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
37 #include "..\..\inc\MtaOleClipb.hxx"
38 
39 #if defined _MSC_VER
40 #pragma warning(push,1)
41 #endif
42 #include <windows.h>
43 #if defined _MSC_VER
44 #pragma warning(pop)
45 #endif
46 
47 class CWinClipboard;
48 class CXNotifyingDataObject;
49 
50 //---------------------------------------------------
51 // impl class to avoid deadlocks between XTDataObject
52 // and the clipboard implementation
53 //---------------------------------------------------
54 
55 class CWinClipbImpl
56 {
57 public:
58     ~CWinClipbImpl( );
59 
60 protected:
61     CWinClipbImpl( const ::rtl::OUString& aClipboardName, CWinClipboard* theWinClipboard );
62 
63     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents(  )
64         throw( ::com::sun::star::uno::RuntimeException );
65 
66     void SAL_CALL setContents(
67         const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
68         const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
69         throw( ::com::sun::star::uno::RuntimeException );
70 
71     ::rtl::OUString SAL_CALL getName(  ) throw( ::com::sun::star::uno::RuntimeException );
72 
73     //------------------------------------------------
74     // XClipboardEx
75     //------------------------------------------------
76 
77     sal_Int8 SAL_CALL getRenderingCapabilities(  ) throw( ::com::sun::star::uno::RuntimeException );
78 
79     //------------------------------------------------
80     // XFlushableClipboard
81     //------------------------------------------------
82 
83     void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException );
84 
85     //------------------------------------------------
86     // XComponent
87     //------------------------------------------------
88 
89     void SAL_CALL dispose( ) throw( ::com::sun::star::uno::RuntimeException );
90 
91     //------------------------------------------------
92     // member functions
93     //------------------------------------------------
94 
95     void SAL_CALL registerClipboardViewer( );
96     void SAL_CALL unregisterClipboardViewer( );
97 
98     static void WINAPI onClipboardContentChanged( void );
99 
100 private:
101     void SAL_CALL onReleaseDataObject( CXNotifyingDataObject* theCaller );
102 
103 private:
104     ::rtl::OUString         m_itsName;
105     CMtaOleClipboard        m_MtaOleClipboard;
106     CWinClipboard*          m_pWinClipboard;
107     CXNotifyingDataObject*  m_pCurrentClipContent;
108     osl::Mutex              m_ClipContentMutex;
109 
110     static osl::Mutex       s_aMutex;
111     static CWinClipbImpl*   s_pCWinClipbImpl;
112 
113 private:
114     CWinClipbImpl( const CWinClipbImpl& );
115     CWinClipbImpl& operator=( const CWinClipbImpl& );
116 
117     friend class CWinClipboard;
118     friend class CXNotifyingDataObject;
119 };
120 
121 #endif
122