excel.cell_alignment_helper.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * DevExtreme (exporter/excel/excel.cell_alignment_helper.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. Object.defineProperty(exports, "__esModule", {
  11. value: true
  12. });
  13. var _type = require("../../core/utils/type");
  14. var _excel = require("./excel.tag_helper");
  15. var _excel2 = _interopRequireDefault(_excel);
  16. function _interopRequireDefault(obj) {
  17. return obj && obj.__esModule ? obj : {
  18. "default": obj
  19. }
  20. }
  21. var cellAlignmentHelper = {
  22. tryCreateTag: function(sourceObj) {
  23. var result = null;
  24. if ((0, _type.isDefined)(sourceObj)) {
  25. result = {
  26. vertical: sourceObj.vertical,
  27. wrapText: sourceObj.wrapText,
  28. horizontal: sourceObj.horizontal
  29. };
  30. if (cellAlignmentHelper.isEmpty(result)) {
  31. result = null
  32. }
  33. }
  34. return result
  35. },
  36. copy: function(source) {
  37. var result = null;
  38. if ((0, _type.isDefined)(source)) {
  39. result = {};
  40. if (void 0 !== source.horizontal) {
  41. result.horizontal = source.horizontal
  42. }
  43. if (void 0 !== source.vertical) {
  44. result.vertical = source.vertical
  45. }
  46. if (void 0 !== source.wrapText) {
  47. result.wrapText = source.wrapText
  48. }
  49. }
  50. return result
  51. },
  52. areEqual: function(leftTag, rightTag) {
  53. return cellAlignmentHelper.isEmpty(leftTag) && cellAlignmentHelper.isEmpty(rightTag) || (0, _type.isDefined)(leftTag) && (0, _type.isDefined)(rightTag) && leftTag.vertical === rightTag.vertical && leftTag.wrapText === rightTag.wrapText && leftTag.horizontal === rightTag.horizontal
  54. },
  55. isEmpty: function(tag) {
  56. return !(0, _type.isDefined)(tag) || !(0, _type.isDefined)(tag.vertical) && !(0, _type.isDefined)(tag.wrapText) && !(0, _type.isDefined)(tag.horizontal)
  57. },
  58. toXml: function(tag) {
  59. return _excel2.default.toXml("alignment", {
  60. vertical: tag.vertical,
  61. wrapText: (0, _type.isDefined)(tag.wrapText) ? Number(tag.wrapText) : void 0,
  62. horizontal: tag.horizontal
  63. })
  64. }
  65. };
  66. exports.default = cellAlignmentHelper;