calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / wizards / source / tutorials / ShowInfoDialog.xba
blobe1da4b596237df5b42e591728aae20d4700a2a1e
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <!--
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 .
19 -->
20 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ShowInfoDialog" script:language="StarBasic">REM ***** BASIC *****
21 Dim oWnd As Object
22 Dim oWnd2 As Object
23 Dim oWnd3 As Object
24 Dim oDoc as Object
26 Sub ShowInfoMain
27 prop() = GetShowInfoProperties()
28 Init(prop(0).Value, prop(1).Value, prop(2).Value, prop(3).Value, prop(4).Value, prop(5).Value, prop(6).Value, prop(7).Value, prop(8).Value)
29 End Sub
31 Sub Init(tFieldText As String, windowX, windowY, windowWidth, windowHeight, tFieldX, tFieldY, tFieldWidth, tFieldHeight)
32 toolkit = createUnoService(&quot;com.sun.star.awt.Toolkit&quot;)
33 Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
34 Dim oBounds As new com.sun.star.awt.Rectangle
35 oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
36 oWndDescr.WindowServiceName = &quot;&quot;
37 oWndDescr.ParentIndex = 0
39 &apos;officeX = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.X
40 &apos;officeY = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.Y
41 &apos;officeWidth = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Width
42 &apos;officeHeight = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Height
43 officeWidth = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Width
44 officeHeight = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Height
46 &apos;dialogWidth = myTutoShowDialog.getPosSize().Width
47 &apos;dialogHeight = myTutoShowDialog.getPosSize().Height
48 X = officeWidth - windowWidth - windowX
49 Y = officeHeight - windowHeight - windowY
51 oBounds.X = X : oBounds.Y = Y
52 oBounds.Width = windowWidth : oBounds.Height = windowHeight
53 oWndDescr.Bounds = oBounds
54 oWndDescr.Parent = thisComponent.CurrentController.Frame.ContainerWindow
55 with com.sun.star.awt.WindowAttribute
56 oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
57 end with
59 oWnd = toolkit.createWindow(oWndDescr)
61 Dim oWndDescr3 As new com.sun.star.awt.WindowDescriptor
62 Dim oBounds3 As new com.sun.star.awt.Rectangle
63 oWndDescr3.Type = com.sun.star.awt.WindowClass.TOP
64 oWndDescr3.WindowServiceName = &quot;fixedimage&quot; &apos;&quot;fixedtext&quot;
65 oWndDescr3.ParentIndex = 0
66 oBounds3.X = 0 : oBounds3.Y = 0
67 oBounds3.Width = tFieldWidth : oBounds3.Height = tFieldHeight
68 oWndDescr3.Bounds = oBounds3
69 oWndDescr3.Parent = oWnd
70 with com.sun.star.awt.WindowAttribute
71 oWndDescr3.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
72 end with
74 oWnd3= toolkit.createWindow(oWndDescr3)
75 &apos;oWnd2.Text = tFieldText
76 &apos;printdbgInfo(oWnd3)
77 setImage(oWnd3)
78 &apos;oWnd3.Background = 16777215
79 &apos; oWnd2.SetBackGround(16776960)
80 oWnd.SetBackGround(16776960)
81 &apos; oWnd.FontDescriptors(0).Name = &quot;Albany&quot;
82 &apos; oWnd.FontDescriptors(0).StyleName = &quot;BOLD&quot;
84 Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
85 Dim oBounds2 As new com.sun.star.awt.Rectangle
86 oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
87 oWndDescr2.WindowServiceName = &quot;fixedtext&quot;
88 oWndDescr2.ParentIndex = 0
89 oBounds2.X = tFieldX : oBounds2.Y = tFieldY
90 oBounds2.Width = tFieldWidth : oBounds2.Height = tFieldHeight
91 oWndDescr2.Bounds = oBounds2
92 oWndDescr2.Parent = oWnd3
93 with com.sun.star.awt.WindowAttribute
94 oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
95 end with
97 oWnd2= toolkit.createWindow(oWndDescr2)
98 oWnd2.Text = tFieldText
99 oWnd2.Background = 268435455
100 &apos;printdbgInfo(oWnd2)
102 &apos;printdbgInfo oWnd.getPosSize()
104 End Sub
106 Function GetShowInfoProperties()
107 stepText = GetStepTitle()
108 Dim Properties(8) As new com.sun.star.beans.NamedValue
109 Properties(0).Name = &quot;ShowInfoDialogText&quot;
110 Properties(0).Value = stepText &amp; &quot;Press [Esc] to abort.&quot;
111 Properties(1).Name = &quot;WindowX&quot;
112 Properties(1).Value = 20
113 Properties(2).Name = &quot;WindowY&quot;
114 Properties(2).Value = 40
115 Properties(3).Name = &quot;WindowWidth&quot;
116 Properties(3).Value = 190
117 Properties(4).Name = &quot;WindowHeight&quot;
118 Properties(4).Value = 50
119 Properties(5).Name = &quot;TFieldX&quot;
120 Properties(5).Value = 7
121 Properties(6).Name = &quot;TFieldY&quot;
122 Properties(6).Value = 8
123 Properties(7).Name = &quot;TFieldWidth&quot;
124 Properties(7).Value = 190
125 Properties(8).Name = &quot;TFieldHeight&quot;
126 Properties(8).Value = 50
127 GetShowInfoProperties = Properties()
128 End Function
130 Sub setShowInfoText()
131 stepText = GetStepTitle()
132 oWnd2.Text = stepText &amp; &quot;Press [Esc] to abort.&quot;
133 End Sub
135 Sub ShowON()
136 setShowInfoText()
137 oWnd.setVisible(True)
138 oWnd3.setVisible(True)
139 oWnd2.setVisible(True)
140 End Sub
142 Sub ShowOFF()
143 &apos;On Local Error Goto NOPROPERTYSETINFO:
144 oWnd.setVisible(False)
145 oWnd2.setVisible(False)
146 oWnd3.setVisible(False)
147 &apos;oDoc.dispose()
148 Exit Sub
149 &apos;NOPROPERTYSETINFO:
150 End Sub
152 Sub DisposeIDialog()
153 &apos;On Local Error Goto NOPROPERTYSETINFO:
154 oWnd3.dispose
155 oWnd2.dispose
156 oWnd.dispose
157 oDoc.dispose()
158 Exit Sub
159 &apos;NOPROPERTYSETINFO:
160 End Sub
162 sub setImage(whatever as Object)
164 templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
165 Dim bitmapPath As String
166 iPos = InStr(templatePath,&quot;/&quot;)
167 if(iPos &gt; 0) Then
168 bitmapPath = templatePath &amp; &quot;../wizard/bitmap/tutorial_background.gif&quot;
169 Else
170 bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\tutorial_background.gif&quot;
171 End If
173 dim props(0) as new com.sun.star.beans.PropertyValue
174 props(0).Name = &quot;Hidden&quot;
175 props(0).Value = true
176 oDoc = StarDesktop.loadComponentFromUrl(&quot;private:factory/swriter&quot;,&quot;_blank&quot;,0,props())
177 oShape = addControlToDefaultForm(&quot;ImageButton&quot;, 1000, 1000, 2000, 1000)
178 imgControl = oShape.getControl()
179 &apos;imgControl.ImageUrl=&quot;file:///D:/Program%20Files/src680_m11_qwizards1_49_TEST/share/gallery/tutoItem.gif&quot;
180 imgControl.ImageUrl = bitmapPath
181 imgControl.addConsumer(whatever)
182 imgControl.startProduction()
183 end sub
185 Function createControlShape(cKind As String) As Object
187 Dim oControlShape As Object
188 Dim oControl As Object
191 oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
192 oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
193 oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.form.control.&quot; &amp; cKind)
194 oControlShape.setControl(oControl)
197 createControlShape() = oControlShape
199 End Function
201 Function createControlShapeWithDefaultControl(cKind As String) As Object
203 Dim oControlShape As Object
204 Dim oControl As Object
207 oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
208 oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
209 oControlShape.setControl(oControl)
212 createControlShapeWithDefaultControl() = oControlShape
214 End Function
216 Function createUNOControlShape(cKind As String, defControl As String) As Object
218 Dim oControlShape As Object
219 Dim oControl As Object
222 oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
223 oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
224 oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.awt.&quot; &amp; defControl)
225 oControlShape.setControl(oControl)
228 createUNOControlShape() = oControlShape
230 End Function
232 Function addShape(oShape As Object) As Boolean
234 Dim vSize As New com.sun.star.awt.Size
235 Dim oDrawPage As Object
236 Dim oForms As Object
237 Dim oForm As Object
239 oDrawPage = oDoc.getDrawPage()
240 oForms = oDrawPage.getForms()
242 if oForms.Count = 0 then
243 oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
244 oForms.insertByIndex(0, oForm)
245 end if
247 vSize.Height = 2000 : vSize.Width = 2000
248 oShape.Size = vSize
249 oDrawPage.add(oShape)
251 addShape() = true
253 End Function
255 sub addControl(cKind as String)
257 Dim oDrawPage As Object
258 Dim oForm As Object, oForms As Object
259 Dim oControl As Object, oControlShape As Object
260 Dim aSz As Variant
261 Dim oText As Object
263 oDrawPage = oDoc.DrawPage
264 oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
265 oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
266 oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
267 oforms = oDrawPage.Forms
268 if oforms.count = 0 then
269 oforms.insertbyindex(0,oForm)
270 end if
271 oControlShape.Control = oControl
272 oDrawPage.add(oControlShape)
274 End sub
276 Function addControlToDefaultForm(cKind as String, x As Integer, y As Integer, width As Integer, height As Integer) As Object
278 Dim oDrawPage As Object
279 Dim oControl As Object, oControlShape As Object
280 Dim pos As New com.sun.star.awt.Point
281 Dim size As New com.sun.star.awt.Size
283 pos.X = x
284 pos.Y = y
285 size.Width = width
286 size.Height = height
288 oDrawPage = oDoc.DrawPage
289 oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
290 oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
291 oControlShape.Control = oControl
292 oControlShape.Position = pos
293 oControlShape.Size = size
294 oDrawPage.add(oControlShape)
296 addControlToDefaultForm() = oControlShape
298 End Function
300 Function addShapeToDrawDoc(oPage as Object, nPosX, nPosY as Integer, oType As String) As Object
301 Dim aPoint As New com.sun.star.awt.Point
302 Dim aSize As New com.sun.star.awt.Size
303 Dim oShape As Object
304 Dim servNames As Variant
306 aPoint.x = nPosX
307 aPoint.y = nPosY
308 aSize.Width = 2000
309 aSize.Height = 1000
310 oShape = oDoc.createInstance(&quot;com.sun.star.drawing.&quot;+oType+&quot;Shape&quot;)
311 oShape.Size = aSize
312 oShape.Position = aPoint
314 if oShape.getPropertySetInfo().hasPropertyByName(&quot;FillColor&quot;) then
315 oShape.FillColor = RGB(128, 255, 0)
316 End If
318 oPage.add(oShape)
320 addShapeToDrawDoc() = oShape
321 End Function
322 </script:module>