当前位置:   article > 正文

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

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等全部改造为明文,可以方便阅读和二次开发

下面是改造后的代码截取。
  1. (function (window, undefined) {
  2. (function (window) {
  3. var MAX_ACTION_TIME = 20;
  4. var TIMEOUT_TIME = 20;
  5. function CActionOnTimerBase() {
  6. this.TimerId = null;
  7. this.Start = false;
  8. this.FirstActionOnTimer = false;
  9. }
  10. CActionOnTimerBase.prototype.Begin = function () {
  11. if (this.Start) this.End();
  12. this.Start = true;
  13. this.OnBegin.apply(this, arguments);
  14. var oThis = this;
  15. if (this.FirstActionOnTimer)
  16. this.TimerId = setTimeout(function () {
  17. oThis.Continue();
  18. }, TIMEOUT_TIME);
  19. else this.Continue();
  20. };
  21. CActionOnTimerBase.prototype.Continue = function () {
  22. if (this.IsContinue()) {
  23. var nTime = performance.now();
  24. this.OnStartTimer();
  25. while (this.IsContinue()) {
  26. if (performance.now() - nTime > MAX_ACTION_TIME) break;
  27. this.DoAction();
  28. }
  29. this.OnEndTimer();
  30. }
  31. var oThis = this;
  32. if (this.IsContinue())
  33. this.TimerId = setTimeout(function () {
  34. oThis.Continue();
  35. }, TIMEOUT_TIME);
  36. else this.End();
  37. };
  38. CActionOnTimerBase.prototype.End = function () {
  39. this.Reset();
  40. if (this.Start) {
  41. this.Start = false;
  42. this.OnEnd();
  43. }
  44. };
  45. CActionOnTimerBase.prototype.Reset = function () {
  46. if (this.TimerId) clearTimeout(this.TimerId);
  47. this.TimerId = null;
  48. this.Index = -1;
  49. };
  50. CActionOnTimerBase.prototype.SetDoFirstActionOnTimer = function (
  51. isOnTimer
  52. ) {
  53. this.FirstActionOnTimer = isOnTimer;
  54. };
  55. CActionOnTimerBase.prototype.OnBegin = function () {};
  56. CActionOnTimerBase.prototype.OnEnd = function () {};
  57. CActionOnTimerBase.prototype.IsContinue = function () {
  58. return false;
  59. };
  60. CActionOnTimerBase.prototype.OnStartTimer = function () {};
  61. CActionOnTimerBase.prototype.DoAction = function () {};
  62. CActionOnTimerBase.prototype.OnEndTimer = function () {};
  63. window["AscCommon"] = window["AscCommon"] || {};
  64. window["AscCommon"].CActionOnTimerBase = CActionOnTimerBase;
  65. })(window);
  66. ("use strict");
  67. (function (window) {
  68. var g_oCanvas = null;
  69. var g_oTable = null;
  70. function GetCanvas() {
  71. if (g_oCanvas == null) {
  72. g_oCanvas = document.createElement("canvas");
  73. g_oCanvas.width =
  74. (TABLE_STYLE_WIDTH_PIX * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
  75. g_oCanvas.height =
  76. (TABLE_STYLE_HEIGHT_PIX * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
  77. }
  78. return g_oCanvas;
  79. }
  80. function GetTable(oLogicDocument) {
  81. if (g_oTable == null) g_oTable = oLogicDocument.GetTableForPreview();
  82. oLogicDocument.CheckTableForPreview(g_oTable);
  83. return g_oTable;
  84. }
  85. function CTableStylesPreviewGenerator(oLogicDocument) {
  86. AscCommon.CActionOnTimerBase.call(this);
  87. this.FirstActionOnTimer = true;
  88. this.Api = oLogicDocument.GetApi();
  89. this.LogicDocument = oLogicDocument;
  90. this.DrawingDocument = oLogicDocument.GetDrawingDocument();
  91. this.TableStyles = [];
  92. this.TableLook = null;
  93. this.Index = -1;
  94. this.Buffer = [];
  95. }
  96. CTableStylesPreviewGenerator.prototype = Object.create(
  97. AscCommon.CActionOnTimerBase.prototype
  98. );
  99. CTableStylesPreviewGenerator.prototype.constructor =
  100. CTableStylesPreviewGenerator;
  101. CTableStylesPreviewGenerator.prototype.OnBegin = function (
  102. isDefaultTableLook
  103. ) {
  104. this.TableStyles = this.LogicDocument.GetAllTableStyles();
  105. this.Index = -1;
  106. this.TableLook = this.DrawingDocument.GetTableLook(isDefaultTableLook);
  107. this.Api.sendEvent(
  108. "asc_onBeginTableStylesPreview",
  109. this.TableStyles.length
  110. );
  111. };
  112. CTableStylesPreviewGenerator.prototype.OnEnd = function () {
  113. this.Api.sendEvent("asc_onEndTableStylesPreview");
  114. };
  115. CTableStylesPreviewGenerator.prototype.IsContinue = function () {
  116. return this.Index < this.TableStyles.length;
  117. };
  118. CTableStylesPreviewGenerator.prototype.DoAction = function () {
  119. var oPreview = this.GetPreview(this.TableStyles[this.Index]);
  120. if (oPreview) this.Buffer.push(oPreview);
  121. this.Index++;
  122. };
  123. CTableStylesPreviewGenerator.prototype.OnEndTimer = function () {
  124. this.Api.sendEvent("asc_onAddTableStylesPreview", this.Buffer);
  125. this.Buffer = [];
  126. };
  127. CTableStylesPreviewGenerator.prototype.GetAllPreviews = function (
  128. isDefaultTableLook
  129. ) {
  130. var oTableLookOld = this.TableLook;
  131. this.TableLook = this.DrawingDocument.GetTableLook(isDefaultTableLook);
  132. var arrStyles = this.LogicDocument.GetAllTableStyles();
  133. var arrPreviews = [];
  134. for (
  135. var nIndex = 0, nCount = arrStyles.length;
  136. nIndex < nCount;
  137. ++nIndex
  138. ) {
  139. var oPreview = this.GetPreview(arrStyles[nIndex]);
  140. if (oPreview) arrPreviews.push(oPreview);
  141. }
  142. this.TableLook = oTableLookOld;
  143. return arrPreviews;
  144. };
  145. CTableStylesPreviewGenerator.prototype.GetAllPreviewsNative = function (
  146. isDefaultTableLook,
  147. oGraphics,
  148. oStream,
  149. oNative,
  150. dW,
  151. dH,
  152. nW,
  153. nH
  154. ) {

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/476211
推荐阅读
相关标签
  

闽ICP备14008679号