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