/// <summary> /// Emit elements into an array /// </summary> /// <param name="elements"></param> /// <param name="arrayElementType"></param> /// <param name="ilg"></param> /// <param name="services"></param> private static void EmitElementArrayLoad(ExpressionElement[] elements, Type arrayElementType, FleeILGenerator ilg, IServiceProvider services) { // Load the array length LiteralElement.EmitLoad(elements.Length, ilg); // Create the array ilg.Emit(OpCodes.Newarr, arrayElementType); // Store the new array in a unique local and remember the index LocalBuilder local = ilg.DeclareLocal(arrayElementType.MakeArrayType()); int arrayLocalIndex = local.LocalIndex; Utility.EmitStoreLocal(ilg, arrayLocalIndex); for (int i = 0; i <= elements.Length - 1; i++) { // Load the array Utility.EmitLoadLocal(ilg, arrayLocalIndex); // Load the index LiteralElement.EmitLoad(i, ilg); // Emit the element (with any required conversions) ExpressionElement element = elements[i]; element.Emit(ilg, services); ImplicitConverter.EmitImplicitConvert(element.ResultType, arrayElementType, ilg); // Store it into the array Utility.EmitArrayStore(ilg, arrayElementType); } // Load the array Utility.EmitLoadLocal(ilg, arrayLocalIndex); }
void RemoveParenthesesFromPrefixSuffix(PageRangeFieldElement pageRangeFieldElement) { if (pageRangeFieldElement == null) { return; } LiteralElement[] prefixes = new LiteralElement[] { pageRangeFieldElement.PageOnePrefix, pageRangeFieldElement.PageTwoPrefix, pageRangeFieldElement.PageMultiPrefix, pageRangeFieldElement.ColumnOnePrefix, pageRangeFieldElement.ColumnTwoPrefix, pageRangeFieldElement.ColumnMultiPrefix, pageRangeFieldElement.ParagraphOnePrefix, pageRangeFieldElement.ParagraphTwoPrefix, pageRangeFieldElement.ParagraphMultiPrefix, pageRangeFieldElement.MarginOnePrefix, pageRangeFieldElement.MarginTwoPrefix, pageRangeFieldElement.MarginMultiPrefix, pageRangeFieldElement.OtherOnePrefix, pageRangeFieldElement.OtherTwoPrefix, pageRangeFieldElement.OtherMultiPrefix }; LiteralElement[] suffixes = new LiteralElement[] { pageRangeFieldElement.PageOneSuffix, pageRangeFieldElement.PageTwoSuffix, pageRangeFieldElement.PageMultiSuffix, pageRangeFieldElement.ColumnOneSuffix, pageRangeFieldElement.ColumnTwoSuffix, pageRangeFieldElement.ColumnMultiSuffix, pageRangeFieldElement.ParagraphOneSuffix, pageRangeFieldElement.ParagraphTwoSuffix, pageRangeFieldElement.ParagraphMultiSuffix, pageRangeFieldElement.MarginOneSuffix, pageRangeFieldElement.MarginTwoSuffix, pageRangeFieldElement.MarginMultiSuffix, pageRangeFieldElement.OtherOneSuffix, pageRangeFieldElement.OtherTwoSuffix, pageRangeFieldElement.OtherMultiSuffix }; foreach (LiteralElement element in prefixes) { TrimStartParentheses(element); } foreach (LiteralElement element in suffixes) { TrimEndParentheses(element); } }
public override Node ExitHexliteral(Token node) { LiteralElement element = IntegralLiteralElement.Create(node.Image, true, _myInUnaryNegate, _myServices); node.AddValue(element); return(node); }
/// <summary> /// Emit elements into an array /// </summary> private static void EmitElementArrayLoad(BaseExpressionElement[] elements, Type arrayElementType, YaleIlGenerator ilg, ExpressionContext context) { // Load the array length LiteralElement.EmitLoad(elements.Length, ilg); // Create the array ilg.Emit(OpCodes.Newarr, arrayElementType); // Store the new array in a unique local and remember the index var local = ilg.DeclareLocal(arrayElementType.MakeArrayType()); var arrayLocalIndex = local.LocalIndex; Utility.EmitStoreLocal(ilg, arrayLocalIndex); for (var i = 0; i <= elements.Length - 1; i++) { // Load the array Utility.EmitLoadLocal(ilg, arrayLocalIndex); // Load the index LiteralElement.EmitLoad(i, ilg); // Emit the element (with any required conversions) var element = elements[i]; element.Emit(ilg, context); ImplicitConverter.EmitImplicitConvert(element.ResultType, arrayElementType, ilg); // Store it into the array Utility.EmitArrayStore(ilg, arrayElementType); } // Load the array Utility.EmitLoadLocal(ilg, arrayLocalIndex); }
public override Node ExitReal(Token node) { string image = node.Image; LiteralElement element = RealLiteralElement.Create(image, _myServices); node.AddValue(element); return(node); }
/// <summary> /// Emit the load of a constant field. We can't emit a ldsfld/ldfld of a constant so we have to get its value /// and then emit a ldc. /// </summary> /// <param name="fi"></param> /// <param name="ilg"></param> /// <param name="services"></param> private static void EmitLiteral(System.Reflection.FieldInfo fi, FleeILGenerator ilg, IServiceProvider services) { object value = fi.GetValue(null); Type t = value.GetType(); TypeCode code = Type.GetTypeCode(t); LiteralElement elem = default(LiteralElement); switch (code) { case TypeCode.Char: case TypeCode.Byte: case TypeCode.SByte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: elem = new Int32LiteralElement(System.Convert.ToInt32(value)); break; case TypeCode.UInt32: elem = new UInt32LiteralElement((UInt32)value); break; case TypeCode.Int64: elem = new Int64LiteralElement((Int64)value); break; case TypeCode.UInt64: elem = new UInt64LiteralElement((UInt64)value); break; case TypeCode.Double: elem = new DoubleLiteralElement((double)value); break; case TypeCode.Single: elem = new SingleLiteralElement((float)value); break; case TypeCode.Boolean: elem = new BooleanLiteralElement((bool)value); break; case TypeCode.String: elem = new StringLiteralElement((string)value); break; default: elem = null; Debug.Fail("Unsupported constant type"); break; } elem.Emit(ilg, services); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = true; if (citation == null) { return(null); } var citationManager = citation.CitationManager; if (citationManager == null) { return(null); } var bibliographyCitation = citation as BibliographyCitation; if (bibliographyCitation == null) { return(null); } int countCites = ( from cite in citationManager.PlaceholderCitations where cite.YearOnly == false && cite.BibOnly == false && cite.Reference == citation.Reference select cite ).Count(); if (countCites == 0) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || componentPart.Elements.Count == 0) { return(null); } LiteralElement countCitesLiteralElement = componentPart.Elements.OfType <LiteralElement>().FirstOrDefault(element => element.Text == "CITE COUNT"); if (countCitesLiteralElement == null) { return(null); } countCitesLiteralElement.Text = countCites.ToString(); handled = false; return(null); }
public override void Emit(FleeILGenerator ilg, IServiceProvider services) { int index = ilg.GetTempLocalIndex(typeof(TimeSpan)); Utility.EmitLoadLocalAddress(ilg, index); LiteralElement.EmitLoad(_myValue.Ticks, ilg); ilg.Emit(OpCodes.Call, _timeSpanConstructor); Utility.EmitLoadLocal(ilg, index); }
void TrimEndParentheses(LiteralElement literalElement) { if (literalElement == null) { return; } if (string.IsNullOrEmpty(literalElement.Text)) { return; } char[] charsToTrim = { ' ', ')' }; literalElement.Text = literalElement.Text.TrimEnd(charsToTrim); }
public override void Emit(FleeILGenerator ilg, IServiceProvider services) { int index = ilg.GetTempLocalIndex(typeof(DateTime)); Utility.EmitLoadLocalAddress(ilg, index); LiteralElement.EmitLoad(_myValue.Ticks, ilg); ConstructorInfo ci = typeof(DateTime).GetConstructor(new Type[] { typeof(long) }); ilg.Emit(OpCodes.Call, ci); Utility.EmitLoadLocal(ilg, index); }
protected override void ProcessElement(LiteralElement element) { String text = element.Text != null ? element.Text : String.Empty; String href = null; if (element.Type == LiteralElementType.Anchor) { href = element.GetAttribute("href"); } _parent.AddElement(text, href, ((element.Format & LiteralFormat.Bold) == LiteralFormat.Bold), ((element.Format & LiteralFormat.Italic) == LiteralFormat.Italic), element.BreakAfter); _hasElements = true; }
protected override void ProcessElement(LiteralElement element) { MobileControl ctl; switch (element.Type) { case LiteralElementType.Text: { LiteralText textCtl = new LiteralText(); textCtl.BreakAfter = element.BreakAfter; ctl = textCtl; break; } case LiteralElementType.Anchor: { Link link = new LiteralLink(); link.NavigateUrl = element.GetAttribute("href"); link.BreakAfter = element.BreakAfter; ctl = link; break; } default: return; } // Need to add text as a child, so that it can be written out unscathed. if (element.Text != null) { ctl.Controls.Add(new LiteralControl(element.Text)); } if ((element.Format & LiteralFormat.Bold) == LiteralFormat.Bold) { ctl.Font.Bold = BooleanOption.True; } if ((element.Format & LiteralFormat.Italic) == LiteralFormat.Italic) { ctl.Font.Italic = BooleanOption.True; } _parentControl.Controls.Add(ctl); _elementsAdded = true; }
IEnumerable <IElement> TextUnitsToLiteralElements(TextUnitCollection textUnits, ComponentPart componentPart) { if (componentPart == null) { yield break; } if (textUnits == null || textUnits.Count == 0) { yield break; } foreach (ITextUnit textUnit in textUnits) { LiteralElement element = new LiteralElement(componentPart, textUnit.Text, ElementApplyCondition.Always); element.FontStyle = textUnit.FontStyle; yield return(element); } }
private void Flush() { if (_currentTag != null) { // In the middle of a tag. There may be multiple inner text elements inside // a tag, e.g. // <a ...>some text <%# a databinding %> some more text</a> // and we're being flushed just at the start of the databinding. if (!_currentTag.IsEmptyText) { ProcessTagInnerText(_currentTag.Text); } _currentTag.Text = String.Empty; return; } if (_lastQueuedElement == null) { return; } // Ignore orphaned whitespace. if (!_lastQueuedElement.ForceBreakTag && _lastQueuedElement.IsEmptyText) { if (!_elementsProcessed) { return; } if (_lastQueuedElement.Text.Length == 0 || _lastQueuedElement.Text[0] != ' ') { return; } _lastQueuedElement.Text = " "; } _lastQueuedElement.BreakAfter = _beginNewParagraph; ProcessElement(_lastQueuedElement); _lastQueuedElement = null; }
private void ProcessElementInternal(LiteralElement element) { // This method needs to fill in an element with formatting and // breaking information, and calls ProcessElement. However, // each element needs to know whether there will be a break // AFTER the element, so elements are processed lazily, keeping // the last one in a single-element queue. LiteralFormat currentFormat = _formatStack.CurrentFormat; if (_lastQueuedElement != null) { // If both the last and current element are text elements, and // the formatting hasn't changed, then just combine the two into // a single element. if (_lastQueuedElement.IsText && element.IsText && (_lastQueuedElement.Format == currentFormat) && !_beginNewParagraph) { _lastQueuedElement.Text += element.Text; return; } else if (_lastQueuedElement.IsEmptyText && !_beginNewParagraph && IgnoreWhiteSpaceElement(_lastQueuedElement)) { // Empty text element with no breaks - so just ignore. } else { _lastQueuedElement.BreakAfter = _beginNewParagraph; ProcessElement(_lastQueuedElement); _elementsProcessed = true; } } _lastQueuedElement = element; _lastQueuedElement.Format = currentFormat; _beginNewParagraph = false; }
protected override void ProcessElement(LiteralElement element) { ControlBuilder subBuilder; switch (element.Type) { case LiteralElementType.Text: Debug.Assert(_tagInnerTextElements == null); subBuilder = ControlBuilder.CreateBuilderFromType( _parser, _parentBuilder, typeof(LiteralText), typeof(LiteralText).Name, null, GetPropertyDictionary(element.Format, element.BreakAfter, null), _lineNumber, _fileName); break; case LiteralElementType.Anchor: { String linkUrl = (String)element.GetAttribute("href"); subBuilder = ControlBuilder.CreateBuilderFromType( _parser, _parentBuilder, typeof(LiteralLink), typeof(LiteralLink).Name, null, GetPropertyDictionary(element.Format, element.BreakAfter, linkUrl), _lineNumber, _fileName); AddTagInnerTextElements(subBuilder); break; } default: return; } _parentBuilder.AppendSubBuilder(subBuilder); if (element.Text != String.Empty) { subBuilder.AppendLiteralString(element.Text); } }
protected override void ProcessElement(LiteralElement element) { ControlBuilder subBuilder; switch (element.Type) { case LiteralElementType.Text: Debug.Assert(_tagInnerTextElements == null); subBuilder = ControlBuilder.CreateBuilderFromType( _parser, _parentBuilder, typeof(LiteralText), typeof(LiteralText).Name, null, GetPropertyDictionary(element.Format, element.BreakAfter, null), _lineNumber, _fileName); break; case LiteralElementType.Anchor: { String linkUrl = (String)element.GetAttribute("href"); subBuilder = ControlBuilder.CreateBuilderFromType( _parser, _parentBuilder, typeof(LiteralLink), typeof(LiteralLink).Name, null, GetPropertyDictionary(element.Format, element.BreakAfter, linkUrl), _lineNumber, _fileName); AddTagInnerTextElements(subBuilder); break; } default: return; } _parentBuilder.AppendSubBuilder(subBuilder); if (element.Text == null || element.Text.Length != 0) { subBuilder.AppendLiteralString(element.Text); } }
private static IEnumerable <LiteralElement> CreateLiteralElements(SerializationContext context) { foreach (Literal literal in context.Snippet.Literals.Where(f => string.IsNullOrEmpty(f.TypeName))) { var element = new LiteralElement(); if (!string.IsNullOrEmpty(literal.DefaultValue)) { element.Default = literal.DefaultValue; } if (!string.IsNullOrEmpty(literal.Identifier)) { element.ID = literal.Identifier; } element.Editable = literal.IsEditable; element.Function = literal.Function; element.ToolTip = literal.ToolTip; yield return(element); } }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; if (citation == null) { return(null); } if (citation.Reference == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || !componentPart.Elements.Any()) { return(null); } #region ReferenceInScope Reference referenceInScope = null; if (componentPart.Scope == ComponentPartScope.Reference) { referenceInScope = citation.Reference; } else if (componentPart.Scope == ComponentPartScope.ParentReference) { referenceInScope = citation.Reference.ParentReference; } if (referenceInScope == null) { return(null); } #endregion IEnumerable <DateTimeFieldElement> dateTimeFieldElements = componentPart.Elements.OfType <DateTimeFieldElement>().ToList(); if (dateTimeFieldElements == null || !dateTimeFieldElements.Any()) { return(null); } bool dateFound = false; CultureInfo targetCulture = CultureInfo.CreateSpecificCulture("en-US"); string targetFullFormat = ""; //use "" and it will be taken from the DateTimeFieldElement string targetYearMonthFormat = "yyyy MMM"; string targetYearOnlyFormat = "yyyy"; foreach (DateTimeFieldElement dateTimeFieldElement in dateTimeFieldElements) { if (string.IsNullOrEmpty(targetFullFormat)) { targetFullFormat = dateTimeFieldElement.Format; } ReferencePropertyId propertyId = dateTimeFieldElement.PropertyId; string dateString = referenceInScope.GetValue(propertyId) as string; if (string.IsNullOrEmpty(dateString)) { continue; } List <Segment> segments = GetSegments(dateString); if (segments == null || !segments.Any()) { continue; } List <LiteralElement> literalElements = new List <LiteralElement>(); foreach (Segment segment in segments) { switch (segment.type) { #region Text case SegmentType.Text: { var literalElement = new LiteralElement(componentPart, segment.text); literalElement.FontStyle = dateTimeFieldElement.FontStyle; literalElements.Add(literalElement); } break; #endregion #region DateTime case SegmentType.DateTime: { string newDateString; if (!segment.ContainsMonthInformation && !segment.ContainsDayInformation) { newDateString = segment.dateTime.ToString(targetYearOnlyFormat, targetCulture); } else if (!segment.ContainsDayInformation) { newDateString = segment.dateTime.ToString(targetYearMonthFormat, targetCulture); } else { newDateString = segment.dateTime.ToString(targetFullFormat, targetCulture); } var literalElement = new LiteralElement(componentPart, newDateString); literalElement.FontStyle = dateTimeFieldElement.FontStyle; literalElements.Add(literalElement); } break; #endregion } } //replace the DateTimeFieldElement by the LiteralElements componentPart.Elements.ReplaceItem(dateTimeFieldElement, literalElements); } //and Citavi handles the rest, therefore we say handled = false && return null handled = false; return(null); }
protected override bool IgnoreWhiteSpaceElement(LiteralElement element) { return(!_hasElements); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; if (citation == null) { return(null); } Reference currentReference = citation.Reference; if (currentReference == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || !componentPart.Elements.Any()) { return(null); } PlaceholderCitation placeholderCitation = citation as PlaceholderCitation; if (placeholderCitation == null) { return(null); } if (placeholderCitation.Entry == null) { return(null); } PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault(); if (pageRangeFieldElement == null) { return(null); } var outputString = "o. S."; if (placeholderCitation.PageRange != null || !string.IsNullOrWhiteSpace(placeholderCitation.PageRange.OriginalString)) { return(null); } var outputLiteralElement = new LiteralElement(componentPart, outputString); outputLiteralElement.FontStyle = pageRangeFieldElement.PageMultiStartFontStyle; componentPart.Elements.ReplaceItem(pageRangeFieldElement, outputLiteralElement); //all literal elements should always be output: foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>()) { literalElement.ApplyCondition = ElementApplyCondition.Always; } return(null); }
protected override bool IgnoreWhiteSpaceElement(LiteralElement element) { return !_hasElements; }
// Parse a single tag. private void ParseTag(String literalText, int tagStart, int tagFinish) { bool isClosingTag = (literalText[tagStart] == '/'); if (isClosingTag) { tagStart++; } // Empty tag? if (tagStart == tagFinish) { return; } // Look for end of tag name. int tagNameFinish = tagStart; while (tagNameFinish < tagFinish && !Char.IsWhiteSpace(literalText[tagNameFinish]) && literalText[tagNameFinish] != '/') { tagNameFinish++; } // Extract tag name, and compare to recognized tags. String tagName = literalText.Substring(tagStart, tagNameFinish - tagStart); LiteralElementType tagType = TagNameToType(tagName); if (tagType == LiteralElementType.Unrecognized) { return; } // Are we already in a complex tag? if (_currentTag != null) { // Ignore any inner tags, except the closing tag. if (_currentTag.Type == tagType && isClosingTag) { ProcessElementInternal(_currentTag); _currentTag = null; } else { // } return; } switch (tagType) { case LiteralElementType.Paragraph: // Do not create two breaks for </p><p> pairs. if (!_isBreakingReset) { _isBreakingReset = true; goto case LiteralElementType.Break; } break; case LiteralElementType.Break: // If a break is already pending, insert an empty one. if (_beginNewParagraph) { ParseText(String.Empty); } if (_lastQueuedElement != null && _lastQueuedElement.Text.Length == 0) { _lastQueuedElement.ForceBreakTag = true; } _beginNewParagraph = true; break; case LiteralElementType.Bold: if (isClosingTag) { _formatStack.Pop(FormatStack.Bold); } else { _formatStack.Push(FormatStack.Bold); } break; case LiteralElementType.Italic: if (isClosingTag) { _formatStack.Pop(FormatStack.Italic); } else { _formatStack.Push(FormatStack.Italic); } break; default: { if (!isClosingTag) { IDictionary attribs = ParseTagAttributes(literalText, tagNameFinish, tagFinish, tagName); _currentTag = new LiteralElement(tagType, attribs); } break; } } if (_isBreakingReset && tagType != LiteralElementType.Paragraph) { _isBreakingReset = false; } }
// Parse a single tag. private void ParseTag(String literalText, int tagStart, int tagFinish) { bool isClosingTag; if ((isClosingTag = (literalText[tagStart] == '/')) == true) { tagStart++; } // Empty tag? if (tagStart == tagFinish) { return; } // Look for end of tag name. int tagNameFinish = tagStart; while (tagNameFinish < tagFinish && !Char.IsWhiteSpace(literalText[tagNameFinish]) && literalText[tagNameFinish] != '/') { tagNameFinish++; } // Extract tag name, and compare to recognized tags. String tagName = literalText.Substring(tagStart, tagNameFinish - tagStart); LiteralElementType tagType = TagNameToType(tagName); if (tagType == LiteralElementType.Unrecognized) { return; } // Are we already in a complex tag? if (_currentTag != null) { // Ignore any inner tags, except the closing tag. if (_currentTag.Type == tagType && isClosingTag) { ProcessElementInternal(_currentTag); _currentTag = null; } else { // TODO: Error? } return; } switch (tagType) { case LiteralElementType.Paragraph: // Do not create two breaks for </p><p> pairs. if (!_isBreakingReset) { _isBreakingReset = true; goto case LiteralElementType.Break; } break; case LiteralElementType.Break: // If a break is already pending, insert an empty one. if (_beginNewParagraph) { ParseText(""); } if (_lastQueuedElement != null && _lastQueuedElement.Text.Length == 0) { _lastQueuedElement.ForceBreakTag = true; } _beginNewParagraph = true; break; case LiteralElementType.Bold: if (isClosingTag) { _formatStack.Pop(FormatStack.Bold); } else { _formatStack.Push(FormatStack.Bold); } break; case LiteralElementType.Italic: if (isClosingTag) { _formatStack.Pop(FormatStack.Italic); } else { _formatStack.Push(FormatStack.Italic); } break; default: { if (!isClosingTag) { IDictionary attribs = ParseTagAttributes(literalText, tagNameFinish, tagFinish, tagName); _currentTag = new LiteralElement(tagType, attribs); } break; } } if (_isBreakingReset && tagType != LiteralElementType.Paragraph) { _isBreakingReset = false; } }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; if (componentPart == null) { return(null); } if (citation == null) { return(null); } if (citation.Reference == null) { return(null); } if (componentPart.Scope == ComponentPartScope.ParentReference && citation.Reference.ParentReference == null) { return(null); } var referenceInScopeOfComponentPart = componentPart.Scope == ComponentPartScope.ParentReference ? citation.Reference.ParentReference : citation.Reference; //check for the first custom field in the componentPart ... we expect this to be the field where the publication media type ist stored ReferencePropertyId[] customFieldProperties = new ReferencePropertyId[] { ReferencePropertyId.CustomField1, ReferencePropertyId.CustomField2, ReferencePropertyId.CustomField3, ReferencePropertyId.CustomField4, ReferencePropertyId.CustomField5, ReferencePropertyId.CustomField6, ReferencePropertyId.CustomField7, ReferencePropertyId.CustomField8, ReferencePropertyId.CustomField9 }; TextFieldElement customFieldElement = componentPart.GetFieldElements().OfType <TextFieldElement>().FirstOrDefault(fieldElement => customFieldProperties.Contains(fieldElement.PropertyId)); if (customFieldElement == null) { return(null); } //check if corresponding reference field contains data var mediaType = referenceInScopeOfComponentPart.GetValue(customFieldElement.PropertyId) as string; if (string.IsNullOrEmpty(mediaType)) { return(null); } //the following words should be output in italics var specialMediaTypes = new string[] { "iPad", "Kindle", "Microsoft", "Word", "PowerPoint", "Excel", "Nook", "Sony", "Adobe" }; var regEx = new Regex(@"\b(" + string.Join("|", specialMediaTypes) + @")\b", RegexOptions.IgnoreCase); if (regEx.IsMatch(mediaType)) { var words = mediaType.Split(' '); var newLiteralElements = new List <LiteralElement>(); for (int i = 0; i < words.Count(); i++) { var word = words[i]; if (string.IsNullOrWhiteSpace(word)) { continue; } LiteralElement newLiteralElement = null; if (i < words.Count() - 1) { newLiteralElement = new LiteralElement(componentPart, word + " "); } else { newLiteralElement = new LiteralElement(componentPart, word); } if (specialMediaTypes.Contains(word)) { newLiteralElement.FontStyle = SwissAcademic.Drawing.FontStyle.Italic; } else { newLiteralElement.FontStyle = SwissAcademic.Drawing.FontStyle.Neutral; } newLiteralElements.Add(newLiteralElement); } var index = componentPart.Elements.IndexOf(customFieldElement); componentPart.Elements.RemoveAt(index); componentPart.Elements.InsertElements(index, newLiteralElements); foreach (var element in componentPart.Elements.OfType <LiteralElement>()) { element.ApplyCondition = ElementApplyCondition.Always; } //componentPart.Elements.ReplaceItem(customFieldElement, newLiteralElements); } return(null); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { //return handled = true if this macro generates the output (as a IEnumerable<ITextUnit>); the standard output will be suppressed //return handled = false if you want Citavi to produce the standard output; //you can still manipulate the component part and its elements before letting Citavi generate the output with handled = false handled = false; if (citation == null) { return(null); } if (citation.Reference == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || componentPart.Elements.Count == 0) { return(null); } var hasDOI = !string.IsNullOrEmpty(citation.Reference.Doi); var hasPubMedId = !string.IsNullOrEmpty(citation.Reference.PubMedId); if (!hasDOI && !hasPubMedId) { return(null); //die Komponente "leert" sich von alleine, denn die (statische) Beschriftung wird nur ausgegeben, wenn eines der Felder Inhalt hat. } IEnumerable <TextFieldElement> doiFieldElements = componentPart.Elements.OfType <TextFieldElement>().Where(element => element.PropertyId == ReferencePropertyId.Doi); if (doiFieldElements == null || doiFieldElements.Count() != 1) { return(null); } TextFieldElement doiFieldElement = doiFieldElements.FirstOrDefault(); if (doiFieldElement == null) { return(null); } IEnumerable <TextFieldElement> pmidFieldElements = componentPart.Elements.OfType <TextFieldElement>().Where(element => element.PropertyId == ReferencePropertyId.PubMedId); if (pmidFieldElements == null || pmidFieldElements.Count() != 1) { return(null); } TextFieldElement pmidFieldElement = pmidFieldElements.FirstOrDefault(); if (pmidFieldElement == null) { return(null); } IEnumerable <LiteralElement> literalElements = componentPart.Elements.OfType <LiteralElement>().Where(element => element.Text == "Identifier: "); if (literalElements == null || literalElements.Count() != 1) { return(null); } LiteralElement literalElement = literalElements.FirstOrDefault(); if (literalElement == null) { return(null); } //nur PubMedID? -> Beschriftung auf "PMID: " if (hasPubMedId && !hasDOI) { literalElement.Text = "PMID: "; return(null); } //nur DOI? -> Beschriftung auf "DOI: " if (!hasPubMedId && hasDOI) { literalElement.Text = "DOI: "; return(null); } //PubMedID UND DOI? -> PubMedID ist zu bevorzugen! Beschriftung auf "PMID: " und DOI-Feldelement rauswerfen if (hasPubMedId && hasDOI) { literalElement.Text = "PMID: "; componentPart.Elements.Remove(doiFieldElement); return(null); } //hierher sollten wir nie kommen, aber wer weiss return(null); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { //Change this to .PeriodSpace, .PeriodOnly, .SpaceOnly or .NoPeriodNoSpace if required //[1] Period/space (Intl. J. History) - DEFAULT //[2] Space only (Intl J History) //[3] Period only (Intl.J.Histry) //[4] No period, no space (IntlJHistory) PeriodicalAbbreviationOutputStyle outputStyle = PeriodicalAbbreviationOutputStyle.SpaceOnly; handled = false; if (citation == null) { return(null); } Reference reference = citation.Reference; if (reference == null) { return(null); } if (!citation.Reference.HasCoreField(ReferenceTypeCoreFieldId.Periodical)) { return(null); } Periodical periodical = reference.Periodical; if (periodical == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || componentPart.Elements.Count == 0) { return(null); } var firstPeriodicalFieldElement = componentPart.Elements.FirstOrDefault <IElement>(element => element is PeriodicalFieldElement) as PeriodicalFieldElement; if (firstPeriodicalFieldElement == null) { return(null); } PeriodicalNameUsage nameUsage = firstPeriodicalFieldElement.PeriodicalNameUsage; if (nameUsage == PeriodicalNameUsage.Name) { return(null); //if the PeriodicalFieldElement is set to ignore abbreviations, we exit here } if (nameUsage == PeriodicalNameUsage.UserAbbreviation2) { return(null); //ditto für UserAbbreviation2, Abkürzung 3 } string abbreviation = String.Empty; string periodicalName = periodical.Name; #region Determine Abbreviation if (nameUsage == PeriodicalNameUsage.StandardAbbreviation) { if (!string.IsNullOrEmpty(periodical.StandardAbbreviation)) { //Wenn das gewählte Feld [Abkürzung 1 bzw. 2] bei einer Zeitschrift gefüllt ist, muss das Skript nicht tätig werden, //sondern der Eintrag wird einfach ausgegeben. return(null); } else if (!string.IsNullOrEmpty(periodical.UserAbbreviation1)) { //Wenn das gewählte Feld [Abkürzung 1 bzw. 2] bei einer Zeitschrift leer ist, das gegenläufige Abkürzungsfeld (1 vs. 2) aber gefüllt, //dann soll das Skript das entsprechende Format generieren. abbreviation = periodical.UserAbbreviation1; } } else if (nameUsage == PeriodicalNameUsage.UserAbbreviation1) { if (!string.IsNullOrEmpty(periodical.UserAbbreviation1)) { //Wenn das gewählte Feld [Abkürzung 1 bzw. 2] bei einer Zeitschrift gefüllt ist, muss das Skript nicht tätig werden, //sondern der Eintrag wird einfach ausgegeben. return(null); } else if (!string.IsNullOrEmpty(periodical.StandardAbbreviation)) { abbreviation = periodical.StandardAbbreviation; } } #endregion //Wenn beide Felder Abkürzung 1 und 2 leer sind, kann und darf das Skript nicht tätig werden. //Wenn dann die Checkbox "Automatisch zurückfallen auf den nächsten verfügbaren Namen" aktiviert ist, wird der vollständige Zeitschriftenname ausgegeben. //Wenn nicht, hängt das Verhalten ja davon ab, ob bei der Komponente das Häkchen vor "Dieses Feld darf nicht leer sein" gesetzt ist, //dementsprechend erscheint ggf. ein Hinweistext oder eben auch nicht. if (string.IsNullOrEmpty(abbreviation)) { return(null); } string[] periodicalNameWords = periodicalName.ToLowerInvariant().Split(new char[] { ' ', '.', ';', ',', ':', '&', '-' }, StringSplitOptions.RemoveEmptyEntries); string[] abbreviationWords = abbreviation.Split(new string[] { " ", " ", " " }, StringSplitOptions.RemoveEmptyEntries); //string[] abbreviationWords = abbreviation.Split(' '); if (!abbreviation.Contains(".")) { List <string> abbreviationWithFullStops = new List <string>(); foreach (string word in abbreviationWords) { if (word.StartsWith("(") || word.EndsWith(")")) { abbreviationWithFullStops.Add(word); } else if (!Array.Exists(periodicalNameWords, x => x == word.ToLowerInvariant())) { abbreviationWithFullStops.Add(word + "."); } else { abbreviationWithFullStops.Add(word); } } abbreviationWords = abbreviationWithFullStops.ToArray(); } string[] wordsWithoutPeriod = new String[abbreviationWords.Length]; abbreviationWords.CopyTo(wordsWithoutPeriod, 0); for (int i = 0; i < wordsWithoutPeriod.Length; i++) { wordsWithoutPeriod[i] = wordsWithoutPeriod[i].TrimEnd('.'); } var outputTextElement = new LiteralElement(componentPart, abbreviation); outputTextElement.FontStyle = firstPeriodicalFieldElement.FontStyle; switch (outputStyle) { case PeriodicalAbbreviationOutputStyle.PeriodOnly: outputTextElement.Text = string.Join("", abbreviationWords); break; case PeriodicalAbbreviationOutputStyle.PeriodSpace: outputTextElement.Text = string.Join(" ", abbreviationWords); break; case PeriodicalAbbreviationOutputStyle.SpaceOnly: outputTextElement.Text = string.Join(" ", wordsWithoutPeriod); break; case PeriodicalAbbreviationOutputStyle.NoPeriodNoSpace: outputTextElement.Text = string.Join("", wordsWithoutPeriod); break; } componentPart.Elements.ReplaceItem(firstPeriodicalFieldElement, outputTextElement); return(null); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; bool addAmbiguityResolvingLetter = true; string noYearString = "o.J."; string noYearTemplate = "{0}{1}"; //add a space if you do not want the ambiguity resolving letter to "stick" to the no-year-string: "{0} {1}" if (citation == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || componentPart.Elements.Count == 0) { return(null); } Reference reference = citation.Reference; if (reference == null) { return(null); } //Reference in Scope of ComponentPart Reference referenceInScope = componentPart.Scope == ComponentPartScope.Reference ? citation.Reference : citation.Reference.ParentReference; if (referenceInScope == null) { return(null); } var yearFieldElement = componentPart.Elements .OfType <DateTimeFieldElement>() .Where(item => item.PropertyId == ReferencePropertyId.Year || item.PropertyId == ReferencePropertyId.YearResolved) .FirstOrDefault() as DateTimeFieldElement; if (yearFieldElement == null) { return(null); } string yearValue = referenceInScope.GetValue(yearFieldElement.PropertyId) as string; if (!string.IsNullOrEmpty(yearValue)) { return(null); } //for the identifying letter we need a corresponding bibliography citation BibliographyCitation correspondingBibliographyCitationInScope = null; BibliographyCitation thisBibliographyCitation = citation as BibliographyCitation; if (componentPart.Scope == ComponentPartScope.Reference) { #region ComponentPartScope.Reference if (thisBibliographyCitation == null) { PlaceholderCitation placeholderCitation = citation as PlaceholderCitation; if (placeholderCitation != null) { correspondingBibliographyCitationInScope = placeholderCitation.CorrespondingBibliographyCitation; } } else { correspondingBibliographyCitationInScope = thisBibliographyCitation; } #endregion } else { #region ComponentPartScope.ParentReference if (citation.CitationManager != null) { foreach (BibliographyCitation otherBibliographyCitation in citation.CitationManager.BibliographyCitations) { if (otherBibliographyCitation == null) { continue; } if (otherBibliographyCitation == thisBibliographyCitation) { continue; } if (otherBibliographyCitation.Reference == null) { continue; } if (otherBibliographyCitation.Reference == referenceInScope) { correspondingBibliographyCitationInScope = otherBibliographyCitation; } } } #endregion } string identifyingLetter = string.Empty; if (correspondingBibliographyCitationInScope != null) { identifyingLetter = correspondingBibliographyCitationInScope.IdentifyingLetter; } string outputString = string.Format(noYearTemplate, noYearString, identifyingLetter); LiteralElement outputLiteralElement = new LiteralElement(componentPart, outputString); outputLiteralElement.FontStyle = yearFieldElement.FontStyle; componentPart.Elements.ReplaceItem(yearFieldElement, outputLiteralElement); //all literal elements should always be output: foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>()) { literalElement.ApplyCondition = ElementApplyCondition.Always; } return(null); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; if (citation == null) { return(null); } if (citation.Reference == null) { return(null); } if (componentPart == null) { return(null); } #region Find electronic address field elements //we treat only electronic address field elemements that output the Edition field IEnumerable <ElectronicAddressFieldElement> electronicAddressFieldElements = componentPart.Elements.OfType <ElectronicAddressFieldElement>().Where(element => element.PropertyId == ReferencePropertyId.OnlineAddress).ToList(); if (electronicAddressFieldElements == null || !electronicAddressFieldElements.Any()) { return(null); } #endregion Find numeric field elements #region Determine reference to look at Reference reference; if (componentPart.Scope == ComponentPartScope.ParentReference) { if (citation.Reference.ParentReference == null) { return(null); } reference = citation.Reference.ParentReference as Reference; } else { reference = citation.Reference as Reference; } if (reference == null) { return(null); } #endregion Determine reference to look at if (string.IsNullOrEmpty(reference.OnlineAddress)) { return(null); } #region Determine reference language Language language; if (String.Equals(reference.LanguageCode, CultureInfo.GetCultureInfo("en").TwoLetterISOLanguageName, StringComparison.OrdinalIgnoreCase)) { language = Language.English; } else if (String.Equals(reference.LanguageCode, CultureInfo.GetCultureInfo("de").TwoLetterISOLanguageName, StringComparison.OrdinalIgnoreCase)) { language = Language.German; } else { language = Language.Other; } #endregion Determine reference language foreach (ElectronicAddressFieldElement element in electronicAddressFieldElements) { var property = element.PropertyId; var value = (string)reference.GetValue(property); //if (string.IsNullOrEmpty(value)) continue; switch (language) { case (Language.English): { //add prefix LiteralElement newElement = new LiteralElement(componentPart, "Online available at "); componentPart.Elements.InsertIElementBefore(element, newElement); //add suffix newElement = new LiteralElement(componentPart, ""); componentPart.Elements.InsertIElementAfter(element, newElement); } break; default: case (Language.German): { //add prefix LiteralElement newElement = new LiteralElement(componentPart, "Online verfügbar unter "); componentPart.Elements.InsertIElementBefore(element, newElement); //add suffix newElement = new LiteralElement(componentPart, ""); componentPart.Elements.InsertIElementAfter(element, newElement); } break; case Language.Other: { //add prefix LiteralElement newElement = new LiteralElement(componentPart, "Online verfügbar unter "); componentPart.Elements.InsertIElementBefore(element, newElement); //add suffix newElement = new LiteralElement(componentPart, ""); componentPart.Elements.InsertIElementAfter(element, newElement); } break; } } return(null); }
private void ProcessElementInternal(LiteralElement element) { // This method needs to fill in an element with formatting and // breaking information, and calls ProcessElement. However, // each element needs to know whether there will be a break // AFTER the element, so elements are processed lazily, keeping // the last one in a single-element queue. LiteralFormat currentFormat = _formatStack.CurrentFormat; if (_lastQueuedElement != null) { // If both the last and current element are text elements, and // the formatting hasn't changed, then just combine the two into // a single element. if (_lastQueuedElement.IsText && element.IsText && (_lastQueuedElement.Format == currentFormat) && !_beginNewParagraph) { _lastQueuedElement.Text += element.Text; return; } else if (_lastQueuedElement.IsEmptyText && !_beginNewParagraph && IgnoreWhiteSpaceElement(_lastQueuedElement)) { // Empty text element with no breaks - so just ignore. } else { _lastQueuedElement.BreakAfter = _beginNewParagraph; ProcessElement(_lastQueuedElement); ElementsProcessed = true; } } _lastQueuedElement = element; _lastQueuedElement.Format = currentFormat; _beginNewParagraph = false; }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { //-------- START OPTIONS ---------------- var outputMode = OutputMode.ShowISSNOnlyOrSuppressJournalName; //append ISSN to journal name or replace the journal name with the ISSN or suppress it when there is no ISSN var prefix = "ISSN "; //add a space e.g., or " ISSN: " var prefixFontStyle = FontStyle.Neutral; //this is how you assign several styles at once: = FontStyle.Bold | FontStyle.Italic; var useBrackets = BracketType.None; //replace None with either of the following: Parentheses, Brackes, CurlyBraces, Slashes, AngleBracktes var bracketsFontStyle = FontStyle.Neutral; var issnFontStyle = FontStyle.Neutral; //-------- END OPTIONS ---------------- handled = false; if (componentPart == null) { return(null); } if (template == null) { return(null); } if (citation == null || citation.Reference == null) { return(null); } var periodical = citation.Reference.Periodical; if (periodical == null) { return(null); } var issnString = periodical.Issn; bool hasISSN = !string.IsNullOrWhiteSpace(issnString); var periodicalFieldElement = componentPart.GetFieldElements().FirstOrDefault <FieldElement>(item => item.PropertyId == ReferencePropertyId.Periodical); if (periodicalFieldElement == null) { return(null); } if (!hasISSN && outputMode == OutputMode.ShowISSNOnlyOrSuppressJournalName) { handled = true; return(null); //suppresses the component altogether } List <LiteralElement> issnElements = new List <LiteralElement>(); #region Prefix if (!string.IsNullOrEmpty(prefix)) { var prefixLiteralElement = new LiteralElement(componentPart, prefix); prefixLiteralElement.FontStyle = prefixFontStyle; issnElements.Add(prefixLiteralElement); } #endregion Prefix #region Opening Bracket string openingBracket = string.Empty; switch (useBrackets) { case BracketType.AngleBrackets: openingBracket = "<"; break; case BracketType.Brackets: openingBracket = "["; break; case BracketType.CurlyBraces: openingBracket = "{"; break; case BracketType.Parentheses: openingBracket = "("; break; case BracketType.Slashes: openingBracket = "/"; break; default: break; } if (hasISSN && !string.IsNullOrEmpty(openingBracket)) { var openingBracketLiteralElement = new LiteralElement(componentPart, openingBracket); openingBracketLiteralElement.FontStyle = bracketsFontStyle; issnElements.Add(openingBracketLiteralElement); } #endregion Opening Bracket #region ISSN if (hasISSN) { var issnLiteralElement = new LiteralElement(componentPart, issnString); issnLiteralElement.FontStyle = issnFontStyle; issnElements.Add(issnLiteralElement); } #endregion ISSN #region Closing Bracket string closingBracket = string.Empty; switch (useBrackets) { case BracketType.AngleBrackets: closingBracket = ">"; break; case BracketType.Brackets: closingBracket = "]"; break; case BracketType.CurlyBraces: closingBracket = "}"; break; case BracketType.Parentheses: closingBracket = ")"; break; case BracketType.Slashes: closingBracket = "/"; break; default: break; } if (hasISSN && !string.IsNullOrEmpty(closingBracket)) { var closingBracketLiteralElement = new LiteralElement(componentPart, closingBracket); closingBracketLiteralElement.FontStyle = bracketsFontStyle; issnElements.Add(closingBracketLiteralElement); } #endregion Closing Bracket if (hasISSN) { int index = componentPart.Elements.IndexOf(periodicalFieldElement); if (outputMode == OutputMode.AppendISSNToJournalName) { if (index == -1) { index = componentPart.Elements.Count - 1; //default: add at the end } componentPart.Elements.InsertElements(index + 1, issnElements); } else { if (index != -1) { componentPart.Elements.ReplaceItem(index, issnElements); //always show LiteralElements var literalElements = componentPart.Elements.OfType <LiteralElement>(); foreach (LiteralElement literalElement in literalElements) { literalElement.ApplyCondition = ElementApplyCondition.Always; } } } } handled = false; return(null); }
public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { //return handled = true if this macro generates the output (as an IEnumerable<ITextUnit>); the standard output will be suppressed //return handled = false if you want Citavi to produce the standard output; handled = false; if (componentPart == null) { return(null); } if (componentPart.Elements == null) { return(null); } if (citation == null) { return(null); } if (citation.Reference == null) { return(null); } PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault(); if (pageRangeFieldElement == null) { return(null); } PageRange pageRangeResolved = PageRange.Empty; if (pageRangeFieldElement is QuotationPageRangeFieldElement) { PlaceholderCitation placeholderCitation = citation as PlaceholderCitation; if (placeholderCitation == null) { return(null); } if (placeholderCitation.Entry == null) { return(null); } pageRangeResolved = placeholderCitation.Entry.PageRange; } else { pageRangeResolved = citation.Reference.PageRange; } if (pageRangeResolved == null) { return(null); } if (pageRangeResolved == PageRange.Empty) { return(null); } if (pageRangeResolved.NumeralSystem != NumeralSystem.Omit) { return(null); } LiteralElement prefix = null; LiteralElement suffix = null; switch (pageRangeResolved.NumberingType) { case NumberingType.Page: prefix = pageRangeFieldElement.PageMultiPrefix; suffix = pageRangeFieldElement.PageMultiSuffix; break; case NumberingType.Column: prefix = pageRangeFieldElement.ColumnMultiPrefix; suffix = pageRangeFieldElement.ColumnMultiSuffix; break; case NumberingType.Paragraph: prefix = pageRangeFieldElement.ParagraphMultiPrefix; suffix = pageRangeFieldElement.ParagraphMultiSuffix; break; case NumberingType.Margin: prefix = pageRangeFieldElement.MarginMultiPrefix; suffix = pageRangeFieldElement.MarginMultiSuffix; break; case NumberingType.Other: prefix = pageRangeFieldElement.OtherMultiPrefix; suffix = pageRangeFieldElement.OtherMultiSuffix; break; } bool hasPrefix = prefix != null && !string.IsNullOrEmpty(prefix.Text); bool hasSuffix = suffix != null && !string.IsNullOrEmpty(suffix.Text); TextUnitCollection pageRangeTextUnits = pageRangeFieldElement.GetTextUnits(citation, template); if (pageRangeTextUnits == null || !pageRangeTextUnits.Any()) { return(null); } foreach (ITextUnit unit in pageRangeTextUnits) { unit.Text = unit.Text.Replace(System.StringUtility.Divis, System.StringUtility.EnDash); } TextUnitCollection output = new TextUnitCollection(); if (hasPrefix && pageRangeTextUnits.First().Text != prefix.Text) { TextUnitCollection prefixTextUnits = prefix.GetTextUnits(citation, template); if (prefixTextUnits != null && prefixTextUnits.Any()) { output.AddRange(prefixTextUnits); } } output.AddRange(pageRangeTextUnits); if (hasSuffix && pageRangeTextUnits.Last().Text != suffix.Text) { TextUnitCollection suffixTextUnits = suffix.GetTextUnits(citation, template); if (suffixTextUnits != null && suffixTextUnits.Any()) { output.AddRange(suffixTextUnits); } } componentPart.Elements.ReplaceItem(pageRangeFieldElement, TextUnitCollectionUtility.TextUnitsToLiteralElements(output, componentPart)); handled = false; //all literal elements should always be output: foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>()) { literalElement.ApplyCondition = ElementApplyCondition.Always; } return(null); }
// Methods overriden by inherited classes. protected abstract void ProcessElement(LiteralElement element);
protected override void ProcessElement(LiteralElement element) { String text = element.Text != null ? element.Text : String.Empty; String href = null; if(element.Type == LiteralElementType.Anchor) { href = element.GetAttribute("href"); } _parent.AddElement(text, href, ((element.Format & LiteralFormat.Bold) == LiteralFormat.Bold), ((element.Format & LiteralFormat.Italic) == LiteralFormat.Italic), element.BreakAfter); _hasElements = true; }
private void Flush() { if (_currentTag != null) { // In the middle of a tag. There may be multiple inner text elements inside // a tag, e.g. // <a ...>some text <%# a databinding %> some more text</a> // and we're being flushed just at the start of the databinding. if (!_currentTag.IsEmptyText) { ProcessTagInnerText(_currentTag.Text); } _currentTag.Text = String.Empty; return; } if (_lastQueuedElement == null) { return; } // Ignore orphaned whitespace. if (!_lastQueuedElement.ForceBreakTag && _lastQueuedElement.IsEmptyText) { if (!ElementsProcessed) { return; } if (_lastQueuedElement.Text.Length == 0 || _lastQueuedElement.Text[0] != ' ') { return; } _lastQueuedElement.Text = " "; } _lastQueuedElement.BreakAfter = _beginNewParagraph; ProcessElement(_lastQueuedElement); _lastQueuedElement = null; }
// Methods overriden by inherited classes. protected abstract void ProcessElement(LiteralElement element);
protected virtual bool IgnoreWhiteSpaceElement(LiteralElement element) { return(true); }
protected virtual bool IgnoreWhiteSpaceElement(LiteralElement element) { return true; }