Get the style color and number just once
[LibreOffice.git] / sal / textenc / tenchelp.hxx
blob983b07669b20d28095c74cb6f7030bb427756626
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 .
20 #ifndef INCLUDED_SAL_TEXTENC_TENCHELP_HXX
21 #define INCLUDED_SAL_TEXTENC_TENCHELP_HXX
23 #include <sal/config.h>
25 #include <rtl/textcvt.h>
26 #include <sal/types.h>
28 #include "unichars.hxx"
30 #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100
31 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF
33 /* ----------------- */
34 /* - TextConverter - */
35 /* ----------------- */
37 typedef
38 sal_Size (* ImplConvertToUnicodeProc)(void const * pData,
39 void * pContext,
40 char const * pSrcBuf,
41 sal_Size nSrcBytes,
42 sal_Unicode * pDestBuf,
43 sal_Size nDestChars,
44 sal_uInt32 nFlags,
45 sal_uInt32 * pInfo,
46 sal_Size * pSrcCvtBytes);
48 typedef
49 sal_Size (* ImplConvertToTextProc)(void const * pData,
50 void * pContext,
51 sal_Unicode const * pSrcBuf,
52 sal_Size nSrcChars,
53 char * pDestBuf,
54 sal_Size nDestBytes,
55 sal_uInt32 nFlags,
56 sal_uInt32 * pInfo,
57 sal_Size * pSrcCvtChars);
59 typedef void * (* ImplCreateTextContextProc)();
61 typedef void (* ImplDestroyTextContextProc)(void * pContext);
63 typedef void (* ImplResetTextContextProc)(void * pContext);
65 typedef void * (* ImplCreateUnicodeContextProc)();
67 typedef void (* ImplDestroyUnicodeContextProc)(void * pContext);
69 typedef void (* ImplResetUnicodeContextProc)(void * pContext);
71 struct ImplTextConverter
73 void const * mpConvertData;
74 ImplConvertToUnicodeProc mpConvertTextToUnicodeProc;
75 ImplConvertToTextProc mpConvertUnicodeToTextProc;
76 ImplCreateTextContextProc mpCreateTextToUnicodeContext;
77 ImplDestroyTextContextProc mpDestroyTextToUnicodeContext;
78 ImplResetTextContextProc mpResetTextToUnicodeContext;
79 ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext;
80 ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext;
81 ImplResetUnicodeContextProc mpResetUnicodeToTextContext;
84 /* ----------------------------- */
85 /* - TextEncoding - Structures - */
86 /* ----------------------------- */
88 struct SAL_DLLPUBLIC_RTTI ImplTextEncodingData
90 ImplTextConverter maConverter;
91 char const * mpBestUnixCharset;
92 char const * mpBestMimeCharset;
93 sal_uInt8 mnMinCharSize;
94 sal_uInt8 mnMaxCharSize;
95 sal_uInt8 mnAveCharSize;
96 sal_uInt8 mnBestWindowsCharset;
97 sal_uInt32 mnInfoFlags;
100 /* ----------------------------------- */
101 /* - TextConverter - Byte-Structures - */
102 /* ----------------------------------- */
104 struct ImplUniCharTabData
106 sal_uInt16 mnUniChar;
107 unsigned char mnChar;
108 unsigned char mnChar2;
109 // to cater for mappings like MS1258 with 1--2 bytes per Unicode char,
110 // 0 if unused
113 struct ImplByteConvertData
115 const sal_uInt16* mpToUniTab1;
116 const sal_uInt16* mpToUniTab2;
117 const unsigned char* mpToCharTab1;
118 const unsigned char* mpToCharTab2;
119 const ImplUniCharTabData* mpToCharExTab;
120 unsigned char mnToUniStart1;
121 unsigned char mnToUniEnd1;
122 unsigned char mnToUniStart2;
123 unsigned char mnToUniEnd2;
124 sal_uInt16 mnToCharStart1;
125 sal_uInt16 mnToCharEnd1;
126 sal_uInt16 mnToCharStart2;
127 sal_uInt16 mnToCharEnd2;
128 sal_uInt16 mnToCharExCount;
131 /* ----------------------------------- */
132 /* - TextConverter - DBCS-Structures - */
133 /* ----------------------------------- */
135 struct ImplDBCSEUDCData
137 unsigned char mnLeadStart;
138 unsigned char mnLeadEnd;
139 unsigned char mnTrail1Start;
140 unsigned char mnTrail1End;
141 unsigned char mnTrail2Start;
142 unsigned char mnTrail2End;
143 unsigned char mnTrail3Start;
144 unsigned char mnTrail3End;
145 unsigned char mnTrailCount;
146 sal_uInt16 mnTrailRangeCount;
147 sal_uInt16 mnUniStart;
148 sal_uInt16 mnUniEnd;
151 struct ImplDBCSToUniLeadTab
153 sal_uInt16 mnUniChar;
154 sal_uInt8 mnTrailStart;
155 sal_uInt8 mnTrailEnd;
156 const sal_uInt16* mpToUniTrailTab;
159 struct ImplUniToDBCSHighTab
161 sal_uInt8 mnLowStart;
162 sal_uInt8 mnLowEnd;
163 const sal_uInt16* mpToUniTrailTab;
166 struct ImplDBCSConvertData
168 const ImplDBCSToUniLeadTab* mpToUniLeadTab;
169 const ImplUniToDBCSHighTab* mpToDBCSHighTab;
170 const ImplDBCSEUDCData* mpEUDCTab;
171 sal_uInt16 mnEUDCCount;
172 unsigned char mnLeadStart;
173 unsigned char mnLeadEnd;
174 unsigned char mnTrailStart;
175 unsigned char mnTrailEnd;
178 /* ---------------------------------- */
179 /* - TextConverter - EUC-Structures - */
180 /* ---------------------------------- */
182 struct ImplEUCJPConvertData
184 const ImplDBCSToUniLeadTab* mpJIS0208ToUniLeadTab;
185 const ImplDBCSToUniLeadTab* mpJIS0212ToUniLeadTab;
186 const ImplUniToDBCSHighTab* mpUniToJIS0208HighTab;
187 const ImplUniToDBCSHighTab* mpUniToJIS0212HighTab;
190 /* --------------------------------- */
191 /* - TextConverter - HelpFunctions - */
192 /* --------------------------------- */
194 inline sal_Unicode ImplGetUndefinedUnicodeChar(
195 unsigned char cChar, sal_uInt32 nFlags)
197 return ((nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK)
198 == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE) ?
199 RTL_TEXTCVT_BYTE_PRIVATE_START + cChar :
200 RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
203 /* ----------------------------- */
204 /* - TextConverter - Functions - */
205 /* ----------------------------- */
207 sal_Size ImplDBCSToUnicode( const void* pData, void* pContext,
208 const char* pSrcBuf, sal_Size nSrcBytes,
209 sal_Unicode* pDestBuf, sal_Size nDestChars,
210 sal_uInt32 nFlags, sal_uInt32* pInfo,
211 sal_Size* pSrcCvtBytes );
212 sal_Size ImplUnicodeToDBCS( const void* pData, void* pContext,
213 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
214 char* pDestBuf, sal_Size nDestBytes,
215 sal_uInt32 nFlags, sal_uInt32* pInfo,
216 sal_Size* pSrcCvtChars );
217 sal_Size ImplEUCJPToUnicode( const void* pData,
218 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 ImplUnicodeToEUCJP( const void* pData,
224 void* pContext,
225 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
226 char* pDestBuf, sal_Size nDestBytes,
227 sal_uInt32 nFlags, sal_uInt32* pInfo,
228 sal_Size* pSrcCvtChars );
229 void* ImplUTF7CreateUTF7TextToUnicodeContext();
230 void ImplUTF7DestroyTextToUnicodeContext( void* pContext );
231 void ImplUTF7ResetTextToUnicodeContext( void* pContext );
232 sal_Size ImplUTF7ToUnicode( const void* pData, void* pContext,
233 const char* pSrcBuf, sal_Size nSrcBytes,
234 sal_Unicode* pDestBuf, sal_Size nDestChars,
235 sal_uInt32 nFlags, sal_uInt32* pInfo,
236 sal_Size* pSrcCvtBytes );
237 void* ImplUTF7CreateUnicodeToTextContext();
238 void ImplUTF7DestroyUnicodeToTextContext( void* pContext );
239 void ImplUTF7ResetUnicodeToTextContext( void* pContext );
240 sal_Size ImplUnicodeToUTF7( const void* pData, void* pContext,
241 const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
242 char* pDestBuf, sal_Size nDestBytes,
243 sal_uInt32 nFlags, sal_uInt32* pInfo,
244 sal_Size* pSrcCvtChars );
246 #endif
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */