OInterfaceContainerHelper3 needs to be thread-safe
[LibreOffice.git] / vcl / win / dtrans / DOTransferable.hxx
blob0e652f9b6a0d9cbd1f63531a5ea461f761ad7f4b
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 #pragma once
22 #include <com/sun/star/datatransfer/XTransferable.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include "DataFmtTransl.hxx"
26 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
27 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
28 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
29 #include <com/sun/star/datatransfer/XSystemTransferable.hpp>
30 #include <cppuhelper/weakref.hxx>
32 #include <systools/win32/comtools.hxx>
34 #include <vector>
36 // forward
37 class CFormatEtc;
39 class CDOTransferable : public ::cppu::WeakImplHelper<
40 css::datatransfer::XTransferable,
41 css::datatransfer::XSystemTransferable>
43 public:
44 typedef css::uno::Sequence< sal_Int8 > ByteSequence_t;
46 // XTransferable
48 virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
50 virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
52 virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
54 // XSystemTransferable
56 virtual css::uno::Any SAL_CALL getData( const css::uno::Sequence<sal_Int8>& aProcessId ) override;
58 explicit CDOTransferable(
59 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
60 const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard,
61 const std::vector<sal_uInt32>& rFormats);
63 explicit CDOTransferable(
64 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
65 IDataObjectPtr rDataObject );
67 private:
68 // some helper functions
70 void initFlavorList( );
71 void initFlavorListFromFormatList(const std::vector<sal_uInt32>& rFormats);
73 void addSupportedFlavor( const css::datatransfer::DataFlavor& aFlavor );
74 css::datatransfer::DataFlavor formatEtcToDataFlavor(sal_uInt32 cfFormat);
76 void tryToGetIDataObjectIfAbsent();
77 ByteSequence_t getClipboardData( CFormatEtc& aFormatEtc );
78 OUString synthesizeUnicodeText( );
80 LCID getLocaleFromClipboard( );
82 bool compareDataFlavors( const css::datatransfer::DataFlavor& lhs,
83 const css::datatransfer::DataFlavor& rhs );
85 private:
86 css::uno::WeakReference<css::datatransfer::clipboard::XClipboard> m_xClipboard;
87 IDataObjectPtr m_rDataObject;
88 css::uno::Sequence< css::datatransfer::DataFlavor > m_FlavorList;
89 const css::uno::Reference< css::uno::XComponentContext > m_xContext;
90 CDataFormatTranslator m_DataFormatTranslator;
91 css::uno::Reference< css::datatransfer::XMimeContentTypeFactory > m_rXMimeCntFactory;
92 ::osl::Mutex m_aMutex;
93 bool m_bUnicodeRegistered;
94 CLIPFORMAT m_TxtFormatOnClipboard;
96 // non supported operations
97 private:
98 CDOTransferable( const CDOTransferable& );
99 CDOTransferable& operator=( const CDOTransferable& );
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */