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