rtf.js
Version:
Render RTF documents in HTML. This also includes rendering WMF and EMF images which are often contained in RTF documents.
1,127 lines (1,064 loc) • 150 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["WMFJS"] = factory();
else
root["WMFJS"] = factory();
})(this, function() {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/util/SVG.ts":
/*!*************************!*\
!*** ./src/util/SVG.ts ***!
\*************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SVGFilters": () => (/* binding */ SVGFilters),
/* harmony export */ "SVGPathBuilder": () => (/* binding */ SVGPathBuilder),
/* harmony export */ "SVG": () => (/* binding */ SVG)
/* harmony export */ });
/*
The MIT License (MIT)
Copyright (c) 2020 Ynse Hoornenborg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var SVGFilters = /** @class */ (function () {
function SVGFilters() {
}
SVGFilters.prototype.flood = function (filter, resultId, color, opacity, _settings) {
var floodElement = document.createElementNS("http://www.w3.org/2000/svg", "feFlood");
if (resultId) {
floodElement.setAttribute("id", resultId);
}
floodElement.setAttribute("flood-color", color);
floodElement.setAttribute("flood-opacity", opacity.toString());
filter.appendChild(floodElement);
};
SVGFilters.prototype.composite = function (filter, resultId, in1, in2, k1, k2, k3, k4, _settings) {
var compositeElement = document.createElementNS("http://www.w3.org/2000/svg", "feComposite");
if (resultId) {
compositeElement.setAttribute("id", resultId);
}
compositeElement.setAttribute("in", in1);
compositeElement.setAttribute("in2", in2);
filter.appendChild(compositeElement);
};
return SVGFilters;
}());
var SVGPathBuilder = /** @class */ (function () {
function SVGPathBuilder() {
this._path = "";
}
SVGPathBuilder.prototype.move = function (x, y) {
this._path += " M " + x + " " + y;
};
SVGPathBuilder.prototype.path = function () {
return this._path.substr(1);
};
SVGPathBuilder.prototype.line = function (pts) {
var _this = this;
pts.forEach(function (point) {
_this._path += " L " + point[0] + " " + point[1];
});
};
SVGPathBuilder.prototype.curveC = function (x1, y1, x2, y2, x, y) {
this._path += " C " + x1 + " " + y1 + ", " + x2 + " " + y2 + ", " + x + " " + y;
};
SVGPathBuilder.prototype.close = function () {
this._path += " Z";
};
return SVGPathBuilder;
}());
var SVG = /** @class */ (function () {
function SVG(svg) {
this.filters = new SVGFilters();
this._defs = undefined;
this._svg = svg;
}
SVG.prototype.svg = function (parent, x, y, width, height, settings) {
var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svgElement.setAttribute("x", x.toString());
svgElement.setAttribute("y", y.toString());
svgElement.setAttribute("width", width.toString());
svgElement.setAttribute("height", height.toString());
this._appendSettings(settings, svgElement);
if (parent != null) {
parent.appendChild(svgElement);
}
else {
this._svg.appendChild(svgElement);
}
return svgElement;
};
SVG.prototype.image = function (parent, x, y, width, height, url, settings) {
var imageElement = document.createElementNS("http://www.w3.org/2000/svg", "image");
imageElement.setAttribute("x", x.toString());
imageElement.setAttribute("y", y.toString());
imageElement.setAttribute("width", width.toString());
imageElement.setAttribute("height", height.toString());
imageElement.setAttributeNS("http://www.w3.org/1999/xlink", "href", url);
this._appendSettings(settings, imageElement);
parent.appendChild(imageElement);
return imageElement;
};
SVG.prototype.rect = function (parent, x, y, width, height, rx, ry, settings) {
var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rectElement.setAttribute("x", x.toString());
rectElement.setAttribute("y", y.toString());
rectElement.setAttribute("width", width.toString());
rectElement.setAttribute("height", height.toString());
if (rx !== undefined) {
if (rx instanceof Number) {
rectElement.setAttribute("rx", rx.toString());
}
else if (rx instanceof Object) {
this._appendSettings(rx, rectElement);
}
}
if (ry !== undefined) {
rectElement.setAttribute("ry", ry.toString());
}
this._appendSettings(settings, rectElement);
parent.appendChild(rectElement);
return rectElement;
};
SVG.prototype.line = function (parent, x1, y1, x2, y2, settings) {
var lineElement = document.createElementNS("http://www.w3.org/2000/svg", "line");
lineElement.setAttribute("x1", x1.toString());
lineElement.setAttribute("y1", y1.toString());
lineElement.setAttribute("x2", x2.toString());
lineElement.setAttribute("y2", y2.toString());
this._appendSettings(settings, lineElement);
parent.appendChild(lineElement);
return lineElement;
};
SVG.prototype.polygon = function (parent, points, settings) {
var polygonElement = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
polygonElement.setAttribute("points", points.map(function (point) { return point.join(","); }).join(" "));
this._appendSettings(settings, polygonElement);
parent.appendChild(polygonElement);
return polygonElement;
};
SVG.prototype.polyline = function (parent, points, settings) {
var polylineElement = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
polylineElement.setAttribute("points", points.map(function (point) { return point.join(","); }).join(" "));
this._appendSettings(settings, polylineElement);
parent.appendChild(polylineElement);
return polylineElement;
};
SVG.prototype.ellipse = function (parent, cx, cy, rx, ry, settings) {
var ellipseElement = document.createElementNS("http://www.w3.org/2000/svg", "ellipse");
ellipseElement.setAttribute("cx", cx.toString());
ellipseElement.setAttribute("cy", cy.toString());
ellipseElement.setAttribute("rx", rx.toString());
ellipseElement.setAttribute("ry", ry.toString());
this._appendSettings(settings, ellipseElement);
parent.appendChild(ellipseElement);
return ellipseElement;
};
SVG.prototype.path = function (parent, builder, settings) {
var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
pathElement.setAttribute("d", builder.path());
this._appendSettings(settings, pathElement);
parent.appendChild(pathElement);
return pathElement;
};
SVG.prototype.text = function (parent, x, y, value, settings) {
var textElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
textElement.setAttribute("x", x.toString());
textElement.setAttribute("y", y.toString());
this._appendSettings(settings, textElement);
var textNode = document.createTextNode(value);
textElement.appendChild(textNode);
parent.appendChild(textElement);
return textElement;
};
SVG.prototype.filter = function (parent, id, x, y, width, height, settings) {
var filterElement = document.createElementNS("http://www.w3.org/2000/svg", "filter");
filterElement.setAttribute("x", x.toString());
filterElement.setAttribute("y", y.toString());
filterElement.setAttribute("width", width.toString());
filterElement.setAttribute("height", height.toString());
this._appendSettings(settings, filterElement);
parent.appendChild(filterElement);
return filterElement;
};
SVG.prototype.pattern = function (parent, resultId, x, y, width, height, settings) {
var patternElement = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
if (resultId) {
patternElement.setAttribute("id", resultId);
}
patternElement.setAttribute("x", x.toString());
patternElement.setAttribute("y", y.toString());
patternElement.setAttribute("width", width.toString());
patternElement.setAttribute("height", height.toString());
this._appendSettings(settings, patternElement);
parent.appendChild(patternElement);
return patternElement;
};
SVG.prototype.defs = function () {
if (this._defs === undefined) {
var defsElement = document.createElementNS("http://www.w3.org/2000/svg", "defs");
this._svg.appendChild(defsElement);
this._defs = defsElement;
}
return this._defs;
};
SVG.prototype.clipPath = function (parent, resultId, units, settings) {
var clipElement = document.createElementNS("http://www.w3.org/2000/svg", "clipPath");
if (resultId) {
clipElement.setAttribute("id", resultId);
}
if (units === undefined) {
units = "userSpaceOnUse";
}
clipElement.setAttribute("clipPathUnits", units);
this._appendSettings(settings, clipElement);
parent.appendChild(clipElement);
return clipElement;
};
SVG.prototype.createPath = function () {
return new SVGPathBuilder();
};
SVG.prototype._appendSettings = function (settings, element) {
if (settings !== undefined) {
Object.keys(settings).forEach(function (key) {
element.setAttribute(key, settings[key]);
});
}
};
return SVG;
}());
/***/ }),
/***/ "./src/util/index.ts":
/*!***************************!*\
!*** ./src/util/index.ts ***!
\***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SVG": () => (/* reexport safe */ _SVG__WEBPACK_IMPORTED_MODULE_0__.SVG)
/* harmony export */ });
/* harmony import */ var _SVG__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SVG */ "./src/util/SVG.ts");
/*
The MIT License (MIT)
Copyright (c) 2020 Tom Zoehner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/***/ }),
/***/ "./src/wmfjs/Bitmap.ts":
/*!*****************************!*\
!*** ./src/wmfjs/Bitmap.ts ***!
\*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "BitmapInfo": () => (/* binding */ BitmapInfo),
/* harmony export */ "DIBitmap": () => (/* binding */ DIBitmap),
/* harmony export */ "Bitmap16": () => (/* binding */ Bitmap16),
/* harmony export */ "PatternBitmap16": () => (/* binding */ PatternBitmap16)
/* harmony export */ });
/* harmony import */ var _Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Helper */ "./src/wmfjs/Helper.ts");
/*
The MIT License (MIT)
Copyright (c) 2015 Thomas Bluemel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BitmapCoreHeader = /** @class */ (function () {
function BitmapCoreHeader(reader, skipsize) {
if (skipsize) {
reader.skip(4);
}
this.width = reader.readUint16();
this.height = reader.readUint16();
this.planes = reader.readUint16();
this.bitcount = reader.readUint16();
}
BitmapCoreHeader.prototype.colors = function () {
return this.bitcount <= 8 ? 1 << this.bitcount : 0;
};
return BitmapCoreHeader;
}());
var BitmapInfoHeader = /** @class */ (function () {
function BitmapInfoHeader(reader, skipsize) {
if (skipsize) {
reader.skip(4);
}
this.width = reader.readInt32();
this.height = reader.readInt32();
this.planes = reader.readUint16();
this.bitcount = reader.readUint16();
this.compression = reader.readUint32();
this.sizeimage = reader.readUint32();
this.xpelspermeter = reader.readInt32();
this.ypelspermeter = reader.readInt32();
this.clrused = reader.readUint32();
this.clrimportant = reader.readUint32();
}
BitmapInfoHeader.prototype.colors = function () {
if (this.clrused !== 0) {
return this.clrused < 256 ? this.clrused : 256;
}
else {
return this.bitcount > 8 ? 0 : 1 << this.bitcount;
}
};
return BitmapInfoHeader;
}());
var BitmapInfo = /** @class */ (function () {
function BitmapInfo(reader, usergb) {
this._reader = reader;
this._offset = reader.pos;
this._usergb = usergb;
var hdrsize = reader.readUint32();
this._infosize = hdrsize;
if (hdrsize === _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BITMAPCOREHEADER_SIZE) {
this._header = new BitmapCoreHeader(reader, false);
this._infosize += this._header.colors() * (usergb ? 3 : 2);
}
else {
this._header = new BitmapInfoHeader(reader, false);
var masks = this._header.compression === _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
if (hdrsize <= _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4)) {
this._infosize = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4);
}
this._infosize += this._header.colors() * (usergb ? 4 : 2);
}
}
BitmapInfo.prototype.getWidth = function () {
return this._header.width;
};
BitmapInfo.prototype.getHeight = function () {
return Math.abs(this._header.height);
};
BitmapInfo.prototype.infosize = function () {
return this._infosize;
};
BitmapInfo.prototype.header = function () {
return this._header;
};
return BitmapInfo;
}());
var DIBitmap = /** @class */ (function () {
function DIBitmap(reader, size) {
this._reader = reader;
this._offset = reader.pos;
this._size = size;
this._info = new BitmapInfo(reader, true);
}
DIBitmap.prototype.getWidth = function () {
return this._info.getWidth();
};
DIBitmap.prototype.getHeight = function () {
return this._info.getHeight();
};
DIBitmap.prototype.base64ref = function () {
var prevpos = this._reader.pos;
this._reader.seek(this._offset);
var mime = "image/bmp";
var header = this._info.header();
var data;
if (header instanceof BitmapInfoHeader && header.compression != null) {
switch (header.compression) {
case _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BitmapCompression.BI_JPEG:
mime = "data:image/jpeg";
break;
case _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.BitmapCompression.BI_PNG:
mime = "data:image/png";
break;
default:
data = this.makeBitmapFileHeader();
break;
}
}
else {
data = this.makeBitmapFileHeader();
}
if (data != null) {
data += this._reader.readBinary(this._size);
}
else {
data = this._reader.readBinary(this._size);
}
var ref = "data:" + mime + ";base64," + btoa(data);
this._reader.seek(prevpos);
return ref;
};
DIBitmap.prototype.makeBitmapFileHeader = function () {
var buf = new ArrayBuffer(14);
var view = new Uint8Array(buf);
view[0] = 0x42;
view[1] = 0x4d;
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper._writeUint32Val(view, 2, this._size + 14);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper._writeUint32Val(view, 10, this._info.infosize() + 14);
return _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper._blobToBinary(view);
};
return DIBitmap;
}());
var Bitmap16 = /** @class */ (function () {
function Bitmap16(reader, size) {
if (reader != null) {
size = size;
this._reader = reader;
this._offset = reader.pos;
this._size = size;
this.type = reader.readInt16();
this.width = reader.readInt16();
this.height = reader.readInt16();
this.widthBytes = reader.readInt16();
this.planes = reader.readUint8();
this.bitsPixel = reader.readUint8();
this.bitsOffset = reader.pos;
this.bitsSize = (((this.width * this.bitsPixel + 15) >> 4) << 1) * this.height;
if (this.bitsSize > size - 10) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Bitmap should have " + this.bitsSize + " bytes, but has " + (size - 10));
}
}
else {
var copy = size;
this._reader = copy._reader;
this._offset = copy._offset;
this._size = copy._size;
this.type = copy.type;
this.width = copy.width;
this.height = copy.height;
this.widthBytes = copy.widthBytes;
this.planes = copy.planes;
this.bitsPixel = copy.bitsPixel;
this.bitsOffset = copy.bitsOffset;
this.bitsSize = copy.bitsSize;
}
}
Bitmap16.prototype.getWidth = function () {
return this.width;
};
Bitmap16.prototype.getHeight = function () {
return this.height;
};
Bitmap16.prototype.clone = function () {
return new Bitmap16(null, this);
};
return Bitmap16;
}());
var PatternBitmap16 = /** @class */ (function (_super) {
__extends(PatternBitmap16, _super);
function PatternBitmap16(reader, size) {
var _this = _super.call(this, reader, size) || this;
if (reader != null) {
_this.bitsOffset += 22; // skip bits (4 bytes) + reserved (18 bytes)
}
return _this;
}
PatternBitmap16.prototype.clone = function () {
return new PatternBitmap16(null, this);
};
return PatternBitmap16;
}(Bitmap16));
/***/ }),
/***/ "./src/wmfjs/Blob.ts":
/*!***************************!*\
!*** ./src/wmfjs/Blob.ts ***!
\***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Blob": () => (/* binding */ Blob)
/* harmony export */ });
/* harmony import */ var _Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Helper */ "./src/wmfjs/Helper.ts");
/*
The MIT License (MIT)
Copyright (c) 2015 Thomas Bluemel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var Blob = /** @class */ (function () {
function Blob(blob, offset) {
if (blob instanceof Blob) {
this.blob = blob.blob;
this.data = blob.data;
this.pos = offset || blob.pos;
}
else {
this.blob = blob;
this.data = new Uint8Array(blob);
this.pos = offset || 0;
}
}
Blob.prototype.eof = function () {
return this.pos >= this.data.length;
};
Blob.prototype.seek = function (newpos) {
if (newpos < 0 || newpos > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Invalid seek position");
}
this.pos = newpos;
};
Blob.prototype.skip = function (cnt) {
var newPos = this.pos + cnt;
if (newPos > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
this.pos = newPos;
};
Blob.prototype.readBinary = function (cnt) {
var end = this.pos + cnt;
if (end > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
var ret = "";
while (cnt-- > 0) {
ret += String.fromCharCode(this.data[this.pos++]);
}
return ret;
};
Blob.prototype.readInt8 = function () {
if (this.pos + 1 > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
return this.data[this.pos++];
};
Blob.prototype.readUint8 = function () {
return this.readInt8() >>> 0;
};
Blob.prototype.readInt32 = function () {
if (this.pos + 4 > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
var val = this.data[this.pos++];
val |= this.data[this.pos++] << 8;
val |= this.data[this.pos++] << 16;
val |= this.data[this.pos++] << 24;
return val;
};
Blob.prototype.readUint32 = function () {
return this.readInt32() >>> 0;
};
Blob.prototype.readUint16 = function () {
if (this.pos + 2 > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
var val = this.data[this.pos++];
val |= this.data[this.pos++] << 8;
return val;
};
Blob.prototype.readInt16 = function () {
var val = this.readUint16();
if (val > 32767) {
val -= 65536;
}
return val;
};
Blob.prototype.readString = function (length) {
if (this.pos + length > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
var ret = "";
for (var i = 0; i < length; i++) {
ret += String.fromCharCode(this.data[this.pos++] >>> 0);
}
return ret;
};
Blob.prototype.readNullTermString = function (maxSize) {
var ret = "";
if (maxSize > 0) {
maxSize--;
for (var i = 0; i < maxSize; i++) {
if (this.pos + i + 1 > this.data.length) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("Unexpected end of file");
}
var byte = this.data[this.pos + i] >>> 0;
if (byte === 0) {
break;
}
ret += String.fromCharCode(byte);
}
}
return ret;
};
return Blob;
}());
/***/ }),
/***/ "./src/wmfjs/GDIContext.ts":
/*!*********************************!*\
!*** ./src/wmfjs/GDIContext.ts ***!
\*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "GDIContext": () => (/* binding */ GDIContext)
/* harmony export */ });
/* harmony import */ var _Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Helper */ "./src/wmfjs/Helper.ts");
/* harmony import */ var _Primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Primitives */ "./src/wmfjs/Primitives.ts");
/* harmony import */ var _Region__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Region */ "./src/wmfjs/Region.ts");
/* harmony import */ var _Style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Style */ "./src/wmfjs/Style.ts");
/*
The MIT License (MIT)
Copyright (c) 2015 Thomas Bluemel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var GDIContextState = /** @class */ (function () {
function GDIContextState(copy, defObjects) {
if (copy != null) {
this._svggroup = copy._svggroup;
this._svgclipChanged = copy._svgclipChanged;
this._svgtextbkfilter = copy._svgtextbkfilter;
this.mapmode = copy.mapmode;
this.stretchmode = copy.stretchmode;
this.textalign = copy.textalign;
this.bkmode = copy.bkmode;
this.textcolor = copy.textcolor.clone();
this.bkcolor = copy.bkcolor.clone();
this.polyfillmode = copy.polyfillmode;
this.wx = copy.wx;
this.wy = copy.wy;
this.ww = copy.ww;
this.wh = copy.wh;
this.vx = copy.vx;
this.vy = copy.vy;
this.vw = copy.vw;
this.vh = copy.vh;
this.x = copy.x;
this.y = copy.y;
this.clip = copy.clip;
this.ownclip = false;
this.selected = {};
for (var type in copy.selected) {
this.selected[type] = copy.selected[type];
}
}
else {
this._svggroup = null;
this._svgclipChanged = false;
this._svgtextbkfilter = null;
this.mapmode = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.MapMode.MM_ANISOTROPIC;
this.stretchmode = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.StretchMode.COLORONCOLOR;
this.textalign = 0; // TA_LEFT | TA_TOP | TA_NOUPDATECP
this.bkmode = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.MixMode.OPAQUE;
this.textcolor = new _Style__WEBPACK_IMPORTED_MODULE_3__.ColorRef(null, 0, 0, 0);
this.bkcolor = new _Style__WEBPACK_IMPORTED_MODULE_3__.ColorRef(null, 255, 255, 255);
this.polyfillmode = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.PolyFillMode.ALTERNATE;
this.wx = 0;
this.wy = 0;
this.ww = 0;
this.wh = 0;
this.vx = 0;
this.vy = 0;
this.vw = 0;
this.vh = 0;
this.x = 0;
this.y = 0;
this.clip = null;
this.ownclip = false;
this.selected = {};
for (var type in defObjects) {
var defObj = defObjects[type];
this.selected[type] = defObj != null ? defObj.clone() : null;
}
}
}
return GDIContextState;
}());
var GDIContext = /** @class */ (function () {
function GDIContext(svg) {
this._svg = svg;
this._svgdefs = null;
this._svgPatterns = {};
this._svgClipPaths = {};
this.defObjects = {
brush: new _Style__WEBPACK_IMPORTED_MODULE_3__.Brush(null, null),
pen: new _Style__WEBPACK_IMPORTED_MODULE_3__.Pen(null, _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.PenStyle.PS_SOLID, new _Primitives__WEBPACK_IMPORTED_MODULE_1__.PointS(null, 1, 1), new _Style__WEBPACK_IMPORTED_MODULE_3__.ColorRef(null, 0, 0, 0), 0, 0),
font: new _Style__WEBPACK_IMPORTED_MODULE_3__.Font(null, null),
palette: null,
region: null,
};
this.state = new GDIContextState(null, this.defObjects);
this.statestack = [this.state];
this.objects = {};
}
GDIContext.prototype.setMapMode = function (mode) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setMapMode: mode=" + mode);
this.state.mapmode = mode;
this.state._svggroup = null;
};
GDIContext.prototype.setWindowOrg = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setWindowOrg: x=" + x + " y=" + y);
this.state.wx = x;
this.state.wy = y;
this.state._svggroup = null;
};
GDIContext.prototype.setWindowExt = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setWindowExt: x=" + x + " y=" + y);
this.state.ww = x;
this.state.wh = y;
this.state._svggroup = null;
};
GDIContext.prototype.offsetWindowOrg = function (offX, offY) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] offsetWindowOrg: offX=" + offX + " offY=" + offY);
this.state.wx += offX;
this.state.wy += offY;
this.state._svggroup = null;
};
GDIContext.prototype.setViewportOrg = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setViewportOrg: x=" + x + " y=" + y);
this.state.vx = x;
this.state.vy = y;
this.state._svggroup = null;
};
GDIContext.prototype.setViewportExt = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setViewportExt: x=" + x + " y=" + y);
this.state.vw = x;
this.state.vh = y;
this.state._svggroup = null;
};
GDIContext.prototype.offsetViewportOrg = function (offX, offY) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] offsetViewportOrg: offX=" + offX + " offY=" + offY);
this.state.vx += offX;
this.state.vy += offY;
this.state._svggroup = null;
};
GDIContext.prototype.saveDC = function () {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] saveDC");
var prevstate = this.state;
this.state = new GDIContextState(this.state);
this.statestack.push(prevstate);
this.state._svggroup = null;
};
GDIContext.prototype.restoreDC = function (saved) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] restoreDC: saved=" + saved);
if (this.statestack.length > 1) {
if (saved === -1) {
this.state = this.statestack.pop();
}
else if (saved < -1) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("restoreDC: relative restore not implemented");
}
else if (saved > 1) {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("restoreDC: absolute restore not implemented");
}
}
else {
throw new _Helper__WEBPACK_IMPORTED_MODULE_0__.WMFJSError("No saved contexts");
}
this.state._svggroup = null;
};
GDIContext.prototype.escape = function (func, blob, offset, count) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] escape: func=" + func + " offset=" + offset + " count=" + count);
};
GDIContext.prototype.setStretchBltMode = function (stretchMode) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setStretchBltMode: stretchMode=" + stretchMode);
};
GDIContext.prototype.stretchDib = function (srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH, rasterOp, colorUsage, dib) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] stretchDib: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16));
srcX = this._todevX(srcX);
srcY = this._todevY(srcY);
srcW = this._todevW(srcW);
srcH = this._todevH(srcH);
dstX = this._todevX(dstX);
dstY = this._todevY(dstY);
dstW = this._todevW(dstW);
dstH = this._todevH(dstH);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] stretchDib: TRANSLATED: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16) + " colorUsage=0x" + colorUsage.toString(16));
this._pushGroup();
this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());
};
GDIContext.prototype.stretchDibBits = function (srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH, rasterOp, dib) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] stretchDibBits: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16));
srcX = this._todevX(srcX);
srcY = this._todevY(srcY);
srcW = this._todevW(srcW);
srcH = this._todevH(srcH);
dstX = this._todevX(dstX);
dstY = this._todevY(dstY);
dstW = this._todevW(dstW);
dstH = this._todevH(dstH);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] stretchDibBits: TRANSLATED:"
+ " srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16));
this._pushGroup();
this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());
};
GDIContext.prototype.rectangle = function (rect, rw, rh) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] rectangle: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
var bottom = this._todevY(rect.bottom);
var right = this._todevX(rect.right);
var top = this._todevY(rect.top);
var left = this._todevX(rect.left);
rw = this._todevH(rw);
rh = this._todevH(rh);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] rectangle: TRANSLATED: bottom=" + bottom + " right=" + right + " top=" + top
+ " left=" + left + " rh=" + rh + " rw=" + rw);
this._pushGroup();
var opts = this._applyOpts(null, true, true, false);
this._svg.rect(this.state._svggroup, left, top, right - left, bottom - top, rw / 2, rh / 2, opts);
};
GDIContext.prototype.textOut = function (x, y, text) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] textOut: x=" + x + " y=" + y + " text=" + text
+ " with font " + this.state.selected.font.toString());
x = this._todevX(x);
y = this._todevY(y);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] textOut: TRANSLATED: x=" + x + " y=" + y);
this._pushGroup();
var opts = this._applyOpts(null, false, false, true);
if (this.state.selected.font.escapement !== 0) {
opts.transform = "rotate(" + [(-this.state.selected.font.escapement / 10), x, y] + ")";
opts.style = "dominant-baseline: middle; text-anchor: start;";
}
if (this.state.bkmode === _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.MixMode.OPAQUE) {
if (this.state._svgtextbkfilter == null) {
var filterId = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper._makeUniqueId("f");
var filter = this._svg.filter(this._getSvgDef(), filterId, 0, 0, 1, 1);
this._svg.filters.flood(filter, null, "#" + this.state.bkcolor.toHex(), 1.0);
this._svg.filters.composite(filter, null, null, "SourceGraphic");
this.state._svgtextbkfilter = filter;
}
opts.filter = "url(#" + this.state._svgtextbkfilter.id + ")";
}
this._svg.text(this.state._svggroup, x, y, text, opts);
};
GDIContext.prototype.extTextOut = function (x, y, text, fwOpts, rect, dx) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] extTextOut: x=" + x + " y=" + y + " text=" + text
+ " with font " + this.state.selected.font.toString());
x = this._todevX(x);
y = this._todevY(y);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] extTextOut: TRANSLATED: x=" + x + " y=" + y);
this._pushGroup();
var opts = this._applyOpts(null, false, false, true);
if (this.state.selected.font.escapement !== 0) {
opts.transform = "rotate(" + [(-this.state.selected.font.escapement / 10), x, y] + ")";
opts.style = "dominant-baseline: middle; text-anchor: start;";
}
if (this.state.bkmode === _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.MixMode.OPAQUE) {
if (this.state._svgtextbkfilter == null) {
var filterId = _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper._makeUniqueId("f");
var filter = this._svg.filter(this._getSvgDef(), filterId, 0, 0, 1, 1);
this._svg.filters.flood(filter, null, "#" + this.state.bkcolor.toHex(), 1.0);
this._svg.filters.composite(filter, null, null, "SourceGraphic");
this.state._svgtextbkfilter = filter;
}
opts.filter = "url(#" + this.state._svgtextbkfilter.id + ")";
}
this._svg.text(this.state._svggroup, x, y, text, opts);
};
GDIContext.prototype.lineTo = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] lineTo: x=" + x + " y=" + y + " with pen " + this.state.selected.pen.toString());
var toX = this._todevX(x);
var toY = this._todevY(y);
var fromX = this._todevX(this.state.x);
var fromY = this._todevY(this.state.y);
// Update position
this.state.x = x;
this.state.y = y;
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] lineTo: TRANSLATED: toX=" + toX + " toY=" + toY + " fromX=" + fromX + " fromY=" + fromY);
this._pushGroup();
var opts = this._applyOpts(null, true, false, false);
this._svg.line(this.state._svggroup, fromX, fromY, toX, toY, opts);
};
GDIContext.prototype.moveTo = function (x, y) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] moveTo: x=" + x + " y=" + y);
this.state.x = x;
this.state.y = y;
};
GDIContext.prototype.polygon = function (points, first) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] polygon: points=" + points + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
var pts = [];
for (var i = 0; i < points.length; i++) {
var point = points[i];
pts.push([this._todevX(point.x), this._todevY(point.y)]);
}
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] polygon: TRANSLATED: pts=" + pts);
if (first) {
this._pushGroup();
}
var opts = {
"fill-rule": this.state.polyfillmode === _Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.GDI.PolyFillMode.ALTERNATE ? "evenodd" : "nonzero",
};
this._applyOpts(opts, true, true, false);
this._svg.polygon(this.state._svggroup, pts, opts);
};
GDIContext.prototype.polyPolygon = function (polygons) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] polyPolygon: polygons.length=" + polygons.length
+ " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
var cnt = polygons.length;
for (var i = 0; i < cnt; i++) {
this.polygon(polygons[i], i === 0);
}
};
GDIContext.prototype.polyline = function (points) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] polyline: points=" + points + " with pen " + this.state.selected.pen.toString());
var pts = [];
for (var i = 0; i < points.length; i++) {
var point = points[i];
pts.push([this._todevX(point.x), this._todevY(point.y)]);
}
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] polyline: TRANSLATED: pts=" + pts);
this._pushGroup();
var opts = this._applyOpts({ fill: "none" }, true, false, false);
this._svg.polyline(this.state._svggroup, pts, opts);
};
GDIContext.prototype.ellipse = function (rect) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] ellipse: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
var bottom = this._todevY(rect.bottom);
var right = this._todevX(rect.right);
var top = this._todevY(rect.top);
var left = this._todevX(rect.left);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] ellipse: TRANSLATED: bottom=" + bottom + " right=" + right + " top=" + top + " left=" + left);
this._pushGroup();
var width2 = (right - left) / 2;
var height2 = (bottom - top) / 2;
var opts = this._applyOpts(null, true, true, false);
this._svg.ellipse(this.state._svggroup, left + width2, top + height2, width2, height2, opts);
};
GDIContext.prototype.excludeClipRect = function (rect) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] excludeClipRect: rect=" + rect.toString());
this._getClipRgn().subtract(rect);
};
GDIContext.prototype.intersectClipRect = function (rect) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] intersectClipRect: rect=" + rect.toString());
this._getClipRgn().intersect(rect);
};
GDIContext.prototype.offsetClipRgn = function (offX, offY) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] offsetClipRgn: offX=" + offX + " offY=" + offY);
this._getClipRgn().offset(offX, offY);
};
GDIContext.prototype.setTextAlign = function (textAlignmentMode) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setTextAlign: textAlignmentMode=0x" + textAlignmentMode.toString(16));
this.state.textalign = textAlignmentMode;
};
GDIContext.prototype.setBkMode = function (bkMode) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setBkMode: bkMode=0x" + bkMode.toString(16));
this.state.bkmode = bkMode;
};
GDIContext.prototype.setTextColor = function (textColor) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setTextColor: textColor=" + textColor.toString());
this.state.textcolor = textColor;
};
GDIContext.prototype.setBkColor = function (bkColor) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setBkColor: bkColor=" + bkColor.toString());
this.state.bkcolor = bkColor;
this.state._svgtextbkfilter = null;
};
GDIContext.prototype.setPolyFillMode = function (polyFillMode) {
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] setPolyFillMode: polyFillMode=" + polyFillMode);
this.state.polyfillmode = polyFillMode;
};
GDIContext.prototype.createBrush = function (brush) {
var idx = this._storeObject(brush);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] createBrush: brush=" + brush.toString() + " with handle " + idx);
};
GDIContext.prototype.createFont = function (font) {
var idx = this._storeObject(font);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] createFont: font=" + font.toString() + " with handle " + idx);
};
GDIContext.prototype.createPen = function (pen) {
var idx = this._storeObject(pen);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] createPen: pen=" + pen.toString() + " width handle " + idx);
};
GDIContext.prototype.createPalette = function (palette) {
var idx = this._storeObject(palette);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] createPalette: palette=" + palette.toString() + " width handle " + idx);
};
GDIContext.prototype.createRegion = function (region) {
var idx = this._storeObject(region);
_Helper__WEBPACK_IMPORTED_MODULE_0__.Helper.log("[gdi] createRegion: region=" + region.toString() + " width handle " + idx);
};
GDIContext.prototype.createPatternBrush = function (patte