xref: /trunk/main/basic/source/inc/image.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*234bd5c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*234bd5c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*234bd5c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*234bd5c5SAndrew Rist  * distributed with this work for additional information
6*234bd5c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*234bd5c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*234bd5c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*234bd5c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*234bd5c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*234bd5c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*234bd5c5SAndrew Rist  * software distributed under the License is distributed on an
15*234bd5c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*234bd5c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*234bd5c5SAndrew Rist  * specific language governing permissions and limitations
18*234bd5c5SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*234bd5c5SAndrew Rist  *************************************************************/
21*234bd5c5SAndrew Rist 
22*234bd5c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SBIMAGE_HXX
25cdf0e10cSrcweir #define _SBIMAGE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sbintern.hxx"
28cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX
29cdf0e10cSrcweir #include <rtl/ustring.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <filefmt.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Diese Klasse liest das vom Compiler erzeugte Image ein und verwaltet
34cdf0e10cSrcweir // den Zugriff auf die einzelnen Elemente.
35cdf0e10cSrcweir 
36cdf0e10cSrcweir struct SbPublicEntry;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class SbiImage {
39cdf0e10cSrcweir     friend class SbiCodeGen;            // Compiler-Klassen, die die private-
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     SbxArrayRef    rTypes;          // User defined types
42cdf0e10cSrcweir     SbxArrayRef    rEnums;          // Enum types
43cdf0e10cSrcweir     sal_uInt32*        pStringOff;      // StringId-Offsets
44cdf0e10cSrcweir     sal_Unicode*   pStrings;        // StringPool
45cdf0e10cSrcweir     char*          pCode;           // Code-Image
46cdf0e10cSrcweir     char*          pLegacyPCode;        // Code-Image
47cdf0e10cSrcweir     sal_Bool           bError;          // sal_True: Fehler
48cdf0e10cSrcweir     sal_uInt16         nFlags;          // Flags (s.u.)
49cdf0e10cSrcweir     short          nStrings;        // Anzahl Strings
50cdf0e10cSrcweir     sal_uInt32         nStringSize;     // Groesse des String-Puffers
51cdf0e10cSrcweir     sal_uInt32         nCodeSize;       // Groesse des Code-Blocks
52cdf0e10cSrcweir     sal_uInt16         nLegacyCodeSize;     // Groesse des Code-Blocks
53cdf0e10cSrcweir     sal_uInt16         nDimBase;        // OPTION BASE-Wert
54cdf0e10cSrcweir     rtl_TextEncoding eCharSet;      // Zeichensatz fuer Strings
55cdf0e10cSrcweir                                     // temporaere Verwaltungs-Variable:
56cdf0e10cSrcweir     short          nStringIdx;      // aktueller String-Index
57cdf0e10cSrcweir     sal_uInt32         nStringOff;      // aktuelle Pos im Stringpuffer
58cdf0e10cSrcweir                                     // Routinen fuer Compiler:
59cdf0e10cSrcweir     void MakeStrings( short );      // StringPool einrichten
60cdf0e10cSrcweir     void AddString( const String& );// String zufuegen
61cdf0e10cSrcweir     void AddCode( char*, sal_uInt32 );  // Codeblock dazu
62cdf0e10cSrcweir     void AddType(SbxObject *);      // User-Type mit aufnehmen
63cdf0e10cSrcweir     void AddEnum(SbxObject *);      // Register enum type
64cdf0e10cSrcweir 
65cdf0e10cSrcweir public:
66cdf0e10cSrcweir     String aName;                   // Makroname
67cdf0e10cSrcweir     ::rtl::OUString aOUSource;      // Quellcode
68cdf0e10cSrcweir     String aComment;                // Kommentar
69cdf0e10cSrcweir     sal_Bool   bInit;                   // sal_True: Init-Code ist gelaufen
70cdf0e10cSrcweir     sal_Bool   bFirstInit;              // sal_True, wenn das Image das erste mal nach
71cdf0e10cSrcweir                                     // dem Compilieren initialisiert wird.
72cdf0e10cSrcweir     SbiImage();
73cdf0e10cSrcweir    ~SbiImage();
74cdf0e10cSrcweir     void Clear();                   // Inhalt loeschen
75cdf0e10cSrcweir     sal_Bool Load( SvStream&, sal_uInt32& nVer );       // Loads image from stream
76cdf0e10cSrcweir                             // nVer is set to version
77cdf0e10cSrcweir                             // of image
78cdf0e10cSrcweir     sal_Bool Load( SvStream& );
79cdf0e10cSrcweir     sal_Bool Save( SvStream&, sal_uInt32 = B_CURVERSION );
IsError()80cdf0e10cSrcweir     sal_Bool IsError()                  { return bError;    }
81cdf0e10cSrcweir 
GetCode() const82cdf0e10cSrcweir     const char* GetCode() const     { return pCode;     }
GetCodeSize() const83cdf0e10cSrcweir     sal_uInt32      GetCodeSize() const { return nCodeSize; }
GetSource32()84cdf0e10cSrcweir     ::rtl::OUString& GetSource32()  { return aOUSource; }
GetBase() const85cdf0e10cSrcweir     sal_uInt16      GetBase() const     { return nDimBase;  }
86cdf0e10cSrcweir     String      GetString( short nId ) const;
87cdf0e10cSrcweir     //const char* GetString( short nId ) const;
88cdf0e10cSrcweir     const SbxObject*  FindType (String aTypeName) const;
89cdf0e10cSrcweir 
GetEnums()90cdf0e10cSrcweir     SbxArrayRef GetEnums()          { return rEnums; }
91cdf0e10cSrcweir 
SetFlag(sal_uInt16 n)92cdf0e10cSrcweir     void        SetFlag( sal_uInt16 n ) { nFlags |= n;      }
GetFlag(sal_uInt16 n) const93cdf0e10cSrcweir     sal_uInt16      GetFlag( sal_uInt16 n ) const { return nFlags & n; }
94cdf0e10cSrcweir     sal_uInt16      CalcLegacyOffset( sal_Int32 nOffset );
95cdf0e10cSrcweir     sal_uInt32      CalcNewOffset( sal_Int16 nOffset );
96cdf0e10cSrcweir     void        ReleaseLegacyBuffer();
97cdf0e10cSrcweir     sal_Bool        ExceedsLegacyLimits();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir };
100cdf0e10cSrcweir 
101cdf0e10cSrcweir #define SBIMG_EXPLICIT      0x0001  // OPTION EXPLICIT ist aktiv
102cdf0e10cSrcweir #define SBIMG_COMPARETEXT   0x0002  // OPTION COMPARE TEXT ist aktiv
103cdf0e10cSrcweir #define SBIMG_INITCODE      0x0004  // Init-Code vorhanden
104cdf0e10cSrcweir #define SBIMG_CLASSMODULE   0x0008  // OPTION ClassModule is active
105cdf0e10cSrcweir 
106cdf0e10cSrcweir #endif
107