home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri Kaikille K-CD 2002 #3 / K-CD_2002-03.iso / OpenOffice / f_0180 / Debug.xba next >
Extensible Markup Language  |  2001-10-01  |  7KB  |  204 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. Dim MaxIndex as Integer
  16.     sObjectStrings(0) = LocObject.dbg_Properties
  17.     sObjectStrings(1) = LocObject.dbg_Methods
  18.     sObjectStrings(2) = LocObject.dbg_SupportedInterfaces
  19.     LocUrl = "private:factory/swriter"
  20.     oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,"_blank",0,NoArgs)
  21.     oLocText = oLocDocument.text
  22.     oLocCursor = oLocText.createTextCursor()
  23.     oLocCursor.gotoStart(False)
  24.     If Vartype(LocObject) = 9 then    ' an Object Variable
  25.         For n = 0 To 2
  26.             sProperties() = ArrayoutofString(sObjectStrings(n),";", MaxIndex)
  27.             For m = 0 To MaxIndex
  28.                 oLocText.insertString(oLocCursor,sProperties(m),False)
  29.                 oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
  30.             Next m
  31.         Next n
  32.     Elseif Vartype(LocObject) = 8 Then    ' a String Variable
  33.         oLocText.insertString(oLocCursor,LocObject,False)
  34.     ElseIf Vartype(LocObject) = 1 Then
  35.         Msgbox("Variable is Null!", 16, GetProductName())
  36.     End If
  37. End Sub
  38.  
  39.  
  40. Sub WriteDbgString(LocString as string)
  41. Dim oLocDesktop as object
  42. Dim LocUrl as String
  43. Dim oLocDocument as Object
  44. Dim oLocCursor as Object
  45. Dim oLocText as Object
  46.  
  47.     LocUrl = "private:factory/swriter"
  48.     oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,"_blank",0,NoArgs)
  49.     oLocText = oLocDocument.text
  50.     oLocCursor = oLocText.createTextCursor()
  51.     oLocCursor.gotoStart(False)
  52.     oLocText.insertString(oLocCursor,LocString,False)
  53. End Sub
  54.  
  55.  
  56. Sub printdbgInfo(LocObject)
  57.     If Vartype(LocObject) = 9 then
  58.         Msgbox LocObject.dbg_properties
  59.         Msgbox LocObject.dbg_methods
  60.         Msgbox LocObject.dbg_supportedinterfaces
  61.     Elseif Vartype(LocObject) = 8 Then    ' a String Variable
  62.         Msgbox LocObject
  63.     ElseIf Vartype(LocObject) = 0 Then
  64.         Msgbox("Variable is Null!", 16, GetProductName())
  65.     Else
  66.         Msgbox("Type of Variable: " & Typename(LocObject), 48, GetProductName())
  67.     End If
  68. End Sub
  69.  
  70.  
  71. Sub ShowArray(LocArray())
  72. Dim i as integer
  73. Dim msgstring
  74.     msgstring = ""
  75.     For i = Lbound(LocArray()) to Ubound(LocArray())
  76.         msgstring = msgstring + LocArray(i) + chr(13)
  77.     Next
  78.     Msgbox msgstring
  79. End Sub
  80.  
  81.  
  82. Sub ShowPropertyValues(oLocObject as Object)
  83. Dim PropName as String
  84. Dim sValues as String
  85.     On Local Error Goto NOPROPERTYSETINFO:
  86.     sValues = ""
  87.     For i = 0 To Ubound(oLocObject.PropertySetInfo.Properties)
  88.         Propname = oLocObject.PropertySetInfo.Properties(i).Name
  89.         sValues = sValues & PropName & chr(13) & " = " & oLocObject.GetPropertyValue(PropName) & chr(13)
  90.     Next i
  91.     Msgbox(sValues , 64, GetProductName())
  92.     Exit Sub
  93.  
  94. NOPROPERTYSETINFO:
  95.     Msgbox("Sorry, No PropertySetInfo attached to the object", 16, GetProductName())
  96.     Resume LEAVEPROC
  97.     LEAVEPROC:
  98. End Sub
  99.  
  100.  
  101. Sub ShowNameValuePair(Pair())
  102. Dim i as Integer
  103. Dim ShowString as String
  104.     ShowString = ""
  105.     On Local Error Resume Next
  106.     For i = 0 To Ubound(Pair())
  107.         ShowString = ShowString & Pair(i).Name & " = "
  108.         ShowString = ShowString & Pair(i).Value & chr(13)
  109.     Next i
  110.     Msgbox ShowString
  111. End Sub
  112.  
  113.  
  114. ' Retrieves all the Elements of aSequence of an object, with the
  115. ' possibility to define a filter(sfilter <> "")
  116. Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
  117. Dim i as Integer
  118. Dim NameString as String
  119.     NameString = ""
  120.     For i = 0 To Ubound(oLocElements())
  121.         If Not IsMissIng(sFilterName) Then
  122.             If Instr(1, oLocElements(i), sFilterName) Then
  123.                 NameString = NameString & oLocElements(i) & chr(13)
  124.             End If
  125.         Else
  126.             NameString = NameString & oLocElements(i) & chr(13)
  127.         End If
  128.     Next i
  129.     Msgbox(NameString, 64, GetProductName())
  130. End Sub
  131.  
  132.  
  133. ' Retrieves all the supported servicenames of an object, with the
  134. ' possibility to define a filter(sfilter <> "")
  135. Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
  136.     On Local Error Goto NOSERVICENAMES
  137.     If IsMissing(sFilterName) Then
  138.         ShowElementNames(oLocobject.SupportedServiceNames())
  139.     Else
  140.         ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
  141.     End If
  142.     Exit Sub
  143.  
  144.     NOSERVICENAMES:
  145.     Msgbox("Sorry, No 'SupportedServiceNames' - Property attached to the object", 16, GetProductName())
  146.     Resume LEAVEPROC
  147.     LEAVEPROC:
  148. End Sub
  149.  
  150.  
  151. ' Retrieves all the available Servicenames of an object, with the
  152. ' possibility to define a filter(sfilter <> "")
  153. Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
  154.     On Local Error Goto NOSERVICENAMES
  155.     If IsMissing(sFilterName) Then
  156.         ShowElementNames(oLocobject.AvailableServiceNames)
  157.     Else
  158.         ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
  159.     End If
  160.     Exit Sub
  161.  
  162.     NOSERVICENAMES:
  163.     Msgbox("Sorry, No 'AvailableServiceNames' - Property attached to the object", 16, GetProductName())
  164.     Resume LEAVEPROC
  165.     LEAVEPROC:
  166. End Sub
  167.  
  168.  
  169. Sub ShowCommands(oLocObject as Object)
  170.     On Local Error Goto NOCOMMANDS
  171.     ShowElementNames(oLocObject.QueryCommands)
  172.     Exit Sub
  173.     NOCOMMANDS:
  174.     Msgbox("Sorry, No 'QueryCommands' - Property attached to the object", 16, GetProductName())
  175.     Resume LEAVEPROC
  176.     LEAVEPROC:
  177. End Sub
  178.  
  179.  
  180. Sub ProtectCurrentSheets()
  181. Dim oDocument as Object
  182. Dim sDocType as String
  183. Dim iResult as Integer
  184. Dim oSheets as Object
  185. Dim i as Integer
  186. Dim bDoProtect as Boolean
  187.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  188.     sDocType = GetDocumentType(oDocument)
  189.     If sDocType = "scalc" Then
  190.         oSheets = oDocument.Sheets
  191.         bDoProtect = False
  192.         For i = 0 To oSheets.Count-1
  193.             If Not oSheets(i).IsProtected Then
  194.                 bDoProtect = True
  195.             End If
  196.         Next i
  197.         If bDoProtect Then
  198.             iResult = Msgbox( "Do you want to protect all sheets of this document?",35, GetProductName())
  199.             If iResult = 6 Then
  200.                 ProtectSheets(oDocument.Sheets)
  201.             End If
  202.         End If
  203.     End If
  204. End Sub</script:module>