develop.xba 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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.
  5. *
  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/.
  9. *
  10. * This file incorporates work covered by the following license notice:
  11. *
  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="develop" script:language="StarBasic">REM ***** BASIC *****
  21. Option Explicit
  22. Public oDBShapeList() as Object
  23. Public oTCShapeList() as Object
  24. Public oDBModelList() as Object
  25. Public oGroupShapeList() as Object
  26. Public oGridShape as Object
  27. Public a as Integer
  28. Public StartA as Integer
  29. Public bIsFirstRun as Boolean
  30. Public bIsVeryFirstRun as Boolean
  31. Public bControlsareCreated as Boolean
  32. Public nDBRefHeight as Long
  33. Public nXTCPos&amp;, nYTCPos&amp;, nXDBPos&amp;, nYDBPos&amp;, nTCHeight&amp;, nTCWidth&amp;, nDBHeight&amp;, nDBWidth&amp;
  34. Dim iReduceWidth as Integer
  35. Function PositionControls(Maxindex as Integer)
  36. Dim oTCModel as Object
  37. Dim oDBModel as Object
  38. Dim i as Integer
  39. InitializePosSizes()
  40. bIsFirstRun = True
  41. bIsVeryFirstRun = True
  42. a = 0
  43. StartA = 0
  44. nMaxRowY = 0
  45. nSecMaxRowY = 0
  46. If CurArrangement = cLeftJustified Or cTopJustified Then
  47. DialogModel.optAlign0.State = 1
  48. End If
  49. For i = 0 To MaxIndex
  50. GetCurrentMetaValues(i)
  51. oTCModel = InsertTextControl(i)
  52. If CurFieldType = com.sun.star.sdbc.DataType.TIMESTAMP Then
  53. InsertTimeStampShape(i)
  54. Else
  55. InsertDBControl(i)
  56. bIsVeryFirstRun = False
  57. oDBModelList(i).LabelControl = oTCModel
  58. End If
  59. GetLabelDiffHeight(i+1)
  60. ResetPosSizes(i)
  61. oProgressbar.Value = i
  62. Next i
  63. ControlCaptionstoStandardLayout()
  64. bControlsareCreated = True
  65. End Function
  66. Sub ResetPosSizes(LastIndex as Integer)
  67. Select Case CurArrangement
  68. Case cColumnarLeft
  69. nYDBPos = nYDBPos + nDBHeight + cVertDistance
  70. If (nYDBPos &gt; cYOffset + nFormHeight) Or (LastIndex = MaxIndex) Then
  71. RepositionColumnarLeftControls(LastIndex)
  72. nXTCPos = nMaxColRightX + 2 * cHoriDistance
  73. nXDBPos = nXTCPos + cHoriDistance + nMaxTCWidth
  74. nYDBPos = cYOffset
  75. bIsFirstRun = True
  76. StartA = LastIndex + 1
  77. a = 0
  78. Else
  79. a = a + 1
  80. End If
  81. nYTCPos = nYDBPos + LABELDIFFHEIGHT
  82. Case cColumnarTop
  83. nYTCPos = nYDBPos + nDBHeight + cVertDistance
  84. If nYTCPos &gt; cYOffset + nFormHeight Then
  85. nXDBPos = nMaxColRightX + cHoriDistance
  86. nXTCPos = nXDBPos
  87. nYDBPos = cYOffset + nTCHeight + cVertDistance
  88. nYTCPos = cYOffset
  89. bIsFirstRun = True
  90. StartA = LastIndex + 1
  91. a = 0
  92. Else
  93. a = a + 1
  94. End If
  95. Case cLeftJustified,cTopJustified
  96. If nMaxColRightX &gt; cXOffset + nFormWidth Then
  97. Dim nOldYTCPos as Long
  98. nOldYTCPos = nYTCPos
  99. CheckJustifiedPosition()
  100. Else
  101. nXTCPos = nMaxColRightX + CHoriDistance
  102. If CurArrangement = cLeftJustified Then
  103. nYTCPos = nYDBPos + LabelDiffHeight
  104. End If
  105. End If
  106. a = a + 1
  107. End Select
  108. End Sub
  109. Sub RepositionColumnarLeftControls(LastIndex as Integer)
  110. Dim aSize As New com.sun.star.awt.Size
  111. Dim aPoint As New com.sun.star.awt.Point
  112. Dim i as Integer
  113. aSize = GetSize(nMaxTCWidth, nTCHeight)
  114. bIsFirstRun = True
  115. For i = StartA To LastIndex
  116. If i = StartA Then
  117. nXTCPos = oTCShapeList(i).Position.X
  118. nXDBPos = nXTCPos + nMaxTCWidth + cHoriDistance
  119. End If
  120. ResetDBShape(oDBShapeList(i), nXDBPos)
  121. CheckOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, True)
  122. Next i
  123. End Sub
  124. Sub ResetDBShape(oLocDBShape as Object, iXPos as Long)
  125. Dim aSize As New com.sun.star.awt.Size
  126. Dim aPoint As New com.sun.star.awt.Point
  127. nYDBPos = oLocDBShape.Position.Y
  128. nDBWidth = oLocDBShape.Size.Width
  129. nDBHeight = oLocDBShape.Size.Height
  130. aPoint = GetPoint(iXPos,nYDBPos)
  131. oLocDBShape.SetPosition(aPoint)
  132. End Sub
  133. Sub InitializePosSizes()
  134. nXTCPos = cXOffset
  135. nTCWidth = 2000
  136. nDBWidth = 2000
  137. nDBHeight = nDBRefHeight
  138. iReduceWidth = 0
  139. Select Case CurArrangement
  140. Case cColumnarLeft, cLeftJustified
  141. GetLabelDiffHeight(0)
  142. nYTCPos = cYOffset + LABELDIFFHEIGHT
  143. nXDBPos = cXOffset + 3050
  144. nYDBPos = cYOffset
  145. Case cColumnarTop, cTopJustified
  146. nXDBPos = cXOffset
  147. nYTCPos = cYOffset
  148. End Select
  149. End Sub
  150. Function InsertTextControl(i as Integer) as Object
  151. Dim oShape as Object
  152. Dim oModel as Object
  153. Dim aPoint as New com.sun.star.awt.Point
  154. Dim aSize As New com.sun.star.awt.Size
  155. If bControlsareCreated Then
  156. Set oShape = oTCShapeList(i)
  157. Set oModel = oShape.GetControl
  158. If CurArrangement = cLeftJustified Then
  159. nTCWidth = GetPreferredWidth(oModel, True, CurFieldname)
  160. Else
  161. nTCWidth = oShape.Size.Width
  162. End If
  163. oShape.Position = GetPoint(nXTCPos, nYTCPos)
  164. If CurArrangement = cColumnarTop Then
  165. oModel.Align = com.sun.star.awt.TextAlign.LEFT
  166. End If
  167. Else
  168. oModel = CreateUnoService(oModelService(cLabel))
  169. aPoint = GetPoint(nXTCPos, nYTCPos)
  170. aSize = GetSize(nTCWidth,nTCHeight)
  171. Set oShape = InsertControl(oDrawPage, oModel, aPoint, aSize)
  172. Set oTCShapeList(i)= oShape
  173. If bIsVeryFirstRun Then
  174. If CurArrangement = cColumnarTop Then
  175. nYDBPos = nYTCPos + nTCHeight
  176. End If
  177. End If
  178. nTCWidth = GetPreferredWidth(oModel, True, CurFieldName)
  179. End If
  180. If CurArrangement = cColumnarLeft Then
  181. &apos; Note This If Sequence must be called before retrieving the outer Points
  182. If bIsFirstRun Then
  183. nMaxTCWidth = nTCWidth
  184. bIsFirstRun = False
  185. ElseIf nTCWidth &gt; nMaxTCWidth Then
  186. nMaxTCWidth = nTCWidth
  187. End If
  188. End If
  189. CheckOuterPoints(oShape.Position.X, nTCWidth, nYTCPos, nTCHeight, False)
  190. Select Case CurArrangement
  191. Case cLeftJustified
  192. nXDBPos = nMaxColRightX
  193. Case cColumnarTop,cTopJustified
  194. oModel.Align = com.sun.star.awt.TextAlign.LEFT
  195. nXDBPos = nXTCPos
  196. nYDBPos = nYTCPos + nTCHeight
  197. If CurFieldLength = 20 And nDBWidth &gt; 2 * nTCWidth Then
  198. iReduceWidth = iReduceWidth + 1
  199. End If
  200. End Select
  201. oShape.SetSize(GetSize(nTCWidth,nTCHeight))
  202. If CurHelpText &lt;&gt; &quot;&quot; Then
  203. oModel.HelpText = CurHelptext
  204. End If
  205. InsertTextControl = oModel
  206. End Function
  207. Sub InsertDBControl(i as Integer)
  208. Dim aPoint as New com.sun.star.awt.Point
  209. Dim aSize As New com.sun.star.awt.Size
  210. Dim oControl as Object
  211. Dim iColRightX as Long
  212. aPoint = GetPoint(nXDBPos, nYDBPos)
  213. If bControlsAreCreated Then
  214. oDBShapeList(i).Position = aPoint
  215. Else
  216. oDBModelList(i) = CreateUnoService(oModelService(CurControlType))
  217. oDBShapeList(i) = InsertControl(oDrawPage, oDBModelList(i), aPoint, aSize)
  218. SetNumerics(oDBModelList(i), CurFieldType)
  219. If CurControlType = cCheckBox Then
  220. oDBModelList(i).Label = &quot;&quot;
  221. End If
  222. oDBModelList(i).DataField = CurFieldName
  223. End If
  224. nDBHeight = GetDBHeight(oDBModelList(i))
  225. nDBWidth = GetPreferredWidth(oDBModelList(i),True)
  226. aSize = GetSize(nDBWidth,nDBHeight)
  227. oDBShapeList(i).SetSize(aSize)
  228. CheckOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, True)
  229. End Sub
  230. Function InsertTimeStampShape(i as Integer) as Object
  231. Dim oDateModel as Object
  232. Dim oTimeModel as Object
  233. Dim oDateShape as Object
  234. Dim oTimeShape as Object
  235. Dim oDateTimeShape as Object
  236. Dim aPoint as New com.sun.star.awt.Point
  237. Dim aSize as New com.sun.star.awt.Size
  238. Dim nDateWidth as Long
  239. Dim nTimeWidth as Long
  240. Dim oGroupShape as Object
  241. aPoint = GetPoint(nXDBPos, nYDBPos)
  242. If bControlsAreCreated Then
  243. oDBShapeList(i).Position = aPoint
  244. nDBWidth = oDBShapeList(i).Size.Width
  245. nDBHeight = oDBShapeList(i).Size.Height
  246. Else
  247. oGroupShape = oDocument.CreateInstance(&quot;com.sun.star.drawing.GroupShape&quot;)
  248. oGroupShape.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
  249. oDrawPage.Add(oGroupShape)
  250. CurFieldType = com.sun.star.sdbc.DataType.DATE
  251. oDateModel = CreateUnoService(&quot;com.sun.star.form.component.DateField&quot;)
  252. oDateModel.DataField = CurFieldName
  253. oDateShape = InsertControl(oGroupShape, oDateModel, aPoint, aSize)
  254. SetNumerics(oDateModel, CurFieldType)
  255. nDBHeight = GetDBHeight(oDateModel)
  256. nDateWidth = GetPreferredWidth(oDateModel,True)
  257. aSize = GetSize(nDateWidth,nDBHeight)
  258. oDateShape.SetSize(aSize)
  259. CurFieldType = com.sun.star.sdbc.DataType.TIME
  260. oTimeModel = CreateUnoService(&quot;com.sun.star.form.component.TimeField&quot;)
  261. oTimeModel.DataField = CurFieldName
  262. oTimeShape = InsertControl(oGroupShape, oTimeModel, aPoint, aSize)
  263. oTimeShape.Position = GetPoint(nXDBPos + 10 + nDateWidth,nYDBPos)
  264. nTimeWidth = GetPreferredWidth(oTimeModel)
  265. aSize = GetSize(nTimeWidth,nDBHeight)
  266. oTimeShape.SetSize(aSize)
  267. nDBWidth = nDateWidth + nTimeWidth + 10
  268. oGroupShape.Position = aPoint
  269. oGroupShape.Size = GetSize(nDBWidth, nDBHeight)
  270. Set oDBShapeList(i)= oGroupShape
  271. End If
  272. CheckOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, True)
  273. InsertTimeStampShape() = oDBShapeList(i)
  274. End Function
  275. &apos; Note: on all Controls except for the checkbox the Label has to be set
  276. &apos; a bit under the DBControl because its Height is also smaller
  277. Sub GetLabelDiffHeight(Index as Integer)
  278. If (CurArrangement = cLeftJustified) Or (CurArrangement = cColumnarLeft) Then
  279. If Index &lt;= Ubound(FieldMetaValues()) Then
  280. If FieldMetaValues(Index,2) = cCheckBox Then
  281. LabelDiffHeight = 0
  282. Else
  283. LabelDiffHeight = BasicLabelDiffHeight
  284. End If
  285. End If
  286. End If
  287. End Sub
  288. Sub CheckJustifiedPosition()
  289. Dim nLeftDist as Long
  290. Dim nRightDist as Long
  291. Dim oLocDBShape as Object
  292. Dim oLocTextShape as Object
  293. Dim nBaseWidth as Long
  294. nBaseWidth = nFormWidth + cXOffset
  295. nLeftDist = nMaxColRightX - nBaseWidth
  296. nRightDist = nBaseWidth - nXTCPos + cHoriDistance
  297. If nLeftDist &lt; 0.5 * nRightDist and iReduceWidth &gt; 2 Then
  298. &apos; Fieldwidths in the line can be made smaller
  299. AdjustLineWidth(StartA, a, nLeftDist, - 1)
  300. If CurArrangement = cLeftjustified Then
  301. nYDBPos = nMaxRowY + cVertDistance
  302. nYTCPos = nYDBPos + LABELDIFFHEIGHT
  303. nXTCPos = cXOffset
  304. Else
  305. nYTCPos = nMaxRowY + cVertDistance
  306. nYDBPos = nYTCPos + nTCHeight
  307. nXTCPos = cXOffset
  308. nXDBPos = cXOffset
  309. End If
  310. bIsFirstRun = True
  311. StartA = a + 1
  312. Else
  313. Set oLocDBShape = oDBShapeList(a)
  314. Set oLocTextShape = oTCShapeList(a)
  315. If CurArrangement = cLeftJustified Then
  316. If nYDBPos + nDBHeight = nMaxRowY Then
  317. &apos; The last Control was the highest in the row
  318. nYDBPos = nSecMaxRowY + cVertDistance
  319. Else
  320. nYDBPos = nMaxRowY + cVertDistance
  321. End If
  322. nYTCPos = nYDBPos + LABELDIFFHEIGHT
  323. nXDBPos = cXOffset + nTCWidth
  324. oLocTextShape.Position = GetPoint(cXOffset, nYTCPos)
  325. oLocDBShape.Position = GetPoint(nXDBPos, nYDBPos)
  326. &apos; PosSizes for the next two Controls
  327. nXTCPos = oLocDBShape.Position.X + oLocDBShape.Size.Width + cHoriDistance
  328. bIsFirstRun = True
  329. CheckOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, True)
  330. nXDBPos = nMaxColRightX + cHoriDistance
  331. Else &apos; cTopJustified
  332. If nYDBPos + nDBHeight = nMaxRowY Then
  333. &apos; The last Control was the highest in the row
  334. nYTCPos = nSecMaxRowY + cVertDistance
  335. Else
  336. nYTCPos = nMaxRowY + cVertDistance
  337. End If
  338. nYDBPos = nYTCPOS + nTCHeight
  339. nXDBPos = cXOffset
  340. nXTCPos = cXOffset
  341. oLocTextShape.Position = GetPoint(cXOffset, nYTCPos)
  342. oLocDBShape.Position = GetPoint(cXOffset, nYDBPos)
  343. bIsFirstRun = True
  344. If nDBWidth &gt; nTCWidth Then
  345. CheckOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, True)
  346. Else
  347. CheckOuterPoints(nXDBPos, nTCWidth, nYDBPos, nDBHeight, True)
  348. End If
  349. nXTCPos = nMaxColRightX + cHoriDistance
  350. nXDBPos = nXTCPos
  351. End If
  352. AdjustLineWidth(StartA, a-1, nRightDist, 1)
  353. StartA = a
  354. End If
  355. iReduceWidth = 0
  356. End Sub
  357. Function GetCorrWidth(StartIndex as Integer, EndIndex as Integer, nDist as Long, Widthfactor as Integer) as Integer
  358. Dim ShapeCount as Integer
  359. If WidthFactor &gt; 0 Then
  360. ShapeCount = EndIndex-StartIndex + 1
  361. Else
  362. ShapeCount = iReduceWidth
  363. End If
  364. GetCorrWidth() = (nDist)/ShapeCount
  365. End Function
  366. Sub AdjustLineWidth(StartIndex as Integer, EndIndex as Integer, nDist as Long, Widthfactor as Integer)
  367. Dim i as Integer
  368. Dim oLocDBShape as Object
  369. Dim oLocTCShape as Object
  370. Dim CorrWidth as Integer
  371. Dim bAdjustPos as Boolean
  372. Dim iLocTCPosX as Long
  373. Dim iLocDBPosX as Long
  374. CorrWidth = GetCorrWidth(StartIndex, EndIndex, nDist, Widthfactor)
  375. bAdjustPos = False
  376. iLocTCPosX = cXOffset
  377. For i = StartIndex To EndIndex
  378. Set oLocDBShape = oDBShapeList(i)
  379. Set oLocTCShape = oTCShapeList(i)
  380. If bAdjustPos Then
  381. oLocTCShape.Position = GetPoint(iLocTCPosX, oLocTCShape.Position.Y)
  382. If CurArrangement = cLeftJustified Then
  383. iLocDBPosX = oLocTCShape.Position.X + oLocTCShape.Size.Width
  384. oLocDBShape.Position = GetPoint(iLocDBPosX, oLocDBShape.Position.Y)
  385. Else
  386. oLocDBShape.Position = GetPoint(iLocTCPosX, oLocTCShape.Position.Y + nTCHeight)
  387. End If
  388. Else
  389. bAdjustPos = True
  390. End If
  391. If CDbl(FieldMetaValues(i,1)) &gt; 20 or WidthFactor &gt; 0 Then
  392. If (CurArrangement = cTopJustified) And (oLocTCShape.Size.Width &gt; oLocDBShape.Size.Width) Then
  393. oLocDBShape.Size = GetSize(oLocTCShape.Size.Width + WidthFactor * CorrWidth, oLocDBShape.Size.Height)
  394. Else
  395. oLocDBShape.Size = GetSize(oLocDBShape.Size.Width + WidthFactor * CorrWidth, oLocDBShape.Size.Height)
  396. End If
  397. End If
  398. iLocTCPosX = oLocDBShape.Position.X + oLocDBShape.Size.Width + cHoriDistance
  399. If CurArrangement = cTopJustified Then
  400. If oLocTCShape.Size.Width &gt; oLocDBShape.Size.Width Then
  401. iLocTCPosX = oLocDBShape.Position.X + oLocTCShape.Size.Width + cHoriDistance
  402. End If
  403. End If
  404. Next i
  405. End Sub
  406. Sub CheckOuterPoints(nXPos, nWidth, nYPos, nHeight, bIsDBField as Boolean)
  407. Dim nColRightX as Long
  408. Dim nRowY as Long
  409. Dim nOldMaxRowY as Long
  410. If CurArrangement = cLeftJustified Or CurArrangement = cTopJustified Then
  411. If bIsDBField Then
  412. &apos; Only at DBControls you can measure the Value of nMaxRowY
  413. If bIsFirstRun Then
  414. nMaxRowY = nYPos + nHeight
  415. nSecMaxRowY = nMaxRowY
  416. Else
  417. nRowY = nYPos + nHeight
  418. If nRowY &gt;= nMaxRowY Then
  419. nOldMaxRowY = nMaxRowY
  420. nSecMaxRowY = nOldMaxRowY
  421. nMaxRowY = nRowY
  422. End If
  423. End If
  424. End If
  425. End If
  426. &apos; Find the outer right point
  427. If bIsFirstRun Then
  428. nMaxColRightX = nXPos + nWidth
  429. bIsFirstRun = False
  430. Else
  431. nColRightX = nXPos + nWidth
  432. If nColRightX &gt; nMaxColRightX Then
  433. nMaxColRightX = nColRightX
  434. End If
  435. End If
  436. End Sub
  437. Function PositionGridControl(MaxIndex as Integer)
  438. Dim oControl as Object
  439. Dim n as Integer
  440. Dim oColumn as Object
  441. Dim aPoint as New com.sun.star.awt.Point
  442. Dim aSize as New com.sun.star.awt.Size
  443. If bControlsareCreated Then
  444. ShapesToNirwana()
  445. End If
  446. oGridModel = CreateUnoService(oModelService(cGridControl))
  447. oGridModel.Name = &quot;Grid1&quot;
  448. aPoint = GetPoint(cXOffset, cYOffset)
  449. aSize = GetSize(nFormWidth, nFormHeight)
  450. oDBForm.InsertByName (oGridModel.Name, oGridModel)
  451. oGridShape = InsertControl(oDrawPage, oGridModel, aPoint, aSize)
  452. For n = 0 to MaxIndex
  453. GetCurrentMetaValues(n)
  454. If CurFieldType = com.sun.star.sdbc.DataType.TIMESTAMP Then
  455. oColumn = SetupGridColumn(oGridModel,&quot;DateField&quot;, False, com.sun.star.sdbc.DataType.DATE, CurFieldName &amp; &quot; &quot; &amp; sDateAppendix)
  456. oColumn = SetupGridColumn(oGridModel,&quot;TimeField&quot;, False, com.sun.star.sdbc.DataType.TIME, CurFieldName &amp; &quot; &quot; &amp; sTimeAppendix)
  457. Else
  458. If CurControlType = cImageControl Then
  459. oColumn = SetupGridColumn(oGridModel,&quot;TextField&quot;, True, CurFieldType, CurFieldName)
  460. Else
  461. oColumn = SetupGridColumn(oGridModel, CurControlName, False, CurFieldType, CurFieldName)
  462. End If
  463. End If
  464. oProgressbar.Value = n
  465. next n
  466. End Function
  467. Function SetupGridColumn(oGridModel as Object, ControlName as String, bHidden as Boolean, iLocFieldType as Integer, ColName as String) as Object
  468. Dim oColumn as Object
  469. CurControlName = ControlName
  470. oColumn = oGridModel.CreateColumn(CurControlName)
  471. oColumn.Name = CalcUniqueContentName(oGridModel, CurControlName)
  472. oColumn.Hidden = bHidden
  473. SetNumerics(oColumn, iLocFieldType)
  474. oColumn.DataField = CurFieldName
  475. oColumn.Label = ColName
  476. oColumn.Width = 0 &apos; Width of column is adjusted to Columname
  477. oGridModel.insertByName(oColumn.Name, oColumn)
  478. End Function
  479. Sub ControlCaptionstoStandardLayout()
  480. Dim i as Integer
  481. Dim iBorderType as Integer
  482. Dim oCurModel as Object
  483. Dim oStyle as Object
  484. Dim iStandardColor as Long
  485. If CurArrangement &lt;&gt; cTabled Then
  486. oStyle = oDocument.StyleFamilies.GetByName(&quot;ParagraphStyles&quot;).GetByName(&quot;Standard&quot;)
  487. iStandardColor = oStyle.CharColor
  488. For i = 0 To MaxIndex
  489. oCurModel = oTCShapeList(i).GetControl
  490. If i = 0 Then
  491. If oCurModel.TextColor = iStandardColor Then
  492. Exit Sub
  493. End If
  494. End If
  495. oCurModel.TextColor = iStandardColor
  496. Next i
  497. End If
  498. End Sub
  499. Sub GroupShapesTogether()
  500. Dim i as Integer
  501. If CurArrangement &lt;&gt; cTabled Then
  502. For i = 0 To MaxIndex
  503. oGroupShapeList(i) = CreateUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)
  504. oGroupShapeList(i).Add(oTCShapeList(i))
  505. oGroupShapeList(i).Add(oDBShapeList(i))
  506. oDrawPage.Group(oGroupShapeList(i))
  507. Next i
  508. Else
  509. RemoveNirwanaShapes()
  510. End If
  511. End Sub</script:module>