summaryrefslogtreecommitdiff
path: root/scripting/workben/bindings
diff options
context:
space:
mode:
authorDuncan Foster <dfoster@openoffice.org>2003-05-16 09:14:24 +0000
committerDuncan Foster <dfoster@openoffice.org>2003-05-16 09:14:24 +0000
commit6b8d30eb75b95a293f6e13e467fe6cc6d088d972 (patch)
tree783fa0578ed4bb8fefdd26323fe15a0ea19cb26a /scripting/workben/bindings
parentb115a7d0b22c3b51b2e1750bc812ad12fe7a24f0 (diff)
#i14018# Need to be able to bind to scripts on the filesystem
Adjusted layout of assign dialogs, and added new button to get filechooser. Assorted changes to support filesys scripts Fixed bug in ScriptRUntimeForBeanshell (misplaced ';')
Diffstat (limited to 'scripting/workben/bindings')
-rw-r--r--scripting/workben/bindings/EventsBinding.xdl12
-rw-r--r--scripting/workben/bindings/KeyBinding.xdl14
-rw-r--r--scripting/workben/bindings/MenuBinding.xdl15
-rw-r--r--scripting/workben/bindings/ScriptBinding.xba142
4 files changed, 157 insertions, 26 deletions
diff --git a/scripting/workben/bindings/EventsBinding.xdl b/scripting/workben/bindings/EventsBinding.xdl
index 2d81651a7181..6402394c704b 100644
--- a/scripting/workben/bindings/EventsBinding.xdl
+++ b/scripting/workben/bindings/EventsBinding.xdl
@@ -11,7 +11,7 @@
<dlg:combobox dlg:id="LanguageCombo" dlg:tab-index="1" dlg:left="63" dlg:top="32" dlg:width="108" dlg:height="12" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:combobox>
- <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="66" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
+ <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="57" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:checkbox>
<dlg:menulist dlg:id="ScriptList" dlg:tab-index="3" dlg:left="63" dlg:top="48" dlg:width="108" dlg:height="44"/>
@@ -46,10 +46,14 @@
<dlg:text dlg:id="Label4" dlg:tab-index="14" dlg:left="5" dlg:top="97" dlg:width="71" dlg:height="8" dlg:value="Choose Event to assign to"/>
<dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="15" dlg:left="42" dlg:top="7" dlg:width="132" dlg:height="6"/>
<dlg:text dlg:id="Label1" dlg:tab-index="16" dlg:left="5" dlg:top="7" dlg:width="36" dlg:height="8" dlg:value="Select script"/>
- <dlg:text dlg:id="Label7" dlg:tab-index="17" dlg:left="12" dlg:top="19" dlg:width="28" dlg:height="10" dlg:value="Location"/>
- <dlg:text dlg:id="Label8" dlg:tab-index="18" dlg:left="12" dlg:top="32" dlg:width="35" dlg:height="8" dlg:value="Language"/>
- <dlg:text dlg:id="Label9" dlg:tab-index="19" dlg:left="12" dlg:top="51" dlg:width="23" dlg:height="13" dlg:value="Script"/>
+ <dlg:text dlg:id="Label7" dlg:tab-index="17" dlg:left="12" dlg:top="17" dlg:width="28" dlg:height="7" dlg:value="Location"/>
+ <dlg:text dlg:id="Label8" dlg:tab-index="18" dlg:left="12" dlg:top="32" dlg:width="35" dlg:height="9" dlg:value="Language"/>
+ <dlg:text dlg:id="Label9" dlg:tab-index="19" dlg:left="12" dlg:top="49" dlg:width="23" dlg:height="8" dlg:value="Script"/>
<dlg:text dlg:id="Label10" dlg:tab-index="20" dlg:left="103" dlg:top="-19" dlg:width="3" dlg:height="0" dlg:value="Label10"/>
<dlg:text dlg:style-id="0" dlg:id="AddOn" dlg:tab-index="21" dlg:disabled="true" dlg:left="17" dlg:top="144" dlg:width="38" dlg:height="10" dlg:value="[Add-on&apos;s only]"/>
+ <dlg:button dlg:id="Browse" dlg:tab-index="22" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.BrowseButton" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:text dlg:id="Label2" dlg:tab-index="23" dlg:left="13" dlg:top="86" dlg:width="45" dlg:height="8" dlg:value="[Filesystem only]"/>
</dlg:bulletinboard>
</dlg:window> \ No newline at end of file
diff --git a/scripting/workben/bindings/KeyBinding.xdl b/scripting/workben/bindings/KeyBinding.xdl
index d4581ae5889b..647d2ffca095 100644
--- a/scripting/workben/bindings/KeyBinding.xdl
+++ b/scripting/workben/bindings/KeyBinding.xdl
@@ -11,10 +11,10 @@
<dlg:combobox dlg:id="LanguageCombo" dlg:tab-index="1" dlg:left="64" dlg:top="34" dlg:width="108" dlg:height="12" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:combobox>
- <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="69" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
+ <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="57" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:checkbox>
- <dlg:menulist dlg:id="ScriptList" dlg:tab-index="3" dlg:left="64" dlg:top="48" dlg:width="108" dlg:height="44"/>
+ <dlg:menulist dlg:id="ScriptList" dlg:tab-index="3" dlg:left="63" dlg:top="49" dlg:width="108" dlg:height="44"/>
<dlg:combobox dlg:id="KeyCombo" dlg:tab-index="4" dlg:left="63" dlg:top="110" dlg:width="108" dlg:height="12" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.KeyComboListener" script:language="StarBasic"/>
</dlg:combobox>
@@ -43,10 +43,14 @@
<dlg:text dlg:id="Label6" dlg:tab-index="15" dlg:left="12" dlg:top="127" dlg:width="40" dlg:height="10" dlg:value="Shortcut Key"/>
<dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="16" dlg:left="43" dlg:top="7" dlg:width="132" dlg:height="6"/>
<dlg:text dlg:id="Label1" dlg:tab-index="17" dlg:left="5" dlg:top="7" dlg:width="36" dlg:height="8" dlg:value="Select script"/>
- <dlg:text dlg:id="Label7" dlg:tab-index="18" dlg:left="12" dlg:top="19" dlg:width="28" dlg:height="10" dlg:value="Location"/>
- <dlg:text dlg:id="Label8" dlg:tab-index="19" dlg:left="12" dlg:top="32" dlg:width="35" dlg:height="8" dlg:value="Language"/>
- <dlg:text dlg:id="Label9" dlg:tab-index="20" dlg:left="13" dlg:top="51" dlg:width="23" dlg:height="12" dlg:value="Script"/>
+ <dlg:text dlg:id="Label7" dlg:tab-index="18" dlg:left="12" dlg:top="17" dlg:width="28" dlg:height="7" dlg:value="Location"/>
+ <dlg:text dlg:id="Label8" dlg:tab-index="19" dlg:left="12" dlg:top="32" dlg:width="35" dlg:height="9" dlg:value="Language"/>
+ <dlg:text dlg:id="Label9" dlg:tab-index="20" dlg:left="12" dlg:top="49" dlg:width="23" dlg:height="8" dlg:value="Script"/>
<dlg:text dlg:id="Label10" dlg:tab-index="21" dlg:left="103" dlg:top="-9" dlg:width="3" dlg:height="0" dlg:value="Label10"/>
<dlg:text dlg:style-id="0" dlg:id="AddOn" dlg:tab-index="22" dlg:disabled="true" dlg:left="17" dlg:top="154" dlg:width="38" dlg:height="10" dlg:value="[Add-on&apos;s only]"/>
+ <dlg:button dlg:id="Browse" dlg:tab-index="23" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.BrowseButton" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:text dlg:id="Label2" dlg:tab-index="24" dlg:left="13" dlg:top="86" dlg:width="45" dlg:height="8" dlg:value="[Filesystem only]"/>
</dlg:bulletinboard>
</dlg:window> \ No newline at end of file
diff --git a/scripting/workben/bindings/MenuBinding.xdl b/scripting/workben/bindings/MenuBinding.xdl
index 8a6bb92b14f5..bca5b5ebcd92 100644
--- a/scripting/workben/bindings/MenuBinding.xdl
+++ b/scripting/workben/bindings/MenuBinding.xdl
@@ -5,13 +5,13 @@
<dlg:style dlg:style-id="0" dlg:font-height="7"/>
</dlg:styles>
<dlg:bulletinboard>
- <dlg:combobox dlg:id="LocationCombo" dlg:tab-index="0" dlg:left="63" dlg:top="16" dlg:width="108" dlg:height="13" dlg:spin="true">
+ <dlg:combobox dlg:id="LocationCombo" dlg:tab-index="0" dlg:left="63" dlg:top="17" dlg:width="108" dlg:height="13" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:combobox>
<dlg:combobox dlg:id="LanguageCombo" dlg:tab-index="1" dlg:left="63" dlg:top="32" dlg:width="108" dlg:height="13" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:combobox>
- <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="69" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
+ <dlg:checkbox dlg:id="detail" dlg:tab-index="2" dlg:left="17" dlg:top="57" dlg:width="44" dlg:height="10" dlg:value="Detailed view" dlg:checked="false">
<script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.LangLocComboListener" script:language="StarBasic"/>
</dlg:checkbox>
<dlg:menulist dlg:id="ScriptList" dlg:tab-index="3" dlg:left="63" dlg:top="49" dlg:width="108" dlg:height="44"/>
@@ -49,9 +49,14 @@
<dlg:text dlg:id="Label6" dlg:tab-index="18" dlg:left="12" dlg:top="127" dlg:width="40" dlg:height="11" dlg:value="Sub Menu"/>
<dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="19" dlg:left="42" dlg:top="6" dlg:width="132" dlg:height="7"/>
<dlg:text dlg:id="Label1" dlg:tab-index="20" dlg:left="5" dlg:top="6" dlg:width="36" dlg:height="9" dlg:value="Select script"/>
- <dlg:text dlg:id="Label7" dlg:tab-index="21" dlg:left="12" dlg:top="17" dlg:width="28" dlg:height="11" dlg:value="Location"/>
- <dlg:text dlg:id="Label8" dlg:tab-index="22" dlg:left="12" dlg:top="30" dlg:width="35" dlg:height="9" dlg:value="Language"/>
- <dlg:text dlg:id="Label9" dlg:tab-index="23" dlg:left="12" dlg:top="52" dlg:width="23" dlg:height="14" dlg:value="Script"/>
+ <dlg:text dlg:id="Label7" dlg:tab-index="21" dlg:left="12" dlg:top="17" dlg:width="28" dlg:height="7" dlg:value="Location"/>
+ <dlg:text dlg:id="Label8" dlg:tab-index="22" dlg:left="12" dlg:top="32" dlg:width="35" dlg:height="9" dlg:value="Language"/>
+ <dlg:text dlg:id="Label9" dlg:tab-index="23" dlg:left="12" dlg:top="49" dlg:width="23" dlg:height="8" dlg:value="Script"/>
<dlg:text dlg:style-id="0" dlg:id="AddOn" dlg:tab-index="24" dlg:disabled="true" dlg:left="17" dlg:top="156" dlg:width="38" dlg:height="11" dlg:value="[Add-on&apos;s only]"/>
+ <dlg:button dlg:id="Browse" dlg:tab-index="25" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.BrowseButton" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:text dlg:id="Label3" dlg:tab-index="26" dlg:left="13" dlg:top="86" dlg:width="45" dlg:height="8" dlg:value="[Filesystem only]"/>
+ <dlg:text dlg:id="Label10" dlg:tab-index="27" dlg:left="9" dlg:top="89" dlg:width="0" dlg:height="0" dlg:value="Label10"/>
</dlg:bulletinboard>
</dlg:window> \ No newline at end of file
diff --git a/scripting/workben/bindings/ScriptBinding.xba b/scripting/workben/bindings/ScriptBinding.xba
index 7db5dc0975f2..b9f264fd4b57 100644
--- a/scripting/workben/bindings/ScriptBinding.xba
+++ b/scripting/workben/bindings/ScriptBinding.xba
@@ -7,6 +7,8 @@ REM ----- Global Variables -----
&apos;bindingDialog can refer to either KeyBinding or MenuBinding dialog
private languages() as String
private locations() as String
+private filesysScripts() as String
+private filesysCount as integer
private bindingDialog as object
private helpDialog as object
&apos;Couldn&apos;t get redim to work, so scriptDisplayList is and array of arrays
@@ -247,7 +249,7 @@ end Sub
Sub initialiseNavigationComboArrays()
- locations = Array ( &quot;User&quot;, &quot;Share&quot;, &quot;Document&quot; )
+ locations = Array ( &quot;User&quot;, &quot;Share&quot;, &quot;Document&quot;, &quot;Filesystem&quot; )
ReDim languages(0) as String
languages(0) = &quot;Java&quot;
@@ -391,23 +393,48 @@ function getScriptURI( selectedScript as String ) as String
location = &quot;user&quot;
elseif ( location = &quot;Share&quot; ) then
location = &quot;share&quot;
+ elseif ( location = &quot;Filesystem&quot; ) then
+ location = &quot;filesystem&quot;
else
location = &quot;document&quot;
end if
- Dim scriptInfo as Object
- scripts() = scriptDisplayList(0)
- for n = LBOUND( scripts() ) to UBOUND( scripts() )
- if ( scripts( n ).Name = selectedScript ) then
- scriptInfo = scripts( n ).Value
- exit for
- end if
- next n
- getScriptURI() = &quot;script://&quot; + scriptInfo.getLogicalName + &quot;?language=&quot; _
- + scriptInfo.getLanguage() + &quot;&amp;amp;function=&quot; + _
- scriptInfo.getFunctionName() + &quot;&amp;amp;location=&quot; + location
+ if ( location = &quot;filesystem&quot; ) then
+ REM need to build URI here - dcf
+ combo = bindingDialog.getControl( &quot;LanguageCombo&quot; )
+ language = combo.text
+ url = selectedscript
+ while instr( url, &quot;/&quot; ) &gt; 0
+ pos = instr( url, &quot;/&quot; )
+ locationpath = locationpath + mid( url, 1, pos )
+ url = mid( url, pos+1, len( url ) - pos )
+ wend
+ functionName = url
+ while instr( url, &quot;.&quot; ) &gt; 0
+ pos = instr( url, &quot;.&quot; )
+ logicalName = logicalName + mid( url, 1, pos )
+ url = mid( url, pos + 1, len( url ) - pos )
+ wend
+ logicalName = mid( logicalName, 1, len( logicalName ) - 1 )
+ getScriptURI() = &quot;script://&quot; + logicalName + &quot;?language=&quot; _
+ + language + &quot;&amp;amp;function=&quot; + functionName _
+ + &quot;&amp;amp;location=filesystem:&quot; + locationPath
+ else
+ Dim scriptInfo as Object
+ scripts() = scriptDisplayList(0)
+ for n = LBOUND( scripts() ) to UBOUND( scripts() )
+
+ if ( scripts( n ).Name = selectedScript ) then
+ scriptInfo = scripts( n ).Value
+ exit for
+ end if
+ next n
+ getScriptURI() = &quot;script://&quot; + scriptInfo.getLogicalName + &quot;?language=&quot; _
+ + scriptInfo.getLanguage() + &quot;&amp;amp;function=&quot; + _
+ scriptInfo.getFunctionName() + &quot;&amp;amp;location=&quot; + location
+ end if
end function
@@ -1002,6 +1029,39 @@ sub PopulateScriptList( lang as String, loc as String )
elseif ( loc = &quot;Document&quot; )then
document = StarDesktop.ActiveFrame.Controller.Model
scriptLocationURI = document.getURL()
+ elseif ( loc = &quot;Filesystem&quot; ) then
+ REM populate the list from the filesysScripts list
+ length = UBOUND( filesysScripts() )
+ if(length = -1) then
+ exit sub
+ endif
+ if ( lang = &quot;BeanShell&quot; ) then
+ extn = &quot;bsh&quot;
+ elseif ( lang = &quot;Rhino&quot; ) then
+ extn = &quot;js&quot;
+ else
+ extn = &quot;&quot;
+ endif
+ dim locnDisplayList( length ) as new com.sun.star.beans.PropertyValue
+ for index = lbound(filesysScripts()) to ubound(filesysScripts())
+ scriptextn = filesysScripts(n)
+ while instr( scriptextn, &quot;.&quot; ) &gt; 0
+ pos = instr( scriptextn, &quot;.&quot; )
+ scriptextn = mid( scriptextn, pos + 1, len( scriptextn ) - pos )
+ wend
+ if ( detailedView ) and ( scriptextn = extn ) then
+ locnDisplayList( index ).Name = filesysScripts( index )
+ locnDisplayList( index ).Value = filesysScripts( index )
+ elseif ( scriptextn = extn ) then
+ REM replace name with simplified view
+ locnDisplayList( index ).Name = filesysScripts( index )
+ locnDisplayList( index ).Value = filesysScripts( index )
+ end if
+ scriptList.addItem( locnDisplayList( index ).Name, index )
+ next index
+ ScriptDisplayList(0) = locnDisplayList()
+ scriptList.selectItemPos( 0, true )
+ exit sub
endif
scriptStorageID = scriptstoragemgr.getScriptStorageID( scriptLocationURI )
if ( scriptStorageID &gt; -1 ) then
@@ -1516,6 +1576,12 @@ sub LangLocComboListener()
end if
end if
+ if ( location = &quot;Filesystem&quot; ) then
+ bindingDialog.Model.Browse.enabled = true
+ else
+ bindingDialog.Model.Browse.enabled = false
+ endif
+
&apos; extra dialog dependant processing
if dialogName = &quot;Menu&quot; then
&apos; will set New button to false if no text in LableBox
@@ -1776,6 +1842,58 @@ sub MenuNewButton()
SubMenuListListener()
end sub
+sub BrowseButton()
+ Dim oFilePicker As Object, oSimpleFileAccess As Object
+ Dim oSettings As Object, oPathSettings As Object
+ Dim sFileURL As String
+ Dim sFiles As Variant
+
+ oFilePicker = CreateUnoService( &quot;com.sun.star.ui.dialogs.FilePicker&quot; )
+ REM need a better way of seeding this
+ oFilePicker.AppendFilter( &quot;BeanShell (*.bsh)&quot;, &quot;*.bsh&quot; )
+ oFilePicker.AppendFilter( &quot;Rhino (*.js)&quot;, &quot;*.js&quot;)
+ oFilePicker.SetCurrentFilter( &quot;BeanShell (*.bsh)&quot; )
+
+ REM if no file URL is set, get path settings from configuration
+ REM perhaps get the documents URL?
+ sFileURL = &quot;&quot;
+
+ If ( sFileURL = &quot;&quot; ) Then
+ oSettings = CreateUnoService( &quot;com.sun.star.frame.Settings&quot; )
+ oPathSettings = oSettings.getByName( &quot;PathSettings&quot; )
+ sFileURL = oPathSettings.getPropertyValue( &quot;Work&quot; )
+ End If
+
+ REM set display directory
+ oSimpleFileAccess = CreateUnoService( &quot;com.sun.star.ucb.SimpleFileAccess&quot; )
+ If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then
+ oFilePicker.setDisplayDirectory( sFileURL )
+ End If
+
+ REM execute file dialog
+ If oFilePicker.execute() Then
+ sFiles = oFilePicker.getFiles()
+ sFileURL = sFiles(0)
+ If oSimpleFileAccess.exists( sFileURL ) Then
+ REM add sFileURL to the list
+ reDIm preserve filesysScripts(filesysCount) as String
+ filesysScripts( filesysCount ) = sFileURL
+ filesysCount=filesysCount+1
+ sFilter = oFilePicker.getCurrentFilter()
+ langCombo = bindingDialog.getControl( &quot;LanguageCombo&quot; )
+ dim items() as String
+ items() = langCombo.getItems()
+ for index = lbound(items()) to ubound(items())
+ iPos = inStr(sFilter,items(index))
+ if( iPos &gt; 0 ) then
+ langCombo.text = items( index )
+ exit for
+ end if
+ next index
+ End If
+ End If
+ LangLocComboListener()
+End Sub
sub KeyOKButton()
WriteXMLFromArray()