首页 > 其他分享 >ONLYOFFICE 明文核心代码 API级别调用 可进行二次开发

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

时间:2023-09-07 23:00:29浏览次数:28  
标签:function ONLYOFFICE CTableStylesPreviewGenerator var window API 二次开发 prototype C

本次改造基于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
    ) {

解析前的代码还是很难读懂的。

ONLYOFFICE 明文核心代码 API级别调用 可进行二次开发_onlyoffice

明文解析后,增加了原生API的调用

ONLYOFFICE 明文核心代码 API级别调用 可进行二次开发_onlyoffice_02

标签:function,ONLYOFFICE,CTableStylesPreviewGenerator,var,window,API,二次开发,prototype,C
From: https://blog.51cto.com/u_15595167/7402674

相关文章

  • 【API Management】使用 APIM Inbound Policy 来修改Content-Type Header的值
    问题描述在使用APIM提供API服务管理的场景中,遇见了客户端请求时候发送的请求Header中的Content-Type不满足后台服务器的要求,但是在客户端要求客户修改代码难度较高。所以面对这样的情况,是否在APIM端修改为对请求的Content-Type进行覆写呢?问题解答可以的。APIM支持通过设置策略(Poli......
  • Apipost压测参数化如何使用
    Apipost7.2.1版本一键压测新增参数化功能如何使用?这里我们用一个多用户登录情况来演示,需要准备包含用户名密码的CSV文件创建CSV文件:新建一个excel表格,在表格中新建usernamepassword,在下方输入每个账号和密码保存文件时将文件类型修改为CSV保存后导入到Apipost中配置接口在接口中配......
  • 十大功能特性,助力开发者玩转API Explorer
    伴随着我国API生态逐渐成熟、市场发展不断完善,API已广泛应用在以网页、移动应用、后端系统集成为主的众多开发场景中。同时,开发者对API的主要诉求已由获取数据能力转变为获取技术能力、甚至业务能力,开发者渴望更加高效便捷的调用方式,除关注API产品本身性能外,也愈发关注优质的服务和......
  • Vue3实战06-CompositionAPI+<script setup>好在哪?
    Vue3的CompositionAPI+<scriptsetup>这种最新的代码组织方式。<scriptsetup>是啥?为啥尤大在微博强推?本文就使用CompositionAPI和<scriptsetup>重构第2讲的清单应用。重构过程将明白,CompositionAPI让我们更好组织代码结构,<scriptsetup>本质是更精简方式写Compositi......
  • Vue3实战06-CompositionAPI+<script setup>好在哪?
    Vue3的CompositionAPI+<scriptsetup>标签内定义的变量和函数,都可以在模板中直接使用。###1.2显示清单应用实现累加器后,回到src/pages/Home.vue组件,使用如下代码显示清单应用。直接importTodoList.vue组件,然后<scriptsetup>会自动把组件注册到当前组件,这样......
  • 如何防止僵尸 API...
    人们越来越依赖WebAPI。2023年PostmanAPI状况报告发现,整整92%的组织计划在明年增加对API的投资。API正在为从内部微服务策略到合作伙伴策略和成熟产品的一切提供动力。然而,这种新发现的API蔓延带来了后果;迫在眉睫的威胁可能会从坟墓中升起来困扰你……当然,我说的是僵尸......
  • 阿里巴巴API接口解析,实现获得商品详情
    要解析阿里巴巴API接口并实现获取商品详情,你需要按照以下步骤进行操作:了解阿里巴巴开放平台:访问阿里巴巴开放平台,并了解相关的API文档、开发者指南和规定。注册开发者账号:在阿里巴巴开放平台上注册一个开发者账号,并创建一个应用,获取到API权限。获取API密钥:为了使用阿里巴巴API接口,......
  • 【ROS2机器人入门到实战】使用Nav2导航API进行导航
    4.使用Nav2导航API进行导航写在前面当前平台文章汇总地址:ROS2机器人从入门到实战获取完整教程及配套资料代码,请关注公众号<鱼香ROS>获取教程配套机器人开发平台:两驱版|四驱版为方便交流,搭建了机器人技术问答社区:地址fishros.org.cnNav2的API其实是Nav2提供的一个Python库,通过该库......
  • ffmpeg中的采集麦克风的 API
    在FFmpeg中,可以使用libavdevice库来采集麦克风的音频。下面是一个简单示例:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<stdint.h> #include<libavformat/avformat.h>#include<libavdevice/avdevice.h> intmain(){av_r......
  • 2023年值得推荐的 API 开发工具
    数字化时代,应用程序编程接口(API)的重要性愈发凸显。API充当着应用程序之间的桥梁,促进数据交换和功能集成。随着API的不断增加和复杂化,开发对API开发工具的要求也越来越高。我们一起来盘点下2023年上半年比较热门的API开发工具。API开发工具的主要作用API开发工具是一......