diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/form/FormControlArranger.java')
-rw-r--r-- | wizards/com/sun/star/wizards/form/FormControlArranger.java | 153 |
1 files changed, 87 insertions, 66 deletions
diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java index 73bad73b5fb1..1f67ee576196 100644 --- a/wizards/com/sun/star/wizards/form/FormControlArranger.java +++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java @@ -31,15 +31,13 @@ package com.sun.star.wizards.form; import com.sun.star.awt.Point; import com.sun.star.awt.Size; -import com.sun.star.beans.UnknownPropertyException; import com.sun.star.container.XNameContainer; -import com.sun.star.lang.IllegalArgumentException; -import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdbc.DataType; import com.sun.star.task.XStatusIndicator; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.Resource; import com.sun.star.wizards.db.*; import com.sun.star.wizards.document.Control; @@ -51,44 +49,45 @@ import com.sun.star.wizards.document.TimeStampControl; public class FormControlArranger { - XNameContainer xFormName; - XMultiServiceFactory xMSF; - public DatabaseControl[] DBControlList = null; - public Control[] LabelControlList = null; + protected DatabaseControl[] DBControlList = null; + + private XNameContainer xFormName; + private XMultiServiceFactory xMSF; + private Control[] LabelControlList = null; private XStatusIndicator xProgressBar; private FieldColumn[] FieldColumns; - DatabaseControl curDBControl; - Control curLabelControl; - int icurArrangement; - boolean bIsFirstRun; - boolean bIsVeryFirstRun; - boolean bControlsareCreated; - int cXOffset; - int cYOffset; - final int cVertDistance = 200; - final int cHoriDistance = 300; - final int cLabelGap = 100; - final double CMAXREDUCTION = 0.7; - FormHandler oFormHandler; - int iReduceWidth; - int nXTCPos; - int nYTCPos; - int nXDBPos; - int nYDBPos; - int nTCHeight; - int nTCWidth; - int nDBHeight; - int nDBWidth; - int nMaxTCWidth; - int nFormWidth; - int nFormHeight; - int nMaxRowY; - int nSecMaxRowY; - int nMaxColRightX; - int a; - int StartA; - int nMaxDBYPos = 0; //the maximum YPosition of a DBControl in the form - Short NBorderType = new Short((short) 1); //3-D Border + private DatabaseControl curDBControl; + // Control curLabelControl; + private int icurArrangement; + private boolean bIsFirstRun; + private boolean bIsVeryFirstRun; + private boolean bControlsareCreated; + private int cXOffset; + private int cYOffset; + private static final int cVertDistance = 200; + private static final int cHoriDistance = 300; + private static final int cLabelGap = 100; + private static final double CMAXREDUCTION = 0.7; + private FormHandler oFormHandler; + private int iReduceWidth; + private int nXTCPos; + private int nYTCPos; + private int nXDBPos; + private int nYDBPos; + private int nTCHeight; + private int nTCWidth; + private int nDBHeight; + private int nDBWidth; + private int nMaxTCWidth; + private int nFormWidth; + private int nFormHeight; + private int nMaxRowY; + private int nSecMaxRowY; + private int nMaxColRightX; + private int a; + private int StartA; + private int nMaxDBYPos = 0; //the maximum YPosition of a DBControl in the form + private Short NBorderType = new Short((short) 1); //3-D Border public FormControlArranger(FormHandler _oFormHandler, XNameContainer _xFormName, CommandMetaData oDBMetaData, XStatusIndicator _xProgressBar, Point _StartPoint, Size _FormSize) { @@ -122,13 +121,18 @@ public class FormControlArranger NBorderType = new Short(_nBorderType); } + public Control[] getLabelControlList() + { + return LabelControlList; + } + private int getCheckBoxDiffHeight(int LastIndex) { if ((LastIndex < DBControlList.length)) { if (DBControlList[LastIndex].getControlType() == FormHandler.SOCHECKBOX) { - return (int) ((oFormHandler.getDBRefHeight() - DBControlList[LastIndex].getDBHeight()) / 2); + return (int) ((oFormHandler.getControlReferenceHeight() - DBControlList[LastIndex].getControlHeight()) / 2); } } return 0; @@ -137,7 +141,7 @@ public class FormControlArranger private boolean isReducable(int _index) { boolean bisreducable = false; - int ntype = this.FieldColumns[_index].FieldType; + int ntype = this.FieldColumns[_index].getFieldType(); switch (ntype) { case DataType.TINYINT: @@ -277,7 +281,7 @@ public class FormControlArranger { int nControlBaseWidth = 0; curDBControl = this.DBControlList[i]; - curLabelControl = this.LabelControlList[i]; + Control curLabelControl = this.LabelControlList[i]; if (i != StartIndex) { curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y)); @@ -291,7 +295,7 @@ public class FormControlArranger { nControlBaseWidth = curDBControl.getSize().Width; } - if (FieldColumns[i].FieldType == DataType.TIMESTAMP) + if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP) { TimeStampControl oDBTimeStampControl = (TimeStampControl) curDBControl; nControlBaseWidth = oDBTimeStampControl.getSize().Width; @@ -380,12 +384,19 @@ public class FormControlArranger xProgressBar.start("", FieldColumns.length); for (int i = 0; i < FieldColumns.length; i++) { - insertLabel(i, _iAlign); - insertDBControl(i); - bIsVeryFirstRun = false; - DBControlList[i].setPropertyValue("LabelControl", curLabelControl.xPropertySet); - resetPosSizes(i); - xProgressBar.setValue(i + 1); + try + { + insertLabel(i, _iAlign); + insertDBControl(i); + bIsVeryFirstRun = false; + DBControlList[i].setPropertyValue("LabelControl", LabelControlList[i].xPropertySet); + resetPosSizes(i); + xProgressBar.setValue(i + 1); + } + catch (RuntimeException e) + { + int dummy = 0; + } } xProgressBar.end(); bControlsareCreated = true; @@ -523,7 +534,7 @@ public class FormControlArranger nXTCPos = cXOffset; nTCWidth = 2000; nDBWidth = 2000; - nDBHeight = oFormHandler.getDBRefHeight(); + nDBHeight = oFormHandler.getControlReferenceHeight(); nTCHeight = oFormHandler.getLabelHeight(); iReduceWidth = 0; if (icurArrangement == FormWizard.SOCOLUMNARLEFT) @@ -560,7 +571,8 @@ public class FormControlArranger { Point aPoint = new Point(nXTCPos, nYTCPos); Size aSize = new Size(nTCWidth, nTCHeight); - this.LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, FieldColumns[i].m_sFieldName, aPoint, aSize); + final String sFieldName = FieldColumns[i].getFieldName(); + this.LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, sFieldName, aPoint, aSize); if (bIsVeryFirstRun) { if (icurArrangement == FormWizard.SOCOLUMNARTOP) @@ -568,9 +580,10 @@ public class FormControlArranger nYDBPos = nYTCPos + nTCHeight; } } - nTCWidth = LabelControlList[i].getPreferredWidth(FieldColumns[i].getFieldTitle()); - } - curLabelControl = LabelControlList[i]; + String sTitle = FieldColumns[i].getFieldTitle(); + nTCWidth = LabelControlList[i].getPreferredWidth(sTitle); + } + Control curLabelControl = LabelControlList[i]; if (icurArrangement == FormWizard.SOCOLUMNARLEFT) { // Note This If Sequence must be called before retrieving the outer Points @@ -613,6 +626,9 @@ public class FormControlArranger { try { + String sFieldName = FieldColumns[i].getFieldName(); + int nFieldType = FieldColumns[i].getFieldType(); + Point aPoint = new Point(nXDBPos, nYDBPos); if (bControlsareCreated) { @@ -620,34 +636,39 @@ public class FormControlArranger } else { - if (FieldColumns[i].FieldType == DataType.TIMESTAMP) + if (nFieldType == DataType.TIMESTAMP) { - DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, FieldColumns[i].m_sFieldName, aPoint); + DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, sFieldName, aPoint); } else { - DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, FieldColumns[i].m_sFieldName, FieldColumns[i].FieldType, aPoint); + DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, sFieldName, nFieldType, aPoint); if (DBControlList[i].getControlType() == FormHandler.SOCHECKBOX) { + // Checkboxes have no Label near by DBControlList[i].setPropertyValue("Label", ""); } } } - this.curDBControl = DBControlList[i]; - nDBHeight = curDBControl.getDBHeight(); - nDBWidth = curDBControl.getDBWidth(); - if (FieldColumns[i].FieldType != DataType.TIMESTAMP) + DatabaseControl aDBControl = DBControlList[i]; + nDBHeight = aDBControl.getControlHeight(); + nDBWidth = aDBControl.getControlWidth(); + if (nFieldType != DataType.TIMESTAMP) { - curDBControl.setSize(new Size(nDBWidth, nDBHeight)); + aDBControl.setSize(new Size(nDBWidth, nDBHeight)); } - if (curDBControl.getControlType() == FormHandler.SOCHECKBOX) + if (aDBControl.getControlType() == FormHandler.SOCHECKBOX) { - nYDBPos = nYDBPos + /*(int)*/ ((oFormHandler.getDBRefHeight() - nDBHeight) / 2); + nYDBPos = nYDBPos + /*(int)*/ ((oFormHandler.getControlReferenceHeight() - nDBHeight) / 2); aPoint = new Point(nXDBPos, nYDBPos); - curDBControl.setPosition(aPoint); + aDBControl.setPosition(aPoint); + } + if (nFieldType == DataType.LONGVARCHAR) /* memo */ + { + Helper.setUnoPropertyValue(LabelControlList[i], "MultiLine", Boolean.TRUE); } checkOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, true); - curDBControl.setPropertyValue("Border", NBorderType); + aDBControl.setPropertyValue("Border", NBorderType); } catch (Exception e) { |