SF_Dialog.xba 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Dialog" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
  4. REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
  5. REM === The SFDialogs library is one of the associated libraries. ===
  6. REM === Full documentation is available on https://help.libreoffice.org/ ===
  7. REM =======================================================================================================================
  8. Option Compatible
  9. Option ClassModule
  10. Option Explicit
  11. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  12. &apos;&apos;&apos; SF_Dialog
  13. &apos;&apos;&apos; =========
  14. &apos;&apos;&apos; Management of dialogs defined with the Basic IDE
  15. &apos;&apos;&apos; Each instance of the current class represents a single dialog box displayed to the user
  16. &apos;&apos;&apos;
  17. &apos;&apos;&apos; A dialog box can be displayed in modal or in non-modal modes
  18. &apos;&apos;&apos; In modal mode, the box is displayed and the execution of the macro process is suspended
  19. &apos;&apos;&apos; until one of the OK or Cancel buttons is pressed. In the meantime, other user actions
  20. &apos;&apos;&apos; executed on the box can trigger specific actions.
  21. &apos;&apos;&apos; In non-modal mode, the dialog box is &quot;floating&quot; on the user desktop and the execution
  22. &apos;&apos;&apos; of the macro process continues normally
  23. &apos;&apos;&apos; A dialog box disappears from memory after its explicit termination.
  24. &apos;&apos;&apos;
  25. &apos;&apos;&apos; Service invocation and usage:
  26. &apos;&apos;&apos; Dim myDialog As Object, lButton As Long
  27. &apos;&apos;&apos; Set myDialog = CreateScriptService(&quot;SFDialogs.Dialog&quot;, Container, Library, DialogName)
  28. &apos;&apos;&apos; &apos; Args:
  29. &apos;&apos;&apos; &apos; Container: &quot;GlobalScope&quot; for preinstalled libraries
  30. &apos;&apos;&apos; &apos; A window name (see its definition in the ScriptForge.UI service)
  31. &apos;&apos;&apos; &apos; &quot;&quot; (default) = the current document
  32. &apos;&apos;&apos; &apos; Library: The (case-sensitive) name of a library contained in the container
  33. &apos;&apos;&apos; &apos; Default = &quot;Standard&quot;
  34. &apos;&apos;&apos; &apos; DialogName: a case-sensitive string designating the dialog where it is about
  35. &apos;&apos;&apos; &apos; ... Initialize controls ...
  36. &apos;&apos;&apos; lButton = myDialog.Execute() &apos; Default mode = Modal
  37. &apos;&apos;&apos; If lButton = myDialog.OKBUTTON Then
  38. &apos;&apos;&apos; &apos; ... Process controls and do what is needed
  39. &apos;&apos;&apos; End If
  40. &apos;&apos;&apos; myDialog.Terminate()
  41. &apos;&apos;&apos;
  42. &apos;&apos;&apos; Detailed user documentation:
  43. &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_dialog.html?DbPAR=BASIC
  44. &apos;&apos;&apos;
  45. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  46. REM ================================================================== EXCEPTIONS
  47. Private Const DIALOGDEADERROR = &quot;DIALOGDEADERROR&quot;
  48. Private Const PAGEMANAGERERROR = &quot;PAGEMANAGERERROR&quot;
  49. REM ============================================================= PRIVATE MEMBERS
  50. Private [Me] As Object
  51. Private [_Parent] As Object
  52. Private ObjectType As String &apos; Must be DIALOG
  53. Private ServiceName As String
  54. &apos; Dialog location
  55. Private _Container As String
  56. Private _Library As String
  57. Private _Name As String
  58. Private _CacheIndex As Long &apos; Index in cache storage
  59. &apos; Dialog UNO references
  60. Private _DialogProvider As Object &apos; com.sun.star.io.XInputStreamProvider
  61. Private _DialogControl As Object &apos; com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
  62. Private _DialogModel As Object &apos; com.sun.star.awt.XControlModel - stardiv.Toolkit.UnoControlDialogModel
  63. &apos; Dialog attributes
  64. Private _Displayed As Boolean &apos; True after Execute()
  65. Private _Modal As Boolean &apos; Set by Execute()
  66. &apos; Dialog position and dimensions
  67. Private _Left As Long
  68. Private _Top As Long
  69. Private _Width As Long
  70. Private _Height As Long
  71. &apos; Page management
  72. Type _PageManager
  73. ControlName As String &apos; Case-sensitive name of control involved in page management
  74. PageMgtType As Integer &apos; One of the PILOTCONTROL, TABCONTROL, NEXTCONTROL, BACKCONTROL constants
  75. PageNumber As Long &apos; When &gt; 0, the page to activate for tab controls
  76. ListenerType As Integer &apos; One of the ITEMSTATECHANGED, ACTIONPERFORMED constants
  77. End Type
  78. Private _PageManagement As Variant &apos; Array of _PageManager objects, one entry by involved control
  79. Private _ItemListener As Object &apos; com.sun.star.awt.XItemListener
  80. Private _ActionListener As Object &apos; com.sun.star.awt.XActionListener
  81. Private _LastPage As Long &apos; When &gt; 0, the last page in a tabbed dialog
  82. &apos; Persistent storage for controls
  83. Private _ControlCache As Variant &apos; Array of control objects sorted like ElementNames of the Dialog model
  84. REM ============================================================ MODULE CONSTANTS
  85. &apos; Dialog usual buttons
  86. Private Const OKBUTTON = 1
  87. Private Const CANCELBUTTON = 0
  88. &apos; Page management
  89. Private Const PILOTCONTROL = 1
  90. Private Const TABCONTROL = 2
  91. Private Const BACKCONTROL = 3
  92. Private Const NEXTCONTROL = 4
  93. Private Const ITEMSTATECHANGED = 1
  94. Private Const ACTIONPERFORMED = 2
  95. REM ====================================================== CONSTRUCTOR/DESTRUCTOR
  96. REM -----------------------------------------------------------------------------
  97. Private Sub Class_Initialize()
  98. Set [Me] = Nothing
  99. Set [_Parent] = Nothing
  100. ObjectType = &quot;DIALOG&quot;
  101. ServiceName = &quot;SFDialogs.Dialog&quot;
  102. _Container = &quot;&quot;
  103. _Library = &quot;&quot;
  104. _Name = &quot;&quot;
  105. _CacheIndex = -1
  106. Set _DialogProvider = Nothing
  107. Set _DialogControl = Nothing
  108. Set _DialogModel = Nothing
  109. _Displayed = False
  110. _Modal = True
  111. _Left = -1
  112. _Top = -1
  113. _Width = -1
  114. _Height = -1
  115. _PageManagement = Array()
  116. Set _ItemListener = Nothing
  117. Set _ActionListener = Nothing
  118. _LastPage = 0
  119. _ControlCache = Array()
  120. End Sub &apos; SFDialogs.SF_Dialog Constructor
  121. REM -----------------------------------------------------------------------------
  122. Private Sub Class_Terminate()
  123. Call Class_Initialize()
  124. End Sub &apos; SFDialogs.SF_Dialog Destructor
  125. REM -----------------------------------------------------------------------------
  126. Public Function Dispose() As Variant
  127. If _CacheIndex &gt;= 0 Then Terminate()
  128. Call Class_Terminate()
  129. Set Dispose = Nothing
  130. End Function &apos; SFDialogs.SF_Dialog Explicit Destructor
  131. REM ================================================================== PROPERTIES
  132. REM -----------------------------------------------------------------------------
  133. Property Get Caption() As Variant
  134. &apos;&apos;&apos; The Caption property refers to the title of the dialog
  135. Caption = _PropertyGet(&quot;Caption&quot;)
  136. End Property &apos; SFDialogs.SF_Dialog.Caption (get)
  137. REM -----------------------------------------------------------------------------
  138. Property Let Caption(Optional ByVal pvCaption As Variant)
  139. &apos;&apos;&apos; Set the updatable property Caption
  140. _PropertySet(&quot;Caption&quot;, pvCaption)
  141. End Property &apos; SFDialogs.SF_Dialog.Caption (let)
  142. REM -----------------------------------------------------------------------------
  143. Property Get Height() As Variant
  144. &apos;&apos;&apos; The Height property refers to the height of the dialog box
  145. Height = _PropertyGet(&quot;Height&quot;)
  146. End Property &apos; SFDialogs.SF_Dialog.Height (get)
  147. REM -----------------------------------------------------------------------------
  148. Property Let Height(Optional ByVal pvHeight As Variant)
  149. &apos;&apos;&apos; Set the updatable property Height
  150. _PropertySet(&quot;Height&quot;, pvHeight)
  151. End Property &apos; SFDialogs.SF_Dialog.Height (let)
  152. REM -----------------------------------------------------------------------------
  153. Property Get Modal() As Boolean
  154. &apos;&apos;&apos; The Modal property specifies if the dialog box has been executed in modal mode
  155. Modal = _PropertyGet(&quot;Modal&quot;)
  156. End Property &apos; SFDialogs.SF_Dialog.Modal (get)
  157. REM -----------------------------------------------------------------------------
  158. Property Get Name() As String
  159. &apos;&apos;&apos; Return the name of the actual dialog
  160. Name = _PropertyGet(&quot;Name&quot;)
  161. End Property &apos; SFDialogs.SF_Dialog.Name
  162. REM -----------------------------------------------------------------------------
  163. Property Get OnFocusGained() As Variant
  164. &apos;&apos;&apos; Get the script associated with the OnFocusGained event
  165. OnFocusGained = _PropertyGet(&quot;OnFocusGained&quot;)
  166. End Property &apos; SFDialogs.SF_Dialog.OnFocusGained (get)
  167. REM -----------------------------------------------------------------------------
  168. Property Get OnFocusLost() As Variant
  169. &apos;&apos;&apos; Get the script associated with the OnFocusLost event
  170. OnFocusLost = _PropertyGet(&quot;OnFocusLost&quot;)
  171. End Property &apos; SFDialogs.SF_Dialog.OnFocusLost (get)
  172. REM -----------------------------------------------------------------------------
  173. Property Get OnKeyPressed() As Variant
  174. &apos;&apos;&apos; Get the script associated with the OnKeyPressed event
  175. OnKeyPressed = _PropertyGet(&quot;OnKeyPressed&quot;)
  176. End Property &apos; SFDialogs.SF_Dialog.OnKeyPressed (get)
  177. REM -----------------------------------------------------------------------------
  178. Property Get OnKeyReleased() As Variant
  179. &apos;&apos;&apos; Get the script associated with the OnKeyReleased event
  180. OnKeyReleased = _PropertyGet(&quot;OnKeyReleased&quot;)
  181. End Property &apos; SFDialogs.SF_Dialog.OnKeyReleased (get)
  182. REM -----------------------------------------------------------------------------
  183. Property Get OnMouseDragged() As Variant
  184. &apos;&apos;&apos; Get the script associated with the OnMouseDragged event
  185. OnMouseDragged = _PropertyGet(&quot;OnMouseDragged&quot;)
  186. End Property &apos; SFDialogs.SF_Dialog.OnMouseDragged (get)
  187. REM -----------------------------------------------------------------------------
  188. Property Get OnMouseEntered() As Variant
  189. &apos;&apos;&apos; Get the script associated with the OnMouseEntered event
  190. OnMouseEntered = _PropertyGet(&quot;OnMouseEntered&quot;)
  191. End Property &apos; SFDialogs.SF_Dialog.OnMouseEntered (get)
  192. REM -----------------------------------------------------------------------------
  193. Property Get OnMouseExited() As Variant
  194. &apos;&apos;&apos; Get the script associated with the OnMouseExited event
  195. OnMouseExited = _PropertyGet(&quot;OnMouseExited&quot;)
  196. End Property &apos; SFDialogs.SF_Dialog.OnMouseExited (get)
  197. REM -----------------------------------------------------------------------------
  198. Property Get OnMouseMoved() As Variant
  199. &apos;&apos;&apos; Get the script associated with the OnMouseMoved event
  200. OnMouseMoved = _PropertyGet(&quot;OnMouseMoved&quot;)
  201. End Property &apos; SFDialogs.SF_Dialog.OnMouseMoved (get)
  202. REM -----------------------------------------------------------------------------
  203. Property Get OnMousePressed() As Variant
  204. &apos;&apos;&apos; Get the script associated with the OnMousePressed event
  205. OnMousePressed = _PropertyGet(&quot;OnMousePressed&quot;)
  206. End Property &apos; SFDialogs.SF_Dialog.OnMousePressed (get)
  207. REM -----------------------------------------------------------------------------
  208. Property Get OnMouseReleased() As Variant
  209. &apos;&apos;&apos; Get the script associated with the OnMouseReleased event
  210. OnMouseReleased = _PropertyGet(&quot;OnMouseReleased&quot;)
  211. End Property &apos; SFDialogs.SF_Dialog.OnMouseReleased (get)
  212. REM -----------------------------------------------------------------------------
  213. Property Get Page() As Variant
  214. &apos;&apos;&apos; A dialog may have several pages that can be traversed by the user step by step.
  215. &apos;&apos;&apos; The Page property of the Dialog object defines which page of the dialog is active.
  216. &apos;&apos;&apos; The Page property of a control defines the page of the dialog on which the control is visible.
  217. &apos;&apos;&apos; For example, if a control has a page value of 1, it is only visible on page 1 of the dialog.
  218. &apos;&apos;&apos; If the page value of the dialog is increased from 1 to 2, then all controls with a page value of 1 disappear
  219. &apos;&apos;&apos; and all controls with a page value of 2 become visible.
  220. Page = _PropertyGet(&quot;Page&quot;)
  221. End Property &apos; SFDialogs.SF_Dialog.Page (get)
  222. REM -----------------------------------------------------------------------------
  223. Property Let Page(Optional ByVal pvPage As Variant)
  224. &apos;&apos;&apos; Set the updatable property Page
  225. _PropertySet(&quot;Page&quot;, pvPage)
  226. End Property &apos; SFDialogs.SF_Dialog.Page (let)
  227. REM -----------------------------------------------------------------------------
  228. Property Get Visible() As Variant
  229. &apos;&apos;&apos; The Visible property is False before the Execute() statement
  230. Visible = _PropertyGet(&quot;Visible&quot;)
  231. End Property &apos; SFDialogs.SF_Dialog.Visible (get)
  232. REM -----------------------------------------------------------------------------
  233. Property Let Visible(Optional ByVal pvVisible As Variant)
  234. &apos;&apos;&apos; Set the updatable property Visible
  235. _PropertySet(&quot;Visible&quot;, pvVisible)
  236. End Property &apos; SFDialogs.SF_Dialog.Visible (let)
  237. REM -----------------------------------------------------------------------------
  238. Property Get Width() As Variant
  239. &apos;&apos;&apos; The Width property refers to the Width of the dialog box
  240. Width = _PropertyGet(&quot;Width&quot;)
  241. End Property &apos; SFDialogs.SF_Dialog.Width (get)
  242. REM -----------------------------------------------------------------------------
  243. Property Let Width(Optional ByVal pvWidth As Variant)
  244. &apos;&apos;&apos; Set the updatable property Width
  245. _PropertySet(&quot;Width&quot;, pvWidth)
  246. End Property &apos; SFDialogs.SF_Dialog.Width (let)
  247. REM -----------------------------------------------------------------------------
  248. Property Get XDialogModel() As Object
  249. &apos;&apos;&apos; The XDialogModel property returns the model UNO object of the dialog
  250. XDialogModel = _PropertyGet(&quot;XDialogModel&quot;)
  251. End Property &apos; SFDialogs.SF_Dialog.XDialogModel (get)
  252. REM -----------------------------------------------------------------------------
  253. Property Get XDialogView() As Object
  254. &apos;&apos;&apos; The XDialogView property returns the view UNO object of the dialog
  255. XDialogView = _PropertyGet(&quot;XDialogView&quot;)
  256. End Property &apos; SFDialogs.SF_Dialog.XDialogView (get)
  257. REM ===================================================================== METHODS
  258. REM -----------------------------------------------------------------------------
  259. Public Function Activate() As Boolean
  260. &apos;&apos;&apos; Set the focus on the current dialog instance
  261. &apos;&apos;&apos; Probably called from after an event occurrence or to focus on a non-modal dialog
  262. &apos;&apos;&apos; Args:
  263. &apos;&apos;&apos; Returns:
  264. &apos;&apos;&apos; True if focusing is successful
  265. &apos;&apos;&apos; Example:
  266. &apos;&apos;&apos; Dim oDlg As Object
  267. &apos;&apos;&apos; Set oDlg = CreateScriptService(,, &quot;myDialog&quot;) &apos; Dialog stored in current document&apos;s standard library
  268. &apos;&apos;&apos; oDlg.Activate()
  269. Dim bActivate As Boolean &apos; Return value
  270. Const cstThisSub = &quot;SFDialogs.Dialog.Activate&quot;
  271. Const cstSubArgs = &quot;&quot;
  272. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  273. bActivate = False
  274. Check:
  275. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  276. If Not _IsStillAlive() Then GoTo Finally
  277. End If
  278. Try:
  279. If Not IsNull(_DialogControl) Then
  280. _DialogControl.setFocus()
  281. bActivate = True
  282. End If
  283. Finally:
  284. Activate = bActivate
  285. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  286. Exit Function
  287. Catch:
  288. GoTo Finally
  289. End Function &apos; SFDialogs.SF_Dialog.Activate
  290. REM -----------------------------------------------------------------------------
  291. Public Function Center(Optional ByRef Parent As Variant) As Boolean
  292. &apos;&apos;&apos; Center the actual dialog instance in the middle of a parent window
  293. &apos;&apos;&apos; Without arguments, the method centers the dialog in the middle of the current window
  294. &apos;&apos;&apos; Args:
  295. &apos;&apos;&apos; Parent: an object, either
  296. &apos;&apos;&apos; - a ScriptForge dialog object
  297. &apos;&apos;&apos; - a ScriptForge document (Calc, Base, ...) object
  298. &apos;&apos;&apos; Returns:
  299. &apos;&apos;&apos; True when successful
  300. &apos;&apos;&apos; Examples:
  301. &apos;&apos;&apos; Sub TriggerEvent(oEvent As Object)
  302. &apos;&apos;&apos; Dim oDialog1 As Object, oDialog2 As Object, lExec As Long
  303. &apos;&apos;&apos; Set oDialog1 = CreateScriptService(&quot;DialogEvent&quot;, oEvent) &apos; The dialog having caused the event
  304. &apos;&apos;&apos; Set oDialog2 = CreateScriptService(&quot;Dialog&quot;, ...) &apos; Open a second dialog
  305. &apos;&apos;&apos; oDialog2.Center(oDialog1)
  306. &apos;&apos;&apos; lExec = oDialog2.Execute()
  307. &apos;&apos;&apos; Select Case lExec
  308. &apos;&apos;&apos; ...
  309. &apos;&apos;&apos; End Sub
  310. Dim bCenter As Boolean &apos; Return value
  311. Dim oUi As Object &apos; ScriptForge.SF_UI
  312. Dim oObjDesc As Object &apos; _ObjectDescriptor type
  313. Dim sObjectType As String &apos; Can be uno or sf object type
  314. Dim oParent As Object &apos; UNO alias of parent
  315. Dim oParentPosSize As Object &apos; Parent com.sun.star.awt.Rectangle
  316. Dim lParentX As Long &apos; X position of parent dialog
  317. Dim lParentY As Long &apos; Y position of parent dialog
  318. Dim oPosSize As Object &apos; Dialog com.sun.star.awt.Rectangle
  319. Const cstThisSub = &quot;SFDialogs.Dialog.Center&quot;
  320. Const cstSubArgs = &quot;[Parent]&quot;
  321. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  322. bCenter = False
  323. Check:
  324. If IsMissing(Parent) Or IsEmpty(Parent) Then Set Parent = Nothing
  325. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  326. If Not ScriptForge.SF_Utils._Validate(Parent, &quot;Parent&quot;, ScriptForge.V_OBJECT) Then GoTo Finally
  327. End If
  328. Set oParentPosSize = Nothing
  329. lParentX = 0 : lParentY = 0
  330. If IsNull(Parent) Then
  331. Set oUi = CreateScriptService(&quot;UI&quot;)
  332. Set oParentPosSize = oUi._PosSize() &apos; Return the position and dimensions of the active window
  333. Else
  334. &apos; Determine the object type
  335. Set oObjDesc = ScriptForge.SF_Utils._VarTypeObj(Parent)
  336. If oObjDesc.iVarType = ScriptForge.V_SFOBJECT Then &apos; ScriptForge object
  337. sObjectType = oObjDesc.sObjectType
  338. &apos; Document or dialog ?
  339. If Not ScriptForge.SF_Array.Contains(Array(&quot;BASE&quot;, &quot;CALC&quot;, &quot;DIALOG&quot;, &quot;DOCUMENT&quot;, &quot;WRITER&quot;), sObjectType, CaseSensitive := True) Then GoTo Finally
  340. If sObjectType = &quot;DIALOG&quot; Then
  341. Set oParent = Parent._DialogControl
  342. Set oParentPosSize = oParent.getPosSize()
  343. lParentX = oParentPosSize.X
  344. lParentY = oParentPosSize.Y
  345. Else
  346. Set oParent = Parent._Component.getCurrentController().Frame.getComponentWindow()
  347. Set oParentPosSize = oParent.getPosSize()
  348. End If
  349. Else
  350. GoTo Finally &apos; UNO object, do nothing
  351. End If
  352. End If
  353. If IsNull(oParentPosSize) Then GoTo Finally
  354. Try:
  355. Set oPosSize = _DialogControl.getPosSize()
  356. With oPosSize
  357. _DialogControl.setPosSize( _
  358. lParentX + CLng((oParentPosSize.Width - .Width) \ 2) _
  359. , lParentY + CLng((oParentPosSize.Height - .Height) \ 2) _
  360. , .Width _
  361. , .Height _
  362. , com.sun.star.awt.PosSize.POSSIZE)
  363. End With
  364. bCenter = True
  365. Finally:
  366. Center = bCenter
  367. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  368. Exit Function
  369. Catch:
  370. GoTo Finally
  371. End Function &apos; SF_Documents.SF_Dialog.Center
  372. REM -----------------------------------------------------------------------------
  373. Public Function Controls(Optional ByVal ControlName As Variant) As Variant
  374. &apos;&apos;&apos; Return either
  375. &apos;&apos;&apos; - the list of the controls contained in the dialog
  376. &apos;&apos;&apos; - a dialog control object based on its name
  377. &apos;&apos;&apos; Args:
  378. &apos;&apos;&apos; ControlName: a valid control name as a case-sensitive string. If absent the list is returned
  379. &apos;&apos;&apos; Returns:
  380. &apos;&apos;&apos; A zero-base array of strings if ControlName is absent
  381. &apos;&apos;&apos; An instance of the SF_DialogControl class if ControlName exists
  382. &apos;&apos;&apos; Exceptions:
  383. &apos;&apos;&apos; ControlName is invalid
  384. &apos;&apos;&apos; Example:
  385. &apos;&apos;&apos; Dim myDialog As Object, myList As Variant, myControl As Object
  386. &apos;&apos;&apos; Set myDialog = CreateScriptService(&quot;SFDialogs.Dialog&quot;, Container, Library, DialogName)
  387. &apos;&apos;&apos; myList = myDialog.Controls()
  388. &apos;&apos;&apos; Set myControl = myDialog.Controls(&quot;myTextBox&quot;)
  389. Dim oControl As Object &apos; The new control class instance
  390. Dim lIndexOfNames As Long &apos; Index in ElementNames array. Used to access _ControlCache
  391. Dim vControl As Variant &apos; Alias of _ControlCache entry
  392. Const cstThisSub = &quot;SFDialogs.Dialog.Controls&quot;
  393. Const cstSubArgs = &quot;[ControlName]&quot;
  394. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  395. Check:
  396. If IsMissing(ControlName) Or IsEmpty(ControlName) Then ControlName = &quot;&quot;
  397. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  398. If Not _IsStillAlive() Then GoTo Finally
  399. If Not ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING) Then GoTo Finally
  400. End If
  401. Try:
  402. If Len(ControlName) = 0 Then
  403. Controls = _DialogModel.getElementNames()
  404. Else
  405. If Not _DialogModel.hasByName(ControlName) Then GoTo CatchNotFound
  406. lIndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
  407. &apos; Reuse cache when relevant
  408. vControl = _ControlCache(lIndexOfNames)
  409. If IsEmpty(vControl) Then
  410. &apos; Create the new dialog control class instance
  411. Set oControl = New SF_DialogControl
  412. With oControl
  413. ._Name = ControlName
  414. Set .[Me] = oControl
  415. Set .[_Parent] = [Me]
  416. ._IndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
  417. ._DialogName = _Name
  418. Set ._ControlModel = _DialogModel.getByName(ControlName)
  419. Set ._ControlView = _DialogControl.getControl(ControlName)
  420. ._Initialize()
  421. End With
  422. Else
  423. Set oControl = vControl
  424. End If
  425. Set Controls = oControl
  426. End If
  427. Finally:
  428. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  429. Exit Function
  430. Catch:
  431. GoTo Finally
  432. CatchNotFound:
  433. ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING, _DialogModel.getElementNames())
  434. GoTo Finally
  435. End Function &apos; SFDialogs.SF_Dialog.Controls
  436. REM -----------------------------------------------------------------------------
  437. Public Sub EndExecute(Optional ByVal ReturnValue As Variant)
  438. &apos;&apos;&apos; Ends the display of a modal dialog and gives back the argument
  439. &apos;&apos;&apos; as return value for the current Execute() action
  440. &apos;&apos;&apos; EndExecute is usually contained in the processing of a macro
  441. &apos;&apos;&apos; triggered by a dialog or control event
  442. &apos;&apos;&apos; Args:
  443. &apos;&apos;&apos; ReturnValue: must be numeric. The value passed to the running Execute() method
  444. &apos;&apos;&apos; Example:
  445. &apos;&apos;&apos; Sub OnEvent(poEvent As Variant)
  446. &apos;&apos;&apos; Dim oDlg As Object
  447. &apos;&apos;&apos; Set oDlg = CreateScriptService(&quot;SFDialogs.DialogEvent&quot;, poEvent)
  448. &apos;&apos;&apos; oDlg.EndExecute(25)
  449. &apos;&apos;&apos; End Sub
  450. Dim lExecute As Long &apos; Alias of ReturnValue
  451. Const cstThisSub = &quot;SFDialogs.Dialog.EndExecute&quot;
  452. Const cstSubArgs = &quot;ReturnValue&quot;
  453. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  454. Check:
  455. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  456. If Not _IsStillAlive() Then GoTo Finally
  457. If Not ScriptForge.SF_Utils._Validate(ReturnValue, &quot;ReturnValue&quot;, V_NUMERIC) Then GoTo Finally
  458. End If
  459. Try:
  460. lExecute = CLng(ReturnValue)
  461. Call _DialogControl.endDialog(lExecute)
  462. Finally:
  463. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  464. Exit Sub
  465. Catch:
  466. GoTo Finally
  467. End Sub &apos; SFDialogs.SF_Dialog.EndExecute
  468. REM -----------------------------------------------------------------------------
  469. Public Function Execute(Optional ByVal Modal As Variant) As Long
  470. &apos;&apos;&apos; Display the dialog and wait for its termination by the user
  471. &apos;&apos;&apos; Args:
  472. &apos;&apos;&apos; Modal: False when non-modal dialog. Default = True
  473. &apos;&apos;&apos; Returns:
  474. &apos;&apos;&apos; 0 = Cancel button pressed
  475. &apos;&apos;&apos; 1 = OK button pressed
  476. &apos;&apos;&apos; Otherwise: the dialog stopped with an EndExecute statement executed from a dialog or control event
  477. &apos;&apos;&apos; Example:
  478. &apos;&apos;&apos; Dim oDlg As Object, lReturn As Long
  479. &apos;&apos;&apos; Set oDlg = CreateScriptService(,, &quot;myDialog&quot;) &apos; Dialog stored in current document&apos;s standard library
  480. &apos;&apos;&apos; lReturn = oDlg.Execute()
  481. &apos;&apos;&apos; Select Case lReturn
  482. Dim lExecute As Long &apos; Return value
  483. Const cstThisSub = &quot;SFDialogs.Dialog.Execute&quot;
  484. Const cstSubArgs = &quot;[Modal=True]&quot;
  485. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  486. lExecute = -1
  487. Check:
  488. If IsMissing(Modal) Or IsEmpty(Modal) Then Modal = True
  489. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  490. If Not _IsStillAlive() Then GoTo Finally
  491. If Not ScriptForge.SF_Utils._Validate(Modal, &quot;Modal&quot;, V_BOOLEAN) Then GoTo Finally
  492. End If
  493. Try:
  494. If Modal Then
  495. _Modal = True
  496. _Displayed = True
  497. lExecute = _DialogControl.execute()
  498. Select Case lExecute
  499. Case 1 : lExecute = OKBUTTON
  500. Case 0 : lExecute = CANCELBUTTON
  501. Case Else
  502. End Select
  503. _Displayed = False
  504. Else
  505. _Modal = False
  506. _Displayed = True
  507. _DialogModel.DesktopAsParent = True
  508. _DialogControl.setVisible(True)
  509. lExecute = 0
  510. End If
  511. Finally:
  512. Execute = lExecute
  513. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  514. Exit Function
  515. Catch:
  516. &apos; When an error is caused by an event error, the location is unknown
  517. SF_Exception.Raise(, &quot;?&quot;)
  518. GoTo Finally
  519. End Function &apos; SFDialogs.SF_Dialog.Execute
  520. REM -----------------------------------------------------------------------------
  521. Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
  522. &apos;&apos;&apos; Return the actual value of the given property
  523. &apos;&apos;&apos; Args:
  524. &apos;&apos;&apos; PropertyName: the name of the property as a string
  525. &apos;&apos;&apos; Returns:
  526. &apos;&apos;&apos; The actual value of the property
  527. &apos;&apos;&apos; Exceptions:
  528. &apos;&apos;&apos; ARGUMENTERROR The property does not exist
  529. &apos;&apos;&apos; Examples:
  530. &apos;&apos;&apos; oDlg.GetProperty(&quot;Caption&quot;)
  531. Const cstThisSub = &quot;SFDialogs.Dialog.GetProperty&quot;
  532. Const cstSubArgs = &quot;&quot;
  533. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  534. GetProperty = Null
  535. Check:
  536. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  537. If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  538. End If
  539. Try:
  540. GetProperty = _PropertyGet(PropertyName)
  541. Finally:
  542. SF_Utils._ExitFunction(cstThisSub)
  543. Exit Function
  544. Catch:
  545. GoTo Finally
  546. End Function &apos; SFDialogs.SF_Dialog.GetProperty
  547. REM -----------------------------------------------------------------------------
  548. Public Function GetTextsFromL10N(Optional ByRef L10N As Variant) As Boolean
  549. &apos;&apos;&apos; Replace all fixed text strings of a dialog by their localized version
  550. &apos;&apos;&apos; Replaced texts are:
  551. &apos;&apos;&apos; - the title of the dialog
  552. &apos;&apos;&apos; - the caption associated with next control types: Button, CheckBox, FixedLine, FixedText, GroupBox and RadioButton
  553. &apos;&apos;&apos; - the content of list- and comboboxes
  554. &apos;&apos;&apos; - the tip- or helptext displayed when the mouse is hovering the control
  555. &apos;&apos;&apos; The current method has a twin method ScriptForge.SF_L10N.AddTextsFromDialog
  556. &apos;&apos;&apos; The current method is probably run before the Execute() method
  557. &apos;&apos;&apos; Args:
  558. &apos;&apos;&apos; L10N : a &quot;L10N&quot; service instance created with CreateScriptService(&quot;L10N&quot;)
  559. &apos;&apos;&apos; Returns:
  560. &apos;&apos;&apos; True when successful
  561. &apos;&apos;&apos; Examples:
  562. &apos;&apos;&apos; Dim myPO As Object, oDlg As Object
  563. &apos;&apos;&apos; Set oDlg = CreateScriptService(&quot;Dialog&quot;, &quot;GlobalScope&quot;, &quot;XrayTool&quot;, &quot;DlgXray&quot;)
  564. &apos;&apos;&apos; Set myPO = CreateScriptService(&quot;L10N&quot;, &quot;C:\myPOFiles\&quot;, &quot;fr-BE&quot;)
  565. &apos;&apos;&apos; oDlg.GetTextsFromL10N(myPO)
  566. Dim bGet As Boolean &apos; Return value
  567. Dim vControls As Variant &apos; Array of control names
  568. Dim sControl As String &apos; A single control name
  569. Dim oControl As Object &apos; SFDialogs.DialogControl
  570. Dim sText As String &apos; The text found in the dialog
  571. Dim sTranslation As String &apos; The translated text got from the dictionary
  572. Dim vSource As Variant &apos; RowSource property of dialog control as an array
  573. Dim bChanged As Boolean &apos; True when at least 1 item of a RowSource is modified
  574. Dim i As Long
  575. Const cstThisSub = &quot;SFDialogs.Dialog.GetTextsFromL10N&quot;
  576. Const cstSubArgs = &quot;L10N&quot;
  577. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  578. bGet = False
  579. Check:
  580. If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  581. If Not SF_Utils._Validate(L10N, &quot;L10N&quot;, V_OBJECT, , , &quot;L10N&quot;) Then GoTo Finally
  582. End If
  583. Try:
  584. &apos; Get the dialog title
  585. sText = Caption
  586. If Len(sText) &gt; 0 Then
  587. sTranslation = L10N._(sText)
  588. If sText &lt;&gt; sTranslation Then Caption = sTranslation
  589. End If
  590. &apos; Scan all controls
  591. vControls = Controls()
  592. For Each sControl In vControls
  593. Set oControl = Controls(sControl)
  594. With oControl
  595. &apos; Extract fixed texts
  596. sText = .Caption
  597. If Len(sText) &gt; 0 Then
  598. sTranslation = L10N._(sText)
  599. If sText &lt;&gt; sTranslation Then .Caption = sTranslation
  600. End If
  601. vSource = .RowSource &apos; List and comboboxes only
  602. If IsArray(vSource) Then
  603. bChanged = False
  604. For i = 0 To UBound(vSource)
  605. If Len(vSource(i)) &gt; 0 Then
  606. sTranslation = L10N._(vSource(i))
  607. If sTranslation &lt;&gt; vSource(i) Then
  608. bChanged = True
  609. vSource(i) = sTranslation
  610. End If
  611. End If
  612. Next i
  613. &apos; Rewrite if at least 1 item has been modified by the translation process
  614. If bChanged Then .RowSource = vSource
  615. End If
  616. sText = .TipText
  617. If Len(sText) &gt; 0 Then
  618. sTranslation = L10N._(sText)
  619. If sText &lt;&gt; sTranslation Then .TipText = sTranslation
  620. End If
  621. End With
  622. Next sControl
  623. bGet = True
  624. Finally:
  625. GetTextsFromL10N = bGet
  626. SF_Utils._ExitFunction(cstThisSub)
  627. Exit Function
  628. Catch:
  629. GoTo Finally
  630. End Function &apos; SFDialogs.SF_Dialog.GetTextsFromL10N
  631. REM -----------------------------------------------------------------------------
  632. Public Function Methods() As Variant
  633. &apos;&apos;&apos; Return the list of public methods of the Model service as an array
  634. Methods = Array( _
  635. &quot;Activate&quot; _
  636. , &quot;Center&quot; _
  637. , &quot;Controls&quot; _
  638. , &quot;EndExecute&quot; _
  639. , &quot;Execute&quot; _
  640. , &quot;GetTextsFromL10N&quot; _
  641. , &quot;Resize&quot; _
  642. , &quot;SetPageManager&quot; _
  643. , &quot;Terminate&quot; _
  644. )
  645. End Function &apos; SFDialogs.SF_Dialog.Methods
  646. REM -----------------------------------------------------------------------------
  647. Public Function Properties() As Variant
  648. &apos;&apos;&apos; Return the list or properties of the Dialog class as an array
  649. Properties = Array( _
  650. &quot;Caption&quot; _
  651. , &quot;Height&quot; _
  652. , &quot;Modal&quot; _
  653. , &quot;Name&quot; _
  654. , &quot;OnFocusGained&quot; _
  655. , &quot;OnFocusLost&quot; _
  656. , &quot;OnKeyPressed&quot; _
  657. , &quot;OnKeyReleased&quot; _
  658. , &quot;OnMouseDragged&quot; _
  659. , &quot;OnMouseEntered&quot; _
  660. , &quot;OnMouseExited&quot; _
  661. , &quot;OnMouseMoved&quot; _
  662. , &quot;OnMousePressed&quot; _
  663. , &quot;OnMouseReleased&quot; _
  664. , &quot;Page&quot; _
  665. , &quot;Visible&quot; _
  666. , &quot;Width&quot; _
  667. , &quot;XDialogModel&quot; _
  668. , &quot;XDialogView&quot; _
  669. )
  670. End Function &apos; SFDialogs.SF_Dialog.Properties
  671. REM -----------------------------------------------------------------------------
  672. Public Function Resize(Optional ByVal Left As Variant _
  673. , Optional ByVal Top As Variant _
  674. , Optional ByVal Width As Variant _
  675. , Optional ByVal Height As Variant _
  676. ) As Boolean
  677. &apos;&apos;&apos; Move the top-left corner of a dialog to new coordinates and/or modify its dimensions
  678. &apos;&apos;&apos; All distances are expressed in 1/100 mm.
  679. &apos;&apos;&apos; Without arguments, the method resets the initial dimensions
  680. &apos;&apos;&apos; Args:
  681. &apos;&apos;&apos; Left : the horizontal distance from the top-left corner
  682. &apos;&apos;&apos; Top : the vertical distance from the top-left corner
  683. &apos;&apos;&apos; Width : the horizontal width of the rectangle containing the Dialog
  684. &apos;&apos;&apos; Height : the vertical height of the rectangle containing the Dialog
  685. &apos;&apos;&apos; Negative or missing arguments are left unchanged
  686. &apos;&apos;&apos; Returns:
  687. &apos;&apos;&apos; True when successful
  688. &apos;&apos;&apos; Examples:
  689. &apos;&apos;&apos; oDialog.Resize(1000, 2000, Height := 6000) &apos; Width is not changed
  690. Dim bResize As Boolean &apos; Return value
  691. Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
  692. Dim iFlags As Integer &apos; com.sun.star.awt.PosSize constants
  693. Const cstThisSub = &quot;SFDialogs.Dialog.Resize&quot;
  694. Const cstSubArgs = &quot;[Left], [Top], [Width], [Height]&quot;
  695. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  696. bResize = False
  697. Check:
  698. If IsMissing(Left) Or IsEmpty(Left) Then Left = -1
  699. If IsMissing(Top) Or IsEmpty(Top) Then Top = -1
  700. If IsMissing(Height) Or IsEmpty(Height) Then Height = -1
  701. If IsMissing(Width) Or IsEmpty(Width) Then Width = -1
  702. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  703. If Not ScriptForge.SF_Utils._Validate(Left, &quot;Left&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  704. If Not ScriptForge.SF_Utils._Validate(Top, &quot;Top&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  705. If Not ScriptForge.SF_Utils._Validate(Width, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  706. If Not ScriptForge.SF_Utils._Validate(Height, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  707. End If
  708. Try:
  709. With _DialogControl
  710. Set oPosSize = .getPosSize()
  711. &apos; Reset factory settings
  712. If Left = -1 And Top = -1 And Width = -1 And Height = -1 Then
  713. &apos;Left = _Left &apos; Initial positions determination is unstable
  714. &apos;Top = _Top
  715. Width = _Width
  716. Height = _Height
  717. End If
  718. &apos; Trace the elements to change
  719. iFlags = 0
  720. With com.sun.star.awt.PosSize
  721. If Left &gt;= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
  722. If Top &gt;= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
  723. If Width &gt; 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
  724. If Height &gt; 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
  725. End With
  726. &apos; Rewrite
  727. If iFlags &gt; 0 Then .setPosSize(CLng(Left), CLng(Top), CLng(Width), CLng(Height), iFlags)
  728. End With
  729. bResize = True
  730. Finally:
  731. Resize = bResize
  732. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  733. Exit Function
  734. Catch:
  735. GoTo Finally
  736. End Function &apos; SF_Documents.SF_Dialog.Resize
  737. REM -----------------------------------------------------------------------------
  738. Public Function SetPageManager(Optional ByVal PilotControls As Variant _
  739. , Optional ByVal TabControls As Variant _
  740. , Optional ByVal WizardControls As Variant _
  741. , Optional ByVal LastPage As variant _
  742. ) As Boolean
  743. &apos;&apos;&apos; Define how the dialog displays pages. The page manager is an alternative to the
  744. &apos;&apos;&apos; direct use of the Page property of the dialog and dialogcontrol objects.
  745. &apos;&apos;&apos;
  746. &apos;&apos;&apos; A dialog may have several pages that can be traversed by the user step by step.
  747. &apos;&apos;&apos; The Page property of the Dialog object defines which page of the dialog is active.
  748. &apos;&apos;&apos; The Page property of a control defines the page of the dialog on which the control is visible.
  749. &apos;&apos;&apos; For example, if a control has a page value of 1, it is only visible on page 1 of the dialog.
  750. &apos;&apos;&apos; If the page value of the dialog is increased from 1 to 2, then all controls with a page value of 1 disappear
  751. &apos;&apos;&apos; and all controls with a page value of 2 become visible.
  752. &apos;&apos;&apos;
  753. &apos;&apos;&apos; The arguments define which controls are involved in the orchestration of the displayed pages.
  754. &apos;&apos;&apos; Possible options:
  755. &apos;&apos;&apos; - select a value in a list- or combobox
  756. &apos;&apos;&apos; - select an item in a group of radio buttons
  757. &apos;&apos;&apos; - select a button linked to a page - placed side-by-side the buttons can simulate a tabbed interface
  758. &apos;&apos;&apos; - press a NEXT or BACK button like in many wizards
  759. &apos;&apos;&apos; Those options may be combined. The control updates will be synchronized.
  760. &apos;&apos;&apos; The method will set the actual page number to 1. Afterwards the Page property may be used to display any other page
  761. &apos;&apos;&apos;
  762. &apos;&apos;&apos; The SetPageManager() method is to be run only once and before the Execute() statement.
  763. &apos;&apos;&apos; If invoked several times, subsequent calls will be ignored.
  764. &apos;&apos;&apos; The method will define new listeners on the concerned controls, addressing generic routines.
  765. &apos;&apos;&apos; The corresponding events will be fired during the dialog execution.
  766. &apos;&apos;&apos; Preset events (in the Basic IDE) will be preserved and executed immediately AFTER the page change.
  767. &apos;&apos;&apos; The listeners will be removed at dialog termination.
  768. &apos;&apos;&apos;
  769. &apos;&apos;&apos; Args:
  770. &apos;&apos;&apos; PilotControls: a comma-separated list of listbox, combobox or radiobutton controls
  771. &apos;&apos;&apos; For radio buttons, provide the first in the group
  772. &apos;&apos;&apos; TabControls: a comma-separated list of button controls in ascending order
  773. &apos;&apos;&apos; WizardControls: a comma-separated list of 2 controls, a BACK button and a NEXT button
  774. &apos;&apos;&apos; LastPage: the index of the last available page. Recommended when use of WizardControls
  775. &apos;&apos;&apos; Returns:
  776. &apos;&apos;&apos; True when successful
  777. &apos;&apos;&apos; Examples:
  778. &apos;&apos;&apos; dialog.SetPageManager(PilotControls := &quot;aListBox,aComboBox&quot;) &apos; 2 controls may cause page changes
  779. Dim bManager As Boolean &apos; Return value
  780. Dim vControls As Variant &apos; Array of involved controls
  781. Dim oControl As Object &apos; A DialogControl object
  782. Dim i As Long
  783. Const cstPrefix = &quot;_SFTAB_&quot; &apos; Prefix of Subs to trigger when involved controls are clicked
  784. Const cstComma = &quot;,&quot;
  785. Const cstThisSub = &quot;SFDialogs.Dialog.SetPageManager&quot;
  786. Const cstSubArgs = &quot;[PilotControls=&quot;&quot;&quot;&quot;], [TabControls=&quot;&quot;&quot;&quot;], [WizardControls=&quot;&quot;&quot;&quot;]&quot;
  787. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  788. bManager = False
  789. Check:
  790. If IsMissing(PilotControls) Or IsEmpty(PilotControls) Then PilotControls = &quot;&quot;
  791. If IsMissing(TabControls) Or IsEmpty(TabControls) Then TabControls = &quot;&quot;
  792. If IsMissing(WizardControls) Or IsEmpty(WizardControls) Then WizardControls = &quot;&quot;
  793. If IsMissing(LastPage) Or IsEmpty(LastPage) Then LastPage = 0
  794. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  795. If Not ScriptForge.SF_Utils._Validate(PilotControls, &quot;PilotControls&quot;, V_STRING) Then GoTo Finally
  796. If Not ScriptForge.SF_Utils._Validate(TabControls, &quot;TabControls&quot;, V_STRING) Then GoTo Finally
  797. If Not ScriptForge.SF_Utils._Validate(WizardControls, &quot;WizardControls&quot;, V_STRING) Then GoTo Finally
  798. If Not ScriptForge.SF_Utils._Validate(LastPage, &quot;LastPage&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  799. End If
  800. &apos; Ignore the call if already done before
  801. If UBound(_PageManagement) &gt;= 0 Then GoTo Finally
  802. Try:
  803. &apos; Common listeners to all involved controls
  804. Set _ItemListener = CreateUnoListener(cstPrefix, &quot;com.sun.star.awt.XItemListener&quot;)
  805. Set _ActionListener = CreateUnoListener(cstPrefix, &quot;com.sun.star.awt.XActionListener&quot;)
  806. &apos; Register the arguments in the _PageManagement array, control by control
  807. &apos; Pilot controls
  808. If Len(PilotControls) &gt; 0 Then
  809. vControls = Split(PilotControls, cstComma)
  810. For i = 0 To UBound(vControls)
  811. If Not _RegisterPageListener(Trim(vControls(i)), &quot;ListBox,ComboBox,RadioButton&quot;, PILOTCONTROL, 0, ITEMSTATECHANGED) Then GoTo Catch
  812. Next i
  813. End If
  814. &apos; Tab controls
  815. If Len(TabControls) &gt; 0 Then
  816. vControls = Split(TabControls, cstComma)
  817. For i = 0 To UBound(vControls)
  818. If Not _RegisterPageListener(Trim(vControls(i)), &quot;Button&quot;, TABCONTROL, i + 1, ACTIONPERFORMED) Then GoTo Catch
  819. Next i
  820. End If
  821. &apos; Wizard controls
  822. If Len(WizardControls) &gt; 0 Then
  823. vControls = Split(WizardControls, cstComma)
  824. For i = 0 To UBound(vControls)
  825. If Not _RegisterPageListener(Trim(vControls(i)), &quot;Button&quot;, Iif(i = 0, BACKCONTROL, NEXTCONTROL), 0, ACTIONPERFORMED) Then GoTo Catch
  826. Next i
  827. End If
  828. &apos; Set the initial page to 1
  829. Page = 1
  830. _LastPage = LastPage
  831. Finally:
  832. SetPageManager = bManager
  833. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  834. Exit Function
  835. Catch:
  836. ScriptForge.SF_Exception.RaiseFatal(PAGEMANAGERERROR, &quot;PilotControls&quot;, PilotControls, &quot;TabControls&quot;, TabControls _
  837. , &quot;WizardControls&quot;, WizardControls)
  838. GoTo Finally
  839. End Function &apos; SFDialogs.SF_Dialog.SetPageManager
  840. REM -----------------------------------------------------------------------------
  841. Public Function SetProperty(Optional ByVal PropertyName As Variant _
  842. , Optional ByRef Value As Variant _
  843. ) As Boolean
  844. &apos;&apos;&apos; Set a new value to the given property
  845. &apos;&apos;&apos; Args:
  846. &apos;&apos;&apos; PropertyName: the name of the property as a string
  847. &apos;&apos;&apos; Value: its new value
  848. &apos;&apos;&apos; Exceptions
  849. &apos;&apos;&apos; ARGUMENTERROR The property does not exist
  850. Const cstThisSub = &quot;SFDialogs.Dialog.SetProperty&quot;
  851. Const cstSubArgs = &quot;PropertyName, Value&quot;
  852. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  853. SetProperty = False
  854. Check:
  855. If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  856. If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  857. End If
  858. Try:
  859. SetProperty = _PropertySet(PropertyName, Value)
  860. Finally:
  861. SF_Utils._ExitFunction(cstThisSub)
  862. Exit Function
  863. Catch:
  864. GoTo Finally
  865. End Function &apos; SFDialogs.SF_Dialog.SetProperty
  866. REM -----------------------------------------------------------------------------
  867. Public Function Terminate() As Boolean
  868. &apos;&apos;&apos; Terminate the dialog service for the current dialog instance
  869. &apos;&apos;&apos; After termination any action on the current instance will be ignored
  870. &apos;&apos;&apos; Args:
  871. &apos;&apos;&apos; Returns:
  872. &apos;&apos;&apos; True if termination is successful
  873. &apos;&apos;&apos; Example:
  874. &apos;&apos;&apos; Dim oDlg As Object, lReturn As Long
  875. &apos;&apos;&apos; Set oDlg = CreateScriptService(,, &quot;myDialog&quot;) &apos; Dialog stored in current document&apos;s standard library
  876. &apos;&apos;&apos; lreturn = oDlg.Execute()
  877. &apos;&apos;&apos; Select Case lReturn
  878. &apos;&apos;&apos; &apos; ...
  879. &apos;&apos;&apos; End Select
  880. &apos;&apos;&apos; oDlg.Terminate()
  881. Dim bTerminate As Boolean &apos; Return value
  882. Const cstThisSub = &quot;SFDialogs.Dialog.Terminate&quot;
  883. Const cstSubArgs = &quot;&quot;
  884. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  885. bTerminate = False
  886. Check:
  887. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  888. If Not _IsStillAlive() Then GoTo Finally
  889. End If
  890. Try:
  891. _RemovePageListeners()
  892. _DialogControl.dispose()
  893. Set _DialogControl = Nothing
  894. SF_Register._CleanCacheEntry(_CacheIndex)
  895. _CacheIndex = -1
  896. Dispose()
  897. bTerminate = True
  898. Finally:
  899. Terminate = bTerminate
  900. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  901. Exit Function
  902. Catch:
  903. GoTo Finally
  904. End Function &apos; SFDialogs.SF_Dialog.Terminate
  905. REM =========================================================== PRIVATE FUNCTIONS
  906. REM -----------------------------------------------------------------------------
  907. Private Function _FindRadioSiblings(ByVal psRadioButton As String) As String
  908. &apos;&apos;&apos; Given the name of the first radio button of a group, return all the names of the group
  909. &apos;&apos;&apos; For dialogs, radio buttons are considered of the same group
  910. &apos;&apos;&apos; when their tab indexes are contiguous.
  911. &apos;&apos;&apos; Args:
  912. &apos;&apos;&apos; psRadioButton: the exact name of the 1st radio button of the group
  913. &apos;&apos;&apos; Returns:
  914. &apos;&apos;&apos; A comma-separated list of the names of the 1st and the next radio buttons
  915. &apos;&apos;&apos; belonging to the same group in their tabindex order.
  916. &apos;&apos;&apos; The input argument when not a radio button
  917. Dim sList As String &apos; Return value
  918. Dim oRadioControl As Object &apos; DialogControl instance corresponding with the argument
  919. Dim oControl As Object &apos; DialogControl instance
  920. Dim vRadioList As Variant &apos; Array of all radio buttons having a tab index &gt; tab index of argument
  921. &apos; 1st column = name of radio button, 2nd = its tab index
  922. Dim iRadioTabIndex As Integer &apos; Tab index of the argument
  923. Dim iTabIndex As Integer &apos; Any tab index
  924. Dim vControlNames As Variant &apos; Array of control names
  925. Dim sControlName As String &apos; A single item in vControlNames()
  926. Dim i As Long
  927. Const cstComma = &quot;,&quot;
  928. Check:
  929. On Local Error GoTo Catch
  930. sList = psRadioButton
  931. vRadioList = Array()
  932. Try:
  933. Set oRadioControl = Controls(psRadioButton)
  934. If oRadioControl.ControlType &lt;&gt; &quot;RadioButton&quot; Then GoTo Finally
  935. iRadioTabIndex = oRadioControl._ControlModel.Tabindex
  936. vRadioList = ScriptForge.SF_Array.AppendRow(vRadioList, Array(psRadioButton, iRadioTabIndex))
  937. &apos; Scan all controls. Store radio buttons having tab index &gt; 1st radio button
  938. vControlNames = Controls()
  939. For Each sControlName In vControlNames
  940. Set oControl = Controls(sControlName)
  941. With oControl
  942. If .Name &lt;&gt; psRadioButton Then
  943. If .ControlType = &quot;RadioButton&quot; Then
  944. iTabIndex = ._ControlModel.Tabindex
  945. If iTabIndex &gt; iRadioTabIndex Then
  946. vRadioList = ScriptForge.SF_Array.AppendRow(vRadioList, Array(.Name, iTabIndex))
  947. End If
  948. End If
  949. End If
  950. End With
  951. Next sControlName
  952. vRadioList = ScriptForge.SF_Array.SortRows(vRadioList, 1)
  953. &apos; Retain contiguous tab indexes
  954. For i = 1 To UBound(vRadioList, 1) &apos; First row = argument
  955. If vRadioList(i, 1) = iRadioTabIndex + i Then sList = sList &amp; cstComma &amp; vRadioList(i, 0)
  956. Next i
  957. Finally:
  958. _FindRadioSiblings = sList
  959. Exit Function
  960. Catch:
  961. sList = psRadioButton
  962. GoTo Finally
  963. End Function &apos; SFDialogs.SF_Dialog._FindRadioSiblings
  964. REM -----------------------------------------------------------------------------
  965. Public Function _GetEventName(ByVal psProperty As String) As String
  966. &apos;&apos;&apos; Return the LO internal event name derived from the SF property name
  967. &apos;&apos;&apos; The SF property name is not case sensitive, while the LO name is case-sensitive
  968. &apos; Corrects the typo on ErrorOccur(r?)ed, if necessary
  969. Dim vProperties As Variant &apos; Array of class properties
  970. Dim sProperty As String &apos; Correctly cased property name
  971. vProperties = Properties()
  972. sProperty = vProperties(ScriptForge.SF_Array.IndexOf(vProperties, psProperty, SortOrder := &quot;ASC&quot;))
  973. _GetEventName = LCase(Mid(sProperty, 3, 1)) &amp; Right(sProperty, Len(sProperty) - 3)
  974. End Function &apos; SFDialogs.SF_Dialog._GetEventName
  975. REM -----------------------------------------------------------------------------
  976. Private Function _GetListener(ByVal psEventName As String) As String
  977. &apos;&apos;&apos; Getting/Setting macros triggered by events requires a Listener-EventName pair
  978. &apos;&apos;&apos; Return the X...Listener corresponding with the event name in argument
  979. Select Case UCase(psEventName)
  980. Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;)
  981. _GetListener = &quot;XFocusListener&quot;
  982. Case UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;)
  983. _GetListener = &quot;XKeyListener&quot;
  984. Case UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseMoved&quot;)
  985. _GetListener = &quot;XMouseMotionListener&quot;
  986. Case UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
  987. _GetListener = &quot;XMouseListener&quot;
  988. Case Else
  989. _GetListener = &quot;&quot;
  990. End Select
  991. End Function &apos; SFDialogs.SF_Dialog._GetListener
  992. REM -----------------------------------------------------------------------------
  993. Public Sub _Initialize()
  994. &apos;&apos;&apos; Complete the object creation process:
  995. &apos;&apos;&apos; - Initialization of private members
  996. &apos;&apos;&apos; - Creation of the dialog graphical interface
  997. &apos;&apos;&apos; - Addition of the new object in the Dialogs buffer
  998. &apos;&apos;&apos; - Initialisation of persistent storage for controls
  999. Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
  1000. Try:
  1001. &apos; Keep reference to model
  1002. Set _DialogModel = _DialogControl.Model
  1003. &apos; Store initial position and dimensions
  1004. Set oPosSize = _DialogControl.getPosSize()
  1005. With oPosSize
  1006. _Left = .X
  1007. _Top = .Y
  1008. _Width = .Width
  1009. _Height = .Height
  1010. End With
  1011. &apos; Add dialog reference to cache
  1012. _CacheIndex = SF_Register._AddDialogToCache(_DialogControl, [Me])
  1013. &apos; Size the persistent storage
  1014. _ControlCache = Array()
  1015. ReDim _ControlCache(0 To UBound(_DialogModel.getElementNames()))
  1016. Finally:
  1017. Exit Sub
  1018. End Sub &apos; SFDialogs.SF_Dialog._Initialize
  1019. REM -----------------------------------------------------------------------------
  1020. Private Function _IsStillAlive(Optional ByVal pbError As Boolean) As Boolean
  1021. &apos;&apos;&apos; Return True if the dialog service is still active
  1022. &apos;&apos;&apos; If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
  1023. &apos;&apos;&apos; Args:
  1024. &apos;&apos;&apos; pbError: if True (default), raise a fatal error
  1025. Dim bAlive As Boolean &apos; Return value
  1026. Dim sDialog As String &apos; Alias of DialogName
  1027. Check:
  1028. On Local Error GoTo Catch &apos; Anticipate DisposedException errors or alike
  1029. If IsMissing(pbError) Then pbError = True
  1030. Try:
  1031. bAlive = ( Not IsNull(_DialogProvider) And Not IsNull(_DialogControl) )
  1032. If Not bAlive Then GoTo Catch
  1033. Finally:
  1034. _IsStillAlive = bAlive
  1035. Exit Function
  1036. Catch:
  1037. bAlive = False
  1038. On Error GoTo 0
  1039. sDialog = _Name
  1040. Dispose()
  1041. If pbError Then ScriptForge.SF_Exception.RaiseFatal(DIALOGDEADERROR, sDialog)
  1042. GoTo Finally
  1043. End Function &apos; SFDialogs.SF_Dialog._IsStillAlive
  1044. REM -----------------------------------------------------------------------------
  1045. Private Sub _JumpToPage(ByVal plPage As Long)
  1046. &apos;&apos;&apos; Called when the Page property is set to a new value
  1047. &apos;&apos;&apos; The rules defined in the _pageManagement array are applied here
  1048. Dim oPageManager As Object &apos; A single entry in _PageManagement of type _PageManager
  1049. Dim oControl As Object &apos; DialogControl instance
  1050. Dim lPage As Long &apos; A dialog page number
  1051. Check:
  1052. On Local Error GoTo Finally
  1053. &apos; ControlName As String &apos; Case-sensitive name of control involved in page management
  1054. &apos; PageMgtType As Integer &apos; One of the PILOTCONTROL, TABCONTROL, BACKCONTROL, NEXTCONTROL constants
  1055. &apos; PageNumber As Long &apos; When &gt; 0, the page to activate for tab controls
  1056. &apos; ListenerType As Integer &apos; One of the ITEMSTATECHANGED, ACTIONPERFORMED constants
  1057. If plPage &lt;= 0 Or (_LastPage &gt; 0 And plPage &gt; _LastPage) Then Exit Sub
  1058. If UBound(_PageManagement) &lt; 0 Then Exit Sub
  1059. Try:
  1060. &apos; Controls listed in the array must be synchronized with the page #
  1061. &apos; Listboxes and comboboxes must be set to the corresponding value
  1062. &apos; The right radio button must be selected
  1063. &apos; One corresponding button must be dimmed, other must be enabled
  1064. &apos; The Next button must be dimmed when last page otherwise enabled
  1065. For Each oPageManager In _PageManagement
  1066. With oPageManager
  1067. lPage = .PageNumber
  1068. Set oControl = Controls(.ControlName)
  1069. With oControl
  1070. Select Case .ControlType
  1071. Case &quot;ListBox&quot;, &quot;ComboBox&quot;
  1072. If plPage &lt;= .ListCount Then .ListIndex = plPage - 1 &apos; ListIndex is zero-based
  1073. Case &quot;RadioButton&quot;
  1074. .Value = ( plPage = lPage )
  1075. Case &quot;Button&quot;
  1076. Select Case oPageManager.PageMgtType
  1077. Case TABCONTROL
  1078. .Value = ( plPage = lPage )
  1079. Case BACKCONTROL
  1080. .Enabled = ( plPage &lt;&gt; 1 )
  1081. Case NEXTCONTROL
  1082. .Enabled = ( _LastPage = 0 Or plPage &lt; _LastPage )
  1083. Case Else
  1084. End Select
  1085. Case Else
  1086. End Select
  1087. End With
  1088. End With
  1089. Next oPageManager
  1090. Finally:
  1091. Exit Sub
  1092. End Sub &apos; SFDialogs.SF_Dialog._JumpToPage
  1093. REM -----------------------------------------------------------------------------
  1094. Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
  1095. &apos;&apos;&apos; Return the value of the named property
  1096. &apos;&apos;&apos; Args:
  1097. &apos;&apos;&apos; psProperty: the name of the property
  1098. Static oSession As Object &apos; Alias of SF_Session
  1099. Dim oDialogEvents As Object &apos; com.sun.star.container.XNameContainer
  1100. Dim sEventName As String &apos; Internal event name
  1101. Dim cstThisSub As String
  1102. Const cstSubArgs = &quot;&quot;
  1103. cstThisSub = &quot;SFDialogs.Dialog.get&quot; &amp; psProperty
  1104. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  1105. ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  1106. If Not _IsStillAlive() Then GoTo Finally
  1107. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  1108. Select Case UCase(psProperty)
  1109. Case UCase(&quot;Caption&quot;)
  1110. If oSession.HasUNOProperty(_DialogModel, &quot;Title&quot;) Then _PropertyGet = _DialogModel.Title
  1111. Case UCase(&quot;Height&quot;)
  1112. If oSession.HasUNOProperty(_DialogModel, &quot;Height&quot;) Then _PropertyGet = _DialogModel.Height
  1113. Case UCase(&quot;Modal&quot;)
  1114. _PropertyGet = _Modal
  1115. Case UCase(&quot;Name&quot;)
  1116. _PropertyGet = _Name
  1117. Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
  1118. , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
  1119. , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
  1120. Set oDialogEvents = _DialogModel.getEvents()
  1121. sEventName = &quot;com.sun.star.awt.&quot; &amp; _GetListener(psProperty) &amp; &quot;::&quot; &amp; _GetEventName(psProperty)
  1122. If oDialogEvents.hasByName(sEventName) Then
  1123. _PropertyGet = oDialogEvents.getByName(sEventName).ScriptCode
  1124. Else
  1125. _PropertyGet = &quot;&quot;
  1126. End If
  1127. Case UCase(&quot;Page&quot;)
  1128. If oSession.HasUNOProperty(_DialogModel, &quot;Step&quot;) Then _PropertyGet = _DialogModel.Step
  1129. Case UCase(&quot;Visible&quot;)
  1130. If oSession.HasUnoMethod(_DialogControl, &quot;isVisible&quot;) Then _PropertyGet = CBool(_DialogControl.isVisible())
  1131. Case UCase(&quot;Width&quot;)
  1132. If oSession.HasUNOProperty(_DialogModel, &quot;Width&quot;) Then _PropertyGet = _DialogModel.Width
  1133. Case UCase(&quot;XDialogModel&quot;)
  1134. Set _PropertyGet = _DialogModel
  1135. Case UCase(&quot;XDialogView&quot;)
  1136. Set _PropertyGet = _DialogControl
  1137. Case Else
  1138. _PropertyGet = Null
  1139. End Select
  1140. Finally:
  1141. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  1142. Exit Function
  1143. Catch:
  1144. GoTo Finally
  1145. End Function &apos; SFDialogs.SF_Dialog._PropertyGet
  1146. REM -----------------------------------------------------------------------------
  1147. Private Function _PropertySet(Optional ByVal psProperty As String _
  1148. , Optional ByVal pvValue As Variant _
  1149. ) As Boolean
  1150. &apos;&apos;&apos; Set the new value of the named property
  1151. &apos;&apos;&apos; Args:
  1152. &apos;&apos;&apos; psProperty: the name of the property
  1153. &apos;&apos;&apos; pvValue: the new value of the given property
  1154. &apos;&apos;&apos; Returns:
  1155. &apos;&apos;&apos; True if successful
  1156. Dim bSet As Boolean &apos; Return value
  1157. Static oSession As Object &apos; Alias of SF_Session
  1158. Dim cstThisSub As String
  1159. Const cstSubArgs = &quot;Value&quot;
  1160. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  1161. bSet = False
  1162. cstThisSub = &quot;SFDialogs.Dialog.set&quot; &amp; psProperty
  1163. ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  1164. If Not _IsStillAlive() Then GoTo Finally
  1165. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  1166. bSet = True
  1167. Select Case UCase(psProperty)
  1168. Case UCase(&quot;Caption&quot;)
  1169. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Caption&quot;, V_STRING) Then GoTo Finally
  1170. If oSession.HasUNOProperty(_DialogModel, &quot;Title&quot;) Then _DialogModel.Title = pvValue
  1171. Case UCase(&quot;Height&quot;)
  1172. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  1173. If oSession.HasUNOProperty(_DialogModel, &quot;Height&quot;) Then _DialogModel.Height = pvValue
  1174. Case UCase(&quot;Page&quot;)
  1175. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Page&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  1176. If oSession.HasUNOProperty(_DialogModel, &quot;Step&quot;) Then
  1177. _DialogModel.Step = CLng(pvValue)
  1178. &apos; Execute the page manager instructions
  1179. _JumpToPage(pvValue)
  1180. End If
  1181. Case UCase(&quot;Visible&quot;)
  1182. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Visible&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  1183. If oSession.HasUnoMethod(_DialogControl, &quot;setVisible&quot;) Then _DialogControl.setVisible(pvValue)
  1184. Case UCase(&quot;Width&quot;)
  1185. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  1186. If oSession.HasUNOProperty(_DialogModel, &quot;Width&quot;) Then _DialogModel.Width = pvValue
  1187. Case Else
  1188. bSet = False
  1189. End Select
  1190. Finally:
  1191. _PropertySet = bSet
  1192. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  1193. Exit Function
  1194. Catch:
  1195. GoTo Finally
  1196. End Function &apos; SFDialogs.SF_Dialog._PropertySet
  1197. REM -----------------------------------------------------------------------------
  1198. Private Function _RegisterPageListener(ByVal psControlName As String _
  1199. , ByVal psControlTypes As String _
  1200. , ByVal piMgtType As Integer _
  1201. , ByVal plPageNumber As Long _
  1202. , ByVal piListener As Integer _
  1203. ) As Boolean
  1204. &apos;&apos;&apos; Insert a new entry in the _PageManagement array when 1st argument is a listbox, a combobox or a button
  1205. &apos;&apos;&apos; or insert a new entry in the _PageManagement array by radio button in the same group as the 1st argument
  1206. &apos;&apos;&apos; Args:
  1207. &apos;&apos;&apos; psControlName: name of the involved control
  1208. &apos;&apos;&apos; psControlTypes: comma-separated list of allowed control types
  1209. &apos;&apos;&apos; piMgtType: one of the PILOTCONTROL, TABCONTROL, BACKCONTROL, NEXTCONTROL constants
  1210. &apos;&apos;&apos; plPageNumber: when &gt; 0 the page to jump to when control is clicked
  1211. &apos;&apos;&apos; piListener: one of the ACTIONPERFORMED, ITEMSTATECHANGED constants
  1212. Dim bRegister As Boolean &apos; Return value
  1213. Dim oControl As Object &apos; A DialogControl object
  1214. Dim oControl2 As Object &apos; An alternative DialogControl object for radio buttons
  1215. Dim vControls As Variant &apos; Array of involved controls - mostly 1 item, more when radio button
  1216. Dim oPageManager As Object &apos; Type _PageManager
  1217. Dim bRadio As Boolean &apos; True when argument is a radio button
  1218. Dim sName As String &apos; Control name
  1219. Dim i As Long
  1220. Check:
  1221. On Local Error GoTo Catch
  1222. bRegister = False
  1223. Try:
  1224. Set oControl = Controls(psControlName)
  1225. With oControl
  1226. &apos; Check the type of control otherwise return False
  1227. If InStr(psControlTypes, .ControlType) = 0 Then GoTo Catch
  1228. &apos; Are there siblings ? Siblings are returned as a comma-separated list of names
  1229. bRadio = ( .ControlType = &quot;RadioButton&quot;)
  1230. If bRadio Then vControls = Split(_FindRadioSiblings(.Name), &quot;,&quot;) Else vControls = Array(.Name)
  1231. &apos; Several loops when radio buttons
  1232. For i = 0 To UBound(vControls)
  1233. sName = vControls(i)
  1234. &apos; Prepare the next entry in the _PageManagement array
  1235. Set oPageManager = New _PageManager
  1236. With oPageManager
  1237. .ControlName = sName
  1238. .PageMgtType = piMgtType
  1239. .PageNumber = Iif(bRadio, i + 1, plPageNumber)
  1240. .ListenerType = piListener
  1241. End With
  1242. _PageManagement = ScriptForge.SF_Array.Append(_PageManagement, oPageManager)
  1243. &apos; Activate the listener
  1244. &apos; Use alternative control for radio buttons &gt; first
  1245. If i = 0 Then Set oControl2 = oControl Else Set oControl2 = Controls(sName)
  1246. With oControl2
  1247. If piListener = ACTIONPERFORMED Then
  1248. ._ControlView.addActionListener(_ActionListener)
  1249. ElseIf piListener = ITEMSTATECHANGED Then
  1250. ._ControlView.addItemListener(_ItemListener)
  1251. End If
  1252. End With
  1253. Next i
  1254. End With
  1255. bRegister = True
  1256. Finally:
  1257. _RegisterPageListener = bRegister
  1258. Exit Function
  1259. Catch:
  1260. GoTo Finally
  1261. End Function &apos; SFDialogs.SF_Dialog._RegisterPageListener
  1262. REM -----------------------------------------------------------------------------
  1263. Private Sub _RemovePageListeners()
  1264. &apos;&apos;&apos; Executed at dialog termination to drop at once all listeners set by the page manager
  1265. Dim oPageManager As Object &apos; Item of _PageManagement array of _PageManager type
  1266. Dim oControl As Object &apos; DialogControl instance
  1267. Dim i As Long
  1268. On Local Error GoTo Finally &apos; Never interrupt
  1269. Try:
  1270. &apos; Scan the _PageManagement array containing the actual settings of the page manager
  1271. For Each oPageManager In _PageManagement
  1272. With oPageManager
  1273. If .ListenerType &gt; 0 Then
  1274. Set oControl = Controls(.ControlName)
  1275. If .ListenerType = ACTIONPERFORMED Then
  1276. oControl._ControlView.removeActionListener(_ActionListener)
  1277. ElseIf .ListenerType = ITEMSTATECHANGED Then
  1278. oControl._ControlView.addItemListener(_ItemListener)
  1279. End If
  1280. End If
  1281. End With
  1282. Next oPageManager
  1283. Set _ActionListener = Nothing
  1284. Set _ItemListener = Nothing
  1285. Finally:
  1286. Exit Sub
  1287. End Sub &apos; SFDialogs.SF_Dialog._RemovePageListeners
  1288. REM -----------------------------------------------------------------------------
  1289. Private Function _Repr() As String
  1290. &apos;&apos;&apos; Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
  1291. &apos;&apos;&apos; Args:
  1292. &apos;&apos;&apos; Return:
  1293. &apos;&apos;&apos; &quot;[DIALOG]: Container.Library.Name&quot;
  1294. _Repr = &quot;[DIALOG]: &quot; &amp; _Container &amp; &quot;.&quot; &amp; _Library &amp; &quot;.&quot; &amp; _Name
  1295. End Function &apos; SFDialogs.SF_Dialog._Repr
  1296. REM ============================================ END OF SFDIALOGS.SF_DIALOG
  1297. </script:module>