diff options
author | Duncan Foster <dfoster@openoffice.org> | 2003-05-29 13:19:56 +0000 |
---|---|---|
committer | Duncan Foster <dfoster@openoffice.org> | 2003-05-29 13:19:56 +0000 |
commit | 2f9518f5d08e809d4829e4e785d585a38cb17331 (patch) | |
tree | 86e2ced10d6fd999ef38d8d30c1205273bea261a /scripting | |
parent | 84a7be8e74b638d4840d061b4f5e73fb75c6dc29 (diff) |
Fixed Browse button irregularities.
Fixed macro to read extension data from registry.
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/workben/bindings/EditDebug.xdl | 2 | ||||
-rw-r--r-- | scripting/workben/bindings/EventsBinding.xdl | 4 | ||||
-rw-r--r-- | scripting/workben/bindings/KeyBinding.xdl | 4 | ||||
-rw-r--r-- | scripting/workben/bindings/MenuBinding.xdl | 4 | ||||
-rw-r--r-- | scripting/workben/bindings/ScriptBinding.xba | 120 |
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'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'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 ----- '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( "com.sun.star.configuration.ConfigurationProvider" ) + Dim configArgs(1) as new com.sun.star.beans.PropertyValue + configargs(0).Name = "nodepath" + configArgs(0).Value = "org.openoffice.Office.Scripting/ScriptRuntimes" + configargs(1).Name = "lazywrite" + configArgs(1).Value = false + oConfigAccess = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", configArgs()) + for index = 0 to ubound(languages()) + if(languages(index) <> "Java") then + xPropSet = oConfigAccess.getByName(languages(index)) + extns() = xPropSet.getPropertyValue("SupportedFileExtensions") + extensions(index) = extns() + endif + next index +end sub + Sub ExecuteEditDebug() locations = Array ( "User", "Share", "Document", "Filesystem" ) languages = Array ( "BeanShell", "Rhino" ) dialogName = "EditDebug" - + initialiseFileExtensions() bindingDialog = LoadDialog( "ScriptBindingLibrary", "EditDebug" ) PopulateLanguageCombo() @@ -251,12 +270,14 @@ end Sub Sub initialiseNavigationComboArrays() locations = Array ( "User", "Share", "Document", "Filesystem" ) ReDim languages(0) as String + ReDim extensions(0) as Object languages(0) = "Java" + REM extensions(0) = "" ' Setup languages array for all supported languages oServiceManager = GetProcessServiceManager() svrArray = oServiceManager.getAvailableServiceNames - + langCount = 1 for index = 0 to ubound(svrArray) iPos = inStr(svrArray(index), "ScriptRuntimeFor") @@ -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) > 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, "/" ) + locationPath = mid( url, 1, pos) url = mid( url, pos+1, len( url ) - pos ) functionName = url pos = lastIndexOf( url, "." ) @@ -1031,26 +1061,28 @@ sub PopulateScriptList( lang as String, loc as String ) if(length = -1) then exit sub endif - if ( lang = "BeanShell" ) then - extn = "bsh" - elseif ( lang = "Rhino" ) then - extn = "js" - else - extn = "" - 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, "." ) 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 = "Filesystem" ) then + if ( location = "Filesystem" ) and ( language <> "Java" ) 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( "com.sun.star.ui.dialogs.FilePicker" ) - REM These need to be pulled from the registry in future - bshfilter = "BeanShell (*.bsh)" - rhinofilter = "Rhino (*.js)" - oFilePicker.AppendFilter( bshfilter, "*.bsh" ) - oFilePicker.AppendFilter( rhinofilter, "*.js" ) - combo = bindingDialog.getControl( "LanguageCombo" ) language = combo.text - - if language = "BeanShell" then - oFilePicker.SetCurrentFilter( bshfilter ) - elseif language = "Rhino" then - oFilePicker.SetCurrentFilter( rhinofilter ) + currentFilter = "" + + for langIndex = 0 to ubound(languages()) + if( languages(langIndex) <> "Java" ) then + filterName = languages(langIndex) + " (" + filterVal="" + extns = extensions(langIndex) + for extnIndex = lbound(extns()) to ubound(extns()) + filterName = filterName + "*." + extns(extnIndex) + "," + filterVal = filterVal + "*." + extns(extnIndex) + "," + next extnIndex + filterName = left(filterName, len(filterName) -1) + ")" + 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) > 0 ) then + oFilePicker.SetCurrentFilter( currentFilter ) end if If sFileURL = "" Then @@ -1707,22 +1749,19 @@ Sub DoBrowseAndEdit() Dim sFileURL As String Dim sFiles As Variant - bshfilter = "BeanShell (*.bsh)" - rhinofilter = "Rhino (*.js)" - oFilePicker = getFilePicker() REM execute file dialog If oFilePicker.execute() Then sFiles = oFilePicker.getFiles() sFileURL = sFiles(0) - + oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) If oSimpleFileAccess.exists( sFileURL ) Then - If (oFilePicker.GetCurrentFilter = bshfilter) then - RunDebugger("BeanShell", sFileURL, "") - ElseIf (oFilePicker.GetCurrentFilter = rhinofilter) then - RunDebugger("Rhino", sFileURL, "") - End If + for langIndex = 0 to ubound(languages()) + If (instr(oFilePicker.GetCurrentFilter, languages(langIndex)) = 1 ) then + RunDebugger(languages(langIndex), sFileURL, "") + 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( "com.sun.star.ucb.SimpleFileAccess" ) 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 |