1<?xml version="1.0" encoding="UTF-8"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ProgressBar" script:language="StarBasic">REM  *****  BASIC  *****
24
25Dim oDialog As Object
26
27Sub Main()
28
29	Dim oLibContainer As Object, oLib As Object
30	Dim oInputStreamProvider As Object
31	Dim oProgressBar As Object
32
33	Const sLibName = &quot;ToolkitControls&quot;
34	Const sDialogName = &quot;ProgressBarDlg&quot;
35
36	REM load/get library and input stream provider
37	oLibContainer = DialogLibraries
38	oLibContainer.loadLibrary( sLibName )
39	oLib = oLibContainer.getByName( sLibName )
40	oInputStreamProvider = oLib.getByName( sDialogName )
41
42	REM create dialog control
43	oDialog = CreateUnoDialog( oInputStreamProvider )
44
45	REM hide progress bar
46	oProgressBar = oDialog.getControl(&quot;ProgressBar1&quot;)
47	oProgressBar.setVisible( False )
48
49	REM show the dialog
50	oDialog.execute()
51
52End Sub
53
54Sub ProgressBarDemo()
55
56	Dim oProgressBar As Object, oProgressBarModel As Object
57	Dim oCancelButtonModel As Object
58	Dim oStartButtonModel As Object
59	Dim ProgressValue As Long
60
61	REM progress bar settings
62	Const ProgressValueMin = 0
63	Const ProgressValueMax = 50
64	Const ProgressStep = 1
65
66	REM set minimum and maximum progress value
67	oProgressBarModel = oDialog.Model.ProgressBar1
68	oProgressBarModel.ProgressValueMin = ProgressValueMin
69	oProgressBarModel.ProgressValueMax = ProgressValueMax
70
71	REM disable cancel and start button
72	oCancelButtonModel = oDialog.Model.CommandButton1
73	oCancelButtonModel.Enabled = False
74	oStartButtonModel = oDialog.Model.CommandButton2
75	oStartButtonModel.Enabled = False
76
77	REM show progress bar
78	oProgressBar = oDialog.getControl(&quot;ProgressBar1&quot;)
79	oProgressBar.setVisible( True )
80
81	REM increase progress value every second
82	For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
83   	    oProgressBarModel.ProgressValue = ProgressValue
84		Wait 40
85	Next ProgressValue
86
87	REM hide progress bar
88	oProgressBar.setVisible( False )
89
90	REM enable cancel and start button
91	oCancelButtonModel.Enabled = True
92	oStartButtonModel.Enabled = True
93
94End Sub
95
96</script:module>