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.reportbuilder.layout; 24 25 import com.sun.star.awt.Rectangle; 26 import com.sun.star.report.XGroup; 27 import com.sun.star.report.XSection; 28 import com.sun.star.wizards.common.Resource; 29 import com.sun.star.wizards.report.IReportDefinitionReadAccess; 30 import com.sun.star.wizards.ui.*; 31 32 /** 33 * 34 * @author ll93751 35 */ 36 public class InBlocksLabelsLeft extends ColumnarTwoColumns 37 { 38 InBlocksLabelsLeft(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)39 public InBlocksLabelsLeft(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) 40 { 41 super(_xDefinitionAccess, _aResource); 42 } 43 getName()44 public String getName() 45 { 46 return "InBlocksLabelsLeftLayoutOfData"; 47 } 48 getLocalizedName()49 public String getLocalizedName() 50 { 51 return getResource().getResText(UIConsts.RID_REPORT + 84); 52 } 53 insertDetailFields()54 protected void insertDetailFields() 55 { 56 copyDetailProperties(); 57 58 final String[] aFieldTitleNames = getFieldTitleNames(); 59 if (aFieldTitleNames == null) 60 { 61 return; 62 } 63 final String[] aFieldNames = getFieldNames(); 64 if (aFieldNames == null) 65 { 66 return; 67 } 68 // int nGroups = getReportDefinition().getGroups().getCount(); 69 70 final XSection xSection = getReportDefinition().getDetail(); 71 72 Rectangle aRectLabelFields = new Rectangle(); 73 74 final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()); 75 76 final int nLabelWidth = getMaxLabelWidth(); // 3000; 77 int nFieldWidth = 3000; 78 79 final int nFactor = nUsablePageWidth / (nLabelWidth + nFieldWidth); 80 int nDeltaTotal = 0; 81 int nDelta = 0; 82 if (nFactor > 0) 83 { 84 nDeltaTotal = nUsablePageWidth - (nFactor * (nLabelWidth + nFieldWidth)); 85 nDelta = nDeltaTotal / nFactor; 86 } 87 88 int i = 0; 89 int nCount = aFieldTitleNames.length; 90 // int x = 0; 91 aRectLabelFields.Y = 0; 92 aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); 93 94 SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); 95 aSOLabel.setFontToBold(); 96 SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); 97 int nLastHeight = 0; 98 while (nCount > 0) 99 { 100 final String sLabel = aFieldTitleNames[i]; 101 // nLabelWidth = 3000; 102 aRectLabelFields = insertLabel(xSection, sLabel, aRectLabelFields, nLabelWidth, aSOLabel); 103 final String sFieldName = convertToFieldName(aFieldNames[i]); 104 nFieldWidth = 3000 + nDelta; 105 aRectLabelFields = insertFormattedField(xSection, sFieldName, aRectLabelFields, nFieldWidth, aSOTextField); 106 nLastHeight = Math.max(aRectLabelFields.Height, nLastHeight); 107 final int nNextX = aRectLabelFields.X + nLabelWidth + nFieldWidth; 108 if (nNextX > (getPageWidth() - getRightPageIndent())) 109 { 110 // TODO: label height is fix 111 aRectLabelFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight); 112 nLastHeight = 0; 113 aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); 114 } 115 ++i; 116 --nCount; 117 } 118 aRectLabelFields.Y += Math.max(aSOLabel.getHeight(LayoutConstants.EmptyLineHeight), nLastHeight); // one empty line 119 xSection.setHeight(aRectLabelFields.Y); 120 doNotBreakInTable(xSection); 121 } 122 insertDetailFieldTitles(int lastGroupPostion)123 protected void insertDetailFieldTitles(int lastGroupPostion) 124 { 125 // we won't extra field titles 126 } 127 } 128