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 24 package org.openoffice.xmerge.converter.xml.sxc; 25 26 /** 27 * This is a class to define a table-column structure. This can then be 28 * used by plugins to write or read their own column types. 29 * 30 * @author Martin Maher 31 */ 32 public class ColumnRowInfo { 33 34 final public static int COLUMN = 0x01; 35 final public static int ROW = 0x02; 36 37 final private static int DEFAULTROWSIZE_MIN = 250; 38 final private static int DEFAULTROWSIZE_MAX = 260; 39 40 private int type; 41 private int dimension = 0; 42 private int repeated = 1; 43 private boolean userDefined = true; 44 private Format fmt = new Format(); 45 46 /** 47 * Constructor for a <code>ColumnRowInfo</code> 48 * 49 * @param type whether Row or column record 50 */ ColumnRowInfo(int type)51 public ColumnRowInfo(int type) { 52 53 this.type = type; 54 } 55 56 /** 57 * Constructor for a <code>ColumnRowInfo</code> 58 * 59 * @param dimension if it's a row the height, a column the width 60 * @param repeated how many times it is repeated 61 * @param type whether Row or column record 62 */ ColumnRowInfo(int dimension, int repeated, int type)63 public ColumnRowInfo(int dimension, int repeated, int type) { 64 65 this.dimension = dimension; 66 this.repeated = repeated; 67 this.type = type; 68 } 69 70 /** 71 * Constructor that includes userDefined field 72 * 73 * @param userDefined whether the record is manually set 74 */ ColumnRowInfo(int dimension, int repeated, int type, boolean userDefined)75 public ColumnRowInfo(int dimension, int repeated, int type, boolean userDefined) { 76 77 this(dimension, repeated, type); 78 this.userDefined = userDefined; 79 } 80 81 /** 82 * sets the definition 83 * 84 * @param fmt sets the definition 85 */ setFormat(Format fmt)86 public void setFormat(Format fmt) { 87 88 this.fmt = fmt; 89 } 90 91 /** 92 * returns Name of the definition 93 * 94 * @return the name which identifies the definition 95 */ getFormat()96 public Format getFormat() { 97 98 return fmt; 99 } 100 101 /** 102 * returns Name of the definition 103 * 104 * @return the name which identifies the definition 105 */ getSize()106 public int getSize() { 107 108 return dimension; 109 } 110 111 /** 112 * Sets the definition 113 * 114 * @param dimension 115 */ setSize(int dimension)116 public void setSize(int dimension) { 117 118 this.dimension = dimension; 119 } 120 /** 121 * Returns the definition itself 122 * 123 * @return the definition 124 */ getRepeated()125 public int getRepeated() { 126 127 return repeated; 128 } 129 130 /** 131 * Returns the base Cell address 132 * 133 * @return the base cell address 134 */ setRepeated(int repeated)135 public void setRepeated(int repeated) { 136 137 this.repeated = repeated; 138 } 139 140 /** 141 * Returns the definition itself 142 * 143 * @return the definition 144 */ isRow()145 public boolean isRow() { 146 147 if(type==ROW) 148 return true; 149 else 150 return false; 151 } 152 153 /** 154 * Returns the base Cell address 155 * 156 * @return the base cell address 157 */ isColumn()158 public boolean isColumn() { 159 160 if(type==COLUMN) 161 return true; 162 else 163 return false; 164 } 165 166 /** 167 * Test if the row height as been set manually 168 * 169 * @return true if user defined otherwise false 170 */ isUserDefined()171 public boolean isUserDefined() { 172 173 return userDefined; 174 } 175 176 /** 177 * Test if the row height is default 178 * 179 * @return true if default otherwise false 180 */ isDefaultSize()181 public boolean isDefaultSize() { 182 183 if( type==ROW && 184 dimension>DEFAULTROWSIZE_MIN && 185 dimension<DEFAULTROWSIZE_MAX) 186 return true; 187 else 188 return false; 189 } 190 } 191