LibreOffice logo
BASEDOCUMENTER
The software tool for documenting your LibreOffice Base applications
 
Database file/home/jean-pierre/Documents/BaseDocumenter/www/databases/Basic/XRay.odb
File actual save date2018-07-29 12:45:41
Scanning done on2018-07-16 18:35:44
Documentation generated on2018-07-29 18:30:22
Table of contents
XRay
Procedures by module
Library Module name Procedure name Language Used by Number of code lines Procedure code
XrayTool _Main addShortTypeStr Basic structure2String (Procedure)
properties2String (Procedure)
simplifiedPropertyString (Procedure)
XrayThisProperty (Procedure)
22
' OUT parameters : propInf, propReadable
Sub addShortTypeStr(thisIdlClass As Object, propInf As String, propReadable As Long)
Dim tc As Long

tc = thisIdlClass.TypeClass
if (tc = com.sun.star.uno.TypeClass.ARRAY) or (tc = com.sun.star.uno.TypeClass.SEQUENCE) then
propReadable = arrayProp
if showAll then
propInf = propInf & "[]" & thisIdlClass.ComponentType.Name
else
tc = thisIdlClass.ComponentType.TypeClass
propInf = propInf & "[]" & TypeClass2Basic(tc)
end if
else
propReadable = TypeClassIsPropReadable(tc)
if showAll then
propInf = propInf & thisIdlClass.Name
else
propInf = propInf & TypeClass2Basic(tc)
end if
end if
End Sub
XrayTool _Main addValueToDisplay Basic propertiesPanelString (Procedure)
structure2String (Procedure)
properties2String (Procedure)
23
' INOUT parameter : propLine
Sub addValueToDisplay(propLine As String, propValue As String)
Dim space1 As Long, strTemplate As String

space1 = propValPos - Len(propLine) -2 ' space within Value column
if Len(propValue) > space1 then
if Len(propValue) > propValMinWidth then ' too wide for display, replace by <...>
if Len(tooWideStr) <= space1 then
strTemplate = String(space1, "x")
RSet strTemplate = tooWideStr
propLine = propLine & " " & strTemplate & " "
else
propLine = propLine & " " & tooWideStr & " "
end if
else
propLine = propLine & " " & propValue & " "
end if
else ' right align to propValPos
strTemplate = String(space1, "x")
RSet strTemplate = propValue
propLine = propLine & " " & strTemplate & " "
end if
End Sub
XrayTool _Main buildAllMethodsNamesInterfaces Basic properties2String (Procedure) 16
Sub buildAllMethodsNamesInterfaces()
Dim info1 As Variant, info2 As Object
Dim s As String, x As Long, xMax As Long

allMethodsNamesInterfaces = ""
info1 = introCurrObj.getMethods(com.sun.star.beans.MethodConcept.ALL)
xMax = UBound(info1)
if xMax < 0 then Exit Sub
for x = 0 to xMax ' get info of each method accessible from the object
info2 = info1(x)
s = "£" & info2.Name & "£" & info2.DeclaringClass.Name & "£"
if InStr(1, allMethodsNamesInterfaces, s, 0) = 0 then ' new name+interface
allMethodsNamesInterfaces = allMethodsNamesInterfaces & s
end if
next
End Sub
XrayTool _Main changeDisplay Basic DlgXray|displayWhat (Control)
DlgXray|AZflag (Control)
DlgXray|showAllFlag (Control)
initXrayDisplay (Procedure)
53
' routine triggered by event : on change on control displayWhat
' routine triggered by event : on change on control AZflag
' routine triggered by event : on change on control showAllFlag
' routine also used at startup
Sub changeDisplay
Dim kt As Object, kth As Object, Txtzone As Object
Dim t0 As Long, ordering As String, header As String

t0 = GetSystemTicks ' speed optimization tests
Txtzone = XrDial.getControl("TxtObjInfos")
kt = XrDial.getControl("showAllFlag")
showAll = (kt.Model.State = 1)
kt = XrDial.getControl("AZflag")
if kt.State = 1 then ordering = "AZ" else ordering = ""
enableControls(XrDial, Array("showAllFlag", "AZflag", "displayWhat", "SDKBtn", "DeeperBtn", "PrettyDisplayBtn"), True)
Txtzone.Text = emptyLine & txt0106 ' wait, please... (also creates a visible change of display)
kth = XrDial.getControl("HeaderLabel")
kth.Text = ""
kt = XrDial.getControl("displayWhat")
Select Case kt.SelectedItemPos
Case 0 ' properties
XrayDisplayWhat = "properties"
Txtzone.Text = propertiesPanelString(ordering)
Case 1 ' methods
XrayDisplayWhat = "methods"
header = " " & txt0405
spaceTo(header, methArgsPos, 1) ' add spaces at right
header = header & "( " & txt0406 & " )"
spaceTo(header, methReturnPos, 1) ' add spaces at right
header = header & "AS " & txt0407
spaceTo(header, methInterfPos, 2) ' add spaces at right
kth.Text = header & txt0408
Txtzone.Text = methodsString(ordering)
Case 2 ' services
XrayDisplayWhat = "services"
enableControls(XrDial, Array("showAllFlag", "AZflag", "DeeperBtn", "PrettyDisplayBtn"), False)
Txtzone.Text = servicesString
Case 3 ' interfaces
XrayDisplayWhat = "interfaces"
enableControls(XrDial, Array("showAllFlag", "AZflag", "DeeperBtn", "PrettyDisplayBtn"), False)
Txtzone.Text = interfacesString ' function declared in Mod4
Case 4 ' listeners
XrayDisplayWhat = "listeners"
enableControls(XrDial, Array("showAllFlag", "AZflag", "DeeperBtn", "PrettyDisplayBtn"), False)
header = ""
spaceTo(header, interfacePos, 1)
kth.Text = header & txt0408
Txtzone.Text = listenersString
End Select
kt = XrDial.getControl("Duration")
'kt.Text = CStr(GetSystemTicks - t0) & " ms" ' speed optimization tests
FocusOnInfoControl
End Sub
XrayTool _Main checkAndDisplayNewObject Basic XrayThisArrayElement (Procedure)
XrayThisStructureElement (Procedure)
XrayThisProperty (Procedure)
XrayThisMethod (Procedure)
10
'  Note :  arg newObj is mandatory ! Optional only to handle error case VarType = 10
Sub checkAndDisplayNewObject(Optional newObj As Variant, ObjPath As String) As Boolean
if isWorthXray(newObj) then
if EqualUnoObjects(newObj, CurrentObj) then
MsgBox(txt0109, 0, WindowTitle) ' this is the same object
elseif initXrayDisplay(newObj, ObjPath, true) then
' OK, ObjPath will be added to listbox ListObj
end if
end if
End Sub
XrayTool _Main createPropertyComments Basic properties2String (Procedure) 23
Function createPropertyComments(propKind As Long) As String
Dim result As String, n As Long

if (propKind and &H00000200) > 0 then
result = result & "attribute, "
else ' real property or pseudo-property
result = pseudoprop(propKind and &H0000000F) ' indicate get? or/and set? if ambiguous pseudo-prop
end if
if ((propKind and &H00000105) = &H00000100) or _
((propKind and &H00000800) = &H00000800) then result = result & "ambiguous name, "
n = propKind H00010000000 ' get the property attributes
if (n and com.sun.star.beans.PropertyAttribute.READONLY) <> 0 then result = result & "read-only, "
if (n and com.sun.star.beans.PropertyAttribute.MAYBEVOID) <> 0 then result = result & "may be void, "
if showAll then
if (n and com.sun.star.beans.PropertyAttribute.REMOVEABLE) <> 0 then result = result & "property may be removed, "
if (n and com.sun.star.beans.PropertyAttribute.MAYBEAMBIGUOUS) <> 0 then result = result & "value may be ambiguous, "
if (n and com.sun.star.beans.PropertyAttribute.MAYBEDEFAULT) <> 0 then result = result & "may be set to default, "
if (n and com.sun.star.beans.PropertyAttribute.BOUND) <> 0 then result = result & "value may be listened, "
if (n and com.sun.star.beans.PropertyAttribute.CONSTRAINED) <> 0 then result = result & "value may be denied, "
if (n and com.sun.star.beans.PropertyAttribute.TRANSIENT) <> 0 then result = result & "value is not persistent, "
end if
createPropertyComments = result
End Function
XrayTool _Main explainAttribute Basic explainPropertyCaracteristics (Procedure) 32
' INOUT parameter : array s()
Sub explainAttribute(propName As String, propKind As Long, s As Variant)
Dim t As String, t2 As String, n As Long

t = s(F3notes)
n = propKind H00010000000 ' get the attributes of the attribute
' see bottom of page http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Properties
s(F3attribProp) = txt0341
' currently, an attribute can't be REMOVEABLE
t2 = findInterfaceOfAttribute(propName)
if Len(t2) > 0 then
t = t & LF & txt0342 & t2
else
Select Case isAlternateDoc(propName, "attribute")
Case "found"
t = t & LF & txt0344
Case "not found"
t = t & LF & txt0343
End Select
end if
if (n and com.sun.star.beans.PropertyAttribute.READONLY) <> 0 then t = t & LF & txt0346
if (n and com.sun.star.beans.PropertyAttribute.MAYBEVOID) <> 0 then t = t & LF & txt0230
if showAll then
if (n and com.sun.star.beans.PropertyAttribute.MAYBEAMBIGUOUS) <> 0 then t = t & LF & txt0234
if (n and com.sun.star.beans.PropertyAttribute.MAYBEDEFAULT) <> 0 then t = t & LF & txt0348
if (n and com.sun.star.beans.PropertyAttribute.BOUND) <> 0 then t = t & LF & txt0231
if (n and com.sun.star.beans.PropertyAttribute.CONSTRAINED) <> 0 then t = t & LF & txt0232
if (n and com.sun.star.beans.PropertyAttribute.TRANSIENT) <> 0 then t = t & LF & txt0347
end if

s(F3notes) = t
End Sub
XrayTool _Main explainPropertyCaracteristics Basic simplifiedPropertyString (Procedure) 12
' INOUT parameter : array s()
Sub explainPropertyCaracteristics(propName As String, propKind As Long, s As Variant)

if (propKind and &H00000800) <> 0 then
s(F3notes) = s(F3notes) & LF & txt0240 ' name conflict : several properties have same name
s(F3important) = txt0229 ' name conflict : see notes - (allow Xraydeeper, however)
elseif (propKind and &H00000200) <> 0 then ' attribute
explainAttribute(propName, propKind, s)
elseif (propKind and &H00000400) <> 0 then ' real property
explainRealProperty(propName, propKind, s)
end if
End Sub
XrayTool _Main explainPseudoPropertyCaracteristics Basic simplifiedPropertyString (Procedure) 52
' INOUT parameter : array s()
Sub explainPseudoPropertyCaracteristics(propName As String, propKind As Long, s As Variant)
Dim t As String, w As String, intfGet As String, intfSet As String

t = s(F3notes)
intfGet = "none"
intfSet = "none"
if (propKind and &H00000001) <> 0 then ' prop is a getter
s(F3get) = txt0219 & "get" & propName & "( ) "
if (propKind and &H00000002) <> 0 then ' getter is ambiguous
t = t & LF & replaceTag(txt0243, "getXxx", "get" & propName & "( ) ") ' name conflict, use getXxx from appropriate interface
s(F3important) = txt0229 ' name conflict : see notes
s(F3canXray) = "noXray"
else
intfGet = getPseudoPropInterface("get", propName) ' should return the interface name, not "none" or "several" !
if (propKind and &H00000004) = 0 then t = t & LF & txt0223 ' no setXxx : pseudo-property can only be read
end if
end if

if (propKind and &H00000004) <> 0 then ' prop is a setter
s(F3set) = txt0219 & "set" & propName & "(" & txt0242 & ") "
if (propKind and &H00000008) <> 0 then ' setter is ambiguous
t = t & LF & replaceTag(txt0244, "setXxx", "set" & propName & "( ) ") ' name conflict, use setXxx from appropriate interface
s(F3important) = txt0229 ' name conflict : see notes
else
intfSet = getPseudoPropInterface("set", propName) ' should return the interface name, not "none" or "several" !
if (propKind and &H00000001) = 0 then ' no getXxxx
t = t & LF & txt0222 ' pseudo-property can only be written
s(F3canXray) = "noXray"
end if
end if
end if

if intfGet <> "none" then
if intfSet <> "none" then
if intfGet = intfSet then
t = t & LF & txt0253 & intfGet ' interface : ...
else ' getXxx and setXxx have different interfaces ! use methods instead of pseudo-prop
w = replaceTag(txt0245, "getXxx", "get" & propName & "( ) ")
w = replaceTag(w, "setXxx", "set" & propName & "( ) ")
t = t & LF & w
end if
elseif (propKind and &H0000000A) = 0 then ' only getXxx, no ambiguity
t = t & LF & txt0252 & intfGet ' interface : ...
end if
else
if (intfSet <> "none") and ((propKind and &H0000000A) = 0) then ' only setXxx, no ambiguity
t = t & LF & txt0252 & intfSet ' interface : ...
end if
end if
s(F3notes) = t
End Sub
XrayTool _Main explainRealProperty Basic explainPropertyCaracteristics (Procedure) 37
' INOUT parameter : array s()
Sub explainRealProperty(propName As String, propKind As Long, s As Variant)
Dim t As String, t2 As String, n As Long

t = s(F3notes)
n = propKind H00010000000 ' get the attributes of the property
s(F3attribProp) = txt0351
if (n and com.sun.star.beans.PropertyAttribute.REMOVEABLE) <> 0 then
t = t & LF & txt0236 & _
LF & Space(4) & txt0220 & "getPropertyValue(""" & propName & """) " & _
LF & Space(4) & txt0221 & "setPropertyValue(""" & propName & """, " & txt0242 & ") " & _
LF & txt0356 ' can't document such property (prop name can be anything)
else
t2 = findServiceOfRealProperty(propName)
if Len(t2) > 0 then
t = t & LF & txt0352 & t2
else
Select Case isAlternateDoc(propName, "property")
Case "found"
t = t & LF & txt0354
Case "not found"
t = t & LF & txt0353
End Select
end if
end if
if (n and com.sun.star.beans.PropertyAttribute.READONLY) <> 0 then t = t & LF & txt0223
if (n and com.sun.star.beans.PropertyAttribute.MAYBEVOID) <> 0 then t = t & LF & txt0230
if showAll then
if (n and com.sun.star.beans.PropertyAttribute.MAYBEAMBIGUOUS) <> 0 then t = t & LF & txt0234
if (n and com.sun.star.beans.PropertyAttribute.MAYBEDEFAULT) <> 0 then t = t & LF & txt0235
if (n and com.sun.star.beans.PropertyAttribute.BOUND) <> 0 then t = t & LF & txt0231
if (n and com.sun.star.beans.PropertyAttribute.CONSTRAINED) <> 0 then t = t & LF & txt0232
if (n and com.sun.star.beans.PropertyAttribute.TRANSIENT) <> 0 then t = t & LF & txt0233
end if

s(F3notes) = t
End Sub
XrayTool _Main foundInXrayList Basic XrayThisArrayElement (Procedure)
XrayThisStructureElement (Procedure)
XrayThisProperty (Procedure)
XrayThisMethod (Procedure)
16
' look if this object has already been Xrayed
' returns true if successful
Function foundInXrayList(newObjName As String) As Boolean
Dim kt As Object, y1 As Integer

kt = XrDial.getControl("ListObj")
for y1 = 0 to kt.ItemCount -1
if newObjName = kt.getItem(y1) then
kt.selectItemPos(y1, true) ' do as if user had selected this position
XrayBack
foundInXrayList = true
exit function
end if
next
foundInXrayList = false
End Function
XrayTool _Main getPropertyCategory Basic FindPropertyDoc (Procedure)
properties2String (Procedure)
simplifiedPropertyString (Procedure)
XrayThisProperty (Procedure)
40
' returns a value composed of binary flags :
' &H00000001 : getXxx exists
' &H00000002 : getXxx is ambiguous (more than one method exists)
' &H00000004 : setXxx exists
' &H00000008 : setXxx is ambiguous (more than one method exists)
' &H00000100 : this name is a getter/setter
' &H00000200 : attribute of interface
' &H00000400 : real property, reachable by XPropertySet, XFastPropertySet or XMultiPropertySet
' &H00000800 : ambiguous name : appears several times as property / pseudo-property / attribute
' &H00nn0000 : in case of attribute or real property, value of Attributes of the property
'
Function getPropertyCategory(propName As String, propAttributes As Long) As Long
Dim result As Long, x As Long, interfName As String

result = 0
if introCurrObj.hasProperty(propName, com.sun.star.beans.PropertyConcept.ATTRIBUTES) then result = result or &H00000200
if introCurrObj.hasProperty(propName, com.sun.star.beans.PropertyConcept.PROPERTYSET) then result = result or &H00000400
if (result and &H00000600) <> 0 then result = result or (&H00010000 * propAttributes)
x = InStr(1, allPropsNames, "£" & propName & "£", 0) ' get first occurrence of propName
if InStr(x +Len(propName) +2, allPropsNames, "£" & propName & "£", 0) > 0 then result = result or &H00000800 ' propName is ambiguous

if introCurrObj.hasProperty(propName, com.sun.star.beans.PropertyConcept.METHODS) then
result = result or &H00000100 ' this property is a getter-setter
' note : hasMethod or getMethods(com.sun.star.beans.MethodConcept.PROPERTY) does not show all getter/setter methods
interfName = getPseudoPropInterface("get", propName)
if interfName = "several" then
result = result or &H00000003
elseif interfName <> "none" then
result = result or &H00000001
end if
interfName = getPseudoPropInterface("set", propName)
if interfName = "several" then
result = result or &H0000000C
elseif interfName <> "none" then
result = result or &H00000004
end if
end if

getPropertyCategory = result
End Function
XrayTool _Main getPseudoPropInterface Basic FindPropertyDoc (Procedure)
getPropertyCategory (Procedure)
explainPseudoPropertyCaracteristics (Procedure)
33
' parameter getset is "get" or "set"
' returns the name of the interface that qualifies as getter or setter
' or "several" if more than one interface satisfies
' or "none" if no interface satisfies
Function getPseudoPropInterface(getset As String, propName As String) As String
Dim methName As String, interfName As String, result As String
Dim info1 As Object, x As Long, y As Long, isGetterSetter As Boolean

result = "none"
methName = getset & propName
x = InStr(1, allMethodsNamesInterfaces, "£" & methName & "£", 0)
Do While x > 0 ' a method of this name exists
x = x +Len(methName) +2
y = InStr(x, allMethodsNamesInterfaces, "£", 0)
interfName = MidP1P2(allMethodsNamesInterfaces, x, y-1)
info1 = introCurrObj.getMethod(join(split(interfName, "."), "_") & "_" & methName, com.sun.star.beans.MethodConcept.ALL)
if getset = "get" then
isGetterSetter = (UBound(info1.ParameterInfos) < 0) and (info1.ReturnType.Name <> "void")
else ' "set"
isGetterSetter = (UBound(info1.ParameterInfos) = 0) and (info1.ReturnType.Name = "void")
end if
if isGetterSetter then
if result = "none" then
result = interfName
else
result = "several"
Exit Do ' ambiguous name : more than one interface provides a getter or setter
end if
end if
x = InStr(y+1, allMethodsNamesInterfaces, "£" & methName & "£", 0) ' search another method of same name
Loop
getPseudoPropInterface = result
End Function
XrayTool _Main getShortTypeStr Basic methodsString (Procedure)
methodsUsingAnyListener (Procedure)
simplifiedStructureElementString (Procedure)
simplifiedMethodString (Procedure)
21
' simplified variant of addShortTypeStr
' returns only the short type string
Function getShortTypeStr(thisIdlClass As Object) As String
Dim tc As Long

tc = thisIdlClass.TypeClass
if (tc = com.sun.star.uno.TypeClass.ARRAY) or (tc = com.sun.star.uno.TypeClass.SEQUENCE) then
if showAll then
getShortTypeStr = "[]" & thisIdlClass.ComponentType.Name
else
tc = thisIdlClass.ComponentType.TypeClass
getShortTypeStr = "[]" & TypeClass2Basic(tc)
end if
else
if showAll then
getShortTypeStr = thisIdlClass.Name
else
getShortTypeStr = TypeClass2Basic(tc)
end if
end if
End Function
XrayTool _Main getValueOfProperty Basic properties2String (Procedure)
simplifiedPropertyString (Procedure)
XrayThisProperty (Procedure)
34
' OUT parameters : v, vError
Sub getValueOfProperty(propName As String, propReadable As Long, propKind As Long, v As Variant, vError As String)

if propReadable > notReadable then
if (propKind and &H00000600) <> 0 then ' attribute or real property
vError = ""
elseif (propKind and &H00000003) = &H00000001 then ' pseudo-property getXxxx non ambiguous
if propReadable = arrayProp then vError = checkHugeArray(propName) else vError = ""
elseif (propKind and &H00000003) = &H00000003 then ' ambiguous getXxx
vError = "ambiguous" ' ambiguous in the context of obtaining a value, ambiguous setXxx is not looked here
else ' pseudo-property setXxxx exists but not getXxxx
vError = "not readable"
end if
else
vError = "not readable"
end if

if Len(vError) = 0 then
on Error Goto nogetValue
v = invocCurrObj.getValue(propName)
on Error Goto 0
if not IsArray(v) then
if propReadable = dataIsAny then propReadable = BasicTypeIsPropReadable(VarType(v)) ' update according to obtained data type
end if
vError = preliminaryDataControl(v)
end if
Exit Sub

nogetValue: ' error in the UNO object
vError = txt0224 & LF & error
Resume nogetValue1
nogetValue1:
on Error Goto 0
End Sub
XrayTool _Main initXrayDisplay Basic XrayBack (Procedure)
Xray (Procedure)
checkAndDisplayNewObject (Procedure)
35
Function initXrayDisplay(ObjX2 As Variant, ObjName As String, newObject As Boolean) As Boolean
Dim kt As Object, invoc As Object
Dim p1 As Integer

initXrayDisplay = True
classeIDL = OOoReflection.getType(ObjX2)
invoc = CreateUnoService("com.sun.star.script.Invocation")
invocCurrObj = invoc.createInstanceWithArguments(Array(ObjX2))
if IsNull(classeIDL) or IsNull(invocCurrObj) then
MsgBox(txt0108, 64, WindowTitle) ' object does not support reflection or introspection
initXrayDisplay = False
exit function
end if
introCurrObj = invocCurrObj.Introspection ' caution : introCurrObj may be Null if ObjX2 is not a Uno object, e.g a Uno data !
if newObject then
kt = XrDial.getControl("ListObj")
kt.Model.Tag = "inhibit"
p1 = kt.ItemCount -1 ' UBound of Items
if p1 = UBound(XrObject()) then kt.removeItems(p1, 1) ' storage is full, overwrite last position
kt.AddItem(ObjName, kt.ItemCount)
kt.selectItemPos(kt.ItemCount -1, true)
kt.Model.Tag = "allow"
XrObject(kt.ItemCount -1) = ObjX2
end if
CurrentObj = ObjX2
CurrentObjQualifiedName = ObjName
allPropsNames = ""
allMethodsNamesInterfaces = ""
kt = XrDial.getControl("displayWhat")
if kt.SelectedItemPos = 0 then
changeDisplay
else
kt.SelectItemPos(0, True) ' changeDisplay will be triggered by change of selected Item
end if
End Function
XrayTool _Main interfacesString Basic changeDisplay (Procedure) 37
Function interfacesString() As String
Dim foundInterfaces As String, intfName As String
Dim allMainInterfaces As Variant, v As Variant
Dim x As Long, y As Long

allMainInterfaces = Array()
On Error Resume Next ' some bizarre UNO objects don't have getTypes(), example : controlObject.ImageProducer
allMainInterfaces = CurrentObj.getTypes()
On Error GoTo 0
foundInterfaces = LF ' collector of interface names
if UBound(allMainInterfaces) >= 0 then
for x = 0 to UBound(allMainInterfaces)
intfName = allMainInterfaces(x).Name
exploreInterfacesOfInterface(intfName, foundInterfaces) ' recursive search
next
else ' as an alternative, use interfaces of methods
if Len(allMethodsNamesInterfaces) > 0 then ' allMethodsNamesInterfaces contains : £name1£interface1££name2£interface2££nameN£interfaceN£
allMainInterfaces = split(deleteTrail(allMethodsNamesInterfaces, "£"), "££") ' one array element per name+interface
for x = 0 to UBound(allMainInterfaces)
y = InStr(2, allMainInterfaces(x), "£", 0) ' search second £
intfName = Mid(allMainInterfaces(x), y+1) ' keep only the interface name
exploreInterfacesOfInterface(intfName, foundInterfaces) ' recursive search
next
else
' no GetTypes() and no methods !
end if
end if

if Len(foundInterfaces) > 1 then
foundInterfaces = Mid(foundInterfaces, 2, Len(foundInterfaces) -2) ' strip LF at start and end
v = split(foundInterfaces, LF)
ShellSort( v() )
interfacesString = join(v(), " " & LF)
else
interfacesString = " " & LF & txt0116 ' this object has no interfaces !
end if
End Function
XrayTool _Main listenersString Basic changeDisplay (Procedure) 61
Function listenersString As String ' this routine is optimized for speed !
Dim allListeners As Variant, info2 As Object, info3 As Variant
Dim s1 As String, s2 As String, allListenerNames As String, t As String
Dim x As Long, xMax As Long, y As Long
Const listen = "Listener"

allListeners = introCurrObj.SupportedListeners
xMax = UBound(allListeners)
if xMax < 0 then
listenersString = " " & LF & txt0116 ' no listeners
Exit Function
end if

allListenerNames = LF
for x = 0 to xMax ' create a list of unique listener names enclosed by LF markers
t = allListeners(x).Name & LF ' listeners may appear several times e.g. com.sun.star.lang.XEventListener
if InStr(1, allListenerNames, LF & t, 0) = 0 then allListenerNames = allListenerNames & t
next
allListeners = split(allListenerNames, LF)
xMax = UBound(allListeners) -1
Dim listenersDescr(xMax) As String ' init : each element is a null string, index 0 and UBound() not used

methodsUsingAnyListener(allListenerNames, listenersDescr() )

for x = 1 to xMax ' each listener
info2 = OOoReflection.forName(allListeners(x))
info3 = info2.Methods
s1 = "" ' will collect all methods found
for y = 0 to UBound(info3) ' each method of the listener (some are not event methods)
t = info3(y).DeclaringClass.Name ' search methods of this event, avoid other methods, e.g. queryInterface, acquire, release
if Right(t, Len(listen)) = listen then ' this method is exported by the interface of the event
s2 = info3(y).Name
spaceTo(s2, interfacePos, 1)
s1 = s1 & LF & s2 & t & " "
end if
next
if Len(s1) > 0 then
s2 = " __ " & info2.Name & " __ " ' prepare header for this listener
s2 = s2 & emptyLine & LF & " _ " & txt0250 & " _ " ' header for the methods corresponding to an event
s1 = s2 & s1 ' header and methods
s1 = s1 & emptyLine & LF & " _ " & txt0251 & " _ " ' add header for methods using the event interface
s2 = listenersDescr(x) ' already found methods using this listener
if Len(s2) > 0 then
listenersDescr(x) = s1 & s2 & emptyLine & emptyLine
else ' no method in this object uses this listener !
listenersDescr(x) = s1 & txt0116 & emptyLine & emptyLine
end if
else ' no event methods found for this interface
listenersDescr(x) = "" ' fake listener, e.g. in odbDoc.ReportsDocuments you find a listener named "void"
end if
next
ShellSort( listenersDescr() )
s1 = textFromUniqueStrings( listenersDescr() ) ' fake listeners are now concatenated in one LF at start of string
if Left(s1, 1) = LF then s1 = Mid(s1, 2)
s1 = amputeRight(s1, 2*Len(emptyLine))
if Len(s1) = 0 then
listenersString = " " & LF & txt0116 ' no listeners
else
listenersString = s1
end if
End Function
XrayTool _Main methodsString Basic changeDisplay (Procedure) 44
Function methodsString(ordering As String) As String
Dim info1 As Variant, info2 As Object, info3 As Variant, paramModes As Variant
Dim infoParam As Object, methodsArray As Variant
Dim methInf As String, methodx As String, methRetx As String, methodsList As String
Dim x As Long, xMax As Long, y As Long

paramModes = Array("", "OUT! ", "IN/OUT! ")
info1 = introCurrObj.getMethods(com.sun.star.beans.MethodConcept.ALL)
xMax = UBound(info1)
if xMax < 0 then
methodsString = " " & LF & txt0116
Exit Function
end if
methodsList = LF
for x = 0 to xMax ' get info of each method accessible from the object
info2 = info1(x)
methodx = info2.Name ' search if this name appears more than once in allMethodsNamesInterfaces
y = InStr(1, allMethodsNamesInterfaces, "£" & methodx & "£", 0) ' appears once
if InStr(y +Len(methodx) +2, allMethodsNamesInterfaces, "£" & methodx & "£", 0) > 0 then methodx = methodx & ambiguousMethodFlag
spaceTo(methodx, methArgsPos, 1) ' add spaces at right
info3 = info2.ParameterInfos
methInf = ""
for y = 0 to UBound(info3)
infoParam = info3(y)
methInf = methInf & paramModes(infoParam.aMode) & infoParam.aName & " as " & getShortTypeStr(infoParam.aType) & ", "
next
methodx = methodx & "( " & deleteTrail(methInf, ", ") & " )"
methRetx = getShortTypeStr(info2.ReturnType)
if methRetx <> "void" then
spaceTo(methodx, methReturnPos, 1) ' add spaces at right
methodx = methodx & "AS " & methRetx
end if
spaceTo(methodx, methInterfPos, 2) ' add spaces at right
methodx = methodx & info2.DeclaringClass.Name & " "
if InStr(1, methodsList, LF & methodx & LF, 0) = 0 then methodsList = methodsList & methodx & LF ' avoid duplicated methods
next
methodsList = Mid(methodsList, 2, Len(methodsList) -2) ' suppress LF from both ends
if ordering = "AZ" then
methodsArray = split(methodsList, LF)
ShellSort( methodsArray() )
methodsList = join(methodsArray(), LF)
end if
methodsString = methodsList
End Function
XrayTool _Main methodsUsingAnyListener Basic listenersString (Procedure) 28
' INOUT parameter : listenersDescr
Sub methodsUsingAnyListener(allListenerNames As String, listenersDescr As Variant)
Dim allMethods As Variant, v As Variant
Dim methodInfos As Object, info3 As Object, infoParam As Object
Dim x As Long, y As Long, z As Long, posListen As Long
Dim t As String, paramType As String

allMethods = introCurrObj.getMethods(com.sun.star.beans.MethodConcept.ALL) ' ALL, not LISTENER which ignores e.g. firePropertiesChangeEvent
for x = 0 to UBound(allMethods)
methodInfos = allMethods(x)
info3 = methodInfos.ParameterInfos
for y = 0 to UBound(info3) ' each argument of the method
infoParam = info3(y)
paramType = getShortTypeStr(infoParam.aType)
if Left(paramType, 2) = "[]" then paramType = Mid(paramType, 3) ' ignore []
posListen = InStr(1, allListenerNames, LF & paramType & LF, 0)
if posListen > 0 then ' search which listener is used
t = Left(allListenerNames, posListen)
v = split(t, LF) ' count the number of LF
z = UBound(v)
t = methodInfos.Name & "()"
spaceTo(t, interfacePos, 1)
t = t & methodInfos.DeclaringClass.Name & " " ' add interface of this method (useful if name conflicts)
if InStr(1, listenersDescr(z), LF & t, 0) = 0 then listenersDescr(z) = listenersDescr(z) & LF & t ' avoid duplicates
end if
next
next
End Sub
XrayTool _Main prepareXray Basic Xray (Procedure) 55
Sub prepareXray
Dim kt As Object

OOoReflection = CreateUnoService("com.sun.star.reflection.CoreReflection")
OOoTypeDescr = GetDefaultContext.getByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager")

' TypeClass enumeration ( same structure for arrays below)
' VOID CHAR BOOLEAN BYTE SHORT
' UNSIGNED_SHORT LONG UNSIGNED_LONG HYPER UNSIGNED_HYPER
' FLOAT DOUBLE STRING TYPE ANY
' ENUM TYPEDEF STRUCT UNION EXCEPTION
' SEQUENCE ARRAY INTERFACE SERVICE MODULE
' INTERFACE_METHOD INTERFACE_ATTRIBUTE UNKNOWN PROPERTY CONSTANT
' CONSTANTS SINGLETON

' converts an API type to the nearest Basic type. Except for char, byte, hyper.
TypeClass2Basic = Array( _
"void", "char", "boolean", "byte", "integer", _
"integer", "long", "long", "hyper", "hyper", _
"single", "double", "string", "type", "variant", _
"integer", "object", "struct", "object", "object", _
"array", "array", "object", "object", "object", _
"object", "object", "unknown", "object", "object", _
"object", "object")


' indicates if a value of a given API type can be read and displayed in the property panel
TypeClassIsPropReadable = Array( _
notReadable, OKreadable, OKreadable, OKreadable, OKreadable, _
OKreadable, OKreadable, OKreadable, OKreadable, OKreadable, _
OKreadable, OKreadable, OKreadable, notReadable, dataIsAny, _
OKreadable, notReadable, noDisplay, notReadable, notReadable, _
arrayProp, arrayProp, noDisplay, noDisplay, noDisplay, _
notReadable, notReadable, notReadable, notReadable, OKreadable, _
notReadable, notReadable)

' indicates if the type obtained from an any can be read and displayed in the property panel
' index is VarType(value)
BasicTypeIsPropReadable = Array( _
OKreadable, OKreadable, OKreadable, OKreadable, OKreadable, OKreadable, OKreadable, OKReadable, _
OKreadable, noDisplay, notReadable, OKreadable, noDisplay, notReadable, notReadable, notReadable, _
OKreadable, OKreadable, OKreadable, OKreadable, OKreadable, notReadable, notReadable, notReadable, _
notReadable, notReadable, notReadable, notReadable, notReadable, notReadable, notReadable, notReadable, _
notReadable, notReadable, notReadable, OKReadable, notReadable, OKReadable, notReadable, notReadable, _
notReadable)

pseudoprop = Array("", "(get), read-only, ", "", "(get?), read-only, ", "(set), write-only, ", "(get,set), ", _
"(set), write-only, ", "(get?,set), ", "", "(get), read-only, ", "", "(get?), read-only, ", "(set?), write-only, ", _
"(get,set?), ", "(set?), write-only, ", "(get?,set?), " )


LF = chr(10) ' New line, Unix style
emptyLine = LF & " "
initDlgXray ' will create the dialogue and XrDial
End Sub
XrayTool _Main properties2String Basic propertiesPanelString (Procedure) 36
Function properties2String(ordering As String) As String
Dim info1 As Variant, info2 As Object, v As Variant
Dim x As Long, xMax As Long, propReadable As Long, propKind As Long
Dim propInf As String, propValue As String, propComment As String, propName As String
Dim vError As String


if Len(allMethodsNamesInterfaces) = 0 then buildAllMethodsNamesInterfaces ' only once per current object
info1 = introCurrObj.getProperties(com.sun.star.beans.PropertyConcept.ALL)
xMax = UBound(info1)
if xMax < 0 then
properties2String = " " & LF & txt0116
Exit Function
end if
if Len(allPropsNames) = 0 then ' only once per current object
for x = 0 to xMax ' each property or pseudo-property
info2 = info1(x)
allPropsNames = allPropsNames & "£" & info2.Name & "£" ' build list £name1££name2££name3£ etc
next
end if
Dim intf2(xMax) As String
for x = 0 to xMax ' each property or pseudo-property
info2 = info1(x)
propInf = replaceSpaces(info2.Name) ' some user-defined properties have spaces, e.g. Info 1 in document properties
spaceTo(propInf, propTypePos, 1) ' tabulation to "type" column
addShortTypeStr(info2.Type, propInf, propReadable)
propKind = getPropertyCategory(info2.Name, info2.Attributes)
propComment = createPropertyComments(propKind)
getValueOfProperty(info2.Name, propReadable, propKind, v, vError)
getShortStringFromValueOfProperty(info2, v, vError, propValue, propComment)
addValueToDisplay(propInf, propValue)
intf2(x) = propInf & deleteTrail(propComment, ", ") & " " ' add a trailing space to simplify code
next
if ordering = "AZ" then ShellSort(intf2())
properties2String = join(intf2(), LF)
End Function
XrayTool _Main propertiesPanelString Basic changeDisplay (Procedure) 42
Function propertiesPanelString(ordering As String) As String
Dim kt As Object
Dim objInternalName As String, typ As String, header As String

if showAll then
propValPos = 72 ' right side of value
propValMinWidth = 20 ' guaranteed minimum width
else
propValPos = 67
propValMinWidth = 9
end if
kt = XrDial.getControl("HeaderLabel")
if IsArray(CurrentObj) then
typ = deleteTrail( LCase(TypeName(CurrentObj)), "()" ) ' the type name is followed by (), delete them
objInternalName = txt0201 & typ
propertiesPanelString = Value2Str(CurrentObj, showFullString +showHexaValue)
enableControls(XrDial, Array("showAllFlag", "AZflag", "displayWhat", "SDKBtn"), False)
elseif classeIDL.TypeClass = com.sun.star.uno.TypeClass.STRUCT then
objInternalName = classeIDL.Name
header = " " & txt0409
spaceTo(header, propTypePos, 1) ' tabulation to "type" column
header = header & txt0402
addValueToDisplay(header, txt0403)
kt.Text = header & txt0404
propertiesPanelString = structure2String(ordering)
enableControls(XrDial, Array("displayWhat"), False)
elseif (VarType(CurrentObj) = 9) and not IsNull(introCurrObj) then ' object
objInternalName = classeIDL.Name
header = " " & txt0401
spaceTo(header, propTypePos, 1) ' tabulation to "type" column
header = header & txt0402
addValueToDisplay(header, txt0403)
kt.Text = header & txt0404
propertiesPanelString = properties2String(ordering)
else ' simple value ( or Uno simple type data )
objInternalName = txt0203 & LCase(TypeName(CurrentObj))
propertiesPanelString = Value2Str(CurrentObj, showFullString +showHexaValue)
enableControls(XrDial, Array("showAllFlag", "AZflag", "displayWhat", "SDKBtn", "DeeperBtn", "PrettyDisplayBtn"), False)
end if
kt = XrDial.getControl("currentObjName")
kt.Text = objInternalName
End Function
XrayTool _Main servicesString Basic changeDisplay (Procedure) 37
Function servicesString() As String
Dim v As Variant, x As Long
Dim avServ As String, avSupp As String

v = Array() ' in case of method not available
On Error Resume Next
v = CurrentObj.getSupportedServiceNames
On Error GoTo 0
if UBound(v) < 0 then
avSupp = txt0116
else
avSupp = LF
for x = 0 to UBound(v)
exploreServicesOfService(v(x), avSupp)
next
v = split(Mid(avSupp, 2, Len(avSupp) -2), LF)
ShellSort(v())
avSupp = join(v(), LF)
end if

v = Array() ' in case of method not available
On Error Resume Next
v = CurrentObj.getAvailableServiceNames
On Error GoTo 0
if UBound(v) < 0 then
avServ = txt0116
else
ShellSort(v())
avServ = join(v(), " " & LF) & " " ' add trailing space to simplify code
end if

servicesString = " " & String(5, "_") & " " & txt0101 & " " & String(5, "_") & _
emptyLine & LF & avSupp & _
emptyLine & emptyLine & LF & _
" " & String(5, "_") & " " & txt0102 & " " & String(5, "_") & _
emptyLine & LF & avServ
End Function
XrayTool _Main simplifiedArrayElementString Basic prettyDisplayPropMethod (Procedure) 15
' returns an array of strings filled at indexes :
' F3name F3type F3value
Function simplifiedArrayElementString(arrayIndex As String) As Variant
Dim s(F3max) As String, t As Variant
Dim elemVal As Variant, idxList As Variant

t = split(CurrentObjQualifiedName, ".")
s(F3name) = t(UBound(t)) & arrayIndex
idxList = split(MidP1P2(arrayIndex, 2, Len(arrayIndex) -1), ",") ' get each index value
elemVal = getArrayElement(CurrentObj, UBound(idxList) +1, idxList)
s(F3type) = deleteTrail( LCase(TypeName(elemVal)), "()" ) ' the type name is followed by (), delete them
s(F3value) = Value2Str(elemVal, showFullString +showHexaValue)
if VarType(elemVal) = 9 then s(F3value) = LF & LF & txt0114 ' do Xray to display the value
simplifiedArrayElementString = s()
End Function
XrayTool _Main simplifiedMethodString Basic prettyDisplayPropMethod (Procedure) 43
' returns an array of strings filled at indexes :
' F3name F3parameters F3type F3Interface_Service F3notes F3canXray
Function simplifiedMethodString(methName As String, currentLine As String) As Variant
Dim s(F3max) As String, t As String, fullMethName As String, errNoXray As String
Dim info1 As Object, info2 As Object, n As Long
Dim params As Variant, paraModes As Variant, paramType As String

paraModes = split(txt0211, "£")
s(F3name) = methName
s(F3Interface_Service) = getLastWordOfString(currentLine) ' interface exporting the method indicated by currentLine
fullMethName = join(split(s(F3Interface_Service), "."), "_") & "_" & methName
if InStr(1, currentLine, methName & ambiguousMethodFlag, 0) = 1 then 'ambiguous method
s(F3Notes) = txt0238 & LF & txt0239 & LF & fullMethName & "( ) "
end if
info1 = introCurrObj.getMethod(fullMethName, com.sun.star.beans.MethodConcept.ALL)
params = info1.ParameterInfos
if UBound(params) < 0 then
s(F3parameters) = txt0215 ' no parameter
else
t = ""
if UBound(params) > 0 then s(F3canXray) = "noXray"
for n = 0 to UBound(params)
info2 = params(n)
if n = 0 then ' check if 1st parameter compatible with XrayDeeper
paramType = info2.aType.Name
if InStr(1, acceptedParamTypes, "£" & paramType & "£", 0) = 0 then
s(F3canXray) = "noXray" ' unacceptable type for Xray deeper
end if
end if
t = t & txt0214 & (n+1) & paraModes(info2.aMode) & info2.aName & " as " & getShortTypeStr(info2.aType, paramType) & LF
next
s(F3parameters) = deleteTrail(t, LF)
end if
t = getShortTypeStr(info1.ReturnType, t)
if t = "void" then
s(F3type) = txt0216 ' method returns nothing
else
s(F3type) = t
end if

if Len(errNoXray) > 0 then s(F3canXray) = "noXray"
simplifiedMethodString = s()
End Function
XrayTool _Main simplifiedPropertyString Basic prettyDisplayPropMethod (Procedure) 54
' returns an array of strings filled at indexes :
' F3name [F3attribProp] [F3get] [F3set] F3type F3value [F3Color]
' F3notes F3important F3canXray
Function simplifiedPropertyString(propName As String) As Variant ' simplified : not for the programmer !
Dim s(F3max) As String, t As String, vError As String, t2 As String
Dim propValue As String, propType As String
Dim info1 As Variant, info2 As Object, v As Variant
Dim propKind As Long, propReadable As Long, x As Long

s(F3name) = propName
info2 = introCurrObj.getProperty(propName, com.sun.star.beans.PropertyConcept.ALL)
addShortTypeStr(info2.Type, propType, propReadable)
s(F3type) = propType
propKind = getPropertyCategory(propName, info2.Attributes)
getValueOfProperty(propName, propReadable, propKind, v, vError)

s(F3notes) = "" ' prepare notes
if (propKind and &H00000100) <> 0 then ' pseudo-property
explainPseudoPropertyCaracteristics(propName, propKind, s)
else
explainPropertyCaracteristics(propName, propKind, s)
end if
t = s(F3notes)
if Len(vError) = 0 then
s(F3value) = Value2Str(v, showFullString +showHexaValue)
if (propType = "any") or (propType = "variant") then s(F3type) = propType & " (" & LCase(TypeName(v)) & ")" ' add final type
t2 = getEnumStringValue(info2.Type, v, " ")
if Len(t2) > 0 then
s(F3value) = s(F3value) & LF & LF & txt0237 & LF & t2 & " "
else
t2 = colorComments(propName, v, showFullString)
if Len(t2) > 0 then
s(F3value) = s(F3value) & LF & LF & t2 & " "
s(F3Color) = v
end if
end if
if (propReadable = noDisplay) and (Len(s(F3canXray)) = 0) then s(F3value) = LF & LF & txt0114 ' Xray deeper to display (object)
elseif vError = "not readable" then
if Len(s(F3canXray)) = 0 then s(F3value) = LF & LF & txt0114 ' Xray deeper to display (object)
elseif vError = "ambiguous" then
' name conflict, already treated
elseif InStr(1, vError, txt0224, 0) = 1 then ' read error : vError = txt0224 & LF & error
s(F3important) = txt0224
t = t & Mid(vError, Len(txt0224) +1) ' show read error data in notes, starting with LF
elseif InStr(1, vError, txt0125, 0) = 1 then ' huge array : vError = txt0125 & LF & info
s(F3important) = txt0125
t = t & Mid(vError, Len(txt0125) +1) ' show further info in notes, starting with LF
else ' error in the UNO object
s(F3important) = vError ' read error or simple diagnostic
end if

s(F3notes) = Mid(t, 2) ' skip first LF, if any notes
simplifiedPropertyString = s()
End Function
XrayTool _Main simplifiedStructureElementString Basic prettyDisplayPropMethod (Procedure) 45
' returns an array of strings filled at indexes :
' F3name F3type F3value [F3Color] F3notes F3important F3canXray
Function simplifiedStructureElementString(elemName As String) As Variant
Dim s(F3max) As String, t As String, t2 As String, errMess As String
Dim elemX As Object, accMode As Long
Dim elemVal As Variant

s(F3name) = elemName
t = ""
elemX = classeIDL.getField(elemName)
s(F3type) = getShortTypeStr(elemX.Type)
accMode = elemX.AccessMode
if accMode = com.sun.star.reflection.FieldAccessMode.READONLY then
t = t & LF & txt0223
end if
if accMode = com.sun.star.reflection.FieldAccessMode.WRITEONLY then
t = t & LF & txt0222
s(F3canXray) = "noXray"
else
elemVal = elemX.get(CurrentObj)
errMess = preliminaryDataControl(elemVal)
if Len(errMess) > 0 then
s(F3important) = errMess
s(F3canXray) = "noXray"
else
s(F3value) = Value2Str(elemVal, showFullString +showHexaValue)
if Len(s(F3value)) = 0 then
s(F3value) = LF & LF & txt0114 ' Xray deeper to display (object)
else ' property contains a displayable value
t2 = getEnumStringValue(elemX.Type, elemVal, " ")
if Len(t2) > 0 then
s(F3value) = s(F3value) & LF & LF & txt0237 & LF & t2 & " "
else
t2 = colorComments(elemName, elemVal, showFullString)
if Len(t2) > 0 then
s(F3value) = s(F3value) & LF & LF & t2 & " "
s(F3Color) = elemVal
end if
end if
end if
end if
end if
s(F3notes) = Mid(t, 2)
simplifiedStructureElementString = s()
End Function
XrayTool _Main structure2String Basic propertiesPanelString (Procedure) 42
Function structure2String(ordering As String) As String
Dim elemList As Variant, elemX As Object, v As Variant
Dim x As Long, xMax As Long, accMode As Long
Dim structInf As String
Dim elemComment As String, vError As String, elemVal As String
Dim propReadable As Long ' not yet used but necessary for addShortTypeStr

elemList = classeIDL.Fields
xMax = UBound(elemList)
Dim intf2(xMax) As String
for x = 0 to xMax
elemX = elemList(x)
structInf = elemX.Name
spaceTo(structInf, propTypePos, 1) ' tabulation to "type" column
addShortTypeStr(elemX.Type, structInf, propReadable)
elemComment = ""
accMode = elemX.AccessMode
if accMode = com.sun.star.reflection.FieldAccessMode.WRITEONLY then
elemComment = "write-only, "
else
if accMode = com.sun.star.reflection.FieldAccessMode.READONLY then elemComment = "read-only, "
on Error Goto nogetValue
v = elemX.get(CurrentObj)
on Error Goto 0
vError = preliminaryDataControl(v)
nogetValue2:
getShortStringFromValueOfProperty(elemX, v, vError, elemVal, elemComment)
addValueToDisplay(structInf, elemVal)
end if
intf2(x) = structInf & deleteTrail(elemComment, ", ") & " " ' add a trailing space to simplify code
next
if ordering = "AZ" then ShellSort(intf2())
structure2String = join(intf2(), LF)
Exit Function

nogetValue: ' error in the UNO object
vError = txt0224 & LF & error
Resume nogetValue1
nogetValue1:
on Error Goto 0
GoTo nogetValue2
End Function
XrayTool _Main Xray Basic XrayMenu (Procedure) 31
Sub Xray(Optional ObjX As Variant)
Dim kt As Object, isCompatibilityModeTrue As Boolean

if IsMissing(ObjX) then ' avoid Basic error and show message instead
MsgBox(txt0121, 64, WindowTitle)
Exit Sub
end if

' protect from CompatibilityMode(True) current and future incompatibilities
isCompatibilityModeTrue = True
On Error Resume Next
isCompatibilityModeTrue = testPrivateAccess ' variable testPrivateAccess is in Module Mod2
On Error GoTo 0
if isCompatibilityModeTrue then CompatibilityMode(False)

prepareXray
if isWorthXray(ObjX) then
OriginalObj = ObjX
if initXrayDisplay(ObjX, txt0113, true) then
kt = XrDial.getControl("OriginName")
kt.Text = txt0115
On Error Resume Next
kt.Text =OriginalObj.ImplementationName
On Error Goto 0
XrDial.Execute
XrDial.Dispose
end if
end if
' restore initial CompatibilityMode() if needed
if isCompatibilityModeTrue then CompatibilityMode(True)
End Sub
XrayTool _Main XrayDeeper2 Basic keyOnXrayInfo (Procedure)
showPrettyDisplay (Procedure)
XrayDeeper (Procedure)
MouseReleaseOnDisplay (Procedure)
22
' called by other routines
Sub XrayDeeper2(currentLine As String, firstWord As String)
Dim v As Variant

firstWord = restoreSpaces(firstWord) ' some user-defined properties have spaces, e.g. Info 1 in document properties
if XrayDisplayWhat = "properties" then
if Left(firstWord, 1) = "(" then ' current line is an element of array
XrayThisArrayElement(firstWord) ' simple case, understand it first !
elseif classeIDL.TypeClass = com.sun.star.uno.TypeClass.STRUCT then
XrayThisStructureElement(firstWord) ' simple case
else
XrayThisProperty(firstWord) ' complex case
end if
elseif XrayDisplayWhat = "methods" then
if InStr(1, currentLine, firstWord & ambiguousMethodFlag, 0) = 1 then 'ambiguous method
XrayThisMethod(firstWord, getLastWordOfString(currentLine) ) ' most complex case
else
XrayThisMethod(firstWord, "") ' no need to specify interface, only one method of this name
end if
end if
FocusOnInfoControl
End Sub
XrayTool _Main XrayThisArrayElement Basic XrayDeeper2 (Procedure) 21
Sub XrayThisArrayElement(arrayIndex As String)
Dim qp2 As String, errMess As String
Dim newObj As Variant, idxList As Variant

qp2 = CurrentObjQualifiedName & arrayIndex ' new Object qualified name
if not foundInXrayList(qp2) then
idxList = split(MidP1P2(arrayIndex, 2, Len(arrayIndex) -1), ",") ' get each index value
On Error Goto doesnotwork
newObj = getArrayElement(CurrentObj, UBound(idxList) +1, idxList)
On Error Goto 0
checkAndDisplayNewObject(newObj, qp2)
end if
Exit Sub

doesnotwork:
errMess = Error
Resume doesnotwork1
doesnotwork1:
On Error Goto 0
MsgBox(txt0108 & LF & errMess, 64, WindowTitle) ' Xray does not work with this - error message
End Sub
XrayTool _Main XrayThisMethod Basic XrayDeeper2 (Procedure) 71
Sub XrayThisMethod(methName As String, interf As String)
Dim fullMethName As String, qp2 As String, paramValue As String, paramType As String, errMess As String
Dim info1 As Object, info2 As Object, params As Variant, newObj As Variant, v As Variant

errMess = checkHugeArray(methName)
if Len(errMess) > 0 then GoTo reportError
if Len(interf) = 0 then
fullMethName = methName
else
fullMethName = join(split(interf, "."), "_") & "_" & methName
end if
info1 = introCurrObj.getMethod(fullMethName, com.sun.star.beans.MethodConcept.ALL)
if info1.ReturnType.Name = "void" then
MsgBox(txt0117, 64, WindowTitle) ' Xray impossible, method returns nothing
else
params = info1.ParameterInfos
Select Case UBound(params)
Case -1 ' no parameter : Xray possible
qp2 = CurrentObjQualifiedName & "." & fullMethName & "()"
if foundInXrayList(qp2) then Exit Sub
On Error Goto doesnotwork1
newObj = invocCurrObj.invoke(fullMethName, Array(), Array(), Array() )
On Error Goto 0
checkAndDisplayNewObject(newObj, qp2)
Case 0 ' one parameter, check if usable
info2 = params(0)
if info2.aMode = com.sun.star.reflection.ParamMode.OUT then ' no need to enter a parameter value
qp2 = CurrentObjQualifiedName & "." & fullMethName & "(v)"
On Error Goto doesnotwork1
newObj = invocCurrObj.invoke(fullMethName, Array(v), Array(0), Array(v) ) ' v will be filled by the method but will not be used
On Error Goto 0
checkAndDisplayNewObject(newObj, qp2)
else
paramType = info2.aType.Name
if InStr(1, acceptedParamTypes, "£" & paramType & "£", 0) = 0 then
MsgBox(txt0119, 64, WindowTitle) ' Xray impossible, parameter of unacceptable type
else ' type is supported, ask for parameter value
paramValue = InputBox(txt0228 & paramType, WindowTitle, "")
if paramType = "string" then
qp2 = CurrentObjQualifiedName & "." & fullMethName & "(""" & paramValue & """)"
else
qp2 = CurrentObjQualifiedName & "." & fullMethName & "(" & paramValue & ")"
end if
if foundInXrayList(qp2) then Exit Sub
On Error Goto doesnotwork2
v = CreateUnoValue(paramType, paramValue)
if info2.aMode = com.sun.star.reflection.ParamMode.INOUT then
newObj = invocCurrObj.invoke(fullMethName, Array(v), Array(0), Array(v) )
else ' com.sun.star.reflection.ParamMode.IN
newObj = invocCurrObj.invoke(fullMethName, Array(v), Array(), Array() )
end if
On Error Goto 0
checkAndDisplayNewObject(newObj, qp2)
end if
end if
Case Else
MsgBox(txt0124, 64, WindowTitle) ' Xray impossible, too many parameters
End Select
end if
Exit Sub

doesnotwork1:
errMess = txt0108 & LF & LF & Error
Resume reportError
doesnotwork2:
errMess = txt0111 & LF & LF & Error ' perhaps incorrect parameter value
Resume reportError
reportError:
On Error Goto 0
MsgBox(errMess, 16, WindowTitle) ' error message
End Sub
XrayTool _Main XrayThisProperty Basic XrayDeeper2 (Procedure) 28
Sub XrayThisProperty(propName As String)
Dim info2 As Object, newObj As Variant
Dim propReadable As Long, propKind As Long
Dim propInf As String, vError As String, qp2 As String

if InStr(1, propName, " ", 0) > 0 then ' some user-defined properties have spaces, e.g. Info 1 in document properties
qp2 = CurrentObjQualifiedName & ".getPropertyValue(""" & propName & """)"
else
qp2 = CurrentObjQualifiedName & "." & propName
end if
if foundInXrayList(qp2) then Exit Sub

info2 = introCurrObj.getProperty(propName, com.sun.star.beans.PropertyConcept.ALL)
addShortTypeStr(info2.Type, propInf, propReadable) ' only propReadable will be used
propKind = getPropertyCategory(propName, info2.Attributes) ' check if property name is ambiguous
if propReadable = notReadable then propReadable = OKreadable ' now force to get the value
getValueOfProperty(info2.Name, propReadable, propKind, newObj, vError)
Select Case vError
Case "not readable"
MsgBox(txt0120, 64, WindowTitle) ' xray impossible : pseudo-property is write-only
Case "ambiguous"
MsgBox(replaceTag(txt0243, "getXxx", "get" & propName & "( ) "), 64, WindowTitle) ' xray impossible through property, use method with correct interface
Case ""
checkAndDisplayNewObject(newObj, qp2)
Case Else
MsgBox(vError, 64, WindowTitle)
End Select
End Sub
XrayTool _Main XrayThisStructureElement Basic XrayDeeper2 (Procedure) 26
Sub XrayThisStructureElement(fieldName As String)
Dim elemX As Object, newObj As Variant
Dim accMode As Long, qp2 As String, errMess As String

elemX = classeIDL.getField(fieldName)
accMode = elemX.AccessMode
if accMode = com.sun.star.reflection.FieldAccessMode.WRITEONLY then
MsgBox(txt0120, 64, WindowTitle) ' xray impossible, write-only
else
qp2 = CurrentObjQualifiedName & "." & fieldName
if not foundInXrayList(qp2) then
On Error Goto doesnotwork
newObj = elemX.get(CurrentObj)
On Error Goto 0
checkAndDisplayNewObject(newObj, qp2)
end if
end if
Exit Sub

doesnotwork:
errMess = Error
Resume doesnotwork1
doesnotwork1:
On Error Goto 0
MsgBox(txt0108 & LF & errMess, 64, WindowTitle) ' Xray does not work with this - error message
End Sub
XrayTool _UITexts TextTranslation Basic   3
Sub TextTranslation
MsgBox("Translators should read the module _UITexts ", 48, WindowTitle)
End Sub
XrayTool _Utilities amputeRight Basic XrayDaddyObject (Procedure)
array2String (Procedure)
arrayElement2String (Procedure)
listenersString (Procedure)
7
' returns the string without L rightmost characters
Function amputeRight(fullString As String, L As Long) As String
if (L<0) or (L>Len(fullString)) then
Err = 14 ' exception invalid parameter
end if
amputeRight = Mid(fullString, 1, Len(fullString) - L)
End Function
XrayTool _Utilities CenterDialog Basic initDlgXray (Procedure)
createDialogue (Procedure)
19
' center dialog in main Window, or slightly shifted Right or Down if dialog has a greater dimension
' this routine was initially provided by Berend Cornelius [Berend.Cornelius@sun.com]
' thanks to Peter Eberlein who suggested to use StarDesktop instead of ThisComponent
' adaptation by Bernard Marcelly (last modification : Xray rev 5.3)
Sub CenterDialog(dlg As Object)
Dim mainFrame As Object, dlgSize As Object
Dim XPos As Long, YPos As Long

if IsNull(StarDesktop.CurrentFrame) then exit sub ' Xray may be called at Office loading time
if IsNull(StarDesktop.CurrentFrame.ContainerWindow) then exit sub ' ContainerWindow may be absent !
' Size and positions are measured in pixels
mainFrame = StarDesktop.CurrentFrame.ContainerWindow.OutputSize
dlgSize = dlg.OutputSize
XPos = (mainFrame.Width/2) - (dlgSize.Width/2)
if XPos < 0 then XPos = 0 ' dialog width is equal or greater than parent window width
YPos = (mainFrame.Height/2) - (dlgSize.Height/2)
if YPos < 0 then YPos = 0 ' dialog height is equal or greater than parent window height
dlg.setPosSize(XPos, YPos, 0, 0, com.sun.star.awt.PosSize.POS)
End Sub
XrayTool _Utilities checkHugeArray Basic getValueOfProperty (Procedure)
XrayThisMethod (Procedure)
26
' Prevent from creating an array that would gobble up the memory, see OpenOffice Bug 35533
' returns an error message or empty string
Function checkHugeArray(firstWord As String) As String
Dim ra As Object, nbrCols As Long, nbrRows As Long, nbrCells As Double, t As String
Const danger = "/Data/DataArray/FormulaArray/getData/getDataArray/getFormulaArray/"

checkHugeArray = ""
if InStr(1, danger, "/" & firstWord & "/", 0) = 0 then Exit Function
On Error GoTo noRangeAddr
ra = CurrentObj.RangeAddress
nbrCols = ra.EndColumn -ra.StartColumn +1
nbrRows = ra.EndRow -ra.StartRow +1
nbrCells = CDbl(nbrCols) * CDbl(nbrRows)
' Xray can display less than 65536 characters, and needs more than 17 characters per element of the array
if nbrCells > 4000.0 then ' too big array (probably the whole sheet)
t = replaceTag(txt0126, "%%", "" & nbrCols & " x " & nbrRows & " = " & nbrCells)
checkHugeArray = txt0125 & LF & t
end if
On Error GoTo 0
Exit Function

noRangeAddr: ' same name but not a spreadsheet method/property
Resume Label1
Label1:
On Error GoTo 0
End Function
XrayTool _Utilities CHex Basic Value2Str (Procedure) 14
' convert to hexa with non significant zeros
Function CHex(nbr As Long, digits As Long) As String
Dim s2 As String

s2 = hex(nbr)
if nbr >= 0 then
do While Len(s2) < digits
s2 = "0" & s2
Loop
else
s2 = Right(s2, digits)
end if
CHex = s2
End Function
XrayTool _Utilities colorComments Basic getShortStringFromValueOfProperty (Procedure)
simplifiedStructureElementString (Procedure)
simplifiedPropertyString (Procedure)
21
' if the item contains a color, returns a displayable string
' if showMinimal, returns RGB(r,g,b) only if not (black or no color)
Function colorComments(itemName As String, colorValue As Variant, howToDisplay As Long) As String
Dim t1 As String, t2 As String

t1 = ""
if (InStr(1, itemName, "Color", 0) > 0 ) and (VarType(colorValue) = 3) then ' this is a Color property
if howToDisplay = showFullString then
if colorValue = -1 then ' no color or automatic
t1 = txt0602
elseif (colorValue >= 0) and (colorValue <= 16777215) then
t1 = txt0603 & Red(colorValue) & space(5) & txt0604 & Green(colorValue) & space(5) & txt0605 & Blue(colorValue)
t2 = getColorName(colorValue) ' find color name from palette
if Len(t2) > 0 then t1 = t1 & LF & txt0601 & t2
end if
elseif (colorValue > 0) and (colorValue <= 16777215) then
t1 = "RGB(" & Red(colorValue) & "," & Green(colorValue) & "," & Blue(colorValue) & ")"
end if
end if
colorComments = t1
End Function
XrayTool _Utilities createDialogue Basic initDlgXray (Procedure)
XrayConfigDialog (Procedure)
prettyDisplayPropMethod (Procedure)
findInText (Procedure)
20
' Center argument not used : OpenOffice default, dialog is centered in parent window (document or dialog calling this one).
' Center=False : position dialog at Left+Top from main Window.
' Center=True : center dialog in main Window; if dialog has a greater dimension, position it to Left or/and Top of main Window.
' Note : OpenOffice may re-position a large dialog on the screen in order to optimize its visible area.
Function createDialogue(DialogName as String, SubTitle As String, Optional Center As Boolean)
Dim oLib as Object, dlg as Object

GlobalScope.DialogLibraries.loadLibrary(Libname) ' Libname is defined elsewhere in this library
oLib = GlobalScope.DialogLibraries.getByName(Libname)
dlg = CreateUnoDialog(oLib.getByName(DialogName))
if Len(SubTitle) = 0 then
dlg.Model.Title = WindowTitle ' WindowTitle is defined elsewhere in this library
else
dlg.Model.Title = WindowTitle & Space(10) & "- " & SubTitle & " -"
end if
if not isMissing(Center) then
if Center then CenterDialog(dlg) else dlg.setPosSize(0, 0, 0, 0, com.sun.star.awt.PosSize.POS)
end if
createDialogue = dlg
End Function
XrayTool _Utilities deleteTrail Basic BrowseSDK2 (Procedure)
array2String (Procedure)
propertiesPanelString (Procedure)
structure2String (Procedure)
properties2String (Procedure)
methodsString (Procedure)
interfacesString (Procedure)
simplifiedArrayElementString (Procedure)
simplifiedMethodString (Procedure)
findInterfaceOfAttribute (Procedure)
11
' if the string terminates with end1, returns the string whithout end1  else return string unchanged
Function deleteTrail(s As String, end1 As String) As String
Dim e As String

e = Right(s, Len(end1))
if e = end1 then
deleteTrail = Mid(s, 1, Len(s) -Len(end1))
else
deleteTrail = s
end if
End Function
XrayTool _Utilities enableControls Basic propertiesPanelString (Procedure)
changeDisplay (Procedure)
XrayMenu (Procedure)
8
Sub enableControls(dlg As Object, ControlsNamesList As Variant, newState As Boolean)
Dim k As Object, n As Long

for n = 0 to UBound(ControlsNamesList)
k = dlg.getControl(ControlsNamesList(n))
k.Enable = newState
next
End Sub
XrayTool _Utilities exploreInterfacesOfInterface Basic interfacesString (Procedure) 16
' recursive search
' INOUT parameter : foundInterfaces (list)
' adds the names of this interface and its ancestors
Sub exploreInterfacesOfInterface(intfName As String, foundInterfaces As String)
Dim x As Long, intf As Object, allBaseInterfaces As Variant

if InStr(1, foundInterfaces, LF & intfName & " " & LF, 0) > 0 then Exit Sub 'interface already explored
intf = OOoReflection.forName(intfName)
if intf.TypeClass = com.sun.star.uno.TypeClass.INTERFACE then ' getTypes may return other than interfaces...
foundInterfaces = foundInterfaces & intfName & " " & LF ' add trailing space to simplify code
allBaseInterfaces = intf.getSuperClasses() ' base interfaces are interfaces herited by this interface
for x = 0 to UBound(allBaseInterfaces)
exploreInterfacesOfInterface(allBaseInterfaces(x).Name, foundInterfaces) ' ... until no more base interfaces
next
end if
End Sub
XrayTool _Utilities exploreServicesOfService Basic servicesString (Procedure) 21
' recursive search
' INOUT parameter : foundServices (list)
' adds the names of this service and its ancestors
Sub exploreServicesOfService(servName As String, foundServices As String)
Dim servDescr As Object, allBaseServ As Variant
Dim x As Long

if InStr(1, foundServices, LF & servName & " " & LF, 0) > 0 then Exit Sub 'interface already explored
foundServices = foundServices & servName & " " & LF ' add trailing space to simplify code
if OOoTypeDescr.hasByHierarchicalName(servName) then
servDescr = OOoTypeDescr.getByHierarchicalName(servName)
allBaseServ = servDescr.MandatoryServices
for x = 0 to UBound(allBaseServ)
exploreServicesOfService(allBaseServ(x).Name, foundServices)
next
allBaseServ = servDescr.OptionalServices
for x = 0 to UBound(allBaseServ)
exploreServicesOfService(allBaseServ(x).Name, foundServices)
next
end if
End Sub
XrayTool _Utilities FindFirstFindNext Basic DlgFind|FindFirstBtn (Control)
DlgFind|FindNextBtn (Control)
9
' routine triggered by buttons FindFirstBtn and FindNextBtn in DlgFind
Sub FindFirstFindNext(evt As Object)
Dim dlg As Object, k As Object

k = evt.Source
dlg = k.Context
dlg.Model.Tag = k.Model.Name
dlg.endExecute
End Sub
XrayTool _Utilities findInterfaceOfAttribute Basic FindPropertyDoc (Procedure)
explainAttribute (Procedure)
31
Function findInterfaceOfAttribute(attribName As String) As String
Dim foundInterface As String, methInterfaces As String, intfName As String, allMainInterfaces As Variant
Dim x As Long

allMainInterfaces = Array()
On Error Resume Next ' some bizarre UNO objects don't have getTypes() ...
allMainInterfaces = CurrentObj.getTypes()
On Error GoTo 0
methInterfaces = LF
foundInterface = ""
if UBound(allMainInterfaces) >= 0 then
for x = 0 to UBound(allMainInterfaces)
intfName = allMainInterfaces(x).Name
searchForAttribute(attribName, intfName, methInterfaces, foundInterface)
if Len(foundInterface) > 0 then Exit For ' no need to search other interfaces (we do not look for name conflicts)
next
else ' as an alternative, use interfaces of methods
if Len(allMethodsNamesInterfaces) > 0 then ' allMethodsNamesInterfaces contains : £name1£interface1££name2£interface2££nameN£interfaceN£
allMainInterfaces = split(deleteTrail(allMethodsNamesInterfaces, "£"), "££") ' one array element per name+interface
for x = 0 to UBound(allMainInterfaces)
y = InStr(2, allMainInterfaces(x), "£", 0) ' search second £
intfName = Mid(allMainInterfaces(x), y+1) ' keep only the interface name
searchForAttribute(attribName, intfName, methInterfaces, foundInterface)
if Len(foundInterface) > 0 then Exit For ' no need to search other interfaces (we do not look for name conflicts)
next
else
' no GetTypes() and no methods !
end if
end if
findInterfaceOfAttribute = foundInterface
End Function
XrayTool _Utilities findInText Basic keyOnXrayInfo (Procedure)
keyOnDlgVal (Procedure)
57
Sub findInText(controlText As Object)
Dim sel As Object, FindDial As Object, k As Object
Dim theText As String, selectedTerm As String, searchTerm As String, button As String
Dim x As Long, startPos As Long

theText = controlText.Text
sel = controlText.Selection
if sel.Min < sel.Max then
selectedTerm = MidP1P2(theText, sel.Min +1, sel.Max)
if InStr(1, LF & searchTexts & LF, LF & selectedTerm & LF, 1) = 0 then
if Len(searchTexts) > 0 then
searchTexts = selectedTerm & LF & searchTexts
else
searchTexts = selectedTerm
end if
end if
else
selectedTerm = ""
end if
if InStr(1, selectedTerm, LF, 0) > 0 then Exit Sub ' ignore search if selection spans several lines
x = -1
Do
if (Len(selectedTerm) > 0) and (x <> 0) then
startPos = sel.Min +Len(selectedTerm) +1
searchTerm = selectedTerm
else
FindDial = createDialogue("DlgFind", txt0265)
if x = 0 then FindDial.Model.Step = 2 else FindDial.Model.Step = 1
k = FindDial.getControl("FindComboBox")
if Len(searchTexts) > 0 then k.Model.StringItemList = split(searchTexts, LF)
k.Text = searchTerm
FindDial.execute
searchTerm = k.Text
if InStr(1, LF & searchTexts & LF, LF & searchTerm & LF, 1) = 0 then
if Len(searchTexts) > 0 then
searchTexts = searchTerm & LF & searchTexts
else
searchTexts = searchTerm
end if
end if
button = FindDial.Model.Tag
FindDial.dispose
Select Case button
Case "FindFirstBtn"
startPos = 1
Case "FindNextBtn"
startPos = sel.Min +2
Case Else
Exit Sub
End Select
end if
x = InStr(startPos, theText, searchTerm, 1) ' search case indifferent
Loop Until x > 0
sel.Min = x -1
sel.Max = x +Len(searchTerm) -1
controlText.Selection = sel
End Sub
XrayTool _Utilities findServiceOfRealProperty Basic FindPropertyDoc (Procedure)
explainRealProperty (Procedure)
16
Function findServiceOfRealProperty(propName As String) As String
Dim allSupportedServices As Variant
Dim x As Long, servName As String, foundService As String

allSupportedServices = Array()
On Error Resume Next
allSupportedServices = CurrentObj.getSupportedServiceNames
On Error GoTo 0
foundService = ""
for x = 0 to UBound(allSupportedServices)
servName = allSupportedServices(x)
searchPropertyInService(propName, servName, foundService)
if Len(foundService) > 0 then Exit For
next
findServiceOfRealProperty = foundService
End Function
XrayTool _Utilities firstWordInCurrentLine Basic BrowseSDK (Procedure)
keyOnXrayInfo (Procedure)
showPrettyDisplay (Procedure)
XrayDeeper (Procedure)
MouseReleaseOnDisplay (Procedure)
15
' OUT parameters : currentLine firstWord
Sub firstWordInCurrentLine(currentLine As String, firstWord As String)
Dim y2 As Long

currentLine = getCurrentLineInInfos(False)
y2 = InStr(1, currentLine, " ", 0) ' search end of word
Select Case y2
Case 0 ' probably no character in currentLine (abnormal case)
firstWord = ""
Case 1 ' comment line, can be found with service or interface display
firstWord = ""
Case Else
firstWord = Left(currentLine, y2 - 1)
End Select
End Sub
XrayTool _Utilities getColorName Basic colorComments (Procedure) 15
Function getColorName(color As Long) As String
Dim ct As Object, colNames As Variant
Dim x As Long, colx As Long, t As String

t = ""
ct = CreateUnoService("com.sun.star.drawing.ColorTable")
colNames = ct.ElementNames
for x = 0 to UBound(colNames)
colx = ct.getByName(colNames(x))
if colx = color then ' color found in palette
t = t & " / " & colNames(x) ' the same color may have different names
end if
next
getColorName = Mid(t, 4)
End Function
XrayTool _Utilities getInfo Basic   13
' this routine returns a text info between two text markers
' startMk terminates at beginning of text info, endMk begins after text info
Function getInfo(bigText As String, startMk As String, endMk As String) As String
Dim x1 As Integer, x2 As Integer

getInfo = ""
x1 = InStr(1, bigText, startMk, 0)
if x1 = 0 then exit function
x1 = x1 +Len(startMk) ' get position of beginning of text info
x2 = InStr(x1, bigText, endMk, 0) ' get position after end of text info
if x2 = 0 then exit function
getInfo = MidP1P2(bigText, x1, x2 -1)
End Function
XrayTool _Utilities getLastWordOfString Basic BrowseSDK2 (Procedure)
simplifiedMethodString (Procedure)
XrayDeeper2 (Procedure)
6
Function getLastWordOfString(currentLine As String) As String
Dim v As Variant

v = split(Trim(currentLine), " ")
getLastWordOfString = v(UBound(v))
End Function
XrayTool _Utilities isControlEnabled Basic BrowseSDK2 (Procedure)
keyOnXrayInfo (Procedure)
MouseReleaseOnDisplay (Procedure)
keyOnDlgVal (Procedure)
6
Function isControlEnabled(dlg As Object, controlName As String) As Boolean
Dim k As Object

k = dlg.getControl(controlName)
isControlEnabled = k.isEnabled()
End Function
XrayTool _Utilities MidP1P2 Basic getAPInameAfter (Procedure)
getAPInameFrom (Procedure)
getCurrentLineInInfos (Procedure)
getPseudoPropInterface (Procedure)
simplifiedArrayElementString (Procedure)
XrayThisArrayElement (Procedure)
findInText (Procedure)
getInfo (Procedure)
5
' returns the substring starting at position p1, ending at position p2
Function MidP1P2(fullString As String, p1 As Long, p2 As Long) As String
if p2<p1 then Err = 14 ' exception invalid parameter
MidP1P2 = Mid(fullString, p1, p2-p1+1)
End Function
XrayTool _Utilities replaceSpaces Basic properties2String (Procedure) 3
Function replaceSpaces(s As String) As String
replaceSpaces = join(split(s, " "), chr(160) )
End Function
XrayTool _Utilities replaceTag Basic FindPropertyDoc (Procedure)
IDLindexesLoadedFromWeb (Procedure)
explainPseudoPropertyCaracteristics (Procedure)
XrayThisProperty (Procedure)
checkHugeArray (Procedure)
11
' returns a string where first occurrence of tag is replaced by replacement
Function replaceTag(aText As String, tag As String, ByVal replacement As String) As String
Dim x As Long

x = InStr(1, aText, tag, 0)
if x = 0 then
replaceTag = aText ' no change
else
replaceTag = Left(aText, x-1) & replacement & Mid(aText, x +len(tag))
end if
End Function
XrayTool _Utilities restoreSpaces Basic BrowseSDK2 (Procedure)
prettyDisplayPropMethod (Procedure)
XrayDeeper2 (Procedure)
3
Function restoreSpaces(s As String) As String
restoreSpaces = join(split(s, chr(160)), " " )
End Function
XrayTool _Utilities searchForAttribute Basic findInterfaceOfAttribute (Procedure) 23
' recursive search
' INOUT parameter : methInterfaces, foundInterface
' returns the name of the interface exporting this attribute
Sub searchForAttribute(attribName As String, intfName As String, methInterfaces As String, foundInterface As String)
Dim intf As Object, allBaseInterfaces As Variant, attrib As Object
Dim x As Long

if InStr(1, methInterfaces, LF & intfName & LF, 0) > 0 then Exit Sub ' interface already analysed
methInterfaces = methInterfaces & intfName & LF
intf = OOoReflection.forName(intfName)
if intf.TypeClass = com.sun.star.uno.TypeClass.INTERFACE then
attrib = intf.getField(attribName)
if not IsNull(attrib) then ' the attribute may be defined in this interface or in one of its base interfaces
foundInterface = intfName
allBaseInterfaces = intf.getSuperClasses() ' base interfaces are interfaces herited by this interface
for x = 0 to UBound(allBaseInterfaces)
intfName = allBaseInterfaces(x).Name
searchForAttribute(attribName, intfName, methInterfaces, foundInterface) ' ... until no more base interfaces or attribute not found
next
Exit Sub ' no need to search other interfaces (we do not look for name conflicts)
end if
end if
End Sub
XrayTool _Utilities searchPropertyInService Basic findServiceOfRealProperty (Procedure) 30
' recursive search
' INOUT parameter : foundService
' returns the name of the service exporting this property
Sub searchPropertyInService(propName As String, servName As String, foundService As String)
Dim servDescr As Object, allProps As Variant, allBaseServ As Variant
Dim x As Long

if OOoTypeDescr.hasByHierarchicalName(servName) then
servDescr = OOoTypeDescr.getByHierarchicalName(servName)
allProps = servDescr.Properties
for x = 0 to UBound(allProps)
if allProps(x).Name = servName & "." & propName then ' this service exports this property
foundService = servName
' a property is declared in its service, it does not reflect a property of an included service -> no need to search deeper
Exit Sub
end if
next
' not found : search in included services
allBaseServ = servDescr.MandatoryServices
for x = 0 to UBound(allBaseServ)
searchPropertyInService(propName, allBaseServ(x).Name, foundService)
if Len(foundService) > 0 then Exit Sub
next
allBaseServ = servDescr.OptionalServices
for x = 0 to UBound(allBaseServ)
searchPropertyInService(propName, allBaseServ(x).Name, foundService)
if Len(foundService) > 0 then Exit Sub
next
end if
End Sub
XrayTool _Utilities ShellSort Basic structure2String (Procedure)
properties2String (Procedure)
methodsString (Procedure)
listenersString (Procedure)
servicesString (Procedure)
interfacesString (Procedure)
24
' sorts a list of strings without case distinction
Sub ShellSort(myList())
Dim k1 As Integer, k2 As Integer, listSize As Integer
Dim x1 As Integer, isSorted As Boolean
Dim swapping
' this routine can be adapted to sort any kind of list
listSize = UBound(myList()) +1 -LBound(myList())
k1 = Fix(listSize /2)
do while k1 > 0
k2 = UBound(myList()) - k1
isSorted = true
for x1 = LBound(myList()) to k2
if StrComp(myList(x1), myList(x1 +k1), 0) = 1 then
swapping = myList(x1)
myList(x1) = myList(x1 +k1)
myList(x1 +k1) = swapping
isSorted = false
end if
next
if isSorted then
k1 = Fix(k1 /2)
end if
loop
End Sub
XrayTool _Utilities spaceTo Basic TextOfElemX (Procedure)
Value2Str (Procedure)
propertiesPanelString (Procedure)
structure2String (Procedure)
properties2String (Procedure)
methodsString (Procedure)
listenersString (Procedure)
methodsUsingAnyListener (Procedure)
changeDisplay (Procedure)
12
' right fills thisString with spaces to obtain a tabulation position tabPos
' modifies : thisString
Sub spaceTo(thisString As String, tabPos As Long, minimalSpace As Long)
Dim p As Long, sp As String

p = tabPos - Len(thisString) -1
if p >= minimalSpace then
thisString = thisString + Space(p)
else
thisString = thisString + Space(minimalSpace)
end if
End Sub
XrayTool _Utilities textFromUniqueStrings Basic listenersString (Procedure) 11
' returns a multi-lines string from unique strings of array listOfStrings
Function textFromUniqueStrings(listOfStrings As Variant) As String
Dim s As String, t As String, x As Long

s = LF
for x = 0 to UBound(listOfStrings)
t = listOfStrings(x) & LF
if InStr(1, s, LF & t, 0) = 0 then s = s & t ' add only if this string is not already in the concatenated list
next
textFromUniqueStrings = Mid(s, 2, Len(s) -2) ' suppress LF from both ends
End Function
XrayTool Mod2 array2String Basic TextOfElemX (Procedure)
Value2Str (Procedure)
55
Function array2String(ObjX1 As Variant, abbreviated As Boolean) As String
Dim s As String, header As String, margin As String, typ As String
Dim n As Long, x1 As Long, x2 As Long, x3 As Long, x4 As Long, x5 As Long
Const nbMaxIndexes = 5 ' max supported dimensions
Dim indexesMin(20) As Long, indexesMax(20) As Long ' max displayable dimensions in first line

if abbreviated then margin = "" else margin = Space(Spaces1stLine)
typ = deleteTrail( LCase(TypeName(ObjX1)), "()" )
if UBound(ObjX1) >= LBound(ObjX1) then
header = margin & txt0210 ' Array(
n = 0
On Error Goto maxDim
Do ' explore successive indexes
n = n+1
indexesMin(n) = LBound(ObjX1, n)
indexesMax(n) = UBound(ObjX1, n)
header = header & indexesMin(n) & " To " & indexesMax(n) & ", "
Loop ' loop ends with an exception
maxDim:
Resume label3
label3:
On Error Goto 0
header = amputeRight(header, 2) ' delete trailing comma and space
header = header & " ) " & "As " & typ & " "
array2String = header
if abbreviated then Exit Function
n = n-1 ' existing dimensions
if n > nbMaxIndexes then
array2String = header & LF & LF & margin & txt0213 ' too many dimensions
Exit Function
end if
' explore each array element and show it as a string
s = " " & emptyLine
for x1 = indexesMin(1) to indexesMax(1)
for x2 = indexesMin(2) to indexesMax(2)
for x3 = indexesMin(3) to indexesMax(3)
for x4 = indexesMin(4) to indexesMax(4)
for x5 = indexesMin(5) to indexesMax(5)
' each Xrayable line must start with a non space character. Here : "("
s = s & LF & arrayElement2String(ObjX1, n, Array(x1,x2,x3,x4,x5))
if Len(s) > 65000 then ' a string contains max 65535 characters
header = header & LF & LF & margin & txt0212 ' too many elements, do not display more
array2String = header & s
Exit Function
end if
next
next
next
next
next
array2String = header & s
else ' empty array
array2String = margin & txt0201 & typ & " : " & emptyValStr
end if
End Function
XrayTool Mod2 arrayElement2String Basic array2String (Procedure) 10
Function arrayElement2String(v As Variant, n As Long, idxList As Variant) As String
Dim x As Long, r As String

r = "("
for x = 1 to n
r = r & idxList(x-1) & ","
next
r = amputeRight(r,1) & ")"
arrayElement2String = TextOfElemX( getArrayElement(v, n, idxList), r)
End Function
XrayTool Mod2 exitPrettyDisplay Basic DlgVal|APIdocBtn4 (Control)
DlgVal|APIdocBtn3 (Control)
DlgVal|XrayBtn3 (Control)
DlgVal|XrayBtn4 (Control)
9
' routine triggered by : XrayBtn3 APIdocBtn3 XrayBtn4 APIdocBtn4 in DlgVal
Sub exitPrettyDisplay(evt As Object)
Dim k As Object, dlg As Object

k = evt.Source
dlg = k.Context
dlg.Model.Tag = k.Model.Tag
dlg.endExecute
End Sub
XrayTool Mod2 fullyQualifiedName Basic TextOfElemX (Procedure) 9
Function fullyQualifiedName(elem As Variant) As String
Dim classeIDL As Object

fullyQualifiedName = txt0115
On Error Resume Next
classeIDL = OOoReflection.getType(elem)
fullyQualifiedName = classeIDL.Name
On Error GoTo 0
End Function
XrayTool Mod2 getArrayElement Basic arrayElement2String (Procedure)
simplifiedArrayElementString (Procedure)
XrayThisArrayElement (Procedure)
14
Function getArrayElement(v As Variant, n As Long, idxList As Variant) As Variant
Select Case n
Case 1
getArrayElement = v(idxList(0))
Case 2
getArrayElement = v(idxList(0),idxList(1))
Case 3
getArrayElement = v(idxList(0),idxList(1),idxList(2))
Case 4
getArrayElement = v(idxList(0),idxList(1),idxList(2),idxList(3))
Case 5
getArrayElement = v(idxList(0),idxList(1),idxList(2),idxList(3),idxList(4))
End Select
End Function
XrayTool Mod2 getEnumStringValue Basic getShortStringFromValueOfProperty (Procedure)
simplifiedStructureElementString (Procedure)
simplifiedPropertyString (Procedure)
21
Function getEnumStringValue(typeOfValue As Object, theValue As Variant, prefix As String) As String
Dim rfl As Object, enufs As Variant, enux As Object
Dim enumString As String, x As Long

getEnumStringValue = ""
if IsEmpty(theValue) or IsNull(theValue) then Exit Function
if showAll then
if typeOfValue.TypeClass = com.sun.star.uno.TypeClass.ENUM then
enumString = typeOfValue.Name
rfl = OOoReflection.forName(enumString)
enufs = rfl.Fields
for x = 0 to UBound(enufs)
enux = enufs(x)
if theValue = enux.get(0) then
getEnumStringValue = prefix & enumString & "." & enux.Name
Exit Function
end if
next
end if
end if
End Function
XrayTool Mod2 getShortStringFromValueOfProperty Basic structure2String (Procedure)
properties2String (Procedure)
29
' OUT parameter : propValue
' INOUT parameter : propComment
Sub getShortStringFromValueOfProperty(info2 As Object, v As Variant, vError As String, propValue As String, propComment As String)
Dim e As String

if Len(vError) = 0 then
propValue = Value2Str(v, showMinimal)
e = getEnumStringValue(info2.Type, v, enumInfo)
if Len(e) > 0 then propComment = propComment & e & ", "
e = colorComments(info2.Name, v, showMinimal)
if Len(e) > 0 then propComment = propComment & e & ", "
elseif vError = "not readable" then
propValue = ""
elseif vError = "ambiguous" then
propValue = ""
elseif vError = txt0227 then ' empty
propValue = emptyValStr
elseif vError = txt0202 then ' null
propValue = nullValStr
elseif vError = txt0209 then ' empty string
propValue = """"""
elseif vError = txt0226 then ' empty array
propValue = emptyValStr
elseif InStr(1, vError, txt0125, 0) = 1 then ' huge array
propValue = ""
else ' error in the UNO object
propValue = "<error>"
end if
End Sub
XrayTool Mod2 isWorthXray Basic Xray (Procedure)
checkAndDisplayNewObject (Procedure)
13
' Displays a diagnostic message in obvious cases
' Note : arg ObjX1 is mandatory ! Optional only to handle error case VarType = 10
Function isWorthXray(Optional ObjX1 As Variant) As Boolean
Dim errMess As String

errMess = preliminaryDataControl(ObjX1)
if Len(errMess) = 0 then
isWorthXray = True
else
MsgBox(errMess, 64, WindowTitle) ' show diagnostic
isWorthXray = False
end if
End Function
XrayTool Mod2 keyOnDlgVal Basic DlgVal|PropValue (Control)
DlgVal|PropertyNotes (Control)
DlgVal|MethodParams (Control)
DlgVal|MethodNotes (Control)
23
' routine triggered by event ButtonPressed on text controls of DlgVal
Sub keyOnDlgVal(evt As Object)
Dim dlg As Object, keyed As Long

dlg = evt.Source.Context
keyed = evt.KeyCode
if evt.Modifiers = com.sun.star.awt.KeyModifier.MOD1 then keyed = -keyed ' Ctrl key was also pushed
Select Case keyed
Case -com.sun.star.awt.Key.F1 ' Ctrl-F1 : find API documentation
if isControlEnabled(dlg, "APIdocBtn" & dlg.Model.Step) then
dlg.Model.Tag = "API"
dlg.endExecute
end if
Case -com.sun.star.awt.Key.F ' Ctrl-F : find term in one of the text controls of DlgVal
dlg = evt.Source.Context
findInText(evt.Source)
Case com.sun.star.awt.Key.F5
if isControlEnabled(dlg, "XrayBtn" & dlg.Model.Step) then
dlg.Model.Tag = "Xray"
dlg.endExecute
end if
End Select
End Sub
XrayTool Mod2 preliminaryDataControl Basic isWorthXray (Procedure)
structure2String (Procedure)
getValueOfProperty (Procedure)
simplifiedStructureElementString (Procedure)
21
' returns empty string or error message. Note :  arg ObjX1 is mandatory ! Optional only to handle error case VarType = 10
Function preliminaryDataControl(Optional ObjX1 As Variant) As String
Dim errMess As String

if isEmpty(ObjX1) then
errMess = txt0227
elseif IsNull(ObjX1) then
errMess = txt0202
elseif VarType(ObjX1) = 10 then ' Basic "Error" type
errMess = txt0208
elseif VarType(ObjX1) = 8 then ' string
if Len(ObjX1) = 0 then errMess = txt0209 ' empty string
elseif VarType(ObjX1) = 37 then ' decimal type : not supported by OOoReflection.getType(ObjX1)
errMess = txt0207 & ObjX1
elseif IsArray(ObjX1) then
if UBound(ObjX1) < 0 then errMess = txt0226 ' empty array
else
errMess = ""
end if
preliminaryDataControl = errMess
End Function
XrayTool Mod2 prettyDisplayPropMethod Basic keyOnXrayInfo (Procedure)
showPrettyDisplay (Procedure)
81
' returns "" or "Xray" or "API"
Function prettyDisplayPropMethod(currentLine As String, firstWord As String) As String
Dim ValDial As Object, k As Object, s As Variant

prettyDisplayPropMethod = ""

if XrayDisplayWhat = "properties" then
if Left(firstWord, 1) = "(" then ' current line is an element of array
s = simplifiedArrayElementString(firstWord)
ValDial = createDialogue("DlgVal", txt0261)
ValDial.Model.Step = 3
setDisplayFont(ValDial, "PropValue")
ValDial.getControl("ObjPath").Text = CurrentObjQualifiedName & firstWord
ValDial.getControl("Indication1").Text = ""
ValDial.getControl("Indication2").Text = ""
ValDial.getControl("APIdocBtn3").Enable = False
elseif classeIDL.TypeClass = com.sun.star.uno.TypeClass.STRUCT then
s = simplifiedStructureElementString(firstWord)
ValDial = createDialogue("DlgVal", txt0260)
ValDial.Model.Step = 3
setDisplayFont(ValDial, "PropValue")
ValDial.getControl("ObjPath").Text = CurrentObjQualifiedName & "." & s(F3name)
ValDial.getControl("Indication1").Text = ""
ValDial.getControl("Indication2").Text = ""
if Len(s(F3Color)) > 0 then
k = ValDial.getControl("ColorPatch")
k.Model.BackGroundColor = CLng(s(F3Color))
end if
else ' property or attribute or pseudo-property
firstWord = restoreSpaces(firstWord) ' some user-defined properties have spaces, e.g. Info 1 in document properties
s = simplifiedPropertyString(firstWord)
ValDial = createDialogue("DlgVal", txt0262)
ValDial.Model.Step = 3
setDisplayFont(ValDial, "PropValue")
if InStr(1, s(F3name), " ", 0) > 0 then ' some user-defined properties have spaces, e.g. Info 1 in document properties
ValDial.getControl("ObjPath").Text = CurrentObjQualifiedName & ".getPropertyValue(""" & s(F3name) & """)"
else
ValDial.getControl("ObjPath").Text = CurrentObjQualifiedName & "." & s(F3name)
end if
if Len(s(F3attribProp)) > 0 then ' attribute or real property
ValDial.getControl("Indication1").Text = ""
ValDial.getControl("Indication2").Text = ""
ValDial.getControl("PropAttr").Text = s(F3attribProp)
elseif Len(s(F3get)) > 0 then ' pseudo-property getXxx, or getXxx and setXxx
ValDial.getControl("Indication1").Text = s(F3get)
ValDial.getControl("Indication2").Text = s(F3set)
ValDial.getControl("PropAttr").Text = ""
elseif Len(s(F3set)) > 0 then 'set Xxx only
ValDial.getControl("Indication1").Text = s(F3set)
ValDial.getControl("Indication2").Text = ""
ValDial.getControl("PropAttr").Text = ""
end if
if Len(s(F3Color)) > 0 then
k = ValDial.getControl("ColorPatch")
k.Model.BackGroundColor = CLng(s(F3Color))
end if
end if
ValDial.getControl("PropValue").Text = s(F3value)
ValDial.getControl("PropertyType").Text = txt0203 & s(F3type)
ValDial.getControl("PropertyName").Text = s(F3name)
ValDial.getControl("ImportantInfo").Text = s(F3important)
ValDial.getControl("PropertyNotes").Text = s(F3notes)
ValDial.getControl("XrayBtn3").Enable = (Len(s(F3canXray)) = 0)
elseif XrayDisplayWhat = "methods" then
s = simplifiedMethodString(firstWord, currentLine)
ValDial = createDialogue("DlgVal", txt0263)
ValDial.Model.Step = 4
setDisplayFont(ValDial, "MethodParams")
ValDial.getControl("ObjPath").Text = CurrentObjQualifiedName & "." & s(F3name)
ValDial.getControl("MethodName").Text = s(F3name)
ValDial.getControl("MethodParams").Text = s(F3parameters)
ValDial.getControl("ReturnedType").Text = s(F3type)
ValDial.getControl("SupportingInterface").Text = s(F3Interface_Service)
ValDial.getControl("MethodNotes").Text = s(F3Notes)
ValDial.getControl("XrayBtn4").Enable = (Len(s(F3canXray)) = 0)
end if

ValDial.Execute
prettyDisplayPropMethod = ValDial.Model.Tag
ValDial.Dispose
End Function
XrayTool Mod2 TextOfElemX Basic arrayElement2String (Procedure) 41
'  Note :  arg aVal is mandatory ! Optional only to handle error case VarType = 10
Function TextOfElemX(Optional aVal As Variant, ByVal s As String) As String
Dim elemName As String, elemValue As String, el2 as variant

spaceTo(s, Spaces1stLine +1, 1) ' pretty display
s = s & ArrayIndexSeparator
if IsArray(aVal) then
TextOfElemX = s & array2String(aVal, True)
elseif VarType(aVal) = 10 then ' the analyzed data is incorrect
TextOfElemX = s & errorValStr & " "
elseif IsEmpty(aVal) then
TextOfElemX = s & emptyValStr & " "
elseif VarType(aVal) = 9 then ' object
if IsNull(aVal) then
TextOfElemX = s & ArrayElementObj & nullValStr
else
elemName = ""
elemValue = ""
el2 = aVal ' intermediate variable is workaround to Basic interpreter bug
On Error Resume Next ' find name and value if exists (propertyValue, etc)
elemName = " --> " & el2.Name
if len(elemName) = 0 then elemName = " --> " & el2.HumanPresentableName ' TransferFlavors
elemValue = Value2Str(el2.Value, showMinimal)
On Error GoTo 0
if Len(elemValue) > 0 then
if Len(elemName)<32 then
elemValue = Space(33 -Len(elemName)) & elemValue
else
elemValue = " " & elemValue
end if
end if
if IsUnoStruct(aVal) then
TextOfElemX = s & ArrayElementStruct & fullyQualifiedName(aVal) & elemName & elemValue & " "
else
TextOfElemX = s & ArrayElementObj & fullyQualifiedName(aVal) & elemName & elemValue & " "
end if
end if
else
TextOfElemX = s & LCase(TypeName(aVal)) & " : " & Value2Str(aVal, showHexaValue)
end if
End Function
XrayTool Mod2 Value2Str Basic TextOfElemX (Procedure)
getShortStringFromValueOfProperty (Procedure)
propertiesPanelString (Procedure)
simplifiedArrayElementString (Procedure)
simplifiedStructureElementString (Procedure)
simplifiedPropertyString (Procedure)
57
' parameter howToDisplay may contain showFullString + showHexaValue
' Note : arg aVal is mandatory ! Optional only to handle error case VarType = 10
Function Value2Str(Optional aVal As Variant, howToDisplay As Long) As String
Dim result As String, VarType2HexaLength As Variant, x As Long

VarType2HexaLength = Array(0,0,4,8,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
' values of VarType 0 10 20 30 40
result = ""
if IsArray(aVal) then
if UBound(aVal) < LBound(aVal) then
result = emptyValStr
elseif (howToDisplay and showFullString) <> 0 then
result = array2String(aVal, False)
end if
else
Select Case VarType(aVal)
Case 0
result = emptyValStr
Case 1
result = nullValStr
Case 2,3,4,5,6,11,17,18,19,35,37 ' Integer, Long, Single, Double, Currency, Boolean, Byte, UShort, ULong, INT64, Decimal
result = LTrim(Str(aVal))
x = VarType2HexaLength(VarType(aVal))
if (x > 0) and ((howToDisplay and showHexaValue) <> 0) then
spaceTo(result, 12, 1)
result = result & txt0204 & CHex(aVal, x) ' hexadecimal equivalent
end if
Case 8 ' String
if (howToDisplay and showFullString) <> 0 then
result = aVal
elseif (InStr(1, aVal, LF, 0) > 0) or (InStr(1, aVal, chr(13), 0) > 0) or (Len(aVal) > 200) then
result = tooWideStr
else
result = """" & aVal & """"
end if
Case 9 ' object
if IsNull(aVal) then result = nullValStr else result = ""
Case 10 ' the analyzed data is incorrect
result = errorValStr
Case 16 ' Char
result = """" & chr(aVal) & """"
if (howToDisplay and showHexaValue) <> 0 then
spaceTo(result, 12, 1)
result = result & txt0204 & CHex(aVal, 4) ' hexadecimal equivalent
end if
Case else
if IsEmpty(aVal) then
result = emptyValStr
elseif IsNull(aVal) then
result = nullValStr
else ' unknown type, will have to be handled in next revision !
result = "Type=" & VarType(aVal) & ":" & LCase(TypeName(aVal))
end if
End Select
end if
Value2Str = result
End Function
XrayTool Mod3 CallBrowser Basic BrowseSDK2 (Procedure)
FindStructureDoc (Procedure)
FindPropertyDoc (Procedure)
displayAlternateDoc (Procedure)
27
Sub CallBrowser(goal As String, ByVal webPage As String, Optional internalLink as String)
Dim launchBr As Object, choiceBr As Long

if FileExists(webPage) then
if not IsMissing(internalLink) then webPage = webPage & "#" & internalLink
launchBr = CreateUnoService("com.sun.star.system.SystemShellExecute")
choiceBr = CLng(BrowserAddress(0))
On Error GoTo browserKO
' note : webPage is an URL, BrowserAddress(n) is a system specific address
if choiceBr < 10 then ' method 1 ( preferred, usually works )
launchBr.execute(BrowserAddress(choiceBr), webPage, 0) ' Native address for browser
else ' method 2 (alternate, could work for some systems)
choiceBr = choiceBr -10
shell(convertToURL(BrowserAddress(choiceBr)), 4, webPage) ' URL address for browser.
end if
On Error GoTo 0
else
MsgBox(txt0105 & goal, 64, WindowTitle) ' could not find a page
end if
Exit Sub

browserKO:
Resume Label1
Label1:
MsgBox(txt0312, 16, WindowTitle) ' configuration problem
On Error GoTo 0
End Sub
XrayTool Mod3 changeDialogWidthHeight Basic DlgXray|ScrollBarH (Control)
DlgXray|ScrollBarW (Control)
12
'  routine triggered by event : value change on control ScrollBarH or ScrollBarW
Sub changeDialogWidthHeight(evt As Object)
Dim k As Object

k = evt.Source
if k.Model.Orientation = com.sun.star.awt.ScrollBarOrientation.HORIZONTAL then
CurrentXrDialDelta.Width = k.Value
else
CurrentXrDialDelta.Height = k.Value
end if
resizeXrDial
End Sub
XrayTool Mod3 FocusOnInfoControl Basic BrowseSDK2 (Procedure)
XrayDeeper2 (Procedure)
changeDisplay (Procedure)
6
Sub FocusOnInfoControl ' used to display again the selection in this control
Dim kt As Object

kt = XrDial.getControl("TxtObjInfos")
kt.setFocus
End Sub
XrayTool Mod3 getConfigDirAddress Basic SDKindexAddress (Procedure)
IDLindexesLoadedFromWeb (Procedure)
getConfigFileAddress (Procedure)
9
Function getConfigDirAddress() As String
Dim ps As Object, sfa As Object, d As String

ps = CreateUnoService("com.sun.star.util.PathSubstitution")
sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
d = ps.substituteVariables("$(user)/XrayData/", True)
if not sfa.exists(d) then sfa.createFolder(d)
getConfigDirAddress = d
End Function
XrayTool Mod3 getConfigFileAddress Basic readXrayConfig (Procedure)
writeXrayConfig (Procedure)
3
Function getConfigFileAddress() As String
getConfigFileAddress = getConfigDirAddress() & "XrayConfig.txt"
End Function
XrayTool Mod3 getCurrentLineInInfos Basic keyOnXrayInfo (Procedure)
firstWordInCurrentLine (Procedure)
32
Function getCurrentLineInInfos(selectLine As Boolean) As String
Dim kt As Object, objInfos As String, sel As New com.sun.star.awt.Selection
Dim y1 As Long, y2 As Long

kt = XrDial.getControl("TxtObjInfos")
objInfos = kt.Text
if Len(objInfos) = 0 then
getCurrentLineInInfos = ""
Exit Function
end if
sel = kt.Selection
y1 = sel.Min ' position of character before cursor position
Do while y1 > 0 ' search start of line
if Mid(objInfos, y1, 1) = LF then Exit Do
y1 = y1 -1
Loop
y1 = y1 +1
y2 = InStr(y1 +1, objInfos, LF, 0) ' search end of line
if y2 = 0 then y2 = Len(objInfos) else y2 = y2 -1
' Now : y1 = position of 1st char in line, y2 = position of last char in line
getCurrentLineInInfos = MidP1P2(objInfos, y1, y2)
if selectLine then ' toggle line selection
if ((sel.Min = y2) and (sel.Max = (y1 -1) )) or ((sel.Max = y2) and (sel.Min = (y1 -1) )) then ' unselect
sel.Min = y1 -1
sel.Max = y1 -1
else ' select whole line
sel.Min = y2 ' select from right to left leaves cursor at start of line
sel.Max = y1 -1
end if
kt.Selection = sel
end if
End Function
XrayTool Mod3 getWorkFilePathName Basic displayAlternateDoc (Procedure) 8
Function getWorkFilePathName() As String
Dim ps As Object, result As String

ps = CreateUnoService("com.sun.star.util.PathSubstitution")
result = ps.substituteVariables("$(temp)/XrayResults.html", True)
if FileExists(result) then kill(result)
getWorkFilePathName = result
End Function
XrayTool Mod3 IDLindexesLoadedFromWeb Basic SetWebAPIpath (Procedure) 54
' returns "OK" or "Cancel" or diagnostic of error
Function IDLindexesLoadedFromWeb(IDLindex1 As String) As String
Dim onLineIDL As String, IDLindexCache As String, indexLetter As String, localIndex As String, errMess As String
Dim n As Long
Dim sfa As Object, ps As Object, k As Object, k1 As Object, k2 As Object
Const indexAright = "index-files/index-1.html"

ps = CreateUnoService("com.sun.star.util.PathSubstitution")
sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
k = XrInit.getControl("ProgressBar1")
k1 = XrInit.getControl("WebAPIBtn")
k2 = XrInit.getControl("SDKpath")

errMess = txt0311 ' message : invalid path
if Right(IDLindex1, Len(indexAright)) = indexAright then
onLineIDL = Left(IDLindex1, Len(IDLindex1) -Len("1.html") )
IDLindexCache = getConfigDirAddress() & "index-"
k.Visible = True ' show Progress Bar
' Reading index files needs some time : last warning.
errMess = "Cancel"
if MsgBox(txt0304 & LF & txt0305, 1+48+256, WindowTitle) = 1 then ' OK, Go !
On Error GoTo badIDL
for n = 1 to 27
indexLetter = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ_", n, 1)
k2.Text = replaceTag(txt0308, "%%", "Global Index " & indexLetter) ' downloading index n
Wait 100 ' let refresh display
errMess = txt0309 & LF & onLineIDL & n & ".html" ' this page does not exist
if not sfa.exists(onLineIDL & n & ".html") then Exit For
localIndex = IDLindexCache & n & ".html"
if sfa.exists(localIndex) then sfa.kill(localIndex)
errMess = txt0313 & LF & onLineIDL & n & ".html" ' download error for this page
sfa.copy(onLineIDL & n & ".html", localIndex) ' download takes several seconds or more, may throw exception
errMess = txt0301 ' download aborted
if k1.Model.State = 0 then Exit For ' button released : abort download
k.Value = n ' show progress
errMess = "OK"
next
wait 200 ' show ProgressBar1 state
end if
end if
Finish:
k.Value = 0 ' empty Progressbar1
k.Visible = False
k2.Text = ""
IDLindexesLoadedFromWeb = errMess
Exit Function

badIDL:
errMess = errMess & LF & LF & error
Resume BadIDL2
BadIDL2:
On Error GoTo 0
GoTo Finish
End Function
XrayTool Mod3 initConfigData Basic readXrayConfig (Procedure) 19
Sub initConfigData()
SDKdisplayAddr = ""
UseLocalSDK = False
BrowserAddress(1) = "C:\Program Files\Mozilla Firefox\firefox.exe"
BrowserAddress(2) = "C:\Program Files\Opera\Opera.exe"
BrowserAddress(3) = "C:\Program Files\Internet Explorer\iexplore.exe"
BrowserAddress(0) = 1
AlternateBrowserCallMethod = False
allowXrayDbleClick = True

startAllInfos = False
startAZorder = False
deltaHeightXrDial = 0
deltaWidthXrDial = 0

DisplayFontName = "Deja Vu Sans Mono"
DisplayFontHeight = 9
DisplayFontWidth = 5
End Sub
XrayTool Mod3 initDlgXray Basic prepareXray (Procedure) 36
Sub initDlgXray
Dim km As Object, k As Object
Const steps = 50

searchTexts = ""
readXrayConfig
XrDial = createDialogue("DlgXray", "")
DefaultXrDialSize = XrDial.OutputSize ' save initial size of dialog
k = XrDial.getControl("HeaderLabel")
DefaultXrDialHeaderSize = k.OutputSize ' save initial size of info edit control
k = XrDial.getControl("TxtObjInfos")
DefaultXrDialInfosSize = k.OutputSize ' save initial size of info edit control

km = XrDial.getControl("ScrollBarH").Model
km.ScrollValueMax = 2 *DefaultXrDialSize.Height
km.LineIncrement = km.ScrollValueMax / steps
km.BlockIncrement = km.ScrollValueMax / steps
km.ScrollValue = deltaHeightXrDial
CurrentXrDialDelta.Height = deltaHeightXrDial ' current addition to Height

km = XrDial.getControl("ScrollBarW").Model
km.ScrollValueMax = 2 * DefaultXrDialSize.Width
km.LineIncrement = km.ScrollValueMax / steps
km.BlockIncrement = km.ScrollValueMax / steps
km.ScrollValue = deltaWidthXrDial
CurrentXrDialDelta.Width = deltaWidthXrDial ' current addition to Width

resizeXrDial ' resize the dialog and the edit control
CenterDialog(XrDial)
setDisplayFont(XrDial, "HeaderLabel")
setDisplayFont(XrDial, "TxtObjInfos")
km = XrDial.getControl("AZflag").Model
if startAZorder then km.State = 1
km = XrDial.getControl("showAllFlag").Model
if startAllInfos then km.State = 1
End Sub
XrayTool Mod3 keyOnXrayInfo Basic DlgXray|TxtObjInfos (Control) 29
' routine triggered by event ButtonPressed on control TxtObjInfos
Sub keyOnXrayInfo(evt As Object)
Dim keyed As Long, currentLine As String, firstWord As String

firstWordInCurrentLine(currentLine, firstWord)
if Len(firstWord) = 0 then Exit Sub

keyed = evt.KeyCode
if evt.Modifiers = com.sun.star.awt.KeyModifier.MOD1 then keyed = -keyed ' Ctrl key was also pushed
Select Case keyed
Case -com.sun.star.awt.Key.F1 ' Ctrl-F1 : find API documentation
BrowseSDK2(currentLine, firstWord) ' routine declared in Mod4
Case -com.sun.star.awt.Key.F ' Ctrl-F : find term in text control of DlgXray
findInText(evt.Source)
Case com.sun.star.awt.Key.F5
if isControlEnabled(XrDial, "DeeperBtn") then XrayDeeper2(currentLine, firstWord)
Case com.sun.star.awt.Key.F2
getCurrentLineInInfos(True) ' select current line
Case com.sun.star.awt.Key.F4
if (XrayDisplayWhat = "properties") or (XrayDisplayWhat = "methods") then
Select Case prettyDisplayPropMethod(currentLine, firstWord)
Case "Xray"
XrayDeeper2(currentLine, firstWord)
Case "API"
BrowseSDK2(currentLine, firstWord)
End Select
end if
End Select
End Sub
XrayTool Mod3 MouseReleaseOnDisplay Basic DlgXray|TxtObjInfos (Control) 13
' routine triggered by event : Mouse button released on control TxtObjInfos
Sub MouseReleaseOnDisplay(evt As Object)
Dim currentLine As String, firstWord As String

if evt.ClickCount > 1 then
if evt.Buttons and com.sun.star.awt.MouseButton.LEFT then ' double-click left
if allowXrayDbleClick and isControlEnabled(XrDial, "DeeperBtn") then
firstWordInCurrentLine(currentLine, firstWord)
if Len(firstWord) > 0 then XrayDeeper2(currentLine, firstWord)
end if
end if
end if
End Sub
XrayTool Mod3 nextStepDlgInit Basic DlgInit|NextBtn (Control)
DlgInit|PrevBtn (Control)
8
' routine triggered by buttons NextBtn PrevBtn
Sub nextStepDlgInit(evt As Object)
Dim k As Object

XrInit.Model.Step = XrInit.Model.Step +CLng(evt.Source.Model.Tag)
k = XrInit.getControl("OKBtn")
k.Enable = (XrInit.Model.Step = 2)
End Sub
XrayTool Mod3 readXrayConfig Basic initDlgXray (Procedure) 58
Sub readXrayConfig()
Dim iniFile As Object, sfa As Object, flux As Object
Dim oneLine As String, configFileURL As String
Dim x As Long, paramName As String, paramValue As String

initConfigData
sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
configFileURL = getConfigFileAddress
if not sfa.exists(configFileURL) then Exit Sub
iniFile = CreateUnoService("com.sun.star.io.TextInputStream")
flux = sfa.openFileRead(configFileURL)
iniFile.InputStream = flux
iniFile.Encoding = "utf8"
Do while not iniFile.isEOF
oneLine = Trim(iniFile.readLine)
if (Left(oneLine, 1) <> "#") and (Len(oneLine) > 0) then
x = InStr(2, oneLine, "=", 0)
if x > 0 then
paramName = Trim( Left(oneLine, x-1) )
paramValue = Trim( Mid(oneLine, x+1) )
Select Case paramName
Case "allowXrayDbleClick"
allowXrayDbleClick = paramValue
Case "SDKdisplayAddr"
SDKdisplayAddr = paramValue
Case "UseLocalSDK"
UseLocalSDK = paramValue
Case "BrowserAddress1"
BrowserAddress(1) = paramValue
Case "BrowserAddress2"
BrowserAddress(2) = paramValue
Case "BrowserAddress3"
BrowserAddress(3) = paramValue
Case "BrowserChoice"
BrowserAddress(0) = paramValue
Case "AlternateBrowserCallMethod"
AlternateBrowserCallMethod = paramValue
Case "startAllInfos"
startAllInfos = paramValue
Case "startAZorder"
startAZorder = paramValue
Case "deltaHeightXrDial"
deltaHeightXrDial = paramValue
Case "deltaWidthXrDial"
deltaWidthXrDial = paramValue
Case "DisplayFontName"
DisplayFontName = paramValue
Case "DisplayFontHeight"
DisplayFontHeight = paramValue
Case "DisplayFontWidth"
DisplayFontWidth = paramValue
End Select
end if
end if
Loop
flux.closeInput
iniFile.closeInput
End Sub
XrayTool Mod3 resizeXrDial Basic initDlgXray (Procedure)
changeDialogWidthHeight (Procedure)
18
Sub resizeXrDial()
Dim k1 As Object, k2 As Object, sz As Object, sz1 As Object, sz2 As Object

sz = DefaultXrDialSize
sz.Width = sz.Width +CurrentXrDialDelta.Width
sz.Height = sz.Height +CurrentXrDialDelta.Height
k1 = XrDial.getControl("HeaderLabel")
sz1 = DefaultXrDialHeaderSize
sz1.Width = sz1.Width +CurrentXrDialDelta.Width ' change only width, not height
k2 = XrDial.getControl("TxtObjInfos")
sz2 = DefaultXrDialInfosSize
sz2.Width = sz2.Width +CurrentXrDialDelta.Width
sz2.Height = sz2.Height +CurrentXrDialDelta.Height
' change all at once
XrDial.OutputSize = sz
k1.OutputSize = sz1
k2.OutputSize = sz2
End Sub
XrayTool Mod3 SDKindexAddress Basic LoadSDKglobalIndex (Procedure) 13
' returns an URL terminated by /index-  or an empty string
Function SDKindexAddress() As String

if Len(SDKdisplayAddr) > 0 then
if UseLocalSDK then
SDKindexAddress = ConvertToURL(SDKdisplayAddr) & "docs/common/ref/index-files/index-"
else ' index pages have been downloaded locally
SDKindexAddress = getConfigDirAddress() & "/index-"
end if
else
SDKindexAddress = ""
end if
End Function
XrayTool Mod3 SDKpagesAddress Basic BrowseSDK2 (Procedure)
FindStructureDoc (Procedure)
FindPropertyDoc (Procedure)
displayAlternateDoc (Procedure)
12
' returns an URL terminated by : ref/   or an empty string
Function SDKpagesAddress() As String
if Len(SDKdisplayAddr) > 0 then
if UseLocalSDK then
SDKpagesAddress = ConvertToURL(SDKdisplayAddr) & "docs/common/ref/"
else
SDKpagesAddress = Left(SDKdisplayAddr, Len(SDKdisplayAddr) -Len("index-files/index-1.html") )
end if
else
SDKpagesAddress = ""
end if
End Function
XrayTool Mod3 setDisplayFont Basic initDlgXray (Procedure)
XrayConfigDialog (Procedure)
prettyDisplayPropMethod (Procedure)
10
Sub setDisplayFont(dlg As Object, controlName As String)
Dim km As Object, fd As Object

km = dlg.getControl(controlName).Model
fd = km.FontDescriptor
fd.Name = DisplayFontName
fd.Height = DisplayFontHeight
fd.Width = DisplayFontWidth
km.FontDescriptor = fd
End Sub
XrayTool Mod3 setFontSizeWidthDefault Basic DlgInit|SizeWidthDefaultBtn (Control) 9
' routine triggered by button SizeWidthDefaultBtn
Sub setFontSizeWidthDefault()
Dim k As Object

k = XrInit.getControl("DisplayFontHeight")
k.Value = 9
k = XrInit.getControl("DisplayFontWidth")
k.Value = 5
End Sub
XrayTool Mod3 SetSDKpath Basic DlgInit|SDKlocalBtn (Control) 21
'  routine triggered by button SDKlocalBtn
Sub SetSDKpath
Dim k As Object, fp As Object, SDKaddr As String

fp = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker")
if fp.execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
SDKaddr = fp.Directory ' chosen directory, in URL notation
' check consistency of provided SDK path
if FileExists(SDKaddr & "/docs/common/ref/com/sun/star/module-ix.html") _
and FileExists(SDKaddr & "/docs/common/ref/index-files/index-1.html") then

k = XrInit.getControl("SDKpath")
k.Text = convertFromURL(SDKaddr & "/")
k = XrInit.getControl("LabelSDKtype")
k.Text = txt0302
MsgBox(txt0314 & LF & txt0306, 64, WindowTitle) ' OK, done
else
MsgBox(txt0311, 16, WindowTitle) ' invalid path
end if
end if
End Sub
XrayTool Mod3 SetWebAPIpath Basic DlgInit|WebAPIBtn (Control) 24
'  routine triggered by button WebAPIBtn
Sub SetWebAPIpath(evt As Object)
Dim k As Object, k1 As Object, SDKaddr As String, r As String

k1 = evt.Source
if k1.Model.State = 0 then Exit Sub ' avoid false event
if UseLocalSDK then SDKaddr = "" else SDKaddr = SDKdisplayAddr
SDKaddr = InputBox(txt0307, WindowTitle, SDKaddr)
if Len(SDKaddr) > 0 then
r = IDLindexesLoadedFromWeb(SDKaddr)
if r = "OK" then ' success
k = XrInit.getControl("SDKpath")
k.Text = SDKaddr
k = XrInit.getControl("LabelSDKtype")
k.Text = txt0303
MsgBox(txt0314 & LF & txt0306, 64, WindowTitle) ' OK, done
elseif r = "Cancel" then
' nothing more to do ...
else
MsgBox(r, 16, WindowTitle) ' error downloading files
end if
end if
k1.Model.State = 0
End Sub
XrayTool Mod3 showPrettyDisplay Basic DlgXray|PrettyDisplayBtn (Control) 14
' routine triggered by button PrettyDisplayBtn of DlgXray
Sub showPrettyDisplay(evt As Object)
Dim currentLine As String, firstWord As String

firstWordInCurrentLine(currentLine, firstWord)
if Len(firstWord) = 0 then Exit Sub

Select Case prettyDisplayPropMethod(currentLine, firstWord)
Case "Xray"
XrayDeeper2(currentLine, firstWord)
Case "API"
BrowseSDK2(currentLine, firstWord)
End Select
End Sub
XrayTool Mod3 testFontForDisplay Basic DlgInit|DisplayFontBtn (Control) 15
' routine triggered by button DisplayFontBtn
Sub testFontForDisplay()
Dim kfH As Object, kfW As Object, kfN As Object, kfExample As Object, fd As Object

kfH = XrInit.getControl("DisplayFontHeight")
kfW = XrInit.getControl("DisplayFontWidth")
kfN = XrInit.getControl("DisplayFontName")
kfExample = XrInit.getControl("DisplayFontExample").Model
fd = kfExample.FontDescriptor
if Len(kfN.Text) = 0 then kfN.Text = "DejaVu Sans Mono" ' default, should exist
fd.Name = kfN.Text
fd.Height = kfH.Value
fd.Width = kfW.Value
kfExample.FontDescriptor = fd
End Sub
XrayTool Mod3 writeXrayConfig Basic XrayConfigDialog (Procedure) 35
Sub writeXrayConfig()
Dim iniFile As Object, sfa As Object, flux As Object
Dim oneLine As String, configFileURL As String
Dim x As Long, paramName As String, paramValue As String

sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
iniFile = CreateUnoService("com.sun.star.io.TextOutputStream")
configFileURL = getConfigFileAddress
if sfa.exists(configFileURL) then sfa.kill(configFileURL)

flux = sfa.openFileWrite(configFileURL)
iniFile.OutputStream = flux
iniFile.Encoding = "utf8"
iniFile.writeString("# Configuration data for Xray, do not modify !" & LF)
iniFile.writeString("# Données de configuration pour Xray, ne pas modifier !" & LF)
iniFile.writeString(LF)
iniFile.writeString("SDKdisplayAddr = " & SDKdisplayAddr & LF)
iniFile.writeString("UseLocalSDK = " & UseLocalSDK & LF)
iniFile.writeString("BrowserAddress1 = " & BrowserAddress(1) & LF)
iniFile.writeString("BrowserAddress2 = " & BrowserAddress(2) & LF)
iniFile.writeString("BrowserAddress3 = " & BrowserAddress(3) & LF)
iniFile.writeString("BrowserChoice = " & BrowserAddress(0) & LF)
iniFile.writeString("AlternateBrowserCallMethod = " & AlternateBrowserCallMethod & LF)
iniFile.writeString("allowXrayDbleClick = " & allowXrayDbleClick & LF)
iniFile.writeString("startAllInfos = " & startAllInfos & LF)
iniFile.writeString("startAZorder = " & startAZorder & LF)
iniFile.writeString("deltaHeightXrDial = " & deltaHeightXrDial & LF)
iniFile.writeString("deltaWidthXrDial = " & deltaWidthXrDial & LF)
iniFile.writeString("DisplayFontName = " & DisplayFontName & LF)
iniFile.writeString("DisplayFontHeight = " & DisplayFontHeight & LF)
iniFile.writeString("DisplayFontWidth = " & DisplayFontWidth & LF)
iniFile.writeString(LF)
flux.closeOutput
iniFile.closeOutput
End Sub
XrayTool Mod3 XrayBack Basic DlgXray|ListObj (Control)
foundInXrayList (Procedure)
10
'  routine triggered by event : modified status on control ListObj
Sub XrayBack
Dim kt As Object, qp As String

kt = XrDial.getControl("ListObj")
if kt.Model.Tag <> "allow" then exit sub
qp = kt.selectedItem
if qp = CurrentObjQualifiedName then exit sub ' no change
initXrayDisplay(XrObject(kt.selectedItemPos), qp, false)
End Sub
XrayTool Mod3 XrayConfigDialog Basic DlgXray|ConfigBtn (Control) 70
' routine also triggered by push of Configuration button in DlgXray dialog
Sub XrayConfigDialog
Dim kt1 As Object, x As Long
Dim kAll As Object, kAZ As Object, kShell As Object
Dim kfN As Object, kfH As Object, kfW As Object, k2Click As Object

XrInit = createDialogue("DlgInit", txt0264)
XrInit.Model.Step = 1
kt1 = XrInit.getControl("ProgressBar1")
kt1.Visible = False
kt1 = XrInit.getControl("SDKpath")
kt1.Text = SDKdisplayAddr
kt1 = XrInit.getControl("LabelSDKtype")
if Len(SDKdisplayAddr) > 0 then
if UseLocalSDK then kt1.Text = txt0302 else kt1.Text = txt0303
end if
kt1 = XrInit.getControl("Browser" & Right(BrowserAddress(0), 1))
kt1.Model.State = 1 ' current choice
For x = 1 to 3 ' all alternative browsers
kt1 = XrInit.getControl("FileControl" & x)
kt1.Text = BrowserAddress(x)
next
kShell = XrInit.getControl("ShellMethod")
if AlternateBrowserCallMethod then kShell.Model.State = 1
k2Click = XrInit.getControl("DblClickFlag")
if allowXrayDbleClick then k2Click.Model.State = 1
kt1 = XrDial.getControl("showAllFlag")
kAll = XrInit.getControl("initAllInfosFlag")
kAll.Model.State = kt1.Model.State
kt1 = XrDial.getControl("AZflag")
kAZ = XrInit.getControl("initAZflag")
kAZ.Model.State = kt1.Model.State
kfH = XrInit.getControl("DisplayFontHeight")
kfH.Value = DisplayFontHeight
kfW = XrInit.getControl("DisplayFontWidth")
kfW.Value = DisplayFontWidth
kfN = XrInit.getControl("DisplayFontName")
kfN.Text = DisplayFontName
setDisplayFont(XrInit, "DisplayFontExample")

if XrInit.Execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
' - - get new configuration data - - -
kt1 = XrInit.getControl("LabelSDKtype")
UseLocalSDK = (kt1.Text = txt0302)
kt1 = XrInit.getControl("SDKpath")
SDKdisplayAddr = kt1.Text
For x = 1 to 3 ' get designated browser addresses
kt1 = XrInit.getControl("FileControl" & x)
BrowserAddress(x) = kt1.Text
kt1 = XrInit.getControl("Browser" & x)
if kt1.State then BrowserAddress(0) = x ' number of designated browser
next
AlternateBrowserCallMethod = (kShell.State = 1)
allowXrayDbleClick = (k2Click.State = 1)
startAllInfos = (kAll.State = 1)
startAZorder = (kAZ.State = 1)
kt1 = XrInit.getControl("setDialogWidthFlag")
if kt1.State = 1 then ' get current delta size of main dialog
deltaHeightXrDial = CurrentXrDialDelta.Height
deltaWidthXrDial = CurrentXrDialDelta.Width
end if
DisplayFontName = kfN.Text
DisplayFontHeight = kfH.Value
DisplayFontWidth = kfW.Value
setDisplayFont(XrDial, "TxtObjInfos")

writeXrayConfig ' Save new configuration data
end if
XrInit.Dispose
End Sub
XrayTool Mod3 XrayDaddyObject Basic DlgXray|daddyObjBtn (Control) 22
'  routine triggered by event : trigger of control daddyObjBtn
Sub XrayDaddyObject
Dim kt As Object, s As String, c As String
Dim allItems As String

kt = XrDial.getControl("ListObj")
s = kt.selectedItem
allItems = LF & join(kt.Items, LF) & LF
Do
c = Right(s,1)
s = amputeRight(s, 1)
if (c = ".") or (c = "(") then
if InStr(1, allitems, LF & s & LF, 0) > 0 then Exit Do ' daddy found
' Daddy was ejected because XrObject() was full. Search for any grand-daddy
end if
Loop Until Len(s) = 0
if Len(s) = 0 then ' original object
kt.selectItemPos(0, True)
else ' select daddy object
kt.selectItem(s, True)
end if
End Sub
XrayTool Mod3 XrayDeeper Basic DlgXray|DeeperBtn (Control) 7
'  routine triggered by event : trigger of control DeeperBtn
Sub XrayDeeper(evt As Object)
Dim currentLine As String, firstWord As String

firstWordInCurrentLine(currentLine, firstWord)
if Len(firstWord) > 0 then XrayDeeper2(currentLine, firstWord)
End Sub
XrayTool Mod3 XrayOriginalObject Basic DlgXray|originObjBtn (Control) 7
'  routine triggered by event : trigger of control originObjBtn
Sub XrayOriginalObject
Dim kt As Object

kt = XrDial.getControl("ListObj")
kt.selectItemPos(0, True)
End Sub
XrayTool Mod4 BrowseSDK Basic DlgXray|SDKBtn (Control) 7
' routine called by button SDKBtn of DlgXray
Sub BrowseSDK(evt As Object)
Dim currentLine As String, firstWord As String

firstWordInCurrentLine(currentLine, firstWord)
if Len(firstWord) > 0 then BrowseSDK2(currentLine, firstWord)
End Sub
XrayTool Mod4 BrowseSDK2 Basic BrowseSDK (Procedure)
keyOnXrayInfo (Procedure)
showPrettyDisplay (Procedure)
39
' called by other routines
Sub BrowseSDK2(currentLine As String, ByVal firstWord As String)
Dim webPage As String, interfName As String, s As String

if isControlEnabled(XrDial, "SDKBtn") then
if SDKpagesAddress = "" then
MsgBox(txt0131, 64, WindowTitle) ' use configure button to specify the API doc address
else
if Left(firstWord, 1) = "(" then ' current line is an element of array
s = getAPInameAfter(currentLine, ArrayIndexSeparator & ArrayElementStruct)
if Len(s) = 0 then s = getAPInameAfter(currentLine, ArrayIndexSeparator & ArrayElementObj)
if Len(s) > 0 then
webPage = SDKpagesAddress & join(split(s, "."), "/") & ".html" ' create page address
CallBrowser(firstWord, webPage)
end if
elseif XrayDisplayWhat = "properties" then ' property or pseudo-property or attribute or structure
if classeIDL.TypeClass = com.sun.star.uno.TypeClass.STRUCT then
FindStructureDoc(firstWord)
else ' search for a property or pseudo-property or attribute
' some user-defined properties have spaces, e.g. Info 1 in document properties
FindPropertyDoc(currentLine, restoreSpaces(firstWord) )
end if
elseif XrayDisplayWhat = "methods" then
interfName = getLastWordOfString(currentLine)
webPage = SDKpagesAddress & join(split(interfName, "."), "/") & ".html" ' create page address
CallBrowser(firstWord, webPage, firstWord)
elseif XrayDisplayWhat = "listeners" then
interfName = getLastWordOfString(currentLine)
webPage = SDKpagesAddress & join(split(interfName, "."), "/") & ".html" ' create page address
CallBrowser(firstWord, webPage, deleteTrail(firstWord, "()") )
else ' service, interface
' get service or interface address and then change separator
webPage = SDKpagesAddress & join(split(firstWord, "."), "/") & ".html" ' create page address
CallBrowser(firstWord, webPage)
end if
end if
end if
FocusOnInfoControl
End Sub
XrayTool Mod4 displayAlternateDoc Basic SearchSDKpage (Procedure) 24
Sub displayAlternateDoc(propName As String, searchWhat As String, bkmkLines As String)
Dim myPage As String, workFileName As String
Dim f1 As Integer
Const myPage1 = "<html> <head> <title>Xray results</title> <base href="""
Const myPage2 = """> </head> <body> "
Const myPage3 = " <dl> "
Const myPage4 = "</dl> </body> </html>"
Const htmlP = " <p>"

myPage = myPage1 & SDKpagesAddress & "index-files/" & myPage2
Select Case searchWhat
Case "property"
myPage = myPage & txt0355 & htmlP
Case "attribute"
myPage = myPage & txt0345 & htmlP
End Select
myPage = myPage & txt0360 & htmlP & myPage3 & LF & bkmkLines & LF & myPage4 & LF
workFileName = getWorkFilePathName()
f1 = FreeFile
Open workFileName for Output As f1
print #f1, myPage
Close #f1
CallBrowser(propName, workFileName)
End Sub
XrayTool Mod4 findPropertyBookmarks Basic SearchSDKpage (Procedure)
isAlternateDoc (Procedure)
22
' creates a string containing the html lines containing propName
' returns the number of lines and lines for this property or attribute
' returns any service or attribute lines
' OUT parameter : bkmkLines
Sub findPropertyBookmarks(propName As String, searchWhat As String, bkmkLines As String)
Dim oneLine As String, htmlName As String

Select Case searchWhat
Case "property"
htmlName = "" & propName & " - property"
Case "attribute"
htmlName = "" & propName & " - attribute"
End Select
bkmkLines = ""
Do while not eof(SDKdev)
Line Input #SDKdev, oneLine
if InStr(1, oneLine, htmlName, 0) > 0 then
bkmkLines = bkmkLines & LF & oneLine
end if
Loop
Close #SDKdev
End Sub
XrayTool Mod4 FindPropertyDoc Basic BrowseSDK2 (Procedure) 45
Sub FindPropertyDoc(currentLine As String, propName As String)
Dim docAddr1 As String, docAddr2 As String, interfName As String, t As String, servName As String
Dim info2 As Object, propKind As Long

info2 = introCurrObj.getProperty(propName, com.sun.star.beans.PropertyConcept.ALL)
propKind = getPropertyCategory(propName, info2.Attributes)
if (propKind and &H00000200) <> 0 then ' attribute
interfName = findInterfaceOfAttribute(propName)
if Len(interfName) > 0 then
docAddr1 = SDKpagesAddress & join(split(interfName, "."), "/") & ".html"
CallBrowser(propName, docAddr1, propName)
else
SearchSDKpage(propName, "attribute") ' find a description of attribute elsewhere
end if
elseif (propKind and &H00000400) <> 0 then ' real property
if ((propKind H00010000000) and com.sun.star.beans.PropertyAttribute.REMOVEABLE) <> 0 then
MsgBox(txt0356, 64, WindowTitle) ' can't document such property (prop name can be anything)
else
servName = findServiceOfRealProperty(propName)
if Len(servName) > 0 then
docAddr1 = SDKpagesAddress & join(split(servName, "."), "/") & ".html"
CallBrowser(propName, docAddr1, propName)
else
SearchSDKpage(propName, "property") ' find a description of property elsewhere
end if
end if
else ' pseudo-property
t = ""
if (propKind and &H00000102) = &H00000102 then t = LF & replaceTag(txt0243, "getXxx", "get" & propName & "( ) ")
if (propKind and &H00000108) = &H00000108 then t = LF & replaceTag(txt0244, "getXxx", "set" & propName & "( ) ")
t = Mid(t, 2)
if Len(t) > 0 then MsgBox(t, 64, WindowTitle)
docAddr1 = ""
if (propKind and &H00000003) = &H00000001 then ' getXxx exists and is not ambiguous
interfName = getPseudoPropInterface("get", propName)
docAddr1 = SDKpagesAddress & join(split(interfName, "."), "/") & ".html"
CallBrowser("get" & propName, docAddr1, "get" & propName)
end if
if (propKind and &H0000000C) = &H00000004 then ' setXxx exists and is not ambiguous
interfName = getPseudoPropInterface("set", propName)
docAddr2 = SDKpagesAddress & join(split(interfName, "."), "/") & ".html"
if docAddr2 <> docAddr1 then CallBrowser("set" & propName, docAddr2, "set" & propName)
end if
end if
End Sub
XrayTool Mod4 FindStructureDoc Basic BrowseSDK2 (Procedure) 8
Sub FindStructureDoc(structName As String)
Dim objInternalName As String, pageAddr As String

objInternalName = classeIDL.Name
pageAddr = SDKpagesAddress & join(split(objInternalName, "."), "/") & ".html"

CallBrowser(structName, pageAddr, structName)
End Sub
XrayTool Mod4 getAPInameAfter Basic BrowseSDK2 (Procedure) 11
Function getAPInameAfter(currentLine As String, marker As String) As String
Dim p1 As Long, p2 As Long

p1 = InStr(1, currentLine, marker, 0)
if p1 = 0 then
getAPInameAfter = ""
else
p2 = InStr(p1 +Len(marker), currentLine, " ", 0)
getAPInameAfter = MidP1P2(currentLine, p1 +Len(marker), p2 -1)
end if
End Function
XrayTool Mod4 getAPInameFrom Basic   15
Function getAPInameFrom(SDKindexLine As String) As String
Dim APIname As String, x1 As Long, x2 As Long
Const css = "com/sun/star/"

getAPInameFrom = ""
x1 = Instr(1, SDKindexLine, css, 0)
if x1 > 0 then
x2 = Instr(x1 +Len(css), SDKindexLine, ".html", 0)
if x2 > 0 then
APIname = MidP1P2(SDKindexLine, x1, x2 -1) ' API name as com/sun/star/etc
APIname = join(split(APIname, "/"), ".") ' now the complete API name as : com.sun.star.etc
getAPInameFrom = APIname
end if
end if
End Function
XrayTool Mod4 isAlternateDoc Basic explainRealProperty (Procedure)
explainAttribute (Procedure)
15
Function isAlternateDoc(propName As String, searchWhat As String) As String
Dim bkmkLines As String, result As String

if LoadSDKglobalIndex(propName, searchWhat) then
findPropertyBookmarks(propName, searchWhat, bkmkLines) ' search within object services
if Len(bkmkLines) > 0 then
result = "found"
else
result = "not found"
end if
else
result = "problem"
end if
isAlternateDoc = result
End Function
XrayTool Mod4 LoadSDKglobalIndex Basic SearchSDKpage (Procedure)
isAlternateDoc (Procedure)
18
' opens  the index page for the letter of the first character of searchName
' returns true if success
Function LoadSDKglobalIndex(searchName As String) As Boolean
Dim DocAddr As String, alpha As Integer, result As Boolean

result = False
alpha = ASC(LCase(searchName)) -ASC("a") +1
if alpha = -1 then alpha = 27 ' name begins with _ character
if (alpha >= 1) and (alpha <= 27) then
DocAddr = SDKindexAddress & CStr(alpha) & ".html"
if FileExists(DocAddr) then
SDKdev = Freefile
Open DocAddr For Input As SDKdev
result = true
end if
end if
LoadSDKglobalIndex = result
End Function
XrayTool Mod4 SearchSDKpage Basic FindPropertyDoc (Procedure) 15
' search and display any doc page in the API indexes for a property or attribute name
Sub SearchSDKpage(propName As String, searchWhat As String)
Dim bkmkLines As String

if LoadSDKglobalIndex(propName, searchWhat) then
findPropertyBookmarks(propName, searchWhat, bkmkLines) ' search within object services
if Len(bkmkLines) > 0 then
displayAlternateDoc(propName, searchWhat, bkmkLines)
else
MsgBox(txt0105 & propName, 64, WindowTitle) ' no doc found
end if
else
MsgBox(txt0131, 16, WindowTitle) ' configuration problem
end if
End Sub
XrayTool Xutils HelperButton Basic DlgXutils|StarDesktopBtn (Control)
DlgXutils|ProcessMngrBtn (Control)
DlgXutils|ThisComponentBtn (Control)
DlgXutils|FirstSelectionBtn (Control)
DlgXutils|ThisControllerBtn (Control)
DlgXutils|CurrentCompBtn (Control)
DlgXutils|ThisSheetBtn (Control)
DlgXutils|ThisSlideBtn (Control)
6
Sub HelperButton(evt As Object)
Dim dlg As Object
dlg = evt.Source.Context
dlg.Model.Tag = evt.Source.Model.Name
dlg.endExecute
End Sub
XrayTool Xutils System_URL_conversion Basic DlgXutils|CommandButton6 (Control)
DlgXutils|CommandButton5 (Control)
12
Sub System_URL_conversion(evt As Object)
Dim dlg As Object, k As Object

dlg = evt.Source.Context
k = dlg.getControl("FileAddress")
if evt.Source.Model.Tag = "toURL" then
k.Text = convertToURL(k.Text)
else
k.Text = convertFromURL(k.Text)
end if
wait 1000 ' avoid unvolontary repetition
End Sub
XrayTool Xutils XrayMenu Basic   58
Sub XrayMenu
Dim oLib As Object, dlg As Object, tc As Object, cc As Object, whichBtn As String, ss As Boolean

GlobalScope.DialogLibraries.LoadLibrary(Libname)
oLib = GlobalScope.DialogLibraries.getByName(Libname)
dlg = CreateUnoDialog(oLib.getByName("DlgXutils"))
On Error Resume Next ' protect from strange objects...
tc = ThisComponent
On Error GoTo 0
if isNull(tc) then
enableControls(dlg, Array("ThisSheetBtn", "ThisSlideBtn", "ThisComponentBtn", "FirstSelectionBtn", "ThisControllerBtn"), False)
else
On Error Resume Next
cc = tc.CurrentController
On Error GoTo 0
if isNull(cc) then ' no controller ??
enableControls(dlg, Array("ThisSheetBtn", "ThisSlideBtn", "ThisControllerBtn", "FirstSelectionBtn"), False)
else
ss = True
On Error Resume Next ' Math object for example does not provide supportsService
ss = cc.supportsService("not a service!")
On Error GoTo 0
if ss then ' method supportsService is not supported !
enableControls(dlg, Array("ThisSheetBtn", "ThisSlideBtn"), False)
elseif cc.supportsService("com.sun.star.sheet.SpreadsheetView") then
enableControls(dlg, Array("ThisSlideBtn"), False)
elseif cc.supportsService("com.sun.star.drawing.DrawingDocumentDrawView") then
enableControls(dlg, Array("ThisSheetBtn"), False)
else ' document is not paginated
enableControls(dlg, Array("ThisSheetBtn", "ThisSlideBtn"), False)
end if
end if
end if

dlg.execute
whichBtn = dlg.Model.Tag ' Tag possibly contains the name of the activated button
dlg.dispose

Select Case whichBtn
Case "ThisComponentBtn"
Xray tc
Case "ThisControllerBtn"
Xray cc
Case "CurrentCompBtn"
Xray StarDesktop.CurrentComponent
Case "ProcessMngrBtn"
Xray GetProcessServiceManager
Case "StarDesktopBtn"
Xray StarDesktop
Case "ThisSheetBtn"
Xray cc.ActiveSheet
Case "ThisSlideBtn"
Xray cc.CurrentPage
Case "FirstSelectionBtn"
Xray tc.CurrentSelection(0)
End Select

End Sub
Standard Module1 DBOpen Basic XRay.odb (Database) 7
Sub DBOpen(Optional poEvent As Object)
If GlobalScope.BasicLibraries.hasByName("XrayTool") Then
GlobalScope.BasicLibraries.loadLibrary("XrayTool")
GlobalScope.DialogLibraries.loadLibrary("XrayTool")
End If
xray GlobalScope.BasicLibraries
End Sub