xref: /aoo4110/main/wizards/source/tools/Debug.xba (revision b1cdbd2c)
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Debug" script:language="StarBasic">REM  *****  BASIC  *****
24
25Sub ActivateReadOnlyFlag()
26	SetBasicReadOnlyFlag(True)
27End Sub
28
29
30Sub DeactivateReadOnlyFlag()
31	SetBasicReadOnlyFlag(False)
32End Sub
33
34
35Sub SetBasicReadOnlyFlag(bReadOnly as Boolean)
36Dim i as Integer
37Dim LibName as String
38Dim BasicLibNames() as String
39	BasicLibNames() = BasicLibraries.ElementNames()
40	For i = 0 To Ubound(BasicLibNames())
41		LibName = BasicLibNames(i)
42		If LibName &lt;&gt; &quot;Standard&quot; Then
43			BasicLibraries.SetLibraryReadOnly(LibName, bReadOnly)
44		End If
45	Next i
46End Sub
47
48
49Sub WritedbgInfo(LocObject as Object)
50Dim locUrl as String
51Dim oLocDocument as Object
52Dim oLocText as Object
53Dim oLocCursor as Object
54Dim NoArgs()
55Dim sObjectStrings(2) as String
56Dim sProperties() as String
57Dim n as Integer
58Dim m as Integer
59Dim MaxIndex as Integer
60	sObjectStrings(0) = LocObject.dbg_Properties
61	sObjectStrings(1) = LocObject.dbg_Methods
62	sObjectStrings(2) = LocObject.dbg_SupportedInterfaces
63	LocUrl = &quot;private:factory/swriter&quot;
64	oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,&quot;_default&quot;,0,NoArgs)
65	oLocText = oLocDocument.text
66	oLocCursor = oLocText.createTextCursor()
67	oLocCursor.gotoStart(False)
68	If Vartype(LocObject) = 9 then	&apos; an Object Variable
69		For n = 0 To 2
70			sProperties() = ArrayoutofString(sObjectStrings(n),&quot;;&quot;, MaxIndex)
71			For m = 0 To MaxIndex
72				oLocText.insertString(oLocCursor,sProperties(m),False)
73				oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
74			Next m
75		Next n
76	Elseif Vartype(LocObject) = 8 Then	&apos; a String Variable
77		oLocText.insertString(oLocCursor,LocObject,False)
78	ElseIf Vartype(LocObject) = 1 Then
79		Msgbox(&quot;Variable is Null!&quot;, 16, GetProductName())
80	End If
81End Sub
82
83
84Sub WriteDbgString(LocString as string)
85Dim oLocDesktop as object
86Dim LocUrl as String
87Dim oLocDocument as Object
88Dim oLocCursor as Object
89Dim oLocText as Object
90
91	LocUrl = &quot;private:factory/swriter&quot;
92	oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,&quot;_default&quot;,0,NoArgs)
93	oLocText = oLocDocument.text
94	oLocCursor = oLocText.createTextCursor()
95	oLocCursor.gotoStart(False)
96	oLocText.insertString(oLocCursor,LocString,False)
97End Sub
98
99
100Sub printdbgInfo(LocObject)
101	If Vartype(LocObject) = 9 then
102		Msgbox LocObject.dbg_properties
103		Msgbox LocObject.dbg_methods
104		Msgbox LocObject.dbg_supportedinterfaces
105	Elseif Vartype(LocObject) = 8 Then	&apos; a String Variable
106		Msgbox LocObject
107	ElseIf Vartype(LocObject) = 0 Then
108		Msgbox(&quot;Variable is Null!&quot;, 16, GetProductName())
109	Else
110		Msgbox(&quot;Type of Variable: &quot; &amp; Typename(LocObject), 48, GetProductName())
111	End If
112End Sub
113
114
115Sub ShowArray(LocArray())
116Dim i as integer
117Dim msgstring
118	msgstring = &quot;&quot;
119	For i = Lbound(LocArray()) to Ubound(LocArray())
120		msgstring = msgstring + LocArray(i) + chr(13)
121	Next
122	Msgbox msgstring
123End Sub
124
125
126Sub ShowPropertyValues(oLocObject as Object)
127Dim PropName as String
128Dim sValues as String
129	On Local Error Goto NOPROPERTYSETINFO:
130	sValues = &quot;&quot;
131	For i = 0 To Ubound(oLocObject.PropertySetInfo.Properties)
132		Propname = oLocObject.PropertySetInfo.Properties(i).Name
133		sValues = sValues &amp; PropName &amp; chr(13) &amp; &quot; = &quot; &amp; oLocObject.GetPropertyValue(PropName) &amp; chr(13)
134	Next i
135	Msgbox(sValues , 64, GetProductName())
136	Exit Sub
137
138NOPROPERTYSETINFO:
139	Msgbox(&quot;Sorry, No PropertySetInfo attached to the object&quot;, 16, GetProductName())
140	Resume LEAVEPROC
141	LEAVEPROC:
142End Sub
143
144
145Sub ShowNameValuePair(Pair())
146Dim i as Integer
147Dim ShowString as String
148	ShowString = &quot;&quot;
149	On Local Error Resume Next
150	For i = 0 To Ubound(Pair())
151		ShowString = ShowString &amp; Pair(i).Name &amp; &quot; = &quot;
152		ShowString = ShowString &amp; Pair(i).Value &amp; chr(13)
153	Next i
154	Msgbox ShowString
155End Sub
156
157
158&apos; Retrieves all the Elements of aSequence of an object, with the
159&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
160Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
161Dim i as Integer
162Dim NameString as String
163	NameString = &quot;&quot;
164	For i = 0 To Ubound(oLocElements())
165		If Not IsMissIng(sFilterName) Then
166			If Instr(1, oLocElements(i), sFilterName) Then
167				NameString = NameString &amp; oLocElements(i) &amp; chr(13)
168			End If
169		Else
170			NameString = NameString &amp; oLocElements(i) &amp; chr(13)
171		End If
172	Next i
173	Msgbox(NameString, 64, GetProductName())
174End Sub
175
176
177&apos; Retrieves all the supported servicenames of an object, with the
178&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
179Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
180	On Local Error Goto NOSERVICENAMES
181	If IsMissing(sFilterName) Then
182		ShowElementNames(oLocobject.SupportedServiceNames())
183	Else
184		ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
185	End If
186	Exit Sub
187
188	NOSERVICENAMES:
189	Msgbox(&quot;Sorry, No &apos;SupportedServiceNames&apos; - Property attached to the object&quot;, 16, GetProductName())
190	Resume LEAVEPROC
191	LEAVEPROC:
192End Sub
193
194
195&apos; Retrieves all the available Servicenames of an object, with the
196&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
197Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
198	On Local Error Goto NOSERVICENAMES
199	If IsMissing(sFilterName) Then
200		ShowElementNames(oLocobject.AvailableServiceNames)
201	Else
202		ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
203	End If
204	Exit Sub
205
206	NOSERVICENAMES:
207	Msgbox(&quot;Sorry, No &apos;AvailableServiceNames&apos; - Property attached to the object&quot;, 16, GetProductName())
208	Resume LEAVEPROC
209	LEAVEPROC:
210End Sub
211
212
213Sub ShowCommands(oLocObject as Object)
214	On Local Error Goto NOCOMMANDS
215	ShowElementNames(oLocObject.QueryCommands)
216	Exit Sub
217	NOCOMMANDS:
218	Msgbox(&quot;Sorry, No &apos;QueryCommands&apos; - Property attached to the object&quot;, 16, GetProductName())
219	Resume LEAVEPROC
220	LEAVEPROC:
221End Sub
222
223
224Sub ProtectCurrentSheets()
225Dim oDocument as Object
226Dim sDocType as String
227Dim iResult as Integer
228Dim oSheets as Object
229Dim i as Integer
230Dim bDoProtect as Boolean
231	oDocument = StarDesktop.ActiveFrame.Controller.Model
232	sDocType = GetDocumentType(oDocument)
233	If sDocType = &quot;scalc&quot; Then
234		oSheets = oDocument.Sheets
235		bDoProtect = False
236		For i = 0 To oSheets.Count-1
237			If Not oSheets(i).IsProtected Then
238				bDoProtect = True
239			End If
240		Next i
241		If bDoProtect Then
242			iResult = Msgbox( &quot;Do you want to protect all sheets of this document?&quot;,35, GetProductName())
243			If iResult = 6 Then
244				ProtectSheets(oDocument.Sheets)
245			End If
246		End If
247	End If
248End Sub
249
250
251Sub FillDocument()
252	oMyReport = createUNOService(&quot;com.sun.star.wizards.report.CallReportWizard&quot;)
253	oMyReport.trigger(&quot;fill&quot;)
254End Sub
255
256</script:module>
257