1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_basic.hxx" 30 #include <tools/shl.hxx> 31 #include <vcl/svapp.hxx> 32 #include <svl/solar.hrc> 33 #include <tools/debug.hxx> 34 #include <vcl/msgbox.hxx> 35 36 #include <basic/sbstar.hxx> 37 #include <basic/basrdll.hxx> 38 #include <basrid.hxx> 39 #include <sb.hrc> 40 41 SttResId::SttResId( sal_uInt32 nId ) : 42 ResId( nId, *((*(BasicDLL**)GetAppData(SHL_BASIC))->GetSttResMgr()) ) 43 { 44 } 45 46 BasResId::BasResId( sal_uInt32 nId ) : 47 ResId( nId, *((*(BasicDLL**)GetAppData(SHL_BASIC))->GetBasResMgr()) ) 48 { 49 } 50 51 BasicDLL::BasicDLL() 52 { 53 *(BasicDLL**)GetAppData(SHL_BASIC) = this; 54 ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); 55 pSttResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(stt), aLocale ); 56 pBasResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(sb), aLocale ); 57 bDebugMode = sal_False; 58 bBreakEnabled = sal_True; 59 } 60 61 BasicDLL::~BasicDLL() 62 { 63 delete pSttResMgr; 64 delete pBasResMgr; 65 } 66 67 void BasicDLL::EnableBreak( sal_Bool bEnable ) 68 { 69 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 70 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 71 if ( pThis ) 72 pThis->bBreakEnabled = bEnable; 73 } 74 75 void BasicDLL::SetDebugMode( sal_Bool bDebugMode ) 76 { 77 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 78 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 79 if ( pThis ) 80 pThis->bDebugMode = bDebugMode; 81 } 82 83 84 void BasicDLL::BasicBreak() 85 { 86 //bJustStopping: Wenn jemand wie wild x-mal STOP drueckt, aber das Basic 87 // nicht schnell genug anhaelt, kommt die Box ggf. oefters... 88 static sal_Bool bJustStopping = sal_False; 89 90 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 91 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 92 if ( pThis ) 93 { 94 if ( StarBASIC::IsRunning() && !bJustStopping && ( pThis->bBreakEnabled || pThis->bDebugMode ) ) 95 { 96 bJustStopping = sal_True; 97 StarBASIC::Stop(); 98 String aMessageStr( BasResId( IDS_SBERR_TERMINATED ) ); 99 InfoBox( 0, aMessageStr ).Execute(); 100 bJustStopping = sal_False; 101 } 102 } 103 } 104 105