xref: /trunk/main/basic/source/inc/sbintern.hxx (revision cdf0e10c)
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 #ifndef _SB_INTERN_HXX
29 #define _SB_INTERN_HXX
30 
31 #include <basic/sbxfac.hxx>
32 #include <unotools/transliterationwrapper.hxx>
33 #include "sb.hxx"
34 
35 namespace utl
36 {
37     class TransliterationWrapper;
38 }
39 class SbUnoFactory;
40 class SbTypeFactory;
41 class SbOLEFactory;
42 class SbFormFactory;
43 class SbiInstance;
44 class SbModule;
45 
46 class SbiFactory : public SbxFactory
47 {
48 public:
49 	virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
50 	virtual SbxObject* CreateObject( const String& );
51 };
52 
53 typedef ::std::vector< String > StringVector;
54 
55 struct SbClassData
56 {
57 	SbxArrayRef		mxIfaces;
58 
59 	// types this module depends on because of use in Dim As New <type>
60 	// needed for initialization order of class modules
61 	StringVector	maRequiredTypes;
62 
63 	SbClassData( void );
64 	~SbClassData( void )
65 		{ clear(); }
66 	void clear( void );
67 };
68 
69 // #115824: Factory class to create class objects (type command)
70 // Implementation: sb.cxx
71 class SbClassFactory : public SbxFactory
72 {
73 	SbxObjectRef	xClassModules;
74 
75 public:
76 	SbClassFactory( void );
77 	virtual ~SbClassFactory();
78 
79 	void AddClassModule( SbModule* pClassModule );
80 	void RemoveClassModule( SbModule* pClassModule );
81 
82 	virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
83 	virtual SbxObject* CreateObject( const String& );
84 
85 	SbModule* FindClass( const String& rClassName );
86 };
87 
88 // Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette
89 class SbErrorStackEntry
90 {
91 public:
92 	SbErrorStackEntry(SbMethodRef aM, xub_StrLen nL, xub_StrLen nC1, xub_StrLen nC2)
93 		: aMethod(aM), nLine(nL), nCol1(nC1), nCol2(nC2) {}
94 	SbMethodRef aMethod;
95 	xub_StrLen nLine;
96 	xub_StrLen nCol1, nCol2;
97 };
98 
99 SV_DECL_PTRARR_DEL(SbErrorStack, SbErrorStackEntry*, 1, 1)
100 
101 
102 
103 struct SbiGlobals
104 {
105 	SbiInstance*	pInst; 			// alle aktiven Runtime-Instanzen
106 	SbiFactory*		pSbFac;			// StarBASIC-Factory
107 	SbUnoFactory*	pUnoFac;		// Factory fuer Uno-Structs bei DIM AS NEW
108 	SbTypeFactory*	pTypeFac;		// Factory for user defined types
109 	SbClassFactory*	pClassFac;		// Factory for user defined classes (based on class modules)
110 	SbOLEFactory*	pOLEFac;		// Factory for OLE types
111 	SbFormFactory*	pFormFac;		// Factory for user forms
112 	SbModule*		pMod;			// aktuell aktives Modul
113 	SbModule*		pCompMod;		// aktuell compiliertes Modul
114 	short			nInst;			// Anzahl BASICs
115 	Link			aErrHdl;		// globaler Error-Handler
116 	Link			aBreakHdl;		// globaler Break-Handler
117 	SbError			nCode;			// aktueller Fehlercode
118 	xub_StrLen		nLine;			// aktuelle Zeile
119 	xub_StrLen		nCol1,nCol2;	// aktuelle Spalten (von,bis)
120 	sal_Bool			bCompiler;		// Flag fuer Compiler-Error
121 	sal_Bool			bGlobalInitErr;	// Beim GlobalInit trat ein Compiler-Fehler auf
122 	sal_Bool			bRunInit;		// sal_True, wenn RunInit vom Basic aktiv ist
123 	String			aErrMsg;		// Puffer fuer GetErrorText()
124 	SbLanguageMode	eLanguageMode;	// Flag fuer Visual-Basic-Script-Modus
125 	SbErrorStack*	pErrStack;		// Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette
126     ::utl::TransliterationWrapper* pTransliterationWrapper;    // For StrComp
127 	sal_Bool			bBlockCompilerError;
128     BasicManager*   pAppBasMgr;
129 	StarBASIC*		pMSOMacroRuntimLib;	// Lib containing MSO Macro Runtime API entry symbols
130 
131 	SbiGlobals();
132 	~SbiGlobals();
133 };
134 
135 // Utility-Makros und -Routinen
136 
137 SbiGlobals* GetSbData();
138 
139 #define	pINST		GetSbData()->pInst
140 #define pMOD		GetSbData()->pMod
141 #define pCMOD		GetSbData()->pCompMod
142 #define pSBFAC		GetSbData()->pSbFac
143 #define pUNOFAC		GetSbData()->pUnoFac
144 #define pTYPEFAC	GetSbData()->pTypeFac
145 #define pCLASSFAC	GetSbData()->pClassFac
146 #define pOLEFAC		GetSbData()->pOLEFac
147 #define pFORMFAC	GetSbData()->pFormFac
148 
149 #endif
150 
151