1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_framework.hxx" 30*cdf0e10cSrcweir #include <uielement/controlmenucontroller.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 33*cdf0e10cSrcweir // my own includes 34*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 35*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 36*cdf0e10cSrcweir #include "services.h" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 39*cdf0e10cSrcweir // interface includes 40*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 41*cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50*cdf0e10cSrcweir // includes of other projects 51*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <vcl/menu.hxx> 54*cdf0e10cSrcweir #include <vcl/svapp.hxx> 55*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx> 56*cdf0e10cSrcweir #include <tools/urlobj.hxx> 57*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 58*cdf0e10cSrcweir #include <rtl/strbuf.hxx> 59*cdf0e10cSrcweir #include <svl/solar.hrc> 60*cdf0e10cSrcweir #include <tools/rcid.h> 61*cdf0e10cSrcweir #include <vcl/image.hxx> 62*cdf0e10cSrcweir #include <svtools/menuoptions.hxx> 63*cdf0e10cSrcweir #include <dispatch/uieventloghelper.hxx> 64*cdf0e10cSrcweir #include <vos/mutex.hxx> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // Copied from svx 67*cdf0e10cSrcweir // Function-Id's 68*cdf0e10cSrcweir #define RID_FMSHELL_CONVERSIONMENU (RID_FORMS_START + 4) 69*cdf0e10cSrcweir #define RID_SVXIMGLIST_FMEXPL (RID_FORMS_START + 0) 70*cdf0e10cSrcweir #define RID_SVXIMGLIST_FMEXPL_HC (RID_FORMS_START + 2) 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // Forms - Ids, used to address images from image list 73*cdf0e10cSrcweir #define SID_FMSLOTS_START (SID_SVX_START + 592) 74*cdf0e10cSrcweir #define SID_MORE_FMSLOTS_START (SID_SVX_START + 702) 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #define SID_FM_CONVERTTO_EDIT (SID_MORE_FMSLOTS_START + 32) 77*cdf0e10cSrcweir #define SID_FM_CONVERTTO_BUTTON (SID_MORE_FMSLOTS_START + 33) 78*cdf0e10cSrcweir #define SID_FM_CONVERTTO_FIXEDTEXT (SID_MORE_FMSLOTS_START + 34) 79*cdf0e10cSrcweir #define SID_FM_CONVERTTO_LISTBOX (SID_MORE_FMSLOTS_START + 35) 80*cdf0e10cSrcweir #define SID_FM_CONVERTTO_CHECKBOX (SID_MORE_FMSLOTS_START + 36) 81*cdf0e10cSrcweir #define SID_FM_CONVERTTO_RADIOBUTTON (SID_MORE_FMSLOTS_START + 37) 82*cdf0e10cSrcweir #define SID_FM_CONVERTTO_GROUPBOX (SID_MORE_FMSLOTS_START + 38) 83*cdf0e10cSrcweir #define SID_FM_CONVERTTO_COMBOBOX (SID_MORE_FMSLOTS_START + 39) 84*cdf0e10cSrcweir #define SID_FM_CONVERTTO_GRID (SID_MORE_FMSLOTS_START + 40) 85*cdf0e10cSrcweir #define SID_FM_CONVERTTO_IMAGEBUTTON (SID_MORE_FMSLOTS_START + 41) 86*cdf0e10cSrcweir #define SID_FM_CONVERTTO_FILECONTROL (SID_MORE_FMSLOTS_START + 42) 87*cdf0e10cSrcweir #define SID_FM_CONVERTTO_DATE (SID_MORE_FMSLOTS_START + 43) 88*cdf0e10cSrcweir #define SID_FM_CONVERTTO_TIME (SID_MORE_FMSLOTS_START + 44) 89*cdf0e10cSrcweir #define SID_FM_CONVERTTO_NUMERIC (SID_MORE_FMSLOTS_START + 45) 90*cdf0e10cSrcweir #define SID_FM_CONVERTTO_CURRENCY (SID_MORE_FMSLOTS_START + 46) 91*cdf0e10cSrcweir #define SID_FM_CONVERTTO_PATTERN (SID_MORE_FMSLOTS_START + 47) 92*cdf0e10cSrcweir #define SID_FM_CONVERTTO_IMAGECONTROL (SID_MORE_FMSLOTS_START + 48) 93*cdf0e10cSrcweir #define SID_FM_CONVERTTO_FORMATTED (SID_MORE_FMSLOTS_START + 49) 94*cdf0e10cSrcweir #define SID_FM_CONVERTTO_SCROLLBAR (SID_MORE_FMSLOTS_START + 68) 95*cdf0e10cSrcweir #define SID_FM_CONVERTTO_SPINBUTTON (SID_MORE_FMSLOTS_START + 69) 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir #define SID_FM_DATEFIELD (SID_MORE_FMSLOTS_START + 2) 98*cdf0e10cSrcweir #define SID_FM_TIMEFIELD (SID_MORE_FMSLOTS_START + 3) 99*cdf0e10cSrcweir #define SID_FM_NUMERICFIELD (SID_MORE_FMSLOTS_START + 4) 100*cdf0e10cSrcweir #define SID_FM_CURRENCYFIELD (SID_MORE_FMSLOTS_START + 5) 101*cdf0e10cSrcweir #define SID_FM_PATTERNFIELD (SID_MORE_FMSLOTS_START + 6) 102*cdf0e10cSrcweir #define SID_FM_IMAGECONTROL (SID_MORE_FMSLOTS_START + 8) 103*cdf0e10cSrcweir #define SID_FM_FORMATTEDFIELD (SID_MORE_FMSLOTS_START + 26) 104*cdf0e10cSrcweir #define SID_FM_SCROLLBAR (SID_MORE_FMSLOTS_START + 66) 105*cdf0e10cSrcweir #define SID_FM_SPINBUTTON (SID_MORE_FMSLOTS_START + 67) 106*cdf0e10cSrcweir #define SID_FM_CONFIG (SID_FMSLOTS_START + 1) 107*cdf0e10cSrcweir #define SID_FM_PUSHBUTTON (SID_FMSLOTS_START + 2) 108*cdf0e10cSrcweir #define SID_FM_RADIOBUTTON (SID_FMSLOTS_START + 3) 109*cdf0e10cSrcweir #define SID_FM_CHECKBOX (SID_FMSLOTS_START + 4) 110*cdf0e10cSrcweir #define SID_FM_FIXEDTEXT (SID_FMSLOTS_START + 5) 111*cdf0e10cSrcweir #define SID_FM_GROUPBOX (SID_FMSLOTS_START + 6) 112*cdf0e10cSrcweir #define SID_FM_EDIT (SID_FMSLOTS_START + 7) 113*cdf0e10cSrcweir #define SID_FM_LISTBOX (SID_FMSLOTS_START + 8) 114*cdf0e10cSrcweir #define SID_FM_COMBOBOX (SID_FMSLOTS_START + 9) 115*cdf0e10cSrcweir #define SID_FM_URLBUTTON (SID_FMSLOTS_START + 10) 116*cdf0e10cSrcweir #define SID_FM_DBGRID (SID_FMSLOTS_START + 11) 117*cdf0e10cSrcweir #define SID_FM_IMAGEBUTTON (SID_FMSLOTS_START + 12) 118*cdf0e10cSrcweir #define SID_FM_FILECONTROL (SID_FMSLOTS_START + 13) 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sal_Int16 nConvertSlots[] = 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir SID_FM_CONVERTTO_EDIT, 123*cdf0e10cSrcweir SID_FM_CONVERTTO_BUTTON, 124*cdf0e10cSrcweir SID_FM_CONVERTTO_FIXEDTEXT, 125*cdf0e10cSrcweir SID_FM_CONVERTTO_LISTBOX, 126*cdf0e10cSrcweir SID_FM_CONVERTTO_CHECKBOX, 127*cdf0e10cSrcweir SID_FM_CONVERTTO_RADIOBUTTON, 128*cdf0e10cSrcweir SID_FM_CONVERTTO_GROUPBOX, 129*cdf0e10cSrcweir SID_FM_CONVERTTO_COMBOBOX, 130*cdf0e10cSrcweir // SID_FM_CONVERTTO_GRID, 131*cdf0e10cSrcweir SID_FM_CONVERTTO_IMAGEBUTTON, 132*cdf0e10cSrcweir SID_FM_CONVERTTO_FILECONTROL, 133*cdf0e10cSrcweir SID_FM_CONVERTTO_DATE, 134*cdf0e10cSrcweir SID_FM_CONVERTTO_TIME, 135*cdf0e10cSrcweir SID_FM_CONVERTTO_NUMERIC, 136*cdf0e10cSrcweir SID_FM_CONVERTTO_CURRENCY, 137*cdf0e10cSrcweir SID_FM_CONVERTTO_PATTERN, 138*cdf0e10cSrcweir SID_FM_CONVERTTO_IMAGECONTROL, 139*cdf0e10cSrcweir SID_FM_CONVERTTO_FORMATTED, 140*cdf0e10cSrcweir SID_FM_CONVERTTO_SCROLLBAR, 141*cdf0e10cSrcweir SID_FM_CONVERTTO_SPINBUTTON 142*cdf0e10cSrcweir }; 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir sal_Int16 nCreateSlots[] = 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir SID_FM_EDIT, 147*cdf0e10cSrcweir SID_FM_PUSHBUTTON, 148*cdf0e10cSrcweir SID_FM_FIXEDTEXT, 149*cdf0e10cSrcweir SID_FM_LISTBOX, 150*cdf0e10cSrcweir SID_FM_CHECKBOX, 151*cdf0e10cSrcweir SID_FM_RADIOBUTTON, 152*cdf0e10cSrcweir SID_FM_GROUPBOX, 153*cdf0e10cSrcweir SID_FM_COMBOBOX, 154*cdf0e10cSrcweir // SID_FM_DBGRID, 155*cdf0e10cSrcweir SID_FM_IMAGEBUTTON, 156*cdf0e10cSrcweir SID_FM_FILECONTROL, 157*cdf0e10cSrcweir SID_FM_DATEFIELD, 158*cdf0e10cSrcweir SID_FM_TIMEFIELD, 159*cdf0e10cSrcweir SID_FM_NUMERICFIELD, 160*cdf0e10cSrcweir SID_FM_CURRENCYFIELD, 161*cdf0e10cSrcweir SID_FM_PATTERNFIELD, 162*cdf0e10cSrcweir SID_FM_IMAGECONTROL, 163*cdf0e10cSrcweir SID_FM_FORMATTEDFIELD, 164*cdf0e10cSrcweir SID_FM_SCROLLBAR, 165*cdf0e10cSrcweir SID_FM_SPINBUTTON 166*cdf0e10cSrcweir }; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir const char* aCommands[] = 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir ".uno:ConvertToEdit", 171*cdf0e10cSrcweir ".uno:ConvertToButton", 172*cdf0e10cSrcweir ".uno:ConvertToFixed", 173*cdf0e10cSrcweir ".uno:ConvertToList", 174*cdf0e10cSrcweir ".uno:ConvertToCheckBox", 175*cdf0e10cSrcweir ".uno:ConvertToRadio", 176*cdf0e10cSrcweir ".uno:ConvertToGroup", 177*cdf0e10cSrcweir ".uno:ConvertToCombo", 178*cdf0e10cSrcweir // ".uno:ConvertToGrid", 179*cdf0e10cSrcweir ".uno:ConvertToImageBtn", 180*cdf0e10cSrcweir ".uno:ConvertToFileControl", 181*cdf0e10cSrcweir ".uno:ConvertToDate", 182*cdf0e10cSrcweir ".uno:ConvertToTime", 183*cdf0e10cSrcweir ".uno:ConvertToNumeric", 184*cdf0e10cSrcweir ".uno:ConvertToCurrency", 185*cdf0e10cSrcweir ".uno:ConvertToPattern", 186*cdf0e10cSrcweir ".uno:ConvertToImageControl", 187*cdf0e10cSrcweir ".uno:ConvertToFormatted", 188*cdf0e10cSrcweir ".uno:ConvertToScrollBar", 189*cdf0e10cSrcweir ".uno:ConvertToSpinButton" 190*cdf0e10cSrcweir }; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 193*cdf0e10cSrcweir // Defines 194*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 195*cdf0e10cSrcweir // 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir using namespace com::sun::star::uno; 198*cdf0e10cSrcweir using namespace com::sun::star::lang; 199*cdf0e10cSrcweir using namespace com::sun::star::frame; 200*cdf0e10cSrcweir using namespace com::sun::star::beans; 201*cdf0e10cSrcweir using namespace com::sun::star::util; 202*cdf0e10cSrcweir using namespace com::sun::star::style; 203*cdf0e10cSrcweir using namespace com::sun::star::container; 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir namespace framework 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE ( ControlMenuController , 209*cdf0e10cSrcweir OWeakObject , 210*cdf0e10cSrcweir SERVICENAME_POPUPMENUCONTROLLER , 211*cdf0e10cSrcweir IMPLEMENTATIONNAME_CONTROLMENUCONTROLLER 212*cdf0e10cSrcweir ) 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir DEFINE_INIT_SERVICE ( ControlMenuController, {} ) 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir ControlMenuController::ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : 217*cdf0e10cSrcweir svt::PopupMenuControllerBase( xServiceManager ), 218*cdf0e10cSrcweir m_pResPopupMenu( 0 ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); 221*cdf0e10cSrcweir m_bWasHiContrast = rSettings.GetHighContrastMode(); 222*cdf0e10cSrcweir m_bShowMenuImages = rSettings.GetUseImagesInMenus(); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ControlMenuController::~ControlMenuController() 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // private function 231*cdf0e10cSrcweir void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir rtl::OUString aResName( RTL_CONSTASCII_USTRINGPARAM( "svx" )); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir ResMgr* pResMgr = ResMgr::CreateResMgr( rtl::OUStringToOString( aResName, RTL_TEXTENCODING_ASCII_US )); 236*cdf0e10cSrcweir ResId aResId( m_bWasHiContrast ? RID_SVXIMGLIST_FMEXPL_HC : RID_SVXIMGLIST_FMEXPL, *pResMgr ); 237*cdf0e10cSrcweir aResId.SetRT( RSC_IMAGELIST ); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if ( pResMgr->IsAvailable( aResId )) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir ImageList aImageList( aResId ); 242*cdf0e10cSrcweir for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir // das entsprechende Image dran 245*cdf0e10cSrcweir if ( m_bShowMenuImages ) 246*cdf0e10cSrcweir pPopupMenu->SetItemImage( nConvertSlots[i], aImageList.GetImage(nCreateSlots[i])); 247*cdf0e10cSrcweir else 248*cdf0e10cSrcweir pPopupMenu->SetItemImage( nConvertSlots[i], Image() ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir delete pResMgr; 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir // private function 256*cdf0e10cSrcweir void ControlMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu ); 259*cdf0e10cSrcweir PopupMenu* pVCLPopupMenu = 0; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir resetPopupMenu( rPopupMenu ); 264*cdf0e10cSrcweir if ( pPopupMenu ) 265*cdf0e10cSrcweir pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if ( pVCLPopupMenu && m_pResPopupMenu ) 268*cdf0e10cSrcweir *pVCLPopupMenu = *m_pResPopupMenu; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir // XEventListener 272*cdf0e10cSrcweir void SAL_CALL ControlMenuController::disposing( const EventObject& ) throw ( RuntimeException ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 277*cdf0e10cSrcweir m_xFrame.clear(); 278*cdf0e10cSrcweir m_xDispatch.clear(); 279*cdf0e10cSrcweir m_xServiceManager.clear(); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir if ( m_xPopupMenu.is() ) 282*cdf0e10cSrcweir m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY )); 283*cdf0e10cSrcweir m_xPopupMenu.clear(); 284*cdf0e10cSrcweir delete m_pResPopupMenu; 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir // XStatusListener 288*cdf0e10cSrcweir void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir sal_uInt16 nMenuId = 0; 293*cdf0e10cSrcweir for (sal_uInt32 i=0; i < sizeof(aCommands)/sizeof(aCommands[0]); ++i) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir if ( Event.FeatureURL.Complete.equalsAscii( aCommands[i] )) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir nMenuId = nConvertSlots[i]; 298*cdf0e10cSrcweir break; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if ( nMenuId ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( m_xPopupMenu ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND ) 311*cdf0e10cSrcweir pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId )); 312*cdf0e10cSrcweir else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir sal_Int16 nSourcePos = m_pResPopupMenu->GetItemPos(nMenuId); 315*cdf0e10cSrcweir sal_Int16 nPrevInSource = nSourcePos; 316*cdf0e10cSrcweir sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND; 317*cdf0e10cSrcweir while (nPrevInSource>0) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir sal_Int16 nPrevId = m_pResPopupMenu->GetItemId(--nPrevInSource); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // do we have the source's predecessor in our conversion menu, too ? 322*cdf0e10cSrcweir nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId ); 323*cdf0e10cSrcweir if ( nPrevInConversion != MENU_ITEM_NOTFOUND ) 324*cdf0e10cSrcweir break; 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir if ( MENU_ITEM_NOTFOUND == nPrevInConversion ) 328*cdf0e10cSrcweir // none of the items which precede the nSID-slot in the source menu are present in our conversion menu 329*cdf0e10cSrcweir nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir pVCLPopupMenu->InsertItem( nMenuId, m_pResPopupMenu->GetItemText( nMenuId ), m_pResPopupMenu->GetItemBits( nMenuId ), ++nPrevInConversion ); 332*cdf0e10cSrcweir pVCLPopupMenu->SetItemImage( nMenuId, m_pResPopupMenu->GetItemImage( nMenuId )); 333*cdf0e10cSrcweir pVCLPopupMenu->SetHelpId( nMenuId, m_pResPopupMenu->GetHelpId( nMenuId )); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir // XMenuListener 339*cdf0e10cSrcweir void ControlMenuController::impl_select(const Reference< XDispatch >& /*_xDispatch*/,const ::com::sun::star::util::URL& aURL) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir UrlToDispatchMap::iterator pIter = m_aURLToDispatchMap.find( aURL.Complete ); 342*cdf0e10cSrcweir if ( pIter != m_aURLToDispatchMap.end() ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir Sequence<PropertyValue> aArgs; 345*cdf0e10cSrcweir Reference< XDispatch > xDispatch = pIter->second; 346*cdf0e10cSrcweir if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# 347*cdf0e10cSrcweir UiEventLogHelper(::rtl::OUString::createFromAscii("ControlMenuController")).log(m_xServiceManager, m_xFrame, aURL, aArgs); 348*cdf0e10cSrcweir if ( xDispatch.is() ) 349*cdf0e10cSrcweir xDispatch->dispatch( aURL, aArgs ); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir void SAL_CALL ControlMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir if ( m_xPopupMenu.is() ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir // Check if some modes have changed so we have to update our menu images 362*cdf0e10cSrcweir const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); 363*cdf0e10cSrcweir sal_Bool bIsHiContrast = rSettings.GetHighContrastMode(); 364*cdf0e10cSrcweir sal_Bool bShowMenuImages = rSettings.GetUseImagesInMenus(); 365*cdf0e10cSrcweir sal_Bool bUpdateImages = (( m_bWasHiContrast != bIsHiContrast ) || ( bShowMenuImages != m_bShowMenuImages )); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir if ( bUpdateImages ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir // The mode has changed or the complete menu so we have to retrieve all images again 370*cdf0e10cSrcweir m_bWasHiContrast = bIsHiContrast; 371*cdf0e10cSrcweir m_bShowMenuImages = bShowMenuImages; 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( m_xPopupMenu ); 374*cdf0e10cSrcweir if ( pPopupMenu ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); 377*cdf0e10cSrcweir if ( pVCLPopupMenu && bUpdateImages ) 378*cdf0e10cSrcweir updateImagesPopupMenu( pVCLPopupMenu ); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir // XPopupMenuController 385*cdf0e10cSrcweir void ControlMenuController::impl_setPopupMenu() 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir if ( m_pResPopupMenu == 0 ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir rtl::OStringBuffer aBuf( 32 ); 390*cdf0e10cSrcweir aBuf.append( "svx" ); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir ResMgr* pResMgr = ResMgr::CreateResMgr( aBuf.getStr() ); 393*cdf0e10cSrcweir if ( pResMgr ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr ); 396*cdf0e10cSrcweir aResId.SetRT( RSC_MENU ); 397*cdf0e10cSrcweir if ( pResMgr->IsAvailable( aResId )) 398*cdf0e10cSrcweir m_pResPopupMenu = new PopupMenu( aResId ); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir updateImagesPopupMenu( m_pResPopupMenu ); 401*cdf0e10cSrcweir delete pResMgr; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir } // if ( m_pResPopupMenu == 0 ) 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir throwIfDisposed(); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir if ( m_xFrame.is() && m_xPopupMenu.is() ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir URL aTargetURL; 415*cdf0e10cSrcweir Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); 416*cdf0e10cSrcweir fillPopupMenu( m_xPopupMenu ); 417*cdf0e10cSrcweir m_aURLToDispatchMap.free(); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir for (sal_uInt32 i=0; i<sizeof(aCommands)/sizeof(aCommands[0]); ++i) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir aTargetURL.Complete = rtl::OUString::createFromAscii( aCommands[i] ); 422*cdf0e10cSrcweir m_xURLTransformer->parseStrict( aTargetURL ); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 425*cdf0e10cSrcweir if ( xDispatch.is() ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir xDispatch->addStatusListener( SAL_STATIC_CAST( XStatusListener*, this ), aTargetURL ); 428*cdf0e10cSrcweir xDispatch->removeStatusListener( SAL_STATIC_CAST( XStatusListener*, this ), aTargetURL ); 429*cdf0e10cSrcweir m_aURLToDispatchMap.insert( UrlToDispatchMap::value_type( aTargetURL.Complete, xDispatch )); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir // XInitialization 436*cdf0e10cSrcweir void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 439*cdf0e10cSrcweir svt::PopupMenuControllerBase::initialize(aArguments); 440*cdf0e10cSrcweir m_aBaseURL = ::rtl::OUString(); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir } 444