1*e7675e54SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*e7675e54SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*e7675e54SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*e7675e54SAndrew Rist * distributed with this work for additional information
6*e7675e54SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*e7675e54SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*e7675e54SAndrew Rist * "License"); you may not use this file except in compliance
9*e7675e54SAndrew Rist * with the License. You may obtain a copy of the License at
10*e7675e54SAndrew Rist *
11*e7675e54SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*e7675e54SAndrew Rist *
13*e7675e54SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*e7675e54SAndrew Rist * software distributed under the License is distributed on an
15*e7675e54SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e7675e54SAndrew Rist * KIND, either express or implied. See the License for the
17*e7675e54SAndrew Rist * specific language governing permissions and limitations
18*e7675e54SAndrew Rist * under the License.
19*e7675e54SAndrew Rist *
20*e7675e54SAndrew Rist *************************************************************/
21*e7675e54SAndrew Rist
22*e7675e54SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _LINGUTIL_HXX_
25cdf0e10cSrcweir #define _LINGUTIL_HXX_
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
29cdf0e10cSrcweir #include <rtl/string.hxx>
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <tools/string.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <vector>
34cdf0e10cSrcweir #include <list>
35cdf0e10cSrcweir
36cdf0e10cSrcweir
37cdf0e10cSrcweir #define A2OU(x) ::rtl::OUString::createFromAscii( x )
38cdf0e10cSrcweir
39cdf0e10cSrcweir #define OU2A(rtlOUString) \
40cdf0e10cSrcweir ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
41cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US).getStr()
42cdf0e10cSrcweir
43cdf0e10cSrcweir #define OU2UTF8(rtlOUString) \
44cdf0e10cSrcweir ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
45cdf0e10cSrcweir RTL_TEXTENCODING_UTF8).getStr()
46cdf0e10cSrcweir
47cdf0e10cSrcweir #define OU2ISO_1(rtlOUString) \
48cdf0e10cSrcweir ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
49cdf0e10cSrcweir RTL_TEXTENCODING_ISO_8859_1).getStr()
50cdf0e10cSrcweir
51cdf0e10cSrcweir #define OU2ENC(rtlOUString, rtlEncoding) \
52cdf0e10cSrcweir ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
53cdf0e10cSrcweir rtlEncoding, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK).getStr()
54cdf0e10cSrcweir
55cdf0e10cSrcweir
56cdf0e10cSrcweir struct SvtLinguConfigDictionaryEntry;
57cdf0e10cSrcweir
58cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
59cdf0e10cSrcweir
60cdf0e10cSrcweir struct lt_rtl_OUString
61cdf0e10cSrcweir {
operator ()lt_rtl_OUString62cdf0e10cSrcweir bool operator() (const rtl::OUString &r1, const rtl::OUString &r2) const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir return r1 < r2;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir };
67cdf0e10cSrcweir
operator ==(const::com::sun::star::lang::Locale & rL1,const::com::sun::star::lang::Locale & rL2)68cdf0e10cSrcweir inline sal_Bool operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com::sun::star::lang::Locale &rL2 )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir return rL1.Language == rL2.Language &&
71cdf0e10cSrcweir rL1.Country == rL2.Country &&
72cdf0e10cSrcweir rL1.Variant == rL2.Variant;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir #if 0
76cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
77cdf0e10cSrcweir
78cdf0e10cSrcweir String GetDirectoryPathFromFileURL( const String &rFileURL );
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir
81cdf0e10cSrcweir #if defined(WNT)
82cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
83cdf0e10cSrcweir // to be use to get a short path name under Windows that still can be used with
84cdf0e10cSrcweir // the 'fopen' call. This is necessary since under Windows there seems to be
85cdf0e10cSrcweir // a restriction of only about 110-130 characters length to a path name in order
86cdf0e10cSrcweir // for it to work with 'fopen'. And that length is usually easily exceeded
87cdf0e10cSrcweir // when using extensions...
88cdf0e10cSrcweir rtl::OString Win_GetShortPathName( const rtl::OUString &rLongPathName );
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir
91cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
92cdf0e10cSrcweir
93cdf0e10cSrcweir // temporary function, to be removed when new style dictionaries
94cdf0e10cSrcweir // using configuration entries are fully implemented and provided
95cdf0e10cSrcweir std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char * pDicType );
96cdf0e10cSrcweir void MergeNewStyleDicsAndOldStyleDics( std::list< SvtLinguConfigDictionaryEntry > &rNewStyleDics, const std::vector< SvtLinguConfigDictionaryEntry > &rOldStyleDics );
97cdf0e10cSrcweir
98cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
99cdf0e10cSrcweir
100cdf0e10cSrcweir
101cdf0e10cSrcweir //Find an encoding from a charset string, using
102cdf0e10cSrcweir //rtl_getTextEncodingFromMimeCharset and falling back to
103cdf0e10cSrcweir //rtl_getTextEncodingFromUnixCharset with the addition of
104cdf0e10cSrcweir //ISCII-DEVANAGARI. On failure will return final fallback of
105cdf0e10cSrcweir //RTL_TEXTENCODING_ISO_8859_1
106cdf0e10cSrcweir rtl_TextEncoding getTextEncodingFromCharset(const sal_Char* pCharset);
107cdf0e10cSrcweir
108cdf0e10cSrcweir #endif
109cdf0e10cSrcweir
110