@sapui5/sap.gantt 1.126.0 → 1.127.1

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 (209) hide show
  1. package/package.json +1 -1
  2. package/src/sap/gantt/.library +1 -1
  3. package/src/sap/gantt/AdhocLine.js +1 -1
  4. package/src/sap/gantt/GanttChart.js +1 -1
  5. package/src/sap/gantt/GanttChartBase.js +1 -1
  6. package/src/sap/gantt/GanttChartContainer.js +1 -1
  7. package/src/sap/gantt/GanttChartWithTable.js +1 -1
  8. package/src/sap/gantt/axistime/AxisTimeStrategyBase.js +1 -1
  9. package/src/sap/gantt/axistime/FullScreenStrategy.js +1 -1
  10. package/src/sap/gantt/axistime/FullScreenTimeLineOptions.js +7 -1
  11. package/src/sap/gantt/axistime/ProportionTimeLineOptions.js +7 -1
  12. package/src/sap/gantt/axistime/ProportionZoomStrategy.js +1 -1
  13. package/src/sap/gantt/axistime/StepwiseTimeLineOptions.js +7 -1
  14. package/src/sap/gantt/axistime/StepwiseZoomStrategy.js +1 -1
  15. package/src/sap/gantt/changeHandlers/simple/AdhocLine.js +1 -1
  16. package/src/sap/gantt/changeHandlers/simple/DeltaLine.js +1 -1
  17. package/src/sap/gantt/changeHandlers/simple/GanttChartContainer.js +1 -1
  18. package/src/sap/gantt/changeHandlers/simple/GanttChartWithTable.js +1 -1
  19. package/src/sap/gantt/config/BirdEyeGroup.js +1 -1
  20. package/src/sap/gantt/config/ChartScheme.js +1 -1
  21. package/src/sap/gantt/config/ColumnAttribute.js +1 -1
  22. package/src/sap/gantt/config/ContainerLayout.js +1 -1
  23. package/src/sap/gantt/config/ExpandChart.js +1 -1
  24. package/src/sap/gantt/config/ExpandChartGroup.js +1 -1
  25. package/src/sap/gantt/config/GanttChartLayout.js +1 -1
  26. package/src/sap/gantt/config/Hierarchy.js +1 -1
  27. package/src/sap/gantt/config/HierarchyColumn.js +1 -1
  28. package/src/sap/gantt/config/LayoutGroup.js +1 -1
  29. package/src/sap/gantt/config/Locale.js +1 -1
  30. package/src/sap/gantt/config/Mode.js +1 -1
  31. package/src/sap/gantt/config/ModeGroup.js +1 -1
  32. package/src/sap/gantt/config/ObjectType.js +1 -1
  33. package/src/sap/gantt/config/SettingGroup.js +1 -1
  34. package/src/sap/gantt/config/SettingItem.js +1 -1
  35. package/src/sap/gantt/config/Shape.js +1 -1
  36. package/src/sap/gantt/config/TimeAxis.js +1 -1
  37. package/src/sap/gantt/config/TimeHorizon.js +1 -1
  38. package/src/sap/gantt/config/TimeZoomGroup.js +1 -1
  39. package/src/sap/gantt/config/ToolbarGroup.js +1 -1
  40. package/src/sap/gantt/config/ToolbarScheme.js +1 -1
  41. package/src/sap/gantt/control/Cell.js +1 -1
  42. package/src/sap/gantt/def/DefBase.js +1 -1
  43. package/src/sap/gantt/def/SvgDefs.js +1 -1
  44. package/src/sap/gantt/def/cal/Calendar.js +1 -1
  45. package/src/sap/gantt/def/cal/CalendarDefs.js +1 -1
  46. package/src/sap/gantt/def/cal/TimeInterval.js +1 -1
  47. package/src/sap/gantt/def/filter/MorphologyFilter.js +1 -1
  48. package/src/sap/gantt/def/gradient/LinearGradient.js +1 -1
  49. package/src/sap/gantt/def/gradient/RadialGradient.js +1 -1
  50. package/src/sap/gantt/def/gradient/Stop.js +1 -1
  51. package/src/sap/gantt/def/pattern/BackSlashPattern.js +1 -1
  52. package/src/sap/gantt/def/pattern/PatternBase.js +1 -1
  53. package/src/sap/gantt/def/pattern/SlashPattern.js +1 -1
  54. package/src/sap/gantt/drawer/AdhocLine.js +1 -1
  55. package/src/sap/gantt/drawer/Drawer.js +1 -1
  56. package/src/sap/gantt/drawer/Legend.js +6 -0
  57. package/src/sap/gantt/drawer/VerticalLine.js +1 -1
  58. package/src/sap/gantt/eventHandler/AutoScrollHandler.js +1 -1
  59. package/src/sap/gantt/eventHandler/BirdEyeHandler.js +7 -1
  60. package/src/sap/gantt/eventHandler/MouseWheelHandler.js +1 -1
  61. package/src/sap/gantt/eventHandler/ShapeHoverHandler.js +1 -1
  62. package/src/sap/gantt/eventHandler/ShapeResizeHandler.js +1 -1
  63. package/src/sap/gantt/eventHandler/TimePeriodZoomHandler.js +1 -1
  64. package/src/sap/gantt/eventHandler/TimePopoverHandler.js +1 -1
  65. package/src/sap/gantt/flexibility/simple/AdhocLine.flexibility.js +7 -1
  66. package/src/sap/gantt/flexibility/simple/DeltaLine.flexibility.js +7 -1
  67. package/src/sap/gantt/flexibility/simple/GanttChartWithTable.flexibility.js +7 -1
  68. package/src/sap/gantt/flexibility/simple/GanttTableColumn.flexibility.js +6 -7
  69. package/src/sap/gantt/layouts/SidePanel.js +1 -1
  70. package/src/sap/gantt/legend/DimensionLegend.js +1 -1
  71. package/src/sap/gantt/legend/LegendBase.js +1 -1
  72. package/src/sap/gantt/legend/LegendContainer.js +1 -1
  73. package/src/sap/gantt/legend/ListLegend.js +1 -1
  74. package/src/sap/gantt/library.js +2 -2
  75. package/src/sap/gantt/messagebundle.properties +8 -2
  76. package/src/sap/gantt/misc/AxisOrdinal.js +1 -1
  77. package/src/sap/gantt/misc/Format.js +2 -2
  78. package/src/sap/gantt/misc/Memoizer.js +1 -1
  79. package/src/sap/gantt/misc/RelativeTimeFormatter.js +1 -1
  80. package/src/sap/gantt/misc/ShapeManager.js +1 -1
  81. package/src/sap/gantt/misc/Utility.js +11 -0
  82. package/src/sap/gantt/overlays/GanttRowOverlay.js +1 -1
  83. package/src/sap/gantt/overlays/Overlay.js +1 -1
  84. package/src/sap/gantt/polyfills/lib.js +6 -0
  85. package/src/sap/gantt/polyfills/time.js +6 -0
  86. package/src/sap/gantt/polyfills/timeUtils/day.js +6 -0
  87. package/src/sap/gantt/polyfills/timeUtils/dayCount.js +6 -0
  88. package/src/sap/gantt/polyfills/timeUtils/days.js +6 -0
  89. package/src/sap/gantt/polyfills/timeUtils/interval.js +6 -0
  90. package/src/sap/gantt/polyfills/timeUtils/millisecond.js +6 -0
  91. package/src/sap/gantt/polyfills/timeUtils/monday.js +6 -0
  92. package/src/sap/gantt/polyfills/timeUtils/saturday.js +6 -0
  93. package/src/sap/gantt/polyfills/timeUtils/weeks.js +6 -0
  94. package/src/sap/gantt/shape/Circle.js +1 -1
  95. package/src/sap/gantt/shape/ClipPath.js +1 -1
  96. package/src/sap/gantt/shape/Definitions.js +1 -1
  97. package/src/sap/gantt/shape/Group.js +1 -1
  98. package/src/sap/gantt/shape/Image.js +1 -1
  99. package/src/sap/gantt/shape/Line.js +1 -1
  100. package/src/sap/gantt/shape/Path.js +1 -1
  101. package/src/sap/gantt/shape/Polygon.js +1 -1
  102. package/src/sap/gantt/shape/Polyline.js +1 -1
  103. package/src/sap/gantt/shape/Rectangle.js +1 -1
  104. package/src/sap/gantt/shape/ResizeShadowShape.js +1 -1
  105. package/src/sap/gantt/shape/SelectedShape.js +1 -1
  106. package/src/sap/gantt/shape/Shape.js +1 -1
  107. package/src/sap/gantt/shape/Text.js +1 -1
  108. package/src/sap/gantt/shape/cal/Calendar.js +1 -1
  109. package/src/sap/gantt/shape/ext/Chevron.js +1 -1
  110. package/src/sap/gantt/shape/ext/Cursor.js +1 -1
  111. package/src/sap/gantt/shape/ext/Diamond.js +1 -1
  112. package/src/sap/gantt/shape/ext/Iconfont.js +1 -1
  113. package/src/sap/gantt/shape/ext/Pentangle.js +1 -1
  114. package/src/sap/gantt/shape/ext/TextRepeat.js +1 -1
  115. package/src/sap/gantt/shape/ext/Triangle.js +1 -1
  116. package/src/sap/gantt/shape/ext/rls/Relationship.js +1 -1
  117. package/src/sap/gantt/shape/ext/rls/SelectedRelationship.js +1 -1
  118. package/src/sap/gantt/shape/ext/ubc/UbcBorderPath.js +1 -1
  119. package/src/sap/gantt/shape/ext/ubc/UbcOverCapacityZonePolygon.js +1 -1
  120. package/src/sap/gantt/shape/ext/ubc/UbcPolygon.js +1 -1
  121. package/src/sap/gantt/shape/ext/ubc/UbcShortageCapacityPolygon.js +1 -1
  122. package/src/sap/gantt/shape/ext/ubc/UbcTooltipRectangle.js +1 -1
  123. package/src/sap/gantt/shape/ext/ubc/UbcUnderCapacityZonePolygon.js +1 -1
  124. package/src/sap/gantt/shape/ext/ubc/UbcUsedPolygon.js +1 -1
  125. package/src/sap/gantt/shape/ext/ubc/UtilizationBarChart.js +1 -1
  126. package/src/sap/gantt/shape/ext/ulc/UlcBorderPath.js +1 -1
  127. package/src/sap/gantt/shape/ext/ulc/UlcClipPath.js +1 -1
  128. package/src/sap/gantt/shape/ext/ulc/UlcClipingPath.js +1 -1
  129. package/src/sap/gantt/shape/ext/ulc/UlcDimension.js +1 -1
  130. package/src/sap/gantt/shape/ext/ulc/UlcMiddleLine.js +1 -1
  131. package/src/sap/gantt/shape/ext/ulc/UlcOverCapacityZoneRectangle.js +1 -1
  132. package/src/sap/gantt/shape/ext/ulc/UlcOverClipRectangle.js +1 -1
  133. package/src/sap/gantt/shape/ext/ulc/UlcRectangle.js +1 -1
  134. package/src/sap/gantt/shape/ext/ulc/UlcTooltipRectangle.js +1 -1
  135. package/src/sap/gantt/shape/ext/ulc/UlcUnderClipRectangle.js +1 -1
  136. package/src/sap/gantt/shape/ext/ulc/UtilizationLineChart.js +1 -1
  137. package/src/sap/gantt/simple/AdhocDiamond.js +1 -1
  138. package/src/sap/gantt/simple/AdhocLine.js +1 -1
  139. package/src/sap/gantt/simple/AggregationUtils.js +1 -1
  140. package/src/sap/gantt/simple/BaseCalendar.js +1 -1
  141. package/src/sap/gantt/simple/BaseChevron.js +1 -1
  142. package/src/sap/gantt/simple/BaseConditionalShape.js +1 -1
  143. package/src/sap/gantt/simple/BaseCursor.js +7 -7
  144. package/src/sap/gantt/simple/BaseDeltaRectangle.js +4 -4
  145. package/src/sap/gantt/simple/BaseDiamond.js +1 -1
  146. package/src/sap/gantt/simple/BaseGroup.js +1 -1
  147. package/src/sap/gantt/simple/BaseImage.js +1 -1
  148. package/src/sap/gantt/simple/BaseLine.js +1 -1
  149. package/src/sap/gantt/simple/BasePath.js +1 -1
  150. package/src/sap/gantt/simple/BasePseudoShape.js +1 -1
  151. package/src/sap/gantt/simple/BaseRectangle.js +2 -2
  152. package/src/sap/gantt/simple/BaseShape.js +7 -5
  153. package/src/sap/gantt/simple/BaseText.js +1 -1
  154. package/src/sap/gantt/simple/BaseTriangle.js +7 -1
  155. package/src/sap/gantt/simple/ContainerToolbar.js +7 -1
  156. package/src/sap/gantt/simple/ContainerToolbarPlaceholder.js +1 -1
  157. package/src/sap/gantt/simple/CoordinateUtils.js +1 -1
  158. package/src/sap/gantt/simple/CustomVariantHandler.js +8 -2
  159. package/src/sap/gantt/simple/DeltaLine.js +1 -1
  160. package/src/sap/gantt/simple/ExpandModel.js +2 -2
  161. package/src/sap/gantt/simple/FindAndSelectUtils.js +6 -0
  162. package/src/sap/gantt/simple/FullScreenUtil.js +7 -1
  163. package/src/sap/gantt/simple/GanttAdaptationData.js +8 -2
  164. package/src/sap/gantt/simple/GanttChartContainer.js +1 -1
  165. package/src/sap/gantt/simple/GanttChartWithTable.js +28 -4
  166. package/src/sap/gantt/simple/GanttDragDropExtension.js +10 -5
  167. package/src/sap/gantt/simple/GanttExtension.js +1 -1
  168. package/src/sap/gantt/simple/GanttHeader.js +1 -1
  169. package/src/sap/gantt/simple/GanttPointerExtension.js +1 -1
  170. package/src/sap/gantt/simple/GanttPopoverExtension.js +2 -2
  171. package/src/sap/gantt/simple/GanttPrinting.js +311 -197
  172. package/src/sap/gantt/simple/GanttRowAction.js +1 -1
  173. package/src/sap/gantt/simple/GanttRowSettings.js +1 -1
  174. package/src/sap/gantt/simple/GanttScrollExtension.js +1 -1
  175. package/src/sap/gantt/simple/GanttSearchSidePanel.js +7 -1
  176. package/src/sap/gantt/simple/GanttUtils.js +6 -3
  177. package/src/sap/gantt/simple/GanttZoomExtension.js +4 -4
  178. package/src/sap/gantt/simple/InnerGanttChart.js +1 -1
  179. package/src/sap/gantt/simple/InnerGanttChartRenderer.js +2 -0
  180. package/src/sap/gantt/simple/LegendContainer.js +1 -1
  181. package/src/sap/gantt/simple/LegendShapeGroup.js +1 -1
  182. package/src/sap/gantt/simple/MultiActivityGroup.js +1 -1
  183. package/src/sap/gantt/simple/MultiActivityRowSettings.js +1 -1
  184. package/src/sap/gantt/simple/PrintConfig.js +314 -0
  185. package/src/sap/gantt/simple/PrintDialogTemplate.js +38 -0
  186. package/src/sap/gantt/simple/PrintUtils.js +151 -0
  187. package/src/sap/gantt/simple/Relationship.js +1 -1
  188. package/src/sap/gantt/simple/RenderUtils.js +1 -1
  189. package/src/sap/gantt/simple/SelectionModel.js +14 -0
  190. package/src/sap/gantt/simple/ShapeScheme.js +1 -1
  191. package/src/sap/gantt/simple/StockChart.js +1 -1
  192. package/src/sap/gantt/simple/StockChartDimension.js +1 -1
  193. package/src/sap/gantt/simple/StockChartPeriod.js +1 -1
  194. package/src/sap/gantt/simple/UtilizationBarChart.js +1 -1
  195. package/src/sap/gantt/simple/UtilizationChart.js +1 -1
  196. package/src/sap/gantt/simple/UtilizationDimension.js +1 -1
  197. package/src/sap/gantt/simple/UtilizationLineChart.js +1 -1
  198. package/src/sap/gantt/simple/UtilizationPeriod.js +1 -1
  199. package/src/sap/gantt/simple/shapes/Shape.js +6 -6
  200. package/src/sap/gantt/simple/shapes/Task.js +1 -1
  201. package/src/sap/gantt/skipTime/DayInterval.js +1 -1
  202. package/src/sap/gantt/skipTime/DiscontinuousProvider.js +8 -2
  203. package/src/sap/gantt/skipTime/SkipInterval.js +1 -1
  204. package/src/sap/gantt/skipTime/SkipPattern.js +1 -1
  205. package/src/sap/gantt/skipTime/WeekPattern.js +1 -1
  206. package/src/sap/gantt/skipTime/WeeklyDiscontinuousProvider.js +6 -0
  207. package/src/sap/gantt/utils/GanttChartConfigurationUtils.js +6 -0
  208. package/src/sap/gantt/utils/GanttCustomisationUtils.js +7 -1
  209. package/src/sap/gantt/utils/GanttFlexibilityUtils.js +7 -1
@@ -69,7 +69,9 @@ sap.ui.define([
69
69
  "sap/ui/model/type/Integer",
70
70
  "sap/ui/model/type/Boolean",
71
71
  "sap/gantt/utils/GanttChartConfigurationUtils",
72
- "sap/ui/core/Lib"
72
+ "sap/ui/core/Lib",
73
+ "sap/gantt/simple/PrintConfig",
74
+ "sap/gantt/simple/PrintUtils"
73
75
  ], function (
74
76
  GanttLibrary,
75
77
  $,
@@ -134,7 +136,9 @@ sap.ui.define([
134
136
  Integer,
135
137
  Boolean,
136
138
  GanttChartConfigurationUtils,
137
- Lib
139
+ Lib,
140
+ PrintConfig,
141
+ PrintUtils
138
142
  ) {
139
143
  "use strict";
140
144
 
@@ -158,7 +162,7 @@ sap.ui.define([
158
162
  * @extend sap.ui.core.Element
159
163
  *
160
164
  * @author SAP SE
161
- * @version 1.126.0
165
+ * @version 1.127.1
162
166
  * @since 1.66
163
167
  *
164
168
  * @constructor
@@ -181,49 +185,6 @@ sap.ui.define([
181
185
  }
182
186
  });
183
187
 
184
- GanttPrinting._oPaperSizes = {
185
- "A5": {
186
- width: mmToPx(148),
187
- height: mmToPx(210)
188
- },
189
- "A4": {
190
- width: mmToPx(210),
191
- height: mmToPx(297)
192
- },
193
- "A3": {
194
- width: mmToPx(297),
195
- height: mmToPx(420)
196
- },
197
- "A2": {
198
- width: mmToPx(420),
199
- height: mmToPx(594)
200
- },
201
- "A1": {
202
- width: mmToPx(594),
203
- height: mmToPx(841)
204
- },
205
- "A0": {
206
- width: mmToPx(841),
207
- height: mmToPx(1189)
208
- },
209
- "Letter": {
210
- width: inToPx(8.5),
211
- height: inToPx(11)
212
- },
213
- "Legal": {
214
- width: inToPx(8.5),
215
- height: inToPx(14)
216
- },
217
- "Tabloid": {
218
- width: inToPx(11),
219
- height: inToPx(17)
220
- },
221
- "Custom": {
222
- width: undefined,
223
- height: undefined
224
- }
225
- };
226
-
227
188
  var TEXTFONT = "9px Arial, Helvetica, sans-serif";
228
189
  var PAGENUMBERFONT = "12px Arial, Helvetica, sans-serif";
229
190
  var MAXCANVASSIZE = "16384";
@@ -237,17 +198,19 @@ sap.ui.define([
237
198
  GanttPrinting.prototype.init = function () {
238
199
 
239
200
  this._oRb = Lib.getResourceBundleFor("sap.gantt");
201
+ var _oPaperSizes = PrintUtils._getPaperConfiguarations();
202
+ var defaultMargin = PrintUtils._mmToPx(5);
240
203
  // size in px computed from mm and in
241
204
 
242
- var oData = {
205
+ this.oInitialValues = {
243
206
  "multiplePage": true,
244
207
  "qualityWarning": false,
245
208
  "showOrientationMessage": false,
246
209
  "orientationMessage": this._oRb.getText("GNT_PRNTG_SINGLE_PAGE_LANDSCAPE"),
247
210
  "portrait": true,
248
211
  "paperSize": "A4",
249
- "paperWidth": GanttPrinting._oPaperSizes.A4.width,
250
- "paperHeight": GanttPrinting._oPaperSizes.A4.height,
212
+ "paperWidth": _oPaperSizes.A4.width,
213
+ "paperHeight": _oPaperSizes.A4.height,
251
214
  "unit": "mm",
252
215
  "repeatSelectionPanel": false,
253
216
  "scale": 100,
@@ -267,21 +230,21 @@ sap.ui.define([
267
230
  "lastPageNumber": undefined,
268
231
  "marginType": "default",
269
232
  "marginLocked": false,
270
- "marginTop": mmToPx(5),
271
- "marginRight": mmToPx(5),
272
- "marginBottom": mmToPx(5),
273
- "marginLeft": mmToPx(5),
233
+ "marginTop": defaultMargin,
234
+ "marginRight": defaultMargin,
235
+ "marginBottom": defaultMargin,
236
+ "marginLeft": defaultMargin,
274
237
  "cropMarks": false,
275
238
  "cropMarksWeight": 0.25,
276
- "cropMarksOffset": mmToPx(3)
239
+ "cropMarksOffset": PrintUtils._mmToPx(3)
277
240
  };
278
241
 
279
- this._oModel = new JSONModel(oData);
242
+ this._oModel = new JSONModel(this.oInitialValues);
280
243
 
281
244
  this._oGanttCanvas = undefined;
282
245
 
283
246
  // 8mm
284
- this._iHeaderAndFooterHeight = mmToPx(8);
247
+ this._iHeaderAndFooterHeight = PrintUtils._mmToPx(8);
285
248
 
286
249
  this._ganttChartContainer = new GanttChartContainer();
287
250
 
@@ -580,19 +543,20 @@ sap.ui.define([
580
543
  /**
581
544
  * Opens the print dialog.
582
545
  * @param {function} fnUpdateTable Optional function which takes cloned gantt chart's table for modification. Applications can loop through the table columns and update certain properties like maxLines to overcome html2canvas limitations.
546
+ * @param {sap.gantt.simple.PrintDialogTemplate} printDialogTemplate which takes custom buttons to display on print Dialog
583
547
  * @returns {Promise} A promise for chaining actions after the print dialog is ready.
584
548
  * @public
585
549
  */
586
- GanttPrinting.prototype.open = function (fnUpdateTable) {
550
+ GanttPrinting.prototype.open = function (fnUpdateTable,printDialogTemplate) {
587
551
  if (!this.getGanttChart() || !this._getOriginalGanttChart().isA("sap.gantt.simple.GanttChartWithTable")) {
588
552
  throw new Error("Association 'ganttChart' of type 'sap.gantt.simple.GanttChartWithTable' is not set");
589
553
  }
554
+
590
555
  var that = this;
591
556
  if (fnUpdateTable) {
592
557
  fnUpdateTable(this._ganttChartClone.getTable());
593
558
  }
594
-
595
- this._createAndOpenDialog();
559
+ this._createAndOpenDialog(false,printDialogTemplate);
596
560
  this._oDialog.getContent()[0].setBusy(true);
597
561
  this._oButtonExport.setEnabled(false);
598
562
 
@@ -600,15 +564,15 @@ sap.ui.define([
600
564
  this._ganttChartClone.setShowGanttHeader(true);
601
565
  return this._drawClonedGantt(false).then(function () {
602
566
  if (that._bMultipleBatches) {
603
- that._openProgressDialog();
604
- }
605
- return that.generateCanvasAsync(0);
606
- }).catch(function(oErrorObj) {
607
- if (oErrorObj && oErrorObj.bMaxCanvasSizeExceeded) {
608
- that._updateDialogPreviewCanvas();
609
- that._oDialog.getContent()[0].setBusy(false);
610
- }
611
- });
567
+ that._openProgressDialog();
568
+ }
569
+ return that.generateCanvasAsync(0);
570
+ }).catch(function(oErrorObj) {
571
+ if (oErrorObj && oErrorObj.bMaxCanvasSizeExceeded || oErrorObj.dateDurationNotSet ) {
572
+ that._updateDialogPreviewCanvas();
573
+ that._oDialog.getContent()[0].setBusy(false);
574
+ }
575
+ });
612
576
  } else {
613
577
  if (GanttChartConfigurationUtils.getRTL()) {
614
578
  that._ganttChartClone._bRenderGanttClone = true;
@@ -624,33 +588,57 @@ sap.ui.define([
624
588
  that._setCloneDivHeightNonOptimised();
625
589
  document.getElementById(that._ganttChartClone.getId() + "-sapGanttBackgroundTableContent").style.height = that._iContentHeight;
626
590
  document.getElementById(that._ganttChartClone.getTable().getId() + "-tableCCnt").style.height = that._iContentHeight;
627
- return that._createGanttCanvas();
591
+ return that._createGanttCanvas();
628
592
  }).then(function (oUpdatedCanvas) {
629
- that._oGanttCanvas = oUpdatedCanvas;
630
- that._updateDialogPreview();
631
- that._oDialog.getContent()[0].setBusy(false);
632
- that._oButtonExport.setEnabled(true);
633
- }).catch(function(oErrorObj) {
634
- if (oErrorObj && oErrorObj.bMaxCanvasSizeExceeded) {
635
- that._updateDialogPreviewCanvas();
593
+ that._oGanttCanvas = oUpdatedCanvas;
594
+ that._updateDialogPreview();
636
595
  that._oDialog.getContent()[0].setBusy(false);
637
- }
596
+ that._oButtonExport.setEnabled(true);
597
+ }).catch(function(oErrorObj) {
598
+ if (oErrorObj && oErrorObj.bMaxCanvasSizeExceeded || oErrorObj.dateDurationNotSet) {
599
+ that._updateDialogPreviewCanvas();
600
+ that._oDialog.getContent()[0].setBusy(false);
601
+ }
638
602
  });
639
603
  }
640
604
  };
641
-
642
-
605
+ /**
606
+ * @param {boolean} bUpdate decides whether to show error dialog
607
+ * @private
608
+ */
609
+ GanttPrinting.prototype._updateDialogErrorPDFPreview = function (bUpdate) {
610
+ var oDialogPreviewDiv = this._oPdfDialogPreview.$().find(".sapGanttPdfPreviewPageDiv");
611
+ var $dialogPreviewDiv = oDialogPreviewDiv[0];
612
+ if (!bUpdate) {
613
+ removeDialogPreviewChilds($dialogPreviewDiv);
614
+ } else {
615
+ this._oPreviewErrorMessageStrip = new MessageStrip({
616
+ text: this._oRb.getText("GNT_PRNTG_ERROR_DATEDURATION_PREVIEW"),
617
+ showIcon: true,
618
+ type: "Error"
619
+ }).addStyleClass("sapGanttPrintingBottomMargin");
620
+ var oPreviewErrorDiv = document.createElement("div");
621
+ oPreviewErrorDiv.id = this.getId() + "-previewErrorMessageStrip";
622
+ oPreviewErrorDiv.style.width = "50%";
623
+ oPreviewErrorDiv.style.marginTop = "25%";
624
+ oPreviewErrorDiv.style.marginLeft = "25%";
625
+ $dialogPreviewDiv.appendChild(oPreviewErrorDiv);
626
+ this._oPreviewErrorMessageStrip.placeAt(this.getId() + "-previewErrorMessageStrip");
627
+ }
628
+ };
643
629
  /**
644
630
  * Opens the print dialog for single page printing.
645
631
  * @param {function} fnUpdateTable Optional function which takes cloned gantt chart's table for modification. Applications can loop through the table columns and update certain properties like maxLines to overcome html2canvas limitations.
632
+ * @param {sap.gantt.simple.PrintDialogTemplate} printDialogTemplate which takes custom buttons to display on print Dialog
646
633
  * @returns {Promise} A promise for chaining actions after the print dialog is ready.
647
634
  * @since 1.111
648
635
  * @experimental
649
636
  */
650
- GanttPrinting.prototype.openPdfPreview = function (fnUpdateTable) {
637
+ GanttPrinting.prototype.openPdfPreview = function (fnUpdateTable,printDialogTemplate) {
651
638
  if (!this.getGanttChart() || !this._getOriginalGanttChart().isA("sap.gantt.simple.GanttChartWithTable")) {
652
639
  throw new Error("Association 'ganttChart' of type 'sap.gantt.simple.GanttChartWithTable' is not set");
653
640
  }
641
+ this._bSinglePage = true;
654
642
  this._oDomToPrint = [];
655
643
  this._oDomToPrintHeight = 0;
656
644
  this._oDomToPrintWidth = 0;
@@ -659,7 +647,7 @@ sap.ui.define([
659
647
  fnUpdateTable(this._ganttChartClone.getTable());
660
648
  }
661
649
 
662
- this._createAndOpenDialog(true);
650
+ this._createAndOpenDialog(true,printDialogTemplate);
663
651
  this._oDialog.getContent()[0].setBusy(true);
664
652
  this._oButtonExport.setEnabled(false);
665
653
  this._ganttChartClone.setShowGanttHeader(true);
@@ -670,6 +658,9 @@ sap.ui.define([
670
658
  return that.generatePdfAsync(0);
671
659
  }).catch(function(oErrorObj) {
672
660
  if (oErrorObj) {
661
+ if (oErrorObj.dateDurationNotSet) {
662
+ that._updateDialogErrorPDFPreview(true);
663
+ }
673
664
  that._oDialog.getContent()[0].setBusy(false);
674
665
  }
675
666
  });
@@ -969,62 +960,6 @@ sap.ui.define([
969
960
  }
970
961
  };
971
962
 
972
- function mmToPx(iMm) {
973
- // 1 millimeter = 3.78 pixel
974
- return iMm * 3.78;
975
- }
976
-
977
- function pxToMm(fPx) {
978
- // 1 millimeter = 3.78 pixel
979
- return fPx / 3.78;
980
- }
981
-
982
- function inToPx(iIn) {
983
- // 1 inch = pixel 0.01042 pixel
984
- return iIn / 0.01042;
985
- }
986
-
987
- function pxToIn(fPx) {
988
- // 1 inch = pixel 0.01042 pixel
989
- return fPx * 0.01042;
990
- }
991
-
992
- GanttPrinting.prototype._convertUnitToPx = function (fVal) {
993
- var sUnit = this._oModel.getProperty("/unit");
994
- if (!sUnit) {
995
- return undefined;
996
- }
997
-
998
- switch (sUnit) {
999
- case "mm":
1000
- return mmToPx(fVal);
1001
- case "cm":
1002
- return mmToPx(fVal) * 10;
1003
- case "in":
1004
- return inToPx(fVal);
1005
- default:
1006
- return undefined;
1007
- }
1008
- };
1009
-
1010
- GanttPrinting.prototype._convertPxToUnit = function (fPx) {
1011
- var sUnit = this._oModel.getProperty("/unit");
1012
- if (!sUnit) {
1013
- return undefined;
1014
- }
1015
-
1016
- switch (sUnit) {
1017
- case "mm":
1018
- return pxToMm(fPx);
1019
- case "cm":
1020
- return pxToMm(fPx) / 10;
1021
- case "in":
1022
- return pxToIn(fPx);
1023
- default:
1024
- return undefined;
1025
- }
1026
- };
1027
-
1028
963
  GanttPrinting.prototype._onChangeUnitComboBox = function () {
1029
964
  this._updatePaperSizeInputs();
1030
965
  this._updateMarginInputs();
@@ -1040,11 +975,12 @@ sap.ui.define([
1040
975
  };
1041
976
 
1042
977
  GanttPrinting.prototype._setPaperSizeInputs = function (fPaperWidth, fPaperHeight) {
978
+ var sUnit = this._oModel.getProperty("/unit");
1043
979
  if (this._oInputPaperWidth) {
1044
- this._oInputPaperWidth.setValue(this._convertPxToUnit(fPaperWidth));
980
+ this._oInputPaperWidth.setValue(PrintUtils._convertPxToUnit(fPaperWidth,sUnit));
1045
981
  }
1046
982
  if (this._oInputPaperHeight) {
1047
- this._oInputPaperHeight.setValue(this._convertPxToUnit(fPaperHeight));
983
+ this._oInputPaperHeight.setValue(PrintUtils._convertPxToUnit(fPaperHeight,sUnit));
1048
984
  }
1049
985
  };
1050
986
 
@@ -1064,7 +1000,7 @@ sap.ui.define([
1064
1000
  return;
1065
1001
  }
1066
1002
 
1067
- var oSizes = GanttPrinting._oPaperSizes[sPaperSize];
1003
+ var oSizes = PrintUtils._getPaperConfiguarations()[sPaperSize];
1068
1004
  if (bPortrait) {
1069
1005
  fPaperWidth = oSizes.width;
1070
1006
  fPaperHeight = oSizes.height;
@@ -1104,7 +1040,8 @@ sap.ui.define([
1104
1040
 
1105
1041
  GanttPrinting.prototype._onChangePaperSizeInput = function (bSinglePage, oEvent) {
1106
1042
  var oChangedInput = oEvent.getSource();
1107
- var fNewValue = this._convertUnitToPx(NumberFormat.getFloatInstance({"groupingSeparator": ',',"decimalSeparator": "."}).parse(oChangedInput.getValue()));
1043
+ var sUnit = this._oModel.getProperty("/unit");
1044
+ var fNewValue = PrintUtils._convertUnitToPx(NumberFormat.getFloatInstance({"groupingSeparator": ',',"decimalSeparator": "."}).parse(oChangedInput.getValue()),sUnit);
1108
1045
 
1109
1046
  if (oChangedInput === this._oInputPaperWidth) {
1110
1047
  this._oModel.setProperty("/paperWidth", fNewValue);
@@ -1174,10 +1111,11 @@ sap.ui.define([
1174
1111
  };
1175
1112
 
1176
1113
  GanttPrinting.prototype._setMarginInputs = function (fTop, fRight, fBottom, fLeft) {
1177
- this._oInputMarginTop.setValue(this._convertPxToUnit(fTop));
1178
- this._oInputMarginRight.setValue(this._convertPxToUnit(fRight));
1179
- this._oInputMarginBottom.setValue(this._convertPxToUnit(fBottom));
1180
- this._oInputMarginLeft.setValue(this._convertPxToUnit(fLeft));
1114
+ var sUnit = this._oModel.getProperty("/unit");
1115
+ this._oInputMarginTop.setValue(PrintUtils._convertPxToUnit(fTop,sUnit));
1116
+ this._oInputMarginRight.setValue(PrintUtils._convertPxToUnit(fRight,sUnit));
1117
+ this._oInputMarginBottom.setValue(PrintUtils._convertPxToUnit(fBottom,sUnit));
1118
+ this._oInputMarginLeft.setValue(PrintUtils._convertPxToUnit(fLeft,sUnit));
1181
1119
  };
1182
1120
 
1183
1121
  GanttPrinting.prototype._setMarginsToModel = function (fTop, fRight, fBottom, fLeft) {
@@ -1202,7 +1140,7 @@ sap.ui.define([
1202
1140
  var sKey = oEvent.getSource().getSelectedKey();
1203
1141
 
1204
1142
  // default margin is 5mm
1205
- var fMargin = mmToPx(5);
1143
+ var fMargin = PrintUtils._mmToPx(5);
1206
1144
  if (sKey === "none") {
1207
1145
  fMargin = 0;
1208
1146
  }
@@ -1222,21 +1160,21 @@ sap.ui.define([
1222
1160
  fMarginRight,
1223
1161
  fMarginBottom,
1224
1162
  fMarginLeft;
1225
-
1163
+ var sUnit = this._oModel.getProperty("/unit");
1226
1164
  if (this._oInputMarginTop.getValueState() !== "Error") {
1227
- fMarginTop = this._convertUnitToPx(this._oInputMarginTop.getValue());
1165
+ fMarginTop = PrintUtils._convertUnitToPx(this._oInputMarginTop.getValue(),sUnit);
1228
1166
  }
1229
1167
 
1230
1168
  if (this._oInputMarginRight.getValueState() !== "Error") {
1231
- fMarginRight = this._convertUnitToPx(this._oInputMarginRight.getValue());
1169
+ fMarginRight = PrintUtils._convertUnitToPx(this._oInputMarginRight.getValue(),sUnit);
1232
1170
  }
1233
1171
 
1234
1172
  if (this._oInputMarginBottom.getValueState() !== "Error") {
1235
- fMarginBottom = this._convertUnitToPx(this._oInputMarginBottom.getValue());
1173
+ fMarginBottom = PrintUtils._convertUnitToPx(this._oInputMarginBottom.getValue(),sUnit);
1236
1174
  }
1237
1175
 
1238
1176
  if (this._oInputMarginLeft.getValueState() !== "Error") {
1239
- fMarginLeft = this._convertUnitToPx(this._oInputMarginLeft.getValue());
1177
+ fMarginLeft = PrintUtils._convertUnitToPx(this._oInputMarginLeft.getValue(),sUnit);
1240
1178
  }
1241
1179
 
1242
1180
  this._setMarginsToModel(fMarginTop, fMarginRight, fMarginBottom, fMarginLeft);
@@ -1253,7 +1191,8 @@ sap.ui.define([
1253
1191
 
1254
1192
  GanttPrinting.prototype._updateCropMarksOffsetInput = function () {
1255
1193
  var fCropMarksOffset = this._oModel.getProperty("/cropMarksOffset");
1256
- this._oInputCropMarksOffset.setValue(this._convertPxToUnit(fCropMarksOffset));
1194
+ var sUnit = this._oModel.getProperty("/unit");
1195
+ this._oInputCropMarksOffset.setValue(PrintUtils._convertPxToUnit(fCropMarksOffset,sUnit));
1257
1196
  };
1258
1197
 
1259
1198
  GanttPrinting.prototype._onChangeMarginInput = function (bSinglePage , oEvent) {
@@ -1264,7 +1203,8 @@ sap.ui.define([
1264
1203
  }
1265
1204
 
1266
1205
  if (this._oModel.getProperty("/marginLocked")) {
1267
- var fNewValue = this._convertUnitToPx(oChangedInput.getValue());
1206
+ var sUnit = this._oModel.getProperty("/unit");
1207
+ var fNewValue = PrintUtils._convertUnitToPx(oChangedInput.getValue(),sUnit);
1268
1208
 
1269
1209
  this._setMarginInputs(fNewValue, fNewValue, fNewValue, fNewValue);
1270
1210
  this._setMarginsToModel(fNewValue, fNewValue, fNewValue, fNewValue);
@@ -1281,9 +1221,10 @@ sap.ui.define([
1281
1221
 
1282
1222
  GanttPrinting.prototype._onChangeCropMarksInput = function (oEvent) {
1283
1223
  var oChangedInput = oEvent.getSource();
1284
- var fNewValue = this._convertUnitToPx(oChangedInput.getValue());
1224
+ var sUnit = this._oModel.getProperty("/unit");
1225
+ var fNewValue = PrintUtils._convertUnitToPx(oChangedInput.getValue(),sUnit);
1285
1226
 
1286
- this._oInputCropMarksOffset.setValue(this._convertPxToUnit(fNewValue));
1227
+ this._oInputCropMarksOffset.setValue(PrintUtils._convertPxToUnit(fNewValue,sUnit));
1287
1228
  this._oModel.setProperty("/cropMarksOffset", fNewValue);
1288
1229
  };
1289
1230
 
@@ -1334,6 +1275,7 @@ sap.ui.define([
1334
1275
  };
1335
1276
 
1336
1277
  GanttPrinting.prototype._onChangeDurationComboBox = function (bSinglePage) {
1278
+ this._validateDurationInput();
1337
1279
  var sDurationValue = this._oModel.getProperty("/duration");
1338
1280
 
1339
1281
  switch (sDurationValue) {
@@ -1365,6 +1307,7 @@ sap.ui.define([
1365
1307
 
1366
1308
  GanttPrinting.prototype._onChangeDurationDatePicker = function (bSinglePage) {
1367
1309
  this._oComboBoxDuration.setSelectedKey("custom");
1310
+ this._oComboBoxDuration.setValueState(ValueState.None);
1368
1311
  if (this._oDatePickerFrom.isValidValue() && this._oDatePickerTo.isValidValue()) {
1369
1312
  if ((this._oDatePickerFrom.getDateValue().getTime() <= this._oDatePickerTo.getDateValue().getTime())) {
1370
1313
  this._oDatePickerFrom.setValueState(ValueState.None);
@@ -1446,7 +1389,7 @@ sap.ui.define([
1446
1389
  var bPageNumber = this._oModel.getProperty("/showPageNumber"),
1447
1390
  bFooterText = this._oModel.getProperty("/showFooterText");
1448
1391
 
1449
- if (!bFooterText || !bPageNumber) {
1392
+ if (!bFooterText || !bPageNumber || this._bSinglePage ) {
1450
1393
  return false;
1451
1394
  }
1452
1395
 
@@ -1469,8 +1412,8 @@ sap.ui.define([
1469
1412
  oCanvasContext.font = TEXTFONT;
1470
1413
  var fFooterTextWidth = oCanvasContext.measureText(sFooterText).width;
1471
1414
 
1472
- if (fPaperWidth / 2 > (fMargin + mmToPx(4) /* footer text padding */
1473
- + fFooterTextWidth + mmToPx(10) /* space between text and page number */ + fPageNumberWidth)) {
1415
+ if (fPaperWidth / 2 > (fMargin + PrintUtils._mmToPx(4) /* footer text padding */
1416
+ + fFooterTextWidth + PrintUtils._mmToPx(10) /* space between text and page number */ + fPageNumberWidth)) {
1474
1417
  return false;
1475
1418
  } else {
1476
1419
  return true;
@@ -1739,7 +1682,6 @@ sap.ui.define([
1739
1682
  return;
1740
1683
  }
1741
1684
  var oModel = this._oModel;
1742
-
1743
1685
  // set new horizons values
1744
1686
  var oTimeStrategy = this._ganttChartClone.getAxisTimeStrategy();
1745
1687
  var oNewVisibleHorizon = oTimeStrategy.getVisibleHorizon().clone();
@@ -1760,6 +1702,31 @@ sap.ui.define([
1760
1702
  this._oButtonExport.setEnabled(false);
1761
1703
  }
1762
1704
 
1705
+ var clonedGanttDivCreated;
1706
+ if (!this._oClonedGanttDiv.id){
1707
+ this._oClonedGanttDiv.id = "clonedGanttDiv";
1708
+ clonedGanttDivCreated = true;
1709
+ if (this._getOriginalGanttChart().$().closest(".sapUiSizeCompact").length > 0) {
1710
+ this._oClonedGanttDiv.classList.add("sapUiSizeCompact");
1711
+ }
1712
+ this._oClonedGanttDiv.style.position = "absolute";
1713
+
1714
+ this._oClonedGanttDiv.style.top = "-17000px";
1715
+ this._oClonedGanttDiv.style.left = "-17000px";
1716
+
1717
+ //ganttChartContainer is not used when optimization is enabled.
1718
+ if (this._ganttChartClone._enableOptimisation) {
1719
+ this._ganttChartClone.placeAt("clonedGanttDiv");
1720
+ } else {
1721
+ this._ganttChartContainer.placeAt("clonedGanttDiv");
1722
+ }
1723
+ this._updateDialogErrorPDFPreview(false);
1724
+ }
1725
+ if (clonedGanttDivCreated){
1726
+ clonedGanttDivCreated = false;
1727
+ //Checks if the binding is present for the table, and if they are not, the bindings are reset.
1728
+ this._addBackOriginalGanttRowBinding(this._ganttChartClone, this._getOriginalGanttChart());
1729
+ }
1763
1730
  this._setGanttCloneDivWidth(oNewTotalHorizon);
1764
1731
  this._setGanttCloneDivHeight();
1765
1732
 
@@ -1889,11 +1856,14 @@ sap.ui.define([
1889
1856
  document.body.appendChild(this._oClonedGanttDiv);
1890
1857
  var height = this._getGanttCloneDivHeight();
1891
1858
  var width = this._getGanttCloneDivWidth(this._ganttChartClone.getAxisTimeStrategy().getTotalHorizon());
1892
-
1893
1859
  if (!bPdfPrint && ((width * this.canvasScale) > MAXCANVASSIZE || (height * this.canvasScale) > MAXCANVASSIZE)) {
1894
1860
  this._oClonedGanttDiv.error = true;
1895
1861
  return Promise.reject({bMaxCanvasSizeExceeded: true});
1896
1862
  }
1863
+ if (!this._validateDurationInput()) {
1864
+ this._oClonedGanttDiv.dateError = true;
1865
+ return Promise.reject({dateDurationNotSet: true});
1866
+ }
1897
1867
  this._oClonedGanttDiv.id = "clonedGanttDiv";
1898
1868
  if (this._getOriginalGanttChart().$().closest(".sapUiSizeCompact").length > 0) {
1899
1869
  this._oClonedGanttDiv.classList.add("sapUiSizeCompact");
@@ -1922,7 +1892,6 @@ sap.ui.define([
1922
1892
  } else {
1923
1893
  this._ganttChartContainer.placeAt("clonedGanttDiv");
1924
1894
  }
1925
-
1926
1895
  //Check if the binding is present for the table is not reset the bindings back.
1927
1896
  this._addBackOriginalGanttRowBinding(this._ganttChartClone, this._getOriginalGanttChart());
1928
1897
  // rendering done by generateCanvasAsync function in case of optimised printing
@@ -2075,16 +2044,16 @@ sap.ui.define([
2075
2044
  var bRTL = GanttChartConfigurationUtils.getRTL();
2076
2045
  if (bRTL) {
2077
2046
  oCanvasContext.textAlign = "right";
2078
- fXTextPosition = fPaperWidth - mmToPx(4);
2047
+ fXTextPosition = fPaperWidth - PrintUtils._mmToPx(4);
2079
2048
  /* text padding */
2080
2049
  } else {
2081
2050
  oCanvasContext.textAlign = "left";
2082
- fXTextPosition = mmToPx(4);
2051
+ fXTextPosition = PrintUtils._mmToPx(4);
2083
2052
  /* text padding */
2084
2053
  }
2085
2054
 
2086
2055
  var fEllipseWidth = oCanvasContext.measureText("...").width;
2087
- var fTargetWidth = fPaperWidth - mmToPx(4) - fEllipseWidth;
2056
+ var fTargetWidth = fPaperWidth - PrintUtils._mmToPx(4) - fEllipseWidth;
2088
2057
 
2089
2058
  var sHeaderText, sFooterText, iTruncatedChars, truncatePointRTL;
2090
2059
  // add header
@@ -2094,7 +2063,7 @@ sap.ui.define([
2094
2063
 
2095
2064
  var fHeaderTextWidth = oCanvasContext.measureText(sHeaderText).width;
2096
2065
 
2097
- if (fHeaderTextWidth > (fPaperWidth - mmToPx(4))){
2066
+ if (fHeaderTextWidth > (fPaperWidth - PrintUtils._mmToPx(4))){
2098
2067
  iTruncatedChars = GanttUtils.geNumberOfTruncatedCharacters(fHeaderTextWidth, fTargetWidth, sHeaderText, oCanvasContext, oCanvasContext.measureText, true);
2099
2068
 
2100
2069
  if (bRTL) {
@@ -2114,7 +2083,7 @@ sap.ui.define([
2114
2083
 
2115
2084
  var fFooterTextWidth = oCanvasContext.measureText(sFooterText).width;
2116
2085
 
2117
- if (fFooterTextWidth > (fPaperWidth - mmToPx(4))){
2086
+ if (fFooterTextWidth > (fPaperWidth - PrintUtils._mmToPx(4))){
2118
2087
  iTruncatedChars = GanttUtils.geNumberOfTruncatedCharacters(fFooterTextWidth, fTargetWidth, sFooterText, oCanvasContext, oCanvasContext.measureText, true);
2119
2088
 
2120
2089
  if (bRTL) {
@@ -2234,10 +2203,10 @@ sap.ui.define([
2234
2203
 
2235
2204
  var bRTL = GanttChartConfigurationUtils.getRTL();
2236
2205
  if (bRTL) {
2237
- fXTextPosition = fPaperWidth - mmToPx(4);
2206
+ fXTextPosition = fPaperWidth - PrintUtils._mmToPx(4);
2238
2207
  /* text padding */
2239
2208
  } else {
2240
- fXTextPosition = mmToPx(4);
2209
+ fXTextPosition = PrintUtils._mmToPx(4);
2241
2210
  /* text padding */
2242
2211
  }
2243
2212
 
@@ -2404,9 +2373,8 @@ sap.ui.define([
2404
2373
  $dialogPreviewDiv.appendChild(oCanvas);
2405
2374
  } else if (!this._oGanttCanvas
2406
2375
  && (this._oClonedGanttDiv.offsetWidth > MAXCANVASSIZE
2407
- || this._oClonedGanttDiv.offsetHeight > MAXCANVASSIZE || this._oClonedGanttDiv.error)) {
2376
+ || this._oClonedGanttDiv.offsetHeight > MAXCANVASSIZE || this._oClonedGanttDiv.error || this._oClonedGanttDiv.dateError)) {
2408
2377
 
2409
- this._oClonedGanttDiv.error = false;
2410
2378
  this._resizePrintingPreviewPage();
2411
2379
  this._oModel.setProperty("/qualityWarning", false);
2412
2380
  this._oModel.setProperty("/showOrientationMessage", false);
@@ -2415,10 +2383,19 @@ sap.ui.define([
2415
2383
  removeDialogPreviewChilds($dialogPreviewDiv);
2416
2384
 
2417
2385
  if (!this._oPreviewErrorMessageStrip) {
2418
- this._oPreviewErrorMessageStrip = this._createPreviewErrorMessageStrip(
2419
- this._oClonedGanttDiv.offsetHeight > MAXCANVASSIZE);
2386
+ if (this._oClonedGanttDiv.error){
2387
+ this._oClonedGanttDiv.error = false;
2388
+ this._oPreviewErrorMessageStrip = this._createPreviewErrorMessageStrip(
2389
+ this._oClonedGanttDiv.offsetHeight > MAXCANVASSIZE);
2390
+ } else if (this._oClonedGanttDiv.dateError){
2391
+ this._oClonedGanttDiv.dateError = false;
2392
+ this._oPreviewErrorMessageStrip = new MessageStrip({
2393
+ text: this._oRb.getText("GNT_PRNTG_ERROR_DATEDURATION_PREVIEW"),
2394
+ showIcon: true,
2395
+ type: "Error"
2396
+ });
2397
+ }
2420
2398
  }
2421
-
2422
2399
  var oPreviewErrorDiv = document.createElement("div");
2423
2400
  oPreviewErrorDiv.id = this.getId() + "-previewErrorMessageStrip";
2424
2401
  oPreviewErrorDiv.style.width = "80%";
@@ -2527,7 +2504,7 @@ sap.ui.define([
2527
2504
  bExportAll = this._oModel.getProperty("/exportAll"),
2528
2505
  aResultArray = [];
2529
2506
 
2530
- if (bExportAll) {
2507
+ if (bExportAll || this._bSinglePage) {
2531
2508
  for (var i = 1; i <= iLastPageNumber; i++) {
2532
2509
  aResultArray.push(i);
2533
2510
  }
@@ -2565,7 +2542,7 @@ sap.ui.define([
2565
2542
  GanttPrinting.prototype._validateFields = function () {
2566
2543
  var bValidated = true;
2567
2544
  bValidated &= this._validateExportRangeInput();
2568
-
2545
+ bValidated &= this._validateDurationInput();
2569
2546
  bValidated &= (this._oInputMarginTop.getValueState() !== "Error");
2570
2547
  bValidated &= (this._oInputMarginRight.getValueState() !== "Error");
2571
2548
  bValidated &= (this._oInputMarginBottom.getValueState() !== "Error");
@@ -2785,7 +2762,7 @@ sap.ui.define([
2785
2762
  oPdf.setFontSize(6.5);
2786
2763
 
2787
2764
  var fEllipseWidth = oPdf.getTextWidth('...') * JSPDFCONSTANT;
2788
- var fTargetWidth = fPaperWidth - mmToPx(4) - fEllipseWidth;
2765
+ var fTargetWidth = fPaperWidth - PrintUtils._mmToPx(4) - fEllipseWidth;
2789
2766
  var sHeaderText, sFooterText, iTruncatedChars, truncatePointRTL;
2790
2767
 
2791
2768
  var bRTL = GanttChartConfigurationUtils.getRTL();
@@ -2796,7 +2773,7 @@ sap.ui.define([
2796
2773
  nHeaderFooterHeight = nHeaderFooterHeight + this._iHeaderAndFooterHeight;
2797
2774
  var fHeaderTextWidth = oPdf.getTextWidth(sHeaderText) * JSPDFCONSTANT;
2798
2775
 
2799
- if (fHeaderTextWidth > (fPaperWidth - mmToPx(4))){
2776
+ if (fHeaderTextWidth > (fPaperWidth - PrintUtils._mmToPx(4))){
2800
2777
  iTruncatedChars = GanttUtils.geNumberOfTruncatedCharacters(fHeaderTextWidth, fTargetWidth, sHeaderText, oPdf, oPdf.getTextWidth, false, JSPDFCONSTANT);
2801
2778
  if (bRTL) {
2802
2779
  truncatePointRTL = sHeaderText.length - iTruncatedChars;
@@ -2816,7 +2793,7 @@ sap.ui.define([
2816
2793
 
2817
2794
  var fFooterTextWidth = oPdf.getTextWidth(sFooterText) * JSPDFCONSTANT;
2818
2795
 
2819
- if (fFooterTextWidth > (fPaperWidth - mmToPx(4))){
2796
+ if (fFooterTextWidth > (fPaperWidth - PrintUtils._mmToPx(4))){
2820
2797
  iTruncatedChars = GanttUtils.geNumberOfTruncatedCharacters(fFooterTextWidth, fTargetWidth, sFooterText, oPdf, oPdf.getTextWidth, false, JSPDFCONSTANT);
2821
2798
  if (bRTL) {
2822
2799
  truncatePointRTL = sFooterText.length - iTruncatedChars;
@@ -3179,8 +3156,11 @@ sap.ui.define([
3179
3156
  var oTotalHorizon = this._ganttChartClone.getAxisTimeStrategy().getTotalHorizon();
3180
3157
  var oStartTime = Format.abapTimestampToDate(oTotalHorizon.getStartTime());
3181
3158
  var oEndTime = Format.abapTimestampToDate(oTotalHorizon.getEndTime());
3182
-
3183
- this._oModel.setProperty("/startDate", oStartTime);
3159
+ this._customDates = {
3160
+ startDate : this._oModel.getProperty("/startDate"),
3161
+ endDate : this._oModel.getProperty("/endDate")
3162
+ };
3163
+ this._oModel.setProperty("/startDate",oStartTime);
3184
3164
  this._oModel.setProperty("/endDate", oEndTime);
3185
3165
  this._oModel.setProperty("/timezone", oLocale.getTimeZone());
3186
3166
 
@@ -3264,7 +3244,7 @@ sap.ui.define([
3264
3244
  this._oDatePickerTo
3265
3245
  ]
3266
3246
  }).addStyleClass("sapGanttPrintingSmallLeftMargin");
3267
-
3247
+ this._updatedatePickerValues();
3268
3248
  return new FlexBox({
3269
3249
  renderType: "Bare",
3270
3250
  alignItems: "Center",
@@ -3276,6 +3256,43 @@ sap.ui.define([
3276
3256
  ]
3277
3257
  });
3278
3258
  };
3259
+ /**
3260
+ * Updates the date picker values as per the provided duration.
3261
+ * @private
3262
+ */
3263
+ GanttPrinting.prototype._updatedatePickerValues = function () {
3264
+ var sDuration = this._oModel.getProperty("/duration");
3265
+ if (sDuration === "all") {
3266
+ var oTotalHorizon = this._ganttChartClone.getAxisTimeStrategy().getTotalHorizon();
3267
+ var oStartTime = Format.abapTimestampToDate(oTotalHorizon.getStartTime());
3268
+ var oEndTime = Format.abapTimestampToDate(oTotalHorizon.getEndTime());
3269
+ this._oModel.setProperty("/startDate", this._validateDate(oStartTime));
3270
+ this._oModel.setProperty("/endDate", this._validateDate(oEndTime));
3271
+ } else if (sDuration === "week") {
3272
+ this._nextWeekRange();
3273
+ } else if (sDuration === "month") {
3274
+ this._nextMonthRange();
3275
+ } else if (sDuration === "custom") {
3276
+ this._oModel.setProperty("/startDate", this._validateDate(this._customDates.startDate));
3277
+ this._oModel.setProperty("/endDate", this._validateDate(this._customDates.endDate));
3278
+ }
3279
+ var oStartDate = this._oModel.getProperty("/startDate");
3280
+ var oEndDate = this._oModel.getProperty("/endDate");
3281
+ this._oDatePickerFrom.setValue(oStartDate);
3282
+ this._oDatePickerTo.setValue(oEndDate);
3283
+
3284
+ var oTimeStrategy = this._ganttChartClone.getAxisTimeStrategy();
3285
+ var oNewVisibleHorizon = oTimeStrategy.getVisibleHorizon().clone();
3286
+ var oNewTotalHorizon = oTimeStrategy.getTotalHorizon().clone();
3287
+
3288
+ oNewVisibleHorizon.setStartTime(this._oModel.getProperty("/startDate"));
3289
+ oNewVisibleHorizon.setEndTime(this._oModel.getProperty("/endDate"));
3290
+ oNewTotalHorizon.setStartTime(this._oModel.getProperty("/startDate"));
3291
+ oNewTotalHorizon.setEndTime(this._oModel.getProperty("/endDate"));
3292
+
3293
+ oTimeStrategy.setTotalHorizon(oNewTotalHorizon);
3294
+ oTimeStrategy.setVisibleHorizon(oNewVisibleHorizon);
3295
+ };
3279
3296
 
3280
3297
  GanttPrinting.prototype._createScale = function () {
3281
3298
  return new Slider({
@@ -3293,7 +3310,7 @@ sap.ui.define([
3293
3310
 
3294
3311
  GanttPrinting.prototype._validateExportRangeInput = function () {
3295
3312
  // do not validate range field if we do not use it
3296
- if (this._oModel.getProperty("/exportAll")) {
3313
+ if (this._oModel.getProperty("/exportAll") || this._bSinglePage) {
3297
3314
  return true;
3298
3315
  }
3299
3316
 
@@ -3308,6 +3325,25 @@ sap.ui.define([
3308
3325
  return false;
3309
3326
  };
3310
3327
 
3328
+ /**
3329
+ * @returns {boolean} validity state of the provided duration input.
3330
+ * @private
3331
+ */
3332
+ GanttPrinting.prototype._validateDurationInput = function () {
3333
+ var sValue = this._oModel.getProperty("/duration");
3334
+ if (!["all",'week','month','custom'].includes(sValue)) {
3335
+ this._oComboBoxDuration.setValueState("Error");
3336
+ this._oComboBoxDuration.setValueStateText(this._oRb.getText("GNT_PRNTG_ERROR_DATEDURATION"));
3337
+ this._oDatePickerFrom.setValueState("Error");
3338
+ this._oDatePickerTo.setValueState("Error");
3339
+ return false;
3340
+ }
3341
+ this._oComboBoxDuration.setValueState("None");
3342
+ this._oDatePickerFrom.setValueState("None");
3343
+ this._oDatePickerTo.setValueState("None");
3344
+ return true;
3345
+ };
3346
+
3311
3347
  GanttPrinting.prototype._createPageRange = function () {
3312
3348
  this._oRangeLabel = new InvisibleText({
3313
3349
  text: this._oRb.getText("GNT_PRNTG_PAGE_RANGE")
@@ -3541,8 +3577,9 @@ sap.ui.define([
3541
3577
  this._oMarginRight.toStatic();
3542
3578
 
3543
3579
  function setMaxMargin(fPaperSize) {
3580
+ var sUnit = this._oModel.getProperty("/unit");
3544
3581
  // max margin is 33.3% of paper size
3545
- return Math.round(this._convertPxToUnit(fPaperSize / 3));
3582
+ return Math.round(PrintUtils._convertPxToUnit(fPaperSize / 3,sUnit));
3546
3583
  }
3547
3584
  // eslint-disable-next-line no-return-assign
3548
3585
  return [
@@ -3599,7 +3636,7 @@ sap.ui.define([
3599
3636
  },
3600
3637
  displayValuePrecision: 1,
3601
3638
  change: this._onChangeMarginInput.bind(this, bSinglePage),
3602
- value: this._convertPxToUnit(this._oModel.getProperty("/marginTop")),
3639
+ value: PrintUtils._convertPxToUnit(this._oModel.getProperty("/marginTop"),this._oModel.getProperty("/unit")),
3603
3640
  fieldWidth: "7rem",
3604
3641
  validationMode: "LiveChange",
3605
3642
  valueStateText: this._oRb.getText("GNT_PRNTG_MARGIN_HEIGHT_ERROR"),
@@ -3625,7 +3662,7 @@ sap.ui.define([
3625
3662
  },
3626
3663
  displayValuePrecision: 1,
3627
3664
  change: this._onChangeMarginInput.bind(this, bSinglePage),
3628
- value: this._convertPxToUnit(this._oModel.getProperty("/marginLeft")),
3665
+ value: PrintUtils._convertPxToUnit(this._oModel.getProperty("/marginLeft"),this._oModel.getProperty("/unit")),
3629
3666
  fieldWidth: "7rem",
3630
3667
  validationMode: "LiveChange",
3631
3668
  valueStateText: this._oRb.getText("GNT_PRNTG_MARGIN_WIDTH_ERROR"),
@@ -3661,7 +3698,7 @@ sap.ui.define([
3661
3698
  },
3662
3699
  displayValuePrecision: 1,
3663
3700
  change: this._onChangeMarginInput.bind(this, bSinglePage),
3664
- value: this._convertPxToUnit(this._oModel.getProperty("/marginBottom")),
3701
+ value: PrintUtils._convertPxToUnit(this._oModel.getProperty("/marginBottom"),this._oModel.getProperty("/unit")),
3665
3702
  fieldWidth: "7rem",
3666
3703
  validationMode: "LiveChange",
3667
3704
  valueStateText: this._oRb.getText("GNT_PRNTG_MARGIN_HEIGHT_ERROR"),
@@ -3687,7 +3724,7 @@ sap.ui.define([
3687
3724
  },
3688
3725
  displayValuePrecision: 1,
3689
3726
  change: this._onChangeMarginInput.bind(this, bSinglePage),
3690
- value: this._convertPxToUnit(this._oModel.getProperty("/marginRight")),
3727
+ value: PrintUtils._convertPxToUnit(this._oModel.getProperty("/marginRight"),this._oModel.getProperty("/unit")),
3691
3728
  fieldWidth: "7rem",
3692
3729
  validationMode: "LiveChange",
3693
3730
  valueStateText: this._oRb.getText("GNT_PRNTG_MARGIN_WIDTH_ERROR"),
@@ -3770,7 +3807,7 @@ sap.ui.define([
3770
3807
  },
3771
3808
  displayValuePrecision: 1,
3772
3809
  change: this._onChangeCropMarksInput.bind(this),
3773
- value: this._convertPxToUnit(this._oModel.getProperty("/cropMarksOffset")),
3810
+ value: PrintUtils._convertPxToUnit(this._oModel.getProperty("/cropMarksOffset"),this._oModel.getProperty("/unit")),
3774
3811
  fieldWidth: "7rem",
3775
3812
  description: "{setting>/unit}"
3776
3813
  })
@@ -4186,8 +4223,92 @@ sap.ui.define([
4186
4223
  }
4187
4224
  return oDialogContent;
4188
4225
  };
4226
+ /**
4227
+ * @since 1.127
4228
+ * Gets the print configuration class with the configuration data.
4229
+ * @returns {sap.gantt.simple.PrintConfig} Print configuration class instance with print configuration data
4230
+ * @public
4231
+ */
4232
+ GanttPrinting.prototype.getPrintData = function(){
4233
+ var oConfigData = Object.assign({}, this._oModel.getData());
4234
+ var sUnit = this._oModel.getProperty("/unit");
4235
+ var objPrintConfigClass = new PrintConfig({
4236
+ pageConfig: {
4237
+ paperHeight: PrintUtils._convertPxToUnit(oConfigData.paperHeight,sUnit),
4238
+ paperWidth: PrintUtils._convertPxToUnit(oConfigData.paperWidth,sUnit),
4239
+ paperSize: oConfigData.paperSize,
4240
+ unit: oConfigData.unit,
4241
+ portrait: oConfigData.portrait,
4242
+ showPageNumber: oConfigData.showPageNumber
4243
+ },
4244
+ textConfig: {
4245
+ showHeaderText: oConfigData.showHeaderText,
4246
+ showFooterText: oConfigData.showFooterText,
4247
+ headerText: oConfigData.headerText,
4248
+ footerText: oConfigData.footerText
4249
+ },
4250
+ marginConfig: {
4251
+ marginLeft: PrintUtils._convertPxToUnit(oConfigData.marginLeft,sUnit),
4252
+ marginBottom: PrintUtils._convertPxToUnit(oConfigData.marginBottom,sUnit),
4253
+ marginRight: PrintUtils._convertPxToUnit(oConfigData.marginRight,sUnit),
4254
+ marginTop: PrintUtils._convertPxToUnit(oConfigData.marginTop,sUnit),
4255
+ marginLocked: oConfigData.marginLocked,
4256
+ marginType: oConfigData.marginType
4257
+ },
4258
+ durationConfig: {
4259
+ duration: oConfigData.duration,
4260
+ startDate: oConfigData.startDate,
4261
+ endDate: oConfigData.endDate
4262
+ },
4263
+ exportConfig: {
4264
+ exportAsJPEG: oConfigData.exportAsJPEG,
4265
+ exportRange: oConfigData.exportRange,
4266
+ exportAll: oConfigData.exportAll,
4267
+ compressionQuality: oConfigData.compressionQuality,
4268
+ scale: oConfigData.scale,
4269
+ multiplePage: oConfigData.multiplePage
4270
+ }
4271
+ });
4272
+ return objPrintConfigClass;
4273
+ };
4274
+ /**
4275
+ * Sets the print configuration data.
4276
+ * @since 1.127
4277
+ * @public
4278
+ * @param {sap.gantt.simple.PrintConfig} objClass configuration class instance with print configuration data.
4279
+ */
4280
+ GanttPrinting.prototype.setPrintData = function(objClass){
4281
+ if (objClass){
4282
+ this._updateModel(objClass);
4283
+ } else {
4284
+ throw new Error("Invalid print config data is set");
4285
+ }
4286
+ };
4189
4287
 
4190
- GanttPrinting.prototype._createAndOpenDialog = function (bSinglePage) {
4288
+ /**
4289
+ * Updates the model with the provided print configuration data class.
4290
+ * @param {sap.gantt.simple.PrintConfig} objClass configuration class instance with print configuration data.
4291
+ * @private
4292
+ */
4293
+ GanttPrinting.prototype._updateModel = function (objClass) {
4294
+ this._oModel = new JSONModel({
4295
+ ...this.oInitialValues,
4296
+ ...(objClass._getPageConfig() || {}),
4297
+ ...(objClass._getTextConfig() || {}),
4298
+ ...(objClass._getMarginConfig() || {}),
4299
+ ...(objClass._getDurationConfig() || {}),
4300
+ ...(objClass._getExportConfig() || {})
4301
+ });
4302
+ ["paperHeight", "paperWidth", "marginTop", "marginLeft", "marginBottom", "marginRight"].forEach(function(property){
4303
+ this._oModel.setProperty(`/${property}`, PrintUtils._convertUnitToPx(this._oModel.getProperty(`/${property}`),this._oModel.getProperty("/unit")));
4304
+ }.bind(this));
4305
+ };
4306
+
4307
+ GanttPrinting.prototype._createAndOpenDialog = function (bSinglePage,printDialogTemplate) {
4308
+ var footerButtonsArray = printDialogTemplate && printDialogTemplate.getFooterButtons() || [];
4309
+ var buttonsArray = footerButtonsArray && footerButtonsArray.map(function(button){
4310
+ return button.clone();
4311
+ });
4191
4312
  var fnExport = bSinglePage ? this.exportSinglePage : this.export;
4192
4313
  this._oDialog = new Dialog({
4193
4314
  title: this._oRb.getText("GNT_PRNTG_PDF_EXPORT_TITLE"),
@@ -4198,20 +4319,13 @@ sap.ui.define([
4198
4319
  content: [
4199
4320
  this._createDialogContent(bSinglePage)
4200
4321
  ],
4201
-
4202
4322
  buttons: [
4323
+ this._footerButtons = buttonsArray,
4203
4324
  this._oButtonExport = new Button({
4204
4325
  text: this._oRb.getText("GNT_PRNTG_EXPORT"),
4205
4326
  type: MobileLibrary.ButtonType.Emphasized,
4206
4327
  press: fnExport.bind(this)
4207
4328
  }),
4208
- // TODO add this feature
4209
- // new Button({
4210
- // text: "Save preset",
4211
- // press: function () {
4212
- // this.savePreset();
4213
- // }.bind(this)
4214
- // }),
4215
4329
  this._oButtonClose = new Button({
4216
4330
  text: this._oRb.getText("GNT_PRNTG_CANCEL"),
4217
4331
  press: function () {