public TextFormatConverter( TextParser parser, FormatStore store, Injection injection, Stream traceStream, bool traceShowTokenNum, int traceStopOnTokenNum, Stream formatConverterTraceStream) : base(store, formatConverterTraceStream) { #if DEBUG if (traceStream != null) { trace = new TestHtmlTrace(traceStream, traceShowTokenNum, traceStopOnTokenNum); } #endif this.parser = parser; this.injection = injection; // open the document container InitializeDocument(); // open the first paragraph container OpenContainer(FormatContainerType.Block, false); Last.SetProperty(PropertyPrecedence.NonStyle, PropertyId.FontSize, new PropertyValue(LengthUnits.Points, 10)); }
internal override FormatConverter CreatePullChain(Stream sourceStream, IProgressMonitor progressMonitor) { this.Locked = true; this.reportBytes = new ReportBytes(); RtfParser parser; if (this.enableHtmlDeencapsulation) { RtfPreviewStream rtfPreviewStream = sourceStream as RtfPreviewStream; if (rtfPreviewStream == null || rtfPreviewStream.Parser == null || rtfPreviewStream.InternalPosition != 0 || rtfPreviewStream.InputRtfStream == null) { rtfPreviewStream = new RtfPreviewStream(sourceStream, base.InputStreamBufferSize); } parser = new RtfParser(rtfPreviewStream.InputRtfStream, base.InputStreamBufferSize, base.TestBoundaryConditions, progressMonitor, rtfPreviewStream.Parser, this.reportBytes); if (rtfPreviewStream.Encapsulation == RtfEncapsulation.Html) { return(this.CreateDeencapsulationChain(parser, progressMonitor)); } } else { parser = new RtfParser(sourceStream, false, base.InputStreamBufferSize, base.TestBoundaryConditions, progressMonitor, this.reportBytes); } FormatStore formatStore = new FormatStore(); return(new RtfFormatConverter(parser, formatStore, false, this.TestTraceStream, this.TestTraceShowTokenNum, this.TestTraceStopOnTokenNum, this.TestFormatConverterTraceStream)); }
public virtual void Initialize(FormatStore store, SourceFormat sourceFormat, string comment) { this.sourceFormat = sourceFormat; this.comment = comment; this.formatStore = store; this.Restart(this.formatStore.RootNode); }
public TextFormatConverter(TextParser parser, FormatStore store, Injection injection, Stream traceStream, bool traceShowTokenNum, int traceStopOnTokenNum, Stream formatConverterTraceStream) : base(store, formatConverterTraceStream) { this.parser = parser; this.injection = injection; base.InitializeDocument(); base.OpenContainer(FormatContainerType.Block, false); base.Last.SetProperty(PropertyPrecedence.NonStyle, PropertyId.FontSize, new PropertyValue(LengthUnits.Points, 10)); }
private FormatConverter CreateChain(ConverterInput input, IProgressMonitor progressMonitor) { this.Locked = true; HtmlParser parser = new HtmlParser(input, this.detectEncodingFromMetaTag, false, this.testMaxTokenRuns, this.testMaxHtmlTagAttributes, base.TestBoundaryConditions); HtmlNormalizingParser parser2 = new HtmlNormalizingParser(parser, null, false, this.testMaxHtmlNormalizerNesting, base.TestBoundaryConditions, this.testNormalizerTraceStream, this.testNormalizerTraceShowTokenNum, this.testNormalizerTraceStopOnTokenNum); FormatStore formatStore = new FormatStore(); return(new HtmlFormatConverter(parser2, formatStore, false, false, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum, this.TestFormatConverterTraceStream, progressMonitor)); }
internal FormatConverter(FormatStore formatStore, Stream formatConverterTraceStream) { this.Store = formatStore; this.BuildStack = new FormatConverter.BuildStackEntry[16]; this.ContainerStyleBuildHelper = new StyleBuildHelper(this.Store); this.StyleBuildHelper = new StyleBuildHelper(this.Store); this.MultiValueBuildHelper = new MultiValueBuildHelper(this.Store); this.FontFaceDictionary = new Dictionary <string, PropertyValue>(StringComparer.OrdinalIgnoreCase); }
// Token: 0x06001BC3 RID: 7107 RVA: 0x000D52A3 File Offset: 0x000D34A3 internal StyleBuildHelper(FormatStore store) { this.Store = store; this.PropertyMask = default(PropertyBitMask); this.entries = null; this.topEntry = 0; this.currentEntry = -1; this.nonFlagPropertiesCount = 0; }
internal FormatConverter CreateDeencapsulationChain(RtfParser parser, IProgressMonitor progressMonitor) { HtmlInRtfExtractingInput input = new HtmlInRtfExtractingInput(parser, this.TestMaxHtmlTagSize, base.TestBoundaryConditions, this.TestTraceStream, this.TestTraceShowTokenNum, this.TestTraceStopOnTokenNum); HtmlParser parser2 = new HtmlParser(input, false, false, this.TestMaxTokenRuns, this.TestMaxHtmlTagAttributes, base.TestBoundaryConditions); HtmlNormalizingParser parser3 = new HtmlNormalizingParser(parser2, null, false, this.TestMaxHtmlNormalizerNesting, base.TestBoundaryConditions, this.TestNormalizerTraceStream, this.TestNormalizerTraceShowTokenNum, this.TestNormalizerTraceStopOnTokenNum); FormatStore formatStore = new FormatStore(); return(new HtmlFormatConverter(parser3, formatStore, false, false, this.TestHtmlTraceStream, this.TestHtmlTraceShowTokenNum, this.TestHtmlTraceStopOnTokenNum, this.TestFormatConverterTraceStream, progressMonitor)); }
private FormatConverter CreateChain(ConverterInput input, IProgressMonitor progressMonitor) { this.RecognizeHyperlinks = true; this.Locked = true; TextParser parser = new TextParser(input, this.unwrapFlowed, this.unwrapDelSp, this.testMaxTokenRuns, base.TestBoundaryConditions); FormatStore store = new FormatStore(); return(new TextFormatConverter(parser, store, null, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum, this.testFormatConverterTraceStream)); }
public void SaveConfig(string path, bool stylesOnly = false) { path = path ?? ConfigPath; try { var d = Path.GetDirectoryName(path); if (Directory.Exists(d) == false) { Directory.CreateDirectory(d); } object o; if (stylesOnly) { o = new { Version = CurrentVersion, Styles = GetCustomizedStyles() }; } else { o = this; Version = CurrentVersion; Styles = GetCustomizedStyles().ToList(); } File.WriteAllText(path, JsonConvert.SerializeObject( o, Formatting.Indented, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, NullValueHandling = NullValueHandling.Ignore, Converters = { new Newtonsoft.Json.Converters.StringEnumConverter() } })); if (path == ConfigPath) { _LastSaved = _LastLoaded = DateTime.Now; //_ConfigManager?.MarkVersioned(); Debug.WriteLine("Config saved"); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { Styles = null; } IEnumerable <SyntaxStyle> GetCustomizedStyles() { return(FormatStore.GetStyles() .Where(i => i.Value?.IsSet == true) .Select(i => { var s = new SyntaxStyle(i.Key); i.Value.CopyTo(s); return s; })); } }
internal static int GetFormatCrc(FormatStore formatStore, FormatNode formatNode) { int num = 0; TextRun textRun = formatStore.GetTextRun(formatNode.BeginTextPosition); if (!textRun.Equals(TextRun.Invalid)) { while (!textRun.IsEnd() && textRun.Type != TextRunType.NonSpace) { textRun.MoveNext(); } if (!textRun.IsEnd()) { num = (int)textRun.GetWordChar(0); } } Dictionary<PropertyId, List<PropertyValue>> dictionary = new Dictionary<PropertyId, List<PropertyValue>>(); do { if (formatNode.Properties != null) { foreach (Property property in formatNode.Properties) { if (!property.IsNull) { List<PropertyValue> list; if (!dictionary.TryGetValue(property.Id, out list)) { list = new List<PropertyValue>(); dictionary.Add(property.Id, list); } list.Add(property.Value); } } } formatNode = formatNode.Parent; } while (formatNode.Parent != FormatNode.Null); foreach (KeyValuePair<PropertyId, List<PropertyValue>> keyValuePair in dictionary) { int propertyCrc = BodyFragmentInfo.GetPropertyCrc(formatStore, keyValuePair.Key, keyValuePair.Value); if (propertyCrc != 0) { num ^= propertyCrc; } } return num; }
private static int GetFontFaceCrc(FormatStore formatStore, PropertyValue value) { if (value.Type == PropertyType.MultiValue) { return BodyFragmentInfo.GetFontFaceCrc(formatStore, formatStore.MultiValues.Plane(value.Value)[formatStore.MultiValues.Index(value.Value)].Values[0]); } int num = 0; string str = formatStore.Strings.Plane(value.StringHandle)[formatStore.Strings.Index(value.StringHandle)].Str; for (int i = 0; i < str.Length; i++) { char c = char.ToLowerInvariant(str[i]); if (i % 4 == 3) { num += (int)(c >> 8); } num += (int)((int)c << (8 * (i % 4) & 31)); } return num; }
// Token: 0x06001AEE RID: 6894 RVA: 0x000D1718 File Offset: 0x000CF918 internal FormatStyle(FormatStore store, int styleHandle) { this.Styles = store.Styles; this.StyleHandle = styleHandle; }
internal StringValue(FormatStore store, int stringHandle) { this.Strings = store.Strings; this.StringHandle = stringHandle; }
private static int GetPropertyCrc(FormatStore formatStore, PropertyId propertyId, IList<PropertyValue> propertyValues) { int num = 0; if (propertyId <= PropertyId.Language) { switch (propertyId) { case PropertyId.FontColor: if (propertyValues[0].Type == PropertyType.Color && propertyValues[0].Color.RGB != BodyFragmentInfo.defaultFontColor.RGB) { num = (int)propertyValues[0].Color.RGB; goto IL_1AA; } goto IL_1AA; case PropertyId.FontSize: break; case PropertyId.FontFace: num = BodyFragmentInfo.GetFontFaceCrc(formatStore, propertyValues[0]); goto IL_1AA; case PropertyId.TextAlignment: num = ((propertyValues[0].Enum == 3) ? 0 : propertyValues[0].Enum); goto IL_1AA; default: if (propertyId == PropertyId.Language) { num = propertyValues[0].Integer; goto IL_1AA; } break; } } else { switch (propertyId) { case PropertyId.RightMargin: case PropertyId.LeftMargin: { float num2 = 0f; foreach (PropertyValue propertyValue in propertyValues) { num2 += propertyValue.Millimeters; if (propertyValue.Type == PropertyType.AbsLength) { break; } } num = (int)num2; goto IL_1AA; } case PropertyId.BottomMargin: break; default: switch (propertyId) { case PropertyId.RightBorderWidth: case PropertyId.LeftBorderWidth: { float num3 = 0f; foreach (PropertyValue propertyValue2 in propertyValues) { num3 += propertyValue2.Millimeters; } num = (int)(num3 * 2f); goto IL_1AA; } } break; } } return 0; IL_1AA: if (num != 0) { int num4 = (int)(propertyId % PropertyId.LeftMargin); num = (num << num4) + (num >> 32 - num4); } return num; }
// Token: 0x06001BD3 RID: 7123 RVA: 0x000D5CA6 File Offset: 0x000D3EA6 internal MultiValueBuildHelper(FormatStore store) { this.Store = store; this.Values = null; this.ValuesCount = 0; }
internal FormatNode(FormatStore store, int nodeHandle) { this.nodes = store.Nodes; this.nodeHandle = nodeHandle; }
// Token: 0x06001B08 RID: 6920 RVA: 0x000D1C80 File Offset: 0x000CFE80 internal MultiValue(FormatStore store, int multiValueHandle) { this.MultiValues = store.MultiValues; this.MultiValueHandle = multiValueHandle; }
protected virtual void Dispose(bool disposing) { currentOutputLevel.node = FormatNode.Null; outputStack = null; formatStore = null; }