/** * Internal constructor and Initializer */ private TextRun(TextHeaderAtom tha, TextBytesAtom tba, TextCharsAtom tca, StyleTextPropAtom sta) { _headerAtom = tha; _styleAtom = sta; if(tba != null) { _byteAtom = tba; _isUnicode = false; } else { _charAtom = tca; _isUnicode = true; } String RunRawText = GetText(); // Figure out the rich text Runs LinkedList pStyles = new LinkedList(); LinkedList cStyles = new LinkedList(); if(_styleAtom != null) { // Get the style atom to grok itself _styleAtom.SetParentTextSize(RunRawText.Length); pStyles = _styleAtom.GetParagraphStyles(); cStyles = _styleAtom.GetCharacterStyles(); } buildRichTextRuns(pStyles, cStyles, RunRawText); }
/** * Ensure a StyleTextPropAtom is present for this Run, * by Adding if required. Normally for internal TextRun use. */ public void ensureStyleAtomPresent() { if(_styleAtom != null) { // All there return; } // Create a new one at the right size _styleAtom = new StyleTextPropAtom(getRawText().Length + 1); // Use the TextHeader atom to Get at the parent RecordContainer RunAtomsParent = _headerAtom.GetParentRecord(); // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom Record AddAfter = _byteAtom; if(_byteAtom == null) { AddAfter = _charAtom; } RunAtomsParent.AddChildAfter(_styleAtom, AddAfter); // Feed this to our sole rich text run if(_rtRuns.Length != 1) { throw new InvalidOperationException("Needed to add StyleTextPropAtom when had many rich text Runs"); } // These are the only styles for now _rtRuns[0].supplyTextProps( (TextPropCollection)_styleAtom.GetParagraphStyles().Get(0), (TextPropCollection)_styleAtom.GetCharacterStyles().Get(0), false, false ); }