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 _LINGUTIL_HXX_
25 #define _LINGUTIL_HXX_
26 
27 
28 #include <com/sun/star/lang/Locale.hpp>
29 #include <rtl/string.hxx>
30 #include <rtl/ustring.hxx>
31 #include <tools/string.hxx>
32 
33 #include <vector>
34 #include <list>
35 
36 
37 #define A2OU(x) ::rtl::OUString::createFromAscii( x )
38 
39 #define OU2A(rtlOUString) \
40     ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
41     RTL_TEXTENCODING_ASCII_US).getStr()
42 
43 #define OU2UTF8(rtlOUString) \
44     ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
45     RTL_TEXTENCODING_UTF8).getStr()
46 
47 #define OU2ISO_1(rtlOUString) \
48     ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
49     RTL_TEXTENCODING_ISO_8859_1).getStr()
50 
51 #define OU2ENC(rtlOUString, rtlEncoding) \
52     ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
53     rtlEncoding, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK).getStr()
54 
55 
56 struct SvtLinguConfigDictionaryEntry;
57 
58 ///////////////////////////////////////////////////////////////////////////
59 
60 struct lt_rtl_OUString
61 {
operator ()lt_rtl_OUString62     bool operator() (const rtl::OUString &r1, const rtl::OUString &r2) const
63     {
64         return r1 < r2;
65     }
66 };
67 
operator ==(const::com::sun::star::lang::Locale & rL1,const::com::sun::star::lang::Locale & rL2)68 inline sal_Bool operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com::sun::star::lang::Locale &rL2 )
69 {
70     return  rL1.Language ==  rL2.Language   &&
71             rL1.Country  ==  rL2.Country    &&
72             rL1.Variant  ==  rL2.Variant;
73 }
74 
75 #if 0
76 ///////////////////////////////////////////////////////////////////////////
77 
78 String GetDirectoryPathFromFileURL( const String &rFileURL );
79 #endif
80 
81 #if defined(WNT)
82 ///////////////////////////////////////////////////////////////////////////
83 // to be use to get a short path name under Windows that still can be used with
84 // the 'fopen' call. This is necessary since under Windows there seems to be
85 // a restriction of only about 110-130 characters length to a path name in order
86 // for it to work with 'fopen'. And that length is usually easily exceeded
87 // when using extensions...
88 rtl::OString Win_GetShortPathName( const rtl::OUString &rLongPathName );
89 #endif
90 
91 ///////////////////////////////////////////////////////////////////////////
92 
93 // temporary function, to be removed when new style dictionaries
94 // using configuration entries are fully implemented and provided
95 std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char * pDicType );
96 void MergeNewStyleDicsAndOldStyleDics( std::list< SvtLinguConfigDictionaryEntry > &rNewStyleDics, const std::vector< SvtLinguConfigDictionaryEntry > &rOldStyleDics );
97 
98 ///////////////////////////////////////////////////////////////////////////
99 
100 
101 //Find an encoding from a charset string, using
102 //rtl_getTextEncodingFromMimeCharset and falling back to
103 //rtl_getTextEncodingFromUnixCharset with the addition of
104 //ISCII-DEVANAGARI. On failure will return final fallback of
105 //RTL_TEXTENCODING_ISO_8859_1
106 rtl_TextEncoding getTextEncodingFromCharset(const sal_Char* pCharset);
107 
108 #endif
109 
110