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