Line 55
Link Here
|
55 |
package org.apache.poi.hssf.record; |
55 |
package org.apache.poi.hssf.record; |
|
|
56 |
|
56 |
import java.util.List; |
57 |
import java.util.List; |
57 |
import java.util.Stack; |
58 |
import java.util.Stack; |
58 |
|
59 |
import org.apache.poi.hssf.model.Workbook; |
59 |
import org.apache.poi.hssf.record.formula.Area3DPtg; |
60 |
import org.apache.poi.hssf.record.formula.Area3DPtg; |
60 |
import org.apache.poi.hssf.record.formula.Ptg; |
61 |
import org.apache.poi.hssf.record.formula.Ptg; |
61 |
import org.apache.poi.hssf.record.formula.Ref3DPtg; |
62 |
import org.apache.poi.hssf.record.formula.Ref3DPtg; |
62 |
import org.apache.poi.hssf.util.RangeAddress; |
63 |
import org.apache.poi.hssf.util.RangeAddress; |
63 |
import org.apache.poi.hssf.util.SheetReferences; |
|
|
64 |
import org.apache.poi.util.HexDump; |
64 |
import org.apache.poi.util.HexDump; |
65 |
import org.apache.poi.util.LittleEndian; |
65 |
import org.apache.poi.util.LittleEndian; |
66 |
import org.apache.poi.util.StringUtil; |
66 |
import org.apache.poi.util.StringUtil; |
67 |
/** |
67 |
/** |
68 |
* Title: Name Record (aka Named Range) <P> |
68 |
* @Title Name Record (aka Named Range) |
69 |
* Description: Defines a named range within a workbook. <P> |
69 |
* @Description Defines a named range within a workbook. |
70 |
* REFERENCE: <P> |
70 |
* @REFERENCE |
71 |
* @author Libin Roman (Vista Portal LDT. Developer) |
71 |
* @author Libin Roman (Vista Portal LDT. Developer) |
72 |
* @author Sergei Kozello (sergeikozello at mail.ru) |
72 |
* @author Sergei Kozello (sergeikozello at mail.ru) |
73 |
* @author Glen Stampoultzis (glens at apache.org) |
73 |
* @author Glen Stampoultzis (glens at apache.org) |
Lines 127-128
Link Here
|
127 |
*/ |
127 |
*/ |
128 |
public final static byte BUILTIN_SHEET_TITLE = (byte)12; |
128 |
public final static byte BUILTIN_SHEET_TITLE = (byte)12; |
|
|
129 |
public static final short OPT_HIDDEN_NAME = (short) 0x0001; |
130 |
public static final short OPT_FUNCTION_NAME = (short) 0x0002; |
131 |
public static final short OPT_COMMAND_NAME = (short) 0x0004; |
132 |
public static final short OPT_MACRO = (short) 0x0008; |
133 |
public static final short OPT_COMPLEX = (short) 0x0010; |
134 |
public static final short OPT_BUILTIN = (short) 0x0020; |
135 |
public static final short OPT_BINDATA = (short) 0x1000; |
136 |
|
129 |
private short field_1_option_flag; |
137 |
private short field_1_option_flag; |
130 |
private byte field_2_keyboard_shortcut; |
138 |
private byte field_2_keyboard_shortcut; |
Lines 192-197
Link Here
|
192 |
{ |
200 |
{ |
193 |
this(); |
201 |
this(); |
194 |
this.field_12_builtIn_name = builtin; |
202 |
this.field_12_builtIn_name = builtin; |
195 |
this.setOptionFlag((short)(this.getOptionFlag() | (short)0x20)); |
203 |
this.setOptionFlag((short)(this.getOptionFlag() | OPT_BUILTIN)); |
196 |
this.setNameTextLength((byte)1); |
204 |
this.setNameTextLength((byte)1); |
197 |
this.setEqualsToIndexToSheet(index); //the extern sheets are set through references |
205 |
this.setEqualsToIndexToSheet(index); //the extern sheets are set through references |
Line 252
Link Here
|
252 |
/** |
260 |
/** |
253 |
* Convenience method to retrieve the index the name refers to. |
261 |
* Convenience method to retrieve the index the name refers to. |
254 |
* @see getEqualsToIndexToSheet() |
262 |
* @see #getEqualsToIndexToSheet() |
255 |
* @return short |
263 |
* @return short |
256 |
*/ |
264 |
*/ |
257 |
public short getIndexToSheet() { |
265 |
public short getIndexToSheet() { |
Lines 346-347
Link Here
|
346 |
return field_1_option_flag; |
354 |
return field_1_option_flag; |
347 |
} |
355 |
} |
|
|
356 |
/** |
357 |
* @return function group |
358 |
* @see FnGroupCountRecord |
359 |
*/ |
360 |
public byte getFnGroup() { |
361 |
int masked = field_1_option_flag & 0x0fc0; |
362 |
return (byte) (masked >> 4); |
363 |
} |
364 |
|
348 |
/** returns the keyboard shortcut |
365 |
/** returns the keyboard shortcut |
349 |
* @return keyboard shortcut |
366 |
* @return keyboard shortcut |
350 |
*/ |
367 |
*/ |
Lines 409-410
Link Here
|
409 |
return field_11_compressed_unicode_flag; |
426 |
return field_11_compressed_unicode_flag; |
410 |
} |
427 |
} |
|
|
428 |
/** |
429 |
* @return true if name is hidden |
430 |
*/ |
431 |
public boolean isHiddenName() { |
432 |
return (field_1_option_flag & OPT_HIDDEN_NAME) != 0; |
433 |
} |
434 |
|
435 |
/** |
436 |
* @return true if name is a function |
437 |
*/ |
438 |
public boolean isFunctionName() { |
439 |
return (field_1_option_flag & OPT_FUNCTION_NAME) != 0; |
440 |
} |
441 |
|
442 |
/** |
443 |
* @return true if name is a command |
444 |
*/ |
445 |
public boolean isCommandName() { |
446 |
return (field_1_option_flag & OPT_COMMAND_NAME) != 0; |
447 |
} |
448 |
|
449 |
/** |
450 |
* @return true if function macro or command macro |
451 |
*/ |
452 |
public boolean isMacro() { |
453 |
return (field_1_option_flag & OPT_MACRO) != 0; |
454 |
} |
455 |
|
456 |
/** |
457 |
* @return true if array formula or user defined |
458 |
*/ |
459 |
public boolean isComplexFunction() { |
460 |
return (field_1_option_flag & OPT_COMPLEX) != 0; |
461 |
} |
462 |
|
463 |
|
411 |
/**Convenience Function to determine if the name is a built-in name |
464 |
/**Convenience Function to determine if the name is a built-in name |
412 |
*/ |
465 |
*/ |
413 |
public boolean isBuiltInName() |
466 |
public boolean isBuiltInName() |
414 |
{ |
467 |
{ |
415 |
return ((this.getOptionFlag() & (short)0x20) != 0); |
468 |
return ((this.getOptionFlag() & OPT_BUILTIN) != 0); |
416 |
} |
469 |
} |
|
|
470 |
|
417 |
/** gets the name |
471 |
/** gets the name |
418 |
* @return name |
472 |
* @return name |
419 |
*/ |
473 |
*/ |
Line 511
Link Here
|
511 |
data[18 + offset] = getCompressedUnicodeFlag(); |
565 |
data[18 + offset] = getCompressedUnicodeFlag(); |
512 |
/* temp: gjs |
566 |
/* temp: gjs |
513 |
if ( ( field_1_option_flag & (short) 0x20 ) != 0 ) |
567 |
if (isBuiltInName()) |
514 |
{ |
568 |
{ |
515 |
LittleEndian.putShort( data, 2 + offset, (short) ( 16 + field_13_raw_name_definition.length ) ); |
569 |
LittleEndian.putShort( data, 2 + offset, (short) ( 16 + field_13_raw_name_definition.length ) ); |
Lines 647-653
Link Here
|
647 |
/** gets the reference , the area only (range) |
701 |
/** gets the reference , the area only (range) |
648 |
* @return area reference |
702 |
* @return area reference |
649 |
*/ |
703 |
*/ |
650 |
public String getAreaReference(SheetReferences refs){ |
704 |
public String getAreaReference(Workbook book){ |
651 |
if (field_13_name_definition == null) return "#REF!"; |
705 |
if (field_13_name_definition == null) return "#REF!"; |
652 |
Ptg ptg = (Ptg) field_13_name_definition.peek(); |
706 |
Ptg ptg = (Ptg) field_13_name_definition.peek(); |
653 |
String result = ""; |
707 |
String result = ""; |
654 |
if (ptg.getClass() == Area3DPtg.class){ |
708 |
if (ptg.getClass() == Area3DPtg.class){ |
655 |
result = ptg.toFormulaString(refs); |
709 |
result = ptg.toFormulaString(book); |
656 |
} else if (ptg.getClass() == Ref3DPtg.class){ |
710 |
} else if (ptg.getClass() == Ref3DPtg.class){ |
657 |
result = ptg.toFormulaString(refs); |
711 |
result = ptg.toFormulaString(book); |
658 |
} |
712 |
} |
659 |
return result; |
713 |
return result; |
Line 727
Link Here
|
727 |
/* |
781 |
/* |
728 |
temp: gjs |
782 |
temp: gjs |
729 |
if ( ( field_1_option_flag & (short)0x20 ) != 0 ) { |
783 |
if (isBuiltInName()) { |
730 |
// DEBUG |
784 |
// DEBUG |
731 |
// System.out.println( "Built-in name" ); |
785 |
// System.out.println( "Built-in name" ); |