1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.wizards.form; 24 25 import com.sun.star.awt.Point; 26 import com.sun.star.awt.Size; 27 import com.sun.star.container.XNameContainer; 28 import com.sun.star.lang.XMultiServiceFactory; 29 import com.sun.star.sdbc.DataType; 30 import com.sun.star.task.XStatusIndicator; 31 import com.sun.star.uno.AnyConverter; 32 import com.sun.star.uno.Exception; 33 import com.sun.star.wizards.common.Helper; 34 import com.sun.star.wizards.common.Resource; 35 import com.sun.star.wizards.common.PropertyNames; 36 import com.sun.star.wizards.db.*; 37 import com.sun.star.wizards.document.Control; 38 import com.sun.star.wizards.document.DatabaseControl; 39 import com.sun.star.wizards.document.FormHandler; 40 import com.sun.star.wizards.document.Shape; 41 import com.sun.star.wizards.document.TimeStampControl; 42 43 public class FormControlArranger 44 { 45 46 public static final String LABELCONTROL = "LabelControl"; 47 protected DatabaseControl[] DBControlList = null; 48 private XNameContainer xFormName; 49 private XMultiServiceFactory xMSF; 50 private Control[] LabelControlList = null; 51 private XStatusIndicator xProgressBar; 52 private FieldColumn[] FieldColumns; 53 // Control curLabelControl; 54 private int icurArrangement; 55 private boolean bIsFirstRun; 56 private boolean bIsVeryFirstRun; 57 private boolean bControlsareCreated; 58 private int cXOffset; 59 private int cYOffset; 60 private static final int cVertDistance = 200; 61 private static final int cHoriDistance = 300; 62 private static final int cLabelGap = 100; 63 private static final double CMAXREDUCTION = 0.7; 64 private FormHandler oFormHandler; 65 private int iReduceWidth; 66 private int m_currentLabelPosX; 67 private int m_currentLabelPosY; 68 private int m_currentControlPosX; 69 private int m_currentControlPosY; 70 private int m_LabelHeight; 71 private int m_LabelWidth; 72 private int m_dbControlHeight; 73 private int m_dbControlWidth; 74 private int m_MaxLabelWidth; 75 private int nFormWidth; 76 private int nFormHeight; 77 private int m_currentMaxRowHeight; 78 private int nSecMaxRowY; 79 private int m_maxPostionX; 80 private int a; 81 private int StartA; 82 private int m_controlMaxPosY = 0; //the maximum YPosition of a DBControl in the form 83 private Short NBorderType = new Short((short) 1); //3-D Border 84 FormControlArranger(FormHandler _oFormHandler, XNameContainer _xFormName, CommandMetaData oDBMetaData, XStatusIndicator _xProgressBar, Point _StartPoint, Size _FormSize)85 public FormControlArranger(FormHandler _oFormHandler, XNameContainer _xFormName, CommandMetaData oDBMetaData, XStatusIndicator _xProgressBar, Point _StartPoint, Size _FormSize) 86 { 87 FieldColumns = oDBMetaData.FieldColumns; 88 xMSF = oDBMetaData.xMSF; 89 xFormName = _xFormName; 90 xProgressBar = _xProgressBar; 91 LabelControlList = new Control[FieldColumns.length]; 92 DBControlList = new DatabaseControl[FieldColumns.length]; 93 oFormHandler = _oFormHandler; 94 cXOffset = _StartPoint.X; 95 cYOffset = _StartPoint.Y; 96 setFormSize(_FormSize); 97 } 98 // Note: on all Controls except for the checkbox the Label has to be set 99 // a bit under the DBControl because its Height is also smaller 100 getLabelDiffHeight(int _index)101 private int getLabelDiffHeight(int _index) 102 { 103 final DatabaseControl curDBControl = DBControlList[_index]; 104 if (curDBControl != null && curDBControl.getControlType() == FormHandler.SOCHECKBOX) 105 { 106 return getCheckBoxDiffHeight(_index); 107 } 108 return oFormHandler.getBasicLabelDiffHeight(); 109 } 110 setBorderType(short _nBorderType)111 public void setBorderType(short _nBorderType) 112 { 113 NBorderType = new Short(_nBorderType); 114 } 115 getLabelControlList()116 public Control[] getLabelControlList() 117 { 118 return LabelControlList; 119 } 120 getCheckBoxDiffHeight(int LastIndex)121 private int getCheckBoxDiffHeight(int LastIndex) 122 { 123 if (LastIndex < DBControlList.length && DBControlList[LastIndex].getControlType() == FormHandler.SOCHECKBOX) 124 { 125 return (oFormHandler.getControlReferenceHeight() - DBControlList[LastIndex].getControlHeight()) / 2; 126 } 127 return 0; 128 } 129 isReducable(int _index, int i_labelWidth, int i_dbControlWidth)130 private boolean isReducable(int _index, int i_labelWidth, int i_dbControlWidth) 131 { 132 boolean bisreducable = false; 133 int ntype = FieldColumns[_index].getFieldType(); 134 switch (ntype) 135 { 136 case DataType.TINYINT: 137 case DataType.SMALLINT: 138 case DataType.INTEGER: 139 case DataType.FLOAT: 140 case DataType.DATE: 141 case DataType.TIME: 142 case DataType.TIMESTAMP: 143 case DataType.REAL: 144 case DataType.DOUBLE: 145 case DataType.NUMERIC: 146 case DataType.DECIMAL: 147 case DataType.BIT: 148 case DataType.BOOLEAN: 149 bisreducable = false; 150 break; 151 case DataType.VARCHAR: 152 short nTextLen; 153 try 154 { 155 nTextLen = AnyConverter.toShort(DBControlList[_index].xPropertySet.getPropertyValue("MaxTextLen")); 156 if ((nTextLen == 0) || (nTextLen > 20)) 157 { 158 bisreducable = true; 159 } 160 } 161 catch (Exception e) 162 { 163 e.printStackTrace(System.out); 164 } 165 break; 166 case DataType.BIGINT: 167 bisreducable = true; 168 break; 169 default: 170 bisreducable = true; 171 } 172 if (bisreducable && i_labelWidth > 0.9 * CMAXREDUCTION * i_dbControlWidth) 173 { 174 bisreducable = false; 175 } 176 return bisreducable; 177 } 178 getControlGroupWidth()179 private int getControlGroupWidth() 180 { 181 if (m_dbControlWidth > m_LabelWidth) 182 { 183 return m_dbControlWidth; 184 } 185 else 186 { 187 return m_LabelWidth; 188 } 189 } 190 checkJustifiedPosition(int a)191 private void checkJustifiedPosition(int a) 192 { 193 int nBaseWidth = nFormWidth + cXOffset; 194 int nLeftDist = m_maxPostionX - nBaseWidth; 195 int nRightDist = nBaseWidth - (DBControlList[a].getPosition().X - cHoriDistance); 196 if (nLeftDist < 0.5 * nRightDist) 197 { 198 // Fieldwidths in the line can be made smaller.. 199 adjustLineWidth(StartA, a, nLeftDist, -1); 200 m_currentLabelPosY = m_currentMaxRowHeight + cVertDistance; 201 m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; 202 m_currentLabelPosX = cXOffset; 203 m_currentControlPosX = cXOffset; 204 bIsFirstRun = true; 205 StartA = a + 1; 206 } 207 else 208 { 209 // FieldWidths in the line can be made wider... 210 if (m_currentControlPosY + m_dbControlHeight == m_currentMaxRowHeight) 211 { 212 // The last Control was the highest in the row 213 m_currentLabelPosY = nSecMaxRowY; 214 } 215 else 216 { 217 m_currentLabelPosY = m_currentMaxRowHeight; 218 } 219 m_currentLabelPosY += cVertDistance; 220 m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; 221 m_currentControlPosX = cXOffset; 222 m_currentLabelPosX = cXOffset; 223 LabelControlList[a].setPosition(new Point(cXOffset, m_currentLabelPosY)); 224 DBControlList[a].setPosition(new Point(cXOffset, m_currentControlPosY)); 225 bIsFirstRun = true; 226 checkOuterPoints(m_currentControlPosX, m_dbControlWidth > m_LabelWidth ? m_dbControlWidth : m_LabelWidth, m_currentControlPosY, m_dbControlHeight, true); 227 m_currentLabelPosX = m_maxPostionX + cHoriDistance; 228 m_currentControlPosX = m_currentLabelPosX; 229 adjustLineWidth(StartA, a - 1, nRightDist, 1); 230 StartA = a; 231 } 232 } 233 getCorrWidth(int StartIndex, int EndIndex, int nDist, int Widthfactor)234 private int getCorrWidth(int StartIndex, int EndIndex, int nDist, int Widthfactor) 235 { 236 int ShapeCount; 237 if (Widthfactor > 0) 238 { 239 // shapes are made wide 240 ShapeCount = EndIndex - StartIndex + 1; 241 } 242 else 243 { 244 // shapes are made more narrow 245 ShapeCount = iReduceWidth; 246 } 247 return (nDist) / ShapeCount; 248 } 249 250 /** 251 * 252 * @param StartIndex 253 * @param EndIndex 254 * @param nDist 255 * @param WidthFactor is either '+1' or '-1' and determines whether the control shapes widths are to be made smaller or larger 256 */ adjustLineWidth(int StartIndex, int EndIndex, int nDist, int WidthFactor)257 private void adjustLineWidth(int StartIndex, int EndIndex, int nDist, int WidthFactor) 258 { 259 int CorrWidth = getCorrWidth(StartIndex, EndIndex, nDist, WidthFactor); 260 int iLocTCPosX = cXOffset; 261 for (int i = StartIndex; i <= EndIndex; i++) 262 { 263 int nControlBaseWidth = 0; 264 DatabaseControl dbControl = DBControlList[i]; 265 Control curLabelControl = LabelControlList[i]; 266 if (i != StartIndex) 267 { 268 curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y)); 269 dbControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y + m_LabelHeight)); 270 } 271 final Size labelSize = curLabelControl.getSize(); 272 Size controlSize = dbControl.getSize(); 273 if (((labelSize.Width > controlSize.Width)) && (WidthFactor > 0)) 274 { 275 nControlBaseWidth = labelSize.Width; 276 } 277 else 278 { 279 nControlBaseWidth = controlSize.Width; 280 } 281 if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP) 282 { 283 TimeStampControl oDBTimeStampControl = (TimeStampControl) dbControl; 284 nControlBaseWidth = oDBTimeStampControl.getSize().Width; 285 } 286 if (WidthFactor > 0 || isReducable(i, labelSize.Width, controlSize.Width)) 287 { 288 controlSize.Width = nControlBaseWidth + WidthFactor * CorrWidth; 289 dbControl.setSize(controlSize); 290 controlSize = dbControl.getSize(); 291 } 292 293 if (labelSize.Width > controlSize.Width) 294 { 295 iLocTCPosX += labelSize.Width; 296 } 297 else 298 { 299 iLocTCPosX += controlSize.Width; 300 } 301 iLocTCPosX += cHoriDistance; 302 } 303 if (WidthFactor > 0) 304 { 305 iReduceWidth = 1; 306 } 307 else 308 { 309 iReduceWidth = 0; 310 } 311 } 312 checkOuterPoints(int i_nXPos, int i_nWidth, int i_nYPos, int i_nHeight, boolean i_bIsDBField)313 private void checkOuterPoints(int i_nXPos, int i_nWidth, int i_nYPos, int i_nHeight, boolean i_bIsDBField) 314 { 315 if (icurArrangement == FormWizard.IN_BLOCK_TOP && i_bIsDBField) 316 { 317 // Only at DBControls you can measure the Value of nMaxRowY 318 if (bIsFirstRun) 319 { 320 m_currentMaxRowHeight = i_nYPos + i_nHeight; 321 nSecMaxRowY = m_currentMaxRowHeight; 322 } 323 else 324 { 325 int nRowY = i_nYPos + i_nHeight; 326 if (nRowY >= m_currentMaxRowHeight) 327 { 328 nSecMaxRowY = m_currentMaxRowHeight; 329 m_currentMaxRowHeight = nRowY; 330 } 331 } 332 } 333 // Find the outer right point 334 if (bIsFirstRun) 335 { 336 m_maxPostionX = i_nXPos + i_nWidth; 337 bIsFirstRun = false; 338 } 339 else 340 { 341 int nColRightX = i_nXPos + i_nWidth; 342 if (nColRightX > m_maxPostionX) 343 { 344 m_maxPostionX = nColRightX; 345 } 346 } 347 } 348 positionControls(int _icurArrangement, Point _aStartPoint, Size _aFormSize, short _iAlign, Short _NBorderType)349 public void positionControls(int _icurArrangement, Point _aStartPoint, Size _aFormSize, short _iAlign, Short _NBorderType) 350 { 351 try 352 { 353 NBorderType = _NBorderType; 354 setStartPoint(_aStartPoint); 355 icurArrangement = _icurArrangement; 356 initializePosSizes(); 357 initializeControlColumn(-1); 358 bIsVeryFirstRun = true; 359 m_currentMaxRowHeight = 0; 360 nSecMaxRowY = 0; 361 m_maxPostionX = 0; 362 xProgressBar.start(PropertyNames.EMPTY_STRING, FieldColumns.length); 363 for (int i = 0; i < FieldColumns.length; i++) 364 { 365 try 366 { 367 insertLabel(i, _iAlign); 368 insertDBControl(i); 369 bIsVeryFirstRun = false; 370 DBControlList[i].setPropertyValue(LABELCONTROL, LabelControlList[i].xPropertySet); 371 resetPosSizes(i); 372 xProgressBar.setValue(i + 1); 373 } 374 catch (RuntimeException e) 375 { 376 } 377 } 378 xProgressBar.end(); 379 bControlsareCreated = true; 380 } 381 catch (Exception e) 382 { 383 e.printStackTrace(System.out); 384 } 385 } 386 areControlsexisting()387 public boolean areControlsexisting() 388 { 389 if (DBControlList != null) 390 { 391 if (DBControlList.length > 0) 392 { 393 return (DBControlList[0] != null); 394 } 395 } 396 return false; 397 } 398 initializeControlColumn(int LastIndex)399 private void initializeControlColumn(int LastIndex) 400 { 401 bIsFirstRun = true; 402 StartA = LastIndex + 1; 403 a = 0; 404 } 405 resetPosSizes(int LastIndex)406 private void resetPosSizes(int LastIndex) 407 { 408 int nYRefPos = m_currentControlPosY; 409 switch (icurArrangement) 410 { 411 case FormWizard.COLUMNAR_LEFT: 412 m_currentControlPosY = m_currentControlPosY + m_dbControlHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex); 413 nYRefPos = m_currentControlPosY; 414 if ((m_currentControlPosY > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1))) 415 { 416 repositionColumnarLeftControls(LastIndex); 417 m_currentLabelPosX = m_maxPostionX + 2 * cHoriDistance; 418 m_currentControlPosX = m_currentLabelPosX + cLabelGap + m_MaxLabelWidth; 419 m_currentControlPosY = cYOffset; 420 nYRefPos = m_currentControlPosY; 421 initializeControlColumn(LastIndex); 422 } 423 else 424 { 425 /*a = a + 1;*/ 426 /* a += 1;*/ 427 ++a; 428 } 429 m_currentLabelPosY = m_currentControlPosY + getLabelDiffHeight(LastIndex); 430 if ((nYRefPos + m_dbControlHeight) > m_controlMaxPosY) 431 { 432 m_controlMaxPosY = nYRefPos + m_dbControlHeight; 433 } 434 435 break; 436 case FormWizard.COLUMNAR_TOP: 437 m_currentLabelPosY = m_currentControlPosY + m_dbControlHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex); 438 439 if ((m_currentLabelPosY > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1))) 440 { 441 m_currentControlPosX = m_maxPostionX + cHoriDistance; 442 m_currentLabelPosX = m_currentControlPosX; 443 nYRefPos = m_currentControlPosY; 444 m_currentControlPosY = cYOffset + m_LabelHeight + cVertDistance; 445 m_currentLabelPosY = cYOffset; 446 initializeControlColumn(LastIndex); 447 } 448 else 449 { 450 ++a; 451 } 452 if ((nYRefPos + m_dbControlHeight + cVertDistance) > m_controlMaxPosY) 453 { 454 m_controlMaxPosY = nYRefPos + m_dbControlHeight + cVertDistance; 455 } 456 break; 457 458 case FormWizard.IN_BLOCK_TOP: 459 if (isReducable(a, m_LabelWidth, m_dbControlWidth)) 460 { 461 ++iReduceWidth; 462 } 463 //if (m_maxPostionX > (nFormWidth-cXOffset-cXOffset)) // cXOffset + nFormWidth 464 if (m_maxPostionX > cXOffset + nFormWidth) 465 { 466 checkJustifiedPosition(a); 467 nYRefPos = m_currentControlPosY; 468 } 469 else 470 { 471 m_currentLabelPosX = m_maxPostionX + cHoriDistance; 472 } 473 if (a == FieldColumns.length - 1) 474 { 475 checkJustifiedPosition(a); 476 nYRefPos = m_currentControlPosY; 477 } 478 m_currentControlPosX = m_currentLabelPosX; 479 ++a; 480 if ((nYRefPos + m_dbControlHeight) > m_controlMaxPosY) 481 { 482 m_controlMaxPosY = nYRefPos + m_dbControlHeight; 483 } 484 break; 485 } 486 } 487 repositionColumnarLeftControls(int LastIndex)488 private void repositionColumnarLeftControls(int LastIndex) 489 { 490 bIsFirstRun = true; 491 for (int i = StartA; i <= LastIndex; i++) 492 { 493 if (i == StartA) 494 { 495 m_currentLabelPosX = LabelControlList[i].getPosition().X; 496 m_currentControlPosX = m_currentLabelPosX + m_MaxLabelWidth + cHoriDistance; 497 } 498 LabelControlList[i].setSize(new Size(m_MaxLabelWidth, m_LabelHeight)); 499 resetDBShape(DBControlList[i], m_currentControlPosX); 500 checkOuterPoints(m_currentControlPosX, m_dbControlWidth, m_currentControlPosY, m_dbControlHeight, true); 501 } 502 } 503 resetDBShape(Shape _curDBControl, int iXPos)504 private void resetDBShape(Shape _curDBControl, int iXPos) 505 { 506 m_dbControlWidth = _curDBControl.getSize().Width; 507 m_dbControlHeight = _curDBControl.getSize().Height; 508 _curDBControl.setPosition(new Point(iXPos, _curDBControl.getPosition().Y)); 509 } 510 initializePosSizes()511 private void initializePosSizes() 512 { 513 m_controlMaxPosY = 0; 514 m_currentLabelPosX = cXOffset; 515 m_LabelWidth = 2000; 516 m_dbControlWidth = 2000; 517 m_dbControlHeight = oFormHandler.getControlReferenceHeight(); 518 m_LabelHeight = oFormHandler.getLabelHeight(); 519 iReduceWidth = 0; 520 if (icurArrangement == FormWizard.COLUMNAR_LEFT) 521 { 522 m_currentLabelPosY = cYOffset + getLabelDiffHeight(0); 523 m_currentControlPosX = cXOffset + 3050; 524 m_currentControlPosY = cYOffset; 525 } 526 else 527 { 528 m_currentControlPosX = cXOffset; 529 m_currentLabelPosY = cYOffset; 530 } 531 } 532 insertLabel(int i, int _iAlign)533 private void insertLabel(int i, int _iAlign) 534 { 535 try 536 { 537 Point aPoint = new Point(m_currentLabelPosX, m_currentLabelPosY); 538 Size aSize = new Size(m_LabelWidth, m_LabelHeight); 539 if (bControlsareCreated) 540 { 541 LabelControlList[i].setPosition(aPoint); 542 if (icurArrangement != FormWizard.COLUMNAR_LEFT) 543 { 544 m_LabelWidth = LabelControlList[i].getPreferredWidth(FieldColumns[i].getFieldTitle()); 545 aSize.Width = m_LabelWidth; 546 LabelControlList[i].setSize(aSize); 547 } 548 else 549 { 550 m_LabelWidth = LabelControlList[i].getSize().Width; 551 } 552 } 553 else 554 { 555 final String sFieldName = FieldColumns[i].getFieldName(); 556 LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, sFieldName, aPoint, aSize); 557 if (bIsVeryFirstRun && icurArrangement == FormWizard.COLUMNAR_TOP) 558 { 559 m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; 560 } 561 final String sTitle = FieldColumns[i].getFieldTitle(); 562 m_LabelWidth = LabelControlList[i].getPreferredWidth(sTitle); 563 aSize.Width = m_LabelWidth; 564 LabelControlList[i].setSize(aSize); 565 } 566 Control curLabelControl = LabelControlList[i]; 567 if (icurArrangement == FormWizard.COLUMNAR_LEFT) 568 { 569 // Note This If Sequence must be called before retrieving the outer Points 570 if (bIsFirstRun) 571 { 572 m_MaxLabelWidth = m_LabelWidth; 573 bIsFirstRun = false; 574 } 575 else if (m_LabelWidth > m_MaxLabelWidth) 576 { 577 m_MaxLabelWidth = m_LabelWidth; 578 } 579 } 580 checkOuterPoints(m_currentLabelPosX, m_LabelWidth, m_currentLabelPosY, m_LabelHeight, false); 581 if ((icurArrangement == FormWizard.COLUMNAR_TOP) || (icurArrangement == FormWizard.IN_BLOCK_TOP)) 582 { 583 m_currentControlPosX = m_currentLabelPosX; 584 m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; 585 curLabelControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_ALIGN, new Short((short) com.sun.star.awt.TextAlign.LEFT)); 586 } 587 else 588 { 589 curLabelControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_ALIGN, new Short((short) _iAlign)); 590 } 591 if (!bControlsareCreated) 592 { 593 curLabelControl.setSize(new Size(m_LabelWidth, m_LabelHeight)); 594 } 595 // if (CurHelpText != PropertyNames.EMPTY_STRING){ 596 // oModel.HelpText = CurHelptext; 597 // } 598 } 599 catch (Exception e) 600 { 601 e.printStackTrace(System.out); 602 } 603 } 604 insertDBControl(int i)605 private void insertDBControl(int i) 606 { 607 try 608 { 609 String sFieldName = FieldColumns[i].getFieldName(); 610 int nFieldType = FieldColumns[i].getFieldType(); 611 612 Point aPoint = new Point(m_currentControlPosX, m_currentControlPosY); 613 if (bControlsareCreated) 614 { 615 DBControlList[i].setPosition(aPoint); 616 } 617 else 618 { 619 if (nFieldType == DataType.TIMESTAMP) 620 { 621 DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, sFieldName, aPoint); 622 } 623 else 624 { 625 DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, sFieldName, nFieldType, aPoint); 626 if (DBControlList[i].getControlType() == FormHandler.SOCHECKBOX) 627 { 628 // Checkboxes have no Label near by 629 DBControlList[i].setPropertyValue(PropertyNames.PROPERTY_LABEL, PropertyNames.EMPTY_STRING); 630 } 631 } 632 } 633 DatabaseControl aDBControl = DBControlList[i]; 634 m_dbControlHeight = aDBControl.getControlHeight(); 635 m_dbControlWidth = aDBControl.getControlWidth(); 636 if (nFieldType != DataType.TIMESTAMP) 637 { 638 aDBControl.setSize(new Size(m_dbControlWidth, m_dbControlHeight)); 639 } 640 if (aDBControl.getControlType() == FormHandler.SOCHECKBOX) 641 { 642 m_currentControlPosY = m_currentControlPosY + /*(int)*/ ((oFormHandler.getControlReferenceHeight() - m_dbControlHeight) / 2); 643 aPoint = new Point(m_currentControlPosX, m_currentControlPosY); 644 aDBControl.setPosition(aPoint); 645 } 646 if (nFieldType == DataType.LONGVARCHAR) /* memo */ 647 648 { 649 Helper.setUnoPropertyValue(LabelControlList[i], PropertyNames.PROPERTY_MULTILINE, Boolean.TRUE); 650 } 651 checkOuterPoints(m_currentControlPosX, m_dbControlWidth, m_currentControlPosY, m_dbControlHeight, true); 652 aDBControl.setPropertyValue(PropertyNames.PROPERTY_BORDER, NBorderType); 653 } 654 catch (Exception e) 655 { 656 e.printStackTrace(System.out); 657 } 658 } 659 assignFieldLength(int _fieldlength)660 private int assignFieldLength(int _fieldlength) 661 { 662 if (_fieldlength >= 65535) 663 { 664 return -1; 665 } 666 else 667 { 668 return _fieldlength; 669 } 670 } 671 getFormHeight()672 public int getFormHeight() 673 { 674 return m_controlMaxPosY - cYOffset; 675 } 676 getEntryPointY()677 public int getEntryPointY() 678 { 679 if (icurArrangement == FormWizard.COLUMNAR_TOP) 680 { 681 Control curLabelControl2 = LabelControlList[0]; 682 return curLabelControl2.getPosition().Y; 683 } 684 else 685 { 686 DatabaseControl curDBControl2 = DBControlList[0]; 687 return curDBControl2.getPosition().Y; 688 } 689 } 690 setStartPoint(Point _aPoint)691 public void setStartPoint(Point _aPoint) 692 { 693 cXOffset = _aPoint.X; 694 cYOffset = _aPoint.Y; 695 } 696 adjustYPositions(int _diffY)697 public void adjustYPositions(int _diffY) 698 { 699 for (int i = 0; i < DBControlList.length; i++) 700 { 701 Point aPoint = DBControlList[i].getPosition(); 702 DBControlList[i].setPosition(new Point(aPoint.X, aPoint.Y - _diffY)); 703 aPoint = LabelControlList[i].getPosition(); 704 LabelControlList[i].setPosition(new Point(aPoint.X, aPoint.Y - _diffY)); 705 } 706 m_controlMaxPosY = -_diffY; 707 cYOffset = -_diffY; 708 } 709 setFormSize(Size _FormSize)710 public void setFormSize(Size _FormSize) 711 { 712 nFormHeight = _FormSize.Height; 713 nFormWidth = _FormSize.Width; 714 } 715 } 716