@syncfusion/ej2-docx-renderer 0.0.0-stage → 35.2.15
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.
- package/README.md +2 -2
- package/base.d.ts +4 -0
- package/base.js +4 -0
- package/dist/ej2-docx-renderer.umd.min.js +2 -0
- package/dist/ej2-docx-renderer.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx-renderer.es2015.js +52432 -0
- package/dist/es6/ej2-docx-renderer.es2015.js.map +1 -0
- package/dist/es6/ej2-docx-renderer.es5.js +54425 -0
- package/dist/es6/ej2-docx-renderer.es5.js.map +1 -0
- package/dist/global/ej2-docx-renderer.min.js +2 -0
- package/dist/global/ej2-docx-renderer.min.js.map +1 -0
- package/dist/global/index.d.ts +5 -0
- package/format.d.ts +4 -0
- package/format.js +4 -0
- package/helper.d.ts +4 -0
- package/helper.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/list.d.ts +4 -0
- package/list.js +4 -0
- package/package.json +26 -4
- package/parser.d.ts +4 -0
- package/parser.js +4 -0
- package/src/base/constants.d.ts +2 -0
- package/src/base/constants.js +2 -0
- package/src/base/dictionary.d.ts +52 -0
- package/src/base/dictionary.js +137 -0
- package/src/base/index.d.ts +9 -0
- package/src/base/index.js +9 -0
- package/src/base/keywords.d.ts +422 -0
- package/src/base/keywords.js +422 -0
- package/src/base/types.d.ts +2590 -0
- package/src/base/types.js +1056 -0
- package/src/base/unique-format.d.ts +87 -0
- package/src/base/unique-format.js +858 -0
- package/src/base/unique-formats.d.ts +32 -0
- package/src/base/unique-formats.js +87 -0
- package/src/document-canvas.d.ts +61 -0
- package/src/document-canvas.js +221 -0
- package/src/docx-renderer.d.ts +941 -0
- package/src/docx-renderer.js +2251 -0
- package/src/format/border.d.ts +53 -0
- package/src/format/border.js +600 -0
- package/src/format/borders.d.ts +44 -0
- package/src/format/borders.js +314 -0
- package/src/format/cell-format.d.ts +42 -0
- package/src/format/cell-format.js +309 -0
- package/src/format/character-format.d.ts +152 -0
- package/src/format/character-format.js +1224 -0
- package/src/format/index.d.ts +14 -0
- package/src/format/index.js +14 -0
- package/src/format/list-format.d.ts +32 -0
- package/src/format/list-format.js +238 -0
- package/src/format/paragraph-format.d.ts +103 -0
- package/src/format/paragraph-format.js +854 -0
- package/src/format/row-format.d.ts +119 -0
- package/src/format/row-format.js +545 -0
- package/src/format/section-format.d.ts +89 -0
- package/src/format/section-format.js +689 -0
- package/src/format/shading.d.ts +24 -0
- package/src/format/shading.js +137 -0
- package/src/format/style.d.ts +106 -0
- package/src/format/style.js +286 -0
- package/src/format/table-format.d.ts +51 -0
- package/src/format/table-format.js +395 -0
- package/src/global.js +1 -0
- package/src/helper/document-editor-helper.d.ts +515 -0
- package/src/helper/document-editor-helper.js +1302 -0
- package/src/helper/document-editor-settings.d.ts +293 -0
- package/src/helper/document-editor-settings.js +94 -0
- package/src/helper/index.d.ts +5 -0
- package/src/helper/index.js +5 -0
- package/src/helper/layout-helper-methods.d.ts +539 -0
- package/src/helper/layout-helper-methods.js +1065 -0
- package/src/helper/renderer-hooks.d.ts +74 -0
- package/src/helper/renderer-hooks.js +14 -0
- package/src/helper/revision-helper-methods.d.ts +199 -0
- package/src/helper/revision-helper-methods.js +362 -0
- package/src/index.d.ts +18 -0
- package/src/index.js +18 -0
- package/src/layout-helper.d.ts +190 -0
- package/src/layout-helper.js +1368 -0
- package/src/layout.d.ts +779 -0
- package/src/layout.js +17232 -0
- package/src/list/abstract-list.d.ts +25 -0
- package/src/list/abstract-list.js +67 -0
- package/src/list/index.d.ts +7 -0
- package/src/list/index.js +7 -0
- package/src/list/level-override.d.ts +22 -0
- package/src/list/level-override.js +43 -0
- package/src/list/list-level.d.ts +57 -0
- package/src/list/list-level.js +249 -0
- package/src/list/list.d.ts +30 -0
- package/src/list/list.js +100 -0
- package/src/page.d.ts +4155 -0
- package/src/page.js +11342 -0
- package/src/parser/index.d.ts +1 -0
- package/src/parser/index.js +1 -0
- package/src/parser/sfdt-reader.d.ts +254 -0
- package/src/parser/sfdt-reader.js +4569 -0
- package/src/render.d.ts +226 -0
- package/src/render.js +4222 -0
- package/src/text-helper.d.ts +144 -0
- package/src/text-helper.js +1079 -0
- package/src/text-helpers/index.d.ts +2 -0
- package/src/text-helpers/index.js +2 -0
- package/src/text-helpers/optimized.d.ts +45 -0
- package/src/text-helpers/optimized.js +121 -0
- package/src/text-helpers/regular.d.ts +37 -0
- package/src/text-helpers/regular.js +93 -0
- package/src/themes/font-scheme.d.ts +28 -0
- package/src/themes/font-scheme.js +107 -0
- package/src/themes/index.d.ts +6 -0
- package/src/themes/index.js +6 -0
- package/src/themes/major-minor-font-scheme.d.ts +14 -0
- package/src/themes/major-minor-font-scheme.js +45 -0
- package/src/themes/themes.d.ts +11 -0
- package/src/themes/themes.js +31 -0
- package/src/utility/index.d.ts +1 -0
- package/src/utility/index.js +1 -0
- package/src/utility/path-util.d.ts +133 -0
- package/src/utility/path-util.js +639 -0
- package/text-helpers.d.ts +4 -0
- package/text-helpers.js +4 -0
- package/themes.d.ts +4 -0
- package/themes.js +4 -0
- package/utility.d.ts +4 -0
- package/utility.js +4 -0
|
@@ -0,0 +1,1368 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
import { WColumnFormat } from './format/index';
|
|
16
|
+
import { Page, Rect, ParagraphWidget, HeaderFooterWidget, Padding, TextFrame, FootNoteWidget, ShapeBase } from './page';
|
|
17
|
+
import { LineWidget, TableWidget, TableRowWidget } from './page';
|
|
18
|
+
import { LayoutHelperMethods } from './index';
|
|
19
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
var LayoutHelper = /** @class */ (function () {
|
|
24
|
+
function LayoutHelper(owner) {
|
|
25
|
+
this.visiblePages = [];
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
this.padding = new Padding(10, 10, 30, 10);
|
|
30
|
+
/**
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
this.textWrap = true;
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
this.containerTop = 0;
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
this.containerWidth = 0;
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
this.containerLeft = 0;
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
this.isWebPrinting = false;
|
|
50
|
+
this.documentHelper = owner;
|
|
51
|
+
this.columnLayoutArea = new ColumnLayout(this);
|
|
52
|
+
}
|
|
53
|
+
LayoutHelper.prototype.updateClientArea = function (bodyWidget, page, isReLayout) {
|
|
54
|
+
var sectionFormat;
|
|
55
|
+
if (!isNullOrUndefined(bodyWidget)) {
|
|
56
|
+
sectionFormat = bodyWidget.sectionFormat;
|
|
57
|
+
this.columnLayoutArea.setColumns(sectionFormat);
|
|
58
|
+
}
|
|
59
|
+
var width = 0;
|
|
60
|
+
var height = 0;
|
|
61
|
+
if (this instanceof WebLayoutHelper) {
|
|
62
|
+
var top_1 = 0;
|
|
63
|
+
width = (this.documentHelper.visibleBounds.width - (this.padding.right * 4) - (this.padding.left * 2)) / this.documentHelper.zoomFactor;
|
|
64
|
+
if (width < 0) {
|
|
65
|
+
width = 0;
|
|
66
|
+
}
|
|
67
|
+
height = Number.POSITIVE_INFINITY;
|
|
68
|
+
this.clientArea = new Rect(this.padding.left / this.documentHelper.zoomFactor, top_1, width, height);
|
|
69
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
var top_2 = 0;
|
|
73
|
+
var headerDistance = 48;
|
|
74
|
+
var footerDistance = 48;
|
|
75
|
+
var pageHeight = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageHeight);
|
|
76
|
+
var bottomMargin = LayoutHelperMethods.convertPointToPixel(sectionFormat.bottomMargin);
|
|
77
|
+
if (!isNullOrUndefined(sectionFormat)) {
|
|
78
|
+
top_2 = LayoutHelperMethods.convertPointToPixel(sectionFormat.topMargin);
|
|
79
|
+
headerDistance = LayoutHelperMethods.convertPointToPixel(sectionFormat.headerDistance);
|
|
80
|
+
footerDistance = LayoutHelperMethods.convertPointToPixel(sectionFormat.footerDistance);
|
|
81
|
+
}
|
|
82
|
+
var isEmptyWidget = false;
|
|
83
|
+
if (!isNullOrUndefined(page.headerWidget)) {
|
|
84
|
+
isEmptyWidget = page.headerWidget.isEmpty;
|
|
85
|
+
if (top_2 >= 0) {
|
|
86
|
+
if (!isEmptyWidget || isEmptyWidget && this.documentHelper.editorProperties.enableHeaderAndFooter) {
|
|
87
|
+
// For Word 2013, header can able to placed beyond 40% of page height.
|
|
88
|
+
if (this.documentHelper.compatibilityMode === 'Word2013') {
|
|
89
|
+
top_2 = Math.max(headerDistance + page.headerWidget.height, top_2);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
top_2 = Math.min(Math.max(headerDistance + page.headerWidget.height, top_2), pageHeight / 100 * 40);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
top_2 = Math.abs(top_2);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var bottom = 0.667 + bottomMargin;
|
|
101
|
+
if (!isNullOrUndefined(page.footerWidget)) {
|
|
102
|
+
isEmptyWidget = page.footerWidget.isEmpty;
|
|
103
|
+
var footnoteHeight = !isNullOrUndefined(page.footnoteWidget) ? page.footnoteWidget.height : 0;
|
|
104
|
+
footnoteHeight = Math.min(footnoteHeight, ((pageHeight - top_2 - bottom) / 100 * 90));
|
|
105
|
+
if (bottom >= 0) {
|
|
106
|
+
if (!isEmptyWidget || isEmptyWidget && this.documentHelper.editorProperties.enableHeaderAndFooter) {
|
|
107
|
+
bottom = 0.667 + Math.min(pageHeight / 100 * 40, Math.max(footerDistance + page.footerWidget.height, bottomMargin));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
bottom = Math.abs(bottom);
|
|
112
|
+
}
|
|
113
|
+
bottom += footnoteHeight;
|
|
114
|
+
}
|
|
115
|
+
if (!isNullOrUndefined(sectionFormat)) {
|
|
116
|
+
width = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageWidth - sectionFormat.leftMargin - sectionFormat.rightMargin);
|
|
117
|
+
height = pageHeight - top_2 - bottom;
|
|
118
|
+
}
|
|
119
|
+
if (width < 0) {
|
|
120
|
+
width = 0;
|
|
121
|
+
}
|
|
122
|
+
var clientArea = new Rect(LayoutHelperMethods.convertPointToPixel(sectionFormat.leftMargin), top_2, width, pageHeight - top_2 - bottom);
|
|
123
|
+
if (page.footnoteWidget && isReLayout && !this.documentHelper.editorProperties.isFootNote) {
|
|
124
|
+
if (page.footnoteWidget.y !== 0 && this.clientArea.y + this.clientArea.height > page.footnoteWidget.y) {
|
|
125
|
+
var sub = (this.clientArea.y + this.clientArea.height - page.footnoteWidget.y);
|
|
126
|
+
this.clientArea.height -= sub / 2;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (bodyWidget.page.bodyWidgets[0].columnIndex !== 0) {
|
|
130
|
+
this.documentHelper.layout.updateColumnIndex(bodyWidget, false, true);
|
|
131
|
+
}
|
|
132
|
+
this.setClientArea(bodyWidget, clientArea);
|
|
133
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
LayoutHelper.prototype.setClientArea = function (bodyWidget, clientArea) {
|
|
137
|
+
this.clientArea = this.columnLayoutArea.getColumnBoundsByBodyWidget(bodyWidget, clientArea);
|
|
138
|
+
bodyWidget.x = this.clientArea.x;
|
|
139
|
+
bodyWidget.width = this.clientArea.width;
|
|
140
|
+
};
|
|
141
|
+
LayoutHelper.prototype.updateClientAreaTopOrLeft = function (tableWidget, beforeLayout) {
|
|
142
|
+
if (beforeLayout) {
|
|
143
|
+
this.clientActiveArea.y = this.clientActiveArea.y + tableWidget.topBorderWidth;
|
|
144
|
+
this.clientActiveArea.x = this.clientActiveArea.x + tableWidget.leftBorderWidth;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
LayoutHelper.prototype.updateClientAreaForTable = function (tableWidget) {
|
|
148
|
+
this.clientActiveArea.x = this.clientArea.x = tableWidget.x;
|
|
149
|
+
this.clientActiveArea.width = this.clientArea.width = tableWidget.width;
|
|
150
|
+
};
|
|
151
|
+
LayoutHelper.prototype.updateClientAreaForRow = function (row, beforeLayout) {
|
|
152
|
+
var tableWidget = row.ownerTable;
|
|
153
|
+
if (beforeLayout) {
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.clientActiveArea.x = this.clientArea.x = tableWidget.x;
|
|
157
|
+
this.clientActiveArea.width = this.clientArea.width = tableWidget.width;
|
|
158
|
+
this.clientArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
159
|
+
this.clientActiveArea = new Rect(this.clientActiveArea.x, this.clientActiveArea.y, this.clientActiveArea.width, this.clientActiveArea.height);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
LayoutHelper.prototype.updateClientAreaForCell = function (cell, beforeLayout) {
|
|
163
|
+
var rowWidget = cell.ownerRow;
|
|
164
|
+
var cellWidget = cell;
|
|
165
|
+
if (beforeLayout) {
|
|
166
|
+
this.clientActiveArea.x = this.clientArea.x = cellWidget.x;
|
|
167
|
+
this.clientActiveArea.y = cellWidget.y;
|
|
168
|
+
this.clientActiveArea.width = this.clientArea.width = cellWidget.width > 0 ? cellWidget.width : 0;
|
|
169
|
+
if ((this instanceof PageLayoutHelper)) {
|
|
170
|
+
this.clientActiveArea.height = Number.POSITIVE_INFINITY;
|
|
171
|
+
}
|
|
172
|
+
this.clientArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
173
|
+
this.clientActiveArea = new Rect(this.clientActiveArea.x, this.clientActiveArea.y, this.clientActiveArea.width, this.clientActiveArea.height);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.clientActiveArea.x = this.clientArea.x = cellWidget.x + cellWidget.width + cellWidget.margin.right;
|
|
177
|
+
if (rowWidget.x + rowWidget.width - this.clientArea.x < 0) {
|
|
178
|
+
this.clientActiveArea.width = this.clientArea.width = 0;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.clientActiveArea.width = this.clientArea.width = rowWidget.x + rowWidget.width - this.clientArea.x;
|
|
182
|
+
}
|
|
183
|
+
this.clientActiveArea.y = cellWidget.y - cellWidget.margin.top - LayoutHelperMethods.convertPointToPixel(cell.ownerTable.tableFormat.cellSpacing);
|
|
184
|
+
if (!cell.ownerTable.isInsideTable) {
|
|
185
|
+
this.clientActiveArea.height = this.clientArea.bottom - rowWidget.y > 0 ? this.clientArea.bottom - rowWidget.y : 0;
|
|
186
|
+
if (!cell.ownerTable.wrapTextAround && this.documentHelper.layout.existFootnoteHeight > 0) {
|
|
187
|
+
var updateHeight = this.clientActiveArea.height - this.documentHelper.layout.existFootnoteHeight;
|
|
188
|
+
this.clientActiveArea.height = updateHeight < 0 ? 0 : updateHeight;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
this.clientArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
192
|
+
this.clientActiveArea = new Rect(this.clientActiveArea.x, this.clientActiveArea.y, this.clientActiveArea.width, this.clientActiveArea.height);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
LayoutHelper.prototype.updateClientAreaForTextBoxShape = function (textBox, beforeLayout, shiftNextWidget) {
|
|
196
|
+
if (textBox.textWrappingStyle === 'Inline' && !shiftNextWidget && isNullOrUndefined(textBox.containerShape)) {
|
|
197
|
+
textBox.y = this.clientActiveArea.y;
|
|
198
|
+
textBox.x = this.clientActiveArea.x;
|
|
199
|
+
}
|
|
200
|
+
if (beforeLayout) {
|
|
201
|
+
var marginLeft = textBox.textFrame.marginLeft;
|
|
202
|
+
var marginRight = textBox.textFrame.marginRight;
|
|
203
|
+
var marginTop = textBox.textFrame.marginTop;
|
|
204
|
+
var marginBottom = textBox.textFrame.marginBottom;
|
|
205
|
+
var width = textBox.width;
|
|
206
|
+
var height = Number.POSITIVE_INFINITY;
|
|
207
|
+
this.clientArea = new Rect(textBox.x + marginLeft, textBox.y + marginTop, width - marginLeft - marginRight, height - marginTop - marginBottom);
|
|
208
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
LayoutHelper.prototype.updateClientAreaByWidgetFootNote = function (widget) {
|
|
212
|
+
this.clientArea.x = widget.x;
|
|
213
|
+
this.clientArea.y = widget.y;
|
|
214
|
+
this.clientActiveArea.x = widget.x;
|
|
215
|
+
this.clientActiveArea.y = widget.y;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
LayoutHelper.prototype.updateClientAreaForTextWrap = function (area) {
|
|
221
|
+
this.clientActiveArea = new Rect(area.x, area.y, area.width, area.height);
|
|
222
|
+
};
|
|
223
|
+
LayoutHelper.prototype.updateBoundsBasedOnTextWrap = function (bottom) {
|
|
224
|
+
var diff = bottom - this.clientActiveArea.y;
|
|
225
|
+
this.clientActiveArea.y = bottom;
|
|
226
|
+
this.clientActiveArea.height = this.clientActiveArea.height - diff;
|
|
227
|
+
};
|
|
228
|
+
LayoutHelper.prototype.updateBoundsBasedOnTextWrapTable = function (bottom) {
|
|
229
|
+
if (bottom > this.clientArea.bottom) {
|
|
230
|
+
this.clientActiveArea = new Rect(this.clientArea.x, bottom, this.clientArea.width, this.clientArea.bottom - bottom);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
var diff = bottom - this.clientArea.y;
|
|
234
|
+
this.clientArea.y = bottom;
|
|
235
|
+
this.clientArea.height = this.clientArea.height - diff;
|
|
236
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
237
|
+
};
|
|
238
|
+
LayoutHelper.prototype.updateClientAreaByWidget = function (widget) {
|
|
239
|
+
this.clientArea.x = widget.x;
|
|
240
|
+
this.clientArea.y = widget.y;
|
|
241
|
+
this.clientActiveArea.x = widget.x;
|
|
242
|
+
this.clientActiveArea.y = widget.y;
|
|
243
|
+
};
|
|
244
|
+
LayoutHelper.prototype.updateClientAreaLocation = function (widget, area) {
|
|
245
|
+
widget.x = area.x;
|
|
246
|
+
widget.y = area.y;
|
|
247
|
+
widget.width = area.width;
|
|
248
|
+
};
|
|
249
|
+
LayoutHelper.prototype.updateClientAreaForBlock = function (block, beforeLayout, tableCollection, updateYPosition, updateXPosition) {
|
|
250
|
+
var leftIndent = LayoutHelperMethods.convertPointToPixel(block.leftIndent);
|
|
251
|
+
var rightIndent = LayoutHelperMethods.convertPointToPixel(block.rightIndent);
|
|
252
|
+
var bidi = block.bidi;
|
|
253
|
+
var width = 0;
|
|
254
|
+
if (beforeLayout) {
|
|
255
|
+
if (block instanceof TableWidget && tableCollection) {
|
|
256
|
+
var tableWidget = tableCollection[0];
|
|
257
|
+
if (block.bodyWidget.sectionFormat.columns.length <= 1) {
|
|
258
|
+
this.clientActiveArea.x = this.clientArea.x = tableWidget.x;
|
|
259
|
+
this.clientActiveArea.width = this.clientArea.width = tableWidget.width;
|
|
260
|
+
if (updateXPosition && this.documentHelper.getFirstParagraphInFirstCell(block)) {
|
|
261
|
+
this.updateTableXPositionBasedOnTextWrap(block);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//Updates the location of last item.
|
|
265
|
+
tableWidget = tableCollection[tableCollection.length - 1];
|
|
266
|
+
tableWidget.x = this.clientActiveArea.x;
|
|
267
|
+
tableWidget.y = this.clientActiveArea.y;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
if (block instanceof TableWidget && !isNullOrUndefined(block.tableFormat)) {
|
|
271
|
+
if (!block.isGridUpdated) {
|
|
272
|
+
block.buildTableColumns();
|
|
273
|
+
block.isGridUpdated = true;
|
|
274
|
+
}
|
|
275
|
+
var tableAlignment = this.tableAlignmentForBidi(block, bidi);
|
|
276
|
+
// For Auto Fit to Window case, the left indent should not be included in the calculation.
|
|
277
|
+
if (tableAlignment !== 'Left' && (!isNullOrUndefined(this.documentHelper) && this.documentHelper.isEditorModule && !this.documentHelper.editorProperties.isAutofitToWindow)) {
|
|
278
|
+
var tableWidth = 0;
|
|
279
|
+
// If the grid is calculated, we can direclty get the width from the grid.
|
|
280
|
+
// Otherwise, calculate the width.
|
|
281
|
+
tableWidth = LayoutHelperMethods.convertPointToPixel(block.tableHolder.getTotalWidth(0));
|
|
282
|
+
tableWidth = tableWidth === 0 ? block.tableHolder.tableWidth === 0 ?
|
|
283
|
+
block.getTableClientWidth(block.getOwnerWidth(false)) : block.tableHolder.tableWidth : tableWidth;
|
|
284
|
+
if (tableAlignment === 'Center') {
|
|
285
|
+
if (!this.documentHelper.isRowOrCellResizing) {
|
|
286
|
+
tableWidth = block.getTableCellWidth();
|
|
287
|
+
}
|
|
288
|
+
if ((this.documentHelper.viewer instanceof PageLayoutHelper)) {
|
|
289
|
+
leftIndent = (this.clientArea.width - tableWidth) / 2;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
leftIndent = this.clientArea.width - tableWidth;
|
|
294
|
+
}
|
|
295
|
+
if (bidi) {
|
|
296
|
+
leftIndent = leftIndent - LayoutHelperMethods.convertPointToPixel(block.leftIndent);
|
|
297
|
+
rightIndent = leftIndent;
|
|
298
|
+
}
|
|
299
|
+
if (!block.isInsideTable) {
|
|
300
|
+
//leftIndent = (block.tableFormat.horizontalPositionAbs === 'Left') ? block.tableFormat.horizontalPosition : leftIndent;
|
|
301
|
+
}
|
|
302
|
+
this.documentHelper.tableLefts.push(leftIndent);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
width = this.clientArea.width - (leftIndent + LayoutHelperMethods.convertPointToPixel(block.rightIndent));
|
|
306
|
+
var x = this.clientArea.x + (bidi ? rightIndent : leftIndent);
|
|
307
|
+
width = (width > 0 || (block instanceof ParagraphWidget && block.paragraphFormat.firstLineIndent < 0)) ? width : 0;
|
|
308
|
+
this.clientActiveArea.x = this.clientArea.x = x;
|
|
309
|
+
this.clientActiveArea.width = this.clientArea.width = width;
|
|
310
|
+
if (updateYPosition) {
|
|
311
|
+
this.updateParagraphYPositionBasedonTextWrap(block, new Rect(this.clientActiveArea.x, this.clientActiveArea.y, this.clientActiveArea.width, this.clientActiveArea.height));
|
|
312
|
+
}
|
|
313
|
+
if (updateXPosition) {
|
|
314
|
+
if (block instanceof ParagraphWidget) {
|
|
315
|
+
this.updateParagraphXPositionBasedOnTextWrap(block);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.updateTableXPositionBasedOnTextWrap(block);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// Clears table left for table with right or center alignment.
|
|
325
|
+
if (block instanceof TableWidget && !isNullOrUndefined(block.tableFormat)) {
|
|
326
|
+
var tableAlignment = this.tableAlignmentForBidi(block, bidi);
|
|
327
|
+
if (!block.isGridUpdated) {
|
|
328
|
+
block.buildTableColumns();
|
|
329
|
+
block.isGridUpdated = true;
|
|
330
|
+
}
|
|
331
|
+
if (tableAlignment !== 'Left' && this.documentHelper.tableLefts.length > 0) {
|
|
332
|
+
leftIndent = this.documentHelper.tableLefts.pop();
|
|
333
|
+
if (bidi) {
|
|
334
|
+
rightIndent = leftIndent;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
width = this.clientArea.width + leftIndent + LayoutHelperMethods.convertPointToPixel(block.rightIndent);
|
|
339
|
+
var x = this.clientArea.x - (bidi ? rightIndent : leftIndent);
|
|
340
|
+
width = (width > 0 || (block instanceof ParagraphWidget && block.paragraphFormat.firstLineIndent < 0)) ? width : 0;
|
|
341
|
+
this.clientActiveArea.x = this.clientArea.x = x;
|
|
342
|
+
this.clientActiveArea.width = this.clientArea.width = width;
|
|
343
|
+
}
|
|
344
|
+
this.clientArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
345
|
+
this.clientActiveArea = new Rect(this.clientActiveArea.x, this.clientActiveArea.y, this.clientActiveArea.width, this.clientActiveArea.height);
|
|
346
|
+
};
|
|
347
|
+
LayoutHelper.prototype.updateParagraphYPositionBasedonTextWrap = function (block, rect) {
|
|
348
|
+
var bodyWidget = block.bodyWidget;
|
|
349
|
+
var clientLayoutArea = this.clientActiveArea;
|
|
350
|
+
if (bodyWidget && bodyWidget.floatingElements.length > 0 && block instanceof ParagraphWidget && !(block.containerWidget instanceof TextFrame)
|
|
351
|
+
&& !block.isInsideTable && !(block.containerWidget instanceof FootNoteWidget)) {
|
|
352
|
+
var isWord2013 = this.documentHelper.compatibilityMode === 'Word2013';
|
|
353
|
+
var paragraph = block;
|
|
354
|
+
var isEmptyPara = paragraph.isEmpty();
|
|
355
|
+
var paragraphHeight = paragraph.height;
|
|
356
|
+
if (paragraphHeight === 0) {
|
|
357
|
+
paragraphHeight = this.documentHelper.textHelper.getParagraphMarkSize(paragraph.characterFormat).Height;
|
|
358
|
+
}
|
|
359
|
+
//Update Layout area based on text wrap
|
|
360
|
+
if (((!paragraph.isInHeaderFooter || paragraph.isInsideTable)
|
|
361
|
+
|| isWord2013)) {
|
|
362
|
+
var yposition = rect.y;
|
|
363
|
+
// As per Microsoft Word behavior, need to update bottom position of first inline item to floating item bottom,
|
|
364
|
+
// when first inline item of page intersects in-between two adjacent floating items parallel in vertical
|
|
365
|
+
// for Word document lower than Microsoft Word 2013 version.
|
|
366
|
+
// To do: Currently this behavior handled for bottom position update based on Y position,
|
|
367
|
+
// need to handle this behavior for bottom position update based on X position in UpdateParagraphXPositionBasedOnTextWrap method.
|
|
368
|
+
var isFirstItemBottomPositionUpdated = false;
|
|
369
|
+
//Need to handle sorting floating items.
|
|
370
|
+
// Sort based on Y position
|
|
371
|
+
// bodyWidget.floatingElements.sort(function (a, b) { return a.y - b.y; });
|
|
372
|
+
// Sort based on X position
|
|
373
|
+
// bodyWidget.floatingElements.sort(function (a, b) { return a.x - b.x; });
|
|
374
|
+
var previousItem = paragraph.previousRenderedWidget;
|
|
375
|
+
for (var i = 0; i < bodyWidget.floatingElements.length; i++) {
|
|
376
|
+
var floatingItem = bodyWidget.floatingElements[i];
|
|
377
|
+
var isInsideHeaderFooter = false;
|
|
378
|
+
if (floatingItem instanceof ShapeBase) {
|
|
379
|
+
isInsideHeaderFooter = floatingItem.paragraph.isInHeaderFooter;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
isInsideHeaderFooter = floatingItem.bodyWidget instanceof HeaderFooterWidget ? true : false;
|
|
383
|
+
}
|
|
384
|
+
if (paragraph.isInsideTable) {
|
|
385
|
+
if (floatingItem instanceof TableWidget && !floatingItem.isInsideTable) {
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
var textWrappingBounds = this.getTextWrappingBound(floatingItem);
|
|
390
|
+
var textWrappingStyle = floatingItem instanceof TableWidget ? 'Square' : floatingItem.textWrappingStyle;
|
|
391
|
+
var textWrappingType = floatingItem instanceof TableWidget ? 'Both' : floatingItem.textWrappingType;
|
|
392
|
+
var minimumWidthRequired = 24;
|
|
393
|
+
if (!(clientLayoutArea.x > (textWrappingBounds.right + minimumWidthRequired) || clientLayoutArea.right < textWrappingBounds.x - minimumWidthRequired)) {
|
|
394
|
+
if ((((rect.y + (floatingItem instanceof TableWidget && !isEmptyPara && paragraph.floatingElements.length === 0 ? paragraphHeight : paragraph.height) > textWrappingBounds.y
|
|
395
|
+
|| isFirstItemBottomPositionUpdated) && rect.y < (textWrappingBounds.bottom))) && textWrappingStyle !== 'Inline'
|
|
396
|
+
&& textWrappingStyle !== 'TopAndBottom' && textWrappingStyle !== 'InFrontOfText'
|
|
397
|
+
&& textWrappingStyle !== 'Behind') {
|
|
398
|
+
var rightIndent = 0;
|
|
399
|
+
var paragarphRightIndent = LayoutHelperMethods.convertPointToPixel(paragraph.paragraphFormat.rightIndent);
|
|
400
|
+
var firstLineIndent = LayoutHelperMethods.convertPointToPixel(paragraph.paragraphFormat.firstLineIndent);
|
|
401
|
+
firstLineIndent = ((!isEmptyPara && paragraph.childWidgets[0].isFirstLine()) && firstLineIndent > 0) ? firstLineIndent : 0;
|
|
402
|
+
if (rect.x >= textWrappingBounds.x && textWrappingType !== 'Left') {
|
|
403
|
+
rightIndent = paragarphRightIndent;
|
|
404
|
+
}
|
|
405
|
+
// Gets the value from right indent when it is negative, otherwise sets the value as zero.
|
|
406
|
+
rightIndent = rightIndent < 0 ? rightIndent : 0;
|
|
407
|
+
if (floatingItem && (floatingItem instanceof TableWidget) && floatingItem.wrapTextAround
|
|
408
|
+
&& !isEmptyPara && !paragraph.isContainsShapeAlone() && isWord2013 && rect.y < textWrappingBounds.bottom) {
|
|
409
|
+
rect.y = textWrappingBounds.bottom;
|
|
410
|
+
}
|
|
411
|
+
if (rect.x < textWrappingBounds.x && rect.x > textWrappingBounds.x && textWrappingType !== 'Left') {
|
|
412
|
+
if (rect.right > textWrappingBounds.x) {
|
|
413
|
+
rect.width = rect.width - (rect.right - textWrappingBounds.right);
|
|
414
|
+
}
|
|
415
|
+
if (rect.width < minimumWidthRequired) {
|
|
416
|
+
//Skip to wrap the immediate paragraph of floating table based on corresponding floating table.
|
|
417
|
+
if (isWord2013 || !((floatingItem instanceof TableWidget) && previousItem === floatingItem)) {
|
|
418
|
+
this.updateBoundsBasedOnTextWrap(textWrappingBounds.bottom);
|
|
419
|
+
rect = this.clientActiveArea;
|
|
420
|
+
}
|
|
421
|
+
if ((!isEmptyPara && paragraph.childWidgets[0].isFirstLine() || isEmptyPara) && isWord2013 ? true : !isInsideHeaderFooter) {
|
|
422
|
+
paragraph.y = this.clientActiveArea.y;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
rect.x = textWrappingBounds.right;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else if (rect.x >= textWrappingBounds.x && rect.x < textWrappingBounds.right) {
|
|
430
|
+
rect.width = rect.width - (textWrappingBounds.right - rect.x) - rightIndent;
|
|
431
|
+
//checks minimum width
|
|
432
|
+
if (rect.width < minimumWidthRequired || isFirstItemBottomPositionUpdated) {
|
|
433
|
+
rect.width = this.clientActiveArea.right - textWrappingBounds.right - rightIndent;
|
|
434
|
+
var isPositionsUpdated = false;
|
|
435
|
+
if (rect.width < minimumWidthRequired || isFirstItemBottomPositionUpdated) {
|
|
436
|
+
// If left side of floating item has minimum width to layout the paragraph, then find the minimum bottom among the floating items to the left side of current floating item.
|
|
437
|
+
// Then update the Y position to that bottom.
|
|
438
|
+
if (this.clientActiveArea.x + minimumWidthRequired < textWrappingBounds.x) {
|
|
439
|
+
var tempBounds = this.getIntersectingItemBounds(bodyWidget.floatingElements, floatingItem, yposition);
|
|
440
|
+
if (!isNullOrUndefined(tempBounds) && tempBounds.bottom <= textWrappingBounds.bottom) {
|
|
441
|
+
this.updateBoundsBasedOnTextWrap(tempBounds.bottom);
|
|
442
|
+
rect = this.clientActiveArea;
|
|
443
|
+
isPositionsUpdated = true;
|
|
444
|
+
//When we update the client area to the bottom of floating item, we also need to updtae the X position.
|
|
445
|
+
//To-Do: Some more X position updating cases also need to handle.
|
|
446
|
+
paragraph.x = tempBounds.x;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
// Skip to wrap the immediate paragraph of floating table based on corresponding floating table.
|
|
450
|
+
if ((isWord2013) && !isPositionsUpdated) {
|
|
451
|
+
if (floatingItem instanceof TableWidget && previousItem === floatingItem) {
|
|
452
|
+
this.updateBoundsBasedOnTextWrapTable(textWrappingBounds.bottom);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
this.updateBoundsBasedOnTextWrap(textWrappingBounds.bottom);
|
|
456
|
+
}
|
|
457
|
+
rect = this.clientActiveArea;
|
|
458
|
+
}
|
|
459
|
+
if ((!isEmptyPara && paragraph.childWidgets[0].isFirstLine() || isEmptyPara) && isWord2013 ? true : !isInsideHeaderFooter) {
|
|
460
|
+
paragraph.y = this.clientActiveArea.y;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
rect.x = textWrappingBounds.right;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
rect.x = textWrappingBounds.right;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else if (textWrappingBounds.x > rect.x && rect.right > textWrappingBounds.x) {
|
|
472
|
+
rect.width = textWrappingBounds.x - rect.x;
|
|
473
|
+
//checks minimum width
|
|
474
|
+
if (rect.width < minimumWidthRequired) {
|
|
475
|
+
rect.width = this.clientActiveArea.right - textWrappingBounds.right - rightIndent;
|
|
476
|
+
if (rect.width < minimumWidthRequired) {
|
|
477
|
+
//Skip to wrap the immediate paragraph of floating table based on corresponding floating table.
|
|
478
|
+
if (isWord2013 || !((floatingItem instanceof TableWidget) && previousItem === floatingItem)) {
|
|
479
|
+
this.updateBoundsBasedOnTextWrap(textWrappingBounds.bottom);
|
|
480
|
+
rect = this.clientActiveArea;
|
|
481
|
+
}
|
|
482
|
+
if ((!isEmptyPara && paragraph.childWidgets[0].isFirstLine() || isEmptyPara) && isWord2013 ? true : !isInsideHeaderFooter) {
|
|
483
|
+
paragraph.y = this.clientActiveArea.y;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
rect.x = textWrappingBounds.right;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
else if ((bodyWidget.floatingElements.length > 0 && ((rect.y >= (textWrappingBounds.y) && rect.y < (textWrappingBounds.bottom))
|
|
493
|
+
|| ((rect.y + paragraphHeight >= textWrappingBounds.y) && (rect.y + paragraphHeight < (textWrappingBounds.bottom))))
|
|
494
|
+
&& textWrappingStyle === 'TopAndBottom')) {
|
|
495
|
+
//Skip to wrap the immediate paragraph of floating table based on corresponding floating table.
|
|
496
|
+
if (isWord2013 || !((floatingItem instanceof TableWidget) && previousItem === floatingItem)) {
|
|
497
|
+
var width = this.documentHelper.textHelper.getParagraphMarkWidth(paragraph.characterFormat);
|
|
498
|
+
if (this.documentHelper.compatibilityMode === 'Word2007' && isEmptyPara && !paragraph.bidi &&
|
|
499
|
+
!isNullOrUndefined(paragraph.paragraphFormat) && paragraph.paragraphFormat.textAlignment !== 'Left'
|
|
500
|
+
&& paragraph.paragraphFormat.textAlignment !== 'Center' && this.clientActiveArea.x + width < textWrappingBounds.x) {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
this.updateBoundsBasedOnTextWrap(textWrappingBounds.bottom);
|
|
504
|
+
// Sets true to update bottom position of first inline item in page
|
|
505
|
+
// when this item's bottom position already updated based on previous floating item.
|
|
506
|
+
if (!isWord2013 && (!isEmptyPara && paragraph.childWidgets[0].isFirstLine() || isEmptyPara)) {
|
|
507
|
+
isFirstItemBottomPositionUpdated = true;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if ((!isEmptyPara && paragraph.childWidgets[0].isFirstLine() || isEmptyPara) && isWord2013 ? true : !isInsideHeaderFooter) {
|
|
511
|
+
paragraph.y = this.clientActiveArea.y;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
// //Reset the floating item bounds to original position
|
|
516
|
+
// ResetXPositionForRTLLayouting(i, ref textWrappingBounds, floatingItemXPosition);
|
|
517
|
+
}
|
|
518
|
+
//Update the wrapping difference value.
|
|
519
|
+
// if (isFirstItem && yValue < rect.Y) {
|
|
520
|
+
// (m_lcOperator as Layouter).WrappingDifference = (float)(rect.Y - (m_lcOperator as Layouter).PageTopMargin);
|
|
521
|
+
// }
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* @private
|
|
527
|
+
*/
|
|
528
|
+
LayoutHelper.prototype.updateParagraphXPositionBasedOnTextWrap = function (block) {
|
|
529
|
+
// #region textwrap
|
|
530
|
+
var yValue = 0;
|
|
531
|
+
var isFirstItem = false;
|
|
532
|
+
var isWord2013 = this.documentHelper.compatibilityMode === 'Word2013';
|
|
533
|
+
var bodyWidget = block.containerWidget;
|
|
534
|
+
var clientLayoutArea = this.clientActiveArea;
|
|
535
|
+
// if (!(m_lcOperator as Layouter).IsLayoutingHeaderFooter &&
|
|
536
|
+
// (m_lcOperator as Layouter).WrappingDifference === Number.MIN_VALUE &&
|
|
537
|
+
// Math.round(yPosition, 2) === Math.round((m_lcOperator as Layouter).PageTopMargin, 2)) {
|
|
538
|
+
// yValue = yPosition;
|
|
539
|
+
// isFirstItem = true;
|
|
540
|
+
// }
|
|
541
|
+
if ((this instanceof PageLayoutHelper) && !isNullOrUndefined(bodyWidget) && block instanceof ParagraphWidget && !isNullOrUndefined(bodyWidget.page) && !isNullOrUndefined(bodyWidget.page.headerWidget)) {
|
|
542
|
+
var floatingItems = bodyWidget.page.headerWidget.floatingElements;
|
|
543
|
+
if (floatingItems.length > 0 &&
|
|
544
|
+
(!block.isInHeaderFooter || block.isInsideTable ||
|
|
545
|
+
isWord2013) &&
|
|
546
|
+
!(block.containerWidget instanceof FootNoteWidget) && !(block.bodyWidget instanceof TextFrame)) {
|
|
547
|
+
// const clientLayoutArea: RectangleF = (m_lcOperator as Layouter).ClientLayoutArea;
|
|
548
|
+
// clientLayoutArea.X = xPosition;
|
|
549
|
+
// clientLayoutArea.Y = yPosition;
|
|
550
|
+
//let cellPadings: number = 0;
|
|
551
|
+
var paragraph = block;
|
|
552
|
+
//if (paragraph.isInsideTable) {
|
|
553
|
+
//const cellLayoutInfo: CellLayoutInfo = ((paragraph.GetOwnerEntity() as WTableCell) as IWidget).LayoutInfo as CellLayoutInfo;
|
|
554
|
+
//cellPadings = cellLayoutInfo.Paddings.Left + cellLayoutInfo.Paddings.Right;
|
|
555
|
+
// }
|
|
556
|
+
// let defMinWidth: number = minimumWidthRequired - cellPadings;
|
|
557
|
+
// const size: SizeF = (paragraph as IWidget).LayoutInfo.Size;
|
|
558
|
+
for (var i = 0; i < floatingItems.length; i++) {
|
|
559
|
+
var floatingItem = floatingItems[i];
|
|
560
|
+
// if (paragraph.IsInCell && floatingItems[i].allowOverlap &&
|
|
561
|
+
// (paragraph.associatedCell.ownerRow.ownerTable.tableFormat.positioning.allowOverlap) {
|
|
562
|
+
if (paragraph.isInsideTable) {
|
|
563
|
+
if (floatingItem instanceof TableWidget && !floatingItem.isInsideTable) {
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
// }
|
|
568
|
+
var textWrappingBounds = (this).getTextWrappingBound(floatingItem);
|
|
569
|
+
var textWrappingStyle = floatingItem instanceof TableWidget ? 'Square' : floatingItem.textWrappingStyle;
|
|
570
|
+
var textWrappingType = floatingItem instanceof TableWidget ? 'Both' : floatingItem.textWrappingType;
|
|
571
|
+
//let ownerBody: BodyWidget = undefined;
|
|
572
|
+
//As per Microsoft Word behavior, when floating item and paragraph in cell means,
|
|
573
|
+
//then, wrap the bounds for the items in same cell only.
|
|
574
|
+
//Skip, if it is in different cell.
|
|
575
|
+
// let ownerBody: BodyWidget = undefined
|
|
576
|
+
// if (!this.isInSameTextBody(paragraph, floatingItem, ownerBody) &&
|
|
577
|
+
// paragraph.isInsideTable && bodyWidget instanceof TableCellWidget) {
|
|
578
|
+
// continue;
|
|
579
|
+
// }
|
|
580
|
+
// if (this.IsInFrame((m_lcOperator as Layouter).FloatingItems[i].FloatingEntity as WParagraph) &&
|
|
581
|
+
// this.IsOwnerCellInFrame(paragraph)) {
|
|
582
|
+
// continue;
|
|
583
|
+
// }
|
|
584
|
+
// if (paragraph.ParagraphFormat.Bidi &&
|
|
585
|
+
// (this.IsInSameTextBody(paragraph, (m_lcOperator as Layouter).FloatingItems[i], ownerBody) &&
|
|
586
|
+
// paragraph.IsInCell && ownerBody instanceof WTableCell)) {
|
|
587
|
+
// this.ModifyXPositionForRTLLayouting(i, textWrappingBounds, (m_layoutArea as any).ClientArea);
|
|
588
|
+
// } else if (paragraph.ParagraphFormat.Bidi) {
|
|
589
|
+
// this.ModifyXPositionForRTLLayouting(i, textWrappingBounds, (m_lcOperator as Layouter).ClientLayoutArea);
|
|
590
|
+
// }
|
|
591
|
+
var minimumWidthRequired = 24;
|
|
592
|
+
// if (textWrappingStyle === TextWrappingStyle.Tight || textWrappingStyle === TextWrappingStyle.Through) {
|
|
593
|
+
// minimumWidthRequired = paragraph.Document.Settings.CompatibilityMode === CompatibilityMode.Word2013 ?
|
|
594
|
+
// DEF_MIN_WIDTH_2013_TIGHTANDTHROW : DEF_MIN_WIDTH_TIGHTANDTHROW;
|
|
595
|
+
// }
|
|
596
|
+
// minimumWidthRequired -= cellPadings;
|
|
597
|
+
// defMinWidth = minimumWidthRequired;
|
|
598
|
+
// if (textWrappingStyle === TextWrappingStyle.Tight || textWrappingStyle === TextWrappingStyle.Through &&
|
|
599
|
+
// (m_lcOperator as Layouter).FloatingItems[i].IsDoesNotDenotesRectangle) {
|
|
600
|
+
// const temp: RectangleF = this.AdjustTightAndThroughBounds(
|
|
601
|
+
// (m_lcOperator as Layouter).FloatingItems[i], clientLayoutArea, size.Height);
|
|
602
|
+
// if (temp.X !== 0) {
|
|
603
|
+
// textWrappingBounds = temp;
|
|
604
|
+
// defMinWidth = size.Width;
|
|
605
|
+
// }
|
|
606
|
+
// }
|
|
607
|
+
if (!paragraph.isInsideTable &&
|
|
608
|
+
(!(clientLayoutArea.x > textWrappingBounds.right + minimumWidthRequired ||
|
|
609
|
+
clientLayoutArea.right < textWrappingBounds.x - minimumWidthRequired))) {
|
|
610
|
+
if (floatingItems.length > 0 &&
|
|
611
|
+
(clientLayoutArea.y + paragraph.height > textWrappingBounds.y && clientLayoutArea.y < textWrappingBounds.bottom) &&
|
|
612
|
+
textWrappingStyle !== "Inline" &&
|
|
613
|
+
textWrappingStyle !== "TopAndBottom" &&
|
|
614
|
+
textWrappingStyle !== "InFrontOfText" &&
|
|
615
|
+
textWrappingStyle !== "Behind") {
|
|
616
|
+
var rightIndent = LayoutHelperMethods.convertPointToPixel(paragraph.paragraphFormat.rightIndent);
|
|
617
|
+
if (paragraph.paragraphFormat.textAlignment != "Left" && (clientLayoutArea.x < textWrappingBounds.x && clientLayoutArea.x + paragraph.width > textWrappingBounds.x)) {
|
|
618
|
+
paragraph.x = clientLayoutArea.x;
|
|
619
|
+
}
|
|
620
|
+
else if (clientLayoutArea.x >= textWrappingBounds.x && clientLayoutArea.x < textWrappingBounds.right && !paragraph.paragraphFormat.bidi) {
|
|
621
|
+
clientLayoutArea.width = clientLayoutArea.width - (textWrappingBounds.right - clientLayoutArea.x) - rightIndent;
|
|
622
|
+
if (clientLayoutArea.width < minimumWidthRequired) {
|
|
623
|
+
clientLayoutArea.width = this.clientActiveArea.right - textWrappingBounds.right - rightIndent;
|
|
624
|
+
if (clientLayoutArea.width < minimumWidthRequired) {
|
|
625
|
+
var remainingHeightOfFloatingItem = textWrappingBounds.bottom > clientLayoutArea.y ? textWrappingBounds.bottom - clientLayoutArea.y : 0;
|
|
626
|
+
var updatedHeight = clientLayoutArea.height - remainingHeightOfFloatingItem;
|
|
627
|
+
paragraph.x = clientLayoutArea.x;
|
|
628
|
+
clientLayoutArea.width = this.clientArea.width;
|
|
629
|
+
clientLayoutArea.height = updatedHeight < 0 ? 0 : updatedHeight;
|
|
630
|
+
clientLayoutArea.y = textWrappingBounds.bottom;
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
clientLayoutArea.x = textWrappingBounds.right;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else if (this.documentHelper.compatibilityMode === "Word2007" ||
|
|
637
|
+
clientLayoutArea.y <= textWrappingBounds.bottom) {
|
|
638
|
+
// if (this.IsNeedToUpdateParagraphYPosition(clientLayoutArea.Y, textWrappingStyle,
|
|
639
|
+
// paragraph, clientLayoutArea.Y + size.Height + paragraph.ParagraphFormat.AfterSpacing, textWrappingBounds.Bottom)) {
|
|
640
|
+
// paragraph.x = clientLayoutArea.x;
|
|
641
|
+
// clientLayoutArea.width = clientLayoutArea.width;
|
|
642
|
+
// clientLayoutArea.y = textWrappingBounds.bottom;
|
|
643
|
+
// clientLayoutArea.height = clientLayoutArea.height -
|
|
644
|
+
// (textWrappingBounds.bottom - clientLayoutArea.y);
|
|
645
|
+
// this.updateBoundsBasedOnTextWrap(textWrappingBounds.bottom);
|
|
646
|
+
// } else {
|
|
647
|
+
//const paraInfo: ParagraphLayoutInfo = paragraph.m_layoutInfo as ParagraphLayoutInfo;
|
|
648
|
+
var leftIndent = LayoutHelperMethods.convertPointToPixel(paragraph.paragraphFormat.leftIndent);
|
|
649
|
+
var firstLineIndent = LayoutHelperMethods.convertPointToPixel(paragraph.paragraphFormat.firstLineIndent);
|
|
650
|
+
if (leftIndent + firstLineIndent + clientLayoutArea.x < textWrappingBounds.right) {
|
|
651
|
+
// paragraph.x = textWrappingBounds.right;
|
|
652
|
+
clientLayoutArea.x = textWrappingBounds.right;
|
|
653
|
+
if (isWord2013) {
|
|
654
|
+
//this.documentHelper.layout.IsXpositionUpated = true;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// }
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
else if ((textWrappingBounds.x - minimumWidthRequired > clientLayoutArea.x && clientLayoutArea.right > textWrappingBounds.x) ||
|
|
661
|
+
(clientLayoutArea.x > textWrappingBounds.x && clientLayoutArea.x > textWrappingBounds.right)) {
|
|
662
|
+
paragraph.x = clientLayoutArea.x;
|
|
663
|
+
}
|
|
664
|
+
// else if (clientLayoutArea.x > textWrappingBounds.x - minimumWidthRequired && clientLayoutArea.x < textWrappingBounds.right) {
|
|
665
|
+
// const width: number = clientLayoutArea.width + (clientLayoutArea.x - textWrappingBounds.right);
|
|
666
|
+
// if (width < minimumWidthRequired) {
|
|
667
|
+
// clientLayoutArea.y = textWrappingBounds.bottom;
|
|
668
|
+
// } else {
|
|
669
|
+
// paragraph.x = textWrappingBounds.right;
|
|
670
|
+
// }
|
|
671
|
+
// }
|
|
672
|
+
// else if (this.IsNeedToUpdateParagraphYPosition(clientLayoutArea.Y, textWrappingStyle,
|
|
673
|
+
// paragraph, clientLayoutArea.Y + size.Height + paragraph.ParagraphFormat.AfterSpacing, textWrappingBounds.Bottom)) {
|
|
674
|
+
// (paragraph.m_layoutInfo as ParagraphLayoutInfo).XPosition = clientLayoutArea.X;
|
|
675
|
+
// clientLayoutArea.Width = (m_lcOperator as Layouter).ClientLayoutArea.Width;
|
|
676
|
+
// clientLayoutArea.Y = textWrappingBounds.Bottom;
|
|
677
|
+
// clientLayoutArea.Height = (m_lcOperator as Layouter).ClientLayoutArea.Height -
|
|
678
|
+
// (textWrappingBounds.Bottom - (m_lcOperator as Layouter).ClientLayoutArea.Y);
|
|
679
|
+
// (m_layoutArea as any).UpdateBoundsBasedOnTextWrap(textWrappingBounds.Bottom);
|
|
680
|
+
// }
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
//this.ResetXPositionForRTLLayouting(i, textWrappingBounds, floatingItemXPosition);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
// if (m_widget instanceof WParagraph) {
|
|
687
|
+
// const sortYPosition: FloatingItem[] = (m_lcOperator as Layouter).FloatingItems.slice(0);
|
|
688
|
+
// FloatingItem.SortFloatingItems(sortYPosition, SortPosition.Y);
|
|
689
|
+
// this.UpdateXYPositionBasedOnAdjacentFloatingItems(sortYPosition, clientLayoutArea, size,
|
|
690
|
+
// m_widget as WParagraph, false);
|
|
691
|
+
// }
|
|
692
|
+
// if (isFirstItem && yValue < yPosition) {
|
|
693
|
+
// (m_lcOperator as Layouter).WrappingDifference = yPosition - (m_lcOperator as Layouter).PageTopMargin;
|
|
694
|
+
// }
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* @private
|
|
699
|
+
*/
|
|
700
|
+
LayoutHelper.prototype.updateTableXPositionBasedOnTextWrap = function (block) {
|
|
701
|
+
// Get the first row width
|
|
702
|
+
var firstRowWidth = LayoutHelperMethods.convertPointToPixel(block.childWidgets[0].getFirstRowWidth());
|
|
703
|
+
var bodyWidget = block.bodyWidget;
|
|
704
|
+
if ((this instanceof PageLayoutHelper) && !isNullOrUndefined(bodyWidget) && !isNullOrUndefined(bodyWidget.page) && !isNullOrUndefined(bodyWidget.page.headerWidget)) {
|
|
705
|
+
var floatingItems = bodyWidget.page.headerWidget.floatingElements;
|
|
706
|
+
// textwrap
|
|
707
|
+
// Update Layout area based on text wrap and ignore the yposition update while
|
|
708
|
+
// wrapping bounds already added to the collection
|
|
709
|
+
if (floatingItems.length > 0 && (!block.isInHeaderFooter || !block.isInsideTable || this.documentHelper.compatibilityMode === 'Word2013')
|
|
710
|
+
&& !(block.containerWidget instanceof TextFrame)) {
|
|
711
|
+
var rect = this.clientActiveArea;
|
|
712
|
+
//let wrapItemIndex: number = -1;
|
|
713
|
+
// sort the list items based on y position,
|
|
714
|
+
// Call Sort on the list. This will use the
|
|
715
|
+
// default comparer, which is the Compare method
|
|
716
|
+
// implemented on FloatingItem.
|
|
717
|
+
//FloatingItem.sortFloatingItems(this.m_lcOperator.floatingItems, SortPosition.Y);
|
|
718
|
+
for (var i = 0; i < floatingItems.length; i++) {
|
|
719
|
+
var floatingItem = floatingItems[i];
|
|
720
|
+
var textWrappingBounds = (this).getTextWrappingBound(floatingItem);
|
|
721
|
+
var textWrappingStyle = floatingItem instanceof TableWidget ? 'Square' : floatingItem.textWrappingStyle;
|
|
722
|
+
var allowOverlap = floatingItem instanceof TableWidget ? floatingItem.positioning.allowOverlap : floatingItem.allowOverlap;
|
|
723
|
+
// if (this.isAdjustTightAndThroughBounds(textWrappingStyle, i)) {
|
|
724
|
+
// let temp: RectangleF = this.adjustTightAndThroughBounds(this.m_lcOperator.floatingItems[i], rect, size.height);
|
|
725
|
+
// textWrappingBounds = temp;
|
|
726
|
+
// }
|
|
727
|
+
// let ownerBody: WTextBody = null;
|
|
728
|
+
// // As per Microsoft Word behavior, when floating item and table in cell means,
|
|
729
|
+
// // then, wrap the bounds for the items in same cell only.
|
|
730
|
+
// // Skip, if it is in different cell.
|
|
731
|
+
// if (!this.isInSameTextBody(this.m_table, this.m_lcOperator.floatingItems[i], ownerBody)
|
|
732
|
+
// && this.m_table.isInCell && ownerBody instanceof WTableCell)
|
|
733
|
+
// continue;
|
|
734
|
+
// // Skip if the current table is in different frame
|
|
735
|
+
// if (this.isInFrame(this.m_lcOperator.floatingItems[i].floatingEntity as WParagraph) && this.m_table.isFrame)
|
|
736
|
+
// continue;
|
|
737
|
+
// // Adjusts the text wrapping bounds based on distance from text values when floating table intersects with another floating item.
|
|
738
|
+
// textWrappingBounds = this.adjustTextWrappingBounds(this.m_lcOperator.floatingItems[i], clientLayoutArea, size,
|
|
739
|
+
// wrapItemIndex, i, rect, textWrappingBounds, textWrappingStyle, allowOverlap);
|
|
740
|
+
var minimumWidthRequired = 24;
|
|
741
|
+
var paragarph = this.documentHelper.getFirstParagraphInFirstCell(block);
|
|
742
|
+
var height = this.documentHelper.textHelper.getParagraphMarkSize(paragarph.characterFormat).Height;
|
|
743
|
+
var rowHeight = block.childWidgets[0] instanceof TableRowWidget ? block.childWidgets[0].height : 0;
|
|
744
|
+
if (rowHeight > height) {
|
|
745
|
+
height = rowHeight;
|
|
746
|
+
}
|
|
747
|
+
var width = LayoutHelperMethods.convertPointToPixel(block.getTableClientWidth(block.getContainerWidth()));
|
|
748
|
+
if (!(this.clientArea.x > textWrappingBounds.right + minimumWidthRequired || this.clientArea.right < textWrappingBounds.x - minimumWidthRequired)) {
|
|
749
|
+
if (this.isFloatingItemIntersect(block, rect, textWrappingBounds, textWrappingStyle, allowOverlap, height, width)) {
|
|
750
|
+
if (rect.x >= textWrappingBounds.x && rect.x < textWrappingBounds.right) {
|
|
751
|
+
rect.width = rect.width - (textWrappingBounds.right - rect.x);
|
|
752
|
+
//checks minimum width
|
|
753
|
+
if (rect.width < minimumWidthRequired || (rect.width < firstRowWidth && firstRowWidth > 0)) {
|
|
754
|
+
rect.width = this.clientActiveArea.right - textWrappingBounds.right;
|
|
755
|
+
//Check if the client active area width is lesser than table width to update the y position
|
|
756
|
+
if (rect.width < minimumWidthRequired || ((rect.width < firstRowWidth && firstRowWidth > 0) &&
|
|
757
|
+
this.clientArea.right <= firstRowWidth + textWrappingBounds.right)) {
|
|
758
|
+
//When the table y position is lesser than the text wrapping bottom position then
|
|
759
|
+
//difference of these two should be subtracted from the table client height instead of the floating item height.
|
|
760
|
+
var remainingHeightOfFloatingItem = (textWrappingBounds.bottom > rect.y) ? textWrappingBounds.bottom - rect.y : 0;
|
|
761
|
+
rect.y = textWrappingBounds.bottom;
|
|
762
|
+
rect.width = this.clientArea.width;
|
|
763
|
+
rect.height = rect.height - remainingHeightOfFloatingItem;
|
|
764
|
+
this.updateClientAreaForTextWrap(rect);
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
rect.x = textWrappingBounds.right;
|
|
768
|
+
// if (textWrappingStyle == TextWrappingStyle.Through
|
|
769
|
+
// && this.m_lcOperator.floatingItems[i].isDoesNotDenotesRectangle) {
|
|
770
|
+
// textWrappingBounds = this.adjustTightAndThroughBounds(this.m_lcOperator.floatingItems[i], rect, size.height);
|
|
771
|
+
// if (textWrappingBounds.x != 0)
|
|
772
|
+
// rect.width = textWrappingBounds.x - rect.x;
|
|
773
|
+
// }
|
|
774
|
+
this.updateClientAreaForTextWrap(rect);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
rect.x = textWrappingBounds.right;
|
|
779
|
+
// if (textWrappingStyle == TextWrappingStyle.Through
|
|
780
|
+
// && this.m_lcOperator.floatingItems[i].isDoesNotDenotesRectangle) {
|
|
781
|
+
// textWrappingBounds = this.adjustTightAndThroughBounds(this.m_lcOperator.floatingItems[i], rect, size.height);
|
|
782
|
+
// if (textWrappingBounds.x != 0)
|
|
783
|
+
// rect.width = textWrappingBounds.x - rect.x;
|
|
784
|
+
// }
|
|
785
|
+
this.updateClientAreaForTextWrap(rect);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
// else if ((rect.right - textWrappingBounds.right) > 0
|
|
789
|
+
// && (rect.right - textWrappingBounds.right) < rect.width
|
|
790
|
+
// && (rect.y >= textWrappingBounds.y
|
|
791
|
+
// || (rect.y + size.height) >= textWrappingBounds.y)) {
|
|
792
|
+
// //If the table is intersect with another floating item from the top ,then we need to consider distance from text with respect to relative margin position.
|
|
793
|
+
// if (rect.x < textWrappingBounds.x && rect.right > textWrappingBounds.x) {
|
|
794
|
+
// if (this.m_table.tableFormat.positioning.horizPositionAbs == HorizontalPosition.Left)
|
|
795
|
+
// rect.x += this.m_table.tableFormat.positioning.distanceFromLeft;
|
|
796
|
+
// else if (this.m_table.tableFormat.positioning.horizPositionAbs == HorizontalPosition.Right)
|
|
797
|
+
// rect.x -= this.m_table.tableFormat.positioning.distanceFromRight;
|
|
798
|
+
// }
|
|
799
|
+
// //When the table y position is lesser than the text wrapping bottom position then
|
|
800
|
+
// //difference of these two should be subtracted from the table client height instead of the floating item height.
|
|
801
|
+
// let remainingHeightOfFloatingItem = (textWrappingBounds.bottom > rect.y) ? textWrappingBounds.bottom - rect.y : 0;
|
|
802
|
+
// rect.y = textWrappingBounds.bottom;
|
|
803
|
+
// rect.height = rect.height - remainingHeightOfFloatingItem;
|
|
804
|
+
// this.createLayoutArea(rect);
|
|
805
|
+
// }
|
|
806
|
+
// else if (textWrappingBounds.x > rect.x && rect.right > textWrappingBounds.x) {
|
|
807
|
+
// rect.width = textWrappingBounds.x - rect.x;
|
|
808
|
+
// //checks minimum width
|
|
809
|
+
// if (rect.width < DEF_MIN_WIDTH || (rect.width < firstRowWidth && firstRowWidth > 0)) {
|
|
810
|
+
// rect.width = this.m_layoutArea.clientActiveArea.right - textWrappingBounds.right;
|
|
811
|
+
// if (rect.width < DEF_MIN_WIDTH || (rect.width < firstRowWidth && firstRowWidth > 0)) {
|
|
812
|
+
// //Check if the client active area width is greater than table width to update the x position
|
|
813
|
+
// if (this.m_layoutArea.clientArea.right < this.m_lcOperator.clientLayoutArea.right
|
|
814
|
+
// && textWrappingBounds.right < this.m_lcOperator.clientLayoutArea.right
|
|
815
|
+
// && this.m_lcOperator.clientLayoutArea.right - textWrappingBounds.right > DEF_MIN_WIDTH
|
|
816
|
+
// && Math.round(this.m_layoutArea.clientActiveArea.width, 2) > Math.round(firstRowWidth, 2)) {
|
|
817
|
+
// rect.width = this.m_lcOperator.clientLayoutArea.right - textWrappingBounds.right;
|
|
818
|
+
// rect.x = textWrappingBounds.right;
|
|
819
|
+
// if (textWrappingStyle == TextWrappingStyle.Through
|
|
820
|
+
// && this.m_lcOperator.floatingItems[i].isDoesNotDenotesRectangle) {
|
|
821
|
+
// textWrappingBounds = this.adjustTightAndThroughBounds(this.m_lcOperator.floatingItems[i], rect, size.height);
|
|
822
|
+
// if (textWrappingBounds.x != 0)
|
|
823
|
+
// rect.width = textWrappingBounds.x - rect.x;
|
|
824
|
+
// }
|
|
825
|
+
// }
|
|
826
|
+
// else {
|
|
827
|
+
// //When the table y position is lesser than the text wrapping bottom position then
|
|
828
|
+
// //difference of these two should be subtracted from the table client height instead of the floating item height.
|
|
829
|
+
// let remainingHeightOfFloatingItem = (textWrappingBounds.bottom > rect.y) ? textWrappingBounds.bottom - rect.y : 0;
|
|
830
|
+
// rect.y = textWrappingBounds.bottom;
|
|
831
|
+
// rect.height = rect.height - remainingHeightOfFloatingItem;
|
|
832
|
+
// }
|
|
833
|
+
// this.createLayoutArea(rect);
|
|
834
|
+
// }
|
|
835
|
+
// }
|
|
836
|
+
// else
|
|
837
|
+
// this.createLayoutArea(rect);
|
|
838
|
+
// }
|
|
839
|
+
// else if (rect.x > textWrappingBounds.x && rect.x > textWrappingBounds.right) {
|
|
840
|
+
// rect.width = this.m_layoutArea.clientArea.width;
|
|
841
|
+
// this.createLayoutArea(rect);
|
|
842
|
+
// }
|
|
843
|
+
// else if (rect.x > textWrappingBounds.x && rect.x < textWrappingBounds.right) {
|
|
844
|
+
// rect.width = rect.width - (textWrappingBounds.right - rect.x);
|
|
845
|
+
// rect.x = textWrappingBounds.right;
|
|
846
|
+
// if (textWrappingStyle == TextWrappingStyle.Through
|
|
847
|
+
// && this.m_lcOperator.floatingItems[i].isDoesNotDenotesRectangle) {
|
|
848
|
+
// textWrappingBounds = this.adjustTightAndThroughBounds(this.m_lcOperator.floatingItems[i], rect, size.height);
|
|
849
|
+
// if (textWrappingBounds.x != 0)
|
|
850
|
+
// rect.width = textWrappingBounds.x - rect.x;
|
|
851
|
+
// }
|
|
852
|
+
// this.createLayoutArea(rect);
|
|
853
|
+
// }
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
LayoutHelper.prototype.isFloatingItemIntersect = function (table, rect, textWrappingBounds, textWrappingStyle, allowOverlap, height, width) {
|
|
861
|
+
return ((Math.round(rect.y + height) >= Math.round(textWrappingBounds.y)
|
|
862
|
+
&& Math.round(rect.y) < Math.round(textWrappingBounds.bottom))
|
|
863
|
+
//Checks whether the bottom of the table intersects with floating item.
|
|
864
|
+
|| Math.round(rect.y + height) <= Math.round(textWrappingBounds.bottom)
|
|
865
|
+
&& Math.round(rect.y + height) >= Math.round(textWrappingBounds.y))
|
|
866
|
+
&& textWrappingStyle !== "Inline"
|
|
867
|
+
&& textWrappingStyle !== "TopAndBottom"
|
|
868
|
+
&& textWrappingStyle !== "InFrontOfText"
|
|
869
|
+
&& textWrappingStyle !== "Behind"
|
|
870
|
+
&& !(allowOverlap && (table.tableFormat !== null && table.wrapTextAround && table.positioning.allowOverlap));
|
|
871
|
+
};
|
|
872
|
+
LayoutHelper.prototype.getIntersectingItemBounds = function (floatingElements, intersectedfloatingItem, yPosition) {
|
|
873
|
+
var floatingItem = this.getMinBottomFloatingItem(floatingElements, this.getIntersectingFloatingItems(floatingElements, intersectedfloatingItem, yPosition));
|
|
874
|
+
if (!isNullOrUndefined(floatingItem)) {
|
|
875
|
+
var floatingItemBound = this.getTextWrappingBound(floatingItem);
|
|
876
|
+
return floatingItemBound;
|
|
877
|
+
}
|
|
878
|
+
return undefined;
|
|
879
|
+
};
|
|
880
|
+
LayoutHelper.prototype.getMinBottomFloatingItem = function (floatingElements, fItems) {
|
|
881
|
+
var minBottomItemIndex = -1;
|
|
882
|
+
var minBottom = Number.MAX_VALUE;
|
|
883
|
+
var skippedCount = 0;
|
|
884
|
+
// Sort based on X position
|
|
885
|
+
floatingElements.sort(function (a, b) { return a.x - b.x; });
|
|
886
|
+
for (var i = 0; i < fItems.length; i++) {
|
|
887
|
+
var floatingItem = floatingElements[i];
|
|
888
|
+
var item = this.getTextWrappingBound(floatingItem);
|
|
889
|
+
if (minBottom > item.bottom) {
|
|
890
|
+
// Need to ignore if floating items preserved in same frame.
|
|
891
|
+
if (floatingItem && fItems.indexOf(floatingItem) + 1 < fItems.length) {
|
|
892
|
+
skippedCount++;
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
minBottom = item.bottom;
|
|
896
|
+
minBottomItemIndex = fItems.indexOf(floatingItem);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
//If floating item which has minimum bottom is first item (no items preserved left side of this item).
|
|
901
|
+
//Then return current item Other cases need to handle.
|
|
902
|
+
return minBottomItemIndex - skippedCount == 0 ? fItems[minBottomItemIndex] : null;
|
|
903
|
+
};
|
|
904
|
+
LayoutHelper.prototype.getIntersectingFloatingItems = function (floatingElements, intersectedfloatingItem, yPosition) {
|
|
905
|
+
var fItems = [];
|
|
906
|
+
//Get all the items which preserved left side of the current floating item.
|
|
907
|
+
for (var i = 0; i < floatingElements.length; i++) {
|
|
908
|
+
{
|
|
909
|
+
var floatingItem = floatingElements[i];
|
|
910
|
+
var itemTextWrapBound = this.getTextWrappingBound(floatingItem);
|
|
911
|
+
var intersectItemTextWrapBound = this.getTextWrappingBound(intersectedfloatingItem);
|
|
912
|
+
if (yPosition <= itemTextWrapBound.bottom
|
|
913
|
+
&& intersectItemTextWrapBound.bottom >= itemTextWrapBound.bottom
|
|
914
|
+
&& itemTextWrapBound.right > this.clientActiveArea.x
|
|
915
|
+
&& itemTextWrapBound.x < intersectItemTextWrapBound.x)
|
|
916
|
+
fItems.push(floatingItem);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
return fItems;
|
|
920
|
+
};
|
|
921
|
+
LayoutHelper.prototype.getTextWrappingBound = function (floatingItem) {
|
|
922
|
+
var distanceLeft = 0;
|
|
923
|
+
var distanceTop = 0;
|
|
924
|
+
var distanceRight = 0;
|
|
925
|
+
var distanceBottom = 0;
|
|
926
|
+
var width = 0;
|
|
927
|
+
if (floatingItem instanceof ShapeBase) {
|
|
928
|
+
distanceLeft = floatingItem.distanceLeft;
|
|
929
|
+
distanceTop = floatingItem.distanceTop;
|
|
930
|
+
distanceRight = floatingItem.distanceRight;
|
|
931
|
+
distanceBottom = floatingItem.distanceBottom;
|
|
932
|
+
width = floatingItem.width;
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
width = floatingItem.getTableCellWidth();
|
|
936
|
+
distanceLeft = floatingItem.positioning.distanceLeft;
|
|
937
|
+
distanceTop = floatingItem.positioning.distanceTop;
|
|
938
|
+
distanceRight = floatingItem.positioning.distanceRight;
|
|
939
|
+
distanceBottom = floatingItem.positioning.distanceBottom;
|
|
940
|
+
}
|
|
941
|
+
var textWrappingBounds = new Rect(floatingItem.x - distanceLeft, floatingItem.y - distanceTop, width + distanceLeft + distanceRight, floatingItem.height + distanceTop + distanceBottom);
|
|
942
|
+
return textWrappingBounds;
|
|
943
|
+
};
|
|
944
|
+
LayoutHelper.prototype.tableAlignmentForBidi = function (block, bidi) {
|
|
945
|
+
var tableAlignment = block.tableFormat.tableAlignment;
|
|
946
|
+
if (bidi) {
|
|
947
|
+
if (tableAlignment === 'Left') {
|
|
948
|
+
tableAlignment = 'Right';
|
|
949
|
+
}
|
|
950
|
+
else if (tableAlignment === 'Right') {
|
|
951
|
+
tableAlignment = 'Left';
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return tableAlignment;
|
|
955
|
+
};
|
|
956
|
+
LayoutHelper.prototype.cutFromLeft = function (x) {
|
|
957
|
+
if (x < this.clientActiveArea.x) {
|
|
958
|
+
x = this.clientActiveArea.x;
|
|
959
|
+
}
|
|
960
|
+
if (x > this.clientActiveArea.right && this.textWrap) {
|
|
961
|
+
x = this.clientActiveArea.right;
|
|
962
|
+
}
|
|
963
|
+
this.clientActiveArea.width = this.clientActiveArea.right > x ? this.clientActiveArea.right - x : 0;
|
|
964
|
+
this.clientActiveArea.x = x;
|
|
965
|
+
};
|
|
966
|
+
LayoutHelper.prototype.cutFromTop = function (y) {
|
|
967
|
+
if (y < this.clientActiveArea.y) {
|
|
968
|
+
y = this.clientActiveArea.y;
|
|
969
|
+
}
|
|
970
|
+
if (y > this.clientActiveArea.bottom) {
|
|
971
|
+
y = this.clientActiveArea.bottom;
|
|
972
|
+
}
|
|
973
|
+
this.clientActiveArea.height = this.clientActiveArea.bottom - y;
|
|
974
|
+
this.clientActiveArea.x = this.clientArea.x;
|
|
975
|
+
this.clientActiveArea.width = this.clientArea.width;
|
|
976
|
+
this.clientActiveArea.y = y;
|
|
977
|
+
};
|
|
978
|
+
LayoutHelper.prototype.updateClientWidth = function (width) {
|
|
979
|
+
this.clientActiveArea.x -= width;
|
|
980
|
+
if (this.clientActiveArea.width + width > 0) {
|
|
981
|
+
this.clientActiveArea.width += width;
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
this.clientActiveArea.width = 0;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
LayoutHelper.prototype.destroy = function () {
|
|
988
|
+
this.clientArea = undefined;
|
|
989
|
+
this.clientActiveArea = undefined;
|
|
990
|
+
};
|
|
991
|
+
/**
|
|
992
|
+
* Disposes the internal objects which are maintained.
|
|
993
|
+
* @private
|
|
994
|
+
*/
|
|
995
|
+
LayoutHelper.prototype.componentDestroy = function () {
|
|
996
|
+
this.clientArea = undefined;
|
|
997
|
+
this.clientActiveArea = undefined;
|
|
998
|
+
};
|
|
999
|
+
return LayoutHelper;
|
|
1000
|
+
}());
|
|
1001
|
+
export { LayoutHelper };
|
|
1002
|
+
/**
|
|
1003
|
+
* @private
|
|
1004
|
+
*/
|
|
1005
|
+
var PageLayoutHelper = /** @class */ (function (_super) {
|
|
1006
|
+
__extends(PageLayoutHelper, _super);
|
|
1007
|
+
/**
|
|
1008
|
+
* Initialize the constructor of PageLayoutHelper
|
|
1009
|
+
*/
|
|
1010
|
+
function PageLayoutHelper(owner) {
|
|
1011
|
+
var _this = _super.call(this, owner) || this;
|
|
1012
|
+
_this.pageLeft = 30;
|
|
1013
|
+
_this.owner = owner;
|
|
1014
|
+
return _this;
|
|
1015
|
+
}
|
|
1016
|
+
Object.defineProperty(PageLayoutHelper.prototype, "pageGap", {
|
|
1017
|
+
/**
|
|
1018
|
+
* @private
|
|
1019
|
+
*/
|
|
1020
|
+
get: function () {
|
|
1021
|
+
return 20;
|
|
1022
|
+
},
|
|
1023
|
+
enumerable: true,
|
|
1024
|
+
configurable: true
|
|
1025
|
+
});
|
|
1026
|
+
PageLayoutHelper.prototype.createNewPage = function (section, index) {
|
|
1027
|
+
var pagelayout = this;
|
|
1028
|
+
var yPos = this.pageGap;
|
|
1029
|
+
if (this.documentHelper.pages.length > 0) {
|
|
1030
|
+
yPos = this.documentHelper.pages[this.documentHelper.pages.length - 1].boundingRectangle.bottom + this.pageGap;
|
|
1031
|
+
}
|
|
1032
|
+
var page = new Page(this.documentHelper);
|
|
1033
|
+
this.updatePageBoundingRectangle(section, page, yPos);
|
|
1034
|
+
if (isNullOrUndefined(index)) {
|
|
1035
|
+
this.documentHelper.pages.push(page);
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
this.documentHelper.pages.splice(index, 0, page);
|
|
1039
|
+
}
|
|
1040
|
+
page.bodyWidgets.push(section);
|
|
1041
|
+
page.bodyWidgets[page.bodyWidgets.length - 1].page = page;
|
|
1042
|
+
this.updateClientArea(section, page);
|
|
1043
|
+
this.documentHelper.layout.layoutHeaderFooter(section, pagelayout, page);
|
|
1044
|
+
this.updateClientArea(section, page);
|
|
1045
|
+
this.documentHelper.layout.footnoteHeight = 0;
|
|
1046
|
+
return page;
|
|
1047
|
+
};
|
|
1048
|
+
PageLayoutHelper.prototype.updatePageBoundingRectangle = function (section, page, yPosition) {
|
|
1049
|
+
//page.viewer = this;
|
|
1050
|
+
var pageWidth = !isNullOrUndefined(section.sectionFormat) ? LayoutHelperMethods.convertPointToPixel(section.sectionFormat.pageWidth) : 816;
|
|
1051
|
+
var pageHeight = !isNullOrUndefined(section.sectionFormat) ? LayoutHelperMethods.convertPointToPixel(section.sectionFormat.pageHeight) : 1056;
|
|
1052
|
+
var xPos = (this.documentHelper.visibleBounds.width - pageWidth * this.documentHelper.zoomFactor) / 2;
|
|
1053
|
+
if (xPos < this.pageLeft) {
|
|
1054
|
+
xPos = this.pageLeft;
|
|
1055
|
+
}
|
|
1056
|
+
page.boundingRectangle = new Rect(xPos, yPosition, pageWidth, pageHeight);
|
|
1057
|
+
};
|
|
1058
|
+
PageLayoutHelper.prototype.getCurrentPageHeaderFooter = function (section, isHeader) {
|
|
1059
|
+
return this.getCurrentHeaderFooter(this.getHeaderFooterType(section, isHeader), section.index);
|
|
1060
|
+
};
|
|
1061
|
+
/**
|
|
1062
|
+
* A page that follows the page where the section already started (continuous section) is not its first page.
|
|
1063
|
+
*/
|
|
1064
|
+
PageLayoutHelper.prototype.isFirstPageOfSection = function (page, isHeader) {
|
|
1065
|
+
var previous = page.previousPage;
|
|
1066
|
+
var sectionIndex = page.bodyWidgets[0].sectionIndex;
|
|
1067
|
+
if (previous.bodyWidgets[previous.bodyWidgets.length - 1].sectionIndex !== sectionIndex) {
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
if (!isHeader) {
|
|
1071
|
+
// Only the header of such a section is switched; the footer keeps the regular footer of the continuing page.
|
|
1072
|
+
return false;
|
|
1073
|
+
}
|
|
1074
|
+
var headersFooters = this.documentHelper.headersFooters[sectionIndex];
|
|
1075
|
+
var hasOwnFirstPage = !isNullOrUndefined(headersFooters)
|
|
1076
|
+
&& (!isNullOrUndefined(headersFooters[this.getHeaderFooter('FirstPageHeader')])
|
|
1077
|
+
|| !isNullOrUndefined(headersFooters[this.getHeaderFooter('FirstPageFooter')]));
|
|
1078
|
+
return hasOwnFirstPage && !isNullOrUndefined(previous.headerWidget)
|
|
1079
|
+
&& previous.headerWidget.headerFooterType === 'FirstPageHeader'
|
|
1080
|
+
&& previous.bodyWidgets[0].sectionIndex !== sectionIndex;
|
|
1081
|
+
};
|
|
1082
|
+
PageLayoutHelper.prototype.getHeaderFooterType = function (section, isHeader) {
|
|
1083
|
+
var type;
|
|
1084
|
+
type = isHeader ? 'OddHeader' : 'OddFooter';
|
|
1085
|
+
var page = section.page;
|
|
1086
|
+
if (section.sectionFormat.differentFirstPage && (isNullOrUndefined(page.previousPage) || (!isNullOrUndefined(page.previousPage) && page.sectionIndex !== page.previousPage.sectionIndex && this.isFirstPageOfSection(page, isHeader)))) {
|
|
1087
|
+
type = isHeader ? 'FirstPageHeader' : 'FirstPageFooter';
|
|
1088
|
+
}
|
|
1089
|
+
else if (section.sectionFormat.differentOddAndEvenPages && (page.index + 1) % 2 === 0) {
|
|
1090
|
+
type = isHeader ? 'EvenHeader' : 'EvenFooter';
|
|
1091
|
+
}
|
|
1092
|
+
return type;
|
|
1093
|
+
};
|
|
1094
|
+
PageLayoutHelper.prototype.getCurrentHeaderFooter = function (type, sectionIndex) {
|
|
1095
|
+
if (this.documentHelper.headersFooters[sectionIndex]) {
|
|
1096
|
+
var index = this.getHeaderFooter(type);
|
|
1097
|
+
var headerFooter = this.documentHelper.headersFooters[sectionIndex][index];
|
|
1098
|
+
if (!headerFooter) {
|
|
1099
|
+
var currentSecIndex = sectionIndex > 0 ? sectionIndex - 1 : sectionIndex;
|
|
1100
|
+
while (!headerFooter && currentSecIndex !== -1) {
|
|
1101
|
+
headerFooter = this.documentHelper.headersFooters[currentSecIndex][index];
|
|
1102
|
+
currentSecIndex--;
|
|
1103
|
+
}
|
|
1104
|
+
if (!headerFooter) {
|
|
1105
|
+
headerFooter = this.createHeaderFooterWidget(type);
|
|
1106
|
+
headerFooter.isEmpty = true;
|
|
1107
|
+
}
|
|
1108
|
+
if (sectionIndex == 0) {
|
|
1109
|
+
this.documentHelper.headersFooters[sectionIndex][index] = headerFooter;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return headerFooter;
|
|
1113
|
+
}
|
|
1114
|
+
else if (sectionIndex > 0) {
|
|
1115
|
+
return this.getCurrentHeaderFooter(type, sectionIndex - 1);
|
|
1116
|
+
}
|
|
1117
|
+
return undefined;
|
|
1118
|
+
};
|
|
1119
|
+
PageLayoutHelper.prototype.createHeaderFooterWidget = function (type) {
|
|
1120
|
+
var headerFooter = new HeaderFooterWidget(type);
|
|
1121
|
+
var paragraph = new ParagraphWidget();
|
|
1122
|
+
paragraph.childWidgets.push(new LineWidget(paragraph));
|
|
1123
|
+
var style;
|
|
1124
|
+
if (type.indexOf('Header') !== -1) {
|
|
1125
|
+
style = this.documentHelper.styles.findByName('Header');
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
style = this.documentHelper.styles.findByName('Footer');
|
|
1129
|
+
}
|
|
1130
|
+
paragraph.paragraphFormat.baseStyle = style;
|
|
1131
|
+
paragraph.paragraphFormat.listFormat.baseStyle = style;
|
|
1132
|
+
headerFooter.childWidgets.push(paragraph);
|
|
1133
|
+
paragraph.containerWidget = headerFooter;
|
|
1134
|
+
return headerFooter;
|
|
1135
|
+
};
|
|
1136
|
+
PageLayoutHelper.prototype.getHeaderFooter = function (type) {
|
|
1137
|
+
switch (type) {
|
|
1138
|
+
case 'OddHeader':
|
|
1139
|
+
return 0;
|
|
1140
|
+
case 'OddFooter':
|
|
1141
|
+
return 1;
|
|
1142
|
+
case 'EvenHeader':
|
|
1143
|
+
return 2;
|
|
1144
|
+
case 'EvenFooter':
|
|
1145
|
+
return 3;
|
|
1146
|
+
case 'FirstPageHeader':
|
|
1147
|
+
return 4;
|
|
1148
|
+
case 'FirstPageFooter':
|
|
1149
|
+
return 5;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
PageLayoutHelper.prototype.updateHFClientArea = function (sectionFormat, isHeader) {
|
|
1153
|
+
var width = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageWidth - sectionFormat.leftMargin - sectionFormat.rightMargin);
|
|
1154
|
+
if (width < 0) {
|
|
1155
|
+
width = 0;
|
|
1156
|
+
}
|
|
1157
|
+
if (isHeader) {
|
|
1158
|
+
this.clientArea = new Rect(LayoutHelperMethods.convertPointToPixel(sectionFormat.leftMargin), LayoutHelperMethods.convertPointToPixel(sectionFormat.headerDistance), width, Number.POSITIVE_INFINITY);
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
this.clientArea = new Rect(LayoutHelperMethods.convertPointToPixel(sectionFormat.leftMargin), LayoutHelperMethods.convertPointToPixel(sectionFormat.pageHeight - sectionFormat.footerDistance), width, Number.POSITIVE_INFINITY);
|
|
1162
|
+
}
|
|
1163
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, this.clientArea.height);
|
|
1164
|
+
};
|
|
1165
|
+
PageLayoutHelper.prototype.updateHeaderFooterClientAreaWithTop = function (sectionFormat, isHeader, page) {
|
|
1166
|
+
this.updateHFClientArea(sectionFormat, isHeader);
|
|
1167
|
+
if (!isHeader) {
|
|
1168
|
+
if (page.footerWidget.y < this.clientActiveArea.y) {
|
|
1169
|
+
this.clientActiveArea.y = page.footerWidget.y;
|
|
1170
|
+
this.clientActiveArea.height = Number.POSITIVE_INFINITY;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
PageLayoutHelper.prototype.updateFootnoteClientArea = function (sectionFormat, footnote, footNoteType, para) {
|
|
1175
|
+
var width = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageWidth - sectionFormat.leftMargin - sectionFormat.rightMargin);
|
|
1176
|
+
var left = LayoutHelperMethods.convertPointToPixel(sectionFormat.leftMargin);
|
|
1177
|
+
var bottomMargin = LayoutHelperMethods.convertPointToPixel(sectionFormat.bottomMargin);
|
|
1178
|
+
var footerDistance = LayoutHelperMethods.convertPointToPixel(sectionFormat.footerDistance);
|
|
1179
|
+
var top = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageHeight) - Math.max(footerDistance + footnote.page.footerWidget.height, bottomMargin);
|
|
1180
|
+
this.clientArea = new Rect(left, top, width, Number.POSITIVE_INFINITY);
|
|
1181
|
+
this.clientActiveArea = new Rect(this.clientArea.x, this.clientArea.y, this.clientArea.width, Number.POSITIVE_INFINITY);
|
|
1182
|
+
};
|
|
1183
|
+
return PageLayoutHelper;
|
|
1184
|
+
}(LayoutHelper));
|
|
1185
|
+
export { PageLayoutHelper };
|
|
1186
|
+
var WebLayoutHelper = /** @class */ (function (_super) {
|
|
1187
|
+
__extends(WebLayoutHelper, _super);
|
|
1188
|
+
function WebLayoutHelper(owner) {
|
|
1189
|
+
return _super.call(this, owner) || this;
|
|
1190
|
+
/* if (isNullOrUndefined(owner) || isNullOrUndefined(owner.element)) {
|
|
1191
|
+
return;
|
|
1192
|
+
}*/
|
|
1193
|
+
}
|
|
1194
|
+
Object.defineProperty(WebLayoutHelper.prototype, "pageGap", {
|
|
1195
|
+
/**
|
|
1196
|
+
* @private
|
|
1197
|
+
*/
|
|
1198
|
+
get: function () {
|
|
1199
|
+
return 0;
|
|
1200
|
+
},
|
|
1201
|
+
enumerable: true,
|
|
1202
|
+
configurable: true
|
|
1203
|
+
});
|
|
1204
|
+
/**
|
|
1205
|
+
* Creates new page.
|
|
1206
|
+
* @private
|
|
1207
|
+
*/
|
|
1208
|
+
WebLayoutHelper.prototype.createNewPage = function (section, index) {
|
|
1209
|
+
var page;
|
|
1210
|
+
var yPos = 0;
|
|
1211
|
+
var x = 10;
|
|
1212
|
+
if (this.documentHelper.pages.length > 0) {
|
|
1213
|
+
yPos = this.documentHelper.pages[this.documentHelper.pages.length - 1].boundingRectangle.bottom;
|
|
1214
|
+
}
|
|
1215
|
+
page = new Page(this.documentHelper);
|
|
1216
|
+
if (this.documentHelper.pages.length === 0) {
|
|
1217
|
+
page.boundingRectangle = new Rect(x, yPos, this.documentHelper.visibleBounds.width, this.documentHelper.visibleBounds.height);
|
|
1218
|
+
}
|
|
1219
|
+
else {
|
|
1220
|
+
page.boundingRectangle = new Rect(x, yPos - 20, this.documentHelper.visibleBounds.width, this.documentHelper.visibleBounds.height);
|
|
1221
|
+
}
|
|
1222
|
+
this.documentHelper.pages.push(page);
|
|
1223
|
+
this.updateClientArea(undefined, page);
|
|
1224
|
+
page.bodyWidgets.push(section);
|
|
1225
|
+
page.bodyWidgets[page.bodyWidgets.length - 1].page = page;
|
|
1226
|
+
return page;
|
|
1227
|
+
};
|
|
1228
|
+
return WebLayoutHelper;
|
|
1229
|
+
}(LayoutHelper));
|
|
1230
|
+
export { WebLayoutHelper };
|
|
1231
|
+
/**
|
|
1232
|
+
* @private
|
|
1233
|
+
*/
|
|
1234
|
+
var ColumnLayout = /** @class */ (function () {
|
|
1235
|
+
/**
|
|
1236
|
+
* Initialize the constructor of Column Layout Settings
|
|
1237
|
+
*/
|
|
1238
|
+
function ColumnLayout(layoutHelper) {
|
|
1239
|
+
this.layoutHelperIn = layoutHelper;
|
|
1240
|
+
this.clear();
|
|
1241
|
+
}
|
|
1242
|
+
Object.defineProperty(ColumnLayout.prototype, "currentIndex", {
|
|
1243
|
+
get: function () {
|
|
1244
|
+
return this.currentIndexIn;
|
|
1245
|
+
},
|
|
1246
|
+
set: function (value) {
|
|
1247
|
+
if (value >= 0) {
|
|
1248
|
+
this.currentIndexIn = value;
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
enumerable: true,
|
|
1252
|
+
configurable: true
|
|
1253
|
+
});
|
|
1254
|
+
Object.defineProperty(ColumnLayout.prototype, "columnCount", {
|
|
1255
|
+
get: function () {
|
|
1256
|
+
var colCount;
|
|
1257
|
+
if (!isNullOrUndefined(this.columnIn)) {
|
|
1258
|
+
colCount = this.numberOfColumnsIn;
|
|
1259
|
+
}
|
|
1260
|
+
colCount = colCount > 0 ? colCount : 1;
|
|
1261
|
+
return colCount;
|
|
1262
|
+
},
|
|
1263
|
+
enumerable: true,
|
|
1264
|
+
configurable: true
|
|
1265
|
+
});
|
|
1266
|
+
/**
|
|
1267
|
+
* @private
|
|
1268
|
+
* @param sectionFormat
|
|
1269
|
+
*/
|
|
1270
|
+
ColumnLayout.prototype.setColumns = function (sectionFormat) {
|
|
1271
|
+
this.pageWidth = LayoutHelperMethods.convertPointToPixel(sectionFormat.pageWidth - sectionFormat.leftMargin - sectionFormat.rightMargin);
|
|
1272
|
+
this.numberOfColumnsIn = sectionFormat.numberOfColumns;
|
|
1273
|
+
if (!isNullOrUndefined(sectionFormat.columns)) {
|
|
1274
|
+
var columns = sectionFormat.columns;
|
|
1275
|
+
var columnList = [];
|
|
1276
|
+
for (var i = 0; i < sectionFormat.numberOfColumns; i++) {
|
|
1277
|
+
var space = this.defaultSpaceIn;
|
|
1278
|
+
var width = 0;
|
|
1279
|
+
if (!isNullOrUndefined(columns) && columns.length > 0) {
|
|
1280
|
+
space = columns[i].space;
|
|
1281
|
+
width = columns[i].width;
|
|
1282
|
+
}
|
|
1283
|
+
var col = this.getColumnObj(width, space, sectionFormat.numberOfColumns, sectionFormat.equalWidth);
|
|
1284
|
+
col.index = i;
|
|
1285
|
+
columnList.push(col);
|
|
1286
|
+
}
|
|
1287
|
+
this.columnIn = columnList;
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
/**
|
|
1291
|
+
* @private
|
|
1292
|
+
*/
|
|
1293
|
+
ColumnLayout.prototype.clear = function () {
|
|
1294
|
+
this.currentIndexIn = 0;
|
|
1295
|
+
this.defaultSpaceIn = 36;
|
|
1296
|
+
this.columnIn = null;
|
|
1297
|
+
this.pageWidth = 0;
|
|
1298
|
+
};
|
|
1299
|
+
ColumnLayout.prototype.reset = function () {
|
|
1300
|
+
this.currentIndex = 0;
|
|
1301
|
+
};
|
|
1302
|
+
/**
|
|
1303
|
+
* @private
|
|
1304
|
+
* @param bodyWidget
|
|
1305
|
+
* @param clientArea
|
|
1306
|
+
* @returns
|
|
1307
|
+
*/
|
|
1308
|
+
ColumnLayout.prototype.getColumnBounds = function (bodyWidget, clientArea) {
|
|
1309
|
+
var colIndex = this.currentIndexIn;
|
|
1310
|
+
return this.getColumnBoundsByIndex(colIndex, clientArea);
|
|
1311
|
+
};
|
|
1312
|
+
/**
|
|
1313
|
+
* @private
|
|
1314
|
+
* @param bodyWidget
|
|
1315
|
+
* @param clientArea
|
|
1316
|
+
* @returns
|
|
1317
|
+
*/
|
|
1318
|
+
ColumnLayout.prototype.getColumnBoundsByBodyWidget = function (bodyWidget, clientArea) {
|
|
1319
|
+
var colIndex = bodyWidget.columnIndex;
|
|
1320
|
+
return this.getColumnBoundsByIndex(colIndex, clientArea);
|
|
1321
|
+
};
|
|
1322
|
+
/**
|
|
1323
|
+
* @private
|
|
1324
|
+
* @param bodyWidget
|
|
1325
|
+
* @param clientArea
|
|
1326
|
+
* @returns
|
|
1327
|
+
*/
|
|
1328
|
+
ColumnLayout.prototype.getNextColumnByBodyWidget = function (bodyWidget) {
|
|
1329
|
+
var colIndex = bodyWidget.columnIndex;
|
|
1330
|
+
var nextColumn = this.getColumnByIndex(colIndex + 1);
|
|
1331
|
+
return nextColumn;
|
|
1332
|
+
};
|
|
1333
|
+
ColumnLayout.prototype.getColumnByIndex = function (index) {
|
|
1334
|
+
if (index >= 0 && index < this.columnCount && !isNullOrUndefined(this.columnIn) && this.columnIn.length > 0) {
|
|
1335
|
+
return this.columnIn[index];
|
|
1336
|
+
}
|
|
1337
|
+
return undefined;
|
|
1338
|
+
};
|
|
1339
|
+
ColumnLayout.prototype.getColumnObj = function (colWidth, colSpace, noOfCols, isEqualWidth) {
|
|
1340
|
+
var totalSpace = (noOfCols - 1) * colSpace;
|
|
1341
|
+
var colObj = new WColumnFormat();
|
|
1342
|
+
if ((isEqualWidth || colWidth === 0) && !isNullOrUndefined(this.pageWidth)) {
|
|
1343
|
+
colWidth = (this.pageWidth - totalSpace) / noOfCols;
|
|
1344
|
+
}
|
|
1345
|
+
colObj.width = colWidth;
|
|
1346
|
+
colObj.space = colSpace;
|
|
1347
|
+
return colObj;
|
|
1348
|
+
};
|
|
1349
|
+
ColumnLayout.prototype.getColumnBoundsByIndex = function (colIndex, clientArea) {
|
|
1350
|
+
var colRect = new Rect(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
|
|
1351
|
+
if (colIndex >= 0 && this.columnIn.length > 0) {
|
|
1352
|
+
var curColumn = void 0;
|
|
1353
|
+
var prevColumn = void 0;
|
|
1354
|
+
if (!isNullOrUndefined(this.columnIn[colIndex])) {
|
|
1355
|
+
curColumn = this.getColumnByIndex(colIndex);
|
|
1356
|
+
colRect.width = curColumn.width;
|
|
1357
|
+
for (var i = 0; i < colIndex; i++) {
|
|
1358
|
+
prevColumn = this.columnIn[i];
|
|
1359
|
+
colRect.x += prevColumn.width;
|
|
1360
|
+
colRect.x += prevColumn.space;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return colRect;
|
|
1365
|
+
};
|
|
1366
|
+
return ColumnLayout;
|
|
1367
|
+
}());
|
|
1368
|
+
export { ColumnLayout };
|