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 #ifndef __FRAMEWORK_UIELEMENT_LANGUAGESELECTIONMENUCONTROLLER_HXX_ 25 #define __FRAMEWORK_UIELEMENT_LANGUAGESELECTIONMENUCONTROLLER_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #include <macros/xserviceinfo.hxx> 32 #include <stdtypes.h> 33 34 //_________________________________________________________________________________________________________________ 35 // interface includes 36 //_________________________________________________________________________________________________________________ 37 #include <com/sun/star/lang/XServiceInfo.hpp> 38 #include <com/sun/star/lang/XTypeProvider.hpp> 39 #include <com/sun/star/lang/XInitialization.hpp> 40 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41 #include <com/sun/star/frame/XFrame.hpp> 42 #include <com/sun/star/frame/XDispatch.hpp> 43 #include <com/sun/star/frame/XStatusListener.hpp> 44 #include <com/sun/star/frame/XPopupMenuController.hpp> 45 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp> 46 47 //_________________________________________________________________________________________________________________ 48 // includes of other projects 49 //_________________________________________________________________________________________________________________ 50 #include <svtools/popupmenucontrollerbase.hxx> 51 #include <toolkit/awt/vclxmenu.hxx> 52 #include <cppuhelper/weak.hxx> 53 #include <rtl/ustring.hxx> 54 55 #include "helper/mischelper.hxx" 56 57 namespace framework 58 { 59 class LanguageSelectionMenuController : public svt::PopupMenuControllerBase 60 { 61 using svt::PopupMenuControllerBase::disposing; 62 63 public: 64 LanguageSelectionMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); 65 virtual ~LanguageSelectionMenuController(); 66 67 // XServiceInfo 68 DECLARE_XSERVICEINFO 69 70 // XPopupMenuController 71 virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException); 72 73 // XInitialization 74 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 75 76 // XStatusListener 77 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 78 79 // XEventListener 80 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 81 82 private: 83 virtual void impl_setPopupMenu(); 84 virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL); 85 enum Mode 86 { 87 MODE_SetLanguageSelectionMenu, 88 MODE_SetLanguageParagraphMenu, 89 MODE_SetLanguageAllTextMenu 90 }; 91 92 sal_Bool m_bShowMenu; 93 ::rtl::OUString m_aLangStatusCommandURL; 94 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xLanguageDispatch; 95 ::rtl::OUString m_aMenuCommandURL_Lang; 96 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xMenuDispatch_Lang; 97 ::rtl::OUString m_aMenuCommandURL_Font; 98 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xMenuDispatch_Font; 99 ::rtl::OUString m_aMenuCommandURL_CharDlgForParagraph; 100 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xMenuDispatch_CharDlgForParagraph; 101 ::rtl::OUString m_aCurLang; 102 sal_Int16 m_nScriptType; 103 ::rtl::OUString m_aKeyboardLang; 104 ::rtl::OUString m_aGuessedTextLang; 105 LanguageGuessingHelper m_aLangGuessHelper; 106 107 void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu, const Mode rMode ); 108 }; 109 } 110 111 #endif // __FRAMEWORK_UIELEMENT_LANGUAGESELECTIONMENUCONTROLLER_HXX_ 112