UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

69 lines (68 loc) 3.39 kB
import { NoteProperties, NoteNumberingRestartType } from "../../../../../../common/model/footnotes/footnote"; import { MapCreator } from "../../../../../../common/utils/map-creator"; import { TranslationTables } from "../../../translation-table/translation-tables"; import { LeafElementDestination, ElementDestination } from "../destination"; export class NotePropertiesLeafElementDestination extends LeafElementDestination { constructor(data, footNote) { super(data); this.footNote = footNote; } } class NoteNumberingStartDestination extends NotePropertiesLeafElementDestination { async processElementOpen(reader) { this.footNote.startingNumber = this.data.readerHelper.getWpSTIntegerValue(reader, "val", 1); } } class NoteNumberingRestartTypeDestination extends NotePropertiesLeafElementDestination { async processElementOpen(reader) { this.footNote.numberingRestartType = this.data.readerHelper.getWpEnumValue(reader, "val", TranslationTables.noteNumberingRestartTypeTable.importMap, NoteNumberingRestartType.Continuous); } } export class NotePropertiesDestination extends ElementDestination { static { this.handlerTable = new MapCreator() .add('pos', (data) => this.getThis(data).createPlacementDestination(data)) .add('numFmt', (data) => this.getThis(data).createNumberingFormatDestination(data)) .add('numStart', (data) => new NoteNumberingStartDestination(data, this.getThis(data).notes)) .add('numRestart', (data) => new NoteNumberingRestartTypeDestination(data, this.getThis(data).notes)) .get(); } static getThis(data) { return data.destinationStack.getThis(); } constructor(data, defaultPosition, defaultFormat) { super(data); this.notes = NoteProperties.createDefault(); this.defaultPosition = defaultPosition; this.defaultFormat = defaultFormat; } get elementHandlerTable() { return NotePropertiesDestination.handlerTable; } async processElementClose(_reader) { this.setProperties(this.notes); } createPlacementDestination(data) { return new NotePlacementDestination(data, this.notes, this.defaultPosition); } createNumberingFormatDestination(data) { return new NoteNumberingFormatDestination(data, this.notes, this.defaultFormat); } } export class NotePlacementDestination extends NotePropertiesLeafElementDestination { constructor(data, footNote, defaultPosition) { super(data, footNote); this.defaultPosition = defaultPosition; } async processElementOpen(reader) { const footNotePosition = this.data.readerHelper.getWpEnumValue(reader, "val", TranslationTables.footNotePlacementTable.importMap, this.defaultPosition); this.footNote.position = footNotePosition; } } export class NoteNumberingFormatDestination extends NotePropertiesLeafElementDestination { constructor(data, footNote, defaultNumberingFormat) { super(data, footNote); this.defaultNumberingFormat = defaultNumberingFormat; } async processElementOpen(reader) { this.footNote.numberingFormat = this.data.readerHelper.getWpEnumValue(reader, "val", TranslationTables.pageNumberingFormatTable.importMap, this.defaultNumberingFormat); } }