View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-Excel: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Open World Ltd, Kevin Rogers
4   //
5   // This file is part of MillScript-Excel.
6   //
7   // MillScript-Excel is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-Excel is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-Excel; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.office.excel.records;
22  
23  import org.millscript.office.excel.Record;
24  import org.millscript.office.excel.RecordParser;
25  import org.millscript.office.excel.records.substructures.CellAttributes;
26  
27  /**
28   * 
29   */
30  public class Row extends Record {
31  
32      private CellAttributes defaultRowAttributes;
33  
34      private int indexOfFirstCell;
35  
36      private int indexOfLastCell;
37  
38      private int indexOfThisRow;
39  
40      private int indexToXFRecord;
41  
42      private int rowOptions;
43  
44      private int relativeOffsetToFirstCell;
45  
46      private int rowHeight;
47  
48      public Row( final int row, final int firstCell, final int lastCell ) {
49          this.indexOfThisRow = row;
50          this.indexOfFirstCell = firstCell;
51          this.indexOfLastCell = lastCell;
52      }
53  
54      public boolean additionalSpaceAboveTheRow() {
55          return 0 != ( this.rowOptions & 0x10000000 );
56      }
57  
58      public boolean additionalSpaceBelowTheRow() {
59          return 0 != ( this.rowOptions & 0x20000000 );
60      }
61  
62      public int getIndexToXFRecord() {
63          if ( this.rowHasExplicitDefaultFormat() ) {
64              return ( this.rowOptions & 0x0FFF0000 ) >> 16;
65          } else {
66              return -1;
67          }
68      }
69  
70      public byte getOutlineLevel() {
71          return (byte) ( this.rowOptions & 0x00000007 );
72      }
73  
74      /**
75       * @see org.millscript.office.excel.Record#handle(org.millscript.office.excel.RecordParser)
76       */
77      @Override
78      public void handle( final RecordParser recordParser ) {
79          // Set the row width is the worksheet
80          recordParser.getCurrentWorksheet().initialiseRow( this.indexOfThisRow + 1, this.indexOfLastCell + 1 );
81      }
82  
83      public boolean outlineGroupEdgeHereAndIsCollapsed() {
84          return 0 != ( this.rowOptions & 0x00000010 );
85      }
86  
87      public boolean rowIsHidden() {
88          return 0 != ( this.rowOptions & 0x00000020 );
89      }
90  
91      public boolean rowHasExplicitDefaultFormat() {
92          return 0 != ( this.rowOptions & 0x00000080 );
93      }
94  
95      public boolean rowHeightAndDefaultFontHeightDoNotMatch() {
96          return 0 != ( this.rowOptions & 0x00000040 );
97      }
98  
99      /**
100      * @param defaults The defaultRowAttributes to set.
101      */
102     public void setDefaultRowAttributes( final CellAttributes defaults ) {
103         this.defaultRowAttributes = defaults;
104     }
105 
106     /**
107      * @param index The indexToXFRecord to set.
108      */
109     public void setIndexToXFRecord( final int index ) {
110         this.indexToXFRecord = index;
111     }
112 
113     /**
114      * @param options The options to set.
115      */
116     public void setOptions( final int options ) {
117         this.rowOptions = options;
118     }
119 
120     /**
121      * @param offset The relativeOffsetToFirstCell to set.
122      */
123     public void setRelativeOffsetToFirstCell( final int offset ) {
124         this.relativeOffsetToFirstCell = offset;
125     }
126 
127     /**
128      * @param height The rowHeight to set.
129      */
130     public void setRowHeight( final int height ) {
131         this.rowHeight = height;
132     }
133 
134 }