Hello world extension
I’m going to modify the following hello world BASIC extension. It has a BASIC script here:
Progress bar
I have the BASIC code and also the XML dialog for a progress bar that I borrowed from here: BASIC|Calc: Progress bar - #3 by Ratslinger
I need to add the following BASIC code and XML dialog of the progress bar example to the above hello world extension.
Progress bar code
REM ***** BASIC *****
Option Explicit
Sub ProgressBarDemo()
Dim oProgressBar as Object, oProgressBarModel As Object, oDialog as Object
Dim ProgressValue As Long
Dim oSheet as Object
Dim oCell as Object
Dim ProgressValueMin as Integer
Dim ProgressValueMax as Integer
REM Dialog1 contains progress bar ProgressBar1 saved in standard library
DialogLibraries.loadLibrary("Standard")
oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
REM progress bar settings
ProgressValueMin = InputBox ("Please enter a starting value:","Input Required")
ProgressValueMax = InputBox ("Please enter a ending value:","Input Required")
' Const ProgressValueMin = 0
' Const ProgressValueMax = 40
Const ProgressStep = 4
REM set minimum and maximum progress value
oProgressBarModel = oDialog.getModel().getByName( "ProgressBar1" )
oProgressBarModel.setPropertyValue( "ProgressValueMin", ProgressValueMin)
oProgressBarModel.setPropertyValue( "ProgressValueMax", ProgressValueMax)
REM show progress bar
oDialog.setVisible( True )
REM increase progress value every second
oSheet=thiscomponent.getcurrentcontroller.activesheet
oCell=oSheet.getCellByPosition(0,9)
For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
oProgressBarModel.setPropertyValue( "ProgressValue", ProgressValue )
REM This is where you perform whatever action you are wanting
oCell.SetString(ProgressValue)
Wait 1000
Next ProgressValue
oCell.SetString("Done")
End Sub
Progress bar dialog
And this file named Dialog1.xdl
with this content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Dialog1" dlg:left="13" dlg:top="11" dlg:width="197" dlg:height="78" dlg:closeable="true" dlg:moveable="true">
<dlg:bulletinboard>
<dlg:progressmeter dlg:id="ProgressBar1" dlg:tab-index="0" dlg:left="15" dlg:top="41" dlg:width="170" dlg:height="22"/>
<dlg:text dlg:id="Label1" dlg:tab-index="1" dlg:left="15" dlg:top="14" dlg:width="55" dlg:height="9" dlg:value="Progress -----"/>
</dlg:bulletinboard>
</dlg:window>
Question
I have tried some approaches but none worked. I’m getting confused about how to add the progress bar example to the hello world extension. I’d apreciate any hint or help. Thanks.