16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
106d739b60SAndrew Rist  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
196d739b60SAndrew Rist  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
226d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <uielement/langselectionstatusbarcontroller.hxx>
28cdf0e10cSrcweir #include <classes/fwkresid.hxx>
29cdf0e10cSrcweir #include <services.h>
30cdf0e10cSrcweir #include <classes/resource.hrc>
31cdf0e10cSrcweir #include <vos/mutex.hxx>
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #include <vcl/window.hxx>
34cdf0e10cSrcweir #include <vcl/status.hxx>
35cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <com/sun/star/frame/XPopupMenuController.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/PopupMenuDirection.hpp>
39cdf0e10cSrcweir #include <svtools/langtab.hxx>
40cdf0e10cSrcweir #include "sal/types.h"
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp>
43cdf0e10cSrcweir #include <com/sun/star/document/XDocumentLanguages.hpp>
44cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
45cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/XModule.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <classes/fwkresid.hxx>
50cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
51cdf0e10cSrcweir #include <classes/resource.hrc>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
54cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
55cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
56cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
57cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
58cdf0e10cSrcweir 
59450ff861SAriel Constenla-Haile #include <toolkit/helper/vclunohelper.hxx>
60cdf0e10cSrcweir #include <tools/gen.hxx>
61cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp>
62cdf0e10cSrcweir #include <svl/languageoptions.hxx>
63cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
64cdf0e10cSrcweir #include <dispatch/uieventloghelper.hxx>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #include "helper/mischelper.hxx"
67cdf0e10cSrcweir 
68450ff861SAriel Constenla-Haile #include <rtl/ustrbuf.hxx>
69450ff861SAriel Constenla-Haile 
70cdf0e10cSrcweir #include <map>
71cdf0e10cSrcweir #include <set>
72cdf0e10cSrcweir 
73cdf0e10cSrcweir using namespace ::cppu;
74cdf0e10cSrcweir using namespace ::com::sun::star;
75cdf0e10cSrcweir using namespace ::com::sun::star::uno;
76cdf0e10cSrcweir using namespace ::com::sun::star::lang;
77cdf0e10cSrcweir using namespace ::com::sun::star::frame;
78cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
79cdf0e10cSrcweir using namespace ::com::sun::star::document;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir using ::rtl::OUString;
82450ff861SAriel Constenla-Haile using ::rtl::OUStringBuffer;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir namespace framework
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 
DEFINE_XSERVICEINFO_MULTISERVICE(LangSelectionStatusbarController,OWeakObject,SERVICENAME_STATUSBARCONTROLLER,IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER)88cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE        (   LangSelectionStatusbarController     	    ,
89cdf0e10cSrcweir                                             OWeakObject                             ,
90cdf0e10cSrcweir                                             SERVICENAME_STATUSBARCONTROLLER		    ,
91cdf0e10cSrcweir 											IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER
92cdf0e10cSrcweir 										)
93cdf0e10cSrcweir 
94cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   LangSelectionStatusbarController, {} )
95cdf0e10cSrcweir 
96cdf0e10cSrcweir LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) :
97cdf0e10cSrcweir     svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ),
98cdf0e10cSrcweir 	m_bShowMenu( sal_True ),
99cdf0e10cSrcweir     m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ),
100cdf0e10cSrcweir     m_aLangGuessHelper( xServiceManager )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
initialize(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> & aArguments)104cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
105cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::initialize" );
108cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     svt::StatusbarController::initialize( aArguments );
111cdf0e10cSrcweir 
112450ff861SAriel Constenla-Haile     if ( m_xStatusbarItem.is() )
113cdf0e10cSrcweir     {
114450ff861SAriel Constenla-Haile         m_xStatusbarItem->setText( String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ) );
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
LangMenu(const::com::sun::star::awt::Point & aPos)118450ff861SAriel Constenla-Haile void LangSelectionStatusbarController::LangMenu(
119450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos )
120cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" );
123cdf0e10cSrcweir 	if (!m_bShowMenu)
124cdf0e10cSrcweir 		return;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	//add context menu
127cdf0e10cSrcweir     const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu"));
128cdf0e10cSrcweir 	Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
129cdf0e10cSrcweir     //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph
130cdf0e10cSrcweir 	Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     SvtLanguageTable    aLanguageTable;
133450ff861SAriel Constenla-Haile 
134cdf0e10cSrcweir     // get languages to be displayed in the menu
135cdf0e10cSrcweir     std::set< OUString > aLangItems;
136cdf0e10cSrcweir     FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper,
137cdf0e10cSrcweir             m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     //
140cdf0e10cSrcweir     // add first few entries to main menu
141cdf0e10cSrcweir     //
142cdf0e10cSrcweir 	sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1);
143cdf0e10cSrcweir     const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));  // multiple languages in current selection
144cdf0e10cSrcweir     const OUString sEmpty;  // 'no language found' from language guessing
145cdf0e10cSrcweir     std::map< sal_Int16, OUString > aLangMap;
146cdf0e10cSrcweir     std::set< OUString >::const_iterator it;
147cdf0e10cSrcweir     for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
148cdf0e10cSrcweir     {
149cdf0e10cSrcweir         const OUString & rStr( *it );
150cdf0e10cSrcweir         if ( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) ) &&
151cdf0e10cSrcweir              rStr != sAsterix &&
152cdf0e10cSrcweir              rStr != sEmpty)
153cdf0e10cSrcweir 		{
154cdf0e10cSrcweir             DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9,
155cdf0e10cSrcweir                     "nItemId outside of expected range!" );
156450ff861SAriel Constenla-Haile 	        xPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
157cdf0e10cSrcweir 		    if ( rStr == m_aCurLang )
158cdf0e10cSrcweir 	        {
159cdf0e10cSrcweir 				//make a sign for the current language
160cdf0e10cSrcweir                 xPopupMenu->checkItem( nItemId, sal_True );
161cdf0e10cSrcweir 		    }
162cdf0e10cSrcweir             aLangMap[ nItemId ] = rStr;
163cdf0e10cSrcweir 			++nItemId;
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir     }
166450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_NONE,  String( FwkResId( STR_LANGSTATUS_NONE )), 0, MID_LANG_SEL_NONE );
167450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), 0, MID_LANG_SEL_RESET );
168450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_MORE,  String( FwkResId( STR_LANGSTATUS_MORE )), 0, MID_LANG_SEL_MORE );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     //
171cdf0e10cSrcweir     // add entries to submenu ('set language for paragraph')
172cdf0e10cSrcweir     //
173cdf0e10cSrcweir 	nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1);
174cdf0e10cSrcweir     for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
175cdf0e10cSrcweir     {
176cdf0e10cSrcweir         const OUString & rStr( *it );
177cdf0e10cSrcweir         if( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
178cdf0e10cSrcweir             rStr != sAsterix &&
179cdf0e10cSrcweir             rStr != sEmpty)
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir             DBG_ASSERT( MID_LANG_PARA_1 <= nItemId && nItemId <= MID_LANG_PARA_9,
182cdf0e10cSrcweir                     "nItemId outside of expected range!" );
183450ff861SAriel Constenla-Haile             subPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
184cdf0e10cSrcweir 			aLangMap[nItemId] = rStr;
185cdf0e10cSrcweir             ++nItemId;
186cdf0e10cSrcweir 		}
187cdf0e10cSrcweir     }
188450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_NONE,  String( FwkResId( STR_LANGSTATUS_NONE )), 0, MID_LANG_PARA_NONE );
189450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), 0, MID_LANG_PARA_RESET );
190450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_MORE,  String( FwkResId( STR_LANGSTATUS_MORE )), 0, MID_LANG_PARA_MORE );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     //
193cdf0e10cSrcweir     // add last two entries to main menu
194cdf0e10cSrcweir     //
195cdf0e10cSrcweir 	xPopupMenu->insertSeparator( MID_LANG_PARA_SEPERATOR );
196450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_PARA_STRING, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), 0, MID_LANG_PARA_STRING );
197cdf0e10cSrcweir 	xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     //
201cdf0e10cSrcweir     // now display the popup menu and execute every command ...
202cdf0e10cSrcweir     //
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY );
205*31d843d7SAriel Constenla-Haile     com::sun::star::awt::Rectangle aRect( aPos.X, aPos.Y, 0, 0 );
206*31d843d7SAriel Constenla-Haile 	sal_Int16 nId = xPopupMenu->execute( xParent, aRect, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
207cdf0e10cSrcweir     //click "More..."
208cdf0e10cSrcweir     if ( nId && m_xFrame.is() )
209cdf0e10cSrcweir     {
210450ff861SAriel Constenla-Haile         OUStringBuffer aBuff;
211450ff861SAriel Constenla-Haile         //set selected language as current language for selection
212450ff861SAriel Constenla-Haile         const OUString aSelectedLang = aLangMap[nId];
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
215cdf0e10cSrcweir 		{
216450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_") ));
217450ff861SAriel Constenla-Haile 			aBuff.append( aSelectedLang );
218cdf0e10cSrcweir 		}
219cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_NONE)
220cdf0e10cSrcweir 		{
221cdf0e10cSrcweir             //set None as current language for selection
222450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE") ));
223cdf0e10cSrcweir 		}
224cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_RESET)
225cdf0e10cSrcweir 		{
226cdf0e10cSrcweir             // reset language attributes for selection
227450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES") ));
228cdf0e10cSrcweir         }
229cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_MORE)
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			//open the dialog "format/character" for current selection
232450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialog?Language:string=*") ));
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir         else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
235cdf0e10cSrcweir 		{
236450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_") ));
237450ff861SAriel Constenla-Haile             aBuff.append( aSelectedLang );
238cdf0e10cSrcweir 		}
239cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_NONE)
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             //set None as language for current paragraph
242450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE") ));
243cdf0e10cSrcweir         }
244cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_RESET)
245cdf0e10cSrcweir         {
246cdf0e10cSrcweir             // reset language attributes for paragraph
247450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES") ));
248cdf0e10cSrcweir         }
249cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_MORE)
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir 			//open the dialog "format/character" for current paragraph
252450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialogForParagraph") ));
253cdf0e10cSrcweir 		}
254cdf0e10cSrcweir 
255450ff861SAriel Constenla-Haile         const Sequence< beans::PropertyValue > aDummyArgs;
256450ff861SAriel Constenla-Haile         execute( aBuff.makeStringAndClear(), aDummyArgs );
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
command(const::com::sun::star::awt::Point & aPos,::sal_Int32 nCommand,::sal_Bool,const::com::sun::star::uno::Any &)260cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::command(
261450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos,
262cdf0e10cSrcweir     ::sal_Int32 nCommand,
263cdf0e10cSrcweir     ::sal_Bool /*bMouseEvent*/,
264cdf0e10cSrcweir     const ::com::sun::star::uno::Any& /*aData*/ )
265cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::command" );
268cdf0e10cSrcweir 	if ( nCommand & ::awt::Command::CONTEXTMENU )
269cdf0e10cSrcweir 	{
270450ff861SAriel Constenla-Haile         LangMenu( aPos );
271cdf0e10cSrcweir 	}
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
click(const::com::sun::star::awt::Point & aPos)274450ff861SAriel Constenla-Haile void SAL_CALL LangSelectionStatusbarController::click(
275450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos )
276cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::click" );
279450ff861SAriel Constenla-Haile     LangMenu( aPos );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir // XStatusListener
statusChanged(const FeatureStateEvent & Event)283cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event )
284cdf0e10cSrcweir throw ( RuntimeException )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     // This function will be called when observed data changes,
287cdf0e10cSrcweir     // for example the selection or keyboard language.
288cdf0e10cSrcweir     // - It displays the language in use in the status bar
289cdf0e10cSrcweir     // - and it stores the relevant data for creating the menu
290cdf0e10cSrcweir     //   at some later point in the member variables
291cdf0e10cSrcweir     //      m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" );
294cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     if ( m_bDisposed )
297cdf0e10cSrcweir         return;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	m_bShowMenu = sal_True;
300cdf0e10cSrcweir 	m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX;  //set the default value
301450ff861SAriel Constenla-Haile 
302450ff861SAriel Constenla-Haile     if ( m_xStatusbarItem.is() )
303cdf0e10cSrcweir     {
304450ff861SAriel Constenla-Haile         OUString aStrValue;
305cdf0e10cSrcweir         Sequence< OUString > aSeq;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         if ( Event.State >>= aStrValue )
308450ff861SAriel Constenla-Haile             m_xStatusbarItem->setText( aStrValue );
309cdf0e10cSrcweir         else if ( Event.State >>= aSeq )
310cdf0e10cSrcweir         {
311cdf0e10cSrcweir             if ( aSeq.getLength() == 4 )
312cdf0e10cSrcweir             {
313cdf0e10cSrcweir 				OUString aStatusText = aSeq[0];
314450ff861SAriel Constenla-Haile 				if ( 0 == aStatusText.compareToAscii( RTL_CONSTASCII_STRINGPARAM("*") ))
315450ff861SAriel Constenla-Haile                 {
316450ff861SAriel Constenla-Haile                     aStatusText = String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
317450ff861SAriel Constenla-Haile                 }
318450ff861SAriel Constenla-Haile                 m_xStatusbarItem->setText( aStatusText );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir                 // Retrieve all other values from the sequence and
321cdf0e10cSrcweir                 // store it members!
322cdf0e10cSrcweir 				m_aCurLang      = aSeq[0];
323cdf0e10cSrcweir                 m_nScriptType   = static_cast< sal_Int16 >( aSeq[1].toInt32() );
324cdf0e10cSrcweir 	            m_aKeyboardLang = aSeq[2];
325cdf0e10cSrcweir                 m_aGuessedTextLang  = aSeq[3];
326cdf0e10cSrcweir             }
327cdf0e10cSrcweir         }
328cdf0e10cSrcweir         else if ( !Event.State.hasValue() )
329cdf0e10cSrcweir 		{
330450ff861SAriel Constenla-Haile             m_xStatusbarItem->setText( OUString() );
331cdf0e10cSrcweir 			m_bShowMenu = sal_False;	// no language -> no menu
332cdf0e10cSrcweir 		}
333cdf0e10cSrcweir     }
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
338