Source Code Cross Referenced for Area3DPtg.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » record » formula » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.record.formula 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:           Licensed to the Apache Software Foundation (ASF) under one or more
003:           contributor license agreements.  See the NOTICE file distributed with
004:           this work for additional information regarding copyright ownership.
005:           The ASF licenses this file to You under the Apache License, Version 2.0
006:           (the "License"); you may not use this file except in compliance with
007:           the License.  You may obtain a copy of the License at
008:
009:               http://www.apache.org/licenses/LICENSE-2.0
010:
011:           Unless required by applicable law or agreed to in writing, software
012:           distributed under the License is distributed on an "AS IS" BASIS,
013:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:           See the License for the specific language governing permissions and
015:           limitations under the License.
016:        ==================================================================== */
017:
018:        package org.apache.poi.hssf.record.formula;
019:
020:        import org.apache.poi.util.LittleEndian;
021:        import org.apache.poi.hssf.util.AreaReference;
022:        import org.apache.poi.hssf.util.CellReference;
023:        import org.apache.poi.hssf.util.SheetReferences;
024:
025:        import org.apache.poi.hssf.model.Workbook;
026:        import org.apache.poi.hssf.record.RecordInputStream;
027:        import org.apache.poi.util.BitField;
028:        import org.apache.poi.util.BitFieldFactory;
029:
030:        /**
031:         * Title:        Area 3D Ptg - 3D referecnce (Sheet + Area)<P>
032:         * Description:  Defined a area in Extern Sheet. <P>
033:         * REFERENCE:  <P>
034:         * @author Libin Roman (Vista Portal LDT. Developer)
035:         * @author avik
036:         * @author Jason Height (jheight at chariot dot net dot au)
037:         * @version 1.0-pre
038:         */
039:
040:        public class Area3DPtg extends Ptg {
041:            public final static byte sid = 0x3b;
042:            private final static int SIZE = 11; // 10 + 1 for Ptg
043:            private short field_1_index_extern_sheet;
044:            private short field_2_first_row;
045:            private short field_3_last_row;
046:            private short field_4_first_column;
047:            private short field_5_last_column;
048:
049:            private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
050:            private BitField colRelative = BitFieldFactory.getInstance(0x4000);
051:
052:            /** Creates new AreaPtg */
053:            public Area3DPtg() {
054:            }
055:
056:            public Area3DPtg(String arearef, short externIdx) {
057:                setArea(arearef);
058:                setExternSheetIndex(externIdx);
059:
060:            }
061:
062:            public Area3DPtg(RecordInputStream in) {
063:                field_1_index_extern_sheet = in.readShort();
064:                field_2_first_row = in.readShort();
065:                field_3_last_row = in.readShort();
066:                field_4_first_column = in.readShort();
067:                field_5_last_column = in.readShort();
068:            }
069:
070:            public String toString() {
071:                StringBuffer buffer = new StringBuffer();
072:
073:                buffer.append("AreaPtg\n");
074:                buffer.append(
075:                        "Index to Extern Sheet = " + getExternSheetIndex())
076:                        .append("\n");
077:                buffer.append("firstRow = " + getFirstRow()).append("\n");
078:                buffer.append("lastRow  = " + getLastRow()).append("\n");
079:                buffer.append("firstCol = " + getFirstColumn()).append("\n");
080:                buffer.append("lastCol  = " + getLastColumn()).append("\n");
081:                buffer.append("firstColRel= " + isFirstRowRelative()).append(
082:                        "\n");
083:                buffer.append("lastColRowRel = " + isLastRowRelative()).append(
084:                        "\n");
085:                buffer.append("firstColRel   = " + isFirstColRelative())
086:                        .append("\n");
087:                buffer.append("lastColRel    = " + isLastColRelative()).append(
088:                        "\n");
089:                return buffer.toString();
090:            }
091:
092:            public void writeBytes(byte[] array, int offset) {
093:                array[0 + offset] = (byte) (sid + ptgClass);
094:                LittleEndian.putShort(array, 1 + offset, getExternSheetIndex());
095:                LittleEndian.putShort(array, 3 + offset, getFirstRow());
096:                LittleEndian.putShort(array, 5 + offset, getLastRow());
097:                LittleEndian.putShort(array, 7 + offset, getFirstColumnRaw());
098:                LittleEndian.putShort(array, 9 + offset, getLastColumnRaw());
099:            }
100:
101:            public int getSize() {
102:                return SIZE;
103:            }
104:
105:            public short getExternSheetIndex() {
106:                return field_1_index_extern_sheet;
107:            }
108:
109:            public void setExternSheetIndex(short index) {
110:                field_1_index_extern_sheet = index;
111:            }
112:
113:            public short getFirstRow() {
114:                return field_2_first_row;
115:            }
116:
117:            public void setFirstRow(short row) {
118:                field_2_first_row = row;
119:            }
120:
121:            public short getLastRow() {
122:                return field_3_last_row;
123:            }
124:
125:            public void setLastRow(short row) {
126:                field_3_last_row = row;
127:            }
128:
129:            public short getFirstColumn() {
130:                return (short) (field_4_first_column & 0xFF);
131:            }
132:
133:            public short getFirstColumnRaw() {
134:                return field_4_first_column;
135:            }
136:
137:            public boolean isFirstRowRelative() {
138:                return rowRelative.isSet(field_4_first_column);
139:            }
140:
141:            public boolean isFirstColRelative() {
142:                return colRelative.isSet(field_4_first_column);
143:            }
144:
145:            public void setFirstColumn(short column) {
146:                field_4_first_column &= 0xFF00;
147:                field_4_first_column |= column & 0xFF;
148:            }
149:
150:            public void setFirstColumnRaw(short column) {
151:                field_4_first_column = column;
152:            }
153:
154:            public short getLastColumn() {
155:                return (short) (field_5_last_column & 0xFF);
156:            }
157:
158:            public short getLastColumnRaw() {
159:                return field_5_last_column;
160:            }
161:
162:            public boolean isLastRowRelative() {
163:                return rowRelative.isSet(field_5_last_column);
164:            }
165:
166:            public boolean isLastColRelative() {
167:                return colRelative.isSet(field_5_last_column);
168:            }
169:
170:            public void setLastColumn(short column) {
171:                field_5_last_column &= 0xFF00;
172:                field_5_last_column |= column & 0xFF;
173:            }
174:
175:            public void setLastColumnRaw(short column) {
176:                field_5_last_column = column;
177:            }
178:
179:            /**
180:             * sets the first row to relative or not
181:             * @param rel FIXME: Document this!
182:             */
183:            public void setFirstRowRelative(boolean rel) {
184:                field_4_first_column = rowRelative.setShortBoolean(
185:                        field_4_first_column, rel);
186:            }
187:
188:            /**
189:             * set whether the first column is relative
190:             */
191:            public void setFirstColRelative(boolean rel) {
192:                field_4_first_column = colRelative.setShortBoolean(
193:                        field_4_first_column, rel);
194:            }
195:
196:            /**
197:             * set whether the last row is relative or not
198:             * @param rel FIXME: Document this!
199:             */
200:            public void setLastRowRelative(boolean rel) {
201:                field_5_last_column = rowRelative.setShortBoolean(
202:                        field_5_last_column, rel);
203:            }
204:
205:            /**
206:             * set whether the last column should be relative or not
207:             */
208:            public void setLastColRelative(boolean rel) {
209:                field_5_last_column = colRelative.setShortBoolean(
210:                        field_5_last_column, rel);
211:            }
212:
213:            /*public String getArea(){
214:            	RangeAddress ra = new RangeAddress( getFirstColumn(),getFirstRow() + 1, getLastColumn(), getLastRow() + 1);
215:            	String result = ra.getAddress();
216:
217:            	return result;
218:            }*/
219:
220:            public void setArea(String ref) {
221:                AreaReference ar = new AreaReference(ref);
222:
223:                setFirstRow((short) ar.getCells()[0].getRow());
224:                setFirstColumn((short) ar.getCells()[0].getCol());
225:                setLastRow((short) ar.getCells()[1].getRow());
226:                setLastColumn((short) ar.getCells()[1].getCol());
227:                setFirstColRelative(!ar.getCells()[0].isColAbsolute());
228:                setLastColRelative(!ar.getCells()[1].isColAbsolute());
229:                setFirstRowRelative(!ar.getCells()[0].isRowAbsolute());
230:                setLastRowRelative(!ar.getCells()[1].isRowAbsolute());
231:
232:            }
233:
234:            public String toFormulaString(Workbook book) {
235:                SheetReferences refs = book == null ? null : book
236:                        .getSheetReferences();
237:                StringBuffer retval = new StringBuffer();
238:                if (refs != null) {
239:                    retval.append(refs
240:                            .getSheetName(this .field_1_index_extern_sheet));
241:                    retval.append('!');
242:                }
243:                retval.append((new CellReference(getFirstRow(),
244:                        getFirstColumn(), !isFirstRowRelative(),
245:                        !isFirstColRelative())).toString());
246:                retval.append(':');
247:                retval
248:                        .append((new CellReference(getLastRow(),
249:                                getLastColumn(), !isLastRowRelative(),
250:                                !isLastColRelative())).toString());
251:                return retval.toString();
252:            }
253:
254:            public byte getDefaultOperandClass() {
255:                return Ptg.CLASS_REF;
256:            }
257:
258:            public Object clone() {
259:                Area3DPtg ptg = new Area3DPtg();
260:                ptg.field_1_index_extern_sheet = field_1_index_extern_sheet;
261:                ptg.field_2_first_row = field_2_first_row;
262:                ptg.field_3_last_row = field_3_last_row;
263:                ptg.field_4_first_column = field_4_first_column;
264:                ptg.field_5_last_column = field_5_last_column;
265:                ptg.setClass(ptgClass);
266:                return ptg;
267:            }
268:
269:            public boolean equals(Object o) {
270:                if (this  == o)
271:                    return true;
272:                if (!(o instanceof  Area3DPtg))
273:                    return false;
274:
275:                final Area3DPtg area3DPtg = (Area3DPtg) o;
276:
277:                if (field_1_index_extern_sheet != area3DPtg.field_1_index_extern_sheet)
278:                    return false;
279:                if (field_2_first_row != area3DPtg.field_2_first_row)
280:                    return false;
281:                if (field_3_last_row != area3DPtg.field_3_last_row)
282:                    return false;
283:                if (field_4_first_column != area3DPtg.field_4_first_column)
284:                    return false;
285:                if (field_5_last_column != area3DPtg.field_5_last_column)
286:                    return false;
287:
288:                return true;
289:            }
290:
291:            public int hashCode() {
292:                int result;
293:                result = (int) field_1_index_extern_sheet;
294:                result = 29 * result + (int) field_2_first_row;
295:                result = 29 * result + (int) field_3_last_row;
296:                result = 29 * result + (int) field_4_first_column;
297:                result = 29 * result + (int) field_5_last_column;
298:                return result;
299:            }
300:
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.