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 #include <list> 25 #include <sal/types.h> 26 #include <tools/string.hxx> 27 #include <rtl/ustring.hxx> 28 #include <tools/resid.hxx> 29 #include <com/sun/star/lang/Locale.hpp> 30 #include <com/sun/star/container/XNameAccess.hpp> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include <svl/languageoptions.hxx> 33 34 namespace desktop 35 { 36 37 class LanguageSelection 38 { 39 public: 40 enum LanguageSelectionStatus 41 { 42 LS_STATUS_OK, 43 LS_STATUS_CANNOT_DETERMINE_LANGUAGE, 44 LS_STATUS_CONFIGURATIONACCESS_BROKEN 45 }; 46 47 static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); 48 static rtl::OUString getLanguageString(); 49 static bool prepareLanguage(); 50 static LanguageSelectionStatus getStatus(); 51 52 private: 53 static const rtl::OUString usFallbackLanguage; 54 static rtl::OUString aFoundLanguage; 55 static sal_Bool bFoundLanguage; 56 static LanguageSelectionStatus m_eStatus; 57 58 static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > 59 getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate=sal_False); 60 static com::sun::star::uno::Sequence< rtl::OUString > getInstalledLanguages(); 61 static sal_Bool isInstalledLanguage(rtl::OUString& usLocale, sal_Bool bExact=sal_False); 62 static rtl::OUString getFirstInstalledLanguage(); 63 static rtl::OUString getUserUILanguage(); 64 static rtl::OUString getUserLanguage(); 65 static rtl::OUString getSystemLanguage(); 66 static void resetUserLanguage(); 67 static void setDefaultLanguage(const rtl::OUString&); 68 }; 69 70 } //namespace desktop 71