コード例 #1
0
ファイル: PAPX.cs プロジェクト: JnS-Software-LLC/npoi
        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;
        }
コード例 #2
0
        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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: PAPX.cs プロジェクト: JnS-Software-LLC/npoi
        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;
        }
コード例 #5
0
ファイル: SEPX.cs プロジェクト: ctddjyds/npoi
 public byte[] GetGrpprl()
 {
     if (sectionProperties != null)
     {
         byte[] grpprl = SectionSprmCompressor
                 .CompressSectionProperty(sectionProperties);
         _buf = new SprmBuffer(grpprl, 0);
     }
     return ((SprmBuffer)_buf).ToByteArray();
 }
コード例 #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);
        }
コード例 #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;
        }
コード例 #8
0
ファイル: PAPX.cs プロジェクト: JnS-Software-LLC/npoi
 public PAPX(int charStart, int charEnd, SprmBuffer buf):
     base(charStart, charEnd, buf)
 {
     
     _phe = new ParagraphHeight();
 }
コード例 #9
0
        public CachedPropertyNode(int start, int end, SprmBuffer buf)
            : base(start, end, buf)
        {

        }
コード例 #10
0
ファイル: CHPX.cs プロジェクト: hanwangkun/npoi
        public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf)
            : base(fcStart, translator.LookIndexBackward(fcEnd), translator, buf)
        {

        }
コード例 #11
0
ファイル: CHPX.cs プロジェクト: hanwangkun/npoi
 internal CHPX(int charStart, int charEnd, SprmBuffer buf):
     base(charStart, charEnd, buf)
 {
     
 }
コード例 #12
0
        public override bool Equals(Object obj)
        {
            SprmBuffer sprmBuf = (SprmBuffer)obj;

            return(Arrays.Equals(_buf, sprmBuf._buf));
        }
コード例 #13
0
ファイル: CharacterRun.cs プロジェクト: 89sos98/npoi
        /**
         *
         * @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();
        }
コード例 #14
0
ファイル: SprmBuffer.cs プロジェクト: ctddjyds/npoi
 public Object Clone()
 {
     SprmBuffer retVal = new SprmBuffer();
     retVal._buf = new byte[_buf.Length];
     Array.Copy(_buf, 0, retVal._buf, 0, _buf.Length);
     return retVal;
 }
コード例 #15
0
ファイル: Paragraph.cs プロジェクト: 89sos98/npoi
        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();
        }
コード例 #16
0
ファイル: Paragraph.cs プロジェクト: 89sos98/npoi
 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();
 }