summaryrefslogtreecommitdiff
path: root/scripting/workben/bindings
diff options
context:
space:
mode:
authorDuncan Foster <dfoster@openoffice.org>2003-05-29 13:19:56 +0000
committerDuncan Foster <dfoster@openoffice.org>2003-05-29 13:19:56 +0000
commit2f9518f5d08e809d4829e4e785d585a38cb17331 (patch)
tree86e2ced10d6fd999ef38d8d30c1205273bea261a /scripting/workben/bindings
parent84a7be8e74b638d4840d061b4f5e73fb75c6dc29 (diff)
Fixed Browse button irregularities.
Fixed macro to read extension data from registry.
Diffstat (limited to 'scripting/workben/bindings')
-rw-r--r--scripting/workben/bindings/EditDebug.xdl2
-rw-r--r--scripting/workben/bindings/EventsBinding.xdl4
-rw-r--r--scripting/workben/bindings/KeyBinding.xdl4
-rw-r--r--scripting/workben/bindings/MenuBinding.xdl4
-rw-r--r--scripting/workben/bindings/ScriptBinding.xba120
5 files changed, 87 insertions, 47 deletions
diff --git a/scripting/workben/bindings/EditDebug.xdl b/scripting/workben/bindings/EditDebug.xdl
index 9c88a9493878..e975c81c302e 100644
--- a/scripting/workben/bindings/EditDebug.xdl
+++ b/scripting/workben/bindings/EditDebug.xdl
@@ -27,7 +27,7 @@
<dlg:text dlg:id="Label8" dlg:tab-index="11" dlg:left="12" dlg:top="31" dlg:width="35" dlg:height="9" dlg:value="Language"/>
<dlg:text dlg:id="Label9" dlg:tab-index="12" dlg:left="12" dlg:top="53" dlg:width="24" dlg:height="14" dlg:value="Script"/>
<dlg:fixedline dlg:id="FixedLine2" dlg:tab-index="13" dlg:left="7" dlg:top="120" dlg:width="167" dlg:height="7"/>
- <dlg:button dlg:id="Browse" dlg:tab-index="4" dlg:left="136" dlg:top="101" dlg:width="36" dlg:height="14" dlg:value="Browse...">
+ <dlg:button dlg:id="Browse" dlg:tab-index="4" dlg:disabled="true" dlg:left="136" dlg:top="101" dlg:width="36" dlg:height="14" dlg:value="Browse...">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="ScriptBindingLibrary.ScriptBinding.DoBrowseAndEdit" script:language="StarBasic"/>
</dlg:button>
</dlg:bulletinboard>
diff --git a/scripting/workben/bindings/EventsBinding.xdl b/scripting/workben/bindings/EventsBinding.xdl
index 64b51d4b1353..9047e9dad5a2 100644
--- a/scripting/workben/bindings/EventsBinding.xdl
+++ b/scripting/workben/bindings/EventsBinding.xdl
@@ -15,7 +15,7 @@
<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"/>
- <dlg:button dlg:id="Browse" dlg:tab-index="4" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <dlg:button dlg:id="Browse" dlg:tab-index="4" 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:radiogroup>
@@ -56,4 +56,4 @@
<dlg:text dlg:style-id="0" dlg:id="AddOn" dlg:tab-index="22" dlg:disabled="true" dlg:left="17" dlg:top="144" dlg:width="38" dlg:height="10" dlg:value="[Add-on&apos;s only]"/>
<dlg:text dlg:id="Label2" dlg:tab-index="23" dlg:disabled="true" 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
+</dlg:window>
diff --git a/scripting/workben/bindings/KeyBinding.xdl b/scripting/workben/bindings/KeyBinding.xdl
index 8ad3bf781b42..c0a11bc207a5 100644
--- a/scripting/workben/bindings/KeyBinding.xdl
+++ b/scripting/workben/bindings/KeyBinding.xdl
@@ -15,7 +15,7 @@
<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"/>
- <dlg:button dlg:id="Browse" dlg:tab-index="4" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <dlg:button dlg:id="Browse" dlg:tab-index="4" 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:combobox dlg:id="KeyCombo" dlg:tab-index="5" dlg:left="63" dlg:top="110" dlg:width="108" dlg:height="12" dlg:spin="true">
@@ -53,4 +53,4 @@
<dlg:text dlg:style-id="0" dlg:id="AddOn" dlg:tab-index="23" dlg:disabled="true" dlg:left="17" dlg:top="154" dlg:width="38" dlg:height="10" dlg:value="[Add-on&apos;s only]"/>
<dlg:text dlg:id="Label2" dlg:tab-index="24" dlg:disabled="true" 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
+</dlg:window>
diff --git a/scripting/workben/bindings/MenuBinding.xdl b/scripting/workben/bindings/MenuBinding.xdl
index d83edf619b91..35906546cedb 100644
--- a/scripting/workben/bindings/MenuBinding.xdl
+++ b/scripting/workben/bindings/MenuBinding.xdl
@@ -15,7 +15,7 @@
<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"/>
- <dlg:button dlg:id="Browse" dlg:tab-index="4" dlg:disabled="true" dlg:left="17" dlg:top="71" dlg:width="36" dlg:height="14" dlg:value="Browse">
+ <dlg:button dlg:id="Browse" dlg:tab-index="4" 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:combobox dlg:id="MenuCombo" dlg:tab-index="5" dlg:left="63" dlg:top="109" dlg:width="108" dlg:height="13" dlg:spin="true">
@@ -59,4 +59,4 @@
<dlg:text dlg:id="Label3" dlg:tab-index="26" dlg:disabled="true" 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
+</dlg:window>
diff --git a/scripting/workben/bindings/ScriptBinding.xba b/scripting/workben/bindings/ScriptBinding.xba
index 4cca23366bc7..14a04fc07025 100644
--- a/scripting/workben/bindings/ScriptBinding.xba
+++ b/scripting/workben/bindings/ScriptBinding.xba
@@ -6,6 +6,7 @@ REM ----- Global Variables -----
&apos;bindingDialog can refer to either KeyBinding or MenuBinding dialog
private languages() as String
+private extensions() as Object
private locations() as String
private filesysScripts() as String
private filesysCount as integer
@@ -212,12 +213,30 @@ Sub updateMapWithDisabledKeys()
End Sub
+Sub initialiseFileExtensions()
+ ReDim extensions(ubound(languages())+1) as Object
+ oConfigProvider = CreateUnoService( &quot;com.sun.star.configuration.ConfigurationProvider&quot; )
+ Dim configArgs(1) as new com.sun.star.beans.PropertyValue
+ configargs(0).Name = &quot;nodepath&quot;
+ configArgs(0).Value = &quot;org.openoffice.Office.Scripting/ScriptRuntimes&quot;
+ configargs(1).Name = &quot;lazywrite&quot;
+ configArgs(1).Value = false
+ oConfigAccess = oConfigProvider.createInstanceWithArguments(&quot;com.sun.star.configuration.ConfigurationAccess&quot;, configArgs())
+ for index = 0 to ubound(languages())
+ if(languages(index) &lt;&gt; &quot;Java&quot;) then
+ xPropSet = oConfigAccess.getByName(languages(index))
+ extns() = xPropSet.getPropertyValue(&quot;SupportedFileExtensions&quot;)
+ extensions(index) = extns()
+ endif
+ next index
+end sub
+
Sub ExecuteEditDebug()
locations = Array ( &quot;User&quot;, &quot;Share&quot;, &quot;Document&quot;, &quot;Filesystem&quot; )
languages = Array ( &quot;BeanShell&quot;, &quot;Rhino&quot; )
dialogName = &quot;EditDebug&quot;
-
+ initialiseFileExtensions()
bindingDialog = LoadDialog( &quot;ScriptBindingLibrary&quot;, &quot;EditDebug&quot; )
PopulateLanguageCombo()
@@ -251,12 +270,14 @@ end Sub
Sub initialiseNavigationComboArrays()
locations = Array ( &quot;User&quot;, &quot;Share&quot;, &quot;Document&quot;, &quot;Filesystem&quot; )
ReDim languages(0) as String
+ ReDim extensions(0) as Object
languages(0) = &quot;Java&quot;
+ REM extensions(0) = &quot;&quot;
&apos; Setup languages array for all supported languages
oServiceManager = GetProcessServiceManager()
svrArray = oServiceManager.getAvailableServiceNames
-
+
langCount = 1
for index = 0 to ubound(svrArray)
iPos = inStr(svrArray(index), &quot;ScriptRuntimeFor&quot;)
@@ -271,6 +292,7 @@ Sub initialiseNavigationComboArrays()
langCount = langCount +1
endif
next index
+ initialiseFileExtensions()
End Sub
@@ -387,6 +409,13 @@ function GetDocumentType( bindingType as string ) as string
end function
function lastIndexOf( targetStr as String, substr as String ) as Integer
+ copyStr = targetStr
+ while instr(copyStr, substr) &gt; 0
+ pos = instr(copyStr, substr)
+ tpos = tpos + pos
+ copyStr = mid(copyStr, pos+1, len(copyStr)-pos )
+ wend
+ lastIndexOf() = tpos
end function
function getScriptURI( selectedScript as String ) as String
@@ -410,6 +439,7 @@ function getScriptURI( selectedScript as String ) as String
language = combo.text
url = selectedscript
pos = lastIndexOf( url, &quot;/&quot; )
+ locationPath = mid( url, 1, pos)
url = mid( url, pos+1, len( url ) - pos )
functionName = url
pos = lastIndexOf( url, &quot;.&quot; )
@@ -1031,26 +1061,28 @@ sub PopulateScriptList( lang as String, loc as String )
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
+ for langIndex = lbound(languages()) to ubound(languages())
+ if ( lang = languages(langIndex)) then
+ extns = extensions(langIndex)
+ exit for
+ endif
+ next langIndex
dim locnDisplayList( length ) as new com.sun.star.beans.PropertyValue
for index = lbound(filesysScripts()) to ubound(filesysScripts())
scriptextn = filesysScripts(n)
pos = lastIndexOf( scriptextn, &quot;.&quot; )
scriptextn = mid( scriptextn, pos + 1, len( scriptextn ) - pos )
- 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
+ for extnsIndex = lbound(extns) to ubound(extns)
+ extn = extns(extnsIndex)
+ 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
+ next extnsIndex
scriptList.addItem( locnDisplayList( index ).Name, index )
next index
ScriptDisplayList(0) = locnDisplayList()
@@ -1572,7 +1604,7 @@ sub LangLocComboListener()
end if
end if
- if ( location = &quot;Filesystem&quot; ) then
+ if ( location = &quot;Filesystem&quot; ) and ( language &lt;&gt; &quot;Java&quot; ) then
bindingDialog.Model.Browse.enabled = true
else
bindingDialog.Model.Browse.enabled = false
@@ -1671,19 +1703,29 @@ function getFilePicker() as Object
REM file dialog
oFilePicker = CreateUnoService( &quot;com.sun.star.ui.dialogs.FilePicker&quot; )
- REM These need to be pulled from the registry in future
- bshfilter = &quot;BeanShell (*.bsh)&quot;
- rhinofilter = &quot;Rhino (*.js)&quot;
- oFilePicker.AppendFilter( bshfilter, &quot;*.bsh&quot; )
- oFilePicker.AppendFilter( rhinofilter, &quot;*.js&quot; )
-
combo = bindingDialog.getControl( &quot;LanguageCombo&quot; )
language = combo.text
-
- if language = &quot;BeanShell&quot; then
- oFilePicker.SetCurrentFilter( bshfilter )
- elseif language = &quot;Rhino&quot; then
- oFilePicker.SetCurrentFilter( rhinofilter )
+ currentFilter = &quot;&quot;
+
+ for langIndex = 0 to ubound(languages())
+ if( languages(langIndex) &lt;&gt; &quot;Java&quot; ) then
+ filterName = languages(langIndex) + &quot; (&quot;
+ filterVal=&quot;&quot;
+ extns = extensions(langIndex)
+ for extnIndex = lbound(extns()) to ubound(extns())
+ filterName = filterName + &quot;*.&quot; + extns(extnIndex) + &quot;,&quot;
+ filterVal = filterVal + &quot;*.&quot; + extns(extnIndex) + &quot;,&quot;
+ next extnIndex
+ filterName = left(filterName, len(filterName) -1) + &quot;)&quot;
+ filterVal = left(filterVal, len(filterVal) -1)
+ if(instr(filterName,language) = 1 ) then
+ currentFilter = filterName
+ end if
+ oFilePicker.AppendFilter(filterName, filterVal)
+ end if
+ next langIndex
+ if(len(currentFilter) &gt; 0 ) then
+ oFilePicker.SetCurrentFilter( currentFilter )
end if
If sFileURL = &quot;&quot; Then
@@ -1707,22 +1749,19 @@ Sub DoBrowseAndEdit()
Dim sFileURL As String
Dim sFiles As Variant
- bshfilter = &quot;BeanShell (*.bsh)&quot;
- rhinofilter = &quot;Rhino (*.js)&quot;
-
oFilePicker = getFilePicker()
REM execute file dialog
If oFilePicker.execute() Then
sFiles = oFilePicker.getFiles()
sFileURL = sFiles(0)
-
+ oSimpleFileAccess = CreateUnoService( &quot;com.sun.star.ucb.SimpleFileAccess&quot; )
If oSimpleFileAccess.exists( sFileURL ) Then
- If (oFilePicker.GetCurrentFilter = bshfilter) then
- RunDebugger(&quot;BeanShell&quot;, sFileURL, &quot;&quot;)
- ElseIf (oFilePicker.GetCurrentFilter = rhinofilter) then
- RunDebugger(&quot;Rhino&quot;, sFileURL, &quot;&quot;)
- End If
+ for langIndex = 0 to ubound(languages())
+ If (instr(oFilePicker.GetCurrentFilter, languages(langIndex)) = 1 ) then
+ RunDebugger(languages(langIndex), sFileURL, &quot;&quot;)
+ End If
+ next langIndex
End If
bindingDialog.endExecute()
End If
@@ -1850,9 +1889,10 @@ sub BrowseButton()
If oFilePicker.execute() Then
sFiles = oFilePicker.getFiles()
sFileURL = sFiles(0)
+ oSimpleFileAccess = CreateUnoService( &quot;com.sun.star.ucb.SimpleFileAccess&quot; )
If oSimpleFileAccess.exists( sFileURL ) Then
REM add sFileURL to the list
- reDIm preserve filesysScripts(filesysCount) as String
+ ReDim preserve filesysScripts(filesysCount) as String
filesysScripts( filesysCount ) = sFileURL
filesysCount=filesysCount+1
sFilter = oFilePicker.getCurrentFilter()
@@ -1992,4 +2032,4 @@ end sub
sub HelpOKButton()
helpDialog.endExecute()
end sub
-</script:module>
+</script:module> \ No newline at end of file