summaryrefslogtreecommitdiff
path: root/basic/source/runtime
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-06 23:34:23 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-07 02:14:53 -0600
commit27239ad23006b1fd1ddb21467f4c1fd637b560d5 (patch)
tree605b30a50f25ef7e8f0d6511d6df24790ece90b9 /basic/source/runtime
parentf510217832a6edaf6a44169cabdf739985d00125 (diff)
basic: String -> OUString
Change-Id: I42479b4bade5111e38d69f04c889c166f340d5ba
Diffstat (limited to 'basic/source/runtime')
-rw-r--r--basic/source/runtime/inputbox.cxx6
-rw-r--r--basic/source/runtime/iosys.cxx32
-rw-r--r--basic/source/runtime/methods.cxx609
-rw-r--r--basic/source/runtime/methods1.cxx165
-rw-r--r--basic/source/runtime/runtime.cxx10
-rw-r--r--basic/source/runtime/sbdiagnose.cxx8
-rw-r--r--basic/source/runtime/stdobj.cxx20
-rw-r--r--basic/source/runtime/stdobj1.cxx54
-rw-r--r--basic/source/runtime/step0.cxx201
-rw-r--r--basic/source/runtime/step2.cxx17
10 files changed, 604 insertions, 518 deletions
diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx
index 2bfc65e79af9..8a03001ef4f6 100644
--- a/basic/source/runtime/inputbox.cxx
+++ b/basic/source/runtime/inputbox.cxx
@@ -156,11 +156,11 @@ RTLFUNC(InputBox)
String aTitle;
String aDefault;
sal_Int32 nX = -1, nY = -1; // center
- const String& rPrompt = rPar.Get(1)->GetString();
+ const String& rPrompt = rPar.Get(1)->GetOUString();
if ( nArgCount > 2 && !rPar.Get(2)->IsErr() )
- aTitle = rPar.Get(2)->GetString();
+ aTitle = rPar.Get(2)->GetOUString();
if ( nArgCount > 3 && !rPar.Get(3)->IsErr() )
- aDefault = rPar.Get(3)->GetString();
+ aDefault = rPar.Get(3)->GetOUString();
if ( nArgCount > 4 )
{
if ( nArgCount != 6 )
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index d1d7c32631cc..c6cf5fad1cb5 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -71,15 +71,15 @@ class SbiInputDialog : public ModalDialog {
Edit aInput;
OKButton aOk;
CancelButton aCancel;
- String aText;
+ OUString aText;
DECL_LINK( Ok, Window * );
DECL_LINK( Cancel, Window * );
public:
- SbiInputDialog( Window*, const String& );
- const String& GetInput() { return aText; }
+ SbiInputDialog( Window*, const OUString& );
+ const OUString& GetInput() { return aText; }
};
-SbiInputDialog::SbiInputDialog( Window* pParent, const String& rPrompt )
+SbiInputDialog::SbiInputDialog( Window* pParent, const OUString& rPrompt )
:ModalDialog( pParent, WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ),
aInput( this, WB_3DLOOK | WB_LEFT | WB_BORDER ),
aOk( this ), aCancel( this )
@@ -306,7 +306,7 @@ class OslStream : public SvStream
osl::File maFile;
public:
- OslStream( const String& rName, short nStrmMode );
+ OslStream( const OUString& rName, short nStrmMode );
~OslStream();
virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize );
virtual sal_uIntPtr PutData( const void* pData, sal_uIntPtr nSize );
@@ -315,7 +315,7 @@ public:
virtual void SetSize( sal_uIntPtr nSize );
};
-OslStream::OslStream( const String& rName, short nStrmMode )
+OslStream::OslStream( const OUString& rName, short nStrmMode )
: maFile( rName )
{
sal_uInt32 nFlags;
@@ -563,9 +563,11 @@ SbError SbiStream::Open
nLine = 0;
nExpandOnWriteTo = 0;
if( ( nStrmMode & ( STREAM_READ|STREAM_WRITE ) ) == STREAM_READ )
+ {
nStrmMode |= STREAM_NOCREATE;
- String aStr(rtl::OStringToOUString(rName, osl_getThreadTextEncoding()));
- String aNameStr = getFullPath( aStr );
+ }
+ OUString aStr(rtl::OStringToOUString(rName, osl_getThreadTextEncoding()));
+ OUString aNameStr = getFullPath( aStr );
if( hasUno() )
{
@@ -849,9 +851,9 @@ void SbiIoSystem::Shutdown()
rtl::OUString aOutStr(rtl::OStringToOUString(aOut, osl_getThreadTextEncoding()));
#if defined GCC
Window* pParent = Application::GetDefDialogParent();
- MessBox( pParent, WinBits( WB_OK ), String(), aOutStr ).Execute();
+ MessBox( pParent, WinBits( WB_OK ), OUString(), aOutStr ).Execute();
#else
- MessBox( GetpApp()->GetDefDialogParent(), WinBits( WB_OK ), String(), aOutStr ).Execute();
+ MessBox( GetpApp()->GetDefDialogParent(), WinBits( WB_OK ), OUString(), aOutStr ).Execute();
#endif
}
aOut = rtl::OString();
@@ -983,17 +985,21 @@ void SbiIoSystem::WriteCon(const rtl::OString& rText)
n2 = n1;
}
if( n1 > n2 )
+ {
n1 = n2;
- rtl::OString s(aOut.copy(0, n1));
+ }
+ OString s(aOut.copy(0, n1));
aOut = aOut.copy(n1);
while (aOut[0] == '\n' || aOut[0] == '\r')
+ {
aOut = aOut.copy(1);
- String aStr(rtl::OStringToOUString(s, osl_getThreadTextEncoding()));
+ }
+ OUString aStr(rtl::OStringToOUString(s, osl_getThreadTextEncoding()));
{
SolarMutexGuard aSolarGuard;
if( !MessBox( GetpApp()->GetDefDialogParent(),
WinBits( WB_OK_CANCEL | WB_DEF_OK ),
- String(), aStr ).Execute() )
+ OUString(), aStr ).Execute() )
{
nError = SbERR_USER_ABORT;
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 5dab1a21a084..881ee8678c0e 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -107,16 +107,17 @@ SbxVariable* getDefaultProp( SbxVariable* pRef );
// from source/classes/sbxmod.cxx
uno::Reference< frame::XModel > getDocumentModel( StarBASIC* );
-static void FilterWhiteSpace( String& rStr )
+static void FilterWhiteSpace( OUString& rStr )
{
- if (!rStr.Len())
+ if (rStr.isEmpty())
+ {
return;
-
+ }
rtl::OUStringBuffer aRet;
- for (xub_StrLen i = 0; i < rStr.Len(); ++i)
+ for (sal_Int32 i = 0; i < rStr.getLength(); ++i)
{
- sal_Unicode cChar = rStr.GetChar(i);
+ sal_Unicode cChar = rStr[i];
if ((cChar != ' ') && (cChar != '\t') &&
(cChar != '\n') && (cChar != '\r'))
{
@@ -152,7 +153,7 @@ static inline bool isFolder( FileStatus::Type aType )
// Converts possibly relative paths to absolute paths
// according to the setting done by ChDir/ChDrive
-String getFullPath( const String& aRelPath )
+OUString getFullPath( const OUString& aRelPath )
{
OUString aFileURL;
@@ -195,7 +196,7 @@ RTLFUNC(CreateObject)
{
(void)bWrite;
- String aClass( rPar.Get( 1 )->GetString() );
+ OUString aClass( rPar.Get( 1 )->GetOUString() );
SbxObjectRef p = SbxBase::CreateObject( aClass );
if( !p )
StarBASIC::Error( SbERR_CANNOT_LOAD );
@@ -217,7 +218,7 @@ RTLFUNC(Error)
StarBASIC::Error( SbERR_INTERNAL_ERROR );
else
{
- String aErrorMsg;
+ OUString aErrorMsg;
SbError nErr = 0L;
sal_Int32 nCode = 0;
if( rPar.Count() == 1 )
@@ -239,8 +240,8 @@ RTLFUNC(Error)
}
bool bVBA = SbiRuntime::isVBAEnabled();
- String tmpErrMsg;
- if( bVBA && aErrorMsg.Len() > 0 )
+ OUString tmpErrMsg;
+ if( bVBA && !aErrorMsg.isEmpty())
{
tmpErrMsg = aErrorMsg;
}
@@ -341,15 +342,15 @@ RTLFUNC(Asc)
else
{
SbxVariableRef pArg = rPar.Get( 1 );
- String aStr( pArg->GetString() );
- if ( aStr.Len() == 0 )
+ OUString aStr( pArg->GetOUString() );
+ if ( aStr.isEmpty())
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
rPar.Get(0)->PutEmpty();
}
else
{
- sal_Unicode aCh = aStr.GetBuffer()[0];
+ sal_Unicode aCh = aStr[0];
rPar.Get(0)->PutLong( aCh );
}
}
@@ -418,15 +419,15 @@ RTLFUNC(CurDir)
int nCurDir = 0; // Current dir // JSM
if ( rPar.Count() == 2 )
{
- String aDrive = rPar.Get(1)->GetString();
- if ( aDrive.Len() != 1 )
+ OUString aDrive = rPar.Get(1)->GetOUString();
+ if ( aDrive.getLength() != 1 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
else
{
- nCurDir = (int)aDrive.GetBuffer()[0];
+ nCurDir = (int)aDrive[0];
if ( !isalpha( nCurDir ) )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -492,10 +493,11 @@ RTLFUNC(ChDir)
{
::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetOUString() );
}
- ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(ChDrive)
@@ -505,26 +507,28 @@ RTLFUNC(ChDrive)
rPar.Get(0)->PutEmpty();
if (rPar.Count() != 2)
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
// Implementation of StepRENAME with UCB
-void implStepRenameUCB( const String& aSource, const String& aDest )
+void implStepRenameUCB( const OUString& aSource, const OUString& aDest )
{
uno::Reference< ucb::XSimpleFileAccess3 > xSFI = getFileAccess();
if( xSFI.is() )
{
try
{
- String aSourceFullPath = getFullPath( aSource );
+ OUString aSourceFullPath = getFullPath( aSource );
if( !xSFI->exists( aSourceFullPath ) )
{
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
return;
}
- String aDestFullPath = getFullPath( aDest );
+ OUString aDestFullPath = getFullPath( aDest );
if( xSFI->exists( aDestFullPath ) )
{
StarBASIC::Error( SbERR_FILE_EXISTS );
@@ -542,7 +546,7 @@ void implStepRenameUCB( const String& aSource, const String& aDest )
}
// Implementation of StepRENAME with OSL
-void implStepRenameOSL( const String& aSource, const String& aDest )
+void implStepRenameOSL( const OUString& aSource, const OUString& aDest )
{
FileBase::RC nRet = File::move( getFullPathUNC( aSource ), getFullPathUNC( aDest ) );
if( nRet != FileBase::E_None )
@@ -559,8 +563,8 @@ RTLFUNC(FileCopy)
rPar.Get(0)->PutEmpty();
if (rPar.Count() == 3)
{
- String aSource = rPar.Get(1)->GetString();
- String aDest = rPar.Get(2)->GetString();
+ OUString aSource = rPar.Get(1)->GetOUString();
+ OUString aDest = rPar.Get(2)->GetOUString();
if( hasUno() )
{
uno::Reference< ucb::XSimpleFileAccess3 > xSFI = getFileAccess();
@@ -597,14 +601,14 @@ RTLFUNC(Kill)
rPar.Get(0)->PutEmpty();
if (rPar.Count() == 2)
{
- String aFileSpec = rPar.Get(1)->GetString();
+ OUString aFileSpec = rPar.Get(1)->GetOUString();
if( hasUno() )
{
uno::Reference< ucb::XSimpleFileAccess3 > xSFI = getFileAccess();
if( xSFI.is() )
{
- String aFullPath = getFullPath( aFileSpec );
+ OUString aFullPath = getFullPath( aFileSpec );
if( !xSFI->exists( aFullPath ) || xSFI->isFolder( aFullPath ) )
{
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
@@ -639,7 +643,7 @@ RTLFUNC(MkDir)
rPar.Get(0)->PutEmpty();
if (rPar.Count() == 2)
{
- String aPath = rPar.Get(1)->GetString();
+ OUString aPath = rPar.Get(1)->GetOUString();
if( hasUno() )
{
@@ -670,7 +674,7 @@ RTLFUNC(MkDir)
// In OSL only empty directories can be deleted
// so we have to delete all files recursively
-void implRemoveDirRecursive( const String& aDirPath )
+void implRemoveDirRecursive( const OUString& aDirPath )
{
DirectoryItem aItem;
FileBase::RC nRet = DirectoryItem::get( aDirPath, aItem );
@@ -700,12 +704,13 @@ void implRemoveDirRecursive( const String& aDirPath )
DirectoryItem aItem2;
nRet = aDir.getNextItem( aItem2 );
if( nRet != FileBase::E_None )
+ {
break;
-
+ }
// Handle flags
FileStatus aFileStatus2( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL );
nRet = aItem2.getFileStatus( aFileStatus2 );
- ::rtl::OUString aPath = aFileStatus2.getFileURL();
+ OUString aPath = aFileStatus2.getFileURL();
// Directory?
FileStatus::Type aType2 = aFileStatus2.getFileType();
@@ -733,7 +738,7 @@ RTLFUNC(RmDir)
rPar.Get(0)->PutEmpty();
if (rPar.Count() == 2)
{
- String aPath = rPar.Get(1)->GetString();
+ OUString aPath = rPar.Get(1)->GetOUString();
if( hasUno() )
{
uno::Reference< ucb::XSimpleFileAccess3 > xSFI = getFileAccess();
@@ -750,7 +755,7 @@ RTLFUNC(RmDir)
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
if( bCompatibility )
{
- Sequence< ::rtl::OUString > aContent = xSFI->getFolderContents( aPath, true );
+ Sequence< OUString > aContent = xSFI->getFolderContents( aPath, true );
sal_Int32 nCount = aContent.getLength();
if( nCount > 0 )
{
@@ -815,7 +820,7 @@ RTLFUNC(FileLen)
else
{
SbxVariableRef pArg = rPar.Get( 1 );
- String aStr( pArg->GetString() );
+ OUString aStr( pArg->GetOUString() );
sal_Int32 nLen = 0;
if( hasUno() )
{
@@ -897,18 +902,17 @@ RTLFUNC(InStr)
StarBASIC::Error( SbERR_BAD_ARGUMENT );
else
{
- sal_uInt16 nStartPos = 1;
+ sal_Int32 nStartPos = 1;
+ sal_Int32 nFirstStringPos = 1;
- sal_uInt16 nFirstStringPos = 1;
if ( nArgCount >= 3 )
{
- sal_Int32 lStartPos = rPar.Get(1)->GetLong();
- if( lStartPos <= 0 || lStartPos > 0xffff )
+ nStartPos = rPar.Get(1)->GetLong();
+ if( nStartPos <= 0 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
- lStartPos = 1;
+ nStartPos = 1;
}
- nStartPos = (sal_uInt16)lStartPos;
nFirstStringPos++;
}
@@ -928,11 +932,11 @@ RTLFUNC(InStr)
{
bTextMode = rPar.Get(4)->GetInteger();
}
- sal_uInt16 nPos;
- const String& rToken = rPar.Get(nFirstStringPos+1)->GetString();
+ sal_Int32 nPos;
+ const OUString& rToken = rPar.Get(nFirstStringPos+1)->GetOUString();
// #97545 Always find empty string
- if( !rToken.Len() )
+ if( rToken.isEmpty() )
{
nPos = nStartPos;
}
@@ -940,27 +944,18 @@ RTLFUNC(InStr)
{
if( !bTextMode )
{
- const String& rStr1 = rPar.Get(nFirstStringPos)->GetString();
-
- nPos = rStr1.Search( rToken, nStartPos-1 );
- if ( nPos == STRING_NOTFOUND )
- nPos = 0;
- else
- nPos++;
+ const OUString& rStr1 = rPar.Get(nFirstStringPos)->GetOUString();
+ nPos = rStr1.indexOf( rToken, nStartPos - 1 ) + 1;
}
else
{
- String aStr1 = rPar.Get(nFirstStringPos)->GetString();
- String aToken = rToken;
+ OUString aStr1 = rPar.Get(nFirstStringPos)->GetOUString();
+ OUString aToken = rToken;
- aStr1.ToUpperAscii();
- aToken.ToUpperAscii();
+ aStr1 = aStr1.toAsciiUpperCase();
+ aToken = aToken.toAsciiUpperCase();
- nPos = aStr1.Search( aToken, nStartPos-1 );
- if ( nPos == STRING_NOTFOUND )
- nPos = 0;
- else
- nPos++;
+ nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
}
}
rPar.Get(0)->PutLong( nPos );
@@ -982,17 +977,17 @@ RTLFUNC(InStrRev)
}
else
{
- String aStr1 = rPar.Get(1)->GetString();
- String aToken = rPar.Get(2)->GetString();
+ OUString aStr1 = rPar.Get(1)->GetOUString();
+ OUString aToken = rPar.Get(2)->GetOUString();
- sal_Int32 lStartPos = -1;
+ sal_Int32 nStartPos = -1;
if ( nArgCount >= 3 )
{
- lStartPos = rPar.Get(3)->GetLong();
- if( (lStartPos <= 0 && lStartPos != -1) || lStartPos > 0xffff )
+ nStartPos = rPar.Get(3)->GetLong();
+ if( (nStartPos <= 0 && nStartPos != -1))
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
- lStartPos = -1;
+ nStartPos = -1;
}
}
@@ -1009,15 +1004,19 @@ RTLFUNC(InStrRev)
bTextMode = 1;;
}
if ( nArgCount == 4 )
+ {
bTextMode = rPar.Get(4)->GetInteger();
+ }
+ sal_Int32 nStrLen = aStr1.getLength();
+ if( nStartPos == -1 )
+ {
+ nStartPos = nStrLen;
+ }
- sal_uInt16 nStrLen = aStr1.Len();
- sal_uInt16 nStartPos = lStartPos == -1 ? nStrLen : (sal_uInt16)lStartPos;
-
- sal_uInt16 nPos = 0;
+ sal_Int32 nPos = 0;
if( nStartPos <= nStrLen )
{
- sal_uInt16 nTokenLen = aToken.Len();
+ sal_Int32 nTokenLen = aToken.getLength();
if( !nTokenLen )
{
// Always find empty string
@@ -1027,27 +1026,14 @@ RTLFUNC(InStrRev)
{
if( !bTextMode )
{
- ::rtl::OUString aOUStr1 ( aStr1 );
- ::rtl::OUString aOUToken( aToken );
- sal_Int32 nRet = aOUStr1.lastIndexOf( aOUToken, nStartPos );
- if( nRet == -1 )
- nPos = 0;
- else
- nPos = (sal_uInt16)nRet + 1;
+ nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
}
else
{
- aStr1.ToUpperAscii();
- aToken.ToUpperAscii();
-
- ::rtl::OUString aOUStr1 ( aStr1 );
- ::rtl::OUString aOUToken( aToken );
- sal_Int32 nRet = aOUStr1.lastIndexOf( aOUToken, nStartPos );
+ aStr1 = aStr1.toAsciiUpperCase();
+ aToken = aToken.toAsciiUpperCase();
- if( nRet == -1 )
- nPos = 0;
- else
- nPos = (sal_uInt16)nRet + 1;
+ nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
}
}
}
@@ -1117,7 +1103,7 @@ RTLFUNC(LCase)
else
{
const CharClass& rCharClass = GetCharClass();
- String aStr( rPar.Get(1)->GetString() );
+ OUString aStr( rPar.Get(1)->GetOUString() );
aStr = rCharClass.lowercase(aStr);
rPar.Get(0)->PutString( aStr );
}
@@ -1134,18 +1120,18 @@ RTLFUNC(Left)
}
else
{
- String aStr( rPar.Get(1)->GetString() );
- sal_Int32 lResultLen = rPar.Get(2)->GetLong();
- if( lResultLen > 0xffff )
+ OUString aStr( rPar.Get(1)->GetOUString() );
+ sal_Int32 nResultLen = rPar.Get(2)->GetLong();
+ if( nResultLen < 0 )
{
- lResultLen = 0xffff;
+ nResultLen = 0;
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
}
- else if( lResultLen < 0 )
+ else if(nResultLen > aStr.getLength())
{
- lResultLen = 0;
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ nResultLen = aStr.getLength();
}
- aStr.Erase( (sal_uInt16)lResultLen );
+ aStr = aStr.copy(0, nResultLen );
rPar.Get(0)->PutString( aStr );
}
}
@@ -1199,7 +1185,7 @@ RTLFUNC(Mid)
(void)pBasic;
(void)bWrite;
- sal_uIntPtr nArgCount = rPar.Count()-1;
+ int nArgCount = rPar.Count()-1;
if ( nArgCount < 2 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -1211,41 +1197,46 @@ RTLFUNC(Mid)
// In contrast to the original the third parameter (nLength)
// can't be left out here. That's considered in bWrite already.
if( nArgCount == 4 )
+ {
bWrite = sal_True;
-
- String aArgStr = rPar.Get(1)->GetString();
- sal_uInt16 nStartPos = (sal_uInt16)(rPar.Get(2)->GetLong() );
+ }
+ OUString aArgStr = rPar.Get(1)->GetOUString();
+ sal_Int32 nStartPos = rPar.Get(2)->GetLong();
if ( nStartPos == 0 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
nStartPos--;
- sal_uInt16 nLen = 0xffff;
+ sal_Int32 nLen = -1;
bool bWriteNoLenParam = false;
if ( nArgCount == 3 || bWrite )
{
sal_Int32 n = rPar.Get(3)->GetLong();
if( bWrite && n == -1 )
+ {
bWriteNoLenParam = true;
- nLen = (sal_uInt16)n;
+ }
+ nLen = n;
}
- String aResultStr;
if ( bWrite )
{
+ OUStringBuffer aResultStr;
SbiInstance* pInst = GetSbData()->pInst;
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
if( bCompatibility )
{
- sal_uInt16 nArgLen = aArgStr.Len();
+ sal_Int32 nArgLen = aArgStr.getLength();
if( nStartPos + 1 > nArgLen )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
- String aReplaceStr = rPar.Get(4)->GetString();
- sal_uInt16 nReplaceStrLen = aReplaceStr.Len();
- sal_uInt16 nReplaceLen;
+ OUString aReplaceStr = rPar.Get(4)->GetOUString();
+ sal_Int32 nReplaceStrLen = aReplaceStr.getLength();
+ sal_Int32 nReplaceLen;
if( bWriteNoLenParam )
{
nReplaceLen = nReplaceStrLen;
@@ -1253,31 +1244,35 @@ RTLFUNC(Mid)
else
{
nReplaceLen = nLen;
- if( nReplaceLen > nReplaceStrLen )
+ if( nReplaceLen < 0 || nReplaceLen > nReplaceStrLen )
+ {
nReplaceLen = nReplaceStrLen;
+ }
}
- sal_uInt16 nReplaceEndPos = nStartPos + nReplaceLen;
+ sal_Int32 nReplaceEndPos = nStartPos + nReplaceLen;
if( nReplaceEndPos > nArgLen )
+ {
nReplaceLen -= (nReplaceEndPos - nArgLen);
-
+ }
aResultStr = aArgStr;
- sal_uInt16 nErase = nReplaceLen;
- aResultStr.Erase( nStartPos, nErase );
- aResultStr.Insert( aReplaceStr, 0, nReplaceLen, nStartPos );
+ sal_Int32 nErase = nReplaceLen;
+ aResultStr.remove( nStartPos, nErase );
+ aResultStr.insert( nStartPos, aReplaceStr.getStr(), nReplaceLen);
}
else
{
aResultStr = aArgStr;
- aResultStr.Erase( nStartPos, nLen );
- aResultStr.Insert(rPar.Get(4)->GetString(),0,nLen,nStartPos);
+ aResultStr.remove( nStartPos, nLen );
+ aResultStr.insert( nStartPos, rPar.Get(4)->GetOUString().getStr(), nLen);
}
- rPar.Get(1)->PutString( aResultStr );
+ rPar.Get(1)->PutString( aResultStr.makeStringAndClear() );
}
else
{
- aResultStr = aArgStr.Copy( nStartPos, nLen );
+ OUString aResultStr;
+ aResultStr = aArgStr.copy( nStartPos, nLen );
rPar.Get(0)->PutString( aResultStr );
}
}
@@ -1323,9 +1318,9 @@ RTLFUNC(Replace)
}
else
{
- String aExpStr = rPar.Get(1)->GetString();
- String aFindStr = rPar.Get(2)->GetString();
- String aReplaceStr = rPar.Get(3)->GetString();
+ OUString aExpStr = rPar.Get(1)->GetOUString();
+ OUString aFindStr = rPar.Get(2)->GetOUString();
+ OUString aReplaceStr = rPar.Get(3)->GetOUString();
sal_Int32 lStartPos = 1;
if ( nArgCount >= 4 )
@@ -1334,7 +1329,7 @@ RTLFUNC(Replace)
{
lStartPos = rPar.Get(4)->GetLong();
}
- if( lStartPos < 1 || lStartPos > 0xffff )
+ if( lStartPos < 1)
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
lStartPos = 1;
@@ -1348,7 +1343,7 @@ RTLFUNC(Replace)
{
lCount = rPar.Get(5)->GetLong();
}
- if( lCount < -1 || lCount > 0xffff )
+ if( lCount < -1)
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
lCount = -1;
@@ -1368,28 +1363,29 @@ RTLFUNC(Replace)
bTextMode = 1;
}
if ( nArgCount == 6 )
+ {
bTextMode = rPar.Get(6)->GetInteger();
-
- sal_uInt16 nExpStrLen = aExpStr.Len();
- sal_uInt16 nFindStrLen = aFindStr.Len();
- sal_uInt16 nReplaceStrLen = aReplaceStr.Len();
+ }
+ sal_Int32 nExpStrLen = aExpStr.getLength();
+ sal_Int32 nFindStrLen = aFindStr.getLength();
+ sal_Int32 nReplaceStrLen = aReplaceStr.getLength();
if( lStartPos <= nExpStrLen )
{
- sal_uInt16 nPos = static_cast<sal_uInt16>( lStartPos - 1 );
- sal_uInt16 nCounts = 0;
+ sal_Int32 nPos = lStartPos - 1;
+ sal_Int32 nCounts = 0;
while( lCount == -1 || lCount > nCounts )
{
- String aSrcStr( aExpStr );
+ OUString aSrcStr( aExpStr );
if( bTextMode )
{
- aSrcStr.ToUpperAscii();
- aFindStr.ToUpperAscii();
+ aSrcStr = aSrcStr.toAsciiUpperCase();
+ aFindStr = aFindStr.toAsciiUpperCase();
}
- nPos = aSrcStr.Search( aFindStr, nPos );
- if( nPos != STRING_NOTFOUND )
+ nPos = aSrcStr.indexOf( aFindStr, nPos );
+ if( nPos >= 0 )
{
- aExpStr.Replace( nPos, nFindStrLen, aReplaceStr );
+ aExpStr = aExpStr.replaceAt( nPos, nFindStrLen, aReplaceStr );
nPos = nPos - nFindStrLen + nReplaceStrLen + 1;
nCounts++;
}
@@ -1399,7 +1395,7 @@ RTLFUNC(Replace)
}
}
}
- rPar.Get(0)->PutString( aExpStr.Copy( static_cast<sal_uInt16>(lStartPos - 1) ) );
+ rPar.Get(0)->PutString( aExpStr.copy( lStartPos - 1 ) );
}
}
@@ -1491,7 +1487,7 @@ RTLFUNC(Space)
}
else
{
- rtl::OUStringBuffer aBuf;
+ OUStringBuffer aBuf;
string::padToLength(aBuf, rPar.Get(1)->GetLong(), ' ');
rPar.Get(0)->PutString(aBuf.makeStringAndClear());
}
@@ -1508,7 +1504,7 @@ RTLFUNC(Spc)
}
else
{
- rtl::OUStringBuffer aBuf;
+ OUStringBuffer aBuf;
string::padToLength(aBuf, rPar.Get(1)->GetLong(), ' ');
rPar.Get(0)->PutString(aBuf.makeStringAndClear());
}
@@ -1548,7 +1544,8 @@ RTLFUNC(Str)
}
else
{
- String aStr;
+ OUString aStr;
+ OUString aStrNew("");
SbxVariableRef pArg = rPar.Get( 1 );
pArg->Format( aStr );
@@ -1556,34 +1553,47 @@ RTLFUNC(Str)
if( pArg->IsNumericRTL() )
{
// replace commas by points so that it's symmetric to Val!
- aStr.SearchAndReplace( ',', '.' );
+ aStr = aStr.replaceFirst( ",", "." );
SbiInstance* pInst = GetSbData()->pInst;
bool bCompatibility = ( pInst && pInst->IsCompatibility() );
if( bCompatibility )
{
- xub_StrLen nLen = aStr.Len();
+ sal_Int32 nLen = aStr.getLength();
- const sal_Unicode* pBuf = aStr.GetBuffer();
+ const sal_Unicode* pBuf = aStr.getStr();
bool bNeg = ( pBuf[0] == '-' );
- sal_uInt16 iZeroSearch = 0;
+ sal_Int32 iZeroSearch = 0;
if( bNeg )
+ {
+ aStrNew += "-";
iZeroSearch++;
-
- sal_uInt16 iNext = iZeroSearch + 1;
+ }
+ else
+ {
+ if( pBuf[0] != ' ' )
+ {
+ aStrNew += " ";
+ }
+ }
+ sal_Int32 iNext = iZeroSearch + 1;
if( pBuf[iZeroSearch] == '0' && nLen > iNext && pBuf[iNext] == '.' )
{
- aStr.Erase( iZeroSearch, 1 );
- pBuf = aStr.GetBuffer();
+ iZeroSearch += 1;
}
- if( !bNeg )
- aStr.Insert( ' ', 0 );
+ aStrNew += aStr.copy(iZeroSearch);
}
else
- aStr.Insert( ' ', 0 );
+ {
+ aStrNew = " " + aStr;
+ }
}
- rPar.Get(0)->PutString( aStr );
+ else
+ {
+ aStrNew = aStr;
+ }
+ rPar.Get(0)->PutString( aStrNew );
}
}
@@ -1598,8 +1608,8 @@ RTLFUNC(StrComp)
rPar.Get(0)->PutEmpty();
return;
}
- const String& rStr1 = rPar.Get(1)->GetString();
- const String& rStr2 = rPar.Get(2)->GetString();
+ const OUString& rStr1 = rPar.Get(1)->GetOUString();
+ const OUString& rStr2 = rPar.Get(2)->GetOUString();
SbiInstance* pInst = GetSbData()->pInst;
sal_Int16 nTextCompare;
@@ -1617,9 +1627,9 @@ RTLFUNC(StrComp)
nTextCompare = rPar.Get(3)->GetInteger();
if( !bCompatibility )
+ {
nTextCompare = !nTextCompare;
-
- StringCompare aResult;
+ }
sal_Int32 nRetValue = 0;
if( nTextCompare )
{
@@ -1640,13 +1650,17 @@ RTLFUNC(StrComp)
}
else
{
- aResult = rStr1.CompareTo( rStr2 );
- if ( aResult == COMPARE_LESS )
+ sal_Int32 aResult;
+ aResult = rStr1.compareTo( rStr2 );
+ if ( aResult < 0 )
+ {
nRetValue = -1;
- else if ( aResult == COMPARE_GREATER )
+ }
+ else if ( aResult > 0)
+ {
nRetValue = 1;
+ }
}
-
rPar.Get(0)->PutInteger( sal::static_int_cast< sal_Int16 >( nRetValue ) );
}
@@ -1664,17 +1678,20 @@ RTLFUNC(String)
sal_Unicode aFiller;
sal_Int32 lCount = rPar.Get(1)->GetLong();
if( lCount < 0 || lCount > 0xffff )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
- sal_uInt16 nCount = (sal_uInt16)lCount;
+ }
if( rPar.Get(2)->GetType() == SbxINTEGER )
+ {
aFiller = (sal_Unicode)rPar.Get(2)->GetInteger();
+ }
else
{
- const String& rStr = rPar.Get(2)->GetString();
- aFiller = rStr.GetBuffer()[0];
+ const OUString& rStr = rPar.Get(2)->GetOUString();
+ aFiller = rStr[0];
}
- rtl::OUStringBuffer aBuf;
- string::padToLength(aBuf, nCount, aFiller);
+ OUStringBuffer aBuf(lCount);
+ string::padToLength(aBuf, lCount, aFiller);
rPar.Get(0)->PutString(aBuf.makeStringAndClear());
}
}
@@ -1707,7 +1724,7 @@ RTLFUNC(UCase)
else
{
const CharClass& rCharClass = GetCharClass();
- String aStr( rPar.Get(1)->GetString() );
+ OUString aStr( rPar.Get(1)->GetOUString() );
aStr = rCharClass.uppercase( aStr );
rPar.Get(0)->PutString( aStr );
}
@@ -1728,13 +1745,13 @@ RTLFUNC(Val)
double nResult = 0.0;
char* pEndPtr;
- String aStr( rPar.Get(1)->GetString() );
+ OUString aStr( rPar.Get(1)->GetOUString() );
FilterWhiteSpace( aStr );
- if ( aStr.GetBuffer()[0] == '&' && aStr.Len() > 1 )
+ if ( aStr[0] == '&' && aStr.getLength() > 1 )
{
int nRadix = 10;
- char aChar = (char)aStr.GetBuffer()[1];
+ char aChar = (char)aStr[1];
if ( aChar == 'h' || aChar == 'H' )
{
nRadix = 16;
@@ -1745,7 +1762,7 @@ RTLFUNC(Val)
}
if ( nRadix != 10 )
{
- rtl::OString aByteStr(rtl::OUStringToOString(aStr, osl_getThreadTextEncoding()));
+ OString aByteStr(rtl::OUStringToOString(aStr, osl_getThreadTextEncoding()));
sal_Int16 nlResult = (sal_Int16)strtol( aByteStr.getStr()+2, &pEndPtr, nRadix);
nResult = (double)nlResult;
}
@@ -1807,7 +1824,7 @@ RTLFUNC(CDateToIso)
implGetDateYear( aDate ),
implGetDateMonth( aDate ),
implGetDateDay( aDate ) );
- String aRetStr = rtl::OUString::createFromAscii( Buffer );
+ OUString aRetStr = rtl::OUString::createFromAscii( Buffer );
rPar.Get(0)->PutString( aRetStr );
}
else
@@ -1824,15 +1841,15 @@ RTLFUNC(CDateFromIso)
if ( rPar.Count() == 2 )
{
- String aStr = rPar.Get(1)->GetString();
- sal_Int16 iMonthStart = aStr.Len() - 4;
- String aYearStr = aStr.Copy( 0, iMonthStart );
- String aMonthStr = aStr.Copy( iMonthStart, 2 );
- String aDayStr = aStr.Copy( iMonthStart+2, 2 );
+ OUString aStr = rPar.Get(1)->GetOUString();
+ sal_Int16 iMonthStart = aStr.getLength() - 4;
+ OUString aYearStr = aStr.copy( 0, iMonthStart );
+ OUString aMonthStr = aStr.copy( iMonthStart, 2 );
+ OUString aDayStr = aStr.copy( iMonthStart+2, 2 );
double dDate;
- if( implDateSerial( (sal_Int16)aYearStr.ToInt32(),
- (sal_Int16)aMonthStr.ToInt32(), (sal_Int16)aDayStr.ToInt32(), dDate ) )
+ if( implDateSerial( (sal_Int16)aYearStr.toInt32(),
+ (sal_Int16)aMonthStr.toInt32(), (sal_Int16)aDayStr.toInt32(), dDate ) )
{
rPar.Get(0)->PutDate( dDate );
}
@@ -1922,7 +1939,7 @@ RTLFUNC(DateValue)
sal_uInt32 nIndex;
double fResult;
- String aStr( rPar.Get(1)->GetString() );
+ OUString aStr( rPar.Get(1)->GetOUString() );
sal_Bool bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
short nType = pFormatter->GetType( nIndex );
@@ -1991,7 +2008,7 @@ RTLFUNC(TimeValue)
sal_uInt32 nIndex;
double fResult;
- sal_Bool bSuccess = pFormatter->IsNumberFormat( rPar.Get(1)->GetString(),
+ sal_Bool bSuccess = pFormatter->IsNumberFormat( rPar.Get(1)->GetOUString(),
nIndex, fResult );
short nType = pFormatter->GetType(nIndex);
if(bSuccess && (nType==NUMBERFORMAT_TIME||nType==NUMBERFORMAT_DATETIME))
@@ -2180,13 +2197,13 @@ RTLFUNC(Time)
{
Time aTime( Time::SYSTEM );
SbxVariable* pMeth = rPar.Get( 0 );
- String aRes;
+ OUString aRes;
if( pMeth->IsFixed() )
{
// Time$: hh:mm:ss
char buf[ 20 ];
snprintf( buf, sizeof(buf), "%02d:%02d:%02d",
- aTime.GetHour(), aTime.GetMin(), aTime.GetSec() );
+ aTime.GetHour(), aTime.GetMin(), aTime.GetSec() );
aRes = rtl::OUString::createFromAscii( buf );
}
else
@@ -2253,7 +2270,7 @@ RTLFUNC(Date)
SbxVariable* pMeth = rPar.Get( 0 );
if( pMeth->IsString() )
{
- String aRes;
+ OUString aRes;
Color* pCol;
SvNumberFormatter* pFormatter = NULL;
@@ -2496,7 +2513,7 @@ RTLFUNC(IsMissing)
}
// Function looks for wildcards, removes them and always returns the pure path
-String implSetupWildcard( const String& rFileParam, SbiRTLData* pRTLData )
+OUString implSetupWildcard( const OUString& rFileParam, SbiRTLData* pRTLData )
{
static sal_Char cDelim1 = (sal_Char)'/';
static sal_Char cDelim2 = (sal_Char)'\\';
@@ -2505,47 +2522,54 @@ String implSetupWildcard( const String& rFileParam, SbiRTLData* pRTLData )
delete pRTLData->pWildCard;
pRTLData->pWildCard = NULL;
- pRTLData->sFullNameToBeChecked = String();
-
- String aFileParam = rFileParam;
- xub_StrLen nLastWild = aFileParam.SearchBackward( cWild1 );
- if( nLastWild == STRING_NOTFOUND )
- nLastWild = aFileParam.SearchBackward( cWild2 );
- bool bHasWildcards = ( nLastWild != STRING_NOTFOUND );
+ pRTLData->sFullNameToBeChecked = OUString();
+ OUString aFileParam = rFileParam;
+ sal_Int32 nLastWild = aFileParam.lastIndexOf( cWild1 );
+ if( nLastWild < 0 )
+ {
+ nLastWild = aFileParam.lastIndexOf( cWild2 );
+ }
+ bool bHasWildcards = ( nLastWild >= 0 );
- xub_StrLen nLastDelim = aFileParam.SearchBackward( cDelim1 );
- if( nLastDelim == STRING_NOTFOUND )
- nLastDelim = aFileParam.SearchBackward( cDelim2 );
+ sal_Int32 nLastDelim = aFileParam.lastIndexOf( cDelim1 );
+ if( nLastDelim < 0 )
+ {
+ nLastDelim = aFileParam.lastIndexOf( cDelim2 );
+ }
if( bHasWildcards )
{
// Wildcards in path?
- if( nLastDelim != STRING_NOTFOUND && nLastDelim > nLastWild )
+ if( nLastDelim >= 0 && nLastDelim > nLastWild )
+ {
return aFileParam;
+ }
}
else
{
- String aPathStr = getFullPath( aFileParam );
- if( nLastDelim != aFileParam.Len() - 1 )
+ OUString aPathStr = getFullPath( aFileParam );
+ if( nLastDelim != aFileParam.getLength() - 1 )
+ {
pRTLData->sFullNameToBeChecked = aPathStr;
+ }
return aPathStr;
}
- rtl::OUString aPureFileName;
- if( nLastDelim == STRING_NOTFOUND )
+ OUString aPureFileName;
+ if( nLastDelim < 0 )
{
aPureFileName = aFileParam;
- aFileParam = String();
+ aFileParam = OUString();
}
else
{
- aPureFileName = aFileParam.Copy( nLastDelim + 1 );
- aFileParam = aFileParam.Copy( 0, nLastDelim );
+ aPureFileName = aFileParam.copy( nLastDelim + 1 );
+ aFileParam = aFileParam.copy( 0, nLastDelim );
}
// Try again to get a valid URL/UNC-path with only the path
- String aPathStr = getFullPath( aFileParam );
+ OUString aPathStr = getFullPath( aFileParam );
// Is there a pure file name left? Otherwise the path is
// invalid anyway because it was not accepted by OSL before
@@ -2556,7 +2580,7 @@ String implSetupWildcard( const String& rFileParam, SbiRTLData* pRTLData )
return aPathStr;
}
-inline sal_Bool implCheckWildcard( const String& rName, SbiRTLData* pRTLData )
+inline sal_Bool implCheckWildcard( const OUString& rName, SbiRTLData* pRTLData )
{
sal_Bool bMatch = sal_True;
@@ -2568,7 +2592,7 @@ inline sal_Bool implCheckWildcard( const String& rName, SbiRTLData* pRTLData )
}
-bool isRootDir( String aDirURLStr )
+bool isRootDir( OUString aDirURLStr )
{
INetURLObject aDirURLObj( aDirURLStr );
bool bRoot = false;
@@ -2604,7 +2628,7 @@ RTLFUNC(Dir)
(void)pBasic;
(void)bWrite;
- String aPath;
+ OUString aPath;
sal_uInt16 nParCount = rPar.Count();
if( nParCount > 3 )
@@ -2628,21 +2652,21 @@ RTLFUNC(Dir)
{
if ( nParCount >= 2 )
{
- String aFileParam = rPar.Get(1)->GetString();
+ OUString aFileParam = rPar.Get(1)->GetOUString();
- String aFileURLStr = implSetupWildcard( aFileParam, pRTLData );
- if( pRTLData->sFullNameToBeChecked.Len() > 0 )
+ OUString aFileURLStr = implSetupWildcard( aFileParam, pRTLData );
+ if( !pRTLData->sFullNameToBeChecked.isEmpty())
{
sal_Bool bExists = sal_False;
try { bExists = xSFI->exists( aFileURLStr ); }
catch(const Exception & ) {}
- String aNameOnlyStr;
+ OUString aNameOnlyStr;
if( bExists )
{
INetURLObject aFileURL( aFileURLStr );
aNameOnlyStr = aFileURL.getName( INetURLObject::LAST_SEGMENT,
- true, INetURLObject::DECODE_WITH_CHARSET );
+ true, INetURLObject::DECODE_WITH_CHARSET );
}
rPar.Get(0)->PutString( aNameOnlyStr );
return;
@@ -2650,7 +2674,7 @@ RTLFUNC(Dir)
try
{
- String aDirURLStr;
+ OUString aDirURLStr;
sal_Bool bFolder = xSFI->isFolder( aFileURLStr );
if( bFolder )
@@ -2659,7 +2683,7 @@ RTLFUNC(Dir)
}
else
{
- String aEmptyStr;
+ OUString aEmptyStr;
rPar.Get(0)->PutString( aEmptyStr );
}
@@ -2721,7 +2745,7 @@ RTLFUNC(Dir)
else if( pRTLData->nCurDirPos >= pRTLData->aDirSeq.getLength() )
{
pRTLData->aDirSeq.realloc( 0 );
- aPath.Erase();
+ aPath = "";
break;
}
else
@@ -2773,9 +2797,9 @@ RTLFUNC(Dir)
// TODO: OSL
if ( nParCount >= 2 )
{
- String aFileParam = rPar.Get(1)->GetString();
+ OUString aFileParam = rPar.Get(1)->GetOUString();
- String aDirURL = implSetupWildcard( aFileParam, pRTLData );
+ OUString aDirURL = implSetupWildcard( aFileParam, pRTLData );
sal_uInt16 nFlags = 0;
if ( nParCount > 2 )
@@ -2795,7 +2819,7 @@ RTLFUNC(Dir)
{
delete pRTLData->pDir;
pRTLData->pDir = NULL;
- rPar.Get(0)->PutString( String() );
+ rPar.Get(0)->PutString( OUString() );
return;
}
@@ -2842,7 +2866,7 @@ RTLFUNC(Dir)
{
delete pRTLData->pDir;
pRTLData->pDir = NULL;
- aPath.Erase();
+ aPath = "";
break;
}
@@ -2892,12 +2916,12 @@ RTLFUNC(GetAttr)
#if defined( WNT )
if( SbiRuntime::isVBAEnabled() )
{
- DirEntry aEntry( rPar.Get(1)->GetString() );
+ DirEntry aEntry( rPar.Get(1)->GetOUString() );
aEntry.ToAbs();
// #57064 extract the real-path for virtual URLs
- rtl::OString aByteStrFullPath(rtl::OUStringToOString(aEntry.GetFull(),
- osl_getThreadTextEncoding()));
+ OString aByteStrFullPath(rtl::OUStringToOString(aEntry.GetFull(),
+ osl_getThreadTextEncoding()));
DWORD nRealFlags = GetFileAttributes (aByteStrFullPath.getStr());
if (nRealFlags != 0xffffffff)
{
@@ -2924,7 +2948,7 @@ RTLFUNC(GetAttr)
{
try
{
- String aPath = getFullPath( rPar.Get(1)->GetString() );
+ OUString aPath = getFullPath( rPar.Get(1)->GetOUString() );
sal_Bool bExists = sal_False;
try { bExists = xSFI->exists( aPath ); }
catch(const Exception & ) {}
@@ -2959,7 +2983,7 @@ RTLFUNC(GetAttr)
else
{
DirectoryItem aItem;
- DirectoryItem::get( getFullPathUNC( rPar.Get(1)->GetString() ), aItem );
+ DirectoryItem::get( getFullPathUNC( rPar.Get(1)->GetOUString() ), aItem );
FileStatus aFileStatus( osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type );
aItem.getFileStatus( aFileStatus );
sal_uInt64 nAttributes = aFileStatus.getAttributes();
@@ -2996,7 +3020,7 @@ RTLFUNC(FileDateTime)
}
else
{
- String aPath = rPar.Get(1)->GetString();
+ OUString aPath = rPar.Get(1)->GetOUString();
Time aTime( Time::EMPTY );
Date aDate( Date::EMPTY );
if( hasUno() )
@@ -3053,7 +3077,7 @@ RTLFUNC(FileDateTime)
SbiInstance::PrepareNumberFormatter( pFormatter, n, n, nIndex );
}
- String aRes;
+ OUString aRes;
pFormatter->GetOutputString( fSerial, nIndex, aRes, &pCol );
rPar.Get(0)->PutString( aRes );
@@ -3281,14 +3305,14 @@ RTLFUNC(Format)
}
else
{
- String aResult;
+ OUString aResult;
if( nArgCount == 2 )
{
rPar.Get(1)->Format( aResult );
}
else
{
- String aFmt( rPar.Get(2)->GetString() );
+ OUString aFmt( rPar.Get(2)->GetOUString() );
rPar.Get(1)->Format( aResult, &aFmt );
}
rPar.Get(0)->PutString( aResult );
@@ -3365,64 +3389,66 @@ RTLFUNC(Shell)
{
oslProcessOption nOptions = osl_Process_SEARCHPATH | osl_Process_DETACHED;
- String aCmdLine = rPar.Get(1)->GetString();
+ OUString aCmdLine = rPar.Get(1)->GetOUString();
// attach additional parameters - everything must be parsed anyway
if( nArgCount >= 4 )
{
- aCmdLine.AppendAscii( " " );
- aCmdLine += rPar.Get(3)->GetString();
+ aCmdLine += " ";
+ aCmdLine += rPar.Get(3)->GetOUString();
}
- else if( !aCmdLine.Len() )
+ else if( aCmdLine.isEmpty() )
{
// avaoid special treatment (empty list)
- aCmdLine.AppendAscii( " " );
+ aCmdLine += " ";
}
- sal_uInt16 nLen = aCmdLine.Len();
+ sal_Int32 nLen = aCmdLine.getLength();
// #55735 if there are parameters, they have to be seperated
// #72471 also seperate the single parameters
std::list<String> aTokenList;
- String aToken;
- sal_uInt16 i = 0;
+ OUString aToken;
+ sal_Int32 i = 0;
sal_Unicode c;
while( i < nLen )
{
for ( ;; ++i )
{
- c = aCmdLine.GetBuffer()[ i ];
+ c = aCmdLine[ i ];
if ( c != ' ' && c != '\t' )
+ {
break;
+ }
}
if( c == '\"' || c == '\'' )
{
- sal_uInt16 iFoundPos = aCmdLine.Search( c, i + 1 );
+ sal_Int32 iFoundPos = aCmdLine.indexOf( c, i + 1 );
- if( iFoundPos == STRING_NOTFOUND )
+ if( iFoundPos < 0 )
{
- aToken = aCmdLine.Copy( i, STRING_LEN );
+ aToken = aCmdLine.copy( i);
i = nLen;
}
else
{
- aToken = aCmdLine.Copy( i + 1, (iFoundPos - i - 1) );
+ aToken = aCmdLine.copy( i + 1, (iFoundPos - i - 1) );
i = iFoundPos + 1;
}
}
else
{
- sal_uInt16 iFoundSpacePos = aCmdLine.Search( ' ', i );
- sal_uInt16 iFoundTabPos = aCmdLine.Search( '\t', i );
- sal_uInt16 iFoundPos = Min( iFoundSpacePos, iFoundTabPos );
+ sal_Int32 iFoundSpacePos = aCmdLine.indexOf( ' ', i );
+ sal_Int32 iFoundTabPos = aCmdLine.indexOf( '\t', i );
+ sal_Int32 iFoundPos = iFoundSpacePos >= 0 ? iFoundTabPos >= 0 ? Min( iFoundSpacePos, iFoundTabPos ) : iFoundSpacePos : -1;
- if( iFoundPos == STRING_NOTFOUND )
+ if( iFoundPos < 0 )
{
- aToken = aCmdLine.Copy( i, STRING_LEN );
+ aToken = aCmdLine.copy( i );
i = nLen;
}
else
{
- aToken = aCmdLine.Copy( i, (iFoundPos - i) );
+ aToken = aCmdLine.copy( i, (iFoundPos - i) );
i = iFoundPos;
}
}
@@ -3462,22 +3488,21 @@ RTLFUNC(Shell)
// #72471 work parameter(s) up
std::list<String>::const_iterator iter = aTokenList.begin();
- const String& rStr = *iter;
- ::rtl::OUString aOUStrProg( rStr.GetBuffer(), rStr.Len() );
- ::rtl::OUString aOUStrProgUNC = getFullPathUNC( aOUStrProg );
+ const OUString& rStr = *iter;
+ OUString aOUStrProg( rStr.getStr(), rStr.getLength() );
+ OUString aOUStrProgUNC = getFullPathUNC( aOUStrProg );
++iter;
- sal_uInt16 nParamCount = sal::static_int_cast< sal_uInt16 >(
- aTokenList.size() - 1 );
+ sal_uInt16 nParamCount = sal::static_int_cast< sal_uInt16 >(aTokenList.size() - 1 );
rtl_uString** pParamList = NULL;
if( nParamCount )
{
pParamList = new rtl_uString*[nParamCount];
for(int iList = 0; iter != aTokenList.end(); ++iList, ++iter)
{
- const String& rParamStr = (*iter);
- const ::rtl::OUString aTempStr( rParamStr.GetBuffer(), rParamStr.Len());
+ const OUString& rParamStr = (*iter);
+ const OUString aTempStr( rParamStr.getStr(), rParamStr.getLength());
pParamList[iList] = NULL;
rtl_uString_assign(&(pParamList[iList]), aTempStr.pData);
}
@@ -3530,7 +3555,7 @@ RTLFUNC(VarType)
}
// Exported function
-rtl::OUString getBasicTypeName( SbxDataType eType )
+OUString getBasicTypeName( SbxDataType eType )
{
static const char* pTypeNames[] =
{
@@ -3590,7 +3615,9 @@ String getObjectTypeName( SbxVariable* pVar )
{
SbxBase* pObj = pVar->GetObject();
if( !pObj )
- sRet = String( RTL_CONSTASCII_USTRINGPARAM("Nothing") );
+ {
+ sRet = OUString("Nothing");
+ }
else
{
SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pVar );
@@ -3662,7 +3689,7 @@ RTLFUNC(TypeName)
SbxDataType eType = rPar.Get(1)->GetType();
bool bIsArray = ( ( eType & SbxARRAY ) != 0 );
- String aRetStr;
+ OUString aRetStr;
if ( SbiRuntime::isVBAEnabled() && eType == SbxOBJECT )
{
aRetStr = getObjectTypeName( rPar.Get(1) );
@@ -3672,7 +3699,9 @@ RTLFUNC(TypeName)
aRetStr = getBasicTypeName( eType );
}
if( bIsArray )
- aRetStr.AppendAscii( "()" );
+ {
+ aRetStr += "()";
+ }
rPar.Get(0)->PutString( aRetStr );
}
}
@@ -3688,8 +3717,8 @@ RTLFUNC(Len)
}
else
{
- const String& rStr = rPar.Get(1)->GetString();
- rPar.Get(0)->PutLong( (sal_Int32)rStr.Len() );
+ const OUString& rStr = rPar.Get(1)->GetOUString();
+ rPar.Get(0)->PutLong( rStr.getLength() );
}
}
@@ -3711,8 +3740,8 @@ RTLFUNC(DDEInitiate)
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
- const OUString& rApp = rPar.Get(1)->GetString();
- const OUString& rTopic = rPar.Get(2)->GetString();
+ const OUString& rApp = rPar.Get(1)->GetOUString();
+ const OUString& rTopic = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
size_t nChannel;
@@ -3802,7 +3831,7 @@ RTLFUNC(DDERequest)
return;
}
size_t nChannel = rPar.Get(1)->GetInteger();
- const OUString& rItem = rPar.Get(2)->GetString();
+ const OUString& rItem = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
OUString aResult;
SbError nDdeErr = pDDE->Request( nChannel, rItem, aResult );
@@ -3836,7 +3865,7 @@ RTLFUNC(DDEExecute)
return;
}
size_t nChannel = rPar.Get(1)->GetInteger();
- const OUString& rCommand = rPar.Get(2)->GetString();
+ const OUString& rCommand = rPar.Get(2)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->Execute( nChannel, rCommand );
if( nDdeErr )
@@ -3865,8 +3894,8 @@ RTLFUNC(DDEPoke)
return;
}
size_t nChannel = rPar.Get(1)->GetInteger();
- const OUString& rItem = rPar.Get(2)->GetString();
- const OUString& rData = rPar.Get(3)->GetString();
+ const OUString& rItem = rPar.Get(2)->GetOUString();
+ const OUString& rData = rPar.Get(3)->GetOUString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->Poke( nChannel, rItem, rData );
if( nDdeErr )
@@ -4037,12 +4066,12 @@ RTLFUNC(StrConv)
return;
}
- String aOldStr = rPar.Get(1)->GetString();
+ OUString aOldStr = rPar.Get(1)->GetOUString();
sal_Int32 nConversion = rPar.Get(2)->GetLong();
sal_uInt16 nLanguage = LANGUAGE_SYSTEM;
- sal_uInt16 nOldLen = aOldStr.Len();
+ sal_Int32 nOldLen = aOldStr.getLength();
if( nOldLen == 0 )
{
// null string,return
@@ -4054,7 +4083,7 @@ RTLFUNC(StrConv)
if ( (nConversion & 0x03) == 3 ) // vbProperCase
{
const CharClass& rCharClass = GetCharClass();
- aOldStr = rCharClass.titlecase( aOldStr.ToLowerAscii(), 0, nOldLen );
+ aOldStr = rCharClass.titlecase( aOldStr.toAsciiLowerCase(), 0, nOldLen );
}
else if ( (nConversion & 0x01) == 1 ) // vbUpperCase
{
@@ -4077,9 +4106,10 @@ RTLFUNC(StrConv)
nType |= i18n::TransliterationModules_HIRAGANA_KATAKANA;
}
else if ( (nConversion & 0x20) == 32 ) // vbHiragana
+ {
nType |= i18n::TransliterationModules_KATAKANA_HIRAGANA;
-
- String aNewStr( aOldStr );
+ }
+ OUString aNewStr( aOldStr );
if( nType != 0 )
{
uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
@@ -4092,32 +4122,33 @@ RTLFUNC(StrConv)
if ( (nConversion & 0x40) == 64 ) // vbUnicode
{
// convert the string to byte string, preserving unicode (2 bytes per character)
- sal_uInt16 nSize = aNewStr.Len()*2;
- const sal_Unicode* pSrc = aNewStr.GetBuffer();
+ sal_Int32 nSize = aNewStr.getLength()*2;
+ const sal_Unicode* pSrc = aNewStr.getStr();
sal_Char* pChar = new sal_Char[nSize+1];
- for( sal_uInt16 i=0; i < nSize; i++ )
+ for( sal_Int32 i=0; i < nSize; i++ )
{
pChar[i] = static_cast< sal_Char >( (i%2) ? ((*pSrc) >> 8) & 0xff : (*pSrc) & 0xff );
if( i%2 )
+ {
pSrc++;
+ }
}
pChar[nSize] = '\0';
::rtl::OString aOStr(pChar);
delete[] pChar;
// there is no concept about default codepage in unix. so it is incorrectly in unix
- ::rtl::OUString aOUStr = ::rtl::OStringToOUString(aOStr, osl_getThreadTextEncoding());
- aNewStr = String(aOUStr);
- rPar.Get(0)->PutString( aNewStr );
+ OUString aOUStr = ::rtl::OStringToOUString(aOStr, osl_getThreadTextEncoding());
+ rPar.Get(0)->PutString( aOUStr );
return;
}
else if ( (nConversion & 0x80) == 128 ) // vbFromUnicode
{
- ::rtl::OUString aOUStr(aNewStr);
+ OUString aOUStr(aNewStr);
// there is no concept about default codepage in unix. so it is incorrectly in unix
::rtl::OString aOStr = ::rtl::OUStringToOString(aNewStr,osl_getThreadTextEncoding());
const sal_Char* pChar = aOStr.getStr();
- sal_uInt16 nArraySize = static_cast< sal_uInt16 >( aOStr.getLength() );
+ sal_Int32 nArraySize = aOStr.getLength();
SbxDimArray* pArray = new SbxDimArray(SbxBYTE);
bool bIncIndex = (IsBaseIndexOne() && SbiRuntime::isVBAEnabled() );
if(nArraySize)
@@ -4136,7 +4167,7 @@ RTLFUNC(StrConv)
pArray->unoAddDim( 0, -1 );
}
- for( sal_uInt16 i=0; i< nArraySize; i++)
+ for( sal_Int32 i=0; i< nArraySize; i++)
{
SbxVariable* pNew = new SbxVariable( SbxBYTE );
pNew->PutByte(*pChar);
@@ -4195,8 +4226,7 @@ RTLFUNC(Load)
}
else if( pObj->IsA( TYPE( SbxObject ) ) )
{
- SbxVariable* pVar = ((SbxObject*)pObj)->
- Find( String( RTL_CONSTASCII_USTRINGPARAM("Load") ), SbxCLASS_METHOD );
+ SbxVariable* pVar = ((SbxObject*)pObj)->Find( OUString("Load"), SbxCLASS_METHOD );
if( pVar )
{
pVar->GetInteger();
@@ -4228,8 +4258,7 @@ RTLFUNC(Unload)
}
else if( pObj->IsA( TYPE( SbxObject ) ) )
{
- SbxVariable* pVar = ((SbxObject*)pObj)->
- Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD );
+ SbxVariable* pVar = ((SbxObject*)pObj)->Find( OUString("Unload"), SbxCLASS_METHOD );
if( pVar )
{
pVar->GetInteger();
@@ -4249,7 +4278,7 @@ RTLFUNC(LoadPicture)
return;
}
- String aFileURL = getFullPath( rPar.Get(1)->GetString() );
+ OUString aFileURL = getFullPath( rPar.Get(1)->GetOUString() );
SvStream* pStream = utl::UcbStreamHelper::CreateStream( aFileURL, STREAM_READ );
if( pStream != NULL )
{
@@ -4279,7 +4308,7 @@ RTLFUNC(SavePicture)
SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject();
if( pObj->IsA( TYPE( SbStdPicture ) ) )
{
- SvFileStream aOStream( rPar.Get(2)->GetString(), STREAM_WRITE | STREAM_TRUNC );
+ SvFileStream aOStream( rPar.Get(2)->GetOUString(), STREAM_WRITE | STREAM_TRUNC );
Graphic aGraphic = ((SbStdPicture*)pObj)->GetGraphic();
aOStream << aGraphic;
}
@@ -4371,10 +4400,12 @@ RTLFUNC(MsgBox)
}
nWinBits |= nWinDefBits;
- String aMsg = rPar.Get(1)->GetString();
- String aTitle;
+ OUString aMsg = rPar.Get(1)->GetOUString();
+ OUString aTitle;
if( nArgCount >= 4 )
- aTitle = rPar.Get(3)->GetString();
+ {
+ aTitle = rPar.Get(3)->GetOUString();
+ }
else
{
aTitle = GetpApp()->GetAppName();
@@ -4431,7 +4462,7 @@ RTLFUNC(SetAttr)
rPar.Get(0)->PutEmpty();
if ( rPar.Count() == 3 )
{
- String aStr = rPar.Get(1)->GetString();
+ OUString aStr = rPar.Get(1)->GetOUString();
sal_Int16 nFlags = rPar.Get(2)->GetInteger();
if( hasUno() )
@@ -4490,8 +4521,10 @@ RTLFUNC(DumpAllObjects)
{
SbxObject* p = pBasic;
while( p->GetParent() )
+ {
p = p->GetParent();
- SvFileStream aStrm( rPar.Get( 1 )->GetString(),
+ }
+ SvFileStream aStrm( rPar.Get( 1 )->GetOUString(),
STREAM_WRITE | STREAM_TRUNC );
p->Dump( aStrm, rPar.Get( 2 )->GetBool() );
aStrm.Close();
@@ -4510,7 +4543,7 @@ RTLFUNC(FileExists)
if ( rPar.Count() == 2 )
{
- String aStr = rPar.Get(1)->GetString();
+ OUString aStr = rPar.Get(1)->GetOUString();
sal_Bool bExists = sal_False;
if( hasUno() )
@@ -4622,7 +4655,7 @@ RTLFUNC(Partition)
}
}
aRetStr.append( aUpperValue );
- rPar.Get(0)->PutString( String(aRetStr.makeStringAndClear()) );
+ rPar.Get(0)->PutString( aRetStr.makeStringAndClear());
}
#endif
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 0d55f47b1be1..e12a69f0e94a 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -128,7 +128,7 @@ RTLFUNC(CallByName)
}
// 2. parameter is ProcedureName
- String aNameStr = rPar.Get(2)->GetString();
+ OUString aNameStr = rPar.Get(2)->GetOUString();
// 3. parameter is CallType
sal_Int16 nCallType = rPar.Get(3)->GetInteger();
@@ -323,7 +323,7 @@ RTLFUNC(CDbl) // JSM
if( pSbxVariable->GetType() == SbxSTRING )
{
// #41690
- String aScanStr = pSbxVariable->GetString();
+ OUString aScanStr = pSbxVariable->GetOUString();
SbError Error = SbxValue::ScanNumIntnl( aScanStr, nVal );
if( Error != SbxERR_OK )
{
@@ -392,7 +392,7 @@ RTLFUNC(CSng) // JSM
{
// #41690
double dVal = 0.0;
- String aScanStr = pSbxVariable->GetString();
+ OUString aScanStr = pSbxVariable->GetOUString();
SbError Error = SbxValue::ScanNumIntnl( aScanStr, dVal, /*bSingle=*/true );
if( SbxBase::GetError() == SbxERR_OK && Error != SbxERR_OK )
{
@@ -417,11 +417,11 @@ RTLFUNC(CStr) // JSM
(void)pBasic;
(void)bWrite;
- String aString;
+ OUString aString;
if ( rPar.Count() == 2 )
{
SbxVariable *pSbxVariable = rPar.Get(1);
- aString = pSbxVariable->GetString();
+ aString = pSbxVariable->GetOUString();
}
else
{
@@ -718,7 +718,7 @@ RTLFUNC(Trim)
}
else
{
- rtl::OUString aStr(comphelper::string::strip(rPar.Get(1)->GetString(), ' '));
+ rtl::OUString aStr(comphelper::string::strip(rPar.Get(1)->GetOUString(), ' '));
rPar.Get(0)->PutString(aStr);
}
}
@@ -772,8 +772,10 @@ RTLFUNC(FreeLibrary)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
- GetSbData()->pInst->GetDllMgr()->FreeDll( rPar.Get(1)->GetString() );
+ }
+ GetSbData()->pInst->GetDllMgr()->FreeDll( rPar.Get(1)->GetOUString() );
}
bool IsBaseIndexOne()
{
@@ -916,7 +918,7 @@ RTLFUNC(FindObject)
return;
}
- String aNameStr = rPar.Get(1)->GetString();
+ OUString aNameStr = rPar.Get(1)->GetOUString();
SbxBase* pFind = StarBASIC::FindSBXInCurrentScope( aNameStr );
SbxObject* pFindObj = NULL;
@@ -954,7 +956,7 @@ RTLFUNC(FindPropertyObject)
pObj = PTR_CAST(SbxObject,pObjVarObj);
}
- String aNameStr = rPar.Get(2)->GetString();
+ OUString aNameStr = rPar.Get(2)->GetOUString();
SbxObject* pFindObj = NULL;
if( pObj )
@@ -1314,10 +1316,10 @@ RTLFUNC(Environ)
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
- String aResult;
+ OUString aResult;
// should be ANSI but that's not possible under Win16 in the DLL
- rtl::OString aByteStr(rtl::OUStringToOString(rPar.Get(1)->GetString(),
- osl_getThreadTextEncoding()));
+ rtl::OString aByteStr(rtl::OUStringToOString(rPar.Get(1)->GetOUString(),
+ osl_getThreadTextEncoding()));
const char* pEnvStr = getenv(aByteStr.getStr());
if ( pEnvStr )
{
@@ -1428,7 +1430,7 @@ RTLFUNC(ResolvePath)
if ( rPar.Count() == 2 )
{
- String aStr = rPar.Get(1)->GetString();
+ OUString aStr = rPar.Get(1)->GetOUString();
DirEntry aEntry( aStr );
rPar.Get(0)->PutString( aStr );
}
@@ -1637,7 +1639,7 @@ RTLFUNC(ConvertToUrl)
if ( rPar.Count() == 2 )
{
- String aStr = rPar.Get(1)->GetString();
+ OUString aStr = rPar.Get(1)->GetOUString();
INetURLObject aURLObj( aStr, INET_PROT_FILE );
OUString aFileURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE );
if( aFileURL.isEmpty() )
@@ -1648,6 +1650,7 @@ RTLFUNC(ConvertToUrl)
{
aFileURL = aStr;
}
+ rPar.Get(0)->PutString(aFileURL);
}
else
{
@@ -1662,12 +1665,14 @@ RTLFUNC(ConvertFromUrl)
if ( rPar.Count() == 2 )
{
- String aStr = rPar.Get(1)->GetString();
+ OUString aStr = rPar.Get(1)->GetOUString();
OUString aSysPath;
::osl::File::getSystemPathFromFileURL( aStr, aSysPath );
if( aSysPath.isEmpty() )
+ {
aSysPath = aStr;
- rPar.Get(0)->PutString( String(aSysPath) );
+ }
+ rPar.Get(0)->PutString(aSysPath);
}
else
{
@@ -1708,20 +1713,24 @@ RTLFUNC(Join)
if( pArr )
{
if( pArr->GetDims() != 1 )
+ {
StarBASIC::Error( SbERR_WRONG_DIMS ); // Syntax Error?!
-
- String aDelim;
+ }
+ OUString aDelim;
if( nParCount == 3 )
- aDelim = rPar.Get(2)->GetString();
+ {
+ aDelim = rPar.Get(2)->GetOUString();
+ }
else
- aDelim = rtl::OUString(" ");
-
- String aRetStr;
+ {
+ aDelim = " ";
+ }
+ OUString aRetStr;
short nLower, nUpper;
pArr->GetDim( 1, nLower, nUpper );
for( short i = nLower ; i <= nUpper ; ++i )
{
- String aStr = pArr->Get( &i )->GetString();
+ OUString aStr = pArr->Get( &i )->GetOUString();
aRetStr += aStr;
if( i != nUpper )
{
@@ -1749,50 +1758,58 @@ RTLFUNC(Split)
return;
}
- String aExpression = rPar.Get(1)->GetString();
+ OUString aExpression = rPar.Get(1)->GetOUString();
short nArraySize = 0;
StringVector vRet;
- if( aExpression.Len() )
+ if( !aExpression.isEmpty() )
{
- String aDelim;
+ OUString aDelim;
if( nParCount >= 3 )
- aDelim = rPar.Get(2)->GetString();
+ {
+ aDelim = rPar.Get(2)->GetOUString();
+ }
else
- aDelim = rtl::OUString(" ");
+ {
+ aDelim = " ";
+ }
sal_Int32 nCount = -1;
if( nParCount == 4 )
+ {
nCount = rPar.Get(3)->GetLong();
-
- xub_StrLen nDelimLen = aDelim.Len();
+ }
+ sal_Int32 nDelimLen = aDelim.getLength();
if( nDelimLen )
{
- xub_StrLen iSearch = STRING_NOTFOUND;
- xub_StrLen iStart = 0;
+ sal_Int32 iSearch = -1;
+ sal_Int32 iStart = 0;
do
{
bool bBreak = false;
if( nCount >= 0 && nArraySize == nCount - 1 )
+ {
bBreak = true;
-
- iSearch = aExpression.Search( aDelim, iStart );
- String aSubStr;
- if( iSearch != STRING_NOTFOUND && !bBreak )
+ }
+ iSearch = aExpression.indexOf( aDelim, iStart );
+ OUString aSubStr;
+ if( iSearch >= 0 && !bBreak )
{
- aSubStr = aExpression.Copy( iStart, iSearch - iStart );
+ aSubStr = aExpression.copy( iStart, iSearch - iStart );
iStart = iSearch + nDelimLen;
}
else
{
- aSubStr = aExpression.Copy( iStart );
+ aSubStr = aExpression.copy( iStart );
}
vRet.push_back( aSubStr );
nArraySize++;
if( bBreak )
+ {
break;
+ }
}
- while( iSearch != STRING_NOTFOUND );
+ while( iSearch >= 0 );
}
else
{
@@ -1967,13 +1984,13 @@ enum Interval
struct IntervalInfo
{
Interval meInterval;
- const char* mpStringCode;
+ const OUString mStringCode;
double mdValue;
bool mbSimple;
- IntervalInfo( Interval eInterval, const char* pStringCode, double dValue, bool bSimple )
+ IntervalInfo( Interval eInterval, const OUString sStringCode, double dValue, bool bSimple )
: meInterval( eInterval )
- , mpStringCode( pStringCode )
+ , mStringCode( sStringCode )
, mdValue( dValue )
, mbSimple( bSimple )
{}
@@ -1991,17 +2008,19 @@ static IntervalInfo pIntervalTable[] =
IntervalInfo( INTERVAL_H, "h", (1.0 / 24.0), true ), // Hour
IntervalInfo( INTERVAL_N, "n", (1.0 / 1440.0), true), // Minute
IntervalInfo( INTERVAL_S, "s", (1.0 / 86400.0), true ), // Second
- IntervalInfo( INTERVAL_NONE, NULL, 0.0, false )
+ IntervalInfo( INTERVAL_NONE, "", 0.0, false )
};
-IntervalInfo* getIntervalInfo( const String& rStringCode )
+IntervalInfo* getIntervalInfo( const OUString& rStringCode )
{
IntervalInfo* pInfo = NULL;
sal_Int16 i = 0;
- while( (pInfo = pIntervalTable + i)->mpStringCode != NULL )
+ while( !(pInfo = pIntervalTable + i)->mStringCode.isEmpty() )
{
- if( rStringCode.EqualsIgnoreCaseAscii( pInfo->mpStringCode ) )
+ if( rStringCode.equalsIgnoreAsciiCase( pInfo->mStringCode ) )
+ {
break;
+ }
i++;
}
return pInfo;
@@ -2039,7 +2058,7 @@ RTLFUNC(DateAdd)
return;
}
- String aStringCode = rPar.Get(1)->GetString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo* pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -2164,7 +2183,7 @@ RTLFUNC(DateDiff)
return;
}
- String aStringCode = rPar.Get(1)->GetString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo* pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -2364,7 +2383,7 @@ RTLFUNC(DatePart)
return;
}
- String aStringCode = rPar.Get(1)->GetString();
+ OUString aStringCode = rPar.Get(1)->GetOUString();
IntervalInfo* pInfo = getIntervalInfo( aStringCode );
if( !pInfo )
{
@@ -2504,7 +2523,7 @@ RTLFUNC(FormatDateTime)
return;
}
- String aRetStr;
+ OUString aRetStr;
SbxVariableRef pSbxVar = new SbxVariable( SbxSTRING );
switch( nNamedFormat )
{
@@ -2515,20 +2534,22 @@ RTLFUNC(FormatDateTime)
// 12/21/2004 11:24:50 AM
// 21.12.2004 12:13:51
- case 0:
- pSbxVar->PutDate( dDate );
- aRetStr = pSbxVar->GetString();
- break;
+ case 0:
+ pSbxVar->PutDate( dDate );
+ aRetStr = pSbxVar->GetOUString();
+ break;
// LongDate: Display a date using the long date format specified
// in your computer's regional settings.
// Tuesday, December 21, 2004
// Dienstag, 21. December 2004
- case 1:
+ case 1:
{
SvNumberFormatter* pFormatter = NULL;
if( GetSbData()->pInst )
+ {
pFormatter = GetSbData()->pInst->GetNumberFormatter();
+ }
else
{
sal_uInt32 n; // Dummy
@@ -2550,27 +2571,31 @@ RTLFUNC(FormatDateTime)
// ShortDate: Display a date using the short date format specified
// in your computer's regional settings.
// 21.12.2004
- case 2:
- pSbxVar->PutDate( floor(dDate) );
- aRetStr = pSbxVar->GetString();
- break;
+ case 2:
+ pSbxVar->PutDate( floor(dDate) );
+ aRetStr = pSbxVar->GetOUString();
+ break;
// LongTime: Display a time using the time format specified
// in your computer's regional settings.
// 11:24:50 AM
// 12:13:51
- case 3:
+ case 3:
// ShortTime: Display a time using the 24-hour format (hh:mm).
// 11:24
- case 4:
- double n;
- double dTime = modf( dDate, &n );
- pSbxVar->PutDate( dTime );
- if( nNamedFormat == 3 )
- aRetStr = pSbxVar->GetString();
- else
- aRetStr = pSbxVar->GetString().Copy( 0, 5 );
- break;
+ case 4:
+ double n;
+ double dTime = modf( dDate, &n );
+ pSbxVar->PutDate( dTime );
+ if( nNamedFormat == 3 )
+ {
+ aRetStr = pSbxVar->GetOUString();
+ }
+ else
+ {
+ aRetStr = pSbxVar->GetOUString().copy( 0, 5 );
+ }
+ break;
}
rPar.Get(0)->PutString( aRetStr );
@@ -3207,7 +3232,7 @@ RTLFUNC(StrReverse)
return;
}
- rtl::OUString aStr = comphelper::string::reverseString(pSbxVariable->GetString());
+ rtl::OUString aStr = comphelper::string::reverseString(pSbxVariable->GetOUString());
rPar.Get(0)->PutString( aStr );
}
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 84e320fe4429..3c2c661cc9fc 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -373,7 +373,7 @@ void SbiInstance::PrepareNumberFormatter( SvNumberFormatter*& rpNumberFormatter,
rpNumberFormatter = new SvNumberFormatter( xFactory, eLangType );
- xub_StrLen nCheckPos = 0; short nType;
+ sal_uInt16 nCheckPos = 0; short nType;
rnStdTimeIdx = rpNumberFormatter->GetStandardFormat( NUMBERFORMAT_TIME, eLangType );
// the formatter's standard templates have only got a two-digit date
@@ -422,7 +422,7 @@ void setBasicWatchMode( bool bOn )
void SbiInstance::Error( SbError n )
{
- Error( n, String() );
+ Error( n, OUString() );
}
void SbiInstance::Error( SbError n, const OUString& rMsg )
@@ -963,7 +963,7 @@ SbxVariableRef SbiRuntime::PopVar()
#endif
SbxVariableRef xVar = refExprStk->Get( --nExprLvl );
#ifdef DBG_UTIL
- if ( xVar->GetName().EqualsAscii( "Cells" ) )
+ if ( xVar->GetName().equalsAscii( "Cells" ) )
OSL_TRACE( "" );
#endif
// methods hold themselves in parameter 0
@@ -1256,8 +1256,8 @@ SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* p
// DLL-calls
void SbiRuntime::DllCall
- ( const String& aFuncName,
- const String& aDLLName,
+ ( const OUString& aFuncName,
+ const OUString& aDLLName,
SbxArray* pArgs, // parameter (from index 1, can be NULL)
SbxDataType eResType, // return value
bool bCDecl ) // true: according to C-conventions
diff --git a/basic/source/runtime/sbdiagnose.cxx b/basic/source/runtime/sbdiagnose.cxx
index 2e5c1dcb3835..2168c04956f2 100644
--- a/basic/source/runtime/sbdiagnose.cxx
+++ b/basic/source/runtime/sbdiagnose.cxx
@@ -31,7 +31,7 @@
static DbgChannelId nRestoreChannelId = 0;
static DbgChannelId nAssertionChannelId = 0;
static StarBASICRef xAssertionChannelBasic;
-static String sCaptureFunctionName;
+static OUString sCaptureFunctionName;
static bool bReportingAssertion = false;
void ResetCapturedAssertions()
@@ -42,7 +42,7 @@ void ResetCapturedAssertions()
}
nRestoreChannelId = 0;
xAssertionChannelBasic = NULL;
- sCaptureFunctionName = String();
+ sCaptureFunctionName = OUString();
bReportingAssertion = false;
}
@@ -90,8 +90,8 @@ RTLFUNC(CaptureAssertions)
#ifdef DBG_UTIL
DBG_TESTSOLARMUTEX();
- String const sFunctionName = rPar.Get(1)->GetString();
- if ( sFunctionName.Len() == 0 )
+ OUString const sFunctionName = rPar.Get(1)->GetOUString();
+ if ( sFunctionName.isEmpty() )
{
ResetCapturedAssertions();
return;
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 70384dbf3f04..2a69f445d513 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -72,9 +72,9 @@ struct Methods {
struct StringHashCode
{
- size_t operator()( const String& rStr ) const
+ size_t operator()( const OUString& rStr ) const
{
- return rtl_ustr_hashCode_WithLength( rStr.GetBuffer(), rStr.Len() );
+ return rtl_ustr_hashCode_WithLength( rStr.getStr(), rStr.getLength() );
}
};
@@ -715,21 +715,21 @@ static Methods aMethods[] = {
{ NULL, SbxNULL, -1,NULL,0 }}; // end of the table
-SbiStdObject::SbiStdObject( const String& r, StarBASIC* pb ) : SbxObject( r )
+SbiStdObject::SbiStdObject( const OUString& r, StarBASIC* pb ) : SbxObject( r )
{
// do we have to initialize the hashcodes?
Methods* p = aMethods;
if( !p->nHash )
while( p->nArgs != -1 )
{
- String aName_ = rtl::OUString::createFromAscii( p->pName );
+ OUString aName_ = rtl::OUString::createFromAscii( p->pName );
p->nHash = SbxVariable::MakeHashCode( aName_ );
p += ( p->nArgs & _ARGSMASK ) + 1;
}
// #i92642: Remove default properties
- Remove( rtl::OUString("Name"), SbxCLASS_DONTCARE );
- Remove( rtl::OUString("Parent"), SbxCLASS_DONTCARE );
+ Remove( OUString("Name"), SbxCLASS_DONTCARE );
+ Remove( OUString("Parent"), SbxCLASS_DONTCARE );
SetParent( pb );
@@ -753,7 +753,7 @@ SbiStdObject::~SbiStdObject()
// return NULL without error code, so that a whole chain of
// objects can be asked for the method/property.
-SbxVariable* SbiStdObject::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t )
{
// entered already?
SbxVariable* pVar = SbxObject::Find( rName, t );
@@ -798,7 +798,7 @@ SbxVariable* SbiStdObject::Find( const rtl::OUString& rName, SbxClassType t )
short nType = ( p->nArgs & _TYPEMASK );
if( p->nArgs & _CONST )
nAccess |= SBX_CONST;
- String aName_ = rtl::OUString::createFromAscii( p->pName );
+ OUString aName_ = rtl::OUString::createFromAscii( p->pName );
SbxClassType eCT = SbxCLASS_OBJECT;
if( nType & _PROPERTY )
{
@@ -873,10 +873,12 @@ SbxInfo* SbiStdObject::GetInfo( short nIdx )
for( short i = 0; i < nPar; i++ )
{
p++;
- String aName_ = rtl::OUString::createFromAscii( p->pName );
+ OUString aName_ = rtl::OUString::createFromAscii( p->pName );
sal_uInt16 nFlags_ = ( p->nArgs >> 8 ) & 0x03;
if( p->nArgs & _OPT )
+ {
nFlags_ |= SBX_OPTIONAL;
+ }
pInfo_->AddParam( aName_, p->eType, nFlags_ );
}
return pInfo_;
diff --git a/basic/source/runtime/stdobj1.cxx b/basic/source/runtime/stdobj1.cxx
index 0cd55efb3a6f..6b8f6a9bf7c6 100644
--- a/basic/source/runtime/stdobj1.cxx
+++ b/basic/source/runtime/stdobj1.cxx
@@ -46,7 +46,7 @@ SbStdFactory::SbStdFactory()
{
}
-SbxObject* SbStdFactory::CreateObject( const rtl::OUString& rClassName )
+SbxObject* SbStdFactory::CreateObject( const OUString& rClassName )
{
if( rClassName.equalsIgnoreAsciiCase("Picture") )
return new SbStdPicture;
@@ -115,16 +115,16 @@ void SbStdPicture::PropHeight( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
TYPEINIT1( SbStdPicture, SbxObject );
SbStdPicture::SbStdPicture() :
- SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Picture") ) )
+ SbxObject( OUString("Picture"))
{
// Properties
- SbxVariable* p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Type") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ SbxVariable* p = Make( OUString("Type"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READ | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_TYPE );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Width") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("Width"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READ | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_WIDTH );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Height") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("Height"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READ | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_HEIGHT );
}
@@ -134,7 +134,7 @@ SbStdPicture::~SbStdPicture()
}
-SbxVariable* SbStdPicture::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbStdPicture::Find( const OUString& rName, SbxClassType t )
{
// entered already?
return SbxObject::Find( rName, t );
@@ -218,36 +218,40 @@ void SbStdFont::PropSize( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
void SbStdFont::PropName( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
{
if( bWrite )
- SetFontName( pVar->GetString() );
+ {
+ SetFontName( pVar->GetOUString() );
+ }
else
+ {
pVar->PutString( GetFontName() );
+ }
}
TYPEINIT1( SbStdFont, SbxObject );
SbStdFont::SbStdFont() :
- SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Font") ) )
+ SbxObject( OUString("Font") )
{
// Properties
- SbxVariable* p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Bold") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ SbxVariable* p = Make( OUString("Bold"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_BOLD );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Italic") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("Italic"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_ITALIC );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("StrikeThrough") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("StrikeThrough"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_STRIKETHROUGH );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Underline") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("Underline"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_UNDERLINE );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Size") ), SbxCLASS_PROPERTY, SbxVARIANT );
+ p = Make( OUString("Size"), SbxCLASS_PROPERTY, SbxVARIANT );
p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
p->SetUserData( ATTR_IMP_SIZE );
// handle name property yourself
- p = Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
+ p = Find( OUString("Name"), SbxCLASS_PROPERTY );
DBG_ASSERT( p, "Keine Name Property" );
p->SetUserData( ATTR_IMP_NAME );
}
@@ -257,7 +261,7 @@ SbStdFont::~SbStdFont()
}
-SbxVariable* SbStdFont::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbStdFont::Find( const OUString& rName, SbxClassType t )
{
return SbxObject::Find( rName, t );
}
@@ -356,7 +360,7 @@ void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
return;
}
- pVar->PutString( String() );
+ pVar->PutString( OUString() );
}
void SbStdClipboard::MethSetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
@@ -394,29 +398,29 @@ void SbStdClipboard::MethSetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
TYPEINIT1( SbStdClipboard, SbxObject );
SbStdClipboard::SbStdClipboard() :
- SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Clipboard") ) )
+ SbxObject( OUString("Clipboard") )
{
- SbxVariable* p = Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
+ SbxVariable* p = Find( OUString("Name"), SbxCLASS_PROPERTY );
DBG_ASSERT( p, "Keine Name Property" );
p->SetUserData( ATTR_IMP_NAME );
// register methods
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Clear") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("Clear"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_CLEAR );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetData") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("GetData"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_GETDATA );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetFormat") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("GetFormat"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_GETFORMAT );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetText") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("GetText"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_GETTEXT );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("SetData") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("SetData"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_SETDATA );
- p = Make( String( RTL_CONSTASCII_USTRINGPARAM("SetText") ), SbxCLASS_METHOD, SbxEMPTY );
+ p = Make( OUString("SetText"), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE );
p->SetUserData( METH_SETTEXT );
}
@@ -426,7 +430,7 @@ SbStdClipboard::~SbStdClipboard()
}
-SbxVariable* SbStdClipboard::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbStdClipboard::Find( const OUString& rName, SbxClassType t )
{
return SbxObject::Find( rName, t );
}
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx
index 9f938eeec268..dc0798499e74 100644
--- a/basic/source/runtime/step0.cxx
+++ b/basic/source/runtime/step0.cxx
@@ -201,75 +201,79 @@ namespace
}
}
- String VBALikeToRegexp(const String &rIn)
+ OUString VBALikeToRegexp(const OUString &rIn)
{
- String sResult;
- const sal_Unicode *start = rIn.GetBuffer();
- const sal_Unicode *end = start + rIn.Len();
+ OUStringBuffer sResult;
+ const sal_Unicode *start = rIn.getStr();
+ const sal_Unicode *end = start + rIn.getLength();
int seenright = 0;
- sResult.Append('^');
+ sResult.append('^');
while (start < end)
{
switch (*start)
{
- case '?':
- sResult.Append('.');
- start++;
- break;
- case '*':
- sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM(".*")));
- start++;
- break;
- case '#':
- sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM("[0-9]")));
- start++;
- break;
- case ']':
- sResult.Append('\\');
- sResult.Append(*start++);
- break;
- case '[':
- sResult.Append(*start++);
- seenright = 0;
- while (start < end && !seenright)
+ 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)
+ {
+ switch (*start)
{
- switch (*start)
+ case '[':
+ case '?':
+ case '*':
+ sResult.append('\\');
+ sResult.append(*start);
+ break;
+ case ']':
+ sResult.append(*start);
+ seenright = 1;
+ break;
+ case '!':
+ sResult.append('^');
+ break;
+ default:
+ if (NeedEsc(*start))
{
- 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);
- break;
+ sResult.append('\\');
}
- start++;
+ sResult.append(*start);
+ break;
}
- break;
- default:
- if (NeedEsc(*start))
- sResult.Append('\\');
- sResult.Append(*start++);
+ start++;
+ }
+ break;
+ default:
+ if (NeedEsc(*start))
+ {
+ sResult.append('\\');
+ }
+ sResult.append(*start++);
}
}
- sResult.Append('$');
+ sResult.append('$');
- return sResult;
+ return sResult.makeStringAndClear();
}
}
@@ -278,8 +282,8 @@ void SbiRuntime::StepLIKE()
SbxVariableRef refVar1 = PopVar();
SbxVariableRef refVar2 = PopVar();
- String pattern = VBALikeToRegexp(refVar1->GetString());
- String value = refVar2->GetString();
+ OUString pattern = VBALikeToRegexp(refVar1->GetOUString());
+ OUString value = refVar2->GetOUString();
com::sun::star::util::SearchOptions aSearchOpt;
@@ -300,7 +304,7 @@ void SbiRuntime::StepLIKE()
}
SbxVariable* pRes = new SbxVariable;
utl::TextSearch aSearch(aSearchOpt);
- xub_StrLen nStart=0, nEnd=value.Len();
+ sal_uInt16 nStart=0, nEnd=value.getLength();
int bRes = aSearch.SearchFrwrd(value, &nStart, &nEnd);
pRes->PutBool( bRes != 0 );
@@ -390,8 +394,8 @@ inline bool checkUnoStructCopy( bool bVBA, SbxVariableRef& refVal, SbxVariableRe
if ( ( !pUnoVal && !pUnoStructVal ) )
return false;
- String sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName();
- String sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName();
+ OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName();
+ OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName();
if ( pUnoStructObj )
{
@@ -633,7 +637,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
if( pUnoObj != NULL )
{
Any aControlAny = pUnoObj->getUnoAny();
- String aDeclareClassName = refVar->GetDeclareClassName();
+ OUString aDeclareClassName = refVar->GetDeclareClassName();
OUString aVBAType = aDeclareClassName;
OUString aPrefix = refVar->GetName();
SbxObjectRef xScopeObj = refVar->GetParent();
@@ -696,7 +700,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
SbxObject* pValObj = PTR_CAST(SbxObject,pValObjBase);
if( pValObj != NULL )
{
- String aObjClass = pValObj->GetClassName();
+ OUString aObjClass = pValObj->GetClassName();
SbClassModuleObject* pClassModuleObj = PTR_CAST(SbClassModuleObject,pValObjBase);
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
@@ -706,7 +710,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
rDimAsNewRecoverHash[refVar] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule );
}
- else if( aObjClass.EqualsIgnoreCaseAscii( "Collection" ) )
+ else if( aObjClass.equalsIgnoreAsciiCase( "Collection" ) )
{
rDimAsNewRecoverHash[refVar] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), NULL );
@@ -753,13 +757,15 @@ void SbiRuntime::StepLSET()
{
sal_uInt16 n = refVar->GetFlags();
if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
+ {
refVar->SetFlag( SBX_WRITE );
- String aRefVarString = refVar->GetString();
- String aRefValString = refVal->GetString();
+ }
+ OUString aRefVarString = refVar->GetOUString();
+ OUString aRefValString = refVal->GetOUString();
- sal_uInt16 nVarStrLen = aRefVarString.Len();
- sal_uInt16 nValStrLen = aRefValString.Len();
- rtl::OUStringBuffer aNewStr;
+ sal_Int32 nVarStrLen = aRefVarString.getLength();
+ sal_Int32 nValStrLen = aRefValString.getLength();
+ OUStringBuffer aNewStr;
if( nVarStrLen > nValStrLen )
{
aNewStr.append(aRefValString);
@@ -767,7 +773,7 @@ void SbiRuntime::StepLSET()
}
else
{
- aNewStr.append(aRefValString.Copy(0, nVarStrLen));
+ aNewStr = aRefValString.copy( 0, nVarStrLen );
}
refVar->PutString(aNewStr.makeStringAndClear());
@@ -787,13 +793,15 @@ void SbiRuntime::StepRSET()
{
sal_uInt16 n = refVar->GetFlags();
if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
+ {
refVar->SetFlag( SBX_WRITE );
- String aRefVarString = refVar->GetString();
- String aRefValString = refVal->GetString();
+ }
+ OUString aRefVarString = refVar->GetOUString();
+ OUString aRefValString = refVal->GetOUString();
+ sal_Int32 nVarStrLen = aRefVarString.getLength();
+ sal_Int32 nValStrLen = aRefValString.getLength();
- sal_uInt16 nVarStrLen = aRefVarString.Len();
- sal_uInt16 nValStrLen = aRefValString.Len();
- rtl::OUStringBuffer aNewStr;
+ OUStringBuffer aNewStr(nVarStrLen);
if (nVarStrLen > nValStrLen)
{
comphelper::string::padToLength(aNewStr, nVarStrLen - nValStrLen, ' ');
@@ -801,7 +809,7 @@ void SbiRuntime::StepRSET()
}
else
{
- aNewStr.append(aRefValString.Copy(0, nVarStrLen));
+ aNewStr.append(aRefValString.copy(0, nVarStrLen));
}
refVar->PutString(aNewStr.makeStringAndClear());
@@ -1161,10 +1169,10 @@ void SbiRuntime::StepARGV()
// Input to Variable. The variable is on TOS and is
// is removed afterwards.
-
void SbiRuntime::StepINPUT()
{
- String s;
+ OUStringBuffer sin = "";
+ OUString s;
char ch = 0;
SbError err;
// Skip whitespace
@@ -1195,8 +1203,10 @@ void SbiRuntime::StepINPUT()
}
}
else if( !sep && (ch == ',' || ch == '\n') )
+ {
break;
- s += ch;
+ }
+ sin.append( ch );
ch = pIosys->Read();
}
// skip whitespace
@@ -1214,6 +1224,7 @@ void SbiRuntime::StepINPUT()
}
if( !err )
{
+ s = sin.makeStringAndClear();
SbxVariableRef pVar = GetTOS();
// try to fill the variable with a numeric value first,
// then with a string value
@@ -1226,12 +1237,12 @@ void SbiRuntime::StepINPUT()
SbxBase::ResetError();
}
// the value has to be scanned in completely
- else if( nLen != s.Len() && !pVar->PutString( s ) )
+ else if( nLen != s.getLength() && !pVar->PutString( s ) )
{
err = SbxBase::GetError();
SbxBase::ResetError();
}
- else if( nLen != s.Len() && pVar->IsNumeric() )
+ else if( nLen != s.getLength() && pVar->IsNumeric() )
{
err = SbxBase::GetError();
SbxBase::ResetError();
@@ -1344,7 +1355,7 @@ void SbiRuntime::StepENDCASE()
void SbiRuntime::StepSTDERROR()
{
pError = NULL; bError = true;
- pInst->aErrorMsg = String();
+ pInst->aErrorMsg = OUString();
pInst->nErr = 0L;
pInst->nErl = 0;
nError = 0L;
@@ -1353,7 +1364,7 @@ void SbiRuntime::StepSTDERROR()
void SbiRuntime::StepNOERROR()
{
- pInst->aErrorMsg = String();
+ pInst->aErrorMsg = OUString();
pInst->nErr = 0L;
pInst->nErl = 0;
nError = 0L;
@@ -1389,12 +1400,14 @@ void SbiRuntime::StepCHANNEL0()
void SbiRuntime::StepPRINT() // print TOS
{
SbxVariableRef p = PopVar();
- String s1 = p->GetString();
- String s;
+ OUString s1 = p->GetOUString();
+ OUString s;
if( p->GetType() >= SbxINTEGER && p->GetType() <= SbxDOUBLE )
- s = ' '; // one blank before
+ {
+ s = " "; // one blank before
+ }
s += s1;
- rtl::OString aByteStr(rtl::OUStringToOString(s, osl_getThreadTextEncoding()));
+ OString aByteStr(rtl::OUStringToOString(s, osl_getThreadTextEncoding()));
pIosys->Write( aByteStr );
Error( pIosys->GetError() );
}
@@ -1402,7 +1415,7 @@ void SbiRuntime::StepPRINT() // print TOS
void SbiRuntime::StepPRINTF() // print TOS in field
{
SbxVariableRef p = PopVar();
- OUString s1 = p->GetString();
+ OUString s1 = p->GetOUString();
OUStringBuffer s;
if( p->GetType() >= SbxINTEGER && p->GetType() <= SbxDOUBLE )
{
@@ -1428,13 +1441,17 @@ void SbiRuntime::StepWRITE() // write TOS
case SbxDATE: ch = '#'; break;
default: break;
}
- String s;
+ OUString s;
if( ch )
- s += ch;
- s += p->GetString();
+ {
+ s += OUString(ch);
+ }
+ s += p->GetOUString();
if( ch )
- s += ch;
- rtl::OString aByteStr(rtl::OUStringToOString(s, osl_getThreadTextEncoding()));
+ {
+ s += OUString(ch);
+ }
+ OString aByteStr(rtl::OUStringToOString(s, osl_getThreadTextEncoding()));
pIosys->Write( aByteStr );
Error( pIosys->GetError() );
}
@@ -1443,8 +1460,8 @@ void SbiRuntime::StepRENAME() // Rename Tos+1 to Tos
{
SbxVariableRef pTos1 = PopVar();
SbxVariableRef pTos = PopVar();
- String aDest = pTos1->GetString();
- String aSource = pTos->GetString();
+ OUString aDest = pTos1->GetOUString();
+ OUString aSource = pTos->GetOUString();
if( hasUno() )
{
@@ -1461,7 +1478,7 @@ void SbiRuntime::StepRENAME() // Rename Tos+1 to Tos
void SbiRuntime::StepPROMPT()
{
SbxVariableRef p = PopVar();
- rtl::OString aStr(rtl::OUStringToOString(p->GetString(), osl_getThreadTextEncoding()));
+ rtl::OString aStr(rtl::OUStringToOString(p->GetOUString(), osl_getThreadTextEncoding()));
pIosys->SetPrompt( aStr );
}
diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index 841fbe25202f..0f6c07bd2b67 100644
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -327,7 +327,7 @@ SbxBase* SbiRuntime::FindElementExtern( const OUString& rName )
const SbxParamInfo* pParam = pInfo->GetParam( j );
while( pParam )
{
- if( pParam->aName.EqualsIgnoreCaseAscii( rName ) )
+ if( pParam->aName.equalsIgnoreAsciiCase( rName ) )
{
if( j >= nParamCount )
{
@@ -372,7 +372,7 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
sal_uInt16 nArgCount = refArgv->Count();
for( i = 1 ; i < nArgCount ; i++ )
{
- if( refArgv->GetAlias( i ).Len() )
+ if( !refArgv->GetAlias(i).isEmpty() )
{
bHasNamed = true; break;
}
@@ -470,7 +470,7 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
const SbxParamInfo* pParam = pInfo->GetParam( j );
while( pParam )
{
- if( pParam->aName.EqualsIgnoreCaseAscii( rName ) )
+ if( pParam->aName.equalsIgnoreAsciiCase( rName ) )
{
nCurPar = j;
break;
@@ -664,8 +664,8 @@ void SbiRuntime::StepRTL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
PushVar( FindElement( rBasic.pRtl, nOp1, nOp2, SbERR_PROC_UNDEFINED, false ) );
}
-void
-SbiRuntime::StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError nNotFound, bool bLocal, bool bStatic )
+void SbiRuntime::StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2,
+ SbError nNotFound, bool bLocal, bool bStatic )
{
if( !refLocals )
{
@@ -782,8 +782,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
if( pParam && ( (pParam->nFlags & SBX_OPTIONAL) != 0 ) )
{
// Default value?
- sal_uInt16 nDefaultId = sal::static_int_cast< sal_uInt16 >(
- pParam->nUserData & 0xffff );
+ sal_uInt16 nDefaultId = (sal_uInt16)(pParam->nUserData & 0x0ffff);
if( nDefaultId > 0 )
{
OUString aDefaultStr = pImg->GetString( nDefaultId );
@@ -980,7 +979,7 @@ void SbiRuntime::StepOPEN( sal_uInt32 nOp1, sal_uInt32 nOp2 )
SbxVariableRef pLen = PopVar();
short nBlkLen = pLen->GetInteger();
short nChan = pChan->GetInteger();
- OString aName(rtl::OUStringToOString(pName->GetString(), osl_getThreadTextEncoding()));
+ OString aName(rtl::OUStringToOString(pName->GetOUString(), osl_getThreadTextEncoding()));
pIosys->Open( nChan, aName, static_cast<short>( nOp1 ),
static_cast<short>( nOp2 ), nBlkLen );
Error( pIosys->GetError() );
@@ -1190,7 +1189,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
- rtl::OUStringBuffer aBuf;
+ OUStringBuffer aBuf;
comphelper::string::padToLength(aBuf, nCount, 0);
pVar->PutString(aBuf.makeStringAndClear());
}