mirror of
https://github.com/tbluemel/rtf.js.git
synced 2026-11-30 16:47:59 +01:00
2 lines
53 KiB
JavaScript
Generated
2 lines
53 KiB
JavaScript
Generated
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):"function"==typeof define&&define.amd?define(["./jquery.svg","./jquery.svgfilter","jquery"],e):"object"==typeof exports?exports.WMFJS=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):t.WMFJS=e(t.$,t.$,t.$)}(this,function(t,e,r){return function(t){var e={};function r(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(s,i,function(e){return t[e]}.bind(null,i));return s},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=36)}([,function(e,r){e.exports=t},function(t,r){t.exports=e},,function(t,e){t.exports=r},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";r.r(e);r(1),r(2);var s=r(37);r.d(e,"Renderer",function(){return s.Renderer});var i=r(39);r.d(e,"Error",function(){return i.WMFJSError}),r.d(e,"loggingEnabled",function(){return i.loggingEnabled})},function(t,e,r){"use strict";r.r(e),r.d(e,"Renderer",function(){return a}),r.d(e,"WMFRect16",function(){return h}),r.d(e,"WMFPlacable",function(){return p}),r.d(e,"WMF",function(){return c});var s=r(4),i=r(38),n=r(40),o=r(39),l=r(45),a=function(){function t(t){this.parse(t),o.Helper.log("WMFJS.Renderer instantiated")}return t.prototype.render=function(t){var e=this,r=s("<div>").svg({onLoad:function(r){return e._render(r,t.mapMode,t.xExt,t.yExt)},settings:{viewBox:[0,0,t.xExt,t.yExt].join(" "),preserveAspectRatio:"none"}}),i=s(r[0]).svg("get");return s(i.root()).attr("width",t.width).attr("height",t.height)},t.prototype.parse=function(t){this._img=null;var e,r,s,n,l=new i.Blob(t),a=l.readUint32();switch(2596720087===a?(s=new p(l),n=l.pos,e=l.readUint16(),r=l.readUint16()):(n=0,e=65535&a,r=a>>>16&65535),e){case o.Helper.GDI.MetafileType.MEMORYMETAFILE:case o.Helper.GDI.MetafileType.DISKMETAFILE:if(r===o.Helper.GDI.METAHEADER_SIZE/2){var h=l.readUint16();switch(h){case o.Helper.GDI.MetafileVersion.METAVERSION100:case o.Helper.GDI.MetafileVersion.METAVERSION300:this._img=new c(l,s,h,n+2*r)}}}if(null==this._img)throw new o.WMFJSError("Format not recognized")},t.prototype._render=function(t,e,r,s){var i=new n.GDIContext(t);i.setViewportExt(r,s),i.setMapMode(e),o.Helper.log("[WMF] BEGIN RENDERING ---\x3e"),this._img.render(i),o.Helper.log("[WMF] <--- DONE RENDERING")},t}(),h=function(){function t(t){this.left=t.readInt16(),this.top=t.readInt16(),this.right=t.readInt16(),this.bottom=t.readInt16()}return t.prototype.toString=function(){return"{left: "+this.left+", top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+"}"},t}(),p=function(){return function(t){t.skip(2),this.boundingBox=new h(t),this.unitsPerInch=t.readInt16(),t.skip(4),t.skip(2),o.Helper.log("Got bounding box "+this.boundingBox+" and "+this.unitsPerInch+" units/inch")}}(),c=function(){function t(t,e,r,s){this._version=r,this._hdrsize=s,this._placable=e,this._records=new l.WMFRecords(t,this._hdrsize)}return t.prototype.render=function(t){this._records.play(t)},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"Blob",function(){return i});var s=r(39),i=function(){function t(e,r){e instanceof t?(this.blob=e.blob,this.data=e.data,this.pos=r||e.pos):(this.blob=e,this.data=new Uint8Array(e),this.pos=r||0)}return t.prototype.eof=function(){return this.pos>=this.data.length},t.prototype.seek=function(t){if(t<0||t>this.data.length)throw new s.WMFJSError("Invalid seek position");this.pos=t},t.prototype.skip=function(t){var e=this.pos+t;if(e>this.data.length)throw new s.WMFJSError("Unexpected end of file");this.pos=e},t.prototype.readBinary=function(t){if(this.pos+t>this.data.length)throw new s.WMFJSError("Unexpected end of file");for(var e="";t-- >0;)e+=String.fromCharCode(this.data[this.pos++]);return e},t.prototype.readInt8=function(){if(this.pos+1>this.data.length)throw new s.WMFJSError("Unexpected end of file");return this.data[this.pos++]},t.prototype.readUint8=function(){return this.readInt8()>>>0},t.prototype.readInt32=function(){if(this.pos+4>this.data.length)throw new s.WMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8,t|=this.data[this.pos++]<<16,t|=this.data[this.pos++]<<24},t.prototype.readUint32=function(){return this.readInt32()>>>0},t.prototype.readUint16=function(){if(this.pos+2>this.data.length)throw new s.WMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8},t.prototype.readInt16=function(){var t=this.readUint16();return t>32767&&(t-=65536),t},t.prototype.readString=function(t){if(this.pos+t>this.data.length)throw new s.WMFJSError("Unexpected end of file");for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.data[this.pos++]>>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var r=0;r<t;r++){if(this.pos+r+1>this.data.length)throw new s.WMFJSError("Unexpected end of file");var i=this.data[this.pos+r]>>>0;if(0===i)break;e+=String.fromCharCode(i)}}return e},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"WMFJSError",function(){return s}),r.d(e,"loggingEnabled",function(){return n}),r.d(e,"Helper",function(){return o});var s=function(t){this.name="WMFJSError",this.message=t,this.stack=(new Error).stack};s.prototype=new Error;var i=!0;function n(t){i=t}var o=function(){function t(){}return t.log=function(t){i&&console.log(t)},t._makeUniqueId=function(t){return"wmfjs_"+t+this._uniqueId++},t._writeUint32Val=function(t,e,r){t[e++]=255&r,t[e++]=r>>>8&255,t[e++]=r>>>16&255,t[e++]=r>>>24&255},t._blobToBinary=function(t){for(var e="",r=t.length,s=0;s<r;s++)e+=String.fromCharCode(t[s]);return e},t.GDI={METAHEADER_SIZE:18,BITMAPINFOHEADER_SIZE:40,BITMAPCOREHEADER_SIZE:12,MetafileType:{MEMORYMETAFILE:1,DISKMETAFILE:2},MetafileVersion:{METAVERSION100:256,METAVERSION300:768},RecordType:{META_EOF:0,META_REALIZEPALETTE:53,META_SETPALENTRIES:55,META_SETBKMODE:258,META_SETMAPMODE:259,META_SETROP2:260,META_SETRELABS:261,META_SETPOLYFILLMODE:262,META_SETSTRETCHBLTMODE:263,META_SETTEXTCHAREXTRA:264,META_RESTOREDC:295,META_RESIZEPALETTE:313,META_DIBCREATEPATTERNBRUSH:322,META_SETLAYOUT:329,META_SETBKCOLOR:513,META_SETTEXTCOLOR:521,META_OFFSETVIEWPORTORG:529,META_LINETO:531,META_MOVETO:532,META_OFFSETCLIPRGN:544,META_FILLREGION:552,META_SETMAPPERFLAGS:561,META_SELECTPALETTE:564,META_POLYGON:804,META_POLYLINE:805,META_SETTEXTJUSTIFICATION:522,META_SETWINDOWORG:523,META_SETWINDOWEXT:524,META_SETVIEWPORTORG:525,META_SETVIEWPORTEXT:526,META_OFFSETWINDOWORG:527,META_SCALEWINDOWEXT:1040,META_SCALEVIEWPORTEXT:1042,META_EXCLUDECLIPRECT:1045,META_INTERSECTCLIPRECT:1046,META_ELLIPSE:1048,META_FLOODFILL:1049,META_FRAMEREGION:1065,META_ANIMATEPALETTE:1078,META_TEXTOUT:1313,META_POLYPOLYGON:1336,META_EXTFLOODFILL:1352,META_RECTANGLE:1051,META_SETPIXEL:1055,META_ROUNDRECT:1564,META_PATBLT:1565,META_SAVEDC:30,META_PIE:2074,META_STRETCHBLT:2851,META_ESCAPE:1574,META_INVERTREGION:298,META_PAINTREGION:299,META_SELECTCLIPREGION:300,META_SELECTOBJECT:301,META_SETTEXTALIGN:302,META_ARC:2071,META_CHORD:2096,META_BITBLT:2338,META_EXTTEXTOUT:2610,META_SETDIBTODEV:3379,META_DIBBITBLT:2368,META_DIBSTRETCHBLT:2881,META_STRETCHDIB:3907,META_DELETEOBJECT:496,META_CREATEPALETTE:247,META_CREATEPATTERNBRUSH:505,META_CREATEPENINDIRECT:762,META_CREATEFONTINDIRECT:763,META_CREATEBRUSHINDIRECT:764,META_CREATEREGION:1791},MetafileEscapes:{NEWFRAME:1,ABORTDOC:2,NEXTBAND:3,SETCOLORTABLE:4,GETCOLORTABLE:5,FLUSHOUT:6,DRAFTMODE:7,QUERYESCSUPPORT:8,SETABORTPROC:9,STARTDOC:10,ENDDOC:11,GETPHYSPAGESIZE:12,GETPRINTINGOFFSET:13,GETSCALINGFACTOR:14,META_ESCAPE_ENHANCED_METAFILE:15,SETPENWIDTH:16,SETCOPYCOUNT:17,SETPAPERSOURCE:18,PASSTHROUGH:19,GETTECHNOLOGY:20,SETLINECAP:21,SETLINEJOIN:22,SETMITERLIMIT:23,BANDINFO:24,DRAWPATTERNRECT:25,GETVECTORPENSIZE:26,GETVECTORBRUSHSIZE:27,ENABLEDUPLEX:28,GETSETPAPERBINS:29,GETSETPRINTORIENT:30,ENUMPAPERBINS:31,SETDIBSCALING:32,EPSPRINTING:33,ENUMPAPERMETRICS:34,GETSETPAPERMETRICS:35,POSTSCRIPT_DATA:37,POSTSCRIPT_IGNORE:38,GETDEVICEUNITS:42,GETEXTENDEDTEXTMETRICS:256,GETPAIRKERNTABLE:258,EXTTEXTOUT:512,GETFACENAME:513,DOWNLOADFACE:514,METAFILE_DRIVER:2049,QUERYDIBSUPPORT:3073,BEGIN_PATH:4096,CLIP_TO_PATH:4097,END_PATH:4098,OPEN_CHANNEL:4110,DOWNLOADHEADER:4111,CLOSE_CHANNEL:4112,POSTSCRIPT_PASSTHROUGH:4115,ENCAPSULATED_POSTSCRIPT:4116,POSTSCRIPT_IDENTIFY:4117,POSTSCRIPT_INJECTION:4118,CHECKJPEGFORMAT:4119,CHECKPNGFORMAT:4120,GET_PS_FEATURESETTING:4121,MXDC_ESCAPE:4122,SPCLPASSTHROUGH2:4568},MapMode:{MM_TEXT:1,MM_LOMETRIC:2,MM_HIMETRIC:3,MM_LOENGLISH:4,MM_HIENGLISH:5,MM_TWIPS:6,MM_ISOTROPIC:7,MM_ANISOTROPIC:8},StretchMode:{BLACKONWHITE:1,WHITEONBLACK:2,COLORONCOLOR:3,HALFTONE:4},TextAlignmentMode:{TA_UPDATECP:1,TA_RIGHT:2,TA_CENTER:6,TA_BOTTOM:8,TA_BASELINE:24,TA_RTLREADING:256},MixMode:{TRANSPARENT:1,OPAQUE:2},VerticalTextAlignmentMode:{VTA_BOTTOM:2,VTA_CENTER:6,VTA_LEFT:8,VTA_BASELINE:24},BrushStyle:{BS_SOLID:0,BS_NULL:1,BS_HATCHED:2,BS_PATTERN:3,BS_INDEXED:4,BS_DIBPATTERN:5,BS_DIBPATTERNPT:6,BS_PATTERN8X8:7,BS_DIBPATTERN8X8:8,BS_MONOPATTERN:9},PenStyle:{PS_SOLID:0,PS_DASH:1,PS_DOT:2,PS_DASHDOT:3,PS_DASHDOTDOT:4,PS_NULL:5,PS_INSIDEFRAME:6,PS_USERSTYLE:7,PS_ALTERNATE:8,PS_ENDCAP_SQUARE:256,PS_ENDCAP_FLAT:512,PS_JOIN_BEVEL:4096,PS_JOIN_MITER:8192},PolyFillMode:{ALTERNATE:1,WINDING:2},ColorUsage:{DIB_RGB_COLORS:0,DIB_PAL_COLORS:1,DIB_PAL_INDICES:2},PaletteEntryFlag:{PC_RESERVED:1,PC_EXPLICIT:2,PC_NOCOLLAPSE:4},BitmapCompression:{BI_RGB:0,BI_RLE8:1,BI_RLE4:2,BI_BITFIELDS:3,BI_JPEG:4,BI_PNG:5}},t._uniqueId=0,t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"GDIContextState",function(){return a}),r.d(e,"GDIContext",function(){return h});var s=r(4),i=r(39),n=r(41),o=r(42),l=r(43),a=function(){return function(t,e){if(null!=t)for(var r in this._svggroup=t._svggroup,this._svgclipChanged=t._svgclipChanged,this._svgtextbkfilter=t._svgtextbkfilter,this.mapmode=t.mapmode,this.stretchmode=t.stretchmode,this.textalign=t.textalign,this.bkmode=t.bkmode,this.textcolor=t.textcolor.clone(),this.bkcolor=t.bkcolor.clone(),this.polyfillmode=t.polyfillmode,this.wx=t.wx,this.wy=t.wy,this.ww=t.ww,this.wh=t.wh,this.vx=t.vx,this.vy=t.vy,this.vw=t.vw,this.vh=t.vh,this.x=t.x,this.y=t.y,this.clip=t.clip,this.ownclip=!1,this.selected={},t.selected)this.selected[r]=t.selected[r];else for(var r in this._svggroup=null,this._svgclipChanged=!1,this._svgtextbkfilter=null,this.mapmode=i.Helper.GDI.MapMode.MM_ANISOTROPIC,this.stretchmode=i.Helper.GDI.StretchMode.COLORONCOLOR,this.textalign=0,this.bkmode=i.Helper.GDI.MixMode.OPAQUE,this.textcolor=new l.ColorRef(null,0,0,0),this.bkcolor=new l.ColorRef(null,255,255,255),this.polyfillmode=i.Helper.GDI.PolyFillMode.ALTERNATE,this.wx=0,this.wy=0,this.ww=0,this.wh=0,this.vx=0,this.vy=0,this.vw=0,this.vh=0,this.x=0,this.y=0,this.clip=null,this.ownclip=!1,this.selected={},e){var s=e[r];this.selected[r]=null!=s?s.clone():null}}}(),h=function(){function t(t){this._svg=t,this._svgdefs=null,this._svgPatterns={},this._svgClipPaths={},this.defObjects={brush:new l.Brush(null,null),pen:new l.Pen(null,i.Helper.GDI.PenStyle.PS_SOLID,new n.PointS(null,1,1),new l.ColorRef(null,0,0,0),0,0),font:new l.Font(null,null),palette:null,region:null},this.state=new a(null,this.defObjects),this.statestack=[this.state],this.objects={}}return t.prototype.setMapMode=function(t){i.Helper.log("[gdi] setMapMode: mode="+t),this.state.mapmode=t,this.state._svggroup=null},t.prototype.setWindowOrg=function(t,e){i.Helper.log("[gdi] setWindowOrg: x="+t+" y="+e),this.state.wx=t,this.state.wy=e,this.state._svggroup=null},t.prototype.setWindowExt=function(t,e){i.Helper.log("[gdi] setWindowExt: x="+t+" y="+e),this.state.ww=t,this.state.wh=e,this.state._svggroup=null},t.prototype.offsetWindowOrg=function(t,e){i.Helper.log("[gdi] offsetWindowOrg: offX="+t+" offY="+e),this.state.wx+=t,this.state.wy+=e,this.state._svggroup=null},t.prototype.setViewportOrg=function(t,e){i.Helper.log("[gdi] setViewportOrg: x="+t+" y="+e),this.state.vx=t,this.state.vy=e,this.state._svggroup=null},t.prototype.setViewportExt=function(t,e){i.Helper.log("[gdi] setViewportExt: x="+t+" y="+e),this.state.vw=t,this.state.vh=e,this.state._svggroup=null},t.prototype.offsetViewportOrg=function(t,e){i.Helper.log("[gdi] offsetViewportOrg: offX="+t+" offY="+e),this.state.vx+=t,this.state.vy+=e,this.state._svggroup=null},t.prototype.saveDC=function(){i.Helper.log("[gdi] saveDC");var t=this.state;this.state=new a(this.state),this.statestack.push(t),this.state._svggroup=null},t.prototype.restoreDC=function(t){if(i.Helper.log("[gdi] restoreDC: saved="+t),!(this.statestack.length>1))throw new i.WMFJSError("No saved contexts");if(-1===t)this.state=this.statestack.pop();else{if(t<-1)throw new i.WMFJSError("restoreDC: relative restore not implemented");if(t>1)throw new i.WMFJSError("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.escape=function(t,e,r,s){i.Helper.log("[gdi] escape: func="+t+" offset="+r+" count="+s)},t.prototype.setStretchBltMode=function(t){i.Helper.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.stretchDib=function(t,e,r,s,n,o,l,a,h,p,c){i.Helper.log("[gdi] stretchDib: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),r=this._todevW(r),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),l=this._todevW(l),a=this._todevH(a),i.Helper.log("[gdi] stretchDib: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)+" colorUsage=0x"+p.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,l,a,c.base64ref())},t.prototype.stretchDibBits=function(t,e,r,s,n,o,l,a,h,p){i.Helper.log("[gdi] stretchDibBits: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),r=this._todevW(r),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),l=this._todevW(l),a=this._todevH(a),i.Helper.log("[gdi] stretchDibBits: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,l,a,p.base64ref())},t.prototype.rectangle=function(t,e,r){i.Helper.log("[gdi] rectangle: rect="+t.toString()+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());var s=this._todevY(t.bottom),n=this._todevX(t.right),o=this._todevY(t.top),l=this._todevX(t.left);e=this._todevH(e),r=this._todevH(r),i.Helper.log("[gdi] rectangle: TRANSLATED: bottom="+s+" right="+n+" top="+o+" left="+l+" rh="+r+" rw="+e),this._pushGroup();var a=this._applyOpts(null,!0,!0,!1);this._svg.rect(this.state._svggroup,l,o,n-l,s-o,e/2,r/2,a)},t.prototype.textOut=function(t,e,r){i.Helper.log("[gdi] textOut: x="+t+" y="+e+" text="+r+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),i.Helper.log("[gdi] textOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var n=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(n.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",n.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===i.Helper.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var o=i.Helper._makeUniqueId("f"),l=this._svg.filter(this._getSvgDef(),o,0,0,1,1);this._svg.filters.flood(l,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(l,null,null,"SourceGraphic"),this.state._svgtextbkfilter=l}n.filter="url(#"+s(this.state._svgtextbkfilter).attr("id")+")"}this._svg.text(this.state._svggroup,t,e,r,n)},t.prototype.extTextOut=function(t,e,r,n,o,l){i.Helper.log("[gdi] extTextOut: x="+t+" y="+e+" text="+r+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),i.Helper.log("[gdi] extTextOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var a=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(a.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",a.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===i.Helper.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var h=i.Helper._makeUniqueId("f"),p=this._svg.filter(this._getSvgDef(),h,0,0,1,1);this._svg.filters.flood(p,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(p,null,null,"SourceGraphic"),this.state._svgtextbkfilter=p}a.filter="url(#"+s(this.state._svgtextbkfilter).attr("id")+")"}this._svg.text(this.state._svggroup,t,e,r,a)},t.prototype.lineTo=function(t,e){i.Helper.log("[gdi] lineTo: x="+t+" y="+e+" with pen "+this.state.selected.pen.toString());var r=this._todevX(t),s=this._todevY(e),n=this._todevX(this.state.x),o=this._todevY(this.state.y);this.state.x=t,this.state.y=e,i.Helper.log("[gdi] lineTo: TRANSLATED: toX="+r+" toY="+s+" fromX="+n+" fromY="+o),this._pushGroup();var l=this._applyOpts(null,!0,!1,!1);this._svg.line(this.state._svggroup,n,o,r,s,l)},t.prototype.moveTo=function(t,e){i.Helper.log("[gdi] moveTo: x="+t+" y="+e),this.state.x=t,this.state.y=e},t.prototype.polygon=function(t,e){i.Helper.log("[gdi] polygon: points="+t+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var r=[],s=0;s<t.length;s++){var n=t[s];r.push([this._todevX(n.x),this._todevY(n.y)])}i.Helper.log("[gdi] polygon: TRANSLATED: pts="+r),e&&this._pushGroup();var o={"fill-rule":this.state.polyfillmode===i.Helper.GDI.PolyFillMode.ALTERNATE?"evenodd":"nonzero"};this._applyOpts(o,!0,!0,!1),this._svg.polygon(this.state._svggroup,r,o)},t.prototype.polyPolygon=function(t){i.Helper.log("[gdi] polyPolygon: polygons.length="+t.length+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var e=t.length,r=0;r<e;r++)this.polygon(t[r],0===r)},t.prototype.polyline=function(t){i.Helper.log("[gdi] polyline: points="+t+" with pen "+this.state.selected.pen.toString());for(var e=[],r=0;r<t.length;r++){var s=t[r];e.push([this._todevX(s.x),this._todevY(s.y)])}i.Helper.log("[gdi] polyline: TRANSLATED: pts="+e),this._pushGroup();var n=this._applyOpts({fill:"none"},!0,!1,!1);this._svg.polyline(this.state._svggroup,e,n)},t.prototype.ellipse=function(t){i.Helper.log("[gdi] ellipse: rect="+t.toString()+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());var e=this._todevY(t.bottom),r=this._todevX(t.right),s=this._todevY(t.top),n=this._todevX(t.left);i.Helper.log("[gdi] ellipse: TRANSLATED: bottom="+e+" right="+r+" top="+s+" left="+n),this._pushGroup();var o=(r-n)/2,l=(e-s)/2,a=this._applyOpts(null,!0,!0,!1);this._svg.ellipse(this.state._svggroup,n+o,s+l,o,l,a)},t.prototype.excludeClipRect=function(t){i.Helper.log("[gdi] excludeClipRect: rect="+t.toString()),this._getClipRgn().subtract(t)},t.prototype.intersectClipRect=function(t){i.Helper.log("[gdi] intersectClipRect: rect="+t.toString()),this._getClipRgn().intersect(t)},t.prototype.offsetClipRgn=function(t,e){i.Helper.log("[gdi] offsetClipRgn: offX="+t+" offY="+e),this._getClipRgn().offset(t,e)},t.prototype.setTextAlign=function(t){i.Helper.log("[gdi] setTextAlign: textAlignmentMode=0x"+t.toString(16)),this.state.textalign=t},t.prototype.setBkMode=function(t){i.Helper.log("[gdi] setBkMode: bkMode=0x"+t.toString(16)),this.state.bkmode=t},t.prototype.setTextColor=function(t){i.Helper.log("[gdi] setTextColor: textColor="+t.toString()),this.state.textcolor=t},t.prototype.setBkColor=function(t){i.Helper.log("[gdi] setBkColor: bkColor="+t.toString()),this.state.bkcolor=t,this.state._svgtextbkfilter=null},t.prototype.setPolyFillMode=function(t){i.Helper.log("[gdi] setPolyFillMode: polyFillMode="+t),this.state.polyfillmode=t},t.prototype.createBrush=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createBrush: brush="+t.toString()+" with handle "+e)},t.prototype.createFont=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createFont: font="+t.toString()+" with handle "+e)},t.prototype.createPen=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createPen: pen="+t.toString()+" width handle "+e)},t.prototype.createPalette=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createPalette: palette="+t.toString()+" width handle "+e)},t.prototype.createRegion=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createRegion: region="+t.toString()+" width handle "+e)},t.prototype.createPatternBrush=function(t){var e=this._storeObject(t);i.Helper.log("[gdi] createRegion: region="+t.toString()+" width handle "+e)},t.prototype.selectObject=function(t,e){var r=this._getObject(t);null==r||null!=e&&r.type!==e?i.Helper.log("[gdi] selectObject: objIdx="+t+(r?" invalid object type: "+r.type:"[invalid index]")):(this._selectObject(r),i.Helper.log("[gdi] selectObject: objIdx="+t+(r?" selected "+r.type+": "+r.toString():"[invalid index]")))},t.prototype.deleteObject=function(t){var e=this._deleteObject(t);i.Helper.log("[gdi] deleteObject: objIdx="+t+(e?" deleted object":"[invalid index]"))},t.prototype._pushGroup=function(){if(null==this.state._svggroup||this.state._svgclipChanged){this.state._svgclipChanged=!1,this.state._svgtextbkfilter=null;var t={viewBox:[this.state.vx,this.state.vy,this.state.vw,this.state.vh].join(" "),preserveAspectRatio:"none"};null!=this.state.clip?(i.Helper.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" with clipping"),t["clip-path"]="url(#"+this._getSvgClipPathForRegion(this.state.clip)+")"):i.Helper.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" without clipping"),this.state._svggroup=this._svg.svg(this.state._svggroup,this.state.vx,this.state.vy,this.state.vw,this.state.vh,t)}},t.prototype._storeObject=function(t){for(var e=0;null!=this.objects[e.toString()]&&e<=65535;)e++;return e>65535?(i.Helper.log("[gdi] Too many objects!"),-1):(this.objects[e.toString()]=t,e)},t.prototype._getObject=function(t){var e=this.objects[t.toString()];return null==e&&i.Helper.log("[gdi] No object with handle "+t),e},t.prototype._getSvgDef=function(){return null==this._svgdefs&&(this._svgdefs=this._svg.defs()),this._svgdefs},t.prototype._getSvgClipPathForRegion=function(t){for(var e in this._svgClipPaths){if(this._svgClipPaths[e]===t)return e}var r=i.Helper._makeUniqueId("c"),s=this._svg.clipPath(this._getSvgDef(),r,"userSpaceOnUse");switch(t.complexity){case 1:this._svg.rect(s,this._todevX(t.bounds.left),this._todevY(t.bounds.top),this._todevW(t.bounds.right-t.bounds.left),this._todevH(t.bounds.bottom-t.bounds.top),{fill:"black",strokeWidth:0});break;case 2:for(var n=0;n<t.scans.length;n++)for(var o=t.scans[n],l=0;l<o.scanlines.length;l++){var a=o.scanlines[l];this._svg.rect(s,this._todevX(a.left),this._todevY(o.top),this._todevW(a.right-a.left),this._todevH(o.bottom-o.top),{fill:"black",strokeWidth:0})}}return this._svgClipPaths[r]=t,r},t.prototype._getSvgPatternForBrush=function(t){for(var e in this._svgPatterns){if(this._svgPatterns[e]===t)return e}var r,s,n;switch(t.style){case i.Helper.GDI.BrushStyle.BS_PATTERN:r=t.pattern.getWidth(),s=t.pattern.getHeight();break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:r=t.dibpatternpt.getWidth(),s=t.dibpatternpt.getHeight(),n=t.dibpatternpt.base64ref();break;default:throw new i.WMFJSError("Invalid brush style")}var o=i.Helper._makeUniqueId("p"),l=this._svg.pattern(this._getSvgDef(),o,0,0,r,s,{patternUnits:"userSpaceOnUse"});return this._svg.image(l,0,0,r,s,n),this._svgPatterns[o]=t,o},t.prototype._selectObject=function(t){this.state.selected[t.type]=t,"region"===t.type&&(this.state._svgclipChanged=!0)},t.prototype._deleteObject=function(t){var e=this.objects[t.toString()];if(null!=e){for(var r=0;r<this.statestack.length;r++){var s=this.statestack[r];s.selected[e.type]===e&&(s.selected[e.type]=this.defObjects[e.type].clone())}return delete this.objects[t.toString()],!0}return i.Helper.log("[gdi] Cannot delete object with invalid handle "+t),!1},t.prototype._getClipRgn=function(){return null!=this.state.clip?this.state.ownclip||(this.state.clip=this.state.clip.clone()):null!=this.state.selected.region?this.state.clip=this.state.selected.region.clone():this.state.clip=Object(o.CreateSimpleRegion)(this.state.wx,this.state.wy,this.state.wx+this.state.ww,this.state.wy+this.state.wh),this.state.ownclip=!0,this.state.clip},t.prototype._todevX=function(t){return Math.floor((t-this.state.wx)*(this.state.vw/this.state.ww))+this.state.vx},t.prototype._todevY=function(t){return Math.floor((t-this.state.wy)*(this.state.vh/this.state.wh))+this.state.vy},t.prototype._todevW=function(t){return Math.floor(t*(this.state.vw/this.state.ww))+this.state.vx},t.prototype._todevH=function(t){return Math.floor(t*(this.state.vh/this.state.wh))+this.state.vy},t.prototype._tologicalX=function(t){return Math.floor((t-this.state.vx)/(this.state.vw/this.state.ww))+this.state.wx},t.prototype._tologicalY=function(t){return Math.floor((t-this.state.vy)/(this.state.vh/this.state.wh))+this.state.wy},t.prototype._tologicalW=function(t){return Math.floor(t/(this.state.vw/this.state.ww))+this.state.wx},t.prototype._tologicalH=function(t){return Math.floor(t/(this.state.vh/this.state.wh))+this.state.wy},t.prototype._applyOpts=function(t,e,r,s){if(null==t&&(t={}),e){var n=this.state.selected.pen;if(n.style!==i.Helper.GDI.PenStyle.PS_NULL){t.stroke="#"+n.color.toHex(),t.strokeWidth=this._todevW(n.width.x);var o=void 0;0!=(n.linecap&i.Helper.GDI.PenStyle.PS_ENDCAP_SQUARE)?(t["stroke-linecap"]="square",o=1):0!=(n.linecap&i.Helper.GDI.PenStyle.PS_ENDCAP_FLAT)?(t["stroke-linecap"]="butt",o=t.strokeWidth):(t["stroke-linecap"]="round",o=1),0!=(n.join&i.Helper.GDI.PenStyle.PS_JOIN_BEVEL)?t["stroke-linejoin"]="bevel":0!=(n.join&i.Helper.GDI.PenStyle.PS_JOIN_MITER)?t["stroke-linejoin"]="miter":t["stroke-linejoin"]="round";var l=4*t.strokeWidth,a=2*t.strokeWidth;switch(n.style){case i.Helper.GDI.PenStyle.PS_DASH:t["stroke-dasharray"]=[l,a].toString();break;case i.Helper.GDI.PenStyle.PS_DOT:t["stroke-dasharray"]=[o,a].toString();break;case i.Helper.GDI.PenStyle.PS_DASHDOT:t["stroke-dasharray"]=[l,a,o,a].toString();break;case i.Helper.GDI.PenStyle.PS_DASHDOTDOT:t["stroke-dasharray"]=[l,a,o,a,o,a].toString()}}}if(r){var h=this.state.selected.brush;switch(h.style){case i.Helper.GDI.BrushStyle.BS_SOLID:t.fill="#"+h.color.toHex();break;case i.Helper.GDI.BrushStyle.BS_PATTERN:case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:t.fill="url(#"+this._getSvgPatternForBrush(h)+")";break;case i.Helper.GDI.BrushStyle.BS_NULL:t.fill="none";break;default:i.Helper.log("[gdi] unsupported brush style: "+h.style),t.fill="none"}}if(s){var p=this.state.selected.font;t["font-family"]=p.facename,t["font-size"]=this._todevH(Math.abs(p.height)),t.fill="#"+this.state.textcolor.toHex()}return t},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"PointS",function(){return i}),r.d(e,"Rect",function(){return n}),r.d(e,"Obj",function(){return o});var s=r(39),i=function(){function t(t,e,r){null!=t?(this.x=t.readInt16(),this.y=t.readInt16()):(this.x=e,this.y=r)}return t.prototype.clone=function(){return new t(null,this.x,this.y)},t.prototype.toString=function(){return"{x: "+this.x+", y: "+this.y+"}"},t}(),n=function(){function t(t,e,r,s,i){null!=t?(this.bottom=t.readInt16(),this.right=t.readInt16(),this.top=t.readInt16(),this.left=t.readInt16()):(this.bottom=i,this.right=s,this.top=r,this.left=e)}return t.prototype.clone=function(){return new t(null,this.left,this.top,this.right,this.bottom)},t.prototype.toString=function(){return"{left: "+this.left+", top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+"}"},t.prototype.empty=function(){return this.left>=this.right||this.top>=this.bottom},t.prototype.intersect=function(e){return this.empty()||e.empty()?null:this.left>=e.right||this.top>=e.bottom||this.right<=e.left||this.bottom<=e.top?null:new t(null,Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom))},t}(),o=function(){function t(t){this.type=t}return t.prototype.clone=function(){throw new s.WMFJSError("clone not implemented")},t.prototype.toString=function(){throw new s.WMFJSError("toString not implemented")},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"Region",function(){return o}),r.d(e,"CreateSimpleRegion",function(){return l}),r.d(e,"Scan",function(){return a});var s=r(39),i=r(41),n=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),o=function(t){function e(e,r){var n=t.call(this,"region")||this;if(null!=e){if(e.skip(2),6!==e.readInt16())throw new s.WMFJSError("Invalid region identifier");e.skip(2);e.readInt16();var o=e.readInt16();e.skip(2);var l=e.readInt16(),h=e.readInt16(),p=e.readInt16(),c=e.readInt16();n.bounds=new i.Rect(null,l,h,p,c),n.scans=[];for(var u=0;u<o;u++)n.scans.push(new a(e));n._updateComplexity()}else if(null!=r){if(n.bounds=null!=r.bounds?r.bounds.clone():null,null!=r.scans){n.scans=[];for(u=0;u<r.scans.length;u++)n.scans.push(r.scans[u].clone())}else n.scans=null;n.complexity=r.complexity}else n.bounds=null,n.scans=null,n.complexity=0;return n}return n(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return"{complexity: "+["null","simple","complex"][this.complexity]+" bounds: "+(null!=this.bounds?this.bounds.toString():"[none]")+" #scans: "+(null!=this.scans?this.scans.length:"[none]")+"}"},e.prototype._updateComplexity=function(){if(null==this.bounds)this.complexity=0,this.scans=null;else if(this.bounds.empty())this.complexity=0,this.scans=null,this.bounds=null;else if(null==this.scans)this.complexity=1;else if(this.complexity=2,1===this.scans.length){var t=this.scans[0];if(t.top===this.bounds.top&&t.bottom===this.bounds.bottom&&1===t.scanlines.length){var e=t.scanlines[0];e.left===this.bounds.left&&e.right===this.bounds.right&&(this.scans=null,this.complexity=1)}}},e.prototype.subtract=function(t){if((s.Helper.log("[wmf] Region "+this.toString()+" subtract "+t.toString()),null!=this.bounds)&&null!=this.bounds.intersect(t)){null==this.scans&&(this.scans=[],this.scans.push(new a(null,null,this.bounds.top,this.bounds.bottom,[{left:this.bounds.left,right:this.bounds.right}])),this.complexity=2);for(var e=0;e<this.scans.length;){if((f=this.scans[e]).bottom>=t.top){var r=f.clone();f.bottom=t.top-1,r.top=t.top,f.top>=f.bottom?this.scans[e]=r:(s.Helper.log("[wmf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}for(var n=e;e<this.scans.length;){if((f=this.scans[e]).top>t.bottom)break;if(f.bottom>t.bottom){r=f.clone();f.bottom=t.bottom,r.top=t.bottom+1,f.top>=f.bottom?this.scans[e]=r:(s.Helper.log("[wmf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}if(n<this.scans.length){var o=e;for(e=n;e<o;){(f=this.scans[e]).subtract(t.left,t.right)?e++:(s.Helper.log("[wmf] Region remove now empty scan "+e+" due to subtraction"),this.scans.splice(e,1),o--)}}if(null!=this.scans){for(var l,h=void 0,p=void 0,c=void 0,u=this.scans.length,d=0;d<u;d++){var f=this.scans[d];0===d&&(l=f.top),d===u-1&&(c=f.bottom);var E=f.scanlines.length;if(E>0){var T=f.scanlines[0];(null==h||T.left<h)&&(h=T.left),T=f.scanlines[E-1],(null==p||T.right>p)&&(p=T.right)}}null!=h&&null!=l&&null!=p&&null!=c?(this.bounds=new i.Rect(null,h,l,p,c),this._updateComplexity()):(this.bounds=null,this.scans=null,this.complexity=0)}else this._updateComplexity()}s.Helper.log("[wmf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(s.Helper.log("[wmf] Region "+this.toString()+" intersect with "+t.toString()),null!=this.bounds)if(this.bounds=this.bounds.intersect(t),null!=this.bounds){if(null!=this.scans){for(var e=0;e<this.scans.length;){if(!((r=this.scans[e]).bottom<this.bounds.top))break;e++}for(e>0&&(s.Helper.log("[wmf] Region remove "+e+" scans from top"),this.scans.splice(0,e),this.scans.length>0&&(this.scans[0].top=this.bounds.top)),e=0;e<this.scans.length;){var r;if((r=this.scans[e]).top>this.bounds.bottom){s.Helper.log("[wmf] Region remove "+(this.scans.length-e)+" scans from bottom"),this.scans.splice(e,this.scans.length-e);break}r.intersect(this.bounds.left,this.bounds.right)?e++:(s.Helper.log("[wmf] Region remove now empty scan "+e+" due to intersection"),this.scans.splice(e,1))}this.scans.length>0&&(this.scans[this.scans.length-1].bottom=this.bounds.bottom),this._updateComplexity()}}else this.scans=null,this.complexity=0;s.Helper.log("[wmf] Region intersection -> "+this.toString())},e.prototype.offset=function(t,e){if(null!=this.bounds&&(this.bounds.left+=t,this.bounds.top+=e,this.bounds.right+=t,this.bounds.bottom+=e),null!=this.scans)for(var r=this.scans.length,s=0;s<r;s++){var i=this.scans[s];i.top+=e,i.bottom+=e;for(var n=i.scanlines.length,o=0;o<n;o++){var l=i.scanlines[o];l.left+=t,l.right+=t}}},e}(i.Obj);function l(t,e,r,s){var n=new o(null,null);return n.bounds=new i.Rect(null,t,e,r,s),n._updateComplexity(),n}var a=function(){function t(t,e,r,s,i){if(null!=t){var n=t.readUint16();this.top=t.readUint16(),this.bottom=t.readUint16(),this.scanlines=[];for(var o=0;o<n;o++){var l=t.readUint16(),a=t.readUint16();this.scanlines.push({left:l,right:a})}t.skip(2)}else if(null!=e){this.top=e.top,this.bottom=e.bottom,this.scanlines=[];for(o=0;o<e.scanlines.length;o++){var h=e.scanlines[o];this.scanlines.push({left:h.left,right:h.right})}}else this.top=r,this.bottom=s,this.scanlines=i}return t.prototype.clone=function(){return new t(null,this)},t.prototype.subtract=function(t,e){var r;for(r=0;r<this.scanlines.length;){if(!((n=this.scanlines[r]).left<=t))break;n.right>=t&&(n.right=t-1,n.left>=n.right)?this.scanlines.splice(r,1):r++}for(var s=r,i=0;r<this.scanlines.length;){var n;if((n=this.scanlines[r]).right>e){n.left=e,i=r-s,n.left>=n.right&&i++;break}r++}return i>0&&s<this.scanlines.length&&this.scanlines.splice(s,i),this.scanlines.length>0},t.prototype.intersect=function(t,e){for(var r=0;r<this.scanlines.length;r++){if((s=this.scanlines[r]).left>=t||s.right>=t){r>0&&this.scanlines.splice(0,r);break}}if(this.scanlines.length>0){var s;(s=this.scanlines[0]).left<t&&(s.left=t);for(r=0;r<this.scanlines.length;r++)if((s=this.scanlines[r]).left>e){this.scanlines.splice(r,this.scanlines.length-r);break}this.scanlines.length>0&&(s=this.scanlines[this.scanlines.length-1]).right>e&&(s.right=e)}return this.scanlines.length>0},t.prototype.toString=function(){return"{ #scanlines: "+this.scanlines.length+"}"},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"ColorRef",function(){return l}),r.d(e,"Font",function(){return a}),r.d(e,"Brush",function(){return h}),r.d(e,"Pen",function(){return p}),r.d(e,"PaletteEntry",function(){return c}),r.d(e,"Palette",function(){return u});var s=r(44),i=r(39),n=r(41),o=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),l=function(){function t(t,e,r,s){null!=t?(this.r=t.readUint8(),this.g=t.readUint8(),this.b=t.readUint8(),t.skip(1)):(this.r=e,this.g=r,this.b=s)}return t.prototype.clone=function(){return new t(null,this.r,this.g,this.b)},t.prototype.toHex=function(){return(16777216+(this.r<<16|this.g<<8|this.b)).toString(16).slice(1)},t.prototype.toString=function(){return"{r: "+this.r+", g: "+this.g+", b: "+this.b+"}"},t}(),a=function(t){function e(e,r){var s=t.call(this,"font")||this;if(null!=e){s.height=e.readInt16(),s.width=e.readInt16(),s.escapement=e.readInt16(),s.orientation=e.readInt16(),s.weight=e.readInt16(),s.italic=e.readUint8(),s.underline=e.readUint8(),s.strikeout=e.readUint8(),s.charset=e.readUint8(),s.outprecision=e.readUint8(),s.clipprecision=e.readUint8(),s.quality=e.readUint8();var i=e.readUint8();s.pitch=15&i,s.family=i>>6&3;var n=r,o=e.pos;s.facename=e.readNullTermString(Math.min(n-(e.pos-o),32))}else null!=r?(r=r,s.height=r.height,s.width=r.width,s.escapement=r.escapement,s.orientation=r.orientation,s.weight=r.weight,s.italic=r.italic,s.underline=r.underline,s.strikeout=r.strikeout,s.charset=r.charset,s.outprecision=r.outprecision,s.clipprecision=r.clipprecision,s.quality=r.quality,s.pitch=r.pitch,s.family=r.family,s.facename=r.facename):(s.height=-80,s.width=0,s.escapement=0,s.orientation=0,s.weight=400,s.italic=0,s.underline=0,s.strikeout=0,s.charset=0,s.outprecision=0,s.clipprecision=0,s.quality=0,s.pitch=0,s.family=0,s.facename="Helvetica");return s}return o(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return JSON.stringify(this)},e}(n.Obj),h=function(t){function e(e,r,n){var o=t.call(this,"brush")||this;if(null!=e){var a=r,h=e.pos;if(!0===n||!1===n)switch(o.style=e.readUint16(),n&&o.style!==i.Helper.GDI.BrushStyle.BS_PATTERN&&(o.style=i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT),o.style){case i.Helper.GDI.BrushStyle.BS_SOLID:o.color=new l(e);break;case i.Helper.GDI.BrushStyle.BS_PATTERN:e.skip(n?2:6),o.pattern=new s.Bitmap16(e,a-(e.pos-h));break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:o.colorusage=n?e.readUint16():e.readUint32(),n||e.skip(2),o.dibpatternpt=new s.DIBitmap(e,a-(e.pos-h));break;case i.Helper.GDI.BrushStyle.BS_HATCHED:o.color=new l(e),o.hatchstyle=e.readUint16()}else n instanceof s.PatternBitmap16&&(o.style=i.Helper.GDI.BrushStyle.BS_PATTERN,o.pattern=n)}else if(null!=r)switch(r=r,o.style=r.style,o.style){case i.Helper.GDI.BrushStyle.BS_SOLID:o.color=r.color.clone();break;case i.Helper.GDI.BrushStyle.BS_PATTERN:o.pattern=r.pattern.clone();break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:o.colorusage=r.colorusage,o.dibpatternpt=r.dibpatternpt;break;case i.Helper.GDI.BrushStyle.BS_HATCHED:o.color=r.color.clone(),o.hatchstyle=r.hatchstyle}return o}return o(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){var t="{style: "+this.style;switch(this.style){case i.Helper.GDI.BrushStyle.BS_SOLID:t+=", color: "+this.color.toString();break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:t+=", colorusage: "+this.colorusage;break;case i.Helper.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(n.Obj),p=function(t){function e(e,r,s,o,a,h){var p=t.call(this,"pen")||this;return null!=e?(r=e.readUint16(),p.style=255&r,p.width=new n.PointS(e),p.color=new l(e),p.linecap=r&(i.Helper.GDI.PenStyle.PS_ENDCAP_SQUARE|i.Helper.GDI.PenStyle.PS_ENDCAP_FLAT),p.join=r&(i.Helper.GDI.PenStyle.PS_JOIN_BEVEL|i.Helper.GDI.PenStyle.PS_JOIN_MITER)):(p.style=r,p.width=s,p.color=o,p.linecap=a,p.join=h),p}return o(e,t),e.prototype.clone=function(){return new e(null,this.style,this.width.clone(),this.color.clone(),this.linecap,this.join)},e.prototype.toString=function(){return"{style: "+this.style+", width: "+this.width.toString()+", color: "+this.color.toString()+", linecap: "+this.linecap+", join: "+this.join+"}"},e}(n.Obj),c=function(){function t(t,e){null!=t?(this.flag=t.readUint8(),this.b=t.readUint8(),this.g=t.readUint8(),this.r=t.readUint8()):(this.flag=e.flag,this.b=e.b,this.g=e.g,this.r=e.r)}return t.prototype.clone=function(){return new t(null,this)},t}(),u=function(t){function e(e,r){var s=t.call(this,"palette")||this;if(null!=e){s.start=e.readUint16();var i=e.readUint16();for(s.entries=[];i>0;)s.entries.push(new c(e))}else{s.start=r.start,s.entries=[];for(var n=r.entries.length,o=0;o<n;o++)s.entries.push(r.entries[o])}return s}return o(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return"{ #entries: "+this.entries.length+"}"},e}(n.Obj)},function(t,e,r){"use strict";r.r(e),r.d(e,"BitmapBase",function(){return n}),r.d(e,"BitmapCoreHeader",function(){return o}),r.d(e,"BitmapInfoHeader",function(){return l}),r.d(e,"BitmapInfo",function(){return a}),r.d(e,"DIBitmap",function(){return h}),r.d(e,"Bitmap16",function(){return p}),r.d(e,"PatternBitmap16",function(){return c});var s=r(39),i=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),n=function(){function t(){}return t.prototype.getWidth=function(){throw new s.WMFJSError("getWidth not implemented")},t.prototype.getHeight=function(){throw new s.WMFJSError("getHeight not implemented")},t}(),o=function(){function t(t,e){e&&t.skip(4),this.width=t.readUint16(),this.height=t.readUint16(),this.planes=t.readUint16(),this.bitcount=t.readUint16()}return t.prototype.colors=function(){return this.bitcount<=8?1<<this.bitcount:0},t}(),l=function(){function t(t,e){e&&t.skip(4),this.width=t.readInt32(),this.height=t.readInt32(),this.planes=t.readUint16(),this.bitcount=t.readUint16(),this.compression=t.readUint32(),this.sizeimage=t.readUint32(),this.xpelspermeter=t.readInt32(),this.ypelspermeter=t.readInt32(),this.clrused=t.readUint32(),this.clrimportant=t.readUint32()}return t.prototype.colors=function(){return 0!==this.clrused?this.clrused<256?this.clrused:256:this.bitcount>8?0:1<<this.bitcount},t}(),a=function(t){function e(e,r){var i=t.call(this)||this;i._reader=e,i._offset=e.pos,i._usergb=r;var n=e.readUint32();if(i._infosize=n,n===s.Helper.GDI.BITMAPCOREHEADER_SIZE)i._header=new o(e,!1),i._infosize+=i._header.colors()*(r?3:2);else{i._header=new l(e,!1);var a=i._header.compression===s.Helper.GDI.BitmapCompression.BI_BITFIELDS?3:0;n<=s.Helper.GDI.BITMAPINFOHEADER_SIZE+4*a&&(i._infosize=s.Helper.GDI.BITMAPINFOHEADER_SIZE+4*a),i._infosize+=i._header.colors()*(r?4:2)}return i}return i(e,t),e.prototype.getWidth=function(){return this._header.width},e.prototype.getHeight=function(){return Math.abs(this._header.height)},e.prototype.infosize=function(){return this._infosize},e.prototype.header=function(){return this._header},e}(n),h=function(t){function e(e,r){var s=t.call(this)||this;return s._reader=e,s._offset=e.pos,s._size=r,s._info=new a(e,!0),s}return i(e,t),e.prototype.getWidth=function(){return this._info.getWidth()},e.prototype.getHeight=function(){return this._info.getHeight()},e.prototype.base64ref=function(){var t=this._reader.pos;this._reader.seek(this._offset);var e,r="image/bmp",i=this._info.header();if(i instanceof l&&null!=i.compression)switch(i.compression){case s.Helper.GDI.BitmapCompression.BI_JPEG:r="data:image/jpeg";break;case s.Helper.GDI.BitmapCompression.BI_PNG:r="data:image/png";break;default:e=this.makeBitmapFileHeader()}else e=this.makeBitmapFileHeader();null!=e?e+=this._reader.readBinary(this._size):e=this._reader.readBinary(this._size);var n="data:"+r+";base64,"+btoa(e);return this._reader.seek(t),n},e.prototype.makeBitmapFileHeader=function(){var t=new ArrayBuffer(14),e=new Uint8Array(t);return e[0]=66,e[1]=77,s.Helper._writeUint32Val(e,2,this._size+14),s.Helper._writeUint32Val(e,10,this._info.infosize()+14),s.Helper._blobToBinary(e)},e}(n),p=function(t){function e(e,r){var i=t.call(this)||this;if(null!=e){if(r=r,i._reader=e,i._offset=e.pos,i._size=r,i.type=e.readInt16(),i.width=e.readInt16(),i.height=e.readInt16(),i.widthBytes=e.readInt16(),i.planes=e.readUint8(),i.bitsPixel=e.readUint8(),i.bitsOffset=e.pos,i.bitsSize=(i.width*i.bitsPixel+15>>4<<1)*i.height,i.bitsSize>r-10)throw new s.WMFJSError("Bitmap should have "+i.bitsSize+" bytes, but has "+(r-10))}else{var n=r;i._reader=n._reader,i._offset=n._offset,i._size=n._size,i.type=n.type,i.width=n.width,i.height=n.height,i.widthBytes=n.widthBytes,i.planes=n.planes,i.bitsPixel=n.bitsPixel,i.bitsOffset=n.bitsOffset,i.bitsSize=n.bitsSize}return i}return i(e,t),e.prototype.getWidth=function(){return this.width},e.prototype.getHeight=function(){return this.height},e.prototype.clone=function(){return new e(null,this)},e}(n),c=function(t){function e(e,r){var s=t.call(this,e,r)||this;return null!=e&&(s.bitsOffset+=22),s}return i(e,t),e.prototype.clone=function(){return new e(null,this)},e}(p)},function(t,e,r){"use strict";r.r(e),r.d(e,"WMFRecords",function(){return h});var s=r(44),i=r(38),n=r(39),o=r(41),l=r(42),a=r(43),h=function(){function t(t,e){this._records=[];var r=!1,h=e,p=function(){t.seek(h);var e=t.readUint32();if(e<3)throw new n.WMFJSError("Invalid record size");var p=t.readUint16();switch(p){case n.Helper.GDI.RecordType.META_EOF:return r=!0,"break-main_loop";case n.Helper.GDI.RecordType.META_SETMAPMODE:var u=t.readUint16();c._records.push(function(t){t.setMapMode(u)});break;case n.Helper.GDI.RecordType.META_SETWINDOWORG:var d=t.readInt16(),f=t.readInt16();c._records.push(function(t){t.setWindowOrg(f,d)});break;case n.Helper.GDI.RecordType.META_SETWINDOWEXT:var E=t.readInt16(),T=t.readInt16();c._records.push(function(t){t.setWindowExt(T,E)});break;case n.Helper.GDI.RecordType.META_OFFSETWINDOWORG:var g=t.readInt16(),_=t.readInt16();c._records.push(function(t){t.offsetWindowOrg(_,g)});break;case n.Helper.GDI.RecordType.META_SETVIEWPORTORG:var I=t.readInt16(),y=t.readInt16();c._records.push(function(t){t.setViewportOrg(y,I)});break;case n.Helper.GDI.RecordType.META_SETVIEWPORTEXT:var S=t.readInt16(),v=t.readInt16();c._records.push(function(t){t.setViewportExt(v,S)});break;case n.Helper.GDI.RecordType.META_OFFSETVIEWPORTORG:var A=t.readInt16(),R=t.readInt16();c._records.push(function(t){t.offsetViewportOrg(R,A)});break;case n.Helper.GDI.RecordType.META_SAVEDC:c._records.push(function(t){t.saveDC()});break;case n.Helper.GDI.RecordType.META_RESTOREDC:var b=t.readInt16();c._records.push(function(t){t.restoreDC(b)});break;case n.Helper.GDI.RecordType.META_SETSTRETCHBLTMODE:var M=t.readUint16();c._records.push(function(t){t.setStretchBltMode(M)});break;case n.Helper.GDI.RecordType.META_DIBSTRETCHBLT:var O=t.readUint16()|t.readUint16()<<16,H=t.readInt16(),D=t.readInt16(),w=t.readInt16(),P=t.readInt16(),m=t.readInt16(),C=t.readInt16(),G=t.readInt16(),B=t.readInt16(),N=2*e-(t.pos-h),x=new s.DIBitmap(t,N);c._records.push(function(t){t.stretchDibBits(P,w,D,H,B,G,C,m,O,x)});break;case n.Helper.GDI.RecordType.META_STRETCHDIB:var L=t.readUint16()|t.readUint16()<<16,k=t.readInt16(),U=t.readInt16(),F=t.readInt16(),W=t.readInt16(),j=t.readInt16(),X=t.readInt16(),Y=t.readInt16(),V=t.readInt16(),J=t.readInt16(),q=(N=2*e-(t.pos-h),new s.DIBitmap(t,N));c._records.push(function(t){t.stretchDib(j,W,F,U,J,V,Y,X,L,k,q)});break;case n.Helper.GDI.RecordType.META_ESCAPE:var z=t.readUint16(),Z=t.readUint16(),K=t.pos,Q=new i.Blob(t,K);c._records.push(function(t){t.escape(z,Q,K,Z)});break;case n.Helper.GDI.RecordType.META_SETTEXTALIGN:var $=t.readUint16();c._records.push(function(t){t.setTextAlign($)});break;case n.Helper.GDI.RecordType.META_SETBKMODE:var tt=t.readUint16();c._records.push(function(t){t.setBkMode(tt)});break;case n.Helper.GDI.RecordType.META_SETTEXTCOLOR:var et=new a.ColorRef(t);c._records.push(function(t){t.setTextColor(et)});break;case n.Helper.GDI.RecordType.META_SETBKCOLOR:var rt=new a.ColorRef(t);c._records.push(function(t){t.setBkColor(rt)});break;case n.Helper.GDI.RecordType.META_CREATEBRUSHINDIRECT:N=2*e-(t.pos-h);var st=new a.Brush(t,N,!1);c._records.push(function(t){t.createBrush(st)});break;case n.Helper.GDI.RecordType.META_DIBCREATEPATTERNBRUSH:N=2*e-(t.pos-h);var it=new a.Brush(t,N,!0);c._records.push(function(t){t.createBrush(it)});break;case n.Helper.GDI.RecordType.META_CREATEPENINDIRECT:var nt=new a.Pen(t);c._records.push(function(t){t.createPen(nt)});break;case n.Helper.GDI.RecordType.META_CREATEFONTINDIRECT:N=2*e-(t.pos-h);var ot=new a.Font(t,N);c._records.push(function(t){t.createFont(ot)});break;case n.Helper.GDI.RecordType.META_SELECTOBJECT:var lt=t.readUint16();c._records.push(function(t){t.selectObject(lt,null)});break;case n.Helper.GDI.RecordType.META_SELECTPALETTE:var at=t.readUint16();c._records.push(function(t){t.selectObject(at,"palette")});break;case n.Helper.GDI.RecordType.META_SELECTCLIPREGION:var ht=t.readUint16();c._records.push(function(t){t.selectObject(ht,"region")});break;case n.Helper.GDI.RecordType.META_DELETEOBJECT:var pt=t.readUint16();c._records.push(function(t){t.deleteObject(pt)});break;case n.Helper.GDI.RecordType.META_RECTANGLE:var ct=new o.Rect(t);c._records.push(function(t){t.rectangle(ct,0,0)});break;case n.Helper.GDI.RecordType.META_ROUNDRECT:var ut=t.readInt16(),dt=t.readInt16(),ft=new o.Rect(t);c._records.push(function(t){t.rectangle(ft,dt,ut)});break;case n.Helper.GDI.RecordType.META_LINETO:var Et=t.readInt16(),Tt=t.readInt16();c._records.push(function(t){t.lineTo(Tt,Et)});break;case n.Helper.GDI.RecordType.META_MOVETO:var gt=t.readInt16(),_t=t.readInt16();c._records.push(function(t){t.moveTo(_t,gt)});break;case n.Helper.GDI.RecordType.META_TEXTOUT:if((Rt=t.readInt16())>0){var It=t.readString(Rt);t.skip(Rt%2);var yt=t.readInt16(),St=t.readInt16();c._records.push(function(t){t.textOut(St,yt,It)})}break;case n.Helper.GDI.RecordType.META_EXTTEXTOUT:var vt=t.readInt16(),At=t.readInt16(),Rt=t.readInt16(),bt=t.readUint16(),Mt=null,Ot=null;2*e===14+Rt+Rt%2&&(Mt=!1,Ot=!1),2*e===22+Rt+Rt%2&&(Mt=!0,Ot=!1),2*e===14+Rt+Rt%2+2*Rt&&(Mt=!1,Ot=!0),2*e===22+Rt+Rt%2+2*Rt&&(Mt=!0,Ot=!0);var Ht=Mt?new o.Rect(t):null;if(Rt>0){var Dt=t.readString(Rt);t.skip(Rt%2);var wt=[];if(Ot)for(var Pt=0;Pt<Dt.length;Pt++)wt.push(t.readInt16());c._records.push(function(t){t.extTextOut(At,vt,Dt,bt,Ht,wt)})}break;case n.Helper.GDI.RecordType.META_EXCLUDECLIPRECT:var mt=new o.Rect(t);c._records.push(function(t){t.excludeClipRect(mt)});break;case n.Helper.GDI.RecordType.META_INTERSECTCLIPRECT:var Ct=new o.Rect(t);c._records.push(function(t){t.intersectClipRect(Ct)});break;case n.Helper.GDI.RecordType.META_POLYGON:for(var Gt=t.readInt16(),Bt=[];Gt>0;)Bt.push(new o.PointS(t)),Gt--;c._records.push(function(t){t.polygon(Bt,!0)});break;case n.Helper.GDI.RecordType.META_SETPOLYFILLMODE:var Nt=t.readUint16();c._records.push(function(t){t.setPolyFillMode(Nt)});break;case n.Helper.GDI.RecordType.META_POLYPOLYGON:Gt=t.readUint16();var xt=[];for(Pt=0;Pt<Gt;Pt++)xt.push(t.readUint16());var Lt=[];for(Pt=0;Pt<Gt;Pt++){for(var kt=xt[Pt],Ut=[],Ft=0;Ft<kt;Ft++)Ut.push(new o.PointS(t));Lt.push(Ut)}c._records.push(function(t){t.polyPolygon(Lt)});break;case n.Helper.GDI.RecordType.META_POLYLINE:Gt=t.readInt16();for(var Wt=[];Gt>0;)Wt.push(new o.PointS(t)),Gt--;c._records.push(function(t){t.polyline(Wt)});break;case n.Helper.GDI.RecordType.META_ELLIPSE:var jt=new o.Rect(t);c._records.push(function(t){t.ellipse(jt)});break;case n.Helper.GDI.RecordType.META_CREATEPALETTE:var Xt=new a.Palette(t);c._records.push(function(t){t.createPalette(Xt)});break;case n.Helper.GDI.RecordType.META_CREATEREGION:var Yt=new l.Region(t);c._records.push(function(t){t.createRegion(Yt)});break;case n.Helper.GDI.RecordType.META_CREATEPATTERNBRUSH:N=2*e-(t.pos-h);var Vt=new s.PatternBitmap16(t,N),Jt=new a.Brush(t,N,Vt);c._records.push(function(t){t.createPatternBrush(Jt)});break;case n.Helper.GDI.RecordType.META_OFFSETCLIPRGN:var qt=t.readInt16(),zt=t.readInt16();c._records.push(function(t){t.offsetClipRgn(zt,qt)});break;case n.Helper.GDI.RecordType.META_REALIZEPALETTE:case n.Helper.GDI.RecordType.META_SETPALENTRIES:case n.Helper.GDI.RecordType.META_SETROP2:case n.Helper.GDI.RecordType.META_SETRELABS:case n.Helper.GDI.RecordType.META_SETTEXTCHAREXTRA:case n.Helper.GDI.RecordType.META_RESIZEPALETTE:case n.Helper.GDI.RecordType.META_SETLAYOUT:case n.Helper.GDI.RecordType.META_FILLREGION:case n.Helper.GDI.RecordType.META_SETMAPPERFLAGS:case n.Helper.GDI.RecordType.META_SETTEXTJUSTIFICATION:case n.Helper.GDI.RecordType.META_SCALEWINDOWEXT:case n.Helper.GDI.RecordType.META_SCALEVIEWPORTEXT:case n.Helper.GDI.RecordType.META_FLOODFILL:case n.Helper.GDI.RecordType.META_FRAMEREGION:case n.Helper.GDI.RecordType.META_ANIMATEPALETTE:case n.Helper.GDI.RecordType.META_EXTFLOODFILL:case n.Helper.GDI.RecordType.META_SETPIXEL:case n.Helper.GDI.RecordType.META_PATBLT:case n.Helper.GDI.RecordType.META_PIE:case n.Helper.GDI.RecordType.META_STRETCHBLT:case n.Helper.GDI.RecordType.META_INVERTREGION:case n.Helper.GDI.RecordType.META_PAINTREGION:case n.Helper.GDI.RecordType.META_ARC:case n.Helper.GDI.RecordType.META_CHORD:case n.Helper.GDI.RecordType.META_BITBLT:case n.Helper.GDI.RecordType.META_SETDIBTODEV:case n.Helper.GDI.RecordType.META_DIBBITBLT:default:var Zt="UNKNOWN";for(var Kt in n.Helper.GDI.RecordType){if(n.Helper.GDI.RecordType[Kt]===p){Zt=Kt;break}}n.Helper.log("[WMF] "+Zt+" record (0x"+p.toString(16)+") at offset 0x"+h.toString(16)+" with "+2*e+" bytes")}h+=2*e},c=this;t:for(;!r;){switch(p()){case"break-main_loop":break t}}if(!r)throw new n.WMFJSError("Could not read all records")}return t.prototype.play=function(t){for(var e=this._records.length,r=0;r<e;r++)this._records[r](t)},t}()}])});
|
|
//# sourceMappingURL=WMFJS.bundle.min.js.map
|