From 69c95bcb9923e3c7d15fe5e4ec038f225787ac37 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Mar 2022 19:30:09 +0300 Subject: [PATCH] [DE] Show pdf/xps info --- .../main/app/controller/Main.js | 12 +- .../main/app/view/FileMenuPanels.js | 158 ++++++++++++++++-- apps/documenteditor/main/locale/en.json | 6 + 3 files changed, 153 insertions(+), 23 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 5c119aa79..cbef73f27 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1610,6 +1610,12 @@ define([ this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this)); this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this)); + + var value = Common.localStorage.getItem('de-settings-unit'); + value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); + Common.Utils.Metric.setCurrentMetric(value); + Common.Utils.InternalSettings.set("de-settings-unit", value); }, applyModeEditorElements: function() { @@ -1660,11 +1666,7 @@ define([ toolbarView.on('insertcontrol', _.bind(me.onInsertControl, me)); } - var value = Common.localStorage.getItem('de-settings-unit'); - value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); - (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); - Common.Utils.Metric.setCurrentMetric(value); - Common.Utils.InternalSettings.set("de-settings-unit", value); + var value = Common.Utils.InternalSettings.get("de-settings-unit"); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); value = Common.localStorage.itemExists('de-hidden-rulers') ? Common.localStorage.getBool('de-hidden-rulers') : (this.appOptions.customization && !!this.appOptions.customization.hideRulers); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 15d38da6a..e22600ac7 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1094,33 +1094,47 @@ define([ '', '', '', + '', + '', + '', + '', '', '', // '', // '', // '', // '', - '', + '', '', '
', '', - '', + '', '', '
', '', - '', + '', '', '
', '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', '', '', '', '', - '', - '', + '', + '', '', '', '', @@ -1132,7 +1146,23 @@ define([ '', '', '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', '
', '', @@ -1177,6 +1207,7 @@ define([ this.lblStatParagraphs = $markup.findById('#id-info-paragraphs'); this.lblStatSymbols = $markup.findById('#id-info-symbols'); this.lblStatSpaces = $markup.findById('#id-info-spaces'); + this.lblPageSize = $markup.findById('#id-info-pages-size'); // this.lblEditTime = $markup.find('#id-info-edittime'); // edited info @@ -1270,6 +1301,15 @@ define([ } }).on('keydown:before', keyDownBefore); + // pdf info + this.lblPageSize = $markup.findById('#id-info-page-size'); + this.lblPdfTitle = $markup.findById('#id-lbl-info-title'); + this.lblPdfSubject = $markup.findById('#id-lbl-info-subject'); + this.lblPdfAuthor = $markup.findById('#id-lbl-info-author'); + this.lblPdfVer = $markup.findById('#id-info-pdf-ver'); + this.lblPdfTagged = $markup.findById('#id-info-pdf-tagged'); + this.lblFastWV = $markup.findById('#id-info-fast-wv'); + this.btnApply = new Common.UI.Button({ el: $markup.findById('#fminfo-btn-apply') }); @@ -1346,10 +1386,16 @@ define([ this._ShowHideDocInfo(false); $('tr.divider.general', this.el)[visible?'show':'hide'](); + var pdfProps = (this.api) ? this.api.asc_getPdfProps() : null; var appname = (this.api) ? this.api.asc_getAppProps() : null; if (appname) { + $('.pdf-info', this.el).hide(); appname = (appname.asc_getApplication() || '') + (appname.asc_getAppVersion() ? ' ' : '') + (appname.asc_getAppVersion() || ''); this.lblApplication.text(appname); + } else if (pdfProps) { + $('.docx-info', this.el).hide(); + appname = pdfProps ? pdfProps.Producer || '' : ''; + this.lblApplication.text(appname); } this._ShowHideInfoItem(this.lblApplication, !!appname); @@ -1359,7 +1405,8 @@ define([ if (value) this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'})); this._ShowHideInfoItem(this.lblDate, !!value); - } + } else if (pdfProps) + this.updatePdfInfo(pdfProps); }, updateFileInfo: function() { @@ -1371,14 +1418,6 @@ define([ value; this.coreProps = props; - // var app = (this.api) ? this.api.asc_getAppProps() : null; - // if (app) { - // value = app.asc_getTotalTime(); - // if (value) - // this.lblEditTime.text(value + ' ' + this.txtMinutes); - // } - // this._ShowHideInfoItem(this.lblEditTime, !!value); - if (props) { var visible = false; value = props.asc_getModified(); @@ -1413,6 +1452,82 @@ define([ this.SetDisabled(); }, + updatePdfInfo: function(props) { + if (!this.rendered) + return; + + var me = this, + value; + + if (props) { + value = props.CreationDate; + if (value) { + value = new Date(value); + this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'})); + } + this._ShowHideInfoItem(this.lblDate, !!value); + + var visible = false; + value = props.ModDate; + if (value) { + value = new Date(value); + this.lblModifyDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'})); + } + visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; + visible = this._ShowHideInfoItem(this.lblModifyBy, false) || visible; + $('tr.divider.modify', this.el)[visible?'show':'hide'](); + + if (props.PageWidth && props.PageHeight && (typeof props.PageWidth === 'number') && (typeof props.PageHeight === 'number')) { + var w = props.PageWidth, + h = props.PageHeight; + switch (Common.Utils.Metric.getCurrentMetric()) { + case Common.Utils.Metric.c_MetricUnits.cm: + w = parseFloat((w* 25.4 / 72000.).toFixed(2)); + h = parseFloat((h* 25.4 / 72000.).toFixed(2)); + break; + case Common.Utils.Metric.c_MetricUnits.pt: + w = parseFloat((w/100.).toFixed(2)); + h = parseFloat((h/100.).toFixed(2)); + break; + case Common.Utils.Metric.c_MetricUnits.inch: + w = parseFloat((w/7200.).toFixed(2)); + h = parseFloat((h/7200.).toFixed(2)); + break; + } + this.lblPageSize.text(w + ' ' + Common.Utils.Metric.getCurrentMetricName() + ' x ' + h + ' ' + Common.Utils.Metric.getCurrentMetricName()); + this._ShowHideInfoItem(this.lblPageSize, true); + } else + this._ShowHideInfoItem(this.lblPageSize, false); + + value = props.Title; + value && this.lblPdfTitle.text(value); + visible = this._ShowHideInfoItem(this.lblPdfTitle, !!value); + + value = props.Subject; + value && this.lblPdfSubject.text(value); + visible = this._ShowHideInfoItem(this.lblPdfSubject, !!value) || visible; + $('tr.divider.pdf-title', this.el)[visible?'show':'hide'](); + + value = props.Author || props.Creator; + value && this.lblPdfAuthor.text(value); + this._ShowHideInfoItem(this.lblPdfAuthor, !!value); + + value = props.Version; + value && this.lblPdfVer.text(value); + this._ShowHideInfoItem(this.lblPdfVer, !!value); + + value = props.Tagged; + if (value !== undefined) + this.lblPdfTagged.text(value===true ? this.txtYes : this.txtNo); + this._ShowHideInfoItem(this.lblPdfTagged, value !== undefined); + + value = props.FastWebView; + if (value !== undefined) + this.lblFastWV.text(value===true ? this.txtYes : this.txtNo); + this._ShowHideInfoItem(this.lblFastWV, value !== undefined); + } + }, + _ShowHideInfoItem: function(el, visible) { el.closest('tr')[visible?'show':'hide'](); return visible; @@ -1565,7 +1680,14 @@ define([ txtAddAuthor: 'Add Author', txtAddText: 'Add Text', txtMinutes: 'min', - okButtonText: 'Apply' + okButtonText: 'Apply', + txtPageSize: 'Page Size', + txtPdfVer: 'PDF Version', + txtPdfTagged: 'Tagged PDF', + txtFastWV: 'Fast Web View', + txtYes: 'Yes', + txtNo: 'No' + }, DE.Views.FileMenuPanels.DocumentInfo || {})); DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 09661e9f6..5dea69452 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1705,6 +1705,12 @@ "DE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", "DE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", "DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words", + "DE.Views.FileMenuPanels.DocumentInfo.txtPageSize": "Page Size", + "DE.Views.FileMenuPanels.DocumentInfo.txtPdfVer": "PDF Version", + "DE.Views.FileMenuPanels.DocumentInfo.txtPdfTagged": "Tagged PDF", + "DE.Views.FileMenuPanels.DocumentInfo.txtFastWV": "Fast Web View", + "DE.Views.FileMenuPanels.DocumentInfo.txtYes": "Yes", + "DE.Views.FileMenuPanels.DocumentInfo.txtNo": "No", "DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", "DE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning",