workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / basic / sbx.hxx
blobeb9007232391703ddad0f0d2bee29c88fd9ec867
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 <config_options.h>
23 #include <tools/ref.hxx>
24 #include <svl/hint.hxx>
26 #include <basic/sbxdef.hxx>
27 #include <basic/sbxobj.hxx>
28 #include <basic/basicdllapi.h>
30 #include <utility>
31 #include <vector>
32 #include <memory>
34 class SvStream;
36 class SfxBroadcaster;
38 // Parameter information
39 struct SbxParamInfo
41 const OUString aName; // Name of the parameter
42 SbxDataType eType; // Data type
43 SbxFlagBits nFlags; // Flag-Bits
44 sal_uInt32 nUserData; // IDs etc.
45 SbxParamInfo( OUString s, SbxDataType t, SbxFlagBits n )
46 : aName(std::move( s )), eType( t ), nFlags( n ), nUserData( 0 ) {}
49 typedef std::vector<std::unique_ptr<SbxParamInfo>> SbxParams;
51 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbxInfo final : public SvRefBase
53 friend class SbxVariable;
54 friend class SbMethod;
56 OUString aComment;
57 OUString aHelpFile;
58 sal_uInt32 nHelpId;
59 SbxParams m_Params;
61 SbxInfo(SbxInfo const&) = delete;
62 void operator=(SbxInfo const&) = delete;
64 void LoadData( SvStream&, sal_uInt16 );
65 void StoreData( SvStream& ) const;
66 virtual ~SbxInfo() override;
67 public:
68 SbxInfo();
69 SbxInfo( OUString , sal_uInt32 );
71 void AddParam( const OUString&, SbxDataType, SbxFlagBits=SbxFlagBits::Read );
72 const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
73 const OUString& GetComment() const { return aComment; }
74 const OUString& GetHelpFile() const { return aHelpFile; }
75 sal_uInt32 GetHelpId() const { return nHelpId; }
77 void SetComment( const OUString& r ) { aComment = r; }
80 class BASIC_DLLPUBLIC SbxHint final : public SfxHint
82 SbxVariable* pVar;
83 public:
84 SbxHint( SfxHintId n, SbxVariable* v ) : SfxHint( n ), pVar( v ) {}
85 SbxVariable* GetVar() const { return pVar; }
88 // SbxArray is an unidimensional, dynamic Array
89 // The variables convert from SbxVariablen. Put()/Insert() into the
90 // declared datatype, if they are not SbxVARIANT.
92 struct SbxVarEntry;
94 class BASIC_DLLPUBLIC SbxArray : public SbxBase
96 // #100883 Method to set method directly to parameter array
97 friend class SbMethod;
98 friend class SbClassModuleObject;
99 friend SbxObjectRef cloneTypeObjectImpl( const SbxObject& rTypeObj );
100 BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
102 std::vector<SbxVarEntry> mVarEntries; // The variables
103 SbxDataType eType; // Data type of the array
105 protected:
106 virtual ~SbxArray() override;
107 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
108 virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override;
110 public:
111 SBX_DECL_PERSIST_NODATA(SBXID_ARRAY,1);
112 SbxArray( SbxDataType=SbxVARIANT );
113 SbxArray( const SbxArray& ) = delete;
114 SbxArray& operator=( const SbxArray& );
115 virtual void Clear() override;
116 sal_uInt32 Count() const;
117 virtual SbxDataType GetType() const override;
118 SbxVariableRef& GetRef(sal_uInt32);
119 SbxVariable* Get(sal_uInt32);
120 void Put(SbxVariable*, sal_uInt32);
121 void Insert(SbxVariable*, sal_uInt32);
122 void Remove( sal_uInt32 );
123 void Remove( SbxVariable const * );
124 void Merge( SbxArray* );
125 OUString GetAlias(sal_uInt32);
126 void PutAlias(const OUString&, sal_uInt32);
127 SbxVariable* Find( const OUString&, SbxClassType );
130 // SbxDimArray is an array that can dimensioned using BASIC conventions.
131 struct SbxDim { // an array-dimension:
132 sal_Int32 nLbound, nUbound; // Limitations
133 sal_Int32 nSize; // Number of elements
136 class BASIC_DLLPUBLIC SbxDimArray final : public SbxArray
138 std::vector<SbxDim> m_vDimensions; // Dimension table
139 BASIC_DLLPRIVATE void AddDimImpl(sal_Int32, sal_Int32, bool bAllowSize0);
140 bool mbHasFixedSize;
142 sal_uInt32 Offset(const sal_Int32*);
143 sal_uInt32 Offset(SbxArray*);
144 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
145 virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override;
146 virtual ~SbxDimArray() override;
147 public:
148 SBX_DECL_PERSIST_NODATA(SBXID_DIMARRAY,1);
149 SbxDimArray( SbxDataType=SbxVARIANT );
150 SbxDimArray( const SbxDimArray& ) = delete;
151 SbxDimArray& operator=( const SbxDimArray& );
152 virtual void Clear() override;
153 SbxVariable* Get( SbxArray* );
155 using SbxArray::GetRef;
156 using SbxArray::Get;
157 SbxVariable* Get(const sal_Int32*);
158 using SbxArray::Put;
159 void Put(SbxVariable*, const sal_Int32*);
160 sal_Int32 GetDims() const { return m_vDimensions.size(); }
161 void AddDim(sal_Int32, sal_Int32);
162 void unoAddDim(sal_Int32, sal_Int32);
163 bool GetDim(sal_Int32, sal_Int32&, sal_Int32&) const;
164 bool hasFixedSize() const { return mbHasFixedSize; };
165 void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
168 class SbxCollection : public SbxObject
170 void Initialize();
171 protected:
172 virtual ~SbxCollection() override;
173 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
174 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
175 // Overridable methods (why not pure virtual?):
176 virtual void CollAdd( SbxArray* pPar );
177 void CollItem( SbxArray* pPar );
178 virtual void CollRemove( SbxArray* pPar );
180 public:
181 SBX_DECL_PERSIST_NODATA(SBXID_COLLECTION,1);
182 SbxCollection();
183 SbxCollection( const SbxCollection& );
184 SbxCollection& operator=( const SbxCollection& );
185 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
186 virtual void Clear() override;
189 class SbxStdCollection final : public SbxCollection
191 OUString aElemClass;
192 bool bAddRemoveOk;
193 virtual ~SbxStdCollection() override;
194 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
195 virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override;
196 virtual void CollAdd( SbxArray* pPar ) override;
197 virtual void CollRemove( SbxArray* pPar ) override;
198 public:
199 SBX_DECL_PERSIST_NODATA(SBXID_FIXCOLLECTION,1);
200 SbxStdCollection();
201 SbxStdCollection( const SbxStdCollection& );
202 SbxStdCollection& operator=( const SbxStdCollection& );
203 virtual void Insert( SbxVariable* ) override;
206 typedef tools::SvRef<SbxArray> SbxArrayRef;
207 typedef tools::SvRef<SbxInfo> SbxInfoRef;
208 typedef tools::SvRef<SbxDimArray> SbxDimArrayRef;
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */