LCOV - code coverage report
Current view: top level - basic/source/runtime - basrdll.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 17 37 45.9 %
Date: 2015-06-13 12:38:46 Functions: 7 10 70.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <svl/solar.hrc>
      23             : #include <tools/debug.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <vcl/settings.hxx>
      26             : 
      27             : #include <basic/sbstar.hxx>
      28             : #include <basic/basrdll.hxx>
      29             : #include <basrid.hxx>
      30             : #include <sb.hrc>
      31             : #include <sbxbase.hxx>
      32             : 
      33         156 : struct BasicDLL::Impl
      34             : {
      35             :     bool        bDebugMode;
      36             :     bool        bBreakEnabled;
      37             : 
      38             :     std::unique_ptr<ResMgr> xBasResMgr;
      39             :     std::unique_ptr<SbxAppData> xSbxAppData;
      40             : 
      41         245 :     Impl()
      42             :         : bDebugMode(false)
      43             :         , bBreakEnabled(true)
      44         245 :         , xBasResMgr(ResMgr::CreateResMgr("sb", Application::GetSettings().GetUILanguageTag()))
      45         490 :         , xSbxAppData(new SbxAppData)
      46         245 :     { }
      47             : };
      48             : 
      49          20 : BasResId::BasResId( sal_uInt32 nId ) :
      50          20 :     ResId( nId, *(BASIC_DLL()->GetBasResMgr()) )
      51             : {
      52          20 : }
      53             : 
      54         245 : BasicDLL::BasicDLL()
      55         245 :     : m_xImpl(new Impl)
      56             : {
      57         245 :     BASIC_DLL() = this;
      58         245 : }
      59             : 
      60         156 : BasicDLL::~BasicDLL()
      61             : {
      62         156 : }
      63             : 
      64          57 : ResMgr* BasicDLL::GetBasResMgr() const { return m_xImpl->xBasResMgr.get(); }
      65             : 
      66           0 : void BasicDLL::EnableBreak( bool bEnable )
      67             : {
      68           0 :     BasicDLL* pThis = BASIC_DLL();
      69             :     DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
      70           0 :     if ( pThis )
      71             :     {
      72           0 :         pThis->m_xImpl->bBreakEnabled = bEnable;
      73             :     }
      74           0 : }
      75             : 
      76           0 : void BasicDLL::SetDebugMode( bool bDebugMode )
      77             : {
      78           0 :     BasicDLL* pThis = BASIC_DLL();
      79             :     DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
      80           0 :     if ( pThis )
      81             :     {
      82           0 :         pThis->m_xImpl->bDebugMode = bDebugMode;
      83             :     }
      84           0 : }
      85             : 
      86             : 
      87           0 : void BasicDLL::BasicBreak()
      88             : {
      89           0 :     BasicDLL* pThis = BASIC_DLL();
      90             :     DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
      91           0 :     if ( pThis )
      92             :     {
      93             :         // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
      94             :         // but the Basic doesn't stop early enough, the box might appear more often...
      95             :         static bool bJustStopping = false;
      96           0 :         if (StarBASIC::IsRunning() && !bJustStopping
      97           0 :             && (pThis->m_xImpl->bBreakEnabled || pThis->m_xImpl->bDebugMode))
      98             :         {
      99           0 :             bJustStopping = true;
     100           0 :             StarBASIC::Stop();
     101           0 :             ScopedVclPtr<InfoBox>::Create( nullptr, BasResId(IDS_SBERR_TERMINATED).toString() )->Execute();
     102           0 :             bJustStopping = false;
     103             :         }
     104             :     }
     105           0 : }
     106             : 
     107      446728 : SbxAppData& GetSbxData_Impl()
     108             : {
     109      446728 :     return *BASIC_DLL()->m_xImpl->xSbxAppData;
     110             : }
     111             : 
     112             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11