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 : #ifndef INCLUDED_BASIC_SOURCE_INC_IMAGE_HXX
21 : #define INCLUDED_BASIC_SOURCE_INC_IMAGE_HXX
22 :
23 : #include "sbintern.hxx"
24 : #include <rtl/ustring.hxx>
25 : #include <filefmt.hxx>
26 :
27 : // This class reads in the image that's been produced by the compiler
28 : // and manages the access to the single elements.
29 :
30 : class SbiImage {
31 : friend class SbiCodeGen; // compiler classes, that the private-
32 :
33 : SbxArrayRef rTypes; // User defined types
34 : SbxArrayRef rEnums; // Enum types
35 : sal_uInt32* pStringOff; // StringId-Offsets
36 : sal_Unicode* pStrings; // StringPool
37 : char* pCode; // Code-Image
38 : char* pLegacyPCode; // Code-Image
39 : bool bError;
40 : sal_uInt16 nFlags;
41 : short nStrings;
42 : sal_uInt32 nStringSize;
43 : sal_uInt32 nCodeSize;
44 : sal_uInt16 nLegacyCodeSize;
45 : sal_uInt16 nDimBase; // OPTION BASE value
46 : rtl_TextEncoding eCharSet;
47 : // temporary management-variable:
48 : short nStringIdx;
49 : sal_uInt32 nStringOff; // current Pos in the stringbuffer
50 : // routines for the compiler:
51 : void MakeStrings( short ); // establish StringPool
52 : void AddString( const OUString& );
53 : void AddCode( char*, sal_uInt32 );
54 : void AddType(SbxObject *);
55 : void AddEnum(SbxObject *);
56 :
57 : public:
58 : OUString aName; // macro name
59 : OUString aOUSource; // source code
60 : OUString aComment;
61 : bool bInit;
62 : bool bFirstInit;
63 :
64 : SbiImage();
65 : ~SbiImage();
66 : void Clear();
67 : bool Load( SvStream&, sal_uInt32& nVer );
68 : // nVer is set to version
69 : // of image
70 : bool Save( SvStream&, sal_uInt32 = B_CURVERSION );
71 0 : bool IsError() { return bError; }
72 :
73 0 : const char* GetCode() const { return pCode; }
74 0 : sal_uInt32 GetCodeSize() const { return nCodeSize; }
75 : OUString& GetSource32() { return aOUSource; }
76 0 : sal_uInt16 GetBase() const { return nDimBase; }
77 : OUString GetString( short nId ) const;
78 : const SbxObject* FindType (const OUString& aTypeName) const;
79 :
80 0 : SbxArrayRef GetEnums() { return rEnums; }
81 :
82 0 : void SetFlag( sal_uInt16 n ) { nFlags |= n; }
83 0 : sal_uInt16 GetFlag( sal_uInt16 n ) const { return nFlags & n; }
84 : sal_uInt16 CalcLegacyOffset( sal_Int32 nOffset );
85 : sal_uInt32 CalcNewOffset( sal_Int16 nOffset );
86 : void ReleaseLegacyBuffer();
87 : bool ExceedsLegacyLimits();
88 : };
89 :
90 : #define SBIMG_EXPLICIT 0x0001 // OPTION EXPLICIT is active
91 : #define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT is active
92 : #define SBIMG_INITCODE 0x0004 // Init-Code does exist
93 : #define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active
94 :
95 : #endif
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|