1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"Debug" script:
language=
"StarBasic">REM ***** BASIC *****
22 Sub ActivateReadOnlyFlag()
23 SetBasicReadOnlyFlag(True)
27 Sub DeactivateReadOnlyFlag()
28 SetBasicReadOnlyFlag(False)
32 Sub SetBasicReadOnlyFlag(bReadOnly as Boolean)
35 Dim BasicLibNames() as String
36 BasicLibNames() = BasicLibraries.ElementNames()
37 For i =
0 To Ubound(BasicLibNames())
38 LibName = BasicLibNames(i)
39 If LibName
<> "Standard
" Then
40 BasicLibraries.SetLibraryReadOnly(LibName, bReadOnly)
46 Sub WritedbgInfo(LocObject as Object)
48 Dim oLocDocument as Object
49 Dim oLocText as Object
50 Dim oLocCursor as Object
52 Dim sObjectStrings(
2) as String
53 Dim sProperties() as String
56 Dim MaxIndex as Integer
57 sObjectStrings(
0) = LocObject.dbg_Properties
58 sObjectStrings(
1) = LocObject.dbg_Methods
59 sObjectStrings(
2) = LocObject.dbg_SupportedInterfaces
60 LocUrl =
"private:factory/swriter
"
61 oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,
"_default
",
0,NoArgs)
62 oLocText = oLocDocument.text
63 oLocCursor = oLocText.createTextCursor()
64 oLocCursor.gotoStart(False)
65 If Vartype(LocObject) =
9 then
' an Object Variable
67 sProperties() = ArrayoutofString(sObjectStrings(n),
";
", MaxIndex)
69 oLocText.insertString(oLocCursor,sProperties(m),False)
70 oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
73 Elseif Vartype(LocObject) =
8 Then
' a String Variable
74 oLocText.insertString(oLocCursor,LocObject,False)
75 ElseIf Vartype(LocObject) =
1 Then
76 Msgbox(
"Variable is Null!
",
16, GetProductName())
81 Sub WriteDbgString(LocString as string)
82 Dim oLocDesktop as object
84 Dim oLocDocument as Object
85 Dim oLocCursor as Object
86 Dim oLocText as Object
88 LocUrl =
"private:factory/swriter
"
89 oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,
"_default
",
0,NoArgs)
90 oLocText = oLocDocument.text
91 oLocCursor = oLocText.createTextCursor()
92 oLocCursor.gotoStart(False)
93 oLocText.insertString(oLocCursor,LocString,False)
97 Sub printdbgInfo(LocObject)
98 If Vartype(LocObject) =
9 then
99 Msgbox LocObject.dbg_properties
100 Msgbox LocObject.dbg_methods
101 Msgbox LocObject.dbg_supportedinterfaces
102 Elseif Vartype(LocObject) =
8 Then
' a String Variable
104 ElseIf Vartype(LocObject) =
0 Then
105 Msgbox(
"Variable is Null!
",
16, GetProductName())
107 Msgbox(
"Type of Variable:
" & Typename(LocObject),
48, GetProductName())
112 Sub ShowArray(LocArray())
115 msgstring =
""
116 For i = Lbound(LocArray()) to Ubound(LocArray())
117 msgstring = msgstring + LocArray(i) + chr(
13)
123 Sub ShowPropertyValues(oLocObject as Object)
124 Dim PropName as String
125 Dim sValues as String
126 On Local Error Goto NOPROPERTYSETINFO:
127 sValues =
""
128 For i =
0 To Ubound(oLocObject.PropertySetInfo.Properties)
129 Propname = oLocObject.PropertySetInfo.Properties(i).Name
130 sValues = sValues
& PropName
& chr(
13)
& " =
" & oLocObject.GetPropertyValue(PropName)
& chr(
13)
132 Msgbox(sValues ,
64, GetProductName())
136 Msgbox(
"Sorry, No PropertySetInfo attached to the object
",
16, GetProductName())
142 Sub ShowNameValuePair(Pair())
144 Dim ShowString as String
145 ShowString =
""
146 On Local Error Resume Next
147 For i =
0 To Ubound(Pair())
148 ShowString = ShowString
& Pair(i).Name
& " =
"
149 ShowString = ShowString
& Pair(i).Value
& chr(
13)
155 ' Retrieves all the Elements of aSequence of an object, with the
156 ' possibility to define a filter(sfilter
<> "")
157 Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
159 Dim NameString as String
160 NameString =
""
161 For i =
0 To Ubound(oLocElements())
162 If Not IsMissIng(sFilterName) Then
163 If Instr(
1, oLocElements(i), sFilterName) Then
164 NameString = NameString
& oLocElements(i)
& chr(
13)
167 NameString = NameString
& oLocElements(i)
& chr(
13)
170 Msgbox(NameString,
64, GetProductName())
174 ' Retrieves all the supported servicenames of an object, with the
175 ' possibility to define a filter(sfilter
<> "")
176 Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
177 On Local Error Goto NOSERVICENAMES
178 If IsMissing(sFilterName) Then
179 ShowElementNames(oLocobject.SupportedServiceNames())
181 ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
186 Msgbox(
"Sorry, No
'SupportedServiceNames
' - Property attached to the object
",
16, GetProductName())
192 ' Retrieves all the available Servicenames of an object, with the
193 ' possibility to define a filter(sfilter
<> "")
194 Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
195 On Local Error Goto NOSERVICENAMES
196 If IsMissing(sFilterName) Then
197 ShowElementNames(oLocobject.AvailableServiceNames)
199 ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
204 Msgbox(
"Sorry, No
'AvailableServiceNames
' - Property attached to the object
",
16, GetProductName())
210 Sub ShowCommands(oLocObject as Object)
211 On Local Error Goto NOCOMMANDS
212 ShowElementNames(oLocObject.QueryCommands)
215 Msgbox(
"Sorry, No
'QueryCommands
' - Property attached to the object
",
16, GetProductName())
221 Sub ProtectCurrentSheets()
222 Dim oDocument as Object
223 Dim sDocType as String
224 Dim iResult as Integer
225 Dim oSheets as Object
227 Dim bDoProtect as Boolean
228 oDocument = StarDesktop.ActiveFrame.Controller.Model
229 sDocType = GetDocumentType(oDocument)
230 If sDocType =
"scalc
" Then
231 oSheets = oDocument.Sheets
233 For i =
0 To oSheets.Count-
1
234 If Not oSheets(i).IsProtected Then
239 iResult = Msgbox(
"Do you want to protect all sheets of this document?
",
35, GetProductName())
241 ProtectSheets(oDocument.Sheets)
249 oMyReport = createUNOService(
"com.sun.star.wizards.report.CallReportWizard
")
250 oMyReport.trigger(
"fill
")