MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
/** @class Office Office控件。
* @o2cn Ntko Office控件
* @example
* //可以在脚本中获取该组件
* //方法1:
* var attachment = this.form.get("name"); //获取组件
* //方法2
* var attachment = this.target; //在组件事件脚本中获取
* @extends MWF.xApplication.process.Xform.$Module
* @o2category FormComponents
* @o2range {Process|CMS}
* @hideconstructor
*/
MWF.xApplication.process.Xform.Office = MWF.APPOffice = new Class(
/** @lends MWF.xApplication.process.Xform.Office# */
{
Extends: MWF.APP$Module,
isActive: false,
options:{
"ProductCaption": "O2",
"ProductKey": "EDCC626CB85C9A1D3E0D7BDDDC2637753C596725",
"makerCaption": "浙江兰德纵横网络技术股份有限公司",
"makerKey": "E138DABB4AC26C2D8E09FAE59AB3BDE87AFB9D7B",
"version": "5.0.4.0",
"clsid": "A64E3073-2016-4baf-A89D-FFE1FAA10EC0",
"codeBase": "../o2_lib/officecontrol/5040/OfficeControl.cab",
"clsid64": "A64E3073-2016-4baf-A89D-FFE1FAA10EE1",
"codeBase64": "../o2_lib/officecontrol/5040/ofctnewclsid.cab",
"pdfType": "PDF.NtkoDocument",
"pdfVersion": "4.0.0.3",
"pdfCodeBase": "../o2_lib/officecontrol/5040/ntkooledocall.cab",
"pdfCodeBase64": "../o2_lib/officecontrol/5040/ntkooledocall64.cab",
"files": ["doc","docx","dotx","dot","xls","xlsx","xlsm","xlt","xltx","pptx","ppt","pot","potx","potm","pdf"],
/**
* @event MWF.xApplication.process.Xform.Office#queryLoad
* @ignore
*/
/**
* @event MWF.xApplication.process.Xform.Office#postLoad
* @ignore
*/
/**
* 点击套红按钮触发。
* @event MWF.xApplication.process.Xform.Office#redFile
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 点击盖章按钮触发。
* @event MWF.xApplication.process.Xform.Office#seal
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* Ntko控件执行AfterOpenFromURL事件(BeginOpenFromURL方法执行完毕之后被触发)时执行。
* 本事件可以通过this.event获取当前打开的文档对象。比如,对于一个Word文档,第二个参数是一个Word.Document对象。
* @event MWF.xApplication.process.Xform.Office#afterOpen
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* Ntko控件执行OnDocumentOpened事件(Office文档打开完毕)时触发。
* 本事件可以通过this.event获取以下内容
*
{
url : url, //Office文档路径或者URL
doc : doc //Office文档的自动化接口,比如,对于一个Word文档,第二个参数是一个Word.Document对象。
}
* @event MWF.xApplication.process.Xform.Office#afterOpenOffice
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 在新建Office文档后触发。
* @event MWF.xApplication.process.Xform.Office#afterCreate
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 在保存Office文档前触发。
* @event MWF.xApplication.process.Xform.Office#beforeSave
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 在保存Office文档后触发。
* @event MWF.xApplication.process.Xform.Office#afterSave
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 在关闭Office文档时执行。
* @event MWF.xApplication.process.Xform.Office#afterCloseOffice
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
"moduleEvents": ["redFile",
"afterOpen",
"afterOpenOffice",
"afterCreate",
"seal",
"beforeSave",
"afterSave",
"afterCloseOffice",
"load"
]
},
initialize: function(node, json, form, options){
this.node = $(node);
this.node.store("module", this);
this.json = json;
this.form = form;
this.field = true;
this.openedAttachment = null;
this.fieldModuleLoaded = false;
},
_loadUserInterface: function(){
this.node.empty();
this.node.setStyles({
"min-height": "100px"
});
// this.isActive = true;
if (Browser.name==="ie" || Browser.name==="chrome" || Browser.name==="firefox"){
// if (Browser.name==="ie"){
this.isActive = true;
this.file = null;
if (!this.form.officeList) this.form.officeList=[];
this.form.officeList.push(this);
}
},
_afterLoaded: function(){
if (!this.json.isNotLoadNow){
this.loadOffice();
}
//this.fireEvent("load");
},
loadOffice: function(file){
if (!this.officeLoaded){
if (!this.isActive){
this.loadOfficeNotActive();
}else{
MWF.getJSON("../o2_lib/officecontrol/config.json", function(json){
this.officeConfig = json;
}.bind(this), false);
this.loadOfficeContorl(file);
}
this.officeLoaded = true;
}else{
if (this.officeOCX) this.officeOCX.BeginOpenFromURL(file, true, this.readonly);
}
this.fieldModuleLoaded = true;
},
getProgID: function(){
switch (this.json.officeType){
case "word":
return "Word.Document";
case "excel":
return "Excel.Sheet";
case "ppt":
return "PowerPoint.Show";
}
return "Word.Document"
},
getTemplateName: function(){
switch (this.json.officeType){
case "word":
return "template.docx";
case "excel":
return "template.xlsx";
case "ppt":
return "template.pptx";
}
return "template.docx"
},
defaultParam: function(readonly){
var o = {
"ProductCaption": this.json.productCaption || this.options.ProductCaption,
"ProductKey": this.json.productKey || this.options.ProductKey,
"MakerCaption": this.officeConfig.makerCaption || this.json.makerCaption || this.options.makerCaption,
"MakerKey": this.officeConfig.makerKey || this.options.makerKey || this.options.MakerKey,
"Titlebar": "0",
"Menubar": "0",
"ToolBars": (readonly) ? "0" : "1",
"Statusbar": "0",
"IsUseUTF8URL": "1",
"IsUseUTF8Data": "1",
"BorderStyle": (readonly) ? "0" : "0",
"IsNoCopy": "0",
"IsResetToolbarsOnOpen": "1",
"FileNew": "0",
"FileOpen": "1",
"FileClose": "0",
"FileSave": "0",
"FileProperties": "0"
};
return o;
},
loadOfficeContorl: function(file){
if (this.node.getSize().y<800) this.node.setStyle("height", "800px");
if (!layout.desktop.offices) layout.desktop.offices = {};
layout.desktop.offices[this.getOfficeObjectId()] = this;
if (this.readonly){
this.loadOfficeEdit(file, true);
}else if (this.json.isReadonly || this.form.json.isReadonly){
this.readonly = true;
this.loadOfficeEdit(file, true);
}else{
if (this.json.readScript && this.json.readScript.code){
var flag = this.form.Macro.exec(this.json.readScript.code, this);
if (flag){
this.readonly = true;
this.loadOfficeEdit(file, true);
}else{
this.loadOfficeEdit(file);
}
}else{
this.loadOfficeEdit(file);
}
}
},
loadOfficeSpacer: function(){
var size = this.node.getSize();
this.officeNode = new Element("div#officeNode", {
"styles": this.form.css.officeAreaNode
}).inject(this.node);
var y = size.y-40;
this.officeNode.setStyle("height", ""+y+"px");
this.form.app.addEvent("uncurrent", function(){
var display = this.officeNode.getStyle("display");
this.officeNode.store("officeDisplay", display);
this.officeNode.setStyle("display", "none");
}.bind(this));
this.form.app.addEvent("current", function(){
var display = this.officeNode.retrieve("officeDisplay");
if (display) this.officeNode.setStyle("display", display);
if (this.officeOCX) this.officeOCX.Activate(true);
}.bind(this));
this.form.app.addEvent("queryClose", function(){
this.fireEvent("queryClose");
var id = this.getOfficeObjectId();
layout.desktop.offices[id] = null;
delete layout.desktop.offices[id];
}.bind(this));
},
hide: function(){
if (this.officeNode.getStyle("display")!="none"){
var display = this.officeNode.getStyle("display");
this.officeNode.store("officeDisplay", display);
this.officeNode.setStyle("display", "none");
}
},
show: function(){
if ((layout.desktop.currentApp && layout.desktop.currentApp.appId===this.form.app.appId) || this.form.app.inBrowser){
var display = this.officeNode.retrieve("officeDisplay");
if (display) this.officeNode.setStyle("display", display);
if (this.officeOCX) this.officeOCX.Activate(true);
}
},
isCover: function(node){
},
getFormId: function(){
var id = (!this.form.businessData.workCompleted) ? this.form.businessData.work.id : this.form.businessData.workCompleted.id;
return "form"+this.json.id+id;
},
getFileName: function(){
var ename = "docx";
switch (this.json.officeType){
case "word":
ename = "docx";
break;
case "excel":
ename = "xlsx";
break;
case "ppt":
ename = "pptx";
}
var id = (!this.form.businessData.workCompleted) ? this.form.businessData.work.id : this.form.businessData.workCompleted.id;
return "file"+this.json.id+id+"."+ename;
},
getOfficeObjectId: function(){
var id = (!this.form.businessData.workCompleted) ? this.form.businessData.work.id : this.form.businessData.workCompleted.id;
return "NTKOOCX"+this.json.id+id;
},
getFileInputName: function(){
var id = (!this.form.businessData.workCompleted) ? this.form.businessData.work.id : this.form.businessData.workCompleted.id;
return "fileInput"+this.json.id+id;
},
getTempleteUrl: function(){
//return "../x_desktop/temp/杭州城管委文件.doc";
if (this.json.template){
var root = "";
var flag = this.json.template.substr(0,1);
if (flag==="/"){
root = this.json.template.substr(1, this.json.template.indexOf("/", 1)-1);
}else{
root = this.json.template.substr(0, this.json.template.indexOf("/"));
}
if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
var host = MWF.Actions.getHost(root);
return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
}
}
return this.json.template;
},
getFile: function(site){
var file = null;
atts = this.form.businessData.attachmentList;
for (var i=0; i