UNPKG

devexpress-richedit

Version:

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

55 lines (54 loc) 3.32 kB
import { MapCreator } from '../../../../../../common/utils/map-creator'; import { StringMapUtils } from '@devexpress/utils/lib/utils/map/string'; import { DocxNsType } from '../../../utils/constants'; import { LinkedStyleIdDestination } from './base/linked-style-id-destination'; import { NextStyleDestination } from './base/next-style-destination'; import { StyleHiddenDestination } from './base/style-hidden-destination'; import { StyleNameDestination } from './base/style-name-destination'; import { StyleParentIdDestination } from './base/style-parent-id-destination'; import { StyleQFormatDestination } from './base/style-qformat-destination'; import { StyleSemiHiddenDestination } from './base/style-semi-hidden-destination'; import { StyleConditionalTableFormatting } from './style-conditional-table-formatting'; import { StyleDestinationBase } from './style-destination-base'; export class StyleDestination extends StyleDestinationBase { static { this.handlerTable = new MapCreator(StringMapUtils.map(StyleDestinationBase.handlerTable, e => e)) .add('basedOn', (data, _reader) => new StyleParentIdDestination(data)) .add('hidden', (data, _reader) => new StyleHiddenDestination(data)) .add('qFormat', (data, _reader) => new StyleQFormatDestination(data)) .add('semiHidden', (data, _reader) => new StyleSemiHiddenDestination(data)) .add('name', (data, _reader) => new StyleNameDestination(data)) .add('link', (data, _reader) => new LinkedStyleIdDestination(data)) .add('next', (data, _reader) => new NextStyleDestination(data)) .add('tblStylePr', (data, _reader) => new StyleConditionalTableFormatting(data)) .get(); } get currImporter() { return this.data.stylesImporter.currImporter; } get elementHandlerTable() { return StyleDestination.handlerTable; } async processElementOpen(reader) { super.processElementOpen(reader); switch (reader.getAttributeNS('type', this.data.constants.namespaces[DocxNsType.WordProcessing].namespace)) { case 'character': this.data.stylesImporter.currImporter = this.data.stylesImporter.characterManager; break; case 'table': this.data.stylesImporter.currImporter = this.data.stylesImporter.tableManager; break; case 'tableCell': this.data.stylesImporter.currImporter = this.data.stylesImporter.tableCellManager; break; case 'numbering': this.data.stylesImporter.currImporter = this.data.stylesImporter.numberingListManager; break; case 'paragraph': default: this.data.stylesImporter.currImporter = this.data.stylesImporter.paragraphManager; break; } this.currImporter.startImport(); this.currImporter.currInfo.id = reader.getAttributeNS('styleId', this.data.constants.namespaces[DocxNsType.WordProcessing].namespace); this.currImporter.currInfo.isDefault = this.data.readerHelper.getWpSTOnOffValue(reader, 'default', false); } processElementClose(reader) { super.processElementClose(reader); this.currImporter.endImport(this); } }