1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"ScriptBinding" script:
language=
"StarBasic">REM ***** BASIC *****
5 REM ----- Global Variables -----
7 'bindingDialog can refer to either KeyBinding or MenuBinding dialog
8 private languages() as String
9 private extensions() as Object
10 private locations() as String
11 private filesysScripts() as String
12 private filesysCount as integer
13 private bindingDialog as object
14 private helpDialog as object
15 'Couldn
't get redim to work, so scriptDisplayList is and array of arrays
16 'where the one and only array in scriptDisplayList is an array
17 'of com.sun.star.beans.PropertyValue, where Name = [logicalName][FunctionName]
18 'and value is ScriptStorage object
19 private scriptDisplayList(
0)
20 private testArray() as String
21 'Array to store lines from the xml file
22 private xmlFile() as string
23 'Name of the xml file [writer/calc][menubar/keybindings].xml
24 private xmlFileName as string
25 'Number of lines in the xml file
26 private numberOfLines as integer
28 'Parallel arrays to store all top-level menu names and line positions
29 private menuItems() as string
30 private menuItemLinePosition() as integer
31 'Counter for the number of top-level menus
32 private menuCount as integer
34 'Parallel arrays to store all sub-menu names and line positions for a particular top-level menu
35 private subMenuItems() as string
36 private subMenuItemLinePosition() as integer
37 'Counter for the number of sub-menus
38 private subMenuCount as integer
40 'Parallel arrays to store all script names and line positions
41 private scriptNames() as string
42 private scriptLinePosition() as integer
43 'Counter for the number of scripts
44 private scriptCount as integer
46 'Array to store all combinations of key bindings
47 private allKeyBindings() as string
50 'KeyBindArrayOfArrays(
0) contains array of
"SHIFT + CONTROL + F Keys
" data
52 'KeyBindArrayOfArrays(
1) contains SHIFT + CONTROL + digits
53 'KeyBindArrayOfArrays(
2) contains SHIFT + CONTROL + letters
54 'KeyBindArrayOfArrays(
3) contains CONTROL + F keys
55 'KeyBindArrayOfArrays(
4) contains CONTROL + digits
56 'KeyBindArrayOfArrays(
5) contains CONTROL + letters
57 'KeyBindArrayOfArrays(
6) contains SHIFT + F keys
58 private KeyBindArrayOfArrays(
6)
60 'Each PropertyValue represents a key, Name member contains the script (if a binding exists)
61 ' the Value contains and integer
62 ' 0 means no script bound
63 ' 1 script is bound to an office function
64 ' >1 line number of entry in xmlfile array
65 private keyAllocationMap(
6,
25) as new com.sun.star.beans.PropertyValue
66 'array to store key group descriptions
67 private AllKeyGroupsArray(
6) as String
70 'Array of props to store all event bindings for the Applications
71 private allEventTypesApp(
14 ) as new com.sun.star.beans.PropertyValue
72 'Array of props to store all event bindings for the Document
73 private allEventTypesDoc(
14 ) as new com.sun.star.beans.PropertyValue
74 'Array of props to store all event types (Name) and textual description (Value)
75 private allEventTypes(
14 ) as new com.sun.star.beans.PropertyValue
78 private dialogName as String
79 REM ------ Storage Refresh Function ------
82 sub RefreshUserScripts()
83 ' TDB - change Menu bindings to allow user to refresh all, user, share or document script
84 RefreshAppScripts(
"USER
" )
87 sub RefreshAllScripts()
88 RefreshAppScripts(
"USER
" )
89 RefreshAppScripts(
"SHARE
" )
90 RefreshDocumentScripts
93 sub RefreshAppScripts( appName as String )
94 On Error Goto ErrorHandler
95 smgr = getProcessServiceManager()
96 context = smgr.getPropertyValue(
"DefaultContext
" )
97 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
99 scriptstoragemgr.refreshScriptStorage( appName )
105 MsgBox (
"Error: Unable to refresh Java (scripts)
" + chr$(
10) + chr$(
10)+
"Detail:
" & error$ + chr$(
10) + chr$(
10)+
"Action: Please restart Office
",
0,
"Error
" )
109 sub RefreshDocumentScripts()
110 On Error Goto ErrorHandler
111 smgr = getProcessServiceManager()
112 context = smgr.getPropertyValue(
"DefaultContext
" )
113 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
115 oDocURL = ThisComponent.GetCurrentController.getModel.getURL
117 On Error Goto ErrorHandlerDoc
118 scriptstoragemgr.refreshScriptStorage( oDocURL )
124 ' Ignore document script errors as it will happen when refreshing an unsaved doc
129 MsgBox (
"Error: Unable to refresh Java (scripts)
" + chr$(
10) + chr$(
10)+
"Detail:
" & error$ + chr$(
10) + chr$(
10)+
"Action: Please restart Office
",
0,
"Error
" )
134 REM ----- Launch Functions -----
136 Sub createAndPopulateKeyArrays()
137 'Create SHIFT + CONTROL + F keys array
138 'Dim keyGroupProp as new com.sun.star.beans.PropertyValue
142 SCFKey( FKey -
1 ) =
"SHIFT + CONTROL + F
" + FKey
145 KeyBindArrayOfArrays(
0) = SCFKey()
147 'Create SHIFT + CONTROL + digits
150 SCDKey( Digit ) =
"SHIFT + CONTROL +
" + Digit
152 KeyBindArrayOfArrays(
1) = SCDKey()
154 'Create SHIFT + CONTROL + letters
158 SCLKey( Alpha -
65 ) =
"SHIFT + CONTROL +
" + chr$( Alpha )
160 KeyBindArrayOfArrays(
2) = SCLKey()
162 'Create CONTROL + F keys
165 CFKey( Fkey -
1 ) =
"CONTROL + F
" + FKey
167 KeyBindArrayOfArrays(
3) = CFKey()
169 'Create CONTROL + digits
172 CDKey( Digit ) =
"CONTROL +
" + Digit
174 KeyBindArrayOfArrays(
4) = CDKey()
176 'Create CONTROL + letters
179 CLKey( Alpha -
65 ) =
"CONTROL +
" + chr$( Alpha )
181 KeyBindArrayOfArrays(
5) = CLKey()
183 'Create SHIFT + F Keys
186 SFKey( Fkey -
1 ) =
"SHIFT + F
" + FKey
188 KeyBindArrayOfArrays(
6) = SFKey()
192 Sub updateMapWithDisabledKeys()
193 'disable CONTROL + F1
&
194 keyAllocationMap(
3,
0 ).Value =
1
195 keyAllocationMap(
3,
0 ).Name =
""
196 'disable CONTROL + F4
&
197 keyAllocationMap(
3,
3 ).Value =
1
198 keyAllocationMap(
3,
3 ).Name =
""
199 'disable CONTROL + F6
200 keyAllocationMap(
3,
5 ).Value =
1
201 keyAllocationMap(
3,
5 ).Name =
""
204 'disable SHIFT + F1
&
205 keyAllocationMap(
6,
0 ).Value =
1
206 keyAllocationMap(
6,
0 ).Name =
""
207 'disable SHIFT + F2
&
208 keyAllocationMap(
6,
1 ).Value =
1
209 keyAllocationMap(
6,
1 ).Name =
""
210 'disable SHIFT + F6
&
211 keyAllocationMap(
6,
5 ).Value =
1
212 keyAllocationMap(
6,
5 ).Name =
""
216 Sub initialiseFileExtensions()
217 ReDim extensions(ubound(languages())+
1) as Object
218 oConfigProvider = CreateUnoService(
"com.sun.star.configuration.ConfigurationProvider
" )
219 Dim configArgs(
1) as new com.sun.star.beans.PropertyValue
220 configargs(
0).Name =
"nodepath
"
221 configArgs(
0).Value =
"org.openoffice.Office.Scripting/ScriptRuntimes
"
222 configargs(
1).Name =
"lazywrite
"
223 configArgs(
1).Value = false
224 oConfigAccess = oConfigProvider.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess
", configArgs())
225 for index =
0 to ubound(languages())
226 if(languages(index)
<> "Java
") then
227 xPropSet = oConfigAccess.getByName(languages(index))
228 extns() = xPropSet.getPropertyValue(
"SupportedFileExtensions
")
229 extensions(index) = extns()
234 Sub ExecuteEditDebug()
236 locations = Array (
"User
",
"Share
",
"Document
",
"Filesystem
" )
237 languages = Array (
"BeanShell
",
"JavaScript
" )
238 dialogName =
"EditDebug
"
239 initialiseFileExtensions()
240 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"EditDebug
" )
242 PopulateLanguageCombo()
243 PopulateLocationCombo()
244 PopulateScriptList( languages(
0), locations(
0) )
246 bindingDialog.execute()
249 Sub ExecuteKeyBinding()
250 dialogName =
"Key
"
251 createAndPopulateKeyArrays()
252 updateMapWithDisabledKeys()
253 xmlFileName = GetDocumentType(
"Key
" )
255 if not (ReadXMLToArray(
"Key
" )) then
259 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"KeyBinding
" )
260 PopulateKeyBindingList(
0)
261 initialiseNavigationComboArrays()
262 PopulateLanguageCombo()
263 PopulateLocationCombo()
264 PopulateScriptList( languages(
0), locations(
0) )
265 PopulateTopLevelKeyBindingList()
266 bindingDialog.execute()
270 Sub initialiseNavigationComboArrays()
271 locations = Array (
"User
",
"Share
",
"Document
",
"Filesystem
" )
272 ReDim languages(
0) as String
273 ReDim extensions(
0) as Object
274 languages(
0) =
"Java
"
275 REM extensions(
0) =
""
277 ' Setup languages array for all supported languages
278 oServiceManager = GetProcessServiceManager()
279 svrArray = oServiceManager.getAvailableServiceNames
282 for index =
0 to ubound(svrArray)
283 iPos = inStr(svrArray(index),
"ScriptProviderFor
")
285 if (iPos
> 0) then
286 lang = Mid(svrArray(index), iPos + Len(
"ScriptProviderFor
")
288 if not (lang =
"Java
") then
289 'Add to language vector
290 ReDim Preserve languages(langCount) as String
291 languages(langCount) = lang
292 langCount = langCount +
1
296 initialiseFileExtensions()
300 Sub ExecuteEventBinding
301 dialogName =
"Event
"
302 createAllEventTypes()
303 createAllEventBindings()
305 'Populate application event bindings array (from config xml file)
306 if not (ReadXMLToArray(
"Event
" )) then
309 'Populate document event bindings array (using Office API calls)
312 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"EventsBinding
" )
313 initialiseNavigationComboArrays()
314 PopulateLanguageCombo()
315 PopulateLocationCombo()
316 PopulateScriptList( languages(
0), locations(
0) )
317 populateEventList(
0 )
319 bindingDialog.execute()
322 Sub ExecuteMenuBinding()
323 dialogName =
"Menu
"
324 xmlFileName = GetDocumentType(
"Menu
" )
325 if not (ReadXMLToArray(
"Menu
" )) then
329 bindingDialog = LoadDialog(
"ScriptBindingLibrary
",
"MenuBinding
" )
330 initialiseNavigationComboArrays()
331 PopulateLanguageCombo()
332 PopulateLocationCombo()
333 PopulateScriptList( languages(
0), locations(
0) )
335 PopulateSubMenuList(
1 )
337 subMenuList = bindingDialog.getControl(
"SubMenuList
")
339 subMenuList.selectItemPos(
0, true )
341 bindingDialog.execute()
345 REM ----- Initialising functions -----
348 function LoadDialog( libName as string, dialogName as string ) as object
349 dim library as object
350 dim libDialog as object
351 dim runtimeDialog as object
352 libContainer = DialogLibraries
353 libContainer.LoadLibrary( libName )
354 library = libContainer.getByName( libname )
355 libDialog = library.getByName( dialogName )
356 runtimeDialog = CreateUnoDialog( libDialog )
357 LoadDialog() = runtimeDialog
362 function GetDocumentType( bindingType as string ) as string
363 document = StarDesktop.ActiveFrame.Controller.Model
364 Dim errornumber As Integer
367 if document.SupportsService(
"com.sun.star.sheet.SpreadsheetDocument
") then
368 if bindingType =
"Key
" then
369 GetDocumentType() =
"calckeybinding.xml
"
371 if bindingType =
"Menu
" then
372 GetDocumentType() =
"calcmenubar.xml
"
375 elseif document.SupportsService(
"com.sun.star.text.TextDocument
") then
376 if bindingType =
"Key
" then
377 GetDocumentType() =
"writerkeybinding.xml
"
379 if bindingType =
"Menu
" then
380 GetDocumentType() =
"writermenubar.xml
"
383 elseif document.SupportsService(
"com.sun.star.presentation.PresentationDocument
") then
384 if bindingType =
"Key
" then
385 GetDocumentType() =
"impresskeybinding.xml
"
387 if bindingType =
"Menu
" then
388 GetDocumentType() =
"impressmenubar.xml
"
391 elseif document.SupportsService(
"com.sun.star.presentation.PresentationDocument
") then
392 if bindingType =
"Key
" then
393 GetDocumentType() =
"impresskeybinding.xml
"
395 if bindingType =
"Menu
" then
396 GetDocumentType() =
"impressmenubar.xml
"
399 elseif document.SupportsService(
"com.sun.star.drawing.DrawingDocument
") then
400 if bindingType =
"Key
" then
401 GetDocumentType() =
"drawkeybinding.xml
"
403 if bindingType =
"Menu
" then
404 GetDocumentType() =
"drawmenubar.xml
"
408 MsgBox (
"Error: Couldn
't determine configuration file type
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
412 function lastIndexOf( targetStr as String, substr as String ) as Integer
414 while instr(copyStr, substr)
> 0
415 pos = instr(copyStr, substr)
417 copyStr = mid(copyStr, pos+
1, len(copyStr)-pos )
422 function getScriptURI( selectedScript as String ) as String
423 combo = bindingDialog.getControl(
"LocationCombo
" )
424 location = combo.text
425 if ( location =
"User
" ) then
426 location =
"user
"
427 elseif ( location =
"Share
" ) then
428 location =
"share
"
429 elseif ( location =
"Filesystem
" ) then
430 location =
"filesystem
"
432 location =
"document
"
437 if ( location =
"filesystem
" ) then
438 REM need to build URI here - dcf
439 combo = bindingDialog.getControl(
"LanguageCombo
" )
440 language = combo.text
442 pos = lastIndexOf( url,
"/
" )
443 locationPath = mid( url,
1, pos)
444 url = mid( url, pos+
1, len( url ) - pos )
446 pos = lastIndexOf( url,
".
" )
447 logicalName = mid( url,
1, pos -
1 )
448 getScriptURI() =
"script://
" + logicalName +
"?language=
" _
449 + language +
"&amp;function=
" + functionName _
450 +
"&amp;location=filesystem:
" + locationPath
452 Dim scriptInfo as Object
453 scripts() = scriptDisplayList(
0)
454 for n = LBOUND( scripts() ) to UBOUND( scripts() )
456 if ( scripts( n ).Name = selectedScript ) then
457 scriptInfo = scripts( n ).Value
461 getScriptURI() =
"script://
" + scriptInfo.getLogicalName +
"?language=
" _
462 + scriptInfo.getLanguage() +
"&amp;function=
" + _
463 scriptInfo.getFunctionName() +
"&amp;location=
" + location
468 function GetOfficePath() as string
469 REM Error check and prompt user to manually input Office Path
470 settings = CreateUnoService(
"com.sun.star.frame.Settings
" )
471 path = settings.getByName(
"PathSettings
" )
472 unformattedOfficePath = path.getPropertyValue(
"UserPath
" )
474 dim officePath as string
475 const removeFromEnd =
"/user
"
476 const removeFromEndWindows =
"\user
"
478 REM If Solaris or Linux
479 if not ( instr( unformattedOfficePath, removeFromEnd ) =
0 ) then
480 endPosition = instr( unformattedOfficePath, removeFromEnd )
481 officePath = mid( unformattedOfficePath,
1, endPosition )
483 else if not ( instr( unformattedOfficePath, removeFromEndWindows ) =
0 ) then
484 endPosition = instr( unformattedOfficePath, removeFromEndWindows )
485 officePath = mid( unformattedOfficePath,
1, endPosition )
486 while instr( officePath,
"\
" )
> 0
487 backSlash = instr( officePath,
"\
" )
488 startPath = mid( officePath,
1, backSlash -
1 )
489 endPath = mid( officePath, backslash +
1, len( officePath ) - backSlash )
490 officePath = startPath +
"/
" + endPath
493 MsgBox (
"Error: Office path not found
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
498 GetOfficePath() = officePath
503 REM ----- File I/O functions -----
506 function ReadXMLToArray( bindingType as string ) as boolean
507 On Error Goto ErrorHandler
508 if ( bindingType =
"Event
" ) then
509 xmlfilename =
"eventbindings.xml
"
512 simplefileaccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
513 filestream = simplefileaccess.openFileRead(
"file://
" + GetOfficePath() +
"user/config/soffice.cfg/
" + xmlFileName )
515 textin = CreateUnoService(
"com.sun.star.io.TextInputStream
" )
516 textin.setInputStream( filestream )
518 redim xmlFile(
400 ) as String
519 redim menuItems(
30 ) as String
520 redim menuItemLinePosition(
30 ) as Integer
521 redim scriptNames(
120 ) as string
522 redim scriptLinePosition(
120) as integer
528 do while not textin.isEOF()
529 xmlline = textin.readLine()
530 xmlFile( lineCount ) = xmlline
532 const menuItemWhiteSpace =
2
533 const menuXMLTag =
"<menu:menu
"
535 if bindingType =
"Menu
" then
536 evaluateForMenu( xmlline, lineCount )
537 elseif bindingType =
"Key
" then
538 processKeyXMLLine( lineCount, xmlline )
539 elseif bindingType =
"Event
" then
540 evaluateForEvent( xmlline, lineCount )
542 MsgBox (
"Error: Couldn
't determine file type
" + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
544 lineCount = lineCount +
1
547 'Set global variable numberOfLines (lineCount is one too many at end of the loop)
548 numberOfLines = lineCount -
1
549 'Set global variable menuCount (it is one too many at end of the loop)
550 menuCount = menuCount -
1
552 filestream.closeInput()
553 ReadXMLToArray( ) = true
558 MsgBox (
"Error: Unable to read Star Office configuration file -
" + xmlFileName + chr$(
10) + chr$(
10) +
"Action: Please reinstall Scripting Framework
",
0,
"Error
" )
559 ReadXMLToArray( ) = false
564 sub evaluateForMenu( xmlline as string, lineCount as integer )
565 const menuItemWhiteSpace =
2
566 const menuXMLTag =
"<menu:menu
"
567 'If the xml line is a top-level menu
568 if instr( xmlline, menuXMLTag ) = menuItemWhiteSpace then
569 menuLabel = ExtractLabelFromXMLLine( xmlline )
570 menuItems( menuCount ) = menuLabel
571 menuItemLinePosition( menuCount ) = lineCount
572 menuCount = menuCount +
1
576 sub evaluateForEvent( xmlline as string, lineCount as integer )
577 dim eventName as String
578 'if the xml line identifies a script or SB macro
579 dim scriptName as string
580 dim lineNumber as integer
581 if instr( xmlline,
"event:language=
" + chr$(
34) +
"Script
" )
> 0 then
582 eventName = ExtractEventNameFromXMLLine( xmlline )
583 scriptName = ExtractEventScriptFromXMLLine( xmlline )
584 lineNumber = lineCount
585 elseif instr( xmlline,
"event:language=
" + chr$(
34) +
"StarBasic
" )
> 0 then
586 eventName = ExtractEventNameFromXMLLine( xmlline )
587 scriptName =
"Allocated to Office function
"
591 'Need to sequence to find the corresponding index for the event type
592 for n =
0 to ubound( allEventTypesApp() )
593 if ( eventName = allEventTypes( n ).Name ) then
594 allEventTypesApp( n ).Name = scriptName
595 allEventTypesApp( n ).Value = lineNumber
601 function isOKscriptProps( props() as Object, eventName as string ) as Boolean
602 On Error Goto ErrorHandler
603 props = ThisComponent.getEvents().getByName( eventName )
604 test = ubound( props() )
605 isOKscriptProps() = true
609 isOKscriptProps() = false
612 sub ReadEventsFromDoc()
613 On Error Goto ErrorHandler
615 eventSupplier = ThisComponent
616 for n =
0 to ubound( allEventTypes() )
617 Dim scriptProps() as Object
618 if (isOKscriptProps( scriptProps(), allEventTypes( n ).Name) ) then
619 if ( ubound( scriptProps )
> 0 ) then
620 if ( scriptProps(
0).Value =
"Script
" ) then
622 allEventTypesDoc(n).Name = scriptProps(
1).Value
623 allEventTypesDoc(n).value =
2
624 elseif( scriptProps(
0).Value =
"StarBasic
" ) then
625 'StarBasic macro
626 allEventTypesDoc(n).Name =
"Allocated to Office function
"
627 allEventTypesDoc(n).value =
1
635 ' eventProps is undefined if there are no event bindings in the doc
641 sub WriteEventsToDoc()
642 On Error Goto ErrorHandler
644 eventSupplier = ThisComponent
645 for n =
0 to ubound( allEventTypes() )
646 scriptName = allEventTypesDoc( n ).Name
647 eventName = allEventTypes( n ).Name
648 if( allEventTypesDoc( n ).Value
> 1 ) then
'script
650 AddEventToDocViaAPI( scriptName, eventName )
651 elseif( allEventTypesDoc( n ).Value =
0 ) then
'blank (this will
"remove
" already blank entries)
652 'remove from doc
653 RemoveEventFromDocViaAPI( eventName )
655 'Otherwise it is a StarBasic binding - leave alone
657 'Mark document as modified ( should happen automatically as a result of calling the API )
658 ThisComponent.CurrentController.getModel().setModified( True )
663 msgbox(
"Error calling UNO API for writing event bindings to the document
" )
667 sub RemoveEventFromDocViaAPI( event as string )
668 dim document as object
669 dim dispatcher as object
671 dim url as new com.sun.star.util.URL
673 document = ThisComponent.CurrentController.Frame
674 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
675 dim args(
0) as new com.sun.star.beans.PropertyValue
676 args(
0).Name =
""
677 args(
0).Value = event
679 url.Complete =
"script://_$ScriptFrmwrkHelper.removeEvent?
" _
680 +
"language=Java
&function=ScriptFrmwrkHelper.removeEvent
" _
681 +
"&location=share
"
683 parser.parseStrict(url)
684 disp = document.queryDispatch(url,
"",
0)
685 disp.dispatch(url,args())
689 sub AddEventToDocViaAPI( scriptName as string, eventName as string )
690 dim properties(
1 ) as new com.sun.star.beans.PropertyValue
691 properties(
0 ).Name =
"EventType
"
692 properties(
0 ).Value =
"Script
"
693 properties(
1 ).Name =
"Script
"
694 properties(
1 ).Value = scriptName
696 eventSupplier = ThisComponent
697 nameReplace = eventSupplier.getEvents()
698 nameReplace.replaceByName( eventName, properties() )
702 ' returns
0 for Fkey
706 function getKeyTypeOffset( key as String ) as integer
708 if ( length
> 1 ) then
709 getKeyTypeOffset() =
0
711 elseif ( key
>=
"0" AND key
<=
"9" ) then
712 getKeyTypeOffset() =
1
714 getKeyTypeOffset() =
2
718 function getKeyGroupIndex( key as String, offset as Integer ) as Integer
719 ' Keys we are interested in are A - Z, F2 - F12,
0 -
9 anything else should
720 ' ensure -
1 is returned
721 cutKey = mid( key,
2 )
723 if ( cutKey
<> "" ) then
724 acode = asc ( mid( cutKey,
1,
1) )
725 if ( acode
> 57 ) then
726 getKeyGroupIndex() = -
1
734 getKeyGroupIndex() = num -
1
737 num = asc( key ) -
48
738 getKeyGroupIndex() = num
741 num = asc( key ) -
65
742 getKeyGroupIndex() = num
745 getKeyGroupIndex() = -
1
748 Sub processKeyXMLLine( lineCount as Integer, xmlline as String )
750 if instr( xmlline,
"<accel:item
" )
> 0 then
753 if instr( xmlline,
"accel:shift=
"+chr$(
34)+
"true
"+chr$(
34) )
> 0 then
756 if instr( xmlFile( lineCount ),
"accel:mod1=
"+chr$(
34)+
"true
"+chr$(
34) )
> 0 then
759 offsetIntoArrayOfArrays = -
1 'default unknown
760 if ( control AND shift ) then
761 offsetIntoArrayOfArrays =
0
762 elseif ( control ) then
763 offsetIntoArrayOfArrays =
3
764 elseif ( shift ) then
765 offsetIntoArrayOfArrays =
6
767 ' Calculate which of the
7 key group arrays we need to point to
768 key = ExtractKeyCodeFromXMLLine( xmlline )
769 keyTypeOffset = getKeyTypeOffset( key )
770 offsetIntoArrayOfArrays = offsetIntoArrayOfArrays + keyTypeOffset
772 ' Calculate from the key the offset into key group array we need to point to
773 KeyGroupIndex = getKeyGroupIndex( key, keyTypeOffset )
774 if ( offsetIntoArrayOfArrays = -
1 ) then
775 'Unknown key group, no processing necessary
778 if ( KeyGroupIndex
> -
1 ) then
780 ' Determine if a script framework binding is present or not
781 if instr( xmlline,
"script://
" )
> 0 then
782 ' its one of ours so update its details
783 scriptName = ExtractScriptIdFromXMLLine( xmlline )
785 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value = lineCount
786 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
788 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value =
1
789 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name =
""
796 Sub WriteXMLFromArray()
797 On Error Goto ErrorHandler
798 cfgFile = GetOfficePath() +
"user/config/soffice.cfg/
" + xmlFileName
799 updateCfgFile( cfgFile )
800 'if ( false ) then
' config stuff not in build yet
802 updateConfig( xmlFileName )
804 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
" )
810 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
" )
814 Sub UpdateCfgFile ( fileName as String )
815 dim ScriptProvider as Object
818 dim displayDialogFlag as boolean
819 displayDialogFlag = false
820 args(
0) = ThisComponent
821 args(
1) = displayDialogFlag
823 ScriptProvider = createUnoService(
"drafts.com.sun.star.script.framework.provider.MasterScriptProvider
")
824 ScriptProvider.initialize( args() )
825 Script = ScriptProvider.getScript(
"script://_$ScriptFrmwrkHelper.updateCfgFile?
" _
826 +
"language=Java
&function=ScriptFrmwrkHelper.updateCfgFile
&location=share
")
830 dim localNumLines as integer
832 inArgs(
0) = xmlFile()
834 inArgs(
2) = numberOfLines
835 Script.invoke( inArgs(), outIndex(), outArgs() )
838 sub UpdateConfig( a$ )
839 dim document as object
840 dim dispatcher as object
843 dim url as new com.sun.star.util.URL
844 document = ThisComponent.CurrentController.Frame
845 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
846 dim args1(
0) as new com.sun.star.beans.PropertyValue
847 args1(
0).Name =
"StreamName
"
849 url.Complete =
".uno:UpdateConfiguration
"
850 parser.parseStrict(url)
851 disp = document.queryDispatch(url,
"",
0)
852 disp.dispatch(url,args1())
857 sub AddNewEventBinding( scriptName as string, eventPosition as integer, isApp as boolean )
858 event = allEventTypes( eventPosition ).Name
859 'dim scriptProp as new com.sun.star.beans.PropertyValue
861 'scriptProp.Name = scriptName
862 'scriptProp.Value = numberOfLines
863 allEventTypesApp( eventPosition ).Name = scriptName
864 allEventTypesApp( eventPosition ).Value = numberOfLines
866 newline =
" <event:event event:name=
" + chr$(
34) + event + chr$(
34)
867 newline = newline +
" event:language=
" + chr$(
34) +
"Script
" + chr$(
34) +
" xlink:href=
" + chr$(
34)
868 newline = newline + scriptName + chr$(
34) +
" xlink:type=
" + chr$(
34) +
"simple
" + chr$(
34) +
"/
>"
869 xmlFile( numberOfLines ) = newline
870 xmlFile( numberOfLines +
1 ) =
"</event:events
>"
871 numberOfLines = numberOfLines +
1
873 'scriptProp.Name = scriptName
874 'scriptProp.Value =
2
875 allEventTypesDoc( eventPosition ).Name = scriptName
876 allEventTypesDoc( eventPosition ).Value =
2
880 REM ----- Array update functions -----
883 sub AddNewMenuBinding( newScript as string, newMenuLabel as string, newLinePosition as integer )
884 dim newXmlFile(
400 ) as string
885 dim newLineInserted as boolean
886 dim lineCounter as integer
889 do while lineCounter
<= numberOfLines
890 if not newLineInserted then
891 REM If the line number is the position at which to insert the new line
892 if lineCounter = newLinePosition then
893 if( instr( xmlFile( lineCounter ),
"<menu:menupopup
>" )
> 0 ) then
894 indent = GetMenuWhiteSpace( xmlFile( newLinePosition +
1 ) )
895 newXmlFile( lineCounter ) = xmlFile( lineCounter )
896 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)+
"/
>" )
898 indent = GetMenuWhiteSpace( xmlFile( newLinePosition -
1 ) )
899 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)+
"/
>" )
900 newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
902 REM added -
1 for debug --
>
903 ' indent = GetMenuWhiteSpace( xmlFile( newLinePosition ) )
904 ' 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)+
"/
>" )
905 ' newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
906 newLineInserted = true
908 newXmlFile( lineCounter ) = xmlFile( lineCounter )
911 REM if the new line has been inserted the read from one position behind
912 newXmlFile( lineCounter +
1 ) = xmlFile( lineCounter )
914 lineCounter = lineCounter +
1
917 numberOfLines = numberOfLines +
1
919 REM read the new file into the global array
920 for n =
1 to numberOfLines
921 xmlFile( n ) = newXmlFile( n )
927 sub AddNewKeyBinding( scriptName as string, shift as boolean, control as boolean, key as string )
929 dim keyCombo as string
930 newLine =
" <accel:item accel:code=
"+chr$(
34)+
"KEY_
" + key +chr$(
34)
932 keyCombo =
"SHIFT +
"
933 newLine = newLine +
" accel:shift=
"+chr$(
34)+
"true
"+chr$(
34)
936 keyCombo = keyCombo +
"CONTROL +
"
937 newLine = newLine +
" accel:mod1=
"+chr$(
34)+
"true
"+chr$(
34)
939 keyCombo = keyCombo + key
940 newLine = newLine +
" xlink:href=
"+chr$(
34)+ scriptName +chr$(
34) +
"/
>"
942 if ( control AND shift ) then
943 offsetIntoArrayOfArrays =
0
944 elseif ( control ) then
945 offsetIntoArrayOfArrays =
3
946 elseif ( shift ) then
947 offsetIntoArrayOfArrays =
6
950 keyTypeOffset = getKeyTypeOffset( key )
951 offsetIntoArrayOfArrays = offsetIntoArrayOfArrays + keyTypeOffset
952 ' Calculate from the key the offset into key group array we need to point to
953 KeyGroupIndex = getKeyGroupIndex( key, keyTypeOffset )
955 ' if key is allready allocated to a script then just reallocate
956 if ( keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value
> 1 ) then
958 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
959 'replace line in xml file
960 xmlFile( keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value ) = newLine
962 ' this is a new binding, create a new line in xml file
963 for n =
1 to numberOfLines
964 if n = numberOfLines then
965 xmlFile( n ) = newLine
966 xmlFile( n +
1 ) =
"</accel:acceleratorlist
>"
969 xmlFile( n ) = xmlFile( n )
973 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Value = n
974 keyAllocationMap( offsetIntoArrayOfArrays, KeyGroupIndex ).Name = scriptName
975 numberOfLines = numberOfLines +
1
981 Sub RemoveBinding( lineToRemove as Integer )
982 xmlFile( lineToRemove ) =
""
985 REM Adds or removes the starting xml line positions for each top-level menu after the menu with the added script
986 sub UpdateTopLevelMenus( topLevelMenuPosition as integer, addLine as boolean )
987 for n = topLevelMenuPosition to
8
989 menuItemLinePosition( n ) = menuItemLinePosition( n ) +
1
996 REM Remove scriptNames and scriptLinePosition entries
997 sub RemoveScriptNameAndPosition( keyComboPosition )
998 dim updatedScriptNames(
120 ) as string
999 dim updatedScriptLinePosition(
120 ) as integer
1000 dim removedScript as boolean
1001 removedScript = false
1003 for n =
1 to scriptCount
1004 if not removedScript then
1005 if not( n = keyComboPosition ) then
1006 updatedScriptNames( n ) = scriptNames( n )
1008 removedScript = true
1011 updatedScriptNames( n -
1 ) = scriptNames( n )
1014 scriptCount = scriptCount -
1
1016 for n =
1 to scriptCount
1017 scriptNames( n ) = updatedScriptNames( n )
1023 REM ----- Populating Dialog Controls -----
1025 Sub PopulateLanguageCombo()
1026 langCombo = bindingDialog.getControl(
"LanguageCombo
" )
1027 langCombo.removeItems(
0, langCombo.getItemCount() )
1028 for n = LBOUND( languages() ) to UBOUND ( languages() )
1029 langCombo.addItem( languages( n ), n )
1031 langCombo.setDropDownLineCount( n )
1032 langCombo.text = langCombo.getItem(
0 )
1035 Sub PopulateLocationCombo()
1036 dim ScriptProvider as Object
1038 dim displayDialogFlag as boolean
1039 displayDialogFlag = false
1040 args(
0) = ThisComponent
1041 args(
1) = displayDialogFlag
1043 ScriptProvider = createUnoService(
"drafts.com.sun.star.script.framework.provider.MasterScriptProvider
")
1044 ScriptProvider.initialize( args() )
1046 locCombo = bindingDialog.getControl(
"LocationCombo
" )
1047 locCombo.removeItems(
0, locCombo.getItemCount() )
1048 for n = LBOUND( locations() ) to UBOUND ( locations() )
1049 locCombo.addItem( locations( n ), n )
1051 locCombo.setDropDownLineCount( n )
1052 locCombo.text = locCombo.getItem(
0 )
1055 sub PopulateScriptList( lang as String, loc as String )
1056 Dim detailedView as boolean
1057 detailedView = bindingDialog.Model.detail.state
1058 scriptList = bindingDialog.getControl(
"ScriptList
" )
1059 scriptList.removeItems(
0, scriptList.getItemCount() )
1061 smgr = getProcessServiceManager()
1062 context = smgr.getPropertyValue(
"DefaultContext
" )
1063 scriptstoragemgr = context.getValueByName(
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager
" )
1064 scriptLocationURI =
"USER
"
1065 if ( loc =
"Share
" ) then
1066 scriptLocationURI =
"SHARE
"
1067 elseif ( loc =
"Document
" )then
1068 document = StarDesktop.ActiveFrame.Controller.Model
1069 scriptLocationURI = document.getURL()
1070 elseif ( loc =
"Filesystem
" ) then
1071 REM populate the list from the filesysScripts list
1072 if(lang =
"Java
" ) then
1075 length = UBOUND( filesysScripts() )
1076 if(length = -
1) then
1079 for langIndex = lbound(languages()) to ubound(languages())
1080 if ( lang = languages(langIndex)) then
1081 extns = extensions(langIndex)
1085 dim locnDisplayList( length ) as new com.sun.star.beans.PropertyValue
1086 for index = lbound(filesysScripts()) to ubound(filesysScripts())
1087 scriptextn = filesysScripts( index )
1088 pos = lastIndexOf( scriptextn,
".
" )
1089 scriptextn = mid( scriptextn, pos +
1, len( scriptextn ) - pos )
1091 for extnsIndex = lbound(extns()) to ubound(extns())
1092 extn = extns(extnsIndex)
1093 if ( scriptextn = extn ) then
1094 if ( detailedView ) then
1095 locnDisplayList( index ).Name = filesysScripts( index )
1096 locnDisplayList( index ).Value = filesysScripts( index )
1098 REM replace name with simplified view
1099 locnDisplayList( index ).Name = filesysScripts( index )
1100 locnDisplayList( index ).Value = filesysScripts( index )
1102 scriptList.addItem( locnDisplayList( index ).Name, index )
1107 ScriptDisplayList(
0) = locnDisplayList()
1108 scriptList.selectItemPos(
0, true )
1110 REM !!!!At this point we exit the sub!!!!
1115 scriptStorageID = scriptstoragemgr.getScriptStorageID( scriptLocationURI )
1116 dim resultList() as Object
1117 if ( scriptStorageID
> -
1 ) then
1118 storage = scriptstoragemgr.getScriptStorage( scriptStorageID )
1119 implementations() = storage.getAllImplementations()
1120 length = UBOUND( implementations() )
1121 reservedScriptTag =
"_$
"
1122 if ( length
> -
1 ) then
1123 dim tempDisplayList( length ) as new com.sun.star.beans.PropertyValue
1124 for n = LBOUND( implementations() ) to UBOUND( implementations() )
1125 logicalName = implementations( n ).getLogicalName()
1126 firstTwoChars = LEFT( logicalName,
2 )
1127 'Only display scripts whose logicalnames don
't begin with
"_$
"
1128 if ( firstTwoChars
<> reservedScriptTag ) then
1129 if ( lang = implementations( n ).getLanguage() ) then
1130 if ( detailedView ) then
1131 tempDisplayList( n ).Name = logicalName _
1132 +
" [
" + implementations( n ).getFunctionName() +
"]
"
1133 tempDisplayList( n ).Value = implementations( n )
1135 tempDisplayList( n ).Name = logicalName
1136 tempDisplayList( n ).Value = implementations( n )
1138 scriptList.addItem( tempDisplayList( n ).Name, n )
1142 resultList = tempDisplayList()
1144 ScriptDisplayList(
0) = resultList()
1146 scriptList.selectItemPos(
0, true )
1150 sub PopulateMenuCombo()
1151 menuComboBox = bindingDialog.getControl(
"MenuCombo
" )
1152 menuComboBox.removeItems(
0, menuComboBox.getItemCount() )
1153 for n =
1 to menuCount
1154 menuComboBox.addItem( menuItems( n ), n -
1 )
1156 menuComboBox.setDropDownLineCount(
8 )
1157 menuComboBox.text = menuComboBox.getItem(
0 )
1161 sub PopulateSubMenuList( menuItemPosition as integer )
1162 redim subMenuItems(
100 ) as string
1163 redim subMenuItemLinePosition(
100 ) as integer
1164 dim lineNumber as integer
1165 const menuItemWhiteSpace =
4
1166 const menuXMLTag =
"<menu:menu
"
1169 REM xmlStartLine and xmlEndLine refer to the first and last lines
1170 ' menuItemPosition of a top-level menu (
1=File to
8=Help ) add one line
1171 xmlStartLine = menuItemLinePosition( menuItemPosition ) +
1
1173 REM If last menu item is chosen
1174 if menuItemPosition = menuCount then
1175 xmlEndLine = numberOfLines
1177 REM Other wise get the line before the next top-level menu begins
1178 xmlEndLine = menuItemLinePosition( menuItemPosition +
1 ) -
1
1181 for lineNumber = xmlStartLine to xmlEndLine
1182 REM Insert all sub-menus and sub-popupmenus
1183 if not( instr( xmlFile( lineNumber ), menuXMLTag ) =
0 ) and instr( xmlFile( lineNumber ),
"menupopup
") =
0 then
1184 subMenuIndent = GetMenuWhiteSpace( xmlFile( lineNumber ) )
1185 if subMenuIndent =
" " then
1186 subMenuIndent =
""
1188 subMenuIndent = subMenuIndent + subMenuIndent
1190 if not( instr( xmlFile( lineNumber ),
"menuseparator
" ) =
0 ) then
1191 subMenuItems( subMenuCount ) = subMenuIndent +
"----------------
"
1193 subMenuName = ExtractLabelFromXMLLine( xmlFile( lineNumber ) )
1194 REM Add script Name if there is one bound to menu item
1195 if instr( xmlFile( lineNumber ),
"script://
" )
> 0 then
1196 script = ExtractScriptIdFromXMLLine( xmlFile( lineNumber ) )
1197 subMenuItems( subMenuCount ) = ( subMenuIndent + subMenuName +
" [
" + script +
"]
" )
1199 subMenuItems( subMenuCount ) = subMenuIndent + subMenuName
1202 subMenuItemLinePosition( subMenuCount ) = lineNumber
1203 subMenuCount = subMenuCount +
1
1207 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1209 currentPosition = subMenuList.getSelectedItemPos()
1211 subMenuList.removeItems(
0, subMenuList.getItemCount() )
1212 'If there are no sub-menus i.e. a dynamically generated menu like Format
1213 'if subMenuCount =
1 then
1214 if menuItems( menuItemPosition ) =
"Format
" then
1215 subMenuList.addItem(
"Unable to Assign Scripts to this menu
",
0 )
1217 for n =
1 to subMenuCount -
1
1218 subMenuList.addItem( subMenuItems( n ), n -
1 )
1222 subMenuList.selectItemPos( currentPosition, true )
1224 SubMenuListListener()
1225 MenuLabelBoxListener()
1230 sub PopulateTopLevelKeyBindingList()
1232 allKeyGroupsArray(
0) =
"SHIFT + CONTROL + F keys
"
1233 allKeyGroupsArray(
1) =
"SHIFT + CONTROL + digits
" ' CURRENTLY DISABLED
1234 allKeyGroupsArray(
2) =
"SHIFT + CONTROL + letters
"
1235 allKeyGroupsArray(
3) =
"CONTROL + F keys
"
1236 allKeyGroupsArray(
4) =
"CONTROL + digits
"
1237 allKeyGroupsArray(
5) =
"CONTROL + letters
"
1238 allKeyGroupsArray(
6) =
"SHIFT + F keys
"
1240 keyCombo = bindingDialog.getControl(
"KeyCombo
" )
1241 keyCombo.removeItems(
0, keyCombo.getItemCount() )
1243 for n = LBOUND( allKeyGroupsArray() ) to UBOUND( allKeyGroupsArray() )
1244 ' SHIFT + CONTROL + digits group is disabled at the moment, so skip
1246 if ( n
<> 1 ) then
1247 keyCombo.addItem( allKeyGroupsArray( n ), pos )
1251 keyCombo.text = keyCombo.getItem(
0 )
1254 sub PopulateKeyBindingList( keyGroupIndex as Integer )
1255 keyList = bindingDialog.getControl(
"KeyList
" )
1256 selectedPos = keyList.getSelectedItemPos()
1257 keyList.removeItems(
0, keyList.getItemCount() )
1259 ShortCutKeyArray() = KeyBindArrayOfArrays( keyGroupIndex )
1261 Dim keyProp as new com.sun.star.beans.PropertyValue
1262 for n = lbound( ShortCutKeyArray() ) to ubound( ShortCutKeyArray() )
1263 keyName = ShortCutKeyArray( n )
1264 if ( keyAllocationMap( keyGroupIndex, n ).Value =
1 ) then
1265 keyName = keyName +
" [Allocated to Office function]
"
1267 elseif ( keyAllocationMap( keyGroupIndex, n ).Value
> 1 ) then
1268 keyName = keyName +
" " + keyAllocationMap( keyGroupIndex, n ).Name
1270 keyList.addItem( keyName, n )
1273 if ( selectedPos
<> -
1 )then
1274 keyList.selectItemPos( selectedPos, true )
1276 keyList.selectItemPos(
0, true )
1281 sub populateEventList( focusPosition as integer )
1282 allApps = bindingDialog.getControl(
"AllAppsOption
" )
1283 eventList = bindingDialog.getControl(
"EventList
" )
1284 eventList.removeItems(
0, eventList.getItemCount() )
1286 dim isApp as boolean
1287 if allApps.state = true then
' Application event
1293 ' use allEventTypes() to fill list box
1294 ' for each element compare with allEventTypesApp
1295 dim scriptName as string
1296 dim lineNumber as integer
1297 for n =
0 to ubound( allEventTypes() )
1298 ' If the line number is
1 then SB macro
1299 ' more than
1 it is the line number of the script
1300 if isApp and n
> 12 then
1304 lineNumber = allEventTypesApp( n ).Value
1305 scriptName = allEventTypesApp( n ).Name
1307 lineNumber = allEventTypesDoc( n ).Value
1308 scriptName = allEventTypesDoc( n ).Name
1310 stringToAdd =
""
1311 if ( lineNumber
>=
1 ) then
1312 stringToAdd =
" [
" + scriptName +
"]
"
1314 eventList.addItem( allEventTypes( n ).Value +
" " + stringToAdd, n )
1317 eventList.selectItemPos( focusPosition, true )
1322 sub CreateAllKeyBindings()
1323 reDim allKeyBindings(
105 ) as string
1324 keyBindingPosition =
1
1327 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL + F
" + FKey
1328 keyBindingPosition = keyBindingPosition +
1
1331 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL +
" + Digit
1332 keyBindingPosition = keyBindingPosition +
1
1334 for Alpha =
65 to
90
1335 allKeyBindings( keyBindingPosition ) =
"SHIFT + CONTROL +
" + chr$( Alpha )
1336 keyBindingPosition = keyBindingPosition +
1
1340 allKeyBindings( keyBindingPosition ) =
"CONTROL + F
" + FKey
1341 keyBindingPosition = keyBindingPosition +
1
1344 allKeyBindings( keyBindingPosition ) =
"CONTROL +
" + Digit
1345 keyBindingPosition = keyBindingPosition +
1
1347 for Alpha =
65 to
90
1348 allKeyBindings( keyBindingPosition ) =
"CONTROL +
" + chr$( Alpha )
1349 keyBindingPosition = keyBindingPosition +
1
1353 allKeyBindings( keyBindingPosition ) =
"SHIFT + F
" + FKey
1354 keyBindingPosition = keyBindingPosition +
1
1359 sub createAllEventTypes()
1360 allEventTypes(
0 ).Name =
"OnStartApp
"
1361 allEventTypes(
0 ).Value =
"Start Application
"
1362 allEventTypes(
1 ).Name =
"OnCloseApp
"
1363 allEventTypes(
1 ).Value =
"Close Application
"
1364 allEventTypes(
2 ).Name =
"OnNew
"
1365 allEventTypes(
2 ).Value =
"Create Document
"
1366 allEventTypes(
3 ).Name =
"OnLoad
"
1367 allEventTypes(
3 ).Value =
"Open Document
"
1368 allEventTypes(
4 ).Name =
"OnSaveAs
"
1369 allEventTypes(
4 ).Value =
"Save Document As
"
1370 allEventTypes(
5 ).Name =
"OnSaveAsDone
"
1371 allEventTypes(
5 ).Value =
"Document has been saved as
"
1372 allEventTypes(
6 ).Name =
"OnSave
"
1373 allEventTypes(
6 ).Value =
"Save Document
"
1374 allEventTypes(
7 ).Name =
"OnSaveDone
"
1375 allEventTypes(
7 ).Value =
"Document has been saved
"
1376 allEventTypes(
8 ).Name =
"OnPrepareUnload
"
1377 allEventTypes(
8 ).Value =
"Close Document
"
1378 allEventTypes(
9 ).Name =
"OnUnload
"
1379 allEventTypes(
9 ).Value =
"Close Document
"
1380 allEventTypes(
10 ).Name =
"OnFocus
"
1381 allEventTypes(
10 ).Value =
"Activate document
"
1382 allEventTypes(
11 ).Name =
"OnUnfocus
"
1383 allEventTypes(
11 ).Value =
"DeActivate document
"
1384 allEventTypes(
12 ).Name =
"OnPrint
"
1385 allEventTypes(
12 ).Value =
"Print Document
"
1386 REM The following are document-only events
1387 allEventTypes(
13 ).Name =
"OnMailMerge
"
1388 allEventTypes(
13 ).Value =
"Print form letters
"
1389 allEventTypes(
14 ).Name =
"OnPageCountChange
"
1390 allEventTypes(
14 ).Value =
"Changing the page count
"
1394 sub createAllEventBindings()
1395 'dim props as new com.sun.star.beans.PropertyValue
1396 'props.Name =
"" 'Name = script name
1397 'props.Value =
0 'Value =
0 for empty,
1 for macro, linenumber for script
1399 ' Creates all types of event bindings for both Application and Document
1400 ' Initially both arrays have no bindings allocated to the events
1401 ' The value for Doc is only Script/macro name (no need for line number)
1402 for n =
0 to ubound( allEventTypes() )
1403 allEventTypesApp( n ).Name =
""
1404 allEventTypesApp( n ).Value =
0
1405 allEventTypesDoc( n ).Name =
""
1406 allEventTypesDoc( n ).Value =
0
1411 REM ----- Text Handling Functions -----
1414 function ExtractLabelFromXMLLine( XMLLine as string ) as string
1415 labelStart = instr( XMLLine,
"label=
"+chr$(
34)) +
7
1416 labelEnd = instr( XMLLine, chr$(
34)+
">" )
1417 if labelEnd =
0 then
1418 labelEnd = instr( XMLLine, chr$(
34)+
"/
>" )
1420 labelLength = labelEnd - labelStart
1422 menuLabelUnformatted = mid( XMLLine, labelStart, labelLength )
1423 tildePosition = instr( menuLabelUnformatted,
"~
" )
1424 select case tildePosition
1426 menuLabel = menuLabelUnformatted
1428 menuLabel = right( menuLabelUnformatted, labelLength -
1 )
1430 menuLabelLeft = left( menuLabelUnformatted, tildePosition -
1 )
1431 menuLabelRight = right( menuLabelUnformatted, labelLength - tildePosition )
1432 menuLabel = menuLabelLeft + menuLabelRight
1435 ExtractLabelFromXMLLine() = menuLabel
1439 function ExtractScriptIdFromXMLLine( XMLLine as string ) as string
1440 idStart = instr( XMLLine,
"script://
") +
9
1441 if instr( XMLLine, chr$(
34)+
" menu:helpid=
" ) =
0 then
1442 idEnd = instr( XMLLIne,
"?location=
" )
1444 idEnd = instr( XMLLine,
""+chr$(
34)+
" menu:helpid=
" )
1446 idLength = idEnd - idStart
1447 scriptId = mid( XMLLine, idStart, idLength )
1449 ExtractScriptIdFromXMLLine() = scriptId
1452 function ExtractEventScriptFromXMLLine( xmlline as string )
1453 if instr( xmlline,
"script://
" )
> 0 then
1454 idStart = instr( xmlline,
"script://
") +
9
1455 idEnd = instr( xmlline, chr$(
34)+
" xlink:type=
" )
1456 idLength = idEnd - idStart
1457 scriptId = mid( xmlline, idStart, idLength )
1459 ExtractEventScriptFromXMLLine() = scriptId
1463 function ExtractEventNameFromXMLLine( xmlline as string )
1464 idStart = instr( xmlline,
"event:name=
" + chr$(
34) ) +
12
1465 idEnd = instr( xmlline, chr$(
34)+
" event:language
" )
1466 idLength = idEnd - idStart
1467 event = mid( xmlline, idStart, idLength )
1469 ExtractEventNameFromXMLLine() = event
1472 function ExtractKeyCodeFromXMLLine( XMLLine as string ) as string
1473 keyStart = instr( XMLLine,
"code=
"+chr$(
34)+
"KEY_
") +
10
1474 keyCode = mid( XMLLine, keyStart, ( len( XMLLine ) - keyStart ) )
1475 keyEnd = instr( keyCode, chr$(
34) )
1476 keyCode = mid( keyCode,
1, keyEnd -
1 )
1478 ExtractKeyCodeFromXMLLine() = keyCode
1482 function GetMenuWhiteSpace( MenuXMLLine as string ) as string
1483 whiteSpace =
""
1484 numberOfSpaces = instr( MenuXMLLine,
"<" ) -
1
1485 for i =
1 to numberOfSpaces
1486 whiteSpace = whiteSpace +
" "
1489 GetMenuWhiteSpace() = whiteSpace
1492 function IsAllocatedMenuItem( script as string ) as boolean
1493 foundMenuItem = false
1498 if strcomp( script, subMenuItems( count ) ) =
0 then
1499 foundMenuItem = true
1501 loop while not( foundMenuItem ) and count
< subMenuCount
1503 linePosition = subMenuItemLinePosition( count )
1505 if not( instr( xmlFile( linePosition ),
"script://
" ) =
0 ) then
1509 isAllocatedMenuItem() = Allocated
1513 function HasShiftKey( keyCombo ) as boolean
1514 if instr( keyCombo,
"SHIFT
" ) =
0 then
1520 HasShiftKey = hasShift
1524 function HasControlKey( keyCombo ) as boolean
1525 if instr( keyCombo,
"CONTROL
" ) =
0 then
1531 HasControlKey = hasControl
1535 function ExtractKeyFromCombo( keyString as string ) as string
1536 while not( instr( keyString,
"+
" ) =
0 )
1537 removeTo = instr( keyString,
"+
" ) +
2
1538 keyString = mid( keyString, removeTo, ( len( keyString ) - removeTo ) +
1 )
1540 ExtractKeyFromCombo() = keyString
1545 REM ------ Event Handling Functions (Listeners) ------
1548 sub KeyListListener()
1549 keyShortCutList = bindingDialog.getControl(
"KeyList
" )
1550 selectedShortCut = keyShortCutList.getSelectedItem()
1551 combo = bindingDialog.getControl(
"KeyCombo
" )
1553 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1554 selectedScript = menuScriptList.getSelectedItem()
1556 keyGroup = combo.text
1557 dim keyGroupIndex as Integer
1558 dim selectedKeyIndex as Integer
1559 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
1560 if ( allKeyGroupsArray( n ) = keyGroup )then
1565 selectedKeyIndex = keyShortCutList.getSelectedItemPos()
1567 if keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value
> 1 then
1568 bindingDialog.Model.Delete.enabled = true
1569 bindingDialog.Model.AddOn.enabled = true
1570 if selectedScript
<> "" then
1571 bindingDialog.Model.NewButton.enabled = true
1576 if keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value =
1 then
1577 bindingDialog.Model.Delete.enabled = false
1578 bindingDialog.Model.AddOn.enabled = false
1579 bindingDialog.Model.NewButton.enabled = false
1581 bindingDialog.Model.Delete.enabled = false
1582 bindingDialog.Model.AddOn.enabled = false
1583 if selectedScript
<> "" then
1584 bindingDialog.Model.NewButton.enabled = true
1591 sub SubMenuListListener()
1592 scriptList = bindingDialog.getControl(
"ScriptList
" )
1593 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1594 selectedMenuItem = subMenuList.getSelectedItem()
1595 if IsAllocatedMenuItem( selectedMenuItem ) then
1596 bindingDialog.Model.Delete.enabled = true
1597 bindingDialog.Model.AddOn.enabled = true
1599 bindingDialog.Model.Delete.enabled = false
1600 bindingDialog.Model.AddOn.enabled = false
1604 REM a keypress listener that in turn fires the MenuCL on a return key even only
1605 sub fireMenuComboListernerOnRet( eventobj as object )
1606 if (eventobj.KeyCode =
1280 ) then
1611 'Populates the SubMenuList with the appropriate menu items from the Top-level menu selected from the combo box
1612 sub MenuComboListener()
1613 combo = bindingDialog.getControl(
"MenuCombo
" )
1614 newToplevelMenu = combo.text
1617 counter = counter +
1
1618 loop while not( newToplevelMenu = menuItems( counter ) )
1620 PopulateSubMenuList( counter )
1623 REM a keypress listener that in turn fires the LLCL on a return key even only
1624 sub fireLangLocComboListernerOnRet( eventobj as object )
1625 if (eventobj.KeyCode =
1280 ) then
1626 LangLocComboListener()
1630 sub LangLocComboListener()
1632 combo = bindingDialog.getControl(
"LanguageCombo
" )
1633 language = combo.text
1634 combo = bindingDialog.getControl(
"LocationCombo
" )
1635 location = combo.text
1637 PopulateScriptList( language,location )
1639 'Enable/disable Assign button
1640 scriptList = bindingDialog.getControl(
"ScriptList
" )
1641 if not (dialogName =
"EditDebug
") then
1642 if scriptList.getSelectedItem() =
"" then
1643 bindingDialog.Model.NewButton.enabled = false
1647 if ( location =
"Filesystem
" ) and ( language
<> "Java
" ) then
1648 bindingDialog.Model.Browse.enabled = true
1649 if not (dialogName =
"EditDebug
") then
1650 bindingDialog.Model.fsonly.enabled = true
1653 bindingDialog.Model.Browse.enabled = false
1654 if not (dialogName =
"EditDebug
") then
1655 bindingDialog.Model.fsonly.enabled = false
1659 ' extra dialog dependant processing
1660 if dialogName =
"Menu
" then
1661 ' will set New button to false if no text in LableBox
1662 MenuLabelBoxListener()
1663 elseif dialogName =
"Key
" then
1664 ' will set Assigne button to false if appropriate
1666 elseif dialogName =
"Event
" then
1672 REM a keypress listener that in turn fires the KeyCL on a return key even only
1673 sub fireKeyComboListernerOnRet( eventobj as object )
1674 if (eventobj.KeyCode =
1280 ) then
1679 'Populates the KeyList with the appropriate key combos from the Top-level key group selected from the combo box
1680 sub KeyComboListener()
1681 combo = bindingDialog.getControl(
"KeyCombo
" )
1682 keyGroup = combo.text
1683 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
1684 if ( allKeyGroupsArray( n ) = keyGroup )then
1689 PopulateKeyBindingList( keyGroupIndex )
1693 sub MenuLabelBoxListener()
1694 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1695 selectedScript = menuScriptList.getSelectedItem()
1696 'if the SubMenuList is from a dynamically created menu (e.g. Format)
1697 'or if the Menu Label text box is empty
1698 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1699 firstItem = subMenuList.getItem(
0 )
1700 if bindingDialog.Model.MenuLabelBox.text =
"" OR firstItem =
"Unable to Assign Scripts to this menu
" OR selectedScript =
"" then
1701 bindingDialog.Model.NewButton.enabled = false
1703 bindingDialog.Model.NewButton.enabled = true
1707 sub AppDocEventListener()
1708 populateEventList(
0 )
1713 sub EventListListener()
1714 on error goto ErrorHandler
1716 eventList = bindingDialog.getControl(
"EventList
" )
1717 eventPos = eventList.getSelectedItemPos()
1719 allApps = bindingDialog.getControl(
"AllAppsOption
" )
1721 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1722 selectedScript = menuScriptList.getSelectedItem()
1724 dim binding as integer
1725 if allApps.state = true then
1726 binding = allEventTypesApp( eventPos ).Value
1728 binding = allEventTypesDoc( eventPos ).Value
1731 if ( binding
> 1 ) then
1732 bindingDialog.Model.Delete.enabled = true
1734 bindingDialog.Model.Delete.enabled = false
1737 if ( binding =
1 ) then
1738 ' staroffice binding, can
't assign
1739 bindingDialog.Model.NewButton.enabled = false
1740 elseif ( selectedScript
<> "" ) then
1741 bindingDialog.Model.NewButton.enabled = true
1747 bindingDialog.Model.Delete.enabled = false
1752 REM ------ Event Handling Functions (Buttons) ------
1754 function getFilePicker() as Object
1756 oFilePicker = CreateUnoService(
"com.sun.star.ui.dialogs.FilePicker
" )
1758 combo = bindingDialog.getControl(
"LanguageCombo
" )
1759 language = combo.text
1760 currentFilter =
""
1762 for langIndex =
0 to ubound(languages())
1763 if( languages(langIndex)
<> "Java
" ) then
1764 filterName = languages(langIndex) +
" (
"
1765 filterVal=
""
1766 extns = extensions(langIndex)
1767 for extnIndex = lbound(extns()) to ubound(extns())
1768 filterName = filterName +
"*.
" + extns(extnIndex) +
",
"
1769 filterVal = filterVal +
"*.
" + extns(extnIndex) +
",
"
1771 filterName = left(filterName, len(filterName) -
1) +
")
"
1772 filterVal = left(filterVal, len(filterVal) -
1)
1773 if(instr(filterName,language) =
1 ) then
1774 currentFilter = filterName
1776 oFilePicker.AppendFilter(filterName, filterVal)
1779 if(len(currentFilter)
> 0 ) then
1780 oFilePicker.SetCurrentFilter( currentFilter )
1783 If sFileURL =
"" Then
1784 oSettings = CreateUnoService(
"com.sun.star.frame.Settings
" )
1785 oPathSettings = oSettings.getByName(
"PathSettings
" )
1786 sFileURL = oPathSettings.getPropertyValue(
"Work
" )
1789 REM set display directory
1790 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1792 If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then
1793 oFilePicker.setDisplayDirectory( sFileURL )
1795 getFilePicker() = oFilePicker
1798 Sub DoBrowseAndEdit()
1799 Dim oFilePicker As Object, oSimpleFileAccess As Object
1800 Dim oSettings As Object, oPathSettings As Object
1801 Dim sFileURL As String
1802 Dim sFiles As Variant
1804 oFilePicker = getFilePicker()
1805 REM execute file dialog
1806 If oFilePicker.execute() Then
1807 sFiles = oFilePicker.getFiles()
1809 sFileURL = sFiles(
0)
1810 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1811 If oSimpleFileAccess.exists( sFileURL ) Then
1812 for langIndex =
0 to ubound(languages())
1813 If (instr(oFilePicker.GetCurrentFilter, languages(langIndex)) =
1 ) then
1814 RunDebugger(languages(langIndex), sFileURL,
"")
1818 bindingDialog.endExecute()
1822 Sub RunDebugger(lang as String, uri as String, filename as String)
1823 dim document as object
1824 dim dispatcher as object
1825 dim parser as object
1826 dim url as new com.sun.star.util.URL
1828 document = ThisComponent.CurrentController.Frame
1829 parser = createUnoService(
"com.sun.star.util.URLTransformer
")
1830 dim args(
2) as new com.sun.star.beans.PropertyValue
1831 args(
0).Name =
"language
"
1832 args(
0).Value = lang
1833 args(
1).Name =
"uri
"
1835 args(
2).Name =
"filename
"
1836 args(
2).Value = filename
1838 url.Complete =
"script://_$DebugRunner.Debug?
" _
1839 +
"language=Java
&function=DebugRunner.go
" _
1840 +
"&location=share
"
1842 parser.parseStrict(url)
1843 disp = document.queryDispatch(url,
"",
0)
1844 disp.dispatch(url, args())
1848 Dim scriptInfo as Object
1850 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1851 selectedScript = menuScriptList.getSelectedItem()
1853 if not (selectedScript =
"") then
1854 scripts() = scriptDisplayList(
0)
1855 for n = LBOUND( scripts() ) to UBOUND( scripts() )
1856 if ( scripts( n ).Name = selectedScript ) then
1857 scriptInfo = scripts( n ).Value
1862 RunDebugger(scriptInfo.getLanguage, scriptInfo.getParcelURI, scriptInfo.getFunctionName)
1863 bindingDialog.endExecute()
1869 bindingDialog.endExecute()
1873 sub MenuCancelButton()
1874 bindingDialog.endExecute()
1878 sub MenuHelpButton()
1879 helpDialog = LoadDialog(
"ScriptBindingLibrary
",
"HelpBinding
" )
1880 helpDialog.execute()
1884 sub MenuDeleteButton()
1885 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1886 linePos = subMenuItemLinePosition( subMenuList.getSelectedItemPos() +
1 )
1888 RemoveBinding( linePos )
1890 REM Update the top-level menu
's line positions
1891 combo = bindingDialog.getControl(
"MenuCombo
" )
1892 newToplevelMenu = combo.text
1895 counter = counter +
1
1896 loop while not( newToplevelMenu = menuItems( counter ) )
1897 UpdateTopLevelMenus( counter +
1, false )
1901 subMenuList.selectItemPos( subMenuList.getSelectedItemPos(), true )
1906 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1907 selectedScript = menuScriptList.getSelectedItem()
1908 scriptURI = getScriptURI( selectedScript )
1909 newMenuLabel = bindingDialog.Model.MenuLabelBox.text
1911 subMenuList = bindingDialog.getControl(
"SubMenuList
" )
1913 REM Update the top-level menu
's line positions
1914 combo = bindingDialog.getControl(
"MenuCombo
" )
1915 newToplevelMenu = combo.text
1918 counter = counter +
1
1919 loop while not( newToplevelMenu = menuItems( counter ) )
1920 UpdateTopLevelMenus( counter +
1, true )
1922 REM New line position is one ahead of the selected sub menu item
1923 linePos = subMenuItemLinePosition( subMenuList.getSelectedItemPos() +
1 ) +
1
1925 AddNewMenuBinding( scriptURI, newMenuLabel, linePos )
1928 subMenuList.selectItemPos( subMenuList.getSelectedItemPos() +
1, true )
1929 SubMenuListListener()
1933 Dim oFilePicker As Object, oSimpleFileAccess As Object
1934 Dim oSettings As Object, oPathSettings As Object
1935 Dim sFileURL As String
1936 Dim sFiles As Variant
1938 oFilePicker = getFilePicker()
1940 REM execute file dialog
1941 If oFilePicker.execute() Then
1942 sFiles = oFilePicker.getFiles()
1943 sFileURL = sFiles(
0)
1944 oSimpleFileAccess = CreateUnoService(
"com.sun.star.ucb.SimpleFileAccess
" )
1945 If oSimpleFileAccess.exists( sFileURL ) Then
1946 REM add sFileURL to the list
1947 ReDim preserve filesysScripts(filesysCount) as String
1948 filesysScripts( filesysCount ) = sFileURL
1949 filesysCount=filesysCount+
1
1950 ' if user changed filter in file picker then populate
1951 ' language with language associated with that in file picker
1952 sFilter = oFilePicker.getCurrentFilter()
1953 langCombo = bindingDialog.getControl(
"LanguageCombo
" )
1954 dim items() as String
1955 items() = langCombo.getItems()
1956 for index = lbound(items()) to ubound(items())
1957 iPos = inStr(sFilter,
" ")
1958 Dim theLanguage as String
1959 if( iPos
> 0 ) then
1960 theLanguage = Left( sFilter, iPos -
1)
1961 if ( theLanguage = items( index ) ) then
1962 langCombo.text = items( index )
1969 LangLocComboListener()
1974 bindingDialog.endExecute()
1978 sub KeyCancelButton()
1979 bindingDialog.endExecute()
1984 helpDialog = LoadDialog(
"ScriptBindingLibrary
",
"HelpBinding
" )
1985 helpDialog.execute()
1990 combo = bindingDialog.getControl(
"KeyCombo
" )
1991 keyGroup = combo.text
1992 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
1993 if ( allKeyGroupsArray( n ) = keyGroup )then
1998 menuScriptList = bindingDialog.getControl(
"ScriptList
" )
1999 script = menuScriptList.getSelectedItem()
2000 scriptURI = getScriptURI( script )
2002 keyList = bindingDialog.getControl(
"KeyList
" )
2003 keyIndex = keyList.getSelectedItemPos()
2004 ShortCutKeyArray() = KeyBindArrayOfArrays( keyGroupIndex )
2005 keyText = ShortCutKeyArray( keyIndex )
2007 AddNewKeyBinding( scriptURI, HasShiftKey( keyText ), HasControlKey( keyText ), ExtractKeyFromCombo( keyText ) )
2013 sub KeyDeleteButton()
2015 keyShortCutList = bindingDialog.getControl(
"KeyList
" )
2016 selectedShortCut = keyShortCutList.getSelectedItem()
2017 combo = bindingDialog.getControl(
"KeyCombo
" )
2019 keyGroup = combo.text
2020 dim keyGroupIndex as Integer
2021 dim selectedKeyIndex as Integer
2022 for n = lbound ( allKeyGroupsArray() ) to ubound ( allKeyGroupsArray() )
2023 if ( allKeyGroupsArray( n ) = keyGroup )then
2028 selectedKeyIndex = keyShortCutList.getSelectedItemPos()
2029 linePosition = keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value
2030 keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Value =
0
2031 keyAllocationMap( keyGroupIndex, selectedKeyIndex ).Name =
""
2032 RemoveBinding( linePosition )
2037 sub EventNewButton()
2038 eventScriptList = bindingDialog.getControl(
"ScriptList
" )
2039 selectedScript = eventScriptList.getSelectedItem()
2040 scriptURI = getScriptURI( selectedScript )
2041 eventList = bindingDialog.getControl(
"EventList
" )
2042 eventPosition = eventList.getSelectedItemPos()
2044 allApps = bindingDialog.getControl(
"AllAppsOption
" )
2045 dim isApp as boolean
2046 if allApps.state = true then
'Application
2051 AddNewEventBinding( scriptURI, eventPosition, isApp )
2053 populateEventList( eventPosition )
2058 sub EventDeleteButton()
2059 eventList = bindingDialog.getControl(
"EventList
" )
2060 REM Check that combo is a script
2061 eventPosition = eventList.getSelectedItemPos()
2063 allApps = bindingDialog.getControl(
"AllAppsOption
" )
2064 if allApps.state = true then
'Application
2065 linePosition = allEventTypesApp( eventPosition ).Value
2066 'dim eventProp as new com.sun.star.beans.PropertyValue
2067 'eventProp.Name =
""
2068 'eventProp.Value =
0
2069 allEventTypesApp( eventPosition ).Name =
""
2070 allEventTypesApp( eventPosition ).Value =
0
2071 RemoveBinding( linePosition )
2073 'DeleteEvent( allEventTypes( eventPosition ) )
2074 allEventTypesDoc( eventPosition ).Name =
""
2075 allEventTypesDoc( eventPosition ).Value =
0
2078 PopulateEventList( eventPosition )
2086 bindingDialog.endExecute()
2091 helpDialog.endExecute()