LibreOffice Module basic (master) 1
sbx.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <config_options.h>
23#include <tools/ref.hxx>
24#include <svl/hint.hxx>
25
26#include <basic/sbxdef.hxx>
27#include <basic/sbxobj.hxx>
28#include <basic/basicdllapi.h>
29
30#include <utility>
31#include <vector>
32#include <memory>
33
34class SvStream;
35
36class SfxBroadcaster;
37
38// Parameter information
40{
41 const OUString aName; // Name of the parameter
42 SbxDataType eType; // Data type
43 SbxFlagBits nFlags; // Flag-Bits
44 sal_uInt32 nUserData; // IDs etc.
46 : aName(std::move( s )), eType( t ), nFlags( n ), nUserData( 0 ) {}
47};
48
49typedef std::vector<std::unique_ptr<SbxParamInfo>> SbxParams;
50
51class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbxInfo final : public SvRefBase
52{
53 friend class SbxVariable;
54 friend class SbMethod;
55
56 OUString aComment;
57 OUString aHelpFile;
58 sal_uInt32 nHelpId;
59 SbxParams m_Params;
60
61 SbxInfo(SbxInfo const&) = delete;
62 void operator=(SbxInfo const&) = delete;
63
64 void LoadData( SvStream&, sal_uInt16 );
65 void StoreData( SvStream& ) const;
66 virtual ~SbxInfo() override;
67public:
68 SbxInfo();
69 SbxInfo( OUString , sal_uInt32 );
70
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; }
76
77 void SetComment( const OUString& r ) { aComment = r; }
78};
79
80class BASIC_DLLPUBLIC SbxHint final : public SfxHint
81{
83public:
84 SbxHint( SfxHintId n, SbxVariable* v ) : SfxHint( n ), pVar( v ) {}
85 SbxVariable* GetVar() const { return pVar; }
86};
87
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.
91
92struct SbxVarEntry;
93
95{
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 );
101
102 std::vector<SbxVarEntry> mVarEntries; // The variables
103 SbxDataType eType; // Data type of the array
104
105protected:
106 virtual ~SbxArray() override;
107 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
108 virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override;
109
110public:
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 );
128};
129
130// SbxDimArray is an array that can dimensioned using BASIC conventions.
131struct SbxDim { // an array-dimension:
132 sal_Int32 nLbound, nUbound; // Limitations
133 sal_Int32 nSize; // Number of elements
134};
135
137{
138 std::vector<SbxDim> m_vDimensions; // Dimension table
139 BASIC_DLLPRIVATE void AddDimImpl(sal_Int32, sal_Int32, bool bAllowSize0);
141
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;
147public:
150 SbxDimArray( const SbxDimArray& ) = delete;
151 SbxDimArray& operator=( const SbxDimArray& );
152 virtual void Clear() override;
154
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; };
166};
167
169{
170 void Initialize();
171protected:
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 );
179
180public:
184 SbxCollection& operator=( const SbxCollection& );
185 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
186 virtual void Clear() override;
187};
188
189class SbxStdCollection final : public SbxCollection
190{
191 OUString aElemClass;
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;
198public:
202 SbxStdCollection& operator=( const SbxStdCollection& );
203 virtual void Insert( SbxVariable* ) override;
204};
205
209
210/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
#define BASIC_DLLPRIVATE
Definition: basicdllapi.h:19
#define BASIC_DLLPUBLIC
Definition: basicdllapi.h:17
virtual bool LoadData(SvStream &, sal_uInt16) override
Definition: sbxmod.cxx:1975
virtual std::pair< bool, sal_uInt32 > StoreData(SvStream &) const override
Definition: sbxmod.cxx:2011
Definition: sbx.hxx:95
SbxVariableRef & GetRef(sal_uInt32)
Definition: sbxarray.cxx:92
SbxArray(const SbxArray &)=delete
SBX_DECL_PERSIST_NODATA(SBXID_ARRAY, 1)
std::vector< SbxVarEntry > mVarEntries
Definition: sbx.hxx:102
SbxVariable * Get(sal_uInt32)
Definition: sbxarray.cxx:108
void Put(SbxVariable *, sal_uInt32)
Definition: sbxarray.cxx:123
SbxDataType eType
Definition: sbx.hxx:103
SBX_DECL_PERSIST_NODATA(SBXID_COLLECTION, 1)
std::vector< SbxDim > m_vDimensions
Definition: sbx.hxx:138
bool mbHasFixedSize
Definition: sbx.hxx:140
SBX_DECL_PERSIST_NODATA(SBXID_DIMARRAY, 1)
sal_Int32 GetDims() const
Definition: sbx.hxx:160
bool hasFixedSize() const
Definition: sbx.hxx:164
void setHasFixedSize(bool bHasFixedSize)
Definition: sbx.hxx:165
SbxDimArray(const SbxDimArray &)=delete
Definition: sbx.hxx:81
SbxVariable * GetVar() const
Definition: sbx.hxx:85
SbxVariable * pVar
Definition: sbx.hxx:82
SbxHint(SfxHintId n, SbxVariable *v)
Definition: sbx.hxx:84
OUString aElemClass
Definition: sbx.hxx:191
SBX_DECL_PERSIST_NODATA(SBXID_FIXCOLLECTION, 1)
bool bAddRemoveOk
Definition: sbx.hxx:192
SvRefBase & operator=(const SvRefBase &)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
float v
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
SfxHintId
sal_Int64 n
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
void Clear(EHistoryType eHistory)
Put
SbxObjectRef cloneTypeObjectImpl(const SbxObject &rTypeObj)
Definition: sb.cxx:520
tools::SvRef< SbxArray > SbxArrayRef
Definition: sbx.hxx:206
tools::SvRef< SbxDimArray > SbxDimArrayRef
Definition: sbx.hxx:208
std::vector< std::unique_ptr< SbxParamInfo > > SbxParams
Definition: sbx.hxx:49
tools::SvRef< SbxInfo > SbxInfoRef
Definition: sbx.hxx:207
constexpr auto SBXID_ARRAY
Definition: sbxdef.hxx:171
constexpr auto SBXID_FIXCOLLECTION
Definition: sbxdef.hxx:175
SbxDataType
Definition: sbxdef.hxx:37
@ SbxVARIANT
Definition: sbxdef.hxx:51
SbxClassType
Definition: sbxdef.hxx:27
constexpr auto SBXID_COLLECTION
Definition: sbxdef.hxx:174
SbxFlagBits
Definition: sbxdef.hxx:131
constexpr auto SBXID_DIMARRAY
Definition: sbxdef.hxx:172
Definition: sbx.hxx:131
sal_Int32 nLbound
Definition: sbx.hxx:132
sal_Int32 nSize
Definition: sbx.hxx:133
SbxDataType eType
Definition: sbx.hxx:42
const OUString aName
Definition: sbx.hxx:41
SbxParamInfo(OUString s, SbxDataType t, SbxFlagBits n)
Definition: sbx.hxx:45
SbxFlagBits nFlags
Definition: sbx.hxx:43
sal_uInt32 nUserData
Definition: sbx.hxx:44
Count