xref: /trunk/main/basic/source/inc/image.hxx (revision 234bd5c5)
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 #ifndef _SBIMAGE_HXX
25 #define _SBIMAGE_HXX
26 
27 #include "sbintern.hxx"
28 #ifndef _RTL_USTRING_HXX
29 #include <rtl/ustring.hxx>
30 #endif
31 #include <filefmt.hxx>
32 
33 // Diese Klasse liest das vom Compiler erzeugte Image ein und verwaltet
34 // den Zugriff auf die einzelnen Elemente.
35 
36 struct SbPublicEntry;
37 
38 class SbiImage {
39 	friend class SbiCodeGen;			// Compiler-Klassen, die die private-
40 
41 	SbxArrayRef    rTypes;			// User defined types
42 	SbxArrayRef    rEnums;			// Enum types
43 	sal_uInt32*		   pStringOff;		// StringId-Offsets
44 	sal_Unicode*   pStrings;		// StringPool
45 	char* 		   pCode;			// Code-Image
46 	char* 		   pLegacyPCode;		// Code-Image
47 	sal_Bool		   bError;			// sal_True: Fehler
48 	sal_uInt16		   nFlags;			// Flags (s.u.)
49 	short		   nStrings;   		// Anzahl Strings
50 	sal_uInt32		   nStringSize;		// Groesse des String-Puffers
51 	sal_uInt32		   nCodeSize;		// Groesse des Code-Blocks
52 	sal_uInt16		   nLegacyCodeSize;		// Groesse des Code-Blocks
53 	sal_uInt16		   nDimBase;		// OPTION BASE-Wert
54 	rtl_TextEncoding eCharSet;		// Zeichensatz fuer Strings
55 									// temporaere Verwaltungs-Variable:
56 	short		   nStringIdx;		// aktueller String-Index
57 	sal_uInt32		   nStringOff;		// aktuelle Pos im Stringpuffer
58 									// Routinen fuer Compiler:
59 	void MakeStrings( short );		// StringPool einrichten
60 	void AddString( const String& );// String zufuegen
61 	void AddCode( char*, sal_uInt32 );	// Codeblock dazu
62 	void AddType(SbxObject *);      // User-Type mit aufnehmen
63 	void AddEnum(SbxObject *);      // Register enum type
64 
65 public:
66 	String aName;					// Makroname
67     ::rtl::OUString aOUSource;		// Quellcode
68 	String aComment;				// Kommentar
69 	sal_Bool   bInit;					// sal_True: Init-Code ist gelaufen
70 	sal_Bool   bFirstInit;      		// sal_True, wenn das Image das erste mal nach
71                                     // dem Compilieren initialisiert wird.
72 	SbiImage();
73    ~SbiImage();
74 	void Clear();					// Inhalt loeschen
75 	sal_Bool Load( SvStream&, sal_uInt32& nVer );		// Loads image from stream
76 							// nVer is set to version
77 							// of image
78 	sal_Bool Load( SvStream& );
79 	sal_Bool Save( SvStream&, sal_uInt32 = B_CURVERSION );
IsError()80 	sal_Bool IsError() 					{ return bError;    }
81 
GetCode() const82 	const char* GetCode() const 	{ return pCode; 	}
GetCodeSize() const83 	sal_uInt32		GetCodeSize() const	{ return nCodeSize;	}
GetSource32()84     ::rtl::OUString& GetSource32() 	{ return aOUSource; }
GetBase() const85 	sal_uInt16		GetBase() const		{ return nDimBase;	}
86 	String		GetString( short nId ) const;
87 	//const char* GetString( short nId ) const;
88 	const SbxObject*  FindType (String aTypeName) const;
89 
GetEnums()90 	SbxArrayRef GetEnums()			{ return rEnums; }
91 
SetFlag(sal_uInt16 n)92 	void		SetFlag( sal_uInt16 n )	{ nFlags |= n;		}
GetFlag(sal_uInt16 n) const93 	sal_uInt16		GetFlag( sal_uInt16 n )	const { return nFlags & n; }
94 	sal_uInt16		CalcLegacyOffset( sal_Int32 nOffset );
95 	sal_uInt32		CalcNewOffset( sal_Int16 nOffset );
96 	void		ReleaseLegacyBuffer();
97 	sal_Bool		ExceedsLegacyLimits();
98 
99 };
100 
101 #define	SBIMG_EXPLICIT		0x0001	// OPTION EXPLICIT ist aktiv
102 #define	SBIMG_COMPARETEXT	0x0002	// OPTION COMPARE TEXT ist aktiv
103 #define	SBIMG_INITCODE		0x0004	// Init-Code vorhanden
104 #define	SBIMG_CLASSMODULE	0x0008	// OPTION ClassModule is active
105 
106 #endif
107