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 .
20 #ifndef INCLUDED_DTRANS_SOURCE_WIN32_DTOBJ_FETCLIST_HXX
21 #define INCLUDED_DTRANS_SOURCE_WIN32_DTOBJ_FETCLIST_HXX
23 #include <sal/types.h>
24 #include <com/sun/star/datatransfer/XTransferable.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
29 #pragma warning(push,1)
37 /*****************************************************************
38 a simple container for FORMATECT structures
39 instances of this class are not thread-safe
40 *****************************************************************/
42 class CFormatEtcContainer
45 CFormatEtcContainer( );
47 // duplicates not allowed
48 void SAL_CALL
addFormatEtc( const CFormatEtc
& fetc
);
50 // removes the specified formatetc
51 void SAL_CALL
removeFormatEtc( const CFormatEtc
& fetc
);
53 // removes the formatetc at pos
54 void SAL_CALL
removeAllFormatEtc( );
56 bool SAL_CALL
hasFormatEtc( const CFormatEtc
& fetc
) const;
58 bool SAL_CALL
hasElements( ) const;
61 void SAL_CALL
beginEnumFormatEtc( );
63 // copies the specified number of formatetc structures starting
64 // at the current enum position
65 // the return value is the number of copied elements; if the
66 // current enum position is at the end the return value is 0
67 sal_uInt32 SAL_CALL
nextFormatEtc( LPFORMATETC lpFetc
, sal_uInt32 aNum
= 1 );
69 // skips the specified number of elements in the container
70 bool SAL_CALL
skipFormatEtc( sal_uInt32 aNum
);
73 typedef std::vector
< CFormatEtc
> FormatEtcMap_t
;
76 FormatEtcMap_t m_FormatMap
;
77 FormatEtcMap_t::iterator m_EnumIterator
;
80 /*****************************************************************
81 a helper class which converts data flavors to clipformats,
82 creates an appropriate formatetc structures and if possible
83 synthesizes clipboard formats if necessary, e.g. if text
84 is provided a locale will also be provided;
85 the class registers the formatetc within a CFormatEtcContainer
87 instances of this class are not thread-safe and multiple
88 instances of this class would use the same static variables
89 that's why this class should not be used by multiple threads,
90 only one thread of a process should use it
91 *****************************************************************/
94 class CDataFormatTranslator
;
96 class CFormatRegistrar
99 CFormatRegistrar( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
100 const CDataFormatTranslator
& aDataFormatTranslator
);
102 void SAL_CALL
RegisterFormats( const css::uno::Reference
< css::datatransfer::XTransferable
>& aXTransferable
,
103 CFormatEtcContainer
& aFormatEtcContainer
);
105 bool SAL_CALL
hasSynthesizedLocale( ) const;
106 static LCID SAL_CALL
getSynthesizedLocale( );
107 static sal_uInt32 SAL_CALL
getRegisteredTextCodePage( );
108 css::datatransfer::DataFlavor SAL_CALL
getRegisteredTextFlavor( ) const;
110 static bool SAL_CALL
isSynthesizeableFormat( const CFormatEtc
& aFormatEtc
);
111 static bool SAL_CALL
needsToSynthesizeAccompanyFormats( const CFormatEtc
& aFormatEtc
);
114 OUString SAL_CALL
getCharsetFromDataFlavor( const css::datatransfer::DataFlavor
& aFlavor
);
116 bool SAL_CALL
hasUnicodeFlavor(
117 const css::uno::Reference
< css::datatransfer::XTransferable
>& aXTransferable
) const;
119 static bool SAL_CALL
findLocaleForTextCodePage( );
121 static bool SAL_CALL
isLocaleOemCodePage( LCID lcid
, sal_uInt32 codepage
);
122 static bool SAL_CALL
isLocaleAnsiCodePage( LCID lcid
, sal_uInt32 codepage
);
123 static bool SAL_CALL
isLocaleCodePage( LCID lcid
, LCTYPE lctype
, sal_uInt32 codepage
);
125 static BOOL CALLBACK
EnumLocalesProc( LPSTR lpLocaleStr
);
128 const CDataFormatTranslator
& m_DataFormatTranslator
;
129 bool m_bHasSynthesizedLocale
;
130 css::datatransfer::DataFlavor m_RegisteredTextFlavor
;
132 const css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
134 static LCID m_TxtLocale
;
135 static sal_uInt32 m_TxtCodePage
;
138 CFormatRegistrar( const CFormatRegistrar
& );
139 CFormatRegistrar
& operator=( const CFormatRegistrar
& );
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */