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')
} {
if (editor) window['editor'] = window.editor = editor = this;
window.editor = editor; }
this.WordControl = new CEditorPage(this);
this.WordControl.m_oLogicDocument = new CDocument(this.WordControl.m_oDrawingDocument);
this.WordControl.m_oDrawingDocument.m_oLogicDocument = this.WordControl.m_oLogicDocument;
this.WordControl = new CEditorPage(this); this.chartStyleManager = new ChartStyleManager();
this.WordControl.m_oLogicDocument = new CDocument(this.WordControl.m_oDrawingDocument); this.chartPreviewManager = new ChartPreviewManager();
this.WordControl.m_oDrawingDocument.m_oLogicDocument = this.WordControl.m_oLogicDocument;
this.chartStyleManager = new ChartStyleManager();
this.chartPreviewManager = new ChartPreviewManager();
}
asc_docs_api.prototype.LoadDocument = function( doc )
{
this.LoadedObjectDS = Common_CopyObj(this.WordControl.m_oLogicDocument.Get_Styles().Style);
var oBinaryFileReader = new BinaryFileReader(this.WordControl.m_oLogicDocument);
oBinaryFileReader.Read( doc );
}
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;
for (var i = 0; i < Count; i++)
{
var Changes = new CCollaborativeChanges();
Changes.Set_Id(e[i]["id"]);
Changes.Set_Data(e[i]["data"]);
CollaborativeEditing.Add_Changes(Changes);
} }
if(Count > 0)
CollaborativeEditing.Apply_OtherChanges(); asc_docs_merge_api.prototype = {
} LoadDocument: function( doc )
asc_docs_api.prototype.Save = function() {
{ this.LoadedObjectDS = Common_CopyObj(this.WordControl.m_oLogicDocument.Get_Styles().Style);
var oBinaryFileWriter = new BinaryFileWriter(this.WordControl.m_oLogicDocument); var oBinaryFileReader = new BinaryFileReader(this.WordControl.m_oLogicDocument);
return oBinaryFileWriter.Write(); oBinaryFileReader.Read( doc );
} },
ApplyChanges: function(e)
if(window.exports==undefined) {
{ var Count = e.length;
window.exports = {}; for (var i = 0; i < Count; i++)
} {
exports['asc_docs_api'] = asc_docs_api; var Changes = new CCollaborativeChanges();
asc_docs_api.prototype['LoadDocument'] = asc_docs_api.prototype.LoadDocument; Changes.Set_Id(e[i]["id"]);
asc_docs_api.prototype['CreateFontsCharMap'] = asc_docs_api.prototype.CreateFontsCharMap; Changes.Set_Data(e[i]["data"]);
asc_docs_api.prototype['ApplyChanges'] = asc_docs_api.prototype.ApplyChanges; CollaborativeEditing.Add_Changes(Changes);
asc_docs_api.prototype['Save'] = asc_docs_api.prototype.Save; }
\ No newline at end of file if(Count > 0)
CollaborativeEditing.Apply_OtherChanges();
},
Save: function()
{
var oBinaryFileWriter = new BinaryFileWriter(this.WordControl.m_oLogicDocument);
return oBinaryFileWriter.Write();
}
};
exports['asc_docs_merge_api'] = asc_docs_merge_api;
prot = asc_docs_merge_api.prototype;
prot['LoadDocument'] = prot.LoadDocument;
prot['ApplyChanges'] = prot.ApplyChanges;
prot['Save'] = prot.Save;
})();
...@@ -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