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