Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/basic/source/inc/sbintern.hxx
Line
Count
Source
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
#pragma once
21
22
#include <basic/sbstar.hxx>
23
#include <sbxfac.hxx>
24
#include "sbunoobj.hxx"
25
#include <unotools/transliterationwrapper.hxx>
26
#include <comphelper/errcode.hxx>
27
#include <config_features.h>
28
#include <optional>
29
30
namespace utl
31
{
32
    class TransliterationWrapper;
33
}
34
class SbiInstance;
35
class SbModule;
36
class BasicManager;
37
38
class SbiFactory final : public SbxFactory
39
{
40
public:
41
    virtual SbxBaseRef Create( sal_uInt16 nSbxId, sal_uInt32 ) override;
42
    virtual SbxObjectRef CreateObject( const OUString& ) override;
43
};
44
45
struct SbClassData
46
{
47
    SbxArrayRef     mxIfaces;
48
49
    // types this module depends on because of use in Dim As New <type>
50
    // needed for initialization order of class modules
51
    std::vector< OUString >    maRequiredTypes;
52
53
    SbClassData();
54
    ~SbClassData()
55
0
        { clear(); }
56
    void clear();
57
};
58
59
// #115824: Factory class to create class objects (type command)
60
// Implementation: sb.cxx
61
class SbClassFactory final : public SbxFactory
62
{
63
    SbxObjectRef    xClassModules;
64
65
public:
66
    SbClassFactory();
67
    virtual ~SbClassFactory() override;
68
69
    void AddClassModule( SbModule* pClassModule );
70
    void RemoveClassModule( SbModule* pClassModule );
71
72
    virtual SbxBaseRef Create( sal_uInt16 nSbxId, sal_uInt32 ) override;
73
    virtual SbxObjectRef CreateObject( const OUString& ) override;
74
75
    SbModule* FindClass( const OUString& rClassName );
76
};
77
78
// Factory class to create user defined objects (type command)
79
class SbTypeFactory final : public SbxFactory
80
{
81
public:
82
    virtual SbxBaseRef Create( sal_uInt16 nSbxId, sal_uInt32 ) override;
83
    virtual SbxObjectRef CreateObject( const OUString& ) override;
84
};
85
86
class SbFormFactory final : public SbxFactory
87
{
88
public:
89
    virtual SbxBaseRef Create( sal_uInt16 nSbxId, sal_uInt32 ) override;
90
    virtual SbxObjectRef CreateObject( const OUString& ) override;
91
};
92
93
// Factory class to create OLE objects
94
class SbOLEFactory final : public SbxFactory
95
{
96
public:
97
    virtual SbxBaseRef Create( sal_uInt16 nSbxId, sal_uInt32 ) override;
98
    virtual SbxObjectRef CreateObject( const OUString& ) override;
99
};
100
101
struct SbiGlobals
102
{
103
    static SbiGlobals* pGlobals;
104
    SbiInstance*    pInst;          // all active runtime instances
105
#if HAVE_FEATURE_SCRIPTING
106
    std::optional<SbiFactory>   pSbFac;    // StarBASIC-Factory
107
    std::optional<SbUnoFactory> pUnoFac;   // Factory for Uno-Structs at DIM AS NEW
108
    std::optional<SbTypeFactory>
109
                    pTypeFac;       // Factory for user defined types
110
    std::unique_ptr<SbClassFactory>
111
                    pClassFac;      // Factory for user defined classes (based on class modules)
112
    std::optional<SbOLEFactory>
113
                    pOLEFac;        // Factory for OLE types
114
    std::optional<SbFormFactory>
115
                    pFormFac;       // Factory for user forms
116
    std::unique_ptr<BasicManager> pAppBasMgr;
117
#endif
118
    SbModule*       pMod;           // currently active module
119
    SbModule*       pCompMod;       // currently compiled module
120
    short           nInst;          // number of BASICs
121
    Link<StarBASIC*,bool>            aErrHdl;        // global error handler
122
    Link<StarBASIC*,BasicDebugFlags> aBreakHdl;      // global break handler
123
    ErrCodeMsg      nCode;
124
    sal_Int32       nLine;
125
    sal_Int32       nCol1,nCol2;    // from... to...
126
    bool            bCompilerError; // flag for compiler error
127
    bool            bGlobalInitErr;
128
    bool            bRunInit;       // true, if RunInit active from the Basic
129
    OUString        aErrMsg;        // buffer for GetErrorText()
130
    std::unique_ptr<::utl::TransliterationWrapper> pTransliterationWrapper;    // For StrComp
131
    bool            bBlockCompilerError;
132
    StarBASIC*      pMSOMacroRuntimLib; // Lib containing MSO Macro Runtime API entry symbols
133
134
    SbiGlobals();
135
    ~SbiGlobals();
136
};
137
138
// utility macros and routines
139
140
SbiGlobals* GetSbData();
141
142
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */