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 *****
5 Sub ActivateReadOnlyFlag()
6 SetBasicReadOnlyFlag(True)
10 Sub DeactivateReadOnlyFlag()
11 SetBasicReadOnlyFlag(False)
15 Sub SetBasicReadOnlyFlag(bReadOnly as Boolean)
18 Dim 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)
29 Sub WritedbgInfo(LocObject as Object)
31 Dim oLocDocument as Object
32 Dim oLocText as Object
33 Dim oLocCursor as Object
35 Dim sObjectStrings(
2) as String
36 Dim sProperties() as String
39 Dim 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
50 sProperties() = ArrayoutofString(sObjectStrings(n),
";
", MaxIndex)
52 oLocText.insertString(oLocCursor,sProperties(m),False)
53 oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
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())
64 Sub WriteDbgString(LocString as string)
65 Dim oLocDesktop as object
67 Dim oLocDocument as Object
68 Dim oLocCursor as Object
69 Dim oLocText as Object
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)
80 Sub 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
87 ElseIf Vartype(LocObject) =
0 Then
88 Msgbox(
"Variable is Null!
",
16, GetProductName())
90 Msgbox(
"Type of Variable:
" & Typename(LocObject),
48, GetProductName())
95 Sub ShowArray(LocArray())
98 msgstring =
""
99 For i = Lbound(LocArray()) to Ubound(LocArray())
100 msgstring = msgstring + LocArray(i) + chr(
13)
106 Sub ShowPropertyValues(oLocObject as Object)
107 Dim PropName as String
108 Dim 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)
115 Msgbox(sValues ,
64, GetProductName())
119 Msgbox(
"Sorry, No PropertySetInfo attached to the object
",
16, GetProductName())
125 Sub ShowNameValuePair(Pair())
127 Dim 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)
138 ' Retrieves all the Elements of aSequence of an object, with the
139 ' possibility to define a filter(sfilter
<> "")
140 Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
142 Dim 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)
150 NameString = NameString
& oLocElements(i)
& chr(
13)
153 Msgbox(NameString,
64, GetProductName())
157 ' Retrieves all the supported servicenames of an object, with the
158 ' possibility to define a filter(sfilter
<> "")
159 Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
160 On Local Error Goto NOSERVICENAMES
161 If IsMissing(sFilterName) Then
162 ShowElementNames(oLocobject.SupportedServiceNames())
164 ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
169 Msgbox(
"Sorry, No
'SupportedServiceNames
' - Property attached to the object
",
16, GetProductName())
175 ' Retrieves all the available Servicenames of an object, with the
176 ' possibility to define a filter(sfilter
<> "")
177 Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
178 On Local Error Goto NOSERVICENAMES
179 If IsMissing(sFilterName) Then
180 ShowElementNames(oLocobject.AvailableServiceNames)
182 ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
187 Msgbox(
"Sorry, No
'AvailableServiceNames
' - Property attached to the object
",
16, GetProductName())
193 Sub ShowCommands(oLocObject as Object)
194 On Local Error Goto NOCOMMANDS
195 ShowElementNames(oLocObject.QueryCommands)
198 Msgbox(
"Sorry, No
'QueryCommands
' - Property attached to the object
",
16, GetProductName())
204 Sub ProtectCurrentSheets()
205 Dim oDocument as Object
206 Dim sDocType as String
207 Dim iResult as Integer
208 Dim oSheets as Object
210 Dim bDoProtect as Boolean
211 oDocument = StarDesktop.ActiveFrame.Controller.Model
212 sDocType = GetDocumentType(oDocument)
213 If sDocType =
"scalc
" Then
214 oSheets = oDocument.Sheets
216 For i =
0 To oSheets.Count-
1
217 If Not oSheets(i).IsProtected Then
222 iResult = Msgbox(
"Do you want to protect all sheets of this document?
",
35, GetProductName())
224 ProtectSheets(oDocument.Sheets)
232 oMyReport = createUNOService(
"com.sun.star.wizards.report.CallReportWizard
")
233 oMyReport.trigger(
"fill
")