bump product version to 4.1.6.2
[LibreOffice.git] / dtrans / source / win32 / dtobj / FetcList.hxx
blob2352578cdea18bdecefee6e9b7cd51c792ad60d0
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 .
21 #ifndef _FETCLIST_HXX_
22 #define _FETCLIST_HXX_
24 #include <sal/types.h>
25 #include <com/sun/star/datatransfer/XTransferable.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include "Fetc.hxx"
29 #if defined _MSC_VER
30 #pragma warning(push,1)
31 #endif
32 #include <windows.h>
33 #if defined _MSC_VER
34 #pragma warning(pop)
35 #endif
36 #include <vector>
38 /*****************************************************************
39 a simple container for FORMATECT structures
40 instances of this class are not thread-safe
41 *****************************************************************/
43 class CFormatEtcContainer
45 public:
46 CFormatEtcContainer( );
48 // duplicates not allowed
49 void SAL_CALL addFormatEtc( const CFormatEtc& fetc );
51 // removes the specified formatetc
52 void SAL_CALL removeFormatEtc( const CFormatEtc& fetc );
54 // removes the formatetc at pos
55 void SAL_CALL removeAllFormatEtc( );
57 sal_Bool SAL_CALL hasFormatEtc( const CFormatEtc& fetc ) const;
59 sal_Bool SAL_CALL hasElements( ) const;
61 // begin enumeration
62 void SAL_CALL beginEnumFormatEtc( );
64 // copies the specified number of formatetc structures starting
65 // at the current enum position
66 // the return value is the number of copied elements; if the
67 // current enum position is at the end the return value is 0
68 sal_uInt32 SAL_CALL nextFormatEtc( LPFORMATETC lpFetc, sal_uInt32 aNum = 1 );
70 // skips the specified number of elements in the container
71 sal_Bool SAL_CALL skipFormatEtc( sal_uInt32 aNum );
73 protected:
74 typedef std::vector< CFormatEtc > FormatEtcMap_t;
76 private:
77 FormatEtcMap_t m_FormatMap;
78 FormatEtcMap_t::iterator m_EnumIterator;
81 /*****************************************************************
82 a helper class which converts data flavors to clipformats,
83 creates an appropriate formatetc structures and if possible
84 synthesizes clipboard formats if necessary, e.g. if text
85 is provided a locale will also be provided;
86 the class registers the formatetc within a CFormatEtcContainer
88 instances of this class are not thread-safe and multiple
89 instances of this class would use the same static variables
90 that's why this class should not be used by multiple threads,
91 only one thread of a process should use it
92 *****************************************************************/
94 // forward
95 class CDataFormatTranslator;
97 class CFormatRegistrar
99 public:
100 CFormatRegistrar( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
101 const CDataFormatTranslator& aDataFormatTranslator );
103 void SAL_CALL RegisterFormats( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable,
104 CFormatEtcContainer& aFormatEtcContainer );
106 sal_Bool SAL_CALL hasSynthesizedLocale( ) const;
107 LCID SAL_CALL getSynthesizedLocale( ) const;
108 sal_uInt32 SAL_CALL getRegisteredTextCodePage( ) const;
109 com::sun::star::datatransfer::DataFlavor SAL_CALL getRegisteredTextFlavor( ) const;
111 sal_Bool SAL_CALL isSynthesizeableFormat( const CFormatEtc& aFormatEtc ) const;
112 sal_Bool SAL_CALL needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const;
114 private:
115 sal_Bool SAL_CALL isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const;
116 OUString SAL_CALL getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
118 sal_Bool SAL_CALL hasUnicodeFlavor(
119 const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable ) const;
121 sal_Bool SAL_CALL findLocaleForTextCodePage( );
123 static sal_Bool SAL_CALL isLocaleOemCodePage( LCID lcid, sal_uInt32 codepage );
124 static sal_Bool SAL_CALL isLocaleAnsiCodePage( LCID lcid, sal_uInt32 codepage );
125 static sal_Bool SAL_CALL isLocaleCodePage( LCID lcid, LCTYPE lctype, sal_uInt32 codepage );
127 static BOOL CALLBACK EnumLocalesProc( LPSTR lpLocaleStr );
129 private:
130 const CDataFormatTranslator& m_DataFormatTranslator;
131 sal_Bool m_bHasSynthesizedLocale;
132 com::sun::star::datatransfer::DataFlavor m_RegisteredTextFlavor;
134 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
136 static LCID m_TxtLocale;
137 static sal_uInt32 m_TxtCodePage;
139 private:
140 CFormatRegistrar( const CFormatRegistrar& );
141 CFormatRegistrar& operator=( const CFormatRegistrar& );
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */