Example #1
0
        private SprmBuffer FindHuge(SprmBuffer buf, byte[] datastream)
        {
            byte[] grpprl = buf.ToByteArray();
            if (grpprl.Length == 8 && datastream != null) // then check for sprmPHugePapx
            {
                SprmOperation sprm = new SprmOperation(grpprl, 2);
                if ((sprm.Operation == 0x45 || sprm.Operation == 0x46)
                    && sprm.SizeCode == 3)
                {
                    int hugeGrpprlOffset = sprm.Operand;
                    if (hugeGrpprlOffset + 1 < datastream.Length)
                    {
                        int grpprlSize = LittleEndian.GetShort(datastream, hugeGrpprlOffset);
                        if (hugeGrpprlOffset + grpprlSize < datastream.Length)
                        {
                            byte[] hugeGrpprl = new byte[grpprlSize + 2];
                            // copy original istd into huge Grpprl
                            hugeGrpprl[0] = grpprl[0]; 
                            hugeGrpprl[1] = grpprl[1];
                            // copy Grpprl from dataStream
                            Array.Copy(datastream, hugeGrpprlOffset + 2, hugeGrpprl, 2,
                                             grpprlSize);

                            return new SprmBuffer(hugeGrpprl,2);
                        }
                    }
                }
            }
            return null;
        }
        public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset, int fcMin)
        {
            //skips through the prms before we reach the piece table. These contain data
            //for actual fast saved files
            List<SprmBuffer> sprmBuffers = new List<SprmBuffer>();
            //skips through the prms before we reach the piece table. These contain data
            //for actual fast saved files
            while (tableStream[offset] == GRPPRL_TYPE)
            {
                offset++;
                int size = LittleEndian.GetShort(tableStream, offset);
                offset += LittleEndianConsts.SHORT_SIZE;
                byte[] bs = LittleEndian.GetByteArray(tableStream, offset, size);
                offset += size;

                SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
                sprmBuffers.Add(sprmBuffer);
            }
            this._grpprls = sprmBuffers.ToArray();

            if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE)
            {
                throw new IOException("The text piece table is corrupted");
            }
            int pieceTableSize = LittleEndian.GetInt(tableStream, ++offset);
            offset += LittleEndianConsts.INT_SIZE;
            _tpt = new TextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin);
        }
Example #3
0
        public Object Clone()
        {
            SprmBuffer retVal = new SprmBuffer();

            retVal._buf = new byte[_buf.Length];
            Array.Copy(_buf, 0, retVal._buf, 0, _buf.Length);
            return(retVal);
        }
Example #4
0
        public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf, byte[] dataStream)
            : base(fcStart, fcEnd, translator, buf)
        {

            _phe = new ParagraphHeight();
            buf = FindHuge(buf, dataStream);
            if (buf != null)
                _buf = buf;
        }
Example #5
0
 public byte[] GetGrpprl()
 {
     if (sectionProperties != null)
     {
         byte[] grpprl = SectionSprmCompressor
                 .CompressSectionProperty(sectionProperties);
         _buf = new SprmBuffer(grpprl, 0);
     }
     return ((SprmBuffer)_buf).ToByteArray();
 }
Example #6
0
        public static TableProperties UncompressTAP(SprmBuffer sprmBuffer)
        {
            TableProperties tableProperties;

            SprmOperation sprmOperation = sprmBuffer.FindSprm(unchecked ((short)0xd608));

            if (sprmOperation != null)
            {
                byte[] grpprl = sprmOperation.Grpprl;
                int    offset = sprmOperation.GrpprlOffset;
                short  itcMac = grpprl[offset];
                tableProperties = new TableProperties(itcMac);
            }
            else
            {
                //logger.log(POILogger.WARN,
                //        "Some table rows didn't specify number of columns in SPRMs");
                tableProperties = new TableProperties((short)1);
            }

            for (SprmIterator iterator = sprmBuffer.Iterator(); iterator.HasNext();)
            {
                SprmOperation sprm = iterator.Next();

                /*
                 * TAPXs are actually PAPXs so we have to make sure we are only
                 * trying to uncompress the right type of sprm.
                 */
                if (sprm.Type == SprmOperation.TYPE_TAP)
                {
                    try
                    {
                        UncompressTAPOperation(tableProperties, sprm);
                    }
                    catch (IndexOutOfRangeException ex)
                    {
                        //logger.log(POILogger.ERROR, "Unable to apply ", sprm,
                        //        ": ", ex, ex);
                    }
                }
            }
            return(tableProperties);
        }
Example #7
0
        public static TableProperties UncompressTAP(SprmBuffer sprmBuffer)
        {
            TableProperties tableProperties;

            SprmOperation sprmOperation = sprmBuffer.FindSprm(unchecked((short)0xd608));
            if (sprmOperation != null)
            {
                byte[] grpprl = sprmOperation.Grpprl;
                int offset = sprmOperation.GrpprlOffset;
                short itcMac = grpprl[offset];
                tableProperties = new TableProperties(itcMac);
            }
            else
            {
                //logger.log(POILogger.WARN,
                //        "Some table rows didn't specify number of columns in SPRMs");
                tableProperties = new TableProperties((short)1);
            }

            for (SprmIterator iterator = sprmBuffer.Iterator(); iterator.HasNext(); )
            {
                SprmOperation sprm = iterator.Next();

                /*
                 * TAPXs are actually PAPXs so we have to make sure we are only
                 * trying to uncompress the right type of sprm.
                 */
                if (sprm.Type == SprmOperation.TYPE_TAP)
                {
                    try
                    {
                        UncompressTAPOperation(tableProperties, sprm);
                    }
                    catch ( IndexOutOfRangeException ex)
                    {
                        //logger.log(POILogger.ERROR, "Unable to apply ", sprm,
                        //        ": ", ex, ex);
                    }
                }
            }
            return tableProperties;
        }
Example #8
0
 public PAPX(int charStart, int charEnd, SprmBuffer buf):
     base(charStart, charEnd, buf)
 {
     
     _phe = new ParagraphHeight();
 }
        public CachedPropertyNode(int start, int end, SprmBuffer buf)
            : base(start, end, buf)
        {

        }
Example #10
0
        public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf)
            : base(fcStart, translator.LookIndexBackward(fcEnd), translator, buf)
        {

        }
Example #11
0
 internal CHPX(int charStart, int charEnd, SprmBuffer buf):
     base(charStart, charEnd, buf)
 {
     
 }
Example #12
0
        public override bool Equals(Object obj)
        {
            SprmBuffer sprmBuf = (SprmBuffer)obj;

            return(Arrays.Equals(_buf, sprmBuf._buf));
        }
Example #13
0
        /**
         *
         * @param chpx The chpx this object is based on.
         * @param ss The stylesheet for the document this run belongs to.
         * @param istd The style index if this Run's base style.
         * @param parent The parent range of this character run (usually a paragraph).
         */
        internal CharacterRun(CHPX chpx, StyleSheet ss, short istd, Range parent)
            : base(Math.Max(parent._start, chpx.Start), Math.Min(parent._end, chpx.End), parent)
        {

            _props = chpx.GetCharacterProperties(ss, istd);
            _chpx = chpx.GetSprmBuf();
        }
Example #14
0
 public Object Clone()
 {
     SprmBuffer retVal = new SprmBuffer();
     retVal._buf = new byte[_buf.Length];
     Array.Copy(_buf, 0, retVal._buf, 0, _buf.Length);
     return retVal;
 }
Example #15
0
        internal Paragraph(PAPX papx, Range parent)
            : base(Math.Max(parent._start, papx.Start), Math.Min(parent._end, papx.End), parent)
        {

            _props = papx.GetParagraphProperties(_doc.GetStyleSheet());
            _papx = papx.GetSprmBuf();
            _istd = papx.GetIstd();
        }
Example #16
0
 internal Paragraph(int startIdx, int endIdx, Table parent)
     : base(startIdx, endIdx, parent)
 {
     InitAll();
     PAPX papx = (PAPX)_paragraphs[_parEnd - 1];
     _props = papx.GetParagraphProperties(_doc.GetStyleSheet());
     _papx = papx.GetSprmBuf();
     _istd = papx.GetIstd();
 }