Fix doc-info (pdf/xps/djvu)
This commit is contained in:
parent
352d9d51fa
commit
7e8e35122b
|
@ -586,6 +586,12 @@
|
||||||
"textSubject": "Subject",
|
"textSubject": "Subject",
|
||||||
"textSymbols": "Symbols",
|
"textSymbols": "Symbols",
|
||||||
"textTitle": "Title",
|
"textTitle": "Title",
|
||||||
|
"textPageSize": "Page Size",
|
||||||
|
"textPdfVer": "PDF Version",
|
||||||
|
"textPdfTagged": "Tagged PDF",
|
||||||
|
"textFastWV": "Fast Web View",
|
||||||
|
"textYes": "Yes",
|
||||||
|
"textNo": "No",
|
||||||
"textTop": "Top",
|
"textTop": "Top",
|
||||||
"textUnitOfMeasurement": "Unit Of Measurement",
|
"textUnitOfMeasurement": "Unit Of Measurement",
|
||||||
"textUploaded": "Uploaded",
|
"textUploaded": "Uploaded",
|
||||||
|
|
|
@ -1,20 +1,105 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { observer, inject } from "mobx-react";
|
import { observer, inject } from "mobx-react";
|
||||||
import DocumentInfo from "../../view/settings/DocumentInfo";
|
import DocumentInfo from "../../view/settings/DocumentInfo";
|
||||||
|
import { withTranslation } from 'react-i18next';
|
||||||
|
|
||||||
class DocumentInfoController extends Component {
|
class DocumentInfoController extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.docProps = this.getDocProps();
|
this.docProps = this.getDocProps();
|
||||||
|
this.pdfProps = this.getPdfProps();
|
||||||
|
this.docInfoObject = {};
|
||||||
|
|
||||||
|
this.getAppProps = this.getAppProps.bind(this);
|
||||||
|
|
||||||
if(this.docProps) {
|
if(this.docProps) {
|
||||||
this.modified = this.getModified();
|
this.updateFileInfo(this.docProps);
|
||||||
this.modifiedBy = this.getModifiedBy();
|
} else if (this.pdfProps) {
|
||||||
this.creators = this.getCreators();
|
this.updatePdfInfo(this.pdfProps);
|
||||||
this.title = this.getTitle();
|
}
|
||||||
this.subject = this.getSubject();
|
|
||||||
this.description = this.getDescription();
|
console.log(this.docInfoObject)
|
||||||
this.created = this.getCreated();
|
}
|
||||||
|
|
||||||
|
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();
|
return api.asc_getCoreProps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPdfProps() {
|
||||||
|
const api = Common.EditorApi.get();
|
||||||
|
return api.asc_getPdfProps();
|
||||||
|
}
|
||||||
|
|
||||||
getAppProps() {
|
getAppProps() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
const appProps = api.asc_getAppProps();
|
const appProps = api.asc_getAppProps();
|
||||||
|
let appName;
|
||||||
|
|
||||||
if (appProps) {
|
if (appProps) {
|
||||||
let appName =
|
appName =
|
||||||
(appProps.asc_getApplication() || "") +
|
(appProps.asc_getApplication() || "") +
|
||||||
(appProps.asc_getAppVersion() ? " " : "") +
|
(appProps.asc_getAppVersion() ? " " : "") +
|
||||||
(appProps.asc_getAppVersion() || "");
|
(appProps.asc_getAppVersion() || "");
|
||||||
return appName;
|
return appName;
|
||||||
|
} else if (this.pdfProps) {
|
||||||
|
appName = this.pdfProps ? this.pdfProps.Producer || '' : '';
|
||||||
|
return appName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getModified() {
|
getModified(valueModified) {
|
||||||
let valueModified = this.docProps.asc_getModified();
|
|
||||||
const _lang = this.props.storeAppOptions.lang;
|
const _lang = this.props.storeAppOptions.lang;
|
||||||
|
|
||||||
if (valueModified) {
|
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() {
|
componentDidMount() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
api.startGetDocInfo();
|
api.startGetDocInfo();
|
||||||
|
@ -95,17 +155,11 @@ class DocumentInfoController extends Component {
|
||||||
return (
|
return (
|
||||||
<DocumentInfo
|
<DocumentInfo
|
||||||
getAppProps={this.getAppProps}
|
getAppProps={this.getAppProps}
|
||||||
modified={this.modified}
|
docInfoObject={this.docInfoObject}
|
||||||
modifiedBy={this.modifiedBy}
|
|
||||||
creators={this.creators}
|
|
||||||
created={this.created}
|
|
||||||
title={this.title}
|
|
||||||
subject={this.subject}
|
|
||||||
description={this.description}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default inject("storeAppOptions")(observer(DocumentInfoController));
|
export default inject("storeAppOptions")(observer(withTranslation()(DocumentInfoController)));
|
|
@ -7,6 +7,8 @@ const PageDocumentInfo = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _t = t("Settings", { returnObjects: true });
|
const _t = t("Settings", { returnObjects: true });
|
||||||
const storeInfo = props.storeDocumentInfo;
|
const storeInfo = props.storeDocumentInfo;
|
||||||
|
const fileType = storeInfo.dataDoc.fileType;
|
||||||
|
|
||||||
const dataApp = props.getAppProps();
|
const dataApp = props.getAppProps();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -17,6 +19,21 @@ const PageDocumentInfo = (props) => {
|
||||||
wordsCount,
|
wordsCount,
|
||||||
} = storeInfo.infoObj;
|
} = 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 dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc));
|
||||||
const isLoaded = storeInfo.isLoaded;
|
const isLoaded = storeInfo.isLoaded;
|
||||||
|
|
||||||
|
@ -62,70 +79,87 @@ const PageDocumentInfo = (props) => {
|
||||||
<ListItem title={t('Settings.textWords')} after={isLoaded ? String(wordsCount) : _t.textLoading}></ListItem>
|
<ListItem title={t('Settings.textWords')} after={isLoaded ? String(wordsCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title={t('Settings.textSymbols')} after={isLoaded ? String(symbolsCount) : _t.textLoading}></ListItem>
|
<ListItem title={t('Settings.textSymbols')} after={isLoaded ? String(symbolsCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title={t('Settings.textSpaces')} after={isLoaded ? String(symbolsWSCount) : _t.textLoading}></ListItem>
|
<ListItem title={t('Settings.textSpaces')} after={isLoaded ? String(symbolsWSCount) : _t.textLoading}></ListItem>
|
||||||
|
{pageSize && <ListItem title={t('Settings.textPageSize')} after={pageSize}></ListItem>}
|
||||||
</List>
|
</List>
|
||||||
{props.title ? (
|
{title ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textTitle}</BlockTitle>
|
<BlockTitle>{t('Settings.textTitle')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.title}></ListItem>
|
<ListItem title={title}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.subject ? (
|
{subject ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textSubject}</BlockTitle>
|
<BlockTitle>{t('Settings.textSubject')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.subject}></ListItem>
|
<ListItem title={subject}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.description ? (
|
{description ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textComment}</BlockTitle>
|
<BlockTitle>{t('Settings.textComment')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.description}></ListItem>
|
<ListItem title={description}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.modified ? (
|
{modifyDate ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textLastModified}</BlockTitle>
|
<BlockTitle>{t('Settings.textLastModified')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.modified}></ListItem>
|
<ListItem title={modifyDate}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.modifiedBy ? (
|
{modifyBy ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textLastModifiedBy}</BlockTitle>
|
<BlockTitle>{t('Settings.textLastModifiedBy')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.modifiedBy}></ListItem>
|
<ListItem title={modifyBy}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.created ? (
|
{dateCreated ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textCreated}</BlockTitle>
|
<BlockTitle>{t('Settings.textCreated')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={props.created}></ListItem>
|
<ListItem title={dateCreated}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{dataApp ? (
|
{dataApp ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textApplication}</BlockTitle>
|
<BlockTitle>{t('Settings.textApplication')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={dataApp}></ListItem>
|
<ListItem title={dataApp}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{props.creators ? (
|
{fileType === 'xps' && author ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BlockTitle>{_t.textAuthor}</BlockTitle>
|
<BlockTitle>{t('Settings.textAuthor')}</BlockTitle>
|
||||||
|
<List>
|
||||||
|
<ListItem title={author}></ListItem>
|
||||||
|
</List>
|
||||||
|
</Fragment>
|
||||||
|
) : null}
|
||||||
|
{ fileType === 'pdf' ? (
|
||||||
|
<List>
|
||||||
|
<ListItem title={t('Settings.textAuthor')} after={author} />
|
||||||
|
<ListItem title={t('Settings.textPdfVer')} after={version} />
|
||||||
|
<ListItem title={t('Settings.textPdfTagged')} after={tagged} />
|
||||||
|
<ListItem title={t('Settings.textFastWV')} after={fastWebView} />
|
||||||
|
</List>
|
||||||
|
) : null}
|
||||||
|
{creators ? (
|
||||||
|
<Fragment>
|
||||||
|
<BlockTitle>{t('Settings.textAuthor')}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
{
|
{
|
||||||
props.creators.split(/\s*[,;]\s*/).map(item => {
|
creators.split(/\s*[,;]\s*/).map(item => {
|
||||||
return <ListItem title={item}></ListItem>
|
return <ListItem key="item" title={item}></ListItem>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</List>
|
</List>
|
||||||
|
|
Loading…
Reference in a new issue