Commit 259905ff authored by Alexey.Golubev's avatar Alexey.Golubev Committed by Alexander.Trofimov

Рефакторинг для включения кода в sdk-all.js

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47899 954022d7-b5bf-4e40-9824-e11837661b57
parent 45381015
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
"sdk": { "sdk": {
"src": [ "src": [
"../Common/Build/License.js", "../Common/Build/License.js",
"../Word/merge/utils.js", "../Common/Merge/NodejsEnv.js",
"../Common/docscoapisettings.js",
"../Common/docscoapicommon.js", "../Common/docscoapicommon.js",
"../Common/docscoapi.js", "../Common/docscoapi.js",
"../Common/spellcheckapisettings.js",
"../Common/spellcheckapi.js", "../Common/spellcheckapi.js",
"../Common/wordcopypaste.js", "../Common/wordcopypaste.js",
"../Common/spellCheckLanguage.js", "../Common/spellCheckLanguage.js",
......
var editor = undefined; (function () {
function asc_docs_api() var prot;
{ function asc_docs_merge_api()
if (editor == undefined)
{ {
editor = this; if (typeof editor == 'undefined')
{
window['editor'] = window.editor = editor = this;
} }
if (editor)
window.editor = editor;
this.WordControl = new CEditorPage(this); this.WordControl = new CEditorPage(this);
this.WordControl.m_oLogicDocument = new CDocument(this.WordControl.m_oDrawingDocument); this.WordControl.m_oLogicDocument = new CDocument(this.WordControl.m_oDrawingDocument);
...@@ -14,25 +13,17 @@ function asc_docs_api() ...@@ -14,25 +13,17 @@ function asc_docs_api()
this.chartStyleManager = new ChartStyleManager(); this.chartStyleManager = new ChartStyleManager();
this.chartPreviewManager = new ChartPreviewManager(); this.chartPreviewManager = new ChartPreviewManager();
} }
asc_docs_api.prototype.LoadDocument = function( doc ) asc_docs_merge_api.prototype = {
{ LoadDocument: function( doc )
{
this.LoadedObjectDS = Common_CopyObj(this.WordControl.m_oLogicDocument.Get_Styles().Style); this.LoadedObjectDS = Common_CopyObj(this.WordControl.m_oLogicDocument.Get_Styles().Style);
var oBinaryFileReader = new BinaryFileReader(this.WordControl.m_oLogicDocument); var oBinaryFileReader = new BinaryFileReader(this.WordControl.m_oLogicDocument);
oBinaryFileReader.Read( doc ); oBinaryFileReader.Read( doc );
} },
ApplyChanges: function(e)
asc_docs_api.prototype.CreateFontsCharMap = function() {
{
var _info = new CFontsCharMap();
_info.StartWork();
this.WordControl.m_oLogicDocument.Document_CreateFontCharMap(_info);
return _info.EndWork();
}
asc_docs_api.prototype.ApplyChanges = function(e)
{
var Count = e.length; var Count = e.length;
for (var i = 0; i < Count; i++) for (var i = 0; i < Count; i++)
{ {
...@@ -43,19 +34,18 @@ asc_docs_api.prototype.ApplyChanges = function(e) ...@@ -43,19 +34,18 @@ asc_docs_api.prototype.ApplyChanges = function(e)
} }
if(Count > 0) if(Count > 0)
CollaborativeEditing.Apply_OtherChanges(); CollaborativeEditing.Apply_OtherChanges();
} },
asc_docs_api.prototype.Save = function() Save: function()
{ {
var oBinaryFileWriter = new BinaryFileWriter(this.WordControl.m_oLogicDocument); var oBinaryFileWriter = new BinaryFileWriter(this.WordControl.m_oLogicDocument);
return oBinaryFileWriter.Write(); return oBinaryFileWriter.Write();
} }
};
exports['asc_docs_merge_api'] = asc_docs_merge_api;
prot = asc_docs_merge_api.prototype;
if(window.exports==undefined) prot['LoadDocument'] = prot.LoadDocument;
{ prot['ApplyChanges'] = prot.ApplyChanges;
window.exports = {}; prot['Save'] = prot.Save;
} })();
exports['asc_docs_api'] = asc_docs_api;
asc_docs_api.prototype['LoadDocument'] = asc_docs_api.prototype.LoadDocument;
asc_docs_api.prototype['CreateFontsCharMap'] = asc_docs_api.prototype.CreateFontsCharMap;
asc_docs_api.prototype['ApplyChanges'] = asc_docs_api.prototype.ApplyChanges;
asc_docs_api.prototype['Save'] = asc_docs_api.prototype.Save;
\ No newline at end of file
...@@ -9,13 +9,15 @@ var base_file = process.argv[2]; ...@@ -9,13 +9,15 @@ var base_file = process.argv[2];
var changes_file = process.argv[3]; var changes_file = process.argv[3];
var output_file = process.argv[4]; var output_file = process.argv[4];
setTimeout( main, 15000, base_file, changes_file, output_file); setTimeout( main, 0, base_file, changes_file, output_file);
function main(base_file, changes_file, output_file) function main(base_file, changes_file, output_file)
{ {
try{ var error_code = 1;
try {
//var TimeStart = new Date();
var sdk_all = require('./sdk-all.js'); var sdk_all = require('./sdk-all.js');
var editor = new sdk_all.asc_docs_api(); var editor = new sdk_all.asc_docs_merge_api();
var fs = require('fs'); var fs = require('fs');
var base_doc = fs.readFileSync(base_file, 'utf-8'); var base_doc = fs.readFileSync(base_file, 'utf-8');
...@@ -25,9 +27,19 @@ function main(base_file, changes_file, output_file) ...@@ -25,9 +27,19 @@ function main(base_file, changes_file, output_file)
editor.ApplyChanges( doc_changes ); editor.ApplyChanges( doc_changes );
var changed_doc = editor.Save(); var changed_doc = editor.Save();
fs.writeFileSync(output_file, changed_doc, 'utf-8'); fs.writeFileSync(output_file, changed_doc, 'utf-8');/**/
//var TimeEnd = new Date();
//console.log("Execution duration:", TimeEnd - TimeStart, " ms.");
error_code = 0;
} }
catch(err){
catch(err) {
console.log("Error:", err); console.log("Error:", err);
} }
finally {
process.exit(error_code);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment