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_UI" script:
language=
"StarBasic" script:
moduleType=
"normal">REM =======================================================================================================================
4 REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
5 REM === Full documentation is available on https://help.libreoffice.org/ ===
6 REM =======================================================================================================================
11 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
12 ''' SF_UI
13 ''' =====
14 ''' Singleton class module for the identification and the manipulation of the
15 ''' different windows composing the whole LibreOffice application:
16 ''' - Windows selection
17 ''' - Windows moving and resizing
18 ''' - Statusbar settings
19 ''' - Creation of new windows
20 ''' - Access to the underlying
"documents
"
22 ''' WindowName: how to designate a window. It can be either
23 ''' a full FileName given in the notation indicated by the current value of SF_FileSystem.FileNaming
24 ''' or the last component of the full FileName or even only its BaseName
25 ''' or the title of the window
26 ''' or, for new documents, something like
"Untitled
1"
27 ''' or one of the special windows
"BASICIDE
" and
"WELCOMESCREEN
"
28 ''' The window search is case-sensitive
30 ''' Service invocation example:
31 ''' Dim ui As Variant
32 ''' ui = CreateScriptService(
"UI
")
34 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
36 REM ================================================================== EXCEPTIONS
38 Const DOCUMENTERROR =
"DOCUMENTERROR
" ' Requested document was not found
39 Const DOCUMENTCREATIONERROR =
"DOCUMENTCREATIONERROR
" ' Incoherent arguments, new document could not be created
40 Const DOCUMENTOPENERROR =
"DOCUMENTOPENERROR
" ' Document could not be opened, check the arguments
41 Const BASEDOCUMENTOPENERROR =
"BASEDOCUMENTOPENERROR
" ' Id. for Base document
43 REM ============================================================= PRIVATE MEMBERS
46 Component As Object
' com.sun.star.lang.XComponent
47 Frame As Object
' com.sun.star.comp.framework.Frame
48 WindowName As String
' Object Name
49 WindowTitle As String
' Only mean to identify new documents
50 WindowFileName As String
' URL of file name
51 DocumentType As String
' Writer, Calc, ...
54 ' The progress/status bar of the active window
55 'Private oStatusBar As Object
' com.sun.star.task.XStatusIndicator
57 REM ============================================================ MODULE CONSTANTS
59 ' Special windows
60 Const BASICIDE =
"BASICIDE
"
61 Const WELCOMESCREEN =
"WELCOMESCREEN
"
63 ' Document types (only if not
1 of the special windows)
64 Const BASEDOCUMENT =
"Base
"
65 Const CALCDOCUMENT =
"Calc
"
66 Const DRAWDOCUMENT =
"Draw
"
67 Const IMPRESSDOCUMENT =
"Impress
"
68 Const MATHDOCUMENT =
"Math
"
69 Const WRITERDOCUMENT =
"Writer
"
71 ' Window subtypes - Not supported yet
72 Const BASETABLE =
"BASETABLE
"
73 Const BASEQUERY =
"BASEQUERY
"
74 Const BASEREPORT =
"BASEREPORT
"
75 Const BASEDIAGRAM =
"BASEDIAGRAM
"
77 ' Macro execution modes
78 Const cstMACROEXECNORMAL =
0 ' Default, execution depends on user configuration and choice
79 Const cstMACROEXECNEVER =
1 ' Macros are not executed
80 Const cstMACROEXECALWAYS =
2 ' Macros are always executed
82 REM ===================================================== CONSTRUCTOR/DESTRUCTOR
84 REM -----------------------------------------------------------------------------
85 Public Function Dispose() As Variant
87 End Function
' ScriptForge.SF_UI Explicit destructor
89 REM ================================================================== PROPERTIES
91 REM -----------------------------------------------------------------------------
92 Public Function ActiveWindow() As String
93 ''' Returns a valid WindowName for the currently active window
94 ''' When
"" is returned, the window could not be identified
96 Dim vWindow As Window
' A component
97 Dim oComp As Object
' com.sun.star.lang.XComponent
99 Set oComp = StarDesktop.CurrentComponent
100 If Not IsNull(oComp) Then
101 vWindow = SF_UI._IdentifyWindow(oComp)
103 If Len(.WindowFileName)
> 0 Then
104 ActiveWindow = SF_FileSystem._ConvertFromUrl(.WindowFileName)
105 ElseIf Len(.WindowName)
> 0 Then
106 ActiveWindow = .WindowName
107 ElseIf Len(.WindowTitle)
> 0 Then
108 ActiveWindow = .WindowTitle
110 ActiveWindow =
""
115 End Function
' ScriptForge.SF_UI.ActiveWindow
117 REM -----------------------------------------------------------------------------
118 Property Get MACROEXECALWAYS As Integer
119 ''' Macros are always executed
120 MACROEXECALWAYS = cstMACROEXECALWAYS
121 End Property
' ScriptForge.SF_UI.MACROEXECALWAYS
123 REM -----------------------------------------------------------------------------
124 Property Get MACROEXECNEVER As Integer
125 ''' Macros are not executed
126 MACROEXECNEVER = cstMACROEXECNEVER
127 End Property
' ScriptForge.SF_UI.MACROEXECNEVER
129 REM -----------------------------------------------------------------------------
130 Property Get MACROEXECNORMAL As Integer
131 ''' Default, execution depends on user configuration and choice
132 MACROEXECNORMAL = cstMACROEXECNORMAL
133 End Property
' ScriptForge.SF_UI.MACROEXECNORMAL
135 REM -----------------------------------------------------------------------------
136 Property Get ObjectType As String
137 ''' Only to enable object representation
138 ObjectType =
"SF_UI
"
139 End Property
' ScriptForge.SF_UI.ObjectType
141 REM ===================================================================== METHODS
143 REM -----------------------------------------------------------------------------
144 Public Function Activate(Optional ByVal WindowName As Variant) As Boolean
145 ''' Make the specified window active
146 ''' Args:
147 ''' WindowName: see definitions
148 ''' Returns:
149 ''' True if the given window is found and can be activated
150 ''' There is no change in the actual user interface if no window matches the selection
151 ''' Examples:
152 ''' ui.Activate(
"C:\Me\My file.odt
")
154 Dim bActivate As Boolean
' Return value
155 Dim oEnum As Object
' com.sun.star.container.XEnumeration
156 Dim oComp As Object
' com.sun.star.lang.XComponent
157 Dim vWindow As Window
' A single component
158 Dim oContainer As Object
' com.sun.star.awt.XWindow
159 Const cstThisSub =
"UI.Activate
"
160 Const cstSubArgs =
"WindowName
"
162 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
166 If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName =
""
167 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
168 If Not SF_Utils._ValidateFile(WindowName,
"WindowName
") Then GoTo Finally
172 Set oEnum = StarDesktop.Components().createEnumeration
173 Do While oEnum.hasMoreElements
174 Set oComp = oEnum.nextElement
175 vWindow = SF_UI._IdentifyWindow(oComp)
177 ' Does the current window match the arguments ?
178 If (Len(.WindowFileName)
> 0 And .WindowFileName = SF_FileSystem._ConvertToUrl(WindowName)) _
179 Or (Len(.WindowName)
> 0 And .WindowName = WindowName) _
180 Or (Len(.WindowTitle)
> 0 And .WindowTitle = WindowName) Then
181 Set oContainer = vWindow.Frame.ContainerWindow
183 If .isVisible() = False Then .setVisible(True)
186 .toFront()
' Force window change in Linux
187 Wait
1 ' Bypass desynchro issue in Linux
197 SF_Utils._ExitFunction(cstThisSub)
201 End Function
' ScriptForge.SF_UI.Activate
203 REM -----------------------------------------------------------------------------
204 Public Function CreateBaseDocument(Optional ByVal FileName As Variant _
205 , Optional ByVal EmbeddedDatabase As Variant _
206 , Optional ByVal RegistrationName As Variant _
208 ''' Create a new LibreOffice Base document embedding an empty database of the given type
209 ''' Args:
210 ''' FileName: Identifies the file to create. It must follow the SF_FileSystem.FileNaming notation
211 ''' If the file already exists, it is overwritten without warning
212 ''' EmbeddedDatabase: either
"HSQLDB
" (default) or
"FIREBIRD
"
213 ''' RegistrationName: the name used to store the new database in the databases register
214 ''' If
"" (default), no registration takes place
215 ''' If the name already exists it is overwritten without warning
216 ''' Returns:
217 ''' A SFDocuments.SF_Document object or one of its subclasses
218 ''' Examples:
219 ''' Dim myBase As Object
220 ''' Set myBase = ui.CreateBaseDocument(
"C:\Databases\MyBaseFile.odb
",
"FIREBIRD
")
222 Dim oCreate As Variant
' Return value
223 Dim oDBContext As Object
' com.sun.star.sdb.DatabaseContext
224 Dim oDatabase As Object
' com.sun.star.comp.dba.ODatabaseSource
225 Dim oComp As Object
' Loaded component com.sun.star.lang.XComponent
226 Dim sFileName As String
' Alias of FileName
227 Dim FSO As Object
' Alias for FileSystem service
228 Const cstDocType =
"private:factory/s
"
229 Const cstThisSub =
"UI.CreateBaseDocument
"
230 Const cstSubArgs =
"FileName, [EmbeddedDatabase=
""HSQLDB
""|
""FIREBIRD
""], [RegistrationName=
""""]
"
232 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
233 Set oCreate = Nothing
236 If IsMissing(EmbeddedDatabase) Or IsEmpty(EmbeddedDatabase) Then EmbeddedDatabase =
"HSQLDB
"
237 If IsMissing(RegistrationName) Or IsEmpty(RegistrationName) Then RegistrationName =
""
238 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
239 If Not SF_Utils._ValidateFile(FileName,
"FileName
") Then GoTo Finally
240 If Not SF_Utils._Validate(EmbeddedDatabase,
"EmbeddedDatabase
", V_STRING, Array(
"HSQLDB
",
"FIREBIRD
")) Then GoTo Finally
241 If Not SF_Utils._Validate(RegistrationName,
"RegistrationName
", V_STRING) Then GoTo Finally
245 Set oDBContext = SF_Utils._GetUNOService(
"DatabaseContext
")
247 Set oDatabase = .createInstance()
248 oDatabase.URL =
"sdbc:embedded:
" & LCase(EmbeddedDatabase)
249 ' Create empty Base document
250 Set FSO = CreateScriptService(
"FileSystem
")
251 sFileName = FSO._ConvertToUrl(FileName)
252 ' An existing file is overwritten without warning
253 If FSO.FileExists(FileName) Then FSO.DeleteFile(FileName)
254 If FSO.FileExists(FileName
& ".lck
") Then FSO.DeleteFile(FileName
& ".lck
")
255 oDatabase.DatabaseDocument.storeAsURL(sFileName, Array(SF_Utils._MakePropertyValue(
"Overwrite
", True)))
256 ' Register database if requested
257 If Len(RegistrationName)
> 0 Then
258 If .hasRegisteredDatabase(RegistrationName) Then
259 .changeDatabaseLocation(RegistrationName, sFileName)
261 .registerDatabaseLocation(RegistrationName, sFileName)
266 Set oCreate = OpenBaseDocument(FileName)
269 Set CreateBaseDocument = oCreate
270 SF_Utils._ExitFunction(cstThisSub)
274 End Function
' ScriptForge.SF_UI.CreateBaseDocument
276 REM -----------------------------------------------------------------------------
277 Public Function CreateDocument(Optional ByVal DocumentType As Variant _
278 , Optional ByVal TemplateFile As Variant _
279 , Optional ByVal Hidden As Variant _
281 ''' Create a new LibreOffice document of a given type or based on a given template
282 ''' Args:
283 ''' DocumentType:
"Calc
",
"Writer
", etc. If absent, a TemplateFile must be given
284 ''' TemplateFile: the full FileName of the template to build the new document on
285 ''' If the file does not exist, the argument is ignored
286 ''' The
"FileSystem
" service provides the TemplatesFolder and UserTemplatesFolder
287 ''' properties to help to build the argument
288 ''' Hidden: if True, open in the background (default = False)
289 ''' To use with caution: activation or closure can only happen programmatically
290 ''' Returns:
291 ''' A SFDocuments.SF_Document object or one of its subclasses
292 ''' Exceptions:
293 ''' DOCUMENTCREATIONERROR Wrong arguments
294 ''' Examples:
295 ''' Dim myDoc1 As Object, myDoc2 As Object, FSO As Object
296 ''' Set myDoc1 = ui.CreateDocument(
"Calc
")
297 ''' Set FSO = CreateScriptService(
"FileSystem
")
298 ''' Set myDoc2 = ui.CreateDocument(, FSO.BuildPath(FSO.TemplatesFolder,
"personal/CV.ott
"))
300 Dim oCreate As Variant
' Return value
301 Dim vProperties As Variant
' Array of com.sun.star.beans.PropertyValue
302 Dim bTemplateExists As Boolean
' True if TemplateFile is valid
303 Dim sNew As String
' File url
304 Dim oComp As Object
' Loaded component com.sun.star.lang.XComponent
305 Const cstDocType =
"private:factory/s
"
306 Const cstThisSub =
"UI.CreateDocument
"
307 Const cstSubArgs =
"[DocumentType=
""""], [TemplateFile=
""""], [Hidden=False]
"
309 '>>> If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
310 Set oCreate = Nothing
313 If IsMissing(DocumentType) Or IsEmpty(DocumentType) Then DocumentType =
""
314 If IsMissing(TemplateFile) Or IsEmpty(TemplateFile) Then TemplateFile =
""
315 If IsMissing(Hidden) Or IsEmpty(Hidden) Then Hidden = False
317 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
318 If Not SF_Utils._Validate(DocumentType,
"DocumentType
", V_STRING _
319 , Array(
"", BASEDOCUMENT, CALCDOCUMENT, DRAWDOCUMENT _
320 , IMPRESSDOCUMENT, MATHDOCUMENT, WRITERDOCUMENT)) Then GoTo Finally
321 If Not SF_Utils._ValidateFile(TemplateFile,
"TemplateFile
", , True) Then GoTo Finally
322 If Not SF_Utils._Validate(Hidden,
"Hidden
", V_BOOLEAN) Then GoTo Finally
325 If Len(DocumentType) + Len(TemplateFile) =
0 Then GoTo CatchError
326 If Len(TemplateFile)
> 0 Then bTemplateExists = SF_FileSystem.FileExists(TemplateFile) Else bTemplateExists = False
327 If Len(DocumentType) =
0 Then
328 If Not bTemplateExists Then GoTo CatchError
332 If bTemplateExists Then sNew = SF_FileSystem._ConvertToUrl(TemplateFile) Else sNew = cstDocType
& LCase(DocumentType)
333 vProperties = Array( _
334 SF_Utils._MakePropertyValue(
"AsTemplate
", bTemplateExists) _
335 , SF_Utils._MakePropertyValue(
"Hidden
", Hidden) _
337 Set oComp = StarDesktop.loadComponentFromURL(sNew,
"_blank
",
0, vProperties)
338 If Not IsNull(oComp) Then Set oCreate = CreateScriptService(
"SFDocuments.Document
", oComp)
341 Set CreateDocument = oCreate
342 SF_Utils._ExitFunction(cstThisSub)
347 SF_Exception.RaiseFatal(DOCUMENTCREATIONERROR,
"DocumentType
", DocumentType,
"TemplateFile
", TemplateFile)
349 End Function
' ScriptForge.SF_UI.CreateDocument
351 REM -----------------------------------------------------------------------------
352 Public Function Documents() As Variant
353 ''' Returns the list of the currently open documents. Special windows are ignored.
354 ''' Returns:
355 ''' A zero-based
1D array of filenames (in SF_FileSystem.FileNaming notation)
356 ''' or of window titles for unsaved documents
357 ''' Examples:
358 ''' Dim vDocs As Variant, sDoc As String
359 ''' vDocs = ui.Documents()
360 ''' For each sDoc In vDocs
361 ''' ...
363 Dim vDocuments As Variant
' Return value
364 Dim oEnum As Object
' com.sun.star.container.XEnumeration
365 Dim oComp As Object
' com.sun.star.lang.XComponent
366 Dim vWindow As Window
' A single component
367 Const cstThisSub =
"UI.Documents
"
368 Const cstSubArgs =
""
370 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
374 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
377 Set oEnum = StarDesktop.Components().createEnumeration
378 Do While oEnum.hasMoreElements
379 Set oComp = oEnum.nextElement
380 vWindow = SF_UI._IdentifyWindow(oComp)
382 If Len(.WindowFileName)
> 0 Then
383 vDocuments = SF_Array.Append(vDocuments, SF_FileSystem._ConvertFromUrl(.WindowFileName))
384 ElseIf Len(.WindowTitle)
> 0 Then
385 vDocuments = SF_Array.Append(vDocuments, .WindowTitle)
391 Documents = vDocuments
392 SF_Utils._ExitFunction(cstThisSub)
396 End Function
' ScriptForge.SF_UI.Documents
398 REM -----------------------------------------------------------------------------
399 Public Function GetDocument(Optional ByVal WindowName As Variant) As Variant
400 ''' Returns a SFDocuments.Document object referring to the active window or the given window
401 ''' Args:
402 ''' WindowName: see definitions. If absent the active window is considered
403 ''' Exceptions:
404 ''' DOCUMENTERROR The targeted window could not be found
405 ''' Examples:
406 ''' Dim oDoc As Object
407 ''' Set oDoc = ui.GetDocument
408 ''' oDoc.Save()
410 Dim oDocument As Object
' Return value
411 Const cstThisSub =
"UI.GetDocument
"
412 Const cstSubArgs =
"[WindowName]
"
414 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
415 Set oDocument = Nothing
418 If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName =
""
419 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
420 If Not SF_Utils._ValidateFile(WindowName,
"WindowName
", , True) Then GoTo Finally
424 Set oDocument = SF_Services.CreateScriptService(
"SFDocuments.Document
", WindowName)
425 If IsNull(oDocument) Then GoTo CatchDeliver
428 Set GetDocument = oDocument
429 SF_Utils._ExitFunction(cstThisSub)
434 SF_Exception.RaiseFatal(DOCUMENTERROR,
"WindowName
", WindowName)
436 End Function
' ScriptForge.SF_UI.GetDocument
438 REM -----------------------------------------------------------------------------
439 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
440 ''' Return the actual value of the given property
441 ''' Args:
442 ''' PropertyName: the name of the property as a string
443 ''' Returns:
444 ''' The actual value of the property
445 ''' Exceptions
446 ''' ARGUMENTERROR The property does not exist
448 Const cstThisSub =
"UI.GetProperty
"
449 Const cstSubArgs =
"PropertyName
"
451 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
455 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
456 If Not SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
460 Select Case UCase(PropertyName)
461 Case
"ACTIVEWINDOW
" : GetProperty = ActiveWindow()
466 SF_Utils._ExitFunction(cstThisSub)
470 End Function
' ScriptForge.SF_UI.GetProperty
472 REM -----------------------------------------------------------------------------
473 Public Sub Maximize(Optional ByVal WindowName As Variant)
474 ''' Maximizes the active window or the given window
475 ''' Args:
476 ''' WindowName: see definitions. If absent the active window is considered
477 ''' Examples:
478 ''' ui.Maximize
479 ''' ...
481 Dim oEnum As Object
' com.sun.star.container.XEnumeration
482 Dim oComp As Object
' com.sun.star.lang.XComponent
483 Dim vWindow As Window
' A single component
484 Dim oContainer As Object
' com.sun.star.awt.XWindow
485 Dim bFound As Boolean
' True if window found
486 Const cstThisSub =
"UI.Maximize
"
487 Const cstSubArgs =
"[WindowName]
"
489 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
492 If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName =
""
493 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
494 If Not SF_Utils._ValidateFile(WindowName,
"WindowName
", , True) Then GoTo Finally
499 If Len(WindowName)
> 0 Then
500 Set oEnum = StarDesktop.Components().createEnumeration
501 Do While oEnum.hasMoreElements And Not bFound
502 Set oComp = oEnum.nextElement
503 vWindow = SF_UI._IdentifyWindow(oComp)
505 ' Does the current window match the arguments ?
506 If (Len(.WindowFileName)
> 0 And .WindowFileName = SF_FileSystem.ConvertToUrl(WindowName)) _
507 Or (Len(.WindowName)
> 0 And .WindowName = WindowName) _
508 Or (Len(.WindowTitle)
> 0 And .WindowTitle = WindowName) Then bFound = True
512 vWindow = SF_UI._IdentifyWindow(StarDesktop.CurrentComponent)
517 Set oContainer = vWindow.Frame.ContainerWindow
518 oContainer.IsMaximized = True
522 SF_Utils._ExitFunction(cstThisSub)
526 End Sub
' ScriptForge.SF_UI.Maximize
528 REM -----------------------------------------------------------------------------
529 Public Sub Minimize(Optional ByVal WindowName As Variant)
530 ''' Minimizes the current window or the given window
531 ''' Args:
532 ''' WindowName: see definitions. If absent the current window is considered
533 ''' Examples:
534 ''' ui.Minimize(
"myFile.ods
")
535 ''' ...
537 Dim oEnum As Object
' com.sun.star.container.XEnumeration
538 Dim oComp As Object
' com.sun.star.lang.XComponent
539 Dim vWindow As Window
' A single component
540 Dim oContainer As Object
' com.sun.star.awt.XWindow
541 Dim bFound As Boolean
' True if window found
542 Const cstThisSub =
"UI.Minimize
"
543 Const cstSubArgs =
"[WindowName]
"
545 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
548 If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName =
""
549 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
550 If Not SF_Utils._ValidateFile(WindowName,
"WindowName
", , True) Then GoTo Finally
555 If Len(WindowName)
> 0 Then
556 Set oEnum = StarDesktop.Components().createEnumeration
557 Do While oEnum.hasMoreElements And Not bFound
558 Set oComp = oEnum.nextElement
559 vWindow = SF_UI._IdentifyWindow(oComp)
561 ' Does the current window match the arguments ?
562 If (Len(.WindowFileName)
> 0 And .WindowFileName = SF_FileSystem.ConvertToUrl(WindowName)) _
563 Or (Len(.WindowName)
> 0 And .WindowName = WindowName) _
564 Or (Len(.WindowTitle)
> 0 And .WindowTitle = WindowName) Then bFound = True
568 vWindow = SF_UI._IdentifyWindow(StarDesktop.CurrentComponent)
573 Set oContainer = vWindow.Frame.ContainerWindow
574 oContainer.IsMinimized = True
578 SF_Utils._ExitFunction(cstThisSub)
582 End Sub
' ScriptForge.SF_UI.Minimize
584 REM -----------------------------------------------------------------------------
585 Public Function Methods() As Variant
586 ''' Return the list of public methods of the UI service as an array
588 Methods = Array(
"Activate
" _
589 ,
"CreateBaseDocument
" _
590 ,
"CreateDocument
" _
591 ,
"Documents
" _
592 ,
"GetDocument
" _
593 ,
"Maximize
" _
594 ,
"Minimize
" _
595 ,
"OpenBaseDocument
" _
596 ,
"OpenDocument
" _
597 ,
"Resize
" _
598 ,
"SetStatusbar
" _
599 ,
"ShowProgressBar
" _
600 ,
"WindowExists
" _
603 End Function
' ScriptForge.SF_UI.Methods
605 REM -----------------------------------------------------------------------------
606 Public Function OpenBaseDocument(Optional ByVal FileName As Variant _
607 , Optional ByVal RegistrationName As Variant _
608 , Optional ByVal MacroExecution As Variant _
610 ''' Open an existing LibreOffice Base document and return a SFDocuments.Document object
611 ''' Args:
612 ''' FileName: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation
613 ''' RegistrationName: the name of a registered database
614 ''' It is ignored if FileName
<> ""
615 ''' MacroExecution: one of the MACROEXECxxx constants
616 ''' Returns:
617 ''' A SFDocuments.SF_Base object
618 ''' Null if the opening failed, including when due to a user decision
619 ''' Exceptions:
620 ''' BASEDOCUMENTOPENERROR Wrong arguments
621 ''' Examples:
622 ''' Dim mBasec As Object, FSO As Object
623 ''' Set myBase = ui.OpenBaseDocument(
"C:\Temp\myDB.odb
", MacroExecution := ui.MACROEXECNEVER)
625 Dim oOpen As Variant
' Return value
626 Dim vProperties As Variant
' Array of com.sun.star.beans.PropertyValue
627 Dim oDBContext As Object
' com.sun.star.sdb.DatabaseContext
628 Dim oComp As Object
' Loaded component com.sun.star.lang.XComponent
629 Dim sFile As String
' Alias for FileName
630 Dim iMacro As Integer
' Alias for MacroExecution
631 Const cstThisSub =
"UI.OpenBaseDocument
"
632 Const cstSubArgs =
"[FileName=
""""], [RegistrationName=
""""], [MacroExecution=
0|
1|
2]
"
634 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
638 If IsMissing(FileName) Or IsEmpty(FileName) Then FileName =
""
639 If IsMissing(RegistrationName) Or IsEmpty(RegistrationName) Then RegistrationName =
""
640 If IsMissing(MacroExecution) Or IsEmpty(MacroExecution) Then MacroExecution = MACROEXECNORMAL
642 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
643 If Not SF_Utils._ValidateFile(FileName,
"FileName
", , True) Then GoTo Finally
644 If Not SF_Utils._Validate(RegistrationName,
"RegistrationName
", V_STRING) Then GoTo Finally
645 If Not SF_Utils._Validate(MacroExecution,
"MacroExecution
", V_NUMERIC _
646 , Array(MACROEXECNORMAL, MACROEXECNEVER, MACROEXECALWAYS)) Then GoTo Finally
649 ' Check the existence of FileName
650 If Len(FileName) =
0 Then
' FileName has precedence over RegistrationName
651 If Len(RegistrationName) =
0 Then GoTo CatchError
652 Set oDBContext = SF_Utils._GetUNOService(
"DatabaseContext
")
653 If Not oDBContext.hasRegisteredDatabase(RegistrationName) Then GoTo CatchError
654 FileName = SF_FileSystem._ConvertFromUrl(oDBContext.getDatabaseLocation(RegistrationName))
656 If Not SF_FileSystem.FileExists(FileName) Then GoTo CatchError
659 With com.sun.star.document.MacroExecMode
660 Select Case MacroExecution
661 Case
0 : iMacro = .USE_CONFIG
662 Case
1 : iMacro = .NEVER_EXECUTE
663 Case
2 : iMacro = .ALWAYS_EXECUTE_NO_WARN
667 vProperties = Array(SF_Utils._MakePropertyValue(
"MacroExecutionMode
", iMacro))
669 sFile = SF_FileSystem._ConvertToUrl(FileName)
670 Set oComp = StarDesktop.loadComponentFromURL(sFile,
"_blank
",
0, vProperties)
671 If Not IsNull(oComp) Then Set oOpen = CreateScriptService(
"SFDocuments.Document
", oComp)
674 Set OpenBaseDocument = oOpen
675 SF_Utils._ExitFunction(cstThisSub)
680 SF_Exception.RaiseFatal(BASEDOCUMENTOPENERROR,
"FileName
", FileName,
"RegistrationName
", RegistrationName)
682 End Function
' ScriptForge.SF_UI.OpenBaseDocument
684 REM -----------------------------------------------------------------------------
685 Public Function OpenDocument(Optional ByVal FileName As Variant _
686 , Optional ByVal Password As Variant _
687 , Optional ByVal ReadOnly As Variant _
688 , Optional ByVal Hidden As Variant _
689 , Optional ByVal MacroExecution As Variant _
690 , Optional ByVal FilterName As Variant _
691 , Optional ByVal FilterOptions As Variant _
693 ''' Open an existing LibreOffice document with the given options
694 ''' Args:
695 ''' FileName: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation
696 ''' Password: To use when the document is protected
697 ''' If wrong or absent while the document is protected, the user will be prompted to enter a password
698 ''' ReadOnly: Default = False
699 ''' Hidden: if True, open in the background (default = False)
700 ''' To use with caution: activation or closure can only happen programmatically
701 ''' MacroExecution: one of the MACROEXECxxx constants
702 ''' FilterName: the name of a filter that should be used for loading the document
703 ''' If present, the filter must exist
704 ''' FilterOptions: an optional string of options associated with the filter
705 ''' Returns:
706 ''' A SFDocuments.SF_Document object or one of its subclasses
707 ''' Null if the opening failed, including when due to a user decision
708 ''' Exceptions:
709 ''' DOCUMENTOPENERROR Wrong arguments
710 ''' Examples:
711 ''' Dim myDoc As Object, FSO As Object
712 ''' Set myDoc = ui.OpenDocument(
"C:\Temp\myFile.odt
", MacroExecution := ui.MACROEXECNEVER)
714 Dim oOpen As Variant
' Return value
715 Dim oFilterFactory As Object
' com.sun.star.document.FilterFactory
716 Dim vProperties As Variant
' Array of com.sun.star.beans.PropertyValue
717 Dim oComp As Object
' Loaded component com.sun.star.lang.XComponent
718 Dim sFile As String
' Alias for FileName
719 Dim iMacro As Integer
' Alias for MacroExecution
720 Const cstThisSub =
"UI.OpenDocument
"
721 Const cstSubArgs =
"FileName, [Password=
""""], [ReadOnly=False], [Hidden=False], [MacroExecution=
0|
1|
2], [FilterName=
""""], [FilterOptions=
""""]
"
723 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
727 If IsMissing(Password) Or IsEmpty(Password) Then Password =
""
728 If IsMissing(ReadOnly) Or IsEmpty(ReadOnly) Then ReadOnly = False
729 If IsMissing(Hidden) Or IsEmpty(Hidden) Then Hidden = False
730 If IsMissing(MacroExecution) Or IsEmpty(MacroExecution) Then MacroExecution = MACROEXECNORMAL
731 If IsMissing(FilterName) Or IsEmpty(FilterName) Then FilterName =
""
732 If IsMissing(FilterOptions) Or IsEmpty(FilterOptions) Then FilterOptions =
""
734 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
735 If Not SF_Utils._ValidateFile(FileName,
"FileName
") Then GoTo Finally
736 If Not SF_Utils._Validate(Password,
"Password
", V_STRING) Then GoTo Finally
737 If Not SF_Utils._Validate(ReadOnly,
"ReadOnly
", V_BOOLEAN) Then GoTo Finally
738 If Not SF_Utils._Validate(Hidden,
"Hidden
", V_BOOLEAN) Then GoTo Finally
739 If Not SF_Utils._Validate(MacroExecution,
"MacroExecution
", V_NUMERIC _
740 , Array(MACROEXECNORMAL, MACROEXECNEVER, MACROEXECALWAYS)) Then GoTo Finally
741 If Not SF_Utils._Validate(FilterName,
"FilterName
", V_STRING) Then GoTo Finally
742 If Not SF_Utils._Validate(FilterOptions,
"FilterOptions
", V_STRING) Then GoTo Finally
745 ' Check the existence of FileName and FilterName
746 If Not SF_FileSystem.FileExists(FileName) Then GoTo CatchError
747 If Len(FilterName)
> 0 Then
748 Set oFilterFactory = SF_Utils._GetUNOService(
"FilterFactory
")
749 If Not oFilterFactory.hasByName(FilterName) Then GoTo CatchError
753 With com.sun.star.document.MacroExecMode
754 Select Case MacroExecution
755 Case
0 : iMacro = .USE_CONFIG
756 Case
1 : iMacro = .NEVER_EXECUTE
757 Case
2 : iMacro = .ALWAYS_EXECUTE_NO_WARN
761 vProperties = Array( _
762 SF_Utils._MakePropertyValue(
"ReadOnly
", ReadOnly) _
763 , SF_Utils._MakePropertyValue(
"Hidden
", Hidden) _
764 , SF_Utils._MakePropertyValue(
"MacroExecutionMode
", iMacro) _
765 , SF_Utils._MakePropertyValue(
"FilterName
", FilterName) _
766 , SF_Utils._MakePropertyValue(
"FilterOptions
", FilterOptions) _
768 If Len(Password)
> 0 Then
' Password is to add only if
<> "" !?
769 vProperties = SF_Array.Append(vProperties, SF_Utils._MakePropertyValue(
"Password
", Password))
772 sFile = SF_FileSystem._ConvertToUrl(FileName)
773 Set oComp = StarDesktop.loadComponentFromURL(sFile,
"_blank
",
0, vProperties)
774 If Not IsNull(oComp) Then Set oOpen = CreateScriptService(
"SFDocuments.Document
", oComp)
777 Set OpenDocument = oOpen
778 SF_Utils._ExitFunction(cstThisSub)
783 SF_Exception.RaiseFatal(DOCUMENTOPENERROR,
"FileName
", FileName,
"Password
", Password,
"FilterName
", FilterName)
785 End Function
' ScriptForge.SF_UI.OpenDocument
787 REM -----------------------------------------------------------------------------
788 Public Function Properties() As Variant
789 ''' Return the list or properties of the Timer class as an array
791 Properties = Array( _
792 "ActiveWindow
" _
795 End Function
' ScriptForge.SF_UI.Properties
797 REM -----------------------------------------------------------------------------
798 Public Sub Resize(Optional ByVal Left As Variant _
799 , Optional ByVal Top As Variant _
800 , Optional ByVal Width As Variant _
801 , Optional ByVal Height As Variant _
803 ''' Resizes and/or moves the active window. Negative arguments are ignored.
804 ''' If the window was minimized or without arguments, it is restored
805 ''' Args:
806 ''' Left, Top: Distances from top and left edges of the screen
807 ''' Width, Height: Dimensions of the window
808 ''' Examples:
809 ''' ui.Resize(
10,,
500)
' Top and Height are unchanged
810 ''' ...
812 Dim vWindow As Window
' A single component
813 Dim oContainer As Object
' com.sun.star.awt.XWindow
814 Dim iPosSize As Integer
' Computes which of the
4 arguments should be considered
815 Const cstThisSub =
"UI.Resize
"
816 Const cstSubArgs =
"[Left], [Top], [Width], [Height]
"
818 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
821 If IsMissing(Left) Or IsEmpty(Left) Then Left = -
1
822 If IsMissing(Top) Or IsEmpty(Top) Then Top = -
1
823 If IsMissing(Width) Or IsEmpty(Width) Then Width = -
1
824 If IsMissing(Height) Or IsEmpty(Height) Then Height = -
1
825 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
826 If Not SF_Utils._Validate(Left,
"Left
", V_NUMERIC) Then GoTo Finally
827 If Not SF_Utils._Validate(Top,
"Top
", V_NUMERIC) Then GoTo Finally
828 If Not SF_Utils._Validate(Width,
"Width
", V_NUMERIC) Then GoTo Finally
829 If Not SF_Utils._Validate(Height,
"Height
", V_NUMERIC) Then GoTo Finally
833 vWindow = SF_UI._IdentifyWindow(StarDesktop.CurrentComponent)
834 If Not IsNull(vWindow.Frame) Then
835 Set oContainer = vWindow.Frame.ContainerWindow
837 If Left
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
838 If Top
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
839 If Width
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
840 If Height
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
844 .setPosSize(Left, Top, Width, Height, iPosSize)
849 SF_Utils._ExitFunction(cstThisSub)
853 End Sub
' ScriptForge.SF_UI.Resize
855 REM -----------------------------------------------------------------------------
856 Public Function SetProperty(Optional ByVal PropertyName As Variant _
857 , Optional ByRef Value As Variant _
859 ''' Set a new value to the given property
860 ''' Args:
861 ''' PropertyName: the name of the property as a string
862 ''' Value: its new value
863 ''' Exceptions
864 ''' ARGUMENTERROR The property does not exist
866 Const cstThisSub =
"UI.SetProperty
"
867 Const cstSubArgs =
"PropertyName, Value
"
869 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
873 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
874 If Not SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
878 Select Case UCase(PropertyName)
883 SF_Utils._ExitFunction(cstThisSub)
887 End Function
' ScriptForge.SF_UI.SetProperty
889 REM -----------------------------------------------------------------------------
890 Public Sub SetStatusbar(Optional ByVal Text As Variant _
891 , Optional ByVal Percentage As Variant _
893 ''' Display a text and a progressbar in the status bar of the active window
894 ''' Any subsequent calls in the same macro run refer to the same status bar of the same window,
895 ''' even if the window is not active anymore
896 ''' A call without arguments resets the status bar to its normal state.
897 ''' Args:
898 ''' Text: the optional text to be displayed before the progress bar
899 ''' Percentage: the optional degree of progress between
0 and
100
900 ''' Examples:
901 ''' Dim i As Integer
902 ''' For i =
0 To
100
903 ''' ui.SetStatusbar(
"Progress ...
", i)
904 ''' Wait
50
905 ''' Next i
906 ''' ui.SetStatusbar
909 Dim oControl As Object
910 Static oStatusbar As Object
911 Const cstThisSub =
"UI.SetStatusbar
"
912 Const cstSubArgs =
"[Text], [Percentage]
"
914 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
917 If IsMissing(Text) Or IsEmpty(Text) Then Text =
""
918 If IsMissing(Percentage) Or IsEmpty(Percentage) Then Percentage = -
1
919 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
920 If Not SF_Utils._Validate(Text,
"Text
", V_STRING) Then GoTo Finally
921 If Not SF_Utils._Validate(Percentage,
"Percentage
", V_NUMERIC) Then GoTo Finally
926 If IsNull(oStatusbar) Then
' Initial call
927 Set oComp = StarDesktop.CurrentComponent
928 If Not IsNull(oComp) Then
929 Set oControl = Nothing
930 If SF_Session.HasUnoProperty(oComp,
"CurrentController
") Then Set oControl = oComp.CurrentController
931 If Not IsNull(oControl) Then
932 If SF_Session.HasUnoMethod(oControl,
"getStatusIndicator
") Then oStatusbar = oControl.getStatusIndicator()
935 If Not IsNull(oStatusbar) Then
936 .start(
"",
100)
939 If Not IsNull(oStatusbar) Then
940 If Len(Text) =
0 And Percentage = -
1 Then
943 If Len(Text)
> 0 Then .setText(Text)
944 If Percentage
>=
0 And Percentage
<=
100 Then .setValue(Percentage)
950 SF_Utils._ExitFunction(cstThisSub)
954 End Sub
' ScriptForge.SF_UI.SetStatusbar
956 REM -----------------------------------------------------------------------------
957 Public Sub ShowProgressBar(Optional Title As Variant _
958 , Optional ByVal Text As Variant _
959 , Optional ByVal Percentage As Variant _
961 ''' Display a non-modal dialog box. Specify its title, an explicatory text and the progress on a progressbar
962 ''' A call without arguments erases the progress bar dialog.
963 ''' The box will anyway vanish at the end of the macro run.
964 ''' Args:
965 ''' Title: the title appearing on top of the dialog box (Default =
"ScriptForge
")
966 ''' Text: the optional text to be displayed above the progress bar (default = zero-length string)
967 ''' Percentage: the degree of progress between
0 and
100. Default =
0
968 ''' Examples:
969 ''' Dim i As Integer
970 ''' For i =
0 To
100
971 ''' ui.ShowProgressBar(,
"Progress ...
" & i
& "/
100", i)
972 ''' Wait
50
973 ''' Next i
974 ''' ui.ShowProgressBar
976 Dim bFirstCall As Boolean
' True at first invocation of method
977 Static oDialog As Object
' SFDialogs.Dialog object
978 Static oFixedText As Object
' SFDialogs.DialogControl object
979 Static oProgressBar As Object
' SFDialogs.DialogControl object
980 Dim sTitle As String
' Alias of Title
981 Const cstThisSub =
"UI.ShowProgressBar
"
982 Const cstSubArgs =
"[Title], [Text], [Percentage]
"
984 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
987 If IsMissing(Title) Or IsEmpty(Title) Then Title =
""
988 If IsMissing(Text) Or IsEmpty(Text) Then Text =
""
989 If IsMissing(Percentage) Or IsEmpty(Percentage) Then Percentage = -
1
990 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
991 If Not SF_Utils._Validate(Title,
"Title
", V_STRING) Then GoTo Finally
992 If Not SF_Utils._Validate(Text,
"Text
", V_STRING) Then GoTo Finally
993 If Not SF_Utils._Validate(Percentage,
"Percentage
", V_NUMERIC) Then GoTo Finally
998 bFirstCall = ( IsNull(oDialog) )
999 If Not bFirstCall Then bFirstCall = Not ._IsStillAlive(False)
' False to not raise an error
1000 If bFirstCall Then Set oDialog = CreateScriptService(
"SFDialogs.Dialog
",
"GlobalScope
",
"ScriptForge
",
"dlgProgress
")
1002 If Not IsNull(oDialog) Then
1003 If Len(Title) =
0 And Len(Text) =
0 And Percentage = -
1 Then
1004 Set oDialog = .Dispose()
1006 .Caption = Iif(Len(Title)
> 0, Title,
"ScriptForge
")
1008 Set oFixedText = .Controls(
"ProgressText
")
1009 Set oProgressBar = .Controls(
"ProgressBar
")
1010 .Controls(
"CloseButton
").Caption = _SF_.Interface.GetText(
"CLOSEBUTTON
")
1011 .Execute(Modal := False)
1013 If Len(Text)
> 0 Then oFixedText.Caption = Text
1014 oProgressBar.Value = Iif(Percentage
>=
0 And Percentage
<=
100, Percentage,
0)
1020 SF_Utils._ExitFunction(cstThisSub)
1024 End Sub
' ScriptForge.SF_UI.ShowProgressBar
1026 REM -----------------------------------------------------------------------------
1027 Public Function WindowExists(Optional ByVal WindowName As Variant) As Boolean
1028 ''' Returns True if the specified window exists
1029 ''' Args:
1030 ''' WindowName: see definitions
1031 ''' Returns:
1032 ''' True if the given window is found
1033 ''' Examples:
1034 ''' ui.WindowExists(
"C:\Me\My file.odt
")
1036 Dim bWindowExists As Boolean
' Return value
1037 Dim oEnum As Object
' com.sun.star.container.XEnumeration
1038 Dim oComp As Object
' com.sun.star.lang.XComponent
1039 Dim vWindow As Window
' A single component
1040 Dim oContainer As Object
' com.sun.star.awt.XWindow
1041 Const cstThisSub =
"UI.WindowExists
"
1042 Const cstSubArgs =
"WindowName
"
1044 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1045 bWindowExists = False
1048 If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName =
""
1049 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1050 If Not SF_Utils._ValidateFile(WindowName,
"WindowName
") Then GoTo Finally
1054 Set oEnum = StarDesktop.Components().createEnumeration
1055 Do While oEnum.hasMoreElements
1056 Set oComp = oEnum.nextElement
1057 vWindow = SF_UI._IdentifyWindow(oComp)
1059 ' Does the current window match the arguments ?
1060 If (Len(.WindowFileName)
> 0 And .WindowFileName = SF_FileSystem.ConvertToUrl(WindowName)) _
1061 Or (Len(.WindowName)
> 0 And .WindowName = WindowName) _
1062 Or (Len(.WindowTitle)
> 0 And .WindowTitle = WindowName) Then
1063 bWindowExists = True
1070 WindowExists = bWindowExists
1071 SF_Utils._ExitFunction(cstThisSub)
1075 End Function
' ScriptForge.SF_UI.WindowExists
1077 REM =========================================================== PRIVATE FUNCTIONS
1079 REM -----------------------------------------------------------------------------
1080 Public Sub _CloseProgressBar(Optional ByRef poEvent As Object)
1081 ''' Triggered by the Close button in the dlgProgress dialog
1082 ''' to simply close the dialog
1084 ShowProgressBar()
' Without arguments =
> close the dialog
1086 End Sub
' ScriptForge.SF_UI._CloseProgressBar
1088 REM -----------------------------------------------------------------------------
1089 Public Function _IdentifyWindow(ByRef poComponent As Object) As Object
1090 ''' Return a Window object (definition on top of module) based on component given as argument
1091 ''' Is a shortcut to explore the most relevant properties or objects bound to a UNO component
1093 Dim oWindow As Window
' Return value
1094 Dim sImplementation As String
' Component
's implementationname
1095 Dim sIdentifier As String
' Component
's identifier
1096 Dim vArg As Variant
' One single item of the Args UNO property
1097 Dim FSO As Object
' Alias for SF_FileSystem
1099 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1100 Set _IdentifyWindow = Nothing
1101 sImplementation =
"" : sIdentifier =
""
1103 Set FSO = SF_FileSystem
1105 Set .Frame = Nothing
1106 Set .Component = Nothing
1107 .WindowName =
""
1108 .WindowTitle =
""
1109 .WindowFileName =
""
1110 .DocumentType =
""
1111 If IsNull(poComponent) Then GoTo Finally
1112 If SF_Session.HasUnoProperty(poComponent,
"ImplementationName
") Then sImplementation = poComponent.ImplementationName
1113 If SF_Session.HasUnoProperty(poComponent,
"Identifier
") Then sIdentifier = poComponent.Identifier
1114 Set .Component = poComponent
1115 Select Case sImplementation
1116 Case
"com.sun.star.comp.basic.BasicIDE
"
1117 .WindowName = BASICIDE
1118 Case
"com.sun.star.comp.dba.ODatabaseDocument
" ' No identifier
1119 .WindowFileName = SF_Utils._GetPropertyValue(poComponent.Args,
"URL
")
1120 If Len(.WindowFileName)
> 0 Then .WindowName = FSO.GetName(FSO._ConvertFromUrl(.WindowFileName))
1121 .DocumentType = BASEDOCUMENT
1122 Case
"org.openoffice.comp.dbu.ODatasourceBrowser
"
1123 Case
"org.openoffice.comp.dbu.OTableDesign
",
"org.openoffice.comp.dbu.OQueryDesign
" ' Table or Query in Edit mode
1124 Case
"org.openoffice.comp.dbu.ORelationDesign
"
1125 Case
"com.sun.star.comp.sfx2.BackingComp
" ' Welcome screen
1126 Set .Frame = poComponent.Frame
1127 .WindowName = WELCOMESCREEN
1129 If Len(sIdentifier)
> 0 Then
1130 ' Do not use URL : it contains the TemplateFile when new documents are created from a template
1131 .WindowFileName = poComponent.Location
1132 If Len(.WindowFileName)
> 0 Then .WindowName = FSO.GetName(FSO._ConvertFromUrl(.WindowFileName))
1133 If SF_Session.HasUnoProperty(poComponent,
"Title
") Then .WindowTitle = poComponent.Title
1134 Select Case sIdentifier
1135 Case
"com.sun.star.sdb.FormDesign
" ' Form
1136 Case
"com.sun.star.sdb.TextReportDesign
" ' Report
1137 Case
"com.sun.star.text.TextDocument
" ' Writer
1138 .DocumentType = WRITERDOCUMENT
1139 Case
"com.sun.star.sheet.SpreadsheetDocument
" ' Calc
1140 .DocumentType = CALCDOCUMENT
1141 Case
"com.sun.star.presentation.PresentationDocument
" ' Impress
1142 .DocumentType = IMPRESSDOCUMENT
1143 Case
"com.sun.star.drawing.DrawingDocument
" ' Draw
1144 .DocumentType = DRAWDOCUMENT
1145 Case
"com.sun.star.formula.FormulaProperties
" ' Math
1146 .DocumentType = MATHDOCUMENT
1151 If IsNull(.Frame) Then
1152 If Not IsNull(poComponent.CurrentController) Then Set .Frame = poComponent.CurrentController.Frame
1157 Set _IdentifyWindow = oWindow
1161 End Function
' ScriptForge.SF_UI._IdentifyWindow
1163 REM -----------------------------------------------------------------------------
1164 Private Function _Repr() As String
1165 ''' Convert the UI instance to a readable string, typically for debugging purposes (DebugPrint ...)
1166 ''' Args:
1167 ''' Return:
1168 ''' "[UI]
"
1170 _Repr =
"[UI]
"
1172 End Function
' ScriptForge.SF_UI._Repr
1174 REM ============================================ END OF SCRIPTFORGE.SF_UI