1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"ScriptBinding" script:
language=
"StarBasic">REM ***** BASIC *****
22 REM ----- Global Variables -----
24 'bindingDialog can refer to either KeyBinding or MenuBinding dialog
25 private languages() as String
26 private extensions() as Object
27 private locations() as String
28 private filesysScripts() as String
29 private filesysCount as integer
30 private bindingDialog as object
31 private helpDialog as object
32 'Couldn
't get redim to work, so scriptDisplayList is and array of arrays
33 'where the one and only array in scriptDisplayList is an array
34 'of com.sun.star.beans.PropertyValue, where Name = [logicalName][FunctionName]
35 'and value is ScriptStorage object
36 private scriptDisplayList(
0)
37 private testArray() as String
38 'Array to store lines from the xml file
39 private xmlFile() as string
40 'Name of the xml file [writer/calc][menubar/keybindings].xml
41 private xmlFileName as string
42 'Number of lines in the xml file
43 private numberOfLines as integer
45 'Parallel arrays to store all top-level menu names and line positions
46 private menuItems() as string
47 private menuItemLinePosition() as integer
48 'Counter for the number of top-level menus
49 private menuCount as integer
51 'Parallel arrays to store all sub-menu names and line positions for a particular top-level menu
52 private subMenuItems() as string
53 private subMenuItemLinePosition() as integer
54 'Counter for the number of sub-menus
55 private subMenuCount as integer
57 'Parallel arrays to store all script names and line positions
58 private scriptNames() as string
59 private scriptLinePosition() as integer
60 'Counter for the number of scripts
61 private scriptCount as integer
63 'Array to store all combinations of key bindings
64 private allKeyBindings() as string
67 'KeyBindArrayOfArrays(
0) contains array of
"SHIFT + CONTROL + F Keys
" data
69 'KeyBindArrayOfArrays(
1) contains SHIFT + CONTROL + digits
70 'KeyBindArrayOfArrays(
2) contains SHIFT + CONTROL + letters
71 'KeyBindArrayOfArrays(
3) contains CONTROL + F keys
72 'KeyBindArrayOfArrays(
4) contains CONTROL + digits
73 'KeyBindArrayOfArrays(
5) contains CONTROL + letters
74 'KeyBindArrayOfArrays(
6) contains SHIFT + F keys
75 private KeyBindArrayOfArrays(
6)
77 'Each PropertyValue represents a key, Name member contains the script (if a binding exists)
78 ' the Value contains and integer
79 ' 0 means no script bound
80 ' 1 script is bound to an office function
81 ' >1 line number of entry in xmlfile array
82 private keyAllocationMap(
6,
25) as new com.sun.star.beans.PropertyValue
83 'array to store key group descriptions
84 private AllKeyGroupsArray(
6) as String
87 'Array of props to store all event bindings for the Applications
88 private allEventTypesApp(
14 ) as new com.sun.star.beans.PropertyValue
89 'Array of props to store all event bindings for the Document
90 private allEventTypesDoc(
14 ) as new com.sun.star.beans.PropertyValue
91 'Array of props to store all event types (Name) and textual description (Value)
92 private allEventTypes(
14 ) as new com.sun.star.beans.PropertyValue
95 private dialogName as String
96 REM ------ Storage Refresh Function ------
99 sub RefreshUserScripts()
100 ' TDB - change Menu bindings to allow user to refresh all, user, share or document script
101 RefreshAppScripts(
"USER
" )
104 sub RefreshAllScripts()
105 RefreshAppScripts(
"USER
" )
106 RefreshAppScripts(
"SHARE
" )
107 RefreshDocumentScripts
110 sub RefreshAppScripts( appName as String )
111 On Error Goto ErrorHandler
112 smgr = getProcessServiceManager()
113 context = smgr.getPropertyValue(
"DefaultContext
" )
114 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
116 scriptstoragemgr.refreshScriptStorage( appName )
122 MsgBox (
"Error: Unable to refresh Java (scripts)
" + chr$(
10) + chr$(
10)+
"Detail:
" & error$ + chr$(
10) + chr$(
10)+
"Action: Please restart Office
",
0,
"Error
" )
126 sub RefreshDocumentScripts()
127 On Error Goto ErrorHandler
128 smgr = getProcessServiceManager()
129 context = smgr.getPropertyValue(
"DefaultContext
" )
130 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
132 oDocURL = ThisComponent.GetCurrentController.getModel.getURL
134 On Error Goto ErrorHandlerDoc
135 scriptstoragemgr.refreshScriptStorage( oDocURL )
141 ' Ignore document script errors as it will happen when refreshing an unsaved doc
146 MsgBox (
"Error: Unable to refresh Java (scripts)
" + chr$(
10) + chr$(
10)+
"Detail:
" & error$ + chr$(
10) + chr$(
10)+
"Action: Please restart Office
",
0,
"Error
" )
151 REM ----- Launch Functions -----
153 Sub createAndPopulateKeyArrays()
154 'Create SHIFT + CONTROL + F keys array
155 'Dim keyGroupProp as new com.sun.star.beans.PropertyValue
159 SCFKey( FKey -
1 ) =
"SHIFT + CONTROL + F
" + FKey
162 KeyBindArrayOfArrays(
0) = SCFKey()
164 'Create SHIFT + CONTROL + digits
167 SCDKey( Digit ) =
"SHIFT + CONTROL +
" + Digit
169 KeyBindArrayOfArrays(
1) = SCDKey()
171 'Create SHIFT + CONTROL + letters
175 SCLKey( Alpha -
65 ) =
"SHIFT + CONTROL +
" + chr$( Alpha )
177 KeyBindArrayOfArrays(
2) = SCLKey()
179 'Create CONTROL + F keys
182 CFKey( Fkey -
1 ) =
"CONTROL + F
" + FKey
184 KeyBindArrayOfArrays(
3) = CFKey()
186 'Create CONTROL + digits
189 CDKey( Digit ) =
"CONTROL +
" + Digit
191 KeyBindArrayOfArrays(
4) = CDKey()
193 'Create CONTROL + letters
196 CLKey( Alpha -
65 ) =
"CONTROL +
" + chr$( Alpha )
198 KeyBindArrayOfArrays(
5) = CLKey()
200 'Create SHIFT + F Keys
203 SFKey( Fkey -
1 ) =
"SHIFT + F
" + FKey
205 KeyBindArrayOfArrays(
6) = SFKey()
209 Sub updateMapWithDisabledKeys()
210 'disable CONTROL + F1
&
211 keyAllocationMap(
3,
0 ).Value =
1
212 keyAllocationMap(
3,
0 ).Name =
""
213 'disable CONTROL + F4
&
214 keyAllocationMap(
3,
3 ).Value =
1
215 keyAllocationMap(
3,
3 ).Name =
""
216 'disable CONTROL + F6
217 keyAllocationMap(
3,
5 ).Value =
1
218 keyAllocationMap(
3,
5 ).Name =
""
221 'disable SHIFT + F1
&
222 keyAllocationMap(
6,
0 ).Value =
1
223 keyAllocationMap(
6,
0 ).Name =
""
224 'disable SHIFT + F2
&
225 keyAllocationMap(
6,
1 ).Value =
1
226 keyAllocationMap(
6,
1 ).Name =
""
227 'disable SHIFT + F6
&
228 keyAllocationMap(
6,
5 ).Value =
1
229 keyAllocationMap(
6,
5 ).Name =
""
233 Sub initialiseFileExtensions()
234 ReDim extensions(ubound(languages())+
1) as Object
235 oConfigProvider = CreateUnoService(
"com.sun.star.configuration.ConfigurationProvider
" )
236 Dim configArgs(
1) as new com.sun.star.beans.PropertyValue
237 configargs(
0).Name =
"nodepath
"
238 configArgs(
0).Value =
"org.openoffice.Office.Scripting/ScriptRuntimes
"
239 configargs(
1).Name =
"lazywrite
"
240 configArgs(
1).Value = false
241 oConfigAccess = oConfigProvider.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess
", configArgs())
242 for index =
0 to ubound(languages())
243 if(languages(index)
<> "Java
") then
244 xPropSet = oConfigAccess.getByName(languages(index))
245 extns() = xPropSet.getPropertyValue(
"SupportedFileExtensions
")
246 extensions(index) = extns()
251 Sub ExecuteEditDebug()
253 locations = Array (
"User
",
"Share
",
"Document
",
"Filesystem
" )
254 languages = Array (
"BeanShell
",
"JavaScript
" )
255 dialogName =
"EditDebug
"
256 initialiseFileExtensions()
257 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"EditDebug
" )
259 PopulateLanguageCombo()
260 PopulateLocationCombo()
261 PopulateScriptList( languages(
0), locations(
0) )
263 bindingDialog.execute()
266 Sub ExecuteKeyBinding()
267 dialogName =
"Key
"
268 createAndPopulateKeyArrays()
269 updateMapWithDisabledKeys()
270 xmlFileName = GetDocumentType(
"Key
" )
272 if not (ReadXMLToArray(
"Key
" )) then
276 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"KeyBinding
" )
277 PopulateKeyBindingList(
0)
278 initialiseNavigationComboArrays()
279 PopulateLanguageCombo()
280 PopulateLocationCombo()
281 PopulateScriptList( languages(
0), locations(
0) )
282 PopulateTopLevelKeyBindingList()
283 bindingDialog.execute()
287 Sub initialiseNavigationComboArrays()
288 locations = Array (
"User
",
"Share
",
"Document
",
"Filesystem
" )
289 ReDim languages(
0) as String
290 ReDim extensions(
0) as Object
291 languages(
0) =
"Java
"
292 REM extensions(
0) =
""
294 ' Setup languages array for all supported languages
295 oServiceManager = GetProcessServiceManager()
296 svrArray = oServiceManager.getAvailableServiceNames
299 for index =
0 to ubound(svrArray)
300 iPos = inStr(svrArray(index),
"ScriptProviderFor
")
302 if (iPos
> 0) then
303 lang = Mid(svrArray(index), iPos + Len(
"ScriptProviderFor
")
305 if not (lang =
"Java
") then
306 'Add to language vector
307 ReDim Preserve languages(langCount) as String
308 languages(langCount) = lang
309 langCount = langCount +
1
313 initialiseFileExtensions()
317 Sub ExecuteEventBinding
318 dialogName =
"Event
"
319 createAllEventTypes()
320 createAllEventBindings()
322 'Populate application event bindings array (from config xml file)
323 if not (ReadXMLToArray(
"Event
" )) then
326 'Populate document event bindings array (using Office API calls)
329 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"EventsBinding
" )
330 initialiseNavigationComboArrays()
331 PopulateLanguageCombo()
332 PopulateLocationCombo()
333 PopulateScriptList( languages(
0), locations(
0) )
334 populateEventList(
0 )
336 bindingDialog.execute()
339 Sub ExecuteMenuBinding()
340 dialogName =
"Menu
"
341 xmlFileName = GetDocumentType(
"Menu
" )
342 if not (ReadXMLToArray(
"Menu
" )) then
346 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"MenuBinding
" )
347 initialiseNavigationComboArrays()
348 PopulateLanguageCombo()
349 PopulateLocationCombo()
350 PopulateScriptList( languages(
0), locations(
0) )
352 PopulateSubMenuList(
1 )
354 subMenuList = bindingDialog.getControl(
"SubMenuList
")
356 subMenuList.selectItemPos(
0, true )
358 bindingDialog.execute()
362 REM ----- Initialising functions -----
365 function LoadDialog( libName as string, dialogName as string ) as object
366 dim library as object
367 dim libDialog as object
368 dim runtimeDialog as object
369 libContainer = DialogLibraries
370 libContainer.LoadLibrary( libName )
371 library = libContainer.getByName( libname )
372 libDialog = library.getByName( dialogName )
373 runtimeDialog = CreateUnoDialog( libDialog )
374 LoadDialog() = runtimeDialog
379 function GetDocumentType( bindingType as string ) as string
380 document = StarDesktop.ActiveFrame.Controller.Model
381 Dim errornumber As Integer
384 if document.SupportsService(
"com.sun.star.sheet.SpreadsheetDocument
") then
385 if bindingType =
"Key
" then
386 GetDocumentType() =
"calckeybinding.xml
"
388 if bindingType =
"Menu
" then
389 GetDocumentType() =
"calcmenubar.xml
"
392 elseif document.SupportsService(
"com.sun.star.text.TextDocument
") then
393 if bindingType =
"Key
" then
394 GetDocumentType() =
"writerkeybinding.xml
"
396 if bindingType =
"Menu
" then
397 GetDocumentType() =
"writermenubar.xml
"
400 elseif document.SupportsService(
"com.sun.star.presentation.PresentationDocument
") then
401 if bindingType =
"Key
" then
402 GetDocumentType() =
"impresskeybinding.xml
"
404 if bindingType =
"Menu
" then
405 GetDocumentType() =
"impressmenubar.xml
"
408 elseif document.SupportsService(
"com.sun.star.presentation.PresentationDocument
") then
409 if bindingType =
"Key
" then
410 GetDocumentType() =
"impresskeybinding.xml
"
412 if bindingType =
"Menu
" then
413 GetDocumentType() =
"impressmenubar.xml
"
416 elseif document.SupportsService(
"com.sun.star.drawing.DrawingDocument
") then
417 if bindingType =
"Key
" then
418 GetDocumentType() =
"drawkeybinding.xml
"
420 if bindingType =
"Menu
" then
421 GetDocumentType() =
"drawmenubar.xml
"
425 MsgBox (
"Error: Couldn
't determine configuration file type
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
429 function lastIndexOf( targetStr as String, substr as String ) as Integer
431 while instr(copyStr, substr)
> 0
432 pos = instr(copyStr, substr)
434 copyStr = mid(copyStr, pos+
1, len(copyStr)-pos )
439 function getScriptURI( selectedScript as String ) as String
440 combo = bindingDialog.getControl(
"LocationCombo
" )
441 location = combo.text
442 if ( location =
"User
" ) then
443 location =
"user
"
444 elseif ( location =
"Share
" ) then
445 location =
"share
"
446 elseif ( location =
"Filesystem
" ) then
447 location =
"filesystem
"
449 location =
"document
"
454 if ( location =
"filesystem
" ) then
455 REM need to build URI here - dcf
456 combo = bindingDialog.getControl(
"LanguageCombo
" )
457 language = combo.text
459 pos = lastIndexOf( url,
"/
" )
460 locationPath = mid( url,
1, pos)
461 url = mid( url, pos+
1, len( url ) - pos )
463 pos = lastIndexOf( url,
".
" )
464 logicalName = mid( url,
1, pos -
1 )
465 getScriptURI() =
"script://
" + logicalName +
"?language=
" _
466 + language +
"&amp;function=
" + functionName _
467 +
"&amp;location=filesystem:
" + locationPath
469 Dim scriptInfo as Object
470 scripts() = scriptDisplayList(
0)
471 for n = LBOUND( scripts() ) to UBOUND( scripts() )
473 if ( scripts( n ).Name = selectedScript ) then
474 scriptInfo = scripts( n ).Value
478 getScriptURI() =
"script://
" + scriptInfo.getLogicalName +
"?language=
" _
479 + scriptInfo.getLanguage() +
"&amp;function=
" + _
480 scriptInfo.getFunctionName() +
"&amp;location=
" + location
485 function GetOfficePath() as string
486 REM Error check and prompt user to manually input Office Path
487 settings = CreateUnoService(
"com.sun.star.frame.Settings
" )
488 path = settings.getByName(
"PathSettings
" )
489 unformattedOfficePath = path.getPropertyValue(
"UserPath
" )
491 dim officePath as string
492 const removeFromEnd =
"/user
"
493 const removeFromEndWindows =
"\user
"
495 REM If Solaris or Linux
496 if not ( instr( unformattedOfficePath, removeFromEnd ) =
0 ) then
497 endPosition = instr( unformattedOfficePath, removeFromEnd )
498 officePath = mid( unformattedOfficePath,
1, endPosition )
500 else if not ( instr( unformattedOfficePath, removeFromEndWindows ) =
0 ) then
501 endPosition = instr( unformattedOfficePath, removeFromEndWindows )
502 officePath = mid( unformattedOfficePath,
1, endPosition )
503 while instr( officePath,
"\
" )
> 0
504 backSlash = instr( officePath,
"\
" )
505 startPath = mid( officePath,
1, backSlash -
1 )
506 endPath = mid( officePath, backslash +
1, len( officePath ) - backSlash )
507 officePath = startPath +
"/
" + endPath
510 MsgBox (
"Error: Office path not found
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
515 GetOfficePath() = officePath
520 REM ----- File I/O functions -----
523 function ReadXMLToArray( bindingType as string ) as boolean
524 On Error Goto ErrorHandler
525 if ( bindingType =
"Event
" ) then
526 xmlfilename =
"eventbindings.xml
"
529 simplefileaccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
530 filestream = simplefileaccess.openFileRead(
"file://
" + GetOfficePath() +
"user/config/soffice.cfg/
" + xmlFileName )
532 textin = CreateUnoService(
"com.sun.star.io.TextInputStream
" )
533 textin.setInputStream( filestream )
535 redim xmlFile(
400 ) as String
536 redim menuItems(
30 ) as String
537 redim menuItemLinePosition(
30 ) as Integer
538 redim scriptNames(
120 ) as string
539 redim scriptLinePosition(
120) as integer
545 do while not textin.isEOF()
546 xmlline = textin.readLine()
547 xmlFile( lineCount ) = xmlline
549 const menuItemWhiteSpace =
2
550 const menuXMLTag =
"<menu:menu
"
552 if bindingType =
"Menu
" then
553 evaluateForMenu( xmlline, lineCount )
554 elseif bindingType =
"Key
" then
555 processKeyXMLLine( lineCount, xmlline )
556 elseif bindingType =
"Event
" then
557 evaluateForEvent( xmlline, lineCount )
559 MsgBox (
"Error: Couldn
't determine file type
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
561 lineCount = lineCount +
1
564 'Set global variable numberOfLines (lineCount is one too many at end of the loop)
565 numberOfLines = lineCount -
1
566 'Set global variable menuCount (it is one too many at end of the loop)
567 menuCount = menuCount -
1
569 filestream.closeInput()
570 ReadXMLToArray( ) = true
575 MsgBox (
"Error: Unable to read Star Office configuration file -
" + xmlFileName + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
576 ReadXMLToArray( ) = false
581 sub evaluateForMenu( xmlline as string, lineCount as integer )
582 const menuItemWhiteSpace =
2
583 const menuXMLTag =
"<menu:menu
"
584 'If the xml line is a top-level menu
585 if instr( xmlline, menuXMLTag ) = menuItemWhiteSpace then
586 menuLabel = ExtractLabelFromXMLLine( xmlline )
587 menuItems( menuCount ) = menuLabel
588 menuItemLinePosition( menuCount ) = lineCount
589 menuCount = menuCount +
1
593 sub evaluateForEvent( xmlline as string, lineCount as integer )
594 dim eventName as String
595 'if the xml line identifies a script or SB macro
596 dim scriptName as string
597 dim lineNumber as integer
598 if instr( xmlline,
"event:language=
" + chr$(
34) +
"Script
" )
> 0 then
599 eventName = ExtractEventNameFromXMLLine( xmlline )
600 scriptName = ExtractEventScriptFromXMLLine( xmlline )
601 lineNumber = lineCount
602 elseif instr( xmlline,
"event:language=
" + chr$(
34) +
"StarBasic
" )
> 0 then
603 eventName = ExtractEventNameFromXMLLine( xmlline )
604 scriptName =
"Allocated to Office function
"
608 'Need to sequence to find the corresponding index for the event type
609 for n =
0 to ubound( allEventTypesApp() )
610 if ( eventName = allEventTypes( n ).Name ) then
611 allEventTypesApp( n ).Name = scriptName
612 allEventTypesApp( n ).Value = lineNumber
618 function isOKscriptProps( props() as Object, eventName as string ) as Boolean
619 On Error Goto ErrorHandler
620 props = ThisComponent.getEvents().getByName( eventName )
621 test = ubound( props() )
622 isOKscriptProps() = true
626 isOKscriptProps() = false
629 sub ReadEventsFromDoc()
630 On Error Goto ErrorHandler
632 eventSupplier = ThisComponent
633 for n =
0 to ubound( allEventTypes() )
634 Dim scriptProps() as Object
635 if (isOKscriptProps( scriptProps(), allEventTypes( n ).Name) ) then
636 if ( ubound( scriptProps )
> 0 ) then
637 if ( scriptProps(
0).Value =
"Script
" ) then
639 allEventTypesDoc(n).Name = scriptProps(
1).Value
640 allEventTypesDoc(n).value =
2
641 elseif( scriptProps(
0).Value =
"StarBasic
" ) then
642 'StarBasic macro
643 allEventTypesDoc(n).Name =
"Allocated to Office function
"
644 allEventTypesDoc(n).value =
1
652 ' eventProps is undefined if there are no event bindings in the doc
658 sub WriteEventsToDoc()
659 On Error Goto ErrorHandler
661 eventSupplier = ThisComponent
662 for n =
0 to ubound( allEventTypes() )
663 scriptName = allEventTypesDoc( n ).Name
664 eventName = allEventTypes( n ).Name
665 if( allEventTypesDoc( n ).Value
> 1 ) then
'script
667 AddEventToDocViaAPI( scriptName, eventName )
668 elseif( allEventTypesDoc( n ).Value =
0 ) then
'blank (this will
"remove
" already blank entries)
669 'remove from doc
670 RemoveEventFromDocViaAPI( eventName )
672 'Otherwise it is a StarBasic binding - leave alone
674 'Mark document as modified ( should happen automatically as a result of calling the API )
675 ThisComponent.CurrentController.getModel().setModified( True )
680 msgbox(
"Error calling UNO API for writing event bindings to the document
" )
684 sub RemoveEventFromDocViaAPI( event as string )
685 dim document as object
686 dim dispatcher as object
688 dim url as new com.sun.star.util.URL
690 document = ThisComponent.CurrentController.Frame
691 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
692 dim args(
0) as new com.sun.star.beans.PropertyValue
693 args(
0).Name =
""
694 args(
0).Value = event
696 url.Complete =
"script://_$ScriptFrmwrkHelper.removeEvent?
" _
697 +
"language=Java
&function=ScriptFrmwrkHelper.removeEvent
" _
698 +
"&location=share
"
700 parser.parseStrict(url)
701 disp = document.queryDispatch(url,
"",
0)
702 disp.dispatch(url,args())
706 sub AddEventToDocViaAPI( scriptName as string, eventName as string )
707 dim properties(
1 ) as new com.sun.star.beans.PropertyValue
708 properties(
0 ).Name =
"EventType
"
709 properties(
0 ).Value =
"Script
"
710 properties(
1 ).Name =
"Script
"
711 properties(
1 ).Value = scriptName
713 eventSupplier = ThisComponent
714 nameReplace = eventSupplier.getEvents()
715 nameReplace.replaceByName( eventName, properties() )
719 ' returns
0 for Fkey
723 function getKeyTypeOffset( key as String ) as integer
725 if ( length
> 1 ) then
726 getKeyTypeOffset() =
0
728 elseif ( key
>=
"0" AND key
<=
"9" ) then
729 getKeyTypeOffset() =
1
731 getKeyTypeOffset() =
2
735 function getKeyGroupIndex( key as String, offset as Integer ) as Integer
736 ' Keys we are interested in are A - Z, F2 - F12,
0 -
9 anything else should
737 ' ensure -
1 is returned
738 cutKey = mid( key,
2 )
740 if ( cutKey
<> "" ) then
741 acode = asc ( mid( cutKey,
1,
1) )
742 if ( acode
> 57 ) then
743 getKeyGroupIndex() = -
1
751 getKeyGroupIndex() = num -
1
754 num = asc( key ) -
48
755 getKeyGroupIndex() = num
758 num = asc( key ) -
65
759 getKeyGroupIndex() = num
762 getKeyGroupIndex() = -
1
765 Sub processKeyXMLLine( lineCount as Integer, xmlline as String )
767 if instr( xmlline,
"<accel:item
" )
> 0 then
770 if instr( xmlline,
"accel:shift=
"+chr$(
34)+
"true
"+chr$(
34) )
> 0 then
773 if instr( xmlFile( lineCount ),
"accel:mod1=
"+chr$(
34)+
"true
"+chr$(
34) )
> 0 then
776 offsetIntoArrayOfArrays = -
1 'default unknown
777 if ( control AND shift ) then
778 offsetIntoArrayOfArrays =
0
779 elseif ( control ) then
780 offsetIntoArrayOfArrays =
3
781 elseif ( shift ) then
782 offsetIntoArrayOfArrays =
6
784 ' Calculate which of the
7 key group arrays we need to point to
785 key = ExtractKeyCodeFromXMLLine( xmlline )
786 keyTypeOffset = getKeyTypeOffset( key )
787 offsetIntoArrayOfArrays = offsetIntoArrayOfArrays + keyTypeOffset
789 ' Calculate from the key the offset into key group array we need to point to
790 KeyGroupIndex = getKeyGroupIndex( key, keyTypeOffset )
791 if ( offsetIntoArrayOfArrays = -
1 ) then
792 'Unknown key group, no processing necessary
795 if ( KeyGroupIndex
> -
1 ) then
797 ' Determine if a script framework binding is present or not
798 if instr( xmlline,
"script://
" )
> 0 then
799 ' its one of ours so update its details
800 scriptName = ExtractScriptIdFromXMLLine( xmlline )
802 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value = lineCount
803 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
805 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value =
1
806 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name =
""
813 Sub WriteXMLFromArray()
814 On Error Goto ErrorHandler
815 cfgFile = GetOfficePath() +
"user/config/soffice.cfg/
" + xmlFileName
816 updateCfgFile( cfgFile )
817 'if ( false ) then
' config stuff not in build yet
819 updateConfig( xmlFileName )
821 msgbox (
"Office must be restarted before your changes will take effect.
"+ chr$(
10)+
"Also close the Office QuickStarter (Windows and Linux)
",
48,
"Assign Script (Java) To Menu
" )
827 MsgBox (
"Error: Unable to write to Star Office configuration file
" + chr$(
10) +
"/
" + GetOfficePath() +
"user/config/soffice.cfg/
" +xmlFileName + chr$(
10) + chr$(
10) +
"Action: Please make sure you have write access to this file
",
0,
"Error
" )
831 Sub UpdateCfgFile ( fileName as String )
832 dim ScriptProvider as Object
835 dim displayDialogFlag as boolean
836 displayDialogFlag = false
837 args(
0) = ThisComponent
838 args(
1) = displayDialogFlag
840 ScriptProvider = createUnoService(
"drafts.com.sun.star.script.framework.provider.MasterScriptProvider
")
841 ScriptProvider.initialize( args() )
842 Script = ScriptProvider.getScript(
"script://_$ScriptFrmwrkHelper.updateCfgFile?
" _
843 +
"language=Java
&function=ScriptFrmwrkHelper.updateCfgFile
&location=share
")
847 dim localNumLines as integer
849 inArgs(
0) = xmlFile()
851 inArgs(
2) = numberOfLines
852 Script.invoke( inArgs(), outIndex(), outArgs() )
855 sub UpdateConfig( a$ )
856 dim document as object
857 dim dispatcher as object
860 dim url as new com.sun.star.util.URL
861 document = ThisComponent.CurrentController.Frame
862 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
863 dim args1(
0) as new com.sun.star.beans.PropertyValue
864 args1(
0).Name =
"StreamName
"
866 url.Complete =
".uno:UpdateConfiguration
"
867 parser.parseStrict(url)
868 disp = document.queryDispatch(url,
"",
0)
869 disp.dispatch(url,args1())
874 sub AddNewEventBinding( scriptName as string, eventPosition as integer, isApp as boolean )
875 event = allEventTypes( eventPosition ).Name
876 'dim scriptProp as new com.sun.star.beans.PropertyValue
878 'scriptProp.Name = scriptName
879 'scriptProp.Value = numberOfLines
880 allEventTypesApp( eventPosition ).Name = scriptName
881 allEventTypesApp( eventPosition ).Value = numberOfLines
883 newline =
" <event:event event:name=
" + chr$(
34) + event + chr$(
34)
884 newline = newline +
" event:language=
" + chr$(
34) +
"Script
" + chr$(
34) +
" xlink:href=
" + chr$(
34)
885 newline = newline + scriptName + chr$(
34) +
" xlink:type=
" + chr$(
34) +
"simple
" + chr$(
34) +
"/
>"
886 xmlFile( numberOfLines ) = newline
887 xmlFile( numberOfLines +
1 ) =
"</event:events
>"
888 numberOfLines = numberOfLines +
1
890 'scriptProp.Name = scriptName
891 'scriptProp.Value =
2
892 allEventTypesDoc( eventPosition ).Name = scriptName
893 allEventTypesDoc( eventPosition ).Value =
2
897 REM ----- Array update functions -----
900 sub AddNewMenuBinding( newScript as string, newMenuLabel as string, newLinePosition as integer )
901 dim newXmlFile(
400 ) as string
902 dim newLineInserted as boolean
903 dim lineCounter as integer
906 do while lineCounter
<= numberOfLines
907 if not newLineInserted then
908 REM If the line number is the position at which to insert the new line
909 if lineCounter = newLinePosition then
910 if( instr( xmlFile( lineCounter ),
"<menu:menupopup
>" )
> 0 ) then
911 indent = GetMenuWhiteSpace( xmlFile( newLinePosition +
1 ) )
912 newXmlFile( lineCounter ) = xmlFile( lineCounter )
913 newXmlFile( lineCounter +
1 ) = ( indent +
"<menu:menuitem menu:id=
"+chr$(
34) + newScript + chr$(
34)+
" menu:helpid=
"+chr$(
34)+
"1929"+chr$(
34)+
" menu:label=
"+chr$(
34)+ newMenuLabel + chr$(
34)+
"/
>" )
915 indent = GetMenuWhiteSpace( xmlFile( newLinePosition -
1 ) )
916 newXmlFile( lineCounter ) = ( indent +
"<menu:menuitem menu:id=
"+chr$(
34) + newScript + chr$(
34)+
" menu:helpid=
"+chr$(
34)+
"1929"+chr$(
34)+
" menu:label=
"+chr$(
34)+ newMenuLabel + chr$(
34)+
"/
>" )
917 newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
919 REM added -
1 for debug --
>
920 ' indent = GetMenuWhiteSpace( xmlFile( newLinePosition ) )
921 ' newXmlFile( lineCounter ) = ( indent +
"<menu:menuitem menu:id=
"+chr$(
34)+
"script://
" + newScript + chr$(
34)+
" menu:helpid=
"+chr$(
34)+
"1929"+chr$(
34)+
" menu:label=
"+chr$(
34)+ newMenuLabel + chr$(
34)+
"/
>" )
922 ' newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
923 newLineInserted = true
925 newXmlFile( lineCounter ) = xmlFile( lineCounter )
928 REM if the new line has been inserted the read from one position behind
929 newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
931 lineCounter = lineCounter +
1
934 numberOfLines = numberOfLines +
1
936 REM read the new file into the global array
937 for n =
1 to numberOfLines
938 xmlFile( n ) = newXmlFile( n )
944 sub AddNewKeyBinding( scriptName as string, shift as boolean, control as boolean, key as string )
946 dim keyCombo as string
947 newLine =
" <accel:item accel:code=
"+chr$(
34)+
"KEY_
" + key +chr$(
34)
949 keyCombo =
"SHIFT +
"
950 newLine = newLine +
" accel:shift=
"+chr$(
34)+
"true
"+chr$(
34)
953 keyCombo = keyCombo +
"CONTROL +
"
954 newLine = newLine +
" accel:mod1=
"+chr$(
34)+
"true
"+chr$(
34)
956 keyCombo = keyCombo + key
957 newLine = newLine +
" xlink:href=
"+chr$(
34)+ scriptName +chr$(
34) +
"/
>"
959 if ( control AND shift ) then
960 offsetIntoArrayOfArrays =
0
961 elseif ( control ) then
962 offsetIntoArrayOfArrays =
3
963 elseif ( shift ) then
964 offsetIntoArrayOfArrays =
6
967 keyTypeOffset = getKeyTypeOffset( key )
968 offsetIntoArrayOfArrays = offsetIntoArrayOfArrays + keyTypeOffset
969 ' Calculate from the key the offset into key group array we need to point to
970 KeyGroupIndex = getKeyGroupIndex( key, keyTypeOffset )
972 ' if key is already allocated to a script then just reallocate
973 if ( keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value
> 1 ) then
975 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
976 'replace line in xml file
977 xmlFile( keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value ) = newLine
979 ' this is a new binding, create a new line in xml file
980 for n =
1 to numberOfLines
981 if n = numberOfLines then
982 xmlFile( n ) = newLine
983 xmlFile( n +
1 ) =
"</accel:acceleratorlist
>"
986 xmlFile( n ) = xmlFile( n )
990 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value = n
991 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
992 numberOfLines = numberOfLines +
1
998 Sub RemoveBinding( lineToRemove as Integer )
999 xmlFile( lineToRemove ) =
""
1002 REM Adds or removes the starting xml line positions for each top-level menu after the menu with the added script
1003 sub UpdateTopLevelMenus( topLevelMenuPosition as integer, addLine as boolean )
1004 for n = topLevelMenuPosition to
8
1006 menuItemLinePosition( n ) = menuItemLinePosition( n ) +
1
1013 REM Remove scriptNames and scriptLinePosition entries
1014 sub RemoveScriptNameAndPosition( keyComboPosition )
1015 dim updatedScriptNames(
120 ) as string
1016 dim updatedScriptLinePosition(
120 ) as integer
1017 dim removedScript as boolean
1018 removedScript = false
1020 for n =
1 to scriptCount
1021 if not removedScript then
1022 if not( n = keyComboPosition ) then
1023 updatedScriptNames( n ) = scriptNames( n )
1025 removedScript = true
1028 updatedScriptNames( n -
1 ) = scriptNames( n )
1031 scriptCount = scriptCount -
1
1033 for n =
1 to scriptCount
1034 scriptNames( n ) = updatedScriptNames( n )
1040 REM ----- Populating Dialog Controls -----
1042 Sub PopulateLanguageCombo()
1043 langCombo = bindingDialog.getControl(
"LanguageCombo
" )
1044 langCombo.removeItems(
0, langCombo.getItemCount() )
1045 for n = LBOUND( languages() ) to UBOUND ( languages() )
1046 langCombo.addItem( languages( n ), n )
1048 langCombo.setDropDownLineCount( n )
1049 langCombo.text = langCombo.getItem(
0 )
1052 Sub PopulateLocationCombo()
1053 dim ScriptProvider as Object
1055 dim displayDialogFlag as boolean
1056 displayDialogFlag = false
1057 args(
0) = ThisComponent
1058 args(
1) = displayDialogFlag
1060 ScriptProvider = createUnoService(
"drafts.com.sun.star.script.framework.provider.MasterScriptProvider
")
1061 ScriptProvider.initialize( args() )
1063 locCombo = bindingDialog.getControl(
"LocationCombo
" )
1064 locCombo.removeItems(
0, locCombo.getItemCount() )
1065 for n = LBOUND( locations() ) to UBOUND ( locations() )
1066 locCombo.addItem( locations( n ), n )
1068 locCombo.setDropDownLineCount( n )
1069 locCombo.text = locCombo.getItem(
0 )
1072 sub PopulateScriptList( lang as String, loc as String )
1073 Dim detailedView as boolean
1074 detailedView = bindingDialog.Model.detail.state
1075 scriptList = bindingDialog.getControl(
"ScriptList
" )
1076 scriptList.removeItems(
0, scriptList.getItemCount() )
1078 smgr = getProcessServiceManager()
1079 context = smgr.getPropertyValue(
"DefaultContext
" )
1080 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
1081 scriptLocationURI =
"USER
"
1082 if ( loc =
"Share
" ) then
1083 scriptLocationURI =
"SHARE
"
1084 elseif ( loc =
"Document
" )then
1085 document = StarDesktop.ActiveFrame.Controller.Model
1086 scriptLocationURI = document.getURL()
1087 elseif ( loc =
"Filesystem
" ) then
1088 REM populate the list from the filesysScripts list
1089 if(lang =
"Java
" ) then
1092 length = UBOUND( filesysScripts() )
1093 if(length = -
1) then
1096 for langIndex = lbound(languages()) to ubound(languages())
1097 if ( lang = languages(langIndex)) then
1098 extns = extensions(langIndex)
1102 dim locnDisplayList( length ) as new com.sun.star.beans.PropertyValue
1103 for index = lbound(filesysScripts()) to ubound(filesysScripts())
1104 scriptextn = filesysScripts( index )
1105 pos = lastIndexOf( scriptextn,
".
" )
1106 scriptextn = mid( scriptextn, pos +
1, len( scriptextn ) - pos )
1108 for extnsIndex = lbound(extns()) to ubound(extns())
1109 extn = extns(extnsIndex)
1110 if ( scriptextn = extn ) then
1111 if ( detailedView ) then
1112 locnDisplayList( index ).Name = filesysScripts( index )
1113 locnDisplayList( index ).Value = filesysScripts( index )
1115 REM replace name with simplified view
1116 locnDisplayList( index ).Name = filesysScripts( index )
1117 locnDisplayList( index ).Value = filesysScripts( index )
1119 scriptList.addItem( locnDisplayList( index ).Name, index )
1124 ScriptDisplayList(
0) = locnDisplayList()
1125 scriptList.selectItemPos(
0, true )
1127 REM !!!!At this point we exit the sub!!!!
1132 scriptStorageID = scriptstoragemgr.getScriptStorageID( scriptLocationURI )
1133 dim resultList() as Object
1134 if ( scriptStorageID
> -
1 ) then
1135 storage = scriptstoragemgr.getScriptStorage( scriptStorageID )
1136 implementations() = storage.getAllImplementations()
1137 length = UBOUND( implementations() )
1138 reservedScriptTag =
"_$
"
1139 if ( length
> -
1 ) then
1140 dim tempDisplayList( length ) as new com.sun.star.beans.PropertyValue
1141 for n = LBOUND( implementations() ) to UBOUND( implementations() )
1142 logicalName = implementations( n ).getLogicalName()
1143 firstTwoChars = LEFT( logicalName,
2 )
1144 'Only display scripts whose logicalnames don
't begin with
"_$
"
1145 if ( firstTwoChars
<> reservedScriptTag ) then
1146 if ( lang = implementations( n ).getLanguage() ) then
1147 if ( detailedView ) then
1148 tempDisplayList( n ).Name = logicalName _
1149 +
" [
" + implementations( n ).getFunctionName() +
"]
"
1150 tempDisplayList( n ).Value = implementations( n )
1152 tempDisplayList( n ).Name = logicalName
1153 tempDisplayList( n ).Value = implementations( n )
1155 scriptList.addItem( tempDisplayList( n ).Name, n )
1159 resultList = tempDisplayList()
1161 ScriptDisplayList(
0) = resultList()
1163 scriptList.selectItemPos(
0, true )
1167 sub PopulateMenuCombo()
1168 menuComboBox = bindingDialog.getControl(
"MenuCombo
" )
1169 menuComboBox.removeItems(
0, menuComboBox.getItemCount() )
1170 for n =
1 to menuCount
1171 menuComboBox.addItem( menuItems( n ), n -
1 )
1173 menuComboBox.setDropDownLineCount(
8 )
1174 menuComboBox.text = menuComboBox.getItem(
0 )
1178 sub PopulateSubMenuList( menuItemPosition as integer )
1179 redim subMenuItems(
100 ) as string
1180 redim subMenuItemLinePosition(
100 ) as integer
1181 dim lineNumber as integer
1182 const menuItemWhiteSpace =
4
1183 const menuXMLTag =
"<menu:menu
"
1186 REM xmlStartLine and xmlEndLine refer to the first and last lines
1187 ' menuItemPosition of a top-level menu (
1=File to
8=Help ) add one line
1188 xmlStartLine = menuItemLinePosition( menuItemPosition ) +
1
1190 REM If last menu item is chosen
1191 if menuItemPosition = menuCount then
1192 xmlEndLine = numberOfLines
1194 REM Other wise get the line before the next top-level menu begins
1195 xmlEndLine = menuItemLinePosition( menuItemPosition +
1 ) -
1
1198 for lineNumber = xmlStartLine to xmlEndLine
1199 REM Insert all sub-menus and sub-popupmenus
1200 if not( instr( xmlFile( lineNumber ), menuXMLTag ) =
0 ) and instr( xmlFile( lineNumber ),
"menupopup
") =
0 then
1201 subMenuIndent = GetMenuWhiteSpace( xmlFile( lineNumber ) )
1202 if subMenuIndent =
" " then
1203 subMenuIndent =
""
1205 subMenuIndent = subMenuIndent + subMenuIndent
1207 if not( instr( xmlFile( lineNumber ),
"menuseparator
" ) =
0 ) then
1208 subMenuItems( subMenuCount ) = subMenuIndent +
"----------------
"
1210 subMenuName = ExtractLabelFromXMLLine( xmlFile( lineNumber ) )
1211 REM Add script Name if there is one bound to menu item
1212 if instr( xmlFile( lineNumber ),
"script://
" )
> 0 then
1213 script = ExtractScriptIdFromXMLLine( xmlFile( lineNumber ) )
1214 subMenuItems( subMenuCount ) = ( subMenuIndent + subMenuName +
" [
" + script +
"]
" )
1216 subMenuItems( subMenuCount ) = subMenuIndent + subMenuName
1219 subMenuItemLinePosition( subMenuCount ) = lineNumber
1220 subMenuCount = subMenuCount +
1
1224 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1226 currentPosition = subMenuList.getSelectedItemPos()
1228 subMenuList.removeItems(
0, subMenuList.getItemCount() )
1229 'If there are no sub-menus i.e. a dynamically generated menu like Format
1230 'if subMenuCount =
1 then
1231 if menuItems( menuItemPosition ) =
"Format
" then
1232 subMenuList.addItem(
"Unable to Assign Scripts to this menu
",
0 )
1234 for n =
1 to subMenuCount -
1
1235 subMenuList.addItem( subMenuItems( n ), n -
1 )
1239 subMenuList.selectItemPos( currentPosition, true )
1241 SubMenuListListener()
1242 MenuLabelBoxListener()
1247 sub PopulateTopLevelKeyBindingList()
1249 allKeyGroupsArray(
0) =
"SHIFT + CONTROL + F keys
"
1250 allKeyGroupsArray(
1) =
"SHIFT + CONTROL + digits
" ' CURRENTLY DISABLED
1251 allKeyGroupsArray(
2) =
"SHIFT + CONTROL + letters
"
1252 allKeyGroupsArray(
3) =
"CONTROL + F keys
"
1253 allKeyGroupsArray(
4) =
"CONTROL + digits
"
1254 allKeyGroupsArray(
5) =
"CONTROL + letters
"
1255 allKeyGroupsArray(
6) =
"SHIFT + F keys
"
1257 keyCombo = bindingDialog.getControl(
"KeyCombo
" )
1258 keyCombo.removeItems(
0, keyCombo.getItemCount() )
1260 for n = LBOUND( allKeyGroupsArray() ) to UBOUND( allKeyGroupsArray() )
1261 ' SHIFT + CONTROL + digits group is disabled at the moment, so skip
1263 if ( n
<> 1 ) then
1264 keyCombo.addItem( allKeyGroupsArray( n ), pos )
1268 keyCombo.text = keyCombo.getItem(
0 )
1271 sub PopulateKeyBindingList( keyGroupIndex as Integer )
1272 keyList = bindingDialog.getControl(
"KeyList
" )
1273 selectedPos = keyList.getSelectedItemPos()
1274 keyList.removeItems(
0, keyList.getItemCount() )
1276 ShortCutKeyArray() = KeyBindArrayOfArrays( keyGroupIndex )
1278 Dim keyProp as new com.sun.star.beans.PropertyValue
1279 for n = lbound( ShortCutKeyArray() ) to ubound( ShortCutKeyArray() )
1280 keyName = ShortCutKeyArray( n )
1281 if ( keyAllocationMap( keyGroupIndex, n ).Value =
1 ) then
1282 keyName = keyName +
" [Allocated to Office function]
"
1284 elseif ( keyAllocationMap( keyGroupIndex, n ).Value
> 1 ) then
1285 keyName = keyName +
" " + keyAllocationMap( keyGroupIndex, n ).Name
1287 keyList.addItem( keyName, n )
1290 if ( selectedPos
<> -
1 )then
1291 keyList.selectItemPos( selectedPos, true )
1293 keyList.selectItemPos(
0, true )
1298 sub populateEventList( focusPosition as integer )
1299 allApps = bindingDialog.getControl(
"AllAppsOption
" )
1300 eventList = bindingDialog.getControl(
"EventList
" )
1301 eventList.removeItems(
0, eventList.getItemCount() )
1303 dim isApp as boolean
1304 if allApps.state = true then
' Application event
1310 ' use allEventTypes() to fill list box
1311 ' for each element compare with allEventTypesApp
1312 dim scriptName as string
1313 dim lineNumber as integer
1314 for n =
0 to ubound( allEventTypes() )
1315 ' If the line number is
1 then SB macro
1316 ' more than
1 it is the line number of the script
1317 if isApp and n
> 12 then
1321 lineNumber = allEventTypesApp( n ).Value
1322 scriptName = allEventTypesApp( n ).Name
1324 lineNumber = allEventTypesDoc( n ).Value
1325 scriptName = allEventTypesDoc( n ).Name
1327 stringToAdd =
""
1328 if ( lineNumber
>=
1 ) then
1329 stringToAdd =
" [
" + scriptName +
"]
"
1331 eventList.addItem( allEventTypes( n ).Value +
" " + stringToAdd, n )
1334 eventList.selectItemPos( focusPosition, true )
1339 sub CreateAllKeyBindings()
1340 reDim allKeyBindings(
105 ) as string
1341 keyBindingPosition =
1
1344 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL + F
" + FKey
1345 keyBindingPosition = keyBindingPosition +
1
1348 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL +
" + Digit
1349 keyBindingPosition = keyBindingPosition +
1
1351 for Alpha =
65 to
90
1352 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL +
" + chr$( Alpha )
1353 keyBindingPosition = keyBindingPosition +
1
1357 allKeyBindings( keyBindingPosition ) =
"CONTROL + F
" + FKey
1358 keyBindingPosition = keyBindingPosition +
1
1361 allKeyBindings( keyBindingPosition ) =
"CONTROL +
" + Digit
1362 keyBindingPosition = keyBindingPosition +
1
1364 for Alpha =
65 to
90
1365 allKeyBindings( keyBindingPosition ) =
"CONTROL +
" + chr$( Alpha )
1366 keyBindingPosition = keyBindingPosition +
1
1370 allKeyBindings( keyBindingPosition ) =
"SHIFT + F
" + FKey
1371 keyBindingPosition = keyBindingPosition +
1
1376 sub createAllEventTypes()
1377 allEventTypes(
0 ).Name =
"OnStartApp
"
1378 allEventTypes(
0 ).Value =
"Start Application
"
1379 allEventTypes(
1 ).Name =
"OnCloseApp
"
1380 allEventTypes(
1 ).Value =
"Close Application
"
1381 allEventTypes(
2 ).Name =
"OnNew
"
1382 allEventTypes(
2 ).Value =
"Create Document
"
1383 allEventTypes(
3 ).Name =
"OnLoad
"
1384 allEventTypes(
3 ).Value =
"Open Document
"
1385 allEventTypes(
4 ).Name =
"OnSaveAs
"
1386 allEventTypes(
4 ).Value =
"Save Document As
"
1387 allEventTypes(
5 ).Name =
"OnSaveAsDone
"
1388 allEventTypes(
5 ).Value =
"Document has been saved as
"
1389 allEventTypes(
6 ).Name =
"OnSave
"
1390 allEventTypes(
6 ).Value =
"Save Document
"
1391 allEventTypes(
7 ).Name =
"OnSaveDone
"
1392 allEventTypes(
7 ).Value =
"Document has been saved
"
1393 allEventTypes(
8 ).Name =
"OnPrepareUnload
"
1394 allEventTypes(
8 ).Value =
"Close Document
"
1395 allEventTypes(
9 ).Name =
"OnUnload
"
1396 allEventTypes(
9 ).Value =
"Close Document
"
1397 allEventTypes(
10 ).Name =
"OnFocus
"
1398 allEventTypes(
10 ).Value =
"Activate document
"
1399 allEventTypes(
11 ).Name =
"OnUnfocus
"
1400 allEventTypes(
11 ).Value =
"DeActivate document
"
1401 allEventTypes(
12 ).Name =
"OnPrint
"
1402 allEventTypes(
12 ).Value =
"Print Document
"
1403 REM The following are document-only events
1404 allEventTypes(
13 ).Name =
"OnMailMerge
"
1405 allEventTypes(
13 ).Value =
"Print form letters
"
1406 allEventTypes(
14 ).Name =
"OnPageCountChange
"
1407 allEventTypes(
14 ).Value =
"Changing the page count
"
1411 sub createAllEventBindings()
1412 'dim props as new com.sun.star.beans.PropertyValue
1413 'props.Name =
"" 'Name = script name
1414 'props.Value =
0 'Value =
0 for empty,
1 for macro, linenumber for script
1416 ' Creates all types of event bindings for both Application and Document
1417 ' Initially both arrays have no bindings allocated to the events
1418 ' The value for Doc is only Script/macro name (no need for line number)
1419 for n =
0 to ubound( allEventTypes() )
1420 allEventTypesApp( n ).Name =
""
1421 allEventTypesApp( n ).Value =
0
1422 allEventTypesDoc( n ).Name =
""
1423 allEventTypesDoc( n ).Value =
0
1428 REM ----- Text Handling Functions -----
1431 function ExtractLabelFromXMLLine( XMLLine as string ) as string
1432 labelStart = instr( XMLLine,
"label=
"+chr$(
34)) +
7
1433 labelEnd = instr( XMLLine, chr$(
34)+
">" )
1434 if labelEnd =
0 then
1435 labelEnd = instr( XMLLine, chr$(
34)+
"/
>" )
1437 labelLength = labelEnd - labelStart
1439 menuLabelUnformatted = mid( XMLLine, labelStart, labelLength )
1440 tildePosition = instr( menuLabelUnformatted,
"~
" )
1441 select case tildePosition
1443 menuLabel = menuLabelUnformatted
1445 menuLabel = right( menuLabelUnformatted, labelLength -
1 )
1447 menuLabelLeft = left( menuLabelUnformatted, tildePosition -
1 )
1448 menuLabelRight = right( menuLabelUnformatted, labelLength - tildePosition )
1449 menuLabel = menuLabelLeft + menuLabelRight
1452 ExtractLabelFromXMLLine() = menuLabel
1456 function ExtractScriptIdFromXMLLine( XMLLine as string ) as string
1457 idStart = instr( XMLLine,
"script://
") +
9
1458 if instr( XMLLine, chr$(
34)+
" menu:helpid=
" ) =
0 then
1459 idEnd = instr( XMLLIne,
"?location=
" )
1461 idEnd = instr( XMLLine,
""+chr$(
34)+
" menu:helpid=
" )
1463 idLength = idEnd - idStart
1464 scriptId = mid( XMLLine, idStart, idLength )
1466 ExtractScriptIdFromXMLLine() = scriptId
1469 function ExtractEventScriptFromXMLLine( xmlline as string )
1470 if instr( xmlline,
"script://
" )
> 0 then
1471 idStart = instr( xmlline,
"script://
") +
9
1472 idEnd = instr( xmlline, chr$(
34)+
" xlink:type=
" )
1473 idLength = idEnd - idStart
1474 scriptId = mid( xmlline, idStart, idLength )
1476 ExtractEventScriptFromXMLLine() = scriptId
1480 function ExtractEventNameFromXMLLine( xmlline as string )
1481 idStart = instr( xmlline,
"event:name=
" + chr$(
34) ) +
12
1482 idEnd = instr( xmlline, chr$(
34)+
" event:language
" )
1483 idLength = idEnd - idStart
1484 event = mid( xmlline, idStart, idLength )
1486 ExtractEventNameFromXMLLine() = event
1489 function ExtractKeyCodeFromXMLLine( XMLLine as string ) as string
1490 keyStart = instr( XMLLine,
"code=
"+chr$(
34)+
"KEY_
") +
10
1491 keyCode = mid( XMLLine, keyStart, ( len( XMLLine ) - keyStart ) )
1492 keyEnd = instr( keyCode, chr$(
34) )
1493 keyCode = mid( keyCode,
1, keyEnd -
1 )
1495 ExtractKeyCodeFromXMLLine() = keyCode
1499 function GetMenuWhiteSpace( MenuXMLLine as string ) as string
1500 whiteSpace =
""
1501 numberOfSpaces = instr( MenuXMLLine,
"<" ) -
1
1502 for i =
1 to numberOfSpaces
1503 whiteSpace = whiteSpace +
" "
1506 GetMenuWhiteSpace() = whiteSpace
1509 function IsAllocatedMenuItem( script as string ) as boolean
1510 foundMenuItem = false
1515 if strcomp( script, subMenuItems( count ) ) =
0 then
1516 foundMenuItem = true
1518 loop while not( foundMenuItem ) and count
< subMenuCount
1520 linePosition = subMenuItemLinePosition( count )
1522 if not( instr( xmlFile( linePosition ),
"script://
" ) =
0 ) then
1526 isAllocatedMenuItem() = Allocated
1530 function HasShiftKey( keyCombo ) as boolean
1531 if instr( keyCombo,
"SHIFT
" ) =
0 then
1537 HasShiftKey = hasShift
1541 function HasControlKey( keyCombo ) as boolean
1542 if instr( keyCombo,
"CONTROL
" ) =
0 then
1548 HasControlKey = hasControl
1552 function ExtractKeyFromCombo( keyString as string ) as string
1553 while not( instr( keyString,
"+
" ) =
0 )
1554 removeTo = instr( keyString,
"+
" ) +
2
1555 keyString = mid( keyString, removeTo, ( len( keyString ) - removeTo ) +
1 )
1557 ExtractKeyFromCombo() = keyString
1562 REM ------ Event Handling Functions (Listeners) ------
1565 sub KeyListListener()
1566 keyShortCutList = bindingDialog.getControl(
"KeyList
" )
1567 selectedShortCut = keyShortCutList.getSelectedItem()
1568 combo = bindingDialog.getControl(
"KeyCombo
" )
1570 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1571 selectedScript = menuScriptList.getSelectedItem()
1573 keyGroup = combo.text
1574 dim keyGroupIndex as Integer
1575 dim selectedKeyIndex as Integer
1576 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
1577 if ( allKeyGroupsArray( n ) = keyGroup )then
1582 selectedKeyIndex = keyShortCutList.getSelectedItemPos()
1584 if keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value
> 1 then
1585 bindingDialog.Model.Delete.enabled = true
1586 bindingDialog.Model.AddOn.enabled = true
1587 if selectedScript
<> "" then
1588 bindingDialog.Model.NewButton.enabled = true
1593 if keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value =
1 then
1594 bindingDialog.Model.Delete.enabled = false
1595 bindingDialog.Model.AddOn.enabled = false
1596 bindingDialog.Model.NewButton.enabled = false
1598 bindingDialog.Model.Delete.enabled = false
1599 bindingDialog.Model.AddOn.enabled = false
1600 if selectedScript
<> "" then
1601 bindingDialog.Model.NewButton.enabled = true
1608 sub SubMenuListListener()
1609 scriptList = bindingDialog.getControl(
"ScriptList
" )
1610 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1611 selectedMenuItem = subMenuList.getSelectedItem()
1612 if IsAllocatedMenuItem( selectedMenuItem ) then
1613 bindingDialog.Model.Delete.enabled = true
1614 bindingDialog.Model.AddOn.enabled = true
1616 bindingDialog.Model.Delete.enabled = false
1617 bindingDialog.Model.AddOn.enabled = false
1621 REM a keypress listener that in turn fires the MenuCL on a return key even only
1622 sub fireMenuComboListernerOnRet( eventobj as object )
1623 if (eventobj.KeyCode =
1280 ) then
1628 'Populates the SubMenuList with the appropriate menu items from the Top-level menu selected from the combo box
1629 sub MenuComboListener()
1630 combo = bindingDialog.getControl(
"MenuCombo
" )
1631 newToplevelMenu = combo.text
1634 counter = counter +
1
1635 loop while not( newToplevelMenu = menuItems( counter ) )
1637 PopulateSubMenuList( counter )
1640 REM a keypress listener that in turn fires the LLCL on a return key even only
1641 sub fireLangLocComboListernerOnRet( eventobj as object )
1642 if (eventobj.KeyCode =
1280 ) then
1643 LangLocComboListener()
1647 sub LangLocComboListener()
1649 combo = bindingDialog.getControl(
"LanguageCombo
" )
1650 language = combo.text
1651 combo = bindingDialog.getControl(
"LocationCombo
" )
1652 location = combo.text
1654 PopulateScriptList( language,location )
1656 'Enable/disable Assign button
1657 scriptList = bindingDialog.getControl(
"ScriptList
" )
1658 if not (dialogName =
"EditDebug
") then
1659 if scriptList.getSelectedItem() =
"" then
1660 bindingDialog.Model.NewButton.enabled = false
1664 if ( location =
"Filesystem
" ) and ( language
<> "Java
" ) then
1665 bindingDialog.Model.Browse.enabled = true
1666 if not (dialogName =
"EditDebug
") then
1667 bindingDialog.Model.fsonly.enabled = true
1670 bindingDialog.Model.Browse.enabled = false
1671 if not (dialogName =
"EditDebug
") then
1672 bindingDialog.Model.fsonly.enabled = false
1676 ' extra dialog dependant processing
1677 if dialogName =
"Menu
" then
1678 ' will set New button to false if no text in LableBox
1679 MenuLabelBoxListener()
1680 elseif dialogName =
"Key
" then
1681 ' will set Assigne button to false if appropriate
1683 elseif dialogName =
"Event
" then
1689 REM a keypress listener that in turn fires the KeyCL on a return key even only
1690 sub fireKeyComboListernerOnRet( eventobj as object )
1691 if (eventobj.KeyCode =
1280 ) then
1696 'Populates the KeyList with the appropriate key combos from the Top-level key group selected from the combo box
1697 sub KeyComboListener()
1698 combo = bindingDialog.getControl(
"KeyCombo
" )
1699 keyGroup = combo.text
1700 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
1701 if ( allKeyGroupsArray( n ) = keyGroup )then
1706 PopulateKeyBindingList( keyGroupIndex )
1710 sub MenuLabelBoxListener()
1711 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1712 selectedScript = menuScriptList.getSelectedItem()
1713 'if the SubMenuList is from a dynamically created menu (e.g. Format)
1714 'or if the Menu Label text box is empty
1715 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1716 firstItem = subMenuList.getItem(
0 )
1717 if bindingDialog.Model.MenuLabelBox.text =
"" OR firstItem =
"Unable to Assign Scripts to this menu
" OR selectedScript =
"" then
1718 bindingDialog.Model.NewButton.enabled = false
1720 bindingDialog.Model.NewButton.enabled = true
1724 sub AppDocEventListener()
1725 populateEventList(
0 )
1730 sub EventListListener()
1731 on error goto ErrorHandler
1733 eventList = bindingDialog.getControl(
"EventList
" )
1734 eventPos = eventList.getSelectedItemPos()
1736 allApps = bindingDialog.getControl(
"AllAppsOption
" )
1738 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1739 selectedScript = menuScriptList.getSelectedItem()
1741 dim binding as integer
1742 if allApps.state = true then
1743 binding = allEventTypesApp( eventPos ).Value
1745 binding = allEventTypesDoc( eventPos ).Value
1748 if ( binding
> 1 ) then
1749 bindingDialog.Model.Delete.enabled = true
1751 bindingDialog.Model.Delete.enabled = false
1754 if ( binding =
1 ) then
1755 ' staroffice binding, can
't assign
1756 bindingDialog.Model.NewButton.enabled = false
1757 elseif ( selectedScript
<> "" ) then
1758 bindingDialog.Model.NewButton.enabled = true
1764 bindingDialog.Model.Delete.enabled = false
1769 REM ------ Event Handling Functions (Buttons) ------
1771 function getFilePicker() as Object
1773 oFilePicker = CreateUnoService(
"com.sun.star.ui.dialogs.FilePicker
" )
1775 combo = bindingDialog.getControl(
"LanguageCombo
" )
1776 language = combo.text
1777 currentFilter =
""
1779 for langIndex =
0 to ubound(languages())
1780 if( languages(langIndex)
<> "Java
" ) then
1781 filterName = languages(langIndex) +
" (
"
1782 filterVal=
""
1783 extns = extensions(langIndex)
1784 for extnIndex = lbound(extns()) to ubound(extns())
1785 filterName = filterName +
"*.
" + extns(extnIndex) +
",
"
1786 filterVal = filterVal +
"*.
" + extns(extnIndex) +
",
"
1788 filterName = left(filterName, len(filterName) -
1) +
")
"
1789 filterVal = left(filterVal, len(filterVal) -
1)
1790 if(instr(filterName,language) =
1 ) then
1791 currentFilter = filterName
1793 oFilePicker.AppendFilter(filterName, filterVal)
1796 if(len(currentFilter)
> 0 ) then
1797 oFilePicker.SetCurrentFilter( currentFilter )
1800 If sFileURL =
"" Then
1801 oSettings = CreateUnoService(
"com.sun.star.frame.Settings
" )
1802 oPathSettings = oSettings.getByName(
"PathSettings
" )
1803 sFileURL = oPathSettings.getPropertyValue(
"Work
" )
1806 REM set display directory
1807 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1809 If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then
1810 oFilePicker.setDisplayDirectory( sFileURL )
1812 getFilePicker() = oFilePicker
1815 Sub DoBrowseAndEdit()
1816 Dim oFilePicker As Object, oSimpleFileAccess As Object
1817 Dim oSettings As Object, oPathSettings As Object
1818 Dim sFileURL As String
1819 Dim sFiles As Variant
1821 oFilePicker = getFilePicker()
1822 REM execute file dialog
1823 If oFilePicker.execute() Then
1824 sFiles = oFilePicker.getFiles()
1826 sFileURL = sFiles(
0)
1827 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1828 If oSimpleFileAccess.exists( sFileURL ) Then
1829 for langIndex =
0 to ubound(languages())
1830 If (instr(oFilePicker.GetCurrentFilter, languages(langIndex)) =
1 ) then
1831 RunDebugger(languages(langIndex), sFileURL,
"")
1835 bindingDialog.endExecute()
1839 Sub RunDebugger(lang as String, uri as String, filename as String)
1840 dim document as object
1841 dim dispatcher as object
1842 dim parser as object
1843 dim url as new com.sun.star.util.URL
1845 document = ThisComponent.CurrentController.Frame
1846 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
1847 dim args(
2) as new com.sun.star.beans.PropertyValue
1848 args(
0).Name =
"language
"
1849 args(
0).Value = lang
1850 args(
1).Name =
"uri
"
1852 args(
2).Name =
"filename
"
1853 args(
2).Value = filename
1855 url.Complete =
"script://_$DebugRunner.Debug?
" _
1856 +
"language=Java
&function=DebugRunner.go
" _
1857 +
"&location=share
"
1859 parser.parseStrict(url)
1860 disp = document.queryDispatch(url,
"",
0)
1861 disp.dispatch(url, args())
1865 Dim scriptInfo as Object
1867 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1868 selectedScript = menuScriptList.getSelectedItem()
1870 if not (selectedScript =
"") then
1871 scripts() = scriptDisplayList(
0)
1872 for n = LBOUND( scripts() ) to UBOUND( scripts() )
1873 if ( scripts( n ).Name = selectedScript ) then
1874 scriptInfo = scripts( n ).Value
1879 RunDebugger(scriptInfo.getLanguage, scriptInfo.getParcelURI, scriptInfo.getFunctionName)
1880 bindingDialog.endExecute()
1886 bindingDialog.endExecute()
1890 sub MenuCancelButton()
1891 bindingDialog.endExecute()
1895 sub MenuHelpButton()
1896 helpDialog = LoadDialog(
"ScriptBindingLibrary
",
"HelpBinding
" )
1897 helpDialog.execute()
1901 sub MenuDeleteButton()
1902 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1903 linePos = subMenuItemLinePosition( subMenuList.getSelectedItemPos() +
1 )
1905 RemoveBinding( linePos )
1907 REM Update the top-level menu
's line positions
1908 combo = bindingDialog.getControl(
"MenuCombo
" )
1909 newToplevelMenu = combo.text
1912 counter = counter +
1
1913 loop while not( newToplevelMenu = menuItems( counter ) )
1914 UpdateTopLevelMenus( counter +
1, false )
1918 subMenuList.selectItemPos( subMenuList.getSelectedItemPos(), true )
1923 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1924 selectedScript = menuScriptList.getSelectedItem()
1925 scriptURI = getScriptURI( selectedScript )
1926 newMenuLabel = bindingDialog.Model.MenuLabelBox.text
1928 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1930 REM Update the top-level menu
's line positions
1931 combo = bindingDialog.getControl(
"MenuCombo
" )
1932 newToplevelMenu = combo.text
1935 counter = counter +
1
1936 loop while not( newToplevelMenu = menuItems( counter ) )
1937 UpdateTopLevelMenus( counter +
1, true )
1939 REM New line position is one ahead of the selected sub menu item
1940 linePos = subMenuItemLinePosition( subMenuList.getSelectedItemPos() +
1 ) +
1
1942 AddNewMenuBinding( scriptURI, newMenuLabel, linePos )
1945 subMenuList.selectItemPos( subMenuList.getSelectedItemPos() +
1, true )
1946 SubMenuListListener()
1950 Dim oFilePicker As Object, oSimpleFileAccess As Object
1951 Dim oSettings As Object, oPathSettings As Object
1952 Dim sFileURL As String
1953 Dim sFiles As Variant
1955 oFilePicker = getFilePicker()
1957 REM execute file dialog
1958 If oFilePicker.execute() Then
1959 sFiles = oFilePicker.getFiles()
1960 sFileURL = sFiles(
0)
1961 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1962 If oSimpleFileAccess.exists( sFileURL ) Then
1963 REM add sFileURL to the list
1964 ReDim preserve filesysScripts(filesysCount) as String
1965 filesysScripts( filesysCount ) = sFileURL
1966 filesysCount=filesysCount+
1
1967 ' if user changed filter in file picker then populate
1968 ' language with language associated with that in file picker
1969 sFilter = oFilePicker.getCurrentFilter()
1970 langCombo = bindingDialog.getControl(
"LanguageCombo
" )
1971 dim items() as String
1972 items() = langCombo.getItems()
1973 for index = lbound(items()) to ubound(items())
1974 iPos = inStr(sFilter,
" ")
1975 Dim theLanguage as String
1976 if( iPos
> 0 ) then
1977 theLanguage = Left( sFilter, iPos -
1)
1978 if ( theLanguage = items( index ) ) then
1979 langCombo.text = items( index )
1986 LangLocComboListener()
1991 bindingDialog.endExecute()
1995 sub KeyCancelButton()
1996 bindingDialog.endExecute()
2001 helpDialog = LoadDialog(
"ScriptBindingLibrary
",
"HelpBinding
" )
2002 helpDialog.execute()
2007 combo = bindingDialog.getControl(
"KeyCombo
" )
2008 keyGroup = combo.text
2009 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
2010 if ( allKeyGroupsArray( n ) = keyGroup )then
2015 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
2016 script = menuScriptList.getSelectedItem()
2017 scriptURI = getScriptURI( script )
2019 keyList = bindingDialog.getControl(
"KeyList
" )
2020 keyIndex = keyList.getSelectedItemPos()
2021 ShortCutKeyArray() = KeyBindArrayOfArrays( keyGroupIndex )
2022 keyText = ShortCutKeyArray( keyIndex )
2024 AddNewKeyBinding( scriptURI, HasShiftKey( keyText ), HasControlKey( keyText ), ExtractKeyFromCombo( keyText ) )
2030 sub KeyDeleteButton()
2032 keyShortCutList = bindingDialog.getControl(
"KeyList
" )
2033 selectedShortCut = keyShortCutList.getSelectedItem()
2034 combo = bindingDialog.getControl(
"KeyCombo
" )
2036 keyGroup = combo.text
2037 dim keyGroupIndex as Integer
2038 dim selectedKeyIndex as Integer
2039 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
2040 if ( allKeyGroupsArray( n ) = keyGroup )then
2045 selectedKeyIndex = keyShortCutList.getSelectedItemPos()
2046 linePosition = keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value
2047 keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value =
0
2048 keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Name =
""
2049 RemoveBinding( linePosition )
2054 sub EventNewButton()
2055 eventScriptList = bindingDialog.getControl(
"ScriptList
" )
2056 selectedScript = eventScriptList.getSelectedItem()
2057 scriptURI = getScriptURI( selectedScript )
2058 eventList = bindingDialog.getControl(
"EventList
" )
2059 eventPosition = eventList.getSelectedItemPos()
2061 allApps = bindingDialog.getControl(
"AllAppsOption
" )
2062 dim isApp as boolean
2063 if allApps.state = true then
'Application
2068 AddNewEventBinding( scriptURI, eventPosition, isApp )
2070 populateEventList( eventPosition )
2075 sub EventDeleteButton()
2076 eventList = bindingDialog.getControl(
"EventList
" )
2077 REM Check that combo is a script
2078 eventPosition = eventList.getSelectedItemPos()
2080 allApps = bindingDialog.getControl(
"AllAppsOption
" )
2081 if allApps.state = true then
'Application
2082 linePosition = allEventTypesApp( eventPosition ).Value
2083 'dim eventProp as new com.sun.star.beans.PropertyValue
2084 'eventProp.Name =
""
2085 'eventProp.Value =
0
2086 allEventTypesApp( eventPosition ).Name =
""
2087 allEventTypesApp( eventPosition ).Value =
0
2088 RemoveBinding( linePosition )
2090 'DeleteEvent( allEventTypes( eventPosition ) )
2091 allEventTypesDoc( eventPosition ).Name =
""
2092 allEventTypesDoc( eventPosition ).Value =
0
2095 PopulateEventList( eventPosition )
2103 bindingDialog.endExecute()
2108 helpDialog.endExecute()