xref: /AOO41X/main/dtrans/source/win32/dtobj/FetcList.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir #ifndef _FETCLIST_HXX_
30*cdf0e10cSrcweir #define _FETCLIST_HXX_
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir //------------------------------------------------------------------------
33*cdf0e10cSrcweir // includes
34*cdf0e10cSrcweir //------------------------------------------------------------------------
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <sal/types.h>
37*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
38*cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
39*cdf0e10cSrcweir #include "Fetc.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #if defined _MSC_VER
42*cdf0e10cSrcweir #pragma warning(push,1)
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #include <windows.h>
45*cdf0e10cSrcweir #if defined _MSC_VER
46*cdf0e10cSrcweir #pragma warning(pop)
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #include <vector>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /*****************************************************************
51*cdf0e10cSrcweir 	a simple container for FORMATECT structures
52*cdf0e10cSrcweir 	instances of this class are not thread-safe
53*cdf0e10cSrcweir *****************************************************************/
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir class CFormatEtcContainer
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir public:
58*cdf0e10cSrcweir 	CFormatEtcContainer( );
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	// duplicates not allowed
61*cdf0e10cSrcweir 	void SAL_CALL addFormatEtc( const CFormatEtc& fetc );
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	// removes the specified formatetc
64*cdf0e10cSrcweir 	void SAL_CALL removeFormatEtc( const CFormatEtc& fetc );
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 	// removes the formatetc at pos
67*cdf0e10cSrcweir 	void SAL_CALL removeAllFormatEtc( );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	sal_Bool SAL_CALL hasFormatEtc( const CFormatEtc& fetc ) const;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	sal_Bool SAL_CALL hasElements( ) const;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	// begin enumeration
74*cdf0e10cSrcweir 	void SAL_CALL beginEnumFormatEtc( );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	// copies the specified number of formatetc structures starting
77*cdf0e10cSrcweir 	// at the current enum position
78*cdf0e10cSrcweir 	// the return value is the number of copied elements; if the
79*cdf0e10cSrcweir 	// current enum position is at the end the return value is 0
80*cdf0e10cSrcweir 	sal_uInt32 SAL_CALL nextFormatEtc( LPFORMATETC lpFetc, sal_uInt32 aNum = 1 );
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	// skips the specified number of elements in the container
83*cdf0e10cSrcweir 	sal_Bool SAL_CALL skipFormatEtc( sal_uInt32 aNum );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir protected:
86*cdf0e10cSrcweir 	typedef std::vector< CFormatEtc > FormatEtcMap_t;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir private:
89*cdf0e10cSrcweir 	FormatEtcMap_t           m_FormatMap;
90*cdf0e10cSrcweir 	FormatEtcMap_t::iterator m_EnumIterator;
91*cdf0e10cSrcweir };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir /*****************************************************************
94*cdf0e10cSrcweir 	a helper class which converts data flavors to clipformats,
95*cdf0e10cSrcweir 	creates an appropriate formatetc structures and if possible
96*cdf0e10cSrcweir 	synthesizes clipboard formats if necessary, e.g. if text
97*cdf0e10cSrcweir 	is provided a locale will also be provided;
98*cdf0e10cSrcweir 	the class registers the formatetc within a CFormatEtcContainer
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	instances of this class are not thread-safe and multiple
101*cdf0e10cSrcweir 	instances of this class would use the same static variables
102*cdf0e10cSrcweir 	that's why this class should not be used by multiple threads,
103*cdf0e10cSrcweir 	only one thread of a process should use it
104*cdf0e10cSrcweir *****************************************************************/
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir // forward
107*cdf0e10cSrcweir class CDataFormatTranslator;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir class CFormatRegistrar
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir public:
112*cdf0e10cSrcweir 	CFormatRegistrar( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager,
113*cdf0e10cSrcweir 					  const CDataFormatTranslator& aDataFormatTranslator );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	void SAL_CALL RegisterFormats( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable,
116*cdf0e10cSrcweir 								   CFormatEtcContainer& aFormatEtcContainer );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	sal_Bool   SAL_CALL hasSynthesizedLocale( ) const;
119*cdf0e10cSrcweir 	LCID       SAL_CALL getSynthesizedLocale( ) const;
120*cdf0e10cSrcweir 	sal_uInt32 SAL_CALL getRegisteredTextCodePage( ) const;
121*cdf0e10cSrcweir 	com::sun::star::datatransfer::DataFlavor SAL_CALL getRegisteredTextFlavor( ) const;
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	sal_Bool  SAL_CALL isSynthesizeableFormat( const CFormatEtc& aFormatEtc ) const;
124*cdf0e10cSrcweir 	sal_Bool  SAL_CALL needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir private:
127*cdf0e10cSrcweir 	sal_Bool      SAL_CALL isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const;
128*cdf0e10cSrcweir 	rtl::OUString SAL_CALL getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	sal_Bool SAL_CALL hasUnicodeFlavor(
131*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable ) const;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	sal_Bool SAL_CALL findLocaleForTextCodePage( );
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	static sal_Bool SAL_CALL isLocaleOemCodePage( LCID lcid, sal_uInt32 codepage );
136*cdf0e10cSrcweir 	static sal_Bool SAL_CALL isLocaleAnsiCodePage( LCID lcid, sal_uInt32 codepage );
137*cdf0e10cSrcweir 	static sal_Bool SAL_CALL isLocaleCodePage( LCID lcid, LCTYPE lctype, sal_uInt32 codepage );
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	static BOOL CALLBACK EnumLocalesProc( LPSTR lpLocaleStr );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir private:
142*cdf0e10cSrcweir 	const CDataFormatTranslator&			 m_DataFormatTranslator;
143*cdf0e10cSrcweir 	sal_Bool								 m_bHasSynthesizedLocale;
144*cdf0e10cSrcweir 	com::sun::star::datatransfer::DataFlavor m_RegisteredTextFlavor;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >	m_SrvMgr;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	static LCID       m_TxtLocale;
149*cdf0e10cSrcweir 	static sal_uInt32 m_TxtCodePage;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir private:
152*cdf0e10cSrcweir 	CFormatRegistrar( const CFormatRegistrar& );
153*cdf0e10cSrcweir 	CFormatRegistrar& operator=( const CFormatRegistrar& );
154*cdf0e10cSrcweir };
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir #endif
157