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 #include <com/sun/star/frame/XDesktop.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp> 32*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 34*cdf0e10cSrcweir #include <basic/basrdll.hxx> 35*cdf0e10cSrcweir #include <tools/urlobj.hxx> 36*cdf0e10cSrcweir #include <svl/macitem.hxx> 37*cdf0e10cSrcweir #include <basic/sbxfac.hxx> 38*cdf0e10cSrcweir #include <basic/sbx.hxx> 39*cdf0e10cSrcweir #include <vcl/gradient.hxx> 40*cdf0e10cSrcweir #include <svl/rectitem.hxx> 41*cdf0e10cSrcweir #include <svl/intitem.hxx> 42*cdf0e10cSrcweir #include <svl/eitem.hxx> 43*cdf0e10cSrcweir #include <basic/sbmod.hxx> 44*cdf0e10cSrcweir #include <svl/whiter.hxx> 45*cdf0e10cSrcweir #include <basic/sbmeth.hxx> 46*cdf0e10cSrcweir #include <basic/sbstar.hxx> 47*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 48*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 49*cdf0e10cSrcweir #include <basic/sbuno.hxx> 50*cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 51*cdf0e10cSrcweir #include <svtools/ehdl.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <unotools/undoopt.hxx> 54*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 55*cdf0e10cSrcweir #include <unotools/useroptions.hxx> 56*cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include <sfx2/appuno.hxx> 59*cdf0e10cSrcweir #include <sfx2/module.hxx> 60*cdf0e10cSrcweir #include "arrdecl.hxx" 61*cdf0e10cSrcweir #include <sfx2/app.hxx> 62*cdf0e10cSrcweir #include "sfxtypes.hxx" 63*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 64*cdf0e10cSrcweir #include <sfx2/msg.hxx> 65*cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 66*cdf0e10cSrcweir #include <sfx2/progress.hxx> 67*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 68*cdf0e10cSrcweir #include <sfx2/objitem.hxx> 69*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 70*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 71*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 72*cdf0e10cSrcweir #include "sfx2/tplpitem.hxx" 73*cdf0e10cSrcweir #include "sfx2/minfitem.hxx" 74*cdf0e10cSrcweir #include "app.hrc" 75*cdf0e10cSrcweir #include <sfx2/evntconf.hxx> 76*cdf0e10cSrcweir #include <sfx2/request.hxx> 77*cdf0e10cSrcweir #include <sfx2/dinfdlg.hxx> 78*cdf0e10cSrcweir #include "appdata.hxx" 79*cdf0e10cSrcweir #include "appbas.hxx" 80*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 81*cdf0e10cSrcweir #include "sfx2/basmgr.hxx" 82*cdf0e10cSrcweir #include "sorgitm.hxx" 83*cdf0e10cSrcweir #include "appbaslib.hxx" 84*cdf0e10cSrcweir #include <basic/basicmanagerrepository.hxx> 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir #define ITEMID_SEARCH SID_SEARCH_ITEM 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir #include <svl/srchitem.hxx> 89*cdf0e10cSrcweir #include <vos/socket.hxx> 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir #define SFX_TYPEMAP 92*cdf0e10cSrcweir #define Selection 93*cdf0e10cSrcweir #include "sfxslots.hxx" 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir using namespace ::com::sun::star; 96*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 97*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 98*cdf0e10cSrcweir using namespace ::com::sun::star::script; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir using ::basic::BasicManagerRepository; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir //======================================================================== 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //------------------------------------------------------------------------ 105*cdf0e10cSrcweir String lcl_GetVersionString(ResMgr* /*pAppData_ImplResMgr*/) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir ::rtl::OUString aDefault; 108*cdf0e10cSrcweir String aVersion( utl::Bootstrap::getBuildIdData( aDefault )); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir if ( aVersion.Len() == 0 ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir DBG_ERROR( "No BUILDID in bootstrap file found" ); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir aVersion.Erase( 0, aVersion.Search( ':' ) + 1 ); 116*cdf0e10cSrcweir aVersion.Erase( aVersion.Search( ')' ) ); 117*cdf0e10cSrcweir return aVersion; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir //========================================================================= 121*cdf0e10cSrcweir sal_uInt16 SfxApplication::SaveBasicManager() const 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir return 0; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //-------------------------------------------------------------------- 127*cdf0e10cSrcweir sal_uInt16 SfxApplication::SaveBasicAndDialogContainer() const 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir if ( pAppData_Impl->pBasicManager->isValid() ) 130*cdf0e10cSrcweir pAppData_Impl->pBasicManager->storeAllLibraries(); 131*cdf0e10cSrcweir return 0; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir //-------------------------------------------------------------------- 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void SfxApplication::RegisterBasicConstants 137*cdf0e10cSrcweir ( 138*cdf0e10cSrcweir const char*, // Prefix vor Konstanten-Namen 139*cdf0e10cSrcweir const SfxConstant*, // Array von <SfxConstant> Instanzen 140*cdf0e10cSrcweir sal_uInt16 // Anahl der Kontanten in pConsts 141*cdf0e10cSrcweir ) 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir /* [Beschreibung] 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir Diese Methode meldet Konstanten beim BASIC an. Sie sollte on-demand 146*cdf0e10cSrcweir (in GetSbxObject() der Applikation) gerufen werden. Das Array mu\s 147*cdf0e10cSrcweir alphabetisch nach den Namen sortiert sein! 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir Durch den Prefix kann Speicher gespart und das Suchen beschleunigt 150*cdf0e10cSrcweir werden. Im StarOffice soll der Prefix "so" verwendet werden. 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir [Beispiel] 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir const SfxConstant __FAR_DATA aConstants[] = 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir SFX_BOOL_CONSTANT( "False", sal_False ), 158*cdf0e10cSrcweir SFX_BOOL_CONSTANT( "True", sal_True ), 159*cdf0e10cSrcweir }; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir ... 162*cdf0e10cSrcweir SFX_APP()->RegisterBasicConstants( 0, aConstants, 2 ); 163*cdf0e10cSrcweir ... 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir */ 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir // DBG_ASSERT( pAppData_Impl->pBasicMgr, "no basic available" ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // pAppData_Impl->pBasicMgr->GetLib(0)->Insert( 171*cdf0e10cSrcweir // new SfxConstants_Impl( pPrefix, pConsts, nCount ) ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir //-------------------------------------------------------------------- 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir SbxVariable* MakeVariable( StarBASIC *pBas, SbxObject *pObject, 177*cdf0e10cSrcweir const char *pName, sal_uInt32 nSID, SbxDataType eType, SbxClassType eClassType ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir SbxVariable *pVar = pBas->Make( String::CreateFromAscii(pName), eClassType, eType ); //SbxCLASS_PROPERTY 180*cdf0e10cSrcweir pVar->SetUserData( nSID ); 181*cdf0e10cSrcweir pVar->SetFlag( SBX_DONTSTORE ); 182*cdf0e10cSrcweir pObject->StartListening( pVar->GetBroadcaster() ); 183*cdf0e10cSrcweir return pVar; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir //-------------------------------------------------------------------- 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir BasicManager* SfxApplication::GetBasicManager() 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir return BasicManagerRepository::getApplicationBasicManager( true ); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir //-------------------------------------------------------------------- 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir Reference< XLibraryContainer > SfxApplication::GetDialogContainer() 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir if ( !pAppData_Impl->pBasicManager->isValid() ) 198*cdf0e10cSrcweir GetBasicManager(); 199*cdf0e10cSrcweir return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS ); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //-------------------------------------------------------------------- 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir Reference< XLibraryContainer > SfxApplication::GetBasicContainer() 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir if ( !pAppData_Impl->pBasicManager->isValid() ) 207*cdf0e10cSrcweir GetBasicManager(); 208*cdf0e10cSrcweir return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS ); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir //-------------------------------------------------------------------- 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir StarBASIC* SfxApplication::GetBasic() 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir return GetBasicManager()->GetLib(0); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir //------------------------------------------------------------------------- 219*cdf0e10cSrcweir void SfxApplication::PropExec_Impl( SfxRequest &rReq ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir rReq.GetArgs(); 222*cdf0e10cSrcweir sal_uInt16 nSID = rReq.GetSlot(); 223*cdf0e10cSrcweir switch ( nSID ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir case SID_CREATE_BASICOBJECT: 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pItem, SfxStringItem, nSID, sal_False); 228*cdf0e10cSrcweir if ( pItem ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir SbxObject* pObject = SbxBase::CreateObject( pItem->GetValue() ); 231*cdf0e10cSrcweir pObject->AddRef(); 232*cdf0e10cSrcweir //(mba) rReq.SetReturnValue( SfxObjectItem( 0, pObject ) ); 233*cdf0e10cSrcweir rReq.Done(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir break; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir case SID_DELETE_BASICOBJECT: 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pItem, SfxObjectItem, nSID, sal_False); 241*cdf0e10cSrcweir if ( pItem ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir //(mba) SbxObject* pObject = pItem->GetObject(); 244*cdf0e10cSrcweir //(mba) pObject->ReleaseRef(); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir break; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir case SID_ATTR_UNDO_COUNT: 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pCountItem, SfxUInt16Item, nSID, sal_False); 252*cdf0e10cSrcweir SvtUndoOptions().SetUndoCount( pCountItem->GetValue() ); 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir case SID_WIN_VISIBLE: 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir break; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir case SID_STATUSBARTEXT: 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, nSID, sal_False); 264*cdf0e10cSrcweir String aText = pStringItem->GetValue(); 265*cdf0e10cSrcweir if ( aText.Len() ) 266*cdf0e10cSrcweir GetpApp()->ShowStatusText( aText ); 267*cdf0e10cSrcweir else 268*cdf0e10cSrcweir GetpApp()->HideStatusText(); 269*cdf0e10cSrcweir break; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir case SID_OFFICE_PRIVATE_USE: 273*cdf0e10cSrcweir case SID_OFFICE_COMMERCIAL_USE: 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir DBG_ASSERT( sal_False, "SfxApplication::PropExec_Impl()\nSID_OFFICE_PRIVATE_USE & SID_OFFICE_COMMERCIAL_USE are obsolete!\n" ); 276*cdf0e10cSrcweir break; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir case SID_OFFICE_CUSTOMERNUMBER: 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, nSID, sal_False); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if ( pStringItem ) 284*cdf0e10cSrcweir SvtUserOptions().SetCustomerNumber( pStringItem->GetValue() ); 285*cdf0e10cSrcweir break; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir //------------------------------------------------------------------------- 291*cdf0e10cSrcweir void SfxApplication::PropState_Impl( SfxItemSet &rSet ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir // SfxViewFrame *pFrame = SfxViewFrame::Current(); 294*cdf0e10cSrcweir SfxWhichIter aIter(rSet); 295*cdf0e10cSrcweir for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir switch ( nSID ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir case SID_PROGNAME: 300*cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_PROGNAME, GetName() ) ); 301*cdf0e10cSrcweir break; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir case SID_ACTIVEDOCUMENT: 304*cdf0e10cSrcweir rSet.Put( SfxObjectItem( SID_ACTIVEDOCUMENT, SfxObjectShell::Current() ) ); 305*cdf0e10cSrcweir break; 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir case SID_APPLICATION: 308*cdf0e10cSrcweir rSet.Put( SfxObjectItem( SID_APPLICATION, this ) ); 309*cdf0e10cSrcweir break; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir case SID_PROGFILENAME: 312*cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_PROGFILENAME, Application::GetAppFileName() ) ); 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir case SID_ATTR_UNDO_COUNT: 316*cdf0e10cSrcweir rSet.Put( SfxUInt16Item( SID_ATTR_UNDO_COUNT, sal::static_int_cast< sal_uInt16 >( SvtUndoOptions().GetUndoCount() ) ) ); 317*cdf0e10cSrcweir break; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir case SID_UPDATE_VERSION: 320*cdf0e10cSrcweir rSet.Put( SfxUInt32Item( SID_UPDATE_VERSION, SUPD ) ); 321*cdf0e10cSrcweir break; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir case SID_OFFICE_CUSTOMERNUMBER: 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir rSet.Put( SfxStringItem( nSID, SvtUserOptions().GetCustomerNumber() ) ); 326*cdf0e10cSrcweir break; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332