/** This method will Read a byte from the current record*/

        public int Read()
        {
            CheckRecordPosition(LittleEndianConsts.BYTE_SIZE);
            _currentDataOffset += LittleEndianConsts.BYTE_SIZE;
            pos += LittleEndianConsts.BYTE_SIZE;
            return(_dataInput.ReadByte());
        }
Beispiel #2
0
        /**
         * @param ris the RecordInputstream to read the record from
         */
        public NameCommentRecord(RecordInputStream ris)
        {
            ILittleEndianInput in1 = ris;

            field_1_record_type       = in1.ReadShort();
            field_2_frt_cell_ref_flag = in1.ReadShort();
            field_3_reserved          = in1.ReadLong();
            int field_4_name_length    = in1.ReadShort();
            int field_5_comment_length = in1.ReadShort();

            if (in1.ReadByte() == 0)
            {
                field_6_name_text = StringUtil.ReadCompressedUnicode(in1, field_4_name_length);
            }
            else
            {
                field_6_name_text = StringUtil.ReadUnicodeLE(in1, field_4_name_length);
            }
            if (in1.ReadByte() == 0)
            {
                field_7_comment_text = StringUtil.ReadCompressedUnicode(in1, field_5_comment_length);
            }
            else
            {
                field_7_comment_text = StringUtil.ReadUnicodeLE(in1, field_5_comment_length);
            }
        }
Beispiel #3
0
        public ColorGradientFormatting(ILittleEndianInput in1)
        {
            in1.ReadShort(); // Ignored
            in1.ReadByte();  // Reserved
            int numI = in1.ReadByte();
            int numG = in1.ReadByte();

            if (numI != numG)
            {
                //log.Log(POILogger.WARN, "Inconsistent Color Gradient defintion, found " + numI + " vs " + numG + " entries");
            }
            options = (byte)in1.ReadByte();

            thresholds = new ColorGradientThreshold[numI];
            for (int i = 0; i < thresholds.Length; i++)
            {
                thresholds[i] = new ColorGradientThreshold(in1);
            }
            colors = new ExtendedColor[numG];
            for (int i = 0; i < colors.Length; i++)
            {
                in1.ReadDouble(); // Slightly pointless step counter
                colors[i] = new ExtendedColor(in1);
            }
        }
Beispiel #4
0
        private static object ReadAConstantValue(ILittleEndianInput in1)
        {
            byte grbit = (byte)in1.ReadByte();

            switch (grbit)
            {
            case TYPE_EMPTY:
                in1.ReadLong();     // 8 byte 'not used' field
                return(EMPTY_REPRESENTATION);

            case TYPE_NUMBER:
                return(in1.ReadDouble());

            case TYPE_STRING:
                return(StringUtil.ReadUnicodeString(in1));

            case TYPE_BOOLEAN:
                return(ReadBoolean(in1));

            case TYPE_ERROR_CODE:
                int errCode = in1.ReadUShort();
                // next 6 bytes are Unused
                in1.ReadUShort();
                in1.ReadInt();
                return(ErrorConstant.ValueOf(errCode));
            }
            throw new Exception("Unknown grbit value (" + grbit + ")");
        }
Beispiel #5
0
 /** Creates new Ico Multi-State Threshold */
 public IconMultiStateThreshold(ILittleEndianInput in1)
     : base(in1)
 {
     equals = (byte)in1.ReadByte();
     // Reserved, 4 bytes, all 0
     in1.ReadInt();
 }
Beispiel #6
0
        public static Ptg CreatePtg(ILittleEndianInput in1)
        {
            byte id = (byte)in1.ReadByte();

            if (id < 0x20)
            {
                return(CreateBasePtg(id, in1));
            }

            Ptg retval = CreateClassifiedPtg(id, in1);

            if (id >= 0x60)
            {
                retval.PtgClass = CLASS_ARRAY;
            }
            else if (id >= 0x40)
            {
                retval.PtgClass = CLASS_VALUE;
            }
            else
            {
                retval.PtgClass = CLASS_REF;
            }

            return(retval);
        }
Beispiel #7
0
        public static String ReadUtf8LPP4(ILittleEndianInput is1)
        {
            int length = is1.ReadInt();

            if (length == 0 || length == 4)
            {
                //@SuppressWarnings("unused")
                int skip = is1.ReadInt(); // ignore
                return(length == 0 ? null : "");
            }

            byte[] data = new byte[length];
            is1.ReadFully(data);

            // Padding (variable): A set of bytes that MUST be of correct size such that the size of the UTF-8-LP-P4
            // structure is a multiple of 4 bytes. If PAdding is present, each byte MUST be 0x00. If
            // the length is exactly 0x00000000, this specifies a null string, and the entire structure uses
            // exactly 4 bytes. If the length is exactly 0x00000004, this specifies an empty string, and the
            // entire structure also uses exactly 4 bytes
            int scratchedBytes = length % 4;

            if (scratchedBytes > 0)
            {
                for (int i = 0; i < (4 - scratchedBytes); i++)
                {
                    is1.ReadByte();
                }
            }

            return(Encoding.UTF8.GetString(data, 0, data.Length));
            //return new String(data, 0, data.length, Charset.forName("UTF-8"));
        }
Beispiel #8
0
        /**
         * InputStream <c>in</c> is expected to contain:
         * <ol>
         * <li>byte is16BitFlag</li>
         * <li>byte[]/char[] characterData</li>
         * </ol>
         * For this encoding, the is16BitFlag is always present even if nChars==0.
         * <br/>
         * This method should be used when the nChars field is <em>not</em> stored
         * as a ushort immediately before the is16BitFlag. Otherwise, {@link
         * #readUnicodeString(LittleEndianInput)} can be used.
         */
        public static String ReadUnicodeString(ILittleEndianInput in1, int nChars)
        {
            byte is16Bit = (byte)in1.ReadByte();

            if ((is16Bit & 0x01) == 0)
            {
                return(ReadCompressedUnicode(in1, nChars));
            }
            return(ReadUnicodeLE(in1, nChars));
        }
        public IconMultiStateFormatting(ILittleEndianInput in1)
        {
            in1.ReadShort(); // Ignored
            in1.ReadByte();  // Reserved
            int num = in1.ReadByte();
            int set = in1.ReadByte();

            iconSet = IconSet.ById(set);
            if (iconSet.num != num)
            {
                //log.Log(POILogger.WARN, "Inconsistent Icon Set defintion, found " + iconSet + " but defined as " + num + " entries");
            }
            options = (byte)in1.ReadByte();

            thresholds = new Threshold[iconSet.num];
            for (int i = 0; i < thresholds.Length; i++)
            {
                thresholds[i] = new IconMultiStateThreshold(in1);
            }
        }
Beispiel #10
0
        /**
         * InputStream <c>in</c> is expected to contain:
         * <ol>
         * <li>ushort nChars</li>
         * <li>byte is16BitFlag</li>
         * <li>byte[]/char[] characterData</li>
         * </ol>
         * For this encoding, the is16BitFlag is always present even if nChars==0.
         */
        public static String ReadUnicodeString(ILittleEndianInput in1)
        {
            int  nChars = in1.ReadUShort();
            byte flag   = (byte)in1.ReadByte();

            if ((flag & 0x01) == 0)
            {
                return(ReadCompressedUnicode(in1, nChars));
            }
            return(ReadUnicodeLE(in1, nChars));
        }
Beispiel #11
0
 public LbsDropData(ILittleEndianInput in1)
 {
     _wStyle = in1.ReadUShort();
     _cLine  = in1.ReadUShort();
     _dxMin  = in1.ReadUShort();
     _str    = StringUtil.ReadUnicodeString(in1);
     if (StringUtil.GetEncodedSize(_str) % 2 != 0)
     {
         _unused = (byte)in1.ReadByte();
     }
 }
Beispiel #12
0
        /** Create a StringPtg from a stream */
        public StringPtg(ILittleEndianInput in1)
        {
            int field_1_length = in1.ReadUByte();
			field_2_options = (byte)in1.ReadByte();
            _is16bitUnicode = (field_2_options & 0x01) != 0;
            if (_is16bitUnicode)
            {
                field_3_string = StringUtil.ReadUnicodeLE(in1, field_1_length);
            }
            else
            {
                field_3_string = StringUtil.ReadCompressedUnicode(in1, field_1_length);
            }
        }
Beispiel #13
0
        /** Create a StringPtg from a stream */
        public StringPtg(ILittleEndianInput in1)
        {
            int field_1_length = in1.ReadUByte();

            field_2_options = (byte)in1.ReadByte();
            _is16bitUnicode = (field_2_options & 0x01) != 0;
            if (_is16bitUnicode)
            {
                field_3_string = StringUtil.ReadUnicodeLE(in1, field_1_length);
            }
            else
            {
                field_3_string = StringUtil.ReadCompressedUnicode(in1, field_1_length);
            }
        }
Beispiel #14
0
        public DataBarFormatting(ILittleEndianInput in1)
        {
            in1.ReadShort(); // Ignored
            in1.ReadByte();  // Reserved
            options = (byte)in1.ReadByte();

            percentMin = (byte)in1.ReadByte();
            percentMax = (byte)in1.ReadByte();
            if (percentMin < 0 || percentMin > 100)
            {
                //log.Log(POILogger.WARN, "Inconsistent Minimum Percentage found " + percentMin);
                Console.WriteLine("Inconsistent Minimum Percentage found " + percentMin);
            }

            if (percentMax < 0 || percentMax > 100)
            {
                //log.Log(POILogger.WARN, "Inconsistent Minimum Percentage found " + percentMin);
                Console.WriteLine("Inconsistent Minimum Percentage found " + percentMin);
            }

            color        = new ExtendedColor(in1);
            thresholdMin = new DataBarThreshold(in1);
            thresholdMax = new DataBarThreshold(in1);
        }
Beispiel #15
0
        /** Creates new Threshold */
        protected Threshold(ILittleEndianInput in1)
        {
            type = (byte)in1.ReadByte();
            short formulaLen = in1.ReadShort();

            if (formulaLen > 0)
            {
                formula = Formula.Read(formulaLen, in1);
            }
            else
            {
                formula = Formula.Create(null);
            }
            // Value is only there for non-formula, non min/max thresholds
            if (formulaLen == 0 && type != RangeType.MIN.id &&
                type != RangeType.MAX.id)
            {
                value = in1.ReadDouble();
            }
        }
Beispiel #16
0
 public AttrPtg(ILittleEndianInput in1)
 {
     field_1_options = (byte)in1.ReadByte();
     field_2_data    = in1.ReadShort();
     if (IsOptimizedChoose)
     {
         int   nCases    = field_2_data;
         int[] jumpTable = new int[nCases];
         for (int i = 0; i < jumpTable.Length; i++)
         {
             jumpTable[i] = in1.ReadUShort();
         }
         _jumpTable        = jumpTable;
         _chooseFuncOffset = in1.ReadUShort();
     }
     else
     {
         _jumpTable        = null;
         _chooseFuncOffset = -1;
     }
 }
Beispiel #17
0
        public AttrPtg(ILittleEndianInput in1)
        {
            field_1_options =(byte)in1.ReadByte();
            field_2_data = in1.ReadShort();
            if (IsOptimizedChoose)
            {
                int nCases = field_2_data;
                int[] jumpTable = new int[nCases];
                for (int i = 0; i < jumpTable.Length; i++)
                {
                    jumpTable[i] = in1.ReadUShort();
                }
                _jumpTable = jumpTable;
                _chooseFuncOffset = in1.ReadUShort();
            }
            else
            {
                _jumpTable = null;
                _chooseFuncOffset = -1;
            }

        }
Beispiel #18
0
 private static object ReadAConstantValue(ILittleEndianInput in1)
 {
     byte grbit = (byte)in1.ReadByte();
     switch (grbit)
     {
         case TYPE_EMPTY:
             in1.ReadLong(); // 8 byte 'not used' field
             return EMPTY_REPRESENTATION;
         case TYPE_NUMBER:
             return in1.ReadDouble();
         case TYPE_STRING:
             return StringUtil.ReadUnicodeString(in1);
         case TYPE_BOOLEAN:
             return ReadBoolean(in1);
         case TYPE_ERROR_CODE:
             int errCode = in1.ReadUShort();
             // next 6 bytes are Unused
             in1.ReadUShort();
             in1.ReadInt();
             return ErrorConstant.ValueOf(errCode);
     }
     throw new Exception("Unknown grbit value (" + grbit + ")");
 }
Beispiel #19
0
 /**Creates new function pointer from a byte array
  * usually called while reading an excel file.
  */
 public static FuncVarPtg Create(ILittleEndianInput in1)
 {
     return(Create(in1.ReadByte(), in1.ReadShort()));
 }
Beispiel #20
0
         /**Creates new function pointer from a byte array
  * usually called while reading an excel file.
  */
 public static FuncVarPtg Create(ILittleEndianInput in1)  {
     return Create(in1.ReadByte(), in1.ReadShort());
 }
Beispiel #21
0
        /**
         * @param in the stream to read data from
         * @param cbFContinued the seconf short in the record header
         * @param cmoOt the Containing Obj's {@link CommonObjectDataSubRecord#field_1_objectType}
         */
        public LbsDataSubRecord(ILittleEndianInput in1, int cbFContinued, int cmoOt)
        {
            _cbFContinued = cbFContinued;

            int encodedTokenLen = in1.ReadUShort();

            if (encodedTokenLen > 0)
            {
                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");
                }
                _linkPtg = ptgs[0];
                switch (encodedTokenLen - formulaSize - 6)
                {
                case 1:
                    _unknownPostFormulaByte = (byte)in1.ReadByte();
                    break;

                case 0:
                    _unknownPostFormulaByte = null;
                    break;

                default:
                    throw new RecordFormatException("Unexpected leftover bytes");
                }
            }

            _cLines = in1.ReadUShort();
            _iSel   = in1.ReadUShort();
            _flags  = in1.ReadUShort();
            _idEdit = in1.ReadUShort();

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This field MUST exist if and only if the Containing Obj?s cmo.ot is equal to 0x14.
            if (cmoOt == 0x14)
            {
                _dropData = new LbsDropData(in1);
            }

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This array MUST exist if and only if the fValidPlex flag (0x2) is set
            if ((_flags & 0x2) != 0)
            {
                _rgLines = new String[_cLines];
                for (int i = 0; i < _cLines; i++)
                {
                    _rgLines[i] = StringUtil.ReadUnicodeString(in1);
                }
            }

            // bits 5-6 in the _flags specify the type
            // of selection behavior this list control is expected to support

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This array MUST exist if and only if the wListType field is not equal to 0.
            if (((_flags >> 4) & 0x2) != 0)
            {
                _bsels = new bool[_cLines];
                for (int i = 0; i < _cLines; i++)
                {
                    _bsels[i] = in1.ReadByte() == 1;
                }
            }
        }
Beispiel #22
0
        /**
         * Constructs an EmbeddedObjectRef record and Sets its fields appropriately.
         *
         * @param in the record input stream.
         */
        public EmbeddedObjectRefSubRecord(ILittleEndianInput in1, int size)
        {
            // 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 remaining      = size - LittleEndianConsts.SHORT_SIZE;

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

            remaining          -= LittleEndianConsts.SHORT_SIZE;
            field_1_unknown_int = in1.ReadInt();
            remaining          -= LittleEndianConsts.INT_SIZE;
            byte[] formulaRawBytes = ReadRawData(in1, formulaSize);
            remaining     -= 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 (remaining >= dataLenAfterFormula + 3)
            {
                int tag = in1.ReadByte();
                stringByteCount = LittleEndianConsts.BYTE_SIZE;
                if (tag != 0x03)
                {
                    throw new RecordFormatException("Expected byte 0x03 here");
                }
                int nChars = in1.ReadUShort();
                stringByteCount += LittleEndianConsts.SHORT_SIZE;
                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;
                    stringByteCount     += LittleEndianConsts.BYTE_SIZE;
                    if (field_3_unicode_flag)
                    {
                        field_4_ole_classname = StringUtil.ReadUnicodeLE(in1, nChars);
                        stringByteCount      += nChars * 2;
                    }
                    else
                    {
                        field_4_ole_classname = StringUtil.ReadCompressedUnicode(in1, nChars);
                        stringByteCount      += nChars;
                    }
                }
                else
                {
                    field_4_ole_classname = "";
                }
            }
            else
            {
                field_4_ole_classname = null;
                stringByteCount       = 0;
            }
            remaining -= stringByteCount;
            // Pad to next 2-byte boundary
            if (((stringByteCount + formulaSize) % 2) != 0)
            {
                int b = in1.ReadByte();
                remaining -= LittleEndianConsts.BYTE_SIZE;
                if (field_2_refPtg != null && field_4_ole_classname == null)
                {
                    field_4_unknownByte = (byte)b;
                }
            }
            int nUnexpectedPadding = remaining - dataLenAfterFormula;

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

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

            field_6_unknown = ReadRawData(in1, remaining);
        }
Beispiel #23
0
 public BoolPtg(ILittleEndianInput in1)
 {
     field_1_value = (in1.ReadByte() == 1);
 }
Beispiel #24
0
            internal ExtRst(ILittleEndianInput in1, int expectedLength)
            {
                reserved = in1.ReadShort();

                // Old style detection (Reserved = 0xFF)
                if (reserved == -1)
                {
                    populateEmpty();
                    return;
                }

                // Spot corrupt records
                if (reserved != 1)
                {
                    _logger.Log(POILogger.WARN, "Warning - ExtRst has wrong magic marker, expecting 1 but found " + reserved + " - ignoring");
                    // Grab all the remaining data, and ignore it
                    for (int i = 0; i < expectedLength - 2; i++)
                    {
                        in1.ReadByte();
                    }
                    // And make us be empty
                    populateEmpty();
                    return;
                }

                // Carry on Reading in as normal
                short stringDataSize = in1.ReadShort();

                formattingFontIndex = in1.ReadShort();
                formattingOptions   = in1.ReadShort();

                // RPHSSub
                numberOfRuns = in1.ReadUShort();
                short length1 = in1.ReadShort();
                // No really. Someone Clearly forgot to read
                //  the docs on their datastructure...
                short length2 = in1.ReadShort();

                // And sometimes they write out garbage :(
                if (length1 == 0 && length2 > 0)
                {
                    length2 = 0;
                }
                if (length1 != length2)
                {
                    throw new InvalidOperationException(
                              "The two length fields of the Phonetic Text don't agree! " +
                              length1 + " vs " + length2
                              );
                }
                phoneticText = StringUtil.ReadUnicodeLE(in1, length1);

                int RunData = stringDataSize - 4 - 6 - (2 * phoneticText.Length);
                int numRuns = (RunData / 6);

                phRuns = new PhRun[numRuns];
                for (int i = 0; i < phRuns.Length; i++)
                {
                    phRuns[i] = new PhRun(in1);
                }

                int extraDataLength = RunData - (numRuns * 6);

                if (extraDataLength < 0)
                {
                    //System.err.Println("Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
                    extraDataLength = 0;
                }
                extraData = new byte[extraDataLength];
                for (int i = 0; i < extraData.Length; i++)
                {
                    extraData[i] = (byte)in1.ReadByte();
                }
            }
Beispiel #25
0
 public BoolPtg(ILittleEndianInput in1)
 {
     field_1_value = (in1.ReadByte() == 1);
 }
 public LbsDropData(ILittleEndianInput in1){
     _wStyle = in1.ReadUShort();
     _cLine = in1.ReadUShort();
     _dxMin = in1.ReadUShort();
     _str = StringUtil.ReadUnicodeString(in1);
     if(StringUtil.GetEncodedSize(_str) % 2 != 0){
         _unused = (byte)in1.ReadByte();
     }
 }
        /**
         * Constructs an EmbeddedObjectRef record and Sets its fields appropriately.
         *
         * @param in the record input stream.
         */
        public EmbeddedObjectRefSubRecord(ILittleEndianInput in1, int size)
        {
            // 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 remaining = size - LittleEndianConsts.SHORT_SIZE;

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

            remaining -= LittleEndianConsts.SHORT_SIZE;
            field_1_unknown_int = in1.ReadInt();
            remaining -= LittleEndianConsts.INT_SIZE;
            byte[] formulaRawBytes = ReadRawData(in1, formulaSize);
            remaining -= 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 (remaining >= dataLenAfterFormula + 3)
            {
                int tag = in1.ReadByte();
                stringByteCount = LittleEndianConsts.BYTE_SIZE;
                if (tag != 0x03)
                {
                    throw new RecordFormatException("Expected byte 0x03 here");
                }
                int nChars = in1.ReadUShort();
                stringByteCount += LittleEndianConsts.SHORT_SIZE;
                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;
                    stringByteCount += LittleEndianConsts.BYTE_SIZE;
                    if (field_3_unicode_flag)
                    {
                        field_4_ole_classname = StringUtil.ReadUnicodeLE(in1,nChars);
                        stringByteCount += nChars * 2;
                    }
                    else
                    {
                        field_4_ole_classname = StringUtil.ReadCompressedUnicode(in1,nChars);
                        stringByteCount += nChars;
                    }
                }
                else
                {
                    field_4_ole_classname = "";
                }
            }
            else
            {
                field_4_ole_classname = null;
                stringByteCount = 0;
            }
            remaining -= stringByteCount;
            // Pad to next 2-byte boundary
            if (((stringByteCount + formulaSize) % 2) != 0)
            {
                int b = in1.ReadByte();
                remaining -= LittleEndianConsts.BYTE_SIZE;
                if (field_2_refPtg != null && field_4_ole_classname == null)
                {
                    field_4_unknownByte = (byte)b;
                }
            }
            int nUnexpectedPadding = remaining - dataLenAfterFormula;

            if (nUnexpectedPadding > 0)
            {
                logger.Log(POILogger.ERROR, "Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
                ReadRawData(in1, nUnexpectedPadding);
                remaining -= nUnexpectedPadding;
            }

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

            field_6_unknown = ReadRawData(in1, remaining);
        }
    /**
     * @param in the stream to read data from
     * @param cbFContinued the seconf short in the record header
     * @param cmoOt the Containing Obj's {@link CommonObjectDataSubRecord#field_1_objectType}
     */
        public LbsDataSubRecord(ILittleEndianInput in1, int cbFContinued, int cmoOt)
        {
            _cbFContinued = cbFContinued;

            int encodedTokenLen = in1.ReadUShort();
            if (encodedTokenLen > 0)
            {
                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");
                }
                _linkPtg = ptgs[0];
                switch (encodedTokenLen - formulaSize - 6)
                {
                    case 1:
                        _unknownPostFormulaByte = (byte)in1.ReadByte();
                        break;
                    case 0:
                        _unknownPostFormulaByte = null;
                        break;
                    default:
                        throw new RecordFormatException("Unexpected leftover bytes");
                }
            }

            _cLines = in1.ReadUShort();
            _iSel = in1.ReadUShort();
            _flags = in1.ReadUShort();
            _idEdit = in1.ReadUShort();

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This field MUST exist if and only if the Containing Obj?s cmo.ot is equal to 0x14.
            if (cmoOt == 0x14)
            {
                _dropData = new LbsDropData(in1);
            }

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This array MUST exist if and only if the fValidPlex flag (0x2) is set
            if ((_flags & 0x2) != 0)
            {
                _rgLines = new String[_cLines];
                for (int i = 0; i < _cLines; i++)
                {
                    _rgLines[i] = StringUtil.ReadUnicodeString(in1);
                }
            }

            // bits 5-6 in the _flags specify the type
            // of selection behavior this list control is expected to support

            // From [MS-XLS].pdf 2.5.147 FtLbsData:
            // This array MUST exist if and only if the wListType field is not equal to 0.
            if (((_flags >> 4) & 0x2) != 0)
            {
                _bsels = new bool[_cLines];
                for (int i = 0; i < _cLines; i++)
                {
                    _bsels[i] = in1.ReadByte() == 1;
                }
            }

        }
Beispiel #29
0
        /**
         * InputStream <c>in</c> is expected to contain:
         * <ol>
         * <li>ushort nChars</li>
         * <li>byte is16BitFlag</li>
         * <li>byte[]/char[] characterData</li>
         * </ol>
         * For this encoding, the is16BitFlag is always present even if nChars==0.
         */
        public static String ReadUnicodeString(ILittleEndianInput in1)
        {

            int nChars = in1.ReadUShort();
            byte flag = (byte)in1.ReadByte();
            if ((flag & 0x01) == 0)
            {
                return ReadCompressedUnicode(in1, nChars);
            }
            return ReadUnicodeLE(in1, nChars);
        }
Beispiel #30
0
 public ErrPtg(ILittleEndianInput in1)
     : this(in1.ReadByte())
 {
 }
Beispiel #31
0
 /**
  * InputStream <c>in</c> is expected to contain:
  * <ol>
  * <li>byte is16BitFlag</li>
  * <li>byte[]/char[] characterData</li>
  * </ol>
  * For this encoding, the is16BitFlag is always present even if nChars==0.
  * <br/>
  * This method should be used when the nChars field is <em>not</em> stored 
  * as a ushort immediately before the is16BitFlag. Otherwise, {@link 
  * #readUnicodeString(LittleEndianInput)} can be used. 
  */
 public static String ReadUnicodeString(ILittleEndianInput in1, int nChars)
 {
     byte is16Bit = (byte)in1.ReadByte();
     if ((is16Bit & 0x01) == 0)
     {
         return ReadCompressedUnicode(in1, nChars);
     }
     return ReadUnicodeLE(in1, nChars);
 }
Beispiel #32
0
        public static Ptg CreatePtg(ILittleEndianInput in1)
        {
            byte id = (byte)in1.ReadByte();

            if (id < 0x20)
            {
                return CreateBasePtg(id, in1);
            }

            Ptg retval = CreateClassifiedPtg(id, in1);

            if (id >= 0x60)
            {
                retval.PtgClass = CLASS_ARRAY;
            }
            else if (id >= 0x40)
            {
                retval.PtgClass = CLASS_VALUE;
            }
            else
            {
                retval.PtgClass = CLASS_REF;
            }

            return retval;
        }
Beispiel #33
0
 public ErrPtg(ILittleEndianInput in1)
     : this(in1.ReadByte())
 {
     
 }