merged tag ooo/DEV300_m102
[LibreOffice.git] / lingucomponent / source / lingutil / lingutil.hxx
blob6c53edfd9cf4816eaf61221691bd373e12b4e392
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _LINGUTIL_HXX_
29 #define _LINGUTIL_HXX_
32 #include <com/sun/star/lang/Locale.hpp>
33 #include <rtl/string.hxx>
34 #include <rtl/ustring.hxx>
35 #include <tools/string.hxx>
37 #include <vector>
38 #include <list>
41 #define A2OU(x) ::rtl::OUString::createFromAscii( x )
43 #define OU2A(rtlOUString) \
44 ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
45 RTL_TEXTENCODING_ASCII_US).getStr()
47 #define OU2UTF8(rtlOUString) \
48 ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
49 RTL_TEXTENCODING_UTF8).getStr()
51 #define OU2ISO_1(rtlOUString) \
52 ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
53 RTL_TEXTENCODING_ISO_8859_1).getStr()
55 #define OU2ENC(rtlOUString, rtlEncoding) \
56 ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), \
57 rtlEncoding, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK).getStr()
60 struct SvtLinguConfigDictionaryEntry;
62 ///////////////////////////////////////////////////////////////////////////
64 struct lt_rtl_OUString
66 bool operator() (const rtl::OUString &r1, const rtl::OUString &r2) const
68 return r1 < r2;
72 inline sal_Bool operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com::sun::star::lang::Locale &rL2 )
74 return rL1.Language == rL2.Language &&
75 rL1.Country == rL2.Country &&
76 rL1.Variant == rL2.Variant;
79 #if 0
80 ///////////////////////////////////////////////////////////////////////////
82 String GetDirectoryPathFromFileURL( const String &rFileURL );
83 #endif
85 #if defined(WNT)
86 ///////////////////////////////////////////////////////////////////////////
87 // to be use to get a short path name under Windows that still can be used with
88 // the 'fopen' call. This is necessary since under Windows there seems to be
89 // a restriction of only about 110-130 characters length to a path name in order
90 // for it to work with 'fopen'. And that length is usually easily exceeded
91 // when using extensions...
92 rtl::OString Win_GetShortPathName( const rtl::OUString &rLongPathName );
93 #endif
95 ///////////////////////////////////////////////////////////////////////////
97 // temporary function, to be removed when new style dictionaries
98 // using configuration entries are fully implemented and provided
99 std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char * pDicType );
100 void MergeNewStyleDicsAndOldStyleDics( std::list< SvtLinguConfigDictionaryEntry > &rNewStyleDics, const std::vector< SvtLinguConfigDictionaryEntry > &rOldStyleDics );
102 ///////////////////////////////////////////////////////////////////////////
105 //Find an encoding from a charset string, using
106 //rtl_getTextEncodingFromMimeCharset and falling back to
107 //rtl_getTextEncodingFromUnixCharset with the addition of
108 //ISCII-DEVANAGARI. On failure will return final fallback of
109 //RTL_TEXTENCODING_ISO_8859_1
110 rtl_TextEncoding getTextEncodingFromCharset(const sal_Char* pCharset);
112 #endif