LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / basic / source / inc / image.hxx
blobb33009c1e029a94bbfcb86437a9844f600831428
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <basic/sbx.hxx>
23 #include <rtl/ustring.hxx>
24 #include "filefmt.hxx"
25 #include <o3tl/typed_flags_set.hxx>
26 #include <vector>
28 // This class reads in the image that's been produced by the compiler
29 // and manages the access to the single elements.
31 enum class SbiImageFlags
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
39 namespace o3tl
41 template<> struct typed_flags<SbiImageFlags> : is_typed_flags<SbiImageFlags, 0xf> {};
44 class SbiImage {
45 friend class SbiCodeGen; // compiler classes, that the private-
47 SbxArrayRef rTypes; // User defined types
48 SbxArrayRef rEnums; // Enum types
49 std::vector<sal_uInt32> mvStringOffsets; // StringId-Offsets
50 std::unique_ptr<sal_Unicode[]> pStrings; // StringPool
51 std::vector<sal_uInt8> aCode; // Code-Image
52 std::vector<sal_uInt8> aLegacyPCode; // Code-Image
53 bool bError;
54 SbiImageFlags nFlags;
55 sal_uInt32 nStringSize;
56 sal_uInt16 nDimBase; // OPTION BASE value
57 rtl_TextEncoding eCharSet;
58 // temporary management-variable:
59 short nStringIdx;
60 sal_uInt32 nStringOff; // current Pos in the stringbuffer
61 // routines for the compiler:
62 void MakeStrings( short ); // establish StringPool
63 void AddString( const OUString& );
64 void AddCode(std::vector<sal_uInt8>&&);
65 void AddType(SbxObject const *);
66 void AddEnum(SbxObject *);
68 public:
69 OUString aName; // macro name
70 OUString aOUSource; // source code
71 OUString aComment;
72 bool bInit;
73 bool bFirstInit;
75 SbiImage();
76 ~SbiImage();
77 void Clear();
78 bool Load( SvStream&, sal_uInt32& nVer );
79 // nVer is set to version
80 // of image
81 bool Save( SvStream&, sal_uInt32 = B_CURVERSION );
82 bool IsError() const { return bError; }
84 const sal_uInt8* GetCode() const { return aCode.data(); }
85 sal_uInt32 GetCodeSize() const { return aCode.size(); }
86 sal_uInt16 GetBase() const { return nDimBase; }
87 OUString GetString( short nId, SbxDataType *eType = nullptr ) const;
88 const SbxObject* FindType (const OUString& aTypeName) const;
90 const SbxArrayRef& GetEnums() const { return rEnums; }
92 void SetFlag( SbiImageFlags n ) { nFlags |= n; }
93 bool IsFlag( SbiImageFlags n ) const { return bool(nFlags & n); }
94 sal_uInt16 CalcLegacyOffset( sal_Int32 nOffset );
95 sal_uInt32 CalcNewOffset( sal_Int16 nOffset );
96 void ReleaseLegacyBuffer();
97 bool ExceedsLegacyLimits();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */