|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
-
-
-
- let testFuncs=null;
- function dispatcher(info) {
- var funcs = info.funcs;
- wps.WpsApplication().Options.UseLocalUserInfo=true
-
-
-
- for (var index = 0; index < funcs.length; index++) {
- var func = funcs[index];
- for (var key in func) {
- if (key === "GetDocStatus") {
- return GetDocStatus(func[key])
- } else if (key === "ExitWPS") {
- ExitWPS(func[key])
- }
- }
- }
-
-
- setTimeout(function(){
- for (var index = 0; index < funcs.length; index++) {
- testFuncs=funcs;
- var func = funcs[index];
- for (var key in func) {
- func[key].isOA=true;
- if (key === "OpenDoc") {
- OpenDoc(func[key]);
- } else if (key === "OnlineEditDoc") {
- OnlineEditDoc(func[key]);
- } else if (key === "NewDoc") {
- OpenDoc(func[key]);
- } else if (key === "UseTemplate") {
- OpenDoc(func[key]);
- } else if (key === "InsertRedHead") {
- InsertRedHead(func[key]);
- } else if (key === "taskPaneBookMark"){
- taskPaneBookMark(func[key])
- } else if (key === "NewOfficialDocument"){
- return OpenDoc(func[key])
- }
- }
- }
- },100)
- return {message:"ok", app:wps.WpsApplication().Name}
- }
-
-
-
- function GetDocStatus() {
- let l_doc = wps.WpsApplication().ActiveDocument
- if (l_doc && pCheckIfOADoc()) {
- return{
- message: "GetDocStatus",
- docstatus:{
- words: l_doc.Words.Count,
- saved: l_doc.Saved,
- pages: l_doc.ActiveWindow.Panes.Item(1).Pages.Count
- }
- }
- }
- }
-
-
- function ExitWPS() {
-
- wps.WpsApplication().Activate();
- let l_doc = wps.WpsApplication().ActiveDocument
- if (l_doc && pCheckIfOADoc()) {
- l_doc.Close();
- }
- if(wps.confirm("要关闭WPS软件,请确认文档都已保存。\n点击确定后关闭WPS,点击取消继续编辑。")){
- wps.WpsApplication().Quit();
- }
- }
-
-
- function OnlineEditDoc(OaParams) {
- if (OaParams.fileName == "") {
- NewFile(OaParams);
- } else {
-
- OpenOnLineFile(OaParams);
- }
- }
-
-
- function OpenDoc(OaParams) {
- console.log(OaParams);
- if (OaParams.fileName == "") {
- console.log('zouzhe?');
- NewFile(OaParams);
-
- } else {
- console.log('zouzhe111?');
-
- OpenFile(OaParams);
- }
- }
-
- function taskPaneBookMark(OaParams){
- let filePath = OaParams.fileName
- if (filePath == "")
- return
- OpenFile(OaParams);
-
-
- let id = wps.PluginStorage.getItem(constStrEnum.taskpaneid)
- if (id){
- let tp = wps.GetTaskPane(id)
- tp.Width = 300
- tp.Visible = true
- }
- else{
- let url = getHtmlURL("taskpane.html");
- let tp = wps.CreateTaskPane(url, "书签操作")
- if (tp){
- tp.DockPosition = WPS_Enum.msoCTPDockPositionRight
- tp.Width = 300
- tp.Visible = true
- wps.PluginStorage.setItem(constStrEnum.taskpaneid, tp.ID)
- }
- }
- }
|