Example #1
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();
        }
Example #2
0
        public void TestRead()
        {

            byte[] data = new byte[22];
            LittleEndian.PutShort(data, 0, DVALRecord.sid);
            LittleEndian.PutShort(data, 2, (short)18);
            LittleEndian.PutShort(data, 4, (short)55);
            LittleEndian.PutInt(data, 6, 56);
            LittleEndian.PutInt(data, 10, 57);
            LittleEndian.PutInt(data, 14, 58);
            LittleEndian.PutInt(data, 18, 59);

            RecordInputStream in1 = new RecordInputStream(new MemoryStream(data));
            in1.NextRecord();
            DVALRecord dv = new DVALRecord(in1);

            Assert.AreEqual(55, dv.Options);
            Assert.AreEqual(56, dv.HorizontalPos);
            Assert.AreEqual(57, dv.VerticalPos);
            Assert.AreEqual(58, dv.ObjectID);
            if (dv.DVRecNo == 0)
            {
                Assert.Fail("Identified bug 44510");
            }
            Assert.AreEqual(59, dv.DVRecNo);
        }
Example #3
0
        public ViewDefinitionRecord(RecordInputStream in1)
        {
            rwFirst = in1.ReadUShort();
            rwLast = in1.ReadUShort();
            colFirst = in1.ReadUShort();
            colLast = in1.ReadUShort();
            rwFirstHead = in1.ReadUShort();
            rwFirstData = in1.ReadUShort();
            colFirstData = in1.ReadUShort();
            iCache = in1.ReadUShort();
            reserved = in1.ReadUShort();
            sxaxis4Data = in1.ReadUShort();
            ipos4Data = in1.ReadUShort();
            cDim = in1.ReadUShort();
            cDimRw = in1.ReadUShort();
            cDimCol = in1.ReadUShort();
            cDimPg = in1.ReadUShort();
            cDimData = in1.ReadUShort();
            cRw = in1.ReadUShort();
            cCol = in1.ReadUShort();
            grbit = in1.ReadUShort();
            itblAutoFmt = in1.ReadUShort();
            int cchName = in1.ReadUShort();
            int cchData = in1.ReadUShort();

            name = StringUtil.ReadUnicodeString(in1, cchName);
            dataField = StringUtil.ReadUnicodeString(in1, cchData);
        }
Example #4
0
        /**
         * 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();
        }
Example #5
0
			public StreamEncryptionInfo(RecordInputStream rs, List<Record> outputRecs)
			{
				Record rec;
				rs.NextRecord();
				int recSize = 4 + rs.Remaining;
				rec = RecordFactory.CreateSingleRecord(rs);
				outputRecs.Add(rec);
				FilePassRecord fpr = null;
				if (rec is BOFRecord)
				{
					_hasBOFRecord = true;
					// Fetch the next record, and see if it indicates whether
					//  the document is encrypted or not
					if (rs.HasNextRecord)
					{
						rs.NextRecord();
						rec = RecordFactory.CreateSingleRecord(rs);
						recSize += rec.RecordSize;
						outputRecs.Add(rec);
						// Encrypted is normally BOF then FILEPASS
						// May sometimes be BOF, WRITEPROTECT, FILEPASS
						if (rec is WriteProtectRecord && rs.HasNextRecord)
						{
							rs.NextRecord();
							rec = RecordFactory.CreateSingleRecord(rs);
							recSize += rec.RecordSize;
							outputRecs.Add(rec);
						}
						// If it's a FILEPASS, track it specifically but
						//  don't include it in the main stream
						if (rec is FilePassRecord)
						{
							fpr = (FilePassRecord)rec;
							outputRecs.RemoveAt(outputRecs.Count - 1);
							// TODO - add fpr not Added to outPutRecs
							rec = outputRecs[0];
						}
						else
						{
							// workbook not encrypted (typical case)
							if (rec is EOFRecord)
							{
								// A workbook stream is never empty, so crash instead
								// of trying to keep track of nesting level
								throw new InvalidOperationException("Nothing between BOF and EOF");
							}
						}
					}
				}
				else
				{
					// Invalid in a normal workbook stream.
					// However, some test cases work on sub-sections of
					// the workbook stream that do not begin with BOF
					_hasBOFRecord = false;
				}
				_InitialRecordsSize = recSize;
				_filePassRec = fpr;
				_lastRecord = rec;
			}
Example #6
0
        /**
         * Constructs a Bar record and s its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public BarRecord(RecordInputStream in1)
        {

            field_1_barSpace = in1.ReadShort();
            field_2_categorySpace = in1.ReadShort();
            field_3_formatFlags = in1.ReadShort();
        }
Example #7
0
        /**
         * Reads <tt>size</tt> bytes of the input stream, to Create an array of <tt>Ptg</tt>s.
         * Extra data (beyond <tt>size</tt>) may be Read if and <tt>ArrayPtg</tt>s are present.
         */
        public static Ptg[] ReadTokens(int size, RecordInputStream in1)
        {
		    ArrayList temp = new ArrayList(4 + size / 2);
		    int pos = 0;
		    ArrayList arrayPtgs = null;
		    while (pos < size) {
			    Ptg ptg = Ptg.CreatePtg( in1 );
			    if (ptg is ArrayPtg) {
				    if (arrayPtgs == null) {
					    arrayPtgs = new ArrayList(5);
				    }
				    arrayPtgs.Add(ptg);
				    pos += ArrayPtg.PLAIN_TOKEN_SIZE;
			    } else {
				    pos += ptg.Size;
			    }
			    temp.Add( ptg );
		    }
		    if(pos != size) {
			    throw new Exception("Ptg array size mismatch");
		    }
		    if (arrayPtgs != null) {
			    for (int i=0;i<arrayPtgs.Count;i++) {
				    ArrayPtg p = (ArrayPtg)arrayPtgs[i];
				    p.ReadTokenValues(in1);
			    }
		    }
		    return ToPtgArray(temp);
        }
Example #8
0
        /**
         * Constructs a OBJ record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public ObjRecord(RecordInputStream in1)
        {
            subrecords = new ArrayList();
            //Check if this can be continued, if so then the
            //following wont work properly
            int subSize = 0;
            byte[] subRecordData = in1.ReadRemainder();

            RecordInputStream subRecStream = new RecordInputStream(new MemoryStream(subRecordData));
            while (subRecStream.HasNextRecord)
            {
                subRecStream.NextRecord();
                Record subRecord = SubRecord.CreateSubRecord(subRecStream);
                subSize += subRecord.RecordSize;
                subrecords.Add(subRecord);
            }

            /**
             * Add the EndSubRecord explicitly.
             * 
             * TODO - the reason the EndSubRecord Is always skipped Is because its 'sid' Is zero and
             * that causes subRecStream.HasNextRecord() to return false.
             * There may be more than the size of EndSubRecord left-over, if there Is any pAdding 
             * after that record.  The content of the EndSubRecord and the pAdding Is all zeros.
             * So there's not much to look at past the last substantial record.
             * 
             * See Bugs 41242/45133 for details.
             */
            if (subRecordData.Length - subSize >= 4)
            {
                subrecords.Add(new EndSubRecord());
            }
        }
Example #9
0
        /**
         * Constructs a Style record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public StyleRecord(RecordInputStream in1)
        {
            fHighByte = BitFieldFactory.GetInstance(0x01); //have to init here, since we are being called
            //from base, and class level init hasnt been done. 
            field_1_xf_index = in1.ReadShort();
            if (Type == STYLE_BUILT_IN)
            {
                field_2_builtin_style = (byte)in1.ReadByte();
                field_3_outline_style_level = (byte)in1.ReadByte();
            }
            else if (Type == STYLE_USER_DEFINED)
            {
                field_2_name_length = in1.ReadShort();

                // Some files from Crystal Reports lack
                //  the remaining fields, which Is naughty
                if (in1.Remaining > 0)
                {
                    field_3_string_options = (byte)in1.ReadByte();

                    byte[] str = in1.ReadRemainder();
                    if (fHighByte.IsSet(field_3_string_options))
                    {
                        field_4_name = StringUtil.GetFromUnicodeBE(str, 0, field_2_name_length);
                    }
                    else
                    {
                        field_4_name = StringUtil.GetFromCompressedUnicode(str, 0, field_2_name_length);
                    }
                }
            }

            // todo sanity Check exception to make sure we're one or the other
        }
Example #10
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 + ")");
            }
        }
Example #11
0
        public void FillFields(RecordInputStream in1)
        {
            this.field_Addr_number = in1.ReadShort();
            this.field_regions_list = new ArrayList(this.field_Addr_number);

            for (int k = 0; k < this.field_Addr_number; k++)
            {
                short first_row = in1.ReadShort();
                short first_col = in1.ReadShort();

                short last_row = first_row;
                short last_col = first_col;
                if (in1.Remaining >= 4)
                {
                    last_row = in1.ReadShort();
                    last_col = in1.ReadShort();
                }
                else
                {
                    // Ran out of data
                    // For now, Issue a warning, finish, and 
                    //  hope for the best....
                    logger.Log(POILogger.WARN, "Ran out of data reading cell references for DVRecord");
                    k = this.field_Addr_number;
                }

                AddrStructure region = new AddrStructure(first_row, first_col, last_row, last_col);
                this.field_regions_list.Add(region);
            }
        }
Example #12
0
 /**
  * Constructs a Guts record and Sets its fields appropriately.
  * @param in the RecordInputstream to Read the record from
  */
 public GutsRecord(RecordInputStream in1)
 {
     field_1_left_row_gutter = in1.ReadShort();
     field_2_top_col_gutter = in1.ReadShort();
     field_3_row_level_max = in1.ReadShort();
     field_4_col_level_max = in1.ReadShort();
 }
Example #13
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 = "";
            }
        }
        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);
            }
        }
Example #15
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();
        }
Example #16
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.");
            }
        }
Example #17
0
        /**
         * construct an Unknown record.  No fields are interperated and the record will
         * be Serialized in its original form more or less
         * @param in the RecordInputstream to Read the record from
         */

        public UnknownRecord(RecordInputStream in1)
        {
            _sid = in1.Sid;
            _rawData = in1.ReadRemainder();

            //Console.WriteLine("UnknownRecord: 0x"+StringUtil.ToHexString(sid));
        }
Example #18
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;
            }
        }
Example #19
0
        /**
         * Constructs a ObjectLink record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public ObjectLinkRecord(RecordInputStream in1)
        {

            field_1_anchorId = in1.ReadShort();
            field_2_link1 = in1.ReadShort();
            field_3_link2 = in1.ReadShort();
        }
        public int FillField(RecordInputStream in1)
        {
            short tokenSize = in1.ReadShort();
            formulaTokens = Ptg.ReadTokens(tokenSize, in1);

            return tokenSize + 2;
        }
Example #21
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()));
            }
        }
Example #22
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);
        }
Example #23
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();
        }
        /**
         * Constructs a FileSharing record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public FileSharingRecord(RecordInputStream in1)
        {
            field_1_Readonly = in1.ReadShort();
            field_2_password = in1.ReadShort();

            int nameLen = in1.ReadShort();

            if (nameLen > 0)
            {
                // TODO - Current examples(3) from junits only have zero Length username. 
                field_3_username_unicode_options = (byte)in1.ReadByte();
                field_3_username_value = in1.ReadCompressedUnicode(nameLen);
                
                if (field_3_username_value == null)
                {
                   // In some cases the user name can be null after reading from
                   // the input stream so we make sure this has a value
                   field_3_username_value = "";
                }
            }
            else
            {
                field_3_username_value = "";
            }
        }
Example #25
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();
    }
Example #26
0
        /**
         * Constructs a DataFormat record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public DataFormatRecord(RecordInputStream in1)
        {
            field_1_pointNumber = in1.ReadShort();
            field_2_seriesIndex = in1.ReadShort();
            field_3_seriesNumber = in1.ReadShort();
            field_4_formatFlags = in1.ReadShort();
        }
Example #27
0
        /**
         * Constructs a DVAL record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public DVALRecord(RecordInputStream in1)
        {
            this.field_1_options = in1.ReadShort();
            this.field_2_horiz_pos = in1.ReadInt();
            this.field_3_vert_pos = in1.ReadInt();
            this.field_cbo_id = in1.ReadInt();
            this.field_5_dv_no = in1.ReadInt();
        }
Example #28
0
        /**
         * Constructs a TabID record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public TabIdRecord(RecordInputStream in1)
        {
            _tabids = new short[in1.Remaining / 2];
            for (int k = 0; k < _tabids.Length; k++)
            {
                _tabids[k] = in1.ReadShort();
            }
        }
Example #29
0
        public CFHeaderRecord(RecordInputStream in1)
        {
            field_1_numcf = in1.ReadShort();
            field_2_need_recalculation = in1.ReadShort();
            field_3_enclosing_cell_range = new CellRangeAddress(in1);
            field_4_cell_ranges = new CellRangeAddressList(in1);

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

        public CategorySeriesAxisRecord(RecordInputStream in1)
    {
        field_1_crossingPoint = in1.ReadShort();
        field_2_labelFrequency = in1.ReadShort();
        field_3_tickMarkFrequency = in1.ReadShort();
        field_4_options = in1.ReadShort(); 
    
    }
Example #31
0
        /**
         * Constructs an LabelSST record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public LabelSSTRecord(RecordInputStream in1)
            : base(in1)
        {
            field_4_sst_index = in1.ReadInt();
        }
Example #32
0
        /**
         * Constructs a CalcModeRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public CalcModeRecord(RecordInputStream in1)
        {
            field_1_calcmode = in1.ReadShort();
        }
Example #33
0
        /**
         * Constructs a Protect record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public ScenarioProtectRecord(RecordInputStream in1)
        {
            field_1_protect = in1.ReadShort();
        }
Example #34
0
 public Break(RecordInputStream in1)
 {
     main    = in1.ReadUShort() - 1;
     subFrom = in1.ReadUShort();
     subTo   = in1.ReadUShort();
 }
Example #35
0
 private static UnicodeString ReadUnicodeString(RecordInputStream in1)
 {
     return(new UnicodeString(in1));
 }
Example #36
0
        /**
         * Constructs a Precision record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public PrecisionRecord(RecordInputStream in1)
        {
            field_1_precision = in1.ReadShort();
        }
Example #37
0
 /**
  * construct an UserSViewEnd record.  No fields are interpreted and the record will
  * be Serialized in its original form more or less
  * @param in the RecordInputstream to read the record from
  */
 public UserSViewEnd(RecordInputStream in1)
 {
     _rawData = in1.ReadRemainder();
 }
Example #38
0
        /**
         * Constructs a UseSelFS record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public UseSelFSRecord(RecordInputStream in1)
        {
            field_1_flag = in1.ReadShort();
        }
        /**
         * Constructs a ProtectionRev4 record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public ProtectionRev4Record(RecordInputStream in1) :
            this(in1.ReadShort())
        {
        }
Example #40
0
        /**
         * Constructs a CodepageRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public CodepageRecord(RecordInputStream in1)
        {
            field_1_codepage = in1.ReadShort();
        }
Example #41
0
        /**
         * Constructs a RECALCID record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RecalcIdRecord(RecordInputStream in1)
        {
            in1.ReadUShort(); // field 'rt' should have value 0x01C1, but Excel doesn't care during reading
            _reserved0 = in1.ReadUShort();
            _engineId  = in1.ReadInt();
        }
Example #42
0
 private static byte[] Read(RecordInputStream in1, int size)
 {
     byte[] result = new byte[size];
     in1.ReadFully(result);
     return(result);
 }
Example #43
0
        /**
         * Constructs a RefreshAll record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RefreshAllRecord(RecordInputStream in1)
        {
            field_1_refreshall = in1.ReadShort();
        }
Example #44
0
        /**
         * Constructs a OBJ record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public ObjRecord(RecordInputStream in1)
        {
            // TODO - problems with OBJ sub-records stream
            // MS spec says first sub-record is always CommonObjectDataSubRecord,
            // and last is
            // always EndSubRecord. OOO spec does not mention ObjRecord(0x005D).
            // Existing POI test data seems to violate that rule. Some test data
            // seems to contain
            // garbage, and a crash is only averted by stopping at what looks like
            // the 'EndSubRecord'

            //Check if this can be continued, if so then the
            //following wont work properly
            //int subSize = 0;
            byte[] subRecordData = in1.ReadRemainder();

            if (LittleEndian.GetUShort(subRecordData, 0) != CommonObjectDataSubRecord.sid)
            {
                // seems to occur in just one junit on "OddStyleRecord.xls" (file created by CrystalReports)
                // Excel tolerates the funny ObjRecord, and replaces it with a corrected version
                // The exact logic/reasoning is not yet understood
                _uninterpretedData = subRecordData;
                subrecords         = null;
                return;
            }
            //if (subRecordData.Length % 2 != 0)
            //{
            //    String msg = "Unexpected length of subRecordData : " + HexDump.ToHex(subRecordData);
            //    throw new RecordFormatException(msg);
            //}
            subrecords = new List <SubRecord>();
            using (MemoryStream bais = new MemoryStream(subRecordData))
            {
                LittleEndianInputStream   subRecStream = new LittleEndianInputStream(bais);
                CommonObjectDataSubRecord cmo          = (CommonObjectDataSubRecord)SubRecord.CreateSubRecord(subRecStream, 0);
                subrecords.Add(cmo);
                while (true)
                {
                    SubRecord subRecord = SubRecord.CreateSubRecord(subRecStream, cmo.ObjectType);
                    subrecords.Add(subRecord);
                    if (subRecord.IsTerminating)
                    {
                        break;
                    }
                }
                int nRemainingBytes = subRecStream.Available();
                if (nRemainingBytes > 0)
                {
                    // At present (Oct-2008), most unit test samples have (subRecordData.length % 2 == 0)
                    _isPaddedToQuadByteMultiple = subRecordData.Length % MAX_PAD_ALIGNMENT == 0;
                    if (nRemainingBytes >= (_isPaddedToQuadByteMultiple ? MAX_PAD_ALIGNMENT : NORMAL_PAD_ALIGNMENT))
                    {
                        if (!CanPaddingBeDiscarded(subRecordData, nRemainingBytes))
                        {
                            String msg = "Leftover " + nRemainingBytes
                                         + " bytes in subrecord data " + HexDump.ToHex(subRecordData);
                            throw new RecordFormatException(msg);
                        }
                        _isPaddedToQuadByteMultiple = false;
                    }
                }
                else
                {
                    _isPaddedToQuadByteMultiple = false;
                }
                _uninterpretedData = null;
            }
        }
Example #45
0
        /**
         * Constructs an HCenter record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public HCenterRecord(RecordInputStream in1)
        {
            field_1_hcenter = in1.ReadShort();
        }
Example #46
0
        /**
         * Constructs a BlankRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public BlankRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_col = in1.ReadShort();
            field_3_xf  = in1.ReadShort();
        }
Example #47
0
        /**
         * Main constructor -- kinda dummy because we don't validate or fill fields
         *
         * @param in the RecordInputstream to Read the record from
         */

        public ContinueRecord(RecordInputStream in1)
        {
            field_1_data = in1.ReadRemainder();
        }
Example #48
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.ReadShort();
        }
Example #49
0
 /// <summary>
 /// Constructs a DefaultRowHeight record and Sets its fields appropriately.
 /// </summary>
 /// <param name="in1">the RecordInputstream to Read the record from</param>
 public DefaultRowHeightRecord(RecordInputStream in1)
 {
     field_1_option_flags = in1.ReadShort();
     field_2_row_height   = in1.ReadShort();
 }
 /**
  * reads only the range (1 {@link CellRangeAddress8Bit}) from the stream
  */
 public SharedValueRecordBase(RecordInputStream in1)
 {
     _range = new CellRangeAddress8Bit(in1);
 }
Example #51
0
        /**
         * Constructs a Password record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public PasswordRecord(RecordInputStream in1)
        {
            field_1_password = in1.ReadShort();
        }
        /**
         * Read hyperlink from input stream
         *
         * @param in the stream to Read from
         */
        public HyperlinkRecord(RecordInputStream in1)
        {
            _range = new CellRangeAddress(in1);

            // 16-byte GUID
            _guid = new GUID(in1);

            /**
             * streamVersion (4 bytes): An unsigned integer that specifies the version number
             * of the serialization implementation used to save this structure. This value MUST equal 2.
             */
            int streamVersion = in1.ReadInt();

            if (streamVersion != 0x00000002)
            {
                throw new RecordFormatException("Stream Version must be 0x2 but found " + streamVersion);
            }
            _linkOpts = in1.ReadInt();

            if ((_linkOpts & HLINK_LABEL) != 0)
            {
                int label_len = in1.ReadInt();
                _label = in1.ReadUnicodeLEString(label_len);
            }
            if ((_linkOpts & HLINK_TARGET_FRAME) != 0)
            {
                int len = in1.ReadInt();
                _targetFrame = in1.ReadUnicodeLEString(len);
            }
            if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) != 0)
            {
                _moniker = null;
                int nChars = in1.ReadInt();
                _address = in1.ReadUnicodeLEString(nChars);
            }
            if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) == 0)
            {
                _moniker = new GUID(in1);

                if (URL_MONIKER.Equals(_moniker))
                {
                    int length = in1.ReadInt();

                    /**
                     * The value of <code>length<code> be either the byte size of the url field
                     * (including the terminating NULL character) or the byte size of the url field plus 24.
                     * If the value of this field is set to the byte size of the url field,
                     * then the tail bytes fields are not present.
                     */
                    int remaining = in1.Remaining;
                    if (length == remaining)
                    {
                        int nChars = length / 2;
                        _address = in1.ReadUnicodeLEString(nChars);
                    }
                    else
                    {
                        int nChars = (length - TAIL_SIZE) / 2;
                        _address = in1.ReadUnicodeLEString(nChars);

                        /**
                         * TODO: make sense of the remaining bytes
                         * According to the spec they consist of:
                         * 1. 16-byte  GUID: This field MUST equal
                         *    {0xF4815879, 0x1D3B, 0x487F, 0xAF, 0x2C, 0x82, 0x5D, 0xC4, 0x85, 0x27, 0x63}
                         * 2. Serial version, this field MUST equal 0 if present.
                         * 3. URI Flags
                         */
                        _uninterpretedTail = ReadTail(URL_uninterpretedTail, in1);
                    }
                }
                else if (FILE_MONIKER.Equals(_moniker))
                {
                    _fileOpts = in1.ReadShort();

                    int len = in1.ReadInt();
                    _shortFilename     = StringUtil.ReadCompressedUnicode(in1, len);
                    _uninterpretedTail = ReadTail(FILE_uninterpretedTail, in1);
                    int size = in1.ReadInt();
                    if (size > 0)
                    {
                        int charDataSize = in1.ReadInt();

                        //From the spec: An optional unsigned integer that MUST be 3 if present
                        int optFlags = in1.ReadUShort();
                        if (optFlags != 0x0003)
                        {
                            throw new RecordFormatException("Expected 0x3 but found " + optFlags);
                        }
                        _address = StringUtil.ReadUnicodeLE(in1, charDataSize / 2);
                    }
                    else
                    {
                        _address = null;
                    }
                }
                else if (STD_MONIKER.Equals(_moniker))
                {
                    _fileOpts = in1.ReadShort();

                    int len = in1.ReadInt();

                    byte[] path_bytes = new byte[len];
                    in1.ReadFully(path_bytes);

                    _address = Encoding.UTF8.GetString(path_bytes);
                }
            }

            if ((_linkOpts & HLINK_PLACE) != 0)
            {
                int len = in1.ReadInt();
                _textMark = in1.ReadUnicodeLEString(len);
            }

            if (in1.Remaining > 0)
            {
                Console.WriteLine(HexDump.ToHex(in1.ReadRemainder()));
            }
        }
Example #53
0
 /**
  * @param in the RecordInputstream to Read the record from
  */
 public HorizontalPageBreakRecord(RecordInputStream in1)
     : base(in1)
 {
 }
        /**
         * Constructs a CalcCountRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         *
         */

        public CalcCountRecord(RecordInputStream in1)
        {
            field_1_iterations = in1.ReadShort();
        }
Example #55
0
 public PrintSizeRecord(RecordInputStream in1)
 {
     printSize = in1.ReadShort();
 }
Example #56
0
 public Excel9FileRecord(RecordInputStream in1)
 {
 }
Example #57
0
 /**
  * Constructs a BottomMargin record and Sets its fields appropriately.
  *
  * @param in the RecordInputstream to Read the record from
  */
 public BottomMarginRecord(RecordInputStream in1)
 {
     field_1_margin = in1.ReadDouble();
 }
        public CFRule12Record(RecordInputStream in1)
        {
            futureHeader        = new FtrHeader(in1);
            ConditionType       = ((byte)in1.ReadByte());
            ComparisonOperation = ((byte)in1.ReadByte());
            int field_3_formula1_len = in1.ReadUShort();
            int field_4_formula2_len = in1.ReadUShort();

            ext_formatting_length = in1.ReadInt();
            ext_formatting_data   = new byte[0];
            if (ext_formatting_length == 0)
            {
                // 2 bytes reserved
                in1.ReadUShort();
            }
            else
            {
                int len = ReadFormatOptions(in1);
                if (len < ext_formatting_length)
                {
                    ext_formatting_data = new byte[ext_formatting_length - len];
                    in1.ReadFully(ext_formatting_data);
                }
            }

            Formula1 = (Formula.Read(field_3_formula1_len, in1));
            Formula2 = (Formula.Read(field_4_formula2_len, in1));

            int formula_scale_len = in1.ReadUShort();

            formula_scale = Formula.Read(formula_scale_len, in1);

            ext_opts              = (byte)in1.ReadByte();
            priority              = in1.ReadUShort();
            template_type         = in1.ReadUShort();
            template_param_length = (byte)in1.ReadByte();
            if (template_param_length == 0 || template_param_length == 16)
            {
                template_params = new byte[template_param_length];
                in1.ReadFully(template_params);
            }
            else
            {
                //logger.Log(POILogger.WARN, "CF Rule v12 template params length should be 0 or 16, found " + template_param_length);
                in1.ReadRemainder();
            }

            byte type = ConditionType;

            if (type == CONDITION_TYPE_COLOR_SCALE)
            {
                color_gradient = new ColorGradientFormatting(in1);
            }
            else if (type == CONDITION_TYPE_DATA_BAR)
            {
                data_bar = new DataBarFormatting(in1);
            }
            else if (type == CONDITION_TYPE_FILTER)
            {
                filter_data = in1.ReadRemainder();
            }
            else if (type == CONDITION_TYPE_ICON_SET)
            {
                multistate = new IconMultiStateFormatting(in1);
            }
        }
        /**
         * Constructs an Codepage record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public InterfaceHdrRecord(RecordInputStream in1)
        {
            field_1_codepage = in1.ReadShort();
        }
Example #60
0
 /**
  * @param in the RecordInputstream to Read the record from
  */
 public RefSubRecord(RecordInputStream in1)
     : this(in1.ReadShort(), in1.ReadShort(), in1.ReadShort())
 {
 }