summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2014-12-19 23:21:52 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2014-12-19 23:35:14 +0100
commit2a7a6d1a70ae0087bbd77bf84df1f38d47d4801d (patch)
treec7d3b5630c0d4b2ec072e54991d7ad2c366c2331 /wizards
parente59629b94e36aaa7b2bfb24e433c1c25cbd479b4 (diff)
protect against division by zero
Change-Id: Ib91120e626f772bb52531c4a35fc70f04cc5c48f
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/form/FormControlArranger.java88
1 files changed, 47 insertions, 41 deletions
diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java
index 8b2374338934..bfa972c6ab14 100644
--- a/wizards/com/sun/star/wizards/form/FormControlArranger.java
+++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java
@@ -227,7 +227,10 @@ public class FormControlArranger
// shapes are made more narrow
ShapeCount = iReduceWidth;
}
- return (nDist) / ShapeCount;
+ if(ShapeCount == 0)
+ return 0;
+ else
+ return (nDist) / ShapeCount;
}
/**
@@ -237,51 +240,54 @@ public class FormControlArranger
* @param nDist
* @param WidthFactor is either '+1' or '-1' and determines whether the control shapes widths are to be made smaller or larger
*/
- private void adjustLineWidth(int StartIndex, int EndIndex, int nDist, int WidthFactor)
+ private void adjustLineWidth(final int StartIndex, final int EndIndex, final int nDist, final int WidthFactor)
{
- int CorrWidth = getCorrWidth(StartIndex, EndIndex, nDist, WidthFactor);
- int iLocTCPosX = cXOffset;
- for (int i = StartIndex; i <= EndIndex; i++)
+ if(StartIndex <= EndIndex)
{
- int nControlBaseWidth = 0;
- DatabaseControl dbControl = DBControlList[i];
- Control curLabelControl = LabelControlList[i];
- if (i != StartIndex)
- {
- curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y));
- dbControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y + m_LabelHeight));
- }
- final Size labelSize = curLabelControl.getSize();
- Size controlSize = dbControl.getSize();
- if (((labelSize.Width > controlSize.Width)) && (WidthFactor > 0))
- {
- nControlBaseWidth = labelSize.Width;
- }
- else
- {
- nControlBaseWidth = controlSize.Width;
- }
- if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP)
- {
- TimeStampControl oDBTimeStampControl = (TimeStampControl) dbControl;
- nControlBaseWidth = oDBTimeStampControl.getSize().Width;
- }
- if (WidthFactor > 0 || isReducable(i, labelSize.Width, controlSize.Width))
+ int CorrWidth = getCorrWidth(StartIndex, EndIndex, nDist, WidthFactor);
+ int iLocTCPosX = cXOffset;
+ for (int i = StartIndex; i <= EndIndex; i++)
{
- controlSize.Width = nControlBaseWidth + WidthFactor * CorrWidth;
- dbControl.setSize(controlSize);
- controlSize = dbControl.getSize();
- }
+ int nControlBaseWidth = 0;
+ DatabaseControl dbControl = DBControlList[i];
+ Control curLabelControl = LabelControlList[i];
+ if (i != StartIndex)
+ {
+ curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y));
+ dbControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y + m_LabelHeight));
+ }
+ final Size labelSize = curLabelControl.getSize();
+ Size controlSize = dbControl.getSize();
+ if (((labelSize.Width > controlSize.Width)) && (WidthFactor > 0))
+ {
+ nControlBaseWidth = labelSize.Width;
+ }
+ else
+ {
+ nControlBaseWidth = controlSize.Width;
+ }
+ if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP)
+ {
+ TimeStampControl oDBTimeStampControl = (TimeStampControl) dbControl;
+ nControlBaseWidth = oDBTimeStampControl.getSize().Width;
+ }
+ if (WidthFactor > 0 || isReducable(i, labelSize.Width, controlSize.Width))
+ {
+ controlSize.Width = nControlBaseWidth + WidthFactor * CorrWidth;
+ dbControl.setSize(controlSize);
+ controlSize = dbControl.getSize();
+ }
- if (labelSize.Width > controlSize.Width)
- {
- iLocTCPosX += labelSize.Width;
- }
- else
- {
- iLocTCPosX += controlSize.Width;
+ if (labelSize.Width > controlSize.Width)
+ {
+ iLocTCPosX += labelSize.Width;
+ }
+ else
+ {
+ iLocTCPosX += controlSize.Width;
+ }
+ iLocTCPosX += cHoriDistance;
}
- iLocTCPosX += cHoriDistance;
}
if (WidthFactor > 0)
{