public ExtendedPivotTableViewFieldsRecord(RecordInputStream in1)
        {

            grbit1 = in1.ReadInt();
            grbit2 = in1.ReadUByte();
            citmShow = in1.ReadUByte();
            isxdiSort = in1.ReadUShort();
            isxdiShow = in1.ReadUShort();
            // This record seems to have different valid encodings
		    switch (in1.Remaining) {
			    case 0:
				    // as per "Microsoft Excel Developer's Kit" book
				    // older version of SXVDEX - doesn't seem to have a sub-total name
				    reserved1 = 0;
				    reserved2 = 0;
				    subName = null;
				    return;
			    case 10:
				    // as per "MICROSOFT OFFICE EXCEL 97-2007 BINARY FILE FORMAT SPECIFICATION" pdf
				    break;
			    default:
				    throw new RecordFormatException("Unexpected remaining size (" + in1.Remaining + ")");
		    }
            int cchSubName = in1.ReadUShort();
            reserved1 = in1.ReadInt();
            reserved2 = in1.ReadInt();
            if (cchSubName != STRING_NOT_PRESENT_LEN)
            {
                subName = in1.ReadUnicodeLEString(cchSubName);
            }
        }
示例#2
0
 public OldSheetRecord(RecordInputStream in1)
 {
     field_1_position_of_BOF = in1.ReadInt();
     field_2_visibility = in1.ReadUByte();
     field_3_type = in1.ReadUByte();
     int field_4_sheetname_length = in1.ReadUByte();
     field_5_sheetname = new byte[field_4_sheetname_length];
     in1.Read(field_5_sheetname, 0, field_4_sheetname_length);
 }
示例#3
0
        /**
         * Constructs a WriteAccess record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WriteAccessRecord(RecordInputStream in1)
        {
            if (in1.Remaining > DATA_SIZE)
            {
                throw new RecordFormatException("Expected data size (" + DATA_SIZE + ") but got ("
                                                + in1.Remaining + ")");
            }
            // The string is always 112 characters (padded with spaces), therefore
            // this record can not be continued.

            int nChars      = in1.ReadUShort();
            int is16BitFlag = in1.ReadUByte();

            if (nChars > DATA_SIZE || (is16BitFlag & 0xFE) != 0)
            {
                // String header looks wrong (probably missing)
                // OOO doc says this is optional anyway.
                // reconstruct data
                byte[] data = new byte[3 + in1.Remaining];
                LittleEndian.PutUShort(data, 0, nChars);
                LittleEndian.PutByte(data, 2, is16BitFlag);
                in1.ReadFully(data, 3, data.Length - 3);
                char[] data1 = new char[data.Length];
                for (int i = 0; i < data.Length; i++)
                {
                    data1[i] = (char)data[i];
                }
                String rawValue = new String(data1);
                Username = rawValue.Trim();
                return;
            }

            String rawText;

            if ((is16BitFlag & 0x01) == 0x00)
            {
                rawText = StringUtil.ReadCompressedUnicode(in1, nChars);
            }
            else
            {
                rawText = StringUtil.ReadUnicodeLE(in1, nChars);
            }
            field_1_username = rawText.Trim();

            // consume padding
            int padSize = in1.Remaining;

            while (padSize > 0)
            {
                // in some cases this seems to be garbage (non spaces)
                in1.ReadUByte();
                padSize--;
            }
        }
示例#4
0
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_index       = in1.ReadShort();
            field_3_not_used    = in1.ReadShort();
            int nameLength    = in1.ReadUByte();
            int multibyteFlag = in1.ReadUByte();

            if (multibyteFlag == 0)
            {
                field_4_name = in1.ReadCompressedUnicode(nameLength);
            }
            else
            {
                field_4_name = in1.ReadUnicodeLEString(nameLength);
            }
            if (!HasFormula)
            {
                if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink)
                {
                    // both need to be incremented
                    int nColumns = in1.ReadUByte() + 1;
                    int nRows    = in1.ReadShort() + 1;

                    int totalCount = nRows * nColumns;
                    _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                    _nColumns  = nColumns;
                    _nRows     = nRows;
                }

                if (in1.Remaining > 0)
                {
                    throw ReadFail("Some Unread data (is formula present?)");
                }
                field_5_name_definition = null;
                return;
            }
            int nBytesRemaining = in1.Available();

            if (in1.Remaining <= 0)
            {
                throw ReadFail("Ran out of record data trying to read formula.");
            }
            short formulaLen = in1.ReadShort();

            nBytesRemaining        -= 2;
            field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
示例#5
0
        public OldFormulaRecord(RecordInputStream ris) :
            base(ris, ris.Sid == biff2_sid)
        {
            ;

            if (IsBiff2)
            {
                field_4_value = ris.ReadDouble();
            }
            else
            {
                long valueLongBits = ris.ReadLong();
                specialCachedValue = SpecialCachedValue.Create(valueLongBits);
                if (specialCachedValue == null)
                {
                    field_4_value = BitConverter.Int64BitsToDouble(valueLongBits);
                }
            }

            if (IsBiff2)
            {
                field_5_options = (short)ris.ReadUByte();
            }
            else
            {
                field_5_options = ris.ReadShort();
            }

            int expression_len  = ris.ReadShort();
            int nBytesAvailable = ris.Available();

            field_6_Parsed_expr = Formula.Read(expression_len, ris, nBytesAvailable);
        }
示例#6
0
        public OldFormulaRecord(RecordInputStream ris) :
            base(ris, ris.Sid == biff2_sid)
        {
            ;

            if (IsBiff2)
            {
                field_4_value = ris.ReadDouble();
            }
            else
            {
                long valueLongBits = ris.ReadLong();
                specialCachedValue = SpecialCachedValue.Create(valueLongBits);
                if (specialCachedValue == null)
                {
                    field_4_value = BitConverter.Int64BitsToDouble(valueLongBits);
                }
            }

            if (IsBiff2)
            {
                field_5_options = (short)ris.ReadUByte();
            }
            else
            {
                field_5_options = ris.ReadShort();
            }

            int expression_len = ris.ReadShort();
            int nBytesAvailable = ris.Available();
            field_6_Parsed_expr = Formula.Read(expression_len, ris, nBytesAvailable);
        }
示例#7
0
        /**
         * Constructs a Font record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public FontRecord(RecordInputStream in1)
        {
            field_1_font_height = in1.ReadShort();
            field_2_attributes = in1.ReadShort();
            field_3_color_palette_index = in1.ReadShort();
            field_4_bold_weight = in1.ReadShort();
            field_5_base_sub_script = in1.ReadShort();
            field_6_underline = (byte)in1.ReadByte();
            field_7_family = (byte)in1.ReadByte();
            field_8_charset = (byte)in1.ReadByte();
            field_9_zero = (byte)in1.ReadByte();
            int field_10_font_name_len = (byte)in1.ReadByte();
            int unicodeFlags = in1.ReadUByte(); // options byte present always (even if no character data)

            if (field_10_font_name_len > 0)
            {
                if (unicodeFlags == 0)
                {   // Is compressed Unicode
                    field_11_font_name = in1.ReadCompressedUnicode(field_10_font_name_len);
                }
                else
                {   // Is not compressed Unicode
                    field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len);
                }
            }
            else
            {
                field_11_font_name = "";
            }
        }
示例#8
0
        /**
         * Constructs a BoolErr record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public BoolErrRecord(RecordInputStream in1)
            : base(in1)
        {
            switch (in1.Remaining)
            {
            case 2:
                _value = in1.ReadByte();
                break;

            case 3:
                _value = in1.ReadUShort();
                break;

            default:
                throw new RecordFormatException("Unexpected size ("
                                                + in1.Remaining + ") for BOOLERR record.");
            }
            int flag = in1.ReadUByte();

            switch (flag)
            {
            case 0:
                _isError = false;
                break;

            case 1:
                _isError = true;
                break;

            default:
                throw new RecordFormatException("Unexpected isError flag ("
                                                + flag + ") for BOOLERR record.");
            }
        }
示例#9
0
        /**
         * Constructs a Font record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public FontRecord(RecordInputStream in1)
        {
            field_1_font_height         = in1.ReadShort();
            field_2_attributes          = in1.ReadShort();
            field_3_color_palette_index = in1.ReadShort();
            field_4_bold_weight         = in1.ReadShort();
            field_5_base_sub_script     = in1.ReadShort();
            field_6_underline           = (byte)in1.ReadByte();
            field_7_family  = (byte)in1.ReadByte();
            field_8_charset = (byte)in1.ReadByte();
            field_9_zero    = (byte)in1.ReadByte();
            int field_10_font_name_len = (byte)in1.ReadByte();
            int unicodeFlags           = in1.ReadUByte(); // options byte present always (even if no character data)

            if (field_10_font_name_len > 0)
            {
                if (unicodeFlags == 0)
                {   // Is compressed Unicode
                    field_11_font_name = in1.ReadCompressedUnicode(field_10_font_name_len);
                }
                else
                {   // Is not compressed Unicode
                    field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len);
                }
            }
            else
            {
                field_11_font_name = "";
            }
        }
示例#10
0
        /**
         * Constructs a BoolErr record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public BoolErrRecord(RecordInputStream in1)
            : base(in1)
        {
            switch (in1.Remaining)
            {
                case 2:
                    _value = in1.ReadByte();
                    break;
                case 3:
                    _value = in1.ReadUShort();
                    break;
                default:
                    throw new RecordFormatException("Unexpected size ("
                            + in1.Remaining + ") for BOOLERR record.");
            }
            int flag = in1.ReadUByte();
            switch (flag)
            {
                case 0:
                    _isError = false;
                    break;
                case 1:
                    _isError = true;
                    break;
                default:
                    throw new RecordFormatException("Unexpected isError flag ("
                            + flag + ") for BOOLERR record.");
            }
        }
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_index = in1.ReadShort();
            field_3_not_used = in1.ReadShort();
            int nameLength = in1.ReadUByte();
            int multibyteFlag = in1.ReadUByte();
            if (multibyteFlag == 0)
            {
                field_4_name = in1.ReadCompressedUnicode(nameLength);
            }
            else
            {
                field_4_name = in1.ReadUnicodeLEString(nameLength);
            }            
            if (!HasFormula)
            {
                if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink)
                {
                    // both need to be incremented
                    int nColumns = in1.ReadUByte() + 1;
                    int nRows = in1.ReadShort() + 1;

                    int totalCount = nRows * nColumns;
                    _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                    _nColumns = nColumns;
                    _nRows = nRows;
                }

                if (in1.Remaining > 0)
                {
                    throw ReadFail("Some Unread data (is formula present?)");
                }
                field_5_name_definition = null;
                return;
            }
            int nBytesRemaining = in1.Available();
            if (in1.Remaining <= 0)
            {
                throw ReadFail("Ran out of record data trying to read formula.");
            }
            short formulaLen = in1.ReadShort();
            nBytesRemaining -= 2;
            field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
示例#12
0
        /**
         * Constructs a Name record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */
        public NameRecord(RecordInputStream in1)
        {
            field_1_option_flag       = in1.ReadShort();
            field_2_keyboard_shortcut = (byte)in1.ReadByte();
            int field_3_length_name_text       = in1.ReadByte();
            int field_4_length_name_definition = in1.ReadShort();

            field_5_externSheetIndex_plus1 = in1.ReadShort();
            field_6_sheetNumber            = in1.ReadUShort();
            int field_7_length_custom_menu      = in1.ReadUByte();
            int field_8_length_description_text = in1.ReadUByte();
            int field_9_length_help_topic_text  = in1.ReadUByte();
            int field_10_length_status_bar_text = in1.ReadUByte();

            //store the name in byte form if it's a built-in name
            field_11_nameIsMultibyte = (in1.ReadByte() != 0);
            if (IsBuiltInName)
            {
                field_12_built_in_code = (byte)in1.ReadByte();
            }
            else
            {
                if (field_11_nameIsMultibyte)
                {
                    field_12_name_text = in1.ReadUnicodeLEString(field_3_length_name_text);
                }
                else
                {
                    field_12_name_text = in1.ReadCompressedUnicode(field_3_length_name_text);
                }
            }
            int nBytesAvailable = in1.Available() - (field_7_length_custom_menu
                                                     + field_8_length_description_text + field_9_length_help_topic_text + field_10_length_status_bar_text);

            field_13_name_definition = SSFormula.Formula.Read(field_4_length_name_definition, in1, nBytesAvailable);

            //Who says that this can only ever be compressed unicode???
            field_14_custom_menu_text = in1.ReadCompressedUnicode(field_7_length_custom_menu);
            field_15_description_text = in1.ReadCompressedUnicode(field_8_length_description_text);
            field_16_help_topic_text  = in1.ReadCompressedUnicode(field_9_length_help_topic_text);
            field_17_status_bar_text  = in1.ReadCompressedUnicode(field_10_length_status_bar_text);
        }
示例#13
0
        /**
         * Constructs a WriteAccess record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WriteAccessRecord(RecordInputStream in1)
        {
            if (in1.Remaining > DATA_SIZE)
            {
                throw new RecordFormatException("Expected data size (" + DATA_SIZE + ") but got ("
                        + in1.Remaining + ")");
            }
            // The string is always 112 characters (padded with spaces), therefore
            // this record can not be continued.

            int nChars = in1.ReadUShort();
            int is16BitFlag = in1.ReadUByte();
            if (nChars > DATA_SIZE || (is16BitFlag & 0xFE) != 0)
            {
                // String header looks wrong (probably missing)
                // OOO doc says this is optional anyway.
                // reconstruct data
                byte[] data = new byte[3 + in1.Remaining];
                LittleEndian.PutUShort(data, 0, nChars);
                LittleEndian.PutByte(data, 2, is16BitFlag);
                in1.ReadFully(data, 3, data.Length - 3);
                char[] data1=new char[data.Length];
                for (int i = 0; i < data.Length; i++)
                {
                    data1[i] = (char)data[i];
                }
                String rawValue = new String(data1);
                Username = rawValue.Trim();
                return;
            }

            String rawText;
            if ((is16BitFlag & 0x01) == 0x00)
            {
                rawText = StringUtil.ReadCompressedUnicode(in1, nChars);
            }
            else
            {
                rawText = StringUtil.ReadUnicodeLE(in1, nChars);
            }
            field_1_username = rawText.Trim();

            // consume padding
            int padSize = in1.Remaining;
            while (padSize > 0)
            {
                // in some cases this seems to be garbage (non spaces)
                in1.ReadUByte();
                padSize--;
            }

        }
示例#14
0
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_ixals       = in1.ReadShort();
            field_3_not_used    = in1.ReadShort();
            int numChars = in1.ReadUByte();

            field_4_name = StringUtil.ReadUnicodeString(in1, numChars);

            // the record body can take different forms.
            // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
            if (!IsOLELink && !IsStdDocumentNameIdentifier)
            {
                // another switch: the fWantAdvise bit specifies whether the body describes
                // an external defined name or a DDE data item
                if (IsAutomaticLink)
                {
                    if (in1.Available() > 0)
                    {
                        //body specifies DDE data item
                        int nColumns = in1.ReadUByte() + 1;
                        int nRows    = in1.ReadShort() + 1;

                        int totalCount = nRows * nColumns;
                        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                        _nColumns  = nColumns;
                        _nRows     = nRows;
                    }
                }
                else
                {
                    //body specifies an external defined name
                    int formulaLen = in1.ReadUShort();
                    field_5_name_definition = Formula.Read(formulaLen, in1);
                }
            }
        }
示例#15
0
        /** Create a StringPtg from a stream */
        public StringPtg(RecordInputStream in1)
        {
            field_1_Length = in1.ReadUByte();
            field_2_options = (byte)in1.ReadByte();
            if (fHighByte.IsSet(field_2_options))
            {
                field_3_string = in1.ReadUnicodeLEString(field_1_Length);
            }
            else
            {
                field_3_string = in1.ReadCompressedUnicode(field_1_Length);
            }

            // SetValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2]));
        }
示例#16
0
        /**
         * Constructs a BoundSheetRecord and Sets its fields appropriately
         *
         * @param in the RecordInputstream to Read the record from
         */
        public BoundSheetRecord(RecordInputStream in1)
        {
            field_1_position_of_BOF = in1.ReadInt();	// bof
            field_2_option_flags = in1.ReadShort();	// flags
            int field_3_sheetname_length = in1.ReadUByte();						// len(str)
            field_4_isMultibyteUnicode = (byte)in1.ReadByte();						// Unicode

            if (this.IsMultibyte)
            {
                field_5_sheetname = in1.ReadUnicodeLEString(field_3_sheetname_length);
            }
            else
            {
                field_5_sheetname = in1.ReadCompressedUnicode(field_3_sheetname_length);
            }
        }
示例#17
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldStringRecord(RecordInputStream in1)
        {
            sid = in1.Sid;

            if (in1.Sid == biff2_sid)
            {
                field_1_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_1_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_2_bytes = new byte[field_1_string_len];
            in1.Read(field_2_bytes, 0, field_1_string_len);
        }
示例#18
0
        private short field_3_xf_index;   // Biff 3+

        protected OldCellRecord(RecordInputStream in1, bool isBiff2)
        {
            this.sid = in1.Sid;
            this.isBiff2 = isBiff2;
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadShort();

            if (isBiff2)
            {
                field_3_cell_attrs = in1.ReadUShort() << 8;
                field_3_cell_attrs += in1.ReadUByte();
            }
            else
            {
                field_3_xf_index = in1.ReadShort();
            }
        }
示例#19
0
        private short field_3_xf_index; // Biff 3+

        protected OldCellRecord(RecordInputStream in1, bool isBiff2)
        {
            this.sid       = in1.Sid;
            this.isBiff2   = isBiff2;
            field_1_row    = in1.ReadUShort();
            field_2_column = in1.ReadShort();

            if (isBiff2)
            {
                field_3_cell_attrs  = in1.ReadUShort() << 8;
                field_3_cell_attrs += in1.ReadUByte();
            }
            else
            {
                field_3_xf_index = in1.ReadShort();
            }
        }
示例#20
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldStringRecord(RecordInputStream in1)
        {
            sid = in1.Sid;

            if (in1.Sid == biff2_sid)
            {
                field_1_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_1_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_2_bytes = new byte[field_1_string_len];
            in1.Read(field_2_bytes, 0, field_1_string_len);
        }
示例#21
0
        /**
         * Constructs a BoundSheetRecord and Sets its fields appropriately
         *
         * @param in the RecordInputstream to Read the record from
         */

        public BoundSheetRecord(RecordInputStream in1)
        {
            field_1_position_of_BOF = in1.ReadInt();           // bof
            field_2_option_flags    = in1.ReadShort();         // flags
            int field_3_sheetname_length = in1.ReadUByte();    // len(str)

            field_4_isMultibyteUnicode = (byte)in1.ReadByte(); // Unicode


            if (this.IsMultibyte)
            {
                field_5_sheetname = in1.ReadUnicodeLEString(field_3_sheetname_length);
            }
            else
            {
                field_5_sheetname = in1.ReadCompressedUnicode(field_3_sheetname_length);
            }
        }
示例#22
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldLabelRecord(RecordInputStream in1)
            : base(in1, in1.Sid == biff2_sid)
        {
            if (IsBiff2)
            {
                field_4_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_4_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_5_bytes = new byte[field_4_string_len];
            in1.Read(field_5_bytes, 0, field_4_string_len);

            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO,
                           "LabelRecord data remains: " + in1.Remaining +
                           " : " + HexDump.ToHex(in1.ReadRemainder())
                           );
            }
        }
示例#23
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldLabelRecord(RecordInputStream in1)
            : base(in1, in1.Sid == biff2_sid)
        {
            if (IsBiff2)
            {
                field_4_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_4_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_5_bytes = new byte[field_4_string_len];
            in1.Read(field_5_bytes, 0, field_4_string_len);

            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO,
                        "LabelRecord data remains: " + in1.Remaining +
                        " : " + HexDump.ToHex(in1.ReadRemainder())
                        );
            }
        }
示例#24
0
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_ixals = in1.ReadShort();
            field_3_not_used = in1.ReadShort();
            int numChars = in1.ReadUByte();
            field_4_name = StringUtil.ReadUnicodeString(in1, numChars);

            // the record body can take different forms.
            // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
            if (!IsOLELink && !IsStdDocumentNameIdentifier)
            {
                // another switch: the fWantAdvise bit specifies whether the body describes
                // an external defined name or a DDE data item
                if (IsAutomaticLink)
                {
                    if (in1.Available() > 0)
                    {
                        //body specifies DDE data item
                        int nColumns = in1.ReadUByte() + 1;
                        int nRows = in1.ReadShort() + 1;

                        int totalCount = nRows * nColumns;
                        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                        _nColumns = nColumns;
                        _nRows = nRows;
                    }
                }
                else
                {
                    //body specifies an external defined name
                    int formulaLen = in1.ReadUShort();
                    field_5_name_definition = Formula.Read(formulaLen, in1);
                }
            }
        }
        public CellRangeAddress8Bit(RecordInputStream in1)
            : base(ReadUShortAndCheck(in1), in1.ReadUShort(), in1.ReadUByte(), in1.ReadUByte())
        {

        }
示例#26
0
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_ixals = in1.ReadShort();
            field_3_not_used = in1.ReadShort();
            int numChars = in1.ReadUByte();
            field_4_name = StringUtil.ReadUnicodeString(in1, numChars);

            // the record body can take different forms.
            // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
            if (!IsOLELink && !IsStdDocumentNameIdentifier)
            {
                // another switch: the fWantAdvise bit specifies whether the body describes
                // an external defined name or a DDE data item
                if (IsAutomaticLink)
                {
                    if (in1.Available() > 0)
                    {
                        //body specifies DDE data item
                        int nColumns = in1.ReadUByte() + 1;
                        int nRows = in1.ReadShort() + 1;

                        int totalCount = nRows * nColumns;
                        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                        _nColumns = nColumns;
                        _nRows = nRows;
                    }
                }
                else
                {
                    //body specifies an external defined name
                    int formulaLen = in1.ReadUShort();
                    field_5_name_definition = Formula.Read(formulaLen, in1);
                }
            }
            //int nameLength = in1.ReadUByte();
            //int multibyteFlag = in1.ReadUByte();
            //if (multibyteFlag == 0)
            //{
            //    field_4_name = in1.ReadCompressedUnicode(nameLength);
            //}
            //else
            //{
            //    field_4_name = in1.ReadUnicodeLEString(nameLength);
            //}
            //if (!HasFormula)
            //{
            //    if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink)
            //    {
            //        // both need to be incremented
            //        int nColumns = in1.ReadUByte() + 1;
            //        int nRows = in1.ReadShort() + 1;

            //        int totalCount = nRows * nColumns;
            //        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
            //        _nColumns = nColumns;
            //        _nRows = nRows;
            //    }

            //    if (in1.Remaining > 0)
            //    {
            //        throw ReadFail("Some Unread data (is formula present?)");
            //    }
            //    field_5_name_definition = null;
            //    return;
            //}
            //int nBytesRemaining = in1.Available();
            //if (in1.Remaining <= 0)
            //{
            //    throw ReadFail("Ran out of record data trying to read formula.");
            //}
            //short formulaLen = in1.ReadShort();
            //nBytesRemaining -= 2;
            //field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
示例#27
0
        /**
         * Constructs a Name record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */
        public NameRecord(RecordInputStream in1)
        {
            field_1_option_flag                 = in1.ReadShort();
		    field_2_keyboard_shortcut           = (byte)in1.ReadByte();
		    int field_3_length_name_text        = in1.ReadByte();
		    int field_4_length_name_definition  = in1.ReadShort();
		    field_5_externSheetIndex_plus1      = in1.ReadShort();
		    field_6_sheetNumber                 = in1.ReadUShort();
		    int field_7_length_custom_menu      = in1.ReadUByte();
		    int field_8_length_description_text = in1.ReadUByte();
		    int field_9_length_help_topic_text  = in1.ReadUByte();
		    int field_10_length_status_bar_text = in1.ReadUByte();

		    //store the name in byte form if it's a built-in name
		    field_11_nameIsMultibyte = (in1.ReadByte() != 0);
		    if (IsBuiltInName) {
			    field_12_built_in_code = (byte)in1.ReadByte();
		    } else {
			    if (field_11_nameIsMultibyte) {
				    field_12_name_text = in1.ReadUnicodeLEString(field_3_length_name_text);
			    } else {
				    field_12_name_text = in1.ReadCompressedUnicode(field_3_length_name_text);
			    }
		    }
          int nBytesAvailable = in1.Available() - (field_7_length_custom_menu
				+ field_8_length_description_text + field_9_length_help_topic_text + field_10_length_status_bar_text);
		    field_13_name_definition = SSFormula.Formula.Read(field_4_length_name_definition, in1, nBytesAvailable);

		    //Who says that this can only ever be compressed unicode???
		    field_14_custom_menu_text = in1.ReadCompressedUnicode(field_7_length_custom_menu);
		    field_15_description_text = in1.ReadCompressedUnicode(field_8_length_description_text);
		    field_16_help_topic_text  = in1.ReadCompressedUnicode(field_9_length_help_topic_text);
		    field_17_status_bar_text  = in1.ReadCompressedUnicode(field_10_length_status_bar_text);

        }
示例#28
0
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_ixals       = in1.ReadShort();
            field_3_not_used    = in1.ReadShort();
            int numChars = in1.ReadUByte();

            field_4_name = StringUtil.ReadUnicodeString(in1, numChars);

            // the record body can take different forms.
            // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
            if (!IsOLELink && !IsStdDocumentNameIdentifier)
            {
                // another switch: the fWantAdvise bit specifies whether the body describes
                // an external defined name or a DDE data item
                if (IsAutomaticLink)
                {
                    if (in1.Available() > 0)
                    {
                        //body specifies DDE data item
                        int nColumns = in1.ReadUByte() + 1;
                        int nRows    = in1.ReadShort() + 1;

                        int totalCount = nRows * nColumns;
                        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                        _nColumns  = nColumns;
                        _nRows     = nRows;
                    }
                }
                else
                {
                    //body specifies an external defined name
                    int formulaLen = in1.ReadUShort();
                    field_5_name_definition = Formula.Read(formulaLen, in1);
                }
            }
            //int nameLength = in1.ReadUByte();
            //int multibyteFlag = in1.ReadUByte();
            //if (multibyteFlag == 0)
            //{
            //    field_4_name = in1.ReadCompressedUnicode(nameLength);
            //}
            //else
            //{
            //    field_4_name = in1.ReadUnicodeLEString(nameLength);
            //}
            //if (!HasFormula)
            //{
            //    if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink)
            //    {
            //        // both need to be incremented
            //        int nColumns = in1.ReadUByte() + 1;
            //        int nRows = in1.ReadShort() + 1;

            //        int totalCount = nRows * nColumns;
            //        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
            //        _nColumns = nColumns;
            //        _nRows = nRows;
            //    }

            //    if (in1.Remaining > 0)
            //    {
            //        throw ReadFail("Some Unread data (is formula present?)");
            //    }
            //    field_5_name_definition = null;
            //    return;
            //}
            //int nBytesRemaining = in1.Available();
            //if (in1.Remaining <= 0)
            //{
            //    throw ReadFail("Ran out of record data trying to read formula.");
            //}
            //short formulaLen = in1.ReadShort();
            //nBytesRemaining -= 2;
            //field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
示例#29
0
        /**
         * Read Constructor.
         *
         * @param inStream RecordInputStream containing a DConRefRecord structure.
         */
        public DConRefRecord(RecordInputStream inStream)
        {
            if (inStream.Sid != sid)
                throw new RecordFormatException("Wrong sid: " + inStream.Sid);

            firstRow = inStream.ReadUShort();
            lastRow = inStream.ReadUShort();
            firstCol = inStream.ReadUByte();
            lastCol = inStream.ReadUByte();

            charCount = inStream.ReadUShort();
            charType = inStream.ReadUByte() & 0x01; //first bit only.

            // byteLength depends on whether we are using single- or double-byte chars.
            int byteLength = charCount * (charType + 1);

            path = new byte[byteLength];
            inStream.ReadFully(path);

            if (path[0] == 0x02)
                _unused = inStream.ReadRemainder();

        }
示例#30
0
        /** 
         * Read in the actual token (array) values. This occurs 
         * AFTER the last Ptg in the expression.
         * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf
         */
        public void ReadTokenValues(RecordInputStream in1)
        {
            short nColumns = (short)in1.ReadUByte();
            short nRows = in1.ReadShort();
            //The token_1_columns and token_2_rows do not follow the documentation.
            //The number of physical rows and columns Is actually +1 of these values.
            //Which Is not explicitly documented.
            nColumns++;
            nRows++;

            token_1_columns = nColumns;
            token_2_rows = nRows;

            int totalCount = nRows * nColumns;
            token_3_arrayValues = ConstantValueParser.Parse(in1, totalCount);
        }