From aa9c0a2f5c6511ac10e9838867a6658c0a203384 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 14:34:40 +0300 Subject: [PATCH] Apply document info (subject, title, comment, authors) --- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 2 +- 4 files changed, 91 insertions(+), 25 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d671c1583..f85c3c306 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -760,6 +760,8 @@ define([ this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0}; this.inProgress = false; this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -787,7 +789,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -795,7 +800,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -803,7 +811,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -823,7 +834,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -840,10 +855,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -903,9 +922,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -920,6 +939,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -948,10 +968,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 808f55dae..eb3340c67 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -658,6 +658,8 @@ define([ ].join('')); this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -677,7 +679,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -685,7 +690,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -693,7 +701,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -713,7 +724,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -730,10 +745,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -790,9 +809,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -807,6 +826,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -835,10 +855,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 3100b1d7a..7436675d8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1109,6 +1109,8 @@ define([ ].join('')); this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -1128,7 +1130,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -1136,7 +1141,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -1144,7 +1152,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -1164,7 +1175,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -1181,10 +1196,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -1241,9 +1260,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -1258,6 +1277,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -1286,10 +1306,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 203fd7a0d..142c59a95 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -754,8 +754,8 @@ "SSE.Controllers.Toolbar.textOperator": "Operators", "SSE.Controllers.Toolbar.textPivot": "Pivot Table", "SSE.Controllers.Toolbar.textRadical": "Radicals", - "SSE.Controllers.Toolbar.textScript": "Scripts", "SSE.Controllers.Toolbar.textSymbols": "Symbols", + "SSE.Controllers.Toolbar.textScript": "Scripts", "SSE.Controllers.Toolbar.textWarning": "Warning", "SSE.Controllers.Toolbar.txtAccent_Accent": "Acute", "SSE.Controllers.Toolbar.txtAccent_ArrowD": "Right-left arrow above",