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 #include <basic/basmgr.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "macropg.hxx" 33*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 35*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 36*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 37*cdf0e10cSrcweir #include <svl/eitem.hxx> 38*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 39*cdf0e10cSrcweir #include <sfx2/app.hxx> 40*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 41*cdf0e10cSrcweir #include <sfx2/sfxdefs.hxx> 42*cdf0e10cSrcweir #include <com/sun/star/container/NoSuchElementException.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 44*cdf0e10cSrcweir #include <dialmgr.hxx> 45*cdf0e10cSrcweir #include "selector.hxx" 46*cdf0e10cSrcweir #include "cfg.hxx" 47*cdf0e10cSrcweir #include "macropg.hrc" 48*cdf0e10cSrcweir #include "helpid.hrc" 49*cdf0e10cSrcweir #include <cuires.hrc> 50*cdf0e10cSrcweir #include "headertablistbox.hxx" 51*cdf0e10cSrcweir #include "macropg_impl.hxx" 52*cdf0e10cSrcweir #include <svx/dialogs.hrc> // RID_SVXPAGE_MACROASSIGN 53*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <algorithm> 56*cdf0e10cSrcweir #include <set> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir using namespace ::com::sun::star; 59*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir static ::rtl::OUString aVndSunStarUNO = 62*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" ); 63*cdf0e10cSrcweir static ::rtl::OUString aVndSunStarScript = 64*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir _SvxMacroTabPage_Impl::_SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet ) : 67*cdf0e10cSrcweir pAssignFT( NULL ), 68*cdf0e10cSrcweir pAssignPB( NULL ), 69*cdf0e10cSrcweir pAssignComponentPB( NULL ), 70*cdf0e10cSrcweir pDeletePB( NULL ), 71*cdf0e10cSrcweir pMacroImg( NULL ), 72*cdf0e10cSrcweir pComponentImg( NULL ), 73*cdf0e10cSrcweir pMacroImg_h( NULL ), 74*cdf0e10cSrcweir pComponentImg_h( NULL ), 75*cdf0e10cSrcweir pStrEvent( NULL ), 76*cdf0e10cSrcweir pAssignedMacro( NULL ), 77*cdf0e10cSrcweir pEventLB( NULL ), 78*cdf0e10cSrcweir bReadOnly( sal_False ), 79*cdf0e10cSrcweir bIDEDialogMode( sal_False ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir const SfxPoolItem* pItem; 82*cdf0e10cSrcweir if ( SFX_ITEM_SET == rAttrSet.GetItemState( SID_ATTR_MACROITEM, sal_False, &pItem ) ) 83*cdf0e10cSrcweir bIDEDialogMode = ((const SfxBoolItem*)pItem)->GetValue(); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir _SvxMacroTabPage_Impl::~_SvxMacroTabPage_Impl() 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir delete pAssignFT; 89*cdf0e10cSrcweir delete pAssignPB; 90*cdf0e10cSrcweir delete pAssignComponentPB; 91*cdf0e10cSrcweir delete pDeletePB; 92*cdf0e10cSrcweir delete pMacroImg; 93*cdf0e10cSrcweir delete pComponentImg; 94*cdf0e10cSrcweir delete pMacroImg_h; 95*cdf0e10cSrcweir delete pComponentImg_h; 96*cdf0e10cSrcweir delete pStrEvent; 97*cdf0e10cSrcweir delete pAssignedMacro; 98*cdf0e10cSrcweir delete pEventLB; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert 102*cdf0e10cSrcweir static long nTabs[] = 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir 2, // Number of Tabs 105*cdf0e10cSrcweir 0, 90 106*cdf0e10cSrcweir }; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir #define TAB_WIDTH_MIN 10 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // IDs for items in HeaderBar of EventLB 111*cdf0e10cSrcweir #define ITEMID_EVENT 1 112*cdf0e10cSrcweir #define ITMEID_ASSMACRO 2 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir #define LB_EVENTS_ITEMPOS 1 116*cdf0e10cSrcweir #define LB_MACROS_ITEMPOS 2 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir IMPL_LINK( _HeaderTabListBox, HeaderEndDrag_Impl, HeaderBar*, pBar ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir DBG_ASSERT( pBar == &maHeaderBar, "*_HeaderTabListBox::HeaderEndDrag_Impl: something is wrong here..." ); 122*cdf0e10cSrcweir (void)pBar; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if( !maHeaderBar.GetCurItemId() ) 125*cdf0e10cSrcweir return 0; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir if( !maHeaderBar.IsItemMode() ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir Size aSz; 130*cdf0e10cSrcweir sal_uInt16 _nTabs = maHeaderBar.GetItemCount(); 131*cdf0e10cSrcweir long nTmpSz = 0; 132*cdf0e10cSrcweir long nWidth = maHeaderBar.GetItemSize( ITEMID_EVENT ); 133*cdf0e10cSrcweir long nBarWidth = maHeaderBar.GetSizePixel().Width(); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir if( nWidth < TAB_WIDTH_MIN ) 136*cdf0e10cSrcweir maHeaderBar.SetItemSize( ITEMID_EVENT, TAB_WIDTH_MIN ); 137*cdf0e10cSrcweir else if( ( nBarWidth - nWidth ) < TAB_WIDTH_MIN ) 138*cdf0e10cSrcweir maHeaderBar.SetItemSize( ITEMID_EVENT, nBarWidth - TAB_WIDTH_MIN ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir long _nWidth; 142*cdf0e10cSrcweir for( sal_uInt16 i = 1 ; i < _nTabs ; ++i ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir _nWidth = maHeaderBar.GetItemSize( i ); 145*cdf0e10cSrcweir aSz.Width() = _nWidth + nTmpSz; 146*cdf0e10cSrcweir nTmpSz += _nWidth; 147*cdf0e10cSrcweir maListBox.SetTab( i, PixelToLogic( aSz, MapMode( MAP_APPFONT ) ).Width(), MAP_APPFONT ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir return 1; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir long _HeaderTabListBox::Notify( NotifyEvent& rNEvt ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir long nRet = Control::Notify( rNEvt ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_GETFOCUS ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir if ( rNEvt.GetWindow() != &maListBox ) 161*cdf0e10cSrcweir maListBox.GrabFocus(); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir return nRet; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir _HeaderTabListBox::_HeaderTabListBox( Window* pParent, const ResId& rId ) : 168*cdf0e10cSrcweir Control( pParent, rId ), 169*cdf0e10cSrcweir maListBox( this, WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ), 170*cdf0e10cSrcweir maHeaderBar( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir maListBox.SetHelpId( HID_MACRO_HEADERTABLISTBOX ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir _HeaderTabListBox::~_HeaderTabListBox() 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void _HeaderTabListBox::ConnectElements( void ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir // calc pos and size of header bar 182*cdf0e10cSrcweir Point aPnt( 0, 0 ); 183*cdf0e10cSrcweir Size aSize( maHeaderBar.CalcWindowSizePixel() ); 184*cdf0e10cSrcweir Size aCtrlSize( GetOutputSizePixel() ); 185*cdf0e10cSrcweir aSize.Width() = aCtrlSize.Width(); 186*cdf0e10cSrcweir maHeaderBar.SetPosSizePixel( aPnt, aSize ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // calc pos and size of ListBox 189*cdf0e10cSrcweir aPnt.Y() += aSize.Height(); 190*cdf0e10cSrcweir aSize.Height() = aCtrlSize.Height() - aSize.Height(); 191*cdf0e10cSrcweir maListBox.SetPosSizePixel( aPnt, aSize ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // set handler 194*cdf0e10cSrcweir maHeaderBar.SetEndDragHdl( LINK( this, _HeaderTabListBox, HeaderEndDrag_Impl ) ); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir maListBox.InitHeaderBar( &maHeaderBar ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir void _HeaderTabListBox::Show( sal_Bool bVisible, sal_uInt16 nFlags ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir maListBox.Show( bVisible, nFlags ); 202*cdf0e10cSrcweir maHeaderBar.Show( bVisible, nFlags ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir void _HeaderTabListBox::Enable( bool bEnable, bool bChild ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir maListBox.Enable( bEnable, bChild ); 208*cdf0e10cSrcweir maHeaderBar.Enable( bEnable, bChild ); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir // assign button ("Add Command") is enabled only if it is not read only 212*cdf0e10cSrcweir // delete button ("Remove Command") is enabled if a current binding exists 213*cdf0e10cSrcweir // and it is not read only 214*cdf0e10cSrcweir void _SvxMacroTabPage::EnableButtons() 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir const SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected(); 217*cdf0e10cSrcweir if ( pE ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir SvLBoxString* pEventMacro = (SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS ); 220*cdf0e10cSrcweir mpImpl->pDeletePB->Enable( 0 != pEventMacro && !mpImpl->bReadOnly ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly ); 223*cdf0e10cSrcweir if( mpImpl->pAssignComponentPB ) 224*cdf0e10cSrcweir mpImpl->pAssignComponentPB->Enable( !mpImpl->bReadOnly ); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir _SvxMacroTabPage::_SvxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet ) 229*cdf0e10cSrcweir : SfxTabPage( pParent, rResId, rAttrSet ), 230*cdf0e10cSrcweir m_xAppEvents(0), 231*cdf0e10cSrcweir m_xDocEvents(0), 232*cdf0e10cSrcweir bReadOnly(false), 233*cdf0e10cSrcweir bDocModified(false), 234*cdf0e10cSrcweir bAppEvents(false), 235*cdf0e10cSrcweir bInitialized(false) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir mpImpl = new _SvxMacroTabPage_Impl( rAttrSet ); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir _SvxMacroTabPage::~_SvxMacroTabPage() 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir // need to delete the user data 243*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 244*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.GetEntry( 0 ); 245*cdf0e10cSrcweir while( pE ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir ::rtl::OUString* pEventName = (::rtl::OUString*)pE->GetUserData(); 248*cdf0e10cSrcweir delete pEventName; 249*cdf0e10cSrcweir pE->SetUserData((void*)0); 250*cdf0e10cSrcweir pE = rListBox.NextSibling( pE ); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir DELETEZ( mpImpl ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 255*cdf0e10cSrcweir void _SvxMacroTabPage::InitResources() 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir // Note: the order here controls the order in which the events are displayed in the UI! 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // the event name to UI string mappings for App Events 260*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP ) ); 261*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP ) ); 262*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCreate", RID_SVXSTR_EVENT_CREATEDOC ) ); 263*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnNew", RID_SVXSTR_EVENT_NEWDOC ) ); 264*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnLoadFinished", RID_SVXSTR_EVENT_LOADDOCFINISHED ) ); 265*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnLoad", RID_SVXSTR_EVENT_OPENDOC ) ); 266*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC ) ); 267*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ) ; 268*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnViewCreated", RID_SVXSTR_EVENT_VIEWCREATED ) ); 269*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnPrepareViewClosing", RID_SVXSTR_EVENT_PREPARECLOSEVIEW ) ); 270*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnViewClosed", RID_SVXSTR_EVENT_CLOSEVIEW ) ) ; 271*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC ) ); 272*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC ) ); 273*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ) ); 274*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ) ); 275*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSaveFailed", RID_SVXSTR_EVENT_SAVEDOCFAILED ) ); 276*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ) ); 277*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ) ); 278*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSaveAsFailed", RID_SVXSTR_EVENT_SAVEASDOCFAILED ) ); 279*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCopyTo", RID_SVXSTR_EVENT_COPYTODOC ) ); 280*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCopyToDone", RID_SVXSTR_EVENT_COPYTODOCDONE ) ); 281*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCopyToFailed", RID_SVXSTR_EVENT_COPYTODOCFAILED ) ); 282*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC ) ); 283*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED ) ); 284*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnTitleChanged", RID_SVXSTR_EVENT_TITLECHANGED ) ); 285*cdf0e10cSrcweir // aDisplayNames.push_back( EventDisplayName( "OnModeChanged", RID_SVXSTR_EVENT_MODECHANGED ) ); 286*cdf0e10cSrcweir // aDisplayNames.push_back( EventDisplayName( "OnVisAreaChanged", RID_SVXSTR_EVENT_VISAREACHANGED ) ); 287*cdf0e10cSrcweir // aDisplayNames.push_back( EventDisplayName( "OnStorageChanged", RID_SVXSTR_EVENT_STORAGECHANGED ) ); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir // application specific events 290*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE ) ); 291*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnMailMergeFinished", RID_SVXSTR_EVENT_MAILMERGE_END ) ); 292*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnFieldMerge", RID_SVXSTR_EVENT_FIELDMERGE ) ); 293*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnFieldMergeFinished", RID_SVXSTR_EVENT_FIELDMERGE_FINISHED ) ); 294*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE ) ); 295*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSubComponentOpened", RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED ) ); 296*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSubComponentClosed", RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED ) ); 297*cdf0e10cSrcweir // aDisplayNames.push_back( EventDisplayName( "OnLayoutFinished", RID_SVXSTR_EVENT_LAYOUT_FINISHED ) ); 298*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnSelect", RID_SVXSTR_EVENT_SELECTIONCHANGED ) ); 299*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnDoubleClick", RID_SVXSTR_EVENT_DOUBLECLICK ) ); 300*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnRightClick", RID_SVXSTR_EVENT_RIGHTCLICK ) ); 301*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnCalculate", RID_SVXSTR_EVENT_CALCULATE ) ); 302*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "OnChange", RID_SVXSTR_EVENT_CONTENTCHANGED ) ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir // the event name to UI string mappings for forms & dialogs 305*cdf0e10cSrcweir // 306*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveAction", RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED ) ); 307*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "actionPerformed", RID_SVXSTR_EVENT_ACTIONPERFORMED ) ); 308*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "changed", RID_SVXSTR_EVENT_CHANGED ) ); 309*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "textChanged", RID_SVXSTR_EVENT_TEXTCHANGED ) ); 310*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "itemStateChanged", RID_SVXSTR_EVENT_ITEMSTATECHANGED ) ); 311*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "focusGained", RID_SVXSTR_EVENT_FOCUSGAINED ) ); 312*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "focusLost", RID_SVXSTR_EVENT_FOCUSLOST ) ); 313*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "keyPressed", RID_SVXSTR_EVENT_KEYTYPED ) ); 314*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "keyReleased", RID_SVXSTR_EVENT_KEYUP ) ); 315*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mouseEntered", RID_SVXSTR_EVENT_MOUSEENTERED ) ); 316*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mouseDragged", RID_SVXSTR_EVENT_MOUSEDRAGGED ) ); 317*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mouseMoved", RID_SVXSTR_EVENT_MOUSEMOVED ) ); 318*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mousePressed", RID_SVXSTR_EVENT_MOUSEPRESSED ) ); 319*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mouseReleased", RID_SVXSTR_EVENT_MOUSERELEASED ) ); 320*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "mouseExited", RID_SVXSTR_EVENT_MOUSEEXITED ) ); 321*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveReset", RID_SVXSTR_EVENT_APPROVERESETTED ) ); 322*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "resetted", RID_SVXSTR_EVENT_RESETTED ) ); 323*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveSubmit", RID_SVXSTR_EVENT_SUBMITTED ) ); 324*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveUpdate", RID_SVXSTR_EVENT_BEFOREUPDATE ) ); 325*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "updated", RID_SVXSTR_EVENT_AFTERUPDATE ) ); 326*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "loaded", RID_SVXSTR_EVENT_LOADED ) ); 327*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "reloading", RID_SVXSTR_EVENT_RELOADING ) ); 328*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "reloaded", RID_SVXSTR_EVENT_RELOADED ) ); 329*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "unloading", RID_SVXSTR_EVENT_UNLOADING ) ); 330*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "unloaded", RID_SVXSTR_EVENT_UNLOADED ) ); 331*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "confirmDelete", RID_SVXSTR_EVENT_CONFIRMDELETE ) ); 332*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveRowChange", RID_SVXSTR_EVENT_APPROVEROWCHANGE ) ); 333*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "rowChanged", RID_SVXSTR_EVENT_ROWCHANGE ) ); 334*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveCursorMove", RID_SVXSTR_EVENT_POSITIONING ) ); 335*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "cursorMoved", RID_SVXSTR_EVENT_POSITIONED ) ); 336*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "approveParameter", RID_SVXSTR_EVENT_APPROVEPARAMETER ) ); 337*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "errorOccured", RID_SVXSTR_EVENT_ERROROCCURED ) ); 338*cdf0e10cSrcweir aDisplayNames.push_back( EventDisplayName( "adjustmentValueChanged", RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED ) ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir // the following method is called when the user clicks OK 342*cdf0e10cSrcweir // We use the contents of the hashes to replace the settings 343*cdf0e10cSrcweir sal_Bool _SvxMacroTabPage::FillItemSet( SfxItemSet& /*rSet*/ ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir try 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir ::rtl::OUString eventName; 348*cdf0e10cSrcweir if( m_xAppEvents.is() ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir EventsHash::iterator h_itEnd = m_appEventsHash.end(); 351*cdf0e10cSrcweir EventsHash::iterator h_it = m_appEventsHash.begin(); 352*cdf0e10cSrcweir for ( ; h_it != h_itEnd; ++h_it ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir eventName = h_it->first; 355*cdf0e10cSrcweir try 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir m_xAppEvents->replaceByName( eventName, GetPropsByName( eventName, m_appEventsHash ) ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir catch( const Exception& ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir if( m_xDocEvents.is() && bDocModified ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir EventsHash::iterator h_itEnd = m_docEventsHash.end(); 368*cdf0e10cSrcweir EventsHash::iterator h_it = m_docEventsHash.begin(); 369*cdf0e10cSrcweir for ( ; h_it != h_itEnd; ++h_it ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir eventName = h_it->first; 372*cdf0e10cSrcweir try 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir m_xDocEvents->replaceByName( eventName, GetPropsByName( eventName, m_docEventsHash ) ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir catch( const Exception& ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir // if we have a valid XModifiable (in the case of doc events) 382*cdf0e10cSrcweir // call setModified(true) 383*cdf0e10cSrcweir // in principle this should not be necessary (see issue ??) 384*cdf0e10cSrcweir if(m_xModifiable.is()) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir m_xModifiable->setModified( sal_True ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir catch(Exception&) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir // what is the return value about?? 394*cdf0e10cSrcweir return sal_False; 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // the following method clears the bindings in the hashes for both doc & app 398*cdf0e10cSrcweir void _SvxMacroTabPage::Reset() 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir // called once in creation - don't reset the data this time 401*cdf0e10cSrcweir if(!bInitialized) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir bInitialized = true; 404*cdf0e10cSrcweir return; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir try 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir ::rtl::OUString sEmpty; 410*cdf0e10cSrcweir if( m_xAppEvents.is() ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir EventsHash::iterator h_itEnd = m_appEventsHash.end(); 413*cdf0e10cSrcweir EventsHash::iterator h_it = m_appEventsHash.begin(); 414*cdf0e10cSrcweir for ( ; h_it != h_itEnd; ++h_it ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir h_it->second.second = sEmpty; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir if( m_xDocEvents.is() && bDocModified ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir EventsHash::iterator h_itEnd = m_docEventsHash.end(); 422*cdf0e10cSrcweir EventsHash::iterator h_it = m_docEventsHash.begin(); 423*cdf0e10cSrcweir for ( ; h_it != h_itEnd; ++h_it ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir h_it->second.second = sEmpty; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir // if we have a valid XModifiable (in the case of doc events) 428*cdf0e10cSrcweir // call setModified(true) 429*cdf0e10cSrcweir if(m_xModifiable.is()) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir m_xModifiable->setModified( sal_True ); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir catch(Exception&) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir DisplayAppEvents(bAppEvents); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir void _SvxMacroTabPage::SetReadOnly( sal_Bool bSet ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir mpImpl->bReadOnly = bSet; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir sal_Bool _SvxMacroTabPage::IsReadOnly() const 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir return mpImpl->bReadOnly; 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir class IconLBoxString : public SvLBoxString 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir Image* m_pMacroImg; 455*cdf0e10cSrcweir Image* m_pComponentImg; 456*cdf0e10cSrcweir Image* m_pMacroImg_h; 457*cdf0e10cSrcweir Image* m_pComponentImg_h; 458*cdf0e10cSrcweir int m_nxImageOffset; 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir public: 461*cdf0e10cSrcweir IconLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& sText, 462*cdf0e10cSrcweir Image* pMacroImg, Image* pComponentImg, 463*cdf0e10cSrcweir Image* pMacroImg_h, Image* pComponentImg_h ); 464*cdf0e10cSrcweir virtual void Paint(const Point& aPos, SvLBox& aDevice, sal_uInt16 nFlags, SvLBoxEntry* pEntry ); 465*cdf0e10cSrcweir }; 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir IconLBoxString::IconLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& sText, 469*cdf0e10cSrcweir Image* pMacroImg, Image* pComponentImg, Image* pMacroImg_h, Image* pComponentImg_h ) 470*cdf0e10cSrcweir : SvLBoxString( pEntry, nFlags, sText ) 471*cdf0e10cSrcweir , m_pMacroImg( pMacroImg ) 472*cdf0e10cSrcweir , m_pComponentImg( pComponentImg ) 473*cdf0e10cSrcweir , m_pMacroImg_h( pMacroImg_h ) 474*cdf0e10cSrcweir , m_pComponentImg_h( pComponentImg_h ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir m_nxImageOffset = 20; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir //=============================================== 480*cdf0e10cSrcweir void IconLBoxString::Paint( const Point& aPos, SvLBox& aDevice, 481*cdf0e10cSrcweir sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir String aTxt( GetText() ); 484*cdf0e10cSrcweir if( aTxt.Len() ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir ::rtl::OUString aURL( aTxt ); 487*cdf0e10cSrcweir sal_Int32 nIndex = aURL.indexOf( aVndSunStarUNO ); 488*cdf0e10cSrcweir bool bUNO = nIndex == 0; 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir sal_Bool bHC = aDevice.GetSettings().GetStyleSettings().GetHighContrastMode(); 491*cdf0e10cSrcweir const Image* pImg; 492*cdf0e10cSrcweir if( bHC ) 493*cdf0e10cSrcweir pImg = bUNO ? m_pComponentImg_h : m_pMacroImg_h; 494*cdf0e10cSrcweir else 495*cdf0e10cSrcweir pImg = bUNO ? m_pComponentImg : m_pMacroImg; 496*cdf0e10cSrcweir aDevice.DrawImage( aPos, *pImg ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir ::rtl::OUString aPureMethod; 499*cdf0e10cSrcweir if( bUNO ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir sal_Int32 nBegin = aVndSunStarUNO.getLength(); 502*cdf0e10cSrcweir aPureMethod = aURL.copy( nBegin ); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir else 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir sal_Int32 nBegin = aVndSunStarScript.getLength(); 507*cdf0e10cSrcweir aPureMethod = aURL.copy( nBegin ); 508*cdf0e10cSrcweir aPureMethod = aPureMethod.copy( 0, aPureMethod.indexOf( '?' ) ); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir Point aPnt(aPos); 512*cdf0e10cSrcweir aPnt.X() += m_nxImageOffset; 513*cdf0e10cSrcweir aDevice.DrawText( aPnt, aPureMethod ); 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir // displays the app events if appEvents=true, otherwise displays the doc events 519*cdf0e10cSrcweir void _SvxMacroTabPage::DisplayAppEvents( bool appEvents) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir bAppEvents = appEvents; 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 524*cdf0e10cSrcweir mpImpl->pEventLB->SetUpdateMode( sal_False ); 525*cdf0e10cSrcweir rListBox.Clear(); 526*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.GetEntry( 0 ); 527*cdf0e10cSrcweir EventsHash* eventsHash; 528*cdf0e10cSrcweir Reference< container::XNameReplace> nameReplace; 529*cdf0e10cSrcweir if(bAppEvents) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir eventsHash = &m_appEventsHash; 532*cdf0e10cSrcweir nameReplace = m_xAppEvents; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir else 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir eventsHash = &m_docEventsHash; 537*cdf0e10cSrcweir nameReplace = m_xDocEvents; 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir // have to use the original XNameReplace since the hash iterators do 540*cdf0e10cSrcweir // not guarantee the order in which the elements are returned 541*cdf0e10cSrcweir if(!nameReplace.is()) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir return; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir Sequence< ::rtl::OUString > eventNames = nameReplace->getElementNames(); 547*cdf0e10cSrcweir ::std::set< ::rtl::OUString > aEventNamesCache; 548*cdf0e10cSrcweir ::std::copy( 549*cdf0e10cSrcweir eventNames.getConstArray(), 550*cdf0e10cSrcweir eventNames.getConstArray() + eventNames.getLength(), 551*cdf0e10cSrcweir ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aEventNamesCache, aEventNamesCache.end() ) 552*cdf0e10cSrcweir ); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir for ( EventDisplayNames::const_iterator displayableEvent = aDisplayNames.begin(); 555*cdf0e10cSrcweir displayableEvent != aDisplayNames.end(); 556*cdf0e10cSrcweir ++displayableEvent 557*cdf0e10cSrcweir ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir ::rtl::OUString sEventName( ::rtl::OUString::createFromAscii( displayableEvent->pAsciiEventName ) ); 560*cdf0e10cSrcweir if ( !nameReplace->hasByName( sEventName ) ) 561*cdf0e10cSrcweir continue; 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir EventsHash::iterator h_it = eventsHash->find( sEventName ); 564*cdf0e10cSrcweir if( h_it == eventsHash->end() ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir OSL_ENSURE( false, "_SvxMacroTabPage::DisplayAppEvents: something's suspicious here!" ); 567*cdf0e10cSrcweir continue; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir ::rtl::OUString eventURL = h_it->second.second; 571*cdf0e10cSrcweir String displayName( CUI_RES( displayableEvent->nEventResourceID ) ); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir displayName += '\t'; 574*cdf0e10cSrcweir SvLBoxEntry* _pE = rListBox.InsertEntry( displayName ); 575*cdf0e10cSrcweir ::rtl::OUString* pEventName = new ::rtl::OUString( sEventName ); 576*cdf0e10cSrcweir _pE->SetUserData( (void*)pEventName ); 577*cdf0e10cSrcweir String sNew( eventURL ); 578*cdf0e10cSrcweir _pE->ReplaceItem( new IconLBoxString( _pE, 0, sNew, 579*cdf0e10cSrcweir mpImpl->pMacroImg, mpImpl->pComponentImg, 580*cdf0e10cSrcweir mpImpl->pMacroImg_h, mpImpl->pComponentImg_h ), LB_MACROS_ITEMPOS ); 581*cdf0e10cSrcweir rListBox.GetModel()->InvalidateEntry( _pE ); 582*cdf0e10cSrcweir rListBox.Select( _pE ); 583*cdf0e10cSrcweir rListBox.MakeVisible( _pE ); 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir pE = rListBox.GetEntry(0); 587*cdf0e10cSrcweir if( pE ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir rListBox.Select( pE ); 590*cdf0e10cSrcweir rListBox.MakeVisible( pE ); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir rListBox.SetUpdateMode( sal_True ); 594*cdf0e10cSrcweir EnableButtons(); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // select event handler on the listbox 598*cdf0e10cSrcweir IMPL_STATIC_LINK( _SvxMacroTabPage, SelectEvent_Impl, SvTabListBox*, EMPTYARG ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir _SvxMacroTabPage_Impl* pImpl = pThis->mpImpl; 601*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox(); 602*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.FirstSelected(); 603*cdf0e10cSrcweir sal_uLong nPos; 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir if( !pE || LISTBOX_ENTRY_NOTFOUND == 606*cdf0e10cSrcweir ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) ) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" ); 609*cdf0e10cSrcweir return 0; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir pThis->EnableButtons(); 613*cdf0e10cSrcweir return 0; 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir IMPL_STATIC_LINK( _SvxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn ) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir return GenericHandler_Impl( pThis, pBtn ); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir IMPL_STATIC_LINK( _SvxMacroTabPage, DoubleClickHdl_Impl, SvTabListBox *, EMPTYARG ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir return GenericHandler_Impl( pThis, NULL ); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir // handler for double click on the listbox, and for the assign/delete buttons 627*cdf0e10cSrcweir long _SvxMacroTabPage::GenericHandler_Impl( _SvxMacroTabPage* pThis, PushButton* pBtn ) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir _SvxMacroTabPage_Impl* pImpl = pThis->mpImpl; 630*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox(); 631*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.FirstSelected(); 632*cdf0e10cSrcweir sal_uLong nPos; 633*cdf0e10cSrcweir if( !pE || LISTBOX_ENTRY_NOTFOUND == 634*cdf0e10cSrcweir ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" ); 637*cdf0e10cSrcweir return 0; 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir const sal_Bool bAssEnabled = pBtn != pImpl->pDeletePB && pImpl->pAssignPB->IsEnabled(); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir ::rtl::OUString* pEventName = (::rtl::OUString*)pE->GetUserData(); 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir ::rtl::OUString sEventURL; 645*cdf0e10cSrcweir ::rtl::OUString sEventType; 646*cdf0e10cSrcweir if(pThis->bAppEvents) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir EventsHash::iterator h_it = pThis->m_appEventsHash.find( *pEventName ); 649*cdf0e10cSrcweir if(h_it != pThis->m_appEventsHash.end() ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir sEventType = h_it->second.first; 652*cdf0e10cSrcweir sEventURL = h_it->second.second; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir else 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir EventsHash::iterator h_it = pThis->m_docEventsHash.find( *pEventName ); 658*cdf0e10cSrcweir if(h_it != pThis->m_docEventsHash.end() ) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir sEventType = h_it->second.first; 661*cdf0e10cSrcweir sEventURL = h_it->second.second; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir bool bDoubleClick = (pBtn == NULL); 666*cdf0e10cSrcweir bool bUNOAssigned = (sEventURL.indexOf( aVndSunStarUNO ) == 0); 667*cdf0e10cSrcweir if( pBtn == pImpl->pDeletePB ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir // delete pressed 670*cdf0e10cSrcweir sEventType = ::rtl::OUString::createFromAscii("Script"); 671*cdf0e10cSrcweir sEventURL = ::rtl::OUString(); 672*cdf0e10cSrcweir if(!pThis->bAppEvents) 673*cdf0e10cSrcweir pThis->bDocModified = true; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir else if ( ( ( pBtn != NULL ) 676*cdf0e10cSrcweir && ( pBtn == pImpl->pAssignComponentPB ) 677*cdf0e10cSrcweir ) 678*cdf0e10cSrcweir || ( bDoubleClick 679*cdf0e10cSrcweir && bUNOAssigned 680*cdf0e10cSrcweir ) 681*cdf0e10cSrcweir ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir AssignComponentDialog* pAssignDlg = new AssignComponentDialog( pThis, sEventURL ); 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir short ret = pAssignDlg->Execute(); 686*cdf0e10cSrcweir if( ret ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir sEventType = ::rtl::OUString::createFromAscii("UNO"); 689*cdf0e10cSrcweir sEventURL = pAssignDlg->getURL(); 690*cdf0e10cSrcweir if(!pThis->bAppEvents) 691*cdf0e10cSrcweir pThis->bDocModified = true; 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir delete pAssignDlg; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir else if( bAssEnabled ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir // assign pressed 698*cdf0e10cSrcweir SvxScriptSelectorDialog* pDlg = new SvxScriptSelectorDialog( pThis, sal_False, pThis->GetFrame() ); 699*cdf0e10cSrcweir if( pDlg ) 700*cdf0e10cSrcweir { 701*cdf0e10cSrcweir short ret = pDlg->Execute(); 702*cdf0e10cSrcweir if ( ret ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir sEventType = ::rtl::OUString::createFromAscii("Script"); 705*cdf0e10cSrcweir sEventURL = pDlg->GetScriptURL(); 706*cdf0e10cSrcweir if(!pThis->bAppEvents) 707*cdf0e10cSrcweir pThis->bDocModified = true; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir // update the hashes 713*cdf0e10cSrcweir if(pThis->bAppEvents) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir EventsHash::iterator h_it = pThis->m_appEventsHash.find( *pEventName ); 716*cdf0e10cSrcweir h_it->second.first = sEventType; 717*cdf0e10cSrcweir h_it->second.second = sEventURL; 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir else 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir EventsHash::iterator h_it = pThis->m_docEventsHash.find( *pEventName ); 722*cdf0e10cSrcweir h_it->second.first = sEventType; 723*cdf0e10cSrcweir h_it->second.second = sEventURL; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir // update the listbox entry 727*cdf0e10cSrcweir pImpl->pEventLB->SetUpdateMode( sal_False ); 728*cdf0e10cSrcweir // pE->ReplaceItem( new SvLBoxString( pE, 0, sEventURL ), LB_MACROS_ITEMPOS ); 729*cdf0e10cSrcweir pE->ReplaceItem( new IconLBoxString( pE, 0, sEventURL, 730*cdf0e10cSrcweir pImpl->pMacroImg, pImpl->pComponentImg, 731*cdf0e10cSrcweir pImpl->pMacroImg_h, pImpl->pComponentImg_h ), LB_MACROS_ITEMPOS ); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir rListBox.GetModel()->InvalidateEntry( pE ); 734*cdf0e10cSrcweir rListBox.Select( pE ); 735*cdf0e10cSrcweir rListBox.MakeVisible( pE ); 736*cdf0e10cSrcweir rListBox.SetUpdateMode( sal_True ); 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir pThis->EnableButtons(); 739*cdf0e10cSrcweir return 0; 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir // pass in the XNameReplace. 743*cdf0e10cSrcweir // can remove the 3rd arg once issue ?? is fixed 744*cdf0e10cSrcweir void _SvxMacroTabPage::InitAndSetHandler( Reference< container::XNameReplace> xAppEvents, Reference< container::XNameReplace> xDocEvents, Reference< util::XModifiable > xModifiable ) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir m_xAppEvents = xAppEvents; 747*cdf0e10cSrcweir m_xDocEvents = xDocEvents; 748*cdf0e10cSrcweir m_xModifiable = xModifiable; 749*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 750*cdf0e10cSrcweir HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar(); 751*cdf0e10cSrcweir Link aLnk(STATIC_LINK(this, _SvxMacroTabPage, AssignDeleteHdl_Impl )); 752*cdf0e10cSrcweir mpImpl->pDeletePB->SetClickHdl( aLnk ); 753*cdf0e10cSrcweir mpImpl->pAssignPB->SetClickHdl( aLnk ); 754*cdf0e10cSrcweir if( mpImpl->pAssignComponentPB ) 755*cdf0e10cSrcweir mpImpl->pAssignComponentPB->SetClickHdl( aLnk ); 756*cdf0e10cSrcweir rListBox.SetDoubleClickHdl( STATIC_LINK(this, _SvxMacroTabPage, DoubleClickHdl_Impl ) ); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir rListBox.SetSelectHdl( STATIC_LINK( this, _SvxMacroTabPage, SelectEvent_Impl )); 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir rListBox.SetSelectionMode( SINGLE_SELECTION ); 761*cdf0e10cSrcweir rListBox.SetTabs( &nTabs[0], MAP_APPFONT ); 762*cdf0e10cSrcweir Size aSize( nTabs[ 2 ], 0 ); 763*cdf0e10cSrcweir rHeaderBar.InsertItem( ITEMID_EVENT, *mpImpl->pStrEvent, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() ); 764*cdf0e10cSrcweir aSize.Width() = 1764; // don't know what, so 42^2 is best to use... 765*cdf0e10cSrcweir rHeaderBar.InsertItem( ITMEID_ASSMACRO, *mpImpl->pAssignedMacro, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() ); 766*cdf0e10cSrcweir rListBox.SetSpaceBetweenEntries( 0 ); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir mpImpl->pEventLB->Show(); 769*cdf0e10cSrcweir mpImpl->pEventLB->ConnectElements(); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir long nMinLineHeight = mpImpl->pMacroImg->GetSizePixel().Height() + 2; 772*cdf0e10cSrcweir if( nMinLineHeight > mpImpl->pEventLB->GetListBox().GetEntryHeight() ) 773*cdf0e10cSrcweir mpImpl->pEventLB->GetListBox().SetEntryHeight( 774*cdf0e10cSrcweir sal::static_int_cast< short >(nMinLineHeight) ); 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir mpImpl->pEventLB->Enable( sal_True ); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir if(!m_xAppEvents.is()) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir return; 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir Sequence< ::rtl::OUString > eventNames = m_xAppEvents->getElementNames(); 783*cdf0e10cSrcweir sal_Int32 nEventCount = eventNames.getLength(); 784*cdf0e10cSrcweir for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent ) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir //need exception handling here 787*cdf0e10cSrcweir try 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir m_appEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xAppEvents->getByName( eventNames[nEvent] ) ); 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir catch (Exception e) 792*cdf0e10cSrcweir {} 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir if(m_xDocEvents.is()) 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir eventNames = m_xDocEvents->getElementNames(); 797*cdf0e10cSrcweir nEventCount = eventNames.getLength(); 798*cdf0e10cSrcweir for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent ) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir try 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir m_docEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xDocEvents->getByName( eventNames[nEvent] ) ); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir catch (Exception e) 805*cdf0e10cSrcweir {} 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir // returns the two props EventType & Script for a given event name 811*cdf0e10cSrcweir Any _SvxMacroTabPage::GetPropsByName( const ::rtl::OUString& eventName, EventsHash& eventsHash ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir const ::std::pair< ::rtl::OUString, ::rtl::OUString >& rAssignedEvent( eventsHash[ eventName ] ); 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir Any aReturn; 816*cdf0e10cSrcweir ::comphelper::NamedValueCollection aProps; 817*cdf0e10cSrcweir if ( rAssignedEvent.first.getLength() && rAssignedEvent.second.getLength() ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir aProps.put( "EventType", rAssignedEvent.first ); 820*cdf0e10cSrcweir aProps.put( "Script", rAssignedEvent.second ); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir aReturn <<= aProps.getPropertyValues(); 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir return aReturn; 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir // converts the Any returned by GetByName into a pair which can be stored in 828*cdf0e10cSrcweir // the EventHash 829*cdf0e10cSrcweir ::std::pair< ::rtl::OUString, ::rtl::OUString > _SvxMacroTabPage::GetPairFromAny( Any aAny ) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir Sequence< beans::PropertyValue > props; 832*cdf0e10cSrcweir ::rtl::OUString type, url; 833*cdf0e10cSrcweir if( sal_True == ( aAny >>= props ) ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir ::comphelper::NamedValueCollection aProps( props ); 836*cdf0e10cSrcweir type = aProps.getOrDefault( "EventType", type ); 837*cdf0e10cSrcweir url = aProps.getOrDefault( "Script", url ); 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir return ::std::make_pair( type, url ); 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir SvxMacroTabPage::SvxMacroTabPage( Window* pParent, const Reference< frame::XFrame >& _rxDocumentFrame, const SfxItemSet& rSet, Reference< container::XNameReplace > xNameReplace, sal_uInt16 nSelectedIndex ) 843*cdf0e10cSrcweir : _SvxMacroTabPage( pParent, CUI_RES( RID_SVXPAGE_MACROASSIGN ), rSet ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ) ); 846*cdf0e10cSrcweir mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ) ); 847*cdf0e10cSrcweir mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ) ); 848*cdf0e10cSrcweir mpImpl->pAssignFT = new FixedText( this, CUI_RES( FT_ASSIGN ) ); 849*cdf0e10cSrcweir mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ) ); 850*cdf0e10cSrcweir mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ) ); 851*cdf0e10cSrcweir mpImpl->pAssignComponentPB = new PushButton( this, CUI_RES( PB_ASSIGN_COMPONENT ) ); 852*cdf0e10cSrcweir mpImpl->pMacroImg = new Image( CUI_RES(IMG_MACRO) ); 853*cdf0e10cSrcweir mpImpl->pComponentImg = new Image( CUI_RES(IMG_COMPONENT) ); 854*cdf0e10cSrcweir mpImpl->pMacroImg_h = new Image( CUI_RES(IMG_MACRO_H) ); 855*cdf0e10cSrcweir mpImpl->pComponentImg_h = new Image( CUI_RES(IMG_COMPONENT_H) ); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir FreeResource(); 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir SetFrame( _rxDocumentFrame ); 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir if( !mpImpl->bIDEDialogMode ) 862*cdf0e10cSrcweir { 863*cdf0e10cSrcweir // Size aSizeAssign; 864*cdf0e10cSrcweir // Point aPosAssign; 865*cdf0e10cSrcweir // mpImpl->pAssignPB->GetPosSizePixel( aPosAssign, aSizeAssign ); 866*cdf0e10cSrcweir Point aPosAssign = mpImpl->pAssignPB->GetPosPixel(); 867*cdf0e10cSrcweir Point aPosComp = mpImpl->pAssignComponentPB->GetPosPixel(); 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir Point aPosDelete = mpImpl->pDeletePB->GetPosPixel(); 870*cdf0e10cSrcweir long nYDiff = aPosComp.Y() - aPosAssign.Y(); 871*cdf0e10cSrcweir aPosDelete.Y() -= nYDiff; 872*cdf0e10cSrcweir mpImpl->pDeletePB->SetPosPixel( aPosDelete ); 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir mpImpl->pAssignComponentPB->Hide(); 875*cdf0e10cSrcweir mpImpl->pAssignComponentPB->Disable(); 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir // must be done after FreeResource is called 879*cdf0e10cSrcweir InitResources(); 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir mpImpl->pEventLB->GetListBox().SetHelpId( HID_SVX_MACRO_LB_EVENT ); 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir InitAndSetHandler( xNameReplace, Reference< container::XNameReplace>(0), Reference< util::XModifiable >(0)); 884*cdf0e10cSrcweir DisplayAppEvents(true); 885*cdf0e10cSrcweir SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); 886*cdf0e10cSrcweir SvLBoxEntry* pE = rListBox.GetEntry( (sal_uLong)nSelectedIndex ); 887*cdf0e10cSrcweir if( pE ) 888*cdf0e10cSrcweir rListBox.Select(pE); 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir SvxMacroTabPage::~SvxMacroTabPage() 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir 895*cdf0e10cSrcweir SvxMacroAssignDlg::SvxMacroAssignDlg( Window* pParent, const Reference< frame::XFrame >& _rxDocumentFrame, const SfxItemSet& rSet, 896*cdf0e10cSrcweir const Reference< container::XNameReplace >& xNameReplace, sal_uInt16 nSelectedIndex ) 897*cdf0e10cSrcweir : SvxMacroAssignSingleTabDialog( pParent, rSet, 0 ) 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir SetTabPage( new SvxMacroTabPage( this, _rxDocumentFrame, rSet, xNameReplace, nSelectedIndex ) ); 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir SvxMacroAssignDlg::~SvxMacroAssignDlg() 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir //=============================================== 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir IMPL_LINK(AssignComponentDialog, ButtonHandler, Button *, EMPTYARG) 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir ::rtl::OUString aMethodName = maMethodEdit.GetText(); 912*cdf0e10cSrcweir maURL = ::rtl::OUString(); 913*cdf0e10cSrcweir if( aMethodName.getLength() ) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir maURL = aVndSunStarUNO; 916*cdf0e10cSrcweir maURL += aMethodName; 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir EndDialog(1); 919*cdf0e10cSrcweir return 0; 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir AssignComponentDialog::AssignComponentDialog( Window * pParent, const ::rtl::OUString& rURL ) 923*cdf0e10cSrcweir : ModalDialog( pParent, CUI_RES( RID_SVXDLG_ASSIGNCOMPONENT ) ) 924*cdf0e10cSrcweir , maMethodLabel( this, CUI_RES( FT_METHOD ) ) 925*cdf0e10cSrcweir , maMethodEdit( this, CUI_RES( EDIT_METHOD ) ) 926*cdf0e10cSrcweir , maOKButton( this, CUI_RES( RID_PB_OK ) ) 927*cdf0e10cSrcweir , maCancelButton( this, CUI_RES( RID_PB_CANCEL ) ) 928*cdf0e10cSrcweir , maHelpButton( this, CUI_RES( RID_PB_HELP ) ) 929*cdf0e10cSrcweir , maURL( rURL ) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir FreeResource(); 932*cdf0e10cSrcweir maOKButton.SetClickHdl(LINK(this, AssignComponentDialog, ButtonHandler)); 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir ::rtl::OUString aMethodName; 935*cdf0e10cSrcweir if( maURL.getLength() ) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir sal_Int32 nIndex = maURL.indexOf( aVndSunStarUNO ); 938*cdf0e10cSrcweir if( nIndex == 0 ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir sal_Int32 nBegin = aVndSunStarUNO.getLength(); 941*cdf0e10cSrcweir aMethodName = maURL.copy( nBegin ); 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir maMethodEdit.SetText( aMethodName, Selection( 0, SELECTION_MAX ) ); 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir AssignComponentDialog::~AssignComponentDialog() 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir // ----------------------------------------------------------------------- 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir IMPL_LINK( SvxMacroAssignSingleTabDialog, OKHdl_Impl, Button *, pButton ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir (void)pButton; //unused 956*cdf0e10cSrcweir pPage->FillItemSet( *pOutSet ); 957*cdf0e10cSrcweir EndDialog( RET_OK ); 958*cdf0e10cSrcweir return 0; 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir // ----------------------------------------------------------------------- 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir SvxMacroAssignSingleTabDialog::SvxMacroAssignSingleTabDialog 964*cdf0e10cSrcweir ( Window *pParent, const SfxItemSet& rSet, sal_uInt16 nUniqueId ) : 965*cdf0e10cSrcweir SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ), 966*cdf0e10cSrcweir pFixedLine ( 0 ), 967*cdf0e10cSrcweir pOKBtn ( 0 ), 968*cdf0e10cSrcweir pCancelBtn ( 0 ), 969*cdf0e10cSrcweir pHelpBtn ( 0 ), 970*cdf0e10cSrcweir pPage ( 0 ), 971*cdf0e10cSrcweir pOptions ( &rSet ), 972*cdf0e10cSrcweir pOutSet ( 0 ) 973*cdf0e10cSrcweir {} 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir // ----------------------------------------------------------------------- 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir SvxMacroAssignSingleTabDialog::~SvxMacroAssignSingleTabDialog() 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir delete pFixedLine; 981*cdf0e10cSrcweir delete pOKBtn; 982*cdf0e10cSrcweir delete pCancelBtn; 983*cdf0e10cSrcweir delete pHelpBtn; 984*cdf0e10cSrcweir delete pPage; 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir // ----------------------------------------------------------------------- 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir // According to SfxSingleTabDialog 990*cdf0e10cSrcweir void SvxMacroAssignSingleTabDialog::SetTabPage( SfxTabPage* pTabPage ) 991*cdf0e10cSrcweir { 992*cdf0e10cSrcweir pFixedLine = new FixedLine( this ); 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir pOKBtn = new OKButton( this, WB_DEFBUTTON ); 995*cdf0e10cSrcweir pOKBtn->SetClickHdl( LINK( this, SvxMacroAssignSingleTabDialog, OKHdl_Impl ) ); 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir pCancelBtn = new CancelButton( this ); 998*cdf0e10cSrcweir pHelpBtn = new HelpButton( this ); 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir pPage = pTabPage; 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir if ( pPage ) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir String sUserData; 1005*cdf0e10cSrcweir pPage->SetUserData( sUserData ); 1006*cdf0e10cSrcweir pPage->Reset( *pOptions ); 1007*cdf0e10cSrcweir pPage->Show(); 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir // Set dialog's and buttons' size and position according to tabpage size 1010*cdf0e10cSrcweir long nSpaceX = LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width(); 1011*cdf0e10cSrcweir long nSpaceY = LogicToPixel( Size( 0, 6 ), MAP_APPFONT ).Height(); 1012*cdf0e10cSrcweir long nHalfSpaceX = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); 1013*cdf0e10cSrcweir long nHalfSpaceY = LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height(); 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir pPage->SetPosPixel( Point() ); 1016*cdf0e10cSrcweir Size aTabpageSize( pPage->GetSizePixel() ); 1017*cdf0e10cSrcweir Size aDialogSize( aTabpageSize ); 1018*cdf0e10cSrcweir Size aButtonSize = LogicToPixel( Size( 50, 14 ), MAP_APPFONT ); 1019*cdf0e10cSrcweir long nButtonWidth = aButtonSize.Width(); 1020*cdf0e10cSrcweir long nButtonHeight = aButtonSize.Height(); 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir Size aFixedLineSize( aTabpageSize ); 1023*cdf0e10cSrcweir long nFixedLineHeight = LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height(); 1024*cdf0e10cSrcweir aFixedLineSize.Height() = nFixedLineHeight; 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir aDialogSize.Height() += nFixedLineHeight + nButtonHeight + nSpaceY + nHalfSpaceY; 1027*cdf0e10cSrcweir SetOutputSizePixel( aDialogSize ); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir long nButtonPosY = aTabpageSize.Height() + nFixedLineHeight + nHalfSpaceY; 1030*cdf0e10cSrcweir long nHelpButtonPosX = nSpaceX; 1031*cdf0e10cSrcweir pHelpBtn->SetPosSizePixel( Point( nHelpButtonPosX, nButtonPosY), aButtonSize ); 1032*cdf0e10cSrcweir pHelpBtn->Show(); 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir long nCancelButtonPosX = aDialogSize.Width() - nButtonWidth - nSpaceX + 1; 1035*cdf0e10cSrcweir pCancelBtn->SetPosSizePixel( Point( nCancelButtonPosX, nButtonPosY), aButtonSize ); 1036*cdf0e10cSrcweir pCancelBtn->Show(); 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir long nOkButtonPosX = nCancelButtonPosX - nButtonWidth - nHalfSpaceX; 1039*cdf0e10cSrcweir pOKBtn->SetPosSizePixel( Point( nOkButtonPosX, nButtonPosY), aButtonSize ); 1040*cdf0e10cSrcweir pOKBtn->Show(); 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir long nFixedLinePosY = aTabpageSize.Height(); 1043*cdf0e10cSrcweir pFixedLine->SetPosSizePixel( Point( 0, nFixedLinePosY), aFixedLineSize ); 1044*cdf0e10cSrcweir pFixedLine->Show(); 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir // Get text from TabPage 1047*cdf0e10cSrcweir SetText( pPage->GetText() ); 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir // Get IDs from TabPage 1050*cdf0e10cSrcweir SetHelpId( pPage->GetHelpId() ); 1051*cdf0e10cSrcweir SetUniqueId( pPage->GetUniqueId() ); 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir } 1054