1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_SAL_TEXTENC_TENCHELP_HXX
30 #define INCLUDED_SAL_TEXTENC_TENCHELP_HXX
32 #include "sal/config.h"
34 #include "rtl/tencinfo.h"
35 #include "rtl/textcvt.h"
36 #include "rtl/textenc.h"
37 #include "sal/types.h"
39 #include "unichars.hxx"
41 #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100
42 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF
44 /* ----------------- */
45 /* - TextConverter - */
46 /* ----------------- */
49 sal_Size (* ImplConvertToUnicodeProc
)(void const * pData
,
53 sal_Unicode
* pDestBuf
,
57 sal_Size
* pSrcCvtBytes
);
60 sal_Size (* ImplConvertToTextProc
)(void const * pData
,
62 sal_Unicode
const * pSrcBuf
,
68 sal_Size
* pSrcCvtChars
);
70 typedef void * (* ImplCreateTextContextProc
)();
72 typedef void (* ImplDestroyTextContextProc
)(void * pContext
);
74 typedef void (* ImplResetTextContextProc
)(void * pContext
);
76 typedef void * (* ImplCreateUnicodeContextProc
)();
78 typedef void (* ImplDestroyUnicodeContextProc
)(void * pContext
);
80 typedef void (* ImplResetUnicodeContextProc
)(void * pContext
);
82 struct ImplTextConverter
84 void 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
;
95 /* ----------------------------- */
96 /* - TextEncoding - Structures - */
97 /* ----------------------------- */
99 struct ImplTextEncodingData
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
;
111 /* ----------------------------------- */
112 /* - TextConverter - Byte-Structures - */
113 /* ----------------------------------- */
115 struct ImplUniCharTabData
117 sal_uInt16 mnUniChar
;
120 // to cater for mappings like MS1258 with 1--2 bytes per Unicode char,
124 struct ImplByteConvertData
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
;
142 /* ----------------------------------- */
143 /* - TextConverter - DBCS-Structures - */
144 /* ----------------------------------- */
146 struct ImplDBCSEUDCData
148 sal_uChar mnLeadStart
;
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
;
162 struct ImplDBCSToUniLeadTab
164 sal_uInt16 mnUniChar
;
165 sal_uInt8 mnTrailStart
;
166 sal_uInt8 mnTrailEnd
;
167 const sal_uInt16
* mpToUniTrailTab
;
170 struct ImplUniToDBCSHighTab
172 sal_uInt8 mnLowStart
;
174 const sal_uInt16
* mpToUniTrailTab
;
177 struct ImplDBCSConvertData
179 const ImplDBCSToUniLeadTab
* mpToUniLeadTab
;
180 const ImplUniToDBCSHighTab
* mpToDBCSHighTab
;
181 sal_uChar mnLeadStart
;
183 sal_uChar mnTrailStart
;
184 sal_uChar mnTrailEnd
;
185 const ImplDBCSEUDCData
* mpEUDCTab
;
186 sal_uInt16 mnEUDCCount
;
189 /* ---------------------------------- */
190 /* - TextConverter - EUC-Structures - */
191 /* ---------------------------------- */
193 struct ImplEUCJPConvertData
195 const ImplDBCSToUniLeadTab
* mpJIS0208ToUniLeadTab
;
196 const ImplDBCSToUniLeadTab
* mpJIS0212ToUniLeadTab
;
197 const ImplUniToDBCSHighTab
* mpUniToJIS0208HighTab
;
198 const ImplUniToDBCSHighTab
* mpUniToJIS0212HighTab
;
201 /* --------------------------------- */
202 /* - TextConverter - HelpFunctions - */
203 /* --------------------------------- */
205 inline sal_Unicode
ImplGetUndefinedUnicodeChar(
206 sal_uChar cChar
, sal_uInt32 nFlags
)
208 return ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK
)
209 == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE
) ?
210 RTL_TEXTCVT_BYTE_PRIVATE_START
+ cChar
:
211 RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER
;
214 /* ----------------------------- */
215 /* - TextConverter - Functions - */
216 /* ----------------------------- */
218 sal_Size
ImplDBCSToUnicode( const void* pData
, void* pContext
,
219 const char* pSrcBuf
, sal_Size nSrcBytes
,
220 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
221 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
222 sal_Size
* pSrcCvtBytes
);
223 sal_Size
ImplUnicodeToDBCS( const void* pData
, void* pContext
,
224 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
225 char* pDestBuf
, sal_Size nDestBytes
,
226 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
227 sal_Size
* pSrcCvtChars
);
228 sal_Size
ImplEUCJPToUnicode( const void* pData
,
230 const char* pSrcBuf
, sal_Size nSrcBytes
,
231 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
232 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
233 sal_Size
* pSrcCvtBytes
);
234 sal_Size
ImplUnicodeToEUCJP( const void* pData
,
236 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
237 char* pDestBuf
, sal_Size nDestBytes
,
238 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
239 sal_Size
* pSrcCvtChars
);
240 void* ImplUTF7CreateUTF7TextToUnicodeContext();
241 void ImplUTF7DestroyTextToUnicodeContext( void* pContext
);
242 void ImplUTF7ResetTextToUnicodeContext( void* pContext
);
243 sal_Size
ImplUTF7ToUnicode( const void* pData
, void* pContext
,
244 const char* pSrcBuf
, sal_Size nSrcBytes
,
245 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
246 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
247 sal_Size
* pSrcCvtBytes
);
248 void* ImplUTF7CreateUnicodeToTextContext();
249 void ImplUTF7DestroyUnicodeToTextContext( void* pContext
);
250 void ImplUTF7ResetUnicodeToTextContext( void* pContext
);
251 sal_Size
ImplUnicodeToUTF7( const void* pData
, void* pContext
,
252 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
253 char* pDestBuf
, sal_Size nDestBytes
,
254 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
255 sal_Size
* pSrcCvtChars
);
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */