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