1*f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e07b45SAndrew Rist  * distributed with this work for additional information
6*f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e07b45SAndrew Rist  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e07b45SAndrew Rist  *
13*f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15*f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18*f8e07b45SAndrew Rist  * under the License.
19*f8e07b45SAndrew Rist  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __MISC_HELPER_HXX_
25cdf0e10cSrcweir #define __MISC_HELPER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
28cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
29cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <i18npool/lang.h>
32cdf0e10cSrcweir #include <svl/languageoptions.hxx>
33cdf0e10cSrcweir #include <rtl/ustring.hxx>
34cdf0e10cSrcweir #include <fwidllapi.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <set>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class SvtLanguageTable;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // flags for script types in use within selection
42cdf0e10cSrcweir #define LS_SCRIPT_LATIN     0x0001
43cdf0e10cSrcweir #define LS_SCRIPT_ASIAN     0x0002
44cdf0e10cSrcweir #define LS_SCRIPT_COMPLEX   0x0004
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace framework
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // menu ids for language status bar control
51cdf0e10cSrcweir enum LangMenuIDs
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     MID_LANG_SEL_1 = 1,     // need to start with 1 since xPopupMenu->execute will return 0 if the menu is cancelled
54cdf0e10cSrcweir     MID_LANG_SEL_2,
55cdf0e10cSrcweir     MID_LANG_SEL_3,
56cdf0e10cSrcweir     MID_LANG_SEL_4,
57cdf0e10cSrcweir     MID_LANG_SEL_5,
58cdf0e10cSrcweir     MID_LANG_SEL_6,
59cdf0e10cSrcweir     MID_LANG_SEL_7,
60cdf0e10cSrcweir     MID_LANG_SEL_8,
61cdf0e10cSrcweir     MID_LANG_SEL_9,
62cdf0e10cSrcweir     MID_LANG_SEL_NONE,
63cdf0e10cSrcweir     MID_LANG_SEL_RESET,
64cdf0e10cSrcweir     MID_LANG_SEL_MORE,
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     MID_LANG_PARA_SEPERATOR,
67cdf0e10cSrcweir     MID_LANG_PARA_STRING,
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     MID_LANG_PARA_1,
70cdf0e10cSrcweir     MID_LANG_PARA_2,
71cdf0e10cSrcweir     MID_LANG_PARA_3,
72cdf0e10cSrcweir     MID_LANG_PARA_4,
73cdf0e10cSrcweir     MID_LANG_PARA_5,
74cdf0e10cSrcweir     MID_LANG_PARA_6,
75cdf0e10cSrcweir     MID_LANG_PARA_7,
76cdf0e10cSrcweir     MID_LANG_PARA_8,
77cdf0e10cSrcweir     MID_LANG_PARA_9,
78cdf0e10cSrcweir     MID_LANG_PARA_NONE,
79cdf0e10cSrcweir     MID_LANG_PARA_RESET,
80cdf0e10cSrcweir     MID_LANG_PARA_MORE,
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
IsScriptTypeMatchingToLanguage(sal_Int16 nScriptType,LanguageType nLang)84cdf0e10cSrcweir inline bool IsScriptTypeMatchingToLanguage( sal_Int16 nScriptType, LanguageType nLang )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir class FWI_DLLPUBLIC LanguageGuessingHelper
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     mutable ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing >    m_xLanguageGuesser;
93cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir public:
LanguageGuessingHelper(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _xServiceManager)96cdf0e10cSrcweir     LanguageGuessingHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceManager) : m_xServiceManager(_xServiceManager){}
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing >  GetGuesser() const;
99cdf0e10cSrcweir };
100cdf0e10cSrcweir 
101cdf0e10cSrcweir FWI_DLLPUBLIC ::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL
102cdf0e10cSrcweir             ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&    _xServiceFactory
103cdf0e10cSrcweir             ,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >&        _xUICommandLabels
104cdf0e10cSrcweir             ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame
105cdf0e10cSrcweir             ,::rtl::OUString& _rModuleIdentifier
106cdf0e10cSrcweir             ,sal_Bool& _rIni
107cdf0e10cSrcweir             ,const sal_Char* _pName);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir FWI_DLLPUBLIC void FillLangItems( std::set< ::rtl::OUString > &rLangItems,
110cdf0e10cSrcweir         const SvtLanguageTable &rLanguageTable,
111cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame,
112cdf0e10cSrcweir         const LanguageGuessingHelper & rLangGuessHelper,
113cdf0e10cSrcweir         sal_Int16               nScriptType,
114cdf0e10cSrcweir         const ::rtl::OUString & rCurLang,
115cdf0e10cSrcweir         const ::rtl::OUString & rKeyboardLang,
116cdf0e10cSrcweir         const ::rtl::OUString & rGuessedTextLang );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir } // namespace framework
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #endif // __MISC_HELPER_HXX_
121cdf0e10cSrcweir 
122