SFDialogs. Υπηρεσία Διάλογος

The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor or dialogs created on-the-fly. Each instance of the current class represents a single dialog box displayed to the user.

tip

Ένα πλαίσιο διαλόγου μπορεί να εμφανιστεί σε αναγκαστικές ή μη αναγκαστικές καταστάσεις.


Στη αναγκαστική κατάσταση, εμφανίζεται το πλαίσιο και η εκτέλεση της διαδικασίας μακροεντολής αναστέλλεται μέχρι να πατηθεί ένα από τα κουμπιά Εντάξει ή Ακύρωση. Στο μεταξύ, οι ενέργειες χρήστη που εκτελούνται στο πλαίσιο μπορούν να ενεργοποιήσουν συγκεκριμένες ενέργειες.

Στη μη αναγκαστική κατάσταση, το πλαίσιο διαλόγου "επιπλέει" στην επιφάνεια εργασίας του χρήστη και η εκτέλεση της διαδικασίας μακροεντολής συνεχίζεται κανονικά. Ένα μη αναγκαστικό παράθυρο διαλόγου κλείνει όταν τερματίζεται με τη μέθοδο Terminate(), ή όταν τελειώσει η συνεδρία του LibreOfficeDev. Το πλήκτρο κλεισίματος παραθύρου είναι ανενεργό σε μη αναγκαστικούς διαλόγους.

Ένα πλαίσιο διαλόγου εξαφανίζεται από τη μνήμη μετά τον ρητό τερματισμό του.

tip

Η υπηρεσία SFDialogs.Dialog σχετίζεται στενά με την υπηρεσία SFDialogs.DialogControl.


Κλήση και χρήση της υπηρεσίας

Πριν τη χρήση της υπηρεσίας Dialog, πρέπει να φορτωθεί ή να εισαχθεί η βιβλιοθήκη ScriptForge:

note

• Οι μακροεντολές Basic απαιτούν τη φόρτωση της βιβλιοθήκης ScriptForge χρησιμοποιώντας την ακόλουθη πρόταση:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Τα σενάρια Python απαιτούν εισαγωγή από την ενότητα scriptforge:
από το scriptforge import CreateScriptService


The Dialog service is invoked through the CreateScriptService method. It requires three supplemental positional arguments to specify the dialog box to activate:

Container (περιέκτης): "GlobalScope" για προεγκατεστημένες βιβλιοθήκες ή όνομα παραθύρου όπως ορίζεται από την υπηρεσία ScriptForge.UI. Η προεπιλεγμένη τιμή κενής συμβολοσειράς "" αντιπροσωπεύει το τρέχον έγγραφο.

Library (Βιβλιοθήκη): Το όνομα με διάκριση πεζών-κεφαλαίων μιας βιβλιοθήκης που περιέχεται στον περιέκτη. Η προεπιλεγμένη τιμή είναι "Standard" (Τυπική).

DialogName (Όνομα διαλόγου): Μια συμβολοσειρά με διάκριση πεζών-κεφαλαίων που προσδιορίζει το παράθυρο διαλόγου.

The examples below in Basic and Python display the dlgConsole dialog that belongs to the ScriptForge shared library:


      Dim oDlg As Object, lButton As Long
      Dim Container As String, Library As String, DialogName As String
      Set oDlg = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole")
      '... η αρχικοποίηση των στοιχείων ελέγχου πηγαίνει εδώ...
      lButton = oDlg.Execute()
      'Προεπιλεγμένη κατάσταση = Modal (Αναγκαστική)
      If lButton = oDlg.OKBUTTON Then
      '... Στοιχεία ελέγχου διεργασίας και κάντε ό,τι χρειάζεται εδώ
      End If
      oDlg.Terminate()
  

Ή χρησιμοποιώντας Python:


    dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole')
    # ... η αρχικοποίηση των στοιχείων ελέγχου πηγαίνει εδώ...
    rc = dlg.Execute()
    # Η προεπιλεγμένη κατάσταση είναι Modal (αναγκαστική)
    if rc == dlg.OKBUTTON:
        # ... Επεξεργαστείτε τα στοιχεία ελέγχου και κάντε ό,τι χρειάζεται εδώ
    dlg.Terminate()
  
note

Use the string "GlobalScope" as the container argument when the dialog is stored either in My Macros & Dialogs or in Application Macros & Dialogs.


tip

The dialog service offers methods that create new controls dynamically in an existing dialog predefined with the Dialog Editor. A dialog is initialized with controls in the Dialog Editor and new controls can be added at run-time before or after the dialog Execute() statement.


The Dialog service can equally be invoked - through the CreateScriptService method - when creating dialogs on-the-fly. It requires two supplemental positional arguments after the name of the ad-hoc service "NewDialog":

DialogName: A case-sensitive string designating the dialog.

Place: Window location of the dialog being either :

All elements are expressed in Map AppFont units.


    Sub newDialog()
        Dim oDlg As Object
       oDlg = CreateScriptService("NewDialog", "myDialog1", Array(100,200, 40, 110))
       ' ...
    End Sub
  

Or using Python:


    def newDialog():
       dlg = CreateScriptService('NewDialog', 'myDialog1', (100,200, 40, 110))
       # ... Process controls and do what is needed
  

All properties and methods applicable to predefined dialogs are available for such new dialogs. In particular the series of CreateXXX() methods for the additionof new dialog controls.

Retrieving the Dialog instance that triggered a dialog event

An instance of the Dialog service can be retrieved via the SFDialogs.DialogEvent service, provided that the dialog was initiated with the Dialog service. In the example below, oDlg contains the Dialog instance that triggered the dialog event.


    Sub aDialogEventHander(ByRef poEvent As Object)
        Dim oDlg As Object
        Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent)
        ' ...
    End Sub
  

Or using Python:


    def control_event_handler(event: uno):
        dlg = CreateScriptService("SFDialogs.DialogEvent", event)
        # ...
  

Note that in the previous examples, the prefix "SFDialogs." may be omitted when deemed appropriate.

Handling exceptions in event handlers

When creating an event handler for dialog events it is good practice to handle errors inside the subroutine itself. For instance, suppose the event handler below is called when the mouse button is pressed in the dialog window.


    Sub OnMouseButtonPressed(ByRef oEvent As Object)
    On Local Error GoTo Catch
        Dim oDialog As Object
        oDialog = CreateScriptService("DialogEvent", oEvent)
        ' Process the event
        Exit Sub
    Catch:
        MsgBox SF_Exception.Description
        SF_Exception.Clear
    End Sub
  
tip

Call SF_Exception.Clear if you do not want the error to propagate after the dialog execution ended.


In Python use native try/except blocks for exception handling as shown below:


    def on_mouse_button_pressed(event=None):
        try:
            dlg = CreateScriptService("DialogEvent", event)
            # Process the event
        except Exception as e:
            # The object "bas" is an instance of the Basic service
            bas.MsgBox(str(e))
  

Ιδιότητες

Όνομα

Μόνο για ανάγνωση

Τύπος

Περιγραφή

OKBUTTON

Ναι

Integer

Value (Τιμή) = 1. Πατήθηκε πλήκτρο OK (Εντάξει).

CANCELBUTTON

Ναι

Integer

Value (Τιμή) = 0. Πατήθηκε πλήκτρο Ακύρωσης.

Caption

Όχι

String

Καθορίστε τον τίτλο του διαλόγου.

Height

Όχι

Long

Καθορίστε το ύψος του πλαισίου διαλόγου.

Modal

Ναι

Boolean

Καθορίζει εάν το πλαίσιο διαλόγου εκτελείται αυτήν τη στιγμή σε λειτουργία modal (αναγκαστική).

Name

Ναι

String

Το όνομα του διαλόγου

Page

Όχι

Integer

Ένα παράθυρο διαλόγου μπορεί να έχει πολλές σελίδες που μπορεί να διασχίσει ο χρήστης βήμα προς βήμα. Η ιδιότητα Page (Σελίδα) του αντικειμένου διαλόγου ορίζει ποια σελίδα του διαλόγου είναι ενεργή.

Visible

Όχι

Boolean

Καθορίστε εάν το πλαίσιο διαλόγου είναι ορατό στην επιφάνεια εργασίας. Από προεπιλογή δεν είναι ορατό μέχρι να εκτελεστεί η μέθοδος Execute() και να είναι ορατή στη συνέχεια.

XDialogModel

Ναι

UNO
object

Το αντικείμενο UNO που αντιπροσωπεύει το μοντέλο διαλόγου. Ανατρέξτε στο XControlModel και UnoControlDialogModel στην τεκμηρίωση της διασύνδεσης προγραμματισμού εφαρμογών (API) για λεπτομερείς πληροφορίες.

XDialogView

Ναι

UNO
object

Το αντικείμενο UNO που αντιπροσωπεύει την προβολή διαλόγου. Ανατρέξτε στα XControl και UnoControlDialog στην τεκμηρίωση της διασύνδεσης προγραμματισμού εφαρμογών (API) για λεπτομερείς πληροφορίες.

Width

Όχι

Long

Καθορίστε το πλάτος του πλαισίου διαλόγου.


Ιδιότητες συμβάντος

On… properties return a URI string with the reference to the script triggered by the event. On… properties can be set programmatically.
Read its specification in the scripting framework URI specification.

Όνομα

Read/Write

Περιγραφή IDE Basic

OnFocusGained

Ναι

Κατά τη λήψη της εστίασης

OnFocusLost

Ναι

Κατά τη απώλεια της εστίασης

OnKeyPressed

Ναι

Με το πλήκτρο πατημένο

OnKeyReleased

Ναι

Με το πλήκτρο απελευθερωμένο

OnMouseDragged

Ναι

Το ποντίκι μετακινήθηκε κατά το πάτημα του πλήκτρου

OnMouseEntered

Ναι

Το ποντίκι εντός

OnMouseExited

Ναι

Το ποντίκι εκτός

OnMouseMoved

Ναι

Το ποντίκι μετακινήθηκε

OnMousePressed

Ναι

Με πατημένο το πλήκτρο του ποντικιού

OnMouseReleased

Ναι

Με απελευθερωμένο το πλήκτρο του ποντικιού


warning

Assigning events via the Basic IDE and assigning events via macros are mutually exclusive.


List of Methods in the Dialog Service

Activate
Center
Controls
CloneControl
CreateButton
CreateCheckBox
CreateComboBox
CreateCurrencyField
CreateDateField
CreateFileControl
CreateFixedLine

CreateFixedText
CreateFormattedField
CreateGroupBox
CreateHyperlink
CreateImageControl
CreateListBox
CreateNumericField
CreatePatternField
CreateProgressBar
CreateRadioButton
CreateScrollBar

CreateTableControl
CreateTextField
CreateTimeField
CreateTreeControl
EndExecute
Execute
GetTextsFromL10N
Resize
OrderTabs
SetPageManager
Terminate


note

Dimensioning a dialog is done by using Map AppFont units. A dialog or control model also uses AppFont units. While their views use pixels.


Activate

Ρυθμίστε την εστίαση στην τρέχουσα παρουσία του Dialog (Διάλογος). Επιστροφή True εάν η εστίαση ήταν επιτυχής.

Αυτή η μέθοδος καλείται από ένα συμβάν διαλόγου ή ελέγχου, ή όταν εμφανίζεται ένα παράθυρο διαλόγου σε μη αναγκαστική λειτουργία.

Σύνταξη:

svc.Activate(): bool

Παράδειγμα:


      Dim oDlg As Object
      Set oDlg = CreateScriptService(,, "myDialog")
      oDlg.Execute()
      ' ...
      oDlg.Activate()
   

Τα παραδείγματα Python και LibreOfficeDev Basic υποθέτουν και τα δύο ότι το παράθυρο διαλόγου είναι αποθηκευμένο στη βιβλιοθήκη Standard (Τυπική)του τρέχοντος εγγράφου.


     dlg = CreateScriptService(,,'myDialog')
     dlg.Execute()
     # ...
     dlg.Activate()
   

Center

Κεντράρει την τρέχουσα παρουσία διαλόγου στη μέση ενός γονικού παραθύρου. Χωρίς ορίσματα, η μέθοδος κεντράρει το παράθυρο διαλόγου στη μέση του τρέχοντος παραθύρου.

Επιστρέφει True όταν είναι επιτυχές.

Σύνταξη:

svc.Center(opt Parent: obj): bool

Παράμετροι:

Parent (Γονικό): Ένα προαιρετικό αντικείμενο που μπορεί να είναι είτε…

Παράδειγμα:

Σε Basic

     Sub TriggerEvent(oEvent As Object)
         Dim oDialog1 As Object, oDialog2 As Object, lExec As Long
         Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' Το παράθυρο διαλόγου που προκάλεσε το συμβάν
         Set oDialog2 = CreateScriptService("Dialog", ...) ' Άνοιγμα δεύτερου διαλόγου
         oDialog2.Center(oDialog1)
         lExec = oDialog2.Execute()
         Select Case lExec
             ...
     End Sub
  
Σε Python

     def triggerEvent(event: uno):
       dlg1 = CreateScriptService('DialogEvent.Dialog', συμβάν) # Το παράθυρο διαλόγου που προκάλεσε το συμβάν
       dlg2 = CreateScriptService('Dialog', ...) # Άνοιγμα δεύτερου διαλόγου
       dlg2.Center(dlg1)
       rc = dlg2.Execute()
       if rc is False:
         # ...
   

CloneControl

Duplicate an existing control of any typein the actual dialog. The duplicated control is left unchanged and can be relocated.

Σύνταξη:

svc.CloneControl(SourceName: str, ControlName: str, Left: num, Top: num): svc

Παράμετροι:

SourceName: The name of the control to duplicate.

ControlName: A valid control name as a case-sensitive string. It must not exist yet.

Left, Top: The coordinates of the new control expressed in Map AppFont units.

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

      Set myButton2 = oDlg.CloneControl("Button1", "Button2", 30, 30)
   
Σε Python

     dlg = dlg.CloneControl('Button1', 'Button2', 30, 30)
   

Controls

Επιστροφή είτε:

Σύνταξη:

svc.Controls(): str[0..*]

svc.Controls(controlname: str): svc

Παράμετροι:

ControlName (Όνομα ελέγχου): Ένα έγκυρο όνομα ελέγχου ως συμβολοσειρά με διάκριση πεζών-κεφαλαίων. Εάν δεν υπάρχει, ο κατάλογος ονομάτων ελέγχου επιστρέφεται ως πίνακας μηδενικής βάσης.

Παράδειγμα:


      Dim myDialog As Object, myList As Variant, myControl As Object
      Set myDialog = CreateScriptService("SFDialogs.Dialog", , "Standard", "Dialog1")
      myList = myDialog.Controls()
      Set myControl = myDialog.Controls("myTextBox")
   

     dlg = CreateScriptService('SFDialogs.Dialog','', 'Standard', 'Dialog1')
     ctrls = dlg.Controls()
     ctrl = dlg.Controls('myTextBox')
   

CreateButton

Create a new control of type Button in the current dialog.

Σύνταξη:

svc.CreateButton(ControlName: str, Place: any, Toggle: bool = False, Push: str = ""): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Toggle: when True a Toggle button is created. Default = False

Push: "OK", "CANCEL" or "" (default)

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myButton = oDlg.CreateButton("Button1", Array(20, 20, 60, 15))
   
Σε Python

     myButton = dlg.CreateButton('Button1', (20, 20, 60, 15))
   

CreateCheckBox

Create a new control of type CheckBox in the current dialog.

Σύνταξη:

svc.CreateCheckBox(ControlName: str, Place: any, Multiline: bool = False): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

MultiLine: When True (default = False), the caption may be displayed on more than one line.

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myCheckBox = oDlg.CreateCheckBox("CheckBox1", Array(20, 20, 60, 15), MultiLine := True)
   
Σε Python

     myCheckBox = dlg.CreateCheckBox('CheckBox1', (20, 20, 60, 15), MultiLine = True)
   

CreateComboBox

Create a new control of type ComboBox in the current dialog.

Σύνταξη:

svc.CreateComboBox(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = True, LineCount: num = 5): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

DropDown: When True (default), a drop down button is displayed

LineCount: Specifies the maximum line count displayed in the drop down (default = 5)

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myComboBox = oDlg.CreateComboBox("ComboBox1", Array(20, 20, 60, 15), Dropdown := True)
   
Σε Python

     myComboBox = dlg.CreateComboBox('ComboBox1', (20, 20, 60, 15), Dropdown = True)
   

CreateCurrencyField

Create a new control of type CurrencyField in the current dialog.

Σύνταξη:

svc.CreateCurrencyField(ControlName: str, Place: any, Border ="3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = +1000000, Increment: num = 1, Accuracy: num = 2): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

Increment: the step when the spin button is pressed. Default = 1

Accuracy: specifies the decimal accuracy. Default = 2 decimal digits

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myCurrencyField = oDlg.CreateCurrencyField("CurrencyField1", Array(20, 20, 60, 15), SpinButton := True)
   
Σε Python

     myCurrencyField = dlg.CreateCurrencyField('CurrencyField1', (20, 20, 60, 15), SpinButton = True)
   

CreateDateField

Create a new control of type DateField in the current dialog.

Σύνταξη:

svc.CreateDateField(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = False, opt MinDate: datetime, opt MaxDate: datetime): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

DropDown: when True (default = False), a dropdown button is shown

MinDate: the smallest date that can be entered in the control. Default = 1900-01-01

MaxDate: the largest date that can be entered in the control. Default = 2200-12-31

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myDateField = oDlg.CreateDateField("DateField1", Array(20, 20, 60, 15), Dropdown := True)
   
Σε Python

     myDateField = dlg.CreateDateField('DateField1', (20, 20, 60, 15), Dropdown = True)
   

CreateFileControl

Create a new control of type FileControl in the current dialog.

Σύνταξη:

svc.CreateFileControl(ControlName: str, Place: any, Border: str = "3D"): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myFileControl = oDlg.CreateFileControl("FileControl1", Array(20, 20, 60, 15))
   
Σε Python

     myFileControl = dlg.CreateFileControl('FileControl1', (20, 20, 60, 15))
   

CreateFixedLine

Create a new control of type FixedLine in the current dialog.

Σύνταξη:

svc.CreateFixedLine(ControlName: str, Place: any, Orientation: str): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Orientation: "H[orizontal]" or "V[ertical]".

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myFixedLine = oDlg.CreateFixedLine("FixedLine1", Array(20, 20, 60, 15), Orientation := "vertical")
   
Σε Python

     myFixedLine = dlg.CreateFixedLine('FixedLine1', (20, 20, 60, 15), Orientation = 'vertical')
   

CreateFixedText

Create a new control of type FixedText in the current dialog.

Σύνταξη:

svc.CreateFixedText(ControlName: str, Place: any, Border: str = "3D", MultiLine: bool = False, Align: str = "LEFT", VerticalAlign: str = "TOP"): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "NONE" (default) or "FLAT" or "3D"

Multiline: When True (default = False), the caption may be displayed on more than one line

Align: horizontal alignment, "LEFT" (default) or "CENTER" or "RIGHT"

VerticalAlign: vertical alignment, "TOP" (default) or "MIDDLE" or "BOTTOM"

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myFixedText = oDlg.CreateFixedText("FixedText1", Array(20, 20, 60, 15), MultiLine := True)
   
Σε Python

     myFixedText = dlg.CreateFixedText('FixedText1', (20, 20, 60, 15), MultiLine = True)
   

CreateFormattedField

Create a new control of type FormattedField in the current dialog.

Σύνταξη:

svc.CreateFormattedField(ControlName: str, Place: any, Border: str = "3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = +1000000): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myFormattedField = oDlg.CreateFormattedField("FormattedField1", Array(20, 20, 60, 15), SpinButton := True)
   
Σε Python

     myFormattedField = dlg.CreateFormattedField('FormattedField1', (20, 20, 60, 15), SpinButton = True)
   

CreateGroupBox

Create a new control of type GroupBox in the current dialog.

Σύνταξη:

svc.CreateGroupBox(ControlName: str, Place: any): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myGroupBox = oDlg.CreateGroupBox("GroupBox1", Array(20, 20, 60, 15))
   
Σε Python

     myGroupBox = dlg.CreateGroupBox('GroupBox1', (20, 20, 60, 15))
   

CreateHyperlink

Create a new control of type Hyperlink in the current dialog.

Σύνταξη:

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "NONE" (default) or "FLAT" or "3D"

MultiLine: When True (default = False), the caption may be displayed on more than one line

Align: horizontal alignment, "LEFT" (default) or "CENTER" or "RIGHT"

VerticalAlign: vertical alignment, "TOP" (default) or "MIDDLE" or "BOTTOM"

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myHyperlink = oDlg.CreateHyperlink("Hyperlink1", Array(20, 20, 60, 15), MultiLine := True)
   
Σε Python

     myHyperlink = dlg.CreateHyperlink('Hyperlink1', (20, 20, 60, 15), MultiLine = True)
   

CreateImageControl

Create a new control of type ImageControl in the current dialog.

Σύνταξη:

svc.CreateImageControl(ControlName: str, Place: any, Border: str = "3D", Scale: str = "FITTOSIZE"): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

Scale: One of next values: "FITTOSIZE" (default), "KEEPRATIO" or "NO"

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myImageControl = oDlg.CreateImageControl("ImageControl1", Array(20, 20, 60, 15))
   
Σε Python

       myImageControl = dlg.CreateImageControl('ImageControl1", (20, 20, 60, 15))
   

CreateListBox

Create a new control of type ListBox in the current dialog.

Σύνταξη:

svc.CreateListBox(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = True, LineCount: num = 5, MultiSelect: bool = False): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

DropDown: When True (default), a drop down button is displayed

LineCount: Specifies the maximum line count displayed in the drop down (default = 5)

MultiSelect: When True, more than 1 entry may be selected. Default = False

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myListBox = oDlg.CreateListBox("ListBox1", Array(20, 20, 60, 15), Dropdown := True, MultiSelect := True)
   
Σε Python

     myListBox = dlg.CreateListBox('ListBox1', (20, 20, 60, 15), Dropdown = True, MultiSelect = True)
   

CreateNumericField

Create a new control of type NumericField in the current dialog.

Σύνταξη:

svc.CreateNumericField(ControlName: str, Place: any, Border: str = "3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = 1000000, Increment: num = 1, Accuracy: num = 2): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

Increment: the step when the spin button is pressed. Default = 1

Accuracy: specifies the decimal accuracy. Default = 2 decimal digits

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myNumericField = oDlg.CreateNumericField("NumericField1", Array(20, 20, 60, 15), SpinButton := True)
   
Σε Python

     myNumericField = dlg.CreateNumericField('NumericField1', (20, 20, 60, 15), SpinButton = True)
   

CreatePatternField

Create a new control of type PatternField in the current dialog.

Σύνταξη:

svc.CreatePatternField(ControlName: str, Place: any, Border: str = "3D", EditMask: str, opt LiteralMax: str): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

EditMask: a character code that determines what the user may enter
Refer to Pattern_Field in the wiki for more information.

LiteralMask: contains the initial values that are displayed in the pattern field

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myPatternField = oDlg.CreatePatternField("PatternField1", Array(20, 20, 60, 15), EditMask := "NNLNNLLLLL", LiteralMask := "__.__.2002")
   
Σε Python

     myPatternField = dlg.CreatePatternField('PatternField1', (20, 20, 60, 15), EditMask = 'NNLNNLLLLL', LiteralMask = '__.__.2002')
   

CreateProgressBar

Create a new control of type ProgressBar in the current dialog.

Σύνταξη:

svc.CreateProgressBar(ControlName: str, opt Place: any, Border: str = "3D", MinValue: num = 0, MaxValue: num = 100): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

MinValue: the smallest value that can be entered in the control. Default = 0

MaxValue: the largest value that can be entered in the control. Default = 100

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myProgressBar = oDlg.CreateProgressBar("ProgressBar1", Array(20, 20, 60, 15), MaxValue := 1000)
   
Σε Python

     myProgressBar = dlg.CreateProgressBar('ProgressBar1', (20, 20, 60, 15), MaxValue = 1000)
   

CreateRadioButton

Create a new control of type RadioButton in the current dialog.

Σύνταξη:

svc.CreateRadioButton(ControlName: str, Place: any, MultiLine: bool = False): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

MultiLine: When True (default = False), the caption may be displayed on more than one line

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myRadioButton = oDlg.CreateRadioButton("RadioButton1", Array(20, 20, 60, 15), MultiLine := True)
   
Σε Python

     myRadioButton = dlg.CreateRadioButton('RadioButton1', (20, 20, 60, 15), MultiLine = True)
   

CreateScrollBar

Create a new control of type ScrollBar in the current dialog.

Σύνταξη:

svc.CreateScrollBar(ControlName: str, Place, Orientation: str, Border: str = "3D", MinValue: num = 0, MaxValue: num = 100): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Orientation: H[orizontal] or V[ertical]

Border: "3D" (default) or "FLAT" or "NONE"

MinValue: the smallest value that can be entered in the control. Default = 0

MaxValue: the largest value that can be entered in the control. Default = 100

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myScrollBar = oDlg.CreateScrollBar("ScrollBar1", Array(20, 20, 60, 15), MaxValue := 1000)
   
Σε Python

     myScrollBar = dialog.CreateScrollBar('ScrollBar1', (20, 20, 60, 15), MaxValue = 1000)
   

CreateTableControl

Create a new control of type TableControl in the current dialog.

Σύνταξη:

svc.CreateTableControl(ControlName: str, Place: any, Border: str = "3D", RowHeaders: bool = True, ColumnHeaders: bool = True, ScrollBars: str = "N", GridLines: bool = False): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

RowHeaders: when True (default), the row Headers are shown

ColumnHeaders: when True (default), the column Headers are shown

ScrollBars: H[orizontal] or V[ertical] or B[oth] or N[one] (default). Scrollbars appear dynamically when they are needed.

GridLines: when True (default = False) horizontal and vertical lines are painted between the grid cells

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myTableControl = oDlg.CreateTableControl("TableControl1", Array(20, 20, 60, 15), ScrollBars := "B")
   
Σε Python

     myTableControl = dlg.CreateTableControl('TableControl1', (20, 20, 60, 15), ScrollBars = 'B')
   

CreateTextField

Create a new control of type TextField in the current dialog.

Σύνταξη:

svc.CreateTextField(ControlName: str, Place: any, Border: str = "3D", MultiLine: bool = False, MaximumLength: num = 0, PasswordCharacter: str = ""): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

MultiLine: When True (default = False), the caption may be displayed on more than one line

MaximumLength: the maximum character count (default = 0 meaning unlimited)

PasswordCharacter: a single character specifying the echo for a password text field (default = "")

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic
Set myTextField = oDlg.CreateTextField("TextField1", Array(20, 20, 120, 50), MultiLine := True)
   
Σε Python

     myTextField = dlg.CreateTextField('TextField1', (20, 20, 120, 50), MultiLine = True)
   

CreateTimeField

Create a new control of type TimeField in the current dialog.

Σύνταξη:

svc.CreateTimeField(ControlName: str, Place: any, Border: str = "3D", MinTime: num = 0, MaxTime: num = 24): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

MinTime: the smallest time that can be entered in the control. Default = 0

MaxTime: the largest time that can be entered in the control. Default = 24h

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myTimeField = oDlg.CreateTimeField("TimeField1", Array(20, 20, 60, 15))
   
Σε Python

     myTimeField = dlog.CreateTimeField('TimeField1', (20, 20, 60, 15))
   

CreateTreeControl

Create a new control of type TreeControl in the current dialog.

Σύνταξη:

svc.CreateTreeControl(ControlName: str, Place: any, Border = "3D"): svc

Παράμετροι:

ControlName: the name of the new control. It must not exist yet.

Place: either …

All elements are expressed in Map AppFont units.

Border: "3D" (default) or "FLAT" or "NONE"

Επιστρεφόμενη τιμή:

An instance of SFDialogs.DialogControl service or Nothing.

Παράδειγμα:

Σε Basic

     Set myTreeControl = oDlg.CreateTreeControl("TreeControl1", Array(20, 20, 60, 15))
   
Σε Python

     myTreeControl = dlg.CreateTreeControl('TreeControl1', (20, 20, 60, 15))
   

EndExecute

Τερματίζει την εμφάνιση ενός αναγκαστικού διαλόγου και επιστρέφει το όρισμα ως επιστρεφόμενη τιμή για την τρέχουσα εκτελούμενη ενέργεια Execute().

Το EndExecute() (Τέλος εκτέλεσης) περιέχεται συνήθως στην επεξεργασία μιας μακροεντολής που ενεργοποιείται από ένα συμβάν διαλόγου ή ελέγχου.

Σύνταξη:

svc.EndExecute(returnvalue: int)

Παράμετροι:

returnvalue (τιμή επιστροφής): Η τιμή μεταβιβάστηκε στην τρέχουσα μέθοδο Execute().

Παράδειγμα:

Σε Basic

      Sub OnEvent(poEvent As com.sun.star.lang.EventObject)
          Dim oDlg As Object
          Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent)
          oDlg.EndExecute(ReturnValue := 25)
      End Sub
   
Σε Python

     from com.sun.star.lang import EventObject
     def on_event(event: EventObject):
         dlg = CreateScriptService("SFDialogs.DialogEvent", event)
         dlg.EndExecute(25)
   
tip

Πάνω από το com.sun.star.lang.EventObject οι αναφορές είναι προαιρετικές. Τέτοιοι σχολιασμοί βοηθούν στον προσδιορισμό της διεπαφής προγραμματισμού εφαρμογών (API) του LibreOfficeDev.


Execute

Εμφάνιση του πλαισίου διαλόγου και, όταν είναι αναγκαστικό, περιμένετε τον τερματισμό του από τον χρήστη. Η επιστρεφόμενη τιμή είναι είτε:

Για παράθυρα διαλόγου που δεν είναι αναγκαστικά, η μέθοδος επιστρέφει πάντα 0 και η εκτέλεση της μακροεντολής συνεχίζεται.

Σύνταξη:

svc.Execute(modal: bool = True): int

Παράμετροι:

modal (αναγκαστικό): False όταν ο διάλογος δεν είναι αναγκαστικός. Προεπιλογή = True.

Παράδειγμα:

Σε αυτό το παράδειγμα Basic, ο διάλογος myDialog αποθηκεύεται στη βιβλιοθήκη Standard (Τυπική) του τρέχοντος εγγράφου.


      Dim oDlg As Object, lReturn As Long
      Set oDlg = CreateScriptService("SFDialogs.Dialog", , , "myDialog")
      lReturn = oDlg.Execute(Modal := False)
      Select Case lReturn
          ' ...
      End Select
   

Αυτός ο κώδικας Python εμφανίζει τον αναγκαστικό διάλογο DlgConvert από την κοινόχρηστη βιβλιοθήκη Basic Euro.


     dlg = CreateScriptService("SFDialogs.Dialog", 'GlobalScope', 'Euro', "DlgConvert")
     rc = dlg.Execute()
     if rc == dlg.CANCELBUTTON:
         # ...
   

GetTextsFromL10N

Αντικαθιστά όλες τις σταθερές συμβολοσειρές κειμένου σε ένα παράθυρο διαλόγου από τις μεταφρασμένες εκδόσεις τους που βασίζονται σε μια παρουσία υπηρεσίας L10N. Αυτή η μέθοδος μεταφράζει τις ακόλουθες συμβολοσειρές:

Η μέθοδος επιστρέφει True εάν είναι επιτυχής.

Για να δημιουργήσετε έναν κατάλογο με μεταφράσιμες συμβολοσειρές σε ένα παράθυρο διαλόγου, χρησιμοποιήστε τη μέθοδο AddTextsFromDialog από την υπηρεσία L10N.

Σύνταξη:

svc.GetTextsFromL10N(l10n: svc): bool

Παράμετροι:

l10n: Μια παρουσία υπηρεσίας L10N από την οποία θα ανακτηθούν μεταφρασμένες συμβολοσειρές.

Παράδειγμα:

Το παρακάτω παράδειγμα φορτώνει μεταφρασμένες συμβολοσειρές και τις εφαρμόζει στο παράθυρο διαλόγου "MyDialog".

Σε Basic

     oDlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog")
     myPO = CreateScriptService("L10N", "/home/user/po_files/")
     oDlg.GetTextsFromL10N(myPO)
     oDlg.Execute()
   
Σε Python

     dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog")
     myPO = CreateScriptService("L10N", "/home/user/po_files/")
     dlg.GetTextsFromL10N(myPO)
     dlg.Execute()
   
tip

Ανατρέξτε στη σελίδα βοήθειας Υπηρεσία L10N για να μάθετε περισσότερα σχετικά με τον τρόπο χειρισμού των αρχείων PO και POT.


OrderTabs

Set the tabulation index of a series of controls. The sequence of controls are given as an array of control names from the first to the last.

warning

Controls with an index >= 1 are not accessible with the TAB key if:
- they are omitted from the given list
- their type is FixedLine, GroupBox or ProgressBar
- they are disabled


Σύνταξη:

svc.TabsList(TabsList: num, Start: num = 1, Increment: num = 1): bool

Παράμετροι:

TabsList: an array of valid control names in the order of tabulation

Start: the tab index to be assigned to the 1st control in the list. Default = 1

Increment: the difference between 2 successive tab indexes. Default = 1

Επιστρεφόμενη τιμή:

True when successful.

Παράδειγμα:

Σε Basic

     oDlg.OrderTabs(Array("myListBox", "myTextField", "myNumericField"), Start := 10)
   
Σε Python

     dlg.OrderTabs(('myListBox', 'myTextField', 'myNumericField'), Start = 10)
   

Resize

Moves the topleft corner of a dialog to new coordinates and/or modify its dimensions. All distances are expressed in AppFont units. Without arguments, the method resets the initial dimensions. Return True if the resize was successful.

Σύνταξη:

svc.Resize(opt Left: num, opt Top: num, opt Width: num, opt Height: num): bool

Παράμετροι:

Left (Αριστερά): η οριζόντια απόσταση από την επάνω αριστερή γωνία

Top (Επάνω): η κατακόρυφη απόσταση από την επάνω αριστερή γωνία

Width (Πλάτος): το πλάτος του ορθογωνίου που περιέχει το παράθυρο διαλόγου

Height (Ύψος): το ύψος του ορθογωνίου που περιέχει το παράθυρο διαλόγου

Missing arguments are left unchanged

Παράδειγμα:

Σε Basic

     oDlg.Resize(1000, 2000, Height := 6000) ' Width is not changed
   
Σε Python

     dlg.Resize(1000, 2000, Height = 6000)  # Width is not changed
   

SetPageManager

Defines which controls in a dialog are responsible for switching pages, making it easier to manage the Page property of a dialog and its controls.

Dialogs may have multiple pages and the currently visible page is defined by the Page dialog property. If the Page property is left unchanged, the default visible page is equal to 0 (zero), meaning that no particular page is defined and all visible controls are displayed regardless of the value set in their own Page property.

When the Page property of a dialog is changed to some other value such as 1, 2, 3 and so forth, then only the controls whose Page property match the current dialog page will be displayed.

By using the SetPageManager method it is possible to define four types of page managers:

tip

It is possible to use more than one page management mechanism at the same time.


This method is supposed to be called just once before calling the Execute method. Subsequent calls are ignored.

If successful this method returns True.

Σύνταξη:

svc.SetPageManager(pilotcontrols: str = "", tabcontrols: str = "", wizardcontrols: str = "", opt lastpage: int): bool

Παράμετροι:

pilotcontrols: a comma-separated list of ListBox, ComboBox or RadioButton control names used as page managers. For RadioButton controls, specify the name of the first control in the group to be used.

tabcontrols: a comma-separated list of button names that will be used as page managers. The order in which they are specified in this argument corresponds to the page number they are associated with.

wizardcontrols: a comma-separated list with the names of two buttons that will be used as the Previous/Next buttons.

lastpage: the number of the last available page. It is recommended to specify this value when using the Previous/Next page manager.

Παράδειγμα:

Consider a dialog with three pages. The dialog has a ListBox control named "aPageList" that will be used to control the visible page. Additionally, there are two buttons named "btnPrevious" and "btnNext" that will be used as the Previous/Next buttons in the dialog.

Σε Basic

    oDlg.SetPageManager(PilotControls := "aPageList", _
                           WizardControls := "btnPrevious,btnNext", _
                           LastPage := 3)
    oDlg.Execute()
  
Σε Python

    dlg.SetPageManager(pilotcontrols="aPageList",
                       wizardcontrols="btnPrevious,btnNext",
                       lastpage=3)
    dlg.Execute()
  

Terminate

Τερματίστε την υπηρεσία Dialog για την τρέχουσα παρουσία. Επιστρέφει True εάν ο τερματισμός ήταν επιτυχής.

Σύνταξη:

svc.Terminate(): bool

Παράδειγμα:

Στα παρακάτω παραδείγματα Basic και Python ανοίγουν οι μη αναγκαστικοί διάλογοι DlgConsole και dlgTrace. Αποθηκεύονται αντίστοιχα στις κοινόχρηστες βιβλιοθήκες ScriptForge και Access2Base. Τα πλήκτρα κλεισίματος διαλόγου είναι απενεργοποιημένα και ο ρητός τερματισμός εκτελείται στο τέλος μιας εκτελούμενης διαδικασίας.

Σε αυτό το παράδειγμα, ένα πλήκτρο στην DlgConsole αντικαθιστά το κλείσιμο παραθύρου με αναστολή:

Σε Basic

     oDlg = CreateScriptService("SFDialogs.Dialog","GlobalScope","ScriptForge","DlgConsole")
     oDlg.Execute(modal:=False)
     Wait 5000
     oDlg.Terminate()
   
Σε Python

     from time import sleep
     dlg = CreateScriptService('SFDialogs.Dialog',"GlobalScope",'Access2Base',"dlgTrace")
     dlg.Execute(modal=False)
     sleep 5
     dlg.Terminate()
   
warning

Όλες οι ρουτίνες ή αναγνωριστικά του ScriptForge στη Basic που έχουν το πρόθεμα χαρακτήρα υπογράμμισης "_" δεσμεύονται για εσωτερική χρήση. Δεν προορίζονται να χρησιμοποιηθούν σε μακροεντολές Basic ή σενάρια Python.