merged tag ooo/DEV300_m102
[LibreOffice.git] / sal / textenc / tenchelp.h
blob98be923472babe5117b44d97732be3f5cd98d5e1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H
29 #define INCLUDED_RTL_TEXTENC_TENCHELP_H
31 #include "rtl/tencinfo.h"
32 #include "rtl/textenc.h"
33 #include "sal/types.h"
35 #if defined __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
39 #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100
40 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF
42 /* ----------------- */
43 /* - TextConverter - */
44 /* ----------------- */
46 typedef void ImplTextConverterData;
48 typedef
49 sal_Size (* ImplConvertToUnicodeProc)(ImplTextConverterData const * pData,
50 void * pContext,
51 sal_Char const * pSrcBuf,
52 sal_Size nSrcBytes,
53 sal_Unicode * pDestBuf,
54 sal_Size nDestChars,
55 sal_uInt32 nFlags,
56 sal_uInt32 * pInfo,
57 sal_Size * pSrcCvtBytes);
59 typedef
60 sal_Size (* ImplConvertToTextProc)(ImplTextConverterData const * pData,
61 void * pContext,
62 sal_Unicode const * pSrcBuf,
63 sal_Size nSrcChars,
64 sal_Char * pDestBuf,
65 sal_Size nDestBytes,
66 sal_uInt32 nFlags,
67 sal_uInt32 * pInfo,
68 sal_Size * pSrcCvtChars);
70 typedef void * (* ImplCreateTextContextProc)(void);
72 typedef void (* ImplDestroyTextContextProc)(void * pContext);
74 typedef void (* ImplResetTextContextProc)(void * pContext);
76 typedef void * (* ImplCreateUnicodeContextProc)(void);
78 typedef void (* ImplDestroyUnicodeContextProc)(void * pContext);
80 typedef void (* ImplResetUnicodeContextProc)(void * pContext);
82 typedef struct
84 ImplTextConverterData const * mpConvertData;
85 ImplConvertToUnicodeProc mpConvertTextToUnicodeProc;
86 ImplConvertToTextProc mpConvertUnicodeToTextProc;
87 ImplCreateTextContextProc mpCreateTextToUnicodeContext;
88 ImplDestroyTextContextProc mpDestroyTextToUnicodeContext;
89 ImplResetTextContextProc mpResetTextToUnicodeContext;
90 ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext;
91 ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext;
92 ImplResetUnicodeContextProc mpResetUnicodeToTextContext;
93 } ImplTextConverter;
95 /* ----------------------------- */
96 /* - TextEncoding - Structures - */
97 /* ----------------------------- */
99 typedef struct
101 ImplTextConverter maConverter;
102 sal_uInt8 mnMinCharSize;
103 sal_uInt8 mnMaxCharSize;
104 sal_uInt8 mnAveCharSize;
105 sal_uInt8 mnBestWindowsCharset;
106 char const * mpBestUnixCharset;
107 char const * mpBestMimeCharset;
108 sal_uInt32 mnInfoFlags;
109 } ImplTextEncodingData;
111 /* ----------------------------------- */
112 /* - TextConverter - Byte-Structures - */
113 /* ----------------------------------- */
115 typedef struct
117 sal_uInt16 mnUniChar;
118 sal_uChar mnChar;
119 sal_uChar mnChar2;
120 // to cater for mappings like MS1258 with 1--2 bytes per Unicode char,
121 // 0 if unused
122 } ImplUniCharTabData;
124 typedef struct
126 const sal_uInt16* mpToUniTab1;
127 const sal_uInt16* mpToUniTab2;
128 sal_uChar mnToUniStart1;
129 sal_uChar mnToUniEnd1;
130 sal_uChar mnToUniStart2;
131 sal_uChar mnToUniEnd2;
132 const sal_uChar* mpToCharTab1;
133 const sal_uChar* mpToCharTab2;
134 const ImplUniCharTabData* mpToCharExTab;
135 sal_uInt16 mnToCharStart1;
136 sal_uInt16 mnToCharEnd1;
137 sal_uInt16 mnToCharStart2;
138 sal_uInt16 mnToCharEnd2;
139 sal_uInt16 mnToCharExCount;
140 } ImplByteConvertData;
142 /* ----------------------------------- */
143 /* - TextConverter - DBCS-Structures - */
144 /* ----------------------------------- */
146 typedef struct
148 sal_uChar mnLeadStart;
149 sal_uChar mnLeadEnd;
150 sal_uChar mnTrail1Start;
151 sal_uChar mnTrail1End;
152 sal_uChar mnTrail2Start;
153 sal_uChar mnTrail2End;
154 sal_uChar mnTrail3Start;
155 sal_uChar mnTrail3End;
156 sal_uChar mnTrailCount;
157 sal_uInt16 mnTrailRangeCount;
158 sal_uInt16 mnUniStart;
159 sal_uInt16 mnUniEnd;
160 } ImplDBCSEUDCData;
162 typedef struct
164 sal_uInt16 mnUniChar;
165 sal_uInt8 mnTrailStart;
166 sal_uInt8 mnTrailEnd;
167 const sal_uInt16* mpToUniTrailTab;
168 } ImplDBCSToUniLeadTab;
170 typedef struct
172 sal_uInt8 mnLowStart;
173 sal_uInt8 mnLowEnd;
174 const sal_uInt16* mpToUniTrailTab;
175 } ImplUniToDBCSHighTab;
177 typedef struct
179 const ImplDBCSToUniLeadTab* mpToUniLeadTab;
180 const ImplUniToDBCSHighTab* mpToDBCSHighTab;
181 sal_uChar mnLeadStart;
182 sal_uChar mnLeadEnd;
183 sal_uChar mnTrailStart;
184 sal_uChar mnTrailEnd;
185 const ImplDBCSEUDCData* mpEUDCTab;
186 sal_uInt16 mnEUDCCount;
187 } ImplDBCSConvertData;
189 /* ---------------------------------- */
190 /* - TextConverter - EUC-Structures - */
191 /* ---------------------------------- */
193 typedef struct
195 const ImplDBCSToUniLeadTab* mpJIS0208ToUniLeadTab;
196 const ImplDBCSToUniLeadTab* mpJIS0212ToUniLeadTab;
197 const ImplUniToDBCSHighTab* mpUniToJIS0208HighTab;
198 const ImplUniToDBCSHighTab* mpUniToJIS0212HighTab;
199 } ImplEUCJPConvertData;
201 /* --------------------------------- */
202 /* - TextConverter - HelpFunctions - */
203 /* --------------------------------- */
205 sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags);
207 sal_Bool
208 ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData,
209 sal_Unicode const ** ppSrcBuf,
210 sal_Unicode const * pEndSrcBuf,
211 sal_Char ** ppDestBuf,
212 sal_Char const * pEndDestBuf,
213 sal_uInt32 nFlags,
214 sal_uInt32 * pInfo);
215 /* sal_True means 'continue,' sal_False means 'break' */
217 /* ----------------------------- */
218 /* - TextConverter - Functions - */
219 /* ----------------------------- */
221 sal_Size ImplSymbolToUnicode( const ImplTextConverterData* pData, void* pContext,
222 const sal_Char* pSrcBuf, sal_Size nSrcBytes,
223 sal_Unicode* pDestBuf, sal_Size nDestChars,
224 sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes );
225 sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, void* pContext,
226 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
227 sal_Char* pDestBuf, sal_Size nDestBytes,
228 sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars );
229 sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, void* pContext,
230 const sal_Char* pSrcBuf, sal_Size nSrcBytes,
231 sal_Unicode* pDestBuf, sal_Size nDestChars,
232 sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes );
233 sal_Size ImplUnicodeToChar( const ImplTextConverterData* pData, void* pContext,
234 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
235 sal_Char* pDestBuf, sal_Size nDestBytes,
236 sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars );
237 sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext,
238 const sal_Char* pSrcBuf, sal_Size nSrcBytes,
239 sal_Unicode* pDestBuf, sal_Size nDestChars,
240 sal_uInt32 nFlags, sal_uInt32* pInfo,
241 sal_Size* pSrcCvtBytes );
242 sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext,
243 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
244 sal_Char* pDestBuf, sal_Size nDestBytes,
245 sal_uInt32 nFlags, sal_uInt32* pInfo,
246 sal_Size* pSrcCvtChars );
247 sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData,
248 void* pContext,
249 const sal_Char* pSrcBuf, sal_Size nSrcBytes,
250 sal_Unicode* pDestBuf, sal_Size nDestChars,
251 sal_uInt32 nFlags, sal_uInt32* pInfo,
252 sal_Size* pSrcCvtBytes );
253 sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData,
254 void* pContext,
255 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
256 sal_Char* pDestBuf, sal_Size nDestBytes,
257 sal_uInt32 nFlags, sal_uInt32* pInfo,
258 sal_Size* pSrcCvtChars );
259 void* ImplUTF7CreateUTF7TextToUnicodeContext( void );
260 void ImplUTF7DestroyTextToUnicodeContext( void* pContext );
261 void ImplUTF7ResetTextToUnicodeContext( void* pContext );
262 sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext,
263 const sal_Char* pSrcBuf, sal_Size nSrcBytes,
264 sal_Unicode* pDestBuf, sal_Size nDestChars,
265 sal_uInt32 nFlags, sal_uInt32* pInfo,
266 sal_Size* pSrcCvtBytes );
267 void* ImplUTF7CreateUnicodeToTextContext( void );
268 void ImplUTF7DestroyUnicodeToTextContext( void* pContext );
269 void ImplUTF7ResetUnicodeToTextContext( void* pContext );
270 sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext,
271 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
272 sal_Char* pDestBuf, sal_Size nDestBytes,
273 sal_uInt32 nFlags, sal_uInt32* pInfo,
274 sal_Size* pSrcCvtChars );
276 void * ImplCreateUtf8ToUnicodeContext(void) SAL_THROW_EXTERN_C();
277 void ImplResetUtf8ToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C();
278 sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData,
279 void * pContext, sal_Char const * pSrcBuf,
280 sal_Size nSrcBytes, sal_Unicode * pDestBuf,
281 sal_Size nDestChars, sal_uInt32 nFlags,
282 sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes)
283 SAL_THROW_EXTERN_C();
284 void * ImplCreateUnicodeToUtf8Context(void) SAL_THROW_EXTERN_C();
285 void ImplResetUnicodeToUtf8Context(void * pContext) SAL_THROW_EXTERN_C();
286 sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData,
287 void * pContext, sal_Unicode const * pSrcBuf,
288 sal_Size nSrcChars, sal_Char * pDestBuf,
289 sal_Size nDestBytes, sal_uInt32 nFlags,
290 sal_uInt32 * pInfo, sal_Size* pSrcCvtChars)
291 SAL_THROW_EXTERN_C();
293 #if defined __cplusplus
295 #endif /* __cplusplus */
297 #endif /* INCLUDED_RTL_TEXTENC_TENCHELP_H */