Exemple #1
0
	/**
	 * 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);
	}
Exemple #2
0
    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;
    }
Exemple #3
0
	/**
	* 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);
	}
Exemple #4
0
	/**
	 * Saves the given string to the records. Doesn't
	 *  touch the stylings.
	 */
	private void storeText(String s) {
		// Remove a single trailing \r, as there is an implicit one at the
		//  end of every record
		if(s\.EndsWith("\r")) {
			s = s.Substring(0, s.Length-1);
		}

		// Store in the appropriate record
		if(_isUnicode) {
			// The atom can safely convert to unicode
			_charAtom.SetText(s);
		} else {
			// Will it fit in a 8 bit atom?
			bool HasMultibyte = StringUtil.HasMultibyte(s);
			if(! hasMultibyte) {
				// Fine to go into 8 bit atom
				byte[] text = new byte[s.Length];
				StringUtil.PutCompressedUnicode(s,text,0);
				_byteAtom.SetText(text);
			} else {
				// Need to swap a TextBytesAtom for a TextCharsAtom

				// Build the new TextCharsAtom
				_charAtom = new TextCharsAtom();
				_charAtom.SetText(s);

				// Use the TextHeaderAtom to do the swap on the parent
				RecordContainer parent = _headerAtom.GetParentRecord();
				Record[] cr = parent.GetChildRecords();
				for(int i=0; i<cr.Length; i++) {
					// Look for TextBytesAtom
					if(cr[i].Equals(_byteAtom)) {
						// Found it, so Replace, then all done
						cr[i] = _charAtom;
						break;
					}
				}

				// Flag the change
				_byteAtom = null;
				_isUnicode = true;
			}
		}
        /**
         * If TextSpecInfoAtom is present, we must update the text size in it,
         * otherwise the ppt will be corrupted
         */
        if(_records != null) for (int i = 0; i < _records.Length; i++) {
            if(_records[i] is TextSpecInfoAtom){
                TextSpecInfoAtom specAtom = (TextSpecInfoAtom)_records[i];
                if((s.Length + 1) != specAtom.GetCharactersCovered()){
                    specAtom.reset(s.Length + 1);
                }
            }
        }
	}