1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_basic.hxx" 26 #include <tools/shl.hxx> 27 #include <vcl/svapp.hxx> 28 #include <svl/solar.hrc> 29 #include <tools/debug.hxx> 30 #include <vcl/msgbox.hxx> 31 32 #include <basic/sbstar.hxx> 33 #include <basic/basrdll.hxx> 34 #include <basrid.hxx> 35 #include <sb.hrc> 36 37 SttResId::SttResId( sal_uInt32 nId ) : 38 ResId( nId, *((*(BasicDLL**)GetAppData(SHL_BASIC))->GetSttResMgr()) ) 39 { 40 } 41 42 BasResId::BasResId( sal_uInt32 nId ) : 43 ResId( nId, *((*(BasicDLL**)GetAppData(SHL_BASIC))->GetBasResMgr()) ) 44 { 45 } 46 47 BasicDLL::BasicDLL() 48 { 49 *(BasicDLL**)GetAppData(SHL_BASIC) = this; 50 ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); 51 pSttResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(stt), aLocale ); 52 pBasResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(sb), aLocale ); 53 bDebugMode = sal_False; 54 bBreakEnabled = sal_True; 55 } 56 57 BasicDLL::~BasicDLL() 58 { 59 delete pSttResMgr; 60 delete pBasResMgr; 61 } 62 63 void BasicDLL::EnableBreak( sal_Bool bEnable ) 64 { 65 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 66 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 67 if ( pThis ) 68 pThis->bBreakEnabled = bEnable; 69 } 70 71 void BasicDLL::SetDebugMode( sal_Bool bDebugMode ) 72 { 73 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 74 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 75 if ( pThis ) 76 pThis->bDebugMode = bDebugMode; 77 } 78 79 80 void BasicDLL::BasicBreak() 81 { 82 //bJustStopping: Wenn jemand wie wild x-mal STOP drueckt, aber das Basic 83 // nicht schnell genug anhaelt, kommt die Box ggf. oefters... 84 static sal_Bool bJustStopping = sal_False; 85 86 BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC); 87 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); 88 if ( pThis ) 89 { 90 if ( StarBASIC::IsRunning() && !bJustStopping && ( pThis->bBreakEnabled || pThis->bDebugMode ) ) 91 { 92 bJustStopping = sal_True; 93 StarBASIC::Stop(); 94 String aMessageStr( BasResId( IDS_SBERR_TERMINATED ) ); 95 InfoBox( 0, aMessageStr ).Execute(); 96 bJustStopping = sal_False; 97 } 98 } 99 } 100 101