View | Details | Raw Unified | Return to bug 26502
Collapse All | Expand All

(-)java/org/apache/poi/hssf/record/FormulaRecord.java (+14 lines)
Lines 64-69 Link Here
64
import java.util.Stack;
64
import java.util.Stack;
65
65
66
import org.apache.poi.hssf.record.formula.Ptg;
66
import org.apache.poi.hssf.record.formula.Ptg;
67
import org.apache.poi.util.BitField;
67
import org.apache.poi.util.LittleEndian;
68
import org.apache.poi.util.LittleEndian;
68
69
69
/**
70
/**
Lines 90-95 Link Here
90
    private short             field_3_xf;
91
    private short             field_3_xf;
91
    private double            field_4_value;
92
    private double            field_4_value;
92
    private short             field_5_options;
93
    private short             field_5_options;
94
    private BitField          alwaysCalc = new BitField(0x0001);
95
    private BitField          calcOnLoad = new BitField(0x0002);
96
    private BitField          sharedFormula = new BitField(0x0008);
93
    private int               field_6_zero;
97
    private int               field_6_zero;
94
    private short             field_7_expression_len;
98
    private short             field_7_expression_len;
95
    private Stack             field_8_parsed_expr;
99
    private Stack             field_8_parsed_expr;
Lines 271-276 Link Here
271
        return field_5_options;
275
        return field_5_options;
272
    }
276
    }
273
277
278
    public boolean isSharedFormula() {
279
      return sharedFormula.isSet(field_5_options);
280
    }
281
274
    /**
282
    /**
275
     * get the length (in number of tokens) of the expression
283
     * get the length (in number of tokens) of the expression
276
     * @return  expression length
284
     * @return  expression length
Lines 573-578 Link Here
573
              buffer.append("    .value           = ").append(getValue())
581
              buffer.append("    .value           = ").append(getValue())
574
                  .append("\n");
582
                  .append("\n");
575
            buffer.append("    .options         = ").append(getOptions())
583
            buffer.append("    .options         = ").append(getOptions())
584
                .append("\n");
585
            buffer.append("      .alwaysCalc         = ").append(alwaysCalc.isSet(getOptions()))
586
                .append("\n");
587
            buffer.append("      .calcOnLoad         = ").append(calcOnLoad.isSet(getOptions()))
588
                .append("\n");
589
            buffer.append("      .sharedFormula         = ").append(sharedFormula.isSet(getOptions()))
576
                .append("\n");
590
                .append("\n");
577
            buffer.append("    .zero            = ").append(field_6_zero)
591
            buffer.append("    .zero            = ").append(field_6_zero)
578
                .append("\n");
592
                .append("\n");
(-)java/org/apache/poi/hssf/record/SharedFormulaRecord.java (+161 lines)
Lines 56-61 Link Here
56
package org.apache.poi.hssf.record;
56
package org.apache.poi.hssf.record;
57
57
58
import org.apache.poi.util.LittleEndian;
58
import org.apache.poi.util.LittleEndian;
59
import org.apache.poi.hssf.record.formula.*;
60
61
import java.util.Stack;
62
import java.util.List;
59
63
60
/**
64
/**
61
 * Title:        SharedFormulaRecord
65
 * Title:        SharedFormulaRecord
Lines 77-82 Link Here
77
    private byte[] thedata = null;
81
    private byte[] thedata = null;
78
    int             offset  = 0;
82
    int             offset  = 0;
79
83
84
    private int               field_1_first_row;
85
    private int               field_2_last_row;
86
    private short             field_3_first_column;
87
    private short             field_4_last_column;
88
    private int               field_5_reserved;
89
    private short             field_6_expression_len;
90
    private Stack             field_7_parsed_expr;
91
92
80
    public SharedFormulaRecord()
93
    public SharedFormulaRecord()
81
    {
94
    {
82
    }
95
    }
Lines 125-130 Link Here
125
        return retval;
138
        return retval;
126
    }
139
    }
127
140
141
    public int getFirstRow() {
142
      return field_1_first_row;
143
    }
144
145
    public int getLastRow() {
146
      return field_2_last_row;
147
    }
148
149
    public short getFirstColumn() {
150
      return field_3_first_column;
151
    }
152
153
    public short getLastColumn() {
154
      return field_4_last_column;
155
    }
156
157
    public short getExpressionLength()
158
    {
159
        return field_6_expression_len;
160
    }
161
128
162
129
    protected void validateSid(short id)
163
    protected void validateSid(short id)
130
    {
164
    {
Lines 146-151 Link Here
146
        buffer.append("[SHARED FORMULA RECORD:" + Integer.toHexString(sid) + "]\n");
180
        buffer.append("[SHARED FORMULA RECORD:" + Integer.toHexString(sid) + "]\n");
147
        buffer.append("    .id        = ").append(Integer.toHexString(sid))
181
        buffer.append("    .id        = ").append(Integer.toHexString(sid))
148
            .append("\n");
182
            .append("\n");
183
        buffer.append("    .first_row       = ")
184
            .append(Integer.toHexString(getFirstRow())).append("\n");
185
        buffer.append("    .last_row    = ")
186
            .append(Integer.toHexString(getLastRow()))
187
            .append("\n");
188
        buffer.append("    .first_column       = ")
189
            .append(Integer.toHexString(getFirstColumn())).append("\n");
190
        buffer.append("    .last_column    = ")
191
            .append(Integer.toHexString(getLastColumn()))
192
            .append("\n");
193
        buffer.append("    .reserved    = ")
194
            .append(Integer.toHexString(field_5_reserved))
195
            .append("\n");
196
        buffer.append("    .expressionlength= ").append(getExpressionLength())
197
            .append("\n");
198
199
        buffer.append("    .numptgsinarray  = ").append(field_7_parsed_expr.size())
200
              .append("\n");
201
202
        for (int k = 0; k < field_7_parsed_expr.size(); k++ ) {
203
           buffer.append("Formula ")
204
                .append(k)
205
                .append("\n")
206
                .append(field_7_parsed_expr.get(k).toString())
207
                .append("\n");
208
        }
209
149
        buffer.append("[/SHARED FORMULA RECORD]\n");
210
        buffer.append("[/SHARED FORMULA RECORD]\n");
150
        return buffer.toString();
211
        return buffer.toString();
151
    }
212
    }
Lines 160-169 Link Here
160
	  */
221
	  */
161
    protected void fillFields(byte [] data, short size, int offset)
222
    protected void fillFields(byte [] data, short size, int offset)
162
    {
223
    {
224
      //Hold onto the raw data until this record is fully implemented.
163
		thedata = new byte[size];
225
		thedata = new byte[size];
164
		System.arraycopy(data, 0, thedata, 0, size);		
226
		System.arraycopy(data, 0, thedata, 0, size);		
165
227
228
      field_1_first_row       = LittleEndian.getShort(data, 0 + offset);
229
      field_2_last_row        = LittleEndian.getShort(data, 2 + offset);
230
      field_3_first_column    = data[4 + offset];
231
      field_4_last_column     = data[5 + offset];
232
      field_5_reserved        = LittleEndian.getShort(data, 6 + offset);
233
      field_6_expression_len = LittleEndian.getShort(data, 8 + offset);
234
      field_7_parsed_expr    = getParsedExpressionTokens(data, size,
235
                               10 + offset);
236
    }
237
238
    private Stack getParsedExpressionTokens(byte [] data, short size,
239
                                            int offset)
240
    {
241
        Stack stack = new Stack();
242
        int   pos   = offset;
243
244
        while (pos < size)
245
        {
246
            Ptg ptg = Ptg.createPtg(data, pos);
247
            pos += ptg.getSize();
248
            stack.push(ptg);
249
        }
250
        return stack;
251
    }
252
253
    public boolean isFormulaInShared(FormulaRecord formula) {
254
      final int formulaRow = formula.getRow();
255
      final int formulaColumn = formula.getColumn();
256
      return ((getFirstRow() <= formulaRow) && (getLastRow() >= formulaRow) &&
257
          (getFirstColumn() <= formulaColumn) && (getLastColumn() >= formulaColumn));
258
    }
259
260
    /** Creates a non shared formula from the shared formula counter part*/
261
    public void convertSharedFormulaRecord(FormulaRecord formula) {
262
      //Sanity checks
263
      final int formulaRow = formula.getRow();
264
      final int formulaColumn = formula.getColumn();
265
      if (isFormulaInShared(formula)) {
266
        formula.setExpressionLength(getExpressionLength());
267
        List newPtgStack = new Stack();
268
269
        for (int k = 0; k < field_7_parsed_expr.size(); k++) {
270
          Ptg ptg = (Ptg) field_7_parsed_expr.get(k);
271
          if (ptg instanceof RefNPtg) {
272
            RefNPtg refNPtg = (RefNPtg)ptg;
273
            ptg = new ReferencePtg( (short)(formulaRow + refNPtg.getRow()),
274
                                    (byte)(formulaColumn + refNPtg.getColumn()),
275
                                   refNPtg.isRowRelative(),
276
                                   refNPtg.isColRelative());
277
          } else if (ptg instanceof RefNVPtg) {
278
            RefNVPtg refNVPtg = (RefNVPtg)ptg;
279
            ptg = new RefVPtg( (short)(formulaRow + refNVPtg.getRow()),
280
                               (byte)(formulaColumn + refNVPtg.getColumn()),
281
                               refNVPtg.isRowRelative(),
282
                               refNVPtg.isColRelative());
283
          } else if (ptg instanceof RefNAPtg) {
284
            RefNAPtg refNAPtg = (RefNAPtg)ptg;
285
            ptg = new RefAPtg( (short)(formulaRow + refNAPtg.getRow()),
286
                               (byte)(formulaColumn + refNAPtg.getColumn()),
287
                               refNAPtg.isRowRelative(),
288
                               refNAPtg.isColRelative());
289
          } else if (ptg instanceof AreaNPtg) {
290
            AreaNPtg areaNPtg = (AreaNPtg)ptg;
291
            ptg = new AreaPtg((short)(formulaRow + areaNPtg.getFirstRow()),
292
                              (short)(formulaRow + areaNPtg.getLastRow()),
293
                              (short)(formulaColumn + areaNPtg.getFirstColumn()),
294
                              (short)(formulaColumn + areaNPtg.getLastColumn()),
295
                              areaNPtg.isFirstRowRelative(),
296
                              areaNPtg.isLastRowRelative(),
297
                              areaNPtg.isFirstColRelative(),
298
                              areaNPtg.isLastColRelative());
299
          } else if (ptg instanceof AreaNVPtg) {
300
            AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
301
            ptg = new AreaVPtg((short)(formulaRow + areaNVPtg.getFirstRow()),
302
                              (short)(formulaRow + areaNVPtg.getLastRow()),
303
                              (short)(formulaColumn + areaNVPtg.getFirstColumn()),
304
                              (short)(formulaColumn + areaNVPtg.getLastColumn()),
305
                              areaNVPtg.isFirstRowRelative(),
306
                              areaNVPtg.isLastRowRelative(),
307
                              areaNVPtg.isFirstColRelative(),
308
                              areaNVPtg.isLastColRelative());
309
          } else if (ptg instanceof AreaNAPtg) {
310
            AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
311
            ptg = new AreaAPtg((short)(formulaRow + areaNAPtg.getFirstRow()),
312
                              (short)(formulaRow + areaNAPtg.getLastRow()),
313
                              (short)(formulaColumn + areaNAPtg.getFirstColumn()),
314
                              (short)(formulaColumn + areaNAPtg.getLastColumn()),
315
                              areaNAPtg.isFirstRowRelative(),
316
                              areaNAPtg.isLastRowRelative(),
317
                              areaNAPtg.isFirstColRelative(),
318
                              areaNAPtg.isLastColRelative());
319
          }
320
          newPtgStack.add(ptg);
321
        }
322
        formula.setParsedExpression(newPtgStack);
323
      } else {
324
        throw new RuntimeException("Coding Error");
325
      }
166
    }
326
    }
327
167
328
168
	/**
329
	/**
169
	 * Mirroring formula records so it is registered in the ValueRecordsAggregate
330
	 * Mirroring formula records so it is registered in the ValueRecordsAggregate
(-)java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java (-3 / +26 lines)
Lines 184-189 Link Here
184
        int k = 0;
184
        int k = 0;
185
185
186
        FormulaRecordAggregate lastFormulaAggregate = null;
186
        FormulaRecordAggregate lastFormulaAggregate = null;
187
        SharedFormulaRecord lastSharedFormula = null;
187
188
188
        for (k = offset; k < records.size(); k++)
189
        for (k = offset; k < records.size(); k++)
189
        {
190
        {
Lines 195-200 Link Here
195
            }
196
            }
196
            if (rec instanceof FormulaRecord)
197
            if (rec instanceof FormulaRecord)
197
            {
198
            {
199
              FormulaRecord formula = (FormulaRecord)rec;
200
              if (formula.isSharedFormula()) {
201
                if ((lastSharedFormula != null) && (lastSharedFormula.isFormulaInShared(formula))) {
202
                  //Convert this Formula Record from a shared formula to a real formula
203
                  lastSharedFormula.convertSharedFormulaRecord(formula);
204
                } else {
205
                  Record nextRecord = (Record) records.get(k + 1);
206
                  if (nextRecord instanceof SharedFormulaRecord) {
207
                    k++;
208
                    lastSharedFormula = (SharedFormulaRecord) nextRecord;
209
210
                    //Convert this Formula Record from a shared formula to a real formula
211
                    lastSharedFormula.convertSharedFormulaRecord(formula);
212
                  }
213
                  else
214
                    throw new RuntimeException(
215
                        "Shared formula bit set but next record not Shared Formula??");
216
                }
217
              } else {
218
                //JMH TBD next record could also be ARRAY record.
219
              }
220
198
                lastFormulaAggregate = new FormulaRecordAggregate((FormulaRecord)rec, null);
221
                lastFormulaAggregate = new FormulaRecordAggregate((FormulaRecord)rec, null);
199
                insertCell( lastFormulaAggregate );
222
                insertCell( lastFormulaAggregate );
200
            }
223
            }
Lines 202-210 Link Here
202
            {
225
            {
203
                lastFormulaAggregate.setStringRecord((StringRecord)rec);
226
                lastFormulaAggregate.setStringRecord((StringRecord)rec);
204
            } 
227
            } 
205
            else if (rec instanceof SharedFormulaRecord) {
228
//            else if (rec instanceof SharedFormulaRecord) {
206
            	lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
229
//            	lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
207
            }
230
//            }
208
            else if (rec.isValue())
231
            else if (rec.isValue())
209
            {
232
            {
210
                insertCell(( CellValueRecordInterface ) rec);
233
                insertCell(( CellValueRecordInterface ) rec);
(-)java/org/apache/poi/hssf/record/formula/AreaPtg.java (-2 / +18 lines)
Lines 87-96 Link Here
87
    private BitField         colRelative = new BitField(0x4000);
87
    private BitField         colRelative = new BitField(0x4000);
88
    private BitField         column      = new BitField(0x3FFF);
88
    private BitField         column      = new BitField(0x3FFF);
89
89
90
    private AreaPtg() {
90
    protected AreaPtg() {
91
      //Required for clone methods
91
      //Required for clone methods
92
    }
92
    }
93
   
93
   
94
    public AreaPtg(short firstRow, short lastRow, short firstColumn, short lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
95
      setFirstRow(firstRow);
96
      setLastRow(lastRow);
97
      setFirstColumn(firstColumn);
98
      setLastColumn(lastColumn);
99
      setFirstRowRelative(firstRowRelative);
100
      setLastRowRelative(lastRowRelative);
101
      setFirstColRelative(firstColRelative);
102
      setLastColRelative(lastColRelative);
103
    }
104
94
    public AreaPtg(String arearef) {
105
    public AreaPtg(String arearef) {
95
        AreaReference ar = new AreaReference(arearef);
106
        AreaReference ar = new AreaReference(arearef);
96
        setFirstRow((short)ar.getCells()[0].getRow());
107
        setFirstRow((short)ar.getCells()[0].getRow());
Lines 114-124 Link Here
114
        //System.out.println(toString());
125
        //System.out.println(toString());
115
    }
126
    }
116
127
128
    public String getAreaPtgName() {
129
      return "AreaPtg";
130
    }
131
117
    public String toString()
132
    public String toString()
118
    {
133
    {
119
        StringBuffer buffer = new StringBuffer();
134
        StringBuffer buffer = new StringBuffer();
120
135
121
        buffer.append("AreaPtg\n");
136
        buffer.append(getAreaPtgName());
137
        buffer.append("\n");
122
        buffer.append("firstRow = " + getFirstRow()).append("\n");
138
        buffer.append("firstRow = " + getFirstRow()).append("\n");
123
        buffer.append("lastRow  = " + getLastRow()).append("\n");
139
        buffer.append("lastRow  = " + getLastRow()).append("\n");
124
        buffer.append("firstCol = " + getFirstColumn()).append("\n");
140
        buffer.append("firstCol = " + getFirstColumn()).append("\n");
(-)java/org/apache/poi/hssf/record/formula/ExpPtg.java (-5 / +33 lines)
Lines 61-66 Link Here
61
package org.apache.poi.hssf.record.formula;
61
package org.apache.poi.hssf.record.formula;
62
62
63
import org.apache.poi.hssf.model.Workbook;
63
import org.apache.poi.hssf.model.Workbook;
64
import org.apache.poi.util.LittleEndian;
64
65
65
/**
66
/**
66
 *
67
 *
Lines 74-79 Link Here
74
{
75
{
75
    private final static int  SIZE = 5;
76
    private final static int  SIZE = 5;
76
    public final static short sid  = 0x1;
77
    public final static short sid  = 0x1;
78
    private short field_1_row;
79
    private short field_2_col;
77
	 private	byte[] existing = null;
80
	 private	byte[] existing = null;
78
81
79
    /** Creates new ExpPtg */
82
    /** Creates new ExpPtg */
Lines 86-100 Link Here
86
89
87
    public ExpPtg(byte [] array, int offset)
90
    public ExpPtg(byte [] array, int offset)
88
    {
91
    {
89
    	existing = new byte[this.getSize()];
92
      offset++;
90
    	System.arraycopy(array, offset, existing, 0, this.getSize());
93
94
      field_1_row  = LittleEndian.getShort(array, offset + 0 );
95
      field_2_col  = LittleEndian.getShort(array, offset + 2 );
96
//    	existing = new byte[this.getSize()];
97
//    	System.arraycopy(array, offset, existing, 0, this.getSize());
91
    }
98
    }
92
99
93
    public void writeBytes(byte [] array, int offset)
100
    public void writeBytes(byte [] array, int offset)
94
    {
101
    {
95
    	if (existing != null) {
102
//    	if (existing != null) {
96
			System.arraycopy(existing, 0, array, offset, existing.length);
103
//			System.arraycopy(existing, 0, array, offset, existing.length);
97
    	}
104
//    	}
105
      array[offset+0]= (byte) (sid + ptgClass);
106
      LittleEndian.putShort(array, offset+1, field_1_row);
107
      LittleEndian.putShort(array, offset+3, field_2_col);
98
    }
108
    }
99
109
100
    public int getSize()
110
    public int getSize()
Lines 102-112 Link Here
102
        return SIZE;
112
        return SIZE;
103
    }
113
    }
104
114
115
    public short getRow() {
116
      return field_1_row;
117
    }
118
119
    public short getColumn() {
120
      return field_2_col;
121
    }
122
105
    public String toFormulaString(Workbook book)
123
    public String toFormulaString(Workbook book)
106
    {
124
    {
107
        return "NO IDEA SHARED FORMULA EXP PTG";
125
        return "NO IDEA SHARED FORMULA EXP PTG";
108
    }
126
    }
109
    
127
    
128
    public String toString()
129
    {
130
        StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
131
132
        buffer.append("row = ").append(getRow()).append("\n");
133
        buffer.append("col = ").append(getColumn()).append("\n");
134
        return buffer.toString();
135
    }
136
137
110
    public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
138
    public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
111
    
139
    
112
    public Object clone() {
140
    public Object clone() {
(-)java/org/apache/poi/hssf/record/formula/Ptg.java (-12 / +27 lines)
Lines 134-147 Link Here
134
        byte id     = data[ offset + 0 ];
134
        byte id     = data[ offset + 0 ];
135
        Ptg  retval = null;
135
        Ptg  retval = null;
136
136
137
        final byte valueRef = ReferencePtg.sid + 0x20;
138
        final byte arrayRef = ReferencePtg.sid + 0x40;
139
        final byte valueFunc = FuncPtg.sid + 0x20;
137
        final byte valueFunc = FuncPtg.sid + 0x20;
140
        final byte arrayFunc = FuncPtg.sid + 0x40;
138
        final byte arrayFunc = FuncPtg.sid + 0x40;
141
        final byte valueFuncVar = FuncVarPtg.sid +0x20;
139
        final byte valueFuncVar = FuncVarPtg.sid +0x20;
142
        final byte arrayFuncVar = FuncVarPtg.sid+0x40;
140
        final byte arrayFuncVar = FuncVarPtg.sid+0x40;
143
        final byte valueArea = AreaPtg.sid + 0x20;
144
        final byte arrayArea = AreaPtg.sid + 0x40;
145
141
146
        switch (id)
142
        switch (id)
147
        {
143
        {
Lines 204-214 Link Here
204
            case AreaPtg.sid :
200
            case AreaPtg.sid :
205
                retval = new AreaPtg(data, offset);
201
                retval = new AreaPtg(data, offset);
206
                break;
202
                break;
207
            case valueArea:
203
            case AreaAPtg.sid :
208
                retval = new AreaPtg(data, offset);
204
                retval = new AreaAPtg(data, offset);
209
                break;
205
                break;
210
            case arrayArea:
206
            case AreaVPtg.sid :
211
                retval = new AreaPtg(data, offset);
207
                retval = new AreaVPtg(data, offset);
208
                break;
209
            case AreaNAPtg.sid :
210
                retval = new AreaNAPtg(data, offset);
211
                 break;
212
            case AreaNPtg.sid :
213
                retval = new AreaNPtg(data, offset);
214
                break;
215
            case AreaNVPtg.sid :
216
                retval = new AreaNVPtg(data, offset);
212
                break;
217
                break;
213
            case MemErrPtg.sid :        // 0x27       These 3 values 
218
            case MemErrPtg.sid :        // 0x27       These 3 values 
214
            case MemErrPtg.sid+0x20 :   // 0x47       documented in 
219
            case MemErrPtg.sid+0x20 :   // 0x47       documented in 
Lines 223-233 Link Here
223
            case ReferencePtg.sid :
228
            case ReferencePtg.sid :
224
                retval = new ReferencePtg(data, offset);
229
                retval = new ReferencePtg(data, offset);
225
                break;   
230
                break;   
226
            case valueRef :
231
            case RefAPtg.sid :
227
                retval = new ReferencePtg(data, offset);
232
                retval = new RefAPtg(data, offset);
228
                break;   
233
                break;   
229
            case arrayRef :
234
            case RefVPtg.sid :
230
                retval = new ReferencePtg(data, offset);
235
                retval = new RefVPtg(data, offset);
236
                break;
237
238
            case RefNAPtg.sid :
239
                retval = new RefNAPtg(data, offset);
240
                break;
241
            case RefNPtg.sid :
242
                retval = new RefNPtg(data, offset);
243
                break;
244
            case RefNVPtg.sid :
245
                retval = new RefNVPtg(data, offset);
231
                break;   
246
                break;   
232
247
233
            case ParenthesisPtg.sid :
248
            case ParenthesisPtg.sid :
(-)java/org/apache/poi/hssf/record/formula/ReferencePtg.java (-5 / +18 lines)
Lines 81-88 Link Here
81
    private short            field_2_col;
81
    private short            field_2_col;
82
    private BitField         rowRelative = new BitField(0x8000);
82
    private BitField         rowRelative = new BitField(0x8000);
83
    private BitField         colRelative = new BitField(0x4000);
83
    private BitField         colRelative = new BitField(0x4000);
84
    private BitField         column      = new BitField(0x3FFF);
84
85
85
    private ReferencePtg() {
86
    protected ReferencePtg() {
86
      //Required for clone methods
87
      //Required for clone methods
87
    }
88
    }
88
    
89
    
Lines 98-103 Link Here
98
        setRowRelative(!c.isRowAbsolute());
99
        setRowRelative(!c.isRowAbsolute());
99
    }
100
    }
100
101
102
    public ReferencePtg(short row, short column, boolean isRowRelative, boolean isColumnRelative) {
103
      setRow(row);
104
      setColumn(column);
105
      setRowRelative(isRowRelative);
106
      setColRelative(isColumnRelative);
107
    }
108
101
    /** Creates new ValueReferencePtg */
109
    /** Creates new ValueReferencePtg */
102
110
103
    public ReferencePtg(byte[] data, int offset)
111
    public ReferencePtg(byte[] data, int offset)
Lines 105-119 Link Here
105
        offset++;   // adjust for ptg
113
        offset++;   // adjust for ptg
106
        field_1_row = LittleEndian.getShort(data, offset + 0);
114
        field_1_row = LittleEndian.getShort(data, offset + 0);
107
        field_2_col = LittleEndian.getShort(data, offset + 2);
115
        field_2_col = LittleEndian.getShort(data, offset + 2);
116
    }
108
117
118
    public String getRefPtgName() {
119
      return "ReferencePtg";
109
    }
120
    }
110
121
111
    public String toString()
122
    public String toString()
112
    {
123
    {
113
        StringBuffer buffer = new StringBuffer("[ValueReferencePtg]\n");
124
        StringBuffer buffer = new StringBuffer("[");
125
        buffer.append(getRefPtgName());
126
        buffer.append("]\n");
114
127
115
        buffer.append("row = ").append(getRow()).append("\n");
128
        buffer.append("row = ").append(getRow()).append("\n");
116
        buffer.append("col = ").append(getColumnRaw()).append("\n");
129
        buffer.append("col = ").append(getColumn()).append("\n");
117
        buffer.append("rowrelative = ").append(isRowRelative()).append("\n");
130
        buffer.append("rowrelative = ").append(isRowRelative()).append("\n");
118
        buffer.append("colrelative = ").append(isColRelative()).append("\n");
131
        buffer.append("colrelative = ").append(isColRelative()).append("\n");
119
        return buffer.toString();
132
        return buffer.toString();
Lines 166-177 Link Here
166
179
167
    public void setColumn(short col)
180
    public void setColumn(short col)
168
    {
181
    {
169
        field_2_col = col;   // fix this
182
      field_2_col = column.setShortValue(field_2_col, col);
170
    }
183
    }
171
184
172
    public short getColumn()
185
    public short getColumn()
173
    {
186
    {
174
        return rowRelative.setShortBoolean(colRelative.setShortBoolean(field_2_col,false),false);
187
      return column.getShortValue(field_2_col);
175
    }
188
    }
176
189
177
    public int getSize()
190
    public int getSize()

Return to bug 26502