From 19d366bc32749e4af09e6ce01557318411ccd060 Mon Sep 17 00:00:00 2001 From: "Alexey.Musinov" Date: Tue, 26 Apr 2016 18:09:50 +0300 Subject: [PATCH] =?UTF-8?q?[mobile]=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=BE=D0=B2=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/configs/webexcel.json | 22 +- cell/native/common.js | 473 +++++++++++++++++++++++++ cell/native/native.js | 664 +----------------------------------- 3 files changed, 488 insertions(+), 671 deletions(-) create mode 100644 cell/native/common.js diff --git a/build/configs/webexcel.json b/build/configs/webexcel.json index 03d308faa4..d01c3e5561 100644 --- a/build/configs/webexcel.json +++ b/build/configs/webexcel.json @@ -175,21 +175,22 @@ "../common/Local/common.js", "../cell/Local/api.js" ], - "mobile": [ + "mobile_banners": [ "../../web-apps/vendor/xregexp/xregexp-all-min.js", "../../web-apps/vendor/underscore/underscore-min.js", + "../cell/native/common.js", + "../common/Native/Wrappers/memory.js", "../common/Native/jquery_native.js", - "../common/Native/Wrappers/memory.js", + "../cell/native/DrawingContext.js" + ], + "mobile": [ "../common/Native/Wrappers/TextMeasurerWrapper.js", "../common/Native/Wrappers/DrawingStream.js", - "../cell/native/DrawingContext.js", - "../cell/native/Graphics.js", - "../cell/native/Overlay.js", "../common/Native/Wrappers/ShapeDrawer.js", - "../cell/native/DrawingDocument.js" - ], - "mobile_banners": [ - "../cell/native/native.js" + "../cell/native/Overlay.js", + "../cell/native/Graphics.js", + "../cell/native/DrawingDocument.js", + "../cell/native/native.js" ], "exclude_mobile": [ "../common/Overlay.js", @@ -201,7 +202,8 @@ "../common/FontsFreeType/FontFile.js", "../common/FontsFreeType/FontManager.js", "../common/FontsFreeType/TextMeasurer.js", - "../cell/model/DrawingObjects/Graphics.js" + "../cell/model/DrawingObjects/Graphics.js", + "../cell/view/iscroll.js" ], "dst": "../cell/sdk-all.js", "externs": [ diff --git a/cell/native/common.js b/cell/native/common.js new file mode 100644 index 0000000000..dcdafe62d6 --- /dev/null +++ b/cell/native/common.js @@ -0,0 +1,473 @@ +var editor = undefined; +var window = {}; +var navigator = {}; +navigator.userAgent = "chrome"; +window.navigator = navigator; +window.location = {}; + +window.location.protocol = ""; +window.location.host = ""; +window.location.href = ""; +window.location.pathname = ""; + +window.NATIVE_EDITOR_ENJINE = true; +window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true; +window.IS_NATIVE_EDITOR = true; + +var document = {}; +window.document = document; + +var History = {}; + +window["Asc"] = {}; +var Asc = window["Asc"]; + +window["AscFonts"] = {}; +var AscFonts = window["AscFonts"]; + +window["AscCommon"] = {}; +var AscCommon = window["AscCommon"]; + +window["AscFormat"] = {}; +var AscFormat = window["AscFormat"]; + +window["AscDFH"] = {}; +var AscDFH = window["AscDFH"]; + +window["AscCH"] = {}; +var AscCH = window["AscCH"]; + +window["AscCommonExcel"] = {}; +var AscCommonExcel = window["AscCommonExcel"]; + +//------------------------------------------------------------------------------------------------- +aStandartNumFormats = []; +aStandartNumFormats[0] = "General"; +aStandartNumFormats[1] = "0"; +aStandartNumFormats[2] = "0.00"; +aStandartNumFormats[3] = "#,##0"; +aStandartNumFormats[4] = "#,##0.00"; +aStandartNumFormats[9] = "0%"; +aStandartNumFormats[10] = "0.00%"; +aStandartNumFormats[11] = "0.00E+00"; +aStandartNumFormats[12] = "# ?/?"; +aStandartNumFormats[13] = "# ??/??"; +aStandartNumFormats[14] = "m/d/yyyy"; +aStandartNumFormats[15] = "d-mmm-yy"; +aStandartNumFormats[16] = "d-mmm"; +aStandartNumFormats[17] = "mmm-yy"; +aStandartNumFormats[18] = "h:mm AM/PM"; +aStandartNumFormats[19] = "h:mm:ss AM/PM"; +aStandartNumFormats[20] = "h:mm"; +aStandartNumFormats[21] = "h:mm:ss"; +aStandartNumFormats[22] = "m/d/yyyy h:mm"; +aStandartNumFormats[37] = "#,##0_);(#,##0)"; +aStandartNumFormats[38] = "#,##0_);[Red](#,##0)"; +aStandartNumFormats[39] = "#,##0.00_);(#,##0.00)"; +aStandartNumFormats[40] = "#,##0.00_);[Red](#,##0.00)"; +aStandartNumFormats[45] = "mm:ss"; +aStandartNumFormats[46] = "[h]:mm:ss"; +aStandartNumFormats[47] = "mm:ss.0"; +aStandartNumFormats[48] = "##0.0E+0"; +aStandartNumFormats[49] = "@"; +aStandartNumFormatsId = {}; + +for(var i in aStandartNumFormats) { + aStandartNumFormatsId[aStandartNumFormats[i]] = i - 0; +} + +//------------------------------------------------------------------------------------------------- + +function Image() { + this.src = ""; + this.onload = function() + { + } + this.onerror = function() + { + } +} +function _image_data() { + this.data = null; + this.length = 0; +} + +function native_pattern_fill() { +} +native_pattern_fill.prototype = { + setTransform : function(transform) {} +}; + +function native_gradient_fill() { +} +native_gradient_fill.prototype = { + addColorStop : function(offset,color) {} +}; + +function native_context2d(parent) { + this.canvas = parent; + + this.globalAlpha = 0; + this.globalCompositeOperation = ""; + this.fillStyle = ""; + this.strokeStyle = ""; + + this.lineWidth = 0; + this.lineCap = 0; + this.lineJoin = 0; + this.miterLimit = 0; + this.shadowOffsetX = 0; + this.shadowOffsetY = 0; + this.shadowBlur = 0; + this.shadowColor = 0; + this.font = ""; + this.textAlign = 0; + this.textBaseline = 0; +} +native_context2d.prototype = { + save : function() {}, + restore : function() {}, + + scale : function(x,y) {}, + rotate : function(angle) {}, + translate : function(x,y) {}, + transform : function(m11,m12,m21,m22,dx,dy) {}, + setTransform : function(m11,m12,m21,m22,dx,dy) {}, + + createLinearGradient : function(x0,y0,x1,y1) { return new native_gradient_fill(); }, + createRadialGradient : function(x0,y0,r0,x1,y1,r1) { return null; }, + createPattern : function(image,repetition) { return new native_pattern_fill(); }, + + clearRect : function(x,y,w,h) {}, + fillRect : function(x,y,w,h) {}, + strokeRect : function(x,y,w,h) {}, + + beginPath : function() {}, + closePath : function() {}, + moveTo : function(x,y) {}, + lineTo : function(x,y) {}, + quadraticCurveTo : function(cpx,cpy,x,y) {}, + bezierCurveTo : function(cp1x,cp1y,cp2x,cp2y,x,y) {}, + arcTo : function(x1,y1,x2,y2,radius) {}, + rect : function(x,y,w,h) {}, + arc : function(x,y,radius,startAngle,endAngle,anticlockwise) {}, + + fill : function() {}, + stroke : function() {}, + clip : function() {}, + isPointInPath : function(x,y) {}, + drawFocusRing : function(element,xCaret,yCaret,canDrawCustom) {}, + + fillText : function(text,x,y,maxWidth) {}, + strokeText : function(text,x,y,maxWidth) {}, + measureText : function(text) {}, + + drawImage : function(img_elem,dx_or_sx,dy_or_sy,dw_or_sw,dh_or_sh,dx,dy,dw,dh) {}, + + createImageData : function(imagedata_or_sw,sh) + { + var _data = new _image_data(); + _data.length = imagedata_or_sw * sh * 4; + _data.data = (typeof(Uint8Array) != 'undefined') ? new Uint8Array(_data.length) : new Array(_data.length); + return _data; + }, + getImageData : function(sx,sy,sw,sh) {}, + putImageData : function(image_data,dx,dy,dirtyX,dirtyY,dirtyWidth,dirtyHeight) {} +}; + +function native_canvas() +{ + this.id = ""; + this.width = 300; + this.height = 150; + + this.nodeType = 1; +} +native_canvas.prototype = +{ + getContext : function(type) + { + if (type == "2d") + return new native_context2d(this); + return null; + }, + + toDataUrl : function(type) + { + return ""; + }, + + addEventListener : function() + { + }, + + attr : function() + { + } +}; + +var _null_object = {}; +_null_object.length = 0; +_null_object.nodeType = 1; +_null_object.offsetWidth = 1; +_null_object.offsetHeight = 1; +_null_object.clientWidth = 1; +_null_object.clientHeight = 1; +_null_object.scrollWidth = 1; +_null_object.scrollHeight = 1; +_null_object.style = {}; +_null_object.documentElement = _null_object; +_null_object.body = _null_object; +_null_object.ownerDocument = _null_object; +_null_object.defaultView = _null_object; + +_null_object.addEventListener = function(){}; +_null_object.setAttribute = function(){}; +_null_object.getElementsByTagName = function() { return []; }; +_null_object.appendChild = function() {}; +_null_object.removeChild = function() {}; +_null_object.insertBefore = function() {}; +_null_object.childNodes = []; +_null_object.parent = _null_object; +_null_object.parentNode = _null_object; +_null_object.find = function() { return this; }; +_null_object.appendTo = function() { return this; }; +_null_object.css = function() { return this; }; +_null_object.width = function() { return 1; }; +_null_object.height = function() { return 1; }; +_null_object.attr = function() { return this; }; +_null_object.prop = function() { return this; }; +_null_object.val = function() { return this; }; +_null_object.remove = function() {}; +_null_object.getComputedStyle = function() { return null; }; +_null_object.getContext = function(type) { + if (type == "2d") + return new native_context2d(this); + return null; +}; + +window._null_object = _null_object; + +document.createElement = function(type) { + if (type && type.toLowerCase) + { + if (type.toLowerCase() == "canvas") + return new native_canvas(); + } + + return _null_object; +}; + +function _return_empty_html_element() { return _null_object; } + +document.createDocumentFragment = _return_empty_html_element; +document.getElementsByTagName = function(tag) { + var ret = []; + if ("head" == tag) + ret.push(_null_object); + return ret; +}; +document.insertBefore = function() {}; +document.appendChild = function() {}; +document.removeChild = function() {}; +document.getElementById = function() { return _null_object; }; +document.createComment = function() { return undefined; }; + +document.documentElement = _null_object; +document.body = _null_object; + +var native = CreateNativeEngine(); +window.native = native; +window["native"] = native; + +var _api = null; + +window.NativeSupportTimeouts = false; +window.NativeTimeoutObject = {}; + +function clearTimeout(_id) { + if (!window.NativeSupportTimeouts) + return; + + window.NativeTimeoutObject["" + _id] = undefined; + window.native["ClearTimeout"](_id); +} +function setTimeout(func, interval) { + if (!window.NativeSupportTimeouts) + return; + + var _id = window.native["GenerateTimeoutId"](interval); + window.NativeTimeoutObject["" + _id] = func; + return _id; +} +function offline_timeoutFire(_id) { + if (!window.NativeSupportTimeouts) + return; + + var _prop = "" + _id; + var _func = window.NativeTimeoutObject[_prop]; + window.NativeTimeoutObject[_prop] = undefined; + + if (!_func) + return; + + _func.call(null); + _func = null; +} +function clearInterval(_id) { + if (!window.NativeSupportTimeouts) + return; + + window.NativeTimeoutObject["" + _id] = undefined; + window.native["ClearTimeout"](_id); +} +function setInterval(func, interval) { + if (!window.NativeSupportTimeouts) + return; + + var _intervalFunc = function() + { + func.call(null); + setTimeout(func, interval); + }; + + var _id = window.native["GenerateTimeoutId"](interval); + window.NativeTimeoutObject["" + _id] = _intervalFunc; + return _id; +} + +window.clearTimeout = clearTimeout; +window.setTimeout = setTimeout; +window.clearInterval = clearInterval; +window.setInterval = setInterval; + +var console = { + log : function(param) { window.native.consoleLog(param); }, + time : function (param) {}, + timeEnd : function (param) {} +}; + +window["NativeCorrectImageUrlOnPaste"] = function(url) { + return window["native"]["CorrectImageUrlOnPaste"](url); +}; +window["NativeCorrectImageUrlOnCopy"] = function(url) { + return window["native"]["CorrectImageUrlOnCopy"](url); +}; + +window['AscFonts'].CFontManager = function CFontManager() { + this.m_oLibrary = {}; + this.Initialize = function(){}; + this.ClearFontsRasterCache = function(){}; +}; +window["use_native_fonts_only"] = true; + +// FT_Common +function _FT_Common() { + this.UintToInt = function(v) + { + return (v>2147483647)?v-4294967296:v; + }; + this.UShort_To_Short = function(v) + { + return (v>32767)?v-65536:v; + }; + this.IntToUInt = function(v) + { + return (v<0)?v+4294967296:v; + }; + this.Short_To_UShort = function(v) + { + return (v<0)?v+65536:v; + }; + this.memset = function(d,v,s) + { + for (var i=0;i2147483647)?v-4294967296:v; - }; - this.UShort_To_Short = function(v) - { - return (v>32767)?v-65536:v; - }; - this.IntToUInt = function(v) - { - return (v<0)?v+4294967296:v; - }; - this.Short_To_UShort = function(v) - { - return (v<0)?v+65536:v; - }; - this.memset = function(d,v,s) - { - for (var i=0;i