Exemplo n.º 1
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e                                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write individual test data page sequences to output file.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePage(BinaryWriter prnWriter,
                                         Int32 indxPaperSize,
                                         Int32 indxPaperType,
                                         Int32 indxOrientation,
                                         Boolean formAsMacro,
                                         UInt32 codePoint,
                                         Int32 indxFont,
                                         PCLFonts.eVariant fontVar)
        {
            const Int32 sizeStd = 1024;

            Byte[] bufStd = new Byte[sizeStd];

            UInt16[] textArray = { 0x00 };

            Int16 posX,
                  posY;

            Int32 indStd;

            Int16 ptSize;

            Byte[] utf8Seq = new Byte[4];
            Int32  utf8Len = 0;

            String utf8HexVal = "";

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

            indStd = 0;

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

            if (indxOrientation < PCLOrientations.getCount())
            {
                PCLXLWriter.addAttrUbyte(ref bufStd,
                                         ref indStd,
                                         PCLXLAttributes.eTag.Orientation,
                                         PCLOrientations.getIdPCLXL(indxOrientation));
            }

            if (indxPaperSize < PCLPaperSizes.getCount())
            {
                PCLXLWriter.addAttrUbyte(ref bufStd,
                                         ref indStd,
                                         PCLXLAttributes.eTag.MediaSize,
                                         PCLPaperSizes.getIdPCLXL(indxPaperSize));
            }

            if ((indxPaperType < PCLPaperTypes.getCount()) &&
                (PCLPaperTypes.getType(indxPaperType) !=
                 PCLPaperTypes.eEntryType.NotSet))
            {
                PCLXLWriter.addAttrUbyteArray(ref bufStd,
                                              ref indStd,
                                              PCLXLAttributes.eTag.MediaType,
                                              PCLPaperTypes.getName(indxPaperType));
            }

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.SimplexPageMode,
                                     (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.BeginPage);

            PCLXLWriter.addAttrUint16XY(ref bufStd,
                                        ref indStd,
                                        PCLXLAttributes.eTag.PageOrigin,
                                        0, 0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetPageOrigin);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.ColorSpace,
                                     (Byte)PCLXLAttrEnums.eVal.eGray);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetColorSpace);

            prnWriter.Write(bufStd, 0, indStd);
            indStd = 0;

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

            if (formAsMacro)
            {
                PCLXLWriter.addAttrUbyteArray(ref bufStd,
                                              ref indStd,
                                              PCLXLAttributes.eTag.StreamName,
                                              _formName);

                PCLXLWriter.addOperator(ref bufStd,
                                        ref indStd,
                                        PCLXLOperators.eTag.ExecStream);

                prnWriter.Write(bufStd, 0, indStd);
                indStd = 0;
            }
            else
            {
                generateOverlay(prnWriter, false,
                                indxPaperSize, indxOrientation);
            }

            prnWriter.Write(bufStd, 0, indStd);

            indStd = 0;


            //----------------------------------------------------------------//
            //                                                                //
            // Code-point data.                                               //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 18;

            PCLXLWriter.font(prnWriter, false, ptSize,
                             _symSet_19U, _fontNameArial);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.GrayLevel,
                                     0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetBrushSource);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.NullPen,
                                     0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetPenSource);

            posX = _posXData;
            posY = _posYData;

            if (codePoint < 0x010000)
            {
                PCLXLWriter.text(prnWriter, false, false,
                                 PCLXLWriter.advances_ArialRegular, ptSize,
                                 posX, posY,
                                 "U+" + codePoint.ToString("x4"));
            }
            else
            {
                // should not happen 'cos XL only supports 16-bit values !
                PCLXLWriter.text(prnWriter, false, false,
                                 PCLXLWriter.advances_ArialRegular, ptSize,
                                 posX, posY,
                                 "U+" + codePoint.ToString("x6"));
            }

            PrnParseDataUTF8.convertUTF32ToUTF8Bytes(codePoint,
                                                     ref utf8Len,
                                                     ref utf8Seq);

            PrnParseDataUTF8.convertUTF32ToUTF8HexString(codePoint,
                                                         true,
                                                         ref utf8HexVal);

            posY += _lineInc;

            PCLXLWriter.text(prnWriter, false, false,
                             PCLXLWriter.advances_ArialRegular, ptSize,
                             posX, posY,
                             utf8HexVal);

            //----------------------------------------------------------------//
            //                                                                //
            // Font data.                                                     //
            //                                                                //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLXLWriter.text(prnWriter, false, false,
                             PCLXLWriter.advances_ArialRegular, ptSize,
                             posX, posY,
                             PCLFonts.getName(indxFont) +
                             " " +
                             Enum.GetName(typeof(PCLFonts.eVariant), fontVar));

            posY += _lineInc;

            ptSize = 36;

            PCLXLWriter.font(prnWriter, false, ptSize,
                             _symSet_18N,
                             PCLFonts.getPCLXLName(indxFont,
                                                   fontVar));

            textArray[0] = (UInt16)codePoint;

            PCLXLWriter.textChar(prnWriter, false,
                                 0,           // ***** dummy value *****
                                 ptSize,
                                 posX, posY,
                                 (UInt16)codePoint);

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

            PCLXLWriter.addAttrUint16(ref bufStd,
                                      ref indStd,
                                      PCLXLAttributes.eTag.PageCopies,
                                      1);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.EndPage);

            prnWriter.Write(bufStd, 0, indStd);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // i n i t i a l i s e D a t a U n i c o d e                          //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Initialise 'Unicode chars' data.                                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void initialiseDataUnicode()
        {
            Int32 index,
                  ctr;

            _initialised = false;

            lbOrientation.Visibility = Visibility.Hidden;
            cbOrientation.Visibility = Visibility.Hidden;

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

            cbUnicodeFont.Items.Clear();

            ctr   = PCLFonts.getCount();
            index = 0;

            for (Int32 i = 0; i < ctr; i++)
            {
                if ((PCLFonts.isBoundFont(i) == false) &&
                    ((PCLFonts.getType(i) ==
                      PCLFonts.eFontType.PresetTypeface) ||
                     (PCLFonts.getType(i) ==
                      PCLFonts.eFontType.PresetFamilyMember)))
                {
                    _subsetUnicodeFonts[index++] = (Int32)i;
                    cbUnicodeFont.Items.Add(PCLFonts.getName(i));
                }
            }

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

            cbUnicodeCp01.Items.Clear();

            for (Int32 i = 0; i < 0x0100; i++)
            {
                cbUnicodeCp01.Items.Add(i.ToString("x2"));
            }

            cbUnicodeCp02.Items.Clear();

            for (Int32 i = 0; i < 0x0100; i++)
            {
                cbUnicodeCp02.Items.Add(i.ToString("x2"));
            }

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

            if (_crntPDL == ToolCommonData.ePrintLang.PCL)
            {
                if ((_indxUnicodeFontPCL < 0) ||
                    (_indxUnicodeFontPCL >= _ctUnicodeFonts))
                {
                    _indxUnicodeFontPCL = 0;
                }

                cbUnicodeFont.SelectedIndex = _indxUnicodeFontPCL;

                setFontOptionsVariants(_indxUnicodeFontPCL,
                                       true,
                                       ref _unicodeFontVarPCL);

                cbUnicodeCp01.SelectedIndex = (Int32)(_unicodeUCS2PCL / 256);
                cbUnicodeCp02.SelectedIndex = (Int32)(_unicodeUCS2PCL % 256);

                if (_flagUnicodeFormAsMacroPCL)
                {
                    chkOptFormAsMacro.IsChecked = true;
                }
                else
                {
                    chkOptFormAsMacro.IsChecked = false;
                }
            }
            else
            {
                if ((_indxUnicodeFontPCLXL < 0) ||
                    (_indxUnicodeFontPCLXL >= _ctUnicodeFonts))
                {
                    _indxUnicodeFontPCLXL = 0;
                }

                cbUnicodeFont.SelectedIndex = _indxUnicodeFontPCLXL;

                setFontOptionsVariants(_indxUnicodeFontPCLXL,
                                       true,
                                       ref _unicodeFontVarPCLXL);

                cbUnicodeCp01.SelectedIndex = (Int32)(_unicodeUCS2PCLXL / 256);
                cbUnicodeCp02.SelectedIndex = (Int32)(_unicodeUCS2PCLXL % 256);

                if (_flagUnicodeFormAsMacroPCLXL)
                {
                    chkOptFormAsMacro.IsChecked = true;
                }
                else
                {
                    chkOptFormAsMacro.IsChecked = false;
                }
            }

            _initialised = true;

            initialiseDescUnicode();

            cbUnicodeCp_SelectionChanged(this, null);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e                                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write individual test data page sequences to output file.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePage(BinaryWriter prnWriter,
                                         Int32 indxPaperSize,
                                         Int32 indxPaperType,
                                         Int32 indxOrientation,
                                         Boolean formAsMacro,
                                         UInt16 logXOffset,
                                         UInt32 codePoint,
                                         Int32 indxFont,
                                         PCLFonts.eVariant fontVar)
        {
            Int16 posX,
                  posY;

            Int16 ptSize;

            Byte[] utf8Seq = new Byte[4];
            Int32  utf8Len = 0;

            String utf8HexVal = "";

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

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlay(prnWriter, false, logXOffset,
                                indxPaperSize, indxOrientation);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Code-point data.                                               //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 18;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontArial,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

            posX = (Int16)(_posXData - logXOffset);
            posY = _posYData;

            if (codePoint < 0x010000)
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "U+" +
                               codePoint.ToString("x4"));
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "U+" +
                               codePoint.ToString("x6"));
            }

            PrnParseDataUTF8.convertUTF32ToUTF8Bytes(codePoint,
                                                     ref utf8Len,
                                                     ref utf8Seq);

            PrnParseDataUTF8.convertUTF32ToUTF8HexString(codePoint,
                                                         true,
                                                         ref utf8HexVal);

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0, utf8HexVal);

            //----------------------------------------------------------------//
            //                                                                //
            // Font data.                                                     //
            //                                                                //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           PCLFonts.getName(indxFont) +
                           " " +
                           Enum.GetName(typeof(PCLFonts.eVariant), fontVar));

            posY += _lineInc;

            ptSize = 36;

            PCLWriter.font(prnWriter, true, "18N",
                           PCLFonts.getPCLFontSelect(indxFont,
                                                     fontVar,
                                                     ptSize, 0));

            PCLWriter.textParsingMethod(
                prnWriter,
                PCLTextParsingMethods.eIndex.m83_UTF8);

            PCLWriter.cursorPosition(prnWriter, posX, posY);

            prnWriter.Write(utf8Seq, 0, utf8Len);

            PCLWriter.formFeed(prnWriter);
        }