summaryrefslogtreecommitdiffstats
path: root/source/text/sbasic/shared/03/sf_ui.xhp
blob: 94d8cdb33f614dbe532afc8dc441cc5ed3033804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
-->

<meta>
  <topic id="SF_UI" indexer="include" status="PUBLISH">
    <title id="tit" xml-lang="en-US">ScriptForge.UI service</title>
    <filename>/text/sbasic/shared/03/sf_ui.xhp</filename>
  </topic>
</meta>
<body>
<section id="abstract">
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id151587913266190">
      <bookmark_value>UI service</bookmark_value>
   </bookmark>

<h1 id="hd_id371587913266310" xml-lang="en-US"><variable id="UIService"><link href="text/sbasic/shared/03/sf_ui.xhp" name="ScriptForge.UI service"><literal>ScriptForge</literal>.<literal>UI</literal> service</link></variable></h1>

<paragraph role="paragraph" xml-lang="en-US" id="par_id31587913266153">The UI (User Interface) service simplifies the identification and the manipulation of the different windows composing the whole %PRODUCTNAME application:</paragraph>
<list type="unordered">
   <listitem>
      <paragraph role="listitem" id="par_id591587913266547" xml-lang="en-US">Windows selection</paragraph>
   </listitem>
   <listitem>
      <paragraph role="listitem" id="par_id511587913266292" xml-lang="en-US">Windows moving and resizing</paragraph>
   </listitem>
   <listitem>
      <paragraph role="listitem" id="par_id51587913266596" xml-lang="en-US">Statusbar settings</paragraph>
   </listitem>
   <listitem>
      <paragraph id="par_id401599404339702"  role="listitem" xml-lang="en-US">Display of a floating progress bar</paragraph>
   </listitem>
   <listitem>
      <paragraph role="listitem" id="par_id761587913266388" xml-lang="en-US">Creation of new windows</paragraph>
   </listitem>
   <listitem>
      <paragraph role="listitem" id="par_id591587913266489" xml-lang="en-US">Access to the underlying "documents"</paragraph>
   </listitem>
</list>
</section>

<tip id="par_id181620312953395">The UI service is the starting point to open, create or access to the content of new or existing documents from a user script.</tip>

<h2 id="hd_id881587913266307">Definitions</h2>

<section id="WindowName">
  <h3 id="hd_id761587913266887" localize="false">WindowName</h3>
  <paragraph role="paragraph" id="par_id741587913266919">A window can be designated using various ways:</paragraph>
  <list type="unordered">
     <listitem>
        <paragraph role="listitem" id="par_id291587913946648" xml-lang="en-US">a full path and file name</paragraph>
     </listitem>
     <listitem>
        <paragraph role="listitem" id="par_id991587914045862" xml-lang="en-US">the last component of the full file name or even only the last component without its suffix</paragraph>
     </listitem>
     <listitem>
        <paragraph role="listitem" id="par_id541587914079744" xml-lang="en-US">the title of the window</paragraph>
     </listitem>
     <listitem>
        <paragraph role="listitem" id="par_id191587914134221" xml-lang="en-US">for new documents, something like "Untitled 1"</paragraph>
     </listitem>
     <listitem>
        <paragraph role="listitem" id="par_id911587914185746" xml-lang="en-US">one of the special windows "<literal>BASICIDE</literal>" and "<literal>WELCOMESCREEN</literal>"</paragraph>
     </listitem>
  </list>
  <paragraph role="paragraph" id="par_id181587914255236" xml-lang="en-US">The window name is case-sensitive.</paragraph>
  <h3 id="hd_id541588520711430" xml-lang="en-US">Document object</h3>
</section>
  <paragraph role="paragraph" id="par_id841588521238711" xml-lang="en-US">The methods <literal>CreateDocument</literal>, <literal>CreateBaseDocument</literal>, <literal>GetDocument</literal> and <literal>OpenDocument</literal>, described below, generate document objects. When a window contains a document, an instance of the <literal>Document</literal> class represents that document. A counterexample the Basic IDE is not a document but is a window in our terminology. Additionally a document has a type: <literal>Calc</literal>, <literal>Impress</literal>, <literal>Writer</literal>, ...</paragraph>
  <paragraph role="paragraph" id="par_id331588521254916" xml-lang="en-US">The specific properties and methods applicable on documents are implemented in a document class.</paragraph>
  <tip id="par_id971588521292976" xml-lang="en-US">The implementation of the document objects class is done in the <literal>SFDocuments</literal> associated library. See its "<literal>Document</literal>" service.</tip>

<h2 id="hd_id91587913266988" xml-lang="en-US">Service invocation</h2>
  <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
  <bascode>
    <paragraph role="bascode" localize="false" id="bas_id391587913266269">Dim ui As Variant</paragraph>
    <paragraph role="bascode" localize="false" id="bas_id851582897798335">GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")</paragraph>
    <paragraph role="bascode" localize="false" id="bas_id1001587913266355">Set ui = CreateScriptService("UI")</paragraph>
  </bascode>
  <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
  <pycode>
    <paragraph role="pycode" localize="false" id="pyc_id61620310677393">from scriptforge import CreateScriptService</paragraph>
    <paragraph role="pycode" localize="false" id="pyc_id601620310674922">svcUI = CreateScriptService("UI")</paragraph>
  </pycode>

<h2 id="hd_id841587913266618" xml-lang="en-US">Properties</h2>
  <table id="tab_id291587913266435">
     <tablerow>
        <tablecell>
           <paragraph id="par_id521587913266568" role="tablehead" xml-lang="en-US">Name</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id421587913266368" role="tablehead" xml-lang="en-US">ReadOnly</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id631587914939732" role="tablehead" xml-lang="en-US">Type</paragraph>
           </tablecell>
        <tablecell>
           <paragraph id="par_id951587913266220" role="tablehead" xml-lang="en-US">Description</paragraph>
        </tablecell>
     </tablerow>
     <tablerow>
        <tablecell>
           <paragraph id="par_id161587913266162" role="tablecontent" localize="false">ActiveWindow</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id651587913266754" role="tablecontent" xml-lang="en-US">Yes</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id421587914989890" role="tablecontent" localize="false">String</paragraph>
           </tablecell>
        <tablecell>
           <paragraph id="par_id351587913266349" role="tablecontent" xml-lang="en-US">a valid and unique <literal>WindowName</literal> for the currently active window. When the window cannot be identified, a zero-length string is returned.</paragraph>
        </tablecell>
     </tablerow>
     <tablerow>
        <tablecell>
           <paragraph id="par_id161597813266162" role="tablecontent" localize="false">Documents</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id658517913266754" role="tablecontent" xml-lang="en-US">Yes</paragraph>
        </tablecell>
        <tablecell>
           <paragraph id="par_id421587994189890" role="tablecontent" localize="false">String array</paragraph>
           </tablecell>
        <tablecell>
           <paragraph id="par_id153587913266349" role="tablecontent" xml-lang="en-US">The list of the currently open documents. Special windows are ignored. This list consists of a zero-based one dimensional array either of filenames (in SF_FileSystem.FileNaming notation) or of window titles for unsaved documents.</paragraph>
        </tablecell>
     </tablerow>
   </table>

<section id="Constants">
<h2 id="hd_id511620762163390">Constants</h2>
<table id="tab_id51620761856238">
   <tablerow>
       <tablecell>
           <paragraph id="par_id761620761856238" role="tablehead">Name</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id591620761856238" role="tablehead">Value</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id711620761856238" role="tablehead">Description</paragraph>
       </tablecell>
   </tablerow>
   <tablerow>
       <tablecell>
           <paragraph id="par_id511620761856238" role="tablecontent">MACROEXECALWAYS</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id761620761856107" role="tablecontent">2</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id341620761856238" role="tablecontent">Macros are always executed</paragraph>
       </tablecell>
   </tablerow>
    <tablerow>
       <tablecell>
           <paragraph id="par_id661620761881513" role="tablecontent">MACROEXECNEVER</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id661620761891082" role="tablecontent">1</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id101620761893011" role="tablecontent">Macros are never executed</paragraph>
       </tablecell>
    </tablerow>
    <tablerow>
       <tablecell>
           <paragraph id="par_id311620761888379" role="tablecontent">MACROEXECNORMAL</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id951620761899067" role="tablecontent">0</paragraph>
       </tablecell>
       <tablecell>
           <paragraph id="par_id11620761899780" role="tablecontent">Macro execution depends on user settings</paragraph>
       </tablecell>
    </tablerow>
</table>
</section>

   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <paragraph role="paragraph" id="par_id311620312548992">The examples below show a <literal>MsgBox</literal> with the names of all currently open documents.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id201587985861232">Dim openDocs as Object, strDocs as String</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id261587985839734">Set openDocs = ui.Documents()</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id621587985950181">strDocs = openDocs(0)</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id11587985956383">For i = 1 to UBound(openDocs)</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id981620312219531">    strDocs = strDocs &amp; Chr(10) &amp; openDocs(i)</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id341587985962974">Next i</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id191620312244070">MsgBox strDocs</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" id="pyc_id21620312350189">svcUI = CreateScriptService("UI")</paragraph>
     <paragraph role="pycode" id="pyc_id631620312351013">sBasic = CreateScriptService("Basic")</paragraph>
     <paragraph role="pycode" id="pyc_id141620312351286">openDocs = svcUI.Documents()</paragraph>
     <paragraph role="pycode" id="pyc_id661620312351500">strDocs = "\n".join(openDocs)</paragraph>
     <paragraph role="pycode" id="pyc_id801620312351676">sBasic.MsgBox(strDocs)</paragraph>
   </pycode>

    <table id="tab_id891606472825856">
    <tablerow>
       <tablecell colspan="3"><paragraph id="par_id881608131596153" role="tablehead">List of Methods in the UI Service</paragraph></tablecell>
    </tablerow>
    <tablerow>
       <tablecell><paragraph id="par_id381606472825856" role="tablecontent" localize="false">
           <link href="text/sbasic/shared/03/sf_ui.xhp#Activate" name="Activate method">Activate</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#CreateBaseDocument" name="CreateBaseDocument method">CreateBaseDocument</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#CreateDocument" name="CreateDocument method">CreateDocument</link> (*)<br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#GetDocument" name="GetDocument method">GetDocument</link>
       </paragraph></tablecell>
       <tablecell><paragraph id="par_id451606472825856" role="tablecontent" localize="false">
           <link href="text/sbasic/shared/03/sf_ui.xhp#Maximize" name="Maximize method">Maximize</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#Minimize" name="Minimize method">Minimize</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#OpenBaseDocument" name="OpenBaseDocument method">OpenBaseDocument</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#OpenDocument" name="OpenDocument method">OpenDocument</link> (*)
       </paragraph></tablecell>
       <tablecell><paragraph id="par_id161606472825856" role="tablecontent" localize="false">
           <link href="text/sbasic/shared/03/sf_ui.xhp#Resize" name="Resize method">Resize</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#SetStatusBar" name="SetStatusBar method">SetStatusBar</link> (*)<br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#ShowProgressBar" name="ShowProgressBar method">ShowProgressBar</link><br/>
           <link href="text/sbasic/shared/03/sf_ui.xhp#WindowExists" name="WindowExists method">WindowExists</link>
       </paragraph></tablecell>
    </tablerow>
    </table>
<warning id="par_id431620322170443">Note, as an exception, that the methods marked <emph>(*)</emph> are <emph>not applicable to Base documents</emph>.</warning>

<section id="Activate">
  <comment> Activate -------------------------------------------------------------------------------------------------------------------------- </comment>
    <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id991587913266189">
       <bookmark_value>UI service;Activate</bookmark_value>
    </bookmark>
  <h2 id="hd_id76158791326673" localize="false">Activate</h2>
  <paragraph role="paragraph" id="par_id201587913266596">Make the specified window active. The method returns <literal>True</literal> if the given window is found and can be activated. There is no change in the actual user interface if no window matches the selection.</paragraph>
    <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
    <paragraph role="paragraph" localize="false" id="par_id331620319796672">
      <input>svc.Activate(windowname: str): bool</input>
    </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
     <paragraph role="paragraph" id="par_id381587913266946"><emph>windowname</emph>: see the definitions above.</paragraph>
    <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
    <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
    <bascode>
      <paragraph role="bascode" localize="false" id="bas_id201587913266745">ui.Activate("C:\Documents\My file.odt")</paragraph>
    </bascode>
    <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
    <pycode>
      <paragraph role="pycode" localize="false" id="pyc_id941620322846267">svcUI.Activate(r"C:\Documents\My file.odt")</paragraph>
    </pycode>
</section>

<section id="CreateBaseDocument">
   <comment> CreateBaseDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id871596554849122">
      <bookmark_value>UI service;CreateBaseDocument</bookmark_value>
   </bookmark>
   <h2 id="hd_id281596554849363" localize="false">CreateBaseDocument</h2>
   <paragraph role="paragraph" id="par_id13159655484952">Creates and stores a new %PRODUCTNAME Base document embedding an empty database of the given type. The method returns a <literal>Document</literal> service instance.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id461620320014911">
     <input>svc.CreateBaseDocument(filename: str, embeddeddatabase: str = 'HSQLDB', registrationname: str = ''): svc</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id441596554849949"><emph>filename</emph> : Identifies the file to create. It must follow the <literal>SF_FileSystem.FileNaming</literal> notation. If the file already exists, it is overwritten without warning</paragraph>
   <paragraph role="paragraph" id="par_id381596554849698" xml-lang="en-US"><emph>embeddeddatabase</emph> : Either "HSQLDB" (default) or "FIREBIRD".</paragraph>
   <paragraph role="paragraph" id="par_id521596554849185" xml-lang="en-US"><emph>registrationname</emph> : The name used to store the new database in the databases register. When = "" (default), no registration takes place. If the name already exists it is overwritten without warning.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id631596554849994">Dim myBase As Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id921596554849612">Set myBase = ui.CreateBaseDocument("C:\Databases\MyBaseFile.odb", "FIREBIRD")</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" id="pyc_id361620323808010">myBase = svcUI.CreateBaseDocument(r"C:\Databases\MyBaseFile.odb", "FIREBIRD")</paragraph>
   </pycode>
</section>

<section id="CreateDocument">
   <comment> CreateDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id461588521753429">
      <bookmark_value>UI service;CreateDocument</bookmark_value>
   </bookmark>
   <h2 id="hd_id45158852175376" localize="false">CreateDocument (*)</h2>
   <paragraph role="paragraph" id="par_id651588521753997">Create a new %PRODUCTNAME document of a given type or based on a given template. The method returns a document object.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id401620320696126">
     <input>svc.CreateDocument(documenttype: str = '', templatefile: str = '', hidden: bool = False): svc</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id51588521753302"><emph>documenttype</emph> : "Calc", "Writer", etc. If absent, the <literal>TemplateFile</literal> argument must be present.</paragraph>
   <paragraph role="paragraph" id="par_id401588522663325" xml-lang="en-US"><emph>templatefile</emph> : The full <literal>FileName</literal> of the template to build the new document on. If the file does not exist, the argument is ignored. The <literal>FileSystem</literal> service provides the <literal>TemplatesFolder</literal> and <literal>UserTemplatesFolder</literal> properties to help to build the argument.</paragraph>
   <paragraph role="paragraph" id="par_id131588522824366" xml-lang="en-US"><emph>hidden</emph>: if <literal>True</literal>, open the new document in the background (default = <literal>False</literal>). To use with caution: activation or closure afterwards can only happen programmatically.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <paragraph role="paragraph" id="par_id701620762417802">In both examples below, the first call to <literal>CreateDocument</literal> method creates a blank Calc document, whereas the second creates a document from a template file.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id201588522371030">Dim myDoc1 As Object, myDoc2 As Object, FSO As Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id931588522377598">Set myDoc1 = ui.CreateDocument("Calc")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id821588522387111">Set FSO = CreateScriptService("FileSystem")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id661588522393007">Set myDoc2 = ui.CreateDocument(, FSO.BuildPath(FSO.TemplatesFolder, "personal/CV.ott"))</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id901620324433095">myDoc1 = svcUI.CreateDocument("Calc")</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id361620324544381">FSO = CreateScriptService("FileSystem")</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id161620324434583">myDoc2 = svcUI.CreateDocument(templatefile = FSO.BuildPath(FSO.TemplatesFolder, "personal/CV.ott"))</paragraph>
   </pycode>
</section>

<section id="GetDocument">
   <comment> GetDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id351588520551838">
      <bookmark_value>UI service;GetDocument</bookmark_value>
   </bookmark>
   <h2 id="hd_id171588520551515" localize="false">GetDocument</h2>
   <paragraph role="paragraph" id="par_id201588520551463">Returns a document object referring to either the active window or the given window.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id811620320778478">
     <input>svc.GetDocument(windowname: str = ''): svc</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id851588520551368"><emph>windowname</emph>: See the definitions <link href="text/sbasic/shared/03/sf_ui.xhp#WindowName" name="WindowName section">above</link>. If this argument is absent, the active window is used.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id191588522924110">Dim myDoc As Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id591588520551682">Set myDoc = ui.GetDocument("C:\Documents\My file.odt")</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id831620330074037">myDoc = svcUI.GetDocument(r"C:\Documents\My file.odt")</paragraph>
   </pycode>
   <tip id="par_id521620330287071">To access the name of the currently active window, refer to the <literal>ActiveWindow</literal> property.</tip>
</section>

<section id="Maximize">
   <comment> Maximize -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id441587986441397">
      <bookmark_value>UI service;Maximize</bookmark_value>
   </bookmark>
   <h2 id="hd_id261587986441738" localize="false">Maximize</h2>
   <paragraph role="paragraph" id="par_id24158798644169">Maximizes the active window or the given window.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id631620320925633">
     <input>svc.Maximize(windowname: str)</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id951587986441954"><emph>windowname</emph>: see the definitions <link href="text/sbasic/shared/03/sf_ui.xhp#WindowName" name="WindowName section">above</link>. If this argument is absent, the active window is maximized.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id891587986441319">ui.Maximize("Untitled 1")</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id181620330373220">svcUI.Maximize("Untitled 1")</paragraph>
   </pycode>
</section>

<section id="Minimize">
   <comment> Minimize -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id2315879865929">
      <bookmark_value>UI service;Minimize</bookmark_value>
   </bookmark>
   <h2 id="hd_id21158798659210" localize="false">Minimize</h2>
   <paragraph role="paragraph" id="par_id871587986592696">Minimizes the active window or the given window.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id201620321224368">
     <input>svc.Minimize(windowname: str)</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id751587986592626"><emph>windowname</emph>: see the definitions <link href="text/sbasic/shared/03/sf_ui.xhp#WindowName" name="WindowName section">above</link>. If this argument is absent, the active window is minimized.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
     <paragraph role="bascode" localize="false" id="bas_id671587986592107">ui.Minimize()</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id481620330501644">svcUI.Minimize()</paragraph>
   </pycode>
</section>

<section id="OpenBaseDocument">
   <comment> OpenBaseDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id291596555746452">
      <bookmark_value>UI service;OpenBaseDocument</bookmark_value>
   </bookmark>
   <h2 id="hd_id671596555746148" localize="false">OpenBaseDocument</h2>
   <paragraph role="paragraph" id="par_id691596555746539">Open an existing %PRODUCTNAME Base document. The method returns a document object.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id21620321395150">
     <input>svc.OpenBaseDocument(filename: str = '', registrationname: str = '', macroexecution: int = 0): svc</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id231596555746385"><emph>filename</emph> : Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. If the file already exists, it is overwritten without warning</paragraph>
   <paragraph role="paragraph" id="par_id711596555746281" xml-lang="en-US"><emph>registrationname</emph> : The name to use to find the database in the databases register. It is ignored if <literal>FileName</literal> &lt;&gt; "".</paragraph>
   <paragraph role="paragraph" id="id721596556313545" xml-lang="en-US"><emph>macroexecution</emph>: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id761596555746795">Dim myBase As Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id91596555746449">Set myBase = ui.OpenBaseDocument("C:\Documents\myDB.odb", MacroExecution := ui.MACROEXECALWAYS)</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id431620331254271">svcUI.OpenBaseDocument(r"C:\Documents\myDB.odb", macroexecution = svcUI.MACROEXECALWAYS)</paragraph>
   </pycode>
   <tip id="par_id941620762989833">To improve code readability you can use <link href="text/sbasic/shared/03/sf_ui.xhp#Constants" name="CHANGE ME">predefined constants</link> for the <literal>macroexecution</literal> argument, as in the examples above.</tip>
</section>

<section id="OpenDocument">
   <comment> OpenDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id141588523635836">
      <bookmark_value>UI service;OpenDocument</bookmark_value>
   </bookmark>
   <h2 id="hd_id451588523635719" localize="false">OpenDocument (*)</h2>
   <paragraph role="paragraph" id="par_id541588523635283">Opens an existing %PRODUCTNAME document with the given options. Returns a document object or one of its subclasses. The method returns <literal>Nothing</literal> (in Basic) / <literal>None</literal> (in Python) if the opening failed, even when the failure is caused by a user decision.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id271620321692960">
     <input>svc.Opendocument(filename: str, password: str = '', readonly: bool = False, hidden: bool = False, macroexecution: int = 0, filtername: str = '', filteroptions: str = ''): svc</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id481588523635890"><emph>filename</emph>: Identifies the file to open. It must follow the <literal>FileNaming</literal> notation of the <literal>FileSystem</literal> service.</paragraph>
   <paragraph role="paragraph" id="par_id451588523635507" xml-lang="en-US"><emph>password</emph>: To use when the document is protected. If wrong or absent while the document is protected, the user will be prompted to enter a password.</paragraph>
   <paragraph role="paragraph" id="par_id611588524329781" xml-lang="en-US"><emph>readonly</emph>: Default = <literal>False</literal>.</paragraph>
   <paragraph role="paragraph" id="par_id641588523635497" xml-lang="en-US"><emph>hidden</emph>: if <literal>True</literal>, open the new document in the background (default = <literal>False</literal>). To use with caution: activation or closure afterwards can only happen programmatically.</paragraph>
   <paragraph role="paragraph" id="par_id981588524474719" xml-lang="en-US"><emph>macroexecution</emph>: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable.</paragraph>
   <paragraph role="paragraph" id="par_id611588524584693" xml-lang="en-US"><emph>filtername</emph>: The name of a filter that should be used for loading the document. If present, the filter must exist.</paragraph>
   <paragraph role="paragraph" id="par_id191588524634348" xml-lang="en-US"><emph>filteroptions</emph>: An optional string of options associated with the filter.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id811588523635720">Dim myDoc As Object, FSO As Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id391588523635826">Set myDoc = ui.OpenDocument("C:\Documents\myFile.odt", ReadOnly := True)</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id891620331804571">svcUI.OpenDocument(r"C:\Documents\myFile.odt", readonly = True)</paragraph>
   </pycode>
</section>

<section id="Resize">
   <comment> Resize -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id951587986945259">
      <bookmark_value>UI service;Resize</bookmark_value>
   </bookmark>
   <h2 id="hd_id551587986945514" localize="false">Resize</h2>
   <paragraph role="paragraph" id="par_id751587986945965">Resizes and/or moves the active window. Absent and negative arguments are ignored. If the window is minimized or maximized, calling <literal>Resize</literal> without arguments restores it.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id411620321819387">
     <input>svc.Resize(left: int = -1, top: int = -1, width: int = -1, height: int = -1)</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id441587986945696"><emph>left, top</emph>: Distances of the top-left corner from top and left edges of the screen, in pixels.</paragraph>
   <paragraph role="paragraph" id="par_id601587987453825" xml-lang="en-US"><emph>width, height</emph>: New dimensions of the window, in pixels.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <paragraph role="paragraph" id="par_id801587987507028">In the following examples, the <literal>width</literal> and <literal>height</literal> of the window are changed while <literal>top</literal> and <literal>left</literal> are left unchanged.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id171587986945392">ui.Resize(, ,500, 500)</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" id="pyc_id971620331945744">svcUI.Resize(width = 500, height = 500)</paragraph>
   </pycode>
   <tip id="par_id21620332301809">To resize a window that is not active, first activate it using the <literal>Activate</literal> method.</tip>
</section>

<section id="SetStatusBar">
   <comment> SetStatusbar -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id25158799642119">
      <bookmark_value>UI service;SetStatusbar</bookmark_value>
   </bookmark>
   <h2 id="hd_id171587996421550" localize="false">SetStatusbar (*)</h2>
   <paragraph role="paragraph" id="par_id281587996421580">Display a text and a progressbar in the status bar of the active window. Any subsequent calls in the same macro run refer to the same status bar of the same window, even if the window is not visible anymore. A call without arguments resets the status bar to its normal state.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id461620321923929">
     <input>svc.SetStatusbar(text: str = '', percentage: int = -1)</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id71587996421829"><emph>text</emph>: An optional text to be displayed in front of the progress bar.</paragraph>
   <paragraph role="paragraph" id="par_id881587996421777" xml-lang="en-US"><emph>percentage</emph>: an optional degree of progress between 0 and 100.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id61587996791867">Dim i As Integer</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id291587996799353">For i = 0 To 100</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id331587996806267">    ui.SetStatusbar("Progress ...", i)</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id491587996813628">    Wait 50</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id841587996820714">Next i</paragraph>
      <paragraph role="bascode" id="bas_id651620332601083">' Resets the statusbar</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id141587996829242">ui.SetStatusbar</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" id="pyc_id631620332653004">from time import sleep</paragraph>
     <paragraph role="pycode" id="pyc_id351620332422330">for i in range(101):</paragraph>
     <paragraph role="bascode" id="bas_id261620332627647">    svcUI.SetStatusbar("Test:", i)</paragraph>
     <paragraph role="pycode" id="pyc_id181620332715974">    sleep(0.05)</paragraph>
     <paragraph role="pycode" id="pyc_id381620332733373">svcUI.SetStatusbar()</paragraph>
   </pycode>
</section>

<section id="ShowProgressBar">
   <comment> ShowProgressBar -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id91159886425573">
      <bookmark_value>UI service;ShowProgressBar</bookmark_value>
   </bookmark>
   <h2 id="hd_id31598864255380" localize="false">ShowProgressBar</h2>
   <paragraph role="paragraph" id="par_id571598864255776">Displays a non-modal dialog box. Specify its title, an explicatory text and a percentage of progress to be represented on a progressbar. The dialog will remain visible until a call to the method without arguments or until the user manually closes the dialog.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id41620322016943">
     <input>svc.ShowProgressBar(title: str = '', text: str = '', percentage: str = -1)</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id441598864535695" xml-lang="en-US"><emph>title</emph> : The title appearing on top of the dialog box. Default = "ScriptForge".</paragraph>
   <paragraph role="paragraph" id="par_id311598864255297"><emph>text</emph>: An optional text to be displayed above the progress bar.</paragraph>
   <paragraph role="paragraph" id="par_id881598864255424" xml-lang="en-US"><emph>percentage</emph>: an optional degree of progress between 0 and 100.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id931598864255666">Dim i As Integer</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id211598864255731">For i = 0 To 100</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id341598864255351">    ui.ShowProgressBar("Window Title", "Progress ..." &amp; i &amp; "/100", i)</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id34159886425576">    Wait 50</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id541598864255593">Next i</paragraph>
      <paragraph role="bascode" id="bas_id651620333289753">' Closes the Progress Bar window</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id21598864255428">ui.ShowProgressBar</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" localize="false" id="pyc_id821620333264948">from time import sleep</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id611620333268146">for i in range(101):</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id331620333268525">    svcUI.ShowProgressBar("Window Title", "Progress ... " + str(i) + "/100", i)</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id451620333268900">    sleep(0.05)</paragraph>
     <paragraph role="pycode" id="pyc_id761620333269236"># Closes the Progress Bar window</paragraph>
     <paragraph role="pycode" localize="false" id="pyc_id81620333269484">svcUI.ShowProgressBar()</paragraph>
   </pycode>
</section>

<section id="WindowExists">
   <comment> WindowExists -------------------------------------------------------------------------------------------------------------------------- </comment>
   <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id431588587119136">
      <bookmark_value>UI service;WindowExists</bookmark_value>
   </bookmark>
   <h2 id="hd_id21588587119344" localize="false">WindowExists</h2>
   <paragraph role="paragraph" id="par_id431588587119925">Returns <literal>True</literal> if the given window could be identified.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
   <paragraph role="paragraph" localize="false" id="par_id521620322090015">
     <input>svc.WindowExists(windowname: str): bool</input>
   </paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
   <paragraph role="paragraph" id="par_id45158858711917"><emph>windowname</emph>: see the definitions above.</paragraph>
   <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
   <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
   <bascode>
      <paragraph role="bascode" localize="false" id="bas_id941588587119772">If ui.WindowExists("C:\Document\My file.odt") Then</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id871588587295216">    ' ...</paragraph>
   </bascode>
   <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
   <pycode>
     <paragraph role="pycode" id="pyc_id441620333481074">if svcUI.WindowExists(r"C:\Document\My file.odt"):</paragraph>
     <paragraph role="pycode" id="pyc_id801620333495532">    # ...</paragraph>
   </pycode>
</section>

<section id="relatedtopics">
  <embed href="text/sbasic/shared/03/sf_document.xhp#DocumentService"/>
</section>
</body>
</helpdocument>