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 sal_Bool SAL_CALL
hasFormatEtc( const CFormatEtc
& fetc
) const;
58 sal_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 sal_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 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
100 const CDataFormatTranslator
& aDataFormatTranslator
);
102 void SAL_CALL
RegisterFormats( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XTransferable
>& aXTransferable
,
103 CFormatEtcContainer
& aFormatEtcContainer
);
105 sal_Bool SAL_CALL
hasSynthesizedLocale( ) const;
106 LCID SAL_CALL
getSynthesizedLocale( ) const;
107 sal_uInt32 SAL_CALL
getRegisteredTextCodePage( ) const;
108 com::sun::star::datatransfer::DataFlavor SAL_CALL
getRegisteredTextFlavor( ) const;
110 sal_Bool SAL_CALL
isSynthesizeableFormat( const CFormatEtc
& aFormatEtc
) const;
111 sal_Bool SAL_CALL
needsToSynthesizeAccompanyFormats( const CFormatEtc
& aFormatEtc
) const;
114 sal_Bool SAL_CALL
isEqualCurrentSystemCodePage( sal_uInt32 aCodePage
) const;
115 OUString SAL_CALL
getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor
& aFlavor
);
117 sal_Bool SAL_CALL
hasUnicodeFlavor(
118 const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XTransferable
>& aXTransferable
) const;
120 sal_Bool SAL_CALL
findLocaleForTextCodePage( );
122 static sal_Bool SAL_CALL
isLocaleOemCodePage( LCID lcid
, sal_uInt32 codepage
);
123 static sal_Bool SAL_CALL
isLocaleAnsiCodePage( LCID lcid
, sal_uInt32 codepage
);
124 static sal_Bool SAL_CALL
isLocaleCodePage( LCID lcid
, LCTYPE lctype
, sal_uInt32 codepage
);
126 static BOOL CALLBACK
EnumLocalesProc( LPSTR lpLocaleStr
);
129 const CDataFormatTranslator
& m_DataFormatTranslator
;
130 sal_Bool m_bHasSynthesizedLocale
;
131 com::sun::star::datatransfer::DataFlavor m_RegisteredTextFlavor
;
133 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
135 static LCID m_TxtLocale
;
136 static sal_uInt32 m_TxtCodePage
;
139 CFormatRegistrar( const CFormatRegistrar
& );
140 CFormatRegistrar
& operator=( const CFormatRegistrar
& );
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */