Ejemplo n.º 1
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a r s e B u f f e r                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Parse provided buffer, assuming that the current print language is //
        // PJL.                                                               //
        //                                                                    //
        //--------------------------------------------------------------------//

        public Boolean parseBuffer(
            Byte []                             buf,
            ref Int32 fileOffset,
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref ToolCommonData.ePrintLang crntPDL,
            ref Boolean endReached,
            PrnParseLinkData linkData,
            PrnParseOptions options,
            DataTable table)
        {
            Boolean seqInvalid;

            //----------------------------------------------------------------//
            //                                                                //
            // Initialise.                                                    //
            //                                                                //
            //----------------------------------------------------------------//

            _buf        = buf;
            _linkData   = linkData;
            _options    = options;
            _table      = table;
            _fileOffset = fileOffset;

            _analysisLevel = _linkData.AnalysisLevel;

            seqInvalid = false;

            //----------------------------------------------------------------//

            _indxOffsetFormat = _options.IndxGenOffsetFormat;

            _options.getOptCharSet(ref _indxCharSetName,
                                   ref _indxCharSetSubAct,
                                   ref _valCharSetSubCode);

            _endOffset = _options.ValCurFOffsetEnd;

            _showPML = _options.FlagPMLWithinPJL;

            //----------------------------------------------------------------//

            if (linkData.isContinuation())
            {
                seqInvalid = parseContinuation(ref bufRem,
                                               ref bufOffset,
                                               ref crntPDL,
                                               ref endReached);
            }
            else
            {
                seqInvalid = parseSequences(ref bufRem,
                                            ref bufOffset,
                                            ref crntPDL,
                                            ref endReached);
            }

            return(seqInvalid);
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // a n a l y s e F o n t H d d r                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Provide an interpretation of the contents of a PCL XL soft font    //
        // header.                                                            //
        //                                                                    //
        //--------------------------------------------------------------------//

        public Boolean analyseFontHddr(Int32 hddrLen,
                                       Byte []          buf,
                                       Int32 fileOffset,
                                       ref Int32 bufRem,
                                       ref Int32 bufOffset,
                                       PrnParseLinkData linkData,
                                       PrnParseOptions options,
                                       DataTable table)
        {
            Int32   binDataLen;
            Boolean validSegs = false;

            PrnParseConstants.eContType contType;

            Boolean continuation = false;

            //----------------------------------------------------------------//
            //                                                                //
            // Initialise.                                                    //
            //                                                                //
            //----------------------------------------------------------------//

            _table      = table;
            _buf        = buf;
            _fileOffset = fileOffset;

            _analysisLevel = linkData.AnalysisLevel;

            _options = options;

            contType = linkData.getContType();

            _indxOffsetFormat = _options.IndxGenOffsetFormat;

            _showBinData = _options.FlagPCLXLMiscBinData;

            //----------------------------------------------------------------//

            if (contType == PrnParseConstants.eContType.None)
            {
                _nextStage = eStage.Start;
                _validHddr = true;
                _firstSeg  = true;

                _hddrLen = hddrLen;
                _hddrRem = hddrLen;
                _hddrPos = fileOffset + bufOffset;
            }
            else
            {
                contType = PrnParseConstants.eContType.None;
                linkData.resetContData();
            }

            //----------------------------------------------------------------//

            if (_nextStage == eStage.Start)
            {
                if (bufRem < _cHddrDescLen)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Font header descriptor is not all in buffer.           //
                    // Initiate continuation.                                 //
                    //                                                        //
                    //--------------------------------------------------------//

                    contType = PrnParseConstants.eContType.PCLXLFontHddr;

                    linkData.setBacktrack(contType, -bufRem);
                }
                else
                {
                    _nextStage = eStage.ShowHddr;
                }
            }

            if (_nextStage == eStage.ShowHddr)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Process font header.                                       //
                //                                                            //
                //------------------------------------------------------------//

                processFontHeader(ref bufRem,
                                  ref bufOffset);

                bufRem    = bufRem - _cHddrDescLen;
                _hddrRem  = _hddrRem - _cHddrDescLen;
                bufOffset = bufOffset + _cHddrDescLen;

                if (_validHddr)
                {
                    _nextStage = eStage.ShowData;
                }
                else
                {
                    _nextStage = eStage.BadSeqA;
                }
            }

            if (_nextStage == eStage.ShowData)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Output details of segmented data:                          //
                //                                                            //
                //------------------------------------------------------------//

                Int32 dummy = 0;

                continuation = _parseSegs.processSegData(_buf,
                                                         _fileOffset,
                                                         false,
                                                         _firstSeg,
                                                         true,
                                                         ref bufRem,
                                                         ref bufOffset,
                                                         ref _hddrDataRem,
                                                         ref _hddrRem,
                                                         ref dummy,
                                                         ref validSegs,
                                                         linkData,
                                                         _options,
                                                         _table);

                _firstSeg = false;
            }

            if (_nextStage == eStage.EndOK)
            {
                //------------------------------------------------------------//
                //                                                            //
                // End of processing of valid header.                         //
                //                                                            //
                //------------------------------------------------------------//

                return(_validHddr);
            }

            if (_nextStage == eStage.BadSeqA)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Inconsistency found.                                       //
                //                                                            //
                //------------------------------------------------------------//

                _nextStage = eStage.BadSeqB;

                PrnParseCommon.addTextRow(
                    PrnParseRowTypes.eType.MsgError,
                    _table,
                    PrnParseConstants.eOvlShow.None,
                    "",
                    "",
                    "",
                    "Processing of header abandoned!");
            }

            if ((_nextStage == eStage.BadSeqB) && (_hddrRem != 0))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Header does not appear to be valid.                        //
                // Treat remainder of header as a binary sequence without     //
                // interpretation.                                            //
                // Check if remainder of download sequence is within the      //
                // buffer.                                                    //
                //                                                            //
                //------------------------------------------------------------//

                if (_hddrRem > bufRem)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Remainder of sequence is not in buffer.                //
                    // Initiate continuation.                                 //
                    //                                                        //
                    //--------------------------------------------------------//

                    contType = PrnParseConstants.eContType.PCLXLFontHddr;

                    binDataLen = bufRem;
                    _hddrRem   = _hddrRem - bufRem;

                    linkData.setContinuation(contType);
                }
                else
                {
                    contType = PrnParseConstants.eContType.None;
                    linkData.resetContData();

                    binDataLen = _hddrRem;
                    _hddrRem   = 0;
                }

                if ((binDataLen) != 0)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Some, or all, of the download data is contained within //
                    // the current 'block'.                                   //
                    //                                                        //
                    //--------------------------------------------------------//

                    PrnParseData.processBinary(
                        _table,
                        PrnParseConstants.eOvlShow.None,
                        buf,
                        fileOffset,
                        bufOffset,
                        binDataLen,
                        "PCLXL Binary",
                        _showBinData,
                        false,
                        true,
                        _indxOffsetFormat,
                        _analysisLevel);

                    bufRem    = bufRem - binDataLen;
                    bufOffset = bufOffset + binDataLen;
                }
            }

            return(_validHddr);
        }