public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled) { handled = false; if (citation == null) { return(null); } Reference reference = citation.Reference; if (reference == null) { return(null); } if (componentPart == null) { return(null); } if (componentPart.Elements == null || !componentPart.Elements.Any() || componentPart.Elements.Count != 1) { return(null); } TextFieldElement firstTextFieldElement = componentPart.Elements.OfType <TextFieldElement>().FirstOrDefault() as TextFieldElement; if (firstTextFieldElement == null) { return(null); } ComponentPartScope scope = componentPart.Scope; Reference referenceInScope = null; if (scope == ComponentPartScope.Reference) { referenceInScope = reference; } else { referenceInScope = reference.ParentReference; } if (referenceInScope == null) { return(null); } ReferencePropertyId propertyTagged = ReferencePropertyId.None; switch (firstTextFieldElement.PropertyId) { case ReferencePropertyId.Title: { propertyTagged = ReferencePropertyId.TitleTagged; } break; case ReferencePropertyId.Subtitle: { propertyTagged = ReferencePropertyId.SubtitleTagged; } break; case ReferencePropertyId.TitleSupplement: { propertyTagged = ReferencePropertyId.TitleSupplementTagged; } break; } if (propertyTagged == ReferencePropertyId.None) { return(null); } string stringTagged = referenceInScope.GetValue(propertyTagged) as string; if (string.IsNullOrEmpty(stringTagged)) { return(null); } if (!HasTags(stringTagged)) { return(null); } bool italicFound = false; TextUnitCollection textUnitCollection = TextUnitCollectionUtility.TaggedTextToTextUnits(firstTextFieldElement, stringTagged); foreach (ITextUnit textUnit in textUnitCollection) { //Flip bits where required if (firstTextFieldElement.FontStyle.HasFlag(FontStyle.Italic)) { textUnit.TemporaryFontStyle ^= FontStyle.Italic; } if (firstTextFieldElement.FontStyle.HasFlag(FontStyle.Bold)) { textUnit.TemporaryFontStyle ^= FontStyle.Bold; } } handled = true; return(textUnitCollection); }
private static List <Person> GetPersonsDisplayed(PersonFieldElement element, Reference reference) { if (element == null) { return(null); } if (element.ComponentPart == null) { return(null); } List <Person> persons = null; ComponentPartScope scope = element.ComponentPart.Scope; Reference referenceInScope = null; if (scope == ComponentPartScope.Reference) { referenceInScope = reference; } else { referenceInScope = reference.ParentReference; } if (referenceInScope == null) { return(null); } switch (element.PropertyId) { #region Authors case ReferencePropertyId.Authors: { if (referenceInScope.Authors != null) { persons = new List <Person>(referenceInScope.Authors); } } break; #endregion Authors #region Editors case ReferencePropertyId.Editors: { if (referenceInScope.Editors != null) { persons = new List <Person>(referenceInScope.Editors); } } break; #endregion Editors #region AuthorsEditorsOrganizations case ReferencePropertyId.AuthorsOrEditorsOrOrganizations: { if (referenceInScope.AuthorsOrEditorsOrOrganizations != null) { persons = new List <Person>(referenceInScope.AuthorsOrEditorsOrOrganizations); } } break; #endregion AuthorsEditorsOrganizations #region Collaborators case ReferencePropertyId.Collaborators: { if (referenceInScope.Collaborators != null) { persons = new List <Person>(referenceInScope.Collaborators); } } break; #endregion Collaborators #region Organizations case ReferencePropertyId.Organizations: { if (referenceInScope.Organizations != null) { persons = new List <Person>(referenceInScope.Organizations); } } break; #endregion Organizations #region OthersInvolved case ReferencePropertyId.OthersInvolved: { if (referenceInScope.OthersInvolved != null) { persons = new List <Person>(referenceInScope.OthersInvolved); } } break; #endregion OthersInvolved } return(persons); }