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);
            }
        }
        /**
         * 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.");
            }
        }
        /**
         * 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--;
            }

        }
        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 = LF.Utils.NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
Exemple #5
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 = "";
            }
        }