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 <vcl/help.hxx> 31*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 32*cdf0e10cSrcweir #include <vcl/metric.hxx> 33*cdf0e10cSrcweir #include "selector.hxx" 34*cdf0e10cSrcweir #include <dialmgr.hxx> 35*cdf0e10cSrcweir #include "selector.hrc" 36*cdf0e10cSrcweir #include <svx/fmresids.hrc> // for RID_SVXIMG_... 37*cdf0e10cSrcweir #include <svx/dialmgr.hxx> // for RID_SVXIMG_... 38*cdf0e10cSrcweir #include <cuires.hrc> 39*cdf0e10cSrcweir #include <sfx2/app.hxx> 40*cdf0e10cSrcweir #include <sfx2/msg.hxx> 41*cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 42*cdf0e10cSrcweir #include <sfx2/minfitem.hxx> 43*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 44*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <comphelper/documentinfo.hxx> 47*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 48*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProvider.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNodeFactory.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedScripts.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/document/XScriptInvocationContext.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchInformationProvider.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchInformation.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir using ::rtl::OUString; 68*cdf0e10cSrcweir using namespace ::com::sun::star; 69*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 70*cdf0e10cSrcweir using namespace ::com::sun::star::script; 71*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 72*cdf0e10cSrcweir using namespace ::com::sun::star::document; 73*cdf0e10cSrcweir using namespace ::com::sun::star::container; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 76*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 77*cdf0e10cSrcweir #include <svtools/imagemgr.hxx> 78*cdf0e10cSrcweir #include <tools/urlobj.hxx> 79*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir SV_IMPL_PTRARR(SvxGroupInfoArr_Impl, SvxGroupInfoPtr); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /* 84*cdf0e10cSrcweir * The implementations of SvxConfigFunctionListBox_Impl and 85*cdf0e10cSrcweir * SvxConfigGroupListBox_Impl are copied from sfx2/source/dialog/cfg.cxx 86*cdf0e10cSrcweir */ 87*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl::SvxConfigFunctionListBox_Impl( Window* pParent, const ResId& rResId) 88*cdf0e10cSrcweir : SvTreeListBox( pParent, rResId ) 89*cdf0e10cSrcweir , pCurEntry( 0 ) 90*cdf0e10cSrcweir , m_pDraggingEntry( 0 ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT ); 93*cdf0e10cSrcweir GetModel()->SetSortMode( SortAscending ); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir // Timer f"ur die BallonHelp 96*cdf0e10cSrcweir aTimer.SetTimeout( 200 ); 97*cdf0e10cSrcweir aTimer.SetTimeoutHdl( 98*cdf0e10cSrcweir LINK( this, SvxConfigFunctionListBox_Impl, TimerHdl ) ); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl::~SvxConfigFunctionListBox_Impl() 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir ClearAll(); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir SvLBoxEntry* SvxConfigFunctionListBox_Impl::GetLastSelectedEntry() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir if ( m_pDraggingEntry != NULL ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir return m_pDraggingEntry; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir else 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir return FirstSelected(); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir void SvxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& rMEvt ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 121*cdf0e10cSrcweir pCurEntry = GetCurEntry(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir if ( pCurEntry && GetEntry( aMousePos ) == pCurEntry ) 124*cdf0e10cSrcweir aTimer.Start(); 125*cdf0e10cSrcweir else 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir Help::ShowBalloon( this, aMousePos, String() ); 128*cdf0e10cSrcweir aTimer.Stop(); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir IMPL_LINK( SvxConfigFunctionListBox_Impl, TimerHdl, Timer*, EMPTYARG) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir aTimer.Stop(); 136*cdf0e10cSrcweir Point aMousePos = GetPointerPosPixel(); 137*cdf0e10cSrcweir SvLBoxEntry *pEntry = GetCurEntry(); 138*cdf0e10cSrcweir if ( pEntry && GetEntry( aMousePos ) == pEntry && pCurEntry == pEntry ) 139*cdf0e10cSrcweir Help::ShowBalloon( this, OutputToScreenPixel( aMousePos ), GetHelpText( pEntry ) ); 140*cdf0e10cSrcweir return 0L; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir void SvxConfigFunctionListBox_Impl::ClearAll() 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir sal_uInt16 nCount = aArr.Count(); 146*cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i++ ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir SvxGroupInfo_Impl *pData = aArr[i]; 149*cdf0e10cSrcweir delete pData; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir aArr.Remove( 0, nCount ); 153*cdf0e10cSrcweir Clear(); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir String SvxConfigFunctionListBox_Impl::GetHelpText( SvLBoxEntry *pEntry ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir // Information zum selektierten Entry aus den Userdaten holen 159*cdf0e10cSrcweir SvxGroupInfo_Impl *pInfo = 160*cdf0e10cSrcweir pEntry ? (SvxGroupInfo_Impl*) pEntry->GetUserData(): 0; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir if ( pInfo ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir if ( pInfo->nKind == SVX_CFGFUNCTION_SLOT ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir OUString aCmdURL( pInfo->sURL ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir OUString aHelpText = Application::GetHelp()->GetHelpText( aCmdURL, this ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir return aHelpText; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir else if ( pInfo->nKind == SVX_CFGFUNCTION_SCRIPT ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir return pInfo->sHelpText; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir return String(); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void SvxConfigFunctionListBox_Impl::FunctionSelected() 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir Help::ShowBalloon( this, Point(), String() ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // drag and drop support 187*cdf0e10cSrcweir DragDropMode SvxConfigFunctionListBox_Impl::NotifyStartDrag( 188*cdf0e10cSrcweir TransferDataContainer& /*aTransferDataContainer*/, SvLBoxEntry* pEntry ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir m_pDraggingEntry = pEntry; 191*cdf0e10cSrcweir return GetDragDropMode(); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir void SvxConfigFunctionListBox_Impl::DragFinished( sal_Int8 /*nDropAction*/ ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir m_pDraggingEntry = NULL; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir sal_Int8 200*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir return DND_ACTION_NONE; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir SvxConfigGroupListBox_Impl::SvxConfigGroupListBox_Impl( 206*cdf0e10cSrcweir Window* pParent, const ResId& rResId, 207*cdf0e10cSrcweir bool _bShowSlots, const Reference< frame::XFrame >& xFrame ) 208*cdf0e10cSrcweir : SvTreeListBox( pParent, rResId ) 209*cdf0e10cSrcweir , m_bShowSlots( _bShowSlots ), 210*cdf0e10cSrcweir m_hdImage(ResId(IMG_HARDDISK,*rResId.GetResMgr())), 211*cdf0e10cSrcweir m_hdImage_hc(ResId(IMG_HARDDISK_HC,*rResId.GetResMgr())), 212*cdf0e10cSrcweir m_libImage(ResId(IMG_LIB,*rResId.GetResMgr())), 213*cdf0e10cSrcweir m_libImage_hc(ResId(IMG_LIB_HC,*rResId.GetResMgr())), 214*cdf0e10cSrcweir m_macImage(ResId(IMG_MACRO,*rResId.GetResMgr())), 215*cdf0e10cSrcweir m_macImage_hc(ResId(IMG_MACRO_HC,*rResId.GetResMgr())), 216*cdf0e10cSrcweir m_docImage(ResId(IMG_DOC,*rResId.GetResMgr())), 217*cdf0e10cSrcweir m_docImage_hc(ResId(IMG_DOC_HC,*rResId.GetResMgr())), 218*cdf0e10cSrcweir m_sMyMacros(String(ResId(STR_MYMACROS,*rResId.GetResMgr()))), 219*cdf0e10cSrcweir m_sProdMacros(String(ResId(STR_PRODMACROS,*rResId.GetResMgr()))) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir FreeResource(); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir if ( xFrame != NULL ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir m_xFrame.set( xFrame ); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir SetNodeBitmaps( 233*cdf0e10cSrcweir aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ), 234*cdf0e10cSrcweir aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ), 235*cdf0e10cSrcweir BMP_COLOR_NORMAL ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir SetNodeBitmaps( 238*cdf0e10cSrcweir aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ), 239*cdf0e10cSrcweir aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ), 240*cdf0e10cSrcweir BMP_COLOR_HIGHCONTRAST ); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir SvxConfigGroupListBox_Impl::~SvxConfigGroupListBox_Impl() 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir ClearAll(); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir void SvxConfigGroupListBox_Impl::ClearAll() 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir sal_uInt16 nCount = aArr.Count(); 252*cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i++ ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SvxGroupInfo_Impl *pData = aArr[i]; 255*cdf0e10cSrcweir delete pData; 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir aArr.Remove( 0, nCount ); 259*cdf0e10cSrcweir Clear(); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir //----------------------------------------------- 263*cdf0e10cSrcweir namespace 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir //........................................... 266*cdf0e10cSrcweir /** examines a component whether it supports XEmbeddedScripts, or provides access to such a 267*cdf0e10cSrcweir component by implementing XScriptInvocationContext. 268*cdf0e10cSrcweir @return 269*cdf0e10cSrcweir the model which supports the embedded scripts, or <NULL/> if it cannot find such a 270*cdf0e10cSrcweir model 271*cdf0e10cSrcweir */ 272*cdf0e10cSrcweir static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY ); 275*cdf0e10cSrcweir if ( !xScripts.is() ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY ); 278*cdf0e10cSrcweir if ( xContext.is() ) 279*cdf0e10cSrcweir xScripts.set( xContext->getScriptContainer(), UNO_QUERY ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir return Reference< XModel >( xScripts, UNO_QUERY ); 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir //........................................... 286*cdf0e10cSrcweir static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir Reference< XModel > xDocument; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir // examine our associated frame 291*cdf0e10cSrcweir try 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" ); 294*cdf0e10cSrcweir if ( _rxFrame.is() ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir // first try the model in the frame 297*cdf0e10cSrcweir Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW ); 298*cdf0e10cSrcweir xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() ); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if ( !xDocument.is() ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir // if there is no suitable document in the frame, try the controller 303*cdf0e10cSrcweir xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir catch( const Exception& ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir return xDocument; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void SvxConfigGroupListBox_Impl::fillScriptList( const Reference< browse::XBrowseNode >& _rxRootNode, SvLBoxEntry* _pParentEntry, bool _bCheapChildsOnDemand ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir OSL_PRECOND( _rxRootNode.is(), "SvxConfigGroupListBox_Impl::fillScriptList: invalid root node!" ); 319*cdf0e10cSrcweir if ( !_rxRootNode.is() ) 320*cdf0e10cSrcweir return; 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir try 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir if ( _rxRootNode->hasChildNodes() ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir Sequence< Reference< browse::XBrowseNode > > children = 327*cdf0e10cSrcweir _rxRootNode->getChildNodes(); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir sal_Bool bIsRootNode = _rxRootNode->getName().equalsAscii("Root"); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir /* To mimic current starbasic behaviour we 332*cdf0e10cSrcweir need to make sure that only the current document 333*cdf0e10cSrcweir is displayed in the config tree. Tests below 334*cdf0e10cSrcweir set the bDisplay flag to sal_False if the current 335*cdf0e10cSrcweir node is a first level child of the Root and is NOT 336*cdf0e10cSrcweir either the current document, user or share */ 337*cdf0e10cSrcweir OUString sCurrentDocTitle; 338*cdf0e10cSrcweir Reference< XModel > xWorkingDocument = lcl_getScriptableDocument_nothrow( m_xFrame ); 339*cdf0e10cSrcweir if ( xWorkingDocument.is() ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir sCurrentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xWorkingDocument ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir for ( long n = 0; n < children.getLength(); n++ ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir Reference< browse::XBrowseNode >& theChild = children[n]; 347*cdf0e10cSrcweir //#139111# some crash reports show that it might be unset 348*cdf0e10cSrcweir if ( !theChild.is() ) 349*cdf0e10cSrcweir continue; 350*cdf0e10cSrcweir ::rtl::OUString sUIName = theChild->getName(); 351*cdf0e10cSrcweir sal_Bool bDisplay = sal_True; 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir if ( bIsRootNode 354*cdf0e10cSrcweir || ( m_bShowSlots && _pParentEntry && ( GetModel()->GetDepth( _pParentEntry ) == 0 ) ) 355*cdf0e10cSrcweir // if we show slots (as in the customize dialog) 356*cdf0e10cSrcweir // then the user & share are added at depth=1 357*cdf0e10cSrcweir ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir if ( sUIName.equalsAscii( "user" ) ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir sUIName = m_sMyMacros; 362*cdf0e10cSrcweir bIsRootNode = sal_True; 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir else if ( sUIName.equalsAscii( "share" ) ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir sUIName = m_sProdMacros; 367*cdf0e10cSrcweir bIsRootNode = sal_True; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir else if ( !sUIName.equals( sCurrentDocTitle ) ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir bDisplay = sal_False; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir if ( !bDisplay ) 376*cdf0e10cSrcweir continue; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir if ( children[n]->getType() == browse::BrowseNodeTypes::SCRIPT ) 379*cdf0e10cSrcweir continue; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir SvLBoxEntry* pNewEntry = InsertEntry( sUIName, _pParentEntry ); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 384*cdf0e10cSrcweir Image aImage = GetImage( theChild, aContext.getUNOContext(), bIsRootNode, BMP_COLOR_NORMAL ); 385*cdf0e10cSrcweir SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); 386*cdf0e10cSrcweir SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir aImage = GetImage( theChild, aContext.getUNOContext(), bIsRootNode, BMP_COLOR_HIGHCONTRAST ); 389*cdf0e10cSrcweir SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST ); 390*cdf0e10cSrcweir SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST ); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir SvxGroupInfo_Impl* pInfo = 393*cdf0e10cSrcweir new SvxGroupInfo_Impl( SVX_CFGGROUP_SCRIPTCONTAINER, 0, theChild ); 394*cdf0e10cSrcweir pNewEntry->SetUserData( pInfo ); 395*cdf0e10cSrcweir aArr.Insert( pInfo, aArr.Count() ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir if ( _bCheapChildsOnDemand ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir /* i30923 - Would be nice if there was a better 400*cdf0e10cSrcweir * way to determine if a basic lib had children 401*cdf0e10cSrcweir * without having to ask for them (which forces 402*cdf0e10cSrcweir * the library to be loaded */ 403*cdf0e10cSrcweir pNewEntry->EnableChildsOnDemand( sal_True ); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir else 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir // if there are granchildren we're interested in, display the '+' before 408*cdf0e10cSrcweir // the entry, but do not yet expand 409*cdf0e10cSrcweir Sequence< Reference< browse::XBrowseNode > > grandchildren = 410*cdf0e10cSrcweir children[n]->getChildNodes(); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir pNewEntry->EnableChildsOnDemand( sal_True ); 417*cdf0e10cSrcweir break; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir catch (const Exception&) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir void SvxConfigGroupListBox_Impl::Init() 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir SetUpdateMode(sal_False); 433*cdf0e10cSrcweir ClearAll(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir Reference< XComponentContext > xContext; 436*cdf0e10cSrcweir Reference < beans::XPropertySet > xProps( 437*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir xContext.set( xProps->getPropertyValue( 440*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), 441*cdf0e10cSrcweir UNO_QUERY ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir // are we showing builtin commands? 444*cdf0e10cSrcweir if ( m_bShowSlots && xContext.is() && m_xFrame.is() ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir Reference< lang::XMultiComponentFactory > xMCF = 447*cdf0e10cSrcweir xContext->getServiceManager(); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir Reference< frame::XDispatchInformationProvider > xDIP( 450*cdf0e10cSrcweir m_xFrame, UNO_QUERY ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XModuleManager > 453*cdf0e10cSrcweir xModuleManager( xMCF->createInstanceWithContext( 454*cdf0e10cSrcweir OUString::createFromAscii( 455*cdf0e10cSrcweir "com.sun.star.frame.ModuleManager" ), 456*cdf0e10cSrcweir xContext ), 457*cdf0e10cSrcweir UNO_QUERY ); 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir OUString aModuleId; 460*cdf0e10cSrcweir try{ 461*cdf0e10cSrcweir aModuleId = xModuleManager->identify( m_xFrame ); 462*cdf0e10cSrcweir }catch(const uno::Exception&) 463*cdf0e10cSrcweir { aModuleId = ::rtl::OUString(); } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir Reference< container::XNameAccess > xNameAccess( 466*cdf0e10cSrcweir xMCF->createInstanceWithContext( 467*cdf0e10cSrcweir OUString::createFromAscii( 468*cdf0e10cSrcweir "com.sun.star.frame.UICommandDescription" ), 469*cdf0e10cSrcweir xContext ), 470*cdf0e10cSrcweir UNO_QUERY ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir if ( xNameAccess.is() ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir xNameAccess->getByName( aModuleId ) >>= m_xModuleCommands; 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir Reference< container::XNameAccess > xAllCategories( 478*cdf0e10cSrcweir xMCF->createInstanceWithContext( 479*cdf0e10cSrcweir OUString::createFromAscii( 480*cdf0e10cSrcweir "com.sun.star.ui.UICategoryDescription" ), 481*cdf0e10cSrcweir xContext ), 482*cdf0e10cSrcweir UNO_QUERY ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir Reference< container::XNameAccess > xModuleCategories; 485*cdf0e10cSrcweir if ( xAllCategories.is() ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir if ( aModuleId.getLength() != 0 ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir try 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir xModuleCategories = Reference< container::XNameAccess >( 492*cdf0e10cSrcweir xAllCategories->getByName( aModuleId ), UNO_QUERY ); 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir catch ( container::NoSuchElementException& ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir if ( !xModuleCategories.is() ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir xModuleCategories = xAllCategories; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir if ( xModuleCategories.is() ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir Sequence< sal_Int16 > gids = 508*cdf0e10cSrcweir xDIP->getSupportedCommandGroups(); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < gids.getLength(); i++ ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir Sequence< frame::DispatchInformation > commands; 513*cdf0e10cSrcweir try 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir commands = 516*cdf0e10cSrcweir xDIP->getConfigurableDispatchInformation( gids[i] ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir catch ( container::NoSuchElementException& ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir continue; 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir if ( commands.getLength() == 0 ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir continue; 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir sal_Int32 gid = gids[i]; 529*cdf0e10cSrcweir OUString idx = OUString::valueOf( gid ); 530*cdf0e10cSrcweir OUString group = idx; 531*cdf0e10cSrcweir try 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir xModuleCategories->getByName( idx ) >>= group; 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir catch ( container::NoSuchElementException& ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir SvLBoxEntry *pEntry = InsertEntry( group, NULL ); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir SvxGroupInfo_Impl *pInfo = 542*cdf0e10cSrcweir new SvxGroupInfo_Impl( SVX_CFGGROUP_FUNCTION, gids[i] ); 543*cdf0e10cSrcweir aArr.Insert( pInfo, aArr.Count() ); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir pEntry->SetUserData( pInfo ); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir if ( xContext.is() ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir // Add Scripting Framework entries 553*cdf0e10cSrcweir Reference< browse::XBrowseNode > rootNode; 554*cdf0e10cSrcweir Reference< XComponentContext> xCtx; 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir try 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir Reference < beans::XPropertySet > _xProps( 559*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); 560*cdf0e10cSrcweir xCtx.set( _xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW ); 561*cdf0e10cSrcweir Reference< browse::XBrowseNodeFactory > xFac( xCtx->getValueByName( 562*cdf0e10cSrcweir OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ), UNO_QUERY_THROW ); 563*cdf0e10cSrcweir rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) ); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir catch( const Exception& ) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir if ( rootNode.is() ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir if ( m_bShowSlots ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir SvxGroupInfo_Impl *pInfo = 575*cdf0e10cSrcweir new SvxGroupInfo_Impl( SVX_CFGGROUP_SCRIPTCONTAINER, 0, rootNode ); 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir String aTitle = 578*cdf0e10cSrcweir String( CUI_RES( STR_SELECTOR_MACROS ) ); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir SvLBoxEntry *pNewEntry = InsertEntry( aTitle, NULL ); 581*cdf0e10cSrcweir pNewEntry->SetUserData( pInfo ); 582*cdf0e10cSrcweir pNewEntry->EnableChildsOnDemand( sal_True ); 583*cdf0e10cSrcweir aArr.Insert( pInfo, aArr.Count() ); 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir else 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir fillScriptList( rootNode, NULL, false ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir MakeVisible( GetEntry( 0,0 ) ); 592*cdf0e10cSrcweir SetUpdateMode( sal_True ); 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir Image SvxConfigGroupListBox_Impl::GetImage( Reference< browse::XBrowseNode > node, Reference< XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir Image aImage; 598*cdf0e10cSrcweir if ( bIsRootNode ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir if ( node->getName().equalsAscii( "user" ) || node->getName().equalsAscii( "share" ) ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir if( bHighContrast == BMP_COLOR_NORMAL ) 603*cdf0e10cSrcweir aImage = m_hdImage; 604*cdf0e10cSrcweir else 605*cdf0e10cSrcweir aImage = m_hdImage_hc; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir OUString factoryURL; 610*cdf0e10cSrcweir OUString nodeName = node->getName(); 611*cdf0e10cSrcweir Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName ); 612*cdf0e10cSrcweir if ( xDocumentModel.is() ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XModuleManager > 615*cdf0e10cSrcweir xModuleManager( 616*cdf0e10cSrcweir xCtx->getServiceManager() 617*cdf0e10cSrcweir ->createInstanceWithContext( 618*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.frame.ModuleManager"), 619*cdf0e10cSrcweir xCtx ), 620*cdf0e10cSrcweir UNO_QUERY_THROW ); 621*cdf0e10cSrcweir Reference<container::XNameAccess> xModuleConfig( 622*cdf0e10cSrcweir xModuleManager, UNO_QUERY_THROW ); 623*cdf0e10cSrcweir // get the long name of the document: 624*cdf0e10cSrcweir OUString appModule( xModuleManager->identify( 625*cdf0e10cSrcweir xDocumentModel ) ); 626*cdf0e10cSrcweir Sequence<beans::PropertyValue> moduleDescr; 627*cdf0e10cSrcweir Any aAny = xModuleConfig->getByName(appModule); 628*cdf0e10cSrcweir if( sal_True != ( aAny >>= moduleDescr ) ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir throw RuntimeException(OUString::createFromAscii("SFTreeListBox::Init: failed to get PropertyValue"), Reference< XInterface >()); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir beans::PropertyValue const * pmoduleDescr = 633*cdf0e10cSrcweir moduleDescr.getConstArray(); 634*cdf0e10cSrcweir for ( sal_Int32 pos = moduleDescr.getLength(); pos--; ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir if (pmoduleDescr[ pos ].Name.equalsAsciiL( 637*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( 638*cdf0e10cSrcweir "ooSetupFactoryEmptyDocumentURL") )) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir pmoduleDescr[ pos ].Value >>= factoryURL; 641*cdf0e10cSrcweir break; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir if( factoryURL.getLength() > 0 ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir if( bHighContrast == BMP_COLOR_NORMAL ) 648*cdf0e10cSrcweir aImage = SvFileInformationManager::GetFileImage( 649*cdf0e10cSrcweir INetURLObject(factoryURL), false, 650*cdf0e10cSrcweir BMP_COLOR_NORMAL ); 651*cdf0e10cSrcweir else 652*cdf0e10cSrcweir aImage = SvFileInformationManager::GetFileImage( 653*cdf0e10cSrcweir INetURLObject(factoryURL), false, 654*cdf0e10cSrcweir BMP_COLOR_HIGHCONTRAST ); 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir else 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir if( bHighContrast == BMP_COLOR_NORMAL ) 659*cdf0e10cSrcweir aImage = m_docImage; 660*cdf0e10cSrcweir else 661*cdf0e10cSrcweir aImage = m_docImage_hc; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir else 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir if( node->getType() == browse::BrowseNodeTypes::SCRIPT ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if( bHighContrast == BMP_COLOR_NORMAL ) 670*cdf0e10cSrcweir aImage = m_macImage; 671*cdf0e10cSrcweir else 672*cdf0e10cSrcweir aImage = m_macImage_hc; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir else 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir if( bHighContrast == BMP_COLOR_NORMAL ) 677*cdf0e10cSrcweir aImage = m_libImage; 678*cdf0e10cSrcweir else 679*cdf0e10cSrcweir aImage = m_libImage_hc; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir return aImage; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir Reference< XInterface > 686*cdf0e10cSrcweir SvxConfigGroupListBox_Impl::getDocumentModel( 687*cdf0e10cSrcweir Reference< XComponentContext >& xCtx, OUString& docName ) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir Reference< XInterface > xModel; 690*cdf0e10cSrcweir Reference< lang::XMultiComponentFactory > mcf = 691*cdf0e10cSrcweir xCtx->getServiceManager(); 692*cdf0e10cSrcweir Reference< frame::XDesktop > desktop ( 693*cdf0e10cSrcweir mcf->createInstanceWithContext( 694*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx ), 695*cdf0e10cSrcweir UNO_QUERY ); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir Reference< container::XEnumerationAccess > componentsAccess = 698*cdf0e10cSrcweir desktop->getComponents(); 699*cdf0e10cSrcweir Reference< container::XEnumeration > components = 700*cdf0e10cSrcweir componentsAccess->createEnumeration(); 701*cdf0e10cSrcweir while (components->hasMoreElements()) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir Reference< frame::XModel > model( 704*cdf0e10cSrcweir components->nextElement(), UNO_QUERY ); 705*cdf0e10cSrcweir if ( model.is() ) 706*cdf0e10cSrcweir { 707*cdf0e10cSrcweir OUString sTdocUrl = ::comphelper::DocumentInfo::getDocumentTitle( model ); 708*cdf0e10cSrcweir if( sTdocUrl.equals( docName ) ) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir xModel = model; 711*cdf0e10cSrcweir break; 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir return xModel; 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir void SvxConfigGroupListBox_Impl::GroupSelected() 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir SvLBoxEntry *pEntry = FirstSelected(); 721*cdf0e10cSrcweir SvxGroupInfo_Impl *pInfo = (SvxGroupInfo_Impl*) pEntry->GetUserData(); 722*cdf0e10cSrcweir pFunctionListBox->SetUpdateMode(sal_False); 723*cdf0e10cSrcweir pFunctionListBox->ClearAll(); 724*cdf0e10cSrcweir if ( pInfo->nKind != SVX_CFGGROUP_FUNCTION && 725*cdf0e10cSrcweir pInfo->nKind != SVX_CFGGROUP_SCRIPTCONTAINER ) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir pFunctionListBox->SetUpdateMode(sal_True); 728*cdf0e10cSrcweir return; 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir switch ( pInfo->nKind ) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir case SVX_CFGGROUP_FUNCTION : 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir SvLBoxEntry *_pEntry = FirstSelected(); 736*cdf0e10cSrcweir if ( _pEntry != NULL ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir SvxGroupInfo_Impl *_pInfo = 739*cdf0e10cSrcweir (SvxGroupInfo_Impl*) _pEntry->GetUserData(); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir Reference< frame::XDispatchInformationProvider > xDIP( 742*cdf0e10cSrcweir m_xFrame, UNO_QUERY ); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir Sequence< frame::DispatchInformation > commands; 745*cdf0e10cSrcweir try 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir commands = xDIP->getConfigurableDispatchInformation( 748*cdf0e10cSrcweir _pInfo->nOrd ); 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir catch ( container::NoSuchElementException& ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < commands.getLength(); i++ ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir if ( commands[i].Command.getLength() == 0 ) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir continue; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir Image aImage; 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir OUString aCmdURL( commands[i].Command ); 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir if ( m_pImageProvider ) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir aImage = m_pImageProvider->GetImage( aCmdURL ); 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir OUString aLabel; 771*cdf0e10cSrcweir try 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir Any a = m_xModuleCommands->getByName( aCmdURL ); 774*cdf0e10cSrcweir Sequence< beans::PropertyValue > aPropSeq; 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir if ( a >>= aPropSeq ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir for ( sal_Int32 k = 0; k < aPropSeq.getLength(); k++ ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir if ( aPropSeq[k].Name.equalsAscii( "Name" ) ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir aPropSeq[k].Value >>= aLabel; 783*cdf0e10cSrcweir break; 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir } 788*cdf0e10cSrcweir catch ( container::NoSuchElementException& ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir if ( aLabel.getLength() == 0 ) 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir aLabel = commands[i].Command; 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir SvLBoxEntry* pFuncEntry = NULL; 798*cdf0e10cSrcweir if ( !!aImage ) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir pFuncEntry = pFunctionListBox->InsertEntry( 801*cdf0e10cSrcweir aLabel, aImage, aImage ); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir else 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir pFuncEntry = pFunctionListBox->InsertEntry( 806*cdf0e10cSrcweir aLabel, NULL ); 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir SvxGroupInfo_Impl *_pGroupInfo = new SvxGroupInfo_Impl( 810*cdf0e10cSrcweir SVX_CFGFUNCTION_SLOT, 123, aCmdURL, ::rtl::OUString() ); 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir pFunctionListBox->aArr.Insert( 813*cdf0e10cSrcweir _pGroupInfo, pFunctionListBox->aArr.Count() ); 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir pFuncEntry->SetUserData( _pGroupInfo ); 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir break; 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir case SVX_CFGGROUP_SCRIPTCONTAINER: 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir Reference< browse::XBrowseNode > rootNode( pInfo->xBrowseNode ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir try { 826*cdf0e10cSrcweir if ( rootNode->hasChildNodes() ) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir Sequence< Reference< browse::XBrowseNode > > children = 829*cdf0e10cSrcweir rootNode->getChildNodes(); 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir for ( long n = 0; n < children.getLength(); n++ ) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir if (!children[n].is()) 834*cdf0e10cSrcweir continue; 835*cdf0e10cSrcweir if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir OUString uri; 838*cdf0e10cSrcweir OUString description; 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY ); 841*cdf0e10cSrcweir if (!xPropSet.is()) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir continue; 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir Any value = 847*cdf0e10cSrcweir xPropSet->getPropertyValue( String::CreateFromAscii( "URI" ) ); 848*cdf0e10cSrcweir value >>= uri; 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir try 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir value = xPropSet->getPropertyValue( 853*cdf0e10cSrcweir String::CreateFromAscii( "Description" ) ); 854*cdf0e10cSrcweir value >>= description; 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir catch (Exception &) { 857*cdf0e10cSrcweir // do nothing, the description will be empty 858*cdf0e10cSrcweir } 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir SvxGroupInfo_Impl* _pGroupInfo = 861*cdf0e10cSrcweir new SvxGroupInfo_Impl( 862*cdf0e10cSrcweir SVX_CFGFUNCTION_SCRIPT, 123, uri, description ); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL ); 865*cdf0e10cSrcweir SvLBoxEntry* pNewEntry = 866*cdf0e10cSrcweir pFunctionListBox->InsertEntry( children[n]->getName(), NULL ); 867*cdf0e10cSrcweir pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL); 868*cdf0e10cSrcweir pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL); 869*cdf0e10cSrcweir aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST ); 870*cdf0e10cSrcweir pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST); 871*cdf0e10cSrcweir pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST); 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir pNewEntry->SetUserData( _pGroupInfo ); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir pFunctionListBox->aArr.Insert( 876*cdf0e10cSrcweir _pGroupInfo, pFunctionListBox->aArr.Count() ); 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir catch (const Exception&) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 885*cdf0e10cSrcweir } 886*cdf0e10cSrcweir break; 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir default: 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir return; 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir 895*cdf0e10cSrcweir if ( pFunctionListBox->GetEntryCount() ) 896*cdf0e10cSrcweir pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) ); 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir pFunctionListBox->SetUpdateMode(sal_True); 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir sal_Bool SvxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent ) 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir sal_Bool bRet = SvTreeListBox::Expand( pParent ); 904*cdf0e10cSrcweir if ( bRet ) 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir // Wieviele Entries k"onnen angezeigt werden ? 907*cdf0e10cSrcweir sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight(); 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir // Wieviele Kinder sollen angezeigt werden ? 910*cdf0e10cSrcweir sal_uLong nChildCount = GetVisibleChildCount( pParent ); 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir // Passen alle Kinder und der parent gleichzeitig in die View ? 913*cdf0e10cSrcweir if ( nChildCount+1 > nEntries ) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir // Wenn nicht, wenigstens parent ganz nach oben schieben 916*cdf0e10cSrcweir MakeVisible( pParent, sal_True ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir else 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir // An welcher relativen ViewPosition steht der aufzuklappende parent 921*cdf0e10cSrcweir SvLBoxEntry *pEntry = GetFirstEntryInView(); 922*cdf0e10cSrcweir sal_uLong nParentPos = 0; 923*cdf0e10cSrcweir while ( pEntry && pEntry != pParent ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir nParentPos++; 926*cdf0e10cSrcweir pEntry = GetNextEntryInView( pEntry ); 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir // Ist unter dem parent noch genug Platz f"ur alle Kinder ? 930*cdf0e10cSrcweir if ( nParentPos + nChildCount + 1 > nEntries ) 931*cdf0e10cSrcweir ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) ); 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir return bRet; 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir void SvxConfigGroupListBox_Impl::RequestingChilds( SvLBoxEntry *pEntry ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir SvxGroupInfo_Impl *pInfo = (SvxGroupInfo_Impl*) pEntry->GetUserData(); 941*cdf0e10cSrcweir pInfo->bWasOpened = sal_True; 942*cdf0e10cSrcweir switch ( pInfo->nKind ) 943*cdf0e10cSrcweir { 944*cdf0e10cSrcweir case SVX_CFGGROUP_SCRIPTCONTAINER: 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir if ( !GetChildCount( pEntry ) ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir Reference< browse::XBrowseNode > rootNode( pInfo->xBrowseNode ) ; 949*cdf0e10cSrcweir fillScriptList( rootNode, pEntry, true /* i30923 */ ); 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir break; 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir default: 955*cdf0e10cSrcweir DBG_ERROR( "Falscher Gruppentyp!" ); 956*cdf0e10cSrcweir break; 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir /* 961*cdf0e10cSrcweir * Implementation of SvxScriptSelectorDialog 962*cdf0e10cSrcweir * 963*cdf0e10cSrcweir * This dialog is used for selecting Slot API commands 964*cdf0e10cSrcweir * and Scripting Framework Scripts. 965*cdf0e10cSrcweir */ 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir SvxScriptSelectorDialog::SvxScriptSelectorDialog( 968*cdf0e10cSrcweir Window* pParent, sal_Bool bShowSlots, const Reference< frame::XFrame >& xFrame ) 969*cdf0e10cSrcweir : 970*cdf0e10cSrcweir ModelessDialog( pParent, CUI_RES( RID_DLG_SCRIPTSELECTOR ) ), 971*cdf0e10cSrcweir aDialogDescription( this, CUI_RES( TXT_SELECTOR_DIALOG_DESCRIPTION ) ), 972*cdf0e10cSrcweir aGroupText( this, CUI_RES( TXT_SELECTOR_CATEGORIES ) ), 973*cdf0e10cSrcweir aCategories( this, CUI_RES( BOX_SELECTOR_CATEGORIES ), bShowSlots, xFrame ), 974*cdf0e10cSrcweir aFunctionText( this, CUI_RES( TXT_SELECTOR_COMMANDS ) ), 975*cdf0e10cSrcweir aCommands( this, CUI_RES( BOX_SELECTOR_COMMANDS ) ), 976*cdf0e10cSrcweir aOKButton( this, CUI_RES( BTN_SELECTOR_OK ) ), 977*cdf0e10cSrcweir aCancelButton( this, CUI_RES( BTN_SELECTOR_CANCEL ) ), 978*cdf0e10cSrcweir aHelpButton( this, CUI_RES( BTN_SELECTOR_HELP ) ), 979*cdf0e10cSrcweir aDescription( this, CUI_RES( GRP_SELECTOR_DESCRIPTION ) ), 980*cdf0e10cSrcweir aDescriptionText( this, CUI_RES( TXT_SELECTOR_DESCRIPTION ) ), 981*cdf0e10cSrcweir m_bShowSlots( bShowSlots ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR(); 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir // If we are showing Slot API commands update labels in the UI, and 987*cdf0e10cSrcweir // enable drag'n'drop 988*cdf0e10cSrcweir if ( m_bShowSlots ) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir aGroupText.SetText( String( ResId( STR_SELECTOR_CATEGORIES, rMgr ) ) ); 991*cdf0e10cSrcweir aOKButton.SetText( String( ResId( STR_SELECTOR_ADD, rMgr ) ) ); 992*cdf0e10cSrcweir aCancelButton.SetText( String( ResId( STR_SELECTOR_CLOSE, rMgr ) ) ); 993*cdf0e10cSrcweir aFunctionText.SetText( String( ResId( STR_SELECTOR_COMMANDS, rMgr ) ) ); 994*cdf0e10cSrcweir SetDialogDescription( 995*cdf0e10cSrcweir String( ResId( STR_SELECTOR_ADD_COMMANDS_DESCRIPTION, rMgr ) ) ); 996*cdf0e10cSrcweir SetText( String( ResId( STR_SELECTOR_ADD_COMMANDS, rMgr ) ) ); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir aCommands.SetDragDropMode( SV_DRAGDROP_APP_COPY ); 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir ResizeControls(); 1002*cdf0e10cSrcweir 1003*cdf0e10cSrcweir aCategories.SetFunctionListBox( &aCommands ); 1004*cdf0e10cSrcweir aCategories.Init(); 1005*cdf0e10cSrcweir // aCategories.Select( aCategories.GetEntry( 0, 0 ) ); 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir aCategories.SetSelectHdl( 1008*cdf0e10cSrcweir LINK( this, SvxScriptSelectorDialog, SelectHdl ) ); 1009*cdf0e10cSrcweir aCommands.SetSelectHdl( LINK( this, SvxScriptSelectorDialog, SelectHdl ) ); 1010*cdf0e10cSrcweir aCommands.SetDoubleClickHdl( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) ); 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir aOKButton.SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) ); 1013*cdf0e10cSrcweir aCancelButton.SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) ); 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir UpdateUI(); 1016*cdf0e10cSrcweir FreeResource(); 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir void SvxScriptSelectorDialog::ResizeControls() 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir Point p, newp; 1022*cdf0e10cSrcweir Size s, news; 1023*cdf0e10cSrcweir long gap; 1024*cdf0e10cSrcweir 1025*cdf0e10cSrcweir sal_uInt16 style = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP | 1026*cdf0e10cSrcweir TEXT_DRAW_LEFT | TEXT_DRAW_WORDBREAK; 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir // get dimensions of dialog instructions control 1029*cdf0e10cSrcweir p = aDialogDescription.GetPosPixel(); 1030*cdf0e10cSrcweir s = aDialogDescription.GetSizePixel(); 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir // get dimensions occupied by text in the control 1033*cdf0e10cSrcweir Rectangle rect = 1034*cdf0e10cSrcweir GetTextRect( Rectangle( p, s ), aDialogDescription.GetText(), style ); 1035*cdf0e10cSrcweir news = rect.GetSize(); 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir // the gap is the difference between the control height and its text height 1038*cdf0e10cSrcweir gap = s.Height() - news.Height(); 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir // resize the dialog instructions control 1041*cdf0e10cSrcweir news = Size( s.Width(), s.Height() - gap ); 1042*cdf0e10cSrcweir aDialogDescription.SetSizePixel( news ); 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir // resize other controls to fill the gap 1045*cdf0e10cSrcweir p = aGroupText.GetPosPixel(); 1046*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1047*cdf0e10cSrcweir aGroupText.SetPosPixel( newp ); 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir p = aCategories.GetPosPixel(); 1050*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1051*cdf0e10cSrcweir aCategories.SetPosPixel( newp ); 1052*cdf0e10cSrcweir s = aCategories.GetSizePixel(); 1053*cdf0e10cSrcweir news = Size( s.Width(), s.Height() + gap ); 1054*cdf0e10cSrcweir aCategories.SetSizePixel( news ); 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir p = aFunctionText.GetPosPixel(); 1057*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1058*cdf0e10cSrcweir aFunctionText.SetPosPixel( newp ); 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir p = aCommands.GetPosPixel(); 1061*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1062*cdf0e10cSrcweir aCommands.SetPosPixel( newp ); 1063*cdf0e10cSrcweir s = aCommands.GetSizePixel(); 1064*cdf0e10cSrcweir news = Size( s.Width(), s.Height() + gap ); 1065*cdf0e10cSrcweir aCommands.SetSizePixel( news ); 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir p = aOKButton.GetPosPixel(); 1068*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1069*cdf0e10cSrcweir aOKButton.SetPosPixel( newp ); 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir p = aCancelButton.GetPosPixel(); 1072*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1073*cdf0e10cSrcweir aCancelButton.SetPosPixel( newp ); 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir p = aHelpButton.GetPosPixel(); 1076*cdf0e10cSrcweir newp = Point( p.X(), p.Y() - gap ); 1077*cdf0e10cSrcweir aHelpButton.SetPosPixel( newp ); 1078*cdf0e10cSrcweir } 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir SvxScriptSelectorDialog::~SvxScriptSelectorDialog() 1081*cdf0e10cSrcweir { 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir IMPL_LINK( SvxScriptSelectorDialog, SelectHdl, Control*, pCtrl ) 1085*cdf0e10cSrcweir { 1086*cdf0e10cSrcweir if ( pCtrl == &aCategories ) 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir aCategories.GroupSelected(); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir else if ( pCtrl == &aCommands ) 1091*cdf0e10cSrcweir { 1092*cdf0e10cSrcweir aCommands.FunctionSelected(); 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir UpdateUI(); 1095*cdf0e10cSrcweir return 0; 1096*cdf0e10cSrcweir } 1097*cdf0e10cSrcweir 1098*cdf0e10cSrcweir IMPL_LINK( SvxScriptSelectorDialog, FunctionDoubleClickHdl, Control*, pCtrl ) 1099*cdf0e10cSrcweir { 1100*cdf0e10cSrcweir (void)pCtrl; 1101*cdf0e10cSrcweir if ( aOKButton.IsEnabled() ) 1102*cdf0e10cSrcweir return ClickHdl( &aOKButton ); 1103*cdf0e10cSrcweir return 0; 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir // Check if command is selected and enable the OK button accordingly 1107*cdf0e10cSrcweir // Grab the help text for this id if available and update the description field 1108*cdf0e10cSrcweir void 1109*cdf0e10cSrcweir SvxScriptSelectorDialog::UpdateUI() 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir OUString url = GetScriptURL(); 1112*cdf0e10cSrcweir if ( url != NULL && url.getLength() != 0 ) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir String rMessage = 1115*cdf0e10cSrcweir aCommands.GetHelpText( aCommands.FirstSelected() ); 1116*cdf0e10cSrcweir aDescriptionText.SetText( rMessage ); 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir aOKButton.Enable( sal_True ); 1119*cdf0e10cSrcweir } 1120*cdf0e10cSrcweir else 1121*cdf0e10cSrcweir { 1122*cdf0e10cSrcweir aDescriptionText.SetText( String() ); 1123*cdf0e10cSrcweir aOKButton.Enable( sal_False ); 1124*cdf0e10cSrcweir } 1125*cdf0e10cSrcweir } 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir IMPL_LINK( SvxScriptSelectorDialog, ClickHdl, Button *, pButton ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir if ( pButton == &aCancelButton ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir // If we are displaying Slot API commands then the dialog is being 1132*cdf0e10cSrcweir // run from Tools/Configure and we should not close it, just hide it 1133*cdf0e10cSrcweir if ( m_bShowSlots == sal_False ) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir EndDialog( RET_CANCEL ); 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir else 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir Hide(); 1140*cdf0e10cSrcweir } 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir else if ( pButton == &aOKButton ) 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir GetAddHdl().Call( this ); 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir // If we are displaying Slot API commands then this the dialog is being 1147*cdf0e10cSrcweir // run from Tools/Configure and we should not close it 1148*cdf0e10cSrcweir if ( m_bShowSlots == sal_False ) 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir EndDialog( RET_OK ); 1151*cdf0e10cSrcweir } 1152*cdf0e10cSrcweir else 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir // Select the next entry in the list if possible 1155*cdf0e10cSrcweir SvLBoxEntry* current = aCommands.FirstSelected(); 1156*cdf0e10cSrcweir SvLBoxEntry* next = aCommands.NextSibling( current ); 1157*cdf0e10cSrcweir 1158*cdf0e10cSrcweir if ( next != NULL ) 1159*cdf0e10cSrcweir { 1160*cdf0e10cSrcweir aCommands.Select( next ); 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir return 0; 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir void 1169*cdf0e10cSrcweir SvxScriptSelectorDialog::SetRunLabel() 1170*cdf0e10cSrcweir { 1171*cdf0e10cSrcweir aOKButton.SetText( String( CUI_RES( STR_SELECTOR_RUN ) ) ); 1172*cdf0e10cSrcweir } 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir void 1175*cdf0e10cSrcweir SvxScriptSelectorDialog::SetDialogDescription( const String& rDescription ) 1176*cdf0e10cSrcweir { 1177*cdf0e10cSrcweir aDialogDescription.SetText( rDescription ); 1178*cdf0e10cSrcweir } 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir String 1181*cdf0e10cSrcweir SvxScriptSelectorDialog::GetScriptURL() const 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir OUString result; 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir SvLBoxEntry *pEntry = const_cast< SvxScriptSelectorDialog* >( this )->aCommands.GetLastSelectedEntry(); 1186*cdf0e10cSrcweir if ( pEntry ) 1187*cdf0e10cSrcweir { 1188*cdf0e10cSrcweir SvxGroupInfo_Impl *pData = (SvxGroupInfo_Impl*) pEntry->GetUserData(); 1189*cdf0e10cSrcweir if ( ( pData->nKind == SVX_CFGFUNCTION_SLOT ) 1190*cdf0e10cSrcweir || ( pData->nKind == SVX_CFGFUNCTION_SCRIPT ) 1191*cdf0e10cSrcweir ) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir result = pData->sURL; 1194*cdf0e10cSrcweir } 1195*cdf0e10cSrcweir } 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir return result; 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir String 1201*cdf0e10cSrcweir SvxScriptSelectorDialog::GetSelectedDisplayName() 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir return aCommands.GetEntryText( aCommands.GetLastSelectedEntry() ); 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir String 1207*cdf0e10cSrcweir SvxScriptSelectorDialog::GetSelectedHelpText() 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir return aCommands.GetHelpText( aCommands.GetLastSelectedEntry() ); 1210*cdf0e10cSrcweir } 1211