diff options
Diffstat (limited to 'wizards/source/access2base/Utils.xba')
-rw-r--r-- | wizards/source/access2base/Utils.xba | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba index 583348b096a8..6028df496253 100644 --- a/wizards/source/access2base/Utils.xba +++ b/wizards/source/access2base/Utils.xba @@ -146,7 +146,7 @@ Const cstByteLength = 25 sArg = "[ARRAY]" Else ' One-dimension arrays only For i = LBound(pvArg) To UBound(pvArg) - sArg = sArg & Utils._CStr(pvArg(i)) & ";" ' Recursive call + sArg = sArg & Utils._CStr(pvArg(i), pbShort) & ";" ' Recursive call Next i If Len(sArg) > 1 Then sArg = Left(sArg, Len(sArg) - 1) End If @@ -205,10 +205,11 @@ Const cstByteLength = 25 End Function ' CStr V0.9.5 REM ----------------------------------------------------------------------------------------------------------------------- -Public Function _CVar(ByRef psArg As String) As Variant +Public Function _CVar(ByRef psArg As String, ByVal Optional pbStrDate As Boolean) As Variant ' psArg is presumed an output of _CStr (stored in the mean time in a text file f.i.) ' _CVar returns the corresponding original variant variable or Null/Nothing if not possible ' Return values may of types Array, Long, Double, Date, Boolean, String, Null or Empty +' pbStrDate = True keeps dates as strings Dim cstEscape1 As String, cstEscape2 As String, vEMPTY As Variant cstEscape1 = Chr(14) ' Form feed used as temporary escape character for \\ @@ -218,6 +219,7 @@ Dim cstEscape1 As String, cstEscape2 As String, vEMPTY As Variant If Len(psArg) = 0 Then Exit Function Dim sArg As String, vArgs() As Variant, vVars() As Variant, i As Integer + If IsMissing(pbStrDate) Then pbStrDate = False sArg = Replace( _ Replace( _ Replace( _ @@ -232,7 +234,7 @@ Dim sArg As String, vArgs() As Variant, vVars() As Variant, i As Integer vVars = Array() Redim vVars(LBound(vArgs) To UBound(vArgs)) For i = LBound(vVars) To UBound(vVars) - vVars(i) = _CVar(vArgs(i)) + vVars(i) = _CVar(vArgs(i), pbStrDate) Next i _CVar = vVars Exit Function @@ -245,14 +247,15 @@ Dim sArg As String, vArgs() As Variant, vVars() As Variant, i As Integer Case sArg = "[OBJECT]" : _CVar = Nothing Case sArg = "[TRUE]" : _CVar = True Case sArg = "[FALSE]" : _CVar = False - Case IsDate(sArg) : _CVar = CDate(sArg) + Case IsDate(sArg) + If pbStrDate Then _CVar = sArg Else _CVar = CDate(sArg) Case IsNumeric(sArg) If InStr(sArg, ".") > 0 Then _CVar = Val(sArg) Else _CVar = CLng(Val(sArg)) ' Val always returns a double End If - Case _RegexSearch(sArg, "^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$" <> "" + Case _RegexSearch(sArg, "^[-+]?[0-9]*\.?[0-9]+(e[-+]?[0-9]+)?$") <> "" _CVar = Val(sArg) ' Scientific notation Case Else : _CVar = Replace(Replace(sArg, cstEscape1, "\"), cstEscape2, ";") End Select @@ -914,6 +917,7 @@ Function _RegexSearch(ByRef psString As String _ , ByVal psRegex As String _ , Optional ByRef plStart As Long _ ) As String +' Search is not case-sensitive ' Return "" if regex not found, otherwise returns the matching string ' plStart = start position of psString to search (starts at 1) ' In output plStart contains the first position of the matching string @@ -929,9 +933,11 @@ Dim lEnd As Long .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP .searchFlag = 0 .searchString = psRegex ' Pattern to be searched + .transliterateFlags = com.sun.star.i18n.TransliterationModules.IGNORE_CASE End With oTextSearch.setOptions(vOptions) If IsMissing(plStart) Then plStart = 1 + If plStart <= 0 Then Exit Function lEnd = Len(psString) vResult = oTextSearch.searchForward(psString, plStart - 1, lEnd) With vResult @@ -939,6 +945,8 @@ Dim lEnd As Long plStart = .startOffset(0) + 1 lEnd = .endOffset(0) + 1 _RegexSearch = Mid(psString, plStart, lEnd - plStart) + Else + plStart = 0 End If End With |