UNPKG

devexpress-richedit

Version:

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

98 lines (97 loc) 5.08 kB
import { TabLeaderType } from '../../../../../layout/main-structures/layout-boxes/layout-tab-space-box'; import { BorderInfo } from '../../../../../model/borders/border-info'; import { TabAlign } from '../../../../../model/paragraph/paragraph'; import { MaskedParagraphProperties, ParagraphLineSpacingType, ParagraphPropertyDescriptor } from '../../../../../model/paragraph/paragraph-properties'; import { TabProperties } from '../../../../../model/paragraph/paragraph-style'; import { ShadingInfo } from '../../../../../model/shadings/shading-info'; import { ParagraphListInfo } from '../../../../../rich-utils/properties-bundle'; export class RtfParagraphProperties { coreProperties = new MaskedParagraphProperties(); paragraphListInfo = ParagraphListInfo.default; get numberingListIndex() { return this.paragraphListInfo.numberingListIndex; } get listLevelIndex() { return this.paragraphListInfo.listLevelIndex; } set shadingPattern(value) { this.coreProperties.setValue(ParagraphPropertyDescriptor.shadingInfo, new ShadingInfo(value, this.coreProperties.shadingInfo.backColor, this.coreProperties.shadingInfo.foreColor)); } set backColor(value) { this.coreProperties.setValue(ParagraphPropertyDescriptor.shadingInfo, new ShadingInfo(this.coreProperties.shadingInfo.shadingPattern, value, this.coreProperties.shadingInfo.foreColor)); } set foreColor(value) { this.coreProperties.setValue(ParagraphPropertyDescriptor.shadingInfo, new ShadingInfo(this.coreProperties.shadingInfo.shadingPattern, this.coreProperties.shadingInfo.backColor, value)); } tabs = new TabProperties(); tabAlignment = TabAlign.Left; tabLeader = TabLeaderType.None; rtfLineSpacingType = 0; rtfLineSpacingMultiplier = 1; useLineSpacingMultiplier = false; inTableParagraph = false; nestingLevel = 0; styleLink = -1; nextStyle = -1; processedBorder = new BorderInfo(); rtfTableStyleIndexForRowOrCell; paragraphFrameFormattingInfo = null; getCoreProperties() { this.applyLineSpacing(); return this.coreProperties; } applyLineSpacing() { this.coreProperties.setValue(ParagraphPropertyDescriptor.lineSpacingType, this.calcLineSpacingType()); this.coreProperties.setValue(ParagraphPropertyDescriptor.lineSpacing, this.calcLineSpacing()); } calcLineSpacingType() { if (this.rtfLineSpacingType < 0) return ParagraphLineSpacingType.Exactly; if (this.rtfLineSpacingType > 0) { if (this.rtfLineSpacingMultiplier == 0) return ParagraphLineSpacingType.AtLeast; else { if (this.rtfLineSpacingType == 240) return ParagraphLineSpacingType.Single; else if (this.rtfLineSpacingType == 360) return ParagraphLineSpacingType.Sesquialteral; else if (this.rtfLineSpacingType == 480) return ParagraphLineSpacingType.Double; else return ParagraphLineSpacingType.Multiple; } } else { if (this.rtfLineSpacingMultiplier == 0 && this.useLineSpacingMultiplier) return ParagraphLineSpacingType.AtLeast; else return ParagraphLineSpacingType.Single; } } calcLineSpacing() { if (this.rtfLineSpacingMultiplier == 0) { if (this.rtfLineSpacingType == 0 && this.useLineSpacingMultiplier) return 240; else return this.rtfLineSpacingType != 0 ? Math.max(Math.abs(this.rtfLineSpacingType), 1) : 0; } else { if (this.rtfLineSpacingType < 0) return Math.max(Math.abs(this.rtfLineSpacingType), 1); else return this.rtfLineSpacingType / 240.0; } } clone() { const obj = new RtfParagraphProperties(); obj.copyFrom(this); return obj; } copyFrom(obj) { this.coreProperties = obj.coreProperties.clone(); this.paragraphListInfo = obj.paragraphListInfo.clone(); this.tabs = obj.tabs.clone(); this.tabAlignment = obj.tabAlignment; this.tabLeader = obj.tabLeader; this.rtfLineSpacingType = obj.rtfLineSpacingType; this.rtfLineSpacingMultiplier = obj.rtfLineSpacingMultiplier; this.useLineSpacingMultiplier = obj.useLineSpacingMultiplier; this.inTableParagraph = obj.inTableParagraph; this.nestingLevel = obj.nestingLevel; this.styleLink = obj.styleLink ? obj.styleLink : null; this.nextStyle = obj.nextStyle ? obj.nextStyle : null; this.processedBorder = obj.processedBorder ? obj.processedBorder.clone() : null; this.rtfTableStyleIndexForRowOrCell = obj.rtfTableStyleIndexForRowOrCell; this.paragraphFrameFormattingInfo = obj.paragraphFrameFormattingInfo ? obj.paragraphFrameFormattingInfo.clone() : null; } }