@sapui5/sap.ui.export 1.129.0 → 1.130.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,17 +4,19 @@
4
4
  */
5
5
 
6
6
  sap.ui.define([
7
- './ExportDialog',
8
- './ExportBase',
9
- './ExportUtils',
10
- './library',
11
- './util/PDFCapabilities',
12
- 'sap/base/Log',
13
- 'sap/ui/base/Object',
14
- 'sap/ui/model/odata/v4/ODataModel',
15
- 'sap/m/BusyDialog'
16
- ], function(ExportDialog, ExportBase, ExportUtils, Library, PDFCapabilities, Log, BaseObject, ODataModel, BusyDialog) {
17
- 'use strict';
7
+ "./ExportDialog",
8
+ "./ExportBase",
9
+ "./ExportUtils",
10
+ "./library",
11
+ "./util/PDFCapabilities",
12
+ "sap/base/i18n/Localization",
13
+ "sap/base/Log",
14
+ "sap/m/BusyDialog",
15
+ "sap/ui/base/Object",
16
+ "sap/ui/model/odata/v4/ODataModel",
17
+ "sap/ui/util/openWindow"
18
+ ], function(ExportDialog, ExportBase, ExportUtils, Library, PDFCapabilities, Localization, Log, BusyDialog, BaseObject, ODataModel, openWindow) {
19
+ "use strict";
18
20
 
19
21
  const FileType = Library.FileType;
20
22
  const EdmType = Library.EdmType;
@@ -24,28 +26,32 @@ sap.ui.define([
24
26
  * @class The <code>sap.ui.export.PortableDocument</code> class allows you to export table data from a UI5 application to a Portable Document Format (*.PDF) file.
25
27
  *
26
28
  * @author SAP SE
27
- * @version 1.129.0
29
+ * @version 1.130.0
28
30
  *
29
31
  * @since 1.96
30
32
  * @alias sap.ui.export.PortableDocument
31
33
  * @extends sap.ui.export.ExportBase
32
34
  * @private
33
35
  */
34
- var PortableDocument = ExportBase.extend('sap.ui.export.PortableDocument', {
36
+ const PortableDocument = ExportBase.extend("sap.ui.export.PortableDocument", {
35
37
 
36
- constructor: function(mSettings, mCapabilities) {
38
+ constructor: function(mSettings, mCapabilities, mCloudFileInfo) {
37
39
  ExportBase.call(this, mSettings, mCapabilities);
38
40
 
39
- if (!BaseObject.isA(this._mCapabilities, 'sap.ui.export.util.PDFCapabilities')) {
41
+ if (!BaseObject.isA(this._mCapabilities, "sap.ui.export.util.PDFCapabilities")) {
40
42
  this._mCapabilities = new PDFCapabilities(this._mCapabilities);
41
43
  }
42
44
 
45
+ if (mCloudFileInfo?.FileShare && mCloudFileInfo?.ParentFileShareItem) {
46
+ this._mCloudFileInfo = mCloudFileInfo;
47
+ }
48
+
43
49
  /* Only apply supported properties */
44
- ['paperSize', 'orientation', 'font', 'fontSize', 'doEnableAccessibility', 'fitToPage', 'signature', 'signatureReason', 'pdfArchive', 'showPageNumber'].forEach(function(sProperty) {
45
- if (typeof mSettings[sProperty] !== 'undefined') {
50
+ ["paperSize", "orientation", "font", "fontSize", "doEnableAccessibility", "fitToPage", "signature", "signatureReason", "pdfArchive", "showPageNumber"].forEach((sProperty) => {
51
+ if (typeof mSettings[sProperty] !== "undefined") {
46
52
  this._mSettings[sProperty] = mSettings[sProperty];
47
53
  }
48
- }.bind(this));
54
+ });
49
55
  }
50
56
  });
51
57
 
@@ -61,15 +67,15 @@ sap.ui.define([
61
67
  * @public
62
68
  */
63
69
  PortableDocument.prototype.processDataSource = function(oDataSource) {
64
- var mDataSource = null;
65
- var sDataSourceType = typeof oDataSource;
70
+ let mDataSource = null;
71
+ const sDataSourceType = typeof oDataSource;
66
72
 
67
73
  if (!oDataSource) {
68
74
  return null;
69
75
  }
70
76
 
71
- if (sDataSourceType != 'object') {
72
- Log.error('Spreadsheet#processDataSource: Unable to apply data source of type ' + sDataSourceType);
77
+ if (sDataSourceType != "object") {
78
+ Log.error("Spreadsheet#processDataSource: Unable to apply data source of type " + sDataSourceType);
73
79
 
74
80
  return null;
75
81
  }
@@ -78,7 +84,7 @@ sap.ui.define([
78
84
  mDataSource = oDataSource;
79
85
  }
80
86
 
81
- if (oDataSource.isA && oDataSource.isA(['sap.ui.model.ListBinding', 'sap.ui.model.TreeBinding'])) {
87
+ if (oDataSource.isA && oDataSource.isA(["sap.ui.model.ListBinding", "sap.ui.model.TreeBinding"])) {
82
88
  mDataSource = this.createDataSourceFromBinding(oDataSource);
83
89
  }
84
90
 
@@ -94,34 +100,34 @@ sap.ui.define([
94
100
  * @private
95
101
  */
96
102
  PortableDocument.prototype.createDataSourceFromBinding = function(oBinding) {
97
- var oDataSource = null;
103
+ let oDataSource = null;
98
104
 
99
- if (oBinding.isA(['sap.ui.model.ClientListBinding', 'sap.ui.model.ClientTreeBinding'])) {
100
- Log.error('Unable to create dataSource configuration due to not supported Binding: ' + oBinding.getMetadata().getName());
105
+ if (oBinding.isA(["sap.ui.model.ClientListBinding", "sap.ui.model.ClientTreeBinding"])) {
106
+ Log.error("Unable to create dataSource configuration due to not supported Binding: " + oBinding.getMetadata().getName());
101
107
  }
102
108
 
103
109
  /**
104
110
  * All other <code>Bindings</code> need to provide a downloadUrl
105
111
  */
106
- if (typeof oBinding.getDownloadUrl === 'function') {
107
- var oModel = oBinding.getModel(),
108
- sDataUrl = ExportUtils.interceptUrl(oBinding.getDownloadUrl('pdf')),
112
+ if (typeof oBinding.getDownloadUrl === "function") {
113
+ const oModel = oBinding.getModel(),
114
+ sDataUrl = ExportUtils.interceptUrl(oBinding.getDownloadUrl("pdf")),
109
115
  sServiceUrl = ExportUtils.interceptUrl(oModel.sServiceUrl),
110
- bV4ODataModel = oModel.isA('sap.ui.model.odata.v4.ODataModel');
116
+ bV4ODataModel = oModel.isA("sap.ui.model.odata.v4.ODataModel");
111
117
 
112
- var oDataUrl = new URL(sDataUrl, document.baseURI);
113
- oDataUrl.hash = '';
118
+ const oDataUrl = new URL(sDataUrl, document.baseURI);
119
+ oDataUrl.hash = "";
114
120
 
115
121
  // Reference the Model for later use
116
122
  this._oModel = oModel;
117
123
 
118
124
  /* Remove $format system query option because it would overwrite the "Accept" header */
119
- oDataUrl.search = oDataUrl.search.split('&').filter(function(val) {
120
- return val.indexOf('$format') == -1;
121
- }).join('&');
125
+ oDataUrl.search = oDataUrl.search.split("&").filter((val) => {
126
+ return val.indexOf("$format") == -1;
127
+ }).join("&");
122
128
 
123
129
  oDataSource = {
124
- type: 'odata',
130
+ type: "odata",
125
131
  version: bV4ODataModel ? 4 : 2,
126
132
  dataUrl: oDataUrl.toString(),
127
133
  serviceUrl: this._resolveServiceUrl(sServiceUrl),
@@ -144,18 +150,19 @@ sap.ui.define([
144
150
  * @private
145
151
  */
146
152
  PortableDocument.prototype._resolveServiceUrl = function(sCurrentServiceUrl) {
147
- var isRelative, sReference;
153
+ if (!sCurrentServiceUrl.endsWith("/")) {
154
+ sCurrentServiceUrl += "/";
155
+ }
148
156
 
149
- sCurrentServiceUrl += sCurrentServiceUrl.endsWith('/') ? '' : '/';
150
- isRelative = /^[\./]/.test(sCurrentServiceUrl);
151
- sReference = this._mCapabilities.DocumentDescriptionReference;
157
+ const isRelative = /^[\./]/.test(sCurrentServiceUrl);
158
+ let sReference = this._mCapabilities.DocumentDescriptionReference;
152
159
 
153
- if (typeof sReference !== 'string' || !sReference) {
154
- return sCurrentServiceUrl.split('/').slice(0, -5).join('/') + '/default/iwbep/common/0001/';
160
+ if (typeof sReference !== "string" || !sReference) {
161
+ return sCurrentServiceUrl.split("/").slice(0, -5).join("/") + "/default/iwbep/common/0001/";
155
162
  }
156
163
 
157
- sReference = sReference.endsWith('/') ? sReference : sReference.split('/').slice(0, -1).join('/') + '/';
158
- var oUrl = new URL(sCurrentServiceUrl, document.baseURI);
164
+ sReference = sReference.endsWith("/") ? sReference : sReference.split("/").slice(0, -1).join("/") + "/";
165
+ let oUrl = new URL(sCurrentServiceUrl, document.baseURI);
159
166
 
160
167
  oUrl = new URL(sReference, oUrl.href);
161
168
 
@@ -176,15 +183,15 @@ sap.ui.define([
176
183
  const iODataVersion = mSettings.dataSource.version;
177
184
 
178
185
  const oDocumentDescription = {
179
- "Title": oWorkbook.context.title,
180
- "Format": {
181
- "PaperSize": mSettings.paperSize,
182
- "Orientation": mSettings.orientation
186
+ Title: oWorkbook.context.title,
187
+ Format: {
188
+ PaperSize: mSettings.paperSize,
189
+ Orientation: mSettings.orientation
183
190
  },
184
- "PDFStandard": {
185
- "DoEnableAccessibility": mSettings.doEnableAccessibility
191
+ PDFStandard: {
192
+ DoEnableAccessibility: mSettings.doEnableAccessibility
186
193
  },
187
- "TableColumns": []
194
+ TableColumns: []
188
195
  };
189
196
 
190
197
 
@@ -192,42 +199,39 @@ sap.ui.define([
192
199
 
193
200
  /* ArchiveFormat */
194
201
  if (this._mCapabilities.ArchiveFormat) {
195
- oDocumentDescription.PDFStandard["UsePDFAConformance"] = mSettings.pdfArchive;
202
+ oDocumentDescription.PDFStandard.UsePDFAConformance = mSettings.pdfArchive;
196
203
  }
197
204
 
198
205
  /* CoverPage */
199
206
  if (this._mCapabilities.CoverPage) {
200
207
  const oMetaInfo = oWorkbook.context.metainfo;
201
- oDocumentDescription["CoverPage"] = [];
208
+ oDocumentDescription.CoverPage = [];
202
209
 
203
210
  if (oMetaInfo instanceof Array) {
204
- oMetaInfo.forEach(function(oGroup) {
211
+ oMetaInfo.forEach((oGroup) => {
205
212
  if (iODataVersion === 2) {
206
- const truncateString = (sValue) => {
207
- return sValue.length > 256 ? sValue.substring(0, 253) + '...' : sValue;
208
- };
209
213
 
210
- oGroup.items.forEach(function(oItem) {
214
+ oGroup.items.forEach((oItem) => {
211
215
  const oCoverPageGroup = {
212
- "Title": oGroup.name,
213
- "Name": oItem.key,
214
- "Value": truncateString(oItem.value)
216
+ Title: oGroup.name,
217
+ Name: oItem.key,
218
+ Value: oItem.value
215
219
  };
216
- oDocumentDescription["CoverPage"].push(oCoverPageGroup);
220
+ oDocumentDescription.CoverPage.push(oCoverPageGroup);
217
221
  });
218
222
  } else {
219
223
  const oCoverPageGroup = {
220
- "Title": oGroup.name,
221
- "Content": []
224
+ Title: oGroup.name,
225
+ Content: []
222
226
  };
223
227
 
224
- oGroup.items.forEach(function(oItem) {
225
- oCoverPageGroup["Content"].push({
226
- "Name": oItem.key,
227
- "Value": oItem.value
228
+ oGroup.items.forEach((oItem) => {
229
+ oCoverPageGroup.Content.push({
230
+ Name: oItem.key,
231
+ Value: oItem.value
228
232
  });
229
233
  });
230
- oDocumentDescription["CoverPage"].push(oCoverPageGroup);
234
+ oDocumentDescription.CoverPage.push(oCoverPageGroup);
231
235
  }
232
236
  });
233
237
  }
@@ -235,63 +239,76 @@ sap.ui.define([
235
239
 
236
240
  /* FitToPage */
237
241
  if (this._mCapabilities.FitToPage) {
238
- oDocumentDescription.Format["FitToPage"] = {
239
- "IsEnabled": mSettings.fitToPage,
240
- "MinimumFontSize": 4
242
+ oDocumentDescription.Format.FitToPage = {
243
+ IsEnabled: mSettings.fitToPage,
244
+ MinimumFontSize: 4
241
245
  };
242
246
  }
243
247
 
244
248
  /* FontSize */
245
249
  if (this._mCapabilities.FontSize) {
246
- oDocumentDescription.Format["FontSize"] = Number(mSettings.fontSize);
250
+ oDocumentDescription.Format.FontSize = Number(mSettings.fontSize);
247
251
  }
248
252
 
249
253
  /* HeaderFooter */
250
254
  if (this._mCapabilities.HeaderFooter && mSettings.showPageNumber) {
251
- oDocumentDescription["Footer"] = {
252
- "Center": {
253
- "Type": "PAGENUM"
255
+ oDocumentDescription.Footer = {
256
+ Center: {
257
+ Type: "PAGENUM"
254
258
  }
255
259
  };
256
260
  }
257
261
 
258
262
  /* Signature */
259
263
  if (this._mCapabilities.Signature) {
260
- oDocumentDescription["Signature"] = {
261
- "DoSign": mSettings.signature,
262
- "Reason": mSettings.signatureReason
264
+ oDocumentDescription.Signature = {
265
+ DoSign: mSettings.signature,
266
+ Reason: mSettings.signatureReason
263
267
  };
264
268
  }
265
269
 
270
+ /* TextDirectionLayout */
271
+ if (this._mCapabilities.TextDirectionLayout) {
272
+ oDocumentDescription.Format.TextDirectionLayout = Localization.getRTL() ? "RTL" : "LTR";
273
+ }
274
+
266
275
  /* Treeview */
267
276
  if (this._mCapabilities.Treeview && oWorkbook.hierarchyLevel && oWorkbook.drillState) {
268
277
  if (iODataVersion === 2) {
269
- oDocumentDescription["Hierarchy"] = {
270
- "DistanceFromRootElement": oWorkbook.hierarchyLevel,
271
- "DrillStateElement": oWorkbook.drillState
278
+ oDocumentDescription.Hierarchy = {
279
+ DistanceFromRootElement: oWorkbook.hierarchyLevel,
280
+ DrillStateElement: oWorkbook.drillState
272
281
  };
273
282
  } else {
274
- oDocumentDescription.Format["TableFormat"] = "TREE";
283
+ oDocumentDescription.Format.TableFormat = "TREE";
275
284
  }
276
285
  }
277
286
 
287
+ if (this._mCapabilities.UploadToFileShare && this._mCloudFileInfo) {
288
+ oDocumentDescription.FileName = this._mCloudFileInfo.FileShareItemName;
289
+ oDocumentDescription.FileShare = {
290
+ Repository: this._mCloudFileInfo.FileShare,
291
+ Folder: this._mCloudFileInfo.ParentFileShareItem
292
+ };
293
+ }
294
+
278
295
  /* Eliminate duplicate or unknown columns before adding them to the DocumentDescription */
279
- oWorkbook.columns.filter(function(oColumn, iIndex, aArray) {
280
- var sProperty = Array.isArray(oColumn.property) ? oColumn.property[0] : oColumn.property;
296
+ oWorkbook.columns.filter((oColumn, iIndex, aArray) => {
297
+ const sProperty = Array.isArray(oColumn.property) ? oColumn.property[0] : oColumn.property;
281
298
 
282
299
  if (!sProperty) {
283
300
  return false;
284
301
  }
285
302
 
286
- return aArray.findIndex(function(oOtherColumn) {
287
- var sOtherProperty = Array.isArray(oOtherColumn.property) ? oOtherColumn.property[0] : oOtherColumn.property;
303
+ return aArray.findIndex((oOtherColumn) => {
304
+ const sOtherProperty = Array.isArray(oOtherColumn.property) ? oOtherColumn.property[0] : oOtherColumn.property;
288
305
 
289
306
  return sProperty === sOtherProperty;
290
307
  }) === iIndex;
291
308
  }).forEach((oColumnSettings) => {
292
309
  const oColumn = {
293
- "Name": Array.isArray(oColumnSettings.property) ? oColumnSettings.property[0] : oColumnSettings.property,
294
- "Header": oColumnSettings.label
310
+ Name: Array.isArray(oColumnSettings.property) ? oColumnSettings.property[0] : oColumnSettings.property,
311
+ Header: oColumnSettings.label
295
312
  };
296
313
 
297
314
  if (this._mCapabilities.IANATimezoneFormat && oColumnSettings.type === EdmType.DateTime) {
@@ -321,15 +338,14 @@ sap.ui.define([
321
338
  * @private
322
339
  */
323
340
  PortableDocument.prototype._getEntitySetName = function(mDataSource) {
324
- var sCollectionName, iVersion;
325
-
326
- iVersion = mDataSource && mDataSource.version || 2; // Use OData V2 by default
341
+ let sCollectionName;
342
+ const iVersion = mDataSource?.version || 2; // Use OData V2 by default
327
343
 
328
- if (this._mCapabilities && typeof this._mCapabilities.DocumentDescriptionCollection === 'string') {
344
+ if (this._mCapabilities && typeof this._mCapabilities.DocumentDescriptionCollection === "string") {
329
345
  sCollectionName = this._mCapabilities.DocumentDescriptionCollection;
330
346
  }
331
347
 
332
- return sCollectionName || (iVersion == 4 ? 'MyDocumentDescriptions' : 'SAP__MyDocumentDescriptions');
348
+ return sCollectionName || (iVersion == 4 ? "MyDocumentDescriptions" : "SAP__MyDocumentDescriptions");
333
349
  };
334
350
 
335
351
  /**
@@ -341,7 +357,7 @@ sap.ui.define([
341
357
  * @private
342
358
  */
343
359
  PortableDocument.prototype._getModel = function(oDataSource) {
344
- var iVersion = oDataSource.version || 2;
360
+ const iVersion = oDataSource.version || 2;
345
361
 
346
362
  return iVersion === 4 ? new ODataModel({
347
363
  serviceUrl: oDataSource.serviceUrl
@@ -361,16 +377,13 @@ sap.ui.define([
361
377
  * @private
362
378
  */
363
379
  PortableDocument.prototype._showWarning = function(mSettings) {
364
- var mParams, oWarningPromise;
365
-
366
- mParams = {
380
+ let oWarningPromise = Promise.resolve();
381
+ const mParams = {
367
382
  rows: mSettings.dataSource.count,
368
383
  rowLimit: this._mCapabilities.ResultSizeMaximum,
369
384
  fileType: FileType.PDF
370
385
  };
371
386
 
372
- oWarningPromise = Promise.resolve();
373
-
374
387
  if (isNaN(mParams.rows) || (mParams.rows > mParams.rowLimit)) {
375
388
  oWarningPromise = ExportDialog.showWarningDialog(mParams);
376
389
  }
@@ -392,13 +405,13 @@ sap.ui.define([
392
405
  return;
393
406
  }
394
407
 
395
- if (typeof vError.text === 'function') {
408
+ if (typeof vError.text === "function") {
396
409
  vError.text()
397
- .then(function(sError) {
410
+ .then((sError) => {
398
411
  ExportDialog.showErrorMessage(sError);
399
412
  })
400
- .catch(function() {
401
- ExportDialog.showErrorMessage(oResourceBundle.getText('PDF_GENERIC_ERROR'));
413
+ .catch(() => {
414
+ ExportDialog.showErrorMessage(oResourceBundle.getText("PDF_GENERIC_ERROR"));
402
415
  });
403
416
  } else if (vError.message) {
404
417
  ExportDialog.showErrorMessage(vError.message);
@@ -416,14 +429,12 @@ sap.ui.define([
416
429
  * annotation.
417
430
  */
418
431
  PortableDocument.prototype._applyResultSize = function(sUrl) {
419
- var iLimit, mDataUrl;
420
-
421
- iLimit = parseInt(this._mCapabilities.ResultSizeMaximum);
432
+ const iLimit = parseInt(this._mCapabilities.ResultSizeMaximum);
422
433
 
423
434
  if (!isNaN(iLimit) && iLimit > 0) {
435
+ const mDataUrl = new URL(sUrl);
424
436
 
425
- mDataUrl = new URL(sUrl);
426
- mDataUrl.search += '&$top=' + iLimit;
437
+ mDataUrl.search += "&$top=" + iLimit;
427
438
  sUrl = mDataUrl.toString();
428
439
  }
429
440
 
@@ -439,18 +450,18 @@ sap.ui.define([
439
450
  * @private
440
451
  */
441
452
  PortableDocument.prototype.setDefaultExportSettings = function(mSettings) {
442
- var oContext = mSettings && mSettings.workbook && mSettings.workbook.context;
453
+ let oContext = mSettings?.workbook?.context;
443
454
 
444
455
  if (!(oContext instanceof Object)) {
445
456
  oContext = mSettings.workbook.context = {};
446
457
  }
447
458
 
448
- if (typeof oContext.title === 'string' && oContext.title) {
459
+ if (typeof oContext.title === "string" && oContext.title) {
449
460
  return Promise.resolve();
450
461
  }
451
462
 
452
- return ExportUtils.getResourceBundle().then(function(oResourceBundle) {
453
- oContext.title = oResourceBundle.getText('XLSX_DEFAULT_TITLE');
463
+ return ExportUtils.getResourceBundle().then((oResourceBundle) => {
464
+ oContext.title = oResourceBundle.getText("XLSX_DEFAULT_TITLE");
454
465
  });
455
466
  };
456
467
 
@@ -467,25 +478,21 @@ sap.ui.define([
467
478
  * @private
468
479
  */
469
480
  PortableDocument.prototype.postDocumentDescription = function(oDocumentDescription, oDataSource) {
470
- var oBinding, oModel, sPath;
481
+ const oModel = this._getModel(oDataSource);
482
+ const sPath = "/" + this._getEntitySetName(oDataSource);
471
483
 
472
- oModel = this._getModel(oDataSource);
473
- sPath = '/' + this._getEntitySetName(oDataSource);
474
-
475
- if (!oModel || !oModel.isA(['sap.ui.model.odata.v4.ODataModel', 'sap.ui.model.odata.v2.ODataModel'])) {
476
- return Promise.reject('Unsupported Model');
484
+ if (!oModel || !oModel.isA(["sap.ui.model.odata.v4.ODataModel", "sap.ui.model.odata.v2.ODataModel"])) {
485
+ return Promise.reject("Unsupported Model");
477
486
  }
478
487
 
479
- return new Promise(function(fnResolve, fnReject) {
480
-
481
- if (oModel.isA('sap.ui.model.odata.v4.ODataModel')) {
482
- oBinding = oModel.bindList(sPath);
488
+ return new Promise((fnResolve, fnReject) => {
483
489
 
484
- oBinding.attachCreateCompleted(function(oEvent) {
485
- var success = oEvent.getParameter('success');
490
+ if (oModel.isA("sap.ui.model.odata.v4.ODataModel")) {
491
+ const oBinding = oModel.bindList(sPath);
486
492
 
487
- if (success) {
488
- fnResolve(oEvent.getParameter('context').getObject()['Id']);
493
+ oBinding.attachCreateCompleted((oEvent) => {
494
+ if (oEvent.getParameter("success")) {
495
+ fnResolve(oEvent.getParameter("context").getObject()["Id"]);
489
496
  } else {
490
497
  fnReject();
491
498
  }
@@ -493,15 +500,15 @@ sap.ui.define([
493
500
 
494
501
  oBinding.create(oDocumentDescription);
495
502
  } else {
496
- var bUseBatch = oModel.bUseBatch;
503
+ const bUseBatch = oModel.bUseBatch;
497
504
 
498
505
  oModel.setUseBatch(false);
499
506
  oModel.create(sPath, oDocumentDescription, {
500
- success: function(oData) {
507
+ success: (oData) => {
501
508
  oModel.setUseBatch(bUseBatch);
502
- fnResolve(oData['Id']);
509
+ fnResolve(oData["Id"]);
503
510
  },
504
- error: function(oError) {
511
+ error: (oError) => {
505
512
  oModel.setUseBatch(bUseBatch);
506
513
  fnReject(oError);
507
514
  }
@@ -523,12 +530,12 @@ sap.ui.define([
523
530
  const oResourceBundle = await ExportUtils.getResourceBundle();
524
531
  const oDocumentDescription = this._createDocumentDescription(mSettings);
525
532
 
526
- let oBusyDialog = new BusyDialog('PDFExportBusyDialog', {
527
- title: oResourceBundle.getText('PROGRESS_TITLE'),
528
- text: oResourceBundle.getText('PDF_GENERATION_IN_PROGRESS'),
533
+ let oBusyDialog = new BusyDialog("PDFExportBusyDialog", {
534
+ title: oResourceBundle.getText("PROGRESS_TITLE"),
535
+ text: oResourceBundle.getText("PDF_GENERATION_IN_PROGRESS"),
529
536
  showCancelButton: true,
530
537
  close: (oEvent) => {
531
- if (oEvent.getParameter('cancelPressed')) {
538
+ if (oEvent.getParameter("cancelPressed")) {
532
539
  this.cancel();
533
540
  }
534
541
 
@@ -541,6 +548,8 @@ sap.ui.define([
541
548
 
542
549
  try {
543
550
  await this._showWarning(mSettings);
551
+ this._request = new AbortController();
552
+
544
553
  const sDocumentDescriptionId = await this.postDocumentDescription(oDocumentDescription, mSettings.dataSource);
545
554
  const response = await this.sendRequest(mSettings.dataSource.dataUrl, sDocumentDescriptionId);
546
555
 
@@ -562,38 +571,39 @@ sap.ui.define([
562
571
  *
563
572
  * @private
564
573
  */
565
- PortableDocument.prototype.sendRequest = function(sUrl, sDocumentDescriptionId) {
566
- sUrl = this._applyResultSize(sUrl);
567
-
568
- return new Promise(function(fnResolve, fnReject) {
569
- var oXHR = this.request = new XMLHttpRequest();
570
-
571
- /* Send GET request to receive PDF file */
572
- oXHR.open('GET', sUrl);
573
- oXHR.responseType = 'blob';
574
- oXHR.setRequestHeader('Accept', this.getMimeType());
575
- oXHR.setRequestHeader('SAP-Document-Description-Id', sDocumentDescriptionId);
576
-
577
- oXHR.addEventListener('abort', function() {
578
- fnReject(null);
579
- });
580
-
581
- oXHR.addEventListener('error', function() {
582
- fnReject('Error occured while requesting data');
583
- });
574
+ PortableDocument.prototype.sendRequest = async function(sUrl, sDocumentDescriptionId) {
575
+ if (this._request?.signal.aborted) {
576
+ throw null; // Explicitly reject the Promise without an error to indicate prior user cancellation
577
+ }
584
578
 
585
- oXHR.addEventListener('load', function() {
586
- var status = oXHR.status;
579
+ sUrl = this._applyResultSize(sUrl);
587
580
 
588
- if (status >= 200 && status < 400) {
589
- fnResolve(oXHR.response);
590
- } else {
591
- fnReject(oXHR.response);
581
+ try {
582
+ const response = await fetch(sUrl, {
583
+ signal: this._request?.signal,
584
+ headers: {
585
+ "Accept": this.getMimeType(),
586
+ "SAP-Document-Description-Id": sDocumentDescriptionId
592
587
  }
593
588
  });
594
589
 
595
- oXHR.send();
596
- }.bind(this));
590
+ if (response.redirected && response.url !== sUrl) {
591
+ openWindow(response.url, "_blank");
592
+ return undefined;
593
+ }
594
+
595
+ if (response.ok) {
596
+ return response.blob();
597
+ } else {
598
+ throw response.text();
599
+ }
600
+ } catch (oError) {
601
+ if (oError.name === "AbortError") {
602
+ throw null; // Explicitly reject the Promise without an error to indicate user cancellation
603
+ } else {
604
+ throw oError; // Technical request error
605
+ }
606
+ }
597
607
  };
598
608
 
599
609
  /**
@@ -605,7 +615,7 @@ sap.ui.define([
605
615
  * @public
606
616
  */
607
617
  PortableDocument.prototype.getMimeType = function() {
608
- return 'application/pdf';
618
+ return "application/pdf";
609
619
  };
610
620
 
611
621
  /**
@@ -617,10 +627,7 @@ sap.ui.define([
617
627
  * @public
618
628
  */
619
629
  PortableDocument.prototype.cancel = function() {
620
- if (this.request && this.request.readyState != XMLHttpRequest.DONE) {
621
- this.request.abort();
622
- this.request = null;
623
- }
630
+ this._request?.abort();
624
631
  };
625
632
 
626
633
  /**
@@ -634,6 +641,7 @@ sap.ui.define([
634
641
  PortableDocument.prototype.destroy = function() {
635
642
  ExportBase.prototype.destroy.apply(this, arguments);
636
643
 
644
+ this._request = null;
637
645
  this._oModel = null;
638
646
  };
639
647
 
@@ -90,7 +90,7 @@ sap.ui.define([
90
90
  * <li><code>workbook.context</code> - Context object that will be applied to the generated file. It may contain the following fields:</li>
91
91
  * <ul>
92
92
  * <li><code>application</code> (string) - The application that creates the XLSX document (default: "SAP UI5")</li>
93
- * <li><code>version</code> (string) - Application version that creates the XLSX document (default: "1.129.0")</li>
93
+ * <li><code>version</code> (string) - Application version that creates the XLSX document (default: "1.130.0")</li>
94
94
  * <li><code>title</code> (string) - Title of the XLSX document (NOT the filename)</li>
95
95
  * <li><code>modifiedBy</code> (string) - User context for the XLSX document</li>
96
96
  * <li><code>sheetName</code> (string) - The label of the data sheet</li>
@@ -174,7 +174,7 @@ sap.ui.define([
174
174
  * columns: aColumns,
175
175
  * context: {
176
176
  * application: 'Debug Test Application',
177
- * version: '1.129.0',
177
+ * version: '1.130.0',
178
178
  * title: 'Some random title',
179
179
  * modifiedBy: 'John Doe',
180
180
  * metaSheetName: 'Custom metadata',
@@ -286,7 +286,7 @@ sap.ui.define([
286
286
  * @class The <code>sap.ui.export.Spreadsheet</code> class allows you to export table data from a UI5 application to a spreadsheet file.
287
287
  *
288
288
  * @author SAP SE
289
- * @version 1.129.0
289
+ * @version 1.130.0
290
290
  *
291
291
  * @since 1.50
292
292
  * @alias sap.ui.export.Spreadsheet
@@ -21,7 +21,7 @@ sap.ui.define(['sap/base/Log', 'sap/ui/export/ExportUtils'], function(Log, Expor
21
21
  * Utility class to perform spreadsheet export.
22
22
  *
23
23
  * @author SAP SE
24
- * @version 1.129.0
24
+ * @version 1.130.0
25
25
  *
26
26
  * @alias sap.ui.export.SpreadsheetExport
27
27
  * @private