/** * Writes out to disk the header, and then all the properties */ public void WriteOut(Stream o) { // First goes the number of characters we affect StyleTextPropAtom.WriteLittleEndian(charactersCovered, o); // Then we have the reserved field if required if (reservedField > -1) { StyleTextPropAtom.WriteLittleEndian(reservedField, o); } // Then the mask field int mask = maskSpecial; for (int i = 0; i < textPropList.Count; i++) { TextProp textProp = (TextProp)textPropList[i]; //sometimes header indicates that the bitmask is present but its value is 0 if (textProp is BitMaskTextProp) { if (mask == 0) { mask |= textProp.GetWriteMask(); } } else { mask |= textProp.GetWriteMask(); } } StyleTextPropAtom.WriteLittleEndian(mask, o); // Then the contents of all the properties for (int i = 0; i < textPropList.Count; i++) { TextProp textProp = textPropList[i]; int val = textProp.GetValue(); if (textProp.GetSize() == 2) { StyleTextPropAtom.WriteLittleEndian((short)val, o); } else if (textProp.GetSize() == 4) { StyleTextPropAtom.WriteLittleEndian(val, o); } } }
/** * 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); }
public TextRun CreateTextRun(){ _txtbox = GetEscherTextboxWrapper(); if(_txtbox == null) _txtbox = new EscherTextboxWrapper(); _txtrun = GetTextRun(); if(_txtrun == null){ TextHeaderAtom tha = new TextHeaderAtom(); tha.SetParentRecord(_txtbox); _txtbox.AppendChildRecord(tha); TextCharsAtom tca = new TextCharsAtom(); _txtbox.AppendChildRecord(tca); StyleTextPropAtom sta = new StyleTextPropAtom(0); _txtbox.AppendChildRecord(sta); _txtrun = new TextRun(tha,tca,sta); _txtRun._records = new Record[]{tha, tca, sta}; _txtRun.SetText(""); _escherContainer.AddChildRecord(_txtbox.GetEscherRecord()); SetDefaultTextProperties(_txtRun); } return _txtRun; }
/** * Constructs a Text Run from a Ascii text block * * @param tha the TextHeaderAtom that defines what's what * @param tba the TextBytesAtom Containing the text * @param sta the StyleTextPropAtom which defines the character stylings */ public TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) { this(tha,tba,null,sta); }
/** * Constructs a Text Run from a Unicode text block * * @param tha the TextHeaderAtom that defines what's what * @param tca the TextCharsAtom Containing the text * @param sta the StyleTextPropAtom which defines the character stylings */ public TextRun(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) { this(tha,null,tca,sta); }
/** * 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 ); }