UNPKG

devexpress-richedit

Version:

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

724 lines 121 kB
import { MapCreator } from '../../../../../utils/map-creator'; import { NumberingListIndexConstants } from '../../../../utils/numbering-list-index-constants'; import { TabLeaderType } from '../../../../../layout/main-structures/layout-boxes/layout-tab-space-box'; import { BorderInfo } from '../../../../../model/borders/border-info'; import { BorderLineStyle } from '../../../../../model/borders/enums'; import { CharacterPropertyDescriptor } from '../../../../../model/character/character-property-descriptor'; import { CharacterFormattingScript, StrikeoutType, UnderlineType } from '../../../../../model/character/enums'; import { ControlOptions } from '../../../../../model/options/control'; import { TabAlign } from '../../../../../model/paragraph/paragraph'; import { ParagraphAlignment, ParagraphFirstLineIndent, ParagraphPropertyDescriptor } from '../../../../../model/paragraph/paragraph-properties'; import { TabInfo } from '../../../../../model/paragraph/paragraph-style'; import { RichUtils } from '../../../../../model/rich-utils'; import { ShadingInfo } from '../../../../../model/shadings/shading-info'; import { ShadingPattern } from '../../../../../model/shadings/shading-pattern'; import { ShadingHelper } from '../../../../../model/shadings/shading-pattern-helper'; import { TableCellPropertiesMask } from '../../../../../model/tables/properties/table-cell-properties'; import { TablePropertiesMask } from '../../../../../model/tables/properties/table-properties'; import { TableRowPropertyDescriptor } from '../../../../../model/tables/properties/table-row-property-descriptor'; import { HorizontalAlignMode, HorizontalAnchorTypes, TableCellMergingState, TableCellVerticalAlignment, TableLayoutType, TableLookTypes, TableRowAlignment, TextDirection, TextWrapping, VerticalAlignMode, VerticalAnchorTypes } from '../../../../../model/tables/secondary-structures/table-base-structures'; import { TableHeightUnitType, TableWidthUnit, TableWidthUnitType } from '../../../../../model/tables/secondary-structures/table-units'; import { RtfArtBorderConverter } from '../../../utils/rtf-art-border-converter'; import { RtfFontType } from '../../model/character/enums'; import { ParagraphFrameFormattingInfo, ParagraphFrameHorizontalPositionAlignment, ParagraphFrameHorizontalRule, ParagraphFrameVerticalPositionAlignment } from '../../model/paragraph/paragraph-frame-formatting-info'; import { RtfParagraphProperties } from '../../model/paragraph/paragraph-properties'; import { DestinationBase } from '../base/destination'; import { SkipDestination } from '../base/skip-destination'; import { TextAfterDestination } from '../base/text-after-destination'; import { TextBeforeDestination } from '../base/text-before-destination'; import { PictureDestination } from '../picture/picture-destination'; import { ShapePictureDestination } from '../shape/pic/shape-picture-destination'; import { DestinationType } from '../utils/destination-type'; import { ParagraphFrameHorizontalPositionType, ParagraphFrameTextWrapType, ParagraphFrameVerticalPositionType } from '../utils/enums'; import { TableCellPropertyDescriptor } from '../../../../../model/tables/properties/table-cell-properties'; export class DestinationSubDocument extends DestinationBase { get destinationType() { return DestinationType.DestinationSubDocument; } get controlCharHT() { return DestinationSubDocument.controlCharHT; } constructor(importer, targetSubDocument) { super(importer); this.subDocument = targetSubDocument; } get canAppendText() { return true; } canProcessSpecialHexChar() { return true; } get documentModel() { return this.subDocument.documentModel; } static onParChar(importer, _ch) { importer.flushDecoder(); importer.importers.paragraph.insertParagraph(); importer.importers.table.tableReader.onEndParagraph(); } static onNonBreakingSpaceChar(importer, _ch) { importer.flushDecoder(); importer.parseCharWithoutDecoding(RichUtils.specialCharacters.NonBreakingSpace); } static onNonBreakingHyphenChar(importer, _ch) { importer.flushDecoder(); importer.parseCharWithoutDecoding('-'); } static onOptionalHyphenChar(_importer, _ch) { } static onNonShapePictureKeyword(importer, _parameterValue, _hasParameter) { importer.destination = new SkipDestination(importer); } static onShapeGroupKeyword(importer, _parameterValue, _hasParameter) { importer.destination = new SkipDestination(importer); } static onTabKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.TabMark); } static onEmDashKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.EmDash); } static onEnDashKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.EnDash); } static onBulletKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.Bullet); } static onLeftSingleQuoteKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.LeftSingleQuote); } static onRightSingleQuoteKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.RightSingleQuote); } static onLeftDoubleQuoteKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.LeftDoubleQuote); } static onRightDoubleQuoteKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.RightDoubleQuote); } static onEmSpaceKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.EmSpace); } static onEnSpaceKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.EnSpace); } static onQmSpaceKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.QmSpace); } static onShapePictureKeyword(importer, _parameterValue, _hasParameter) { importer.destination = new ShapePictureDestination(importer); } static onShapeKeyword(importer, _parameterValue, _hasParameter) { importer.destination = importer.createShapeDestination(); } static onLineBreakKeyword(importer, _parameterValue, _hasParameter) { importer.parseCharWithoutDecoding(RichUtils.specialCharacters.LineBreak); } static onTableOfContentsEntryKeyword(importer, _parameterValue, _hasParameter) { importer.importers.field.startField(); importer.destination = importer.createTableContentFieldDestination(true); } static onTableOfContentsEntryLevelNumberKeyword(importer, parameterValue, hasParameter) { importer.destination.tableOfContentsEntryLevelNumberKeyword(parameterValue, hasParameter); } static onTableOfContentsEntryTypeTableKeyword(importer, parameterValue, hasParameter) { importer.destination.tableOfContentsEntryTypeTableKeyword(parameterValue, hasParameter); } tableOfContentsEntryLevelNumberKeyword(parameterValue, _hasParameter) { this.insertTextCore(` \\l ${parameterValue}`); } tableOfContentsEntryTypeTableKeyword(parameterValue, hasParameter) { const startCharIndex = 32; const endCharIndex = 255; let type = ""; if (hasParameter && parameterValue >= startCharIndex && parameterValue <= endCharIndex) type += String.fromCharCode(parameterValue); this.insertTextCore(` \\f ${type}`); } static onFieldStartKeyword(importer, _parameterValue, _hasParameter) { const destination = importer.destination; destination.startNewField(); } static onDxCustomRunDataKeyword(_importer, _parameterValue, _hasParameter) { } static onZeroWidthJoiner(importer, _parameterValue, _hasParameter) { DestinationSubDocument.insertSpecialCharacterCore(importer, '\u200D'); } static onZeroWidthNonJoiner(importer, _parameterValue, _hasParameter) { DestinationSubDocument.insertSpecialCharacterCore(importer, '\u200C'); } static onZeroWidthBreakOpportunity(importer, _parameterValue, _hasParameter) { DestinationSubDocument.insertSpecialCharacterCore(importer, '\u200C'); } static onZeroWidthNonBreakOpportunity(importer, _parameterValue, _hasParameter) { DestinationSubDocument.insertSpecialCharacterCore(importer, '\u200D'); } static insertSpecialCharacterCore(importer, specialCharacter) { importer.importers.character.insertText(specialCharacter); } static onParKeyword(importer, _parameterValue, _hasParameter) { importer.importers.paragraph.insertParagraph(); importer.importers.table.tableReader.onEndParagraph(); } static onParagraphStyleIndex(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer)) importer.importers.style.paragraph.rtfStyleIndex = parameterValue; } static onTableStyleIndexForRowOrCell(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer)) importer.importers.table.tableReader.rtfTableStyleIndexForRowOrCell = parameterValue; } static onAlignLeftKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) if (importer.importers.paragraph.paragraphFormatting.coreProperties.rightToLeft) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Right); else importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Left); } static onAlignCenterKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Center); } static onAlignRightKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) if (importer.importers.paragraph.paragraphFormatting.coreProperties.rightToLeft) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Left); else importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Right); } static onAlignJustifyKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.alignment, ParagraphAlignment.Justify); } static onLeftIndentKeyword(importer, parameterValue, _hasParameter) { const maxLeftIndent = 31681; if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && parameterValue <= maxLeftIndent) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.leftIndent, parameterValue); } static onRightIndentKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.rightIndent, parameterValue); } static onFirstLineIndentKeyword(importer, parameterValue, _hasParameter) { const info = importer.importers.paragraph.paragraphFormatting; if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) { info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndentType, ParagraphFirstLineIndent.None); info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndent, 0); return; } const indent = parameterValue; if (indent > 0) { info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndentType, ParagraphFirstLineIndent.Indented); info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndent, indent); } else if (indent < 0) { info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndentType, ParagraphFirstLineIndent.Hanging); info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndent, -indent); } else { info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndentType, ParagraphFirstLineIndent.None); info.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndent, 0); } } static onSpacingBeforeKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.spacingBefore, parameterValue); } static onLeftToRightParagraphKeyword(importer, _parameterValue, _hasParameter) { importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.rightToLeft, false); } static onRightToLeftParagraphKeyword(importer, _parameterValue, _hasParameter) { importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.rightToLeft, true); } static shouldApplyParagraphStyle(importer) { return ControlOptions.isEnabled(importer.richOptions.control.paragraphStyle); } static shouldApplyParagraphFormatting(importer) { return ControlOptions.isEnabled(importer.richOptions.control.paragraphFormatting); } static onSpacingAfterKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.spacingAfter, parameterValue); } static onLineSpacingTypeKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) { importer.importers.paragraph.paragraphFormatting.rtfLineSpacingType = parameterValue; importer.importers.paragraph.paragraphFormatting.rtfLineSpacingMultiplier = 0; importer.importers.paragraph.paragraphFormatting.useLineSpacingMultiplier = false; } } static onLineSpacingMultiplierKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) { importer.importers.paragraph.paragraphFormatting.rtfLineSpacingMultiplier = Math.max(0, parameterValue); importer.importers.paragraph.paragraphFormatting.useLineSpacingMultiplier = true; } } static onHyphenateParagraphKeyword(importer, parameterValue, hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; if (hasParameter && parameterValue == 0) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.suppressHyphenation, true); else importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.suppressHyphenation, false); } static onSuppressLineNumbersKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.suppressLineNumbers, true); } static onContextualSpacingKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.contextualSpacing, true); } static onPageBreakBeforeKeyword(importer, parameterValue, hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; if (!hasParameter) parameterValue = 1; importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.pageBreakBefore, parameterValue != 0); } static onBeforeAutoSpacingKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) { importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.beforeAutoSpacing, parameterValue != 0); if (parameterValue != 0) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.spacingBefore, 0); } } static onAfterAutoSpacingKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) { importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.afterAutoSpacing, parameterValue != 0); if (parameterValue != 0) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.spacingAfter, 0); } } static onKeepWithNextKeyword(importer, parameterValue, hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; if (!hasParameter) parameterValue = 1; importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.keepWithNext, parameterValue != 0); } static onKeepLinesTogetherKeyword(importer, parameterValue, hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; if (!hasParameter) parameterValue = 1; importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.keepLinesTogether, parameterValue != 0); } static onWidowOrphanControlOnKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.widowOrphanControl, true); } static onWidowOrphanControlOffKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer)) importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.widowOrphanControl, false); } static onParagraphShadingKeyword(importer, parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = DestinationSubDocument.calculateShadingPattern(parameterValue); } static calculateShadingPattern(parameterValue) { if (parameterValue > 0) { if (parameterValue > 10000) return ShadingPattern.Solid; const index = Math.floor(parameterValue / 250); return ShadingHelper.getShadingPattern(index); } return ShadingPattern.Clear; } static onParagraphVerticalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinVertStripe; } static onParagraphHorizontalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinHorzStripe; } static onParagraphForwardDiagonalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinReverseDiagStripe; } static onParagraphBackwardDiagonalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinDiagStripe; } static onParagraphCrossBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinHorzCross; } static onParagraphDiagonalCrossBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ThinDiagCross; } static onParagraphDarkHorizontalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.HorzStripe; } static onParagraphDarkVerticalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.VertStripe; } static onParagraphDarkForwardDiagonalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.ReverseDiagStripe; } static onParagraphDarkBackwardDiagonalBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.DiagStripe; } static onParagraphDarkCrossBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.HorzCross; } static onParagraphDarkDiagonalCrossBackgroundPatternKeyword(importer, _parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.shadingPattern = ShadingPattern.DiagCross; } static onParagraphFillColorKeyword(importer, parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.foreColor = DestinationSubDocument.getColorIndex(importer, parameterValue); } static getColorIndex(importer, parameterValue) { const props = importer.documentProperties; return props.colorIndexes.getRtfColorIndexById(parameterValue); } static onParagraphBackgroundKeyword(importer, parameterValue, _hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; importer.importers.paragraph.paragraphFormatting.backColor = DestinationSubDocument.getColorIndex(importer, parameterValue); } static onOutlineLevelKeyword(importer, parameterValue, hasParameter) { if (!DestinationSubDocument.shouldApplyParagraphFormatting(importer)) return; let level = parameterValue; if (level < 0 || level > 8) level = 0; else level++; if (!hasParameter) level = 0; importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.outlineLevel, level); } static onResetParagraphPropertiesKeyword(importer, _parameterValue, _hasParameter) { importer.importers.table.tableReader.rtfTableStyleIndexForRowOrCell = 0; if (DestinationSubDocument.shouldApplyParagraphStyle(importer)) { importer.importers.paragraph.paragraphFormatting = new RtfParagraphProperties(); importer.importers.style.paragraph.rtfStyleIndex = 0; } else { importer.importers.paragraph.paragraphFormatting.paragraphListInfo.numberingListIndex = NumberingListIndexConstants.listIndexNotSetted; importer.importers.paragraph.paragraphFormatting.paragraphListInfo.listLevelIndex = 0; importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndent, 0); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.firstLineIndentType, ParagraphFirstLineIndent.None); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.leftIndent, 0); } } static onTopParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.topBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static onBottomParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.bottomBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static onLeftParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.leftBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static onRightParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.rightBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static onBetweenParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.betweenBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static onBarParagraphBorderKeyword(importer, _parameterValue, _hasParameter) { const border = new BorderInfo(); importer.importers.paragraph.paragraphFormatting.coreProperties.setValue(ParagraphPropertyDescriptor.leftBorder, border); importer.importers.paragraph.paragraphFormatting.processedBorder = border; } static ensureFramePropertiesExists(_importer) { return false; } static createDefaultFrameFormattingInfo() { const result = ParagraphFrameFormattingInfo.createDefaultInfo(); return result; } static onFrameHorizontalPositionKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.x = parameterValue + 1; } } static onFrameHorizontalPositionNegativeKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.x = parameterValue + 1; } } static onFrameHorizontalAlignmentCenterKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionAlignment = ParagraphFrameHorizontalPositionAlignment.Center; } } static onFrameHorizontalAlignmentLeftKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionAlignment = ParagraphFrameHorizontalPositionAlignment.Left; } } static onFrameHorizontalAlignmentRightKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionAlignment = ParagraphFrameHorizontalPositionAlignment.Right; } } static onFrameHorizontalAlignmentInsideKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionAlignment = ParagraphFrameHorizontalPositionAlignment.Inside; } } static onFrameHorizontalAlignmentOutsideKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionAlignment = ParagraphFrameHorizontalPositionAlignment.Outside; } } static onFrameVerticalPositionKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.y = parameterValue + 1; } } static onFrameVerticalPositionNegativeKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.y = parameterValue + 1; } } static onFrameVerticalAlignmentInlineKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Inline; } } static onFrameVerticalAlignmentTopKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Top; } } static onFrameVerticalAlignmentCenterKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Center; } } static onFrameVerticalAlignmentBottomKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Bottom; } } static onFrameVerticalAlignmentInsideKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Inside; } } static onFrameVerticalAlignmentOutsideKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionAlignment = ParagraphFrameVerticalPositionAlignment.Outside; } } static onFrameWidthKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.width = Math.abs(parameterValue); } } static onFrameHeightKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.height = Math.abs(parameterValue); if (parameterValue < 0) importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalRule = ParagraphFrameHorizontalRule.Exact; if (parameterValue > 0) importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalRule = ParagraphFrameHorizontalRule.AtLeast; } } static onFramePaddingKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { const value = parameterValue; importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPadding = value; importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPadding = value; } } static onFrameVerticalPaddingKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPadding = parameterValue; } static onFrameHorizontalPaddingKeyword(importer, parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPadding = parameterValue; } static onParagraphHorizontalPositionTypeMarginKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionType = ParagraphFrameHorizontalPositionType.Margin; } } static onParagraphHorizontalPositionTypePageKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionType = ParagraphFrameHorizontalPositionType.Page; } } static onParagraphHorizontalPositionTypeColumnKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.horizontalPositionType = ParagraphFrameHorizontalPositionType.Column; } } static onParagraphVerticalPositionTypeMarginKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionType = ParagraphFrameVerticalPositionType.Margin; } } static onParagraphVerticalPositionTypePageKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionType = ParagraphFrameVerticalPositionType.Page; } } static onParagraphVerticalPositionTypeLineKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphStyle(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.verticalPositionType = ParagraphFrameVerticalPositionType.Paragraph; } } static onFrameNoWrapKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.textWrapType = ParagraphFrameTextWrapType.NotBeside; } } static onFrameWrapOverlayKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.textWrapType = ParagraphFrameTextWrapType.None; } } static onFrameWrapDefaultKeyword(_importer, _parameterValue, _hasParameter) { } static onFrameWrapAroundKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.textWrapType = ParagraphFrameTextWrapType.Around; } } static onFrameWrapTightKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.textWrapType = ParagraphFrameTextWrapType.Tight; } } static onFrameWrapThroughKeyword(importer, _parameterValue, _hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.textWrapType = ParagraphFrameTextWrapType.Through; } } static onFrameLockAnchor(importer, parameterValue, hasParameter) { if (DestinationSubDocument.shouldApplyParagraphFormatting(importer) && DestinationSubDocument.ensureFramePropertiesExists(importer)) { importer.importers.paragraph.paragraphFormatting.paragraphFrameFormattingInfo.lockFrameAnchorToParagraph = hasParameter ? (parameterValue != 0) : false; } } static onCharacterStyleIndex(importer, parameterValue, _hasParameter) { if (ControlOptions.isEnabled(importer.richOptions.control.characterStyle)) importer.importers.style.character.rtfStyleIndex = parameterValue; } static onBoldKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.bold, val); } static onDeletedKeyword(_importer, _parameterValue, _hasParameter) { } static onItalicKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.italic, val); } static onUnderlineKeywordCore(importer, parameterValue, hasParameter, underlineType) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.underlineType, val ? underlineType : UnderlineType.None); } static onUnderlineSingleKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.Single); } static onUnderlineDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.Dotted); } static onUnderlineDashedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.Dashed); } static onUnderlineDashDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.DashDotted); } static onUnderlineDashDotDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.DashDotDotted); } static onUnderlineDoubleKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.Double); } static onUnderlineHeavyWaveKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.HeavyWave); } static onUnderlineLongDashedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.LongDashed); } static onUnderlineThickSingleKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickSingle); } static onUnderlineThickDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickDotted); } static onUnderlineThickDashedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickDashed); } static onUnderlineThickDashDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickDashDotted); } static onUnderlineThickDashDotDottedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickDashDotDotted); } static onUnderlineThickLongDashedKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.ThickLongDashed); } static onUnderlineDoubleWaveKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.DoubleWave); } static onUnderlineWaveKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onUnderlineKeywordCore(importer, parameterValue, hasParameter, UnderlineType.Wave); } static onUnderlineNoneKeyword(importer, _parameterValue, _hasParameter) { importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.underlineType, UnderlineType.None); } static onUnderlineWordsOnlyKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.underlineType, val ? UnderlineType.Single : UnderlineType.None); importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.underlineWordsOnly, val); } static onUnderlineColorKeyword(importer, parameterValue, hasParameter) { if (!hasParameter) parameterValue = 0; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.underlineColor, DestinationSubDocument.getColorIndex(importer, parameterValue)); } static onStrikeoutKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.strikeoutType, val ? StrikeoutType.Single : StrikeoutType.None); } static onDoubleStrikeoutKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.strikeoutType, val ? StrikeoutType.Double : StrikeoutType.None); } static onSubscriptKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.script, val ? CharacterFormattingScript.Subscript : CharacterFormattingScript.Normal); } static onSuperscriptKeyword(importer, parameterValue, hasParameter) { const val = hasParameter ? parameterValue != 0 : true; importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.script, val ? CharacterFormattingScript.Superscript : CharacterFormattingScript.Normal); } static onNoSuperAndSubScriptKeyword(importer, _parameterValue, _hasParameter) { importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.script, CharacterFormattingScript.Normal); } static onLanguageKeyword(importer, parameterValue, hasParameter) { DestinationSubDocument.onLanguageNpKeyword(importer, parameterValue, hasParameter); importer.importers.character.characterFormatting.coreProperties.setValue(CharacterPropertyDescriptor.noProof, false); } static onLanguageE