本次改造基于V7.1.1进行,已经更新进入docker。
这部分东西需要付费购买,请加我的wei:cao_rui_jian_xiong
项目核心sdk_all.js等全部改造为明文,可以方便阅读和二次开发
下面是改造后的代码截取。
(function (window, undefined) {
(function (window) {
var MAX_ACTION_TIME = 20;
var TIMEOUT_TIME = 20;
function CActionOnTimerBase() {
this.TimerId = null;
this.Start = false;
this.FirstActionOnTimer = false;
}
CActionOnTimerBase.prototype.Begin = function () {
if (this.Start) this.End();
this.Start = true;
this.OnBegin.apply(this, arguments);
var oThis = this;
if (this.FirstActionOnTimer)
this.TimerId = setTimeout(function () {
oThis.Continue();
}, TIMEOUT_TIME);
else this.Continue();
};
CActionOnTimerBase.prototype.Continue = function () {
if (this.IsContinue()) {
var nTime = performance.now();
this.OnStartTimer();
while (this.IsContinue()) {
if (performance.now() - nTime > MAX_ACTION_TIME) break;
this.DoAction();
}
this.OnEndTimer();
}
var oThis = this;
if (this.IsContinue())
this.TimerId = setTimeout(function () {
oThis.Continue();
}, TIMEOUT_TIME);
else this.End();
};
CActionOnTimerBase.prototype.End = function () {
this.Reset();
if (this.Start) {
this.Start = false;
this.OnEnd();
}
};
CActionOnTimerBase.prototype.Reset = function () {
if (this.TimerId) clearTimeout(this.TimerId);
this.TimerId = null;
this.Index = -1;
};
CActionOnTimerBase.prototype.SetDoFirstActionOnTimer = function (
isOnTimer
) {
this.FirstActionOnTimer = isOnTimer;
};
CActionOnTimerBase.prototype.OnBegin = function () {};
CActionOnTimerBase.prototype.OnEnd = function () {};
CActionOnTimerBase.prototype.IsContinue = function () {
return false;
};
CActionOnTimerBase.prototype.OnStartTimer = function () {};
CActionOnTimerBase.prototype.DoAction = function () {};
CActionOnTimerBase.prototype.OnEndTimer = function () {};
window["AscCommon"] = window["AscCommon"] || {};
window["AscCommon"].CActionOnTimerBase = CActionOnTimerBase;
})(window);
("use strict");
(function (window) {
var g_oCanvas = null;
var g_oTable = null;
function GetCanvas() {
if (g_oCanvas == null) {
g_oCanvas = document.createElement("canvas");
g_oCanvas.width =
(TABLE_STYLE_WIDTH_PIX * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
g_oCanvas.height =
(TABLE_STYLE_HEIGHT_PIX * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
}
return g_oCanvas;
}
function GetTable(oLogicDocument) {
if (g_oTable == null) g_oTable = oLogicDocument.GetTableForPreview();
oLogicDocument.CheckTableForPreview(g_oTable);
return g_oTable;
}
function CTableStylesPreviewGenerator(oLogicDocument) {
AscCommon.CActionOnTimerBase.call(this);
this.FirstActionOnTimer = true;
this.Api = oLogicDocument.GetApi();
this.LogicDocument = oLogicDocument;
this.DrawingDocument = oLogicDocument.GetDrawingDocument();
this.TableStyles = [];
this.TableLook = null;
this.Index = -1;
this.Buffer = [];
}
CTableStylesPreviewGenerator.prototype = Object.create(
AscCommon.CActionOnTimerBase.prototype
);
CTableStylesPreviewGenerator.prototype.constructor =
CTableStylesPreviewGenerator;
CTableStylesPreviewGenerator.prototype.OnBegin = function (
isDefaultTableLook
) {
this.TableStyles = this.LogicDocument.GetAllTableStyles();
this.Index = -1;
this.TableLook = this.DrawingDocument.GetTableLook(isDefaultTableLook);
this.Api.sendEvent(
"asc_onBeginTableStylesPreview",
this.TableStyles.length
);
};
CTableStylesPreviewGenerator.prototype.OnEnd = function () {
this.Api.sendEvent("asc_onEndTableStylesPreview");
};
CTableStylesPreviewGenerator.prototype.IsContinue = function () {
return this.Index < this.TableStyles.length;
};
CTableStylesPreviewGenerator.prototype.DoAction = function () {
var oPreview = this.GetPreview(this.TableStyles[this.Index]);
if (oPreview) this.Buffer.push(oPreview);
this.Index++;
};
CTableStylesPreviewGenerator.prototype.OnEndTimer = function () {
this.Api.sendEvent("asc_onAddTableStylesPreview", this.Buffer);
this.Buffer = [];
};
CTableStylesPreviewGenerator.prototype.GetAllPreviews = function (
isDefaultTableLook
) {
var oTableLookOld = this.TableLook;
this.TableLook = this.DrawingDocument.GetTableLook(isDefaultTableLook);
var arrStyles = this.LogicDocument.GetAllTableStyles();
var arrPreviews = [];
for (
var nIndex = 0, nCount = arrStyles.length;
nIndex < nCount;
++nIndex
) {
var oPreview = this.GetPreview(arrStyles[nIndex]);
if (oPreview) arrPreviews.push(oPreview);
}
this.TableLook = oTableLookOld;
return arrPreviews;
};
CTableStylesPreviewGenerator.prototype.GetAllPreviewsNative = function (
isDefaultTableLook,
oGraphics,
oStream,
oNative,
dW,
dH,
nW,
nH
) {
解析前的代码还是很难读懂的。
明文解析后,增加了原生API的调用
标签:function,ONLYOFFICE,CTableStylesPreviewGenerator,var,window,API,二次开发,prototype,C From: https://blog.51cto.com/u_15595167/7402674