Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / basic / source / runtime / basrdll.cxx
bloba3145f404979cd67f73e149ff0d4bcd6f24a5329
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <memory>
21 #include <vcl/svapp.hxx>
22 #include <tools/debug.hxx>
23 #include <vcl/weld.hxx>
25 #include <basic/sbstar.hxx>
26 #include <basic/basrdll.hxx>
27 #include <strings.hrc>
28 #include <sbxbase.hxx>
29 #include <config_features.h>
31 struct BasicDLL::Impl
33 bool bDebugMode;
34 bool bBreakEnabled;
36 std::unique_ptr<SbxAppData> xSbxAppData;
38 Impl()
39 : bDebugMode(false)
40 , bBreakEnabled(true)
41 , xSbxAppData(new SbxAppData)
42 { }
45 namespace {
47 BasicDLL * BASIC_DLL;
51 BasicDLL::BasicDLL()
52 : m_xImpl(new Impl)
54 BASIC_DLL = this;
57 BasicDLL::~BasicDLL()
61 void BasicDLL::EnableBreak( bool bEnable )
63 BasicDLL* pThis = BASIC_DLL;
64 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
65 if ( pThis )
67 pThis->m_xImpl->bBreakEnabled = bEnable;
71 void BasicDLL::SetDebugMode( bool bDebugMode )
73 BasicDLL* pThis = BASIC_DLL;
74 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
75 if ( pThis )
77 pThis->m_xImpl->bDebugMode = bDebugMode;
82 void BasicDLL::BasicBreak()
84 BasicDLL* pThis = BASIC_DLL;
85 DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
86 #if HAVE_FEATURE_SCRIPTING
87 if ( pThis )
89 // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
90 // but the Basic doesn't stop early enough, the box might appear more often...
91 static bool bJustStopping = false;
92 if (StarBASIC::IsRunning() && !bJustStopping
93 && (pThis->m_xImpl->bBreakEnabled || pThis->m_xImpl->bDebugMode))
95 bJustStopping = true;
96 StarBASIC::Stop();
97 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
98 VclMessageType::Info, VclButtonsType::Ok,
99 BasResId(IDS_SBERR_TERMINATED)));
100 xInfoBox->run();
101 bJustStopping = false;
104 #endif
107 SbxAppData& GetSbxData_Impl()
109 return *BASIC_DLL->m_xImpl->xSbxAppData;
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */