You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/05/27 10:32:41 UTC

[Bug 55009] TextBox in shapegroup with chinese, the textrun is null

https://issues.apache.org/bugzilla/show_bug.cgi?id=55009

Linfei Zhao <zl...@126.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Linfei Zhao <zl...@126.com> ---
I have solved this problem. the class TextShape has some problem. Function
getTextRun() is as follows:

public TextRun getTextRun(){
        if (null == this._txtrun) initTextRun();
        if (null == this._txtrun && null != this._txtbox) {
            TextHeaderAtom    tha = null; 
            TextBytesAtom     tba = null;
            StyleTextPropAtom sta = null;
            Record[] childRecords = this._txtbox.getChildRecords();
            for (Record r : childRecords) {
                if (r instanceof TextHeaderAtom) {
                    tha = (TextHeaderAtom) r;
                } else if (r instanceof TextBytesAtom) {
                    tba = (TextBytesAtom) r;
                } else if (r instanceof StyleTextPropAtom) {
                    sta = (StyleTextPropAtom) r;
                }
            }
            if (null != tba) {
                this._txtrun = new TextRun(tha, tba, sta);
            }
         }
         return _txtrun;
     }
but sometimes the text is not TextBytesAtom but TextCharsAtom. And TextRun has
two construct function. in this case, we should use another construct function.
Rewrite it as:

public TextRun getTextRun() {
        // TODO Auto-generated method stub
        if (null == this._txtrun) initTextRun();
        if (null == this._txtrun && null != this._txtbox) {
            TextHeaderAtom    tha = null; 
            TextBytesAtom     tba = null;
            StyleTextPropAtom sta = null;
            TextCharsAtom    tca = null;
            Record[] childRecords = this._txtbox.getChildRecords();
            for (Record r : childRecords) {
                if (r instanceof TextHeaderAtom) {
                    tha = (TextHeaderAtom) r;
                } else if (r instanceof TextBytesAtom) {
                    tba = (TextBytesAtom) r;
                } else if (r instanceof StyleTextPropAtom) {
                    sta = (StyleTextPropAtom) r;
                }else if (r instanceof TextCharsAtom) {
                    tca = (TextCharsAtom) r;
                }
            }
            if (null != tba) {
                this._txtrun = new TextRun(tha, tba, sta);
            }else if (null != tca) {
                this._txtrun = new TextRun(tha, tca, sta);
            }
         }
         return _txtrun;
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org