summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-03-05 21:41:31 +0200
committerTor Lillqvist <tml@iki.fi>2012-03-05 22:30:12 +0200
commitb344c30ab49b6faf8a24be42bdfcf4e946a861cd (patch)
tree75699c0eb98676e6f9359a44fae78a29594ad751 /basic
parentb69285590d704b08852c22dbb5ed073bff9998ce (diff)
Sprinkle more DISABLE_SCRIPTING ifdefs
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx196
-rw-r--r--basic/source/runtime/methods1.cxx80
-rw-r--r--basic/source/sbx/sbxarray.cxx2
-rw-r--r--basic/source/sbx/sbxdbl.cxx4
-rw-r--r--basic/source/sbx/sbxscan.cxx2
-rw-r--r--basic/source/sbx/sbxstr.cxx4
-rw-r--r--basic/source/sbx/sbxvalue.cxx13
-rw-r--r--basic/source/sbx/sbxvar.cxx8
8 files changed, 185 insertions, 124 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index efcf67ffd5cd..28ce80fa4ea8 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -120,6 +120,8 @@ SbxVariable* getDefaultProp( SbxVariable* pRef );
#undef GradientSyle_RECT
#endif
+#ifndef DISABLE_SCRIPTING
+
// from source/classes/sbxmod.cxx
Reference< XModel > getDocumentModel( StarBASIC* );
@@ -143,20 +145,7 @@ static void FilterWhiteSpace( String& rStr )
rStr = aRet.makeStringAndClear();
}
-static long GetDayDiff( const Date& rDate )
-{
- Date aRefDate( 1,1,1900 );
- long nDiffDays;
- if ( aRefDate > rDate )
- {
- nDiffDays = (long)(aRefDate - rDate);
- nDiffDays *= -1;
- }
- else
- nDiffDays = (long)(rDate - aRefDate);
- nDiffDays += 2; // adjustment VisualBasic: 1.Jan.1900 == 2
- return nDiffDays;
-}
+static long GetDayDiff( const Date& rDate );
static const CharClass& GetCharClass( void )
{
@@ -1761,68 +1750,7 @@ sal_Int16 implGetDateMonth( double aDate )
return nRet;
}
-sal_Int16 implGetDateYear( double aDate )
-{
- Date aRefDate( 1,1,1900 );
- long nDays = (long) aDate;
- nDays -= 2; // standardize: 1.1.1900 => 0.0
- aRefDate += nDays;
- sal_Int16 nRet = (sal_Int16)( aRefDate.GetYear() );
- return nRet;
-}
-
-sal_Bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double& rdRet )
-{
- if ( nYear < 30 && SbiRuntime::isVBAEnabled() )
- nYear += 2000;
- else if ( nYear < 100 )
- nYear += 1900;
- Date aCurDate( nDay, nMonth, nYear );
- if ((nYear < 100 || nYear > 9999) )
- {
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return sal_False;
- }
- if ( !SbiRuntime::isVBAEnabled() )
- {
- if ( (nMonth < 1 || nMonth > 12 )||
- (nDay < 1 || nDay > 31 ) )
- {
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return sal_False;
- }
- }
- else
- {
- // grab the year & month
- aCurDate = Date( 1, (( nMonth % 12 ) > 0 ) ? ( nMonth % 12 ) : 12 + ( nMonth % 12 ), nYear );
-
- // adjust year based on month value
- // e.g. 2000, 0, xx = 1999, 12, xx ( or December of the previous year )
- // 2000, 13, xx = 2001, 1, xx ( or January of the following year )
- if( ( nMonth < 1 ) || ( nMonth > 12 ) )
- {
- // inacurrate around leap year, don't use days to calculate,
- // just modify the months directory
- sal_Int16 nYearAdj = ( nMonth /12 ); // default to positive months inputed
- if ( nMonth <=0 )
- nYearAdj = ( ( nMonth -12 ) / 12 );
- aCurDate.SetYear( aCurDate.GetYear() + nYearAdj );
- }
-
- // adjust day value,
- // e.g. 2000, 2, 0 = 2000, 1, 31 or the last day of the previous month
- // 2000, 1, 32 = 2000, 2, 1 or the first day of the following month
- if( ( nDay < 1 ) || ( nDay > aCurDate.GetDaysInMonth() ) )
- aCurDate += nDay - 1;
- else
- aCurDate.SetDay( nDay );
- }
-
- long nDiffDays = GetDayDiff( aCurDate );
- rdRet = (double)nDiffDays;
- return sal_True;
-}
+sal_Int16 implGetDateYear( double aDate );
// Function to convert date to ISO 8601 date format
RTLFUNC(CDateToIso)
@@ -2077,17 +2005,7 @@ RTLFUNC(Hour)
}
}
-sal_Int16 implGetMinute( double dDate )
-{
- if( dDate < 0.0 )
- dDate *= -1.0;
- double nFrac = dDate - floor( dDate );
- nFrac *= 86400.0;
- sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
- sal_Int16 nTemp = (sal_Int16)(nSeconds % 3600);
- sal_Int16 nMin = nTemp / 60;
- return nMin;
-}
+sal_Int16 implGetMinute( double dDate );
RTLFUNC(Minute)
{
@@ -4428,4 +4346,108 @@ RTLFUNC(Partition)
rPar.Get(0)->PutString( String(aRetStr.makeStringAndClear()) );
}
+#endif
+
+static long GetDayDiff( const Date& rDate )
+{
+ Date aRefDate( 1,1,1900 );
+ long nDiffDays;
+ if ( aRefDate > rDate )
+ {
+ nDiffDays = (long)(aRefDate - rDate);
+ nDiffDays *= -1;
+ }
+ else
+ nDiffDays = (long)(rDate - aRefDate);
+ nDiffDays += 2; // adjustment VisualBasic: 1.Jan.1900 == 2
+ return nDiffDays;
+}
+
+sal_Int16 implGetDateYear( double aDate )
+{
+ Date aRefDate( 1,1,1900 );
+ long nDays = (long) aDate;
+ nDays -= 2; // standardize: 1.1.1900 => 0.0
+ aRefDate += nDays;
+ sal_Int16 nRet = (sal_Int16)( aRefDate.GetYear() );
+ return nRet;
+}
+
+sal_Bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double& rdRet )
+{
+#ifndef DISABLE_SCRIPTING
+ if ( nYear < 30 && SbiRuntime::isVBAEnabled() )
+ nYear += 2000;
+ else
+#endif
+ if ( nYear < 100 )
+ nYear += 1900;
+ Date aCurDate( nDay, nMonth, nYear );
+ if ((nYear < 100 || nYear > 9999) )
+ {
+#ifndef DISABLE_SCRIPTING
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+#endif
+ return sal_False;
+ }
+
+#ifndef DISABLE_SCRIPTING
+ if ( !SbiRuntime::isVBAEnabled() )
+#endif
+ {
+ if ( (nMonth < 1 || nMonth > 12 )||
+ (nDay < 1 || nDay > 31 ) )
+ {
+#ifndef DISABLE_SCRIPTING
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+#endif
+ return sal_False;
+ }
+ }
+#ifndef DISABLE_SCRIPTING
+ else
+ {
+ // grab the year & month
+ aCurDate = Date( 1, (( nMonth % 12 ) > 0 ) ? ( nMonth % 12 ) : 12 + ( nMonth % 12 ), nYear );
+
+ // adjust year based on month value
+ // e.g. 2000, 0, xx = 1999, 12, xx ( or December of the previous year )
+ // 2000, 13, xx = 2001, 1, xx ( or January of the following year )
+ if( ( nMonth < 1 ) || ( nMonth > 12 ) )
+ {
+ // inacurrate around leap year, don't use days to calculate,
+ // just modify the months directory
+ sal_Int16 nYearAdj = ( nMonth /12 ); // default to positive months inputed
+ if ( nMonth <=0 )
+ nYearAdj = ( ( nMonth -12 ) / 12 );
+ aCurDate.SetYear( aCurDate.GetYear() + nYearAdj );
+ }
+
+ // adjust day value,
+ // e.g. 2000, 2, 0 = 2000, 1, 31 or the last day of the previous month
+ // 2000, 1, 32 = 2000, 2, 1 or the first day of the following month
+ if( ( nDay < 1 ) || ( nDay > aCurDate.GetDaysInMonth() ) )
+ aCurDate += nDay - 1;
+ else
+ aCurDate.SetDay( nDay );
+ }
+#endif
+
+ long nDiffDays = GetDayDiff( aCurDate );
+ rdRet = (double)nDiffDays;
+ return sal_True;
+}
+
+sal_Int16 implGetMinute( double dDate )
+{
+ if( dDate < 0.0 )
+ dDate *= -1.0;
+ double nFrac = dDate - floor( dDate );
+ nFrac *= 86400.0;
+ sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
+ sal_Int16 nTemp = (sal_Int16)(nSeconds % 3600);
+ sal_Int16 nMin = nTemp / 60;
+ return nMin;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 04a21d59af73..91c739f84f33 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -107,6 +107,8 @@ static Reference< XCalendar3 > getLocaleCalendar( void )
return xCalendar;
}
+#ifndef DISABLE_SCRIPTING
+
RTLFUNC(CallByName)
{
(void)pBasic;
@@ -1835,42 +1837,6 @@ RTLFUNC(WeekdayName)
rPar.Get(0)->PutString( String(aRetStr) );
}
-sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 nFirstDay = 0 )
-{
- Date aRefDate( 1,1,1900 );
- long nDays = (long) aDate;
- nDays -= 2; // normieren: 1.1.1900 => 0
- aRefDate += nDays;
- DayOfWeek aDay = aRefDate.GetDayOfWeek();
- sal_Int16 nDay;
- if ( aDay != SUNDAY )
- nDay = (sal_Int16)aDay + 2;
- else
- nDay = 1; // 1 == Sunday
-
- // #117253 optional 2nd parameter "firstdayofweek"
- if( bFirstDayParam )
- {
- if( nFirstDay < 0 || nFirstDay > 7 )
- {
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return 0;
- }
- if( nFirstDay == 0 )
- {
- Reference< XCalendar3 > xCalendar = getLocaleCalendar();
- if( !xCalendar.is() )
- {
- StarBASIC::Error( SbERR_INTERNAL_ERROR );
- return 0;
- }
- nFirstDay = sal_Int16( xCalendar->getFirstDayOfWeek() + 1 );
- }
- nDay = 1 + (nDay + 7 - nFirstDay) % 7;
- }
- return nDay;
-}
-
RTLFUNC(Weekday)
{
(void)pBasic;
@@ -3242,4 +3208,46 @@ RTLFUNC(Me)
refVar->PutObject( pClassModuleObject );
}
+#endif
+
+sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 nFirstDay = 0 )
+{
+ Date aRefDate( 1,1,1900 );
+ long nDays = (long) aDate;
+ nDays -= 2; // normieren: 1.1.1900 => 0
+ aRefDate += nDays;
+ DayOfWeek aDay = aRefDate.GetDayOfWeek();
+ sal_Int16 nDay;
+ if ( aDay != SUNDAY )
+ nDay = (sal_Int16)aDay + 2;
+ else
+ nDay = 1; // 1 == Sunday
+
+ // #117253 optional 2nd parameter "firstdayofweek"
+ if( bFirstDayParam )
+ {
+ if( nFirstDay < 0 || nFirstDay > 7 )
+ {
+#ifndef DISABLE_SCRIPTING
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+#endif
+ return 0;
+ }
+ if( nFirstDay == 0 )
+ {
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
+ if( !xCalendar.is() )
+ {
+#ifndef DISABLE_SCRIPTING
+ StarBASIC::Error( SbERR_INTERNAL_ERROR );
+#endif
+ return 0;
+ }
+ nFirstDay = sal_Int16( xCalendar->getFirstDayOfWeek() + 1 );
+ }
+ nDay = 1 + (nDay + 7 - nFirstDay) % 7;
+ }
+ return nDay;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 544f71708da0..d221e4d85288 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -767,10 +767,12 @@ void SbxDimArray::Put32( SbxVariable* p, const sal_Int32* pIdx )
sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar )
{
+#ifndef DISABLE_SCRIPTING
if( nDim == 0 || !pPar || ( ( nDim != ( pPar->Count() - 1 ) ) && SbiRuntime::isVBAEnabled() ) )
{
SetError( SbxERR_BOUNDS ); return 0;
}
+#endif
sal_uInt32 nPos = 0;
sal_uInt16 nOff = 1; // Non element 0!
for( SbxDim* p = pFirst; p && !IsError(); p = p->pNext )
diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx
index ef6a8ae3d185..9eca1dda0e21 100644
--- a/basic/source/sbx/sbxdbl.cxx
+++ b/basic/source/sbx/sbxdbl.cxx
@@ -78,8 +78,10 @@ double ImpGetDouble( const SbxValues* p )
if( !p->pOUString )
{
nRes = 0;
+#ifndef DISABLE_SCRIPTING
if ( SbiRuntime::isVBAEnabled() )// VBA only behaviour
SbxBase::SetError( SbxERR_CONVERSION );
+#endif
}
else
{
@@ -88,8 +90,10 @@ double ImpGetDouble( const SbxValues* p )
if( ImpScan( *p->pOUString, d, t, NULL ) != SbxERR_OK )
{
nRes = 0;
+#ifndef DISABLE_SCRIPTING
if ( SbiRuntime::isVBAEnabled() )// VBA only behaviour
SbxBase::SetError( SbxERR_CONVERSION );
+#endif
}
else
nRes = d;
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index a25337709e83..b4f111c32f6c 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -219,11 +219,13 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType
if( l >= SbxMININT && l <= SbxMAXINT )
eScanType = SbxINTEGER;
}
+#ifndef DISABLE_SCRIPTING
else if ( SbiRuntime::isVBAEnabled() )
{
OSL_TRACE("Reporting error converting");
return SbxERR_CONVERSION;
}
+#endif
if( pLen )
*pLen = (sal_uInt16) ( p - pStart );
if( !bRes )
diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx
index fc95c5763211..20a7b116793e 100644
--- a/basic/source/sbx/sbxstr.cxx
+++ b/basic/source/sbx/sbxstr.cxx
@@ -260,7 +260,11 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr)
sal_Int32 nArraySize = rStr.getLength() * 2;
const sal_Unicode* pSrc = rStr.getStr();
SbxDimArray* pArray = new SbxDimArray(SbxBYTE);
+#ifdef DISABLE_SCRIPTING
+ bool bIncIndex = false;
+#else
bool bIncIndex = ( IsBaseIndexOne() && SbiRuntime::isVBAEnabled() );
+#endif
if( nArraySize )
{
if( bIncIndex )
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index be3611921ac1..74b9d9c96a3e 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -297,7 +297,11 @@ SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const
((SbxValue*) pObj)->aData.eType == SbxOBJECT &&
((SbxValue*) pObj)->aData.pObj == pObj )
{
+#ifdef DISABLE_SCRIPTING // No sbunoobj
+ const bool bSuccess = false;
+#else
bool bSuccess = handleToStringForCOMObjects( pObj, p );
+#endif
if( !bSuccess )
{
SetError( SbxERR_BAD_PROP_VALUE );
@@ -914,8 +918,11 @@ sal_Bool SbxValue::Convert( SbxDataType eTo )
sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp )
{
+#ifdef DISABLE_SCRIPTING
+ bool bVBAInterop = false;
+#else
bool bVBAInterop = SbiRuntime::isVBAEnabled();
-
+#endif
SbxDataType eThisType = GetType();
SbxDataType eOpType = rOp.GetType();
SbxError eOld = GetError();
@@ -1283,7 +1290,11 @@ Lbl_OpIsEmpty:
sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const
{
+#ifdef DISABLE_SCRIPTING
+ bool bVBAInterop = false;
+#else
bool bVBAInterop = SbiRuntime::isVBAEnabled();
+#endif
sal_Bool bRes = sal_False;
SbxError eOld = GetError();
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index d00115a1ed41..9ad7a5f0de9d 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -93,8 +93,10 @@ SbxVariable::SbxVariable( const SbxVariable& r )
if( r.mpSbxVariableImpl != NULL )
{
mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+#ifndef DISABLE_SCRIPTING
if( mpSbxVariableImpl->m_xComListener.is() )
registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+#endif
}
pCst = NULL;
if( r.CanRead() )
@@ -141,8 +143,10 @@ SbxVariable::~SbxVariable()
if ( maName.EqualsAscii( aCellsStr ) )
maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 );
#endif
+#ifndef DISABLE_SCRIPTING
if( IsSet( SBX_DIM_AS_NEW ))
removeDimAsNewRecoverItem( this );
+#endif
delete mpSbxVariableImpl;
delete pCst;
}
@@ -333,8 +337,10 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r )
if( r.mpSbxVariableImpl != NULL )
{
mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+#ifndef DISABLE_SCRIPTING
if( mpSbxVariableImpl->m_xComListener.is() )
registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+#endif
}
else
mpSbxVariableImpl = NULL;
@@ -422,7 +428,9 @@ void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::
SbxVariableImpl* pImpl = getImpl();
pImpl->m_xComListener = xComListener;
pImpl->m_pComListenerParentBasic = pParentBasic;
+#ifndef DISABLE_SCRIPTING
registerComListenerVariableForBasic( this, pParentBasic );
+#endif
}
void SbxVariable::ClearComListener( void )