1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <rtl/ustring.hxx>
23 #include <sal/types.h>
24 #include <comphelper/compbase.hxx>
25 #include <comphelper/interfacecontainer4.hxx>
26 #include <com/sun/star/datatransfer/XTransferable.hpp>
27 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
28 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
29 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
30 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <osl/conditn.hxx>
36 #include <systools/win32/comtools.hxx>
38 #include "MtaOleClipb.hxx"
39 #include "XNotifyingDataObject.hxx"
41 // implements the XClipboard[Ex] ... interfaces
42 // for the clipboard viewer mechanism we need a static callback function
43 // and a static member to reassociate from this static function to the
45 // watch out: we are using only one static member variable and not a list
46 // because we assume to be instantiated only once
47 // this will be assured by a OneInstanceFactory of the service and not
50 class CWinClipboard final
51 : public comphelper::WeakComponentImplHelper
<css::datatransfer::clipboard::XSystemClipboard
,
52 css::datatransfer::clipboard::XFlushableClipboard
,
53 css::lang::XServiceInfo
>
55 friend STDMETHODIMP_(ULONG
) CXNotifyingDataObject::Release();
57 css::uno::Reference
<css::uno::XComponentContext
> m_xContext
;
58 const OUString m_itsName
;
59 CMtaOleClipboard m_MtaOleClipboard
;
60 CXNotifyingDataObject
* m_pCurrentClipContent
;
61 com::sun::star::uno::Reference
<com::sun::star::datatransfer::XTransferable
> m_foreignContent
;
62 osl::Mutex m_aContentMutex
;
63 osl::Mutex m_aContentCacheMutex
;
64 comphelper::OInterfaceContainerHelper4
<css::datatransfer::clipboard::XClipboardListener
>
67 void notifyAllClipboardListener();
68 void onReleaseDataObject(CXNotifyingDataObject
* theCaller
);
70 void registerClipboardViewer();
71 void unregisterClipboardViewer();
73 static void WINAPI
onClipboardContentChanged();
76 CWinClipboard(const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
77 const OUString
& aClipboardName
);
78 virtual ~CWinClipboard() override
;
81 virtual css::uno::Reference
<css::datatransfer::XTransferable
> SAL_CALL
getContents() override
;
82 virtual void SAL_CALL
setContents(
83 const css::uno::Reference
<css::datatransfer::XTransferable
>& xTransferable
,
84 const css::uno::Reference
<css::datatransfer::clipboard::XClipboardOwner
>& xClipboardOwner
)
86 virtual OUString SAL_CALL
getName() override
;
88 // XFlushableClipboard
89 virtual void SAL_CALL
flushClipboard() override
;
92 virtual sal_Int8 SAL_CALL
getRenderingCapabilities() override
;
95 virtual void SAL_CALL
addClipboardListener(
96 const css::uno::Reference
<css::datatransfer::clipboard::XClipboardListener
>& listener
)
98 virtual void SAL_CALL
removeClipboardListener(
99 const css::uno::Reference
<css::datatransfer::clipboard::XClipboardListener
>& listener
)
103 virtual OUString SAL_CALL
getImplementationName() override
;
104 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
105 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
107 IDataObjectPtr
getIDataObject();
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */