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