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ACnBvW,KAAKgX,IAAMJ,EAAOL,YAClBvW,KAAKiX,MAAQL,EAAOL,YACpBvW,KAAKkX,OAASN,EAAOL,YAO7B,OAJW,YAAA5U,SAAP,WACI,MAAO,UAAY3B,KAAK+W,KAAO,UAAY/W,KAAKgX,IAAM,YAAchX,KAAKiX,MACnE,aAAejX,KAAKkX,OAAS,KAE3C,EAjBA,GAmBA,EAII,SAAYN,GACRA,EAAOd,KAAK,GACZ9V,KAAKspB,YAAc,IAAIC,EAAU3S,GACjC5W,KAAKwpB,aAAe5S,EAAOL,YAC3BK,EAAOd,KAAK,GACZc,EAAOd,KAAK,GACZyC,EAAOxR,IAAI,oBAAsB/G,KAAKspB,YAAc,QAAUtpB,KAAKwpB,aAAe,gBAI1F,aAMI,WAAY5S,EAAcoS,EAAuBG,EAAiBpP,GAC9D/Z,KAAKypB,SAAWN,EAChBnpB,KAAK0pB,SAAW3P,EAChB/Z,KAAK2pB,UAAYX,EACjBhpB,KAAKunB,SAAW,IAAIqC,EAAWhT,EAAQ5W,KAAK0pB,UAMpD,OAHW,YAAAlB,OAAP,SAAcd,GACV1nB,KAAKunB,SAASe,KAAKZ,IAE3B,EAhBA,G","sources":["webpack://rtfjs/webpack/universalModuleDefinition","webpack://rtfjs/webpack/bootstrap","webpack://rtfjs/webpack/runtime/define property getters","webpack://rtfjs/webpack/runtime/hasOwnProperty shorthand","webpack://rtfjs/webpack/runtime/make namespace object","webpack://rtfjs/./src/util/SVG.ts","webpack://rtfjs/./src/wmfjs/Helper.ts","webpack://rtfjs/./src/wmfjs/Blob.ts","webpack://rtfjs/./src/wmfjs/Primitives.ts","webpack://rtfjs/./src/wmfjs/Region.ts","webpack://rtfjs/./src/wmfjs/Bitmap.ts","webpack://rtfjs/./src/wmfjs/Style.ts","webpack://rtfjs/./src/wmfjs/GDIContext.ts","webpack://rtfjs/./src/wmfjs/WMFRecords.ts","webpack://rtfjs/./src/wmfjs/Renderer.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WMFJS\"] = factory();\n\telse\n\t\troot[\"WMFJS\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2020 Ynse Hoornenborg\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nexport class SVGFilters {\n\n public flood(filter: SVGFilterElement, resultId: string, color: string, opacity: number, _settings?: any): void {\n const floodElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"feFlood\");\n if (resultId) {\n floodElement.setAttribute(\"id\", resultId);\n }\n floodElement.setAttribute(\"flood-color\", color);\n floodElement.setAttribute(\"flood-opacity\", opacity.toString());\n filter.appendChild(floodElement);\n }\n\n public composite(filter: SVGFilterElement,\n resultId: string,\n in1: string,\n in2: string,\n k1?: number,\n k2?: number,\n k3?: number,\n k4?: number,\n _settings?: any): void {\n const compositeElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"feComposite\");\n if (resultId) {\n compositeElement.setAttribute(\"id\", resultId);\n }\n compositeElement.setAttribute(\"in\", in1);\n compositeElement.setAttribute(\"in2\", in2);\n filter.appendChild(compositeElement);\n }\n}\n\nexport class SVGPathBuilder {\n private _path = \"\";\n\n public move(x: number, y: number): void {\n this._path += ` M ${x} ${y}`;\n }\n\n public path(): string {\n return this._path.substr(1);\n }\n\n public line(pts: number[][]): void {\n pts.forEach((point) => {\n this._path += ` L ${point[0]} ${point[1]}`;\n });\n }\n\n public curveC(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this._path += ` C ${x1} ${y1}, ${x2} ${y2}, ${x} ${y}`;\n }\n\n public close(): void {\n this._path += ` Z`;\n }\n}\n\nexport class SVG {\n public filters = new SVGFilters();\n private _svg: SVGElement;\n private _defs: SVGDefsElement | undefined = undefined;\n\n constructor(svg: SVGElement) {\n this._svg = svg;\n }\n\n public svg(parent: Element,\n x: number,\n y: number,\n width: number,\n height: number,\n settings?: any): SVGElement {\n const svgElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svgElement.setAttribute(\"x\", x.toString());\n svgElement.setAttribute(\"y\", y.toString());\n svgElement.setAttribute(\"width\", width.toString());\n svgElement.setAttribute(\"height\", height.toString());\n this._appendSettings(settings, svgElement);\n\n if (parent != null) {\n parent.appendChild(svgElement);\n } else {\n this._svg.appendChild(svgElement);\n }\n\n return svgElement;\n }\n\n public image(parent: Element,\n x: number,\n y: number,\n width: number,\n height: number,\n url: string,\n settings?: any): SVGImageElement {\n const imageElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"image\");\n imageElement.setAttribute(\"x\", x.toString());\n imageElement.setAttribute(\"y\", y.toString());\n imageElement.setAttribute(\"width\", width.toString());\n imageElement.setAttribute(\"height\", height.toString());\n imageElement.setAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\", url);\n this._appendSettings(settings, imageElement);\n parent.appendChild(imageElement);\n return imageElement;\n }\n\n public rect(parent: Element,\n x: number,\n y: number,\n width: number,\n height: number,\n rx?: number,\n ry?: number,\n settings?: any): SVGRectElement;\n public rect(parent: Element, x: number, y: number, width: number, height: number, settings?: any): SVGRectElement;\n public rect(parent: Element,\n x: number,\n y: number,\n width: number,\n height: number,\n rx?: number | any,\n ry?: number,\n settings?: any): SVGRectElement {\n const rectElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n rectElement.setAttribute(\"x\", x.toString());\n rectElement.setAttribute(\"y\", y.toString());\n rectElement.setAttribute(\"width\", width.toString());\n rectElement.setAttribute(\"height\", height.toString());\n if (rx !== undefined) {\n if (rx instanceof Number) {\n rectElement.setAttribute(\"rx\", rx.toString());\n } else if (rx instanceof Object) {\n this._appendSettings(rx, rectElement);\n }\n }\n if (ry !== undefined) {\n rectElement.setAttribute(\"ry\", ry.toString());\n }\n this._appendSettings(settings, rectElement);\n parent.appendChild(rectElement);\n return rectElement;\n }\n\n public line(parent: Element, x1: number, y1: number, x2: number, y2: number, settings?: any): SVGLineElement {\n const lineElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"line\");\n lineElement.setAttribute(\"x1\", x1.toString());\n lineElement.setAttribute(\"y1\", y1.toString());\n lineElement.setAttribute(\"x2\", x2.toString());\n lineElement.setAttribute(\"y2\", y2.toString());\n this._appendSettings(settings, lineElement);\n parent.appendChild(lineElement);\n return lineElement;\n }\n\n public polygon(parent: Element, points: number[][], settings?: any): SVGPolygonElement {\n const polygonElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polygon\");\n polygonElement.setAttribute(\"points\", points.map((point) => point.join(\",\")).join(\" \"));\n this._appendSettings(settings, polygonElement);\n parent.appendChild(polygonElement);\n return polygonElement;\n }\n\n public polyline(parent: Element, points: number[][], settings?: any): SVGPolylineElement {\n const polylineElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polyline\");\n polylineElement.setAttribute(\"points\", points.map((point) => point.join(\",\")).join(\" \"));\n this._appendSettings(settings, polylineElement);\n parent.appendChild(polylineElement);\n return polylineElement;\n }\n\n public ellipse(parent: Element, cx: number, cy: number, rx: number, ry: number, settings?: any): SVGEllipseElement {\n const ellipseElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"ellipse\");\n ellipseElement.setAttribute(\"cx\", cx.toString());\n ellipseElement.setAttribute(\"cy\", cy.toString());\n ellipseElement.setAttribute(\"rx\", rx.toString());\n ellipseElement.setAttribute(\"ry\", ry.toString());\n this._appendSettings(settings, ellipseElement);\n parent.appendChild(ellipseElement);\n return ellipseElement;\n }\n\n public path(parent: SVGElement, builder: SVGPathBuilder, settings?: any): SVGPathElement {\n const pathElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n pathElement.setAttribute(\"d\", builder.path());\n this._appendSettings(settings, pathElement);\n parent.appendChild(pathElement);\n return pathElement;\n }\n\n public text(parent: Element, x: number, y: number, value: string, settings?: any): SVGTextElement {\n const textElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n textElement.setAttribute(\"x\", x.toString());\n textElement.setAttribute(\"y\", y.toString());\n this._appendSettings(settings, textElement);\n const textNode = document.createTextNode(value);\n textElement.appendChild(textNode);\n parent.appendChild(textElement);\n return textElement;\n }\n\n public filter(parent: Element,\n id: string,\n x: number,\n y: number,\n width: number,\n height: number,\n settings?: any): SVGFilterElement {\n const filterElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"filter\");\n filterElement.setAttribute(\"x\", x.toString());\n filterElement.setAttribute(\"y\", y.toString());\n filterElement.setAttribute(\"width\", width.toString());\n filterElement.setAttribute(\"height\", height.toString());\n this._appendSettings(settings, filterElement);\n parent.appendChild(filterElement);\n return filterElement;\n }\n\n public pattern(parent: Element,\n resultId: string,\n x: number,\n y: number,\n width: number,\n height: number,\n settings?: any): SVGPatternElement {\n const patternElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"pattern\");\n if (resultId) {\n patternElement.setAttribute(\"id\", resultId);\n }\n patternElement.setAttribute(\"x\", x.toString());\n patternElement.setAttribute(\"y\", y.toString());\n patternElement.setAttribute(\"width\", width.toString());\n patternElement.setAttribute(\"height\", height.toString());\n this._appendSettings(settings, patternElement);\n parent.appendChild(patternElement);\n return patternElement;\n }\n\n public defs(): SVGDefsElement {\n if (this._defs === undefined) {\n const defsElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"defs\");\n this._svg.appendChild(defsElement);\n this._defs = defsElement;\n }\n return this._defs;\n }\n\n public clipPath(parent: Element, resultId: string, units?: string, settings?: any): SVGClipPathElement {\n const clipElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"clipPath\");\n if (resultId) {\n clipElement.setAttribute(\"id\", resultId);\n }\n if (units === undefined) {\n units = \"userSpaceOnUse\";\n }\n clipElement.setAttribute(\"clipPathUnits\", units);\n this._appendSettings(settings, clipElement);\n parent.appendChild(clipElement);\n return clipElement;\n }\n\n public createPath(): SVGPathBuilder {\n return new SVGPathBuilder();\n }\n\n private _appendSettings(settings: any | undefined, element: Element): void {\n if (settings !== undefined) {\n Object.keys(settings).forEach((key) => {\n element.setAttribute(key, settings[key]);\n });\n }\n }\n\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nexport class WMFJSError extends Error {\n constructor(message: string) {\n super(message); // 'Error' breaks prototype chain here\n Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain\n }\n}\n\nlet isLoggingEnabled = true;\n\nexport function loggingEnabled(enabled: boolean): void {\n isLoggingEnabled = enabled;\n}\n\nexport class Helper {\n public static GDI = {\n METAHEADER_SIZE: 18,\n BITMAPINFOHEADER_SIZE: 40,\n BITMAPCOREHEADER_SIZE: 12,\n MetafileType: {\n MEMORYMETAFILE: 1,\n DISKMETAFILE: 2,\n },\n MetafileVersion: {\n METAVERSION100: 0x100,\n METAVERSION300: 0x300,\n },\n RecordType: {\n META_EOF: 0x0000,\n META_REALIZEPALETTE: 0x0035,\n META_SETPALENTRIES: 0x0037,\n META_SETBKMODE: 0x0102,\n META_SETMAPMODE: 0x0103,\n META_SETROP2: 0x0104,\n META_SETRELABS: 0x0105,\n META_SETPOLYFILLMODE: 0x0106,\n META_SETSTRETCHBLTMODE: 0x0107,\n META_SETTEXTCHAREXTRA: 0x0108,\n META_RESTOREDC: 0x0127,\n META_RESIZEPALETTE: 0x0139,\n META_DIBCREATEPATTERNBRUSH: 0x0142,\n META_SETLAYOUT: 0x0149,\n META_SETBKCOLOR: 0x0201,\n META_SETTEXTCOLOR: 0x0209,\n META_OFFSETVIEWPORTORG: 0x0211,\n META_LINETO: 0x0213,\n META_MOVETO: 0x0214,\n META_OFFSETCLIPRGN: 0x0220,\n META_FILLREGION: 0x0228,\n META_SETMAPPERFLAGS: 0x0231,\n META_SELECTPALETTE: 0x0234,\n META_POLYGON: 0x0324,\n META_POLYLINE: 0x0325,\n META_SETTEXTJUSTIFICATION: 0x020a,\n META_SETWINDOWORG: 0x020b,\n META_SETWINDOWEXT: 0x020c,\n META_SETVIEWPORTORG: 0x020d,\n META_SETVIEWPORTEXT: 0x020e,\n META_OFFSETWINDOWORG: 0x020f,\n META_SCALEWINDOWEXT: 0x0410,\n META_SCALEVIEWPORTEXT: 0x0412,\n META_EXCLUDECLIPRECT: 0x0415,\n META_INTERSECTCLIPRECT: 0x0416,\n META_ELLIPSE: 0x0418,\n META_FLOODFILL: 0x0419,\n META_FRAMEREGION: 0x0429,\n META_ANIMATEPALETTE: 0x0436,\n META_TEXTOUT: 0x0521,\n META_POLYPOLYGON: 0x0538,\n META_EXTFLOODFILL: 0x0548,\n META_RECTANGLE: 0x041b,\n META_SETPIXEL: 0x041f,\n META_ROUNDRECT: 0x061c,\n META_PATBLT: 0x061d,\n META_SAVEDC: 0x001e,\n META_PIE: 0x081a,\n META_STRETCHBLT: 0x0b23,\n META_ESCAPE: 0x0626,\n META_INVERTREGION: 0x012a,\n META_PAINTREGION: 0x012b,\n META_SELECTCLIPREGION: 0x012c,\n META_SELECTOBJECT: 0x012d,\n META_SETTEXTALIGN: 0x012e,\n META_ARC: 0x0817,\n META_CHORD: 0x0830,\n META_BITBLT: 0x0922,\n META_EXTTEXTOUT: 0x0a32,\n META_SETDIBTODEV: 0x0d33,\n META_DIBBITBLT: 0x0940,\n META_DIBSTRETCHBLT: 0x0b41,\n META_STRETCHDIB: 0x0f43,\n META_DELETEOBJECT: 0x01f0,\n META_CREATEPALETTE: 0x00f7,\n META_CREATEPATTERNBRUSH: 0x01f9,\n META_CREATEPENINDIRECT: 0x02fa,\n META_CREATEFONTINDIRECT: 0x02fb,\n META_CREATEBRUSHINDIRECT: 0x02fc,\n META_CREATEREGION: 0x06ff,\n },\n MetafileEscapes: {\n NEWFRAME: 0x0001,\n ABORTDOC: 0x0002,\n NEXTBAND: 0x0003,\n SETCOLORTABLE: 0x0004,\n GETCOLORTABLE: 0x0005,\n FLUSHOUT: 0x0006,\n DRAFTMODE: 0x0007,\n QUERYESCSUPPORT: 0x0008,\n SETABORTPROC: 0x0009,\n STARTDOC: 0x000a,\n ENDDOC: 0x000b,\n GETPHYSPAGESIZE: 0x000c,\n GETPRINTINGOFFSET: 0x000d,\n GETSCALINGFACTOR: 0x000e,\n META_ESCAPE_ENHANCED_METAFILE: 0x000f,\n SETPENWIDTH: 0x0010,\n SETCOPYCOUNT: 0x0011,\n SETPAPERSOURCE: 0x0012,\n PASSTHROUGH: 0x0013,\n GETTECHNOLOGY: 0x0014,\n SETLINECAP: 0x0015,\n SETLINEJOIN: 0x0016,\n SETMITERLIMIT: 0x0017,\n BANDINFO: 0x0018,\n DRAWPATTERNRECT: 0x0019,\n GETVECTORPENSIZE: 0x001a,\n GETVECTORBRUSHSIZE: 0x001b,\n ENABLEDUPLEX: 0x001c,\n GETSETPAPERBINS: 0x001d,\n GETSETPRINTORIENT: 0x001e,\n ENUMPAPERBINS: 0x001f,\n SETDIBSCALING: 0x0020,\n EPSPRINTING: 0x0021,\n ENUMPAPERMETRICS: 0x0022,\n GETSETPAPERMETRICS: 0x0023,\n POSTSCRIPT_DATA: 0x0025,\n POSTSCRIPT_IGNORE: 0x0026,\n GETDEVICEUNITS: 0x002a,\n GETEXTENDEDTEXTMETRICS: 0x0100,\n GETPAIRKERNTABLE: 0x0102,\n EXTTEXTOUT: 0x0200,\n GETFACENAME: 0x0201,\n DOWNLOADFACE: 0x0202,\n METAFILE_DRIVER: 0x0801,\n QUERYDIBSUPPORT: 0x0c01,\n BEGIN_PATH: 0x1000,\n CLIP_TO_PATH: 0x1001,\n END_PATH: 0x1002,\n OPEN_CHANNEL: 0x100e,\n DOWNLOADHEADER: 0x100f,\n CLOSE_CHANNEL: 0x1010,\n POSTSCRIPT_PASSTHROUGH: 0x1013,\n ENCAPSULATED_POSTSCRIPT: 0x1014,\n POSTSCRIPT_IDENTIFY: 0x1015,\n POSTSCRIPT_INJECTION: 0x1016,\n CHECKJPEGFORMAT: 0x1017,\n CHECKPNGFORMAT: 0x1018,\n GET_PS_FEATURESETTING: 0x1019,\n MXDC_ESCAPE: 0x101a,\n SPCLPASSTHROUGH2: 0x11d8,\n },\n MapMode: {\n MM_TEXT: 1,\n MM_LOMETRIC: 2,\n MM_HIMETRIC: 3,\n MM_LOENGLISH: 4,\n MM_HIENGLISH: 5,\n MM_TWIPS: 6,\n MM_ISOTROPIC: 7,\n MM_ANISOTROPIC: 8,\n },\n StretchMode: {\n BLACKONWHITE: 1,\n WHITEONBLACK: 2,\n COLORONCOLOR: 3,\n HALFTONE: 4,\n },\n TextAlignmentMode: {\n TA_UPDATECP: 1,\n TA_RIGHT: 2,\n TA_CENTER: 6,\n TA_BOTTOM: 8,\n TA_BASELINE: 24,\n TA_RTLREADING: 256,\n },\n MixMode: {\n TRANSPARENT: 1,\n OPAQUE: 2,\n },\n VerticalTextAlignmentMode: {\n VTA_BOTTOM: 2,\n VTA_CENTER: 6,\n VTA_LEFT: 8,\n VTA_BASELINE: 24,\n },\n BrushStyle: {\n BS_SOLID: 0,\n BS_NULL: 1,\n BS_HATCHED: 2,\n BS_PATTERN: 3,\n BS_INDEXED: 4,\n BS_DIBPATTERN: 5,\n BS_DIBPATTERNPT: 6,\n BS_PATTERN8X8: 7,\n BS_DIBPATTERN8X8: 8,\n BS_MONOPATTERN: 9,\n },\n PenStyle: {\n PS_SOLID: 0,\n PS_DASH: 1,\n PS_DOT: 2,\n PS_DASHDOT: 3,\n PS_DASHDOTDOT: 4,\n PS_NULL: 5,\n PS_INSIDEFRAME: 6,\n PS_USERSTYLE: 7,\n PS_ALTERNATE: 8,\n PS_ENDCAP_SQUARE: 256,\n PS_ENDCAP_FLAT: 512,\n PS_JOIN_BEVEL: 4096,\n PS_JOIN_MITER: 8192,\n },\n PolyFillMode: {\n ALTERNATE: 1,\n WINDING: 2,\n },\n ColorUsage: {\n DIB_RGB_COLORS: 0,\n DIB_PAL_COLORS: 1,\n DIB_PAL_INDICES: 2,\n },\n PaletteEntryFlag: {\n PC_RESERVED: 1,\n PC_EXPLICIT: 2,\n PC_NOCOLLAPSE: 4,\n },\n BitmapCompression: {\n BI_RGB: 0,\n BI_RLE8: 1,\n BI_RLE4: 2,\n BI_BITFIELDS: 3,\n BI_JPEG: 4,\n BI_PNG: 5,\n },\n };\n public static _uniqueId = 0;\n\n public static log(message: string): void {\n if (isLoggingEnabled) {\n console.log(message);\n }\n }\n\n public static _makeUniqueId(prefix: string): string {\n return \"wmfjs_\" + prefix + (this._uniqueId++);\n }\n\n public static _writeUint32Val(uint8arr: Uint8Array, pos: number, val: number): void {\n uint8arr[pos++] = val & 0xff;\n uint8arr[pos++] = (val >>> 8) & 0xff;\n uint8arr[pos++] = (val >>> 16) & 0xff;\n uint8arr[pos++] = (val >>> 24) & 0xff;\n }\n\n public static _blobToBinary(blob: Uint8Array): string {\n let ret = \"\";\n const len = blob.length;\n for (let i = 0; i < len; i++) {\n ret += String.fromCharCode(blob[i]);\n }\n return ret;\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { WMFJSError } from \"./Helper\";\n\nexport class Blob {\n public pos: number;\n private blob: Blob | ArrayBuffer;\n private data: Uint8Array;\n\n constructor(blob: Blob | ArrayBuffer, offset?: number) {\n if (blob instanceof Blob) {\n this.blob = blob.blob;\n this.data = blob.data;\n this.pos = offset || blob.pos;\n } else {\n this.blob = blob;\n this.data = new Uint8Array(blob);\n this.pos = offset || 0;\n }\n }\n\n public eof(): boolean {\n return this.pos >= this.data.length;\n }\n\n public seek(newpos: number): void {\n if (newpos < 0 || newpos > this.data.length) {\n throw new WMFJSError(\"Invalid seek position\");\n }\n this.pos = newpos;\n }\n\n public skip(cnt: number): void {\n const newPos = this.pos + cnt;\n if (newPos > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n this.pos = newPos;\n }\n\n public readBinary(cnt: number): string {\n const end = this.pos + cnt;\n if (end > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n let ret = \"\";\n while (cnt-- > 0) {\n ret += String.fromCharCode(this.data[this.pos++]);\n }\n return ret;\n }\n\n public readInt8(): number {\n if (this.pos + 1 > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n return this.data[this.pos++];\n }\n\n public readUint8(): number {\n return this.readInt8() >>> 0;\n }\n\n public readInt32(): number {\n if (this.pos + 4 > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n let val = this.data[this.pos++];\n val |= this.data[this.pos++] << 8;\n val |= this.data[this.pos++] << 16;\n val |= this.data[this.pos++] << 24;\n return val;\n }\n\n public readUint32(): number {\n return this.readInt32() >>> 0;\n }\n\n public readUint16(): number {\n if (this.pos + 2 > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n let val = this.data[this.pos++];\n val |= this.data[this.pos++] << 8;\n return val;\n }\n\n public readInt16(): number {\n let val = this.readUint16();\n if (val > 32767) {\n val -= 65536;\n }\n return val;\n }\n\n public readString(length: number): string {\n if (this.pos + length > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n let ret = \"\";\n for (let i = 0; i < length; i++) {\n ret += String.fromCharCode(this.data[this.pos++] >>> 0);\n }\n return ret;\n }\n\n public readNullTermString(maxSize: number): string {\n let ret = \"\";\n if (maxSize > 0) {\n maxSize--;\n for (let i = 0; i < maxSize; i++) {\n if (this.pos + i + 1 > this.data.length) {\n throw new WMFJSError(\"Unexpected end of file\");\n }\n const byte = this.data[this.pos + i] >>> 0;\n if (byte === 0) {\n break;\n }\n ret += String.fromCharCode(byte);\n }\n }\n return ret;\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { Blob } from \"./Blob\";\nimport { WMFJSError } from \"./Helper\";\n\nexport class PointS {\n public x: number;\n public y: number;\n\n constructor(reader: Blob, x?: number, y?: number) {\n if (reader != null) {\n this.x = reader.readInt16();\n this.y = reader.readInt16();\n } else {\n this.x = x;\n this.y = y;\n }\n }\n\n public clone(): PointS {\n return new PointS(null, this.x, this.y);\n }\n\n public toString(): string {\n return \"{x: \" + this.x + \", y: \" + this.y + \"}\";\n }\n}\n\nexport class Rect {\n public bottom: number;\n public right: number;\n public top: number;\n public left: number;\n\n constructor(reader: Blob, left?: number, top?: number, right?: number, bottom?: number) {\n if (reader != null) {\n this.bottom = reader.readInt16();\n this.right = reader.readInt16();\n this.top = reader.readInt16();\n this.left = reader.readInt16();\n } else {\n this.bottom = bottom;\n this.right = right;\n this.top = top;\n this.left = left;\n }\n }\n\n public clone(): Rect {\n return new Rect(null, this.left, this.top, this.right, this.bottom);\n }\n\n public toString(): string {\n return \"{left: \" + this.left + \", top: \" + this.top + \", right: \" + this.right\n + \", bottom: \" + this.bottom + \"}\";\n }\n\n public empty(): boolean {\n return this.left >= this.right || this.top >= this.bottom;\n }\n\n public intersect(rect: Rect): null | Rect {\n if (this.empty() || rect.empty()) {\n return null;\n }\n if (this.left >= rect.right || this.top >= rect.bottom ||\n this.right <= rect.left || this.bottom <= rect.top) {\n return null;\n }\n return new Rect(null, Math.max(this.left, rect.left), Math.max(this.top, rect.top),\n Math.min(this.right, rect.right), Math.min(this.bottom, rect.bottom));\n }\n}\n\nexport class Obj {\n public type: string;\n\n constructor(type: string) {\n this.type = type;\n }\n\n public clone(): Obj {\n throw new WMFJSError(\"clone not implemented\");\n }\n\n public toString(): string {\n throw new WMFJSError(\"toString not implemented\");\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { Blob } from \"./Blob\";\nimport { Helper, WMFJSError } from \"./Helper\";\nimport { Obj, Rect } from \"./Primitives\";\n\nexport class Region extends Obj {\n public bounds: Rect;\n public scans: Scan[];\n public complexity: number;\n\n constructor(reader: Blob, copy?: Region) {\n super(\"region\");\n if (reader != null) {\n reader.skip(2);\n if (reader.readInt16() !== 6) {\n throw new WMFJSError(\"Invalid region identifier\");\n }\n reader.skip(2);\n const rgnSize = reader.readInt16();\n const scanCnt = reader.readInt16();\n reader.skip(2);\n // note, Rect in reverse, can't use Rect(reader) directly\n const left = reader.readInt16();\n const top = reader.readInt16();\n const right = reader.readInt16();\n const bottom = reader.readInt16();\n this.bounds = new Rect(null, left, top, right, bottom);\n this.scans = [];\n for (let i = 0; i < scanCnt; i++) {\n this.scans.push(new Scan(reader));\n }\n this._updateComplexity();\n } else if (copy != null) {\n this.bounds = copy.bounds != null ? copy.bounds.clone() : null;\n if (copy.scans != null) {\n this.scans = [];\n for (let i = 0; i < copy.scans.length; i++) {\n this.scans.push(copy.scans[i].clone());\n }\n } else {\n this.scans = null;\n }\n this.complexity = copy.complexity;\n } else {\n this.bounds = null;\n this.scans = null;\n this.complexity = 0;\n }\n }\n\n public clone(): Region {\n return new Region(null, this);\n }\n\n public toString(): string {\n const _complexity = [\"null\", \"simple\", \"complex\"];\n return \"{complexity: \" + _complexity[this.complexity]\n + \" bounds: \" + (this.bounds != null ? this.bounds.toString() : \"[none]\")\n + \" #scans: \" + (this.scans != null ? this.scans.length : \"[none]\") + \"}\";\n }\n\n public _updateComplexity(): void {\n if (this.bounds == null) {\n this.complexity = 0;\n this.scans = null;\n } else if (this.bounds.empty()) {\n this.complexity = 0;\n this.scans = null;\n this.bounds = null;\n } else if (this.scans == null) {\n this.complexity = 1;\n } else {\n this.complexity = 2;\n if (this.scans.length === 1) {\n const scan = this.scans[0];\n if (scan.top === this.bounds.top && scan.bottom === this.bounds.bottom && scan.scanlines.length === 1) {\n const scanline = scan.scanlines[0];\n if (scanline.left === this.bounds.left && scanline.right === this.bounds.right) {\n this.scans = null;\n this.complexity = 1;\n }\n }\n }\n }\n }\n\n public subtract(rect: Rect): void {\n Helper.log(\"[wmf] Region \" + this.toString() + \" subtract \" + rect.toString());\n\n if (this.bounds != null) {\n const isect = this.bounds.intersect(rect);\n if (isect != null) { // Only need to do anything if there is any chance of an overlap\n if (this.scans == null) {\n // We currently have a simple region and there is some kind of an overlap.\n // We need to create scanlines now. Simplest method is to fake one scan line\n // that equals the simple region and re-use the same logic as for complex regions\n this.scans = [];\n this.scans.push(new Scan(null, null, this.bounds.top, this.bounds.bottom,\n [{left: this.bounds.left, right: this.bounds.right}]));\n this.complexity = 2;\n }\n\n // We (now) have a complex region. First we skip any scans that are entirely above rect.top\n // The first scan that falls partially below rect.top needs to be split into two scans.\n let si = 0;\n while (si < this.scans.length) {\n const scan = this.scans[si];\n if (scan.bottom >= rect.top) {\n // We need to clone this scan into two so that we can subtract from the second one\n const cloned = scan.clone();\n scan.bottom = rect.top - 1;\n cloned.top = rect.top;\n if (scan.top >= scan.bottom) {\n this.scans[si] = cloned;\n } else {\n Helper.log(\"[wmf] Region split top scan \" + si + \" for substraction\");\n this.scans.splice(++si, 0, cloned);\n }\n break;\n }\n si++;\n }\n\n // Now find the first one that falls at least partially below rect.bottom, which needs to be\n // split if it is only partially below rect.bottom\n const first = si;\n while (si < this.scans.length) {\n const scan = this.scans[si];\n if (scan.top > rect.bottom) {\n break;\n }\n if (scan.bottom > rect.bottom) {\n // We need to clone this scan into two so that we can subtract from the first one\n const cloned = scan.clone();\n scan.bottom = rect.bottom;\n cloned.top = rect.bottom + 1;\n if (scan.top >= scan.bottom) {\n this.scans[si] = cloned;\n } else {\n Helper.log(\"[wmf] Region split bottom scan \" + si + \" for substraction\");\n this.scans.splice(++si, 0, cloned);\n }\n break;\n }\n si++;\n }\n\n // Now perform a subtraction on each scan in between rect.top and rect.bottom. Because we\n // cloned scans that partially overlapped rect.top and rect.bottom, we don't have to\n // account for this anymore.\n if (first < this.scans.length) {\n let last = si;\n si = first;\n while (si < last) {\n const scan = this.scans[si];\n if (!scan.subtract(rect.left, rect.right)) {\n Helper.log(\"[wmf] Region remove now empty scan \" + si + \" due to subtraction\");\n this.scans.splice(si, 1);\n last--;\n continue;\n }\n\n si++;\n }\n }\n\n // Update bounds\n if (this.scans != null) {\n let left;\n let top;\n let right;\n let bottom;\n const len = this.scans.length;\n for (let i = 0; i < len; i++) {\n const scan = this.scans[i];\n if (i === 0) {\n top = scan.top;\n }\n if (i === len - 1) {\n bottom = scan.bottom;\n }\n\n const slen = scan.scanlines.length;\n if (slen > 0) {\n let scanline = scan.scanlines[0];\n if (left == null || scanline.left < left) {\n left = scanline.left;\n }\n scanline = scan.scanlines[slen - 1];\n if (right == null || scanline.right > right) {\n right = scanline.right;\n }\n }\n }\n\n if (left != null && top != null && right != null && bottom != null) {\n this.bounds = new Rect(null, left, top, right, bottom);\n this._updateComplexity();\n } else {\n // This has to be a null region now\n this.bounds = null;\n this.scans = null;\n this.complexity = 0;\n }\n } else {\n this._updateComplexity();\n }\n }\n }\n\n Helper.log(\"[wmf] Region subtraction -> \" + this.toString());\n }\n\n public intersect(rect: Rect): void {\n Helper.log(\"[wmf] Region \" + this.toString() + \" intersect with \" + rect.toString());\n if (this.bounds != null) {\n this.bounds = this.bounds.intersect(rect);\n if (this.bounds != null) {\n if (this.scans != null) {\n let si = 0;\n // Remove any scans that are entirely above the new bounds.top\n while (si < this.scans.length) {\n const scan = this.scans[si];\n if (scan.bottom < this.bounds.top) {\n si++;\n } else {\n break;\n }\n }\n if (si > 0) {\n Helper.log(\"[wmf] Region remove \" + si + \" scans from top\");\n this.scans.splice(0, si);\n\n // Adjust the first scan's top to match the new bounds.top\n if (this.scans.length > 0) {\n this.scans[0].top = this.bounds.top;\n }\n }\n\n // Get rid of anything that falls outside the new bounds.left/bounds.right\n si = 0;\n while (si < this.scans.length) {\n const scan = this.scans[si];\n if (scan.top > this.bounds.bottom) {\n // Remove this and all remaining scans that fall entirely below the new bounds.bottom\n Helper.log(\"[wmf] Region remove \" + (this.scans.length - si) + \" scans from bottom\");\n this.scans.splice(si, this.scans.length - si);\n break;\n }\n if (!scan.intersect(this.bounds.left, this.bounds.right)) {\n // Remove now empty scan\n Helper.log(\"[wmf] Region remove now empty scan \" + si + \" due to intersection\");\n this.scans.splice(si, 1);\n continue;\n }\n si++;\n }\n\n // If there are any scans left, adjust the last one's bottom to the new bounds.bottom\n if (this.scans.length > 0) {\n this.scans[this.scans.length - 1].bottom = this.bounds.bottom;\n }\n\n this._updateComplexity();\n }\n } else {\n this.scans = null;\n this.complexity = 0;\n }\n }\n Helper.log(\"[wmf] Region intersection -> \" + this.toString());\n }\n\n public offset(offX: number, offY: number): void {\n if (this.bounds != null) {\n this.bounds.left += offX;\n this.bounds.top += offY;\n this.bounds.right += offX;\n this.bounds.bottom += offY;\n }\n\n if (this.scans != null) {\n const slen = this.scans.length;\n for (let si = 0; si < slen; si++) {\n const scan = this.scans[si];\n scan.top += offY;\n scan.bottom += offY;\n\n const len = scan.scanlines.length;\n for (let i = 0; i < len; i++) {\n const scanline = scan.scanlines[i];\n scanline.left += offX;\n scanline.right += offX;\n }\n }\n }\n }\n}\n\nexport function CreateSimpleRegion(left: number, top: number, right: number, bottom: number): Region {\n const rgn = new Region(null, null);\n rgn.bounds = new Rect(null, left, top, right, bottom);\n rgn._updateComplexity();\n return rgn;\n}\n\nexport class Scan {\n public top: number;\n public bottom: number;\n public scanlines: { left: number, right: number }[];\n\n constructor(reader: Blob, copy?: Scan, top?: number, bottom?: number,\n scanlines?: { left: number, right: number }[]) {\n if (reader != null) {\n const cnt = reader.readUint16();\n this.top = reader.readUint16();\n this.bottom = reader.readUint16();\n this.scanlines = [];\n for (let i = 0; i < cnt; i++) {\n const left = reader.readUint16();\n const right = reader.readUint16();\n this.scanlines.push({left, right});\n }\n reader.skip(2);\n } else if (copy != null) {\n this.top = copy.top;\n this.bottom = copy.bottom;\n this.scanlines = [];\n for (let i = 0; i < copy.scanlines.length; i++) {\n const scanline = copy.scanlines[i];\n this.scanlines.push({left: scanline.left, right: scanline.right});\n }\n } else {\n this.top = top;\n this.bottom = bottom;\n this.scanlines = scanlines;\n }\n }\n\n public clone(): Scan {\n return new Scan(null, this);\n }\n\n public subtract(left: number, right: number): boolean {\n let i;\n\n // Keep everything on the left side\n i = 0;\n while (i < this.scanlines.length) {\n const scanline = this.scanlines[i];\n if (scanline.left <= left) {\n if (scanline.right >= left) {\n scanline.right = left - 1;\n if (scanline.left >= scanline.right) {\n this.scanlines.splice(i, 1);\n continue;\n }\n }\n i++;\n } else {\n break;\n }\n }\n\n // Find the first one that may exceed to the right side\n const first = i;\n let cnt = 0;\n while (i < this.scanlines.length) {\n const scanline = this.scanlines[i];\n if (scanline.right > right) {\n scanline.left = right;\n cnt = i - first;\n if (scanline.left >= scanline.right) {\n cnt++;\n }\n break;\n }\n i++;\n }\n\n // Delete everything we're subtracting\n if (cnt > 0 && first < this.scanlines.length) {\n this.scanlines.splice(first, cnt);\n }\n\n return this.scanlines.length > 0;\n }\n\n public intersect(left: number, right: number): boolean {\n // Get rid of anything that falls entirely outside to the left\n for (let i = 0; i < this.scanlines.length; i++) {\n const scanline = this.scanlines[i];\n if (scanline.left >= left || scanline.right >= left) {\n if (i > 0) {\n this.scanlines.splice(0, i);\n }\n break;\n }\n }\n\n if (this.scanlines.length > 0) {\n // Adjust the first to match the left, if needed\n let scanline = this.scanlines[0];\n if (scanline.left < left) {\n scanline.left = left;\n }\n\n // Get rid of anything that falls entirely outside to the right\n for (let i = 0; i < this.scanlines.length; i++) {\n scanline = this.scanlines[i];\n if (scanline.left > right) {\n this.scanlines.splice(i, this.scanlines.length - i);\n break;\n }\n }\n\n if (this.scanlines.length > 0) {\n // Adjust the last to match the right, if needed\n scanline = this.scanlines[this.scanlines.length - 1];\n if (scanline.right > right) {\n scanline.right = right;\n }\n }\n }\n return this.scanlines.length > 0;\n }\n\n public toString(): string {\n return \"{ #scanlines: \" + this.scanlines.length + \"}\";\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { Blob } from \"./Blob\";\nimport { Helper, WMFJSError } from \"./Helper\";\n\ninterface Bitmap {\n getWidth(): number\n\n getHeight(): number\n}\n\nclass BitmapCoreHeader {\n public width: number;\n public height: number;\n public planes: number;\n public bitcount: number;\n\n constructor(reader: Blob, skipsize: boolean) {\n if (skipsize) {\n reader.skip(4);\n }\n this.width = reader.readUint16();\n this.height = reader.readUint16();\n this.planes = reader.readUint16();\n this.bitcount = reader.readUint16();\n }\n\n public colors(): number {\n return this.bitcount <= 8 ? 1 << this.bitcount : 0;\n }\n}\n\nclass BitmapInfoHeader {\n public width: number;\n public height: number;\n public planes: number;\n public bitcount: number;\n public compression: number;\n public sizeimage: number;\n public xpelspermeter: number;\n public ypelspermeter: number;\n public clrused: number;\n public clrimportant: number;\n\n constructor(reader: Blob, skipsize: boolean) {\n if (skipsize) {\n reader.skip(4);\n }\n this.width = reader.readInt32();\n this.height = reader.readInt32();\n this.planes = reader.readUint16();\n this.bitcount = reader.readUint16();\n this.compression = reader.readUint32();\n this.sizeimage = reader.readUint32();\n this.xpelspermeter = reader.readInt32();\n this.ypelspermeter = reader.readInt32();\n this.clrused = reader.readUint32();\n this.clrimportant = reader.readUint32();\n }\n\n public colors(): number {\n if (this.clrused !== 0) {\n return this.clrused < 256 ? this.clrused : 256;\n } else {\n return this.bitcount > 8 ? 0 : 1 << this.bitcount;\n }\n }\n}\n\nexport class BitmapInfo implements Bitmap {\n private _reader: Blob;\n private _offset: number;\n private _usergb: boolean;\n private _infosize: number;\n private _header: BitmapCoreHeader | BitmapInfoHeader;\n\n constructor(reader: Blob, usergb: boolean) {\n this._reader = reader;\n this._offset = reader.pos;\n this._usergb = usergb;\n const hdrsize = reader.readUint32();\n this._infosize = hdrsize;\n if (hdrsize === Helper.GDI.BITMAPCOREHEADER_SIZE) {\n this._header = new BitmapCoreHeader(reader, false);\n this._infosize += this._header.colors() * (usergb ? 3 : 2);\n } else {\n this._header = new BitmapInfoHeader(reader, false);\n const masks =\n (this._header as BitmapInfoHeader).compression === Helper.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;\n if (hdrsize <= Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4)) {\n this._infosize = Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4);\n }\n this._infosize += this._header.colors() * (usergb ? 4 : 2);\n }\n }\n\n public getWidth(): number {\n return this._header.width;\n }\n\n public getHeight(): number {\n return Math.abs(this._header.height);\n }\n\n public infosize(): number {\n return this._infosize;\n }\n\n public header(): BitmapCoreHeader | BitmapInfoHeader {\n return this._header;\n }\n}\n\nexport class DIBitmap implements Bitmap {\n private _reader: Blob;\n private _offset: number;\n private _size: number;\n private _info: BitmapInfo;\n\n constructor(reader: Blob, size: number) {\n this._reader = reader;\n this._offset = reader.pos;\n this._size = size;\n this._info = new BitmapInfo(reader, true);\n }\n\n public getWidth(): number {\n return this._info.getWidth();\n }\n\n public getHeight(): number {\n return this._info.getHeight();\n }\n\n public base64ref(): string {\n const prevpos = this._reader.pos;\n this._reader.seek(this._offset);\n let mime = \"image/bmp\";\n const header = this._info.header();\n let data;\n if (header instanceof BitmapInfoHeader && header.compression != null) {\n switch (header.compression) {\n case Helper.GDI.BitmapCompression.BI_JPEG:\n mime = \"data:image/jpeg\";\n break;\n case Helper.GDI.BitmapCompression.BI_PNG:\n mime = \"data:image/png\";\n break;\n default:\n data = this.makeBitmapFileHeader();\n break;\n }\n } else {\n data = this.makeBitmapFileHeader();\n }\n\n if (data != null) {\n data += this._reader.readBinary(this._size);\n } else {\n data = this._reader.readBinary(this._size);\n }\n\n const ref = \"data:\" + mime + \";base64,\" + btoa(data);\n this._reader.seek(prevpos);\n return ref;\n }\n\n private makeBitmapFileHeader() {\n const buf = new ArrayBuffer(14);\n const view = new Uint8Array(buf);\n view[0] = 0x42;\n view[1] = 0x4d;\n Helper._writeUint32Val(view, 2, this._size + 14);\n Helper._writeUint32Val(view, 10, this._info.infosize() + 14);\n return Helper._blobToBinary(view);\n }\n}\n\nexport class Bitmap16 implements Bitmap {\n public type: number;\n public width: number;\n public height: number;\n public widthBytes: number;\n public planes: number;\n public bitsPixel: number;\n public bitsOffset: number;\n public bitsSize: number;\n private _reader: Blob;\n private _offset: number;\n private _size: number;\n\n constructor(reader: Blob, size: number | Bitmap16) {\n if (reader != null) {\n size = size as number;\n this._reader = reader;\n this._offset = reader.pos;\n this._size = size;\n this.type = reader.readInt16();\n this.width = reader.readInt16();\n this.height = reader.readInt16();\n this.widthBytes = reader.readInt16();\n this.planes = reader.readUint8();\n this.bitsPixel = reader.readUint8();\n this.bitsOffset = reader.pos;\n this.bitsSize = (((this.width * this.bitsPixel + 15) >> 4) << 1) * this.height;\n if (this.bitsSize > size - 10) {\n throw new WMFJSError(\"Bitmap should have \" + this.bitsSize + \" bytes, but has \" + (size - 10));\n }\n } else {\n const copy = size as Bitmap16;\n this._reader = copy._reader;\n this._offset = copy._offset;\n this._size = copy._size;\n this.type = copy.type;\n this.width = copy.width;\n this.height = copy.height;\n this.widthBytes = copy.widthBytes;\n this.planes = copy.planes;\n this.bitsPixel = copy.bitsPixel;\n this.bitsOffset = copy.bitsOffset;\n this.bitsSize = copy.bitsSize;\n }\n }\n\n public getWidth(): number {\n return this.width;\n }\n\n public getHeight(): number {\n return this.height;\n }\n\n public clone(): Bitmap16 {\n return new Bitmap16(null, this);\n }\n}\n\nexport class PatternBitmap16 extends Bitmap16 {\n constructor(reader: Blob, size: number | Bitmap16) {\n super(reader, size);\n if (reader != null) {\n this.bitsOffset += 22; // skip bits (4 bytes) + reserved (18 bytes)\n }\n }\n\n public clone(): PatternBitmap16 {\n return new PatternBitmap16(null, this);\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { Bitmap16, DIBitmap, PatternBitmap16 } from \"./Bitmap\";\nimport { Blob } from \"./Blob\";\nimport { Helper } from \"./Helper\";\nimport { Obj, PointS } from \"./Primitives\";\n\nexport class ColorRef {\n public r: number;\n public g: number;\n public b: number;\n\n constructor(reader: Blob, r?: number, g?: number, b?: number) {\n if (reader != null) {\n this.r = reader.readUint8();\n this.g = reader.readUint8();\n this.b = reader.readUint8();\n reader.skip(1);\n } else {\n this.r = r;\n this.g = g;\n this.b = b;\n }\n }\n\n public clone(): ColorRef {\n return new ColorRef(null, this.r, this.g, this.b);\n }\n\n public toHex(): string {\n const rgb = (this.r << 16) | (this.g << 8) | this.b;\n return (0x1000000 + rgb).toString(16).slice(1);\n }\n\n public toString(): string {\n return \"{r: \" + this.r + \", g: \" + this.g + \", b: \" + this.b + \"}\";\n }\n}\n\nexport class Font extends Obj {\n public height: number;\n public width: number;\n public escapement: number;\n public orientation: number;\n public weight: number;\n public italic: number;\n public underline: number;\n public strikeout: number;\n public charset: number;\n public outprecision: number;\n public clipprecision: number;\n public quality: number;\n public pitch: number;\n public family: number;\n public facename: string;\n\n constructor(reader: Blob, copy: Font | number) {\n super(\"font\");\n if (reader != null) {\n this.height = reader.readInt16();\n this.width = reader.readInt16();\n this.escapement = reader.readInt16();\n this.orientation = reader.readInt16();\n this.weight = reader.readInt16();\n this.italic = reader.readUint8();\n this.underline = reader.readUint8();\n this.strikeout = reader.readUint8();\n this.charset = reader.readUint8();\n this.outprecision = reader.readUint8();\n this.clipprecision = reader.readUint8();\n this.quality = reader.readUint8();\n const pitchAndFamily = reader.readUint8();\n this.pitch = pitchAndFamily & 0xf; // TODO: double check\n this.family = (pitchAndFamily >> 6) & 0x3; // TODO: double check\n\n const dataLength = copy as number;\n const start = reader.pos;\n this.facename = reader.readNullTermString(Math.min(dataLength - (reader.pos - start), 32));\n } else if (copy != null) {\n copy = copy as Font;\n this.height = copy.height;\n this.width = copy.width;\n this.escapement = copy.escapement;\n this.orientation = copy.orientation;\n this.weight = copy.weight;\n this.italic = copy.italic;\n this.underline = copy.underline;\n this.strikeout = copy.strikeout;\n this.charset = copy.charset;\n this.outprecision = copy.outprecision;\n this.clipprecision = copy.clipprecision;\n this.quality = copy.quality;\n this.pitch = copy.pitch;\n this.family = copy.family;\n this.facename = copy.facename;\n } else {\n // TODO: Values for a default font?\n this.height = -80;\n this.width = 0;\n this.escapement = 0;\n this.orientation = 0;\n this.weight = 400;\n this.italic = 0;\n this.underline = 0;\n this.strikeout = 0;\n this.charset = 0;\n this.outprecision = 0;\n this.clipprecision = 0;\n this.quality = 0;\n this.pitch = 0;\n this.family = 0;\n this.facename = \"Helvetica\";\n }\n }\n\n public clone(): Font {\n return new Font(null, this);\n }\n\n public toString(): string {\n return JSON.stringify(this);\n }\n}\n\nexport class Brush extends Obj {\n public style: number;\n public color: ColorRef;\n public pattern: Bitmap16;\n public colorusage: number;\n public dibpatternpt: DIBitmap;\n public hatchstyle: number;\n\n constructor(reader: Blob, copy: Brush | number, forceDibPattern?: boolean | PatternBitmap16) {\n super(\"brush\");\n if (reader != null) {\n const dataLength = copy as number;\n const start = reader.pos;\n\n if (forceDibPattern === true || forceDibPattern === false) {\n this.style = reader.readUint16();\n if (forceDibPattern && this.style !== Helper.GDI.BrushStyle.BS_PATTERN) {\n this.style = Helper.GDI.BrushStyle.BS_DIBPATTERNPT;\n }\n switch (this.style) {\n case Helper.GDI.BrushStyle.BS_SOLID:\n this.color = new ColorRef(reader);\n break;\n case Helper.GDI.BrushStyle.BS_PATTERN:\n reader.skip(forceDibPattern ? 2 : 6);\n this.pattern = new Bitmap16(reader, dataLength - (reader.pos - start));\n break;\n case Helper.GDI.BrushStyle.BS_DIBPATTERNPT:\n this.colorusage = forceDibPattern ? reader.readUint16() : reader.readUint32();\n if (!forceDibPattern) {\n reader.skip(2);\n }\n this.dibpatternpt = new DIBitmap(reader, dataLength - (reader.pos - start));\n break;\n case Helper.GDI.BrushStyle.BS_HATCHED:\n this.color = new ColorRef(reader);\n this.hatchstyle = reader.readUint16();\n break;\n }\n } else if (forceDibPattern instanceof PatternBitmap16) {\n this.style = Helper.GDI.BrushStyle.BS_PATTERN;\n this.pattern = forceDibPattern;\n }\n } else if (copy != null) {\n copy = copy as Brush;\n this.style = copy.style;\n switch (this.style) {\n case Helper.GDI.BrushStyle.BS_SOLID:\n this.color = copy.color.clone();\n break;\n case Helper.GDI.BrushStyle.BS_PATTERN:\n this.pattern = copy.pattern.clone();\n break;\n case Helper.GDI.BrushStyle.BS_DIBPATTERNPT:\n this.colorusage = copy.colorusage;\n this.dibpatternpt = copy.dibpatternpt;\n break;\n case Helper.GDI.BrushStyle.BS_HATCHED:\n this.color = copy.color.clone();\n this.hatchstyle = copy.hatchstyle;\n break;\n }\n }\n }\n\n public clone(): Brush {\n return new Brush(null, this);\n }\n\n public toString(): string {\n let ret = \"{style: \" + this.style;\n switch (this.style) {\n case Helper.GDI.BrushStyle.BS_SOLID:\n ret += \", color: \" + this.color.toString();\n break;\n case Helper.GDI.BrushStyle.BS_DIBPATTERNPT:\n ret += \", colorusage: \" + this.colorusage;\n break;\n case Helper.GDI.BrushStyle.BS_HATCHED:\n ret += \", color: \" + this.color.toString() + \", hatchstyle: \" + this.hatchstyle;\n break;\n }\n return ret + \"}\";\n }\n}\n\nexport class Pen extends Obj {\n public style: number;\n public width: PointS;\n public color: ColorRef;\n public linecap: number;\n public join: number;\n\n constructor(reader: Blob, style?: number, width?: PointS, color?: ColorRef, linecap?: number, join?: number) {\n super(\"pen\");\n if (reader != null) {\n style = reader.readUint16();\n this.style = style & 0xFF;\n this.width = new PointS(reader);\n this.color = new ColorRef(reader);\n this.linecap = (style & (Helper.GDI.PenStyle.PS_ENDCAP_SQUARE | Helper.GDI.PenStyle.PS_ENDCAP_FLAT));\n this.join = (style & (Helper.GDI.PenStyle.PS_JOIN_BEVEL | Helper.GDI.PenStyle.PS_JOIN_MITER));\n } else {\n this.style = style;\n this.width = width;\n this.color = color;\n this.linecap = linecap;\n this.join = join;\n }\n }\n\n public clone(): Pen {\n return new Pen(null, this.style, this.width.clone(), this.color.clone(), this.linecap, this.join);\n }\n\n public toString(): string {\n return \"{style: \" + this.style + \", width: \" + this.width.toString() + \", color: \" + this.color.toString()\n + \", linecap: \" + this.linecap + \", join: \" + this.join + \"}\";\n }\n}\n\nexport class PaletteEntry {\n public flag: number;\n public b: number;\n public g: number;\n public r: number;\n\n constructor(reader: Blob, copy?: PaletteEntry) {\n if (reader != null) {\n this.flag = reader.readUint8();\n this.b = reader.readUint8();\n this.g = reader.readUint8();\n this.r = reader.readUint8();\n } else {\n this.flag = copy.flag;\n this.b = copy.b;\n this.g = copy.g;\n this.r = copy.r;\n }\n }\n\n public clone(): PaletteEntry {\n return new PaletteEntry(null, this);\n }\n}\n\nexport class Palette extends Obj {\n public start: number;\n public entries: PaletteEntry[];\n\n constructor(reader: Blob, copy?: Palette) {\n super(\"palette\");\n if (reader != null) {\n this.start = reader.readUint16();\n let cnt = reader.readUint16();\n this.entries = [];\n while (cnt > 0) {\n this.entries.push(new PaletteEntry(reader));\n cnt--;\n }\n } else {\n this.start = copy.start;\n this.entries = [];\n const len = copy.entries.length;\n for (let i = 0; i < len; i++) {\n this.entries.push(copy.entries[i]);\n }\n }\n }\n\n public clone(): Palette {\n return new Palette(null, this);\n }\n\n public toString(): string {\n return \"{ #entries: \" + this.entries.length + \"}\"; // TODO\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { SVG } from \"../util\";\nimport { DIBitmap } from \"./Bitmap\";\nimport { Blob } from \"./Blob\";\nimport { Helper, WMFJSError } from \"./Helper\";\nimport { Obj, PointS, Rect } from \"./Primitives\";\nimport { CreateSimpleRegion, Region } from \"./Region\";\nimport { Brush, ColorRef, Font, Palette, Pen } from \"./Style\";\n\ninterface ISelectedStyle {\n brush?: Brush;\n pen?: Pen;\n font?: Font;\n palette?: Palette;\n region?: Region;\n\n [key: string]: Obj | undefined;\n}\n\nclass GDIContextState {\n public _svggroup: SVGElement;\n public _svgclipChanged: boolean;\n public _svgtextbkfilter: SVGFilterElement;\n public mapmode: number;\n public stretchmode: number;\n public textalign: number;\n public bkmode: number;\n public textcolor: ColorRef;\n public bkcolor: ColorRef;\n public polyfillmode: number;\n public wx: number;\n public wy: number;\n public ww: number;\n public wh: number;\n public vx: number;\n public vy: number;\n public vw: number;\n public vh: number;\n public x: number;\n public y: number;\n public clip: Region;\n public ownclip: boolean;\n public selected: ISelectedStyle;\n\n constructor(copy: GDIContextState, defObjects?: ISelectedStyle) {\n if (copy != null) {\n this._svggroup = copy._svggroup;\n this._svgclipChanged = copy._svgclipChanged;\n this._svgtextbkfilter = copy._svgtextbkfilter;\n this.mapmode = copy.mapmode;\n this.stretchmode = copy.stretchmode;\n this.textalign = copy.textalign;\n this.bkmode = copy.bkmode;\n this.textcolor = copy.textcolor.clone();\n this.bkcolor = copy.bkcolor.clone();\n this.polyfillmode = copy.polyfillmode;\n this.wx = copy.wx;\n this.wy = copy.wy;\n this.ww = copy.ww;\n this.wh = copy.wh;\n this.vx = copy.vx;\n this.vy = copy.vy;\n this.vw = copy.vw;\n this.vh = copy.vh;\n this.x = copy.x;\n this.y = copy.y;\n\n this.clip = copy.clip;\n this.ownclip = false;\n\n this.selected = {};\n for (const type in copy.selected) {\n this.selected[type] = copy.selected[type];\n }\n } else {\n this._svggroup = null;\n this._svgclipChanged = false;\n this._svgtextbkfilter = null;\n this.mapmode = Helper.GDI.MapMode.MM_ANISOTROPIC;\n this.stretchmode = Helper.GDI.StretchMode.COLORONCOLOR;\n this.textalign = 0; // TA_LEFT | TA_TOP | TA_NOUPDATECP\n this.bkmode = Helper.GDI.MixMode.OPAQUE;\n this.textcolor = new ColorRef(null, 0, 0, 0);\n this.bkcolor = new ColorRef(null, 255, 255, 255);\n this.polyfillmode = Helper.GDI.PolyFillMode.ALTERNATE;\n this.wx = 0;\n this.wy = 0;\n this.ww = 0;\n this.wh = 0;\n this.vx = 0;\n this.vy = 0;\n this.vw = 0;\n this.vh = 0;\n this.x = 0;\n this.y = 0;\n\n this.clip = null;\n this.ownclip = false;\n\n this.selected = {};\n for (const type in defObjects) {\n const defObj = defObjects[type];\n this.selected[type] = defObj != null ? defObj.clone() : null;\n }\n }\n }\n}\n\nexport class GDIContext {\n private _svg: SVG;\n private _svgdefs: SVGDefsElement;\n private _svgPatterns: { [key: string]: Brush };\n private _svgClipPaths: { [key: string]: Region };\n private defObjects: ISelectedStyle;\n private state: GDIContextState;\n private statestack: GDIContextState[];\n private objects: { [key: string]: Obj };\n\n constructor(svg: SVG) {\n this._svg = svg;\n this._svgdefs = null;\n this._svgPatterns = {};\n this._svgClipPaths = {};\n\n this.defObjects = {\n brush: new Brush(null, null),\n pen: new Pen(null, Helper.GDI.PenStyle.PS_SOLID, new PointS(null, 1, 1), new ColorRef(null, 0, 0, 0), 0, 0),\n font: new Font(null, null),\n palette: null,\n region: null,\n };\n\n this.state = new GDIContextState(null, this.defObjects);\n this.statestack = [this.state];\n this.objects = {};\n }\n\n public setMapMode(mode: number): void {\n Helper.log(\"[gdi] setMapMode: mode=\" + mode);\n this.state.mapmode = mode;\n this.state._svggroup = null;\n }\n\n public setWindowOrg(x: number, y: number): void {\n Helper.log(\"[gdi] setWindowOrg: x=\" + x + \" y=\" + y);\n this.state.wx = x;\n this.state.wy = y;\n this.state._svggroup = null;\n }\n\n public setWindowExt(x: number, y: number): void {\n Helper.log(\"[gdi] setWindowExt: x=\" + x + \" y=\" + y);\n this.state.ww = x;\n this.state.wh = y;\n this.state._svggroup = null;\n }\n\n public offsetWindowOrg(offX: number, offY: number): void {\n Helper.log(\"[gdi] offsetWindowOrg: offX=\" + offX + \" offY=\" + offY);\n this.state.wx += offX;\n this.state.wy += offY;\n this.state._svggroup = null;\n }\n\n public setViewportOrg(x: number, y: number): void {\n Helper.log(\"[gdi] setViewportOrg: x=\" + x + \" y=\" + y);\n this.state.vx = x;\n this.state.vy = y;\n this.state._svggroup = null;\n }\n\n public setViewportExt(x: number, y: number): void {\n Helper.log(\"[gdi] setViewportExt: x=\" + x + \" y=\" + y);\n this.state.vw = x;\n this.state.vh = y;\n this.state._svggroup = null;\n }\n\n public offsetViewportOrg(offX: number, offY: number): void {\n Helper.log(\"[gdi] offsetViewportOrg: offX=\" + offX + \" offY=\" + offY);\n this.state.vx += offX;\n this.state.vy += offY;\n this.state._svggroup = null;\n }\n\n public saveDC(): void {\n Helper.log(\"[gdi] saveDC\");\n const prevstate = this.state;\n this.state = new GDIContextState(this.state);\n this.statestack.push(prevstate);\n this.state._svggroup = null;\n }\n\n public restoreDC(saved: number): void {\n Helper.log(\"[gdi] restoreDC: saved=\" + saved);\n if (this.statestack.length > 1) {\n if (saved === -1) {\n this.state = this.statestack.pop();\n } else if (saved < -1) {\n throw new WMFJSError(\"restoreDC: relative restore not implemented\");\n } else if (saved > 1) {\n throw new WMFJSError(\"restoreDC: absolute restore not implemented\");\n }\n } else {\n throw new WMFJSError(\"No saved contexts\");\n }\n\n this.state._svggroup = null;\n }\n\n public escape(func: number, blob: Blob, offset: number, count: number): void {\n Helper.log(\"[gdi] escape: func=\" + func + \" offset=\" + offset + \" count=\" + count);\n }\n\n public setStretchBltMode(stretchMode: number): void {\n Helper.log(\"[gdi] setStretchBltMode: stretchMode=\" + stretchMode);\n }\n\n public stretchDib(srcX: number, srcY: number, srcW: number, srcH: number,\n dstX: number, dstY: number, dstW: number, dstH: number,\n rasterOp: number, colorUsage: number, dib: DIBitmap): void {\n Helper.log(\"[gdi] stretchDib: srcX=\" + srcX + \" srcY=\" + srcY + \" srcW=\" + srcW + \" srcH=\" + srcH\n + \" dstX=\" + dstX + \" dstY=\" + dstY + \" dstW=\" + dstW + \" dstH=\" + dstH\n + \" rasterOp=0x\" + rasterOp.toString(16));\n srcX = this._todevX(srcX);\n srcY = this._todevY(srcY);\n srcW = this._todevW(srcW);\n srcH = this._todevH(srcH);\n dstX = this._todevX(dstX);\n dstY = this._todevY(dstY);\n dstW = this._todevW(dstW);\n dstH = this._todevH(dstH);\n Helper.log(\"[gdi] stretchDib: TRANSLATED: srcX=\" + srcX + \" srcY=\" + srcY + \" srcW=\" + srcW + \" srcH=\" + srcH\n + \" dstX=\" + dstX + \" dstY=\" + dstY + \" dstW=\" + dstW + \" dstH=\" + dstH\n + \" rasterOp=0x\" + rasterOp.toString(16) + \" colorUsage=0x\" + colorUsage.toString(16));\n this._pushGroup();\n this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());\n }\n\n public dibBits(srcX: number, srcY: number, dstX: number, dstY: number, width: number, height: number,\n rasterOp: number, dib: DIBitmap): void {\n Helper.log(\"[gdi] stretchDibBits: srcX=\" + srcX + \" srcY=\" + srcY\n + \" dstX=\" + dstX + \" dstY=\" + dstY + \" width=\" + width + \" height=\" + height\n + \" rasterOp=0x\" + rasterOp.toString(16));\n srcX = this._todevX(srcX);\n srcY = this._todevY(srcY);\n dstX = this._todevX(dstX);\n dstY = this._todevY(dstY);\n width = this._todevW(width);\n height = this._todevH(height);\n Helper.log(\"[gdi] dibBits: TRANSLATED:\"\n + \" srcX=\" + srcX + \" srcY=\" + srcY + +\" dstX=\" + dstX + \" dstY=\" + dstY\n + \" width=\" + width + \" height=\" + height + \" rasterOp=0x\" + rasterOp.toString(16));\n this._pushGroup();\n this._svg.image(this.state._svggroup, dstX, dstY, width, height, dib.base64ref());\n }\n\n public stretchDibBits(srcX: number, srcY: number, srcW: number, srcH: number,\n dstX: number, dstY: number, dstW: number, dstH: number,\n rasterOp: number, dib: DIBitmap): void {\n Helper.log(\"[gdi] stretchDibBits: srcX=\" + srcX + \" srcY=\" + srcY + \" srcW=\" + srcW + \" srcH=\" + srcH\n + \" dstX=\" + dstX + \" dstY=\" + dstY + \" dstW=\" + dstW + \" dstH=\" + dstH\n + \" rasterOp=0x\" + rasterOp.toString(16));\n srcX = this._todevX(srcX);\n srcY = this._todevY(srcY);\n srcW = this._todevW(srcW);\n srcH = this._todevH(srcH);\n dstX = this._todevX(dstX);\n dstY = this._todevY(dstY);\n dstW = this._todevW(dstW);\n dstH = this._todevH(dstH);\n Helper.log(\"[gdi] stretchDibBits: TRANSLATED:\"\n + \" srcX=\" + srcX + \" srcY=\" + srcY + \" srcW=\" + srcW + \" srcH=\" + srcH\n + \" dstX=\" + dstX + \" dstY=\" + dstY + \" dstW=\" + dstW + \" dstH=\" + dstH\n + \" rasterOp=0x\" + rasterOp.toString(16));\n this._pushGroup();\n this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());\n }\n\n public rectangle(rect: Rect, rw: number, rh: number): void {\n Helper.log(\"[gdi] rectangle: rect=\" + rect.toString() + \" with pen \" + this.state.selected.pen.toString()\n + \" and brush \" + this.state.selected.brush.toString());\n const bottom = this._todevY(rect.bottom);\n const right = this._todevX(rect.right);\n const top = this._todevY(rect.top);\n const left = this._todevX(rect.left);\n rw = this._todevH(rw);\n rh = this._todevH(rh);\n Helper.log(\"[gdi] rectangle: TRANSLATED: bottom=\" + bottom + \" right=\" + right + \" top=\" + top\n + \" left=\" + left + \" rh=\" + rh + \" rw=\" + rw);\n this._pushGroup();\n\n const opts = this._applyOpts(null, true, true, false);\n this._svg.rect(this.state._svggroup, left, top, right - left, bottom - top, rw / 2, rh / 2, opts);\n }\n\n public textOut(x: number, y: number, text: string): void {\n Helper.log(\"[gdi] textOut: x=\" + x + \" y=\" + y + \" text=\" + text\n + \" with font \" + this.state.selected.font.toString());\n x = this._todevX(x);\n y = this._todevY(y);\n Helper.log(\"[gdi] textOut: TRANSLATED: x=\" + x + \" y=\" + y);\n this._pushGroup();\n\n const opts = this._applyOpts(null, false, false, true);\n if (this.state.selected.font.escapement !== 0) {\n opts.transform = \"rotate(\" + [(-this.state.selected.font.escapement / 10), x, y] + \")\";\n opts.style = \"dominant-baseline: middle; text-anchor: start;\";\n }\n if (this.state.bkmode === Helper.GDI.MixMode.OPAQUE) {\n if (this.state._svgtextbkfilter == null) {\n const filterId = Helper._makeUniqueId(\"f\");\n const filter = this._svg.filter(this._getSvgDef(), filterId, 0, 0, 1, 1);\n this._svg.filters.flood(filter, null, \"#\" + this.state.bkcolor.toHex(), 1.0);\n this._svg.filters.composite(filter, null, null, \"SourceGraphic\");\n this.state._svgtextbkfilter = filter;\n }\n\n opts.filter = \"url(#\" + this.state._svgtextbkfilter.id + \")\";\n }\n this._svg.text(this.state._svggroup, x, y, text, opts);\n }\n\n public extTextOut(x: number, y: number, text: string, fwOpts: number, rect: Rect, dx: number[]): void {\n Helper.log(\"[gdi] extTextOut: x=\" + x + \" y=\" + y + \" text=\" + text\n + \" with font \" + this.state.selected.font.toString());\n x = this._todevX(x);\n y = this._todevY(y);\n Helper.log(\"[gdi] extTextOut: TRANSLATED: x=\" + x + \" y=\" + y);\n this._pushGroup();\n\n const opts = this._applyOpts(null, false, false, true);\n if (this.state.selected.font.escapement !== 0) {\n opts.transform = \"rotate(\" + [(-this.state.selected.font.escapement / 10), x, y] + \")\";\n opts.style = \"dominant-baseline: middle; text-anchor: start;\";\n }\n if (this.state.bkmode === Helper.GDI.MixMode.OPAQUE) {\n if (this.state._svgtextbkfilter == null) {\n const filterId = Helper._makeUniqueId(\"f\");\n const filter = this._svg.filter(this._getSvgDef(), filterId, 0, 0, 1, 1);\n this._svg.filters.flood(filter, null, \"#\" + this.state.bkcolor.toHex(), 1.0);\n this._svg.filters.composite(filter, null, null, \"SourceGraphic\");\n this.state._svgtextbkfilter = filter;\n }\n\n opts.filter = \"url(#\" + this.state._svgtextbkfilter.id + \")\";\n }\n this._svg.text(this.state._svggroup, x, y, text, opts);\n }\n\n public lineTo(x: number, y: number): void {\n Helper.log(\"[gdi] lineTo: x=\" + x + \" y=\" + y + \" with pen \" + this.state.selected.pen.toString());\n const toX = this._todevX(x);\n const toY = this._todevY(y);\n const fromX = this._todevX(this.state.x);\n const fromY = this._todevY(this.state.y);\n\n // Update position\n this.state.x = x;\n this.state.y = y;\n\n Helper.log(\"[gdi] lineTo: TRANSLATED: toX=\" + toX + \" toY=\" + toY + \" fromX=\" + fromX + \" fromY=\" + fromY);\n this._pushGroup();\n\n const opts = this._applyOpts(null, true, false, false);\n this._svg.line(this.state._svggroup, fromX, fromY, toX, toY, opts);\n }\n\n public moveTo(x: number, y: number): void {\n Helper.log(\"[gdi] moveTo: x=\" + x + \" y=\" + y);\n this.state.x = x;\n this.state.y = y;\n }\n\n public polygon(points: PointS[], first: boolean): void {\n Helper.log(\"[gdi] polygon: points=\" + points + \" with pen \" + this.state.selected.pen.toString()\n + \" and brush \" + this.state.selected.brush.toString());\n const pts = [];\n for (let i = 0; i < points.length; i++) {\n const point = points[i];\n pts.push([this._todevX(point.x), this._todevY(point.y)]);\n }\n Helper.log(\"[gdi] polygon: TRANSLATED: pts=\" + pts);\n if (first) {\n this._pushGroup();\n }\n const opts = {\n \"fill-rule\": this.state.polyfillmode === Helper.GDI.PolyFillMode.ALTERNATE ? \"evenodd\" : \"nonzero\",\n };\n this._applyOpts(opts, true, true, false);\n this._svg.polygon(this.state._svggroup, pts, opts);\n }\n\n public polyPolygon(polygons: PointS[][]): void {\n Helper.log(\"[gdi] polyPolygon: polygons.length=\" + polygons.length\n + \" with pen \" + this.state.selected.pen.toString()\n + \" and brush \" + this.state.selected.brush.toString());\n\n const cnt = polygons.length;\n for (let i = 0; i < cnt; i++) {\n this.polygon(polygons[i], i === 0);\n }\n }\n\n public polyline(points: PointS[]): void {\n Helper.log(\"[gdi] polyline: points=\" + points + \" with pen \" + this.state.selected.pen.toString());\n const pts = [];\n for (let i = 0; i < points.length; i++) {\n const point = points[i];\n pts.push([this._todevX(point.x), this._todevY(point.y)]);\n }\n Helper.log(\"[gdi] polyline: TRANSLATED: pts=\" + pts);\n this._pushGroup();\n const opts = this._applyOpts({fill: \"none\"}, true, false, false);\n this._svg.polyline(this.state._svggroup, pts, opts);\n }\n\n public ellipse(rect: Rect): void {\n Helper.log(\"[gdi] ellipse: rect=\" + rect.toString() + \" with pen \" + this.state.selected.pen.toString()\n + \" and brush \" + this.state.selected.brush.toString());\n const bottom = this._todevY(rect.bottom);\n const right = this._todevX(rect.right);\n const top = this._todevY(rect.top);\n const left = this._todevX(rect.left);\n Helper.log(\"[gdi] ellipse: TRANSLATED: bottom=\" + bottom + \" right=\" + right + \" top=\" + top + \" left=\" + left);\n this._pushGroup();\n const width2 = (right - left) / 2;\n const height2 = (bottom - top) / 2;\n const opts = this._applyOpts(null, true, true, false);\n this._svg.ellipse(this.state._svggroup, left + width2, top + height2, width2, height2, opts);\n }\n\n public excludeClipRect(rect: Rect): void {\n Helper.log(\"[gdi] excludeClipRect: rect=\" + rect.toString());\n this._getClipRgn().subtract(rect);\n }\n\n public intersectClipRect(rect: Rect): void {\n Helper.log(\"[gdi] intersectClipRect: rect=\" + rect.toString());\n this._getClipRgn().intersect(rect);\n }\n\n public offsetClipRgn(offX: number, offY: number): void {\n Helper.log(\"[gdi] offsetClipRgn: offX=\" + offX + \" offY=\" + offY);\n this._getClipRgn().offset(offX, offY);\n }\n\n public setTextAlign(textAlignmentMode: number): void {\n Helper.log(\"[gdi] setTextAlign: textAlignmentMode=0x\" + textAlignmentMode.toString(16));\n this.state.textalign = textAlignmentMode;\n }\n\n public setBkMode(bkMode: number): void {\n Helper.log(\"[gdi] setBkMode: bkMode=0x\" + bkMode.toString(16));\n this.state.bkmode = bkMode;\n }\n\n public setTextColor(textColor: ColorRef): void {\n Helper.log(\"[gdi] setTextColor: textColor=\" + textColor.toString());\n this.state.textcolor = textColor;\n }\n\n public setBkColor(bkColor: ColorRef): void {\n Helper.log(\"[gdi] setBkColor: bkColor=\" + bkColor.toString());\n this.state.bkcolor = bkColor;\n this.state._svgtextbkfilter = null;\n }\n\n public setPolyFillMode(polyFillMode: number): void {\n Helper.log(\"[gdi] setPolyFillMode: polyFillMode=\" + polyFillMode);\n this.state.polyfillmode = polyFillMode;\n }\n\n public createBrush(brush: Brush): void {\n const idx = this._storeObject(brush);\n Helper.log(\"[gdi] createBrush: brush=\" + brush.toString() + \" with handle \" + idx);\n }\n\n public createFont(font: Font): void {\n const idx = this._storeObject(font);\n Helper.log(\"[gdi] createFont: font=\" + font.toString() + \" with handle \" + idx);\n }\n\n public createPen(pen: Pen): void {\n const idx = this._storeObject(pen);\n Helper.log(\"[gdi] createPen: pen=\" + pen.toString() + \" width handle \" + idx);\n }\n\n public createPalette(palette: Palette): void {\n const idx = this._storeObject(palette);\n Helper.log(\"[gdi] createPalette: palette=\" + palette.toString() + \" width handle \" + idx);\n }\n\n public createRegion(region: Region): void {\n const idx = this._storeObject(region);\n Helper.log(\"[gdi] createRegion: region=\" + region.toString() + \" width handle \" + idx);\n }\n\n public createPatternBrush(patternBrush: Brush): void {\n const idx = this._storeObject(patternBrush);\n Helper.log(\"[gdi] createRegion: region=\" + patternBrush.toString() + \" width handle \" + idx);\n }\n\n public selectObject(objIdx: number, checkType: string): void {\n const obj = this._getObject(objIdx);\n if (obj != null && (checkType == null || obj.type === checkType)) {\n this._selectObject(obj);\n Helper.log(\"[gdi] selectObject: objIdx=\" + objIdx\n + (obj ? \" selected \" + obj.type + \": \" + obj.toString() : \"[invalid index]\"));\n } else {\n Helper.log(\"[gdi] selectObject: objIdx=\" + objIdx\n + (obj ? \" invalid object type: \" + obj.type : \"[invalid index]\"));\n }\n }\n\n public deleteObject(objIdx: number): void {\n const ret = this._deleteObject(objIdx);\n Helper.log(\"[gdi] deleteObject: objIdx=\" + objIdx + (ret ? \" deleted object\" : \"[invalid index]\"));\n }\n\n private _pushGroup() {\n if (this.state._svggroup == null || this.state._svgclipChanged) {\n this.state._svgclipChanged = false;\n this.state._svgtextbkfilter = null;\n\n const settings: any = {\n viewBox: [this.state.vx, this.state.vy, this.state.vw, this.state.vh].join(\" \"),\n preserveAspectRatio: \"none\",\n };\n if (this.state.clip != null) {\n Helper.log(\"[gdi] new svg x=\" + this.state.vx + \" y=\" + this.state.vy\n + \" width=\" + this.state.vw + \" height=\" + this.state.vh + \" with clipping\");\n settings[\"clip-path\"] = \"url(#\" + this._getSvgClipPathForRegion(this.state.clip) + \")\";\n } else {\n Helper.log(\"[gdi] new svg x=\" + this.state.vx + \" y=\" + this.state.vy\n + \" width=\" + this.state.vw + \" height=\" + this.state.vh + \" without clipping\");\n }\n this.state._svggroup = this._svg.svg(this.state._svggroup,\n this.state.vx, this.state.vy, this.state.vw, this.state.vh, settings);\n }\n }\n\n private _storeObject(obj: Obj) {\n let i = 0;\n while (this.objects[i.toString()] != null && i <= 65535) {\n i++;\n }\n if (i > 65535) {\n Helper.log(\"[gdi] Too many objects!\");\n return -1;\n }\n\n this.objects[i.toString()] = obj;\n return i;\n }\n\n private _getObject(objIdx: number) {\n const obj = this.objects[objIdx.toString()];\n if (obj == null) {\n Helper.log(\"[gdi] No object with handle \" + objIdx);\n }\n return obj;\n }\n\n private _getSvgDef() {\n if (this._svgdefs == null) {\n this._svgdefs = this._svg.defs();\n }\n return this._svgdefs;\n }\n\n private _getSvgClipPathForRegion(region: Region) {\n for (const existingId in this._svgClipPaths) {\n const rgn = this._svgClipPaths[existingId];\n if (rgn === region) {\n return existingId;\n }\n }\n\n const id = Helper._makeUniqueId(\"c\");\n const sclip = this._svg.clipPath(this._getSvgDef(), id, \"userSpaceOnUse\");\n switch (region.complexity) {\n case 1:\n this._svg.rect(sclip, this._todevX(region.bounds.left), this._todevY(region.bounds.top),\n this._todevW(region.bounds.right - region.bounds.left),\n this._todevH(region.bounds.bottom - region.bounds.top),\n {\"fill\": \"black\", \"stroke-width\": 0});\n break;\n case 2:\n for (let i = 0; i < region.scans.length; i++) {\n const scan = region.scans[i];\n for (let j = 0; j < scan.scanlines.length; j++) {\n const scanline = scan.scanlines[j];\n this._svg.rect(sclip, this._todevX(scanline.left), this._todevY(scan.top),\n this._todevW(scanline.right - scanline.left), this._todevH(scan.bottom - scan.top),\n {\"fill\": \"black\", \"stroke-width\": 0});\n }\n }\n break;\n }\n this._svgClipPaths[id] = region;\n return id;\n }\n\n private _getSvgPatternForBrush(brush: Brush) {\n for (const existingId in this._svgPatterns) {\n const pat = this._svgPatterns[existingId];\n if (pat === brush) {\n return existingId;\n }\n }\n\n let width;\n let height;\n let img;\n switch (brush.style) {\n case Helper.GDI.BrushStyle.BS_PATTERN:\n width = brush.pattern.getWidth();\n height = brush.pattern.getHeight();\n break;\n case Helper.GDI.BrushStyle.BS_DIBPATTERNPT:\n width = brush.dibpatternpt.getWidth();\n height = brush.dibpatternpt.getHeight();\n img = brush.dibpatternpt.base64ref();\n break;\n default:\n throw new WMFJSError(\"Invalid brush style\");\n }\n\n const id = Helper._makeUniqueId(\"p\");\n const spat = this._svg.pattern(this._getSvgDef(), id, 0, 0, width, height, {patternUnits: \"userSpaceOnUse\"});\n this._svg.image(spat, 0, 0, width, height, img);\n this._svgPatterns[id] = brush;\n return id;\n }\n\n private _selectObject(obj: Obj) {\n this.state.selected[obj.type] = obj;\n if (obj.type === \"region\") {\n this.state._svgclipChanged = true;\n }\n }\n\n private _deleteObject(objIdx: number) {\n const obj = this.objects[objIdx.toString()];\n if (obj != null) {\n for (let i = 0; i < this.statestack.length; i++) {\n const state = this.statestack[i];\n if (state.selected[obj.type] === obj) {\n state.selected[obj.type] = this.defObjects[obj.type].clone();\n }\n }\n delete this.objects[objIdx.toString()];\n return true;\n }\n\n Helper.log(\"[gdi] Cannot delete object with invalid handle \" + objIdx);\n return false;\n }\n\n private _getClipRgn() {\n if (this.state.clip != null) {\n if (!this.state.ownclip) {\n this.state.clip = this.state.clip.clone();\n }\n } else {\n if (this.state.selected.region != null) {\n this.state.clip = this.state.selected.region.clone();\n } else {\n this.state.clip = CreateSimpleRegion(this.state.wx, this.state.wy, this.state.wx + this.state.ww,\n this.state.wy + this.state.wh);\n }\n }\n this.state.ownclip = true;\n return this.state.clip;\n }\n\n private _todevX(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor((val - this.state.wx) * (this.state.vw / this.state.ww)) + this.state.vx;\n }\n\n private _todevY(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor((val - this.state.wy) * (this.state.vh / this.state.wh)) + this.state.vy;\n }\n\n private _todevW(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor(val * (this.state.vw / this.state.ww)) + this.state.vx;\n }\n\n private _todevH(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor(val * (this.state.vh / this.state.wh)) + this.state.vy;\n }\n\n private _tologicalX(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor((val - this.state.vx) / (this.state.vw / this.state.ww)) + this.state.wx;\n }\n\n private _tologicalY(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor((val - this.state.vy) / (this.state.vh / this.state.wh)) + this.state.wy;\n }\n\n private _tologicalW(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor(val / (this.state.vw / this.state.ww)) + this.state.wx;\n }\n\n private _tologicalH(val: number) {\n // http://wvware.sourceforge.net/caolan/mapmode.html\n // logical -> device\n return Math.floor(val / (this.state.vh / this.state.wh)) + this.state.wy;\n }\n\n private _applyOpts(opts: any, usePen: boolean, useBrush: boolean, useFont: boolean) {\n if (opts == null) {\n opts = {};\n }\n if (usePen) {\n const pen = this.state.selected.pen;\n if (pen.style !== Helper.GDI.PenStyle.PS_NULL) {\n opts.stroke = \"#\" + pen.color.toHex(), // TODO: pen style\n opts[\"stroke-width\"] = this._todevW(pen.width.x); // TODO: is .y ever used?\n\n let dotWidth;\n if ((pen.linecap & Helper.GDI.PenStyle.PS_ENDCAP_SQUARE) !== 0) {\n opts[\"stroke-linecap\"] = \"square\";\n dotWidth = 1;\n } else if ((pen.linecap & Helper.GDI.PenStyle.PS_ENDCAP_FLAT) !== 0) {\n opts[\"stroke-linecap\"] = \"butt\";\n dotWidth = opts[\"stroke-width\"];\n } else {\n opts[\"stroke-linecap\"] = \"round\";\n dotWidth = 1;\n }\n\n if ((pen.join & Helper.GDI.PenStyle.PS_JOIN_BEVEL) !== 0) {\n opts[\"stroke-linejoin\"] = \"bevel\";\n } else if ((pen.join & Helper.GDI.PenStyle.PS_JOIN_MITER) !== 0) {\n opts[\"stroke-linejoin\"] = \"miter\";\n } else {\n opts[\"stroke-linejoin\"] = \"round\";\n }\n\n const dashWidth = opts[\"stroke-width\"] * 4;\n const dotSpacing = opts[\"stroke-width\"] * 2;\n switch (pen.style) {\n case Helper.GDI.PenStyle.PS_DASH:\n opts[\"stroke-dasharray\"] = [dashWidth, dotSpacing].toString();\n break;\n case Helper.GDI.PenStyle.PS_DOT:\n opts[\"stroke-dasharray\"] = [dotWidth, dotSpacing].toString();\n break;\n case Helper.GDI.PenStyle.PS_DASHDOT:\n opts[\"stroke-dasharray\"] = [dashWidth, dotSpacing, dotWidth, dotSpacing].toString();\n break;\n case Helper.GDI.PenStyle.PS_DASHDOTDOT:\n opts[\"stroke-dasharray\"]\n = [dashWidth, dotSpacing, dotWidth, dotSpacing, dotWidth, dotSpacing].toString();\n break;\n }\n }\n }\n if (useBrush) {\n const brush = this.state.selected.brush;\n switch (brush.style) {\n case Helper.GDI.BrushStyle.BS_SOLID:\n opts.fill = \"#\" + brush.color.toHex();\n break;\n case Helper.GDI.BrushStyle.BS_PATTERN:\n case Helper.GDI.BrushStyle.BS_DIBPATTERNPT:\n opts.fill = \"url(#\" + this._getSvgPatternForBrush(brush) + \")\";\n break;\n case Helper.GDI.BrushStyle.BS_NULL:\n opts.fill = \"none\";\n break;\n default:\n Helper.log(\"[gdi] unsupported brush style: \" + brush.style);\n opts.fill = \"none\";\n break;\n }\n }\n if (useFont) {\n const font = this.state.selected.font;\n opts[\"font-family\"] = font.facename;\n opts[\"font-size\"] = this._todevH(Math.abs(font.height));\n opts.fill = \"#\" + this.state.textcolor.toHex();\n }\n return opts;\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { DIBitmap, PatternBitmap16 } from \"./Bitmap\";\nimport { Blob } from \"./Blob\";\nimport { GDIContext } from \"./GDIContext\";\nimport { Helper, WMFJSError } from \"./Helper\";\nimport { PointS, Rect } from \"./Primitives\";\nimport { Region } from \"./Region\";\nimport { Brush, ColorRef, Font, Palette, Pen } from \"./Style\";\n\nexport class WMFRecords {\n private _records: ((gdi: GDIContext) => void)[];\n\n constructor(reader: Blob, first: number) {\n this._records = [];\n\n let all = false;\n let curpos = first;\n main_loop: while (!all) {\n reader.seek(curpos);\n const size = reader.readUint32();\n if (size < 3) {\n throw new WMFJSError(\"Invalid record size\");\n }\n const type = reader.readUint16();\n switch (type) {\n case Helper.GDI.RecordType.META_EOF:\n all = true;\n break main_loop;\n case Helper.GDI.RecordType.META_SETMAPMODE: {\n const mapMode = reader.readUint16();\n this._records.push((gdi) => {\n gdi.setMapMode(mapMode);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETWINDOWORG: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.setWindowOrg(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETWINDOWEXT: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.setWindowExt(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_OFFSETWINDOWORG: {\n const offY = reader.readInt16();\n const offX = reader.readInt16();\n this._records.push((gdi) => {\n gdi.offsetWindowOrg(offX, offY);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETVIEWPORTORG: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.setViewportOrg(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETVIEWPORTEXT: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.setViewportExt(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_OFFSETVIEWPORTORG: {\n const offY = reader.readInt16();\n const offX = reader.readInt16();\n this._records.push((gdi) => {\n gdi.offsetViewportOrg(offX, offY);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SAVEDC: {\n this._records.push((gdi) => {\n gdi.saveDC();\n });\n break;\n }\n case Helper.GDI.RecordType.META_RESTOREDC: {\n const saved = reader.readInt16();\n this._records.push((gdi) => {\n gdi.restoreDC(saved);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETSTRETCHBLTMODE: {\n const stretchMode = reader.readUint16();\n this._records.push((gdi) => {\n gdi.setStretchBltMode(stretchMode);\n });\n break;\n }\n case Helper.GDI.RecordType.META_DIBBITBLT: {\n const haveSrcDib = ((type >> 8) + 3 !== size);\n const rasterOp = reader.readUint16() | (reader.readUint16() << 16);\n const srcY = reader.readInt16();\n const srcX = reader.readInt16();\n if (!haveSrcDib) {\n // ignore reserved field\n reader.skip(2);\n }\n const height = reader.readInt16();\n const width = reader.readInt16();\n const destY = reader.readInt16();\n const destX = reader.readInt16();\n if (haveSrcDib) {\n const datalength = size * 2 - (reader.pos - curpos);\n const dib = new DIBitmap(reader, datalength);\n this._records.push((gdi) => {\n gdi.dibBits(srcX, srcY, destX, destY, width, height, rasterOp, dib);\n });\n }\n break;\n }\n case Helper.GDI.RecordType.META_DIBSTRETCHBLT: {\n const haveSrcDib = ((type >> 8) + 3 !== size);\n const rasterOp = reader.readUint16() | (reader.readUint16() << 16);\n const srcH = reader.readInt16();\n const srcW = reader.readInt16();\n const srcY = reader.readInt16();\n const srcX = reader.readInt16();\n const destH = reader.readInt16();\n const destW = reader.readInt16();\n const destY = reader.readInt16();\n const destX = reader.readInt16();\n const datalength = size * 2 - (reader.pos - curpos);\n const dib = new DIBitmap(reader, datalength);\n this._records.push((gdi) => {\n gdi.stretchDibBits(srcX, srcY, srcW, srcH, destX, destY, destW, destH, rasterOp, dib);\n });\n break;\n }\n case Helper.GDI.RecordType.META_STRETCHDIB: {\n const rasterOp = reader.readUint16() | (reader.readUint16() << 16);\n const colorUsage = reader.readInt16();\n const srcH = reader.readInt16();\n const srcW = reader.readInt16();\n const srcY = reader.readInt16();\n const srcX = reader.readInt16();\n const destH = reader.readInt16();\n const destW = reader.readInt16();\n const destY = reader.readInt16();\n const destX = reader.readInt16();\n const datalength = size * 2 - (reader.pos - curpos);\n const dib = new DIBitmap(reader, datalength);\n this._records.push((gdi) => {\n gdi.stretchDib(srcX, srcY, srcW, srcH, destX, destY, destW, destH, rasterOp, colorUsage, dib);\n });\n break;\n }\n case Helper.GDI.RecordType.META_ESCAPE: {\n const func = reader.readUint16();\n const count = reader.readUint16();\n const offset = reader.pos;\n const blob = new Blob(reader, offset);\n this._records.push((gdi) => {\n gdi.escape(func, blob, offset, count);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETTEXTALIGN: {\n const textAlign = reader.readUint16();\n this._records.push((gdi) => {\n gdi.setTextAlign(textAlign);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETBKMODE: {\n const bkMode = reader.readUint16();\n this._records.push((gdi) => {\n gdi.setBkMode(bkMode);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETTEXTCOLOR: {\n const textColor = new ColorRef(reader);\n this._records.push((gdi) => {\n gdi.setTextColor(textColor);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETBKCOLOR: {\n const bkColor = new ColorRef(reader);\n this._records.push((gdi) => {\n gdi.setBkColor(bkColor);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEBRUSHINDIRECT: {\n const datalength = size * 2 - (reader.pos - curpos);\n const brush = new Brush(reader, datalength, false);\n this._records.push((gdi) => {\n gdi.createBrush(brush);\n });\n break;\n }\n case Helper.GDI.RecordType.META_DIBCREATEPATTERNBRUSH: {\n const datalength = size * 2 - (reader.pos - curpos);\n const brush = new Brush(reader, datalength, true);\n this._records.push((gdi) => {\n gdi.createBrush(brush);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEPENINDIRECT: {\n const pen = new Pen(reader);\n this._records.push((gdi) => {\n gdi.createPen(pen);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEFONTINDIRECT: {\n const datalength = size * 2 - (reader.pos - curpos);\n const font = new Font(reader, datalength);\n this._records.push((gdi) => {\n gdi.createFont(font);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SELECTOBJECT: {\n const idx = reader.readUint16();\n this._records.push((gdi) => {\n gdi.selectObject(idx, null);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SELECTPALETTE: {\n const idx = reader.readUint16();\n this._records.push((gdi) => {\n gdi.selectObject(idx, \"palette\");\n });\n break;\n }\n case Helper.GDI.RecordType.META_SELECTCLIPREGION: {\n const idx = reader.readUint16();\n this._records.push((gdi) => {\n gdi.selectObject(idx, \"region\");\n });\n break;\n }\n case Helper.GDI.RecordType.META_DELETEOBJECT: {\n const idx = reader.readUint16();\n this._records.push((gdi) => {\n gdi.deleteObject(idx);\n });\n break;\n }\n case Helper.GDI.RecordType.META_RECTANGLE: {\n const rect = new Rect(reader);\n this._records.push((gdi) => {\n gdi.rectangle(rect, 0, 0);\n });\n break;\n }\n case Helper.GDI.RecordType.META_ROUNDRECT: {\n const rh = reader.readInt16();\n const rw = reader.readInt16();\n const rect = new Rect(reader);\n this._records.push((gdi) => {\n gdi.rectangle(rect, rw, rh);\n });\n break;\n }\n case Helper.GDI.RecordType.META_LINETO: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.lineTo(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_MOVETO: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.moveTo(x, y);\n });\n break;\n }\n case Helper.GDI.RecordType.META_TEXTOUT: {\n const len = reader.readInt16();\n if (len > 0) {\n const text = reader.readString(len);\n reader.skip(len % 2);\n const y = reader.readInt16();\n const x = reader.readInt16();\n this._records.push((gdi) => {\n gdi.textOut(x, y, text);\n });\n }\n break;\n }\n case Helper.GDI.RecordType.META_EXTTEXTOUT: {\n const y = reader.readInt16();\n const x = reader.readInt16();\n const len = reader.readInt16();\n const fwOpts = reader.readUint16();\n\n let hasRect = null;\n let hasDx = null;\n if (size * 2 === 14 + len + len % 2) {\n hasRect = false;\n hasDx = false;\n }\n if (size * 2 === 14 + 8 + len + len % 2) {\n hasRect = true;\n hasDx = false;\n }\n if (size * 2 === 14 + len + len % 2 + len * 2) {\n hasRect = false;\n hasDx = true;\n }\n if (size * 2 === 14 + 8 + len + len % 2 + len * 2) {\n hasRect = true;\n hasDx = true;\n }\n\n const rect = hasRect ? new Rect(reader) : null;\n if (len > 0) {\n const text = reader.readString(len);\n reader.skip(len % 2);\n\n const dx: number[] = [];\n if (hasDx) {\n for (let i = 0; i < text.length; i++) {\n dx.push(reader.readInt16());\n }\n }\n\n this._records.push((gdi) => {\n gdi.extTextOut(x, y, text, fwOpts, rect, dx);\n });\n }\n break;\n }\n case Helper.GDI.RecordType.META_EXCLUDECLIPRECT: {\n const rect = new Rect(reader);\n this._records.push((gdi) => {\n gdi.excludeClipRect(rect);\n });\n break;\n }\n case Helper.GDI.RecordType.META_INTERSECTCLIPRECT: {\n const rect = new Rect(reader);\n this._records.push((gdi) => {\n gdi.intersectClipRect(rect);\n });\n break;\n }\n case Helper.GDI.RecordType.META_POLYGON: {\n let cnt = reader.readInt16();\n const points: PointS[] = [];\n while (cnt > 0) {\n points.push(new PointS(reader));\n cnt--;\n }\n this._records.push((gdi) => {\n gdi.polygon(points, true);\n });\n break;\n }\n case Helper.GDI.RecordType.META_SETPOLYFILLMODE: {\n const polyfillmode = reader.readUint16();\n this._records.push((gdi) => {\n gdi.setPolyFillMode(polyfillmode);\n });\n break;\n }\n case Helper.GDI.RecordType.META_POLYPOLYGON: {\n const cnt = reader.readUint16();\n const polygonsPtCnts = [];\n for (let i = 0; i < cnt; i++) {\n polygonsPtCnts.push(reader.readUint16());\n }\n\n const polygons: PointS[][] = [];\n for (let i = 0; i < cnt; i++) {\n const ptCnt = polygonsPtCnts[i];\n\n const p = [];\n for (let ip = 0; ip < ptCnt; ip++) {\n p.push(new PointS(reader));\n }\n polygons.push(p);\n }\n this._records.push((gdi) => {\n gdi.polyPolygon(polygons);\n });\n break;\n }\n case Helper.GDI.RecordType.META_POLYLINE: {\n let cnt = reader.readInt16();\n const points: PointS[] = [];\n while (cnt > 0) {\n points.push(new PointS(reader));\n cnt--;\n }\n this._records.push((gdi) => {\n gdi.polyline(points);\n });\n break;\n }\n case Helper.GDI.RecordType.META_ELLIPSE: {\n const rect = new Rect(reader);\n this._records.push((gdi) => {\n gdi.ellipse(rect);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEPALETTE: {\n const palette = new Palette(reader);\n this._records.push((gdi) => {\n gdi.createPalette(palette);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEREGION: {\n const region = new Region(reader);\n this._records.push((gdi) => {\n gdi.createRegion(region);\n });\n break;\n }\n case Helper.GDI.RecordType.META_CREATEPATTERNBRUSH: {\n const datalength = size * 2 - (reader.pos - curpos);\n const patternBitmap = new PatternBitmap16(reader, datalength);\n const brush = new Brush(reader, datalength, patternBitmap);\n this._records.push((gdi) => {\n gdi.createPatternBrush(brush);\n });\n break;\n }\n case Helper.GDI.RecordType.META_OFFSETCLIPRGN: {\n const offY = reader.readInt16();\n const offX = reader.readInt16();\n this._records.push((gdi) => {\n gdi.offsetClipRgn(offX, offY);\n });\n break;\n }\n case Helper.GDI.RecordType.META_REALIZEPALETTE:\n case Helper.GDI.RecordType.META_SETPALENTRIES:\n case Helper.GDI.RecordType.META_SETROP2:\n case Helper.GDI.RecordType.META_SETRELABS:\n case Helper.GDI.RecordType.META_SETTEXTCHAREXTRA:\n case Helper.GDI.RecordType.META_RESIZEPALETTE:\n case Helper.GDI.RecordType.META_SETLAYOUT:\n case Helper.GDI.RecordType.META_FILLREGION:\n case Helper.GDI.RecordType.META_SETMAPPERFLAGS:\n case Helper.GDI.RecordType.META_SETTEXTJUSTIFICATION:\n case Helper.GDI.RecordType.META_SCALEWINDOWEXT:\n case Helper.GDI.RecordType.META_SCALEVIEWPORTEXT:\n case Helper.GDI.RecordType.META_FLOODFILL:\n case Helper.GDI.RecordType.META_FRAMEREGION:\n case Helper.GDI.RecordType.META_ANIMATEPALETTE:\n case Helper.GDI.RecordType.META_EXTFLOODFILL:\n case Helper.GDI.RecordType.META_SETPIXEL:\n case Helper.GDI.RecordType.META_PATBLT:\n case Helper.GDI.RecordType.META_PIE:\n case Helper.GDI.RecordType.META_STRETCHBLT:\n case Helper.GDI.RecordType.META_INVERTREGION:\n case Helper.GDI.RecordType.META_PAINTREGION:\n case Helper.GDI.RecordType.META_ARC:\n case Helper.GDI.RecordType.META_CHORD:\n case Helper.GDI.RecordType.META_BITBLT:\n case Helper.GDI.RecordType.META_SETDIBTODEV:\n default: {\n let recordName = \"UNKNOWN\";\n for (const name in Helper.GDI.RecordType) {\n const recordTypes: any = Helper.GDI.RecordType;\n if (recordTypes[name] === type) {\n recordName = name;\n break;\n }\n }\n Helper.log(\"[WMF] \" + recordName + \" record (0x\" + type.toString(16) + \") at offset 0x\"\n + curpos.toString(16) + \" with \" + (size * 2) + \" bytes\");\n break;\n }\n }\n\n curpos += size * 2;\n }\n\n if (!all) {\n throw new WMFJSError(\"Could not read all records\");\n }\n }\n\n public play(gdi: GDIContext): void {\n const len = this._records.length;\n for (let i = 0; i < len; i++) {\n this._records[i](gdi);\n }\n }\n}\n","/*\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Thomas Bluemel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nimport { SVG } from \"../util\";\nimport { Blob } from \"./Blob\";\nimport { GDIContext } from \"./GDIContext\";\nimport { Helper, WMFJSError } from \"./Helper\";\nimport { WMFRecords } from \"./WMFRecords\";\n\nexport interface IRendererSettings {\n width: string;\n height: string;\n xExt: number;\n yExt: number;\n mapMode: number;\n}\n\nexport class Renderer {\n private _img: WMF;\n\n constructor(blob: ArrayBuffer) {\n this.parse(blob);\n Helper.log(\"WMFJS.Renderer instantiated\");\n }\n\n public render(info: IRendererSettings): SVGElement {\n const svgElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\n this._render(new SVG(svgElement), info.mapMode, info.xExt, info.yExt);\n svgElement.setAttribute(\"viewBox\", [0, 0, info.xExt, info.yExt].join(\" \"));\n svgElement.setAttribute(\"preserveAspectRatio\", \"none\"); // TODO: MM_ISOTROPIC vs MM_ANISOTROPIC\n svgElement.setAttribute(\"width\", info.width);\n svgElement.setAttribute(\"height\", info.height);\n return svgElement;\n }\n\n private parse(blob: ArrayBuffer) {\n this._img = null;\n\n const reader = new Blob(blob);\n\n let type;\n let size;\n let placable;\n let headerstart;\n const key = reader.readUint32();\n if (key === 0x9ac6cdd7) {\n placable = new WMFPlacable(reader);\n headerstart = reader.pos;\n type = reader.readUint16();\n size = reader.readUint16();\n } else {\n headerstart = 0;\n type = key & 0xffff;\n size = (key >>> 16) & 0xffff;\n }\n switch (type) {\n case Helper.GDI.MetafileType.MEMORYMETAFILE:\n case Helper.GDI.MetafileType.DISKMETAFILE:\n if (size === Helper.GDI.METAHEADER_SIZE / 2) {\n const version = reader.readUint16();\n switch (version) {\n case Helper.GDI.MetafileVersion.METAVERSION100:\n case Helper.GDI.MetafileVersion.METAVERSION300:\n this._img = new WMF(reader, placable, version, headerstart + (size * 2));\n break;\n }\n }\n break;\n }\n\n if (this._img == null) {\n throw new WMFJSError(\"Format not recognized\");\n }\n }\n\n private _render(svg: SVG, mapMode: number, xExt: number, yExt: number) {\n // See https://www-user.tu-chemnitz.de/~ygu/petzold/ch18b.htm\n const gdi = new GDIContext(svg);\n gdi.setViewportExt(xExt, yExt);\n gdi.setMapMode(mapMode);\n Helper.log(\"[WMF] BEGIN RENDERING --->\");\n this._img.render(gdi);\n Helper.log(\"[WMF] <--- DONE RENDERING\");\n }\n}\n\nclass WMFRect16 {\n private left: number;\n private top: number;\n private right: number;\n private bottom: number;\n\n constructor(reader: Blob) {\n this.left = reader.readInt16();\n this.top = reader.readInt16();\n this.right = reader.readInt16();\n this.bottom = reader.readInt16();\n }\n\n public toString(): string {\n return \"{left: \" + this.left + \", top: \" + this.top + \", right: \" + this.right\n + \", bottom: \" + this.bottom + \"}\";\n }\n}\n\nclass WMFPlacable {\n private boundingBox: WMFRect16;\n private unitsPerInch: number;\n\n constructor(reader: Blob) {\n reader.skip(2);\n this.boundingBox = new WMFRect16(reader);\n this.unitsPerInch = reader.readInt16();\n reader.skip(4);\n reader.skip(2); // TODO: checksum\n Helper.log(\"Got bounding box \" + this.boundingBox + \" and \" + this.unitsPerInch + \" units/inch\");\n }\n}\n\nclass WMF {\n private _version: number;\n private _hdrsize: number;\n private _placable: WMFPlacable;\n private _records: WMFRecords;\n\n constructor(reader: Blob, placable: WMFPlacable, version: number, hdrsize: number) {\n this._version = version;\n this._hdrsize = hdrsize;\n this._placable = placable;\n this._records = new WMFRecords(reader, this._hdrsize);\n }\n\n public render(gdi: GDIContext): void {\n this._records.play(gdi);\n }\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flood","filter","resultId","color","opacity","_settings","floodElement","document","createElementNS","setAttribute","toString","appendChild","composite","in1","in2","k1","k2","k3","k4","compositeElement","_path","move","x","y","path","substr","line","pts","forEach","point","curveC","x1","y1","x2","y2","close","svg","filters","SVGFilters","_defs","undefined","_svg","parent","width","height","settings","svgElement","_appendSettings","image","url","imageElement","setAttributeNS","rect","rx","ry","rectElement","Number","lineElement","polygon","points","polygonElement","map","join","polyline","polylineElement","ellipse","cx","cy","ellipseElement","builder","pathElement","text","textElement","textNode","createTextNode","id","filterElement","pattern","patternElement","defs","defsElement","clipPath","units","clipElement","createPath","SVGPathBuilder","element","keys","message","setPrototypeOf","Error","isLoggingEnabled","loggingEnabled","enabled","log","console","_makeUniqueId","prefix","_uniqueId","_writeUint32Val","uint8arr","pos","val","_blobToBinary","blob","ret","len","length","i","String","fromCharCode","GDI","METAHEADER_SIZE","BITMAPINFOHEADER_SIZE","BITMAPCOREHEADER_SIZE","MetafileType","MEMORYMETAFILE","DISKMETAFILE","MetafileVersion","METAVERSION100","METAVERSION300","RecordType","META_EOF","META_REALIZEPALETTE","META_SETPALENTRIES","META_SETBKMODE","META_SETMAPMODE","META_SETROP2","META_SETRELABS","META_SETPOLYFILLMODE","META_SETSTRETCHBLTMODE","META_SETTEXTCHAREXTRA","META_RESTOREDC","META_RESIZEPALETTE","META_DIBCREATEPATTERNBRUSH","META_SETLAYOUT","META_SETBKCOLOR","META_SETTEXTCOLOR","META_OFFSETVIEWPORTORG","META_LINETO","META_MOVETO","META_OFFSETCLIPRGN","META_FILLREGION","META_SETMAPPERFLAGS","META_SELECTPALETTE","META_POLYGON","META_POLYLINE","META_SETTEXTJUSTIFICATION","META_SETWINDOWORG","META_SETWINDOWEXT","META_SETVIEWPORTORG","META_SETVIEWPORTEXT","META_OFFSETWINDOWORG","META_SCALEWINDOWEXT","META_SCALEVIEWPORTEXT","META_EXCLUDECLIPRECT","META_INTERSECTCLIPRECT","META_ELLIPSE","META_FLOODFILL","META_FRAMEREGION","META_ANIMATEPALETTE","META_TEXTOUT","META_POLYPOLYGON","META_EXTFLOODFILL","META_RECTANGLE","META_SETPIXEL","META_ROUNDRECT","META_PATBLT","META_SAVEDC","META_PIE","META_STRETCHBLT","META_ESCAPE","META_INVERTREGION","META_PAINTREGION","META_SELECTCLIPREGION","META_SELECTOBJECT","META_SETTEXTALIGN","META_ARC","META_CHORD","META_BITBLT","META_EXTTEXTOUT","META_SETDIBTODEV","META_DIBBITBLT","META_DIBSTRETCHBLT","META_STRETCHDIB","META_DELETEOBJECT","META_CREATEPALETTE","META_CREATEPATTERNBRUSH","META_CREATEPENINDIRECT","META_CREATEFONTINDIRECT","META_CREATEBRUSHINDIRECT","META_CREATEREGION","MetafileEscapes","NEWFRAME","ABORTDOC","NEXTBAND","SETCOLORTABLE","GETCOLORTABLE","FLUSHOUT","DRAFTMODE","QUERYESCSUPPORT","SETABORTPROC","STARTDOC","ENDDOC","GETPHYSPAGESIZE","GETPRINTINGOFFSET","GETSCALINGFACTOR","META_ESCAPE_ENHANCED_METAFILE","SETPENWIDTH","SETCOPYCOUNT","SETPAPERSOURCE","PASSTHROUGH","GETTECHNOLOGY","SETLINECAP","SETLINEJOIN","SETMITERLIMIT","BANDINFO","DRAWPATTERNRECT","GETVECTORPENSIZE","GETVECTORBRUSHSIZE","ENABLEDUPLEX","GETSETPAPERBINS","GETSETPRINTORIENT","ENUMPAPERBINS","SETDIBSCALING","EPSPRINTING","ENUMPAPERMETRICS","GETSETPAPERMETRICS","POSTSCRIPT_DATA","POSTSCRIPT_IGNORE","GETDEVICEUNITS","GETEXTENDEDTEXTMETRICS","GETPAIRKERNTABLE","EXTTEXTOUT","GETFACENAME","DOWNLOADFACE","METAFILE_DRIVER","QUERYDIBSUPPORT","BEGIN_PATH","CLIP_TO_PATH","END_PATH","OPEN_CHANNEL","DOWNLOADHEADER","CLOSE_CHANNEL","POSTSCRIPT_PASSTHROUGH","ENCAPSULATED_POSTSCRIPT","POSTSCRIPT_IDENTIFY","POSTSCRIPT_INJECTION","CHECKJPEGFORMAT","CHECKPNGFORMAT","GET_PS_FEATURESETTING","MXDC_ESCAPE","SPCLPASSTHROUGH2","MapMode","MM_TEXT","MM_LOMETRIC","MM_HIMETRIC","MM_LOENGLISH","MM_HIENGLISH","MM_TWIPS","MM_ISOTROPIC","MM_ANISOTROPIC","StretchMode","BLACKONWHITE","WHITEONBLACK","COLORONCOLOR","HALFTONE","TextAlignmentMode","TA_UPDATECP","TA_RIGHT","TA_CENTER","TA_BOTTOM","TA_BASELINE","TA_RTLREADING","MixMode","TRANSPARENT","OPAQUE","VerticalTextAlignmentMode","VTA_BOTTOM","VTA_CENTER","VTA_LEFT","VTA_BASELINE","BrushStyle","BS_SOLID","BS_NULL","BS_HATCHED","BS_PATTERN","BS_INDEXED","BS_DIBPATTERN","BS_DIBPATTERNPT","BS_PATTERN8X8","BS_DIBPATTERN8X8","BS_MONOPATTERN","PenStyle","PS_SOLID","PS_DASH","PS_DOT","PS_DASHDOT","PS_DASHDOTDOT","PS_NULL","PS_INSIDEFRAME","PS_USERSTYLE","PS_ALTERNATE","PS_ENDCAP_SQUARE","PS_ENDCAP_FLAT","PS_JOIN_BEVEL","PS_JOIN_MITER","PolyFillMode","ALTERNATE","WINDING","ColorUsage","DIB_RGB_COLORS","DIB_PAL_COLORS","DIB_PAL_INDICES","PaletteEntryFlag","PC_RESERVED","PC_EXPLICIT","PC_NOCOLLAPSE","BitmapCompression","BI_RGB","BI_RLE8","BI_RLE4","BI_BITFIELDS","BI_JPEG","BI_PNG","offset","Blob","data","Uint8Array","eof","seek","newpos","WMFJSError","skip","cnt","newPos","readBinary","readInt8","readUint8","readInt32","readUint32","readUint16","readInt16","readString","readNullTermString","maxSize","byte","reader","clone","PointS","left","top","right","bottom","Rect","empty","intersect","Math","max","min","type","copy","scanCnt","bounds","scans","push","Scan","_updateComplexity","complexity","Region","scan","scanlines","scanline","subtract","Helper","si","cloned","splice","first","last","slen","offX","offY","Obj","skipsize","planes","bitcount","colors","compression","sizeimage","xpelspermeter","ypelspermeter","clrused","clrimportant","usergb","_reader","_offset","_usergb","hdrsize","_infosize","_header","BitmapCoreHeader","BitmapInfoHeader","masks","getWidth","getHeight","abs","infosize","header","size","_size","_info","BitmapInfo","base64ref","prevpos","mime","makeBitmapFileHeader","ref","btoa","buf","ArrayBuffer","view","widthBytes","bitsPixel","bitsOffset","bitsSize","Bitmap16","PatternBitmap16","r","g","b","ColorRef","toHex","slice","escapement","orientation","weight","italic","underline","strikeout","charset","outprecision","clipprecision","quality","pitchAndFamily","pitch","family","dataLength","start","facename","Font","JSON","stringify","forceDibPattern","style","colorusage","dibpatternpt","DIBitmap","hatchstyle","Brush","linecap","Pen","flag","PaletteEntry","entries","Palette","defObjects","_svggroup","_svgclipChanged","_svgtextbkfilter","mapmode","stretchmode","textalign","bkmode","textcolor","bkcolor","polyfillmode","wx","wy","ww","wh","vx","vy","vw","vh","clip","ownclip","selected","defObj","_svgdefs","_svgPatterns","_svgClipPaths","brush","pen","font","palette","region","state","GDIContextState","statestack","objects","setMapMode","mode","setWindowOrg","setWindowExt","offsetWindowOrg","setViewportOrg","setViewportExt","offsetViewportOrg","saveDC","prevstate","restoreDC","saved","pop","escape","func","count","setStretchBltMode","stretchMode","stretchDib","srcX","srcY","srcW","srcH","dstX","dstY","dstW","dstH","rasterOp","colorUsage","dib","_todevX","_todevY","_todevW","_todevH","_pushGroup","dibBits","stretchDibBits","rectangle","rw","rh","opts","_applyOpts","textOut","transform","filterId","_getSvgDef","extTextOut","fwOpts","dx","lineTo","toX","toY","fromX","fromY","moveTo","polyPolygon","polygons","fill","width2","height2","excludeClipRect","_getClipRgn","intersectClipRect","offsetClipRgn","setTextAlign","textAlignmentMode","setBkMode","bkMode","setTextColor","textColor","setBkColor","bkColor","setPolyFillMode","polyFillMode","createBrush","idx","_storeObject","createFont","createPen","createPalette","createRegion","createPatternBrush","patternBrush","selectObject","objIdx","checkType","_getObject","_selectObject","deleteObject","_deleteObject","viewBox","preserveAspectRatio","_getSvgClipPathForRegion","existingId","sclip","j","_getSvgPatternForBrush","img","spat","patternUnits","rgn","floor","_tologicalX","_tologicalY","_tologicalW","_tologicalH","usePen","useBrush","useFont","stroke","dotWidth","dashWidth","dotSpacing","_records","all","curpos","gdi","haveSrcDib","datalength","hasRect","hasDx","polygonsPtCnts","ptCnt","p","ip","patternBitmap","recordName","main_loop","play","parse","render","info","_render","SVG","mapMode","xExt","yExt","_img","placable","headerstart","WMFPlacable","version","WMF","GDIContext","boundingBox","WMFRect16","unitsPerInch","_version","_hdrsize","_placable","WMFRecords"],"sourceRoot":""}