wizards/source/scriptforge/SF_Array.xba | 12 ++++++------ wizards/source/scriptforge/SF_Exception.xba | 3 +-- wizards/source/scriptforge/SF_FileSystem.xba | 4 ++-- wizards/source/scriptforge/SF_Root.xba | 6 ------ wizards/source/scriptforge/SF_Utils.xba | 14 +++++--------- wizards/source/sfdatabases/SF_Database.xba | 8 ++++---- wizards/source/sfdatabases/SF_Dataset.xba | 16 ++++++++-------- wizards/source/sfdialogs/SF_Dialog.xba | 4 ++-- wizards/source/sfdocuments/SF_Base.xba | 18 +++++++++--------- wizards/source/sfdocuments/SF_Calc.xba | 12 ++++++------ wizards/source/sfdocuments/SF_Document.xba | 2 +- wizards/source/sfdocuments/SF_Form.xba | 2 +- wizards/source/sfdocuments/SF_FormControl.xba | 6 +++--- wizards/source/sfdocuments/SF_Writer.xba | 4 ++-- 14 files changed, 50 insertions(+), 61 deletions(-)
New commits: commit 2f9a4a80c04b2ef0586bf017ddf044e8c965bd19 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Wed Aug 28 14:38:25 2024 +0200 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Thu Aug 29 10:01:17 2024 +0200 ScriptForge (SF_Utils._Valudate) Improve robustness All arguments passed to ScriptForge methods are checked for validity. A.o. a string may be compared with a closed list of allowed values. The comparison may now optionally be made with a CaseSentitive As Boolean parameter. All occurrences where this check makes sense were identified, inventoried and modified. A True argument has been inserted where appropriate. Change-Id: I1a5cb7fb42618bc83fc8ec57c2727fc2a1bfcdb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172530 Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins diff --git a/wizards/source/scriptforge/SF_Array.xba b/wizards/source/scriptforge/SF_Array.xba index c0c9a21827e4..50257829755f 100644 --- a/wizards/source/scriptforge/SF_Array.xba +++ b/wizards/source/scriptforge/SF_Array.xba @@ -324,7 +324,7 @@ Check: End If Try: - bContains = SF_Array._FindItem(Array_1D, ToFind, CaseSensitive, SortOrder)(0) + bContains = SF_Array._FindItem(Array_1D, ToFind, CaseSensitive, UCase(SortOrder))(0) Finally: Contains = bContains @@ -1034,7 +1034,7 @@ Check: End If Try: - vFindItem = SF_Array._FindItem(Array_1D, ToFind, CaseSensitive, SortOrder) + vFindItem = SF_Array._FindItem(Array_1D, ToFind, CaseSensitive, UCase(SortOrder)) If vFindItem(0) = True Then lIndex = vFindItem(1) Else lIndex = LBound(Array_1D) - 1 Finally: @@ -1160,7 +1160,7 @@ Check: Try: lMin = LBound(Array_1D) lMax = UBound(Array_1D) - lIndex = SF_Array._FindItem(Array_1D, Item, CaseSensitive, SortOrder)(1) + lIndex = SF_Array._FindItem(Array_1D, Item, CaseSensitive, UCase(SortOrder))(1) vSorted = SF_Array.Insert(Array_1D, lIndex, Item) Finally: @@ -1884,7 +1884,7 @@ Try: lMin = LBound(Array_1D) lMax = UBound(Array_1D) If lMax < lMin Then GoTo Finally ' Do nothing if the input array is empty - vIndexes() = SF_Array._HeapSort(Array_1D, ( SortOrder = "ASC" ), CaseSensitive) + vIndexes() = SF_Array._HeapSort(Array_1D, ( UCase(SortOrder) = "ASC" ), CaseSensitive) ' Load output array ReDim vSort(lMin To lMax) @@ -1955,7 +1955,7 @@ Try: ' Extract and sort the RowIndex-th row vRow = SF_Array.ExtractRow(Array_2D, RowIndex) If Not SF_Utils._ValidateArray(vRow, "Row #" & CStr(RowIndex), 1, 0) Then GoTo Finally - vIndexes() = SF_Array._HeapSort(vRow, ( SortOrder = "ASC" ), CaseSensitive) + vIndexes() = SF_Array._HeapSort(vRow, ( UCase(SortOrder) = "ASC" ), CaseSensitive) ' Load output array ReDim vSort(lMin1 To lMax1, lMin2 To lMax2) @@ -2032,7 +2032,7 @@ Try: ' Extract and sort the ColumnIndex-th column vCol = SF_Array.ExtractColumn(Array_2D, ColumnIndex) If Not SF_Utils._ValidateArray(vCol, "Column #" & CStr(ColumnIndex), 1, 0) Then GoTo Finally - vIndexes() = SF_Array._HeapSort(vCol, ( SortOrder = "ASC" ), CaseSensitive) + vIndexes() = SF_Array._HeapSort(vCol, ( UCase(SortOrder) = "ASC" ), CaseSensitive) ' Load output array ReDim vSort(lMin1 To lMax1, lMin2 To lMax2) diff --git a/wizards/source/scriptforge/SF_Exception.xba b/wizards/source/scriptforge/SF_Exception.xba index f15941f70f21..02259ffc329b 100644 --- a/wizards/source/scriptforge/SF_Exception.xba +++ b/wizards/source/scriptforge/SF_Exception.xba @@ -809,14 +809,13 @@ Try: sMessage = sLocation _ & " " & " " & " " & .GetText("VALIDATEERROR", pvArgs(0)) _ & " " & " " & .GetText("VALIDATEMISSING", pvArgs(0)) - Case ARGUMENTERROR ' SF_Utils._Validate(Value, Name, Types, Values, Regex, Class) + Case ARGUMENTERROR ' SF_Utils._Validate(Value, Name, Types, Values, CaseSensitive, Class) pvArgs(1) = _RightCase(pvArgs(1)) sMessage = sLocation _ & " " & " " & " " & .GetText("VALIDATEERROR", pvArgs(1)) _ & " " & " " & .GetText("VALIDATIONRULES") If Len(pvArgs(2)) > 0 Then sMessage = sMessage & " " & .GetText("VALIDATETYPES", pvArgs(1), pvArgs(2)) If Len(pvArgs(3)) > 0 Then sMessage = sMessage & " " & .GetText("VALIDATEVALUES", pvArgs(1), pvArgs(3)) - If Len(pvArgs(4)) > 0 Then sMessage = sMessage & " " & .GetText("VALIDATEREGEX", pvArgs(1), pvArgs(4)) If Len(pvArgs(5)) > 0 Then sMessage = sMessage & " " & .GetText("VALIDATECLASS", pvArgs(1), pvArgs(5)) sMessage = sMessage & " " & " " & .GetText("VALIDATEACTUAL", pvArgs(1), pvArgs(0)) Case ARRAYERROR ' SF_Utils._ValidateArray(Value, Name, Dimensions, Types, NotNull) diff --git a/wizards/source/scriptforge/SF_FileSystem.xba b/wizards/source/scriptforge/SF_FileSystem.xba index e37d4d3dcec6..ba1838a12f75 100644 --- a/wizards/source/scriptforge/SF_FileSystem.xba +++ b/wizards/source/scriptforge/SF_FileSystem.xba @@ -709,7 +709,7 @@ Const cstSubArgs = "Extension" Check: If IsEmpty(vExtensions) Then vExtensions = SF_Platform.Extensions If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not SF_Utils._Validate(Extension, "Extension", V_STRING, vExtensions) Then GoTo Finally + If Not SF_Utils._Validate(Extension, "Extension", V_STRING, vExtensions, True) Then GoTo Finally End If Try: @@ -1634,7 +1634,7 @@ Check: Try: ' Derive numeric equivalent of the Mode argument: https://api.libreoffice.org/docs/idl/ref/TemplateDescription_8idl.html With com.sun.star.ui.dialogs.TemplateDescription - If Mode = "OPEN" Then iMode = .FILEOPEN_SIMPLE Else iMode = .FILESAVE_AUTOEXTENSION + If UCase(Mode) = "OPEN" Then iMode = .FILEOPEN_SIMPLE Else iMode = .FILESAVE_AUTOEXTENSION End With ' Activate the filepicker dialog diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba index 45c85f3d6209..63aaf6bdb05a 100644 --- a/wizards/source/scriptforge/SF_Root.xba +++ b/wizards/source/scriptforge/SF_Root.xba @@ -396,12 +396,6 @@ Try: & "%1: Wrong argument name " _ & "%2: Comma separated list of allowed values" _ ) - .AddText( Context := "VALIDATEREGEX" _ - , MsgId := " « %1 » must match next regular expression : %2" _ - , Comment := "SF_Utils._Validate error message " _ - & "%1: Wrong argument name " _ - & "%2: A regular expression" _ - ) .AddText( Context := "VALIDATECLASS" _ , MsgId := " « %1 » must be a Basic object of class : %2" _ , Comment := "SF_Utils._Validate error message " _ diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba index c3c78c591f07..323978db2211 100644 --- a/wizards/source/scriptforge/SF_Utils.xba +++ b/wizards/source/scriptforge/SF_Utils.xba @@ -728,7 +728,7 @@ Public Function _Validate(Optional ByRef pvArgument As Variant _ , ByVal psName As String _ , Optional ByVal pvTypes As Variant _ , Optional ByVal pvValues As Variant _ - , Optional ByVal pvRegex As Variant _ + , Optional ByVal pvCaseSensitive As Variant _ , Optional ByVal pvObjectType As Variant _ ) As Boolean ''' Validate the arguments set by user scripts @@ -739,7 +739,7 @@ Public Function _Validate(Optional ByRef pvArgument As Variant _ ''' psName: the documented name of the argument (can be inserted in an error message) ''' pvTypes: array of allowed VarTypes ''' pvValues: array of allowed values -''' pvRegex: regular expression to comply with +''' pvCaseSensitive: when True the comparison between strings is done case-sensitively ''' pvObjectType: mandatory Basic class ''' Return: True if validation OK ''' Otherwise an error is raised @@ -759,7 +759,7 @@ Const cstMaxValues = 10 ' Maximum number of allowed items to list in an er Try: bValid = True If IsMissing(pvArgument) Then GoTo CatchMissing - If IsMissing(pvRegex) Or IsEmpty(pvRegex) Then pvRegex = "" + If IsMissing(pvCaseSensitive) Or IsEmpty(pvCaseSensitive) Then pvCaseSensitive = False If IsMissing(pvObjectType) Or IsEmpty(pvObjectType) Then pvObjectType = "" iVarType = SF_Utils._VarTypeExt(pvArgument) @@ -776,11 +776,7 @@ Try: ' Check if argument's value is valid If bValid And Not IsMissing(pvValues) Then If Not IsArray(pvValues) Then pvValues = Array(pvValues) - bValid = SF_Array.Contains(pvValues, pvArgument, CaseSensitive := False) - End If - ' Check regular expression - If bValid And Len(pvRegex) > 0 And iVarType = V_STRING Then - If Len(pvArgument) > 0 Then bValid = SF_String.IsRegex(pvArgument, pvRegex, CaseSensitive := False) + bValid = SF_Array.Contains(pvValues, pvArgument, CaseSensitive := pvCaseSensitive) End If ' Check instance types If bValid And Len(pvObjectType) > 0 And iVarType = V_OBJECT Then @@ -802,7 +798,7 @@ Try: ''' Actual value: "Ascending" SF_Exception.RaiseFatal(ARGUMENTERROR _ , SF_Utils._Repr(pvArgument, cstMaxLength), psName, SF_Utils._TypeNames(pvTypes) _ - , SF_Utils._ReprValues(pvValues, cstMaxValues), pvRegex, pvObjectType _ + , SF_Utils._ReprValues(pvValues, cstMaxValues), pvCaseSensitive, pvObjectType _ ) End If diff --git a/wizards/source/sfdatabases/SF_Database.xba b/wizards/source/sfdatabases/SF_Database.xba index ff0eafc5b783..39f6d4fa62ca 100644 --- a/wizards/source/sfdatabases/SF_Database.xba +++ b/wizards/source/sfdatabases/SF_Database.xba @@ -597,7 +597,7 @@ Check: If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then vFormNames = Split(_CollectFormDocuments(oFormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames, True) Then GoTo Finally End If Try: @@ -641,7 +641,7 @@ Const cstSubArgs = "QueryName" Check: If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(QueryName, "QueryName", V_STRING, Queries) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(QueryName, "QueryName", V_STRING, Queries, True) Then GoTo Finally End If Try: @@ -718,7 +718,7 @@ Const cstSubArgs = "TableName" Check: If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(TableName, "TableName", V_STRING, Tables) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(TableName, "TableName", V_STRING, Tables, True) Then GoTo Finally End If Try: @@ -1140,7 +1140,7 @@ Check: If IsMissing(pvOrderClause) Or IsEmpty(pvOrderClause) Then pvOrderClause = "" If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then If Not ScriptForge.SF_Utils._Validate(pvExpression, "Expression", V_STRING) Then GoTo Finally - If Not ScriptForge.SF_Utils._Validate(pvTableName, "TableName", V_STRING, Tables) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(pvTableName, "TableName", V_STRING, Tables, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(pvCriteria, "Criteria", V_STRING) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(pvOrderClause, "OrderClause", V_STRING) Then GoTo Finally End If diff --git a/wizards/source/sfdatabases/SF_Dataset.xba b/wizards/source/sfdatabases/SF_Dataset.xba index 02b3d35affd9..b888c7f5010a 100644 --- a/wizards/source/sfdatabases/SF_Dataset.xba +++ b/wizards/source/sfdatabases/SF_Dataset.xba @@ -444,7 +444,7 @@ Const cstSubArgs = "FieldName, FileName, [Overwrite=False]" Check: If IsMissing(Overwrite) Or IsEmpty(Overwrite) Then Overwrite = False If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(FieldName, "FieldName", V_STRING, _Fields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(FieldName, "FieldName", V_STRING, _Fields, True) Then GoTo Catch If Not ScriptForge.SF_Utils._ValidateFile(FileName, "FileName") Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Overwrite, "Overwrite", ScriptForge.V_BOOLEAN) Then GoTo Finally End If @@ -657,7 +657,7 @@ Const cstSubArgs = "FieldName" Check: If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(FieldName, "FieldName", V_STRING, _Fields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(FieldName, "FieldName", V_STRING, _Fields, True) Then GoTo Catch End If With _RowSet @@ -747,7 +747,7 @@ Check: sSubArgs = cstSubArgs2 ' Arguments list case ScriptForge.SF_Utils._EnterFunction(cstThisSub, sSubArgs) For i = 0 To UBound(pvArgs) Step 2 - If Not ScriptForge.SF_Utils._Validate(pvArgs(i), "FieldName" & i, V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(pvArgs(i), "FieldName" & i, V_STRING, _UpdatableFields, True) Then GoTo Catch Next i End If @@ -772,7 +772,7 @@ Try: If lColIndex >= 0 Then _SetColumnValue(lColIndex, .Item(sKey)) Else ' To force an error - If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields, True) Then GoTo Catch End If Next sKey End With @@ -782,7 +782,7 @@ Try: If lColIndex >= 0 Then If i < UBound(pvArgs) Then _SetColumnValue(lColIndex, pvArgs(i + 1)) Else ' To force an error - If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields, True) Then GoTo Catch End If Next i End If @@ -1176,7 +1176,7 @@ Check: sSubArgs = cstSubArgs2 ' Arguments list case ScriptForge.SF_Utils._EnterFunction(cstThisSub, sSubArgs) For i = 0 To UBound(pvArgs) Step 2 - If Not ScriptForge.SF_Utils._Validate(pvArgs(i), "FieldName" & i, V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(pvArgs(i), "FieldName" & i, V_STRING, _UpdatableFields, True) Then GoTo Catch Next i End If @@ -1194,7 +1194,7 @@ Try: If lColIndex >= 0 Then _SetColumnValue(lColIndex, .Item(sKey)) Else ' To force an error - If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields, True) Then GoTo Catch End If Next sKey End With @@ -1204,7 +1204,7 @@ Try: If lColIndex >= 0 Then If i < UBound(pvArgs) Then _SetColumnValue(lColIndex, pvArgs(i + 1)) Else ' To force an error - If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields) Then GoTo Catch + If Not ScriptForge.SF_Utils._Validate(sKey, "FieldName", V_STRING, _UpdatableFields, True) Then GoTo Catch End If Next i End If diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba index 3951a1ea2658..f044a86db05b 100644 --- a/wizards/source/sfdialogs/SF_Dialog.xba +++ b/wizards/source/sfdialogs/SF_Dialog.xba @@ -603,7 +603,7 @@ Check: If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place := Null) Then GoTo Finally - If Not ScriptForge.SF_Utils._Validate(SourceName, "SourceName", V_String, _DialogModel.getElementNames()) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(SourceName, "SourceName", V_String, _DialogModel.getElementNames(), True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Left, "Left", ScriptForge.V_NUMERIC) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Top, "Top", ScriptForge.V_NUMERIC) Then GoTo Finally @@ -691,7 +691,7 @@ Finally: Catch: GoTo Finally CatchNotFound: - ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _DialogModel.getElementNames()) + ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _DialogModel.getElementNames(), True) GoTo Finally End Function ' SFDialogs.SF_Dialog.Controls diff --git a/wizards/source/sfdocuments/SF_Base.xba b/wizards/source/sfdocuments/SF_Base.xba index c977cb6a29b7..30713e88b587 100644 --- a/wizards/source/sfdocuments/SF_Base.xba +++ b/wizards/source/sfdocuments/SF_Base.xba @@ -163,7 +163,7 @@ Check: ' Build list of available FormDocuments recursively with _CollectFormDocuments If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments() vFormNames = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames, True) Then GoTo Finally End If If Not IsLoaded(FormDocument) Then GoTo Finally @@ -258,7 +258,7 @@ Check: ' Build list of available FormDocuments recursively with _CollectFormDocuments If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments() vFormDocuments = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormDocuments) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormDocuments, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Form, "Form", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally End If If Not IsLoaded(FormDocument) Then GoTo CatchClosed @@ -273,7 +273,7 @@ Try: Forms = vFormNames Else If VarType(Form) = V_STRING Then ' Find the form by name - If Not ScriptForge.SF_Utils._Validate(Form, "Form", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(Form, "Form", V_STRING, vFormNames, True) Then GoTo Finally Set oXForm = oForms.getByName(Form) Else ' Find the form by index If Form < 0 Or Form >= oForms.Count Then GoTo CatchNotFound @@ -420,7 +420,7 @@ Check: If Not _IsStillAlive() Then GoTo Finally ' Build list of available FormDocuments recursively with _CollectFormDocuments vFormNames = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames, True) Then GoTo Finally End If Try: @@ -488,7 +488,7 @@ Check: ' Build list of available FormDocuments recursively with _CollectFormDocuments If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments() vFormNames = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(DesignMode, "DesignMode", ScriptForge.V_BOOLEAN) Then GoTo Finally End If @@ -546,7 +546,7 @@ Check: If IsMissing(DesignMode) Or IsEmpty(DesignMode) Then DesignMode = False vQueries = GetDatabase().Queries ' Includes _IsStillAlive() If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(QueryName, "QueryName", V_STRING, vQueries) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(QueryName, "QueryName", V_STRING, vQueries, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(DesignMode, "DesignMode", ScriptForge.V_BOOLEAN) Then GoTo Finally End If @@ -599,7 +599,7 @@ Check: If IsMissing(DesignMode) Or IsEmpty(DesignMode) Then DesignMode = False vTables = GetDatabase().Tables If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not ScriptForge.SF_Utils._Validate(TableName, "TableName", V_STRING, vTables) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(TableName, "TableName", V_STRING, vTables, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(DesignMode, "DesignMode", ScriptForge.V_BOOLEAN) Then GoTo Finally End If @@ -660,7 +660,7 @@ Check: ' Build list of available FormDocuments recursively with _CollectFormDocuments If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments() vFormNames = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames, True) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Pages, "Pages", V_STRING) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(Copies, "Copies", ScriptForge.V_NUMERIC) Then GoTo Finally End If @@ -741,7 +741,7 @@ Check: ' Build list of available FormDocuments recursively with _CollectFormDocuments If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments() vFormDocuments = Split(_CollectFormDocuments(_FormDocuments), cstToken) - If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormDocuments) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormDocuments, True) Then GoTo Finally End If If Not IsLoaded(FormDocument) Then GoTo CatchClosed diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index aa3e125731db..b917b36a85fa 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -532,7 +532,7 @@ Try: ' Raise error when chart not found If Len(ChartName) > 0 And IsNull(oChart) Then - If Not ScriptForge.SF_Utils._Validate(ChartName, "ChartName", V_STRING, vCharts) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(ChartName, "ChartName", V_STRING, vCharts, True) Then GoTo Finally End If Finally: @@ -1332,7 +1332,7 @@ Try: For i = 0 To UBound(vRows) sField = vRows(i) If Len(sField) > 0 Then - If Not ScriptForge.SF_Utils._Validate(sField, "RowFields", V_STRING, vHeaders) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(sField, "RowFields", V_STRING, vHeaders, True) Then GoTo Finally Set oField = oFields.getByName(sField) oField.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.ROW End If @@ -1342,7 +1342,7 @@ Try: For i = 0 To UBound(vColumns) sField = vColumns(i) If Len(sField) > 0 Then - If Not ScriptForge.SF_Utils._Validate(sField, "ColumnFields", V_STRING, vHeaders) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(sField, "ColumnFields", V_STRING, vHeaders, True) Then GoTo Finally Set oField = oFields.getByName(sField) oField.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.COLUMN End If @@ -1358,7 +1358,7 @@ Try: If UBound(vDataField) > 0 Then sFunction = vDataField(1) Else sFunction = "" ' Define field properties If Len(sField) > 0 Then - If Not ScriptForge.SF_Utils._Validate(sField, "DataFields", V_STRING, vHeaders) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(sField, "DataFields", V_STRING, vHeaders, True) Then GoTo Finally Set oField = oFields.getByName(sField) oField.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.DATA ' Associate the correct function @@ -1654,7 +1654,7 @@ Try: Forms = vFormNames Else If VarType(Form) = V_STRING Then ' Find the form by name - If Not ScriptForge.SF_Utils._Validate(Form, "Form", V_STRING, vFormNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(Form, "Form", V_STRING, vFormNames, True) Then GoTo Finally Set oXForm = oForms.getByName(Form) Else ' Find the form by index If Form < 0 Or Form >= oForms.Count Then GoTo CatchNotFound @@ -2891,7 +2891,7 @@ Check: ' Check that the given style really exists Set oStyleFamilies = _Component.StyleFamilies If oStyleFamilies.hasByName(cstStyle) Then vStyles = oStyleFamilies.getByName(cstStyle).getElementNames() Else vStyles = Array() - If Not ScriptForge.SF_Utils._Validate(Style, "Style", V_STRING, vStyles) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(Style, "Style", V_STRING, vStyles, True) Then GoTo Finally ' Filter formula If Not ScriptForge.SF_Utils._Validate(FilterFormula, "FilterFormula", V_STRING) Then GoTo Finally If Len(FilterFormula) > 0 Then diff --git a/wizards/source/sfdocuments/SF_Document.xba b/wizards/source/sfdocuments/SF_Document.xba index 230be6248a10..2b80dd4cb5d6 100644 --- a/wizards/source/sfdocuments/SF_Document.xba +++ b/wizards/source/sfdocuments/SF_Document.xba @@ -1432,7 +1432,7 @@ Check: If VarType(Printer) = V_STRING Then vPrinters = ScriptForge.SF_Platform.Printers If Len(Printer) > 0 Then - If Not ScriptForge.SF_Utils._Validate(Printer, "Printer", V_STRING, vPrinters) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(Printer, "Printer", V_STRING, vPrinters, True) Then GoTo Finally End If Else If Not ScriptForge.SF_Utils._Validate(Printer, "Printer", V_STRING) Then GoTo Finally ' Manage here the VarType error diff --git a/wizards/source/sfdocuments/SF_Form.xba b/wizards/source/sfdocuments/SF_Form.xba index a5559ae06a8a..ef5907a8d723 100644 --- a/wizards/source/sfdocuments/SF_Form.xba +++ b/wizards/source/sfdocuments/SF_Form.xba @@ -652,7 +652,7 @@ Finally: Catch: GoTo Finally CatchNotFound: - ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _Form.getElementNames()) + ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _Form.getElementNames(), True) GoTo Finally End Function ' SFDocuments.SF_Form.Controls diff --git a/wizards/source/sfdocuments/SF_FormControl.xba b/wizards/source/sfdocuments/SF_FormControl.xba index 180cb682b381..c1f83a03832a 100644 --- a/wizards/source/sfdocuments/SF_FormControl.xba +++ b/wizards/source/sfdocuments/SF_FormControl.xba @@ -747,7 +747,7 @@ Finally: Catch: GoTo Finally CatchNotFound: - ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _ControlModel.getElementNames()) + ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _ControlModel.getElementNames(), True) GoTo Finally End Function ' SFDocuments.SF_FormControl.Controls @@ -1660,7 +1660,7 @@ Const cstSubArgs = "Value" , .TABLEFIELDS Set oDatabase = _ParentForm.GetDatabase() If _ControlModel.ListSourceType = .QUERY Then vList = oDatabase.Queries Else vList = oDatabase.Tables - If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING, vList) Then Goto Finally + If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING, vList, True) Then Goto Finally If _ControlType = CTLCOMBOBOX Then _ControlModel.ListSource = pvValue Else _ControlModel.ListSource = Array(pvValue) _ControlModel.refresh() Case .SQL @@ -1777,7 +1777,7 @@ Const cstSubArgs = "Value" Case CTLCOMBOBOX If oSession.HasUnoProperty(_ControlModel, "Text") And oSession.HasUnoProperty(_ControlModel, "StringItemList") Then If pvValue <> "" Then - If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", V_STRING, _ControlModel.StringItemList) Then Goto Finally + If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", V_STRING, _ControlModel.StringItemList, True) Then Goto Finally End If _ControlModel.Text = pvValue End If diff --git a/wizards/source/sfdocuments/SF_Writer.xba b/wizards/source/sfdocuments/SF_Writer.xba index a7fce5fe9840..5be6e37cf06a 100644 --- a/wizards/source/sfdocuments/SF_Writer.xba +++ b/wizards/source/sfdocuments/SF_Writer.xba @@ -1005,7 +1005,7 @@ Dim i As Long Case "Section" : Set oColl = _Component.getTextSections() End Select If .Target = "Field" Then vNames = Fields() Else vNames = oColl.getElementNames() - If Not ScriptForge.SF_Utils._Validate(.TargetName, .Target, V_STRING, vNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(.TargetName, .Target, V_STRING, vNames, True) Then GoTo Finally Set .TargetObject = oColl.getByName(.TargetName) ' Set text, anchor and cursor: order varies depending on target @@ -1058,7 +1058,7 @@ Dim i As Long If (sLeft1 = """" Or sLeft1 = "'") And Len(sString) > 2 Then .TargetName = Trim(Mid(sString, 2, Len(sString) - 2)) Else .TargetName = Trim(sString) Set oColl = _Component.getTextTables() vNames = oColl.getElementNames() - If Not ScriptForge.SF_Utils._Validate(.TargetName, .Target, V_STRING, vNames) Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(.TargetName, .Target, V_STRING, vNames, True) Then GoTo Finally Set oItem = oColl.getByName(.TargetName) .TargetCell = Split(psTextRange, "!")(2) ' Set text, anchor and cursor