final int nLeftPageIndent = getLeftPageIndent();
final int nLabelWidth = getMaxLabelWidth(); // 3000;
final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups());
final int nFieldWidth = nUsablePageWidth - nLabelWidth;
XGroup aLastGroup = null;
// after done with all groups, we need access to the last group, for set property 'KeepTogether' so we remember it.
for (int i = 0; i < m_aGroupNames.length; i++)
{
lastGroupPosition = i;
final XGroup xGroup = xGroups.createGroup();
aLastGroup = xGroup;
xGroup.setExpression(m_aGroupNames[i]);
xGroup.setHeaderOn(true);
try
{
int nCount = xGroups.getCount();
xGroups.insertByIndex(nCount, xGroup);
final XSection xGroupSection = xGroup.getHeader();
copyGroupProperties(nCount);
Rectangle aRect = new Rectangle();
aRect.X = nLeftPageIndent + getLeftGroupIndent(i);
SectionObject aSO = getDesignTemplate().getGroupLabel(i);
aRect = insertLabel(xGroupSection, getTitleFromFieldName(m_aGroupNames[i]), aRect, nLabelWidth, aSO);
final String sGroupName = convertToFieldName(m_aGroupNames[i]);
aSO = getDesignTemplate().getGroupTextField(i);
aRect = insertFormattedField(xGroupSection, sGroupName, aRect, nFieldWidth, aSO);
int height = aRect.Height;
// draw a line under the label/formattedfield
aRect.X = nLeftPageIndent + getLeftGroupIndent(i);
aRect.Y = aRect.Height;
final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X;
final int nLineHeight = LayoutConstants.LineHeight;
insertHorizontalLine(xGroupSection, aRect, nLineWidth, nLineHeight);
xGroupSection.setHeight(height + nLineHeight);
}
catch (com.sun.star.uno.Exception ex)
{
Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex);
}
}
// hold the inner group together
if (aLastGroup != null)
{
doNotBreakInTable(aLastGroup);
}
}
if (m_aSortNames != null)
{
for (String[] sortFieldName : m_aSortNames)
{
try
{
final XGroup xGroup = xGroups.createGroup();
xGroup.setExpression(sortFieldName[0]);
xGroup.setSortAscending(PropertyNames.ASC.equals(sortFieldName[1]));
xGroup.setHeaderOn(false);
int nCount = xGroups.getCount();
xGroups.insertByIndex(nCount, xGroup);
}
catch (java.lang.Exception ex)
{