devexpress-richedit
Version:
DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.
68 lines (67 loc) • 3.04 kB
JavaScript
import { FixedInterval } from '@devexpress/utils/lib/intervals/fixed';
import { ListUtils } from '@devexpress/utils/lib/utils/list';
import { TableProperties } from '../properties/table-properties';
import { ConditionalTableStyleFormatting } from '../secondary-structures/table-base-structures';
import { TableHeightUnit, TableWidthUnit } from '../secondary-structures/table-units';
export class TableRow {
parentTable;
cells = [];
widthBefore = TableWidthUnit.createDefault();
widthAfter = TableWidthUnit.createDefault();
gridBefore = 0;
gridAfter = 0;
properties;
height = TableHeightUnit.createDefault();
tablePropertiesException = new TableProperties();
get logicColumnCount() { return this.gridBefore + this.gridAfter + ListUtils.accumulate(this.cells, 0, (acc, c) => acc += c.columnSpan); }
conditionalFormatting = ConditionalTableStyleFormatting.WholeTable;
constructor(parentTable, properties) {
this.parentTable = parentTable;
this.properties = properties;
}
get isLastRowInTable() {
return ListUtils.last(this.parentTable.rows) === this;
}
destructor(positionManager) {
for (var cellIndex = 0, cell; cell = this.cells[cellIndex]; cellIndex++)
cell.destructor(positionManager);
}
getStartPosition() {
return this.cells[0].startParagraphPosition.value;
}
getEndPosition() {
return ListUtils.last(this.cells).endParagrapPosition.value;
}
get interval() { return FixedInterval.fromPositions(this.getStartPosition(), this.getEndPosition()); }
getCellColumnIndex(cellIndex) {
return ListUtils.accumulate(this.cells, this.gridBefore, (acc, cell) => acc + cell.columnSpan, 0, cellIndex);
}
getCellIndex(cellColumnIndex) {
let columnSpan = 0;
let cellIndex = -1;
while (columnSpan <= cellColumnIndex)
columnSpan += this.cells[++cellIndex].columnSpan;
return cellIndex;
}
getTotalCellsInRowConsiderGrid() {
let cells = this.gridBefore;
for (let i = 0, cell; cell = this.cells[i]; i++)
cells += cell.columnSpan;
cells += this.gridAfter;
return cells;
}
clone(subDocument, parentTable) {
const properties = subDocument.documentModel.cache.tableRowPropertiesCache.getItem(this.properties);
const result = new TableRow(parentTable, properties);
result.parentTable = parentTable;
result.cells = ListUtils.map(this.cells, r => r.clone(subDocument, result));
result.widthBefore = this.widthBefore.clone();
result.widthAfter = this.widthAfter.clone();
result.gridBefore = this.gridBefore;
result.gridAfter = this.gridAfter;
result.height = this.height.clone();
result.tablePropertiesException = this.tablePropertiesException.clone();
result.conditionalFormatting = this.conditionalFormatting;
return result;
}
}