summaryrefslogtreecommitdiff
path: root/basic/source/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/runtime')
-rw-r--r--basic/source/runtime/basrdll.cxx19
-rw-r--r--basic/source/runtime/comenumwrapper.cxx4
-rw-r--r--basic/source/runtime/comenumwrapper.hxx5
-rw-r--r--basic/source/runtime/ddectrl.cxx2
-rw-r--r--basic/source/runtime/ddectrl.hxx2
-rw-r--r--basic/source/runtime/dllmgr-none.cxx47
-rw-r--r--basic/source/runtime/dllmgr-x64.cxx114
-rw-r--r--basic/source/runtime/dllmgr-x86.cxx49
-rw-r--r--basic/source/runtime/dllmgr.hxx6
-rw-r--r--basic/source/runtime/inputbox.cxx25
-rw-r--r--basic/source/runtime/iosys.cxx31
-rw-r--r--basic/source/runtime/methods.cxx2348
-rw-r--r--basic/source/runtime/methods1.cxx1259
-rw-r--r--basic/source/runtime/props.cxx499
-rw-r--r--basic/source/runtime/runtime.cxx691
-rw-r--r--basic/source/runtime/stdobj.cxx78
-rw-r--r--basic/source/runtime/stdobj1.cxx60
17 files changed, 2392 insertions, 2847 deletions
diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx
index 29cd292e2bdf..853863b4fcfd 100644
--- a/basic/source/runtime/basrdll.cxx
+++ b/basic/source/runtime/basrdll.cxx
@@ -18,6 +18,8 @@
*/
#include <memory>
+#include <mutex>
+
#include <vcl/svapp.hxx>
#include <tools/debug.hxx>
#include <vcl/weld.hxx>
@@ -35,18 +37,17 @@ struct BasicDLLImpl : public SvRefBase
bool bDebugMode;
bool bBreakEnabled;
- std::unique_ptr<SbxAppData> xSbxAppData;
+ SbxAppData aSbxAppData;
BasicDLLImpl()
: bDebugMode(false)
, bBreakEnabled(true)
- , xSbxAppData(new SbxAppData)
{ }
static BasicDLLImpl* BASIC_DLL;
- static osl::Mutex& getMutex()
+ static std::mutex& getMutex()
{
- static osl::Mutex aMutex;
+ static std::mutex aMutex;
return aMutex;
}
};
@@ -56,7 +57,7 @@ BasicDLLImpl* BasicDLLImpl::BASIC_DLL = nullptr;
BasicDLL::BasicDLL()
{
- osl::MutexGuard aGuard(BasicDLLImpl::getMutex());
+ std::scoped_lock aGuard(BasicDLLImpl::getMutex());
if (!BasicDLLImpl::BASIC_DLL)
BasicDLLImpl::BASIC_DLL = new BasicDLLImpl;
m_xImpl = BasicDLLImpl::BASIC_DLL;
@@ -64,10 +65,10 @@ BasicDLL::BasicDLL()
BasicDLL::~BasicDLL()
{
- osl::MutexGuard aGuard(BasicDLLImpl::getMutex());
+ std::scoped_lock aGuard(BasicDLLImpl::getMutex());
const bool bLastRef = m_xImpl->GetRefCount() == 1;
if (bLastRef) {
- BasicDLLImpl::BASIC_DLL->xSbxAppData->m_aGlobErr.clear();
+ BasicDLLImpl::BASIC_DLL->aSbxAppData.m_aGlobErr.clear();
}
m_xImpl.clear();
// only reset BASIC_DLL after the object had been destroyed
@@ -120,12 +121,12 @@ void BasicDLL::BasicBreak()
SbxAppData& GetSbxData_Impl()
{
- return *BasicDLLImpl::BASIC_DLL->xSbxAppData;
+ return BasicDLLImpl::BASIC_DLL->aSbxAppData;
}
bool IsSbxData_Impl()
{
- return BasicDLLImpl::BASIC_DLL && BasicDLLImpl::BASIC_DLL->xSbxAppData;
+ return BasicDLLImpl::BASIC_DLL;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/comenumwrapper.cxx b/basic/source/runtime/comenumwrapper.cxx
index 7e2432e43b15..b7881a1b9ade 100644
--- a/basic/source/runtime/comenumwrapper.cxx
+++ b/basic/source/runtime/comenumwrapper.cxx
@@ -47,9 +47,7 @@ uno::Any SAL_CALL ComEnumerationWrapper::nextElement()
{
uno::Sequence< sal_Int16 > aNamedParamIndex;
uno::Sequence< uno::Any > aNamedParam;
- uno::Sequence< uno::Any > aArgs( 1 );
-
- aArgs[0] <<= m_nCurInd++;
+ uno::Sequence< uno::Any > aArgs{ uno::Any(m_nCurInd++) };
return m_xInvocation->invoke( "item",
aArgs,
diff --git a/basic/source/runtime/comenumwrapper.hxx b/basic/source/runtime/comenumwrapper.hxx
index 560829b331bb..38dd57f274a6 100644
--- a/basic/source/runtime/comenumwrapper.hxx
+++ b/basic/source/runtime/comenumwrapper.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/script/XInvocation.hpp>
#include <cppuhelper/implbase.hxx>
+#include <utility>
class ComEnumerationWrapper : public ::cppu::WeakImplHelper<css::container::XEnumeration>
{
@@ -30,8 +31,8 @@ class ComEnumerationWrapper : public ::cppu::WeakImplHelper<css::container::XEnu
sal_Int32 m_nCurInd;
public:
- explicit ComEnumerationWrapper(const css::uno::Reference<css::script::XInvocation>& xInvocation)
- : m_xInvocation(xInvocation)
+ explicit ComEnumerationWrapper(css::uno::Reference<css::script::XInvocation> xInvocation)
+ : m_xInvocation(std::move(xInvocation))
, m_nCurInd(0)
{
}
diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx
index bb2c4c5548f1..41e5c53d84de 100644
--- a/basic/source/runtime/ddectrl.cxx
+++ b/basic/source/runtime/ddectrl.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
#include <svl/svdde.hxx>
#include "ddectrl.hxx"
#include <basic/sberrors.hxx>
diff --git a/basic/source/runtime/ddectrl.hxx b/basic/source/runtime/ddectrl.hxx
index 3b4f3d9bb122..d341bbcb8e72 100644
--- a/basic/source/runtime/ddectrl.hxx
+++ b/basic/source/runtime/ddectrl.hxx
@@ -20,7 +20,7 @@
#pragma once
#include <tools/link.hxx>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
#include <memory>
#include <vector>
diff --git a/basic/source/runtime/dllmgr-none.cxx b/basic/source/runtime/dllmgr-none.cxx
index f5d48930745c..2a03e2ae7855 100644
--- a/basic/source/runtime/dllmgr-none.cxx
+++ b/basic/source/runtime/dllmgr-none.cxx
@@ -40,9 +40,9 @@ ErrCode returnInt64InOutArg(SbxArray *pArgs, SbxVariable &rRetVal,
{
if (!rRetVal.PutLong(1) && !rRetVal.PutInteger(1))
return ERRCODE_BASIC_BAD_ARGUMENT;
- if (!pArgs || pArgs->Count32() != 2)
+ if (!pArgs || pArgs->Count() != 2)
return ERRCODE_BASIC_BAD_ARGUMENT;
- SbxVariable *pOut = pArgs->Get32(1);
+ SbxVariable* pOut = pArgs->Get(1);
if (!pOut)
return ERRCODE_BASIC_BAD_ARGUMENT;
if (pOut->IsCurrency())
@@ -50,27 +50,26 @@ ErrCode returnInt64InOutArg(SbxArray *pArgs, SbxVariable &rRetVal,
pOut->PutCurrency(nValue);
return ERRCODE_NONE;
}
- if (pOut->IsObject())
- {
- // FIXME: should we clone this and use pOut->PutObject ?
- SbxObject* pObj = dynamic_cast<SbxObject*>( pOut->GetObject() );
- if (!pObj)
- return ERRCODE_BASIC_BAD_ARGUMENT;
-
- // We expect two Longs but other mappings could be possible too.
- SbxArray* pProps = pObj->GetProperties();
- if (pProps->Count32() != 2)
- return ERRCODE_BASIC_BAD_ARGUMENT;
- SbxVariable* pLow = pProps->Get32( 0 );
- SbxVariable* pHigh = pProps->Get32( 1 );
- if (!pLow || !pLow->IsLong() ||
- !pHigh || !pHigh->IsLong())
- return ERRCODE_BASIC_BAD_ARGUMENT;
- pLow->PutLong(nValue & 0xffffffff);
- pHigh->PutLong(nValue >> 32);
- return ERRCODE_NONE;
- }
- return ERRCODE_BASIC_BAD_ARGUMENT;
+ if (!pOut->IsObject())
+ return ERRCODE_BASIC_BAD_ARGUMENT;
+
+ // FIXME: should we clone this and use pOut->PutObject ?
+ SbxObject* pObj = dynamic_cast<SbxObject*>( pOut->GetObject() );
+ if (!pObj)
+ return ERRCODE_BASIC_BAD_ARGUMENT;
+
+ // We expect two Longs but other mappings could be possible too.
+ SbxArray* pProps = pObj->GetProperties();
+ if (pProps->Count() != 2)
+ return ERRCODE_BASIC_BAD_ARGUMENT;
+ SbxVariable* pLow = pProps->Get(0);
+ SbxVariable* pHigh = pProps->Get(1);
+ if (!pLow || !pLow->IsLong() ||
+ !pHigh || !pHigh->IsLong())
+ return ERRCODE_BASIC_BAD_ARGUMENT;
+ pLow->PutLong(nValue & 0xffffffff);
+ pHigh->PutLong(nValue >> 32);
+ return ERRCODE_NONE;
}
ErrCode builtin_kernel32(std::u16string_view aFuncName, SbxArray *pArgs,
@@ -107,6 +106,8 @@ void SbiDllMgr::FreeDll(SAL_UNUSED_PARAMETER OUString const &) {}
SbiDllMgr::SbiDllMgr() = default;
+#if defined(_WIN32)
SbiDllMgr::~SbiDllMgr() = default;
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/dllmgr-x64.cxx b/basic/source/runtime/dllmgr-x64.cxx
index 46f7fec3d204..ec5f79c4ab3e 100644
--- a/basic/source/runtime/dllmgr-x64.cxx
+++ b/basic/source/runtime/dllmgr-x64.cxx
@@ -27,10 +27,12 @@
#include <algorithm>
#include <cstddef>
#include <map>
+#include <string_view>
#include <vector>
#include <basic/sbx.hxx>
#include <basic/sbxvar.hxx>
+#include <comphelper/string.hxx>
#include <runtime.hxx>
#include <osl/thread.h>
#include <osl/diagnose.h>
@@ -40,6 +42,7 @@
#include <sal/log.hxx>
#include <salhelper/simplereferenceobject.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
+#include <o3tl/string_view.hxx>
#undef max
@@ -162,8 +165,9 @@ std::size_t alignment(SbxVariable const * variable) {
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- n = std::max(n, alignment(props->Get32(i)));
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ n = std::max(n, alignment(props->Get(i)));
}
return n;
}
@@ -177,13 +181,13 @@ std::size_t alignment(SbxVariable const * variable) {
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
sal_Int32 up;
- arr->GetDim32(i + 1, low[i], up);
+ arr->GetDim(i + 1, low[i], up);
}
- return alignment(arr->Get32(low.data()));
+ return alignment(arr->Get(low.data()));
}
}
@@ -215,8 +219,9 @@ ErrCode marshalStruct(
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- ErrCode e = marshal(false, props->Get32(i), false, blob, offset, data);
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ ErrCode e = marshal(false, props->Get(i), false, blob, offset, data);
if (e != ERRCODE_NONE) {
return e;
}
@@ -231,15 +236,14 @@ ErrCode marshalArray(
assert(variable != nullptr);
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
- arr->GetDim32(i + 1, low[i], up[i]);
+ arr->GetDim(i + 1, low[i], up[i]);
}
for (std::vector< sal_Int32 > idx = low;;) {
- ErrCode e = marshal(
- false, arr->Get32(idx.data()), false, blob, offset, data);
+ ErrCode e = marshal(false, arr->Get(idx.data()), false, blob, offset, data);
if (e != ERRCODE_NONE) {
return e;
}
@@ -409,8 +413,9 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- data = unmarshal(props->Get32(i), data);
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ data = unmarshal(props->Get(i), data);
}
break;
}
@@ -427,14 +432,14 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
- arr->GetDim32(i + 1, low[i], up[i]);
+ arr->GetDim(i + 1, low[i], up[i]);
}
for (std::vector< sal_Int32 > idx = low;;) {
- data = unmarshal(arr->Get32(idx.data()), data);
+ data = unmarshal(arr->Get(idx.data()), data);
sal_Int32 i = dims - 1;
while (idx[i] == up[i]) {
idx[i] = low[i];
@@ -479,10 +484,10 @@ struct ProcData {
};
ErrCode call(
- OUString const & dll, ProcData const & proc, SbxArray * arguments,
+ std::u16string_view dll, ProcData const & proc, SbxArray * arguments,
SbxVariable & result)
{
- if (arguments && arguments->Count32() > 20)
+ if (arguments && arguments->Count() > 20)
return ERRCODE_BASIC_NOT_IMPLEMENTED;
std::vector< char > stack;
@@ -493,11 +498,11 @@ ErrCode call(
// requires special handling in unmarshalString; other functions might
// require similar treatment, too:
bool special =
- dll.equalsIgnoreAsciiCase("KERNEL32.DLL") &&
- (proc.name == OString("GetLogicalDriveStringsA"));
- for (sal_uInt32 i = 1; i < (arguments == nullptr ? 0 : arguments->Count32()); ++i) {
- ErrCode e = marshal(
- true, arguments->Get32(i), special && i == 2, stack, stack.size(),
+ o3tl::equalsIgnoreAsciiCase(dll, u"KERNEL32.DLL") &&
+ (proc.name == "GetLogicalDriveStringsA");
+ for (sal_uInt32 i = 1; i < (arguments == nullptr ? 0 : arguments->Count()); ++i)
+ {
+ ErrCode e = marshal(true, arguments->Get(i), special && i == 2, stack, stack.size(),
data);
if (e != ERRCODE_NONE) {
return e;
@@ -510,8 +515,6 @@ ErrCode call(
// We fake all calls as being to a varargs function,
// as this means any floating-point argument among the first four
// ones will end up in a XMM register where the callee expects it.
- sal_Int32 (*proc_i)(double d, ...) = reinterpret_cast<sal_Int32 (*)(double, ...)>(proc.proc);
- double (*proc_d)(double d, ...) = reinterpret_cast<double (*)(double, ...)>(proc.proc);
sal_Int64 iRetVal = 0;
double dRetVal = 0.0;
@@ -525,55 +528,21 @@ ErrCode call(
case SbxBOOL:
case SbxBYTE:
{
- auto const st = stack.data();
- iRetVal =
- proc_i(*reinterpret_cast<double *>(st + 0),
- *reinterpret_cast<double *>(st + 1*8),
- *reinterpret_cast<double *>(st + 2*8),
- *reinterpret_cast<double *>(st + 3*8),
- *reinterpret_cast<sal_uInt64 *>(st + 4*8),
- *reinterpret_cast<sal_uInt64 *>(st + 5*8),
- *reinterpret_cast<sal_uInt64 *>(st + 6*8),
- *reinterpret_cast<sal_uInt64 *>(st + 7*8),
- *reinterpret_cast<sal_uInt64 *>(st + 8*8),
- *reinterpret_cast<sal_uInt64 *>(st + 9*8),
- *reinterpret_cast<sal_uInt64 *>(st + 10*8),
- *reinterpret_cast<sal_uInt64 *>(st + 11*8),
- *reinterpret_cast<sal_uInt64 *>(st + 12*8),
- *reinterpret_cast<sal_uInt64 *>(st + 13*8),
- *reinterpret_cast<sal_uInt64 *>(st + 14*8),
- *reinterpret_cast<sal_uInt64 *>(st + 15*8),
- *reinterpret_cast<sal_uInt64 *>(st + 16*8),
- *reinterpret_cast<sal_uInt64 *>(st + 17*8),
- *reinterpret_cast<sal_uInt64 *>(st + 18*8),
- *reinterpret_cast<sal_uInt64 *>(st + 19*8));
+ auto p = reinterpret_cast<sal_Int64 (*)(...)>(proc.proc);
+ auto const st = reinterpret_cast<double *>(stack.data());
+ iRetVal
+ = p(st[0], st[1], st[2], st[3], st[4], st[5], st[6], st[7], st[8], st[9], st[10],
+ st[11], st[12], st[13], st[14], st[15], st[16], st[17], st[18], st[19]);
break;
}
case SbxSINGLE:
case SbxDOUBLE:
{
- auto const st = stack.data();
- dRetVal =
- proc_d(*reinterpret_cast<double *>(st + 0),
- *reinterpret_cast<double *>(st + 1*8),
- *reinterpret_cast<double *>(st + 2*8),
- *reinterpret_cast<double *>(st + 3*8),
- *reinterpret_cast<sal_uInt64 *>(st + 4*8),
- *reinterpret_cast<sal_uInt64 *>(st + 5*8),
- *reinterpret_cast<sal_uInt64 *>(st + 6*8),
- *reinterpret_cast<sal_uInt64 *>(st + 7*8),
- *reinterpret_cast<sal_uInt64 *>(st + 8*8),
- *reinterpret_cast<sal_uInt64 *>(st + 9*8),
- *reinterpret_cast<sal_uInt64 *>(st + 10*8),
- *reinterpret_cast<sal_uInt64 *>(st + 11*8),
- *reinterpret_cast<sal_uInt64 *>(st + 12*8),
- *reinterpret_cast<sal_uInt64 *>(st + 13*8),
- *reinterpret_cast<sal_uInt64 *>(st + 14*8),
- *reinterpret_cast<sal_uInt64 *>(st + 15*8),
- *reinterpret_cast<sal_uInt64 *>(st + 16*8),
- *reinterpret_cast<sal_uInt64 *>(st + 17*8),
- *reinterpret_cast<sal_uInt64 *>(st + 18*8),
- *reinterpret_cast<sal_uInt64 *>(st + 19*8));
+ auto p = reinterpret_cast<double (*)(...)>(proc.proc);
+ auto const st = reinterpret_cast<double*>(stack.data());
+ dRetVal
+ = p(st[0], st[1], st[2], st[3], st[4], st[5], st[6], st[7], st[8], st[9], st[10],
+ st[11], st[12], st[13], st[14], st[15], st[16], st[17], st[18], st[19]);
break;
}
default:
@@ -619,8 +588,9 @@ ErrCode call(
assert(false);
break;
}
- for (sal_uInt32 i = 1; i < (arguments == nullptr ? 0 : arguments->Count32()); ++i) {
- arguments->Get32(i)->ResetFlag(SbxFlagBits::Reference);
+ for (sal_uInt32 i = 1; i < (arguments == nullptr ? 0 : arguments->Count()); ++i)
+ {
+ arguments->Get(i)->ResetFlag(SbxFlagBits::Reference);
//TODO: skipped for errors?!?
}
for (auto const& elem : data.unmarshal)
@@ -641,7 +611,7 @@ ErrCode getProcData(HMODULE handle, OUString const & name, ProcData * proc)
{
assert(proc != nullptr);
if (name.getLength() != 0 && name[0] == '@') { //TODO: "@" vs. "#"???
- sal_Int32 n = name.copy(1).toInt32(); //TODO: handle bad input
+ sal_IntPtr n = o3tl::toInt32(name.subView(1)); //TODO: handle bad input
if (n <= 0 || n > 0xFFFF) {
return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode?
}
diff --git a/basic/source/runtime/dllmgr-x86.cxx b/basic/source/runtime/dllmgr-x86.cxx
index f07495949dff..7ab84d7f8b56 100644
--- a/basic/source/runtime/dllmgr-x86.cxx
+++ b/basic/source/runtime/dllmgr-x86.cxx
@@ -31,6 +31,7 @@
#include <basic/sbx.hxx>
#include <basic/sbxvar.hxx>
+#include <comphelper/string.hxx>
#include "runtime.hxx"
#include <osl/thread.h>
#include <rtl/ref.hxx>
@@ -39,6 +40,7 @@
#include <sal/log.hxx>
#include <salhelper/simplereferenceobject.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
+#include <o3tl/string_view.hxx>
#undef max
@@ -169,8 +171,9 @@ std::size_t alignment(SbxVariable * variable) {
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- n = std::max(n, alignment(props->Get32(i)));
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ n = std::max(n, alignment(props->Get(i)));
}
return n;
}
@@ -184,13 +187,13 @@ std::size_t alignment(SbxVariable * variable) {
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
sal_Int32 up;
- arr->GetDim32(i + 1, low[i], up);
+ arr->GetDim(i + 1, low[i], up);
}
- return alignment(arr->Get32(&low[0]));
+ return alignment(arr->Get(&low[0]));
}
}
@@ -223,8 +226,9 @@ ErrCode marshalStruct(
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- ErrCode e = marshal(false, props->Get32(i), false, blob, offset, data);
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ ErrCode e = marshal(false, props->Get(i), false, blob, offset, data);
if (e != ERRCODE_NONE) {
return e;
}
@@ -239,15 +243,14 @@ ErrCode marshalArray(
assert(variable != 0);
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
- arr->GetDim32(i + 1, low[i], up[i]);
+ arr->GetDim(i + 1, low[i], up[i]);
}
for (std::vector< sal_Int32 > idx = low;;) {
- ErrCode e = marshal(
- false, arr->Get32(&idx[0]), false, blob, offset, data);
+ ErrCode e = marshal(false, arr->Get(&idx[0]), false, blob, offset, data);
if (e != ERRCODE_NONE) {
return e;
}
@@ -417,8 +420,9 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
assert(pobj);
SbxArray* props = pobj->GetProperties();
- for (sal_uInt32 i = 0; i < props->Count32(); ++i) {
- data = unmarshal(props->Get32(i), data);
+ for (sal_uInt32 i = 0; i < props->Count(); ++i)
+ {
+ data = unmarshal(props->Get(i), data);
}
break;
}
@@ -435,14 +439,14 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
assert(arr);
- sal_Int32 dims = arr->GetDims32();
+ sal_Int32 dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
for (sal_Int32 i = 0; i < dims; ++i) {
- arr->GetDim32(i + 1, low[i], up[i]);
+ arr->GetDim(i + 1, low[i], up[i]);
}
for (std::vector< sal_Int32 > idx = low;;) {
- data = unmarshal(arr->Get32(&idx[0]), data);
+ data = unmarshal(arr->Get(&idx[0]), data);
sal_Int32 i = dims - 1;
while (idx[i] == up[i]) {
idx[i] = low[i];
@@ -498,9 +502,9 @@ ErrCode call(
// require similar treatment, too:
bool special = dll.equalsIgnoreAsciiCase("KERNEL32.DLL") &&
(proc.name == OString("GetLogicalDriveStringsA"));
- for (sal_uInt32 i = 1; i < (arguments == 0 ? 0 : arguments->Count32()); ++i) {
- ErrCode e = marshal(
- true, arguments->Get32(i), special && i == 2, stack, stack.size(),
+ for (sal_uInt32 i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i)
+ {
+ ErrCode e = marshal(true, arguments->Get(i), special && i == 2, stack, stack.size(),
data);
if (e != ERRCODE_NONE) {
return e;
@@ -559,8 +563,9 @@ ErrCode call(
assert(false);
break;
}
- for (sal_uInt32 i = 1; i < (arguments == 0 ? 0 : arguments->Count32()); ++i) {
- arguments->Get32(i)->ResetFlag(SbxFlagBits::Reference);
+ for (sal_uInt32 i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i)
+ {
+ arguments->Get(i)->ResetFlag(SbxFlagBits::Reference);
//TODO: skipped for errors?!?
}
for (auto& rUnmarshalData : data.unmarshal)
@@ -581,7 +586,7 @@ ErrCode getProcData(HMODULE handle, OUString const & name, ProcData * proc)
{
assert(proc != 0);
if ( !name.isEmpty() && name[0] == '@' ) { //TODO: "@" vs. "#"???
- sal_Int32 n = name.copy(1).toInt32(); //TODO: handle bad input
+ sal_Int32 n = o3tl::toInt32(name.subView(1)); //TODO: handle bad input
if (n <= 0 || n > 0xFFFF) {
return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode?
}
diff --git a/basic/source/runtime/dllmgr.hxx b/basic/source/runtime/dllmgr.hxx
index 3f984c95105c..fe76cfb681b6 100644
--- a/basic/source/runtime/dllmgr.hxx
+++ b/basic/source/runtime/dllmgr.hxx
@@ -20,7 +20,7 @@
#pragma once
#include <sal/config.h>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
#include <memory>
class SbxArray;
@@ -33,7 +33,9 @@ public:
SbiDllMgr();
+#if defined(_WIN32)
~SbiDllMgr();
+#endif
ErrCode Call(
std::u16string_view function, std::u16string_view library,
@@ -42,7 +44,7 @@ public:
void FreeDll(OUString const & library);
private:
-#if defined(_WIN32) && !defined(_ARM64_)
+#if defined(_WIN32)
struct Impl;
std::unique_ptr< Impl > impl_;
diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx
index bf21aea13ce4..2e154d0e0027 100644
--- a/basic/source/runtime/inputbox.cxx
+++ b/basic/source/runtime/inputbox.cxx
@@ -19,9 +19,9 @@
#include <basic/sberrors.hxx>
#include <tools/lineend.hxx>
+#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
-#include <vcl/window.hxx>
#include <rtlproto.hxx>
#include <memory>
@@ -78,7 +78,7 @@ void SvRTLInputBox::PositionDialog(tools::Long nXTwips, tools::Long nYTwips)
{
Point aDlgPosApp( nXTwips, nYTwips );
OutputDevice* pDefaultDevice = Application::GetDefaultDevice();
- pDefaultDevice->Push(PushFlags::MAPMODE);
+ pDefaultDevice->Push(vcl::PushFlags::MAPMODE);
pDefaultDevice->SetMapMode(MapMode( MapUnit::MapAppFont));
aDlgPosApp = pDefaultDevice->LogicToPixel(aDlgPosApp, MapMode(MapUnit::MapTwip));
pDefaultDevice->Pop();
@@ -110,7 +110,7 @@ IMPL_LINK_NOARG( SvRTLInputBox, CancelHdl, weld::Button&, void )
void SbRtl_InputBox(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32();
+ sal_uInt32 nArgCount = rPar.Count();
if ( nArgCount < 2 )
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
else
@@ -118,11 +118,11 @@ void SbRtl_InputBox(StarBASIC *, SbxArray & rPar, bool)
OUString aTitle;
OUString aDefault;
sal_Int32 nX = -1, nY = -1; // center
- const OUString& rPrompt = rPar.Get32(1)->GetOUString();
- if ( nArgCount > 2 && !rPar.Get32(2)->IsErr() )
- aTitle = rPar.Get32(2)->GetOUString();
- if ( nArgCount > 3 && !rPar.Get32(3)->IsErr() )
- aDefault = rPar.Get32(3)->GetOUString();
+ const OUString& rPrompt = rPar.Get(1)->GetOUString();
+ if (nArgCount > 2 && !rPar.Get(2)->IsErr())
+ aTitle = rPar.Get(2)->GetOUString();
+ if (nArgCount > 3 && !rPar.Get(3)->IsErr())
+ aDefault = rPar.Get(3)->GetOUString();
if ( nArgCount > 4 )
{
if ( nArgCount != 6 )
@@ -130,13 +130,12 @@ void SbRtl_InputBox(StarBASIC *, SbxArray & rPar, bool)
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- nX = rPar.Get32(4)->GetLong();
- nY = rPar.Get32(5)->GetLong();
+ nX = rPar.Get(4)->GetLong();
+ nY = rPar.Get(5)->GetLong();
}
- vcl::Window* pParent = Application::GetDefDialogParent();
- SvRTLInputBox aDlg(pParent ? pParent->GetFrameWeld() : nullptr,rPrompt,aTitle,aDefault,nX,nY);
+ SvRTLInputBox aDlg(Application::GetDefDialogParent(), rPrompt, aTitle, aDefault, nX, nY);
aDlg.run();
- rPar.Get32(0)->PutString(aDlg.GetText());
+ rPar.Get(0)->PutString(aDlg.GetText());
}
}
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 4c991c6676c7..015ed8abc29b 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -20,7 +20,6 @@
#include <string.h>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
-#include <vcl/window.hxx>
#include <osl/file.hxx>
#include <runtime.hxx>
@@ -38,14 +37,12 @@
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+#include <iosys.hxx>
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::ucb;
using namespace com::sun::star::io;
-using namespace com::sun::star::bridge;
-#include <iosys.hxx>
namespace {
@@ -133,17 +130,12 @@ void SbiStream::MapError()
// #89378 New semantic: Don't just ask for UNO but for UCB
bool hasUno()
{
- static bool bNeedInit = true;
- static bool bRetVal = true;
-
- if( bNeedInit )
- {
- bNeedInit = false;
+ static const bool bRetVal = [] {
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
if( !xContext.is() )
{
// No service manager at all
- bRetVal = false;
+ return false;
}
else
{
@@ -152,10 +144,11 @@ bool hasUno()
if ( !( xManager->queryContentProvider( "file:///" ).is() ) )
{
// No UCB
- bRetVal = false;
+ return false;
}
}
- }
+ return true;
+ }();
return bRetVal;
}
@@ -534,7 +527,7 @@ ErrCode const & SbiStream::Read( char& ch )
if (aLine.isEmpty())
{
Read( aLine );
- aLine += OString('\n');
+ aLine += "\n";
}
ch = aLine[0];
aLine = aLine.copy(1);
@@ -567,7 +560,7 @@ namespace
void WriteLines(SvStream &rStream, const OString& rStr)
{
OString aStr(convertLineEnd(rStr, rStream.GetLineDelimiter()) );
- write_uInt8s_FromOString(rStream, aStr);
+ rStream.WriteBytes(aStr.getStr(), aStr.getLength());
endl( rStream );
}
}
@@ -695,8 +688,7 @@ void SbiIoSystem::Shutdown()
// anything left to PRINT?
if( !aOut.isEmpty() )
{
- vcl::Window* pParent = Application::GetDefDialogParent();
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, VclMessageType::Warning,
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(Application::GetDefDialogParent(), VclMessageType::Warning,
VclButtonsType::Ok, aOut));
xBox->run();
}
@@ -728,7 +720,7 @@ char SbiIoSystem::Read()
if( aIn.isEmpty() )
{
ReadCon( aIn );
- aIn += OString('\n');
+ aIn += "\n";
}
ch = aIn[0];
aIn = aIn.copy(1);
@@ -835,8 +827,7 @@ void SbiIoSystem::WriteCon(std::u16string_view rText)
{
SolarMutexGuard aSolarGuard;
- vcl::Window* pParent = Application::GetDefDialogParent();
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, VclMessageType::Warning,
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(Application::GetDefDialogParent(), VclMessageType::Warning,
VclButtonsType::OkCancel, s));
xBox->set_default_response(RET_OK);
if (!xBox->run())
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index d8c0c3f9a583..4dfcdc210ea3 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -24,11 +24,10 @@
#include <basic/sbuno.hxx>
#include <osl/process.h>
#include <vcl/dibtools.hxx>
-#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/sound.hxx>
-#include <tools/wintypes.hxx>
+#include <vcl/wintypes.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/weld.hxx>
#include <basic/sbx.hxx>
@@ -39,6 +38,7 @@
#include <osl/time.h>
#include <unotools/charclass.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/wincodepage.hxx>
#include <tools/wldcrd.hxx>
#include <i18nlangtag/lang.h>
#include <rtl/string.hxx>
@@ -59,6 +59,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/script/XErrorQuery.hpp>
+#include <ooo/vba/VbStrConv.hpp>
#include <ooo/vba/VbTriState.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
#include <memory>
@@ -66,11 +67,12 @@
#include <string_view>
#include <o3tl/char16_t2wchar_t.hxx>
-using namespace comphelper;
-using namespace osl;
-using namespace com::sun::star;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
+// include search util
+#include <com/sun/star/i18n/Transliteration.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
+#include <i18nutil/searchopt.hxx>
+#include <unotools/textsearch.hxx>
+#include <svl/numformat.hxx>
#include <date.hxx>
#include <sbstdobj.hxx>
@@ -99,10 +101,16 @@ using namespace com::sun::star::uno;
#include <unistd.h>
#endif
-#include <com/sun/star/i18n/XCharacterClassification.hpp>
-#include <vcl/unohelp.hxx>
#include <vcl/TypeSerializer.hxx>
+using namespace comphelper;
+using namespace osl;
+using namespace com::sun::star;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+
+static sal_Int32 GetDayDiff(const Date& rDate) { return rDate - Date(1899'12'30); }
+
#if HAVE_FEATURE_SCRIPTING
static void FilterWhiteSpace( OUString& rStr )
@@ -126,8 +134,6 @@ static void FilterWhiteSpace( OUString& rStr )
rStr = aRet.makeStringAndClear();
}
-static tools::Long GetDayDiff( const Date& rDate );
-
static const CharClass& GetCharClass()
{
static CharClass aCharClass( Application::GetSettings().GetLanguageTag() );
@@ -175,16 +181,17 @@ static uno::Reference< ucb::XSimpleFileAccess3 > const & getFileAccess()
void SbRtl_CreateObject(StarBASIC * pBasic, SbxArray & rPar, bool)
{
- OUString aClass( rPar.Get32(1)->GetOUString() );
+ if( rPar.Count() < 2 )
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aClass(rPar.Get(1)->GetOUString());
SbxObjectRef p = SbxBase::CreateObject( aClass );
if( !p.is() )
- StarBASIC::Error( ERRCODE_BASIC_CANNOT_LOAD );
- else
- {
- // Convenience: enter BASIC as parent
- p->SetParent( pBasic );
- rPar.Get32(0)->PutObject( p.get() );
- }
+ return StarBASIC::Error( ERRCODE_BASIC_CANNOT_LOAD );
+
+ // Convenience: enter BASIC as parent
+ p->SetParent( pBasic );
+ rPar.Get(0)->PutObject(p.get());
}
// Error( n )
@@ -192,161 +199,139 @@ void SbRtl_CreateObject(StarBASIC * pBasic, SbxArray & rPar, bool)
void SbRtl_Error(StarBASIC * pBasic, SbxArray & rPar, bool)
{
if( !pBasic )
- StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
+ return StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
+
+ OUString aErrorMsg;
+ ErrCode nErr = ERRCODE_NONE;
+ sal_Int32 nCode = 0;
+ if (rPar.Count() == 1)
+ {
+ nErr = StarBASIC::GetErrBasic();
+ aErrorMsg = StarBASIC::GetErrorMsg();
+ }
else
{
- OUString aErrorMsg;
- ErrCode nErr = ERRCODE_NONE;
- sal_Int32 nCode = 0;
- if( rPar.Count32() == 1 )
- {
- nErr = StarBASIC::GetErrBasic();
- aErrorMsg = StarBASIC::GetErrorMsg();
- }
- else
+ nCode = rPar.Get(1)->GetLong();
+ if( nCode > 65535 )
{
- nCode = rPar.Get32(1)->GetLong();
- if( nCode > 65535 )
- {
- StarBASIC::Error( ERRCODE_BASIC_CONVERSION );
- }
- else
- {
- nErr = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(nCode) );
- }
- }
-
- bool bVBA = SbiRuntime::isVBAEnabled();
- OUString tmpErrMsg;
- if( bVBA && !aErrorMsg.isEmpty())
- {
- tmpErrMsg = aErrorMsg;
+ StarBASIC::Error( ERRCODE_BASIC_CONVERSION );
}
else
{
- StarBASIC::MakeErrorText( nErr, aErrorMsg );
- tmpErrMsg = StarBASIC::GetErrorText();
+ nErr = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(nCode) );
}
- // If this rtlfunc 'Error' passed an errcode the same as the active Err Objects's
- // current err then return the description for the error message if it is set
- // ( complicated isn't it ? )
- if ( bVBA && rPar.Count32() > 1 )
+ }
+ bool bVBA = SbiRuntime::isVBAEnabled();
+ OUString tmpErrMsg;
+ if( bVBA && !aErrorMsg.isEmpty())
+ {
+ tmpErrMsg = aErrorMsg;
+ }
+ else
+ {
+ StarBASIC::MakeErrorText( nErr, aErrorMsg );
+ tmpErrMsg = StarBASIC::GetErrorText();
+ }
+ // If this rtlfunc 'Error' passed an errcode the same as the active Err Objects's
+ // current err then return the description for the error message if it is set
+ // ( complicated isn't it ? )
+ if (bVBA && rPar.Count() > 1)
+ {
+ uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() );
+ if ( xErrObj.is() && xErrObj->getNumber() == nCode && !xErrObj->getDescription().isEmpty() )
{
- uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() );
- if ( xErrObj.is() && xErrObj->getNumber() == nCode && !xErrObj->getDescription().isEmpty() )
- {
- tmpErrMsg = xErrObj->getDescription();
- }
+ tmpErrMsg = xErrObj->getDescription();
}
- rPar.Get32(0)->PutString( tmpErrMsg );
}
+ rPar.Get(0)->PutString(tmpErrMsg);
}
// Sinus
void SbRtl_Sin(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- rPar.Get32(0)->PutDouble( sin( pArg->GetDouble() ) );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ rPar.Get(0)->PutDouble(sin(pArg->GetDouble()));
}
void SbRtl_Cos(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- rPar.Get32(0)->PutDouble( cos( pArg->GetDouble() ) );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ rPar.Get(0)->PutDouble(cos(pArg->GetDouble()));
}
void SbRtl_Atn(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- rPar.Get32(0)->PutDouble( atan( pArg->GetDouble() ) );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ rPar.Get(0)->PutDouble(atan(pArg->GetDouble()));
}
void SbRtl_Abs(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- rPar.Get32(0)->PutDouble( fabs( pArg->GetDouble() ) );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ rPar.Get(0)->PutDouble(fabs(pArg->GetDouble()));
}
void SbRtl_Asc(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ OUString aStr( pArg->GetOUString() );
+ if ( aStr.isEmpty())
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ rPar.Get(0)->PutEmpty();
+ return;
}
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- OUString aStr( pArg->GetOUString() );
- if ( aStr.isEmpty())
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- rPar.Get32(0)->PutEmpty();
- }
- else
- {
- sal_Unicode aCh = aStr[0];
- rPar.Get32(0)->PutLong( aCh );
- }
- }
+ sal_Unicode aCh = aStr[0];
+ rPar.Get(0)->PutLong(aCh);
}
static void implChr( SbxArray& rPar, bool bChrW )
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+
+ OUString aStr;
+ if( !bChrW && SbiRuntime::isVBAEnabled() )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ char c = static_cast<char>(pArg->GetByte());
+ aStr = OUString(&c, 1, osl_getThreadTextEncoding());
}
else
{
- SbxVariableRef pArg = rPar.Get32(1);
-
- OUString aStr;
- if( !bChrW && SbiRuntime::isVBAEnabled() )
+ // Map negative 16-bit values to large positive ones, so that code like Chr(&H8000)
+ // still works after the fix for tdf#62326 changed those four-digit hex notations to
+ // produce negative values:
+ sal_Int32 aCh = pArg->GetLong();
+ if (aCh < -0x8000 || aCh > 0xFFFF)
{
- char c = static_cast<char>(pArg->GetByte());
- aStr = OUString(&c, 1, osl_getThreadTextEncoding());
+ StarBASIC::Error(ERRCODE_BASIC_MATH_OVERFLOW);
+ aCh = 0;
}
- else
- {
- // Map negative 16-bit values to large positive ones, so that code like Chr(&H8000)
- // still works after the fix for tdf#62326 changed those four-digit hex notations to
- // produce negative values:
- sal_Int32 aCh = pArg->GetLong();
- if (aCh < -0x8000 || aCh > 0xFFFF) {
- StarBASIC::Error(ERRCODE_BASIC_MATH_OVERFLOW);
- aCh = 0;
- }
- aStr = OUString(static_cast<sal_Unicode>(aCh));
- }
- rPar.Get32(0)->PutString( aStr );
+ aStr = OUString(static_cast<sal_Unicode>(aCh));
}
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_Chr(StarBASIC *, SbxArray & rPar, bool)
@@ -379,32 +364,28 @@ extern "C" void invalidParameterHandler(
#endif
-void SbRtl_CurDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
+void SbRtl_CurDir(StarBASIC *, SbxArray & rPar, bool)
{
- (void)pBasic;
- (void)bWrite;
-
// #57064 Although this function doesn't work with DirEntry, it isn't touched
// by the adjustment to virtual URLs, as, using the DirEntry-functionality,
// there's no possibility to detect the current one in a way that a virtual URL
// could be delivered.
+ if (rPar.Count() > 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
#if defined(_WIN32)
int nCurDir = 0; // Current dir // JSM
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- OUString aDrive = rPar.Get32(1)->GetOUString();
+ OUString aDrive = rPar.Get(1)->GetOUString();
if ( aDrive.getLength() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
auto c = rtl::toAsciiUpperCase(aDrive[0]);
if ( !rtl::isAsciiUpperCase( c ) )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
nCurDir = c - 'A' + 1;
}
wchar_t pBuffer[ _MAX_PATH ];
@@ -414,14 +395,10 @@ void SbRtl_CurDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
auto const handler = _set_thread_local_invalid_parameter_handler(&invalidParameterHandler);
auto const ok = _wgetdcwd( nCurDir, pBuffer, _MAX_PATH ) != nullptr;
_set_thread_local_invalid_parameter_handler(handler);
- if ( ok )
- {
- rPar.Get32(0)->PutString( OUString(o3tl::toU(pBuffer)) );
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_NO_DEVICE );
- }
+ if ( !ok )
+ return StarBASIC::Error( ERRCODE_BASIC_NO_DEVICE );
+
+ rPar.Get(0)->PutString(OUString(o3tl::toU(pBuffer)));
#else
@@ -430,53 +407,44 @@ void SbRtl_CurDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
int nSize = PATH_INCR;
std::unique_ptr<char[]> pMem;
while( true )
- {
+ {
pMem.reset(new char[nSize]);
if( !pMem )
- {
- StarBASIC::Error( ERRCODE_BASIC_NO_MEMORY );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_NO_MEMORY );
+
if( getcwd( pMem.get(), nSize-1 ) != nullptr )
- {
- rPar.Get32(0)->PutString( OUString::createFromAscii(pMem.get()) );
+ {
+ rPar.Get(0)->PutString(OUString::createFromAscii(pMem.get()));
return;
- }
+ }
if( errno != ERANGE )
- {
- StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
+
nSize += PATH_INCR;
- };
+ };
#endif
}
void SbRtl_ChDir(StarBASIC * pBasic, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() == 2)
- {
- // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.)
- if( SbiRuntime::isVBAEnabled() )
- {
- ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get32(1)->GetOUString() );
- }
- }
- else
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.)
+ if( SbiRuntime::isVBAEnabled() )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ ::basic::vba::registerCurrentDirectory(getDocumentModel(pBasic),
+ rPar.Get(1)->GetOUString());
}
}
void SbRtl_ChDrive(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() != 2)
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
@@ -524,130 +492,120 @@ void implStepRenameOSL( const OUString& aSource, const OUString& aDest )
void SbRtl_FileCopy(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() == 3)
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 3)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aSource = rPar.Get(1)->GetOUString();
+ OUString aDest = rPar.Get(2)->GetOUString();
+ if( hasUno() )
{
- OUString aSource = rPar.Get32(1)->GetOUString();
- OUString aDest = rPar.Get32(2)->GetOUString();
- if( hasUno() )
+ const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
+ if( xSFI.is() )
{
- const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
- if( xSFI.is() )
+ try
{
- try
- {
- xSFI->copy( getFullPath( aSource ), getFullPath( aDest ) );
- }
- catch(const Exception & )
- {
- StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
- }
+ xSFI->copy( getFullPath( aSource ), getFullPath( aDest ) );
}
- }
- else
- {
- FileBase::RC nRet = File::copy( getFullPath( aSource ), getFullPath( aDest ) );
- if( nRet != FileBase::E_None )
+ catch(const Exception & )
{
StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
}
}
}
else
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ {
+ FileBase::RC nRet = File::copy( getFullPath( aSource ), getFullPath( aDest ) );
+ if( nRet != FileBase::E_None )
+ {
+ StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
+ }
+ }
}
void SbRtl_Kill(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() == 2)
- {
- OUString aFileSpec = rPar.Get32(1)->GetOUString();
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- if( hasUno() )
+ OUString aFileSpec = rPar.Get(1)->GetOUString();
+
+ if( hasUno() )
+ {
+ const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
+ if( xSFI.is() )
{
- const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
- if( xSFI.is() )
+ OUString aFullPath = getFullPath( aFileSpec );
+ if( !xSFI->exists( aFullPath ) || xSFI->isFolder( aFullPath ) )
{
- OUString aFullPath = getFullPath( aFileSpec );
- if( !xSFI->exists( aFullPath ) || xSFI->isFolder( aFullPath ) )
- {
- StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
- return;
- }
- try
- {
- xSFI->kill( aFullPath );
- }
- catch(const Exception & )
- {
- StarBASIC::Error( ERRCODE_IO_GENERAL );
- }
+ StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
+ return;
+ }
+ try
+ {
+ xSFI->kill( aFullPath );
+ }
+ catch(const Exception & )
+ {
+ StarBASIC::Error( ERRCODE_IO_GENERAL );
}
- }
- else
- {
- File::remove( getFullPath( aFileSpec ) );
}
}
else
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ File::remove( getFullPath( aFileSpec ) );
}
}
void SbRtl_MkDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() == 2)
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aPath = rPar.Get(1)->GetOUString();
+ if ( SbiRuntime::isVBAEnabled() )
{
- OUString aPath = rPar.Get32(1)->GetOUString();
- if ( SbiRuntime::isVBAEnabled() )
+ // In vba if the full path is not specified then
+ // folder is created relative to the curdir
+ INetURLObject aURLObj( getFullPath( aPath ) );
+ if ( aURLObj.GetProtocol() != INetProtocol::File )
{
- // In vba if the full path is not specified then
- // folder is created relative to the curdir
- INetURLObject aURLObj( getFullPath( aPath ) );
- if ( aURLObj.GetProtocol() != INetProtocol::File )
- {
- SbxArrayRef pPar = new SbxArray();
- SbxVariableRef pResult = new SbxVariable();
- SbxVariableRef pParam = new SbxVariable();
- pPar->Insert32( pResult.get(), pPar->Count32() );
- pPar->Insert32( pParam.get(), pPar->Count32() );
- SbRtl_CurDir( pBasic, *pPar, bWrite );
-
- OUString sCurPathURL;
- File::getFileURLFromSystemPath( pPar->Get32(0)->GetOUString(), sCurPathURL );
-
- aURLObj.SetURL( sCurPathURL );
- aURLObj.Append( aPath );
- File::getSystemPathFromFileURL(aURLObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),aPath ) ;
- }
+ SbxArrayRef pPar = new SbxArray();
+ SbxVariableRef pResult = new SbxVariable();
+ SbxVariableRef pParam = new SbxVariable();
+ pPar->Insert(pResult.get(), pPar->Count());
+ pPar->Insert(pParam.get(), pPar->Count());
+ SbRtl_CurDir( pBasic, *pPar, bWrite );
+
+ OUString sCurPathURL;
+ File::getFileURLFromSystemPath(pPar->Get(0)->GetOUString(), sCurPathURL);
+
+ aURLObj.SetURL( sCurPathURL );
+ aURLObj.Append( aPath );
+ File::getSystemPathFromFileURL(aURLObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),aPath ) ;
}
+ }
- if( hasUno() )
+ if( hasUno() )
+ {
+ const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
+ if( xSFI.is() )
{
- const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
- if( xSFI.is() )
+ try
{
- try
- {
- xSFI->createFolder( getFullPath( aPath ) );
- }
- catch(const Exception & )
- {
- StarBASIC::Error( ERRCODE_IO_GENERAL );
- }
+ xSFI->createFolder( getFullPath( aPath ) );
+ }
+ catch(const Exception & )
+ {
+ StarBASIC::Error( ERRCODE_IO_GENERAL );
}
- }
- else
- {
- Directory::create( getFullPath( aPath ) );
}
}
else
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ Directory::create( getFullPath( aPath ) );
}
}
@@ -665,16 +623,14 @@ static void implRemoveDirRecursive( const OUString& aDirPath )
if( !bExists || !bFolder )
{
- StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
}
Directory aDir( aDirPath );
nRet = aDir.open();
if( nRet != FileBase::E_None )
{
- StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
}
aDir.close();
@@ -684,10 +640,10 @@ static void implRemoveDirRecursive( const OUString& aDirPath )
void SbRtl_RmDir(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if (rPar.Count32() == 2)
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() == 2)
{
- OUString aPath = rPar.Get32(1)->GetOUString();
+ OUString aPath = rPar.Get(1)->GetOUString();
if( hasUno() )
{
const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
@@ -697,8 +653,7 @@ void SbRtl_RmDir(StarBASIC *, SbxArray & rPar, bool)
{
if( !xSFI->isFolder( aPath ) )
{
- StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND );
}
SbiInstance* pInst = GetSbData()->pInst;
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
@@ -707,8 +662,7 @@ void SbRtl_RmDir(StarBASIC *, SbxArray & rPar, bool)
Sequence< OUString > aContent = xSFI->getFolderContents( aPath, true );
if( aContent.hasElements() )
{
- StarBASIC::Error( ERRCODE_BASIC_ACCESS_ERROR );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_ACCESS_ERROR );
}
}
@@ -733,79 +687,72 @@ void SbRtl_RmDir(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_SendKeys(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
+ rPar.Get(0)->PutEmpty();
StarBASIC::Error(ERRCODE_BASIC_NOT_IMPLEMENTED);
}
void SbRtl_Exp(StarBASIC *, SbxArray & rPar, bool)
{
- if( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- else
- {
- double aDouble = rPar.Get32(1)->GetDouble();
- aDouble = exp( aDouble );
- checkArithmeticOverflow( aDouble );
- rPar.Get32(0)->PutDouble( aDouble );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ double aDouble = rPar.Get(1)->GetDouble();
+ aDouble = exp( aDouble );
+ checkArithmeticOverflow( aDouble );
+ rPar.Get(0)->PutDouble(aDouble);
}
void SbRtl_FileLen(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- else
+
+ SbxVariableRef pArg = rPar.Get(1);
+ OUString aStr( pArg->GetOUString() );
+ sal_Int32 nLen = 0;
+ if( hasUno() )
{
- SbxVariableRef pArg = rPar.Get32(1);
- OUString aStr( pArg->GetOUString() );
- sal_Int32 nLen = 0;
- if( hasUno() )
+ const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
+ if( xSFI.is() )
{
- const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
- if( xSFI.is() )
+ try
{
- try
- {
- nLen = xSFI->getSize( getFullPath( aStr ) );
- }
- catch(const Exception & )
- {
- StarBASIC::Error( ERRCODE_IO_GENERAL );
- }
+ nLen = xSFI->getSize( getFullPath( aStr ) );
+ }
+ catch(const Exception & )
+ {
+ StarBASIC::Error( ERRCODE_IO_GENERAL );
}
}
- else
- {
- DirectoryItem aItem;
- (void)DirectoryItem::get( getFullPath( aStr ), aItem );
- FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
- (void)aItem.getFileStatus( aFileStatus );
- nLen = static_cast<sal_Int32>(aFileStatus.getFileSize());
- }
- rPar.Get32(0)->PutLong( static_cast<tools::Long>(nLen) );
}
+ else
+ {
+ DirectoryItem aItem;
+ (void)DirectoryItem::get( getFullPath( aStr ), aItem );
+ FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
+ (void)aItem.getFileStatus( aFileStatus );
+ nLen = static_cast<sal_Int32>(aFileStatus.getFileSize());
+ }
+ rPar.Get(0)->PutLong(nLen);
}
+
void SbRtl_Hex(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
+ if (rPar.Count() < 2)
{
- SbxVariableRef pArg = rPar.Get32(1);
- // converting value to unsigned and limit to 2 or 4 byte representation
- sal_uInt32 nVal = pArg->IsInteger() ?
- static_cast<sal_uInt16>(pArg->GetInteger()) :
- static_cast<sal_uInt32>(pArg->GetLong());
- OUString aStr(OUString::number( nVal, 16 ));
- aStr = aStr.toAsciiUpperCase();
- rPar.Get32(0)->PutString( aStr );
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
+
+ SbxVariableRef pArg = rPar.Get(1);
+ // converting value to unsigned and limit to 2 or 4 byte representation
+ sal_uInt32 nVal = pArg->IsInteger() ?
+ static_cast<sal_uInt16>(pArg->GetInteger()) :
+ static_cast<sal_uInt32>(pArg->GetLong());
+ rPar.Get(0)->PutString(OUString::number(nVal, 16).toAsciiUpperCase());
}
void SbRtl_FuncCaller(StarBASIC *, SbxArray & rPar, bool)
@@ -813,11 +760,11 @@ void SbRtl_FuncCaller(StarBASIC *, SbxArray & rPar, bool)
if ( SbiRuntime::isVBAEnabled() && GetSbData()->pInst && GetSbData()->pInst->pRun )
{
if ( GetSbData()->pInst->pRun->GetExternalCaller() )
- *rPar.Get32(0) = *GetSbData()->pInst->pRun->GetExternalCaller();
+ *rPar.Get(0) = *GetSbData()->pInst->pRun->GetExternalCaller();
else
{
SbxVariableRef pVar = new SbxVariable(SbxVARIANT);
- *rPar.Get32(0) = *pVar;
+ *rPar.Get(0) = *pVar;
}
}
else
@@ -830,7 +777,7 @@ void SbRtl_FuncCaller(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32()-1;
+ const sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 2 )
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
else
@@ -840,7 +787,7 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
if ( nArgCount >= 3 )
{
- nStartPos = rPar.Get32(1)->GetLong();
+ nStartPos = rPar.Get(1)->GetLong();
if( nStartPos <= 0 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -863,10 +810,10 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
}
if ( nArgCount == 4 )
{
- bTextMode = rPar.Get32(4)->GetInteger();
+ bTextMode = rPar.Get(4)->GetInteger();
}
sal_Int32 nPos;
- const OUString& rToken = rPar.Get32(nFirstStringPos+1)->GetOUString();
+ const OUString& rToken = rPar.Get(nFirstStringPos + 1)->GetOUString();
// #97545 Always find empty string
if( rToken.isEmpty() )
@@ -875,23 +822,35 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
}
else
{
- if( !bTextMode )
+ const OUString& rStr1 = rPar.Get(nFirstStringPos)->GetOUString();
+ const sal_Int32 nrStr1Len = rStr1.getLength();
+ if (nStartPos > nrStr1Len)
{
- const OUString& rStr1 = rPar.Get32(nFirstStringPos)->GetOUString();
- nPos = rStr1.indexOf( rToken, nStartPos - 1 ) + 1;
+ // Start position is greater than the string being searched
+ nPos = 0;
}
else
{
- OUString aStr1 = rPar.Get32(nFirstStringPos)->GetOUString();
- OUString aToken = rToken;
-
- aStr1 = aStr1.toAsciiUpperCase();
- aToken = aToken.toAsciiUpperCase();
-
- nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
+ if( !bTextMode )
+ {
+ nPos = rStr1.indexOf( rToken, nStartPos - 1 ) + 1;
+ }
+ else
+ {
+ // tdf#139840 - case-insensitive operation for non-ASCII characters
+ i18nutil::SearchOptions2 aSearchOptions;
+ aSearchOptions.searchString = rToken;
+ aSearchOptions.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE;
+ aSearchOptions.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
+ utl::TextSearch textSearch(aSearchOptions);
+
+ sal_Int32 nStart = nStartPos - 1;
+ sal_Int32 nEnd = nrStr1Len;
+ nPos = textSearch.SearchForward(rStr1, &nStart, &nEnd) ? nStart + 1 : 0;
+ }
}
}
- rPar.Get32(0)->PutLong( nPos );
+ rPar.Get(0)->PutLong(nPos);
}
}
@@ -900,75 +859,79 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_InStrRev(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32()-1;
+ const sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 2 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- else
- {
- OUString aStr1 = rPar.Get32(1)->GetOUString();
- OUString aToken = rPar.Get32(2)->GetOUString();
- sal_Int32 nStartPos = -1;
- if ( nArgCount >= 3 )
- {
- nStartPos = rPar.Get32(3)->GetLong();
- if( nStartPos <= 0 && nStartPos != -1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- nStartPos = -1;
- }
- }
+ const OUString aStr1 = rPar.Get(1)->GetOUString();
+ const OUString aToken = rPar.Get(2)->GetOUString();
- SbiInstance* pInst = GetSbData()->pInst;
- bool bTextMode;
- bool bCompatibility = ( pInst && pInst->IsCompatibility() );
- if( bCompatibility )
- {
- SbiRuntime* pRT = pInst->pRun;
- bTextMode = pRT && pRT->IsImageFlag( SbiImageFlags::COMPARETEXT );
- }
- else
- {
- bTextMode = true;
- }
- if ( nArgCount == 4 )
+ sal_Int32 nStartPos = -1;
+ if ( nArgCount >= 3 )
+ {
+ nStartPos = rPar.Get(3)->GetLong();
+ if( nStartPos <= 0 && nStartPos != -1 )
{
- bTextMode = rPar.Get32(4)->GetInteger();
+ StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ nStartPos = -1;
}
- sal_Int32 nStrLen = aStr1.getLength();
- if( nStartPos == -1 )
+ }
+
+ SbiInstance* pInst = GetSbData()->pInst;
+ bool bTextMode;
+ bool bCompatibility = ( pInst && pInst->IsCompatibility() );
+ if( bCompatibility )
+ {
+ SbiRuntime* pRT = pInst->pRun;
+ bTextMode = pRT && pRT->IsImageFlag( SbiImageFlags::COMPARETEXT );
+ }
+ else
+ {
+ bTextMode = true;
+ }
+ if ( nArgCount == 4 )
+ {
+ bTextMode = rPar.Get(4)->GetInteger();
+ }
+ const sal_Int32 nStrLen = aStr1.getLength();
+ if( nStartPos == -1 )
+ {
+ nStartPos = nStrLen;
+ }
+
+ sal_Int32 nPos = 0;
+ if( nStartPos <= nStrLen )
+ {
+ sal_Int32 nTokenLen = aToken.getLength();
+ if( !nTokenLen )
{
- nStartPos = nStrLen;
+ // Always find empty string
+ nPos = nStartPos;
}
-
- sal_Int32 nPos = 0;
- if( nStartPos <= nStrLen )
+ else if( nStrLen > 0 )
{
- sal_Int32 nTokenLen = aToken.getLength();
- if( !nTokenLen )
+ if( !bTextMode )
{
- // Always find empty string
- nPos = nStartPos;
+ nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
}
- else if( nStrLen > 0 )
+ else
{
- if( !bTextMode )
- {
- nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
- }
- else
- {
- aStr1 = aStr1.toAsciiUpperCase();
- aToken = aToken.toAsciiUpperCase();
-
- nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
- }
+ // tdf#143332 - case-insensitive operation for non-ASCII characters
+ i18nutil::SearchOptions2 aSearchOptions;
+ aSearchOptions.searchString = aToken;
+ aSearchOptions.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE;
+ aSearchOptions.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
+ utl::TextSearch textSearch(aSearchOptions);
+
+ sal_Int32 nStart = 0;
+ sal_Int32 nEnd = nStartPos;
+ nPos = textSearch.SearchBackward(aStr1, &nEnd, &nStart) ? nStart : 0;
}
}
- rPar.Get32(0)->PutLong( nPos );
}
+ rPar.Get(0)->PutLong(nPos);
}
@@ -981,111 +944,87 @@ void SbRtl_InStrRev(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Int(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- double aDouble= pArg->GetDouble();
- /*
- floor( 2.8 ) = 2.0
- floor( -2.8 ) = -3.0
- */
- aDouble = floor( aDouble );
- rPar.Get32(0)->PutDouble( aDouble );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ double aDouble= pArg->GetDouble();
+ /*
+ floor( 2.8 ) = 2.0
+ floor( -2.8 ) = -3.0
+ */
+ aDouble = floor( aDouble );
+ rPar.Get(0)->PutDouble(aDouble);
}
void SbRtl_Fix(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ double aDouble = pArg->GetDouble();
+ if ( aDouble >= 0.0 )
+ aDouble = floor( aDouble );
else
- {
- SbxVariableRef pArg = rPar.Get32(1);
- double aDouble = pArg->GetDouble();
- if ( aDouble >= 0.0 )
- aDouble = floor( aDouble );
- else
- aDouble = ceil( aDouble );
- rPar.Get32(0)->PutDouble( aDouble );
- }
+ aDouble = ceil( aDouble );
+ rPar.Get(0)->PutDouble(aDouble);
}
void SbRtl_LCase(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- const CharClass& rCharClass = GetCharClass();
- OUString aStr( rPar.Get32(1)->GetOUString() );
- aStr = rCharClass.lowercase(aStr);
- rPar.Get32(0)->PutString( aStr );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ const CharClass& rCharClass = GetCharClass();
+ OUString aStr(rPar.Get(1)->GetOUString());
+ aStr = rCharClass.lowercase(aStr);
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_Left(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 3 )
+ if (rPar.Count() < 3)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr(rPar.Get(1)->GetOUString());
+ sal_Int32 nResultLen = rPar.Get(2)->GetLong();
+ if( nResultLen < 0 )
{
+ nResultLen = 0;
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- else
+ else if(nResultLen > aStr.getLength())
{
- OUString aStr( rPar.Get32(1)->GetOUString() );
- sal_Int32 nResultLen = rPar.Get32(2)->GetLong();
- if( nResultLen < 0 )
- {
- nResultLen = 0;
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else if(nResultLen > aStr.getLength())
- {
- nResultLen = aStr.getLength();
- }
- aStr = aStr.copy(0, nResultLen );
- rPar.Get32(0)->PutString( aStr );
+ nResultLen = aStr.getLength();
}
+ aStr = aStr.copy(0, nResultLen );
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_Log(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- double aArg = rPar.Get32(1)->GetDouble();
- if ( aArg > 0 )
- {
- double d = log( aArg );
- checkArithmeticOverflow( d );
- rPar.Get32(0)->PutDouble( d );
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ double aArg = rPar.Get(1)->GetDouble();
+ if ( aArg <= 0 )
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ double d = log( aArg );
+ checkArithmeticOverflow( d );
+ rPar.Get(0)->PutDouble(d);
}
void SbRtl_LTrim(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- OUString aStr(comphelper::string::stripStart(rPar.Get32(1)->GetOUString(), ' '));
- rPar.Get32(0)->PutString(aStr);
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr(comphelper::string::stripStart(rPar.Get(1)->GetOUString(), ' '));
+ rPar.Get(0)->PutString(aStr);
}
@@ -1093,7 +1032,7 @@ void SbRtl_LTrim(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
{
- int nArgCount = rPar.Count32()-1;
+ int nArgCount = rPar.Count() - 1;
if ( nArgCount < 2 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1108,8 +1047,8 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
{
bWrite = true;
}
- OUString aArgStr = rPar.Get32(1)->GetOUString();
- sal_Int32 nStartPos = rPar.Get32(2)->GetLong();
+ OUString aArgStr = rPar.Get(1)->GetOUString();
+ sal_Int32 nStartPos = rPar.Get(2)->GetLong();
if ( nStartPos < 1 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1121,7 +1060,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
bool bWriteNoLenParam = false;
if ( nArgCount == 3 || bWrite )
{
- sal_Int32 n = rPar.Get32(3)->GetLong();
+ sal_Int32 n = rPar.Get(3)->GetLong();
if( bWrite && n == -1 )
{
bWriteNoLenParam = true;
@@ -1137,13 +1076,12 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
if( bCompatibility )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
nStartPos = nArgLen;
}
- OUString aReplaceStr = rPar.Get32(4)->GetOUString();
+ OUString aReplaceStr = rPar.Get(4)->GetOUString();
sal_Int32 nReplaceStrLen = aReplaceStr.getLength();
sal_Int32 nReplaceLen;
if( bWriteNoLenParam )
@@ -1159,13 +1097,13 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
}
}
- OUStringBuffer aResultStr = aArgStr;
+ OUStringBuffer aResultStr(aArgStr);
sal_Int32 nErase = nReplaceLen;
aResultStr.remove( nStartPos, nErase );
aResultStr.insert(
nStartPos, aReplaceStr.getStr(), std::min(nReplaceLen, nReplaceStrLen));
- rPar.Get32(1)->PutString( aResultStr.makeStringAndClear() );
+ rPar.Get(1)->PutString(aResultStr.makeStringAndClear());
}
else
{
@@ -1189,7 +1127,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
if (nLen > 0)
aResultStr = aArgStr.copy( nStartPos, nLen );
}
- rPar.Get32(0)->PutString( aResultStr );
+ rPar.Get(0)->PutString(aResultStr);
}
}
}
@@ -1197,69 +1135,56 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)
void SbRtl_Oct(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- char aBuffer[16];
- SbxVariableRef pArg = rPar.Get32(1);
- if ( pArg->IsInteger() )
- {
- snprintf( aBuffer, sizeof(aBuffer), "%o", pArg->GetInteger() );
- }
- else
- {
- snprintf( aBuffer, sizeof(aBuffer), "%lo", static_cast<long unsigned int>(pArg->GetLong()) );
- }
- rPar.Get32(0)->PutString( OUString::createFromAscii( aBuffer ) );
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariableRef pArg = rPar.Get(1);
+ // converting value to unsigned and limit to 2 or 4 byte representation
+ sal_uInt32 nVal = pArg->IsInteger() ?
+ static_cast<sal_uInt16>(pArg->GetInteger()) :
+ static_cast<sal_uInt32>(pArg->GetLong());
+ rPar.Get(0)->PutString(OUString::number(nVal, 8));
}
// Replace(expression, find, replace[, start[, count[, compare]]])
void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32()-1;
+ const sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 6 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
sal_Int32 lStartPos = 1;
if (nArgCount >= 4)
{
- if (rPar.Get32(4)->GetType() != SbxEMPTY)
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
{
- lStartPos = rPar.Get32(4)->GetLong();
+ lStartPos = rPar.Get(4)->GetLong();
}
if (lStartPos < 1)
{
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
}
+ --lStartPos; // Make it 0-based
sal_Int32 lCount = -1;
if (nArgCount >= 5)
{
- if (rPar.Get32(5)->GetType() != SbxEMPTY)
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
{
- lCount = rPar.Get32(5)->GetLong();
+ lCount = rPar.Get(5)->GetLong();
}
if (lCount < -1)
{
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
}
bool bCaseInsensitive;
if (nArgCount == 6)
{
- bCaseInsensitive = rPar.Get32(6)->GetInteger();
+ bCaseInsensitive = rPar.Get(6)->GetInteger();
}
else
{
@@ -1275,150 +1200,136 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool)
}
}
- const OUString aExpStr = rPar.Get32(1)->GetOUString();
- OUString aFindStr = rPar.Get32(2)->GetOUString();
- const OUString aReplaceStr = rPar.Get32(3)->GetOUString();
- const sal_Int32 nExpStrLen = aExpStr.getLength();
- const sal_Int32 nFindStrLen = aFindStr.getLength();
+ const OUString aExpStr = rPar.Get(1)->GetOUString();
+ OUString aFindStr = rPar.Get(2)->GetOUString();
+ const OUString aReplaceStr = rPar.Get(3)->GetOUString();
OUString aSrcStr(aExpStr);
+ sal_Int32 nPrevPos = std::min(lStartPos, aSrcStr.getLength());
+ css::uno::Sequence<sal_Int32> aOffset;
if (bCaseInsensitive)
{
- // tdf#132389 - case-insensitive operation for non-ASCII characters
- const css::lang::Locale& rLocale = Application::GetSettings().GetUILanguageTag().getLocale();
- css::uno::Reference < i18n::XCharacterClassification > xCharClass = vcl::unohelper::CreateCharacterClassification();
- aSrcStr = xCharClass->toUpper(aSrcStr, 0, aSrcStr.getLength(), rLocale);
- aFindStr = xCharClass->toUpper(aFindStr, 0, aSrcStr.getLength(), rLocale);
- }
+ // tdf#132389: case-insensitive operation for non-ASCII characters
+ // tdf#142487: use css::i18n::Transliteration to correctly handle ß -> ss expansion
+ // tdf#132388: We can't use utl::TextSearch (css::i18n::XTextSearch), because each call to
+ // css::i18n::XTextSearch::SearchForward transliterates input string, making
+ // performance of repeated calls unacceptable
+ auto xTrans = css::i18n::Transliteration::create(comphelper::getProcessComponentContext());
+ xTrans->loadModule(css::i18n::TransliterationModules_IGNORE_CASE, {});
+ aFindStr = xTrans->transliterate(aFindStr, 0, aFindStr.getLength(), aOffset);
+ aSrcStr = xTrans->transliterate(aSrcStr, nPrevPos, aSrcStr.getLength() - nPrevPos, aOffset);
+ nPrevPos = std::distance(aOffset.begin(),
+ std::lower_bound(aOffset.begin(), aOffset.end(), nPrevPos));
+ }
+
+ auto getExpStrPos = [aOffset, nExpLen = aExpStr.getLength()](sal_Int32 nSrcStrPos) -> sal_Int32
+ {
+ assert(!aOffset.hasElements() || aOffset.getLength() >= nSrcStrPos);
+ if (!aOffset.hasElements())
+ return nSrcStrPos;
+ return aOffset.getLength() > nSrcStrPos ? aOffset[nSrcStrPos] : nExpLen;
+ };
// Note: the result starts from lStartPos, removing everything to the left. See i#94895.
- sal_Int32 nPrevPos = std::min(lStartPos - 1, nExpStrLen);
- OUStringBuffer sResult(nExpStrLen - nPrevPos);
+ OUStringBuffer sResult(aSrcStr.getLength() - nPrevPos);
sal_Int32 nCounts = 0;
while (lCount == -1 || lCount > nCounts)
{
sal_Int32 nPos = aSrcStr.indexOf(aFindStr, nPrevPos);
- if (nPos >= 0)
- {
- sResult.append(aExpStr.getStr() + nPrevPos, nPos - nPrevPos);
- sResult.append(aReplaceStr);
- nPrevPos = nPos + nFindStrLen;
- nCounts++;
- }
- else
- {
+ if (nPos < 0)
break;
- }
+
+ lStartPos = getExpStrPos(nPrevPos);
+ sResult.append(aExpStr.getStr() + lStartPos, getExpStrPos(nPos) - lStartPos);
+ sResult.append(aReplaceStr);
+ nPrevPos = nPos + aFindStr.getLength();
+ nCounts++;
}
- sResult.append(aExpStr.getStr() + nPrevPos, nExpStrLen - nPrevPos);
- rPar.Get32(0)->PutString(sResult.makeStringAndClear());
+ lStartPos = getExpStrPos(nPrevPos);
+ sResult.append(aExpStr.getStr() + lStartPos, aExpStr.getLength() - lStartPos);
+ rPar.Get(0)->PutString(sResult.makeStringAndClear());
}
void SbRtl_Right(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 3 )
+ if (rPar.Count() < 3)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ const OUString& rStr = rPar.Get(1)->GetOUString();
+ int nResultLen = rPar.Get(2)->GetLong();
+ if( nResultLen < 0 )
{
+ nResultLen = 0;
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- else
+ int nStrLen = rStr.getLength();
+ if ( nResultLen > nStrLen )
{
- const OUString& rStr = rPar.Get32(1)->GetOUString();
- int nResultLen = rPar.Get32(2)->GetLong();
- if( nResultLen < 0 )
- {
- nResultLen = 0;
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- int nStrLen = rStr.getLength();
- if ( nResultLen > nStrLen )
- {
- nResultLen = nStrLen;
- }
- OUString aResultStr = rStr.copy( nStrLen - nResultLen );
- rPar.Get32(0)->PutString( aResultStr );
+ nResultLen = nStrLen;
}
+ OUString aResultStr = rStr.copy( nStrLen - nResultLen );
+ rPar.Get(0)->PutString(aResultStr);
}
void SbRtl_RTL(StarBASIC * pBasic, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutObject( pBasic->getRTL().get() );
+ rPar.Get(0)->PutObject(pBasic->getRTL().get());
}
void SbRtl_RTrim(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- OUString aStr(comphelper::string::stripEnd(rPar.Get32(1)->GetOUString(), ' '));
- rPar.Get32(0)->PutString(aStr);
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr(comphelper::string::stripEnd(rPar.Get(1)->GetOUString(), ' '));
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_Sgn(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- double aDouble = rPar.Get32(1)->GetDouble();
- sal_Int16 nResult = 0;
- if ( aDouble > 0 )
- {
- nResult = 1;
- }
- else if ( aDouble < 0 )
- {
- nResult = -1;
- }
- rPar.Get32(0)->PutInteger( nResult );
- }
-}
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
-void SbRtl_Space(StarBASIC *, SbxArray & rPar, bool)
-{
- if ( rPar.Count32() < 2 )
+ double aDouble = rPar.Get(1)->GetDouble();
+ sal_Int16 nResult = 0;
+ if ( aDouble > 0 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ nResult = 1;
}
- else
+ else if ( aDouble < 0 )
{
- OUStringBuffer aBuf;
- string::padToLength(aBuf, rPar.Get32(1)->GetLong(), ' ');
- rPar.Get32(0)->PutString(aBuf.makeStringAndClear());
+ nResult = -1;
}
+ rPar.Get(0)->PutInteger(nResult);
}
-void SbRtl_Spc(StarBASIC *, SbxArray & rPar, bool)
+void SbRtl_Space(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- OUStringBuffer aBuf;
- string::padToLength(aBuf, rPar.Get32(1)->GetLong(), ' ');
- rPar.Get32(0)->PutString(aBuf.makeStringAndClear());
+ const sal_Int32 nCount = rPar.Get(1)->GetLong();
+ OUStringBuffer aBuf(nCount);
+ string::padToLength(aBuf, nCount, ' ');
+ rPar.Get(0)->PutString(aBuf.makeStringAndClear());
}
}
void SbRtl_Sqr(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- double aDouble = rPar.Get32(1)->GetDouble();
+ double aDouble = rPar.Get(1)->GetDouble();
if ( aDouble >= 0 )
{
- rPar.Get32(0)->PutDouble( sqrt( aDouble ));
+ rPar.Get(0)->PutDouble(sqrt(aDouble));
}
else
{
@@ -1429,7 +1340,7 @@ void SbRtl_Sqr(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Str(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
@@ -1437,7 +1348,7 @@ void SbRtl_Str(StarBASIC *, SbxArray & rPar, bool)
{
OUString aStr;
OUString aStrNew("");
- SbxVariableRef pArg = rPar.Get32(1);
+ SbxVariableRef pArg = rPar.Get(1);
pArg->Format( aStr );
// Numbers start with a space
@@ -1484,20 +1395,20 @@ void SbRtl_Str(StarBASIC *, SbxArray & rPar, bool)
{
aStrNew = aStr;
}
- rPar.Get32(0)->PutString( aStrNew );
+ rPar.Get(0)->PutString(aStrNew);
}
}
void SbRtl_StrComp(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 3 )
+ if (rPar.Count() < 3)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- rPar.Get32(0)->PutEmpty();
+ rPar.Get(0)->PutEmpty();
return;
}
- const OUString& rStr1 = rPar.Get32(1)->GetOUString();
- const OUString& rStr2 = rPar.Get32(2)->GetOUString();
+ const OUString& rStr1 = rPar.Get(1)->GetOUString();
+ const OUString& rStr2 = rPar.Get(2)->GetOUString();
SbiInstance* pInst = GetSbData()->pInst;
bool bTextCompare;
@@ -1511,8 +1422,8 @@ void SbRtl_StrComp(StarBASIC *, SbxArray & rPar, bool)
{
bTextCompare = true;
}
- if ( rPar.Count32() == 4 )
- bTextCompare = rPar.Get32(3)->GetInteger();
+ if (rPar.Count() == 4)
+ bTextCompare = rPar.Get(3)->GetInteger();
if( !bCompatibility )
{
@@ -1550,85 +1461,83 @@ void SbRtl_StrComp(StarBASIC *, SbxArray & rPar, bool)
nRetValue = 1;
}
}
- rPar.Get32(0)->PutInteger( sal::static_int_cast< sal_Int16 >( nRetValue ) );
+ rPar.Get(0)->PutInteger(sal::static_int_cast<sal_Int16>(nRetValue));
}
void SbRtl_String(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
sal_Unicode aFiller;
- sal_Int32 lCount = rPar.Get32(1)->GetLong();
+ sal_Int32 lCount = rPar.Get(1)->GetLong();
if( lCount < 0 || lCount > 0xffff )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- if( rPar.Get32(2)->GetType() == SbxINTEGER )
+ if (rPar.Get(2)->GetType() == SbxINTEGER)
{
- aFiller = static_cast<sal_Unicode>(rPar.Get32(2)->GetInteger());
+ aFiller = static_cast<sal_Unicode>(rPar.Get(2)->GetInteger());
}
else
{
- const OUString& rStr = rPar.Get32(2)->GetOUString();
+ const OUString& rStr = rPar.Get(2)->GetOUString();
aFiller = rStr[0];
}
OUStringBuffer aBuf(lCount);
string::padToLength(aBuf, lCount, aFiller);
- rPar.Get32(0)->PutString(aBuf.makeStringAndClear());
+ rPar.Get(0)->PutString(aBuf.makeStringAndClear());
}
}
void SbRtl_Tab(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
else
{
- OUStringBuffer aStr;
- comphelper::string::padToLength(aStr, rPar.Get32(1)->GetLong(), '\t');
- rPar.Get32(0)->PutString(aStr.makeStringAndClear());
+ const sal_Int32 nCount = std::max(rPar.Get(1)->GetLong(), sal_Int32(0));
+ OUStringBuffer aStr(nCount);
+ comphelper::string::padToLength(aStr, nCount, '\t');
+ rPar.Get(0)->PutString(aStr.makeStringAndClear());
}
}
void SbRtl_Tan(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- SbxVariableRef pArg = rPar.Get32(1);
- rPar.Get32(0)->PutDouble( tan( pArg->GetDouble() ) );
+ SbxVariableRef pArg = rPar.Get(1);
+ rPar.Get(0)->PutDouble(tan(pArg->GetDouble()));
}
}
void SbRtl_UCase(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
const CharClass& rCharClass = GetCharClass();
- OUString aStr( rPar.Get32(1)->GetOUString() );
+ OUString aStr(rPar.Get(1)->GetOUString());
aStr = rCharClass.uppercase( aStr );
- rPar.Get32(0)->PutString( aStr );
+ rPar.Get(0)->PutString(aStr);
}
}
-void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
+void SbRtl_Val(StarBASIC *, SbxArray & rPar, bool)
{
- (void)pBasic;
- (void)bWrite;
-
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
@@ -1637,7 +1546,7 @@ void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
double nResult = 0.0;
char* pEndPtr;
- OUString aStr( rPar.Get32(1)->GetOUString() );
+ OUString aStr(rPar.Get(1)->GetOUString());
FilterWhiteSpace( aStr );
if ( aStr.getLength() > 1 && aStr[0] == '&' )
@@ -1677,7 +1586,7 @@ void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
#endif
}
- rPar.Get32(0)->PutDouble( nResult );
+ rPar.Get(0)->PutDouble(nResult);
}
}
@@ -1685,9 +1594,8 @@ void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
// Helper functions for date conversion
sal_Int16 implGetDateDay( double aDate )
{
- aDate -= 2.0; // standardize: 1.1.1900 => 0.0
aDate = floor( aDate );
- Date aRefDate( 1, 1, 1900 );
+ Date aRefDate(1899'12'30);
aRefDate.AddDays( aDate );
sal_Int16 nRet = static_cast<sal_Int16>( aRefDate.GetDay() );
@@ -1696,9 +1604,8 @@ sal_Int16 implGetDateDay( double aDate )
sal_Int16 implGetDateMonth( double aDate )
{
- Date aRefDate( 1,1,1900 );
+ Date aRefDate(1899'12'30);
sal_Int32 nDays = static_cast<sal_Int32>(aDate);
- nDays -= 2; // standardize: 1.1.1900 => 0.0
aRefDate.AddDays( nDays );
sal_Int16 nRet = static_cast<sal_Int16>( aRefDate.GetMonth() );
return nRet;
@@ -1728,28 +1635,26 @@ void SbxDateFromUNODate( SbxValue *pVal, const css::util::Date& aUnoDate)
// Function to convert date to UNO date (com.sun.star.util.Date)
void SbRtl_CDateToUnoDate(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- unoToSbxValue(rPar.Get32(0), Any(SbxDateToUNODate(rPar.Get32(1))));
+ unoToSbxValue(rPar.Get(0), Any(SbxDateToUNODate(rPar.Get(1))));
}
// Function to convert date from UNO date (com.sun.star.util.Date)
void SbRtl_CDateFromUnoDate(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 || rPar.Get32(1)->GetType() != SbxOBJECT )
+ if (rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- Any aAny (sbxToUnoValue(rPar.Get32(1), cppu::UnoType<css::util::Date>::get()));
+ Any aAny(sbxToUnoValue(rPar.Get(1), cppu::UnoType<css::util::Date>::get()));
css::util::Date aUnoDate;
if(aAny >>= aUnoDate)
- SbxDateFromUNODate(rPar.Get32(0), aUnoDate);
+ SbxDateFromUNODate(rPar.Get(0), aUnoDate);
else
SbxBase::SetError( ERRCODE_BASIC_CONVERSION );
}
@@ -1775,28 +1680,26 @@ void SbxDateFromUNOTime( SbxValue *pVal, const css::util::Time& aUnoTime)
// Function to convert date to UNO time (com.sun.star.util.Time)
void SbRtl_CDateToUnoTime(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- unoToSbxValue(rPar.Get32(0), Any(SbxDateToUNOTime(rPar.Get32(1))));
+ unoToSbxValue(rPar.Get(0), Any(SbxDateToUNOTime(rPar.Get(1))));
}
// Function to convert date from UNO time (com.sun.star.util.Time)
void SbRtl_CDateFromUnoTime(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 || rPar.Get32(1)->GetType() != SbxOBJECT )
+ if (rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- Any aAny (sbxToUnoValue(rPar.Get32(1), cppu::UnoType<css::util::Time>::get()));
+ Any aAny(sbxToUnoValue(rPar.Get(1), cppu::UnoType<css::util::Time>::get()));
css::util::Time aUnoTime;
if(aAny >>= aUnoTime)
- SbxDateFromUNOTime(rPar.Get32(0), aUnoTime);
+ SbxDateFromUNOTime(rPar.Get(0), aUnoTime);
else
SbxBase::SetError( ERRCODE_BASIC_CONVERSION );
}
@@ -1831,28 +1734,26 @@ void SbxDateFromUNODateTime( SbxValue *pVal, const css::util::DateTime& aUnoDT)
// Function to convert date to UNO date (com.sun.star.util.Date)
void SbRtl_CDateToUnoDateTime(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- unoToSbxValue(rPar.Get32(0), Any(SbxDateToUNODateTime(rPar.Get32(1))));
+ unoToSbxValue(rPar.Get(0), Any(SbxDateToUNODateTime(rPar.Get(1))));
}
// Function to convert date from UNO date (com.sun.star.util.Date)
void SbRtl_CDateFromUnoDateTime(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 || rPar.Get32(1)->GetType() != SbxOBJECT )
+ if (rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- Any aAny (sbxToUnoValue(rPar.Get32(1), cppu::UnoType<css::util::DateTime>::get()));
+ Any aAny(sbxToUnoValue(rPar.Get(1), cppu::UnoType<css::util::DateTime>::get()));
css::util::DateTime aUnoDT;
if(aAny >>= aUnoDT)
- SbxDateFromUNODateTime(rPar.Get32(0), aUnoDT);
+ SbxDateFromUNODateTime(rPar.Get(0), aUnoDT);
else
SbxBase::SetError( ERRCODE_BASIC_CONVERSION );
}
@@ -1860,9 +1761,9 @@ void SbRtl_CDateFromUnoDateTime(StarBASIC *, SbxArray & rPar, bool)
// Function to convert date to ISO 8601 date format YYYYMMDD
void SbRtl_CDateToIso(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- double aDate = rPar.Get32(1)->GetDate();
+ double aDate = rPar.Get(1)->GetDate();
// Date may actually even be -YYYYYMMDD
char Buffer[11];
@@ -1872,7 +1773,7 @@ void SbRtl_CDateToIso(StarBASIC *, SbxArray & rPar, bool)
static_cast<int>(implGetDateMonth( aDate )),
static_cast<int>(implGetDateDay( aDate )) );
OUString aRetStr = OUString::createFromAscii( Buffer );
- rPar.Get32(0)->PutString( aRetStr );
+ rPar.Get(0)->PutString(aRetStr);
}
else
{
@@ -1884,11 +1785,11 @@ void SbRtl_CDateToIso(StarBASIC *, SbxArray & rPar, bool)
// And even YYMMDD for compatibility, sigh...
void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
do
{
- OUString aStr = rPar.Get32(1)->GetOUString();
+ OUString aStr = rPar.Get(1)->GetOUString();
if (aStr.isEmpty())
break;
@@ -1915,7 +1816,7 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
break;
bool bUseTwoDigitYear = false;
- OUString aYearStr, aMonthStr, aDayStr;
+ std::u16string_view aYearStr, aMonthStr, aDayStr;
if (nLen == 6 || nLen == 8 || nLen == 9)
{
// ((Y)YY)YYMMDD
@@ -1925,9 +1826,9 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
const sal_Int32 nMonthPos = (nLen == 8 ? 4 : (nLen == 6 ? 2 : 5));
if (nMonthPos == 2)
bUseTwoDigitYear = true;
- aYearStr = aStr.copy( 0, nMonthPos );
- aMonthStr = aStr.copy( nMonthPos, 2 );
- aDayStr = aStr.copy( nMonthPos + 2, 2 );
+ aYearStr = aStr.subView( 0, nMonthPos );
+ aMonthStr = aStr.subView( nMonthPos, 2 );
+ aDayStr = aStr.subView( nMonthPos + 2, 2 );
}
else
{
@@ -1938,9 +1839,9 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
if (aStr.indexOf('-', nMonthSep + 1) != nMonthSep + 3)
break;
- aYearStr = aStr.copy( 0, nMonthSep );
- aMonthStr = aStr.copy( nMonthSep + 1, 2 );
- aDayStr = aStr.copy( nMonthSep + 4, 2 );
+ aYearStr = aStr.subView( 0, nMonthSep );
+ aMonthStr = aStr.subView( nMonthSep + 1, 2 );
+ aDayStr = aStr.subView( nMonthSep + 4, 2 );
if ( !comphelper::string::isdigitAsciiString(aYearStr) ||
!comphelper::string::isdigitAsciiString(aMonthStr) ||
!comphelper::string::isdigitAsciiString(aDayStr))
@@ -1948,12 +1849,12 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
}
double dDate;
- if (!implDateSerial( static_cast<sal_Int16>(nSign * aYearStr.toInt32()),
- static_cast<sal_Int16>(aMonthStr.toInt32()), static_cast<sal_Int16>(aDayStr.toInt32()),
+ if (!implDateSerial( static_cast<sal_Int16>(nSign * o3tl::toInt32(aYearStr)),
+ static_cast<sal_Int16>(o3tl::toInt32(aMonthStr)), static_cast<sal_Int16>(o3tl::toInt32(aDayStr)),
bUseTwoDigitYear, SbDateCorrection::None, dDate ))
break;
- rPar.Get32(0)->PutDate( dDate );
+ rPar.Get(0)->PutDate(dDate);
return;
}
@@ -1969,50 +1870,47 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_DateSerial(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 4 )
+ if (rPar.Count() < 4)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int16 nYear = rPar.Get32(1)->GetInteger();
- sal_Int16 nMonth = rPar.Get32(2)->GetInteger();
- sal_Int16 nDay = rPar.Get32(3)->GetInteger();
+ sal_Int16 nYear = rPar.Get(1)->GetInteger();
+ sal_Int16 nMonth = rPar.Get(2)->GetInteger();
+ sal_Int16 nDay = rPar.Get(3)->GetInteger();
double dDate;
if( implDateSerial( nYear, nMonth, nDay, true, SbDateCorrection::RollOver, dDate ) )
{
- rPar.Get32(0)->PutDate( dDate );
+ rPar.Get(0)->PutDate(dDate);
}
}
void SbRtl_TimeSerial(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 4 )
+ if (rPar.Count() < 4)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int16 nHour = rPar.Get32(1)->GetInteger();
+ sal_Int16 nHour = rPar.Get(1)->GetInteger();
if ( nHour == 24 )
{
nHour = 0; // because of UNO DateTimes, which go till 24 o'clock
}
- sal_Int16 nMinute = rPar.Get32(2)->GetInteger();
- sal_Int16 nSecond = rPar.Get32(3)->GetInteger();
+ sal_Int16 nMinute = rPar.Get(2)->GetInteger();
+ sal_Int16 nSecond = rPar.Get(3)->GetInteger();
if ((nHour < 0 || nHour > 23) ||
(nMinute < 0 || nMinute > 59 ) ||
(nSecond < 0 || nSecond > 59 ))
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutDate( implTimeSerial(nHour, nMinute, nSecond) ); // JSM
+ rPar.Get(0)->PutDate(implTimeSerial(nHour, nMinute, nSecond)); // JSM
}
void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
@@ -2033,7 +1931,7 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
LanguageType eLangType = Application::GetSettings().GetLanguageTag().getLanguageType();
sal_uInt32 nIndex = pFormatter->GetStandardIndex( eLangType);
double fResult;
- OUString aStr( rPar.Get32(1)->GetOUString() );
+ OUString aStr(rPar.Get(1)->GetOUString());
bool bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
SvNumFormatType nType = pFormatter->GetType( nIndex );
@@ -2062,7 +1960,7 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
fResult = ceil( fResult );
}
}
- rPar.Get32(0)->PutDate( fResult );
+ rPar.Get(0)->PutDate(fResult);
}
else
{
@@ -2073,7 +1971,7 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_TimeValue(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
@@ -2090,7 +1988,7 @@ void SbRtl_TimeValue(StarBASIC *, SbxArray & rPar, bool)
sal_uInt32 nIndex = 0;
double fResult;
- bool bSuccess = pFormatter->IsNumberFormat( rPar.Get32(1)->GetOUString(),
+ bool bSuccess = pFormatter->IsNumberFormat(rPar.Get(1)->GetOUString(),
nIndex, fResult );
SvNumFormatType nType = pFormatter->GetType(nIndex);
if(bSuccess && (nType==SvNumFormatType::TIME||nType==SvNumFormatType::DATETIME))
@@ -2100,7 +1998,7 @@ void SbRtl_TimeValue(StarBASIC *, SbxArray & rPar, bool)
// cut days
fResult = fmod( fResult, 1 );
}
- rPar.Get32(0)->PutDate( fResult );
+ rPar.Get(0)->PutDate(fResult);
}
else
{
@@ -2111,30 +2009,30 @@ void SbRtl_TimeValue(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Day(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- SbxVariableRef pArg = rPar.Get32(1);
+ SbxVariableRef pArg = rPar.Get(1);
double aDate = pArg->GetDate();
sal_Int16 nDay = implGetDateDay( aDate );
- rPar.Get32(0)->PutInteger( nDay );
+ rPar.Get(0)->PutInteger(nDay);
}
}
void SbRtl_Year(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nYear = implGetDateYear( rPar.Get32(1)->GetDate() );
- rPar.Get32(0)->PutInteger( nYear );
+ sal_Int16 nYear = implGetDateYear(rPar.Get(1)->GetDate());
+ rPar.Get(0)->PutInteger(nYear);
}
}
@@ -2149,42 +2047,42 @@ sal_Int16 implGetHour( double dDate )
void SbRtl_Hour(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- double nArg = rPar.Get32(1)->GetDate();
+ double nArg = rPar.Get(1)->GetDate();
sal_Int16 nHour = implGetHour( nArg );
- rPar.Get32(0)->PutInteger( nHour );
+ rPar.Get(0)->PutInteger(nHour);
}
}
void SbRtl_Minute(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- double nArg = rPar.Get32(1)->GetDate();
+ double nArg = rPar.Get(1)->GetDate();
sal_Int16 nMin = implGetMinute( nArg );
- rPar.Get32(0)->PutInteger( nMin );
+ rPar.Get(0)->PutInteger(nMin);
}
}
void SbRtl_Month(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nMonth = implGetDateMonth( rPar.Get32(1)->GetDate() );
- rPar.Get32(0)->PutInteger( nMonth );
+ sal_Int16 nMonth = implGetDateMonth(rPar.Get(1)->GetDate());
+ rPar.Get(0)->PutInteger(nMonth);
}
}
@@ -2204,15 +2102,15 @@ sal_Int16 implGetSecond( double dDate )
void SbRtl_Second(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- double nArg = rPar.Get32(1)->GetDate();
+ double nArg = rPar.Get(1)->GetDate();
sal_Int16 nSecond = implGetSecond( nArg );
- rPar.Get32(0)->PutInteger( nSecond );
+ rPar.Get(0)->PutInteger(nSecond);
}
}
@@ -2231,10 +2129,7 @@ double Now_Impl()
// Date Now()
-void SbRtl_Now(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutDate( Now_Impl() );
-}
+void SbRtl_Now(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutDate(Now_Impl()); }
// Date Time()
@@ -2243,7 +2138,7 @@ void SbRtl_Time(StarBASIC *, SbxArray & rPar, bool bWrite)
if ( !bWrite )
{
tools::Time aTime( tools::Time::SYSTEM );
- SbxVariable* pMeth = rPar.Get32(0);
+ SbxVariable* pMeth = rPar.Get(0);
OUString aRes;
if( pMeth->IsFixed() )
{
@@ -2293,7 +2188,7 @@ void SbRtl_Timer(StarBASIC *, SbxArray & rPar, bool)
nSeconds *= 3600;
nSeconds += aTime.GetMin() * 60;
nSeconds += aTime.GetSec();
- rPar.Get32(0)->PutDate( static_cast<double>(nSeconds) );
+ rPar.Get(0)->PutDate(static_cast<double>(nSeconds));
}
@@ -2303,7 +2198,7 @@ void SbRtl_Date(StarBASIC *, SbxArray & rPar, bool bWrite)
{
Date aToday( Date::SYSTEM );
double nDays = static_cast<double>(GetDayDiff( aToday ));
- SbxVariable* pMeth = rPar.Get32(0);
+ SbxVariable* pMeth = rPar.Get(0);
if( pMeth->IsString() )
{
OUString aRes;
@@ -2338,176 +2233,144 @@ void SbRtl_Date(StarBASIC *, SbxArray & rPar, bool bWrite)
void SbRtl_IsArray(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- rPar.Get32(0)->PutBool((rPar.Get32(1)->GetType() & SbxARRAY) != 0);
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ rPar.Get(0)->PutBool((rPar.Get(1)->GetType() & SbxARRAY) != 0);
}
void SbRtl_IsObject(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- SbxVariable* pVar = rPar.Get32(1);
- bool bObject = pVar->IsObject();
- SbxBase* pObj = (bObject ? pVar->GetObject() : nullptr);
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- if( auto pUnoClass = dynamic_cast<SbUnoClass*>( pObj) )
- {
- bObject = pUnoClass->getUnoClass().is();
- }
- rPar.Get32(0)->PutBool( bObject );
+ SbxVariable* pVar = rPar.Get(1);
+ bool bObject = pVar->IsObject();
+ SbxBase* pObj = (bObject ? pVar->GetObject() : nullptr);
+
+ if( auto pUnoClass = dynamic_cast<SbUnoClass*>( pObj) )
+ {
+ bObject = pUnoClass->getUnoClass().is();
}
+ rPar.Get(0)->PutBool(bObject);
}
void SbRtl_IsDate(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ // #46134 only string is converted, all other types result in sal_False
+ SbxVariableRef xArg = rPar.Get(1);
+ SbxDataType eType = xArg->GetType();
+ bool bDate = false;
+
+ if( eType == SbxDATE )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ bDate = true;
}
- else
+ else if( eType == SbxSTRING )
{
- // #46134 only string is converted, all other types result in sal_False
- SbxVariableRef xArg = rPar.Get32(1);
- SbxDataType eType = xArg->GetType();
- bool bDate = false;
-
- if( eType == SbxDATE )
- {
- bDate = true;
- }
- else if( eType == SbxSTRING )
- {
- ErrCode nPrevError = SbxBase::GetError();
- SbxBase::ResetError();
+ ErrCode nPrevError = SbxBase::GetError();
+ SbxBase::ResetError();
- // force conversion of the parameter to SbxDATE
- xArg->SbxValue::GetDate();
+ // force conversion of the parameter to SbxDATE
+ xArg->SbxValue::GetDate();
- bDate = !SbxBase::IsError();
+ bDate = !SbxBase::IsError();
- SbxBase::ResetError();
- SbxBase::SetError( nPrevError );
- }
- rPar.Get32(0)->PutBool( bDate );
+ SbxBase::ResetError();
+ SbxBase::SetError( nPrevError );
}
+ rPar.Get(0)->PutBool(bDate);
}
void SbRtl_IsEmpty(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pVar = nullptr;
+ if( SbiRuntime::isVBAEnabled() )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ pVar = getDefaultProp(rPar.Get(1));
+ }
+ if ( pVar )
+ {
+ pVar->Broadcast( SfxHintId::BasicDataWanted );
+ rPar.Get(0)->PutBool(pVar->IsEmpty());
}
else
{
- SbxVariable* pVar = nullptr;
- if( SbiRuntime::isVBAEnabled() )
- {
- pVar = getDefaultProp( rPar.Get32(1) );
- }
- if ( pVar )
- {
- pVar->Broadcast( SfxHintId::BasicDataWanted );
- rPar.Get32(0)->PutBool( pVar->IsEmpty() );
- }
- else
- {
- rPar.Get32(0)->PutBool( rPar.Get32(1)->IsEmpty() );
- }
+ rPar.Get(0)->PutBool(rPar.Get(1)->IsEmpty());
}
}
void SbRtl_IsError(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pVar = rPar.Get(1);
+ SbUnoObject* pObj = dynamic_cast<SbUnoObject*>( pVar );
+ if ( !pObj )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ if ( SbxBase* pBaseObj = (pVar->IsObject() ? pVar->GetObject() : nullptr) )
+ {
+ pObj = dynamic_cast<SbUnoObject*>( pBaseObj );
+ }
+ }
+ uno::Reference< script::XErrorQuery > xError;
+ if ( pObj )
+ {
+ xError.set( pObj->getUnoAny(), uno::UNO_QUERY );
+ }
+ if ( xError.is() )
+ {
+ rPar.Get(0)->PutBool(xError->hasError());
}
else
{
- SbxVariable* pVar =rPar.Get32(1);
- SbUnoObject* pObj = dynamic_cast<SbUnoObject*>( pVar );
- if ( !pObj )
- {
- if ( SbxBase* pBaseObj = (pVar->IsObject() ? pVar->GetObject() : nullptr) )
- {
- pObj = dynamic_cast<SbUnoObject*>( pBaseObj );
- }
- }
- uno::Reference< script::XErrorQuery > xError;
- if ( pObj )
- {
- xError.set( pObj->getUnoAny(), uno::UNO_QUERY );
- }
- if ( xError.is() )
- {
- rPar.Get32(0)->PutBool( xError->hasError() );
- }
- else
- {
- rPar.Get32(0)->PutBool( rPar.Get32(1)->IsErr() );
- }
+ rPar.Get(0)->PutBool(rPar.Get(1)->IsErr());
}
}
void SbRtl_IsNull(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ // #51475 because of Uno-objects return true
+ // even if the pObj value is NULL
+ SbxVariableRef pArg = rPar.Get(1);
+ bool bNull = rPar.Get(1)->IsNull();
+ if( !bNull && pArg->GetType() == SbxOBJECT )
{
- // #51475 because of Uno-objects return true
- // even if the pObj value is NULL
- SbxVariableRef pArg = rPar.Get32(1);
- bool bNull = rPar.Get32(1)->IsNull();
- if( !bNull && pArg->GetType() == SbxOBJECT )
+ SbxBase* pObj = pArg->GetObject();
+ if( !pObj )
{
- SbxBase* pObj = pArg->GetObject();
- if( !pObj )
- {
- bNull = true;
- }
+ bNull = true;
}
- rPar.Get32(0)->PutBool( bNull );
}
+ rPar.Get(0)->PutBool(bNull);
}
void SbRtl_IsNumeric(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- rPar.Get32(0)->PutBool( rPar.Get32(1)->IsNumericRTL() );
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ rPar.Get(0)->PutBool(rPar.Get(1)->IsNumericRTL());
}
void SbRtl_IsMissing(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- // #57915 Missing is reported by an error
- rPar.Get32(0)->PutBool( rPar.Get32(1)->IsErr() );
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ // #57915 Missing is reported by an error
+ rPar.Get(0)->PutBool(rPar.Get(1)->IsErr());
}
// Function looks for wildcards, removes them and always returns the pure path
@@ -2518,7 +2381,7 @@ static OUString implSetupWildcard(const OUString& rFileParam, SbiRTLData& rRTLDa
static const char cWild1 = '*';
static const char cWild2 = '?';
- rRTLData.pWildCard.reset();
+ rRTLData.moWildCard.reset();
rRTLData.sFullNameToBeChecked.clear();
OUString aFileParam = rFileParam;
@@ -2572,7 +2435,7 @@ static OUString implSetupWildcard(const OUString& rFileParam, SbiRTLData& rRTLDa
// invalid anyway because it was not accepted by OSL before
if (aPureFileName != "*")
{
- rRTLData.pWildCard = std::make_unique<WildCard>(aPureFileName);
+ rRTLData.moWildCard.emplace(aPureFileName);
}
return aPathStr;
}
@@ -2581,15 +2444,15 @@ static bool implCheckWildcard(std::u16string_view rName, SbiRTLData const& rRTLD
{
bool bMatch = true;
- if (rRTLData.pWildCard)
+ if (rRTLData.moWildCard)
{
- bMatch = rRTLData.pWildCard->Matches(rName);
+ bMatch = rRTLData.moWildCard->Matches(rName);
}
return bMatch;
}
-static bool isRootDir( const OUString& aDirURLStr )
+static bool isRootDir( std::u16string_view aDirURLStr )
{
INetURLObject aDirURLObj( aDirURLStr );
bool bRoot = false;
@@ -2624,7 +2487,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
{
OUString aPath;
- const sal_uInt32 nParCount = rPar.Count32();
+ const sal_uInt32 nParCount = rPar.Count();
if( nParCount > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2640,7 +2503,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
{
if ( nParCount >= 2 )
{
- OUString aFileParam = rPar.Get32(1)->GetOUString();
+ OUString aFileParam = rPar.Get(1)->GetOUString();
OUString aFileURLStr = implSetupWildcard(aFileParam, rRTLData);
if (!rRTLData.sFullNameToBeChecked.isEmpty())
@@ -2656,7 +2519,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
aNameOnlyStr = aFileURL.getName( INetURLObject::LAST_SEGMENT,
true, INetURLObject::DecodeMechanism::WithCharset );
}
- rPar.Get32(0)->PutString( aNameOnlyStr );
+ rPar.Get(0)->PutString(aNameOnlyStr);
return;
}
@@ -2671,14 +2534,14 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
}
else
{
- rPar.Get32(0)->PutString( "" );
+ rPar.Get(0)->PutString("");
}
SbAttributes nFlags = SbAttributes::NONE;
if ( nParCount > 2 )
{
rRTLData.nDirFlags = nFlags
- = static_cast<SbAttributes>(rPar.Get32(2)->GetInteger());
+ = static_cast<SbAttributes>(rPar.Get(2)->GetInteger());
}
else
{
@@ -2778,7 +2641,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
break;
}
}
- rPar.Get32(0)->PutString( aPath );
+ rPar.Get(0)->PutString(aPath);
}
}
else
@@ -2786,7 +2649,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
// TODO: OSL
if ( nParCount >= 2 )
{
- OUString aFileParam = rPar.Get32(1)->GetOUString();
+ OUString aFileParam = rPar.Get(1)->GetOUString();
OUString aDirURL = implSetupWildcard(aFileParam, rRTLData);
@@ -2794,7 +2657,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
if ( nParCount > 2 )
{
rRTLData.nDirFlags = nFlags
- = static_cast<SbAttributes>(rPar.Get32(2)->GetInteger());
+ = static_cast<SbAttributes>(rPar.Get(2)->GetInteger());
}
else
{
@@ -2808,7 +2671,7 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
if( nRet != FileBase::E_None )
{
rRTLData.pDir.reset();
- rPar.Get32(0)->PutString( OUString() );
+ rPar.Get(0)->PutString(OUString());
return;
}
@@ -2889,18 +2752,15 @@ void SbRtl_Dir(StarBASIC *, SbxArray & rPar, bool)
break;
}
}
- rPar.Get32(0)->PutString( aPath );
+ rPar.Get(0)->PutString(aPath);
}
}
}
-void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
+void SbRtl_GetAttr(StarBASIC *, SbxArray & rPar, bool)
{
- (void)pBasic;
- (void)bWrite;
-
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
sal_Int16 nFlags = 0;
@@ -2909,7 +2769,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
#if defined(_WIN32)
if( SbiRuntime::isVBAEnabled() )
{
- OUString aPathURL = getFullPath( rPar.Get32(1)->GetOUString() );
+ OUString aPathURL = getFullPath(rPar.Get(1)->GetOUString());
OUString aPath;
FileBase::getSystemPathFromFileURL( aPathURL, aPath );
DWORD nRealFlags = GetFileAttributesW (o3tl::toW(aPath.getStr()));
@@ -2925,7 +2785,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
{
StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
}
- rPar.Get32(0)->PutInteger( nFlags );
+ rPar.Get(0)->PutInteger(nFlags);
return;
}
@@ -2938,14 +2798,13 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
{
try
{
- OUString aPath = getFullPath( rPar.Get32(1)->GetOUString() );
+ OUString aPath = getFullPath(rPar.Get(1)->GetOUString());
bool bExists = false;
try { bExists = xSFI->exists( aPath ); }
catch(const Exception & ) {}
if( !bExists )
{
- StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
}
bool bReadOnly = xSFI->isReadOnly( aPath );
@@ -2973,7 +2832,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
else
{
DirectoryItem aItem;
- (void)DirectoryItem::get( getFullPath( rPar.Get32(1)->GetOUString() ), aItem );
+ (void)DirectoryItem::get(getFullPath(rPar.Get(1)->GetOUString()), aItem);
FileStatus aFileStatus( osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type );
(void)aItem.getFileStatus( aFileStatus );
sal_uInt64 nAttributes = aFileStatus.getAttributes();
@@ -2990,7 +2849,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
nFlags |= sal_uInt16(SbAttributes::DIRECTORY);
}
}
- rPar.Get32(0)->PutInteger( nFlags );
+ rPar.Get(0)->PutInteger(nFlags);
}
else
{
@@ -3001,13 +2860,13 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- OUString aPath = rPar.Get32(1)->GetOUString();
+ OUString aPath = rPar.Get(1)->GetOUString();
tools::Time aTime( tools::Time::EMPTY );
Date aDate( Date::EMPTY );
if( hasUno() )
@@ -3093,7 +2952,7 @@ void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool)
pFormatter->GetOutputString( fSerial, nIndex, aRes, &pCol );
}
- rPar.Get32(0)->PutString( aRes );
+ rPar.Get(0)->PutString(aRes);
}
}
@@ -3101,19 +2960,18 @@ void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_EOF(StarBASIC *, SbxArray & rPar, bool)
{
// No changes for UCB
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nChannel = rPar.Get32(1)->GetInteger();
+ sal_Int16 nChannel = rPar.Get(1)->GetInteger();
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIO->GetStream( nChannel );
if ( !pSbStrm )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
}
bool beof;
SvStream* pSvStrm = pSbStrm->GetStrm();
@@ -3131,7 +2989,7 @@ void SbRtl_EOF(StarBASIC *, SbxArray & rPar, bool)
{
beof = pSvStrm->eof(); // for binary data!
}
- rPar.Get32(0)->PutBool( beof );
+ rPar.Get(0)->PutBool(beof);
}
}
@@ -3142,22 +3000,21 @@ void SbRtl_FileAttr(StarBASIC *, SbxArray & rPar, bool)
// not touched by the adjustment to virtual URLs, as it only works on
// already opened files and the name doesn't matter there.
- if ( rPar.Count32() != 3 )
+ if (rPar.Count() != 3)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nChannel = rPar.Get32(1)->GetInteger();
+ sal_Int16 nChannel = rPar.Get(1)->GetInteger();
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIO->GetStream( nChannel );
if ( !pSbStrm )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
}
sal_Int16 nRet;
- if ( rPar.Get32(2)->GetInteger() == 1 )
+ if (rPar.Get(2)->GetInteger() == 1)
{
nRet = static_cast<sal_Int16>(pSbStrm->GetMode());
}
@@ -3165,25 +3022,24 @@ void SbRtl_FileAttr(StarBASIC *, SbxArray & rPar, bool)
{
nRet = 0; // System file handle not supported
}
- rPar.Get32(0)->PutInteger( nRet );
+ rPar.Get(0)->PutInteger(nRet);
}
}
void SbRtl_Loc(StarBASIC *, SbxArray & rPar, bool)
{
// No changes for UCB
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nChannel = rPar.Get32(1)->GetInteger();
+ sal_Int16 nChannel = rPar.Get(1)->GetInteger();
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIO->GetStream( nChannel );
if ( !pSbStrm )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
}
SvStream* pSvStrm = pSbStrm->GetStrm();
std::size_t nPos;
@@ -3209,30 +3065,29 @@ void SbRtl_Loc(StarBASIC *, SbxArray & rPar, bool)
{
nPos = pSvStrm->Tell();
}
- rPar.Get32(0)->PutLong( static_cast<sal_Int32>(nPos) );
+ rPar.Get(0)->PutLong(static_cast<sal_Int32>(nPos));
}
}
void SbRtl_Lof(StarBASIC *, SbxArray & rPar, bool)
{
// No changes for UCB
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- sal_Int16 nChannel = rPar.Get32(1)->GetInteger();
+ sal_Int16 nChannel = rPar.Get(1)->GetInteger();
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIO->GetStream( nChannel );
if ( !pSbStrm )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
}
SvStream* pSvStrm = pSbStrm->GetStrm();
sal_uInt64 const nLen = pSvStrm->TellEnd();
- rPar.Get32(0)->PutLong( static_cast<sal_Int32>(nLen) );
+ rPar.Get(0)->PutLong(static_cast<sal_Int32>(nLen));
}
}
@@ -3240,19 +3095,17 @@ void SbRtl_Lof(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Seek(StarBASIC *, SbxArray & rPar, bool)
{
// No changes for UCB
- int nArgs = static_cast<int>(rPar.Count32());
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs < 2 || nArgs > 3 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int16 nChannel = rPar.Get32(1)->GetInteger();
+ sal_Int16 nChannel = rPar.Get(1)->GetInteger();
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIO->GetStream( nChannel );
if ( !pSbStrm )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
}
SvStream* pStrm = pSbStrm->GetStrm();
@@ -3264,15 +3117,14 @@ void SbRtl_Seek(StarBASIC *, SbxArray & rPar, bool)
nPos = nPos / pSbStrm->GetBlockLen();
}
nPos++; // Basic counts from 1
- rPar.Get32(0)->PutLong( static_cast<sal_Int32>(nPos) );
+ rPar.Get(0)->PutLong(static_cast<sal_Int32>(nPos));
}
else // Seek-Statement
{
- sal_Int32 nPos = rPar.Get32(2)->GetLong();
+ sal_Int32 nPos = rPar.Get(2)->GetLong();
if ( nPos < 1 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
nPos--; // Basic counts from 1, SvStreams count from 0
pSbStrm->SetExpandOnWriteTo( 0 );
@@ -3287,7 +3139,7 @@ void SbRtl_Seek(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Format(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32();
+ const sal_uInt32 nArgCount = rPar.Count();
if ( nArgCount < 2 || nArgCount > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -3297,37 +3149,56 @@ void SbRtl_Format(StarBASIC *, SbxArray & rPar, bool)
OUString aResult;
if( nArgCount == 2 )
{
- rPar.Get32(1)->Format( aResult );
+ rPar.Get(1)->Format(aResult);
}
else
{
- OUString aFmt( rPar.Get32(2)->GetOUString() );
- rPar.Get32(1)->Format( aResult, &aFmt );
+ OUString aFmt(rPar.Get(2)->GetOUString());
+ rPar.Get(1)->Format(aResult, &aFmt);
}
- rPar.Get32(0)->PutString( aResult );
+ rPar.Get(0)->PutString(aResult);
}
}
-// https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/formatnumber-function
-void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
+static bool IsMissing(SbxArray& rPar, const sal_uInt32 i)
{
- const sal_uInt32 nArgCount = rPar.Count32();
+ const sal_uInt32 nArgCount = rPar.Count();
+ if (nArgCount <= i)
+ return true;
+
+ SbxVariable* aPar = rPar.Get(i);
+ return (aPar->GetType() == SbxERROR && SbiRuntime::IsMissing(aPar, 1));
+}
+
+static sal_Int16 GetOptionalIntegerParamOrDefault(SbxArray& rPar, const sal_uInt32 i,
+ const sal_Int16 defaultValue)
+{
+ return IsMissing(rPar, i) ? defaultValue : rPar.Get(i)->GetInteger();
+}
+
+static OUString GetOptionalOUStringParamOrDefault(SbxArray& rPar, const sal_uInt32 i,
+ const OUString& defaultValue)
+{
+ return IsMissing(rPar, i) ? defaultValue : rPar.Get(i)->GetOUString();
+}
+
+static void lcl_FormatNumberPercent(SbxArray& rPar, bool isPercent)
+{
+ const sal_uInt32 nArgCount = rPar.Count();
if (nArgCount < 2 || nArgCount > 6)
{
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
// The UI locale never changes -> we can use static value here
static const LocaleDataWrapper localeData(Application::GetSettings().GetUILanguageTag());
sal_Int16 nNumDigitsAfterDecimal = -1;
- if (nArgCount > 2 && !rPar.Get32(2)->IsEmpty())
+ if (nArgCount > 2 && !rPar.Get(2)->IsEmpty())
{
- nNumDigitsAfterDecimal = rPar.Get32(2)->GetInteger();
+ nNumDigitsAfterDecimal = rPar.Get(2)->GetInteger();
if (nNumDigitsAfterDecimal < -1)
{
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
else if (nNumDigitsAfterDecimal > 255)
nNumDigitsAfterDecimal %= 256;
@@ -3336,9 +3207,9 @@ void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
nNumDigitsAfterDecimal = LocaleDataWrapper::getNumDigits();
bool bIncludeLeadingDigit = LocaleDataWrapper::isNumLeadingZero();
- if (nArgCount > 3 && !rPar.Get32(3)->IsEmpty())
+ if (nArgCount > 3 && !rPar.Get(3)->IsEmpty())
{
- switch (rPar.Get32(3)->GetInteger())
+ switch (rPar.Get(3)->GetInteger())
{
case ooo::vba::VbTriState::vbFalse:
bIncludeLeadingDigit = false;
@@ -3350,15 +3221,14 @@ void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
// do nothing;
break;
default:
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
}
bool bUseParensForNegativeNumbers = false;
- if (nArgCount > 4 && !rPar.Get32(4)->IsEmpty())
+ if (nArgCount > 4 && !rPar.Get(4)->IsEmpty())
{
- switch (rPar.Get32(4)->GetInteger())
+ switch (rPar.Get(4)->GetInteger())
{
case ooo::vba::VbTriState::vbFalse:
case ooo::vba::VbTriState::vbUseDefault:
@@ -3368,15 +3238,14 @@ void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
bUseParensForNegativeNumbers = true;
break;
default:
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
}
bool bGroupDigits = false;
- if (nArgCount > 5 && !rPar.Get32(5)->IsEmpty())
+ if (nArgCount > 5 && !rPar.Get(5)->IsEmpty())
{
- switch (rPar.Get32(5)->GetInteger())
+ switch (rPar.Get(5)->GetInteger())
{
case ooo::vba::VbTriState::vbFalse:
case ooo::vba::VbTriState::vbUseDefault:
@@ -3386,53 +3255,59 @@ void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
bGroupDigits = true;
break;
default:
- StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
- return;
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
}
}
- double fVal = rPar.Get32(1)->GetDouble();
+ double fVal = rPar.Get(1)->GetDouble();
+ if (isPercent)
+ fVal *= 100;
const bool bNegative = fVal < 0;
if (bNegative)
fVal = fabs(fVal); // Always work with non-negatives, to easily handle leading zero
static const sal_Unicode decSep = localeData.getNumDecimalSep().toChar();
- OUString aResult = rtl::math::doubleToUString(
+ OUStringBuffer aResult;
+ rtl::math::doubleToUStringBuffer(aResult,
fVal, rtl_math_StringFormat_F, nNumDigitsAfterDecimal, decSep,
bGroupDigits ? localeData.getDigitGrouping().getConstArray() : nullptr,
localeData.getNumThousandSep().toChar());
- if (!bIncludeLeadingDigit && aResult.getLength() > 1 && aResult.startsWith("0"))
- aResult = aResult.copy(1);
+ if (!bIncludeLeadingDigit && aResult.getLength() > 1)
+ aResult.stripStart('0');
if (nNumDigitsAfterDecimal > 0)
{
- sal_Int32 nActualDigits;
const sal_Int32 nSepPos = aResult.indexOf(decSep);
- if (nSepPos == -1)
- nActualDigits = 0;
- else
- nActualDigits = aResult.getLength() - nSepPos - 1;
// VBA allows up to 255 digits; rtl::math::doubleToUString outputs up to 15 digits
// for ~small numbers, so pad them as appropriate.
- if (nActualDigits < nNumDigitsAfterDecimal)
- {
- OUStringBuffer sBuf;
- comphelper::string::padToLength(sBuf, nNumDigitsAfterDecimal - nActualDigits, '0');
- aResult += sBuf;
- }
+ if (nSepPos >= 0)
+ comphelper::string::padToLength(aResult, nSepPos + nNumDigitsAfterDecimal + 1, '0');
}
if (bNegative)
{
if (bUseParensForNegativeNumbers)
- aResult = "(" + aResult + ")";
+ aResult.insert(0, '(').append(')');
else
- aResult = "-" + aResult;
+ aResult.insert(0, '-');
}
+ if (isPercent)
+ aResult.append('%');
+ rPar.Get(0)->PutString(aResult.makeStringAndClear());
+}
- rPar.Get32(0)->PutString(aResult);
+// https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/formatnumber-function
+void SbRtl_FormatNumber(StarBASIC*, SbxArray& rPar, bool)
+{
+ return lcl_FormatNumberPercent(rPar, false);
+}
+
+// https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/formatpercent-function
+void SbRtl_FormatPercent(StarBASIC*, SbxArray& rPar, bool)
+{
+ return lcl_FormatNumberPercent(rPar, true);
}
namespace {
@@ -3463,35 +3338,39 @@ struct RandomNumberGenerator
}
};
-class theRandomNumberGenerator : public rtl::Static<RandomNumberGenerator, theRandomNumberGenerator> {};
+RandomNumberGenerator& theRandomNumberGenerator()
+{
+ static RandomNumberGenerator theGenerator;
+ return theGenerator;
+}
}
void SbRtl_Randomize(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() > 2 )
+ if (rPar.Count() > 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- if( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- int nSeed = static_cast<int>(rPar.Get32(1)->GetInteger());
- theRandomNumberGenerator::get().global_rng.seed(nSeed);
+ int nSeed = static_cast<int>(rPar.Get(1)->GetInteger());
+ theRandomNumberGenerator().global_rng.seed(nSeed);
}
// without parameter, no need to do anything - RNG is seeded at first use
}
void SbRtl_Rnd(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() > 2 )
+ if (rPar.Count() > 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
std::uniform_real_distribution<double> dist(0.0, 1.0);
- double const tmp(dist(theRandomNumberGenerator::get().global_rng));
- rPar.Get32(0)->PutDouble(tmp);
+ double const tmp(dist(theRandomNumberGenerator().global_rng));
+ rPar.Get(0)->PutDouble(tmp);
}
}
@@ -3507,21 +3386,21 @@ void SbRtl_Rnd(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Shell(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32();
+ const sal_uInt32 nArgCount = rPar.Count();
if ( nArgCount < 2 || nArgCount > 5 )
{
- rPar.Get32(0)->PutLong(0);
+ rPar.Get(0)->PutLong(0);
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
oslProcessOption nOptions = osl_Process_SEARCHPATH | osl_Process_DETACHED;
- OUString aCmdLine = rPar.Get32(1)->GetOUString();
+ OUString aCmdLine = rPar.Get(1)->GetOUString();
// attach additional parameters - everything must be parsed anyway
if( nArgCount >= 4 )
{
- OUString tmp = rPar.Get32(3)->GetOUString().trim();
+ OUString tmp = rPar.Get(3)->GetOUString().trim();
if (!tmp.isEmpty())
{
aCmdLine += " " + tmp;
@@ -3592,7 +3471,7 @@ void SbRtl_Shell(StarBASIC *, SbxArray & rPar, bool)
sal_Int16 nWinStyle = 0;
if( nArgCount >= 3 )
{
- nWinStyle = rPar.Get32(2)->GetInteger();
+ nWinStyle = rPar.Get(2)->GetInteger();
switch( nWinStyle )
{
case 2:
@@ -3609,7 +3488,7 @@ void SbRtl_Shell(StarBASIC *, SbxArray & rPar, bool)
bool bSync = false;
if( nArgCount >= 5 )
{
- bSync = rPar.Get32(4)->GetBool();
+ bSync = rPar.Get(4)->GetBool();
}
if( bSync )
{
@@ -3664,21 +3543,21 @@ void SbRtl_Shell(StarBASIC *, SbxArray & rPar, bool)
}
else
{
- rPar.Get32(0)->PutLong( 0 );
+ rPar.Get(0)->PutLong(0);
}
}
}
void SbRtl_VarType(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- SbxDataType eType = rPar.Get32(1)->GetType();
- rPar.Get32(0)->PutInteger( static_cast<sal_Int16>(eType) );
+ SbxDataType eType = rPar.Get(1)->GetType();
+ rPar.Get(0)->PutInteger(static_cast<sal_Int16>(eType));
}
}
@@ -3728,7 +3607,7 @@ OUString getBasicTypeName( SbxDataType eType )
};
size_t nPos = static_cast<size_t>(eType) & 0x0FFF;
- const size_t nTypeNameCount = SAL_N_ELEMENTS( pTypeNames );
+ const size_t nTypeNameCount = std::size( pTypeNames );
if ( nPos >= nTypeNameCount )
{
nPos = nTypeNameCount - 1;
@@ -3801,19 +3680,19 @@ static OUString getObjectTypeName( SbxVariable* pVar )
void SbRtl_TypeName(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- SbxDataType eType = rPar.Get32(1)->GetType();
+ SbxDataType eType = rPar.Get(1)->GetType();
bool bIsArray = ( ( eType & SbxARRAY ) != 0 );
OUString aRetStr;
if ( SbiRuntime::isVBAEnabled() && eType == SbxOBJECT )
{
- aRetStr = getObjectTypeName( rPar.Get32(1) );
+ aRetStr = getObjectTypeName(rPar.Get(1));
}
else
{
@@ -3823,33 +3702,32 @@ void SbRtl_TypeName(StarBASIC *, SbxArray & rPar, bool)
{
aRetStr += "()";
}
- rPar.Get32(0)->PutString( aRetStr );
+ rPar.Get(0)->PutString(aRetStr);
}
}
void SbRtl_Len(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- const OUString& rStr = rPar.Get32(1)->GetOUString();
- rPar.Get32(0)->PutLong( rStr.getLength() );
+ const OUString& rStr = rPar.Get(1)->GetOUString();
+ rPar.Get(0)->PutLong(rStr.getLength());
}
}
void SbRtl_DDEInitiate(StarBASIC *, SbxArray & rPar, bool)
{
- int nArgs = static_cast<int>(rPar.Count32());
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 3 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- const OUString& rApp = rPar.Get32(1)->GetOUString();
- const OUString& rTopic = rPar.Get32(2)->GetOUString();
+ const OUString& rApp = rPar.Get(1)->GetOUString();
+ const OUString& rTopic = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
size_t nChannel;
@@ -3860,20 +3738,20 @@ void SbRtl_DDEInitiate(StarBASIC *, SbxArray & rPar, bool)
}
else
{
- rPar.Get32(0)->PutInteger( static_cast<sal_Int16>(nChannel) );
+ rPar.Get(0)->PutInteger(static_cast<sal_Int16>(nChannel));
}
}
void SbRtl_DDETerminate(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- int nArgs = static_cast<int>(rPar.Count32());
+ rPar.Get(0)->PutEmpty();
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 2 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- size_t nChannel = rPar.Get32(1)->GetInteger();
+ size_t nChannel = rPar.Get(1)->GetInteger();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
ErrCode nDdeErr = pDDE->Terminate( nChannel );
if( nDdeErr )
@@ -3884,12 +3762,11 @@ void SbRtl_DDETerminate(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_DDETerminateAll(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- int nArgs = static_cast<int>(rPar.Count32());
+ rPar.Get(0)->PutEmpty();
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 1 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
@@ -3902,14 +3779,13 @@ void SbRtl_DDETerminateAll(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_DDERequest(StarBASIC *, SbxArray & rPar, bool)
{
- int nArgs = static_cast<int>(rPar.Count32());
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 3 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- size_t nChannel = rPar.Get32(1)->GetInteger();
- const OUString& rItem = rPar.Get32(2)->GetOUString();
+ size_t nChannel = rPar.Get(1)->GetInteger();
+ const OUString& rItem = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
OUString aResult;
ErrCode nDdeErr = pDDE->Request( nChannel, rItem, aResult );
@@ -3919,21 +3795,20 @@ void SbRtl_DDERequest(StarBASIC *, SbxArray & rPar, bool)
}
else
{
- rPar.Get32(0)->PutString( aResult );
+ rPar.Get(0)->PutString(aResult);
}
}
void SbRtl_DDEExecute(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- int nArgs = static_cast<int>(rPar.Count32());
+ rPar.Get(0)->PutEmpty();
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 3 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- size_t nChannel = rPar.Get32(1)->GetInteger();
- const OUString& rCommand = rPar.Get32(2)->GetOUString();
+ size_t nChannel = rPar.Get(1)->GetInteger();
+ const OUString& rCommand = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
ErrCode nDdeErr = pDDE->Execute( nChannel, rCommand );
if( nDdeErr )
@@ -3944,16 +3819,15 @@ void SbRtl_DDEExecute(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_DDEPoke(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- int nArgs = static_cast<int>(rPar.Count32());
+ rPar.Get(0)->PutEmpty();
+ int nArgs = static_cast<int>(rPar.Count());
if ( nArgs != 4 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- size_t nChannel = rPar.Get32(1)->GetInteger();
- const OUString& rItem = rPar.Get32(2)->GetOUString();
- const OUString& rData = rPar.Get32(3)->GetOUString();
+ size_t nChannel = rPar.Get(1)->GetInteger();
+ const OUString& rItem = rPar.Get(2)->GetOUString();
+ const OUString& rData = rPar.Get(3)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
ErrCode nDdeErr = pDDE->Poke( nChannel, rItem, rData );
if( nDdeErr )
@@ -3965,10 +3839,9 @@ void SbRtl_DDEPoke(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_FreeFile(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
+ if (rPar.Count() != 1)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
short nChannel = 1;
@@ -3977,7 +3850,7 @@ void SbRtl_FreeFile(StarBASIC *, SbxArray & rPar, bool)
SbiStream* pStrm = pIO->GetStream( nChannel );
if( !pStrm )
{
- rPar.Get32(0)->PutInteger( nChannel );
+ rPar.Get(0)->PutInteger(nChannel);
return;
}
nChannel++;
@@ -3987,66 +3860,57 @@ void SbRtl_FreeFile(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_LBound(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nParCount = rPar.Count32();
+ const sal_uInt32 nParCount = rPar.Count();
if ( nParCount != 3 && nParCount != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- SbxBase* pParObj = rPar.Get32(1)->GetObject();
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxBase* pParObj = rPar.Get(1)->GetObject();
SbxDimArray* pArr = dynamic_cast<SbxDimArray*>( pParObj );
- if( pArr )
- {
- sal_Int32 nLower, nUpper;
- short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get32(2)->GetInteger()) : 1;
- if( !pArr->GetDim32( nDim, nLower, nUpper ) )
- StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE );
- else
- rPar.Get32(0)->PutLong( nLower );
- }
- else
- StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+ if( !pArr )
+ return StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+
+ sal_Int32 nLower, nUpper;
+ short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get(2)->GetInteger()) : 1;
+ if (!pArr->GetDim(nDim, nLower, nUpper))
+ return StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE );
+ rPar.Get(0)->PutLong(nLower);
}
void SbRtl_UBound(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nParCount = rPar.Count32();
+ const sal_uInt32 nParCount = rPar.Count();
if ( nParCount != 3 && nParCount != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- SbxBase* pParObj = rPar.Get32(1)->GetObject();
+ SbxBase* pParObj = rPar.Get(1)->GetObject();
SbxDimArray* pArr = dynamic_cast<SbxDimArray*>( pParObj );
- if( pArr )
- {
- sal_Int32 nLower, nUpper;
- short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get32(2)->GetInteger()) : 1;
- if( !pArr->GetDim32( nDim, nLower, nUpper ) )
- StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE );
- else
- rPar.Get32(0)->PutLong( nUpper );
- }
- else
- StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+ if( !pArr )
+ return StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+
+ sal_Int32 nLower, nUpper;
+ short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get(2)->GetInteger()) : 1;
+ if (!pArr->GetDim(nDim, nLower, nUpper))
+ return StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE );
+ rPar.Get(0)->PutLong(nUpper);
}
void SbRtl_RGB(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 4 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ if (rPar.Count() != 4)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- sal_Int32 nRed = rPar.Get32(1)->GetInteger() & 0xFF;
- sal_Int32 nGreen = rPar.Get32(2)->GetInteger() & 0xFF;
- sal_Int32 nBlue = rPar.Get32(3)->GetInteger() & 0xFF;
+ sal_Int32 nRed = rPar.Get(1)->GetInteger() & 0xFF;
+ sal_Int32 nGreen = rPar.Get(2)->GetInteger() & 0xFF;
+ sal_Int32 nBlue = rPar.Get(3)->GetInteger() & 0xFF;
sal_Int32 nRGB;
SbiInstance* pInst = GetSbData()->pInst;
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
+ // See discussion in tdf#145725, here's the quotation from a link indicated in the bugtracker
+ // which explains why we need to manage RGB differently according to VB compatibility
+ // "In other words, the individual color components are stored in the opposite order one would expect.
+ // VB stores the red color component in the low-order byte of the long integer's low-order word,
+ // the green color in the high-order byte of the low-order word, and the blue color in the low-order byte of the high-order word"
if( bCompatibility )
{
nRGB = (nBlue << 16) | (nGreen << 8) | nRed;
@@ -4055,7 +3919,7 @@ void SbRtl_RGB(StarBASIC *, SbxArray & rPar, bool)
{
nRGB = (nRed << 16) | (nGreen << 8) | nBlue;
}
- rPar.Get32(0)->PutLong( nRGB );
+ rPar.Get(0)->PutLong(nRGB);
}
void SbRtl_QBColor(StarBASIC *, SbxArray & rPar, bool)
@@ -4080,177 +3944,186 @@ void SbRtl_QBColor(StarBASIC *, SbxArray & rPar, bool)
0xFFFFFF,
};
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int16 nCol = rPar.Get32(1)->GetInteger();
+ sal_Int16 nCol = rPar.Get(1)->GetInteger();
if( nCol < 0 || nCol > 15 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
sal_Int32 nRGB = pRGB[ nCol ];
- rPar.Get32(0)->PutLong( nRGB );
+ rPar.Get(0)->PutLong(nRGB);
}
-// StrConv(string, conversion, LCID)
-void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
+static std::vector<sal_uInt8> byteArray2Vec(SbxArray* pArr)
{
- const sal_uInt32 nArgCount = rPar.Count32()-1;
- if( nArgCount < 2 || nArgCount > 3 )
+ std::vector<sal_uInt8> result;
+ if (pArr)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ const sal_uInt32 nCount = pArr->Count();
+ result.reserve(nCount + 1); // to avoid reallocation when padding in vbFromUnicode
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ result.push_back(pArr->Get(i)->GetByte());
}
+ return result;
+}
- OUString aOldStr = rPar.Get32(1)->GetOUString();
- sal_Int32 nConversion = rPar.Get32(2)->GetLong();
+// Makes sure to get the byte array if passed, or the string converted to the bytes using
+// StringToByteArray in basic/source/sbx/sbxstr.cxx
+static std::vector<sal_uInt8> getByteArray(SbxValue& val)
+{
+ if (val.GetFullType() == SbxOBJECT)
+ if (auto pObj = val.GetObject())
+ if (pObj->GetType() == (SbxARRAY | SbxBYTE))
+ if (auto pArr = dynamic_cast<SbxArray*>(pObj))
+ return byteArray2Vec(pArr);
- sal_Int32 nOldLen = aOldStr.getLength();
- if( nOldLen == 0 )
- {
- // null string,return
- rPar.Get32(0)->PutString(aOldStr);
- return;
- }
+ // Convert to string
+ tools::SvRef<SbxValue> pStringValue(new SbxValue(SbxSTRING));
+ *pStringValue = val;
- TransliterationFlags nType = TransliterationFlags::NONE;
- if ( (nConversion & 0x03) == 3 ) // vbProperCase
- {
- const CharClass& rCharClass = GetCharClass();
- aOldStr = rCharClass.titlecase( aOldStr.toAsciiLowerCase(), 0, nOldLen );
- }
- else if ( (nConversion & 0x01) == 1 ) // vbUpperCase
- {
- nType |= TransliterationFlags::LOWERCASE_UPPERCASE;
- }
- else if ( (nConversion & 0x02) == 2 ) // vbLowerCase
- {
- nType |= TransliterationFlags::UPPERCASE_LOWERCASE;
- }
- if ( (nConversion & 0x04) == 4 ) // vbWide
- {
- nType |= TransliterationFlags::HALFWIDTH_FULLWIDTH;
- }
- else if ( (nConversion & 0x08) == 8 ) // vbNarrow
- {
- nType |= TransliterationFlags::FULLWIDTH_HALFWIDTH;
- }
- if ( (nConversion & 0x10) == 16) // vbKatakana
+ // Convert string to byte array
+ tools::SvRef<SbxValue> pValue(new SbxValue(SbxOBJECT));
+ pValue->PutObject(new SbxArray(SbxBYTE));
+ *pValue = *pStringValue; // Does the magic of conversion of strings to byte arrays
+ return byteArray2Vec(dynamic_cast<SbxArray*>(pValue->GetObject()));
+}
+
+// StrConv(string, conversion, LCID)
+void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
+{
+ const sal_uInt32 nArgCount = rPar.Count() - 1;
+ if( nArgCount < 2 || nArgCount > 3 )
{
- nType |= TransliterationFlags::HIRAGANA_KATAKANA;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- else if ( (nConversion & 0x20) == 32 ) // vbHiragana
+
+ sal_Int32 nConversion = rPar.Get(2)->GetLong();
+ LanguageType nLanguage = LANGUAGE_SYSTEM;
+ if (nArgCount == 3)
{
- nType |= TransliterationFlags::KATAKANA_HIRAGANA;
+ sal_Int32 lcid = rPar.Get(3)->GetLong();
+ nLanguage = LanguageType(lcid);
}
- OUString aNewStr( aOldStr );
- if( nType != TransliterationFlags::NONE )
+
+ if (nConversion == ooo::vba::VbStrConv::vbUnicode) // This mode does not combine
{
- uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
- ::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType );
- uno::Sequence<sal_Int32> aOffsets;
- LanguageType nLanguage = LANGUAGE_SYSTEM;
- aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
- aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
+ // Assume that the passed byte array is encoded in the defined encoding, convert to
+ // UTF-16 and store as string. Passed strings are converted to byte array first.
+ auto inArray = getByteArray(*rPar.Get(1));
+ std::string_view s(reinterpret_cast<char*>(inArray.data()), inArray.size() / sizeof(char));
+ const auto encoding = utl_getWinTextEncodingFromLangStr(LanguageTag(nLanguage).getBcp47());
+ OUString aOUStr = OStringToOUString(s, encoding);
+ rPar.Get(0)->PutString(aOUStr);
+ return;
}
- if ( (nConversion & 0x40) == 64 ) // vbUnicode
+ if (nConversion == ooo::vba::VbStrConv::vbFromUnicode) // This mode does not combine
{
- // convert the string to byte string, preserving unicode (2 bytes per character)
- sal_Int32 nSize = aNewStr.getLength()*2;
- const sal_Unicode* pSrc = aNewStr.getStr();
- std::unique_ptr<char[]> pChar(new char[nSize+1]);
- for( sal_Int32 i=0; i < nSize; i++ )
+ // Assume that the passed byte array is UTF-16-encoded (system-endian), convert to specified
+ // encoding and store as byte array. Passed strings are converted to byte array first.
+ auto inArray = getByteArray(*rPar.Get(1));
+ while (inArray.size() % sizeof(sal_Unicode))
+ inArray.push_back('\0');
+ std::u16string_view s(reinterpret_cast<sal_Unicode*>(inArray.data()),
+ inArray.size() / sizeof(sal_Unicode));
+ const auto encoding = utl_getWinTextEncodingFromLangStr(LanguageTag(nLanguage).getBcp47());
+ OString aOStr = OUStringToOString(s, encoding);
+ const sal_Int32 lb = IsBaseIndexOne() ? 1 : 0;
+ const sal_Int32 ub = lb + aOStr.getLength() - 1;
+ SbxDimArray* pArray = new SbxDimArray(SbxBYTE);
+ pArray->unoAddDim(lb, ub);
+
+ for (sal_Int32 i = 0; i < aOStr.getLength(); ++i)
{
- pChar[i] = static_cast< char >( (i%2) ? ((*pSrc) >> 8) & 0xff : (*pSrc) & 0xff );
- if( i%2 )
- {
- pSrc++;
- }
+ SbxVariable* pNew = new SbxVariable(SbxBYTE);
+ pNew->PutByte(aOStr[i]);
+ pArray->Put(pNew, i);
}
- pChar[nSize] = '\0';
- OString aOStr(pChar.get());
- // there is no concept about default codepage in unix. so it is incorrectly in unix
- OUString aOUStr = OStringToOUString(aOStr, osl_getThreadTextEncoding());
- rPar.Get32(0)->PutString( aOUStr );
+ SbxVariable* retVar = rPar.Get(0);
+ SbxFlagBits nFlags = retVar->GetFlags();
+ retVar->ResetFlag(SbxFlagBits::Fixed);
+ retVar->PutObject(pArray);
+ retVar->SetFlags(nFlags);
+ retVar->SetParameters(nullptr);
return;
}
- else if ( (nConversion & 0x80) == 128 ) // vbFromUnicode
+
+ std::vector<TransliterationFlags> aTranslitSet;
+ auto check = [&nConversion, &aTranslitSet](sal_Int32 conv, TransliterationFlags flag)
{
- // there is no concept about default codepage in unix. so it is incorrectly in unix
- OString aOStr = OUStringToOString(aNewStr,osl_getThreadTextEncoding());
- const char* pChar = aOStr.getStr();
- sal_Int32 nArraySize = aOStr.getLength();
- SbxDimArray* pArray = new SbxDimArray(SbxBYTE);
- bool bIncIndex = IsBaseIndexOne();
- if(nArraySize)
+ if ((nConversion & conv) != conv)
+ return false;
+
+ aTranslitSet.push_back(flag);
+ nConversion &= ~conv;
+ return true;
+ };
+
+ // Check mutually exclusive bits together
+
+ if (!check(ooo::vba::VbStrConv::vbProperCase, TransliterationFlags::TITLE_CASE))
+ if (!check(ooo::vba::VbStrConv::vbUpperCase, TransliterationFlags::LOWERCASE_UPPERCASE))
+ check(ooo::vba::VbStrConv::vbLowerCase, TransliterationFlags::UPPERCASE_LOWERCASE);
+
+ if (!check(ooo::vba::VbStrConv::vbWide, TransliterationFlags::HALFWIDTH_FULLWIDTH))
+ check(ooo::vba::VbStrConv::vbNarrow, TransliterationFlags::FULLWIDTH_HALFWIDTH);
+
+ if (!check(ooo::vba::VbStrConv::vbKatakana, TransliterationFlags::HIRAGANA_KATAKANA))
+ check(ooo::vba::VbStrConv::vbHiragana, TransliterationFlags::KATAKANA_HIRAGANA);
+
+ if (nConversion) // unknown / incorrectly combined bits
+ return StarBASIC::Error(ERRCODE_BASIC_BAD_ARGUMENT);
+
+ OUString aStr = rPar.Get(1)->GetOUString();
+ if (!aStr.isEmpty() && !aTranslitSet.empty())
+ {
+ uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
+
+ for (auto transliterationFlag : aTranslitSet)
{
- if( bIncIndex )
+ if (transliterationFlag == TransliterationFlags::TITLE_CASE)
{
- pArray->AddDim32( 1, nArraySize );
+ // TransliterationWrapper only handles the first character of the passed string
+ // when handling TITLE_CASE; see Transliteration_titlecase::transliterateImpl in
+ // i18npool/source/transliteration/transliteration_body.cxx
+ CharClass aCharClass{ xContext, LanguageTag(nLanguage) };
+ aStr = aCharClass.titlecase(aCharClass.lowercase(aStr));
}
else
{
- pArray->AddDim32( 0, nArraySize-1 );
+ utl::TransliterationWrapper aWrapper(xContext, transliterationFlag);
+ aStr = aWrapper.transliterate(aStr, nLanguage, 0, aStr.getLength(), nullptr);
}
}
- else
- {
- pArray->unoAddDim32( 0, -1 );
- }
-
- for( sal_Int32 i=0; i< nArraySize; i++)
- {
- SbxVariable* pNew = new SbxVariable( SbxBYTE );
- pNew->PutByte(*pChar);
- pChar++;
- pNew->SetFlag( SbxFlagBits::Write );
- sal_Int32 aIdx[1];
- aIdx[0] = i;
- if( bIncIndex )
- {
- ++aIdx[0];
- }
- pArray->Put32(pNew, aIdx);
- }
-
- SbxVariableRef refVar = rPar.Get32(0);
- SbxFlagBits nFlags = refVar->GetFlags();
- refVar->ResetFlag( SbxFlagBits::Fixed );
- refVar->PutObject( pArray );
- refVar->SetFlags( nFlags );
- refVar->SetParameters( nullptr );
- return;
}
- rPar.Get32(0)->PutString(aNewStr);
+
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_Beep(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
+ if (rPar.Count() != 1)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
Sound::Beep();
}
void SbRtl_Load(StarBASIC *, SbxArray & rPar, bool)
{
- if( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- SbxBase* pObj = rPar.Get32(1)->GetObject();
+ SbxBase* pObj = rPar.Get(1)->GetObject();
if ( !pObj )
return;
@@ -4270,15 +4143,14 @@ void SbRtl_Load(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Unload(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if( rPar.Count32() != 2 )
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- SbxBase* pObj = rPar.Get32(1)->GetObject();
+ SbxBase* pObj = rPar.Get(1)->GetObject();
if ( !pObj )
return;
@@ -4298,13 +4170,12 @@ void SbRtl_Unload(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_LoadPicture(StarBASIC *, SbxArray & rPar, bool)
{
- if( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- OUString aFileURL = getFullPath( rPar.Get32(1)->GetOUString() );
+ OUString aFileURL = getFullPath(rPar.Get(1)->GetOUString());
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream( aFileURL, StreamMode::READ ));
if( pStream )
{
@@ -4315,23 +4186,22 @@ void SbRtl_LoadPicture(StarBASIC *, SbxArray & rPar, bool)
SbxObjectRef xRef = new SbStdPicture;
static_cast<SbStdPicture*>(xRef.get())->SetGraphic( aGraphic );
- rPar.Get32(0)->PutObject( xRef.get() );
+ rPar.Get(0)->PutObject(xRef.get());
}
}
void SbRtl_SavePicture(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if( rPar.Count32() != 3 )
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 3)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- SbxBase* pObj = rPar.Get32(1)->GetObject();
+ SbxBase* pObj = rPar.Get(1)->GetObject();
if (SbStdPicture *pPicture = dynamic_cast<SbStdPicture*>(pObj))
{
- SvFileStream aOStream( rPar.Get32(2)->GetOUString(), StreamMode::WRITE | StreamMode::TRUNC );
+ SvFileStream aOStream(rPar.Get(2)->GetOUString(), StreamMode::WRITE | StreamMode::TRUNC);
const Graphic& aGraphic = pPicture->GetGraphic();
TypeSerializer aSerializer(aOStream);
aSerializer.writeGraphic(aGraphic);
@@ -4340,15 +4210,20 @@ void SbRtl_SavePicture(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32();
+ const sal_uInt32 nArgCount = rPar.Count();
if( nArgCount < 2 || nArgCount > 6 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ }
+
+ // tdf#147529 - check for missing parameters
+ if (IsMissing(rPar, 1))
+ {
+ return StarBASIC::Error(ERRCODE_BASIC_NOT_OPTIONAL);
}
- WinBits nType = 0; // MB_OK
- if( nArgCount >= 3 )
- nType = static_cast<WinBits>(rPar.Get32(2)->GetInteger());
+
+ // tdf#151012 - initialize optional parameters with their default values (number of buttons)
+ WinBits nType = static_cast<WinBits>(GetOptionalIntegerParamOrDefault(rPar, 2, 0)); // MB_OK
WinBits nStyle = nType;
nStyle &= 15; // delete bits 4-16
if (nStyle > 5)
@@ -4365,22 +4240,14 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
No = 7
};
- OUString aMsg = rPar.Get32(1)->GetOUString();
- OUString aTitle;
- if( nArgCount >= 4 )
- {
- aTitle = rPar.Get32(3)->GetOUString();
- }
- else
- {
- aTitle = Application::GetDisplayName();
- }
+ OUString aMsg = rPar.Get(1)->GetOUString();
+ // tdf#151012 - initialize optional parameters with their default values (title of dialog box)
+ OUString aTitle = GetOptionalOUStringParamOrDefault(rPar, 3, Application::GetDisplayName());
WinBits nDialogType = nType & (16+32+64);
SolarMutexGuard aSolarGuard;
- vcl::Window* pParentWin = Application::GetDefDialogParent();
- weld::Widget* pParent = pParentWin ? pParentWin->GetFrameWeld() : nullptr;
+ weld::Widget* pParent = Application::GetDefDialogParent();
VclMessageType eType = VclMessageType::Other;
@@ -4401,7 +4268,7 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
}
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
- eType, VclButtonsType::NONE, aMsg));
+ eType, VclButtonsType::NONE, aMsg, GetpApp()));
switch (nStyle)
{
@@ -4467,16 +4334,16 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
xBox->set_title(aTitle);
sal_Int16 nRet = xBox->run();
- rPar.Get32(0)->PutInteger(nRet);
+ rPar.Get(0)->PutInteger(nRet);
}
void SbRtl_SetAttr(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if ( rPar.Count32() == 3 )
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() == 3)
{
- OUString aStr = rPar.Get32(1)->GetOUString();
- SbAttributes nFlags = static_cast<SbAttributes>( rPar.Get32(2)->GetInteger() );
+ OUString aStr = rPar.Get(1)->GetOUString();
+ SbAttributes nFlags = static_cast<SbAttributes>(rPar.Get(2)->GetInteger());
if( hasUno() )
{
@@ -4514,7 +4381,7 @@ void SbRtl_Reset(StarBASIC *, SbxArray &, bool)
void SbRtl_DumpAllObjects(StarBASIC * pBasic, SbxArray & rPar, bool)
{
- const sal_uInt32 nArgCount = rPar.Count32();
+ const sal_uInt32 nArgCount = rPar.Count();
if( nArgCount < 2 || nArgCount > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -4530,9 +4397,9 @@ void SbRtl_DumpAllObjects(StarBASIC * pBasic, SbxArray & rPar, bool)
{
p = p->GetParent();
}
- SvFileStream aStrm( rPar.Get32(1)->GetOUString(),
+ SvFileStream aStrm(rPar.Get(1)->GetOUString(),
StreamMode::WRITE | StreamMode::TRUNC );
- p->Dump( aStrm, rPar.Get32(2)->GetBool() );
+ p->Dump(aStrm, rPar.Get(2)->GetBool());
aStrm.Close();
if( aStrm.GetError() != ERRCODE_NONE )
{
@@ -4544,9 +4411,9 @@ void SbRtl_DumpAllObjects(StarBASIC * pBasic, SbxArray & rPar, bool)
void SbRtl_FileExists(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- OUString aStr = rPar.Get32(1)->GetOUString();
+ OUString aStr = rPar.Get(1)->GetOUString();
bool bExists = false;
if( hasUno() )
@@ -4570,7 +4437,7 @@ void SbRtl_FileExists(StarBASIC *, SbxArray & rPar, bool)
FileBase::RC nRet = DirectoryItem::get( getFullPath( aStr ), aItem );
bExists = (nRet == FileBase::E_None);
}
- rPar.Get32(0)->PutBool( bExists );
+ rPar.Get(0)->PutBool(bExists);
}
else
{
@@ -4580,21 +4447,19 @@ void SbRtl_FileExists(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Partition(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 5 )
+ if (rPar.Count() != 5)
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int32 nNumber = rPar.Get32(1)->GetLong();
- sal_Int32 nStart = rPar.Get32(2)->GetLong();
- sal_Int32 nStop = rPar.Get32(3)->GetLong();
- sal_Int32 nInterval = rPar.Get32(4)->GetLong();
+ sal_Int32 nNumber = rPar.Get(1)->GetLong();
+ sal_Int32 nStart = rPar.Get(2)->GetLong();
+ sal_Int32 nStop = rPar.Get(3)->GetLong();
+ sal_Int32 nInterval = rPar.Get(4)->GetLong();
if( nStart < 0 || nStop <= nStart || nInterval < 1 )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
// the Partition function inserts leading spaces before lowervalue and uppervalue
@@ -4645,7 +4510,7 @@ void SbRtl_Partition(StarBASIC *, SbxArray & rPar, bool)
aRetStr.append(" ");
}
}
- aRetStr.append( aLowerValue ).append(":");
+ aRetStr.append( aLowerValue + ":");
if( nLen > nLen2 )
{
// appending the leading spaces for the uppervalue
@@ -4655,33 +4520,15 @@ void SbRtl_Partition(StarBASIC *, SbxArray & rPar, bool)
}
}
aRetStr.append( aUpperValue );
- rPar.Get32(0)->PutString( aRetStr.makeStringAndClear());
+ rPar.Get(0)->PutString(aRetStr.makeStringAndClear());
}
#endif
-static tools::Long GetDayDiff( const Date& rDate )
-{
- Date aRefDate( 1,1,1900 );
- tools::Long nDiffDays;
- if ( aRefDate > rDate )
- {
- nDiffDays = aRefDate - rDate;
- nDiffDays *= -1;
- }
- else
- {
- nDiffDays = rDate - aRefDate;
- }
- nDiffDays += 2; // adjustment VisualBasic: 1.Jan.1900 == 2
- return nDiffDays;
-}
-
sal_Int16 implGetDateYear( double aDate )
{
- Date aRefDate( 1,1,1900 );
- tools::Long nDays = static_cast<tools::Long>(aDate);
- nDays -= 2; // standardize: 1.1.1900 => 0.0
+ Date aRefDate(1899'12'30);
+ sal_Int32 nDays = static_cast<sal_Int32>(aDate);
aRefDate.AddDays( nDays );
sal_Int16 nRet = aRefDate.GetYear();
return nRet;
@@ -4711,11 +4558,13 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay,
else
#endif
{
- if ( 0 <= nYear && nYear < 100 && (bUseTwoDigitYear
+ if ( 0 <= nYear && nYear < 100 &&
#if HAVE_FEATURE_SCRIPTING
- || SbiRuntime::isVBAEnabled()
+ (bUseTwoDigitYear || SbiRuntime::isVBAEnabled())
+#else
+ bUseTwoDigitYear
#endif
- ) )
+ )
{
nYear += 1900;
}
@@ -4791,8 +4640,7 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay,
}
}
- tools::Long nDiffDays = GetDayDiff( aCurDate );
- rdRet = static_cast<double>(nDiffDays);
+ rdRet = GetDayDiff(aCurDate);
return true;
}
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index c847df8d26e6..57d95b93a526 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -24,7 +24,6 @@
#include <cstddef>
-#include <stdlib.h>
#include <rtl/math.hxx>
#include <vcl/svapp.hxx>
#include <vcl/mapmod.hxx>
@@ -51,6 +50,8 @@
#include <propacc.hxx>
#include <sal/log.hxx>
#include <eventatt.hxx>
+#include <rtl/math.h>
+#include <svl/numformat.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
@@ -59,6 +60,9 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/i18n/LocaleCalendar2.hpp>
#include <com/sun/star/sheet/XFunctionAccess.hpp>
+
+#include <officecfg/Office/Scripting.hxx>
+
#include <memory>
using namespace comphelper;
@@ -71,23 +75,16 @@ static Reference< XCalendar4 > const & getLocaleCalendar()
{
static Reference< XCalendar4 > xCalendar = LocaleCalendar2::create(getProcessComponentContext());
static css::lang::Locale aLastLocale;
- static bool bNeedsInit = true;
+ static bool bNeedsReload = true;
css::lang::Locale aLocale = Application::GetSettings().GetLanguageTag().getLocale();
- bool bNeedsReload = false;
- if( bNeedsInit )
- {
- bNeedsInit = false;
- bNeedsReload = true;
- }
- else if( aLocale.Language != aLastLocale.Language ||
+ bNeedsReload = bNeedsReload ||
+ ( aLocale.Language != aLastLocale.Language ||
aLocale.Country != aLastLocale.Country ||
- aLocale.Variant != aLastLocale.Variant )
- {
- bNeedsReload = true;
- }
+ aLocale.Variant != aLastLocale.Variant );
if( bNeedsReload )
{
+ bNeedsReload = false;
aLastLocale = aLocale;
xCalendar->loadDefaultCalendar( aLocale );
}
@@ -104,7 +101,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
const sal_Int16 vbSet = 8;
// At least 3 parameter needed plus function itself -> 4
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if ( nParCount < 4 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -112,7 +109,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
}
// 1. parameter is object
- SbxBase* pObjVar = rPar.Get32(1)->GetObject();
+ SbxBase* pObjVar = rPar.Get(1)->GetObject();
SbxObject* pObj = nullptr;
if( pObjVar )
pObj = dynamic_cast<SbxObject*>( pObjVar );
@@ -125,11 +122,11 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
return;
}
- // 2. parameter is ProcedureName
- OUString aNameStr = rPar.Get32(2)->GetOUString();
+ // 2. parameter is ProcName
+ OUString aNameStr = rPar.Get(2)->GetOUString();
// 3. parameter is CallType
- sal_Int16 nCallType = rPar.Get32(3)->GetInteger();
+ sal_Int16 nCallType = rPar.Get(3)->GetInteger();
//SbxObject* pFindObj = NULL;
SbxVariable* pFindVar = pObj->Find( aNameStr, SbxClassType::DontCare );
@@ -147,7 +144,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
aVals.eType = SbxVARIANT;
pFindVar->Get( aVals );
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
refVar->Put( aVals );
}
break;
@@ -159,7 +156,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- SbxVariableRef pValVar = rPar.Get32(4);
+ SbxVariableRef pValVar = rPar.Get(4);
if( nCallType == vbLet )
{
SbxValues aVals;
@@ -196,13 +193,13 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
xArray = new SbxArray;
for( sal_uInt32 i = 0 ; i < nMethParamCount ; i++ )
{
- SbxVariable* pPar = rPar.Get32( i + 4 );
- xArray->Put32( pPar, i + 1 );
+ SbxVariable* pPar = rPar.Get(i + 4);
+ xArray->Put(pPar, i + 1);
}
}
// Call method
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
if( xArray.is() )
pMeth->SetParameters( xArray.get() );
pMeth->Call( refVar.get() );
@@ -217,67 +214,64 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_CBool(StarBASIC *, SbxArray & rPar, bool) // JSM
{
bool bVal = false;
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
bVal = pSbxVariable->GetBool();
}
else
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutBool(bVal);
+ rPar.Get(0)->PutBool(bVal);
}
void SbRtl_CByte(StarBASIC *, SbxArray & rPar, bool) // JSM
{
sal_uInt8 nByte = 0;
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
nByte = pSbxVariable->GetByte();
}
else
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutByte(nByte);
+ rPar.Get(0)->PutByte(nByte);
}
void SbRtl_CCur(StarBASIC *, SbxArray & rPar, bool)
{
sal_Int64 nCur = 0;
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
nCur = pSbxVariable->GetCurrency();
}
else
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutCurrency( nCur );
+ rPar.Get(0)->PutCurrency(nCur);
}
-void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
+void SbRtl_CDec(StarBASIC *, SbxArray & rPar, bool)
{
- (void)pBasic;
- (void)bWrite;
-
#ifdef _WIN32
SbxDecimal* pDec = nullptr;
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
pDec = pSbxVariable->GetDecimal();
}
else
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutDecimal( pDec );
+ rPar.Get(0)->PutDecimal(pDec);
#else
- rPar.Get32(0)->PutEmpty();
+ rPar.Get(0)->PutEmpty();
StarBASIC::Error(ERRCODE_BASIC_NOT_IMPLEMENTED);
#endif
}
@@ -285,24 +279,20 @@ void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
void SbRtl_CDate(StarBASIC *, SbxArray & rPar, bool) // JSM
{
double nVal = 0.0;
- if ( rPar.Count32() == 2 )
- {
- SbxVariable *pSbxVariable = rPar.Get32(1);
- nVal = pSbxVariable->GetDate();
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- rPar.Get32(0)->PutDate(nVal);
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pSbxVariable = rPar.Get(1);
+ nVal = pSbxVariable->GetDate();
+ rPar.Get(0)->PutDate(nVal);
}
void SbRtl_CDbl(StarBASIC *, SbxArray & rPar, bool) // JSM
{
double nVal = 0.0;
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
if( pSbxVariable->GetType() == SbxSTRING )
{
// #41690
@@ -323,45 +313,37 @@ void SbRtl_CDbl(StarBASIC *, SbxArray & rPar, bool) // JSM
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutDouble(nVal);
+ rPar.Get(0)->PutDouble(nVal);
}
void SbRtl_CInt(StarBASIC *, SbxArray & rPar, bool) // JSM
{
sal_Int16 nVal = 0;
- if ( rPar.Count32() == 2 )
- {
- SbxVariable *pSbxVariable = rPar.Get32(1);
- nVal = pSbxVariable->GetInteger();
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- rPar.Get32(0)->PutInteger(nVal);
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pSbxVariable = rPar.Get(1);
+ nVal = pSbxVariable->GetInteger();
+ rPar.Get(0)->PutInteger(nVal);
}
void SbRtl_CLng(StarBASIC *, SbxArray & rPar, bool) // JSM
{
sal_Int32 nVal = 0;
- if ( rPar.Count32() == 2 )
- {
- SbxVariable *pSbxVariable = rPar.Get32(1);
- nVal = pSbxVariable->GetLong();
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- rPar.Get32(0)->PutLong(nVal);
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pSbxVariable = rPar.Get(1);
+ nVal = pSbxVariable->GetLong();
+ rPar.Get(0)->PutLong(nVal);
}
void SbRtl_CSng(StarBASIC *, SbxArray & rPar, bool) // JSM
{
float nVal = float(0.0);
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
if( pSbxVariable->GetType() == SbxSTRING )
{
// #41690
@@ -383,205 +365,167 @@ void SbRtl_CSng(StarBASIC *, SbxArray & rPar, bool) // JSM
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->PutSingle(nVal);
+ rPar.Get(0)->PutSingle(nVal);
}
void SbRtl_CStr(StarBASIC *, SbxArray & rPar, bool) // JSM
{
- OUString aString;
- if ( rPar.Count32() == 2 )
- {
- SbxVariable *pSbxVariable = rPar.Get32(1);
- aString = pSbxVariable->GetOUString();
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- rPar.Get32(0)->PutString(aString);
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pSbxVariable = rPar.Get(1);
+ OUString aString = pSbxVariable->GetOUString();
+ rPar.Get(0)->PutString(aString);
}
void SbRtl_CVar(StarBASIC *, SbxArray & rPar, bool) // JSM
{
SbxValues aVals( SbxVARIANT );
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() == 2)
{
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
pSbxVariable->Get( aVals );
}
else
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- rPar.Get32(0)->Put( aVals );
+ rPar.Get(0)->Put(aVals);
}
void SbRtl_CVErr(StarBASIC *, SbxArray & rPar, bool)
{
- sal_Int16 nErrCode = 0;
- if ( rPar.Count32() == 2 )
- {
- SbxVariable *pSbxVariable = rPar.Get32(1);
- nErrCode = pSbxVariable->GetInteger();
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- rPar.Get32(0)->PutErr( nErrCode );
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxVariable* pSbxVariable = rPar.Get(1);
+ sal_Int16 nErrCode = pSbxVariable->GetInteger();
+ rPar.Get(0)->PutErr(nErrCode);
}
void SbRtl_Iif(StarBASIC *, SbxArray & rPar, bool) // JSM
{
- if ( rPar.Count32() == 4 )
+ if (rPar.Count() != 4)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ if (rPar.Get(1)->GetBool())
{
- if (rPar.Get32(1)->GetBool())
- {
- *rPar.Get32(0) = *rPar.Get32(2);
- }
- else
- {
- *rPar.Get32(0) = *rPar.Get32(3);
- }
+ *rPar.Get(0) = *rPar.Get(2);
}
else
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ *rPar.Get(0) = *rPar.Get(3);
}
+
}
void SbRtl_GetSystemType(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
+ if (rPar.Count() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
// Removed for SRC595
- rPar.Get32(0)->PutInteger( -1 );
- }
+ rPar.Get(0)->PutInteger(-1);
}
-void SbRtl_GetGUIType(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
+void SbRtl_GetGUIType(StarBASIC *, SbxArray & rPar, bool)
{
- (void)pBasic;
- (void)bWrite;
+ if (rPar.Count() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- if ( rPar.Count32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
// 17.7.2000 Make simple solution for testtool / fat office
#if defined(_WIN32)
- rPar.Get32(0)->PutInteger( 1 );
+ rPar.Get(0)->PutInteger(1);
#elif defined(UNX)
- rPar.Get32(0)->PutInteger( 4 );
+ rPar.Get(0)->PutInteger(4);
#else
- rPar.Get32(0)->PutInteger( -1 );
+ rPar.Get(0)->PutInteger(-1);
#endif
- }
}
void SbRtl_Red(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- sal_Int32 nRGB = rPar.Get32(1)->GetLong();
- nRGB &= 0x00FF0000;
- nRGB >>= 16;
- rPar.Get32(0)->PutInteger( static_cast<sal_Int16>(nRGB) );
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ sal_Int32 nRGB = rPar.Get(1)->GetLong();
+ nRGB &= 0x00FF0000;
+ nRGB >>= 16;
+ rPar.Get(0)->PutInteger(static_cast<sal_Int16>(nRGB));
+
}
void SbRtl_Green(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- sal_Int32 nRGB = rPar.Get32(1)->GetLong();
- nRGB &= 0x0000FF00;
- nRGB >>= 8;
- rPar.Get32(0)->PutInteger( static_cast<sal_Int16>(nRGB) );
- }
+ if (rPar.Count() != 2)
+
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ sal_Int32 nRGB = rPar.Get(1)->GetLong();
+ nRGB &= 0x0000FF00;
+ nRGB >>= 8;
+ rPar.Get(0)->PutInteger(static_cast<sal_Int16>(nRGB));
}
void SbRtl_Blue(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- sal_Int32 nRGB = rPar.Get32(1)->GetLong();
- nRGB &= 0x000000FF;
- rPar.Get32(0)->PutInteger( static_cast<sal_Int16>(nRGB) );
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ sal_Int32 nRGB = rPar.Get(1)->GetLong();
+ nRGB &= 0x000000FF;
+ rPar.Get(0)->PutInteger(static_cast<sal_Int16>(nRGB));
}
void SbRtl_Switch(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nCount = rPar.Count32();
+ sal_uInt32 nCount = rPar.Count();
if( !(nCount & 0x0001 ))
{
// number of arguments must be odd
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
sal_uInt32 nCurExpr = 1;
while( nCurExpr < (nCount-1) )
{
- if( rPar.Get32( nCurExpr )->GetBool())
+ if (rPar.Get(nCurExpr)->GetBool())
{
- (*rPar.Get32(0)) = *(rPar.Get32(nCurExpr+1));
+ (*rPar.Get(0)) = *(rPar.Get(nCurExpr + 1));
return;
}
nCurExpr += 2;
}
- rPar.Get32(0)->PutNull();
+ rPar.Get(0)->PutNull();
}
//i#64882# Common wait impl for existing Wait and new WaitUntil
// rtl functions
void Wait_Impl( bool bDurationBased, SbxArray& rPar )
{
- if( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
tools::Long nWait = 0;
if ( bDurationBased )
{
- double dWait = rPar.Get32(1)->GetDouble();
+ double dWait = rPar.Get(1)->GetDouble();
double dNow = Now_Impl();
double dSecs = ( dWait - dNow ) * 24.0 * 3600.0;
nWait = static_cast<tools::Long>( dSecs * 1000 ); // wait in thousands of sec
}
else
{
- nWait = rPar.Get32(1)->GetLong();
+ nWait = rPar.Get(1)->GetLong();
}
+
if( nWait < 0 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- Timer aTimer;
+ Timer aTimer("basic Wait_Impl");
aTimer.SetTimeout( nWait );
aTimer.Start();
- while ( aTimer.IsActive() )
+ while ( aTimer.IsActive() && !Application::IsQuit())
{
Application::Yield();
}
@@ -606,57 +550,54 @@ void SbRtl_DoEvents(StarBASIC *, SbxArray & rPar, bool)
// we already process application events etc. in between
// basic runtime pcode ( on a timed basis )
// always return 0
- rPar.Get32(0)->PutInteger( 0 );
+ rPar.Get(0)->PutInteger(0);
Application::Reschedule( true );
}
void SbRtl_GetGUIVersion(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- // Removed for SRC595
- rPar.Get32(0)->PutLong( -1 );
- }
+ if (rPar.Count() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ // Removed for SRC595
+ rPar.Get(0)->PutLong(-1);
}
void SbRtl_Choose(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- sal_Int16 nIndex = rPar.Get32(1)->GetInteger();
- sal_uInt32 nCount = rPar.Count32();
+ sal_Int16 nIndex = rPar.Get(1)->GetInteger();
+ sal_uInt32 nCount = rPar.Count();
nCount--;
if( nCount == 1 || nIndex > sal::static_int_cast<sal_Int16>(nCount-1) || nIndex < 1 )
{
- rPar.Get32(0)->PutNull();
+ rPar.Get(0)->PutNull();
return;
}
- (*rPar.Get32(0)) = *(rPar.Get32(nIndex+1));
+ (*rPar.Get(0)) = *(rPar.Get(nIndex + 1));
}
void SbRtl_Trim(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
+ if (rPar.Count() < 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- OUString aStr(comphelper::string::strip(rPar.Get32(1)->GetOUString(), ' '));
- rPar.Get32(0)->PutString(aStr);
+ OUString aStr(comphelper::string::strip(rPar.Get(1)->GetOUString(), ' '));
+ rPar.Get(0)->PutString(aStr);
}
}
void SbRtl_GetSolarVersion(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutLong( LIBO_VERSION_MAJOR * 10000 + LIBO_VERSION_MINOR * 100 + LIBO_VERSION_MICRO * 1);
+ rPar.Get(0)->PutLong(LIBO_VERSION_MAJOR * 10000 + LIBO_VERSION_MINOR * 100
+ + LIBO_VERSION_MICRO * 1);
}
void SbRtl_TwipsPerPixelX(StarBASIC *, SbxArray & rPar, bool)
@@ -670,7 +611,7 @@ void SbRtl_TwipsPerPixelX(StarBASIC *, SbxArray & rPar, bool)
aSize = pDevice->PixelToLogic( aSize, aMap );
nResult = aSize.Width() / 100;
}
- rPar.Get32(0)->PutLong( nResult );
+ rPar.Get(0)->PutLong(nResult);
}
void SbRtl_TwipsPerPixelY(StarBASIC *, SbxArray & rPar, bool)
@@ -684,17 +625,17 @@ void SbRtl_TwipsPerPixelY(StarBASIC *, SbxArray & rPar, bool)
aSize = pDevice->PixelToLogic( aSize, aMap );
nResult = aSize.Height() / 100;
}
- rPar.Get32(0)->PutLong( nResult );
+ rPar.Get(0)->PutLong(nResult);
}
void SbRtl_FreeLibrary(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- GetSbData()->pInst->GetDllMgr()->FreeDll( rPar.Get32(1)->GetOUString() );
+ GetSbData()->pInst->GetDllMgr()->FreeDll(rPar.Get(1)->GetOUString());
}
bool IsBaseIndexOne()
{
@@ -713,28 +654,28 @@ bool IsBaseIndexOne()
void SbRtl_Array(StarBASIC *, SbxArray & rPar, bool)
{
SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
- sal_uInt32 nArraySize = rPar.Count32() - 1;
+ sal_uInt32 nArraySize = rPar.Count() - 1;
bool bIncIndex = IsBaseIndexOne();
if( nArraySize )
{
if ( bIncIndex )
{
- pArray->AddDim32( 1, sal::static_int_cast<sal_Int32>(nArraySize) );
+ pArray->AddDim(1, sal::static_int_cast<sal_Int32>(nArraySize));
}
else
{
- pArray->AddDim32( 0, sal::static_int_cast<sal_Int32>(nArraySize) - 1 );
+ pArray->AddDim(0, sal::static_int_cast<sal_Int32>(nArraySize) - 1);
}
}
else
{
- pArray->unoAddDim32( 0, -1 );
+ pArray->unoAddDim(0, -1);
}
// insert parameters into the array
for( sal_uInt32 i = 0 ; i < nArraySize ; i++ )
{
- SbxVariable* pVar = rPar.Get32(i+1);
+ SbxVariable* pVar = rPar.Get(i + 1);
SbxVariable* pNew = new SbxEnsureParentVariable(*pVar);
pNew->SetFlag( SbxFlagBits::Write );
sal_Int32 aIdx[1];
@@ -743,11 +684,11 @@ void SbRtl_Array(StarBASIC *, SbxArray & rPar, bool)
{
++aIdx[0];
}
- pArray->Put32(pNew, aIdx);
+ pArray->Put(pNew, aIdx);
}
// return array
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
SbxFlagBits nFlags = refVar->GetFlags();
refVar->ResetFlag( SbxFlagBits::Fixed );
refVar->PutObject( pArray );
@@ -766,25 +707,25 @@ void SbRtl_Array(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_DimArray(StarBASIC *, SbxArray & rPar, bool)
{
SbxDimArray * pArray = new SbxDimArray( SbxVARIANT );
- sal_uInt32 nArrayDims = rPar.Count32() - 1;
+ sal_uInt32 nArrayDims = rPar.Count() - 1;
if( nArrayDims > 0 )
{
for( sal_uInt32 i = 0; i < nArrayDims ; i++ )
{
- sal_Int32 ub = rPar.Get32(i+1)->GetLong();
+ sal_Int32 ub = rPar.Get(i + 1)->GetLong();
if( ub < 0 )
{
StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE );
ub = 0;
}
- pArray->AddDim32( 0, ub );
+ pArray->AddDim(0, ub);
}
}
else
{
- pArray->unoAddDim32( 0, -1 );
+ pArray->unoAddDim(0, -1);
}
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
SbxFlagBits nFlags = refVar->GetFlags();
refVar->ResetFlag( SbxFlagBits::Fixed );
refVar->PutObject( pArray );
@@ -818,13 +759,11 @@ void SbRtl_DimArray(StarBASIC *, SbxArray & rPar, bool)
// 1st parameter = the object's name as string
void SbRtl_FindObject(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ if (rPar.Count() < 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
- OUString aNameStr = rPar.Get32(1)->GetOUString();
+ OUString aNameStr = rPar.Get(1)->GetOUString();
SbxBase* pFind = StarBASIC::FindSBXInCurrentScope( aNameStr );
SbxObject* pFindObj = nullptr;
@@ -832,7 +771,7 @@ void SbRtl_FindObject(StarBASIC *, SbxArray & rPar, bool)
{
pFindObj = dynamic_cast<SbxObject*>( pFind );
}
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( pFindObj );
}
@@ -841,13 +780,11 @@ void SbRtl_FindObject(StarBASIC *, SbxArray & rPar, bool)
// 2nd parameter = the property's name as string
void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() < 3 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ if (rPar.Count() < 3)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
- SbxBase* pObjVar = rPar.Get32(1)->GetObject();
+ SbxBase* pObjVar = rPar.Get(1)->GetObject();
SbxObject* pObj = nullptr;
if( pObjVar )
{
@@ -857,7 +794,7 @@ void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool)
if (auto pSbxVar = dynamic_cast<const SbxVariable*>( pObjVar))
pObj = dynamic_cast<SbxObject*>( pSbxVar->GetObject() );
- OUString aNameStr = rPar.Get32(2)->GetOUString();
+ OUString aNameStr = rPar.Get(2)->GetOUString();
SbxObject* pFindObj = nullptr;
if( pObj )
@@ -870,7 +807,7 @@ void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool)
StarBASIC::Error( ERRCODE_BASIC_BAD_PARAMETER );
}
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( pFindObj );
}
@@ -1092,7 +1029,7 @@ static bool lcl_WriteReadSbxArray( SbxDimArray& rArr, SvStream* pStrm,
{
SAL_WARN_IF( nCurDim <= 0,"basic", "Bad Dim");
sal_Int32 nLower, nUpper;
- if( !rArr.GetDim32( nCurDim, nLower, nUpper ) )
+ if (!rArr.GetDim(nCurDim, nLower, nUpper))
return false;
for(sal_Int32 nCur = nLower; nCur <= nUpper; nCur++ )
{
@@ -1101,7 +1038,7 @@ static bool lcl_WriteReadSbxArray( SbxDimArray& rArr, SvStream* pStrm,
lcl_WriteReadSbxArray(rArr, pStrm, bBinary, nCurDim-1, pOtherDims, bWrite);
else
{
- SbxVariable* pVar = rArr.Get32( pOtherDims );
+ SbxVariable* pVar = rArr.Get(pOtherDims);
bool bRet;
if( bWrite )
bRet = lcl_WriteSbxVariable(*pVar, pStrm, bBinary, 0, true );
@@ -1116,13 +1053,11 @@ static bool lcl_WriteReadSbxArray( SbxDimArray& rArr, SvStream* pStrm,
static void PutGet( SbxArray& rPar, bool bPut )
{
- if ( rPar.Count32() != 4 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- sal_Int16 nFileNo = rPar.Get32(1)->GetInteger();
- SbxVariable* pVar2 = rPar.Get32(2);
+ if (rPar.Count() != 4)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ sal_Int16 nFileNo = rPar.Get(1)->GetInteger();
+ SbxVariable* pVar2 = rPar.Get(2);
SbxDataType eType2 = pVar2->GetType();
bool bHasRecordNo = (eType2 != SbxEMPTY && eType2 != SbxERROR);
tools::Long nRecordNo = pVar2->GetLong();
@@ -1136,10 +1071,7 @@ static void PutGet( SbxArray& rPar, bool bPut )
SbiStream* pSbStrm = pIO->GetStream( nFileNo );
if ( !pSbStrm || !(pSbStrm->GetMode() & (SbiStreamFlags::Binary | SbiStreamFlags::Random)) )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_CHANNEL );
SvStream* pStrm = pSbStrm->GetStrm();
bool bRandom = pSbStrm->IsRandom();
@@ -1159,7 +1091,7 @@ static void PutGet( SbxArray& rPar, bool bPut )
}
SbxDimArray* pArr = nullptr;
- SbxVariable* pVar = rPar.Get32(3);
+ SbxVariable* pVar = rPar.Get(3);
if( pVar->GetType() & SbxARRAY )
{
SbxBase* pParObj = pVar->GetObject();
@@ -1171,7 +1103,7 @@ static void PutGet( SbxArray& rPar, bool bPut )
if( pArr )
{
sal_uInt64 const nFPos = pStrm->Tell();
- sal_Int32 nDims = pArr->GetDims32();
+ sal_Int32 nDims = pArr->GetDims();
std::unique_ptr<sal_Int32[]> pDims(new sal_Int32[ nDims ]);
bRet = lcl_WriteReadSbxArray(*pArr,pStrm,!bRandom,nDims,pDims.get(),bPut);
pDims.reset();
@@ -1201,21 +1133,19 @@ void SbRtl_Get(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Environ(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
OUString aResult;
// should be ANSI but that's not possible under Win16 in the DLL
- OString aByteStr(OUStringToOString(rPar.Get32(1)->GetOUString(),
+ OString aByteStr(OUStringToOString(rPar.Get(1)->GetOUString(),
osl_getThreadTextEncoding()));
const char* pEnvStr = getenv(aByteStr.getStr());
if ( pEnvStr )
{
aResult = OUString(pEnvStr, strlen(pEnvStr), osl_getThreadTextEncoding());
}
- rPar.Get32(0)->PutString( aResult );
+ rPar.Get(0)->PutString(aResult);
}
static double GetDialogZoomFactor( bool bX, tools::Long nValue )
@@ -1250,140 +1180,123 @@ static double GetDialogZoomFactor( bool bX, tools::Long nValue )
void SbRtl_GetDialogZoomFactorX(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- rPar.Get32(0)->PutDouble( GetDialogZoomFactor( true, rPar.Get32(1)->GetLong() ));
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ rPar.Get(0)->PutDouble(GetDialogZoomFactor(true, rPar.Get(1)->GetLong()));
}
void SbRtl_GetDialogZoomFactorY(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- rPar.Get32(0)->PutDouble( GetDialogZoomFactor( false, rPar.Get32(1)->GetLong()));
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ rPar.Get(0)->PutDouble(GetDialogZoomFactor(false, rPar.Get(1)->GetLong()));
}
void SbRtl_EnableReschedule(StarBASIC *, SbxArray & rPar, bool)
{
- rPar.Get32(0)->PutEmpty();
- if ( rPar.Count32() != 2 )
+ rPar.Get(0)->PutEmpty();
+ if (rPar.Count() != 2)
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
if( GetSbData()->pInst )
- GetSbData()->pInst->EnableReschedule( rPar.Get32(1)->GetBool() );
+ GetSbData()->pInst->EnableReschedule(rPar.Get(1)->GetBool());
}
void SbRtl_GetSystemTicks(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- rPar.Get32(0)->PutLong( tools::Time::GetSystemTicks() );
+ if (rPar.Count() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ rPar.Get(0)->PutLong(tools::Time::GetSystemTicks());
}
void SbRtl_GetPathSeparator(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- rPar.Get32(0)->PutString( OUString( SAL_PATHDELIMITER ) );
+ if (rPar.Count() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ rPar.Get(0)->PutString(OUString(SAL_PATHDELIMITER));
}
void SbRtl_ResolvePath(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
- {
- OUString aStr = rPar.Get32(1)->GetOUString();
- rPar.Get32(0)->PutString( aStr );
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr = rPar.Get(1)->GetOUString();
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_TypeLen(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- }
- else
- {
- SbxDataType eType = rPar.Get32(1)->GetType();
- sal_Int16 nLen = 0;
- switch( eType )
- {
- case SbxEMPTY:
- case SbxNULL:
- case SbxVECTOR:
- case SbxARRAY:
- case SbxBYREF:
- case SbxVOID:
- case SbxHRESULT:
- case SbxPOINTER:
- case SbxDIMARRAY:
- case SbxCARRAY:
- case SbxUSERDEF:
- nLen = 0;
- break;
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- case SbxINTEGER:
- case SbxERROR:
- case SbxUSHORT:
- case SbxINT:
- case SbxUINT:
- nLen = 2;
- break;
+ SbxDataType eType = rPar.Get(1)->GetType();
+ sal_Int16 nLen = 0;
+ switch( eType )
+ {
+ case SbxEMPTY:
+ case SbxNULL:
+ case SbxVECTOR:
+ case SbxARRAY:
+ case SbxBYREF:
+ case SbxVOID:
+ case SbxHRESULT:
+ case SbxPOINTER:
+ case SbxDIMARRAY:
+ case SbxCARRAY:
+ case SbxUSERDEF:
+ nLen = 0;
+ break;
- case SbxLONG:
- case SbxSINGLE:
- case SbxULONG:
- nLen = 4;
- break;
+ case SbxINTEGER:
+ case SbxERROR:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ nLen = 2;
+ break;
- case SbxDOUBLE:
- case SbxCURRENCY:
- case SbxDATE:
- case SbxSALINT64:
- case SbxSALUINT64:
- nLen = 8;
- break;
+ case SbxLONG:
+ case SbxSINGLE:
+ case SbxULONG:
+ nLen = 4;
+ break;
- case SbxOBJECT:
- case SbxVARIANT:
- case SbxDATAOBJECT:
- nLen = 0;
- break;
+ case SbxDOUBLE:
+ case SbxCURRENCY:
+ case SbxDATE:
+ case SbxSALINT64:
+ case SbxSALUINT64:
+ nLen = 8;
+ break;
- case SbxCHAR:
- case SbxBYTE:
- case SbxBOOL:
- nLen = 1;
- break;
+ case SbxOBJECT:
+ case SbxVARIANT:
+ case SbxDATAOBJECT:
+ nLen = 0;
+ break;
- case SbxLPSTR:
- case SbxLPWSTR:
- case SbxCoreSTRING:
- case SbxSTRING:
- nLen = static_cast<sal_Int16>(rPar.Get32(1)->GetOUString().getLength());
+ case SbxCHAR:
+ case SbxBYTE:
+ case SbxBOOL:
+ nLen = 1;
break;
- default:
- nLen = 0;
- break;
- }
- rPar.Get32(0)->PutInteger( nLen );
+ case SbxLPSTR:
+ case SbxLPWSTR:
+ case SbxCoreSTRING:
+ case SbxSTRING:
+ nLen = static_cast<sal_Int16>(rPar.Get(1)->GetOUString().getLength());
+ break;
+
+ default:
+ nLen = 0;
+ break;
}
+ rPar.Get(0)->PutInteger(nLen);
}
@@ -1457,51 +1370,44 @@ void SbRtl_GlobalScope(StarBASIC * pBasic, SbxArray & rPar, bool)
{
p = p->GetParent();
}
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( p );
}
// Helper functions to convert Url from/to system paths
void SbRtl_ConvertToUrl(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr = rPar.Get(1)->GetOUString();
+ INetURLObject aURLObj( aStr, INetProtocol::File );
+ OUString aFileURL = aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( aFileURL.isEmpty() )
{
- OUString aStr = rPar.Get32(1)->GetOUString();
- INetURLObject aURLObj( aStr, INetProtocol::File );
- OUString aFileURL = aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( aFileURL.isEmpty() )
- {
- osl::File::getFileURLFromSystemPath(aStr, aFileURL);
- }
- if( aFileURL.isEmpty() )
- {
- aFileURL = aStr;
- }
- rPar.Get32(0)->PutString(aFileURL);
+ osl::File::getFileURLFromSystemPath(aStr, aFileURL);
}
- else
+ if( aFileURL.isEmpty() )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ aFileURL = aStr;
}
+ rPar.Get(0)->PutString(aFileURL);
+
}
void SbRtl_ConvertFromUrl(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() == 2 )
- {
- OUString aStr = rPar.Get32(1)->GetOUString();
- OUString aSysPath;
- ::osl::File::getSystemPathFromFileURL( aStr, aSysPath );
- if( aSysPath.isEmpty() )
- {
- aSysPath = aStr;
- }
- rPar.Get32(0)->PutString(aSysPath);
- }
- else
+ if (rPar.Count() != 2)
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ OUString aStr = rPar.Get(1)->GetOUString();
+ OUString aSysPath;
+ ::osl::File::getSystemPathFromFileURL( aStr, aSysPath );
+ if( aSysPath.isEmpty() )
{
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+ aSysPath = aStr;
}
+ rPar.Get(0)->PutString(aSysPath);
}
@@ -1513,62 +1419,55 @@ void SbRtl_GetDefaultContext(StarBASIC *, SbxArray & rPar, bool)
void SbRtl_Join(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if ( nParCount != 3 && nParCount != 2 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
- SbxBase* pParObj = rPar.Get32(1)->GetObject();
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
+ SbxBase* pParObj = rPar.Get(1)->GetObject();
SbxDimArray* pArr = dynamic_cast<SbxDimArray*>( pParObj );
- if( pArr )
+ if( !pArr )
+ return StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+
+ if (pArr->GetDims() != 1)
+ return StarBASIC::Error( ERRCODE_BASIC_WRONG_DIMS ); // Syntax Error?!
+
+ OUString aDelim;
+ if( nParCount == 3 )
{
- if( pArr->GetDims32() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_WRONG_DIMS ); // Syntax Error?!
- return;
- }
- OUString aDelim;
- if( nParCount == 3 )
- {
- aDelim = rPar.Get32(2)->GetOUString();
- }
- else
- {
- aDelim = " ";
- }
- OUStringBuffer aRetStr(32);
- sal_Int32 nLower, nUpper;
- pArr->GetDim32( 1, nLower, nUpper );
- sal_Int32 aIdx[1];
- for (aIdx[0] = nLower; aIdx[0] <= nUpper; ++aIdx[0])
- {
- OUString aStr = pArr->Get32(aIdx)->GetOUString();
- aRetStr.append(aStr);
- if (aIdx[0] != nUpper)
- {
- aRetStr.append(aDelim);
- }
- }
- rPar.Get32(0)->PutString( aRetStr.makeStringAndClear() );
+ aDelim = rPar.Get(2)->GetOUString();
}
else
{
- StarBASIC::Error( ERRCODE_BASIC_MUST_HAVE_DIMS );
+ aDelim = " ";
}
+ OUStringBuffer aRetStr(32);
+ sal_Int32 nLower, nUpper;
+ pArr->GetDim(1, nLower, nUpper);
+ sal_Int32 aIdx[1];
+ for (aIdx[0] = nLower; aIdx[0] <= nUpper; ++aIdx[0])
+ {
+ OUString aStr = pArr->Get(aIdx)->GetOUString();
+ aRetStr.append(aStr);
+ if (aIdx[0] != nUpper)
+ {
+ aRetStr.append(aDelim);
+ }
+ }
+ rPar.Get(0)->PutString(aRetStr.makeStringAndClear());
+
}
void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if ( nParCount < 2 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- OUString aExpression = rPar.Get32(1)->GetOUString();
+ OUString aExpression = rPar.Get(1)->GetOUString();
sal_Int32 nArraySize = 0;
std::vector< OUString > vRet;
if( !aExpression.isEmpty() )
@@ -1576,7 +1475,7 @@ void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
OUString aDelim;
if( nParCount >= 3 )
{
- aDelim = rPar.Get32(2)->GetOUString();
+ aDelim = rPar.Get(2)->GetOUString();
}
else
{
@@ -1586,7 +1485,7 @@ void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
sal_Int32 nCount = -1;
if( nParCount == 4 )
{
- nCount = rPar.Get32(3)->GetLong();
+ nCount = rPar.Get(3)->GetLong();
}
sal_Int32 nDelimLen = aDelim.getLength();
if( nDelimLen )
@@ -1630,19 +1529,25 @@ void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
// tdf#123025 - split returns an array of substrings
SbxDimArray* pArray = new SbxDimArray( SbxSTRING );
- pArray->unoAddDim32( 0, nArraySize-1 );
+ pArray->unoAddDim(0, nArraySize - 1);
// insert parameter(s) into the array
+ const bool bIsVBAInterOp = SbiRuntime::isVBAEnabled();
for(sal_Int32 i = 0 ; i < nArraySize ; i++ )
{
// tdf#123025 - split returns an array of substrings
SbxVariableRef xVar = new SbxVariable( SbxSTRING );
xVar->PutString( vRet[i] );
- pArray->Put32( xVar.get(), &i );
+ // tdf#144924 - allow the assignment of different data types to the individual elements
+ if (!bIsVBAInterOp)
+ {
+ xVar->ResetFlag(SbxFlagBits::Fixed);
+ }
+ pArray->Put(xVar.get(), &i);
}
// return array
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
SbxFlagBits nFlags = refVar->GetFlags();
refVar->ResetFlag( SbxFlagBits::Fixed );
refVar->PutObject( pArray );
@@ -1653,7 +1558,7 @@ void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
// MonthName(month[, abbreviate])
void SbRtl_MonthName(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount != 2 && nParCount != 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1669,7 +1574,7 @@ void SbRtl_MonthName(StarBASIC *, SbxArray & rPar, bool)
Sequence< CalendarItem2 > aMonthSeq = xCalendar->getMonths2();
sal_Int32 nMonthCount = aMonthSeq.getLength();
- sal_Int16 nVal = rPar.Get32(1)->GetInteger();
+ sal_Int16 nVal = rPar.Get(1)->GetInteger();
if( nVal < 1 || nVal > nMonthCount )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1678,19 +1583,19 @@ void SbRtl_MonthName(StarBASIC *, SbxArray & rPar, bool)
bool bAbbreviate = false;
if( nParCount == 3 )
- bAbbreviate = rPar.Get32(2)->GetBool();
+ bAbbreviate = rPar.Get(2)->GetBool();
const CalendarItem2* pCalendarItems = aMonthSeq.getConstArray();
const CalendarItem2& rItem = pCalendarItems[nVal - 1];
OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
- rPar.Get32(0)->PutString(aRetStr);
+ rPar.Get(0)->PutString(aRetStr);
}
// WeekdayName(weekday, abbreviate, firstdayofweek)
void SbRtl_WeekdayName(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount < 2 || nParCount > 4 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1706,11 +1611,11 @@ void SbRtl_WeekdayName(StarBASIC *, SbxArray & rPar, bool)
Sequence< CalendarItem2 > aDaySeq = xCalendar->getDays2();
sal_Int16 nDayCount = static_cast<sal_Int16>(aDaySeq.getLength());
- sal_Int16 nDay = rPar.Get32(1)->GetInteger();
+ sal_Int16 nDay = rPar.Get(1)->GetInteger();
sal_Int16 nFirstDay = 0;
if( nParCount == 4 )
{
- nFirstDay = rPar.Get32(3)->GetInteger();
+ nFirstDay = rPar.Get(3)->GetInteger();
if( nFirstDay < 0 || nFirstDay > 7 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -1731,7 +1636,7 @@ void SbRtl_WeekdayName(StarBASIC *, SbxArray & rPar, bool)
bool bAbbreviate = false;
if( nParCount >= 3 )
{
- SbxVariable* pPar2 = rPar.Get32(2);
+ SbxVariable* pPar2 = rPar.Get(2);
if( !pPar2->IsErr() )
{
bAbbreviate = pPar2->GetBool();
@@ -1742,29 +1647,29 @@ void SbRtl_WeekdayName(StarBASIC *, SbxArray & rPar, bool)
const CalendarItem2& rItem = pCalendarItems[nDay - 1];
OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
- rPar.Get32(0)->PutString( aRetStr );
+ rPar.Get(0)->PutString(aRetStr);
}
void SbRtl_Weekday(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if ( nParCount < 2 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
else
{
- double aDate = rPar.Get32(1)->GetDate();
+ double aDate = rPar.Get(1)->GetDate();
bool bFirstDay = false;
sal_Int16 nFirstDay = 0;
if ( nParCount > 2 )
{
- nFirstDay = rPar.Get32(2)->GetInteger();
+ nFirstDay = rPar.Get(2)->GetInteger();
bFirstDay = true;
}
sal_Int16 nDay = implGetWeekDay( aDate, bFirstDay, nFirstDay );
- rPar.Get32(0)->PutInteger( nDay );
+ rPar.Get(0)->PutInteger(nDay);
}
}
@@ -1809,13 +1714,13 @@ static IntervalInfo const * getIntervalInfo( const OUString& rStringCode )
{ INTERVAL_N, "n", 1.0 / 1440.0, true }, // Minute
{ INTERVAL_S, "s", 1.0 / 86400.0, true } // Second
};
- for( std::size_t i = 0; i != SAL_N_ELEMENTS(aIntervalTable); ++i )
- {
- if( rStringCode.equalsIgnoreAsciiCaseAscii(
- aIntervalTable[i].mStringCode ) )
- {
- return &aIntervalTable[i];
- }
+ auto const pred = [&rStringCode](const IntervalInfo &aInterval) {
+ return rStringCode.equalsIgnoreAsciiCaseAscii(aInterval.mStringCode);
+ };
+
+ auto intervalIter = std::find_if(std::begin(aIntervalTable), std::end(aIntervalTable), pred);
+ if(intervalIter != std::end(aIntervalTable)) {
+ return intervalIter;
}
return nullptr;
}
@@ -1851,14 +1756,14 @@ static sal_Int16 limitDate( sal_Int32 n32Year, sal_Int16& rMonth, sal_Int16& rDa
void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount != 4 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- OUString aStringCode = rPar.Get32(1)->GetOUString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo const * pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -1866,8 +1771,8 @@ void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool)
return;
}
- sal_Int32 lNumber = rPar.Get32(2)->GetLong();
- double dDate = rPar.Get32(3)->GetDate();
+ sal_Int32 lNumber = rPar.Get(2)->GetLong();
+ double dDate = rPar.Get(3)->GetDate();
double dNewDate = 0;
if( pInfo->mbSimple )
{
@@ -1946,7 +1851,7 @@ void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool)
dNewDate += dHoursMinutesSeconds;
}
- rPar.Get32(0)->PutDate( dNewDate );
+ rPar.Get(0)->PutDate(dNewDate);
}
static double RoundImpl( double d )
@@ -1958,14 +1863,14 @@ void SbRtl_DateDiff(StarBASIC *, SbxArray & rPar, bool)
{
// DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount < 4 || nParCount > 6 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- OUString aStringCode = rPar.Get32(1)->GetOUString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo const * pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -1973,8 +1878,8 @@ void SbRtl_DateDiff(StarBASIC *, SbxArray & rPar, bool)
return;
}
- double dDate1 = rPar.Get32(2)->GetDate();
- double dDate2 = rPar.Get32(3)->GetDate();
+ double dDate1 = rPar.Get(2)->GetDate();
+ double dDate2 = rPar.Get(3)->GetDate();
double dRet = 0.0;
switch( pInfo->meInterval )
@@ -2026,7 +1931,7 @@ void SbRtl_DateDiff(StarBASIC *, SbxArray & rPar, bool)
sal_Int16 nFirstDay = 1; // Default
if( nParCount >= 5 )
{
- nFirstDay = rPar.Get32(4)->GetInteger();
+ nFirstDay = rPar.Get(4)->GetInteger();
if( nFirstDay < 0 || nFirstDay > 7 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2076,7 +1981,7 @@ void SbRtl_DateDiff(StarBASIC *, SbxArray & rPar, bool)
break;
}
}
- rPar.Get32(0)->PutDouble( dRet );
+ rPar.Get(0)->PutDouble(dRet);
}
static double implGetDateOfFirstDayInFirstWeek
@@ -2149,14 +2054,14 @@ void SbRtl_DatePart(StarBASIC *, SbxArray & rPar, bool)
{
// DatePart(interval, date[,firstdayofweek[, firstweekofyear]])
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount < 3 || nParCount > 5 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- OUString aStringCode = rPar.Get32(1)->GetOUString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo const * pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -2164,7 +2069,7 @@ void SbRtl_DatePart(StarBASIC *, SbxArray & rPar, bool)
return;
}
- double dDate = rPar.Get32(2)->GetDate();
+ double dDate = rPar.Get(2)->GetDate();
sal_Int32 nRet = 0;
switch( pInfo->meInterval )
@@ -2203,7 +2108,7 @@ void SbRtl_DatePart(StarBASIC *, SbxArray & rPar, bool)
sal_Int16 nFirstDay = 1; // Default
if( nParCount >= 4 )
{
- nFirstDay = rPar.Get32(3)->GetInteger();
+ nFirstDay = rPar.Get(3)->GetInteger();
bFirstDay = true;
}
nRet = implGetWeekDay( dDate, bFirstDay, nFirstDay );
@@ -2213,11 +2118,11 @@ void SbRtl_DatePart(StarBASIC *, SbxArray & rPar, bool)
{
sal_Int16 nFirstDay = 1; // Default
if( nParCount >= 4 )
- nFirstDay = rPar.Get32(3)->GetInteger();
+ nFirstDay = rPar.Get(3)->GetInteger();
sal_Int16 nFirstWeek = 1; // Default
if( nParCount == 5 )
- nFirstWeek = rPar.Get32(4)->GetInteger();
+ nFirstWeek = rPar.Get(4)->GetInteger();
sal_Int16 nYear = implGetDateYear( dDate );
bool bError = false;
@@ -2259,24 +2164,24 @@ void SbRtl_DatePart(StarBASIC *, SbxArray & rPar, bool)
break;
}
}
- rPar.Get32(0)->PutLong( nRet );
+ rPar.Get(0)->PutLong(nRet);
}
// FormatDateTime(Date[,NamedFormat])
void SbRtl_FormatDateTime(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount < 2 || nParCount > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- double dDate = rPar.Get32(1)->GetDate();
+ double dDate = rPar.Get(1)->GetDate();
sal_Int16 nNamedFormat = 0;
if( nParCount > 2 )
{
- nNamedFormat = rPar.Get32(2)->GetInteger();
+ nNamedFormat = rPar.Get(2)->GetInteger();
if( nNamedFormat < 0 || nNamedFormat > 4 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2360,51 +2265,44 @@ void SbRtl_FormatDateTime(StarBASIC *, SbxArray & rPar, bool)
break;
}
- rPar.Get32(0)->PutString( aRetStr );
+ rPar.Get(0)->PutString(aRetStr);
}
void SbRtl_Frac(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
double dVal = pSbxVariable->GetDouble();
if(dVal >= 0)
- rPar.Get32(0)->PutDouble(dVal - ::rtl::math::approxFloor(dVal));
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxFloor(dVal));
else
- rPar.Get32(0)->PutDouble(dVal - ::rtl::math::approxCeil(dVal));
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxCeil(dVal));
}
void SbRtl_Round(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nParCount = rPar.Count32();
+ sal_uInt32 nParCount = rPar.Count();
if( nParCount != 2 && nParCount != 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
double dVal = pSbxVariable->GetDouble();
double dRes = 0.0;
if( dVal != 0.0 )
{
- bool bNeg = false;
- if( dVal < 0.0 )
- {
- bNeg = true;
- dVal = -dVal;
- }
-
sal_Int16 numdecimalplaces = 0;
if( nParCount == 3 )
{
- numdecimalplaces = rPar.Get32(2)->GetInteger();
+ numdecimalplaces = rPar.Get(2)->GetInteger();
if( numdecimalplaces < 0 || numdecimalplaces > 22 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2412,22 +2310,9 @@ void SbRtl_Round(StarBASIC *, SbxArray & rPar, bool)
}
}
- if( numdecimalplaces == 0 )
- {
- dRes = floor( dVal + 0.5 );
- }
- else
- {
- double dFactor = pow( 10.0, numdecimalplaces );
- dVal *= dFactor;
- dRes = floor( dVal + 0.5 );
- dRes /= dFactor;
- }
-
- if( bNeg )
- dRes = -dRes;
+ dRes = rtl_math_round(dVal, numdecimalplaces, rtl_math_RoundingMode_HalfEven);
}
- rPar.Get32(0)->PutDouble( dRes );
+ rPar.Get(0)->PutDouble(dRes);
}
static void CallFunctionAccessFunction( const Sequence< Any >& aArgs, const OUString& sFuncName, SbxVariable* pRet )
@@ -2456,7 +2341,7 @@ static void CallFunctionAccessFunction( const Sequence< Any >& aArgs, const OUSt
void SbRtl_SYD(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 4 )
{
@@ -2466,18 +2351,20 @@ void SbRtl_SYD(StarBASIC *, SbxArray & rPar, bool)
// retrieve non-optional params
- Sequence< Any > aParams( 4 );
- aParams[ 0 ] <<= rPar.Get32(1)->GetDouble();
- aParams[ 1 ] <<= rPar.Get32(2)->GetDouble();
- aParams[ 2 ] <<= rPar.Get32(3)->GetDouble();
- aParams[ 3 ] <<= rPar.Get32(4)->GetDouble();
+ Sequence< Any > aParams
+ {
+ Any(rPar.Get(1)->GetDouble()),
+ Any(rPar.Get(2)->GetDouble()),
+ Any(rPar.Get(3)->GetDouble()),
+ Any(rPar.Get(4)->GetDouble())
+ };
- CallFunctionAccessFunction( aParams, "SYD", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "SYD", rPar.Get(0));
}
void SbRtl_SLN(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 )
{
@@ -2487,17 +2374,19 @@ void SbRtl_SLN(StarBASIC *, SbxArray & rPar, bool)
// retrieve non-optional params
- Sequence< Any > aParams( 3 );
- aParams[ 0 ] <<= rPar.Get32(1)->GetDouble();
- aParams[ 1 ] <<= rPar.Get32(2)->GetDouble();
- aParams[ 2 ] <<= rPar.Get32(3)->GetDouble();
+ Sequence< Any > aParams
+ {
+ Any(rPar.Get(1)->GetDouble()),
+ Any(rPar.Get(2)->GetDouble()),
+ Any(rPar.Get(3)->GetDouble())
+ };
- CallFunctionAccessFunction( aParams, "SLN", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "SLN", rPar.Get(0));
}
void SbRtl_Pmt(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 5 )
{
@@ -2506,9 +2395,9 @@ void SbRtl_Pmt(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double nper = rPar.Get32(2)->GetDouble();
- double pmt = rPar.Get32(3)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double nper = rPar.Get(2)->GetDouble();
+ double pmt = rPar.Get(3)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2517,29 +2406,31 @@ void SbRtl_Pmt(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 4 )
{
- if( rPar.Get32(4)->GetType() != SbxEMPTY )
- fv = rPar.Get32(4)->GetDouble();
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
+ fv = rPar.Get(4)->GetDouble();
}
// type
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- type = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ type = rPar.Get(5)->GetDouble();
}
- Sequence< Any > aParams( 5 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= nper;
- aParams[ 2 ] <<= pmt;
- aParams[ 3 ] <<= fv;
- aParams[ 4 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(nper),
+ Any(pmt),
+ Any(fv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "Pmt", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "Pmt", rPar.Get(0));
}
void SbRtl_PPmt(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 4 || nArgCount > 6 )
{
@@ -2548,10 +2439,10 @@ void SbRtl_PPmt(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double per = rPar.Get32(2)->GetDouble();
- double nper = rPar.Get32(3)->GetDouble();
- double pv = rPar.Get32(4)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double per = rPar.Get(2)->GetDouble();
+ double nper = rPar.Get(3)->GetDouble();
+ double pv = rPar.Get(4)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2560,30 +2451,32 @@ void SbRtl_PPmt(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- fv = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ fv = rPar.Get(5)->GetDouble();
}
// type
if ( nArgCount >= 6 )
{
- if( rPar.Get32(6)->GetType() != SbxEMPTY )
- type = rPar.Get32(6)->GetDouble();
+ if (rPar.Get(6)->GetType() != SbxEMPTY)
+ type = rPar.Get(6)->GetDouble();
}
- Sequence< Any > aParams( 6 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= per;
- aParams[ 2 ] <<= nper;
- aParams[ 3 ] <<= pv;
- aParams[ 4 ] <<= fv;
- aParams[ 5 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(per),
+ Any(nper),
+ Any(pv),
+ Any(fv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "PPmt", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "PPmt", rPar.Get(0));
}
void SbRtl_PV(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 5 )
{
@@ -2592,9 +2485,9 @@ void SbRtl_PV(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double nper = rPar.Get32(2)->GetDouble();
- double pmt = rPar.Get32(3)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double nper = rPar.Get(2)->GetDouble();
+ double pmt = rPar.Get(3)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2603,29 +2496,31 @@ void SbRtl_PV(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 4 )
{
- if( rPar.Get32(4)->GetType() != SbxEMPTY )
- fv = rPar.Get32(4)->GetDouble();
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
+ fv = rPar.Get(4)->GetDouble();
}
// type
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- type = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ type = rPar.Get(5)->GetDouble();
}
- Sequence< Any > aParams( 5 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= nper;
- aParams[ 2 ] <<= pmt;
- aParams[ 3 ] <<= fv;
- aParams[ 4 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(nper),
+ Any(pmt),
+ Any(fv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "PV", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "PV", rPar.Get(0));
}
void SbRtl_NPV(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 1 || nArgCount > 2 )
{
@@ -2633,24 +2528,26 @@ void SbRtl_NPV(StarBASIC *, SbxArray & rPar, bool)
return;
}
- Sequence< Any > aParams( 2 );
- aParams[ 0 ] <<= rPar.Get32(1)->GetDouble();
- Any aValues = sbxToUnoValue( rPar.Get32(2),
+ Any aValues = sbxToUnoValue(rPar.Get(2),
cppu::UnoType<Sequence<double>>::get() );
// convert for calc functions
Sequence< Sequence< double > > sValues(1);
- aValues >>= sValues[ 0 ];
+ aValues >>= sValues.getArray()[ 0 ];
aValues <<= sValues;
- aParams[ 1 ] = aValues;
+ Sequence< Any > aParams
+ {
+ Any(rPar.Get(1)->GetDouble()),
+ aValues
+ };
- CallFunctionAccessFunction( aParams, "NPV", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "NPV", rPar.Get(0));
}
void SbRtl_NPer(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 5 )
{
@@ -2659,9 +2556,9 @@ void SbRtl_NPer(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double pmt = rPar.Get32(2)->GetDouble();
- double pv = rPar.Get32(3)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double pmt = rPar.Get(2)->GetDouble();
+ double pv = rPar.Get(3)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2670,29 +2567,31 @@ void SbRtl_NPer(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 4 )
{
- if( rPar.Get32(4)->GetType() != SbxEMPTY )
- fv = rPar.Get32(4)->GetDouble();
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
+ fv = rPar.Get(4)->GetDouble();
}
// type
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- type = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ type = rPar.Get(5)->GetDouble();
}
- Sequence< Any > aParams( 5 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= pmt;
- aParams[ 2 ] <<= pv;
- aParams[ 3 ] <<= fv;
- aParams[ 4 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(pmt),
+ Any(pv),
+ Any(fv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "NPer", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "NPer", rPar.Get(0));
}
void SbRtl_MIRR(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 )
{
@@ -2702,25 +2601,27 @@ void SbRtl_MIRR(StarBASIC *, SbxArray & rPar, bool)
// retrieve non-optional params
- Sequence< Any > aParams( 3 );
- Any aValues = sbxToUnoValue( rPar.Get32(1),
+ Any aValues = sbxToUnoValue(rPar.Get(1),
cppu::UnoType<Sequence<double>>::get() );
// convert for calc functions
Sequence< Sequence< double > > sValues(1);
- aValues >>= sValues[ 0 ];
+ aValues >>= sValues.getArray()[ 0 ];
aValues <<= sValues;
- aParams[ 0 ] = aValues;
- aParams[ 1 ] <<= rPar.Get32(2)->GetDouble();
- aParams[ 2 ] <<= rPar.Get32(3)->GetDouble();
+ Sequence< Any > aParams
+ {
+ aValues,
+ Any(rPar.Get(2)->GetDouble()),
+ Any(rPar.Get(3)->GetDouble())
+ };
- CallFunctionAccessFunction( aParams, "MIRR", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "MIRR", rPar.Get(0));
}
void SbRtl_IRR(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 1 || nArgCount > 2 )
{
@@ -2728,12 +2629,12 @@ void SbRtl_IRR(StarBASIC *, SbxArray & rPar, bool)
return;
}
// retrieve non-optional params
- Any aValues = sbxToUnoValue( rPar.Get32(1),
+ Any aValues = sbxToUnoValue(rPar.Get(1),
cppu::UnoType<Sequence<double>>::get() );
// convert for calc functions
Sequence< Sequence< double > > sValues(1);
- aValues >>= sValues[ 0 ];
+ aValues >>= sValues.getArray()[ 0 ];
aValues <<= sValues;
// set default values for Optional args
@@ -2741,20 +2642,22 @@ void SbRtl_IRR(StarBASIC *, SbxArray & rPar, bool)
// guess
if ( nArgCount >= 2 )
{
- if( rPar.Get32(2)->GetType() != SbxEMPTY )
- guess = rPar.Get32(2)->GetDouble();
+ if (rPar.Get(2)->GetType() != SbxEMPTY)
+ guess = rPar.Get(2)->GetDouble();
}
- Sequence< Any > aParams( 2 );
- aParams[ 0 ] = aValues;
- aParams[ 1 ] <<= guess;
+ Sequence< Any > aParams
+ {
+ aValues,
+ Any(guess)
+ };
- CallFunctionAccessFunction( aParams, "IRR", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "IRR", rPar.Get(0));
}
void SbRtl_IPmt(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 4 || nArgCount > 6 )
{
@@ -2763,10 +2666,10 @@ void SbRtl_IPmt(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double per = rPar.Get32(2)->GetInteger();
- double nper = rPar.Get32(3)->GetDouble();
- double pv = rPar.Get32(4)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double per = rPar.Get(2)->GetInteger();
+ double nper = rPar.Get(3)->GetDouble();
+ double pv = rPar.Get(4)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2775,30 +2678,32 @@ void SbRtl_IPmt(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- fv = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ fv = rPar.Get(5)->GetDouble();
}
// type
if ( nArgCount >= 6 )
{
- if( rPar.Get32(6)->GetType() != SbxEMPTY )
- type = rPar.Get32(6)->GetDouble();
+ if (rPar.Get(6)->GetType() != SbxEMPTY)
+ type = rPar.Get(6)->GetDouble();
}
- Sequence< Any > aParams( 6 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= per;
- aParams[ 2 ] <<= nper;
- aParams[ 3 ] <<= pv;
- aParams[ 4 ] <<= fv;
- aParams[ 5 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(per),
+ Any(nper),
+ Any(pv),
+ Any(fv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "IPmt", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "IPmt", rPar.Get(0));
}
void SbRtl_FV(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 5 )
{
@@ -2807,9 +2712,9 @@ void SbRtl_FV(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double rate = rPar.Get32(1)->GetDouble();
- double nper = rPar.Get32(2)->GetDouble();
- double pmt = rPar.Get32(3)->GetDouble();
+ double rate = rPar.Get(1)->GetDouble();
+ double nper = rPar.Get(2)->GetDouble();
+ double pmt = rPar.Get(3)->GetDouble();
// set default values for Optional args
double pv = 0;
@@ -2818,29 +2723,31 @@ void SbRtl_FV(StarBASIC *, SbxArray & rPar, bool)
// pv
if ( nArgCount >= 4 )
{
- if( rPar.Get32(4)->GetType() != SbxEMPTY )
- pv = rPar.Get32(4)->GetDouble();
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
+ pv = rPar.Get(4)->GetDouble();
}
// type
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- type = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ type = rPar.Get(5)->GetDouble();
}
- Sequence< Any > aParams( 5 );
- aParams[ 0 ] <<= rate;
- aParams[ 1 ] <<= nper;
- aParams[ 2 ] <<= pmt;
- aParams[ 3 ] <<= pv;
- aParams[ 4 ] <<= type;
+ Sequence< Any > aParams
+ {
+ Any(rate),
+ Any(nper),
+ Any(pmt),
+ Any(pv),
+ Any(type)
+ };
- CallFunctionAccessFunction( aParams, "FV", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "FV", rPar.Get(0));
}
void SbRtl_DDB(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 4 || nArgCount > 5 )
{
@@ -2849,10 +2756,10 @@ void SbRtl_DDB(StarBASIC *, SbxArray & rPar, bool)
}
// retrieve non-optional params
- double cost = rPar.Get32(1)->GetDouble();
- double salvage = rPar.Get32(2)->GetDouble();
- double life = rPar.Get32(3)->GetDouble();
- double period = rPar.Get32(4)->GetDouble();
+ double cost = rPar.Get(1)->GetDouble();
+ double salvage = rPar.Get(2)->GetDouble();
+ double life = rPar.Get(3)->GetDouble();
+ double period = rPar.Get(4)->GetDouble();
// set default values for Optional args
double factor = 2;
@@ -2860,23 +2767,25 @@ void SbRtl_DDB(StarBASIC *, SbxArray & rPar, bool)
// factor
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- factor = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ factor = rPar.Get(5)->GetDouble();
}
- Sequence< Any > aParams( 5 );
- aParams[ 0 ] <<= cost;
- aParams[ 1 ] <<= salvage;
- aParams[ 2 ] <<= life;
- aParams[ 3 ] <<= period;
- aParams[ 4 ] <<= factor;
+ Sequence< Any > aParams
+ {
+ Any(cost),
+ Any(salvage),
+ Any(life),
+ Any(period),
+ Any(factor)
+ };
- CallFunctionAccessFunction( aParams, "DDB", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "DDB", rPar.Get(0));
}
void SbRtl_Rate(StarBASIC *, SbxArray & rPar, bool)
{
- sal_uInt32 nArgCount = rPar.Count32()-1;
+ sal_uInt32 nArgCount = rPar.Count() - 1;
if ( nArgCount < 3 || nArgCount > 6 )
{
@@ -2889,9 +2798,9 @@ void SbRtl_Rate(StarBASIC *, SbxArray & rPar, bool)
double pmt = 0;
double pv = 0;
- nper = rPar.Get32(1)->GetDouble();
- pmt = rPar.Get32(2)->GetDouble();
- pv = rPar.Get32(3)->GetDouble();
+ nper = rPar.Get(1)->GetDouble();
+ pmt = rPar.Get(2)->GetDouble();
+ pv = rPar.Get(3)->GetDouble();
// set default values for Optional args
double fv = 0;
@@ -2901,44 +2810,46 @@ void SbRtl_Rate(StarBASIC *, SbxArray & rPar, bool)
// fv
if ( nArgCount >= 4 )
{
- if( rPar.Get32(4)->GetType() != SbxEMPTY )
- fv = rPar.Get32(4)->GetDouble();
+ if (rPar.Get(4)->GetType() != SbxEMPTY)
+ fv = rPar.Get(4)->GetDouble();
}
// type
if ( nArgCount >= 5 )
{
- if( rPar.Get32(5)->GetType() != SbxEMPTY )
- type = rPar.Get32(5)->GetDouble();
+ if (rPar.Get(5)->GetType() != SbxEMPTY)
+ type = rPar.Get(5)->GetDouble();
}
// guess
if ( nArgCount >= 6 )
{
- if( rPar.Get32(6)->GetType() != SbxEMPTY )
- guess = rPar.Get32(6)->GetDouble();
+ if (rPar.Get(6)->GetType() != SbxEMPTY)
+ guess = rPar.Get(6)->GetDouble();
}
- Sequence< Any > aParams( 6 );
- aParams[ 0 ] <<= nper;
- aParams[ 1 ] <<= pmt;
- aParams[ 2 ] <<= pv;
- aParams[ 3 ] <<= fv;
- aParams[ 4 ] <<= type;
- aParams[ 5 ] <<= guess;
+ Sequence< Any > aParams
+ {
+ Any(nper),
+ Any(pmt),
+ Any(pv),
+ Any(fv),
+ Any(type),
+ Any(guess)
+ };
- CallFunctionAccessFunction( aParams, "Rate", rPar.Get32( 0 ) );
+ CallFunctionAccessFunction(aParams, "Rate", rPar.Get(0));
}
void SbRtl_StrReverse(StarBASIC *, SbxArray & rPar, bool)
{
- if ( rPar.Count32() != 2 )
+ if (rPar.Count() != 2)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- SbxVariable *pSbxVariable = rPar.Get32(1);
+ SbxVariable* pSbxVariable = rPar.Get(1);
if( pSbxVariable->IsNull() )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2946,13 +2857,13 @@ void SbRtl_StrReverse(StarBASIC *, SbxArray & rPar, bool)
}
OUString aStr = comphelper::string::reverseString(pSbxVariable->GetOUString());
- rPar.Get32(0)->PutString( aStr );
+ rPar.Get(0)->PutString(aStr);
}
void SbRtl_CompatibilityMode(StarBASIC *, SbxArray & rPar, bool)
{
bool bEnabled = false;
- sal_uInt32 nCount = rPar.Count32();
+ sal_uInt32 nCount = rPar.Count();
if ( nCount != 1 && nCount != 2 )
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -2961,24 +2872,24 @@ void SbRtl_CompatibilityMode(StarBASIC *, SbxArray & rPar, bool)
{
if ( nCount == 2 )
{
- pInst->EnableCompatibility( rPar.Get32(1)->GetBool() );
+ pInst->EnableCompatibility(rPar.Get(1)->GetBool());
}
bEnabled = pInst->IsCompatibility();
}
- rPar.Get32(0)->PutBool( bEnabled );
+ rPar.Get(0)->PutBool(bEnabled);
}
void SbRtl_Input(StarBASIC *, SbxArray & rPar, bool)
{
// 2 parameters needed
- if ( rPar.Count32() < 3 )
+ if (rPar.Count() < 3)
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- sal_uInt16 nByteCount = rPar.Get32(1)->GetUShort();
- sal_Int16 nFileNumber = rPar.Get32(2)->GetInteger();
+ sal_uInt16 nByteCount = rPar.Get(1)->GetUShort();
+ sal_Int16 nFileNumber = rPar.Get(2)->GetInteger();
SbiIoSystem* pIosys = GetSbData()->pInst->GetIoSystem();
SbiStream* pSbStrm = pIosys->GetStream( nFileNumber );
@@ -2998,14 +2909,14 @@ void SbRtl_Input(StarBASIC *, SbxArray & rPar, bool)
StarBASIC::Error( err );
return;
}
- rPar.Get32(0)->PutString(OStringToOUString(aByteBuffer, osl_getThreadTextEncoding()));
+ rPar.Get(0)->PutString(OStringToOUString(aByteBuffer, osl_getThreadTextEncoding()));
}
void SbRtl_Me(StarBASIC *, SbxArray & rPar, bool)
{
SbModule* pActiveModule = GetSbData()->pInst->GetActiveModule();
SbClassModuleObject* pClassModuleObject = dynamic_cast<SbClassModuleObject*>( pActiveModule );
- SbxVariableRef refVar = rPar.Get32(0);
+ SbxVariableRef refVar = rPar.Get(0);
if( pClassModuleObject == nullptr )
{
SbObjModule* pMod = dynamic_cast<SbObjModule*>( pActiveModule );
@@ -3020,11 +2931,17 @@ void SbRtl_Me(StarBASIC *, SbxArray & rPar, bool)
#endif
+bool LibreOffice6FloatingPointMode()
+{
+ static bool bMode = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != nullptr;
+
+ return bMode || officecfg::Office::Scripting::Basic::Compatibility::UseLibreOffice6FloatingPointConversion::get();
+}
+
sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam, sal_Int16 nFirstDay )
{
- Date aRefDate( 1,1,1900 );
+ Date aRefDate(1899'12'30);
sal_Int32 nDays = static_cast<sal_Int32>(aDate);
- nDays -= 2; // normalize: 1.1.1900 => 0
aRefDate.AddDays( nDays);
DayOfWeek aDay = aRefDate.GetDayOfWeek();
sal_Int16 nDay;
diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx
index 1d81ee7279fc..82478bf6d3cf 100644
--- a/basic/source/runtime/props.cxx
+++ b/basic/source/runtime/props.cxx
@@ -21,428 +21,151 @@
#include <runtime.hxx>
#include <rtlproto.hxx>
#include <errobject.hxx>
-#include <basegfx/numeric/ftools.hxx>
// Properties and methods lay the return value down at Get (bWrite = sal_False)
// at the element 0 of the Argv; at Put (bWrite = sal_True) the value from
// element 0 is stored.
-void SbRtl_Erl(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutLong( StarBASIC::GetErl() );
-}
+void SbRtl_Erl(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutLong(StarBASIC::GetErl()); }
void SbRtl_Err(StarBASIC *, SbxArray & rPar, bool bWrite)
{
if( SbiRuntime::isVBAEnabled() )
{
- rPar.Get32(0)->PutObject( SbxErrObject::getErrObject().get() );
+ rPar.Get(0)->PutObject(SbxErrObject::getErrObject().get());
}
else
{
if( bWrite )
{
- sal_Int32 nVal = rPar.Get32(0)->GetLong();
+ sal_Int32 nVal = rPar.Get(0)->GetLong();
if( nVal <= 65535 )
StarBASIC::Error( StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(nVal) ) );
}
else
- rPar.Get32(0)->PutLong( StarBASIC::GetVBErrorCode( StarBASIC::GetErrBasic() ) );
+ rPar.Get(0)->PutLong(StarBASIC::GetVBErrorCode(StarBASIC::GetErrBasic()));
}
}
-void SbRtl_False(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutBool( false );
-}
+void SbRtl_False(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutBool(false); }
void SbRtl_Empty(StarBASIC *, SbxArray &, bool) {}
void SbRtl_Nothing(StarBASIC *, SbxArray & rPar, bool)
{
// return an empty object
- rPar.Get32(0)->PutObject( nullptr );
+ rPar.Get(0)->PutObject(nullptr);
}
void SbRtl_Null(StarBASIC *, SbxArray & rPar, bool)
{
// returns an empty object-variable
- rPar.Get32(0)->PutNull();
-}
-
-void SbRtl_PI(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutDouble( F_PI );
-}
-
-void SbRtl_True(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutBool( true );
-}
-
-void SbRtl_ATTR_NORMAL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_ATTR_READONLY(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_ATTR_HIDDEN(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_ATTR_SYSTEM(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4);
-}
-void SbRtl_ATTR_VOLUME(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(8);
-}
-void SbRtl_ATTR_DIRECTORY(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(16);
-}
-void SbRtl_ATTR_ARCHIVE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(32);
-}
-
-void SbRtl_V_EMPTY(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_V_NULL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_V_INTEGER(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_V_LONG(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(3);
-}
-void SbRtl_V_SINGLE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4);
-}
-void SbRtl_V_DOUBLE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(5);
-}
-void SbRtl_V_CURRENCY(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(6);
-}
-void SbRtl_V_DATE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(7);
-}
-void SbRtl_V_STRING(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(8);
-}
-
-void SbRtl_MB_OK(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_MB_OKCANCEL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_MB_ABORTRETRYIGNORE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_MB_YESNOCANCEL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(3);
-}
-void SbRtl_MB_YESNO(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4);
-}
-void SbRtl_MB_RETRYCANCEL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(5);
-}
-void SbRtl_MB_ICONSTOP(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(16);
-}
-void SbRtl_MB_ICONQUESTION(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(32);
-}
-void SbRtl_MB_ICONEXCLAMATION(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(48);
-}
-void SbRtl_MB_ICONINFORMATION(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(64);
-}
-void SbRtl_MB_DEFBUTTON1(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_MB_DEFBUTTON2(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(256);
-}
-void SbRtl_MB_DEFBUTTON3(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(512);
-}
-void SbRtl_MB_APPLMODAL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_MB_SYSTEMMODAL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4096);
-}
-
-void SbRtl_IDOK(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-
-void SbRtl_IDCANCEL(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_IDABORT(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(3);
-}
-void SbRtl_IDRETRY(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4);
-}
-void SbRtl_IDYES(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(6);
-}
-void SbRtl_IDNO(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(7);
-}
-
-void SbRtl_CF_TEXT(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_CF_BITMAP(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_CF_METAFILEPICT(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(3);
-}
-
-void SbRtl_TYP_AUTHORFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(7);
-}
-void SbRtl_TYP_CHAPTERFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(4);
-}
-void SbRtl_TYP_CONDTXTFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(27);
-}
-void SbRtl_TYP_DATEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_TYP_DBFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(19);
-}
-void SbRtl_TYP_DBNAMEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(3);
-}
-void SbRtl_TYP_DBNEXTSETFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(24);
-}
-void SbRtl_TYP_DBNUMSETFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(25);
-}
-void SbRtl_TYP_DBSETNUMBERFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(26);
-}
-void SbRtl_TYP_DDEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(14);
-}
-void SbRtl_TYP_DOCINFOFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(18);
-}
-void SbRtl_TYP_DOCSTATFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(6);
-}
-void SbRtl_TYP_EXTUSERFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(30);
-}
-void SbRtl_TYP_FILENAMEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_TYP_FIXDATEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(31);
-}
-void SbRtl_TYP_FIXTIMEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(32);
-}
-void SbRtl_TYP_FORMELFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(10);
-}
-void SbRtl_TYP_GETFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(9);
-}
-void SbRtl_TYP_GETREFFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(13);
-}
-void SbRtl_TYP_HIDDENPARAFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(17);
-}
-void SbRtl_TYP_HIDDENTXTFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(11);
-}
-void SbRtl_TYP_INPUTFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(16);
-}
-void SbRtl_TYP_MACROFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(15);
-}
-void SbRtl_TYP_NEXTPAGEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(28);
-}
-void SbRtl_TYP_PAGENUMBERFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(5);
-}
-void SbRtl_TYP_POSTITFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(21);
-}
-void SbRtl_TYP_PREVPAGEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(29);
-}
-void SbRtl_TYP_SEQFLD(StarBASIC * , SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(23);
-}
-void SbRtl_TYP_SETFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(8);
-}
-void SbRtl_TYP_SETINPFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(33);
-}
-void SbRtl_TYP_SETREFFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(12);
-}
-void SbRtl_TYP_TEMPLNAMEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(22);
-}
-void SbRtl_TYP_TIMEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_TYP_USERFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(20);
-}
-void SbRtl_TYP_USRINPFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(34);
-}
-void SbRtl_TYP_SETREFPAGEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(35);
-}
-void SbRtl_TYP_GETREFPAGEFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(36);
-}
-void SbRtl_TYP_INTERNETFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(37);
-}
-
-void SbRtl_SET_ON(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_SET_OFF(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-void SbRtl_TOGGLE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-
-void SbRtl_FRAMEANCHORPAGE(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_FRAMEANCHORPARA(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(14);
-}
-void SbRtl_FRAMEANCHORCHAR(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(15);
-}
-
-void SbRtl_CLEAR_ALLTABS(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(2);
-}
-void SbRtl_CLEAR_TAB(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(1);
-}
-void SbRtl_SET_TAB(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(0);
-}
-
-void SbRtl_TYP_JUMPEDITFLD(StarBASIC *, SbxArray & rPar, bool)
-{
- rPar.Get32(0)->PutInteger(38);
-}
+ rPar.Get(0)->PutNull();
+}
+
+void SbRtl_PI(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutDouble(M_PI); }
+
+void SbRtl_True(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutBool(true); }
+
+void SbRtl_ATTR_NORMAL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_ATTR_READONLY(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_ATTR_HIDDEN(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_ATTR_SYSTEM(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4); }
+void SbRtl_ATTR_VOLUME(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(8); }
+void SbRtl_ATTR_DIRECTORY(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(16); }
+void SbRtl_ATTR_ARCHIVE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(32); }
+
+void SbRtl_V_EMPTY(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_V_NULL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_V_INTEGER(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_V_LONG(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
+void SbRtl_V_SINGLE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4); }
+void SbRtl_V_DOUBLE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(5); }
+void SbRtl_V_CURRENCY(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(6); }
+void SbRtl_V_DATE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(7); }
+void SbRtl_V_STRING(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(8); }
+
+void SbRtl_MB_OK(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_MB_OKCANCEL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_MB_ABORTRETRYIGNORE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_MB_YESNOCANCEL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
+void SbRtl_MB_YESNO(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4); }
+void SbRtl_MB_RETRYCANCEL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(5); }
+void SbRtl_MB_ICONSTOP(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(16); }
+void SbRtl_MB_ICONQUESTION(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(32); }
+void SbRtl_MB_ICONEXCLAMATION(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(48); }
+void SbRtl_MB_ICONINFORMATION(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(64); }
+void SbRtl_MB_DEFBUTTON1(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_MB_DEFBUTTON2(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(256); }
+void SbRtl_MB_DEFBUTTON3(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(512); }
+void SbRtl_MB_APPLMODAL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_MB_SYSTEMMODAL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4096); }
+
+void SbRtl_IDOK(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_IDCANCEL(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_IDABORT(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
+void SbRtl_IDRETRY(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4); }
+void SbRtl_IDIGNORE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(5); }
+void SbRtl_IDYES(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(6); }
+void SbRtl_IDNO(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(7); }
+
+void SbRtl_CF_TEXT(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_CF_BITMAP(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_CF_METAFILEPICT(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
+
+void SbRtl_TYP_AUTHORFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(7); }
+void SbRtl_TYP_CHAPTERFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(4); }
+void SbRtl_TYP_CONDTXTFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(27); }
+void SbRtl_TYP_DATEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_TYP_DBFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(19); }
+void SbRtl_TYP_DBNAMEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
+void SbRtl_TYP_DBNEXTSETFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(24); }
+void SbRtl_TYP_DBNUMSETFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(25); }
+void SbRtl_TYP_DBSETNUMBERFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(26); }
+void SbRtl_TYP_DDEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(14); }
+void SbRtl_TYP_DOCINFOFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(18); }
+void SbRtl_TYP_DOCSTATFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(6); }
+void SbRtl_TYP_EXTUSERFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(30); }
+void SbRtl_TYP_FILENAMEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_TYP_FIXDATEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(31); }
+void SbRtl_TYP_FIXTIMEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(32); }
+void SbRtl_TYP_FORMELFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(10); }
+void SbRtl_TYP_GETFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(9); }
+void SbRtl_TYP_GETREFFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(13); }
+void SbRtl_TYP_HIDDENPARAFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(17); }
+void SbRtl_TYP_HIDDENTXTFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(11); }
+void SbRtl_TYP_INPUTFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(16); }
+void SbRtl_TYP_MACROFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(15); }
+void SbRtl_TYP_NEXTPAGEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(28); }
+void SbRtl_TYP_PAGENUMBERFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(5); }
+void SbRtl_TYP_POSTITFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(21); }
+void SbRtl_TYP_PREVPAGEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(29); }
+void SbRtl_TYP_SEQFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(23); }
+void SbRtl_TYP_SETFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(8); }
+void SbRtl_TYP_SETINPFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(33); }
+void SbRtl_TYP_SETREFFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(12); }
+void SbRtl_TYP_TEMPLNAMEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(22); }
+void SbRtl_TYP_TIMEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_TYP_USERFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(20); }
+void SbRtl_TYP_USRINPFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(34); }
+void SbRtl_TYP_SETREFPAGEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(35); }
+void SbRtl_TYP_GETREFPAGEFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(36); }
+void SbRtl_TYP_INTERNETFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(37); }
+
+void SbRtl_SET_ON(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_SET_OFF(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+void SbRtl_TOGGLE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+
+void SbRtl_FRAMEANCHORPAGE(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_FRAMEANCHORPARA(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(14); }
+void SbRtl_FRAMEANCHORCHAR(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(15); }
+
+void SbRtl_CLEAR_ALLTABS(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(2); }
+void SbRtl_CLEAR_TAB(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(1); }
+void SbRtl_SET_TAB(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(0); }
+
+void SbRtl_TYP_JUMPEDITFLD(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(38); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 87cef46cffbe..b2f493689c0b 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -36,21 +36,20 @@
#include <sal/log.hxx>
#include <tools/wldcrd.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
-#include <rtl/instance.hxx>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/character.hxx>
+#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
-#include <i18nutil/searchopt.hxx>
-#include <unotools/syslocale.hxx>
-#include <unotools/textsearch.hxx>
+#include <unicode/regex.h>
#include <basic/sbuno.hxx>
@@ -75,11 +74,12 @@ using com::sun::star::uno::Reference;
using namespace com::sun::star::uno;
using namespace com::sun::star::container;
using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
using namespace com::sun::star::script;
using namespace ::com::sun::star;
+#if HAVE_FEATURE_SCRIPTING
+
static void lcl_clearImpl( SbxVariableRef const & refVar, SbxDataType const & eType );
static void lcl_eraseImpl( SbxVariableRef const & refVar, bool bVBAEnabled );
@@ -113,11 +113,8 @@ private:
bool SbiRuntime::isVBAEnabled()
{
- bool bResult = false;
SbiInstance* pInst = GetSbData()->pInst;
- if ( pInst && GetSbData()->pInst->pRun )
- bResult = pInst->pRun->bVBAEnabled;
- return bResult;
+ return pInst && pInst->pRun && pInst->pRun->bVBAEnabled;
}
void StarBASIC::SetVBAEnabled( bool bEnabled )
@@ -130,21 +127,15 @@ void StarBASIC::SetVBAEnabled( bool bEnabled )
bool StarBASIC::isVBAEnabled() const
{
- if ( bDocBasic )
- {
- if( SbiRuntime::isVBAEnabled() )
- return true;
- return bVBAEnabled;
- }
- return false;
+ return bDocBasic && (bVBAEnabled || SbiRuntime::isVBAEnabled());
}
struct SbiArgv { // Argv stack:
SbxArrayRef refArgv; // Argv
short nArgc; // Argc
- SbiArgv(SbxArrayRef const & refArgv_, short nArgc_) :
- refArgv(refArgv_),
+ SbiArgv(SbxArrayRef refArgv_, short nArgc_) :
+ refArgv(std::move(refArgv_)),
nArgc(nArgc_) {}
};
@@ -289,9 +280,9 @@ const SbiRuntime::pStep2 SbiRuntime::aStep2[] = {// all opcodes with two operand
// SbiRTLData
SbiRTLData::SbiRTLData()
+ : nDirFlags(SbAttributes::NONE)
+ , nCurDirPos(0)
{
- nDirFlags = SbAttributes::NONE;
- nCurDirPos = 0;
}
SbiRTLData::~SbiRTLData()
@@ -384,6 +375,8 @@ SbiDllMgr* SbiInstance::GetDllMgr()
return pDllMgr.get();
}
+#endif
+
// #39629 create NumberFormatter with the help of a static method now
std::shared_ptr<SvNumberFormatter> const & SbiInstance::GetNumberFormatter()
{
@@ -476,6 +469,7 @@ std::shared_ptr<SvNumberFormatter> SbiInstance::PrepareNumberFormatter( sal_uInt
return pNumberFormatter;
}
+#if HAVE_FEATURE_SCRIPTING
// Let engine run. If Flags == BasicDebugFlags::Continue, take Flags over
@@ -598,32 +592,14 @@ SbMethod* SbiInstance::GetCaller( sal_uInt16 nLevel )
SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
: rBasic( *static_cast<StarBASIC*>(pm->pParent) ), pInst( GetSbData()->pInst ),
- pMod( pm ), pMeth( pe ), pImg( pMod->pImage ), mpExtCaller(nullptr), m_nLastTime(0)
+ pMod( pm ), pMeth( pe ), pImg( pMod->pImage.get() )
{
nFlags = pe ? pe->GetDebugFlags() : BasicDebugFlags::NONE;
pIosys = pInst->GetIoSystem();
- pForStk = nullptr;
- pError = nullptr;
- pErrCode =
- pErrStmnt =
- pRestart = nullptr;
- pNext = nullptr;
pCode =
pStmnt = pImg->GetCode() + nStart;
- bRun =
- bError = true;
- bInError = false;
- bBlocked = false;
- nLine = 0;
- nCol1 = 0;
- nCol2 = 0;
- nExprLvl = 0;
- nArgc = 0;
- nError = ERRCODE_NONE;
- nForLvl = 0;
- nOps = 0;
refExprStk = new SbxArray;
- SetVBAEnabled( pMod->IsVBACompat() );
+ SetVBAEnabled( pMod->IsVBASupport() );
SetParameters( pe ? pe->GetParameters() : nullptr );
}
@@ -671,10 +647,10 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
{
refParams = new SbxArray;
// for the return value
- refParams->Put32( pMeth, 0 );
+ refParams->Put(pMeth, 0);
SbxInfo* pInfo = pMeth ? pMeth->GetInfo() : nullptr;
- sal_uInt32 nParamCount = pParams ? pParams->Count32() : 1;
+ sal_uInt32 nParamCount = pParams ? pParams->Count() : 1;
assert(nParamCount <= std::numeric_limits<sal_uInt16>::max());
if( nParamCount > 1 )
{
@@ -687,25 +663,25 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
{
SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
sal_uInt32 nParamArrayParamCount = nParamCount - i;
- pArray->unoAddDim32( 0, nParamArrayParamCount - 1 );
+ pArray->unoAddDim(0, nParamArrayParamCount - 1);
for (sal_uInt32 j = i; j < nParamCount ; ++j)
{
- SbxVariable* v = pParams->Get32( j );
+ SbxVariable* v = pParams->Get(j);
sal_Int32 aDimIndex[1];
aDimIndex[0] = j - i;
- pArray->Put32(v, aDimIndex);
+ pArray->Put(v, aDimIndex);
}
SbxVariable* pArrayVar = new SbxVariable( SbxVARIANT );
pArrayVar->SetFlag( SbxFlagBits::ReadWrite );
pArrayVar->PutObject( pArray );
- refParams->Put32( pArrayVar, i );
+ refParams->Put(pArrayVar, i);
// Block ParamArray for missing parameter
pInfo = nullptr;
break;
}
- SbxVariable* v = pParams->Get32( i );
+ SbxVariable* v = pParams->Get(i);
// methods are always byval!
bool bByVal = dynamic_cast<const SbxMethod *>(v) != nullptr;
SbxDataType t = v->GetType();
@@ -742,7 +718,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
SetIsMissing( v2 );
}
*v2 = *v;
- refParams->Put32( v2, i );
+ refParams->Put(v2, i);
}
else
{
@@ -758,11 +734,11 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
v->Convert( t );
}
}
- refParams->Put32( v, i );
+ refParams->Put(v, i);
}
if( p )
{
- refParams->PutAlias32( p->aName, i );
+ refParams->PutAlias(p->aName, i);
}
}
}
@@ -776,11 +752,11 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
if( p && (p->nUserData & PARAM_INFO_PARAMARRAY) != 0 )
{
SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
- pArray->unoAddDim32( 0, -1 );
+ pArray->unoAddDim(0, -1);
SbxVariable* pArrayVar = new SbxVariable( SbxVARIANT );
pArrayVar->SetFlag( SbxFlagBits::ReadWrite );
pArrayVar->PutObject( pArray );
- refParams->Put32( pArrayVar, nParamCount );
+ refParams->Put(pArrayVar, nParamCount);
}
}
@@ -791,23 +767,26 @@ bool SbiRuntime::Step()
{
if( bRun )
{
+ static sal_uInt32 nLastTime = osl_getGlobalTimer();
+
// in any case check casually!
if( !( ++nOps & 0xF ) && pInst->IsReschedule() )
{
sal_uInt32 nTime = osl_getGlobalTimer();
- if (nTime - m_nLastTime > 5 ) // 20 ms
+ if (nTime - nLastTime > 5) // 20 ms
{
+ nLastTime = nTime;
Application::Reschedule();
- m_nLastTime = nTime;
}
}
// #i48868 blocked by next call level?
while( bBlocked )
{
- if( pInst->IsReschedule() )
+ if( pInst->IsReschedule() ) // And what if not? Busy loop?
{
Application::Reschedule();
+ nLastTime = osl_getGlobalTimer();
}
}
@@ -991,15 +970,9 @@ sal_Int32 SbiRuntime::translateErrorToVba( ErrCode nError, OUString& rMsg )
// if there is an error defined it more than likely
// is not the one you want ( some are the same though )
// we really need a new vba compatible error list
- if ( rMsg.isEmpty() )
- {
- StarBASIC::MakeErrorText( nError, rMsg );
- rMsg = StarBASIC::GetErrorText();
- if ( rMsg.isEmpty() ) // no message for err no, need localized resource here
- {
- rMsg = "Internal Object Error:";
- }
- }
+ // tdf#123144 - always translate an error number to a vba error message
+ StarBASIC::MakeErrorText( nError, rMsg );
+ rMsg = StarBASIC::GetErrorText();
// no num? most likely then it *is* really a vba err
sal_uInt16 nVBErrorCode = StarBASIC::GetVBErrorCode( nError );
sal_Int32 nVBAErrorNumber = ( nVBErrorCode == 0 ) ? sal_uInt32(nError) : nVBErrorCode;
@@ -1015,7 +988,7 @@ void SbiRuntime::PushVar( SbxVariable* pVar )
{
if( pVar )
{
- refExprStk->Put32( pVar, nExprLvl++ );
+ refExprStk->Put(pVar, nExprLvl++);
}
}
@@ -1028,7 +1001,7 @@ SbxVariableRef SbiRuntime::PopVar()
return new SbxVariable;
}
#endif
- SbxVariableRef xVar = refExprStk->Get32( --nExprLvl );
+ SbxVariableRef xVar = refExprStk->Get(--nExprLvl);
SAL_INFO_IF( xVar->GetName() == "Cells", "basic", "PopVar: Name equals 'Cells'" );
// methods hold themselves in parameter 0
if( dynamic_cast<const SbxMethod *>(xVar.get()) != nullptr )
@@ -1061,13 +1034,13 @@ SbxVariable* SbiRuntime::GetTOS()
return new SbxVariable;
}
#endif
- return refExprStk->Get32( static_cast<sal_uInt32>(n) );
+ return refExprStk->Get(static_cast<sal_uInt32>(n));
}
void SbiRuntime::TOSMakeTemp()
{
- SbxVariable* p = refExprStk->Get32( nExprLvl - 1 );
+ SbxVariable* p = refExprStk->Get(nExprLvl - 1);
if ( p->GetType() == SbxEMPTY )
{
p->Broadcast( SfxHintId::BasicDataWanted );
@@ -1084,13 +1057,13 @@ void SbiRuntime::TOSMakeTemp()
pDflt->SetParent( nullptr );
p = new SbxVariable( *pDflt );
p->SetFlag( SbxFlagBits::ReadWrite );
- refExprStk->Put32( p, nExprLvl - 1 );
+ refExprStk->Put(p, nExprLvl - 1);
}
else if( p->GetRefCount() != 1 )
{
SbxVariable* pNew = new SbxVariable( *p );
pNew->SetFlag( SbxFlagBits::ReadWrite );
- refExprStk->Put32( pNew, nExprLvl - 1 );
+ refExprStk->Put(pNew, nExprLvl - 1);
}
}
@@ -1175,20 +1148,28 @@ void SbiRuntime::PushForEach()
pForStk = p;
SbxVariableRef xObjVar = PopVar();
- SbxBase* pObj = xObjVar && xObjVar->GetFullType() == SbxOBJECT ? xObjVar->GetObject() : nullptr;
+ SbxBase* pObj(nullptr);
+ if (xObjVar)
+ {
+ SbxValues v(SbxVARIANT);
+ // Here it may retrieve the value, and change the type from SbxEMPTY to SbxOBJECT
+ xObjVar->Get(v);
+ if (v.eType == SbxOBJECT)
+ pObj = v.pObj;
+ }
if (SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj))
{
p->refEnd = reinterpret_cast<SbxVariable*>(pArray);
- sal_Int32 nDims = pArray->GetDims32();
+ sal_Int32 nDims = pArray->GetDims();
p->pArrayLowerBounds.reset( new sal_Int32[nDims] );
p->pArrayUpperBounds.reset( new sal_Int32[nDims] );
p->pArrayCurIndices.reset( new sal_Int32[nDims] );
sal_Int32 lBound, uBound;
for( sal_Int32 i = 0 ; i < nDims ; i++ )
{
- pArray->GetDim32( i+1, lBound, uBound );
+ pArray->GetDim(i + 1, lBound, uBound);
p->pArrayCurIndices[i] = p->pArrayLowerBounds[i] = lBound;
p->pArrayUpperBounds[i] = uBound;
}
@@ -1201,14 +1182,22 @@ void SbiRuntime::PushForEach()
}
else if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
{
- // XEnumerationAccess?
+ // XEnumerationAccess or XIndexAccess?
Any aAny = pUnoObj->getUnoAny();
+ Reference<XIndexAccess> xIndexAccess;
Reference< XEnumerationAccess > xEnumerationAccess;
if( aAny >>= xEnumerationAccess )
{
p->xEnumeration = xEnumerationAccess->createEnumeration();
p->eForType = ForType::EachXEnumeration;
}
+ // tdf#130307 - support for each loop for objects exposing XIndexAccess
+ else if (aAny >>= xIndexAccess)
+ {
+ p->eForType = ForType::EachXIndexAccess;
+ p->xIndexAccess = xIndexAccess;
+ p->nCurCollectionIndex = 0;
+ }
else if ( isVBAEnabled() && pUnoObj->isNativeCOMObject() )
{
uno::Reference< script::XInvocation > xInvocation;
@@ -1277,8 +1266,6 @@ void SbiRuntime::DllCall
SbxDataType eResType, // return value
bool bCDecl ) // true: according to C-conventions
{
- // NOT YET IMPLEMENTED
-
SbxVariable* pRes = new SbxVariable( eResType );
SbiDllMgr* pDllMgr = pInst->GetDllMgr();
ErrCode nErr = pDllMgr->Call( aFuncName, aDLLName, pArgs, *pRes, bCDecl );
@@ -1308,6 +1295,14 @@ void SbiRuntime::StepArith( SbxOperator eOp )
TOSMakeTemp();
SbxVariable* p2 = GetTOS();
+ // tdf#144353 - do not compute any operation with a missing optional variable
+ if ((p1->GetType() == SbxERROR && IsMissing(p1.get(), 1))
+ || (p2->GetType() == SbxERROR && IsMissing(p2, 1)))
+ {
+ Error(ERRCODE_BASIC_NOT_OPTIONAL);
+ return;
+ }
+
p2->ResetFlag( SbxFlagBits::Fixed );
p2->Compute( eOp, *p1 );
@@ -1318,6 +1313,12 @@ void SbiRuntime::StepUnary( SbxOperator eOp )
{
TOSMakeTemp();
SbxVariable* p = GetTOS();
+ // tdf#144353 - do not compute any operation with a missing optional variable
+ if (p->GetType() == SbxERROR && IsMissing(p, 1))
+ {
+ Error(ERRCODE_BASIC_NOT_OPTIONAL);
+ return;
+ }
p->Compute( eOp, *p );
}
@@ -1326,6 +1327,14 @@ void SbiRuntime::StepCompare( SbxOperator eOp )
SbxVariableRef p1 = PopVar();
SbxVariableRef p2 = PopVar();
+ // tdf#144353 - do not compare a missing optional variable
+ if ((p1->GetType() == SbxERROR && SbiRuntime::IsMissing(p1.get(), 1))
+ || (p2->GetType() == SbxERROR && SbiRuntime::IsMissing(p2.get(), 1)))
+ {
+ SbxBase::SetError(ERRCODE_BASIC_NOT_OPTIONAL);
+ return;
+ }
+
// Make sure objects with default params have
// values ( and type ) set as appropriate
SbxDataType p1Type = p1->GetType();
@@ -1371,7 +1380,7 @@ void SbiRuntime::StepCompare( SbxOperator eOp )
// I dumbly follow the pattern :-/
if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
{
- static SbxVariable* pNULL = [&]() {
+ static SbxVariable* pNULL = []() {
SbxVariable* p = new SbxVariable;
p->PutNull();
p->AddFirstRef();
@@ -1427,101 +1436,68 @@ void SbiRuntime::StepGE() { StepCompare( SbxGE ); }
namespace
{
- bool NeedEsc(sal_Unicode cCode)
- {
- if(!rtl::isAscii(cCode))
- {
- return false;
- }
- switch(cCode)
- {
- case '.':
- case '^':
- case '$':
- case '+':
- case '\\':
- case '|':
- case '{':
- case '}':
- case '(':
- case ')':
- return true;
- default:
- return false;
- }
- }
-
- OUString VBALikeToRegexp(const OUString &rIn)
+ OUString VBALikeToRegexp(std::u16string_view sIn)
{
- OUStringBuffer sResult;
- const sal_Unicode *start = rIn.getStr();
- const sal_Unicode *end = start + rIn.getLength();
-
- int seenright = 0;
+ OUStringBuffer sResult("\\A"); // Match at the beginning of the input
- sResult.append('^');
-
- while (start < end)
+ for (auto start = sIn.begin(), end = sIn.end(); start < end;)
{
- switch (*start)
+ switch (auto ch = *start++)
{
case '?':
sResult.append('.');
- start++;
break;
case '*':
sResult.append(".*");
- start++;
break;
case '#':
sResult.append("[0-9]");
- start++;
- break;
- case ']':
- sResult.append('\\');
- sResult.append(*start++);
break;
case '[':
- sResult.append(*start++);
- seenright = 0;
- while (start < end && !seenright)
+ sResult.append(ch);
+ if (start < end)
+ {
+ if (*start == '!')
+ {
+ sResult.append('^');
+ ++start;
+ }
+ else if (*start == '^')
+ sResult.append('\\');
+ }
+ for (bool seenright = false; start < end && !seenright; ++start)
{
switch (*start)
{
case '[':
- case '?':
- case '*':
+ case '\\':
sResult.append('\\');
- sResult.append(*start);
break;
case ']':
- sResult.append(*start);
- seenright = 1;
- break;
- case '!':
- sResult.append('^');
- break;
- default:
- if (NeedEsc(*start))
- {
- sResult.append('\\');
- }
- sResult.append(*start);
+ seenright = true;
break;
}
- start++;
+ sResult.append(*start);
}
break;
+ case '.':
+ case '^':
+ case '$':
+ case '+':
+ case '\\':
+ case '|':
+ case '{':
+ case '}':
+ case '(':
+ case ')':
+ sResult.append('\\');
+ [[fallthrough]];
default:
- if (NeedEsc(*start))
- {
- sResult.append('\\');
- }
- sResult.append(*start++);
+ sResult.append(ch);
}
}
- sResult.append('$');
+ sResult.append("\\z"); // Match if the current position is at the end of input
return sResult.makeStringAndClear();
}
@@ -1532,15 +1508,8 @@ void SbiRuntime::StepLIKE()
SbxVariableRef refVar1 = PopVar();
SbxVariableRef refVar2 = PopVar();
- OUString pattern = VBALikeToRegexp(refVar1->GetOUString());
OUString value = refVar2->GetOUString();
-
- i18nutil::SearchOptions2 aSearchOpt;
-
- aSearchOpt.AlgorithmType2 = css::util::SearchAlgorithms2::REGEXP;
-
- aSearchOpt.Locale = Application::GetSettings().GetLanguageTag().getLocale();
- aSearchOpt.searchString = pattern;
+ OUString regex = VBALikeToRegexp(refVar1->GetOUString());
bool bTextMode(true);
bool bCompatibility = ( GetSbData()->pInst && GetSbData()->pInst->IsCompatibility() );
@@ -1548,14 +1517,35 @@ void SbiRuntime::StepLIKE()
{
bTextMode = IsImageFlag( SbiImageFlags::COMPARETEXT );
}
+ sal_uInt32 searchFlags = UREGEX_UWORD | UREGEX_DOTALL; // Dot matches newline
if( bTextMode )
{
- aSearchOpt.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
+ searchFlags |= UREGEX_CASE_INSENSITIVE;
+ }
+
+ static sal_uInt32 cachedSearchFlags = 0;
+ static OUString cachedRegex;
+ static std::optional<icu::RegexMatcher> oRegexMatcher;
+ UErrorCode nIcuErr = U_ZERO_ERROR;
+ if (regex != cachedRegex || searchFlags != cachedSearchFlags || !oRegexMatcher)
+ {
+ cachedRegex = regex;
+ cachedSearchFlags = searchFlags;
+ icu::UnicodeString sRegex(false, reinterpret_cast<const UChar*>(cachedRegex.getStr()),
+ cachedRegex.getLength());
+ oRegexMatcher.emplace(sRegex, cachedSearchFlags, nIcuErr);
+ }
+
+ icu::UnicodeString sSource(false, reinterpret_cast<const UChar*>(value.getStr()),
+ value.getLength());
+ oRegexMatcher->reset(sSource);
+
+ bool bRes = oRegexMatcher->matches(nIcuErr);
+ if (nIcuErr)
+ {
+ Error(ERRCODE_BASIC_INTERNAL_ERROR);
}
SbxVariable* pRes = new SbxVariable;
- utl::TextSearch aSearch( aSearchOpt);
- sal_Int32 nStart=0, nEnd=value.getLength();
- bool bRes = aSearch.SearchForward(value, &nStart, &nEnd);
pRes->PutBool( bRes );
PushVar( pRes );
@@ -1606,6 +1596,13 @@ static bool checkUnoStructCopy( bool bVBA, SbxVariableRef const & refVal, SbxVar
SbxDataType eVarType = refVar->GetType();
SbxDataType eValType = refVal->GetType();
+ // tdf#144353 - do not assign a missing optional variable to a property
+ if (refVal->GetType() == SbxERROR && SbiRuntime::IsMissing(refVal.get(), 1))
+ {
+ SbxBase::SetError(ERRCODE_BASIC_NOT_OPTIONAL);
+ return true;
+ }
+
if ( ( bVBA && ( eVarType == SbxEMPTY ) ) || !refVar->CanWrite() )
return false;
@@ -1635,40 +1632,39 @@ static bool checkUnoStructCopy( bool bVBA, SbxVariableRef const & refVal, SbxVar
aAny = pUnoVal ? pUnoVal->getUnoAny() : pUnoStructVal->getUnoAny();
else
return false;
- if ( aAny.getValueType().getTypeClass() == TypeClass_STRUCT )
- {
- refVar->SetType( SbxOBJECT );
- ErrCode eOldErr = SbxBase::GetError();
- // There are some circumstances when calling GetObject
- // will trigger an error, we need to squash those here.
- // Alternatively it is possible that the same scenario
- // could overwrite and existing error. Lets prevent that
- SbxObjectRef xVarObj = static_cast<SbxObject*>(refVar->GetObject());
- if ( eOldErr != ERRCODE_NONE )
- SbxBase::SetError( eOldErr );
- else
- SbxBase::ResetError();
+ if ( aAny.getValueType().getTypeClass() != TypeClass_STRUCT )
+ return false;
- SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( xVarObj.get() );
+ refVar->SetType( SbxOBJECT );
+ ErrCode eOldErr = SbxBase::GetError();
+ // There are some circumstances when calling GetObject
+ // will trigger an error, we need to squash those here.
+ // Alternatively it is possible that the same scenario
+ // could overwrite and existing error. Lets prevent that
+ SbxObjectRef xVarObj = static_cast<SbxObject*>(refVar->GetObject());
+ if ( eOldErr != ERRCODE_NONE )
+ SbxBase::SetError( eOldErr );
+ else
+ SbxBase::ResetError();
- OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName();
- OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName();
+ SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( xVarObj.get() );
- if ( pUnoStructObj )
- {
- StructRefInfo aInfo = pUnoStructObj->getStructInfo();
- aInfo.setValue( aAny );
- }
- else
- {
- SbUnoObject* pNewUnoObj = new SbUnoObject( sName, aAny );
- // #70324: adopt ClassName
- pNewUnoObj->SetClassName( sClassName );
- refVar->PutObject( pNewUnoObj );
- }
- return true;
+ OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName();
+ OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName();
+
+ if ( pUnoStructObj )
+ {
+ StructRefInfo aInfo = pUnoStructObj->getStructInfo();
+ aInfo.setValue( aAny );
}
- return false;
+ else
+ {
+ SbUnoObject* pNewUnoObj = new SbUnoObject( sName, aAny );
+ // #70324: adopt ClassName
+ pNewUnoObj->SetClassName( sClassName );
+ refVar->PutObject( pNewUnoObj );
+ }
+ return true;
}
@@ -1744,10 +1740,10 @@ struct DimAsNewRecoverItem
, m_pClassModule( nullptr )
{}
- DimAsNewRecoverItem( const OUString& rObjClass, const OUString& rObjName,
+ DimAsNewRecoverItem( OUString aObjClass, OUString aObjName,
SbxObject* pObjParent, SbModule* pClassModule )
- : m_aObjClass( rObjClass )
- , m_aObjName( rObjName )
+ : m_aObjClass(std::move( aObjClass ))
+ , m_aObjName(std::move( aObjName ))
, m_pObjParent( pObjParent )
, m_pClassModule( pClassModule )
{}
@@ -1768,17 +1764,16 @@ typedef std::unordered_map< SbxVariable*, DimAsNewRecoverItem,
namespace {
-class GaDimAsNewRecoverHash : public rtl::Static<DimAsNewRecoverHash, GaDimAsNewRecoverHash> {};
+DimAsNewRecoverHash gaDimAsNewRecoverHash;
}
void removeDimAsNewRecoverItem( SbxVariable* pVar )
{
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
- DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( pVar );
- if( it != rDimAsNewRecoverHash.end() )
+ DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( pVar );
+ if( it != gaDimAsNewRecoverHash.end() )
{
- rDimAsNewRecoverHash.erase( it );
+ gaDimAsNewRecoverHash.erase( it );
}
}
@@ -1786,7 +1781,7 @@ void removeDimAsNewRecoverItem( SbxVariable* pVar )
// saving object variable
// not-object variables will cause errors
-constexpr OUStringLiteral pCollectionStr = u"Collection";
+constexpr OUString pCollectionStr = u"Collection"_ustr;
void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bHandleDefaultProp )
{
@@ -1949,9 +1944,8 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
if( xPrevVarObj.is() )
{
// Object is overwritten with NULL, instantiate init object
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
- DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( refVar.get() );
- if( it != rDimAsNewRecoverHash.end() )
+ DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( refVar.get() );
+ if( it != gaDimAsNewRecoverHash.end() )
{
const DimAsNewRecoverItem& rItem = it->second;
if( rItem.m_pClassModule != nullptr )
@@ -1984,16 +1978,15 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
OUString aObjClass = pValObj->GetClassName();
SbClassModuleObject* pClassModuleObj = dynamic_cast<SbClassModuleObject*>( pValObjBase );
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
if( pClassModuleObj != nullptr )
{
SbModule* pClassModule = pClassModuleObj->getClassModule();
- rDimAsNewRecoverHash[refVar.get()] =
+ gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule );
}
else if( aObjClass.equalsIgnoreAsciiCase( "Collection" ) )
{
- rDimAsNewRecoverHash[refVar.get()] =
+ gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), nullptr );
}
}
@@ -2091,7 +2084,7 @@ void SbiRuntime::StepRSET()
}
else
{
- aNewStr.append(std::u16string_view(aRefValString).substr(0, nVarStrLen));
+ aNewStr.append(aRefValString.subView(0, nVarStrLen));
}
refVar->PutString(aNewStr.makeStringAndClear());
@@ -2139,7 +2132,7 @@ void SbiRuntime::DimImpl(const SbxVariableRef& refVar)
SbxArray* pDims = refVar->GetParameters();
// must have an even number of arguments
// have in mind that Arg[0] does not count!
- if( pDims && !( pDims->Count32() & 1 ) )
+ if (pDims && !(pDims->Count() & 1))
{
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
}
@@ -2152,16 +2145,16 @@ void SbiRuntime::DimImpl(const SbxVariableRef& refVar)
{
refVar->ResetFlag( SbxFlagBits::VarToDim );
- for( sal_uInt32 i = 1; i < pDims->Count32(); )
+ for (sal_uInt32 i = 1; i < pDims->Count();)
{
- sal_Int32 lb = pDims->Get32( i++ )->GetLong();
- sal_Int32 ub = pDims->Get32( i++ )->GetLong();
+ sal_Int32 lb = pDims->Get(i++)->GetLong();
+ sal_Int32 ub = pDims->Get(i++)->GetLong();
if( ub < lb )
{
Error( ERRCODE_BASIC_OUT_OF_RANGE );
ub = lb;
}
- pArray->AddDim32( lb, ub );
+ pArray->AddDim(lb, ub);
if ( lb != ub )
{
pArray->setHasFixedSize( true );
@@ -2172,7 +2165,7 @@ void SbiRuntime::DimImpl(const SbxVariableRef& refVar)
{
// #62867 On creating an array of the length 0, create
// a dimension (like for Uno-Sequences of the length 0)
- pArray->unoAddDim32( 0, -1 );
+ pArray->unoAddDim(0, -1);
}
SbxFlagBits nSavFlags = refVar->GetFlags();
refVar->ResetFlag( SbxFlagBits::Fixed );
@@ -2208,11 +2201,11 @@ static void implCopyDimArray( SbxDimArray* pNewArray, SbxDimArray* pOldArray, sa
}
else
{
- SbxVariable* pSource = pOldArray->Get32( pActualIndices );
+ SbxVariable* pSource = pOldArray->Get(pActualIndices);
if (pSource && pOldArray->GetRefCount() > 1)
// tdf#134692: old array will stay alive after the redim - we need to copy deep
pSource = new SbxVariable(*pSource);
- pNewArray->Put32(pSource, pActualIndices);
+ pNewArray->Put(pSource, pActualIndices);
}
}
}
@@ -2227,8 +2220,8 @@ static bool implRestorePreservedArray(SbxDimArray* pNewArray, SbxArrayRef& rrefR
if (rrefRedimpArray)
{
SbxDimArray* pOldArray = static_cast<SbxDimArray*>(rrefRedimpArray.get());
- const sal_Int32 nDimsNew = pNewArray->GetDims32();
- const sal_Int32 nDimsOld = pOldArray->GetDims32();
+ const sal_Int32 nDimsNew = pNewArray->GetDims();
+ const sal_Int32 nDimsOld = pOldArray->GetDims();
if (nDimsOld != nDimsNew)
{
@@ -2249,8 +2242,8 @@ static bool implRestorePreservedArray(SbxDimArray* pNewArray, SbxArrayRef& rrefR
{
sal_Int32 lBoundNew, uBoundNew;
sal_Int32 lBoundOld, uBoundOld;
- pNewArray->GetDim32(i, lBoundNew, uBoundNew);
- pOldArray->GetDim32(i, lBoundOld, uBoundOld);
+ pNewArray->GetDim(i, lBoundNew, uBoundNew);
+ pOldArray->GetDim(i, lBoundOld, uBoundOld);
lBoundNew = std::max(lBoundNew, lBoundOld);
uBoundNew = std::min(uBoundNew, uBoundOld);
sal_Int32 j = i - 1;
@@ -2262,7 +2255,7 @@ static bool implRestorePreservedArray(SbxDimArray* pNewArray, SbxArrayRef& rrefR
// Optimization: pre-allocate underlying container
if (bNeedsPreallocation)
- pNewArray->Put32(nullptr, pUpperBounds.get());
+ pNewArray->Put(nullptr, pUpperBounds.get());
// Copy data from old array by going recursively through all dimensions
// (It would be faster to work on the flat internal data array of an
@@ -2452,7 +2445,7 @@ void SbiRuntime::StepARGV()
SbxVariable* pRes = new SbxVariable( *pVal );
pVal = pRes;
}
- refArgv->Put32( pVal.get(), nArgc++ );
+ refArgv->Put(pVal.get(), nArgc++);
}
}
@@ -2629,20 +2622,20 @@ void SbiRuntime::StepCASE()
refCaseStk = new SbxArray;
}
SbxVariableRef xVar = PopVar();
- refCaseStk->Put32( xVar.get(), refCaseStk->Count32() );
+ refCaseStk->Put(xVar.get(), refCaseStk->Count());
}
// end CASE: free variable
void SbiRuntime::StepENDCASE()
{
- if( !refCaseStk.is() || !refCaseStk->Count32() )
+ if (!refCaseStk.is() || !refCaseStk->Count())
{
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
}
else
{
- refCaseStk->Remove( refCaseStk->Count32() - 1 );
+ refCaseStk->Remove(refCaseStk->Count() - 1);
}
}
@@ -2717,7 +2710,7 @@ void SbiRuntime::StepPRINTF() // print TOS in field
}
s.append(s1);
comphelper::string::padToLength(s, 14, ' ');
- pIosys->Write( s.makeStringAndClear() );
+ pIosys->Write( s );
Error( pIosys->GetError() );
}
@@ -2737,12 +2730,12 @@ void SbiRuntime::StepWRITE() // write TOS
OUString s;
if( ch )
{
- s += OUString(ch);
+ s += OUStringChar(ch);
}
s += p->GetOUString();
if( ch )
{
- s += OUString(ch);
+ s += OUStringChar(ch);
}
pIosys->Write( s );
Error( pIosys->GetError() );
@@ -2817,13 +2810,15 @@ void SbiRuntime::StepERROR()
void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
{
+ // tdf#143707 - check if the data type character was added after the string termination symbol
+ SbxDataType eTypeStr;
// #57844 use localized function
- OUString aStr = pImg->GetString( static_cast<short>( nOp1 ) );
+ OUString aStr = pImg->GetString(nOp1, &eTypeStr);
// also allow , !!!
sal_Int32 iComma = aStr.indexOf(',');
if( iComma >= 0 )
{
- aStr = aStr.replaceAt(iComma, 1, ".");
+ aStr = aStr.replaceAt(iComma, 1, u".");
}
sal_Int32 nParseEnd = 0;
rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
@@ -2833,6 +2828,8 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
SbxDataType eType = SbxDOUBLE;
if ( nParseEnd < aStr.getLength() )
{
+ // tdf#143707 - Check if there was a data type character after the numeric constant,
+ // added by older versions of the fix of the default values for strings.
switch ( aStr[nParseEnd] )
{
// See GetSuffixType in basic/source/comp/scanner.cxx for type characters
@@ -2840,8 +2837,16 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
case '&': eType = SbxLONG; break;
case '!': eType = SbxSINGLE; break;
case '@': eType = SbxCURRENCY; break;
+ // tdf#142460 - properly handle boolean values in string pool
+ case 'b': eType = SbxBOOL; break;
}
}
+ // tdf#143707 - if the data type character is different from the default value, it was added
+ // in basic/source/comp/symtbl.cxx. Hence, change the type of the numeric constant to be loaded.
+ else if (eTypeStr != SbxSTRING)
+ {
+ eType = eTypeStr;
+ }
SbxVariable* p = new SbxVariable( eType );
p->PutDouble( n );
// tdf#133913 - create variable with Variant/Type in order to prevent type conversion errors
@@ -2854,7 +2859,7 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
void SbiRuntime::StepLOADSC( sal_uInt32 nOp1 )
{
SbxVariable* p = new SbxVariable;
- p->PutString( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ p->PutString( pImg->GetString( nOp1 ) );
PushVar( p );
}
@@ -2876,7 +2881,7 @@ void SbiRuntime::StepARGN( sal_uInt32 nOp1 )
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
else
{
- OUString aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aAlias( pImg->GetString( nOp1 ) );
SbxVariableRef pVal = PopVar();
if( bVBAEnabled &&
( dynamic_cast<const SbxMethod*>( pVal.get()) != nullptr
@@ -2890,8 +2895,8 @@ void SbiRuntime::StepARGN( sal_uInt32 nOp1 )
SbxVariable* pRes = new SbxVariable( *pVal );
pVal = pRes;
}
- refArgv->Put32( pVal.get(), nArgc );
- refArgv->PutAlias32( aAlias, nArgc++ );
+ refArgv->Put(pVal.get(), nArgc);
+ refArgv->PutAlias(aAlias, nArgc++);
}
}
@@ -2905,7 +2910,7 @@ void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 )
{
bool bByVal = (nOp1 & 0x8000) != 0; // Is BYVAL requested?
SbxDataType t = static_cast<SbxDataType>(nOp1 & 0x7FFF);
- SbxVariable* pVar = refArgv->Get32( refArgv->Count32() - 1 ); // last Arg
+ SbxVariable* pVar = refArgv->Get(refArgv->Count() - 1); // last Arg
// check BYVAL
if( pVar->GetRefCount() > 2 ) // 2 is normal for BYVAL
@@ -2916,7 +2921,7 @@ void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 )
// Call by Value is requested -> create a copy
pVar = new SbxVariable( *pVar );
pVar->SetFlag( SbxFlagBits::ReadWrite );
- refExprStk->Put32( pVar, refArgv->Count32() - 1 );
+ refExprStk->Put(pVar, refArgv->Count() - 1);
}
else
pVar->SetFlag( SbxFlagBits::Reference ); // Ref-Flag for DllMgr
@@ -2975,24 +2980,54 @@ void SbiRuntime::StepJUMP( sal_uInt32 nOp1 )
pCode = pImg->GetCode() + nOp1;
}
+bool SbiRuntime::EvaluateTopOfStackAsBool()
+{
+ SbxVariableRef tos = PopVar();
+ // In a test e.g. If Null then
+ // will evaluate Null will act as if False
+ if ( bVBAEnabled && tos->IsNull() )
+ {
+ return false;
+ }
+
+ // tdf#151503 - do not evaluate a missing optional variable to a boolean
+ if (tos->GetType() == SbxERROR && IsMissing(tos.get(), 1))
+ {
+ Error(ERRCODE_BASIC_NOT_OPTIONAL);
+ return false;
+ }
+
+ if ( tos->IsObject() )
+ {
+ //GetBool applied to an Object attempts to dereference and evaluate
+ //the underlying value as Bool. Here, we're checking rather that
+ //it is not null
+ return tos->GetObject();
+ }
+ else
+ {
+ return tos->GetBool();
+ }
+}
+
// evaluate TOS, conditional jump (+target)
void SbiRuntime::StepJUMPT( sal_uInt32 nOp1 )
{
- SbxVariableRef p = PopVar();
- if( p->GetBool() )
+ if ( EvaluateTopOfStackAsBool() )
+ {
StepJUMP( nOp1 );
+ }
}
// evaluate TOS, conditional jump (+target)
void SbiRuntime::StepJUMPF( sal_uInt32 nOp1 )
{
- SbxVariableRef p = PopVar();
- // In a test e.g. If Null then
- // will evaluate Null will act as if False
- if( ( bVBAEnabled && p->IsNull() ) || !p->GetBool() )
+ if ( !EvaluateTopOfStackAsBool() )
+ {
StepJUMP( nOp1 );
+ }
}
// evaluate TOS, jump into JUMP-table (+MaxVal)
@@ -3074,7 +3109,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
else
{
SbxDimArray* pArray = reinterpret_cast<SbxDimArray*>(p->refEnd.get());
- sal_Int32 nDims = pArray->GetDims32();
+ sal_Int32 nDims = pArray->GetDims();
// Empty array?
if( nDims == 1 && p->pArrayLowerBounds[0] > p->pArrayUpperBounds[0] )
@@ -3082,7 +3117,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
bEndLoop = true;
break;
}
- SbxVariable* pVal = pArray->Get32( p->pArrayCurIndices.get() );
+ SbxVariable* pVal = pArray->Get(p->pArrayCurIndices.get());
*(p->refVar) = *pVal;
bool bFoundNext = false;
@@ -3115,10 +3150,10 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
BasicCollection* pCollection = static_cast<BasicCollection*>(pForStk->refEnd.get());
SbxArrayRef xItemArray = pCollection->xItemArray;
- sal_Int32 nCount = xItemArray->Count32();
+ sal_Int32 nCount = xItemArray->Count();
if( pForStk->nCurCollectionIndex < nCount )
{
- SbxVariable* pRes = xItemArray->Get32( pForStk->nCurCollectionIndex );
+ SbxVariable* pRes = xItemArray->Get(pForStk->nCurCollectionIndex);
pForStk->nCurCollectionIndex++;
(*pForStk->refVar) = *pRes;
}
@@ -3149,6 +3184,29 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
}
break;
}
+ // tdf#130307 - support for each loop for objects exposing XIndexAccess
+ case ForType::EachXIndexAccess:
+ {
+ SbiForStack* p = pForStk;
+ if (!p->xIndexAccess)
+ {
+ SbxBase::SetError(ERRCODE_BASIC_CONVERSION);
+ pForStk->eForType = ForType::Error; // terminate loop at the next iteration
+ }
+ else if (pForStk->nCurCollectionIndex < p->xIndexAccess->getCount())
+ {
+ Any aElem = p->xIndexAccess->getByIndex(pForStk->nCurCollectionIndex);
+ pForStk->nCurCollectionIndex++;
+ SbxVariableRef xVar = new SbxVariable(SbxVARIANT);
+ unoToSbxValue(xVar.get(), aElem);
+ (*pForStk->refVar) = *xVar;
+ }
+ else
+ {
+ bEndLoop = true;
+ }
+ break;
+ }
case ForType::Error:
{
// We are in Resume Next mode after failed loop initialization
@@ -3168,13 +3226,13 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
void SbiRuntime::StepCASETO( sal_uInt32 nOp1 )
{
- if( !refCaseStk.is() || !refCaseStk->Count32() )
+ if (!refCaseStk.is() || !refCaseStk->Count())
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
else
{
SbxVariableRef xTo = PopVar();
SbxVariableRef xFrom = PopVar();
- SbxVariableRef xCase = refCaseStk->Get32( refCaseStk->Count32() - 1 );
+ SbxVariableRef xCase = refCaseStk->Get(refCaseStk->Count() - 1);
if( *xCase >= *xFrom && *xCase <= *xTo )
StepJUMP( nOp1 );
}
@@ -3342,7 +3400,7 @@ void SbiRuntime::StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt )
{
SbxVariableRef refVal = PopVar();
SbxVariableRef refVar = PopVar();
- OUString aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aClass( pImg->GetString( nOp1 ) );
bool bOk = checkClass_Impl( refVal, aClass, true, true );
if( bOk )
@@ -3364,7 +3422,7 @@ void SbiRuntime::StepSETCLASS( sal_uInt32 nOp1 )
void SbiRuntime::StepTESTCLASS( sal_uInt32 nOp1 )
{
SbxVariableRef xObjVal = PopVar();
- OUString aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aClass( pImg->GetString( nOp1 ) );
bool bDefault = !bVBAEnabled;
bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault );
@@ -3377,7 +3435,7 @@ void SbiRuntime::StepTESTCLASS( sal_uInt32 nOp1 )
void SbiRuntime::StepLIB( sal_uInt32 nOp1 )
{
- aLibName = pImg->GetString( static_cast<short>( nOp1 ) );
+ aLibName = pImg->GetString( nOp1 );
}
// TOS is incremented by BASE, BASE is pushed before (+BASE)
@@ -3431,7 +3489,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
{
bool bFatalError = false;
SbxDataType t = static_cast<SbxDataType>(nOp2);
- OUString aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) );
+ OUString aName( pImg->GetString( nOp1 & 0x7FFF ) );
// Hacky capture of Evaluate [] syntax
// this should be tackled I feel at the pcode level
if ( bIsVBAInterOp && aName.startsWith("[") )
@@ -3531,7 +3589,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
{
pElem->SetName( aName );
}
- refLocals->Put32( pElem, refLocals->Count32() );
+ refLocals->Put(pElem, refLocals->Count());
}
}
@@ -3583,7 +3641,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
pElem->SetFlag( SbxFlagBits::Fixed );
}
pElem->SetName( aName );
- refLocals->Put32( pElem, refLocals->Count32() );
+ refLocals->Put(pElem, refLocals->Count());
}
}
}
@@ -3668,18 +3726,27 @@ SbxBase* SbiRuntime::FindElementExtern( const OUString& rName )
}
if ( !pElem && pMeth )
{
- // for statics, set the method's name in front
- OUString aMethName = pMeth->GetName() + ":" + rName;
- pElem = pMod->Find(aMethName, SbxClassType::DontCare);
+ const OUString aMethName = pMeth->GetName();
+ // tdf#57308 - check if the name is the current method instance
+ if (pMeth->GetName() == rName)
+ {
+ pElem = pMeth;
+ }
+ else
+ {
+ // for statics, set the method's name in front
+ pElem = pMod->Find(aMethName + ":" + rName, SbxClassType::DontCare);
+ }
}
+
// search in parameter list
if( !pElem && pMeth )
{
SbxInfo* pInfo = pMeth->GetInfo();
if( pInfo && refParams.is() )
{
- sal_uInt32 nParamCount = refParams->Count32();
+ sal_uInt32 nParamCount = refParams->Count();
assert(nParamCount <= std::numeric_limits<sal_uInt16>::max());
sal_uInt16 j = 1;
const SbxParamInfo* pParam = pInfo->GetParam( j );
@@ -3695,7 +3762,7 @@ SbxBase* SbiRuntime::FindElementExtern( const OUString& rName )
}
else
{
- pElem = refParams->Get32( j );
+ pElem = refParams->Get(j);
}
break;
}
@@ -3726,10 +3793,10 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
}
bool bHasNamed = false;
sal_uInt32 i;
- sal_uInt32 nArgCount = refArgv->Count32();
+ sal_uInt32 nArgCount = refArgv->Count();
for( i = 1 ; i < nArgCount ; i++ )
{
- if( !refArgv->GetAlias32(i).isEmpty() )
+ if (!refArgv->GetAlias(i).isEmpty())
{
bHasNamed = true; break;
}
@@ -3761,13 +3828,13 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
OUString* pNames = pArg->getNames().getArray();
for( i = 1 ; i < nArgCount ; i++ )
{
- SbxVariable* pVar = refArgv->Get32( i );
- OUString aName = refArgv->GetAlias32(i);
+ SbxVariable* pVar = refArgv->Get(i);
+ OUString aName = refArgv->GetAlias(i);
if (!aName.isEmpty())
{
pNames[i] = aName;
}
- pArg->Put32( pVar, nCurPar++ );
+ pArg->Put(pVar, nCurPar++);
}
refArgv = pArg;
}
@@ -3816,8 +3883,8 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
SbxArray* pArg = new SbxArray;
for( i = 1 ; i < nArgCount ; i++ )
{
- SbxVariable* pVar = refArgv->Get32( i );
- OUString aName = refArgv->GetAlias32(i);
+ SbxVariable* pVar = refArgv->Get(i);
+ OUString aName = refArgv->GetAlias(i);
if (!aName.isEmpty())
{
// nCurPar is set to the found parameter
@@ -3837,13 +3904,13 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
Error( ERRCODE_BASIC_NAMED_NOT_FOUND ); break;
}
}
- pArg->Put32( pVar, nCurPar++ );
+ pArg->Put(pVar, nCurPar++);
}
refArgv = pArg;
}
}
// own var as parameter 0
- refArgv->Put32( p, 0 );
+ refArgv->Put(p, 0);
p->SetParameters( refArgv.get() );
PopArgv();
}
@@ -3882,7 +3949,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
}
else
{
- pElem = pArray->Get32( pPar->Get32( 1 )->GetInteger() );
+ pElem = pArray->Get(pPar->Get(1)->GetInteger());
}
}
}
@@ -3890,7 +3957,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
// #42940, set parameter 0 to NULL so that var doesn't contain itself
if( pPar )
{
- pPar->Put32( nullptr, 0 );
+ pPar->Put(nullptr, 0);
}
}
// consider index-access for UnoObjects
@@ -3916,7 +3983,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
{
if( xIndexAccess.is() )
{
- sal_uInt32 nParamCount = pPar->Count32() - 1;
+ sal_uInt32 nParamCount = pPar->Count() - 1;
if( nParamCount != 1 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -3924,7 +3991,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
}
// get index
- sal_Int32 nIndex = pPar->Get32( 1 )->GetLong();
+ sal_Int32 nIndex = pPar->Get(1)->GetLong();
Reference< XInterface > xRet;
try
{
@@ -4008,12 +4075,12 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
}
// #42940, set parameter 0 to NULL so that var doesn't contain itself
- pPar->Put32( nullptr, 0 );
+ pPar->Put(nullptr, 0);
}
else if (BasicCollection* pCol = dynamic_cast<BasicCollection*>(pObj.get()))
{
pElem = new SbxVariable( SbxVARIANT );
- pPar->Put32( pElem, 0 );
+ pPar->Put(pElem, 0);
pCol->CollItem( pPar );
}
}
@@ -4120,7 +4187,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
SbxVariable* pVar;
// #57915 solve missing in a cleaner way
- sal_uInt32 nParamCount = refParams->Count32();
+ sal_uInt32 nParamCount = refParams->Count();
if( nIdx >= nParamCount )
{
sal_uInt16 iLoop = nIdx;
@@ -4130,11 +4197,11 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
pVar->PutErr( 448 ); // like in VB: Error-Code 448 (ERRCODE_BASIC_NAMED_NOT_FOUND)
// tdf#79426, tdf#125180 - add additional information about a missing parameter
SetIsMissing( pVar );
- refParams->Put32( pVar, iLoop );
+ refParams->Put(pVar, iLoop);
iLoop--;
}
}
- pVar = refParams->Get32( nIdx );
+ pVar = refParams->Get(nIdx);
// tdf#79426, tdf#125180 - check for optionals only if the parameter is actually missing
if( pVar->GetType() == SbxERROR && IsMissing( pVar, 1 ) && nIdx )
@@ -4155,16 +4222,22 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
sal_uInt16 nDefaultId = static_cast<sal_uInt16>(pParam->nUserData & 0x0ffff);
if( nDefaultId > 0 )
{
- OUString aDefaultStr = pImg->GetString( nDefaultId );
+ // tdf#143707 - check if the data type character was added after the string
+ // termination symbol, and convert the variable if it was present. The
+ // data type character was added in basic/source/comp/symtbl.cxx.
+ SbxDataType eTypeStr;
+ OUString aDefaultStr = pImg->GetString( nDefaultId, &eTypeStr );
pVar = new SbxVariable(pParam-> eType);
pVar->PutString( aDefaultStr );
- refParams->Put32( pVar, nIdx );
+ if (eTypeStr != SbxSTRING)
+ pVar->Convert(eTypeStr);
+ refParams->Put(pVar, nIdx);
}
else if ( SbiRuntime::isVBAEnabled() && eType != SbxVARIANT )
{
// tdf#36737 - initialize the parameter with the default value of its type
pVar = new SbxVariable( pParam->eType );
- refParams->Put32( pVar, nIdx );
+ refParams->Put(pVar, nIdx);
}
bOpt = true;
}
@@ -4188,14 +4261,14 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- if( !refCaseStk.is() || !refCaseStk->Count32() )
+ if (!refCaseStk.is() || !refCaseStk->Count())
{
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
}
else
{
SbxVariableRef xComp = PopVar();
- SbxVariableRef xCase = refCaseStk->Get32( refCaseStk->Count32() - 1 );
+ SbxVariableRef xCase = refCaseStk->Get(refCaseStk->Count() - 1);
if( xCase->Compare( static_cast<SbxOperator>(nOp2), *xComp ) )
{
StepJUMP( nOp1 );
@@ -4208,7 +4281,7 @@ void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepCALL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- OUString aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) );
+ OUString aName = pImg->GetString( nOp1 & 0x7FFF );
SbxArray* pArgs = nullptr;
if( nOp1 & 0x8000 )
{
@@ -4226,7 +4299,7 @@ void SbiRuntime::StepCALL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepCALLC( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- OUString aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) );
+ OUString aName = pImg->GetString( nOp1 & 0x7FFF );
SbxArray* pArgs = nullptr;
if( nOp1 & 0x8000 )
{
@@ -4255,7 +4328,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 )
}
else if( nExprLvl )
{
- SbxVariable* p = refExprStk->Get32( 0 );
+ SbxVariable* p = refExprStk->Get(0);
if( p->GetRefCount() > 1 &&
refLocals.is() && refLocals->Find( p->GetName(), p->GetClass() ) )
{
@@ -4316,7 +4389,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 )
}
// 16.10.96: #31460 new concept for StepInto/Over/Out
- // see explanation at _ImplGetBreakCallLevel
+ // see explanation at SbiInstance::CalcBreakCallLevel
if( pInst->nCallLvl <= pInst->nBreakCallLvl )
{
StarBASIC* pStepBasic = GetCurrentBasic( &rBasic );
@@ -4359,21 +4432,21 @@ void SbiRuntime::StepOPEN( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepCREATE( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
- SbxObject *pObj = SbxBase::CreateObject( aClass );
+ OUString aClass( pImg->GetString( nOp2 ) );
+ SbxObjectRef pObj = SbxBase::CreateObject( aClass );
if( !pObj )
{
Error( ERRCODE_BASIC_INVALID_OBJECT );
}
else
{
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
pObj->SetName( aName );
// the object must be able to call the BASIC
pObj->SetParent( &rBasic );
- SbxVariable* pNew = new SbxVariable;
- pNew->PutObject( pObj );
- PushVar( pNew );
+ SbxVariableRef pNew = new SbxVariable;
+ pNew->PutObject( pObj.get() );
+ PushVar( pNew.get() );
}
}
@@ -4406,21 +4479,21 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
if (!pArray)
return;
- const sal_Int32 nDims = pArray->GetDims32();
+ const sal_Int32 nDims = pArray->GetDims();
sal_Int32 nTotalSize = nDims > 0 ? 1 : 0;
// must be a one-dimensional array
sal_Int32 nLower, nUpper;
for( sal_Int32 i = 0 ; i < nDims ; ++i )
{
- pArray->GetDim32( i+1, nLower, nUpper );
+ pArray->GetDim(i + 1, nLower, nUpper);
const sal_Int32 nSize = nUpper - nLower + 1;
nTotalSize *= nSize;
}
// Optimization: pre-allocate underlying container
if (nTotalSize > 0)
- pArray->SbxArray::GetRef32(nTotalSize - 1);
+ pArray->SbxArray::GetRef(nTotalSize - 1);
// First, fill those parts of the array that are preserved
bool bWasError = false;
@@ -4429,13 +4502,13 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
nTotalSize = 0; // on error, don't create objects
// create objects and insert them into the array
- OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
+ OUString aClass( pImg->GetString( nOp2 ) );
OUString aName;
for( sal_Int32 i = 0 ; i < nTotalSize ; ++i )
{
- if (!bRestored || !pArray->SbxArray::GetRef32(i)) // For those left unset after preserve
+ if (!bRestored || !pArray->SbxArray::GetRef(i)) // For those left unset after preserve
{
- SbxObject* pClassObj = SbxBase::CreateObject(aClass);
+ SbxObjectRef pClassObj = SbxBase::CreateObject(aClass);
if (!pClassObj)
{
Error(ERRCODE_BASIC_INVALID_OBJECT);
@@ -4444,11 +4517,11 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
else
{
if (aName.isEmpty())
- aName = pImg->GetString(static_cast<short>(nOp1));
+ aName = pImg->GetString(nOp1);
pClassObj->SetName(aName);
// the object must be able to call the basic
pClassObj->SetParent(&rBasic);
- pArray->SbxArray::Put32(pClassObj, i);
+ pArray->SbxArray::Put(pClassObj.get(), i);
}
}
}
@@ -4456,18 +4529,18 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepTCREATE( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
- OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
+ OUString aClass( pImg->GetString( nOp2 ) );
- SbxObject* pCopyObj = createUserTypeImpl( aClass );
+ SbxObjectRef pCopyObj = createUserTypeImpl( aClass );
if( pCopyObj )
{
pCopyObj->SetName( aName );
}
- SbxVariable* pNew = new SbxVariable;
- pNew->PutObject( pCopyObj );
+ SbxVariableRef pNew = new SbxVariable;
+ pNew->PutObject( pCopyObj.get() );
pNew->SetDeclareClassName( aClass );
- PushVar( pNew );
+ PushVar( pNew.get() );
}
void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 )
@@ -4486,7 +4559,7 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3
if( bFixedString )
{
sal_uInt16 nCount = static_cast<sal_uInt16>( nOp2 >> 17 ); // len = all bits above 0x10000
- OUStringBuffer aBuf;
+ OUStringBuffer aBuf(nCount);
comphelper::string::padToLength(aBuf, nCount);
pVar->PutString(aBuf.makeStringAndClear());
}
@@ -4506,14 +4579,14 @@ void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
refLocals = new SbxArray;
}
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
if( refLocals->Find( aName, SbxClassType::DontCare ) == nullptr )
{
SbxDataType t = static_cast<SbxDataType>(nOp2 & 0xffff);
SbxVariable* p = new SbxVariable( t );
p->SetName( aName );
implHandleSbxFlags( p, t, nOp2 );
- refLocals->Put32( p, refLocals->Count32() );
+ refLocals->Put(p, refLocals->Count());
}
}
@@ -4521,7 +4594,7 @@ void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
void SbiRuntime::StepPUBLIC_Impl( sal_uInt32 nOp1, sal_uInt32 nOp2, bool bUsedForClassModule )
{
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
SbxDataType t = static_cast<SbxDataType>(nOp2 & 0xffff);
bool bFlag = pMod->IsSet( SbxFlagBits::NoModify );
pMod->SetFlag( SbxFlagBits::NoModify );
@@ -4573,7 +4646,7 @@ void SbiRuntime::StepGLOBAL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
StepPUBLIC_Impl( nOp1, nOp2, true );
}
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
SbxDataType t = static_cast<SbxDataType>(nOp2 & 0xffff);
// Store module scope variables at module scope
@@ -4633,7 +4706,7 @@ void SbiRuntime::StepFIND_G( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
// Return dummy variable
SbxDataType t = static_cast<SbxDataType>(nOp2);
- OUString aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) );
+ OUString aName( pImg->GetString( nOp1 & 0x7FFF ) );
SbxVariable* pDummyVar = new SbxVariable( t );
pDummyVar->SetName( aName );
@@ -4658,7 +4731,7 @@ SbxVariable* SbiRuntime::StepSTATIC_Impl(
}
p->SetName( aName );
implHandleSbxFlags( p, t, nOp2 );
- pStatics->Put32( p, pStatics->Count32() );
+ pStatics->Put(p, pStatics->Count());
}
}
return p;
@@ -4666,9 +4739,11 @@ SbxVariable* SbiRuntime::StepSTATIC_Impl(
// establishing a static variable (+StringID+type)
void SbiRuntime::StepSTATIC( sal_uInt32 nOp1, sal_uInt32 nOp2 )
{
- OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
+ OUString aName( pImg->GetString( nOp1 ) );
SbxDataType t = static_cast<SbxDataType>(nOp2 & 0xffff);
StepSTATIC_Impl( aName, t, nOp2 );
}
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 3b835a921be0..5b123d00d5a2 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -58,16 +58,16 @@
namespace {
struct Method {
+ RtlCall pFunc;
std::u16string_view sName;
SbxDataType eType;
short nArgs;
- RtlCall pFunc;
sal_uInt16 nHash;
constexpr Method(std::u16string_view name, SbxDataType type, short args, RtlCall func)
- : sName(name)
+ : pFunc(func)
+ , sName(name)
, eType(type)
, nArgs(args)
- , pFunc(func)
, nHash(SbxVariable::MakeHashCode(name))
{
}
@@ -141,7 +141,7 @@ constexpr Method aMethods[] = {
{ u"CallByName", SbxVARIANT, 3 | FUNCTION_, SbRtl_CallByName },
arg(u"Object", SbxOBJECT),
- arg(u"ProcedureName", SbxSTRING),
+ arg(u"ProcName", SbxSTRING),
arg(u"CallType", SbxINTEGER),
{ u"CBool", SbxBOOL, 1 | FUNCTION_, SbRtl_CBool },
@@ -200,10 +200,10 @@ constexpr Method aMethods[] = {
arg(u"Expression", SbxVARIANT),
{ u"Chr", SbxSTRING, 1 | FUNCTION_, SbRtl_Chr },
- arg(u"string", SbxINTEGER),
+ arg(u"charcode", SbxLONG),
{ u"ChrW", SbxSTRING, 1 | FUNCTION_ | COMPATONLY_, SbRtl_ChrW },
- arg(u"string", SbxINTEGER),
+ arg(u"charcode", SbxLONG),
{ u"CInt", SbxINTEGER, 1 | FUNCTION_, SbRtl_CInt },
arg(u"expression", SbxVARIANT),
@@ -328,8 +328,8 @@ constexpr Method aMethods[] = {
{ u"Ddeterminateall", SbxNULL, FUNCTION_, SbRtl_DDETerminateAll },
{ u"DimArray", SbxOBJECT, FUNCTION_, SbRtl_DimArray },
{ u"Dir", SbxSTRING, 2 | FUNCTION_, SbRtl_Dir },
- arg(u"FileSpec", SbxSTRING, OPT_),
- arg(u"attrmask", SbxINTEGER, OPT_),
+ arg(u"Pathname", SbxSTRING, OPT_),
+ arg(u"Attributes", SbxINTEGER, OPT_),
{ u"DoEvents", SbxINTEGER, FUNCTION_, SbRtl_DoEvents },
{ u"DumpAllObjects", SbxEMPTY, 2 | SUB_, SbRtl_DumpAllObjects },
@@ -401,6 +401,13 @@ constexpr Method aMethods[] = {
arg(u"useParensForNegativeNumbers", SbxINTEGER, OPT_), // vbTriState
arg(u"groupDigits", SbxINTEGER, OPT_), // vbTriState
+{ u"FormatPercent", SbxSTRING, 5 | FUNCTION_ | COMPATONLY_, SbRtl_FormatPercent },
+ arg(u"expression", SbxDOUBLE),
+ arg(u"numDigitsAfterDecimal", SbxINTEGER, OPT_),
+ arg(u"includeLeadingDigit", SbxINTEGER, OPT_), // vbTriState
+ arg(u"useParensForNegativeNumbers", SbxINTEGER, OPT_), // vbTriState
+ arg(u"groupDigits", SbxINTEGER, OPT_), // vbTriState
+
{ u"Frac", SbxDOUBLE, 1 | FUNCTION_, SbRtl_Frac },
arg(u"number", SbxDOUBLE),
@@ -451,6 +458,7 @@ constexpr Method aMethods[] = {
{ u"IDABORT", SbxINTEGER, CPROP_, SbRtl_IDABORT },
{ u"IDCANCEL", SbxINTEGER, CPROP_, SbRtl_IDCANCEL },
+{ u"IDIGNORE", SbxINTEGER, CPROP_, SbRtl_IDIGNORE },
{ u"IDNO", SbxINTEGER, CPROP_, SbRtl_IDNO },
{ u"IDOK", SbxINTEGER, CPROP_, SbRtl_IDOK },
{ u"IDRETRY", SbxINTEGER, CPROP_, SbRtl_IDRETRY },
@@ -479,10 +487,10 @@ constexpr Method aMethods[] = {
arg(u"Compare", SbxINTEGER, OPT_),
{ u"InStrRev", SbxLONG, 4 | FUNCTION_ | COMPATONLY_, SbRtl_InStrRev },
- arg(u"String1", SbxSTRING),
- arg(u"String2", SbxSTRING),
- arg(u"Start", SbxSTRING, OPT_),
- arg(u"Compare", SbxINTEGER, OPT_),
+ arg(u"StringCheck", SbxSTRING),
+ arg(u"StringMatch", SbxSTRING),
+ arg(u"Start", SbxSTRING, OPT_),
+ arg(u"Compare", SbxINTEGER, OPT_),
{ u"Int", SbxDOUBLE, 1 | FUNCTION_, SbRtl_Int },
arg(u"number", SbxDOUBLE),
@@ -527,8 +535,8 @@ constexpr Method aMethods[] = {
arg(u"Variant", SbxVARIANT),
{ u"Join", SbxSTRING, 2 | FUNCTION_, SbRtl_Join },
- arg(u"list", SbxOBJECT),
- arg(u"delimiter", SbxSTRING),
+ arg(u"SourceArray", SbxOBJECT),
+ arg(u"Delimiter", SbxSTRING),
{ u"Kill", SbxNULL, 1 | FUNCTION_, SbRtl_Kill },
arg(u"filespec", SbxSTRING),
@@ -541,7 +549,7 @@ constexpr Method aMethods[] = {
{ u"Left", SbxSTRING, 2 | FUNCTION_, SbRtl_Left },
arg(u"String", SbxSTRING),
- arg(u"Count", SbxLONG),
+ arg(u"Length", SbxLONG),
{ u"Len", SbxLONG, 1 | FUNCTION_, SbRtl_Len },
arg(u"StringOrVariant", SbxVARIANT),
@@ -585,9 +593,9 @@ constexpr Method aMethods[] = {
{ u"Me", SbxOBJECT, 0 | FUNCTION_ | COMPATONLY_, SbRtl_Me },
{ u"Mid", SbxSTRING, 3 | LFUNCTION_, SbRtl_Mid },
- arg(u"String", SbxSTRING),
- arg(u"StartPos", SbxLONG),
- arg(u"Length", SbxLONG, OPT_),
+ arg(u"String", SbxSTRING),
+ arg(u"Start", SbxLONG),
+ arg(u"Length", SbxLONG, OPT_),
{ u"Minute", SbxINTEGER, 1 | FUNCTION_, SbRtl_Minute },
arg(u"Date", SbxDATE),
@@ -703,7 +711,7 @@ constexpr Method aMethods[] = {
{ u"Right", SbxSTRING, 2 | FUNCTION_, SbRtl_Right },
arg(u"String", SbxSTRING),
- arg(u"Count", SbxLONG),
+ arg(u"Length", SbxLONG),
{ u"RmDir", SbxNULL, 1 | FUNCTION_, SbRtl_RmDir },
arg(u"pathname", SbxSTRING),
@@ -734,7 +742,7 @@ constexpr Method aMethods[] = {
arg(u"Wait", SbxBOOL, OPT_),
{ u"SetAttr", SbxNULL, 2 | FUNCTION_, SbRtl_SetAttr },
- arg(u"File", SbxSTRING),
+ arg(u"PathName", SbxSTRING),
arg(u"Attributes", SbxINTEGER),
{ u"SET_OFF", SbxINTEGER, CPROP_, SbRtl_SET_OFF },
@@ -744,8 +752,8 @@ constexpr Method aMethods[] = {
arg(u"number", SbxDOUBLE),
{ u"Shell", SbxLONG, 2 | FUNCTION_, SbRtl_Shell },
- arg(u"Commandstring", SbxSTRING),
- arg(u"WindowStyle", SbxINTEGER, OPT_),
+ arg(u"PathName", SbxSTRING),
+ arg(u"WindowStyle", SbxINTEGER, OPT_),
{ u"Sin", SbxDOUBLE, 1 | FUNCTION_, SbRtl_Sin },
arg(u"number", SbxDOUBLE),
@@ -762,15 +770,15 @@ constexpr Method aMethods[] = {
arg(u"Period", SbxDOUBLE),
{ u"Space", SbxSTRING, 1 | FUNCTION_, SbRtl_Space },
- arg(u"string", SbxLONG),
+ arg(u"Number", SbxLONG),
-{ u"Spc", SbxSTRING, 1 | FUNCTION_, SbRtl_Spc },
- arg(u"Count", SbxLONG),
+{ u"Spc", SbxSTRING, 1 | FUNCTION_, SbRtl_Space },
+ arg(u"Number", SbxLONG),
{ u"Split", SbxOBJECT, 3 | FUNCTION_, SbRtl_Split },
arg(u"expression", SbxSTRING),
arg(u"delimiter", SbxSTRING),
- arg(u"count", SbxLONG),
+ arg(u"Limit", SbxLONG),
{ u"Sqr", SbxDOUBLE, 1 | FUNCTION_, SbRtl_Sqr },
arg(u"number", SbxDOUBLE),
@@ -789,8 +797,8 @@ constexpr Method aMethods[] = {
arg(u"LCID", SbxINTEGER, OPT_),
{ u"String", SbxSTRING, 2 | FUNCTION_, SbRtl_String },
- arg(u"Count", SbxLONG),
- arg(u"Filler", SbxVARIANT),
+ arg(u"Number", SbxLONG),
+ arg(u"Character", SbxVARIANT),
{ u"StrReverse", SbxSTRING, 1 | FUNCTION_ | COMPATONLY_, SbRtl_StrReverse },
arg(u"String1", SbxSTRING),
@@ -867,7 +875,7 @@ constexpr Method aMethods[] = {
arg(u"Var", SbxVARIANT),
{ u"TypeName", SbxSTRING, 1 | FUNCTION_, SbRtl_TypeName },
- arg(u"Var", SbxVARIANT),
+ arg(u"Varname", SbxVARIANT),
{ u"UBound", SbxLONG, 1 | FUNCTION_, SbRtl_UBound },
arg(u"Var", SbxVARIANT),
@@ -882,7 +890,7 @@ constexpr Method aMethods[] = {
arg(u"String", SbxSTRING),
{ u"VarType", SbxINTEGER, 1 | FUNCTION_, SbRtl_VarType },
- arg(u"Var", SbxVARIANT),
+ arg(u"Varname", SbxVARIANT),
{ u"V_EMPTY", SbxINTEGER, CPROP_, SbRtl_V_EMPTY },
{ u"V_NULL", SbxINTEGER, CPROP_, SbRtl_V_NULL },
@@ -926,15 +934,15 @@ SbiStdObject::SbiStdObject( const OUString& r, StarBASIC* pb ) : SbxObject( r )
SetParent( pb );
- pStdFactory.reset( new SbStdFactory );
- SbxBase::AddFactory( pStdFactory.get() );
+ pStdFactory.emplace();
+ SbxBase::AddFactory( &*pStdFactory );
Insert( new SbStdClipboard );
}
SbiStdObject::~SbiStdObject()
{
- SbxBase::RemoveFactory( pStdFactory.get() );
+ SbxBase::RemoveFactory( &*pStdFactory );
pStdFactory.reset();
}
@@ -985,7 +993,7 @@ SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t )
// No instance running => compiling a source on module level.
const SbModule* pModule = GetSbData()->pCompMod;
if (pModule)
- bCompatibility = pModule->IsVBACompat();
+ bCompatibility = pModule->IsVBASupport();
}
if ((bCompatibility && (NORMONLY_ & p->nArgs)) || (!bCompatibility && (COMPATONLY_ & p->nArgs)))
bFound = false;
@@ -1053,7 +1061,7 @@ void SbiStdObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
if( !pPar_ )
{
rPar = pPar_ = new SbxArray;
- pPar_->Put32( pVar, 0 );
+ pPar_->Put(pVar, 0);
}
p( static_cast<StarBASIC*>(GetParent()), *pPar_, bWrite );
return;
diff --git a/basic/source/runtime/stdobj1.cxx b/basic/source/runtime/stdobj1.cxx
index a5ace17b4941..c24c59af95a3 100644
--- a/basic/source/runtime/stdobj1.cxx
+++ b/basic/source/runtime/stdobj1.cxx
@@ -22,29 +22,32 @@
#include <vcl/outdev.hxx>
#include <sbstdobj.hxx>
-#define ATTR_IMP_TYPE 1
-#define ATTR_IMP_WIDTH 2
-#define ATTR_IMP_HEIGHT 3
-#define ATTR_IMP_BOLD 4
-#define ATTR_IMP_ITALIC 5
-#define ATTR_IMP_STRIKETHROUGH 6
-#define ATTR_IMP_UNDERLINE 7
-#define ATTR_IMP_SIZE 9
-#define ATTR_IMP_NAME 10
-
-#define METH_CLEAR 20
-#define METH_GETDATA 21
-#define METH_GETFORMAT 22
-#define METH_GETTEXT 23
-#define METH_SETDATA 24
-#define METH_SETTEXT 25
-
+namespace {
+ enum UserData
+ {
+ ATTR_IMP_TYPE = 1,
+ ATTR_IMP_WIDTH = 2,
+ ATTR_IMP_HEIGHT = 3,
+ ATTR_IMP_BOLD = 4,
+ ATTR_IMP_ITALIC = 5,
+ ATTR_IMP_STRIKETHROUGH = 6,
+ ATTR_IMP_UNDERLINE = 7,
+ ATTR_IMP_SIZE = 9,
+ ATTR_IMP_NAME = 10,
+ METH_CLEAR = 20,
+ METH_GETDATA = 21,
+ METH_GETFORMAT = 22,
+ METH_GETTEXT = 23,
+ METH_SETDATA = 24,
+ METH_SETTEXT = 25
+ };
+}
SbStdFactory::SbStdFactory()
{
}
-SbxObject* SbStdFactory::CreateObject( const OUString& rClassName )
+SbxObjectRef SbStdFactory::CreateObject( const OUString& rClassName )
{
if( rClassName.equalsIgnoreAsciiCase("Picture") )
return new SbStdPicture;
@@ -144,6 +147,7 @@ void SbStdPicture::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
case ATTR_IMP_TYPE: PropType( pVar, bWrite ); return;
case ATTR_IMP_WIDTH: PropWidth( pVar, bWrite ); return;
case ATTR_IMP_HEIGHT: PropHeight( pVar, bWrite ); return;
+ default: break;
}
SbxObject::Notify( rBC, rHint );
@@ -264,6 +268,7 @@ void SbStdFont::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
case ATTR_IMP_UNDERLINE: PropUnderline( pVar, bWrite ); return;
case ATTR_IMP_SIZE: PropSize( pVar, bWrite ); return;
case ATTR_IMP_NAME: PropName( pVar, bWrite ); return;
+ default: break;
}
SbxObject::Notify( rBC, rHint );
@@ -272,7 +277,7 @@ void SbStdFont::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
void SbStdClipboard::MethClear( SbxArray const * pPar_ )
{
- if( pPar_ && (pPar_->Count32() > 1) )
+ if (pPar_ && (pPar_->Count() > 1))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
@@ -282,13 +287,13 @@ void SbStdClipboard::MethClear( SbxArray const * pPar_ )
void SbStdClipboard::MethGetData( SbxArray* pPar_ )
{
- if( !pPar_ || (pPar_->Count32() != 2) )
+ if (!pPar_ || (pPar_->Count() != 2))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
}
- sal_Int16 nFormat = pPar_->Get32(1)->GetInteger();
+ sal_Int16 nFormat = pPar_->Get(1)->GetInteger();
if( nFormat <= 0 || nFormat > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -299,13 +304,13 @@ void SbStdClipboard::MethGetData( SbxArray* pPar_ )
void SbStdClipboard::MethGetFormat( SbxVariable* pVar, SbxArray* pPar_ )
{
- if( !pPar_ || (pPar_->Count32() != 2) )
+ if (!pPar_ || (pPar_->Count() != 2))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
}
- sal_Int16 nFormat = pPar_->Get32(1)->GetInteger();
+ sal_Int16 nFormat = pPar_->Get(1)->GetInteger();
if( nFormat <= 0 || nFormat > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -317,7 +322,7 @@ void SbStdClipboard::MethGetFormat( SbxVariable* pVar, SbxArray* pPar_ )
void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray const * pPar_ )
{
- if( pPar_ && (pPar_->Count32() > 1) )
+ if (pPar_ && (pPar_->Count() > 1))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
@@ -328,13 +333,13 @@ void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray const * pPar_ )
void SbStdClipboard::MethSetData( SbxArray* pPar_ )
{
- if( !pPar_ || (pPar_->Count32() != 3) )
+ if (!pPar_ || (pPar_->Count() != 3))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
}
- sal_Int16 nFormat = pPar_->Get32(2)->GetInteger();
+ sal_Int16 nFormat = pPar_->Get(2)->GetInteger();
if( nFormat <= 0 || nFormat > 3 )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
@@ -345,7 +350,7 @@ void SbStdClipboard::MethSetData( SbxArray* pPar_ )
void SbStdClipboard::MethSetText( SbxArray const * pPar_ )
{
- if( !pPar_ || (pPar_->Count32() != 2) )
+ if (!pPar_ || (pPar_->Count() != 2))
{
StarBASIC::Error( ERRCODE_BASIC_BAD_NUMBER_OF_ARGS );
return;
@@ -412,6 +417,7 @@ void SbStdClipboard::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
case METH_GETTEXT: MethGetText( pVar, pPar_ ); return;
case METH_SETDATA: MethSetData( pPar_ ); return;
case METH_SETTEXT: MethSetText( pPar_ ); return;
+ default: break;
}
SbxObject::Notify( rBC, rHint );