1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FetcList.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _FETCLIST_HXX_
33 #define _FETCLIST_HXX_
35 //------------------------------------------------------------------------
37 //------------------------------------------------------------------------
39 #include <sal/types.h>
40 #include <cppuhelper/servicefactory.hxx>
41 #include <com/sun/star/datatransfer/XTransferable.hpp>
45 #pragma warning(push,1)
53 /*****************************************************************
54 a simple container for FORMATECT structures
55 instances of this class are not thread-safe
56 *****************************************************************/
58 class CFormatEtcContainer
61 CFormatEtcContainer( );
63 // duplicates not allowed
64 void SAL_CALL
addFormatEtc( const CFormatEtc
& fetc
);
66 // removes the specified formatetc
67 void SAL_CALL
removeFormatEtc( const CFormatEtc
& fetc
);
69 // removes the formatetc at pos
70 void SAL_CALL
removeAllFormatEtc( );
72 sal_Bool SAL_CALL
hasFormatEtc( const CFormatEtc
& fetc
) const;
74 sal_Bool SAL_CALL
hasElements( ) const;
77 void SAL_CALL
beginEnumFormatEtc( );
79 // copies the specified number of formatetc structures starting
80 // at the current enum position
81 // the return value is the number of copied elements; if the
82 // current enum position is at the end the return value is 0
83 sal_uInt32 SAL_CALL
nextFormatEtc( LPFORMATETC lpFetc
, sal_uInt32 aNum
= 1 );
85 // skips the specified number of elements in the container
86 sal_Bool SAL_CALL
skipFormatEtc( sal_uInt32 aNum
);
89 typedef std::vector
< CFormatEtc
> FormatEtcMap_t
;
92 FormatEtcMap_t m_FormatMap
;
93 FormatEtcMap_t::iterator m_EnumIterator
;
96 /*****************************************************************
97 a helper class which converts data flavors to clipformats,
98 creates an appropriate formatetc structures and if possible
99 synthesizes clipboard formats if necessary, e.g. if text
100 is provided a locale will also be provided;
101 the class registers the formatetc within a CFormatEtcContainer
103 instances of this class are not thread-safe and multiple
104 instances of this class would use the same static variables
105 that's why this class should not be used by multiple threads,
106 only one thread of a process should use it
107 *****************************************************************/
110 class CDataFormatTranslator
;
112 class CFormatRegistrar
115 CFormatRegistrar( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& ServiceManager
,
116 const CDataFormatTranslator
& aDataFormatTranslator
);
118 void SAL_CALL
RegisterFormats( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XTransferable
>& aXTransferable
,
119 CFormatEtcContainer
& aFormatEtcContainer
);
121 sal_Bool SAL_CALL
hasSynthesizedLocale( ) const;
122 LCID SAL_CALL
getSynthesizedLocale( ) const;
123 sal_uInt32 SAL_CALL
getRegisteredTextCodePage( ) const;
124 com::sun::star::datatransfer::DataFlavor SAL_CALL
getRegisteredTextFlavor( ) const;
126 sal_Bool SAL_CALL
isSynthesizeableFormat( const CFormatEtc
& aFormatEtc
) const;
127 sal_Bool SAL_CALL
needsToSynthesizeAccompanyFormats( const CFormatEtc
& aFormatEtc
) const;
130 sal_Bool SAL_CALL
isEqualCurrentSystemCodePage( sal_uInt32 aCodePage
) const;
131 rtl::OUString SAL_CALL
getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor
& aFlavor
);
133 sal_Bool SAL_CALL
hasUnicodeFlavor(
134 const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XTransferable
>& aXTransferable
) const;
136 sal_Bool SAL_CALL
findLocaleForTextCodePage( );
138 static sal_Bool SAL_CALL
isLocaleOemCodePage( LCID lcid
, sal_uInt32 codepage
);
139 static sal_Bool SAL_CALL
isLocaleAnsiCodePage( LCID lcid
, sal_uInt32 codepage
);
140 static sal_Bool SAL_CALL
isLocaleCodePage( LCID lcid
, LCTYPE lctype
, sal_uInt32 codepage
);
142 static BOOL CALLBACK
EnumLocalesProc( LPSTR lpLocaleStr
);
145 const CDataFormatTranslator
& m_DataFormatTranslator
;
146 sal_Bool m_bHasSynthesizedLocale
;
147 com::sun::star::datatransfer::DataFlavor m_RegisteredTextFlavor
;
149 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_SrvMgr
;
151 static LCID m_TxtLocale
;
152 static sal_uInt32 m_TxtCodePage
;
155 CFormatRegistrar( const CFormatRegistrar
& );
156 CFormatRegistrar
& operator=( const CFormatRegistrar
& );