Beispiel #1
0
        /**
         * Constructs a DV record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public DVRecord(RecordInputStream in1)
        {
            _option_flags = in1.ReadInt();

            _promptTitle = ReadUnicodeString(in1);
            _errorTitle  = ReadUnicodeString(in1);
            _promptText  = ReadUnicodeString(in1);
            _errorText   = ReadUnicodeString(in1);

            int field_size_first_formula = in1.ReadUShort();

            _not_used_1 = in1.ReadShort();

            //read first formula data condition
            _formula1 = NPOI.SS.Formula.Formula.Read(field_size_first_formula, in1);

            int field_size_sec_formula = in1.ReadUShort();

            _not_used_2 = in1.ReadShort();

            //read sec formula data condition
            _formula2 = NPOI.SS.Formula.Formula.Read(field_size_sec_formula, in1);

            //read cell range address list with all affected ranges
            _regions = new CellRangeAddressList(in1);
        }
Beispiel #2
0
        /**
         * Constructs an Label record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public LabelRecord(RecordInputStream in1)
        {
            field_1_row          = in1.ReadUShort();
            field_2_column       = in1.ReadUShort();
            field_3_xf_index     = in1.ReadShort();
            field_4_string_len   = in1.ReadShort();
            field_5_unicode_flag = (byte)in1.ReadByte();
            if (field_4_string_len > 0)
            {
                if (IsUncompressedUnicode)
                {
                    field_6_value = in1.ReadUnicodeLEString(field_4_string_len);
                }
                else
                {
                    field_6_value = in1.ReadCompressedUnicode(field_4_string_len);
                }
            }
            else
            {
                field_6_value = "";
            }
            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO, "LabelRecord data remains: " + in1.Remaining +
                           " : " + HexDump.ToHex(in1.ReadRemainder()));
            }
        }
Beispiel #3
0
            public void Read(RecordInputStream in1)
            {
                _encryptionInfo = in1.ReadUShort();
                switch (_encryptionInfo)
                {
                case ENCRYPTION_OTHER_RC4:
                    // handled below
                    break;

                case ENCRYPTION_OTHER_CAPI_2:
                case ENCRYPTION_OTHER_CAPI_3:
                case ENCRYPTION_OTHER_CAPI_4:
                    throw new EncryptedDocumentException(
                              "HSSF does not currently support CryptoAPI encryption");

                default:
                    throw new RecordFormatException("Unknown encryption info " + _encryptionInfo);
                }
                _minorVersionNo = in1.ReadUShort();
                if (_minorVersionNo != 1)
                {
                    throw new RecordFormatException("Unexpected VersionInfo number for RC4Header " + _minorVersionNo);
                }
                _salt = FilePassRecord.Read(in1, 16);
                _encryptedVerifier     = FilePassRecord.Read(in1, 16);
                _encryptedVerifierHash = FilePassRecord.Read(in1, 16);
            }
Beispiel #4
0
        public CFRuleRecord(RecordInputStream in1)
        {
            field_1_condition_type      = (byte)in1.ReadByte();
            field_2_comparison_operator = (byte)in1.ReadByte();
            int field_3_formula1_len = in1.ReadUShort();
            int field_4_formula2_len = in1.ReadUShort();

            field_5_options  = in1.ReadInt();
            field_6_not_used = in1.ReadShort();

            if (ContainsFontFormattingBlock)
            {
                fontFormatting = new FontFormatting(in1);
            }

            if (ContainsBorderFormattingBlock)
            {
                borderFormatting = new BorderFormatting(in1);
            }

            if (ContainsPatternFormattingBlock)
            {
                patternFormatting = new PatternFormatting(in1);
            }
            field_17_formula1 = FR.Formula.Read(field_3_formula1_len, in1);
            field_18_formula2 = FR.Formula.Read(field_4_formula2_len, in1);
        }
Beispiel #5
0
        /**
         * Constructs an Label record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public LabelRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadUShort();
            field_3_xf_index = in1.ReadShort();
            field_4_string_len = in1.ReadShort();
            field_5_unicode_flag = (byte)in1.ReadByte();
            if (field_4_string_len > 0)
            {
                if (IsUncompressedUnicode)
                {
                    field_6_value = in1.ReadUnicodeLEString(field_4_string_len);
                }
                else
                {
                    field_6_value = in1.ReadCompressedUnicode(field_4_string_len);
                }
            }
            else
            {
                field_6_value = "";
            }
            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO, "LabelRecord data remains: " +in1.Remaining +
                " : " + HexDump.ToHex(in1.ReadRemainder()));
            }
        }
Beispiel #6
0
    /**
     * Constructs a RK record and Sets its fields appropriately.
     * @param in the RecordInputstream to Read the record from
     */

    public RKRecord(RecordInputStream in1)
    {
        field_1_row = in1.ReadUShort();
        field_2_col = in1.ReadUShort();
        field_3_xf_index = in1.ReadShort();
        field_4_rk_number = in1.ReadInt();
    }
        /**
         * Constructs an LabelSST record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public LabelSSTRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadUShort();
            field_3_xf_index = in1.ReadShort();
            field_4_sst_index = in1.ReadInt();
        }
Beispiel #8
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();
            }
        }
Beispiel #9
0
        /**
         * Constructs a <c>NoteRecord</c> and Fills its fields
         * from the supplied <c>RecordInputStream</c>.
         *
         * @param in the stream to Read from
         */
        public NoteRecord(RecordInputStream in1)
        {
            field_1_row     = in1.ReadShort();
            field_2_col     = in1.ReadUShort();
            field_3_flags   = in1.ReadShort();
            field_4_shapeid = in1.ReadUShort();
            int length = in1.ReadShort();

            field_5_hasMultibyte = in1.ReadByte() != 0x00;
            if (field_5_hasMultibyte)
            {
                field_6_author = StringUtil.ReadUnicodeLE(in1, length);
            }
            else
            {
                field_6_author = StringUtil.ReadCompressedUnicode(in1, length);
            }
            if (in1.Available() == 1)
            {
                field_7_padding = (byte)in1.ReadByte();
            }
            else if (in1.Available() == 2 && length == 0)
            {
                // If there's no author, may be double padded
                field_7_padding = (byte)in1.ReadByte();
                in1.ReadByte();
            }
        }
        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);
            }
        }
Beispiel #11
0
        /**
         * Constructs a BoolErr record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public BoolErrRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadUShort();
            field_3_xf_index = in1.ReadShort();
            field_4_bBoolErr = (byte)in1.ReadByte();
            field_5_fError = (byte)in1.ReadByte();
        }
Beispiel #12
0
        public ArrayRecord(RecordInputStream in1)
            : base(in1)
        {

            _options = in1.ReadUShort();
            _field3notUsed = in1.ReadInt();
            int formulaLen = in1.ReadUShort();
            _formulaTokens = Ptg.ReadTokens(formulaLen, in1);
        }
Beispiel #13
0
 public ArrayRecord(RecordInputStream in1)
     : base(in1)
 {
     _options = in1.ReadUShort();
     _field3notUsed = in1.ReadInt();
     int formulaTokenLen = in1.ReadUShort();
     int totalFormulaLen = in1.Available();
     _formula = NPOI.SS.Formula.Formula.Read(formulaTokenLen, in1, totalFormulaLen);
 }
Beispiel #14
0
        public ArrayRecord(RecordInputStream in1)
            : base(in1)
        {
            _options       = in1.ReadUShort();
            _field3notUsed = in1.ReadInt();
            int formulaTokenLen = in1.ReadUShort();
            int totalFormulaLen = in1.Available();

            _formula = NPOI.SS.Formula.Formula.Read(formulaTokenLen, in1, totalFormulaLen);
        }
        public TableStylesRecord(RecordInputStream in1)
        {
            rt       = in1.ReadUShort();
            grbitFrt = in1.ReadUShort();
            in1.ReadFully(unused);
            cts = in1.ReadInt();
            int cchDefListStyle  = in1.ReadUShort();
            int cchDefPivotStyle = in1.ReadUShort();

            rgchDefListStyle  = in1.ReadUnicodeLEString(cchDefListStyle);
            rgchDefPivotStyle = in1.ReadUnicodeLEString(cchDefPivotStyle);
        }
Beispiel #16
0
        public TableStylesRecord(RecordInputStream in1)
        {
            rt = in1.ReadUShort();
            grbitFrt = in1.ReadUShort();
            in1.ReadFully(unused);
            cts = in1.ReadInt();
            int cchDefListStyle = in1.ReadUShort();
            int cchDefPivotStyle = in1.ReadUShort();

            rgchDefListStyle = in1.ReadUnicodeLEString(cchDefListStyle);
            rgchDefPivotStyle = in1.ReadUnicodeLEString(cchDefPivotStyle);
        }
Beispiel #17
0
        public CFRuleRecord(RecordInputStream in1)
        {
            ConditionType       = ((byte)in1.ReadByte());
            ComparisonOperation = ((byte)in1.ReadByte());
            int field_3_formula1_len = in1.ReadUShort();
            int field_4_formula2_len = in1.ReadUShort();

            ReadFormatOptions(in1);

            // "You may not use unions, intersections or array constants in Conditional Formatting criteria"
            Formula1 = (Formula.Read(field_3_formula1_len, in1));
            Formula2 = (Formula.Read(field_4_formula2_len, in1));
        }
Beispiel #18
0
        /// <summary>
        /// Constructs a Selection record and Sets its fields appropriately.
        /// </summary>
        /// <param name="in1">the RecordInputstream to Read the record from</param>
        public SelectionRecord(RecordInputStream in1)
        {
            field_1_pane = (byte)in1.ReadByte();
            
            field_2_row_active_cell = in1.ReadUShort();
            field_3_col_active_cell = in1.ReadShort();
            field_4_ref_active_cell = in1.ReadShort();
            int field_5_num_refs = in1.ReadUShort();

            field_6_refs = new CellRangeAddress8Bit[field_5_num_refs];
            for (int i = 0; i < field_5_num_refs; i++)
            {
                field_6_refs[i] = new CellRangeAddress8Bit(in1);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Constructs a Selection record and Sets its fields appropriately.
        /// </summary>
        /// <param name="in1">the RecordInputstream to Read the record from</param>
        public SelectionRecord(RecordInputStream in1)
        {
            field_1_pane = (byte)in1.ReadByte();

            field_2_row_active_cell = in1.ReadUShort();
            field_3_col_active_cell = in1.ReadShort();
            field_4_ref_active_cell = in1.ReadShort();
            int field_5_num_refs = in1.ReadUShort();

            field_6_refs = new CellRangeAddress8Bit[field_5_num_refs];
            for (int i = 0; i < field_5_num_refs; i++)
            {
                field_6_refs[i] = new CellRangeAddress8Bit(in1);
            }
        }
        /**
         * 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.");
            }
        }
Beispiel #21
0
        /**
         * Constructs a MulRK record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulRKRecord(RecordInputStream in1)
        {
            field_1_row       = in1.ReadUShort();
            field_2_first_col = in1.ReadShort();
            field_3_rks       = RkRec.ParseRKs(in1);
            field_4_last_col  = in1.ReadShort();
        }
Beispiel #22
0
        /**
         * Constructs a MulBlank record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulBlankRecord(RecordInputStream in1)
        {
            _row = in1.ReadUShort();
            _first_col = in1.ReadShort();
            _xfs = ParseXFs(in1);
            _last_col = in1.ReadShort();
        }
Beispiel #23
0
        /**
         * Constructs a MulBlank record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulBlankRecord(RecordInputStream in1)
        {
            _row       = in1.ReadUShort();
            _first_col = in1.ReadShort();
            _xfs       = ParseXFs(in1);
            _last_col  = in1.ReadShort();
        }
Beispiel #24
0
        /**
         * Constructs a MulBlank record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulBlankRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_first_col = in1.ReadShort();
            field_3_xfs = ParseXFs(in1);
            field_4_last_col = in1.ReadShort();
        }
Beispiel #25
0
        /**
         * Constructs a MulRK record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulRKRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_first_col = in1.ReadShort();
            field_3_rks = ParseRKs(in1);
            field_4_last_col = in1.ReadShort();
        }
Beispiel #26
0
        public FeatRecord(RecordInputStream in1)
        {
            futureHeader = new FtrHeader(in1);

            isf_sharedFeatureType = in1.ReadShort();
            reserved1 = (byte)in1.ReadByte();
            reserved2 = in1.ReadInt();
            int cref = in1.ReadUShort();
            cbFeatData = in1.ReadInt();
            reserved3 = in1.ReadShort();

            cellRefs = new CellRangeAddress[cref];
            for (int i = 0; i < cellRefs.Length; i++)
            {
                cellRefs[i] = new CellRangeAddress(in1);
            }

            switch (isf_sharedFeatureType)
            {
                case FeatHdrRecord.SHAREDFEATURES_ISFPROTECTION:
                    sharedFeature = new FeatProtection(in1);
                    break;
                case FeatHdrRecord.SHAREDFEATURES_ISFFEC2:
                    sharedFeature = new FeatFormulaErr2(in1);
                    break;
                case FeatHdrRecord.SHAREDFEATURES_ISFFACTOID:
                    sharedFeature = new FeatSmartTag(in1);
                    break;
                default:
                    System.Console.WriteLine("Unknown Shared Feature " + isf_sharedFeatureType + " found!");
                    break;
            }
        }
Beispiel #27
0
        /**
         * Constructs a MulBlank record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public MulBlankRecord(RecordInputStream in1)
        {
            field_1_row       = in1.ReadUShort();
            field_2_first_col = in1.ReadShort();
            field_3_xfs       = ParseXFs(in1);
            field_4_last_col  = in1.ReadShort();
        }
Beispiel #28
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.");
            }
        }
Beispiel #29
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();
            }
        }
Beispiel #30
0
        /**
         * Constructs a <c>NoteRecord</c> and Fills its fields
         * from the supplied <c>RecordInputStream</c>.
         *
         * @param in the stream to Read from
         */
        public NoteRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadShort();
            field_2_col = in1.ReadUShort();
            field_3_flags = in1.ReadShort();
            field_4_shapeid = in1.ReadUShort();
            int length = in1.ReadShort();
		    field_5_hasMultibyte = in1.ReadByte() != 0x00;
		    if (field_5_hasMultibyte) {
			    field_6_author = StringUtil.ReadUnicodeLE(in1, length);
		    } else {
			    field_6_author = StringUtil.ReadCompressedUnicode(in1, length);
		    }
 		    if (in1.Available() == 1) {
			    field_7_padding = (byte)in1.ReadByte();
		    }
        }
Beispiel #31
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();
            }
        }
Beispiel #32
0
 private static int ReadUShortAndCheck(RecordInputStream in1)
 {
     if (in1.Remaining < ENCODED_SIZE)
     {
         // Ran out of data
         throw new Exception("Ran out of data readin1g CellRangeAddress");
     }
     return in1.ReadUShort();
 }
        /**
         * @param in the RecordInputstream to read the record from
         */
        public CellRangeAddressList(RecordInputStream in1)
        {
            int nItems = in1.ReadUShort();
            _list = new ArrayList(nItems);

            for (int k = 0; k < nItems; k++)
            {
                _list.Add(new CellRangeAddress(in1));
            }
        }
Beispiel #34
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--;
            }
        }
        /**
         * Constructs a SeriesList record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public SeriesListRecord(RecordInputStream in1)
        {
            int nItems = in1.ReadUShort();
    	    short[] ss = new short[nItems];
    	    for (int i = 0; i < nItems; i++) {
			    ss[i] = in1.ReadShort();
    			
		    }
            field_1_seriesNumbers = ss;

        }
Beispiel #36
0
        /**
         * Constructs a Row record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RowRecord(RecordInputStream in1)
        {
            field_1_row_number = in1.ReadUShort();
            field_2_first_col = in1.ReadShort();
            field_3_last_col = in1.ReadShort();
            field_4_height = in1.ReadShort();
            field_5_optimize = in1.ReadShort();
            field_6_reserved = in1.ReadShort();
            field_7_option_flags = in1.ReadShort();
            field_8_xf_index = in1.ReadShort();
        }
Beispiel #37
0
        /**
         * Constructs a Row record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RowRecord(RecordInputStream in1)
        {
            field_1_row_number   = in1.ReadUShort();
            field_2_first_col    = in1.ReadShort();
            field_3_last_col     = in1.ReadShort();
            field_4_height       = in1.ReadShort();
            field_5_optimize     = in1.ReadShort();
            field_6_reserved     = in1.ReadShort();
            field_7_option_flags = in1.ReadShort();
            field_8_xf_index     = in1.ReadShort();
        }
Beispiel #38
0
        /**
         * Constructs a DBCellRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */
        public DBCellRecord(RecordInputStream in1)
        {
            field_1_row_offset = in1.ReadUShort();
            int size = in1.Remaining;
            field_2_cell_offsets = new short[size / 2];

            for (int i = 0; i < field_2_cell_offsets.Length; i++)
            {
                field_2_cell_offsets[i] = in1.ReadShort();
            }
        }
Beispiel #39
0
        /**
         * Constructs a DBCellRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */
        public DBCellRecord(RecordInputStream in1)
        {
            field_1_row_offset = in1.ReadUShort();
            int size = in1.Remaining;

            field_2_cell_offsets = new short[size / 2];

            for (int i = 0; i < field_2_cell_offsets.Length; i++)
            {
                field_2_cell_offsets[i] = in1.ReadShort();
            }
        }
Beispiel #40
0
        /**
         * Constructs a MergedCellsRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public MergeCellsRecord(RecordInputStream in1)
        {
            int nRegions = in1.ReadUShort();
    	    CellRangeAddress[] cras = new CellRangeAddress[nRegions];
    	    for (int i = 0; i < nRegions; i++) 
            {
			    cras[i] = new CellRangeAddress(in1);
		    }
    	    _numberOfRegions = nRegions;
    	    _startIndex = 0;
    	    _regions = cras;
        }
Beispiel #41
0
 /**
  * Constructs a ColumnInfo record and Sets its fields appropriately
  * @param in the RecordInputstream to Read the record from
  */
 public ColumnInfoRecord(RecordInputStream in1)
 {
     field_1_first_col = in1.ReadUShort();
     field_2_last_col = in1.ReadUShort();
     field_3_col_width = in1.ReadShort();
     field_4_xf_index = in1.ReadShort();
     field_5_options = in1.ReadShort();
     switch (in1.Remaining)
     {
         case 2: // usual case
             field_6_reserved = in1.ReadShort();
             break;
         case 1:
             // often COLINFO Gets encoded 1 byte short
             // shouldn't matter because this field Is Unused
             field_6_reserved = in1.ReadByte();
             break;
         default:
             throw new Exception("Unusual record size remaining=(" + in1.Remaining + ")");
     }
 }
Beispiel #42
0
        /**
         * Constructs a ColumnInfo record and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public ColumnInfoRecord(RecordInputStream in1)
        {
            _first_col = in1.ReadUShort();
            _last_col = in1.ReadUShort();
            _col_width = in1.ReadUShort();
            _xf_index = in1.ReadUShort();
            _options = in1.ReadUShort();
            switch (in1.Remaining)
            {
                case 2: // usual case
                    field_6_reserved = in1.ReadUShort();
                    break;
                case 1:
                    // often COLINFO Gets encoded 1 byte short
                    // shouldn't matter because this field Is Unused
                    field_6_reserved = in1.ReadByte();
                    break;
                case 0:
                    // According to bugzilla 48332,
                    // "SoftArtisans OfficeWriter for Excel" totally skips field 6
                    // Excel seems to be OK with this, and assumes zero.
                    field_6_reserved = 0;
                    break;
                default:
                    throw new Exception("Unusual record size remaining=(" + in1.Remaining + ")");
            }
        }
Beispiel #43
0
        public FilePassRecord(RecordInputStream in1)
        {
            _encryptionType = in1.ReadUShort();

            switch (_encryptionType)
            {
            case ENCRYPTION_XOR:
                throw new RecordFormatException("HSSF does not currently support XOR obfuscation");

            case ENCRYPTION_OTHER:
                // handled below
                break;

            default:
                throw new RecordFormatException("Unknown encryption type " + _encryptionType);
            }
            _encryptionInfo = in1.ReadUShort();
            switch (_encryptionInfo)
            {
            case ENCRYPTION_OTHER_RC4:
                // handled below
                break;

            case ENCRYPTION_OTHER_CAPI_2:
            case ENCRYPTION_OTHER_CAPI_3:
                throw new RecordFormatException(
                          "HSSF does not currently support CryptoAPI encryption");

            default:
                throw new RecordFormatException("Unknown encryption info " + _encryptionInfo);
            }
            _minorVersionNo = in1.ReadUShort();
            if (_minorVersionNo != 1)
            {
                throw new RecordFormatException("Unexpected VersionInfo number for RC4Header " + _minorVersionNo);
            }
            _docId    = Read(in1, 16);
            _saltData = Read(in1, 16);
            _saltHash = Read(in1, 16);
        }
Beispiel #44
0
        /**
         * Constructs a ColumnInfo record and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public ColumnInfoRecord(RecordInputStream in1)
        {
            _first_col = in1.ReadUShort();
            _last_col  = in1.ReadUShort();
            _col_width = in1.ReadUShort();
            _xf_index  = in1.ReadUShort();
            _options   = in1.ReadUShort();
            switch (in1.Remaining)
            {
            case 2:     // usual case
                field_6_reserved = in1.ReadUShort();
                break;

            case 1:
                // often COLINFO Gets encoded 1 byte short
                // shouldn't matter because this field Is Unused
                field_6_reserved = in1.ReadByte();
                break;

            case 0:
                // According to bugzilla 48332,
                // "SoftArtisans OfficeWriter for Excel" totally skips field 6
                // Excel seems to be OK with this, and assumes zero.
                field_6_reserved = 0;
                break;

            default:
                throw new Exception("Unusual record size remaining=(" + in1.Remaining + ")");
            }
        }
        /**
         * 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--;
            }

        }
        /**
         * Constructs a MergedCellsRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public MergeCellsRecord(RecordInputStream in1)
        {
            int nRegions = in1.ReadUShort();

            CellRangeAddress[] cras = new CellRangeAddress[nRegions];
            for (int i = 0; i < nRegions; i++)
            {
                cras[i] = new CellRangeAddress(in1);
            }
            _numberOfRegions = nRegions;
            _startIndex      = 0;
            _regions         = cras;
        }
Beispiel #47
0
        /**
         * Constructs an Label record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public LabelRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadUShort();
            field_3_xf_index = in1.ReadShort();
            field_4_string_len = in1.ReadShort();
            field_5_unicode_flag = (byte)in1.ReadByte();
            if (field_4_string_len > 0)
            {
                if (IsUnCompressedUnicode)
                {
                    field_6_value = in1.ReadUnicodeLEString(field_4_string_len);
                }
                else
                {
                    field_6_value = in1.ReadCompressedUnicode(field_4_string_len);
                }
            }
            else
            {
                field_6_value = "";
            }
        }
Beispiel #48
0
        /**
         * Constructs an Label record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public LabelRecord(RecordInputStream in1)
        {
            field_1_row          = in1.ReadUShort();
            field_2_column       = in1.ReadUShort();
            field_3_xf_index     = in1.ReadShort();
            field_4_string_len   = in1.ReadShort();
            field_5_unicode_flag = (byte)in1.ReadByte();
            if (field_4_string_len > 0)
            {
                if (IsUncompressedUnicode)
                {
                    field_6_value = in1.ReadUnicodeLEString(field_4_string_len);
                }
                else
                {
                    field_6_value = in1.ReadCompressedUnicode(field_4_string_len);
                }
            }
            else
            {
                field_6_value = "";
            }
        }
Beispiel #49
0
        /**
         * Constructs a ColumnInfo record and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public ColumnInfoRecord(RecordInputStream in1)
        {
            field_1_first_col = in1.ReadUShort();
            field_2_last_col  = in1.ReadUShort();
            field_3_col_width = in1.ReadShort();
            field_4_xf_index  = in1.ReadShort();
            field_5_options   = in1.ReadShort();
            switch (in1.Remaining)
            {
            case 2:     // usual case
                field_6_reserved = in1.ReadShort();
                break;

            case 1:
                // often COLINFO Gets encoded 1 byte short
                // shouldn't matter because this field Is Unused
                field_6_reserved = in1.ReadByte();
                break;

            default:
                throw new Exception("Unusual record size remaining=(" + in1.Remaining + ")");
            }
        }
 private static object ReadAConstantValue(RecordInputStream in1)
 {
     byte grbit = (byte)in1.ReadByte();
     switch (grbit)
     {
         case TYPE_EMPTY:
             in1.ReadLong(); // 8 byte 'not used' field
             return EMPTY_REPRESENTATION;
         case TYPE_NUMBER:
             return in1.ReadDouble();
         case TYPE_STRING:
             return in1.ReadUnicodeString();
         case TYPE_bool:
             return ReadBoolean(in1);
         case TYPE_ERROR_CODE:
             int errCode = in1.ReadUShort();
             // next 6 bytes are Unused
             in1.ReadUShort();
             in1.ReadInt();
             return ErrorConstant.ValueOf(errCode);
     }
     throw new Exception("Unknown grbit value (" + grbit + ")");
 }
Beispiel #51
0
        public FilePassRecord(RecordInputStream in1)
        {
            _encryptionType = in1.ReadUShort();

            switch (_encryptionType)
            {
                case ENCRYPTION_XOR:
                    throw new RecordFormatException("HSSF does not currently support XOR obfuscation");
                case ENCRYPTION_OTHER:
                    // handled below
                    break;
                default:
                    throw new RecordFormatException("Unknown encryption type " + _encryptionType);
            }
            _encryptionInfo = in1.ReadUShort();
            switch (_encryptionInfo)
            {
                case ENCRYPTION_OTHER_RC4:
                    // handled below
                    break;
                case ENCRYPTION_OTHER_CAPI_2:
                case ENCRYPTION_OTHER_CAPI_3:
                    throw new RecordFormatException(
                            "HSSF does not currently support CryptoAPI encryption");
                default:
                    throw new RecordFormatException("Unknown encryption info " + _encryptionInfo);
            }
            _minorVersionNo = in1.ReadUShort();
            if (_minorVersionNo != 1)
            {
                throw new RecordFormatException("Unexpected VersionInfo number for RC4Header " + _minorVersionNo);
            }
            _docId = Read(in1, 16);
            _saltData = Read(in1, 16);
            _saltHash = Read(in1, 16);
        }
 public ChartTitleFormatRecord(RecordInputStream in1)
 {
     m_recs = in1.ReadUShort();
     int idx;
     CTFormat ctf;
     if (m_formats == null)
     {
         m_formats = new ArrayList(m_recs);
     }
     for (idx = 0; idx < m_recs; idx++)
     {
         ctf = new CTFormat(in1.ReadShort(), in1.ReadShort());
         m_formats.Add(ctf);
     }
 }
Beispiel #53
0
        /**
         * Constructs a Row record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RowRecord(RecordInputStream in1)
        {
            field_1_row_number = in1.ReadUShort();
            if (field_1_row_number < 0)
            {
                throw new ArgumentException("Invalid row number " + field_1_row_number + " found in InputStream");
            }
            field_2_first_col    = in1.ReadShort();
            field_3_last_col     = in1.ReadShort();
            field_4_height       = in1.ReadShort();
            field_5_optimize     = in1.ReadShort();
            field_6_reserved     = in1.ReadShort();
            field_7_option_flags = in1.ReadShort();
            field_8_option_flags = in1.ReadShort();
        }
Beispiel #54
0
        public DataItemRecord(RecordInputStream in1)
        {
            isxvdData = in1.ReadUShort();
            iiftab = in1.ReadUShort();
            df = in1.ReadUShort();
            isxvd = in1.ReadUShort();
            isxvi = in1.ReadUShort();
            ifmt = in1.ReadUShort();

            name = in1.ReadString();
        }
Beispiel #55
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);
        }
Beispiel #56
0
        public FilePassRecord(RecordInputStream in1)
        {
            _encryptionType = in1.ReadUShort();

            switch (_encryptionType)
            {
            case ENCRYPTION_XOR:
                _keyData = new XorKeyData();
                break;

            case ENCRYPTION_OTHER:
                _keyData = new Rc4KeyData();
                break;

            default:
                throw new RecordFormatException("Unknown encryption type " + _encryptionType);
            }

            _keyData.Read(in1);
        }
Beispiel #57
0
        public FeatRecord(RecordInputStream in1)
        {
            futureHeader = new FtrHeader(in1);

            isf_sharedFeatureType = in1.ReadShort();
            reserved1             = (byte)in1.ReadByte();
            reserved2             = in1.ReadInt();
            int cref = in1.ReadUShort();

            cbFeatData = in1.ReadInt();
            reserved3  = in1.ReadShort();

            cellRefs = new CellRangeAddress[cref];
            for (int i = 0; i < cellRefs.Length; i++)
            {
                cellRefs[i] = new CellRangeAddress(in1);
            }

            switch (isf_sharedFeatureType)
            {
            case FeatHdrRecord.SHAREDFEATURES_ISFPROTECTION:
                sharedFeature = new FeatProtection(in1);
                break;

            case FeatHdrRecord.SHAREDFEATURES_ISFFEC2:
                sharedFeature = new FeatFormulaErr2(in1);
                break;

            case FeatHdrRecord.SHAREDFEATURES_ISFFACTOID:
                sharedFeature = new FeatSmartTag(in1);
                break;

            default:
                logger.Log(POILogger.ERROR, "Unknown Shared Feature " + isf_sharedFeatureType + " found!");
                break;
            }
        }
Beispiel #58
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);
                }
            }
        }
Beispiel #59
0
        /**
         * Constructs a DefaultColumnWidth record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public DefaultColWidthRecord(RecordInputStream in1)
        {
            field_1_col_width = in1.ReadUShort();
        }
Beispiel #60
0
 public Break(RecordInputStream in1)
 {
     main    = in1.ReadUShort() - 1;
     subFrom = in1.ReadUShort();
     subTo   = in1.ReadUShort();
 }