@syncfusion/ej2-gantt 19.4.55 → 20.1.47-1460716

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.
Files changed (212) hide show
  1. package/CHANGELOG.md +1072 -1047
  2. package/README.md +75 -75
  3. package/dist/ej2-gantt.umd.min.js +1 -10
  4. package/dist/ej2-gantt.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-gantt.es2015.js +341 -240
  6. package/dist/es6/ej2-gantt.es2015.js.map +1 -1
  7. package/dist/es6/ej2-gantt.es5.js +713 -598
  8. package/dist/es6/ej2-gantt.es5.js.map +1 -1
  9. package/dist/global/ej2-gantt.min.js +1 -10
  10. package/dist/global/ej2-gantt.min.js.map +1 -1
  11. package/dist/global/index.d.ts +0 -9
  12. package/dist/ts/components.ts +4 -0
  13. package/dist/ts/gantt/actions/actions.ts +18 -0
  14. package/dist/ts/gantt/actions/cell-edit.ts +606 -0
  15. package/dist/ts/gantt/actions/chart-scroll.ts +167 -0
  16. package/dist/ts/gantt/actions/column-menu.ts +35 -0
  17. package/dist/ts/gantt/actions/column-reorder.ts +52 -0
  18. package/dist/ts/gantt/actions/column-resize.ts +52 -0
  19. package/dist/ts/gantt/actions/connector-line-edit.ts +829 -0
  20. package/dist/ts/gantt/actions/context-menu.ts +754 -0
  21. package/dist/ts/gantt/actions/day-markers.ts +80 -0
  22. package/dist/ts/gantt/actions/dependency.ts +692 -0
  23. package/dist/ts/gantt/actions/dialog-edit.ts +2208 -0
  24. package/dist/ts/gantt/actions/edit.ts +3499 -0
  25. package/dist/ts/gantt/actions/excel-export.ts +61 -0
  26. package/dist/ts/gantt/actions/filter.ts +302 -0
  27. package/dist/ts/gantt/actions/keyboard.ts +306 -0
  28. package/dist/ts/gantt/actions/pdf-export.ts +214 -0
  29. package/dist/ts/gantt/actions/rowdragdrop.ts +839 -0
  30. package/dist/ts/gantt/actions/selection.ts +536 -0
  31. package/dist/ts/gantt/actions/sort.ts +98 -0
  32. package/dist/ts/gantt/actions/taskbar-edit.ts +1940 -0
  33. package/dist/ts/gantt/actions/toolbar.ts +489 -0
  34. package/dist/ts/gantt/actions/virtual-scroll.ts +60 -0
  35. package/dist/ts/gantt/base/common.ts +9 -0
  36. package/dist/ts/gantt/base/constant.ts +13 -0
  37. package/dist/ts/gantt/base/css-constants.ts +148 -0
  38. package/dist/ts/gantt/base/date-processor.ts +1257 -0
  39. package/dist/ts/gantt/base/enum.ts +372 -0
  40. package/dist/ts/gantt/base/gantt-chart.ts +1248 -0
  41. package/dist/ts/gantt/base/gantt.ts +4069 -0
  42. package/dist/ts/gantt/base/interface.ts +955 -0
  43. package/dist/ts/gantt/base/splitter.ts +174 -0
  44. package/dist/ts/gantt/base/task-processor.ts +2217 -0
  45. package/dist/ts/gantt/base/tree-grid.ts +694 -0
  46. package/dist/ts/gantt/base/utils.ts +208 -0
  47. package/dist/ts/gantt/export/export-helper.ts +552 -0
  48. package/dist/ts/gantt/export/pdf-base/dictionary.ts +152 -0
  49. package/dist/ts/gantt/export/pdf-base/pdf-borders.ts +277 -0
  50. package/dist/ts/gantt/export/pdf-base/pdf-grid-table.ts +901 -0
  51. package/dist/ts/gantt/export/pdf-base/pdf-style/gantt-theme.ts +131 -0
  52. package/dist/ts/gantt/export/pdf-base/pdf-style/style.ts +91 -0
  53. package/dist/ts/gantt/export/pdf-base/treegrid-layouter.ts +414 -0
  54. package/dist/ts/gantt/export/pdf-connector-line.ts +422 -0
  55. package/dist/ts/gantt/export/pdf-gantt.ts +282 -0
  56. package/dist/ts/gantt/export/pdf-taskbar.ts +395 -0
  57. package/dist/ts/gantt/export/pdf-timeline.ts +202 -0
  58. package/dist/ts/gantt/export/pdf-treegrid.ts +406 -0
  59. package/dist/ts/gantt/models/add-dialog-field-settings.ts +33 -0
  60. package/dist/ts/gantt/models/column.ts +464 -0
  61. package/dist/ts/gantt/models/day-working-time.ts +22 -0
  62. package/dist/ts/gantt/models/edit-dialog-field-settings.ts +33 -0
  63. package/dist/ts/gantt/models/edit-settings.ts +79 -0
  64. package/dist/ts/gantt/models/event-marker.ts +27 -0
  65. package/dist/ts/gantt/models/filter-settings.ts +53 -0
  66. package/dist/ts/gantt/models/holiday.ts +34 -0
  67. package/dist/ts/gantt/models/label-settings.ts +30 -0
  68. package/dist/ts/gantt/models/models.ts +36 -0
  69. package/dist/ts/gantt/models/resource-fields.ts +38 -0
  70. package/dist/ts/gantt/models/search-settings.ts +77 -0
  71. package/dist/ts/gantt/models/selection-settings.ts +56 -0
  72. package/dist/ts/gantt/models/sort-settings.ts +50 -0
  73. package/dist/ts/gantt/models/splitter-settings.ts +47 -0
  74. package/dist/ts/gantt/models/task-fields.ts +171 -0
  75. package/dist/ts/gantt/models/timeline-settings.ts +112 -0
  76. package/dist/ts/gantt/models/tooltip-settings.ts +46 -0
  77. package/dist/ts/gantt/renderer/chart-rows.ts +1838 -0
  78. package/dist/ts/gantt/renderer/connector-line.ts +1025 -0
  79. package/dist/ts/gantt/renderer/edit-tooltip.ts +228 -0
  80. package/dist/ts/gantt/renderer/event-marker.ts +96 -0
  81. package/dist/ts/gantt/renderer/nonworking-day.ts +205 -0
  82. package/dist/ts/gantt/renderer/render.ts +5 -0
  83. package/dist/ts/gantt/renderer/timeline.ts +1397 -0
  84. package/dist/ts/gantt/renderer/tooltip.ts +450 -0
  85. package/dist/ts/gantt/renderer/virtual-content-render.ts +50 -0
  86. package/license +9 -9
  87. package/package.json +80 -80
  88. package/src/gantt/actions/cell-edit.js +2 -1
  89. package/src/gantt/actions/dialog-edit.js +2 -1
  90. package/src/gantt/actions/edit.js +36 -9
  91. package/src/gantt/actions/rowdragdrop.js +37 -15
  92. package/src/gantt/actions/selection.js +3 -2
  93. package/src/gantt/actions/taskbar-edit.js +24 -24
  94. package/src/gantt/base/date-processor.js +0 -1
  95. package/src/gantt/base/gantt-chart.js +36 -5
  96. package/src/gantt/base/gantt-model.d.ts +779 -779
  97. package/src/gantt/base/gantt.d.ts +27 -27
  98. package/src/gantt/base/gantt.js +35 -76
  99. package/src/gantt/base/splitter.js +1 -0
  100. package/src/gantt/base/task-processor.js +13 -13
  101. package/src/gantt/base/tree-grid.js +3 -1
  102. package/src/gantt/export/pdf-base/treegrid-layouter.js +13 -13
  103. package/src/gantt/export/pdf-connector-line.js +11 -11
  104. package/src/gantt/export/pdf-gantt.js +24 -24
  105. package/src/gantt/export/pdf-taskbar.js +11 -11
  106. package/src/gantt/export/pdf-treegrid.js +13 -13
  107. package/src/gantt/models/add-dialog-field-settings-model.d.ts +21 -21
  108. package/src/gantt/models/add-dialog-field-settings.js +19 -19
  109. package/src/gantt/models/day-working-time-model.d.ts +11 -11
  110. package/src/gantt/models/day-working-time.js +19 -19
  111. package/src/gantt/models/edit-dialog-field-settings-model.d.ts +21 -21
  112. package/src/gantt/models/edit-dialog-field-settings.js +19 -19
  113. package/src/gantt/models/edit-settings-model.d.ts +50 -50
  114. package/src/gantt/models/edit-settings.js +19 -19
  115. package/src/gantt/models/event-marker-model.d.ts +16 -16
  116. package/src/gantt/models/event-marker.js +19 -19
  117. package/src/gantt/models/filter-settings-model.d.ts +34 -34
  118. package/src/gantt/models/filter-settings.js +19 -19
  119. package/src/gantt/models/holiday-model.d.ts +21 -21
  120. package/src/gantt/models/holiday.js +19 -19
  121. package/src/gantt/models/label-settings-model.d.ts +16 -16
  122. package/src/gantt/models/label-settings.js +19 -19
  123. package/src/gantt/models/resource-fields-model.d.ts +21 -21
  124. package/src/gantt/models/resource-fields.js +19 -19
  125. package/src/gantt/models/search-settings-model.d.ts +56 -56
  126. package/src/gantt/models/search-settings.js +19 -19
  127. package/src/gantt/models/selection-settings-model.d.ts +35 -35
  128. package/src/gantt/models/selection-settings.js +19 -19
  129. package/src/gantt/models/sort-settings-model.d.ts +24 -24
  130. package/src/gantt/models/sort-settings.js +19 -19
  131. package/src/gantt/models/splitter-settings-model.d.ts +30 -30
  132. package/src/gantt/models/splitter-settings.js +19 -19
  133. package/src/gantt/models/task-fields-model.d.ts +110 -110
  134. package/src/gantt/models/task-fields.js +19 -19
  135. package/src/gantt/models/timeline-settings-model.d.ts +71 -71
  136. package/src/gantt/models/timeline-settings.js +19 -19
  137. package/src/gantt/models/tooltip-settings-model.d.ts +26 -26
  138. package/src/gantt/models/tooltip-settings.js +19 -19
  139. package/src/gantt/renderer/chart-rows.js +49 -37
  140. package/src/gantt/renderer/connector-line.js +22 -18
  141. package/src/gantt/renderer/event-marker.js +1 -0
  142. package/src/gantt/renderer/nonworking-day.js +13 -6
  143. package/src/gantt/renderer/timeline.d.ts +1 -0
  144. package/src/gantt/renderer/timeline.js +51 -12
  145. package/src/gantt/renderer/tooltip.js +11 -3
  146. package/styles/bootstrap-dark.css +442 -427
  147. package/styles/bootstrap.css +442 -433
  148. package/styles/bootstrap4.css +454 -479
  149. package/styles/bootstrap5-dark.css +457 -433
  150. package/styles/bootstrap5.css +457 -433
  151. package/styles/fabric-dark.css +438 -421
  152. package/styles/fabric.css +445 -428
  153. package/styles/fluent-dark.css +1938 -0
  154. package/styles/fluent-dark.scss +1 -0
  155. package/styles/fluent.css +1938 -0
  156. package/styles/fluent.scss +1 -0
  157. package/styles/gantt/_all.scss +2 -2
  158. package/styles/gantt/_bootstrap-dark-definition.scss +210 -156
  159. package/styles/gantt/_bootstrap-definition.scss +211 -157
  160. package/styles/gantt/_bootstrap4-definition.scss +213 -158
  161. package/styles/gantt/_bootstrap5-definition.scss +215 -162
  162. package/styles/gantt/_fabric-dark-definition.scss +211 -157
  163. package/styles/gantt/_fabric-definition.scss +211 -157
  164. package/styles/gantt/_fluent-dark-definition.scss +1 -0
  165. package/styles/gantt/_fluent-definition.scss +215 -162
  166. package/styles/gantt/_fusionnew-definition.scss +214 -0
  167. package/styles/gantt/_highcontrast-definition.scss +211 -157
  168. package/styles/gantt/_highcontrast-light-definition.scss +211 -157
  169. package/styles/gantt/_layout.scss +1446 -1027
  170. package/styles/gantt/_material-dark-definition.scss +212 -157
  171. package/styles/gantt/_material-definition.scss +212 -157
  172. package/styles/gantt/_material3-definition.scss +215 -0
  173. package/styles/gantt/_tailwind-definition.scss +215 -161
  174. package/styles/gantt/_theme.scss +702 -668
  175. package/styles/gantt/bootstrap-dark.css +442 -427
  176. package/styles/gantt/bootstrap.css +442 -433
  177. package/styles/gantt/bootstrap4.css +454 -479
  178. package/styles/gantt/bootstrap5-dark.css +457 -433
  179. package/styles/gantt/bootstrap5.css +457 -433
  180. package/styles/gantt/fabric-dark.css +438 -421
  181. package/styles/gantt/fabric.css +445 -428
  182. package/styles/gantt/fluent-dark.css +1938 -0
  183. package/styles/gantt/fluent-dark.scss +22 -0
  184. package/styles/gantt/fluent.css +1938 -0
  185. package/styles/gantt/fluent.scss +22 -0
  186. package/styles/gantt/highcontrast-light.css +405 -405
  187. package/styles/gantt/highcontrast.css +444 -456
  188. package/styles/gantt/icons/_bootstrap-dark.scss +124 -113
  189. package/styles/gantt/icons/_bootstrap.scss +124 -113
  190. package/styles/gantt/icons/_bootstrap4.scss +124 -113
  191. package/styles/gantt/icons/_bootstrap5.scss +124 -112
  192. package/styles/gantt/icons/_fabric-dark.scss +124 -112
  193. package/styles/gantt/icons/_fabric.scss +124 -112
  194. package/styles/gantt/icons/_fluent-dark.scss +1 -0
  195. package/styles/gantt/icons/_fluent.scss +124 -112
  196. package/styles/gantt/icons/_fusionnew.scss +120 -0
  197. package/styles/gantt/icons/_highcontrast.scss +124 -112
  198. package/styles/gantt/icons/_material-dark.scss +124 -112
  199. package/styles/gantt/icons/_material.scss +124 -112
  200. package/styles/gantt/icons/_material3.scss +124 -0
  201. package/styles/gantt/icons/_tailwind-dark.scss +124 -113
  202. package/styles/gantt/icons/_tailwind.scss +124 -113
  203. package/styles/gantt/material-dark.css +446 -417
  204. package/styles/gantt/material.css +445 -419
  205. package/styles/gantt/tailwind-dark.css +452 -482
  206. package/styles/gantt/tailwind.css +449 -479
  207. package/styles/highcontrast-light.css +405 -405
  208. package/styles/highcontrast.css +444 -456
  209. package/styles/material-dark.css +446 -417
  210. package/styles/material.css +445 -419
  211. package/styles/tailwind-dark.css +452 -482
  212. package/styles/tailwind.css +449 -479
@@ -0,0 +1,131 @@
1
+ import { PdfTheme } from './../../../base/enum';
2
+ import { IGanttStyle } from './../../../base/interface';
3
+ import { PdfColor, PdfFontFamily, PdfStringFormat } from '@syncfusion/ej2-pdf-export';
4
+
5
+ /**
6
+ * @hidden
7
+ */
8
+ export class PdfGanttTheme {
9
+ public ganttStyle: IGanttStyle;
10
+ private theme: PdfTheme;
11
+ constructor(theme: PdfTheme) {
12
+ this.theme = theme;
13
+ this.ganttStyle = {};
14
+ this.setTheme(this.ganttStyle, this.theme);
15
+ }
16
+ public get style(): IGanttStyle {
17
+ if (this.ganttStyle) {
18
+ return this.ganttStyle;
19
+ } else {
20
+ this.setTheme(this.ganttStyle, 'Material');
21
+ return this.ganttStyle;
22
+ }
23
+ }
24
+ private setTheme(ganttStyle: IGanttStyle, theme: PdfTheme): void {
25
+ this.initStyles(ganttStyle);
26
+ ganttStyle.columnHeader.fontSize = 9.5;
27
+ ganttStyle.columnHeader.fontColor = new PdfColor(0, 0, 0);
28
+ ganttStyle.columnHeader.fontColor.gray = 0.2;
29
+ ganttStyle.columnHeader.backgroundColor = new PdfColor(255, 255, 255);
30
+ ganttStyle.columnHeader.borderColor = new PdfColor(234, 234, 234);
31
+ ganttStyle.columnHeader.format.lineAlignment = 1; //Centre
32
+ ganttStyle.columnHeader.format.alignment = 0; //Left
33
+ ganttStyle.fontFamily = PdfFontFamily.Helvetica;
34
+ ganttStyle.cell.fontSize = 9.5;
35
+ ganttStyle.cell.backgroundColor = new PdfColor(255, 255, 255);
36
+ ganttStyle.cell.borderColor = new PdfColor(234, 234, 234);
37
+ ganttStyle.cell.fontColor = new PdfColor(0, 0, 0);
38
+ ganttStyle.cell.fontColor.gray = 0.2;
39
+ ganttStyle.cell.format.lineAlignment = 1; // Centre
40
+ ganttStyle.cell.format.alignment = 0; // Left
41
+ ganttStyle.footer.fontSize = 9.5;
42
+ ganttStyle.footer.fontStyle = 0;
43
+ ganttStyle.footer.format.alignment = 1; //Centre
44
+ ganttStyle.footer.format.lineAlignment = 1; // Middle
45
+ ganttStyle.timeline.fontSize = 9.5;
46
+ ganttStyle.timeline.fontStyle = 0;
47
+ ganttStyle.timeline.backgroundColor = new PdfColor(252, 252, 252);
48
+ ganttStyle.timeline.fontColor = new PdfColor(40, 40, 39);
49
+ ganttStyle.chartGridLineColor = new PdfColor(206, 206, 206);
50
+ ganttStyle.timeline.borderColor = new PdfColor(206, 206, 206);
51
+ switch (theme) {
52
+ case 'Bootstrap':
53
+ //chart side theme
54
+ ganttStyle.taskbar.taskColor = new PdfColor(49, 122, 185);
55
+ ganttStyle.taskbar.progressColor = new PdfColor(33, 82, 125);
56
+ ganttStyle.taskbar.parentTaskColor = new PdfColor(119, 119, 119);
57
+ ganttStyle.taskbar.parentProgressColor = new PdfColor(85, 85, 85);
58
+ ganttStyle.taskbar.taskBorderColor = new PdfColor(33, 82, 125);
59
+ ganttStyle.taskbar.parentTaskBorderColor = new PdfColor(85, 85, 85);
60
+ ganttStyle.taskbar.milestoneColor = new PdfColor(85, 85, 85);
61
+ ganttStyle.footer.fontColor = new PdfColor(0, 0, 0);
62
+ ganttStyle.footer.fontColor.gray = 0.2;
63
+ ganttStyle.connectorLineColor = new PdfColor(33, 82, 125);
64
+ ganttStyle.footer.backgroundColor = new PdfColor(255, 255, 255);
65
+ ganttStyle.taskbar.progressFontColor = new PdfColor(255, 255, 255);
66
+ ganttStyle.label.fontColor = new PdfColor(0, 0, 0);
67
+ break;
68
+ case 'Bootstrap 4':
69
+ //chart side theme
70
+ ganttStyle.taskbar.taskColor = new PdfColor(0, 123, 255);
71
+ ganttStyle.taskbar.progressColor = new PdfColor(0, 86, 179);
72
+ ganttStyle.taskbar.parentTaskColor = new PdfColor(108, 117, 125);
73
+ ganttStyle.taskbar.parentProgressColor = new PdfColor(73, 80, 87);
74
+ ganttStyle.taskbar.taskBorderColor = new PdfColor(0, 86, 179);
75
+ ganttStyle.taskbar.parentTaskBorderColor = new PdfColor(73, 80, 87);
76
+ ganttStyle.taskbar.milestoneColor = new PdfColor(73, 80, 87);
77
+ ganttStyle.footer.fontColor = new PdfColor(0, 0, 0);
78
+ ganttStyle.footer.fontColor.gray = 0.2;
79
+ ganttStyle.connectorLineColor = new PdfColor(0, 86, 179);
80
+ ganttStyle.footer.backgroundColor = new PdfColor(255, 255, 255);
81
+ ganttStyle.taskbar.progressFontColor = new PdfColor(255, 255, 255);
82
+ ganttStyle.label.fontColor = new PdfColor(33, 37, 41);
83
+ break;
84
+ case 'Fabric':
85
+ ganttStyle.columnHeader.fontColor = new PdfColor(102, 102, 102);
86
+ ganttStyle.cell.fontColor = new PdfColor(51, 51, 51);
87
+ //chart side theme
88
+ ganttStyle.taskbar.taskColor = new PdfColor(0, 120, 214);
89
+ ganttStyle.taskbar.progressColor = new PdfColor(0, 91, 163);
90
+ ganttStyle.taskbar.parentTaskColor = new PdfColor(118, 118, 118);
91
+ ganttStyle.taskbar.parentProgressColor = new PdfColor(80, 80, 80);
92
+ ganttStyle.taskbar.taskBorderColor = new PdfColor(0, 91, 163);
93
+ ganttStyle.taskbar.parentTaskBorderColor = new PdfColor(80, 80, 80);
94
+ ganttStyle.taskbar.milestoneColor = new PdfColor(80, 80, 80);
95
+ ganttStyle.footer.fontColor = new PdfColor(51, 51, 51);
96
+ ganttStyle.footer.fontColor.gray = 0.2;
97
+ ganttStyle.connectorLineColor = new PdfColor(0, 69, 122);
98
+ ganttStyle.footer.backgroundColor = new PdfColor(255, 255, 255);
99
+ ganttStyle.taskbar.progressFontColor = new PdfColor(255, 255, 255);
100
+ ganttStyle.label.fontColor = new PdfColor(51, 51, 51);
101
+ break;
102
+ default:
103
+ //chart side theme
104
+ ganttStyle.taskbar.taskColor = new PdfColor(88, 105, 197);
105
+ ganttStyle.taskbar.progressColor = new PdfColor(63, 81, 181);
106
+ ganttStyle.taskbar.parentTaskColor = new PdfColor(132, 132, 132);
107
+ ganttStyle.taskbar.parentProgressColor = new PdfColor(97, 97, 97);
108
+ ganttStyle.taskbar.taskBorderColor = new PdfColor(63, 81, 181);
109
+ ganttStyle.taskbar.parentTaskBorderColor = new PdfColor(51, 51, 51);
110
+ ganttStyle.taskbar.milestoneColor = new PdfColor(97, 97, 97);
111
+ ganttStyle.footer.fontColor = new PdfColor(0, 0, 0);
112
+ ganttStyle.footer.fontColor.gray = 0.2;
113
+ ganttStyle.connectorLineColor = new PdfColor(63, 81, 181);
114
+ ganttStyle.footer.backgroundColor = new PdfColor(255, 255, 255);
115
+ ganttStyle.taskbar.progressFontColor = new PdfColor(255, 255, 255);
116
+ ganttStyle.label.fontColor = new PdfColor(51, 51, 51);
117
+ break;
118
+ }
119
+ }
120
+ private initStyles(ganttStyle: IGanttStyle): void {
121
+ ganttStyle.columnHeader = {};
122
+ ganttStyle.columnHeader.format = new PdfStringFormat();
123
+ ganttStyle.cell = {};
124
+ ganttStyle.cell.format = new PdfStringFormat();
125
+ ganttStyle.timeline = {};
126
+ ganttStyle.footer = {};
127
+ ganttStyle.footer.format = new PdfStringFormat();
128
+ ganttStyle.label = {};
129
+ ganttStyle.taskbar = {};
130
+ }
131
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * PdfGridStyleBase.ts class for EJ2-PDF
3
+ */
4
+ import { PdfBrush, PdfPen, PdfFont, PdfBorderOverlapStyle } from '@syncfusion/ej2-pdf-export';
5
+ import { PdfPaddings } from '../index';
6
+ import { PdfHorizontalOverflowType } from '../../../base/interface';
7
+ /**
8
+ * Base class for the `treegrid style`,
9
+ */
10
+ export abstract class PdfTreeGridStyleBase {
11
+ /**
12
+ * Gets or sets the `background brush`.
13
+ *
14
+ * @private
15
+ */
16
+ public backgroundBrush: PdfBrush;
17
+ /**
18
+ * Gets or sets the `text brush`.
19
+ *
20
+ * @private
21
+ */
22
+ public textBrush: PdfBrush;
23
+ /**
24
+ * Gets or sets the `text pen`.
25
+ *
26
+ * @private
27
+ */
28
+ public textPen: PdfPen;
29
+ /**
30
+ * Gets or sets the `font`.
31
+ *
32
+ * @private
33
+ */
34
+ public font: PdfFont;
35
+ /**
36
+ * Gets or sets the `background Image`.
37
+ *
38
+ * @private
39
+ */
40
+ //public backgroundImage: PdfImage;
41
+ }
42
+ /**
43
+ * `PdfTreeGridStyle` class provides customization of the appearance for the 'PdfGrid'.
44
+ *
45
+ */
46
+ export class PdfTreeGridStyle {
47
+ /**
48
+ * Gets or sets the `border overlap style` of the 'PdfGrid'.
49
+ *
50
+ * @private
51
+ */
52
+ public borderOverlapStyle: PdfBorderOverlapStyle;
53
+ /**
54
+ * Gets or sets the type of the `horizontal overflow` of the 'PdfGrid'.
55
+ *
56
+ * @private
57
+ */
58
+ public horizontalOverflowType: PdfHorizontalOverflowType;
59
+ /**
60
+ * Gets or sets a value indicating whether to `allow horizontal overflow`.
61
+ *
62
+ * @private
63
+ */
64
+ public allowHorizontalOverflow: boolean;
65
+ /**
66
+ * Gets or sets the `cell padding`.
67
+ *
68
+ * @private
69
+ */
70
+ public cellPadding: PdfPaddings;
71
+ /**
72
+ * Gets or sets the `cell spacing` of the 'PdfGrid'.
73
+ *
74
+ * @private
75
+ */
76
+ public cellSpacing: number;
77
+
78
+ //constructor
79
+ /**
80
+ * Initialize a new instance for `PdfGridStyle` class.
81
+ *
82
+ * @private
83
+ */
84
+ public constructor() {
85
+ this.cellSpacing = 0;
86
+ this.borderOverlapStyle = PdfBorderOverlapStyle.Overlap;
87
+ this.allowHorizontalOverflow = false;
88
+ this.horizontalOverflowType = PdfHorizontalOverflowType.LastPage;
89
+ this.cellPadding = new PdfPaddings();
90
+ }
91
+ }
@@ -0,0 +1,414 @@
1
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
2
+ import { PdfBorders, PdfTreeGridColumn, PdfTreeGridRow, PdfTreeGridCell, TemporaryDictionary } from './index';
3
+ import { PdfTreeGrid } from '../pdf-treegrid';
4
+ import { PdfHorizontalOverflowType } from '../../base/interface';
5
+ import {
6
+ ElementLayouter, PdfLayoutResult, PdfLayoutFormat, SizeF, PdfPage, PointF, PdfGraphics,
7
+ RectangleF, PdfLayoutParams, RowLayoutResult, PdfLayoutType, PdfLayoutBreakType
8
+ } from '@syncfusion/ej2-pdf-export';
9
+ import { PdfDocument, PdfSection, PdfStringFormat } from '@syncfusion/ej2-pdf-export';
10
+
11
+ /**
12
+ *
13
+ */
14
+ export class PdfTreeGridLayouter extends ElementLayouter {
15
+ private currentPage: PdfPage;
16
+ private currentGraphics: PdfGraphics;
17
+ private currentPageBounds: SizeF;
18
+ private currentBounds: RectangleF;
19
+ private startLocation: PointF;
20
+ public columnRanges: number[][] = [];
21
+ private cellStartIndex: number;
22
+ private cellEndIndex: number;
23
+ private repeatRowIndex: number = -1;
24
+ private treegridHeight: number;
25
+ constructor(baseFormat: PdfTreeGrid) {
26
+ super(baseFormat);
27
+ this.currentBounds = new RectangleF(0, 0, 0, 0);
28
+ }
29
+ public get treegrid(): PdfTreeGrid {
30
+ return this.elements as PdfTreeGrid;
31
+ }
32
+
33
+ public layoutInternal(param: PdfLayoutParams): PdfLayoutResult {
34
+ if (isNullOrUndefined(param)) {
35
+ throw Error('Argument Null Expection');
36
+ }
37
+ this.currentPage = param.page;
38
+ const format: PdfTreeGridLayoutFormat = param.format;
39
+ if (this.currentPage !== null) {
40
+ this.currentPageBounds = this.currentPage.getClientSize();
41
+ }
42
+ this.currentGraphics = this.currentPage.graphics;
43
+ if (format !== null && format.break === PdfLayoutBreakType.FitColumnsToPage) {
44
+ /* eslint-disable-next-line */
45
+ this.currentBounds = new RectangleF(new PointF(param.bounds.x, param.bounds.y), new SizeF(this.treegrid.columns.width, this.currentGraphics.clientSize.height));
46
+ } else {
47
+ this.currentBounds = new RectangleF(new PointF(param.bounds.x, param.bounds.y), this.currentGraphics.clientSize);
48
+ }
49
+ if (this.treegrid.rows.count !== 0) {
50
+ this.currentBounds.width = (param.bounds.width > 0) ? param.bounds.width :
51
+ (this.currentBounds.width - this.treegrid.rows.getRow(0).cells.getCell(0).style.borders.left.width / 2);
52
+ } else {
53
+ throw Error('Please add row or header into grid');
54
+ }
55
+ this.startLocation = new PointF(param.bounds.x, param.bounds.y);
56
+ if (param.bounds.height > 0) {
57
+ this.currentBounds.height = param.bounds.height;
58
+ }
59
+ if (!this.treegrid.style.allowHorizontalOverflow && !this.treegrid.isFitToWidth) {
60
+ this.treegrid.measureColumnsWidth();
61
+ this.determineColumnDrawRanges();
62
+ } else {
63
+ this.treegrid.measureColumnsWidth(this.currentBounds);
64
+ this.columnRanges.push([0, this.treegrid.columns.count - 1]);
65
+ }
66
+ return this.layoutOnPage(param);
67
+ }
68
+ /**
69
+ * `Determines the column draw ranges`.
70
+ *
71
+ * @returns {void} .
72
+ * @private
73
+ */
74
+ private determineColumnDrawRanges(): void {
75
+ let startColumn: number = 0;
76
+ let endColumn: number = 0;
77
+ let cellWidths: number = 0;
78
+ const availableWidth: number = this.currentGraphics.clientSize.width - this.currentBounds.x;
79
+ for (let i: number = 0; i < this.treegrid.columns.count; i++) {
80
+ cellWidths += this.treegrid.columns.getColumn(i).width;
81
+ if (cellWidths >= availableWidth) {
82
+ let subWidths: number = 0;
83
+ for (let j: number = startColumn; j <= i; j++) {
84
+ subWidths += this.treegrid.columns.getColumn(j).width;
85
+ if (subWidths > availableWidth) {
86
+ break;
87
+ }
88
+ endColumn = j;
89
+ }
90
+ this.columnRanges.push([startColumn, endColumn]);
91
+ startColumn = endColumn + 1;
92
+ //endColumn = startColumn;
93
+ cellWidths = (endColumn <= i) ? this.treegrid.columns.getColumn(i).width : 0;
94
+ }
95
+ }
96
+ this.columnRanges.push([startColumn, this.treegrid.columns.count - 1]);
97
+ }
98
+
99
+ private getFormat(format: PdfLayoutFormat): PdfTreeGridLayoutFormat {
100
+ const f: PdfTreeGridLayoutFormat = format as PdfTreeGridLayoutFormat;
101
+ return f;
102
+ }
103
+
104
+ private layoutOnPage(param: PdfLayoutParams): PdfTreeGridLayoutResult {
105
+ const format: PdfTreeGridLayoutFormat = this.getFormat(param.format);
106
+ let result: PdfTreeGridLayoutResult = null;
107
+ const layoutedPages: TemporaryDictionary<PdfPage, number[]> = new TemporaryDictionary<PdfPage, number[]>();
108
+ const startPage: PdfPage = param.page;
109
+ for (let index: number = 0; index < this.columnRanges.length; index++) {
110
+ const range: number[] = this.columnRanges[index];
111
+ this.cellStartIndex = range[0];
112
+ this.cellEndIndex = range[1];
113
+ const rowsCount: number = this.treegrid.rows.count;
114
+ let i: number = 0;
115
+ let repeatRow: boolean = false;
116
+ //Draw row by row with the specified cell range.
117
+ for (let j: number = 0; j < rowsCount; j++) {
118
+ const row: PdfTreeGridRow = this.treegrid.rows.getRow(j);
119
+ i++;
120
+ const originalHeight: number = this.currentBounds.y;
121
+ if (this.currentPage !== null && !layoutedPages.containsKey(this.currentPage)) {
122
+ layoutedPages.add(this.currentPage, range);
123
+ }
124
+ let rowResult: RowLayoutResult = this.drawRow(row);
125
+ //if height remains same, it is understood that row is not draw in the page.
126
+ if (originalHeight === this.currentBounds.y) {
127
+ repeatRow = true;
128
+ this.repeatRowIndex = this.treegrid.rows.rowCollection.indexOf(row);
129
+ } else {
130
+ repeatRow = false;
131
+ this.repeatRowIndex = -1;
132
+ }
133
+ while (!rowResult.isFinish && startPage !== null) {
134
+ if (this.treegrid.allowRowBreakAcrossPages) {
135
+ //If there is no space in the current page, add new page and then draw the remaining row.
136
+ this.currentPage = this.getNextPageFormat(format);
137
+ if (this.treegrid.enableHeader) {
138
+ this.drawHeader();
139
+ }
140
+ this.checkBounds(format);
141
+ rowResult = this.drawRow(row);
142
+ } else if (!this.treegrid.allowRowBreakAcrossPages && i < length) {
143
+ this.currentPage = this.getNextPageFormat(format);
144
+ if (this.treegrid.enableHeader) {
145
+ this.drawHeader();
146
+ }
147
+ break;
148
+ } else if (i >= length) {
149
+ break;
150
+ }
151
+ }
152
+ if (!rowResult.isFinish && startPage !== null && format.layout !== PdfLayoutType.OnePage && repeatRow) {
153
+ this.startLocation.x = this.currentBounds.x;
154
+ this.currentPage = this.getNextPageFormat(format);
155
+ if (this.treegrid.enableHeader) {
156
+ this.drawHeader();
157
+ }
158
+ this.startLocation.y = this.currentBounds.y;
159
+ if (format.paginateBounds === new RectangleF(0, 0, 0, 0)) {
160
+ this.currentBounds.x += this.startLocation.x;
161
+ }
162
+ if (this.currentBounds.x === PdfBorders.default.left.width / 2) {
163
+ this.currentBounds.y += this.startLocation.x;
164
+ }
165
+ this.drawRow(row);
166
+ if (this.currentPage !== null && !layoutedPages.containsKey(this.currentPage)) {
167
+ layoutedPages.add(this.currentPage, range);
168
+ }
169
+ }
170
+ }
171
+ if (this.columnRanges.indexOf(range) < this.columnRanges.length - 1 &&
172
+ startPage !== null && format.layout !== PdfLayoutType.OnePage) {
173
+ this.currentPage = this.getNextPageFormat(format);
174
+ this.checkBounds(format);
175
+ }
176
+ }
177
+ result = this.getLayoutResult();
178
+ if (this.treegrid.style.allowHorizontalOverflow
179
+ && this.treegrid.style.horizontalOverflowType === PdfHorizontalOverflowType.NextPage) {
180
+ this.reArrangePages(layoutedPages);
181
+ }
182
+ return result;
183
+ }
184
+
185
+ private checkBounds(format: PdfTreeGridLayoutFormat): void {
186
+ const location: PointF = new PointF(PdfBorders.default.right.width / 2, PdfBorders.default.top.width / 2);
187
+ if (format.paginateBounds === new RectangleF(0, 0, 0, 0) && this.startLocation === location) {
188
+ this.currentBounds.x += this.startLocation.x;
189
+ this.currentBounds.y += this.startLocation.y;
190
+ }
191
+ }
192
+
193
+ private drawHeader(): void {
194
+ this.drawRow(this.treegrid.rows.getRow(0));
195
+ }
196
+
197
+ private reArrangePages(layoutPages: TemporaryDictionary<PdfPage, number[]>): void {
198
+ const document: PdfDocument = this.currentPage.document;
199
+ const pages: PdfPage[] = [];
200
+ const keys: PdfPage[] = layoutPages.keys();
201
+ for (let i: number = 0; i < keys.length; i++) {
202
+ const page: PdfPage = keys[i];
203
+ page.section = null;
204
+ pages.push(page);
205
+ document.pages.remove(page);
206
+ }
207
+ for (let i: number = 0; i < layoutPages.size(); i++) {
208
+ const count: number = (layoutPages.size() / this.columnRanges.length);
209
+ for (let j: number = i; j < layoutPages.size(); j += count) {
210
+ const page: PdfPage = pages[j];
211
+ if (document.pages.indexOf(page) === -1) {
212
+ document.pages.add(page);
213
+ }
214
+ }
215
+ }
216
+ }
217
+
218
+ // eslint-disable-next-line
219
+ public getNextPageFormat(format: PdfLayoutFormat): PdfPage {
220
+ const section: PdfSection = this.currentPage.section;
221
+ let nextPage: PdfPage = null;
222
+ const index: number = section.indexOf(this.currentPage);
223
+ if (index === section.count - 1) {
224
+ nextPage = (section.add() as PdfPage);
225
+ } else {
226
+ nextPage = (section.getPages()[index + 1] as PdfPage);
227
+ }
228
+ this.currentGraphics = nextPage.graphics;
229
+ this.currentBounds = new RectangleF(new PointF(0, 0), nextPage.getClientSize());
230
+ return nextPage;
231
+ }
232
+
233
+ private getLayoutResult(): PdfTreeGridLayoutResult {
234
+ const bounds: RectangleF = new RectangleF(this.startLocation, new SizeF(this.currentBounds.width, this.currentBounds.y -
235
+ this.startLocation.y));
236
+ return new PdfTreeGridLayoutResult(this.currentPage, bounds);
237
+ }
238
+
239
+ private checkIfDefaultFormat(format: PdfStringFormat): boolean {
240
+ const defaultFormat: PdfStringFormat = new PdfStringFormat();
241
+ return (format.alignment === defaultFormat.alignment && format.characterSpacing === defaultFormat.characterSpacing &&
242
+ format.clipPath === defaultFormat.clipPath && format.firstLineIndent === defaultFormat.firstLineIndent &&
243
+ format.horizontalScalingFactor === defaultFormat.horizontalScalingFactor &&
244
+ format.lineAlignment === defaultFormat.lineAlignment
245
+ && format.lineLimit === defaultFormat.lineLimit && format.lineSpacing === defaultFormat.lineSpacing &&
246
+ format.measureTrailingSpaces === defaultFormat.measureTrailingSpaces && format.noClip === defaultFormat.noClip &&
247
+ format.paragraphIndent === defaultFormat.paragraphIndent && format.rightToLeft === defaultFormat.rightToLeft &&
248
+ format.subSuperScript === defaultFormat.subSuperScript && format.wordSpacing === defaultFormat.wordSpacing &&
249
+ format.wordWrap === defaultFormat.wordWrap);
250
+ }
251
+
252
+ private drawRow(row: PdfTreeGridRow, layoutResult?: RowLayoutResult, height?: number): RowLayoutResult {
253
+ //.. Check if required space available.
254
+ //.....If the row conains spans which falls through more than one page, then draw the row to next page.
255
+ if (isNullOrUndefined(layoutResult)) {
256
+ const result: RowLayoutResult = new RowLayoutResult();
257
+ height = row.rowBreakHeight > 0 ? row.rowBreakHeight : row.height;
258
+ if (height > this.currentPageBounds.height) {
259
+ if (this.treegrid.allowRowBreakAcrossPages) {
260
+ result.isFinish = true;
261
+ this.drawRowWithBreak(result, row, height);
262
+ } else {
263
+ // If AllowRowBreakAcrossPages is not true, draw the row till it fits the page.
264
+ result.isFinish = false;
265
+ this.drawRow(row, result, height);
266
+ }
267
+ } else if (this.currentBounds.y + height > this.currentPageBounds.height ||
268
+ this.currentBounds.y + height > this.currentBounds.height) {
269
+ if (this.repeatRowIndex > -1 && this.repeatRowIndex === row.rowIndex) {
270
+ if (this.treegrid.allowRowBreakAcrossPages) {
271
+ result.isFinish = true;
272
+ this.drawRowWithBreak(result, row, height);
273
+ } else {
274
+ result.isFinish = false;
275
+ this.drawRow(row, result, height);
276
+ }
277
+ } else {
278
+ result.isFinish = false;
279
+ }
280
+ } else {
281
+ result.isFinish = true;
282
+ this.drawRow(row, result, height);
283
+ }
284
+ return result;
285
+ } else {
286
+ const location: PointF = new PointF(this.currentBounds.x, this.currentBounds.y);
287
+ layoutResult.bounds = new RectangleF(location, new SizeF(0, 0));
288
+ let leftAdjustment: number = 0;
289
+ height = this.reCalculateHeight(row, height);
290
+ for (let i: number = this.cellStartIndex; i <= this.cellEndIndex; i++) {
291
+ const cell: PdfTreeGridCell = row.cells.getCell(i);
292
+ const column: PdfTreeGridColumn = this.treegrid.columns.getColumn(i);
293
+ if (column.isTreeColumn) {
294
+ leftAdjustment = (row.level) * 10;
295
+ }
296
+ const cancelSpans: boolean = ((i > this.cellEndIndex + 1) && (cell.columnSpan > 1));
297
+ if (!cancelSpans) {
298
+ for (let j: number = 1; j < cell.columnSpan; j++) {
299
+ row.cells.getCell(i + j).isCellMergeContinue = true;
300
+ }
301
+ }
302
+ const size: SizeF = new SizeF(column.width, height);
303
+ if (!this.checkIfDefaultFormat(column.format) && this.checkIfDefaultFormat(cell.style.format)) {
304
+ cell.style.format = column.format;
305
+ }
306
+ cell.draw(this.currentGraphics, new RectangleF(location, size), cancelSpans, leftAdjustment);
307
+ /* eslint-disable-next-line */
308
+ if (row.treegrid.style.allowHorizontalOverflow && (cell.columnSpan > this.cellEndIndex || i + cell.columnSpan > this.cellEndIndex + 1) && this.cellEndIndex < row.cells.count - 1) {
309
+ row.rowOverflowIndex = this.cellEndIndex;
310
+ }
311
+ location.x += column.width;
312
+ leftAdjustment = 0;
313
+ }
314
+ this.currentBounds.y += height;
315
+ /* eslint-disable-next-line */
316
+ layoutResult.bounds = new RectangleF(new PointF(layoutResult.bounds.x, layoutResult.bounds.y), new SizeF(location.x, location.y));
317
+ return null;
318
+ }
319
+ }
320
+ /**
321
+ * @param {RowLayoutResult} result .
322
+ * @param {PdfTreeGridRow} row .
323
+ * @param {number} height .
324
+ * @returns {void} .
325
+ */
326
+ private drawRowWithBreak(result: RowLayoutResult, row: PdfTreeGridRow, height: number): void {
327
+ const location: PointF = new PointF(this.currentBounds.x, this.currentBounds.y);
328
+ result.bounds = new RectangleF(location, new SizeF(0, 0));
329
+ let leftAdjustment: number = 0;
330
+ this.treegridHeight = this.currentBounds.height;
331
+ // Calculate the remaining height.
332
+ row.rowBreakHeight = this.currentBounds.y + height - this.currentBounds.height;
333
+ // No need to explicit break if the row height is equal to treegrid height.
334
+ for (let c: number = 0; c < row.cells.count; c++) {
335
+ const cell: PdfTreeGridCell = row.cells.getCell(c);
336
+ const cellHeight: number = cell.measureHeight();
337
+ if (cellHeight === height && (cell.value as PdfTreeGrid) === null) {
338
+ row.rowBreakHeight = this.currentBounds.y + height - this.currentBounds.height;
339
+ }
340
+ }
341
+ for (let i: number = this.cellStartIndex; i <= this.cellEndIndex; i++) {
342
+ const column: PdfTreeGridColumn = this.treegrid.columns.getColumn(i);
343
+ if (column.isTreeColumn) {
344
+ leftAdjustment = row.level * 10;
345
+ }
346
+ const cell: PdfTreeGridCell = row.cells.getCell(i);
347
+ const cancelSpans: boolean = ((cell.columnSpan + i > this.cellEndIndex + 1) && (cell.columnSpan > 1));
348
+ if (!cancelSpans) {
349
+ for (let j: number = 1; j < cell.columnSpan; j++) {
350
+ row.cells.getCell(i + j).isCellMergeContinue = true;
351
+ }
352
+ }
353
+ const tHeight: number = this.treegridHeight > 0 ? this.treegridHeight : this.currentBounds.height;
354
+ const size: SizeF = new SizeF(column.width, tHeight);
355
+ if (!this.checkIfDefaultFormat(column.format) && this.checkIfDefaultFormat(cell.style.format)) {
356
+ cell.style.format = column.format;
357
+ }
358
+ cell.draw(this.currentGraphics, new RectangleF(location, size), cancelSpans, leftAdjustment);
359
+ result.isFinish = (!result.isFinish) ? result.isFinish : cell.finishedDrawingCell;
360
+ location.x += column.width;
361
+ leftAdjustment = 0;
362
+ this.currentBounds.y += this.treegridHeight > 0 ? this.treegridHeight : height;
363
+ result.bounds = new RectangleF(new PointF(result.bounds.x, result.bounds.y), new SizeF(location.x, location.y));
364
+ }
365
+ }
366
+ /**
367
+ * `Recalculate row height` for the split cell to be drawn.
368
+ *
369
+ * @param {PdfTreeGridRow} row .
370
+ * @param {number} height .
371
+ * @returns {void} .
372
+ * @private
373
+ */
374
+ public reCalculateHeight(row: PdfTreeGridRow, height: number): number {
375
+ let newHeight: number = 0;
376
+ for (let i: number = this.cellStartIndex; i <= this.cellEndIndex; i++) {
377
+ if (!isNullOrUndefined(row.cells.getCell(i).remainingString) ||
378
+ row.cells.getCell(i).remainingString === '') {
379
+ newHeight = Math.max(newHeight, row.cells.getCell(i).measureHeight());
380
+ }
381
+ }
382
+ return Math.max(height, newHeight);
383
+ }
384
+ }
385
+ export class PdfTreeGridLayoutResult extends PdfLayoutResult {
386
+ /**
387
+ * Constructor
388
+ *
389
+ * @param {PdfPage} page .
390
+ * @param {RectangleF} bounds .
391
+ * @private
392
+ */
393
+ public constructor(page: PdfPage, bounds: RectangleF) {
394
+ super(page, bounds);
395
+ }
396
+ }
397
+ /**
398
+ * `PdfGridLayoutFormat` class represents a flexible grid that consists of columns and rows.
399
+ */
400
+ export class PdfTreeGridLayoutFormat extends PdfLayoutFormat {
401
+ /**
402
+ * Initializes a new instance of the `PdfGridLayoutFormat` class.
403
+ *
404
+ * @param {PdfLayoutFormat} baseFormat .
405
+ * @private
406
+ */
407
+ public constructor(baseFormat?: PdfLayoutFormat) {
408
+ if (typeof baseFormat === 'undefined') {
409
+ super();
410
+ } else {
411
+ super(baseFormat);
412
+ }
413
+ }
414
+ }