xref: /aoo41x/main/sal/inc/rtl/locale.h (revision 514f4c20)
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 
23 
24 #ifndef _RTL_LOCALE_H_
25 #define _RTL_LOCALE_H_
26 
27 #include <rtl/ustring.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef SAL_W32
34 #	pragma pack(push, 8)
35 #elif defined(SAL_OS2)
36 #	pragma pack(push, 4)
37 #endif
38 
39 /**
40 	The implementation structur of a locale. Do not create this structure
41 	direct. Only use the functions rtl_locale_register and
42 	rtl_locale_setDefault. The strings Language, Country and Variant
43 	are constants, so it is not necessary to acquire and release them.
44  */
45 typedef struct _rtl_Locale
46 {
47 	/**
48 	 	Lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
49 	 */
50 	rtl_uString *	Language;
51 	/**
52 	 	uppercase two-letter ISO-3166 code.
53 	 */
54 	rtl_uString *	Country;
55 	/**
56 	 	Lowercase vendor and browser specific code.
57 	 */
58 	rtl_uString *	Variant;
59 	/**
60 	 	The merged hash value of the Language, Country and Variant strings.
61 	 */
62 	sal_Int32		HashCode;
63 } rtl_Locale;
64 
65 #if defined( SAL_W32) ||  defined(SAL_OS2)
66 #pragma pack(pop)
67 #endif
68 
69 /**
70 	Register a locale from language, country and variant.
71 	@param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
72 	@param country uppercase two-letter ISO-3166 code. May be null.
73 	@param variant vendor and browser specific code. May be null.
74  */
75 rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
76 
77 /**
78 	Common method of getting the current default Locale.
79 	Used for the presentation: menus, dialogs, etc.
80 	Generally set once when your applet or application is initialized,
81 	then never reset. (If you do reset the default locale, you
82 	probably want to reload your GUI, so that the change is reflected
83 	in your interface.)
84 	<p>More advanced programs will allow users to use different locales
85 	for different fields, e.g. in a spreadsheet.
86 	<BR>Note that the initial setting will match the host system.
87  */
88 rtl_Locale * SAL_CALL rtl_locale_getDefault();
89 
90 /**
91 	Sets the default.
92 	Normally set once at the beginning of applet or application,
93 	then never reset. <code>setDefault</code> does not reset the host locale.
94 	@param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
95 	@param country uppercase two-letter ISO-3166 code.
96 	@param variant vendor and browser specific code. See class description.
97  */
98 void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
99 
100 /**
101 	Getter for programmatic name of field,
102 	a lowercased two-letter ISO 639-1 or three-letter ISO 639-3 code.
103 	@see #getDisplayLanguage
104  */
105 rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This );
106 
107 /**
108 	Getter for programmatic name of field,
109 	an uppercased two-letter ISO-3166 code.
110 	@see #getDisplayCountry
111  */
112 rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This );
113 
114 /**
115 	Getter for programmatic name of field.
116 	@see #getDisplayVariant
117  */
118 rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This );
119 
120 /**
121 	Returns the hash code of the locale This.
122  */
123 sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This );
124 
125 /**
126 	Returns true if the locals are equal, otherwis false.
127  */
128 sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj  );
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* _RTL_LOCALE_H_ */
135 
136 
137