public IXLFormattedText <T> Substring(Int32 index, Int32 length) { if (index + 1 > Length || (Length - index + 1) < length || length <= 0) { throw new IndexOutOfRangeException("Index and length must refer to a location within the string."); } List <IXLRichString> newRichTexts = new List <IXLRichString>(); var retVal = new XLFormattedText <T>(_defaultFont); Int32 lastPosition = 0; foreach (var rt in _richTexts) { if (lastPosition >= index + 1 + length) // We already have what we need { newRichTexts.Add(rt); } else if (lastPosition + rt.Text.Length >= index + 1) // Eureka! { Int32 startIndex = index - lastPosition; if (startIndex > 0) { newRichTexts.Add(new XLRichString(rt.Text.Substring(0, startIndex), rt, this)); } else if (startIndex < 0) { startIndex = 0; } Int32 leftToTake = length - retVal.Length; if (leftToTake > rt.Text.Length - startIndex) { leftToTake = rt.Text.Length - startIndex; } XLRichString newRt = new XLRichString(rt.Text.Substring(startIndex, leftToTake), rt, this); newRichTexts.Add(newRt); retVal.AddText(newRt); if (startIndex + leftToTake < rt.Text.Length) { newRichTexts.Add(new XLRichString(rt.Text.Substring(startIndex + leftToTake), rt, this)); } } else // We haven't reached the desired position yet { newRichTexts.Add(rt); } lastPosition += rt.Text.Length; } _richTexts = newRichTexts; return(retVal); }
public XLRichText(XLFormattedText <IXLRichText> defaultRichText, IXLFontBase defaultFont) : base(defaultRichText, defaultFont) { Container = this; }
public XLComment(XLCell cell, XLFormattedText <IXLComment> defaultComment, IXLFontBase defaultFont) : base(defaultComment, defaultFont) { Initialize(cell); }
public XLComment(XLCell cell, XLFormattedText <IXLComment> defaultComment, IXLFontBase defaultFont, IXLDrawingStyle style) : base(defaultComment, defaultFont) { Initialize(cell, style); }