bump product version to 4.1.6.2
[LibreOffice.git] / dtrans / source / win32 / clipb / MtaOleClipb.hxx
blobaf8894190d3a5e39ed5f010537e9d29309fc1a20
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _MTAOLECLIPB_HXX_
21 #define _MTAOLECLIPB_HXX_
23 #include <sal/types.h>
24 #include <osl/mutex.hxx>
26 #if defined _MSC_VER
27 #pragma warning(push,1)
28 #endif
29 #include <objidl.h>
30 #if defined _MSC_VER
31 #pragma warning(pop)
32 #endif
34 //--------------------------------------------------------
35 // the Mta-Ole clipboard class is for internal use only!
36 // only one instance of this class should be created, the
37 // user has to ensure this!
38 // the class is not thread-safe because it will be used
39 // only from within the clipboard service and the methods
40 // of the clipboard service are already synchronized
41 //--------------------------------------------------------
43 class CMtaOleClipboard
45 public:
46 typedef void ( WINAPI *LPFNC_CLIPVIEWER_CALLBACK_t )( void );
48 public:
49 CMtaOleClipboard( );
50 ~CMtaOleClipboard( );
52 // clipboard functions
53 HRESULT setClipboard( IDataObject* pIDataObject );
54 HRESULT getClipboard( IDataObject** ppIDataObject );
55 HRESULT flushClipboard( );
57 // register/unregister a clipboard viewer; there can only
58 // be one at a time; parameter NULL means unregister
59 // a clipboard viewer
60 // returns true on success else false; use GetLastError( ) in
61 // false case
62 bool registerClipViewer( LPFNC_CLIPVIEWER_CALLBACK_t pfncClipViewerCallback );
64 private:
65 unsigned int run( );
67 // create a hidden window which serves as an request target; so we
68 // guarantee synchronization
69 void createMtaOleReqWnd( );
71 // message support
72 bool postMessage( UINT msg, WPARAM wParam = 0, LPARAM lParam = 0 );
73 LRESULT sendMessage( UINT msg, WPARAM wParam = 0, LPARAM lParam = 0 );
75 //---------------------------------------------------------------
76 // message handler functions; remember these functions are called
77 // from a different thread context!
78 //---------------------------------------------------------------
80 LRESULT onSetClipboard( IDataObject* pIDataObject );
81 LRESULT onGetClipboard( LPSTREAM* ppStream );
82 LRESULT onFlushClipboard( );
83 bool onRegisterClipViewer( LPFNC_CLIPVIEWER_CALLBACK_t pfncClipViewerCallback );
85 // win32 clipboard-viewer support
86 LRESULT onChangeCBChain( HWND hWndRemove, HWND hWndNext );
87 LRESULT onDrawClipboard( );
89 static LRESULT CALLBACK mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
90 static unsigned int WINAPI oleThreadProc( LPVOID pParam );
92 static unsigned int WINAPI clipboardChangedNotifierThreadProc( LPVOID pParam );
94 bool WaitForThreadReady( ) const;
96 private:
97 HANDLE m_hOleThread;
98 unsigned m_uOleThreadId;
99 HANDLE m_hEvtThrdReady;
100 HWND m_hwndMtaOleReqWnd;
101 ATOM m_MtaOleReqWndClassAtom;
102 HWND m_hwndNextClipViewer;
103 LPFNC_CLIPVIEWER_CALLBACK_t m_pfncClipViewerCallback;
104 bool m_bInRegisterClipViewer;
106 bool m_bRunClipboardNotifierThread;
107 HANDLE m_hClipboardChangedNotifierThread;
108 HANDLE m_hClipboardChangedNotifierEvents[2];
109 HANDLE& m_hClipboardChangedEvent;
110 HANDLE& m_hTerminateClipboardChangedNotifierEvent;
111 osl::Mutex m_ClipboardChangedEventCountMutex;
112 sal_Int32 m_ClipboardChangedEventCount;
114 osl::Mutex m_pfncClipViewerCallbackMutex;
116 static CMtaOleClipboard* s_theMtaOleClipboardInst;
118 // not allowed
119 private:
120 CMtaOleClipboard( const CMtaOleClipboard& );
121 CMtaOleClipboard& operator=( const CMtaOleClipboard& );
123 friend LRESULT CALLBACK mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
126 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */