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