diff --git a/source/text/sbasic/shared/03/sf_dialogcontrol.xhp b/source/text/sbasic/shared/03/sf_dialogcontrol.xhp index 19c8e39b89..d0aa4c7fd0 100644 --- a/source/text/sbasic/shared/03/sf_dialogcontrol.xhp +++ b/source/text/sbasic/shared/03/sf_dialogcontrol.xhp @@ -8,24 +8,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * --> - SFDialogs.DialogControl service /text/sbasic/shared/03/sf_dialogcontrol.xhp -
DialogControl service -

SFDialogs.DialogControl service

- The DialogControl service manages the controls belonging to a dialog defined with the Basic Dialog Editor. Each instance of the current service represents a single control within a dialog box. - API;awt.XControl API;awt.XControlModel @@ -34,31 +29,41 @@ Note that the unique DialogControl.Value property content varies according to the control type. A special attention is given to controls of type tree control. It is easy to populate a tree, either branch by branch, or with a set of branches at once. Populating a tree control can be performed statically or dynamically.
- The SFDialogs.DialogControl service is closely related to the SFDialogs.Dialog service. -

Service invocation

- The DialogControl service is invoked from an existing Dialog service instance thru its Controls() method. The dialog must be initiated with the SFDialogs.Dialog service. + The DialogControl service is invoked from an existing Dialog service instance through its Controls() method. The dialog must be initiated with the SFDialogs.Dialog service. Dim myDialog As Object, myControl As Object Set myDialog = CreateScriptService("SFDialogs.Dialog", "GlobalScope", myLibrary, DialogName) Set myControl = myDialog.Controls("myTextBox") - myControl.Value = "Dialog started at " & Now() + myControl.Value = "Dialog started at " & Now() myDialog.Execute() ' ... process the controls actual values myDialog.Terminate() + + from time import localtime, strftime + dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', lib_name, dlg_name) + text = dlg.Controls('myTextBox') + text.Value = "Dialog started at " + strftime("%a, %d %b %Y %H:%M:%S", localtime()) + dlg.Execute() + # ... process the controls actual values + dlg.Terminate() + Alternatively a control instance can be retrieved via the SFDialogs.DialogEvent service, providing the dialog was initiated with the Dialog service. DialogEvent returns the SFDialogs.DialogControl class instance that triggered the event. Sub SomeEvent(ByRef poEvent As Object) Dim oControl As Object Set oControl = CreateScriptService("SFDialogs.DialogEvent", poEvent) - ' oControl represents now the instance of the Control class having triggered the current event ' ... End Sub + + def some_event(event: uno): + ctrl = CreateScriptService('SFDialogs.DialogEvent', event) + # ... + Note that in previous examples, the prefix "SFDialogs." may be omitted. -

Control types

The DialogControl service is available for these control types: @@ -124,7 +129,6 @@ -

Properties

@@ -755,7 +759,6 @@
-

Event properties

Returns a URI string with the reference to the script triggered by the event. Read its specification in the scripting framework URI specification. @@ -983,22 +986,28 @@ This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event - using the OnNodeExpanded event - to complete the tree dynamically.

- - oControl.AddSubNode(ParentNode As Object, DisplayValue As String[, DataValue As Variant]) As Object - + svc.AddSubNode(parentnode: uno, displayvalue: str, opt datavalue: any): uno

- ParentNode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. - DisplayValue: The text appearing in the tree control box. - DataValue: Any value associated with the new node. Default value is Empty. + parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. + displayvalue: The text appearing in the tree control box. +
+ datavalue: Any value associated with the new node. datavalue may be a string, a number or a date. Omit the argument when not applicable. +

+ %PRODUCTNAME Basic and Python examples pick up current document's myDialog dialog from Standard library. Dim oDlg As Object, myTree As Object, myNode As Object, theRoot As Object - Set oDlg = CreateScriptService(,, "myDialog") - 'Dialog stored in current document's standard library + Set oDlg = CreateScriptService("Dialog",,, "myDialog") Set myTree = oDlg.Controls("myTreeControl") Set theRoot = myTree.CreateRoot("Tree top") Set myNode = myTree.AddSubNode(theRoot, "A branch ...") + + dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog') + tree = dlg.Controls('myTreeControl') + root = tree.CreateRoot('Tree top') + node = tree.AddSubNode(root, 'A branch ...') +
@@ -1010,12 +1019,10 @@ Return True when a subtree, subordinate to a parent node, could be inserted successfully in a tree control. If the parent node had already child nodes before calling this method, the child nodes are erased.

- - oControl.AddSubTree(ParentNode As Object, FlatTree As Variant[, WithDataValue As Boolean]) As Boolean - + svc.AddSubTree(parentnode: uno, flattree: any, opt withdatavalue: bool): bool

- ParentNode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. - FlatTree: a two dimension array sorted on the columns containing the display values. Such an array can be issued by the GetRows method applied on the SFDatabases.Database service. When an array item containing the text to be displayed is Empty or Null, no new subnode is created and the remainder of the row is skipped. + parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. + flattree: a two dimension array sorted on the columns containing the display values. Such an array can be issued by the GetRows method applied on the SFDatabases.Database service. When an array item containing the text to be displayed is Empty or Null, no new subnode is created and the remainder of the row is skipped. Flat tree >>>> Resulting subtree A1 B1 C1 |__ A1 @@ -1032,7 +1039,7 @@ |__ B4 |__ C6 - WithDataValue: When False default value is used, every column of FlatTree contains the text to be displayed in the tree control. When True, the texts to be displayed (DisplayValue) are in columns 0, 2, 4, ... while the data values (DataValue) are in columns 1, 3, 5, ... + withdatavalue: When False default value is used, every column of flattree contains the text to be displayed in the tree control. When True, the texts to be displayed (displayvalue) are in columns 0, 2, 4, ... while the data values (datavalue) are in columns 1, 3, 5, ...

Dim myTree As Object, theRoot As Object, oDb As Object, vData As Variant @@ -1044,9 +1051,19 @@ & "ORDER BY [Category].[Name], [Product].[Name]") myTree.AddSubTree(theRoot, vData, WithDataValue := True) + + SQL_STMT = "SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID] \ + FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID] \ + ORDER BY [Category].[Name], [Product].[Name]" + tree = dlg.Controls('myTreeControl') + root = tree.CreateRoot('By Product category') + db = CreateScriptService('SFDatabases.Database', '/home/.../mydatabase.odb') + sub_tree = db.GetRows(SQL_STMT) + tree.AddSubTree(root, sub_tree, withdatavalue=True) +
-
+
CreateRoot -------------------------------------------------------------------------------------------------------------------------- DialogControl service;CreateRoot @@ -1055,46 +1072,51 @@ Returns a new root node of the tree control, as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. The new tree root is inserted below pre-existing root nodes. This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event to complete the tree dynamically.

- - oControl.CreateRoot(DisplayValue As String[, DataValue As Variant]) As Object - + svc.CreateRoot(displayvalue: str, opt datavalue: any): uno

- DisplayValue: The text appearing in the tree control box. - DataValue: Any value associated with the new node. Default value is Empty. + displayvalue: The text appearing in the tree control box. +

Dim myTree As Object, myNode As Object Set myTree = myDialog.Controls("myTreeControl") Set myNode = myTree.CreateRoot("Tree starts here ...") + + tree = dlg.Controls('myTreeControl') + node = tree.CreateRoot('Tree starts here ...') +
-
- FindNode -------------------------------------------------------------------------------------------------------------------------- +
+ FindNode -------------------------------------------------------------------------------------------------------------------------- DialogControl service;FindNode

FindNode

- Traverses the tree and finds recursively, starting from the root, a node meeting some criteria. Either - 1 match is enough - having its display value matching DisplayValue pattern or having its data value equal to DataValue. The comparisons may be or not case-sensitive. The first matching occurrence is returned as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. + Traverses the tree and finds recursively, starting from the root, a node meeting some criteria. Either - 1 match is enough - having its display value matching displayvalue pattern or having its data value equal to datavalue. The comparisons may be or not case-sensitive. The first matching occurrence is returned as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. When not found, the method returns Nothing, to be tested with the IsNull() builtin function. This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event.

- - oControl.FindNode(DisplayValue = Empty, DataValue = Empty [, CaseSensitive = False]) As Object - + svc.FindNode(displayvalue: str = '', opt datavalue: any, casesensitive = False): uno

- One argument out of DisplayValue or DataValue must be specified. If both present, one match is sufficient to select the node. - DisplayValue: The pattern to be matched. See the SF_String.IsLike() method. When equal to the zero-length string (default), this display value is not searched for. - DataValue: A string, a numeric value, a date. Use Empty default value when no value applies. - CaseSensitive: Default value is False + One argument out of displayvalue or datavalue must be specified. If both present, one match is sufficient to select the node. + displayvalue: The pattern to be matched. Refer to SF_String.IsLike() method for the list of possible wildcards. When equal to the zero-length string (default), this display value is not searched for. + + casesensitive: Default value is False

Dim myTree As Object, myNode As Object Set myTree = myDialog.Controls("myTreeControl") - et myNode = myTree.FindNode("*Sophie*", CaseSensitive := True) + Set myNode = myTree.FindNode("*Sophie*", CaseSensitive := True) + + tree = dlg.Controls('myTreeControl') + node = FindNode('*Sophie*', casesensitive=True) + if node is None: + # ... +
-
SetFocus -------------------------------------------------------------------------------------------------------------------------- @@ -1104,18 +1126,20 @@ Set the focus on the control. Return True if focusing was successful. This method is often called from a dialog or control event.

- - oControl.SetFocus() As Boolean - + svc.SetFocus(): bool

Dim oControl As Object - Set oDlg = CreateScriptService(,, "myDialog") + Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog") Set oControl = oDlg.Controls("thisControl") oControl.SetFocus() + + dlg = CreateScriptService('Dialog', None, None, 'myDialog') + ctrl = dlg.Controls('thisControl') + ctrl.SetFocus() +
-
WriteLine -------------------------------------------------------------------------------------------------------------------------- @@ -1125,6 +1149,7 @@ Add a new line at the end of a multiline text field. A newline character will be inserted when appropriate. The method returns True when successful. An error is raised if the actual control is not of the type TextField or is not multiline.

+ svc.WriteLine(opt line: str): bool oControl.WriteLine([Line As String]) As Boolean @@ -1133,19 +1158,21 @@

Dim oDlg As Object, oControl As Object - Set oDlg = CreateScriptService(,, "myDialog") + Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog") Set oControl = oDlg.Controls("thisControl") oControl.WriteLine("a new line") + + dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog') + ctrl = dlg.Controls('thisControl') + ctr.WriteLine("a new line") +
- -
- - + \ No newline at end of file