示例#1
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;
            }
        }
示例#2
0
文件: EOFRecord.cs 项目: zhgl7688/-
        /**
         * Constructs a EOFRecord record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public EOFRecord(RecordInputStream in1)
        {
        }
示例#3
0
文件: CellRecord.cs 项目: zhgl7688/-
 protected CellRecord(RecordInputStream in1)
 {
     _rowIndex    = in1.ReadUShort();
     _columnIndex = in1.ReadUShort();
     _formatIndex = in1.ReadUShort();
 }
示例#4
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();
 }
示例#5
0
文件: RKRecord.cs 项目: zhgl7688/-
        /**
         * Constructs a RK record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RKRecord(RecordInputStream in1)
            : base(in1)
        {
            field_4_rk_number = in1.ReadInt();
        }
示例#6
0
 /**
  * construct a HeaderFooterRecord 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 HeaderFooterRecord(RecordInputStream in1)
 {
     _rawData = in1.ReadRemainder();
 }
示例#7
0
 /**
  * @param in the RecordInputstream to Read the record from
  */
 public VerticalPageBreakRecord(RecordInputStream in1)
     : base(in1)
 {
 }
示例#8
0
文件: DeltaRecord.cs 项目: zhgl7688/-
        /**
         * Constructs a Delta record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public DeltaRecord(RecordInputStream in1)
        {
            field_1_max_change = in1.ReadDouble();
        }
示例#9
0
        /**
         * Constructs an Header record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public HeaderRecord(RecordInputStream in1) : base(in1)
        {
        }
示例#10
0
 public DrawingRecord(RecordInputStream in1)
 {
     recordData = in1.ReadRemainder();
 }
示例#11
0
 public DrawingGroupRecord(RecordInputStream in1)
     : base(in1)
 {
 }
示例#12
0
        /**
         * Constructs a BackupRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public BackupRecord(RecordInputStream in1)
        {
            field_1_backup = in1.ReadShort();
        }
示例#13
0
        /**
         * Constructs a PasswordRev4 (PROT4REVPASS) record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public PasswordRev4Record(RecordInputStream in1)
        {
            field_1_password = in1.ReadShort();
        }
示例#14
0
        /**
         * Constructs a Protect record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public ObjectProtectRecord(RecordInputStream in1)
        {
            field_1_protect = in1.ReadShort();
        }
示例#15
0
        /**
         * Constructs a VCENTER record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public VCenterRecord(RecordInputStream in1)
        {
            field_1_vcenter = in1.ReadShort();
        }
示例#16
0
        /**
         * Constructs an HideObj record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public HideObjRecord(RecordInputStream in1)
        {
            field_1_hide_obj = in1.ReadShort();
        }
示例#17
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();
        }
示例#18
0
        /**
         * Constructs an SaveRecalc record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public SaveRecalcRecord(RecordInputStream in1)
        {
            field_1_recalc = in1.ReadShort();
        }
示例#19
0
        /**
         * Constructs a CountryRecord and Sets its fields appropriately
         * @param in the RecordInputstream to Read the record from
         */

        public CountryRecord(RecordInputStream in1)
        {
            field_1_default_country = in1.ReadShort();
            field_2_current_country = in1.ReadShort();
        }
示例#20
0
        /**
         * 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()));
            }
        }
示例#21
0
 /**
  * Constructs a Units record and Sets its fields appropriately.
  *
  * @param in the RecordInputstream to Read the record from
  */
 public UnitsRecord(RecordInputStream in1)
 {
     field_1_units = in1.ReadShort();
 }
示例#22
0
 private static byte[] Read(RecordInputStream in1, int size)
 {
     byte[] result = new byte[size];
     in1.ReadFully(result);
     return(result);
 }
示例#23
0
文件: DVRecord.cs 项目: zhgl7688/-
 private static UnicodeString ReadUnicodeString(RecordInputStream in1)
 {
     return(new UnicodeString(in1));
 }
示例#24
0
 private RkRec(RecordInputStream in1)
 {
     xf = in1.ReadShort();
     rk = in1.ReadInt();
 }
示例#25
0
文件: DSFRecord.cs 项目: zhgl7688/-
        /**
         * Constructs a DBCellRecord and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public DSFRecord(RecordInputStream in1) : this(in1.ReadShort())
        {
        }
示例#26
0
        /**
         * Constructs a RefreshAll record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public RefreshAllRecord(RecordInputStream in1)
            : this(in1.ReadUShort())
        {
        }
示例#27
0
        public TextObjectRecord(RecordInputStream in1)
        {
            field_1_options         = in1.ReadUShort();
            field_2_textOrientation = in1.ReadUShort();
            field_3_reserved4       = in1.ReadUShort();
            field_4_reserved5       = in1.ReadUShort();
            field_5_reserved6       = in1.ReadUShort();
            int field_6_textLength           = in1.ReadUShort();
            int field_7_formattingDataLength = in1.ReadUShort();

            field_8_reserved7 = in1.ReadInt();

            if (in1.Remaining > 0)
            {
                // Text Objects can have simple reference formulas
                // (This bit not mentioned in the MS document)
                if (in1.Remaining < 11)
                {
                    throw new RecordFormatException("Not enough remaining data for a link formula");
                }
                int formulaSize = in1.ReadUShort();
                _unknownPreFormulaInt = in1.ReadInt();
                Ptg[] ptgs = Ptg.ReadTokens(formulaSize, in1);
                if (ptgs.Length != 1)
                {
                    throw new RecordFormatException("Read " + ptgs.Length
                                                    + " tokens but expected exactly 1");
                }
                _linkRefPtg = (OperandPtg)ptgs[0];
                if (in1.Remaining > 0)
                {
                    _unknownPostFormulaByte = (byte)in1.ReadByte();
                }
                else
                {
                    _unknownPostFormulaByte = null;
                }
            }
            else
            {
                _linkRefPtg = null;
            }
            if (in1.Remaining > 0)
            {
                throw new RecordFormatException("Unused " + in1.Remaining + " bytes at end of record");
            }

            String text;

            if (field_6_textLength > 0)
            {
                text = ReadRawString(in1, field_6_textLength);
            }
            else
            {
                text = "";
            }
            _text = new HSSFRichTextString(text);

            if (field_7_formattingDataLength > 0)
            {
                ProcessFontRuns(in1, _text, field_7_formattingDataLength);
            }
        }
示例#28
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();
        }
示例#29
0
 /**
  * Constructs a RightMargin record and Sets its fields appropriately.     *     * @param id    id must be 0x27 or an exception     *              will be throw upon validation     * @param size  size the size of the data area of the record     * @param data  data of the record (should not contain sid/len)
  */
 public RightMarginRecord(RecordInputStream in1)
 {
     field_1_margin = in1.ReadDouble();
 }
示例#30
0
 public DrawingSelectionRecord(RecordInputStream in1)
     : base(in1)
 {
 }