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