xref: /trunk/main/sal/inc/rtl/locale.h (revision 01cec6d620143fc02deecf66cdb0013880d92ac2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _RTL_LOCALE_H_
23 #define _RTL_LOCALE_H_
24 
25 #include <rtl/ustring.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifdef SAL_W32
32 #   pragma pack(push, 8)
33 #elif defined(SAL_OS2)
34 #   pragma pack(push, 4)
35 #endif
36 
37 /**
38     The implementation structure of a locale. Do not create this structure
39     direct. Only use the functions rtl_locale_register and
40     rtl_locale_setDefault. The strings Language, Country and Variant
41     are constants, so it is not necessary to acquire and release them.
42  */
43 typedef struct _rtl_Locale
44 {
45     /**
46         Lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
47      */
48     rtl_uString *   Language;
49     /**
50         uppercase two-letter ISO-3166 code.
51      */
52     rtl_uString *   Country;
53     /**
54         Lowercase vendor and browser specific code.
55      */
56     rtl_uString *   Variant;
57     /**
58         The merged hash value of the Language, Country and Variant strings.
59      */
60     sal_Int32       HashCode;
61 } rtl_Locale;
62 
63 #if defined( SAL_W32) || defined(SAL_OS2)
64 #pragma pack(pop)
65 #endif
66 
67 /**
68     Register a locale from language, country and variant.
69     @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
70     @param country uppercase two-letter ISO-3166 code. May be null.
71     @param variant vendor and browser specific code. May be null.
72  */
73 rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
74 
75 /**
76     Common method of getting the current default Locale.
77     Used for the presentation: menus, dialogs, etc.
78     Generally set once when your applet or application is initialized,
79     then never reset. (If you do reset the default locale, you
80     probably want to reload your GUI, so that the change is reflected
81     in your interface.)
82     <p>More advanced programs will allow users to use different locales
83     for different fields, e.g. in a spreadsheet.
84     <BR>Note that the initial setting will match the host system.
85  */
86 rtl_Locale * SAL_CALL rtl_locale_getDefault();
87 
88 /**
89     Sets the default.
90     Normally set once at the beginning of applet or application,
91     then never reset. <code>setDefault</code> does not reset the host locale.
92     @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
93     @param country uppercase two-letter ISO-3166 code.
94     @param variant vendor and browser specific code. See class description.
95  */
96 void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
97 
98 /**
99     Getter for programmatic name of field,
100     a lowercased two-letter ISO 639-1 or three-letter ISO 639-3 code.
101     @see #getDisplayLanguage
102  */
103 rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This );
104 
105 /**
106     Getter for programmatic name of field,
107     an uppercased two-letter ISO-3166 code.
108     @see #getDisplayCountry
109  */
110 rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This );
111 
112 /**
113     Getter for programmatic name of field.
114     @see #getDisplayVariant
115  */
116 rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This );
117 
118 /**
119     Returns the hash code of the locale This.
120  */
121 sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This );
122 
123 /**
124     Returns true if the locals are equal, otherwise false.
125  */
126 sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj );
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* _RTL_LOCALE_H_ */
133