Ejemplo n.º 1
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
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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());
            }
        }
Ejemplo n.º 4
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()));
            }
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
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()));
            }
        }
Ejemplo n.º 8
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
        }
Ejemplo n.º 9
0
        /**
         * Constructs a WSBool record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WSBoolRecord(RecordInputStream in1)
        {
            byte[] data = in1.ReadRemainder();
            field_1_wsbool =
                data[0];
            field_2_wsbool =
                data[1];
        }
        /**
         * Constructs a WSBool record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WSBoolRecord(RecordInputStream in1)
        {
            byte[] data = in1.ReadRemainder();
            field_1_wsbool =
                data[1]; // backwards because theoretically this is one short field
            field_2_wsbool =
                data[0]; // but it was easier to implement it this way to avoid confusion
        }
Ejemplo n.º 11
0
 /**
  * Constructs a WSBool record and Sets its fields appropriately.
  * @param in the RecordInputstream to Read the record from
  */
 public WSBoolRecord(RecordInputStream in1)
 {
     byte[] data = in1.ReadRemainder();
     field_1_wsbool =
     data[ 0 ];
     field_2_wsbool =
     data[ 1 ];
 }
Ejemplo n.º 12
0
        public FeatProtection(RecordInputStream in1)
        {
            fSD = in1.ReadInt();
            passwordVerifier = in1.ReadInt();

            title = StringUtil.ReadUnicodeString(in1);

            securityDescriptor = in1.ReadRemainder();
        }
Ejemplo n.º 13
0
        /**
         * Constructs a WSBool record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WSBoolRecord(RecordInputStream in1)
        {
        byte[] data = in1.ReadRemainder();
        field_1_wsbool =
            data[ 1 ];   // backwards because theoretically this Is one short field
        field_2_wsbool =
            data[ 0 ];   // but it was easier to implement it this way to avoid confusion
                           // because the dev kit shows the masks for it as 2 byte fields
        }
Ejemplo n.º 14
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.ReadShort();
     field_3_flags = in1.ReadShort();
     field_4_shapeid = in1.ReadShort();
     int Length = in1.ReadShort();
     byte[] bytes = in1.ReadRemainder();
     field_5_author = Encoding.UTF8.GetString(bytes, 1, Length);
 }
Ejemplo n.º 15
0
        public FeatHdrRecord(RecordInputStream in1)
        {
            futureHeader = new FtrHeader(in1);

            isf_sharedFeatureType = in1.ReadShort();
            reserved  = (byte)in1.ReadByte();
            cbHdrData = in1.ReadInt();
            // Don't process this just yet, need the BOFRecord
            rgbHdrData = in1.ReadRemainder();
        }
Ejemplo n.º 16
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.ReadShort();
            field_3_flags   = in1.ReadShort();
            field_4_shapeid = in1.ReadShort();
            int Length = in1.ReadShort();

            byte[] bytes = in1.ReadRemainder();
            field_5_author = Encoding.UTF8.GetString(bytes, 1, Length);
        }
Ejemplo n.º 17
0
        /**
         * Constructs a WriteAccess record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WriteAccessRecord(RecordInputStream in1)
        {
            byte[] data = in1.ReadRemainder();
            //The string Is always 112 Chars (pAdded with spaces), therefore
            //this record can not be continued.

            //What a wierd record, it Is not really a Unicode string because the
            //header doesnt provide a correct size indication.???
            //But the header Is present, so we need to skip over it.
            //Odd, Odd, Odd ;-)
            field_1_username = StringUtil.GetFromCompressedUnicode(data, 3, data.Length - 3);
        }
Ejemplo n.º 18
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();

            //if (false && GetBiffName(_sid) == null)
            //{
            //    // unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
            //    // those sids are in a different number space.
            //    // TODO - put unknown OBJ sub-records in a different class
            //    System.Console.WriteLine("Unknown record 0x" + _sid.ToString("X"));
            //}
        }
Ejemplo n.º 19
0
        /**
         * Constructs a WriteAccess record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public WriteAccessRecord(RecordInputStream in1)
        {
            byte[] data = in1.ReadRemainder();
            //The string Is always 112 Chars (pAdded with spaces), therefore
            //this record can not be continued.

            //What a wierd record, it Is not really a Unicode string because the
            //header doesnt provide a correct size indication.???
            //But the header Is present, so we need to skip over it.
            //Odd, Odd, Odd ;-)
            field_1_username = StringUtil.GetFromCompressedUnicode(data, 3, data.Length - 3);

        }
 /**
  * Constructs a Bar record and Sets its fields appropriately.
  *
  * @param in the RecordInputstream to Read the record from
  */
 public AbstractEscherHolderRecord(RecordInputStream in1)
 {
     escherRecords = new ArrayList();
     if (!DESERIALISE)
     {
         rawData = in1.ReadRemainder();
     }
     else
     {
         byte[] data = in1.ReadAllContinuedRemainder();
         ConvertToEscherRecords(0, data.Length, data);
     }
 }
Ejemplo n.º 21
0
 /**
  * Constructs a Bar record and Sets its fields appropriately.
  *
  * @param in the RecordInputstream to Read the record from
  */
 public AbstractEscherHolderRecord(RecordInputStream in1)
 {
     escherRecords = new ArrayList();
     if (!DESERIALISE)
     {
         rawData = in1.ReadRemainder();
     }
     else
     {
         byte[] data = in1.ReadAllContinuedRemainder();
         ConvertToEscherRecords(0, data.Length, data);
     }
 }
Ejemplo n.º 22
0
 /**
  * Constructs a String record and Sets its fields appropriately.
  *
  * @param in the RecordInputstream to Read the record from
  */
 public StringRecord(RecordInputStream in1)
 {
     int field_1_string_Length = in1.ReadShort();
     field_2_unicode_flag = in1.ReadByte() != 0x00;
     byte[] data = in1.ReadRemainder();
     //Why Isnt this using the in1.ReadString methods???
     if (field_2_unicode_flag)
     {
         field_3_string = StringUtil.GetFromUnicodeLE(data, 0, field_1_string_Length);
     }
     else
     {
         field_3_string = StringUtil.GetFromCompressedUnicode(data, 0, field_1_string_Length);
     }
 }
Ejemplo n.º 23
0
        /**
         * Constructs a String record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */
        public StringRecord(RecordInputStream in1)
        {
            int field_1_string_Length = in1.ReadShort();

            field_2_unicode_flag = in1.ReadByte() != 0x00;
            byte[] data = in1.ReadRemainder();
            //Why Isnt this using the in1.ReadString methods???
            if (field_2_unicode_flag)
            {
                field_3_string = StringUtil.GetFromUnicodeLE(data, 0, field_1_string_Length);
            }
            else
            {
                field_3_string = StringUtil.GetFromCompressedUnicode(data, 0, field_1_string_Length);
            }
        }
Ejemplo n.º 24
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldLabelRecord(RecordInputStream in1)
            : base(in1, in1.Sid == biff2_sid)
        {
            if (IsBiff2)
            {
                field_4_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_4_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_5_bytes = new byte[field_4_string_len];
            in1.Read(field_5_bytes, 0, field_4_string_len);

            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO,
                        "LabelRecord data remains: " + in1.Remaining +
                        " : " + HexDump.ToHex(in1.ReadRemainder())
                        );
            }
        }
Ejemplo n.º 25
0
        /**
         * @param in the RecordInputstream to read the record from
         */
        public OldLabelRecord(RecordInputStream in1)
            : base(in1, in1.Sid == biff2_sid)
        {
            if (IsBiff2)
            {
                field_4_string_len = (short)in1.ReadUByte();
            }
            else
            {
                field_4_string_len = in1.ReadShort();
            }

            // Can only decode properly later when you know the codepage
            field_5_bytes = new byte[field_4_string_len];
            in1.Read(field_5_bytes, 0, field_4_string_len);

            if (in1.Remaining > 0)
            {
                logger.Log(POILogger.INFO,
                           "LabelRecord data remains: " + in1.Remaining +
                           " : " + HexDump.ToHex(in1.ReadRemainder())
                           );
            }
        }
Ejemplo n.º 26
0
 public RowDataRecord(RecordInputStream in1)
 {
     _rawData = in1.ReadRemainder();
 }
Ejemplo n.º 27
0
 public RowDataRecord(RecordInputStream in1)
 {
     _rawData = in1.ReadRemainder();
 }
Ejemplo n.º 28
0
 public DrawingRecord(RecordInputStream in1)
 {
     recordData = in1.ReadRemainder();
 }
Ejemplo n.º 29
0
 public DrawingRecord(RecordInputStream in1)
 {
     recordData = in1.ReadRemainder();
 }
Ejemplo n.º 30
0
        public FeatHdrRecord(RecordInputStream in1)
        {
            futureHeader = new FtrHeader(in1);

            isf_sharedFeatureType = in1.ReadShort();
            reserved = (byte)in1.ReadByte();
            cbHdrData = in1.ReadInt();
            // Don't process this just yet, need the BOFRecord
            rgbHdrData = in1.ReadRemainder();
        }
        /**
         * Constructs an EmbeddedObjectRef record and Sets its fields appropriately.
         *
         * @param in the record input stream.
         */
        public EmbeddedObjectRefSubRecord(RecordInputStream in1)
        {
            // Much guess-work going on here due to lack of any documentation.
            // See similar source code in OOO:
            // http://lxr.go-oo.org/source/sc/sc/source/filter/excel/xiescher.cxx
            // 1223 void XclImpOleObj::ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nRecSize )

            int streamIdOffset = in1.ReadShort(); // OOO calls this 'nFmlaLen'

            int dataLenAfterFormula = in1.Remaining - streamIdOffset;
            int formulaSize = in1.ReadUShort();

            field_1_unknown_int = in1.ReadInt();
            byte[] formulaRawBytes = ReadRawData(in1, formulaSize);
            field_2_refPtg = ReadRefPtg(formulaRawBytes);
            if (field_2_refPtg == null)
            {
                // common case
                // field_2_n16 seems to be 5 here
                // The formula almost looks like tTbl but the row/column values seem like garbage.
                field_2_unknownFormulaData = formulaRawBytes;
            }
            else
            {
                field_2_unknownFormulaData = null;
            }


            int stringByteCount;
            if (in1.Remaining >= dataLenAfterFormula + 3)
            {
                int tag = in1.ReadByte();
                if (tag != 0x03)
                {
                    throw new RecordFormatException("Expected byte 0x03 here");
                }
                int nChars = in1.ReadUShort();
                if (nChars > 0)
                {
                    // OOO: the 4th way Xcl stores a unicode string: not even a Grbit byte present if Length 0
                    field_3_unicode_flag = (in1.ReadByte() & 0x01) != 0;
                    if (field_3_unicode_flag)
                    {
                        field_4_ole_classname = in1.ReadUnicodeLEString(nChars);
                        stringByteCount = nChars * 2;
                    }
                    else
                    {
                        field_4_ole_classname = in1.ReadCompressedUnicode(nChars);
                        stringByteCount = nChars;
                    }
                }
                else
                {
                    field_4_ole_classname = "";
                    stringByteCount = 0;
                }
            }
            else
            {
                field_4_ole_classname = null;
                stringByteCount = 0;
            }
            // Pad to next 2-byte boundary
            if (((stringByteCount + formulaSize) % 2) != 0)
            {
                int b = in1.ReadByte();
                if (field_2_refPtg != null && field_4_ole_classname == null)
                {
                    field_4_unknownByte = (byte)b;
                }
            }
            int nUnexpectedPadding = in1.Remaining - dataLenAfterFormula;

            if (nUnexpectedPadding > 0)
            {
                Console.WriteLine("Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
                ReadRawData(in1, nUnexpectedPadding);
            }

            // Fetch the stream ID
            if (dataLenAfterFormula >= 4)
            {
                field_5_stream_id = in1.ReadInt();
            }
            else
            {
                field_5_stream_id = null;
            }

            field_6_unknown = in1.ReadRemainder();
        }
Ejemplo n.º 32
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();
 }
Ejemplo n.º 33
0
 public FeatSmartTag(RecordInputStream in1)
 {
     data = in1.ReadRemainder();
 }
Ejemplo n.º 34
0
        /**
         * Constructs a Group marker record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public GroupMarkerSubRecord(RecordInputStream in1)
        {

            reserved = in1.ReadRemainder();
        }
Ejemplo n.º 35
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();

            //if (false && GetBiffName(_sid) == null)
            //{
            //    // unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
            //    // those sids are in a different number space.
            //    // TODO - put unknown OBJ sub-records in a different class
            //    System.Console.WriteLine("Unknown record 0x" + _sid.ToString("X"));
            //}
        }
Ejemplo n.º 36
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();

        }
Ejemplo n.º 37
0
        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);
            }
        }
Ejemplo n.º 38
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
                        // but some files has 4
                        int usKeyValue = in1.ReadUShort();
                        _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()));
            }
        }
Ejemplo n.º 39
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();
 }
Ejemplo n.º 40
0
        /**
         * Constructs a NoteStructureSubRecord and Sets its fields appropriately.
         *
         */
        public NoteStructureSubRecord(RecordInputStream in1)
        {
            //just grab the raw data
            reserved = in1.ReadRemainder();

        }
Ejemplo n.º 41
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>();
            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;
        }
Ejemplo n.º 42
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();
        }
Ejemplo n.º 43
0
 /**
  * construct an UserSViewBegin 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 UserSViewBegin(RecordInputStream in1)
 {
     _rawData = in1.ReadRemainder();
 }
Ejemplo n.º 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>();
            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;
        }
Ejemplo n.º 45
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();
 }
Ejemplo n.º 46
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()));
            }
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 48
0
        /**
         * Read hyperlink from input stream
         *
         * @param in the stream to Read from
         */
        public HyperlinkRecord(RecordInputStream in1)
        {
            try
            {
                rwFirst = in1.ReadShort();
                rwLast = in1.ReadUShort();
                colFirst = in1.ReadShort();
                colLast = in1.ReadShort();

                // 16-byte GUID
                guid = new byte[16];
                in1.Read(guid, 0, guid.Length);

                label_opts = in1.ReadInt();
                link_opts = in1.ReadInt();

                if ((link_opts & HLINK_LABEL) != 0)
                {
                    int label_len = in1.ReadInt();
                    label = in1.ReadUnicodeLEString(label_len);
                }

                if ((link_opts & HLINK_URL) != 0)
                {
                    moniker = new byte[16];
                    in1.Read(moniker, 0, moniker.Length);

                    if (Arrays.Equals(URL_MONIKER, moniker))
                    {
                        int len = in1.ReadInt();

                        address = in1.ReadUnicodeLEString( (len - URL_TAIL.Length)/2);  //minus the length of tail

                        tail = in1.ReadRemainder();
                    }
                    else if (Arrays.Equals(FILE_MONIKER, moniker))
                    {
                        file_opts = in1.ReadShort();

                        int len = in1.ReadInt();

                        byte[] path_bytes = new byte[len];
                        in1.Read(path_bytes, 0, path_bytes.Length);

                        address = Encoding.UTF8.GetString(path_bytes);

                        tail = in1.ReadRemainder();
                    }
                }
                else if ((link_opts & HLINK_PLACE) != 0)
                {
                    int len = in1.ReadInt();
                    address = in1.ReadUnicodeLEString(len);
                }
            }
            catch (IOException)
            {
                throw;
            }

        }