From 24a560e564835ac45129512724b50f17bda3e4ae Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Mon, 12 May 2025 19:07:29 +0300 Subject: [PATCH] [se][pe] Fix minimization for GetDocumentInfo method --- cell/apiBuilder.js | 60 +++++++++++++++++------------------ slide/apiBuilder.js | 76 ++++++++++++++++++++++----------------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/cell/apiBuilder.js b/cell/apiBuilder.js index 0978f4d5f6..9bae59bb41 100644 --- a/cell/apiBuilder.js +++ b/cell/apiBuilder.js @@ -7957,7 +7957,7 @@ * LastModifiedRaw - the date and time when the file was last modified. * LastModified - the parsed date and time when the file was last modified. * LastModifiedBy - the name of the user who has made the latest change to the document. - * Autrors - the persons who has created the file. + * Authors - the persons who has created the file. * Title - this property allows you to simplify your documents classification. * Tags - this property allows you to simplify your documents classification. * Subject - this property allows you to simplify your documents classification. @@ -7970,21 +7970,21 @@ Api.prototype.GetDocumentInfo = function() { const oDocInfo = { - Application: '', - CreatedRaw: null, - Created: '', - LastModifiedRaw: null, - LastModified: '', - LastModifiedBy: '', - Autrors: [], - Title: '', - Tags: '', - Subject: '', - Comment: '' + "Application": '', + "CreatedRaw": null, + "Created": '', + "LastModifiedRaw": null, + "LastModified": '', + "LastModifiedBy": '', + "Authors": [], + "Title": '', + "Tags": '', + "Subject": '', + "Comment": '' }; let props = (this) ? this.asc_getAppProps() : null; - oDocInfo.Application = (props.asc_getApplication() || '') + (props.asc_getAppVersion() ? ' ' : '') + (props.asc_getAppVersion() || ''); + oDocInfo["Application"] = (props.asc_getApplication() || '') + (props.asc_getAppVersion() ? ' ' : '') + (props.asc_getAppVersion() || ''); let langCode = 1033; // en-US let langName = 'en-us'; @@ -7997,35 +7997,35 @@ } props = this.asc_getCoreProps(); - oDocInfo.CreatedRaw = props.asc_getCreated(); - oDocInfo.LastModifiedRaw = props.asc_getModified(); + oDocInfo["CreatedRaw"] = props.asc_getCreated(); + oDocInfo["LastModifiedRaw"] = props.asc_getModified(); try { - if (oDocInfo.CreatedRaw) - oDocInfo.Created = (oDocInfo.CreatedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' +oDocInfo. CreatedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["CreatedRaw"]) + oDocInfo["Created"] = (oDocInfo["CreatedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["CreatedRaw"].toLocaleString(langName, {timeStyle: 'short'})); - if (oDocInfo.LastModifiedRaw) - oDocInfo.LastModified = (oDocInfo.LastModifiedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.LastModifiedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["LastModifiedRaw"]) + oDocInfo["LastModified"] = (oDocInfo["LastModifiedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["LastModifiedRaw"].toLocaleString(langName, {timeStyle: 'short'})); } catch (e) { langName = 'en'; - if (oDocInfo.CreatedRaw) - oDocInfo.Created = (oDocInfo.CreatedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.CreatedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["CreatedRaw"]) + oDocInfo["Created"] = (oDocInfo["CreatedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["CreatedRaw"].toLocaleString(langName, {timeStyle: 'short'})); - if (oDocInfo.LastModifiedRaw) - oDocInfo.LastModified = (oDocInfo.LastModifiedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.LastModifiedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["LastModifiedRaw"]) + oDocInfo["LastModified"] = (oDocInfo["LastModifiedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["LastModifiedRaw"].toLocaleString(langName, {timeStyle: 'short'})); } const LastModifiedBy = props.asc_getLastModifiedBy(); - oDocInfo.LastModifiedBy = AscCommon.UserInfoParser.getParsedName(LastModifiedBy); - - oDocInfo.Title = (props.asc_getTitle() || ''); - oDocInfo.Tags = (props.asc_getKeywords() || ''); - oDocInfo.Subject = (props.asc_getSubject() || ''); - oDocInfo.Comment = (props.asc_getDescription() || ''); + oDocInfo["LastModifiedBy"] = AscCommon.UserInfoParser.getParsedName(LastModifiedBy); + + oDocInfo["Title"] = (props.asc_getTitle() || ''); + oDocInfo["Tags"] = (props.asc_getKeywords() || ''); + oDocInfo["Subject"] = (props.asc_getSubject() || ''); + oDocInfo["Comment"] = (props.asc_getDescription() || ''); const authors = props.asc_getCreator(); if (authors) - oDocInfo.Autrors = authors.split(/\s*[,;]\s*/); + oDocInfo["Authors"] = authors.split(/\s*[,;]\s*/); return oDocInfo; }; diff --git a/slide/apiBuilder.js b/slide/apiBuilder.js index 71328b50bd..3d3b3aeff1 100644 --- a/slide/apiBuilder.js +++ b/slide/apiBuilder.js @@ -1562,7 +1562,7 @@ * LastModifiedRaw - the date and time when the file was last modified. * LastModified - the parsed date and time when the file was last modified. * LastModifiedBy - the name of the user who has made the latest change to the document. - * Autrors - the persons who has created the file. + * Authors - the persons who has created the file. * Title - this property allows you to simplify your documents classification. * Tags - this property allows you to simplify your documents classification. * Subject - this property allows you to simplify your documents classification. @@ -1572,26 +1572,26 @@ * @returns {object} * @see office-js-api/Examples/{Editor}/ApiPresentation/Methods/GetDocumentInfo.js */ - ApiPresentation.prototype.GetDocumentInfo = function() + ApiDocument.prototype.GetDocumentInfo = function() { const oDocInfo = { - Application: '', - CreatedRaw: null, - Created: '', - LastModifiedRaw: null, - LastModified: '', - LastModifiedBy: '', - Autrors: [], - Title: '', - Tags: '', - Subject: '', - Comment: '' + "Application": '', + "CreatedRaw": null, + "Created": '', + "LastModifiedRaw": null, + "LastModified": '', + "LastModifiedBy": '', + "Authors": [], + "Title": '', + "Tags": '', + "Subject": '', + "Comment": '' }; const api = this.Presentation.Api; - + let props = (api) ? api.asc_getAppProps() : null; - oDocInfo.Application = (props.asc_getApplication() || '') + (props.asc_getAppVersion() ? ' ' : '') + (props.asc_getAppVersion() || ''); - + oDocInfo["Application"] = (props.asc_getApplication() || '') + (props.asc_getAppVersion() ? ' ' : '') + (props.asc_getAppVersion() || ''); + let langCode = 1033; // en-US let langName = 'en-us'; if (api.asc_getLocale) { @@ -1605,36 +1605,36 @@ } props = api.asc_getCoreProps(); - oDocInfo.CreatedRaw = props.asc_getCreated(); - oDocInfo.LastModifiedRaw = props.asc_getModified(); - + oDocInfo["CreatedRaw"] = props.asc_getCreated(); + oDocInfo["LastModifiedRaw"] = props.asc_getModified(); + try { - if (oDocInfo.CreatedRaw) - oDocInfo.Created = (oDocInfo.CreatedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' +oDocInfo. CreatedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["CreatedRaw"]) + oDocInfo["Created"] = (oDocInfo["CreatedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["CreatedRaw"].toLocaleString(langName, {timeStyle: 'short'})); - if (oDocInfo.LastModifiedRaw) - oDocInfo.LastModified = (oDocInfo.LastModifiedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.LastModifiedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["LastModifiedRaw"]) + oDocInfo["LastModified"] = (oDocInfo["LastModifiedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["LastModifiedRaw"].toLocaleString(langName, {timeStyle: 'short'})); } catch (e) { langName = 'en'; - if (oDocInfo.CreatedRaw) - oDocInfo.Created = (oDocInfo.CreatedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.CreatedRaw.toLocaleString(langName, {timeStyle: 'short'})); - - if (oDocInfo.LastModifiedRaw) - oDocInfo.LastModified = (oDocInfo.LastModifiedRaw.toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo.LastModifiedRaw.toLocaleString(langName, {timeStyle: 'short'})); + if (oDocInfo["CreatedRaw"]) + oDocInfo["Created"] = (oDocInfo["CreatedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["CreatedRaw"].toLocaleString(langName, {timeStyle: 'short'})); + + if (oDocInfo["LastModifiedRaw"]) + oDocInfo["LastModified"] = (oDocInfo["LastModifiedRaw"].toLocaleString(langName, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + oDocInfo["LastModifiedRaw"].toLocaleString(langName, {timeStyle: 'short'})); } - + const LastModifiedBy = props.asc_getLastModifiedBy(); - oDocInfo.LastModifiedBy = AscCommon.UserInfoParser.getParsedName(LastModifiedBy); - - oDocInfo.Title = (props.asc_getTitle() || ''); - oDocInfo.Tags = (props.asc_getKeywords() || ''); - oDocInfo.Subject = (props.asc_getSubject() || ''); - oDocInfo.Comment = (props.asc_getDescription() || ''); - + oDocInfo["LastModifiedBy"] = AscCommon.UserInfoParser.getParsedName(LastModifiedBy); + + oDocInfo["Title"] = (props.asc_getTitle() || ''); + oDocInfo["Tags"] = (props.asc_getKeywords() || ''); + oDocInfo["Subject"] = (props.asc_getSubject() || ''); + oDocInfo["Comment"] = (props.asc_getDescription() || ''); + const authors = props.asc_getCreator(); if (authors) - oDocInfo.Autrors = authors.split(/\s*[,;]\s*/); - + oDocInfo["Authors"] = authors.split(/\s*[,;]\s*/); + return oDocInfo; };