home *** CD-ROM | disk | FTP | other *** search
/ com!online 2001 December / COMCD1201.iso / openoffice / f_0179 / Debug.xba next >
Encoding:
Extensible Markup Language  |  2001-06-06  |  5.7 KB  |  176 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Debug" script:language="StarBasic">REM  *****  BASIC  *****
  4.  
  5. Sub WritedbgInfo(LocObject as Object)
  6. Dim locUrl as String
  7. Dim oLocDocument as Object
  8. Dim oLocText as Object
  9. Dim oLocCursor as Object
  10. Dim NoArgs()
  11. Dim sObjectStrings(2) as String
  12. Dim sProperties() as String
  13. Dim n as Integer
  14. Dim m as Integer
  15.     sObjectStrings(0) = LocObject.dbg_Properties
  16.     sObjectStrings(1) = LocObject.dbg_Methods
  17.     sObjectStrings(2) = LocObject.dbg_SupportedInterfaces
  18.     LocUrl = "private:factory/swriter"
  19.     oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,"_blank",0,NoArgs)
  20.     oLocText = oLocDocument.text
  21.     oLocCursor = oLocText.createTextCursor()
  22.     oLocCursor.gotoStart(False)
  23.     If Vartype(LocObject) = 9 then    ' an Object Variable
  24.         For n = 0 To 2
  25.             sProperties() = ArrayoutofString(sObjectStrings(n),";", MaxIndex)
  26.             For m = 0 To MaxIndex
  27.                 oLocText.insertString(oLocCursor,sProperties(m),False)
  28.                 oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
  29.             Next m
  30.         Next n
  31.     Elseif Vartype(LocObject) = 8 Then    ' a String Variable
  32.         oLocText.insertString(oLocCursor,LocObject,False)
  33.     ElseIf Vartype(LocObject) = 1 Then
  34.         Msgbox("Variable is Null!", 16, GetProductName())
  35.     End If
  36. End Sub
  37.  
  38.  
  39. Sub WriteDbgString(LocString as string)
  40. Dim oLocDesktop as object
  41. Dim LocUrl as String
  42. Dim oLocDocument as Object
  43. Dim oLocCursor as Object
  44. Dim oLocText as Object
  45.  
  46.     LocUrl = "private:factory/swriter"
  47.     oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,"_blank",0,NoArgs)
  48.     oLocText = oLocDocument.text
  49.     oLocCursor = oLocText.createTextCursor()
  50.     oLocCursor.gotoStart(False)
  51.     oLocText.insertString(oLocCursor,LocString,False)
  52. End Sub
  53.  
  54.  
  55. Sub printdbgInfo(LocObject)
  56.     If Vartype(LocObject) = 9 then
  57.         Msgbox LocObject.dbg_properties
  58.         Msgbox LocObject.dbg_methods
  59.         Msgbox LocObject.dbg_supportedinterfaces
  60.     Elseif Vartype(LocObject) = 8 Then    ' a String Variable
  61.         Msgbox LocObject
  62.     ElseIf Vartype(LocObject) = 0 Then
  63.         Msgbox("Variable is Null!", 16, GetProductName())
  64.     Else
  65.         Msgbox("Type of Variable: " & Typename(LocObject), 48, GetProductName())
  66.     End If
  67. End Sub
  68.  
  69.  
  70. Sub ShowArray(LocArray())
  71. Dim i as integer
  72. Dim msgstring
  73.     msgstring = ""
  74.     For i = Lbound(LocArray()) to Ubound(LocArray())
  75.         msgstring = msgstring + LocArray(i) + chr(13)
  76.     Next
  77.     Msgbox msgstring
  78. End Sub
  79.  
  80.  
  81. Sub ShowPropertyValues(oLocObject as Object)
  82. Dim PropName as String
  83. Dim sValues as String
  84.     On Local Error Goto NOPROPERTYSETINFO:
  85.     sValues = ""
  86.     For i = 0 To Ubound(oLocObject.PropertySetInfo.Properties)
  87.         Propname = oLocObject.PropertySetInfo.Properties(i).Name
  88.         sValues = sValues & PropName & chr(13) & " = " & oLocObject.GetPropertyValue(PropName) & chr(13)
  89.     Next i
  90.     Msgbox(sValues , 64, GetProductName())
  91.     Exit Sub
  92.  
  93. NOPROPERTYSETINFO:
  94.     Msgbox("Sorry, No PropertySetInfo attached to the object", 16, GetProductName())
  95.     Resume LEAVEPROC
  96.     LEAVEPROC:
  97. End Sub
  98.  
  99.  
  100. Sub ShowNameValuePair(Pair())
  101. Dim i as Integer
  102. Dim ShowString as String
  103.     ShowString = ""
  104.     On Local Error Resume Next
  105.     For i = 0 To Ubound(Pair())
  106.         ShowString = ShowString & Pair(i).Name & " = "
  107.         ShowString = ShowString & Pair(i).Value & chr(13)
  108.     Next i
  109.     Msgbox ShowString
  110. End Sub
  111.  
  112.  
  113. ' Retrieves all the Elements of aSequence of an object, with the
  114. ' possibility to define a filter(sfilter <> "")
  115. Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
  116. Dim i as Integer
  117. Dim NameString as String
  118.     NameString = ""
  119.     For i = 0 To Ubound(oLocElements())
  120.         If Not IsMissIng(sFilterName) Then
  121.             If Instr(1, oLocElements(i), sFilterName) Then
  122.                 NameString = NameString & oLocElements(i) & chr(13)
  123.             End If
  124.         Else
  125.             NameString = NameString & oLocElements(i) & chr(13)
  126.         End If
  127.     Next i
  128.     Msgbox(NameString, 64, GetProductName())
  129. End Sub
  130.  
  131.  
  132. ' Retrieves all the supported servicenames of an object, with the
  133. ' possibility to define a filter(sfilter <> "")
  134. Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
  135.     On Local Error Goto NOSERVICENAMES
  136.     If IsMissing(sFilterName) Then
  137.         ShowElementNames(oLocobject.SupportedServiceNames())
  138.     Else
  139.         ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
  140.     End If
  141.     Exit Sub
  142.  
  143.     NOSERVICENAMES:
  144.     Msgbox("Sorry, No 'SupportedServiceNames' - Property attached to the object", 16, GetProductName())
  145.     Resume LEAVEPROC
  146.     LEAVEPROC:
  147. End Sub
  148.  
  149.  
  150. ' Retrieves all the available Servicenames of an object, with the
  151. ' possibility to define a filter(sfilter <> "")
  152. Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
  153.     On Local Error Goto NOSERVICENAMES
  154.     If IsMissing(sFilterName) Then
  155.         ShowElementNames(oLocobject.AvailableServiceNames)
  156.     Else
  157.         ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
  158.     End If
  159.     Exit Sub
  160.  
  161.     NOSERVICENAMES:
  162.     Msgbox("Sorry, No 'AvailableServiceNames' - Property attached to the object", 16, GetProductName())
  163.     Resume LEAVEPROC
  164.     LEAVEPROC:
  165. End Sub
  166.  
  167.  
  168. Sub ShowCommands(oLocObject as Object)
  169.     On Local Error Goto NOCOMMANDS
  170.     ShowElementNames(oLocObject.QueryCommands)
  171.     Exit Sub
  172.     NOCOMMANDS:
  173.     Msgbox("Sorry, No 'QueryCommands' - Property attached to the object", 16, GetProductName())
  174.     Resume LEAVEPROC
  175.     LEAVEPROC:
  176. End Sub</script:module>