xref: /AOO41X/main/framework/source/uielement/langselectionstatusbarcontroller.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
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
10cdf0e10cSrcweir  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 <toolkit/helper/vclunohelper.hxx>
39cdf0e10cSrcweir #include <com/sun/star/awt/PopupMenuDirection.hpp>
40cdf0e10cSrcweir #include <svtools/langtab.hxx>
41cdf0e10cSrcweir #include "sal/types.h"
42cdf0e10cSrcweir #include <vcl/svapp.hxx>
43cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp>
44cdf0e10cSrcweir #include <com/sun/star/document/XDocumentLanguages.hpp>
45cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
46cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/XModule.hpp>
48cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <classes/fwkresid.hxx>
51cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
52cdf0e10cSrcweir #include <classes/resource.hrc>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
55cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
56cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
57cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
58cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
59cdf0e10cSrcweir 
60450ff861SAriel Constenla-Haile #include <toolkit/helper/vclunohelper.hxx>
61cdf0e10cSrcweir #include <tools/gen.hxx>
62cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp>
63cdf0e10cSrcweir #include <svl/languageoptions.hxx>
64cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
65cdf0e10cSrcweir #include <dispatch/uieventloghelper.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include "helper/mischelper.hxx"
68cdf0e10cSrcweir 
69450ff861SAriel Constenla-Haile #include <rtl/ustrbuf.hxx>
70450ff861SAriel Constenla-Haile 
71cdf0e10cSrcweir #include <map>
72cdf0e10cSrcweir #include <set>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using namespace ::cppu;
75cdf0e10cSrcweir using namespace ::com::sun::star;
76cdf0e10cSrcweir using namespace ::com::sun::star::uno;
77cdf0e10cSrcweir using namespace ::com::sun::star::lang;
78cdf0e10cSrcweir using namespace ::com::sun::star::frame;
79cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
80cdf0e10cSrcweir using namespace ::com::sun::star::document;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir using ::rtl::OUString;
83450ff861SAriel Constenla-Haile using ::rtl::OUStringBuffer;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir namespace framework
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 
DEFINE_XSERVICEINFO_MULTISERVICE(LangSelectionStatusbarController,OWeakObject,SERVICENAME_STATUSBARCONTROLLER,IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER)89cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE        (   LangSelectionStatusbarController     	    ,
90cdf0e10cSrcweir                                             OWeakObject                             ,
91cdf0e10cSrcweir                                             SERVICENAME_STATUSBARCONTROLLER		    ,
92cdf0e10cSrcweir 											IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER
93cdf0e10cSrcweir 										)
94cdf0e10cSrcweir 
95cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   LangSelectionStatusbarController, {} )
96cdf0e10cSrcweir 
97cdf0e10cSrcweir LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) :
98cdf0e10cSrcweir     svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ),
99cdf0e10cSrcweir 	m_bShowMenu( sal_True ),
100cdf0e10cSrcweir     m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ),
101cdf0e10cSrcweir     m_aLangGuessHelper( xServiceManager )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
initialize(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> & aArguments)105cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
106cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::initialize" );
109cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     svt::StatusbarController::initialize( aArguments );
112cdf0e10cSrcweir 
113450ff861SAriel Constenla-Haile     if ( m_xStatusbarItem.is() )
114cdf0e10cSrcweir     {
115450ff861SAriel Constenla-Haile         m_xStatusbarItem->setText( String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ) );
116cdf0e10cSrcweir     }
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
LangMenu(const::com::sun::star::awt::Point & aPos)119450ff861SAriel Constenla-Haile void LangSelectionStatusbarController::LangMenu(
120450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos )
121cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" );
124cdf0e10cSrcweir 	if (!m_bShowMenu)
125cdf0e10cSrcweir 		return;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	//add context menu
128cdf0e10cSrcweir     const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu"));
129cdf0e10cSrcweir 	Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
130cdf0e10cSrcweir     //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph
131cdf0e10cSrcweir 	Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     SvtLanguageTable    aLanguageTable;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     // get languages to be displayed in the menu
136cdf0e10cSrcweir     std::set< OUString > aLangItems;
137cdf0e10cSrcweir     FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper,
138cdf0e10cSrcweir             m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     //
141cdf0e10cSrcweir     // add first few entries to main menu
142cdf0e10cSrcweir     //
143cdf0e10cSrcweir 	sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1);
144cdf0e10cSrcweir     const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));  // multiple languages in current selection
145cdf0e10cSrcweir     const OUString sEmpty;  // 'no language found' from language guessing
146cdf0e10cSrcweir     std::map< sal_Int16, OUString > aLangMap;
147cdf0e10cSrcweir     std::set< OUString >::const_iterator it;
148cdf0e10cSrcweir     for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         const OUString & rStr( *it );
151cdf0e10cSrcweir         if ( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) ) &&
152cdf0e10cSrcweir              rStr != sAsterix &&
153cdf0e10cSrcweir              rStr != sEmpty)
154cdf0e10cSrcweir 		{
155cdf0e10cSrcweir             DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9,
156cdf0e10cSrcweir                     "nItemId outside of expected range!" );
157450ff861SAriel Constenla-Haile 	        xPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
158cdf0e10cSrcweir 		    if ( rStr == m_aCurLang )
159cdf0e10cSrcweir 	        {
160cdf0e10cSrcweir 				//make a sign for the current language
161cdf0e10cSrcweir                 xPopupMenu->checkItem( nItemId, sal_True );
162cdf0e10cSrcweir 		    }
163cdf0e10cSrcweir             aLangMap[ nItemId ] = rStr;
164cdf0e10cSrcweir 			++nItemId;
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir     }
167450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_NONE,  String( FwkResId( STR_LANGSTATUS_NONE )), 0, MID_LANG_SEL_NONE );
168450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), 0, MID_LANG_SEL_RESET );
169450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_SEL_MORE,  String( FwkResId( STR_LANGSTATUS_MORE )), 0, MID_LANG_SEL_MORE );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     //
172cdf0e10cSrcweir     // add entries to submenu ('set language for paragraph')
173cdf0e10cSrcweir     //
174cdf0e10cSrcweir 	nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1);
175cdf0e10cSrcweir     for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         const OUString & rStr( *it );
178cdf0e10cSrcweir         if( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
179cdf0e10cSrcweir             rStr != sAsterix &&
180cdf0e10cSrcweir             rStr != sEmpty)
181cdf0e10cSrcweir 		{
182cdf0e10cSrcweir             DBG_ASSERT( MID_LANG_PARA_1 <= nItemId && nItemId <= MID_LANG_PARA_9,
183cdf0e10cSrcweir                     "nItemId outside of expected range!" );
184450ff861SAriel Constenla-Haile             subPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
185cdf0e10cSrcweir 			aLangMap[nItemId] = rStr;
186cdf0e10cSrcweir             ++nItemId;
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir     }
189450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_NONE,  String( FwkResId( STR_LANGSTATUS_NONE )), 0, MID_LANG_PARA_NONE );
190450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), 0, MID_LANG_PARA_RESET );
191450ff861SAriel Constenla-Haile     subPopupMenu->insertItem( MID_LANG_PARA_MORE,  String( FwkResId( STR_LANGSTATUS_MORE )), 0, MID_LANG_PARA_MORE );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     //
194cdf0e10cSrcweir     // add last two entries to main menu
195cdf0e10cSrcweir     //
196cdf0e10cSrcweir 	xPopupMenu->insertSeparator( MID_LANG_PARA_SEPERATOR );
197450ff861SAriel Constenla-Haile     xPopupMenu->insertItem( MID_LANG_PARA_STRING, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), 0, MID_LANG_PARA_STRING );
198cdf0e10cSrcweir 	xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     //
202cdf0e10cSrcweir     // now display the popup menu and execute every command ...
203cdf0e10cSrcweir     //
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY );
206*31d843d7SAriel Constenla-Haile     com::sun::star::awt::Rectangle aRect( aPos.X, aPos.Y, 0, 0 );
207*31d843d7SAriel Constenla-Haile 	sal_Int16 nId = xPopupMenu->execute( xParent, aRect, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
208cdf0e10cSrcweir     //click "More..."
209cdf0e10cSrcweir     if ( nId && m_xFrame.is() )
210cdf0e10cSrcweir     {
211450ff861SAriel Constenla-Haile         OUStringBuffer aBuff;
212450ff861SAriel Constenla-Haile         //set selected language as current language for selection
213450ff861SAriel Constenla-Haile         const OUString aSelectedLang = aLangMap[nId];
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 		if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
216cdf0e10cSrcweir 		{
217450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_") ));
218450ff861SAriel Constenla-Haile 			aBuff.append( aSelectedLang );
219cdf0e10cSrcweir 		}
220cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_NONE)
221cdf0e10cSrcweir 		{
222cdf0e10cSrcweir             //set None as current language for selection
223450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE") ));
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_RESET)
226cdf0e10cSrcweir 		{
227cdf0e10cSrcweir             // reset language attributes for selection
228450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES") ));
229cdf0e10cSrcweir         }
230cdf0e10cSrcweir 		else if (nId == MID_LANG_SEL_MORE)
231cdf0e10cSrcweir 		{
232cdf0e10cSrcweir 			//open the dialog "format/character" for current selection
233450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialog?Language:string=*") ));
234cdf0e10cSrcweir 		}
235cdf0e10cSrcweir         else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
236cdf0e10cSrcweir 		{
237450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_") ));
238450ff861SAriel Constenla-Haile             aBuff.append( aSelectedLang );
239cdf0e10cSrcweir 		}
240cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_NONE)
241cdf0e10cSrcweir         {
242cdf0e10cSrcweir             //set None as language for current paragraph
243450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE") ));
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_RESET)
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir             // reset language attributes for paragraph
248450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES") ));
249cdf0e10cSrcweir         }
250cdf0e10cSrcweir         else if (nId == MID_LANG_PARA_MORE)
251cdf0e10cSrcweir 		{
252cdf0e10cSrcweir 			//open the dialog "format/character" for current paragraph
253450ff861SAriel Constenla-Haile             aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialogForParagraph") ));
254cdf0e10cSrcweir 		}
255cdf0e10cSrcweir 
256450ff861SAriel Constenla-Haile         const Sequence< beans::PropertyValue > aDummyArgs;
257450ff861SAriel Constenla-Haile         execute( aBuff.makeStringAndClear(), aDummyArgs );
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
command(const::com::sun::star::awt::Point & aPos,::sal_Int32 nCommand,::sal_Bool,const::com::sun::star::uno::Any &)261cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::command(
262450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos,
263cdf0e10cSrcweir     ::sal_Int32 nCommand,
264cdf0e10cSrcweir     ::sal_Bool /*bMouseEvent*/,
265cdf0e10cSrcweir     const ::com::sun::star::uno::Any& /*aData*/ )
266cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::command" );
269cdf0e10cSrcweir 	if ( nCommand & ::awt::Command::CONTEXTMENU )
270cdf0e10cSrcweir 	{
271450ff861SAriel Constenla-Haile         LangMenu( aPos );
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
click(const::com::sun::star::awt::Point & aPos)275450ff861SAriel Constenla-Haile void SAL_CALL LangSelectionStatusbarController::click(
276450ff861SAriel Constenla-Haile     const ::com::sun::star::awt::Point& aPos )
277cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
278cdf0e10cSrcweir {
279cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::click" );
280450ff861SAriel Constenla-Haile     LangMenu( aPos );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir // XStatusListener
statusChanged(const FeatureStateEvent & Event)284cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event )
285cdf0e10cSrcweir throw ( RuntimeException )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     // This function will be called when observed data changes,
288cdf0e10cSrcweir     // for example the selection or keyboard language.
289cdf0e10cSrcweir     // - It displays the language in use in the status bar
290cdf0e10cSrcweir     // - and it stores the relevant data for creating the menu
291cdf0e10cSrcweir     //   at some later point in the member variables
292cdf0e10cSrcweir     //      m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" );
295cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     if ( m_bDisposed )
298cdf0e10cSrcweir         return;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	m_bShowMenu = sal_True;
301cdf0e10cSrcweir 	m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX;  //set the default value
302450ff861SAriel Constenla-Haile 
303450ff861SAriel Constenla-Haile     if ( m_xStatusbarItem.is() )
304cdf0e10cSrcweir     {
305cdf0e10cSrcweir         OUString aStrValue;
306cdf0e10cSrcweir         Sequence< OUString > aSeq;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         if ( Event.State >>= aStrValue )
309450ff861SAriel Constenla-Haile             m_xStatusbarItem->setText( aStrValue );
310cdf0e10cSrcweir         else if ( Event.State >>= aSeq )
311cdf0e10cSrcweir         {
312cdf0e10cSrcweir             if ( aSeq.getLength() == 4 )
313cdf0e10cSrcweir             {
314cdf0e10cSrcweir 				OUString aStatusText = aSeq[0];
315450ff861SAriel Constenla-Haile 				if ( 0 == aStatusText.compareToAscii( RTL_CONSTASCII_STRINGPARAM("*") ))
316450ff861SAriel Constenla-Haile                 {
317450ff861SAriel Constenla-Haile                     aStatusText = String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
318450ff861SAriel Constenla-Haile                 }
319450ff861SAriel Constenla-Haile                 m_xStatusbarItem->setText( aStatusText );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir                 // Retrieve all other values from the sequence and
322cdf0e10cSrcweir                 // store it members!
323cdf0e10cSrcweir 				m_aCurLang      = aSeq[0];
324cdf0e10cSrcweir                 m_nScriptType   = static_cast< sal_Int16 >( aSeq[1].toInt32() );
325cdf0e10cSrcweir 	            m_aKeyboardLang = aSeq[2];
326cdf0e10cSrcweir                 m_aGuessedTextLang  = aSeq[3];
327cdf0e10cSrcweir             }
328cdf0e10cSrcweir         }
329cdf0e10cSrcweir         else if ( !Event.State.hasValue() )
330cdf0e10cSrcweir 		{
331450ff861SAriel Constenla-Haile             m_xStatusbarItem->setText( OUString() );
332cdf0e10cSrcweir 			m_bShowMenu = sal_False;	// no language -> no menu
333cdf0e10cSrcweir 		}
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339