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_cui.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define ITEMID_MACRO 0 32*cdf0e10cSrcweir #include <svl/macitem.hxx> 33*cdf0e10cSrcweir #undef ITEMID_MACRO 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "macroass.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <basic/basmgr.hxx> 38*cdf0e10cSrcweir #include <dialmgr.hxx> 39*cdf0e10cSrcweir #include <svx/dialogs.hrc> 40*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 41*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 44*cdf0e10cSrcweir #include "cfgutil.hxx" 45*cdf0e10cSrcweir #include <sfx2/app.hxx> 46*cdf0e10cSrcweir #include <sfx2/evntconf.hxx> 47*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 48*cdf0e10cSrcweir #include "macroass.hrc" 49*cdf0e10cSrcweir #include "cuires.hrc" 50*cdf0e10cSrcweir #include <vcl/fixed.hxx> 51*cdf0e10cSrcweir #include "headertablistbox.hxx" 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 54*cdf0e10cSrcweir using ::com::sun::star::frame::XFrame; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class _SfxMacroTabPage_Impl 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir _SfxMacroTabPage_Impl( void ); 60*cdf0e10cSrcweir ~_SfxMacroTabPage_Impl(); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir String maStaticMacroLBLabel; 63*cdf0e10cSrcweir PushButton* pAssignPB; 64*cdf0e10cSrcweir PushButton* pDeletePB; 65*cdf0e10cSrcweir String* pStrEvent; 66*cdf0e10cSrcweir String* pAssignedMacro; 67*cdf0e10cSrcweir _HeaderTabListBox* pEventLB; 68*cdf0e10cSrcweir SfxConfigGroupListBox_Impl* pGroupLB; 69*cdf0e10cSrcweir FixedText* pFT_MacroLBLabel; 70*cdf0e10cSrcweir SfxConfigFunctionListBox_Impl* pMacroLB; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir FixedText* pMacroFT; 73*cdf0e10cSrcweir String* pMacroStr; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir sal_Bool bReadOnly; 76*cdf0e10cSrcweir Timer maFillGroupTimer; 77*cdf0e10cSrcweir sal_Bool bGotEvents; 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir _SfxMacroTabPage_Impl::_SfxMacroTabPage_Impl( void ) : 81*cdf0e10cSrcweir pAssignPB( NULL ), 82*cdf0e10cSrcweir pDeletePB( NULL ), 83*cdf0e10cSrcweir pStrEvent( NULL ), 84*cdf0e10cSrcweir pAssignedMacro( NULL ), 85*cdf0e10cSrcweir pEventLB( NULL ), 86*cdf0e10cSrcweir pGroupLB( NULL ), 87*cdf0e10cSrcweir pFT_MacroLBLabel( NULL ), 88*cdf0e10cSrcweir pMacroLB( NULL ), 89*cdf0e10cSrcweir pMacroFT( NULL ), 90*cdf0e10cSrcweir pMacroStr( NULL ), 91*cdf0e10cSrcweir bReadOnly( sal_False ), 92*cdf0e10cSrcweir bGotEvents( sal_False ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir _SfxMacroTabPage_Impl::~_SfxMacroTabPage_Impl() 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir delete pAssignPB; 99*cdf0e10cSrcweir delete pDeletePB; 100*cdf0e10cSrcweir delete pStrEvent; 101*cdf0e10cSrcweir delete pAssignedMacro; 102*cdf0e10cSrcweir delete pEventLB; 103*cdf0e10cSrcweir delete pGroupLB; 104*cdf0e10cSrcweir delete pMacroLB; 105*cdf0e10cSrcweir delete pFT_MacroLBLabel; 106*cdf0e10cSrcweir delete pMacroFT; 107*cdf0e10cSrcweir delete pMacroStr; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir static sal_uInt16 __FAR_DATA aPageRg[] = { 112*cdf0e10cSrcweir SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, 113*cdf0e10cSrcweir 0 114*cdf0e10cSrcweir }; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert 117*cdf0e10cSrcweir static long nTabs[] = 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir 2, // Number of Tabs 120*cdf0e10cSrcweir 0, 90 121*cdf0e10cSrcweir }; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir #define TAB_WIDTH_MIN 10 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // IDs for items in HeaderBar of EventLB 126*cdf0e10cSrcweir #define ITEMID_EVENT 1 127*cdf0e10cSrcweir #define ITMEID_ASSMACRO 2 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir #define LB_EVENTS_ITEMPOS 1 131*cdf0e10cSrcweir #define LB_MACROS_ITEMPOS 2 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir String ConvertToUIName_Impl( SvxMacro *pMacro ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir String aName( pMacro->GetMacName() ); 136*cdf0e10cSrcweir String aEntry; 137*cdf0e10cSrcweir if ( ! pMacro->GetLanguage().EqualsAscii("JavaScript") ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir sal_uInt16 nCount = aName.GetTokenCount('.'); 140*cdf0e10cSrcweir aEntry = aName.GetToken( nCount-1, '.' ); 141*cdf0e10cSrcweir if ( nCount > 2 ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir aEntry += '('; 144*cdf0e10cSrcweir aEntry += aName.GetToken( 0, '.' ); 145*cdf0e10cSrcweir aEntry += '.'; 146*cdf0e10cSrcweir aEntry += aName.GetToken( nCount-2, '.' ); 147*cdf0e10cSrcweir aEntry += ')'; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir return aEntry; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir else 152*cdf0e10cSrcweir return aName; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir void _SfxMacroTabPage::EnableButtons() 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir // Solange die Eventbox leer ist, nichts tun 158*cdf0e10cSrcweir const SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected(); 159*cdf0e10cSrcweir if ( pE ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir // Gebundenes Macro holen 162*cdf0e10cSrcweir const SvxMacro* pM = aTbl.Get( (sal_uInt16)(sal_uLong) pE->GetUserData() ); 163*cdf0e10cSrcweir mpImpl->pDeletePB->Enable( 0 != pM && !mpImpl->bReadOnly ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir String sEventMacro; 166*cdf0e10cSrcweir sEventMacro = ((SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS ))->GetText(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir String sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI(); 169*cdf0e10cSrcweir mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly && !sScriptURI.EqualsIgnoreCaseAscii( sEventMacro ) ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir else 172*cdf0e10cSrcweir mpImpl->pAssignPB->Enable( sal_False ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir _SfxMacroTabPage::_SfxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet ) 176*cdf0e10cSrcweir : SfxTabPage( pParent, rResId, rAttrSet ) 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir mpImpl = new _SfxMacroTabPage_Impl; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir _SfxMacroTabPage::~_SfxMacroTabPage() 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir DELETEZ( mpImpl ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir void _SfxMacroTabPage::AddEvent( const String & rEventName, sal_uInt16 nEventId ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir String sTmp( rEventName ); 190*cdf0e10cSrcweir sTmp += '\t'; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir // falls die Tabelle schon gueltig ist 193*cdf0e10cSrcweir SvxMacro* pM = aTbl.Get( nEventId ); 194*cdf0e10cSrcweir if( pM ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir String sNew( ConvertToUIName_Impl( pM ) ); 197*cdf0e10cSrcweir sTmp += sNew; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().InsertEntry( sTmp ); 201*cdf0e10cSrcweir pE->SetUserData( reinterpret_cast< void* >( sal::static_int_cast< sal_IntPtr >( nEventId )) ); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void _SfxMacroTabPage::ScriptChanged() 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir // neue Bereiche und deren Funktionen besorgen 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir mpImpl->pGroupLB->Show(); 209*cdf0e10cSrcweir mpImpl->pMacroLB->Show(); 210*cdf0e10cSrcweir mpImpl->pMacroFT->SetText( *mpImpl->pMacroStr ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir EnableButtons(); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir sal_Bool _SfxMacroTabPage::FillItemSet( SfxItemSet& rSet ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir SvxMacroItem aItem( GetWhich( aPageRg[0] ) ); 219*cdf0e10cSrcweir ((SvxMacroTableDtor&)aItem.GetMacroTable()) = aTbl; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir const SfxPoolItem* pItem; 222*cdf0e10cSrcweir if( SFX_ITEM_SET != GetItemSet().GetItemState( aItem.Which(), sal_True, &pItem ) 223*cdf0e10cSrcweir || aItem != *(SvxMacroItem*)pItem ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir rSet.Put( aItem ); 226*cdf0e10cSrcweir return sal_True; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir return sal_False; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void _SfxMacroTabPage::PageCreated (SfxAllItemSet aSet) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir const SfxPoolItem* pEventsItem; 234*cdf0e10cSrcweir if( !mpImpl->bGotEvents && SFX_ITEM_SET == aSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir mpImpl->bGotEvents = sal_True; 237*cdf0e10cSrcweir const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents(); 238*cdf0e10cSrcweir for ( sal_uInt16 nNo = 0; nNo < rList.Count(); ++nNo ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir const SfxEventName *pOwn = rList.GetObject(nNo); 241*cdf0e10cSrcweir AddEvent( pOwn->maUIName, pOwn->mnId ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void _SfxMacroTabPage::Reset( const SfxItemSet& rSet ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir const SfxPoolItem* pItem; 249*cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( aPageRg[0] ), sal_True, &pItem )) 250*cdf0e10cSrcweir aTbl = ((SvxMacroItem*)pItem)->GetMacroTable(); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir const SfxPoolItem* pEventsItem; 253*cdf0e10cSrcweir if( !mpImpl->bGotEvents && SFX_ITEM_SET == rSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir mpImpl->bGotEvents = sal_True; 256*cdf0e10cSrcweir const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents(); 257*cdf0e10cSrcweir for ( sal_uInt16 nNo = 0; nNo < rList.Count(); ++nNo ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir const SfxEventName *pOwn = rList.GetObject(nNo); 260*cdf0e10cSrcweir AddEvent( pOwn->maUIName, pOwn->mnId ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir FillEvents(); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 267*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.GetEntry( 0 ); 268*cdf0e10cSrcweir if( pE ) 269*cdf0e10cSrcweir rListBox.SetCurEntry( pE ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir sal_Bool _SfxMacroTabPage::IsReadOnly() const 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir return mpImpl->bReadOnly; 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir IMPL_STATIC_LINK( _SfxMacroTabPage, SelectEvent_Impl, SvTabListBox*, EMPTYARG ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl; 280*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox(); 281*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.FirstSelected(); 282*cdf0e10cSrcweir sal_uLong nPos; 283*cdf0e10cSrcweir if( !pE || LISTBOX_ENTRY_NOTFOUND == 284*cdf0e10cSrcweir ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" ); 287*cdf0e10cSrcweir return 0; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir pThis->ScriptChanged(); 291*cdf0e10cSrcweir pThis->EnableButtons(); 292*cdf0e10cSrcweir return 0; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir IMPL_STATIC_LINK( _SfxMacroTabPage, SelectGroup_Impl, ListBox*, EMPTYARG ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl; 298*cdf0e10cSrcweir String sSel( pImpl->pGroupLB->GetGroup() ); 299*cdf0e10cSrcweir pImpl->pGroupLB->GroupSelected(); 300*cdf0e10cSrcweir const String sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI(); 301*cdf0e10cSrcweir String aLabelText; 302*cdf0e10cSrcweir if( sScriptURI.Len() > 0 ) 303*cdf0e10cSrcweir aLabelText = pImpl->maStaticMacroLBLabel; 304*cdf0e10cSrcweir pImpl->pFT_MacroLBLabel->SetText( aLabelText ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir pThis->EnableButtons(); 307*cdf0e10cSrcweir return 0; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir IMPL_STATIC_LINK( _SfxMacroTabPage, SelectMacro_Impl, ListBox*, EMPTYARG ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl; 313*cdf0e10cSrcweir pImpl->pMacroLB->FunctionSelected(); 314*cdf0e10cSrcweir pThis->EnableButtons(); 315*cdf0e10cSrcweir return 0; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir IMPL_STATIC_LINK( _SfxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn ) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl; 321*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox(); 322*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.FirstSelected(); 323*cdf0e10cSrcweir sal_uLong nPos; 324*cdf0e10cSrcweir if( !pE || LISTBOX_ENTRY_NOTFOUND == 325*cdf0e10cSrcweir ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" ); 328*cdf0e10cSrcweir return 0; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir const sal_Bool bAssEnabled = pBtn != pImpl->pDeletePB && pImpl->pAssignPB->IsEnabled(); 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir // aus der Tabelle entfernen 334*cdf0e10cSrcweir sal_uInt16 nEvent = (sal_uInt16)(sal_uLong)pE->GetUserData(); 335*cdf0e10cSrcweir SvxMacro *pRemoveMacro = pThis->aTbl.Remove( nEvent ); 336*cdf0e10cSrcweir delete pRemoveMacro; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir String sScriptURI; 339*cdf0e10cSrcweir if( bAssEnabled ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI(); 342*cdf0e10cSrcweir if( sScriptURI.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir pThis->aTbl.Insert( 345*cdf0e10cSrcweir nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_SF ) ) ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir else 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir OSL_ENSURE( false, "_SfxMacroTabPage::AssignDeleteHdl_Impl: this branch is *not* dead? (out of interest: tell fs, please!)" ); 350*cdf0e10cSrcweir pThis->aTbl.Insert( 351*cdf0e10cSrcweir nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_STARBASIC ) ) ); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir pImpl->pEventLB->SetUpdateMode( sal_False ); 356*cdf0e10cSrcweir pE->ReplaceItem( new SvLBoxString( pE, 0, sScriptURI ), LB_MACROS_ITEMPOS ); 357*cdf0e10cSrcweir rListBox.GetModel()->InvalidateEntry( pE ); 358*cdf0e10cSrcweir rListBox.Select( pE ); 359*cdf0e10cSrcweir rListBox.MakeVisible( pE ); 360*cdf0e10cSrcweir rListBox.SetUpdateMode( sal_True ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir pThis->EnableButtons(); 363*cdf0e10cSrcweir return 0; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir IMPL_STATIC_LINK( _SfxMacroTabPage, TimeOut_Impl, Timer*, EMPTYARG ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir // FillMacroList() can take a long time -> show wait cursor and disable input 369*cdf0e10cSrcweir SfxTabDialog* pTabDlg = pThis->GetTabDialog(); 370*cdf0e10cSrcweir // perhaps the tabpage is part of a SingleTabDialog then pTabDlg == NULL 371*cdf0e10cSrcweir if ( pTabDlg ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir pTabDlg->EnterWait(); 374*cdf0e10cSrcweir pTabDlg->EnableInput( sal_False ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir pThis->FillMacroList(); 377*cdf0e10cSrcweir if ( pTabDlg ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir pTabDlg->EnableInput( sal_True ); 380*cdf0e10cSrcweir pTabDlg->LeaveWait(); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir return 0; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir void _SfxMacroTabPage::InitAndSetHandler() 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir // Handler installieren 388*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 389*cdf0e10cSrcweir HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar(); 390*cdf0e10cSrcweir Link aLnk(STATIC_LINK(this, _SfxMacroTabPage, AssignDeleteHdl_Impl )); 391*cdf0e10cSrcweir mpImpl->pMacroLB->SetDoubleClickHdl( aLnk ); 392*cdf0e10cSrcweir mpImpl->pDeletePB->SetClickHdl( aLnk ); 393*cdf0e10cSrcweir mpImpl->pAssignPB->SetClickHdl( aLnk ); 394*cdf0e10cSrcweir rListBox.SetDoubleClickHdl( aLnk ); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir rListBox.SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectEvent_Impl )); 397*cdf0e10cSrcweir mpImpl->pGroupLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectGroup_Impl )); 398*cdf0e10cSrcweir mpImpl->pMacroLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectMacro_Impl )); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir rListBox.SetSelectionMode( SINGLE_SELECTION ); 401*cdf0e10cSrcweir rListBox.SetTabs( &nTabs[0], MAP_APPFONT ); 402*cdf0e10cSrcweir Size aSize( nTabs[ 2 ], 0 ); 403*cdf0e10cSrcweir rHeaderBar.InsertItem( ITEMID_EVENT, *mpImpl->pStrEvent, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() ); 404*cdf0e10cSrcweir aSize.Width() = 1764; // don't know what, so 42^2 is best to use... 405*cdf0e10cSrcweir rHeaderBar.InsertItem( ITMEID_ASSMACRO, *mpImpl->pAssignedMacro, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() ); 406*cdf0e10cSrcweir rListBox.SetSpaceBetweenEntries( 0 ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir mpImpl->pEventLB->Show(); 409*cdf0e10cSrcweir mpImpl->pEventLB->ConnectElements(); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir mpImpl->pEventLB->Enable( sal_True ); 412*cdf0e10cSrcweir mpImpl->pGroupLB->Enable( sal_True ); 413*cdf0e10cSrcweir mpImpl->pMacroLB->Enable( sal_True ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir mpImpl->pGroupLB->SetFunctionListBox( mpImpl->pMacroLB ); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir mpImpl->maFillGroupTimer.SetTimeoutHdl( STATIC_LINK( this, _SfxMacroTabPage, TimeOut_Impl ) ); 418*cdf0e10cSrcweir mpImpl->maFillGroupTimer.SetTimeout( 0 ); 419*cdf0e10cSrcweir mpImpl->maFillGroupTimer.Start(); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void _SfxMacroTabPage::FillMacroList() 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir mpImpl->pGroupLB->Init( 425*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 426*cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory >(), 427*cdf0e10cSrcweir GetFrame(), 428*cdf0e10cSrcweir ::rtl::OUString() ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir void _SfxMacroTabPage::FillEvents() 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir sal_uLong nEntryCnt = rListBox.GetEntryCount(); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir // Events aus der Tabelle holen und die EventListBox entsprechen fuellen 438*cdf0e10cSrcweir for( sal_uLong n = 0 ; n < nEntryCnt ; ++n ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.GetEntry( n ); 441*cdf0e10cSrcweir if( pE ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir SvLBoxString* pLItem = ( SvLBoxString* ) pE->GetItem( LB_MACROS_ITEMPOS ); 444*cdf0e10cSrcweir DBG_ASSERT( pLItem && SV_ITEM_ID_LBOXSTRING == pLItem->IsA(), "_SfxMacroTabPage::FillEvents(): no LBoxString" ); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir String sOld( pLItem->GetText() ); 447*cdf0e10cSrcweir String sNew; 448*cdf0e10cSrcweir sal_uInt16 nEventId = ( sal_uInt16 ) ( sal_uLong ) pE->GetUserData(); 449*cdf0e10cSrcweir if( aTbl.IsKeyValid( nEventId ) ) 450*cdf0e10cSrcweir sNew = ConvertToUIName_Impl( aTbl.Get( nEventId ) ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir if( sOld != sNew ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir pE->ReplaceItem( new SvLBoxString( pE, 0, sNew ), LB_MACROS_ITEMPOS ); 455*cdf0e10cSrcweir rListBox.GetModel()->InvalidateEntry( pE ); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir SfxMacroTabPage::SfxMacroTabPage( Window* pParent, const ResId& rResId, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet ) 462*cdf0e10cSrcweir : _SfxMacroTabPage( pParent, rResId, rSet ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ) ); 465*cdf0e10cSrcweir mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ) ); 466*cdf0e10cSrcweir mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ) ); 467*cdf0e10cSrcweir mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ) ); 468*cdf0e10cSrcweir mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ) ); 469*cdf0e10cSrcweir mpImpl->pMacroFT = new FixedText( this, CUI_RES( FT_MACRO ) ); 470*cdf0e10cSrcweir mpImpl->pGroupLB = new SfxConfigGroupListBox_Impl( this, CUI_RES( LB_GROUP ) ); 471*cdf0e10cSrcweir mpImpl->pFT_MacroLBLabel = new FixedText( this, CUI_RES( FT_LABEL4LB_MACROS ) ); 472*cdf0e10cSrcweir mpImpl->maStaticMacroLBLabel= mpImpl->pFT_MacroLBLabel->GetText(); 473*cdf0e10cSrcweir mpImpl->pMacroLB = new SfxConfigFunctionListBox_Impl( this, CUI_RES( LB_MACROS ) ); 474*cdf0e10cSrcweir mpImpl->pMacroStr = new String( CUI_RES( STR_MACROS ) ); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir FreeResource(); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir SetFrame( rxDocumentFrame ); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir InitAndSetHandler(); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir ScriptChanged(); 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir SfxTabPage* SfxMacroTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir return new SfxMacroTabPage( pParent, CUI_RES( RID_SVXPAGE_EVENTASSIGN ), NULL, rAttrSet ); 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir SfxMacroAssignDlg::SfxMacroAssignDlg( Window* pParent, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet ) 491*cdf0e10cSrcweir : SfxSingleTabDialog( pParent, rSet, 0 ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir SfxTabPage* pPage = SfxMacroTabPage::Create( this, rSet ); 494*cdf0e10cSrcweir pPage->SetFrame( rxDocumentFrame ); 495*cdf0e10cSrcweir SetTabPage( pPage ); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir SfxMacroAssignDlg::~SfxMacroAssignDlg() 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir 503