xref: /trunk/main/sal/inc/rtl/textcvt.h (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb) !
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef _RTL_TEXTCVT_H
29 #define _RTL_TEXTCVT_H
30 
31 #ifndef _SAL_TYPES_H
32 #include <sal/types.h>
33 #endif
34 #include <rtl/textenc.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* Documentation about this file can be found at
41    <http://udk.openoffice.org/cpp/man/spec/textconversion.html>. */
42 
43 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
44  */
45 typedef void* rtl_TextToUnicodeConverter;
46 
47 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
48  */
49 typedef void* rtl_TextToUnicodeContext;
50 
51 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
52  */
53 rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEncoding eTextEncoding );
54 
55 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
56  */
57 void                       SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter hConverter );
58 
59 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
60  */
61 rtl_TextToUnicodeContext   SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter );
62 
63 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
64  */
65 void                       SAL_CALL rtl_destroyTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
66 
67 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
68  */
69 void                       SAL_CALL rtl_resetTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
70 
71 #define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR             ((sal_uInt32)0x0001)
72 #define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE            ((sal_uInt32)0x0002)
73 #define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE      ((sal_uInt32)0x0003)
74 #define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT           ((sal_uInt32)0x0004)
75 #define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR           ((sal_uInt32)0x0010)
76 #define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE          ((sal_uInt32)0x0020)
77 #define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT         ((sal_uInt32)0x0030)
78 #define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR               ((sal_uInt32)0x0100)
79 #define RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE              ((sal_uInt32)0x0200)
80 #define RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT             ((sal_uInt32)0x0300)
81 #define RTL_TEXTTOUNICODE_FLAGS_FLUSH                       ((sal_uInt32)0x8000)
82 #define RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE 0x10000
83     /* Accept any global document signatures (for example, in UTF-8, a leading
84        EF BB BF encoding the Byte Order Mark U+FEFF) */
85 
86 #define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK              ((sal_uInt32)0x000F)
87 #define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK            ((sal_uInt32)0x00F0)
88 #define RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK                ((sal_uInt32)0x0F00)
89 
90 #define RTL_TEXTTOUNICODE_INFO_ERROR                        ((sal_uInt32)0x0001)
91 #define RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL             ((sal_uInt32)0x0002)
92 #define RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL            ((sal_uInt32)0x0004)
93 #define RTL_TEXTTOUNICODE_INFO_UNDEFINED                    ((sal_uInt32)0x0008)
94 #define RTL_TEXTTOUNICODE_INFO_MBUNDEFINED                  ((sal_uInt32)0x0010)
95 #define RTL_TEXTTOUNICODE_INFO_INVALID                      ((sal_uInt32)0x0020)
96 
97 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
98  */
99 sal_Size SAL_CALL rtl_convertTextToUnicode( rtl_TextToUnicodeConverter hConverter,
100                                             rtl_TextToUnicodeContext hContext,
101                                             const sal_Char* pSrcBuf, sal_Size nSrcBytes,
102                                             sal_Unicode* pDestBuf, sal_Size nDestChars,
103                                             sal_uInt32 nFlags, sal_uInt32* pInfo,
104                                             sal_Size* pSrcCvtBytes );
105 
106 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
107  */
108 typedef void* rtl_UnicodeToTextConverter;
109 
110 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
111  */
112 typedef void* rtl_UnicodeToTextContext;
113 
114 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
115  */
116 rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEncoding eTextEncoding );
117 
118 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
119  */
120 void                       SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter hConverter );
121 
122 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
123  */
124 rtl_UnicodeToTextContext   SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter );
125 
126 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
127  */
128 void                       SAL_CALL rtl_destroyUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
129 
130 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
131  */
132 void                       SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
133 
134 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR             ((sal_uInt32)0x0001)
135 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE            ((sal_uInt32)0x0002)
136 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0                 ((sal_uInt32)0x0003)
137 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK      ((sal_uInt32)0x0004)
138 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE         ((sal_uInt32)0x0005)
139 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT           ((sal_uInt32)0x0006)
140 #define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR               ((sal_uInt32)0x0010)
141 #define RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE              ((sal_uInt32)0x0020)
142 #define RTL_UNICODETOTEXT_FLAGS_INVALID_0                   ((sal_uInt32)0x0030)
143 #define RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK        ((sal_uInt32)0x0040)
144 #define RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE           ((sal_uInt32)0x0050)
145 #define RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT             ((sal_uInt32)0x0060)
146 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE           ((sal_uInt32)0x0100)
147 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR        ((sal_uInt32)0x0200)
148 #define RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0              ((sal_uInt32)0x0400)
149 #define RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE           ((sal_uInt32)0x0800)
150 #define RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE              ((sal_uInt32)0x1000)
151 #define RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE              ((sal_uInt32)0x2000)
152 #define RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE                 ((sal_uInt32)0x4000)
153 #define RTL_UNICODETOTEXT_FLAGS_FLUSH                       ((sal_uInt32)0x8000)
154 #define RTL_UNICODETOTEXT_FLAGS_GLOBAL_SIGNATURE 0x10000
155     /* Write any global document signatures (for example, in UTF-8, a leading
156        EF BB BF encoding the Byte Order Mark U+FEFF) */
157 
158 #define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK              ((sal_uInt32)0x000F)
159 #define RTL_UNICODETOTEXT_FLAGS_INVALID_MASK                ((sal_uInt32)0x00F0)
160 
161 #define RTL_UNICODETOTEXT_INFO_ERROR                        ((sal_uInt32)0x0001)
162 #define RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL             ((sal_uInt32)0x0002)
163 #define RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL            ((sal_uInt32)0x0004)
164 #define RTL_UNICODETOTEXT_INFO_UNDEFINED                    ((sal_uInt32)0x0008)
165 #define RTL_UNICODETOTEXT_INFO_INVALID                      ((sal_uInt32)0x0010)
166 
167 /** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
168  */
169 sal_Size SAL_CALL rtl_convertUnicodeToText( rtl_UnicodeToTextConverter hConverter,
170                                             rtl_UnicodeToTextContext hContext,
171                                             const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
172                                             sal_Char* pDestBuf, sal_Size nDestBytes,
173                                             sal_uInt32 nFlags, sal_uInt32* pInfo,
174                                             sal_Size* pSrcCvtChars );
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif /* _RTL_TEXTCVT_H */
181