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 
setRepeated(int repeated)130 	public void setRepeated(int repeated) {
131 
132 		this.repeated = repeated;
133 	}
134 
135 	/**
136 	 * Returns the definition itself
137 	 *
138 	 * @return the definition
139 	 */
isRow()140 	public boolean isRow() {
141 
142 		if(type==ROW)
143 			return true;
144 		else
145 			return false;
146 	}
147 
148 	/**
149 	 * Returns the base Cell address
150 	 *
151 	 * @return the base cell address
152 	 */
isColumn()153 	public boolean isColumn() {
154 
155 		if(type==COLUMN)
156 			return true;
157 		else
158 			return false;
159 	}
160 
161 	/**
162 	 * Test if the row height as been set manually
163 	 *
164 	 * @return true if user defined otherwise false
165 	 */
isUserDefined()166 	public boolean isUserDefined() {
167 
168 		return userDefined;
169 	}
170 
171 	/**
172 	 * Test if the row height is default
173 	 *
174 	 * @return true if default otherwise false
175 	 */
isDefaultSize()176 	public boolean isDefaultSize() {
177 
178 		if(	type==ROW &&
179 			dimension>DEFAULTROWSIZE_MIN &&
180 			dimension<DEFAULTROWSIZE_MAX)
181 			return true;
182 		else
183 			return false;
184 	}
185 }
186