From 7e8e35122bf5de0278f0ac779ff4f11c84def2d2 Mon Sep 17 00:00:00 2001 From: Andrey Shimagin Date: Sun, 27 Mar 2022 17:51:44 +0300 Subject: [PATCH 1/3] Fix doc-info (pdf/xps/djvu) --- apps/documenteditor/mobile/locale/en.json | 6 + .../src/controller/settings/DocumentInfo.jsx | 156 ++++++++++++------ .../mobile/src/view/settings/DocumentInfo.jsx | 80 ++++++--- 3 files changed, 168 insertions(+), 74 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 5c0e3ada9..57072c73d 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -586,6 +586,12 @@ "textSubject": "Subject", "textSymbols": "Symbols", "textTitle": "Title", + "textPageSize": "Page Size", + "textPdfVer": "PDF Version", + "textPdfTagged": "Tagged PDF", + "textFastWV": "Fast Web View", + "textYes": "Yes", + "textNo": "No", "textTop": "Top", "textUnitOfMeasurement": "Unit Of Measurement", "textUploaded": "Uploaded", diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index e97a7016a..6b175b2f7 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -1,20 +1,105 @@ import React, { Component } from "react"; import { observer, inject } from "mobx-react"; import DocumentInfo from "../../view/settings/DocumentInfo"; +import { withTranslation } from 'react-i18next'; class DocumentInfoController extends Component { constructor(props) { super(props); this.docProps = this.getDocProps(); + this.pdfProps = this.getPdfProps(); + this.docInfoObject = {}; + + this.getAppProps = this.getAppProps.bind(this); if(this.docProps) { - this.modified = this.getModified(); - this.modifiedBy = this.getModifiedBy(); - this.creators = this.getCreators(); - this.title = this.getTitle(); - this.subject = this.getSubject(); - this.description = this.getDescription(); - this.created = this.getCreated(); + this.updateFileInfo(this.docProps); + } else if (this.pdfProps) { + this.updatePdfInfo(this.pdfProps); + } + + console.log(this.docInfoObject) + } + + updateFileInfo(props) { + let value; + + if(props) { + value = props.asc_getCreated(); + if(value) this.docInfoObject.dateCreated = this.getModified(value); + + value = props.asc_getModified(); + if(value) this.docInfoObject.modifyDate = this.getModified(value); + + value = props.asc_getLastModifiedBy(); + if(value) this.docInfoObject.modifyBy = AscCommon.UserInfoParser.getParsedName(value); + + value = props.asc_getTitle(); + this.docInfoObject.title = value || ''; + value = props.asc_getSubject(); + this.docInfoObject.subject = value || ''; + value = props.asc_getDescription(); + this.docInfoObject.description = value || ''; + + value = props.asc_getCreator(); + if(value) this.docInfoObject.creators = value; + } + } + + updatePdfInfo(props) { + const { t } = this.props; + const _t = t("Settings", { returnObjects: true }); + let value; + + if(props) { + value = props.CreationDate; + if (value) + this.docInfoObject.dateCreated = this.getModified(new Date(value)); + + value = props.ModDate; + if (value) + this.docInfoObject.modifyDate = this.getModified(new Date(value)); + + if(props.PageWidth && props.PageHeight && (typeof props.PageWidth === 'number') && (typeof props.PageHeight === 'number')) { + let width = props.PageWidth, + heigth = props.PageHeight; + switch(Common.Utils.Metric.getCurrentMetric()) { + case Common.Utils.Metric.c_MetricUnits.cm: + width = parseFloat((width* 25.4 / 72000.).toFixed(2)); + heigth = parseFloat((heigth* 25.4 / 72000.).toFixed(2)); + break; + case Common.Utils.Metric.c_MetricUnits.pt: + width = parseFloat((width/100.).toFixed(2)); + heigth = parseFloat((heigth/100.).toFixed(2)); + break; + case Common.Utils.Metric.c_MetricUnits.inch: + width = parseFloat((width/7200.).toFixed(2)); + heigth = parseFloat((heigth/7200.).toFixed(2)); + break; + } + + this.docInfoObject.pageSize = (width + ' ' + Common.Utils.Metric.getCurrentMetricName() + ' x ' + heigth + ' ' + Common.Utils.Metric.getCurrentMetricName()); + } else this.docInfoObject.pageSize = null; + + value = props.Title; + if(value) this.docInfoObject.title = value; + + value = props.Subject; + if(value) this.docInfoObject.subject = value; + + value = props.Author; + if(value) this.docInfoObject.author = value; + + value = props.Version; + if(value) this.docInfoObject.version = value; + + value = props.Tagged; + if (value !== undefined) + this.docInfoObject.tagged = (value===true ? _t.textYes : _t.textNo); + + value = props.FastWebView; + if (value !== undefined) + this.docInfoObject.fastWebView = (value===true ? _t.textYes : _t.textNo); } } @@ -23,21 +108,29 @@ class DocumentInfoController extends Component { return api.asc_getCoreProps(); } + getPdfProps() { + const api = Common.EditorApi.get(); + return api.asc_getPdfProps(); + } + getAppProps() { const api = Common.EditorApi.get(); const appProps = api.asc_getAppProps(); + let appName; if (appProps) { - let appName = + appName = (appProps.asc_getApplication() || "") + (appProps.asc_getAppVersion() ? " " : "") + (appProps.asc_getAppVersion() || ""); return appName; + } else if (this.pdfProps) { + appName = this.pdfProps ? this.pdfProps.Producer || '' : ''; + return appName; } } - getModified() { - let valueModified = this.docProps.asc_getModified(); + getModified(valueModified) { const _lang = this.props.storeAppOptions.lang; if (valueModified) { @@ -53,39 +146,6 @@ class DocumentInfoController extends Component { } } - getModifiedBy() { - let valueModifiedBy = this.docProps.asc_getLastModifiedBy(); - - if (valueModifiedBy) { - return AscCommon.UserInfoParser.getParsedName(valueModifiedBy); - } - } - - getCreators() { - return this.docProps.asc_getCreator(); - } - - getTitle() { - return this.docProps.asc_getTitle(); - } - - getSubject() { - return this.docProps.asc_getSubject(); - } - - getDescription() { - return this.docProps.asc_getDescription(); - } - - getCreated() { - let value = this.docProps.asc_getCreated(); - const _lang = this.props.storeAppOptions.lang; - - if(value) { - return value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleTimeString(_lang, {timeStyle: 'short'}); - } - } - componentDidMount() { const api = Common.EditorApi.get(); api.startGetDocInfo(); @@ -95,17 +155,11 @@ class DocumentInfoController extends Component { return ( ); } } -export default inject("storeAppOptions")(observer(DocumentInfoController)); \ No newline at end of file +export default inject("storeAppOptions")(observer(withTranslation()(DocumentInfoController))); \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 21f4fb3f0..d45a1bf04 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -7,6 +7,8 @@ const PageDocumentInfo = (props) => { const { t } = useTranslation(); const _t = t("Settings", { returnObjects: true }); const storeInfo = props.storeDocumentInfo; + const fileType = storeInfo.dataDoc.fileType; + const dataApp = props.getAppProps(); const { @@ -17,6 +19,21 @@ const PageDocumentInfo = (props) => { wordsCount, } = storeInfo.infoObj; + const { + pageSize, + title, + subject, + description, + dateCreated, + modifyBy, + modifyDate, + author, + version, + tagged, + fastWebView, + creators + } = props.docInfoObject; + const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); const isLoaded = storeInfo.isLoaded; @@ -62,70 +79,87 @@ const PageDocumentInfo = (props) => { + {pageSize && } - {props.title ? ( + {title ? ( - {_t.textTitle} + {t('Settings.textTitle')} - + ) : null} - {props.subject ? ( + {subject ? ( - {_t.textSubject} + {t('Settings.textSubject')} - + ) : null} - {props.description ? ( + {description ? ( - {_t.textComment} + {t('Settings.textComment')} - + ) : null} - {props.modified ? ( + {modifyDate ? ( - {_t.textLastModified} + {t('Settings.textLastModified')} - + ) : null} - {props.modifiedBy ? ( + {modifyBy ? ( - {_t.textLastModifiedBy} + {t('Settings.textLastModifiedBy')} - + ) : null} - {props.created ? ( + {dateCreated ? ( - {_t.textCreated} + {t('Settings.textCreated')} - + ) : null} {dataApp ? ( - {_t.textApplication} + {t('Settings.textApplication')} ) : null} - {props.creators ? ( + {fileType === 'xps' && author ? ( - {_t.textAuthor} + {t('Settings.textAuthor')} + + + + + ) : null} + { fileType === 'pdf' ? ( + + + + + + + ) : null} + {creators ? ( + + {t('Settings.textAuthor')} { - props.creators.split(/\s*[,;]\s*/).map(item => { - return + creators.split(/\s*[,;]\s*/).map(item => { + return }) } From 345a86150bf217c416135af17a518fdde527647d Mon Sep 17 00:00:00 2001 From: Andrey Shimagin Date: Mon, 28 Mar 2022 12:06:26 +0300 Subject: [PATCH 2/3] del console.log --- .../mobile/src/controller/settings/DocumentInfo.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 6b175b2f7..41e941270 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -17,8 +17,6 @@ class DocumentInfoController extends Component { } else if (this.pdfProps) { this.updatePdfInfo(this.pdfProps); } - - console.log(this.docInfoObject) } updateFileInfo(props) { From d655e79be852c44991bb5935e54259b10d745ef7 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Mon, 28 Mar 2022 15:29:30 +0300 Subject: [PATCH 3/3] Update DocumentInfo.jsx --- .../src/controller/settings/DocumentInfo.jsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 41e941270..72ef0f16a 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -32,12 +32,9 @@ class DocumentInfoController extends Component { value = props.asc_getLastModifiedBy(); if(value) this.docInfoObject.modifyBy = AscCommon.UserInfoParser.getParsedName(value); - value = props.asc_getTitle(); - this.docInfoObject.title = value || ''; - value = props.asc_getSubject(); - this.docInfoObject.subject = value || ''; - value = props.asc_getDescription(); - this.docInfoObject.description = value || ''; + this.docInfoObject.title = props.asc_getTitle() || ''; + this.docInfoObject.subject = props.asc_getSubject() || ''; + this.docInfoObject.description = props.asc_getDescription() || ''; value = props.asc_getCreator(); if(value) this.docInfoObject.creators = value; @@ -117,11 +114,11 @@ class DocumentInfoController extends Component { let appName; if (appProps) { - appName = - (appProps.asc_getApplication() || "") + - (appProps.asc_getAppVersion() ? " " : "") + - (appProps.asc_getAppVersion() || ""); - return appName; + appName = appProps.asc_getApplication(); + if ( appName && appProps.asc_getAppVersion() ) + appName += ` ${appProps.asc_getAppVersion()}`; + + return appName || ''; } else if (this.pdfProps) { appName = this.pdfProps ? this.pdfProps.Producer || '' : ''; return appName; @@ -160,4 +157,4 @@ class DocumentInfoController extends Component { } -export default inject("storeAppOptions")(observer(withTranslation()(DocumentInfoController))); \ No newline at end of file +export default inject("storeAppOptions")(observer(withTranslation()(DocumentInfoController)));