ONLYOFFICEV7.5.1 明文核心代码 API级别调用 可进行二次开发

本次改造基于V7.5.1进行,已经更新进入docker。


小伙伴们须知:这部分内容需要付费。


欢迎大家一起交流:V:cao_rui_jian_xiong

 【编译版】可执行demo:GitHub - lz610756247/public_rep

目前两个版本:编译版本200元,明文改造版另议。

form双向表单演示:onlyoffice双向绑定form表单数据_哔哩哔哩_bilibili

项目核心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的调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值