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_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #if defined UNX 32*cdf0e10cSrcweir #include <limits.h> 33*cdf0e10cSrcweir #else // UNX 34*cdf0e10cSrcweir #include <stdlib.h> 35*cdf0e10cSrcweir #define PATH_MAX _MAX_PATH 36*cdf0e10cSrcweir #endif // UNX 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <sfx2/app.hxx> 39*cdf0e10cSrcweir #include <sfx2/frame.hxx> 40*cdf0e10cSrcweir #include <vos/process.hxx> 41*cdf0e10cSrcweir #include <tools/simplerm.hxx> 42*cdf0e10cSrcweir #include <tools/config.hxx> 43*cdf0e10cSrcweir #include <basic/basrdll.hxx> 44*cdf0e10cSrcweir #include <basic/sbmeth.hxx> 45*cdf0e10cSrcweir #include <basic/sbmod.hxx> 46*cdf0e10cSrcweir #include <svtools/asynclink.hxx> 47*cdf0e10cSrcweir #include <svl/stritem.hxx> 48*cdf0e10cSrcweir #include <vcl/sound.hxx> 49*cdf0e10cSrcweir #include <svl/eitem.hxx> 50*cdf0e10cSrcweir #include <svl/urlbmk.hxx> 51*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52*cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 53*cdf0e10cSrcweir #include <svtools/ehdl.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <svl/svdde.hxx> 56*cdf0e10cSrcweir #include <tools/urlobj.hxx> 57*cdf0e10cSrcweir #include <unotools/tempfile.hxx> 58*cdf0e10cSrcweir #include <osl/file.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 61*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 64*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 65*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 66*cdf0e10cSrcweir #include <com/sun/star/frame/XFrameActionListener.hpp> 67*cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 68*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 69*cdf0e10cSrcweir #include <com/sun/star/frame/FrameActionEvent.hpp> 70*cdf0e10cSrcweir #include <com/sun/star/frame/FrameAction.hpp> 71*cdf0e10cSrcweir #include <com/sun/star/loader/XImplementationLoader.hpp> 72*cdf0e10cSrcweir #include <com/sun/star/loader/CannotActivateFactoryException.hpp> 73*cdf0e10cSrcweir #include <com/sun/star/mozilla/XPluginInstance.hpp> 74*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp> 75*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 76*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 77*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 78*cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp> 79*cdf0e10cSrcweir #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp> 80*cdf0e10cSrcweir #include <basic/basmgr.hxx> 81*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 82*cdf0e10cSrcweir #include <vcl/svapp.hxx> 83*cdf0e10cSrcweir #include <rtl/logfile.hxx> 84*cdf0e10cSrcweir #include <sfx2/appuno.hxx> 85*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 86*cdf0e10cSrcweir #include <sfx2/request.hxx> 87*cdf0e10cSrcweir #include "sfxtypes.hxx" 88*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 89*cdf0e10cSrcweir #include "arrdecl.hxx" 90*cdf0e10cSrcweir #include <sfx2/progress.hxx> 91*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 92*cdf0e10cSrcweir #include <sfx2/docfac.hxx> 93*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 94*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 95*cdf0e10cSrcweir #include "fltfnc.hxx" 96*cdf0e10cSrcweir #include "nfltdlg.hxx" 97*cdf0e10cSrcweir #include <sfx2/new.hxx> 98*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 99*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 100*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 101*cdf0e10cSrcweir #include <sfx2/genlink.hxx> 102*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 103*cdf0e10cSrcweir #include "appdata.hxx" 104*cdf0e10cSrcweir #include "openflag.hxx" 105*cdf0e10cSrcweir #include "app.hrc" 106*cdf0e10cSrcweir #include "virtmenu.hxx" 107*cdf0e10cSrcweir #include <sfx2/module.hxx> 108*cdf0e10cSrcweir #include <sfx2/event.hxx> 109*cdf0e10cSrcweir #include "imestatuswindow.hxx" 110*cdf0e10cSrcweir #include "workwin.hxx" 111*cdf0e10cSrcweir #include <sfx2/module.hxx> 112*cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx> 113*cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx> 114*cdf0e10cSrcweir #include "sfx2/stbitem.hxx" 115*cdf0e10cSrcweir #include "eventsupplier.hxx" 116*cdf0e10cSrcweir #include <sfx2/dockwin.hxx> 117*cdf0e10cSrcweir #include <tools/svlibrary.hxx> 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir #ifdef DBG_UTIL 120*cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx> 121*cdf0e10cSrcweir #include <sfx2/mnuitem.hxx> 122*cdf0e10cSrcweir #endif 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir #if defined( WNT ) || defined( OS2 ) 125*cdf0e10cSrcweir #define DDE_AVAILABLE 126*cdf0e10cSrcweir #endif 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir #include <unotools/saveopt.hxx> 129*cdf0e10cSrcweir #include <unotools/undoopt.hxx> 130*cdf0e10cSrcweir #include <svtools/helpopt.hxx> 131*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 132*cdf0e10cSrcweir #include <unotools/viewoptions.hxx> 133*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 134*cdf0e10cSrcweir #include <unotools/historyoptions.hxx> 135*cdf0e10cSrcweir #include <svtools/menuoptions.hxx> 136*cdf0e10cSrcweir #include <svtools/miscopt.hxx> 137*cdf0e10cSrcweir #include <unotools/useroptions.hxx> 138*cdf0e10cSrcweir #include <unotools/startoptions.hxx> 139*cdf0e10cSrcweir #include <unotools/securityoptions.hxx> 140*cdf0e10cSrcweir #include <unotools/localisationoptions.hxx> 141*cdf0e10cSrcweir #include <unotools/inetoptions.hxx> 142*cdf0e10cSrcweir #include <unotools/fontoptions.hxx> 143*cdf0e10cSrcweir #include <unotools/internaloptions.hxx> 144*cdf0e10cSrcweir #include <unotools/workingsetoptions.hxx> 145*cdf0e10cSrcweir #include <unotools/syslocaleoptions.hxx> 146*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 147*cdf0e10cSrcweir #include <framework/addonsoptions.hxx> 148*cdf0e10cSrcweir #include <svtools/ttprops.hxx> 149*cdf0e10cSrcweir #include <unotools/extendedsecurityoptions.hxx> 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir using namespace ::com::sun::star; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // Static member 154*cdf0e10cSrcweir SfxApplication* SfxApplication::pApp = NULL; 155*cdf0e10cSrcweir static BasicDLL* pBasic = NULL; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir class SfxPropertyHandler : public PropertyHandler 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir virtual void Property( ApplicationProperty& ); 160*cdf0e10cSrcweir }; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir static SfxPropertyHandler* pPropertyHandler = 0; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir SfxPropertyHandler* GetOrCreatePropertyHandler() 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if ( !pPropertyHandler ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 169*cdf0e10cSrcweir if ( !pPropertyHandler ) 170*cdf0e10cSrcweir pPropertyHandler = new SfxPropertyHandler; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir return pPropertyHandler; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir void SfxPropertyHandler::Property( ApplicationProperty& rProp ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir TTProperties* pTTProperties = PTR_CAST( TTProperties, &rProp ); 179*cdf0e10cSrcweir if ( pTTProperties ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir pTTProperties->nPropertyVersion = TT_PROPERTIES_VERSION; 182*cdf0e10cSrcweir switch ( pTTProperties->nActualPR ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir case TT_PR_SLOTS: 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pTTProperties->nSidOpenUrl = SID_OPENURL; 187*cdf0e10cSrcweir pTTProperties->nSidFileName = SID_FILE_NAME; 188*cdf0e10cSrcweir pTTProperties->nSidNewDocDirect = SID_NEWDOCDIRECT; 189*cdf0e10cSrcweir pTTProperties->nSidCopy = SID_COPY; 190*cdf0e10cSrcweir pTTProperties->nSidPaste = SID_PASTE; 191*cdf0e10cSrcweir pTTProperties->nSidSourceView = SID_SOURCEVIEW; 192*cdf0e10cSrcweir pTTProperties->nSidSelectAll = SID_SELECTALL; 193*cdf0e10cSrcweir pTTProperties->nSidReferer = SID_REFERER; 194*cdf0e10cSrcweir pTTProperties->nActualPR = 0; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir break; 197*cdf0e10cSrcweir case TT_PR_DISPATCHER: 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // interface for TestTool 200*cdf0e10cSrcweir SfxViewFrame* pViewFrame=0; 201*cdf0e10cSrcweir SfxDispatcher* pDispatcher=0; 202*cdf0e10cSrcweir pViewFrame = SfxViewFrame::Current(); 203*cdf0e10cSrcweir if ( !pViewFrame ) 204*cdf0e10cSrcweir pViewFrame = SfxViewFrame::GetFirst(); 205*cdf0e10cSrcweir if ( pViewFrame ) 206*cdf0e10cSrcweir pDispatcher = pViewFrame->GetDispatcher(); 207*cdf0e10cSrcweir else 208*cdf0e10cSrcweir pDispatcher = NULL; 209*cdf0e10cSrcweir if ( !pDispatcher ) 210*cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NODISPATCHER; 211*cdf0e10cSrcweir else 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir pDispatcher->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON); 214*cdf0e10cSrcweir if ( pTTProperties->mnSID == SID_NEWDOCDIRECT 215*cdf0e10cSrcweir || pTTProperties->mnSID == SID_OPENDOC ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir SfxPoolItem** pArgs = pTTProperties->mppArgs; 218*cdf0e10cSrcweir SfxAllItemSet aSet( SFX_APP()->GetPool() ); 219*cdf0e10cSrcweir if ( pArgs && *pArgs ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir for ( SfxPoolItem **pArg = pArgs; *pArg; ++pArg ) 222*cdf0e10cSrcweir aSet.Put( **pArg ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir if ( pTTProperties->mnSID == SID_NEWDOCDIRECT ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir String aFactory = String::CreateFromAscii("private:factory/"); 227*cdf0e10cSrcweir if ( pArgs && *pArgs ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir SFX_ITEMSET_ARG( &aSet, pFactoryName, SfxStringItem, SID_NEWDOCDIRECT, sal_False ); 230*cdf0e10cSrcweir if ( pFactoryName ) 231*cdf0e10cSrcweir aFactory += pFactoryName->GetValue(); 232*cdf0e10cSrcweir else 233*cdf0e10cSrcweir aFactory += String::CreateFromAscii("swriter"); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir else 236*cdf0e10cSrcweir aFactory += String::CreateFromAscii("swriter"); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir aSet.Put( SfxStringItem( SID_FILE_NAME, aFactory ) ); 239*cdf0e10cSrcweir aSet.ClearItem( SID_NEWDOCDIRECT ); 240*cdf0e10cSrcweir pTTProperties->mnSID = SID_OPENDOC; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir aSet.Put( SfxStringItem( SID_TARGETNAME, DEFINE_CONST_UNICODE("_blank") ) ); 244*cdf0e10cSrcweir if ( pDispatcher->ExecuteFunction( pTTProperties->mnSID, aSet, pTTProperties->mnMode ) 245*cdf0e10cSrcweir == EXECUTE_NO ) 246*cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE; 247*cdf0e10cSrcweir else 248*cdf0e10cSrcweir pTTProperties->nActualPR = 0; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ( pDispatcher->ExecuteFunction( 253*cdf0e10cSrcweir pTTProperties->mnSID, pTTProperties->mppArgs, pTTProperties->mnMode ) 254*cdf0e10cSrcweir == EXECUTE_NO ) 255*cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE; 256*cdf0e10cSrcweir else 257*cdf0e10cSrcweir pTTProperties->nActualPR = 0; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir break; 262*cdf0e10cSrcweir /* 263*cdf0e10cSrcweir case TT_PR_IMG: 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir SvDataMemberObjectRef aDataObject = new SvDataMemberObject(); 266*cdf0e10cSrcweir SvData* pDataBmp = new SvData( FORMAT_BITMAP ); 267*cdf0e10cSrcweir pDataBmp->SetData( pTTProperties->mpBmp ); 268*cdf0e10cSrcweir aDataObject->Append( pDataBmp ); 269*cdf0e10cSrcweir aDataObject->CopyClipboard(); 270*cdf0e10cSrcweir pTTProperties->nActualPR = 0; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir break; 273*cdf0e10cSrcweir */ 274*cdf0e10cSrcweir default: 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir pTTProperties->nPropertyVersion = 0; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir return; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir #include <framework/imageproducer.hxx> 284*cdf0e10cSrcweir #include <framework/acceleratorinfo.hxx> 285*cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx> 286*cdf0e10cSrcweir #include "sfx2/imagemgr.hxx" 287*cdf0e10cSrcweir #include "fwkhelper.hxx" 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir ::osl::Mutex SfxApplication::gMutex; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir SfxApplication* SfxApplication::GetOrCreate() 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir // SFX on demand 294*cdf0e10cSrcweir ::osl::MutexGuard aGuard(SfxApplication::gMutex); 295*cdf0e10cSrcweir if ( !pApp ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir SfxApplication *pNew = new SfxApplication; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir //TODO/CLEANUP 300*cdf0e10cSrcweir //ist das Mutex-Handling OK? 301*cdf0e10cSrcweir static ::osl::Mutex aProtector; 302*cdf0e10cSrcweir ::osl::MutexGuard aGuard2( aProtector ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SetApp" ); 305*cdf0e10cSrcweir pApp = pNew; 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir // at the moment a bug may occur when Initialize_Impl returns sal_False, but this is only temporary because all code that may cause such a 308*cdf0e10cSrcweir // fault will be moved outside the SFX 309*cdf0e10cSrcweir pApp->Initialize_Impl(); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir ::framework::SetImageProducer( GetImage ); 312*cdf0e10cSrcweir ::framework::SetRefreshToolbars( RefreshToolbars ); 313*cdf0e10cSrcweir ::framework::SetToolBoxControllerCreator( SfxToolBoxControllerFactory ); 314*cdf0e10cSrcweir ::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory ); 315*cdf0e10cSrcweir ::framework::SetDockingWindowCreator( SfxDockingWindowFactory ); 316*cdf0e10cSrcweir ::framework::SetIsDockingWindowVisible( IsDockingWindowVisible ); 317*cdf0e10cSrcweir ::framework::SetActivateToolPanel( &SfxViewFrame::ActivateToolPanel ); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir SfxHelp* pSfxHelp = new SfxHelp; 320*cdf0e10cSrcweir Application::SetHelp( pSfxHelp ); 321*cdf0e10cSrcweir if ( SvtHelpOptions().IsHelpTips() ) 322*cdf0e10cSrcweir Help::EnableQuickHelp(); 323*cdf0e10cSrcweir else 324*cdf0e10cSrcweir Help::DisableQuickHelp(); 325*cdf0e10cSrcweir if ( SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp() ) 326*cdf0e10cSrcweir Help::EnableBalloonHelp(); 327*cdf0e10cSrcweir else 328*cdf0e10cSrcweir Help::DisableBalloonHelp(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir return pApp; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir SfxApplication::SfxApplication() 334*cdf0e10cSrcweir : pAppData_Impl( 0 ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SfxApplication" ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir SetName( DEFINE_CONST_UNICODE("StarOffice") ); 339*cdf0e10cSrcweir GetpApp()->SetPropertyHandler( GetOrCreatePropertyHandler() ); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir SvtViewOptions::AcquireOptions(); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir pAppData_Impl = new SfxAppData_Impl( this ); 344*cdf0e10cSrcweir pAppData_Impl->UpdateApplicationSettings( SvtMenuOptions().IsEntryHidingEnabled() ); 345*cdf0e10cSrcweir pAppData_Impl->m_xImeStatusWindow->init(); 346*cdf0e10cSrcweir pApp->PreInit(); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ initialize DDE" ); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir #ifdef DDE_AVAILABLE 351*cdf0e10cSrcweir #ifndef DBG_UTIL 352*cdf0e10cSrcweir InitializeDde(); 353*cdf0e10cSrcweir #else 354*cdf0e10cSrcweir if( !InitializeDde() ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir ByteString aStr( "Kein DDE-Service moeglich. Fehler: " ); 357*cdf0e10cSrcweir if( GetDdeService() ) 358*cdf0e10cSrcweir aStr += ByteString::CreateFromInt32(GetDdeService()->GetError()); 359*cdf0e10cSrcweir else 360*cdf0e10cSrcweir aStr += '?'; 361*cdf0e10cSrcweir DBG_ASSERT( sal_False, aStr.GetBuffer() ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir #endif 364*cdf0e10cSrcweir #endif 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir pBasic = new BasicDLL; 367*cdf0e10cSrcweir StarBASIC::SetGlobalErrorHdl( LINK( this, SfxApplication, GlobalBasicErrorHdl_Impl ) ); 368*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "} initialize DDE" ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir SfxApplication::~SfxApplication() 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir OSL_ENSURE( GetObjectShells_Impl().Count() == 0, "Memory leak: some object shells were not removed!" ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir Broadcast( SfxSimpleHint(SFX_HINT_DYING) ); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir SfxModule::DestroyModules_Impl(); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // delete global options 380*cdf0e10cSrcweir SvtViewOptions::ReleaseOptions(); 381*cdf0e10cSrcweir delete pBasic; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir if ( !pAppData_Impl->bDowning ) 384*cdf0e10cSrcweir Deinitialize(); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir delete pAppData_Impl; 387*cdf0e10cSrcweir pApp = 0; 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir //==================================================================== 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir const String& SfxApplication::GetLastDir_Impl() const 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir /* [Beschreibung] 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir Interne Methode, mit der im SFx das zuletzt mit der Methode 397*cdf0e10cSrcweir <SfxApplication::SetLastDir_Impl()> gesetzte Verzeichnis 398*cdf0e10cSrcweir zurueckgegeben wird. 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir Dieses ist i.d.R. das zuletzt durch den SfxFileDialog 401*cdf0e10cSrcweir angesprochene Verzeichnis. 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir [Querverweis] 404*cdf0e10cSrcweir <SfxApplication::SetLastDir_Impl()> 405*cdf0e10cSrcweir */ 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir return pAppData_Impl->aLastDir; 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir const String& SfxApplication::GetLastSaveDirectory() const 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir /* [Beschreibung] 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir Wie <SfxApplication::GetLastDir_Impl()>, nur extern 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir [Querverweis] 418*cdf0e10cSrcweir <SfxApplication::GetLastDir_Impl()> 419*cdf0e10cSrcweir */ 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir return GetLastDir_Impl(); 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir //-------------------------------------------------------------------- 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir void SfxApplication::SetLastDir_Impl 428*cdf0e10cSrcweir ( 429*cdf0e10cSrcweir const String& rNewDir /* kompletter Verzeichnis-Pfad als String */ 430*cdf0e10cSrcweir ) 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir /* [Beschreibung] 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir Interne Methode, mit der ein Verzeichnis-Pfad gesetzt wird, der 435*cdf0e10cSrcweir zuletzt (z.B. durch den SfxFileDialog) angesprochen wurde. 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir [Querverweis] 438*cdf0e10cSrcweir <SfxApplication::GetLastDir_Impl()> 439*cdf0e10cSrcweir */ 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir pAppData_Impl->aLastDir = rNewDir; 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir //-------------------------------------------------------------------- 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void SfxApplication::ResetLastDir() 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir String aEmpty; 450*cdf0e10cSrcweir pAppData_Impl->aLastDir = aEmpty; 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir //-------------------------------------------------------------------- 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir SfxDispatcher* SfxApplication::GetDispatcher_Impl() 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir return pAppData_Impl->pViewFrame? pAppData_Impl->pViewFrame->GetDispatcher(): pAppData_Impl->pAppDispat; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir //-------------------------------------------------------------------- 461*cdf0e10cSrcweir void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir if ( pFrame != pAppData_Impl->pViewFrame ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir // get the containerframes ( if one of the frames is an InPlaceFrame ) 466*cdf0e10cSrcweir SfxViewFrame *pOldContainerFrame = pAppData_Impl->pViewFrame; 467*cdf0e10cSrcweir while ( pOldContainerFrame && pOldContainerFrame->GetParentViewFrame_Impl() ) 468*cdf0e10cSrcweir pOldContainerFrame = pOldContainerFrame->GetParentViewFrame_Impl(); 469*cdf0e10cSrcweir SfxViewFrame *pNewContainerFrame = pFrame; 470*cdf0e10cSrcweir while ( pNewContainerFrame && pNewContainerFrame->GetParentViewFrame_Impl() ) 471*cdf0e10cSrcweir pNewContainerFrame = pNewContainerFrame->GetParentViewFrame_Impl(); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir // DocWinActivate : both frames belong to the same TopWindow 474*cdf0e10cSrcweir // TopWinActivate : both frames belong to different TopWindows 475*cdf0e10cSrcweir // not used anymore! 476*cdf0e10cSrcweir // sal_Bool bDocWinActivate = pOldContainerFrame && pNewContainerFrame && 477*cdf0e10cSrcweir // pOldContainerFrame->GetTopViewFrame() == pNewContainerFrame->GetTopViewFrame(); 478*cdf0e10cSrcweir sal_Bool bTaskActivate = pOldContainerFrame != pNewContainerFrame; 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir if ( pOldContainerFrame ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir if ( bTaskActivate ) 483*cdf0e10cSrcweir NotifyEvent( SfxViewEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_DEACTIVATEDOC), pOldContainerFrame->GetObjectShell(), pOldContainerFrame->GetFrame().GetController() ) ); 484*cdf0e10cSrcweir pOldContainerFrame->DoDeactivate( bTaskActivate, pFrame ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir if( pOldContainerFrame->GetProgress() ) 487*cdf0e10cSrcweir pOldContainerFrame->GetProgress()->Suspend(); 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir pAppData_Impl->pViewFrame = pFrame; 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir //const SfxObjectShell* pSh = pViewFrame ? pViewFrame->GetObjectShell() : 0; 493*cdf0e10cSrcweir //if ( !pSh ) 494*cdf0e10cSrcweir //{ 495*cdf0e10cSrcweir // // otherwise BaseURL is set in activation of document 496*cdf0e10cSrcweir // INetURLObject aObject( SvtPathOptions().GetWorkPath() ); 497*cdf0e10cSrcweir // aObject.setFinalSlash(); 498*cdf0e10cSrcweir // INetURLObject::SetBaseURL( aObject.GetMainURL( INetURLObject::NO_DECODE ) ); 499*cdf0e10cSrcweir //} 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir if( pNewContainerFrame ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir pNewContainerFrame->DoActivate( bTaskActivate ); 504*cdf0e10cSrcweir if ( bTaskActivate && pNewContainerFrame->GetObjectShell() ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir pNewContainerFrame->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame ); 507*cdf0e10cSrcweir NotifyEvent(SfxViewEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_ACTIVATEDOC), pNewContainerFrame->GetObjectShell(), pNewContainerFrame->GetFrame().GetController() ) ); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir SfxProgress *pProgress = pNewContainerFrame->GetProgress(); 511*cdf0e10cSrcweir if ( pProgress ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir if( pProgress->IsSuspended() ) 514*cdf0e10cSrcweir pProgress->Resume(); 515*cdf0e10cSrcweir else 516*cdf0e10cSrcweir pProgress->SetState( pProgress->GetState() ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if ( pAppData_Impl->pViewFrame->GetViewShell() ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir SfxDispatcher* pDisp = pAppData_Impl->pViewFrame->GetDispatcher(); 522*cdf0e10cSrcweir pDisp->Flush(); 523*cdf0e10cSrcweir pDisp->Update_Impl(sal_True); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir // even if the frame actually didn't change, ensure its document is forwarded 529*cdf0e10cSrcweir // to SfxObjectShell::SetCurrentComponent. 530*cdf0e10cSrcweir // Otherwise, the CurrentComponent might not be correct, in case it has meanwhile 531*cdf0e10cSrcweir // been reset to some other document, by some non-SFX component. 532*cdf0e10cSrcweir // #i49133# / 2007-12-19 / frank.schoenheit@sun.com 533*cdf0e10cSrcweir if ( pFrame && pFrame->GetViewShell() ) 534*cdf0e10cSrcweir pFrame->GetViewShell()->SetCurrentDocument(); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir //-------------------------------------------------------------------- 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir short SfxApplication::QuerySave_Impl( SfxObjectShell& rDoc, sal_Bool /*bAutoSave*/ ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir if ( !rDoc.IsModified() ) 542*cdf0e10cSrcweir return RET_NO; 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir String aMsg( SfxResId( STR_ISMODIFIED ) ); 545*cdf0e10cSrcweir aMsg.SearchAndReplaceAscii( "%1", rDoc.GetTitle() ); 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir SfxFrame& rFrame = SfxViewFrame::GetFirst(&rDoc)->GetFrame(); 548*cdf0e10cSrcweir rFrame.Appear(); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir WinBits nBits = WB_YES_NO_CANCEL | WB_DEF_NO; 551*cdf0e10cSrcweir QueryBox aBox( &rFrame.GetWindow(), nBits, aMsg ); 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir return aBox.Execute(); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir //--------------------------------------------------------------------- 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir ResMgr* SfxApplication::CreateResManager( const char *pPrefix ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir String aMgrName = String::CreateFromAscii( pPrefix ); 561*cdf0e10cSrcweir return ResMgr::CreateResMgr(U2S(aMgrName)); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir //--------------------------------------------------------------------- 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir SimpleResMgr* SfxApplication::CreateSimpleResManager() 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir SimpleResMgr *pRet; 569*cdf0e10cSrcweir const AllSettings& rAllSettings = Application::GetSettings(); 570*cdf0e10cSrcweir ::com::sun::star::lang::Locale aLocale = rAllSettings.GetUILocale(); 571*cdf0e10cSrcweir pRet = new SimpleResMgr( CREATEVERSIONRESMGR_NAME(sfx), aLocale ); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir return pRet; 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir //-------------------------------------------------------------------- 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir ResMgr* SfxApplication::GetSfxResManager() 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir return SfxResId::GetResMgr(); 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir //-------------------------------------------------------------------- 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir SimpleResMgr* SfxApplication::GetSimpleResManager() 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir if ( !pAppData_Impl->pSimpleResManager ) 588*cdf0e10cSrcweir pAppData_Impl->pSimpleResManager = CreateSimpleResManager(); 589*cdf0e10cSrcweir return pAppData_Impl->pSimpleResManager; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir //------------------------------------------------------------------------ 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir void SfxApplication::SetProgress_Impl 595*cdf0e10cSrcweir ( 596*cdf0e10cSrcweir SfxProgress *pProgress 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir DBG_ASSERT( ( !pAppData_Impl->pProgress && pProgress ) || 601*cdf0e10cSrcweir ( pAppData_Impl->pProgress && !pProgress ), 602*cdf0e10cSrcweir "Progress acitivation/deacitivation mismatch" ); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( pAppData_Impl->pProgress && pProgress ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir pAppData_Impl->pProgress->Suspend(); 607*cdf0e10cSrcweir pAppData_Impl->pProgress->UnLock(); 608*cdf0e10cSrcweir delete pAppData_Impl->pProgress; 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir pAppData_Impl->pProgress = pProgress; 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir //------------------------------------------------------------------------ 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir sal_uInt16 SfxApplication::GetFreeIndex() 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir return pAppData_Impl->aIndexBitSet.GetFreeIndex()+1; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir //------------------------------------------------------------------------ 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir void SfxApplication::ReleaseIndex(sal_uInt16 i) 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir pAppData_Impl->aIndexBitSet.ReleaseIndex(i-1); 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir //-------------------------------------------------------------------- 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir void SfxApplication::EnterAsynchronCall_Impl() 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir ++pAppData_Impl->nAsynchronCalls; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir //-------------------------------------------------------------------- 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir void SfxApplication::LeaveAsynchronCall_Impl() 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir --pAppData_Impl->nAsynchronCalls; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir //-------------------------------------------------------------------- 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir bool SfxApplication::IsInAsynchronCall_Impl() const 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir return pAppData_Impl->nAsynchronCalls > 0; 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir //-------------------------------------------------------------------- 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir Window* SfxApplication::GetTopWindow() const 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir SfxWorkWindow* pWork = GetWorkWindow_Impl( SfxViewFrame::Current() ); 654*cdf0e10cSrcweir return pWork ? pWork->GetWindow() : NULL; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir //-------------------------------------------------------------------- 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir uno::Reference< task::XStatusIndicator > SfxApplication::GetStatusIndicator() const 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir if ( !pAppData_Impl->pViewFrame ) 662*cdf0e10cSrcweir return uno::Reference< task::XStatusIndicator >(); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir SfxViewFrame *pTop = pAppData_Impl->pViewFrame; 665*cdf0e10cSrcweir while ( pTop->GetParentViewFrame_Impl() ) 666*cdf0e10cSrcweir pTop = pTop->GetParentViewFrame_Impl(); 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir return pTop->GetFrame().GetWorkWindow_Impl()->GetStatusIndicator(); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir SfxTbxCtrlFactArr_Impl& SfxApplication::GetTbxCtrlFactories_Impl() const 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir return *pAppData_Impl->pTbxCtrlFac; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir SfxStbCtrlFactArr_Impl& SfxApplication::GetStbCtrlFactories_Impl() const 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir return *pAppData_Impl->pStbCtrlFac; 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir SfxMenuCtrlFactArr_Impl& SfxApplication::GetMenuCtrlFactories_Impl() const 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir return *pAppData_Impl->pMenuCtrlFac; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir SfxViewFrameArr_Impl& SfxApplication::GetViewFrames_Impl() const 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir return *pAppData_Impl->pViewFrames; 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir SfxViewShellArr_Impl& SfxApplication::GetViewShells_Impl() const 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir return *pAppData_Impl->pViewShells; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir SfxObjectShellArr_Impl& SfxApplication::GetObjectShells_Impl() const 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir return *pAppData_Impl->pObjShells; 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir void SfxApplication::Invalidate( sal_uInt16 nId ) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst(); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) ) 704*cdf0e10cSrcweir Invalidate_Impl( pFrame->GetBindings(), nId ); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir #define DOSTRING( x ) #x 708*cdf0e10cSrcweir #define STRING( x ) DOSTRING( x ) 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir typedef long (SAL_CALL *basicide_handle_basic_error)(void*); 711*cdf0e10cSrcweir typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(void*, sal_Bool, rtl_uString*); 712*cdf0e10cSrcweir typedef void* (SAL_CALL *basicide_macro_organizer)(sal_Int16); 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir extern "C" { static void SAL_CALL thisModule() {} } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir IMPL_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBasic ) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir // get basctl dllname 719*cdf0e10cSrcweir static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // load module 722*cdf0e10cSrcweir oslModule handleMod = osl_loadModuleRelative( 723*cdf0e10cSrcweir &thisModule, aLibName.pData, 0 ); 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir // get symbol 726*cdf0e10cSrcweir ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_handle_basic_error" ) ); 727*cdf0e10cSrcweir basicide_handle_basic_error pSymbol = (basicide_handle_basic_error) osl_getFunctionSymbol( handleMod, aSymbol.pData ); 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir // call basicide_handle_basic_error in basctl 730*cdf0e10cSrcweir long nRet = pSymbol( pStarBasic ); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir return nRet; 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir sal_Bool SfxApplication::IsXScriptURL( const String& rScriptURL ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir sal_Bool result = sal_False; 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir ::com::sun::star::uno::Reference 740*cdf0e10cSrcweir < ::com::sun::star::lang::XMultiServiceFactory > xSMgr = 741*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir ::com::sun::star::uno::Reference 744*cdf0e10cSrcweir < ::com::sun::star::uri::XUriReferenceFactory > 745*cdf0e10cSrcweir xFactory( xSMgr->createInstance( 746*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( 747*cdf0e10cSrcweir "com.sun.star.uri.UriReferenceFactory" ) ), 748*cdf0e10cSrcweir ::com::sun::star::uno::UNO_QUERY ); 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir if ( xFactory.is() ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir try 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir ::com::sun::star::uno::Reference 755*cdf0e10cSrcweir < ::com::sun::star::uri::XVndSunStarScriptUrl > 756*cdf0e10cSrcweir xUrl( xFactory->parse( rScriptURL ), 757*cdf0e10cSrcweir ::com::sun::star::uno::UNO_QUERY ); 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir if ( xUrl.is() ) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir result = sal_True; 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir catch ( ::com::sun::star::uno::RuntimeException& ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir // ignore, will just return FALSE 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir return result; 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir ::rtl::OUString 773*cdf0e10cSrcweir SfxApplication::ChooseScript() 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir ::rtl::OUString aScriptURL; 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 778*cdf0e10cSrcweir if ( pFact ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir OSL_TRACE("create selector dialog"); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); 783*cdf0e10cSrcweir const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL; 784*cdf0e10cSrcweir uno::Reference< frame::XFrame > xFrame( pFrame ? pFrame->GetFrameInterface() : uno::Reference< frame::XFrame >() ); 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir AbstractScriptSelectorDialog* pDlg = 787*cdf0e10cSrcweir pFact->CreateScriptSelectorDialog( NULL, sal_False, xFrame ); 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir OSL_TRACE("done, now exec it"); 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir sal_uInt16 nRet = pDlg->Execute(); 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir OSL_TRACE("has returned"); 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir if ( nRet == RET_OK ) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir aScriptURL = pDlg->GetScriptURL(); 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir delete pDlg; 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir return aScriptURL; 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir void SfxApplication::MacroOrganizer( sal_Int16 nTabId ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir // get basctl dllname 808*cdf0e10cSrcweir static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir // load module 811*cdf0e10cSrcweir oslModule handleMod = osl_loadModuleRelative( 812*cdf0e10cSrcweir &thisModule, aLibName.pData, 0 ); 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir // get symbol 815*cdf0e10cSrcweir ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_macro_organizer" ) ); 816*cdf0e10cSrcweir basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData ); 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir // call basicide_choose_macro in basctl 819*cdf0e10cSrcweir pSymbol( nTabId ); 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir ErrCode SfxApplication::CallBasic( const String& rCode, BasicManager* pMgr, SbxArray* pArgs, SbxValue* pRet ) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir return pMgr->ExecuteMacro( rCode, pArgs, pRet); 825*cdf0e10cSrcweir } 826