Exemple #1
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--;
            }
        }
Exemple #2
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.");
            }
        }
Exemple #3
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);
        }
Exemple #4
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 = "";
            }
        }
Exemple #5
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);
                }
            }
        }
Exemple #6
0
        private short field_3_xf_index; // Biff 3+

        protected OldCellRecord(RecordInputStream in1, bool isBiff2)
        {
            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();
            }
        }
Exemple #7
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);
        }
        /**
         * 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 (IsMultibyte)
            {
                field_5_sheetname = in1.ReadUnicodeLEString(field_3_sheetname_length);
            }
            else
            {
                field_5_sheetname = in1.ReadCompressedUnicode(field_3_sheetname_length);
            }
        }
Exemple #9
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())
                           );
            }
        }