Java 从docx4j中的docx获取文本框

Java 从docx4j中的docx获取文本框,java,ms-word,docx4j,Java,Ms Word,Docx4j,Word允许用户创建文本框并用颜色填充。我试图从中找出两个值:1字体的颜色2文本框填充的颜色 我已经在docx4j的webapp上尝试了这两个示例,下面是区别 文本框颜色=黑色。文本颜色=黑色 <w:pict> <v:shapetype o:spt="202.0" path="m0,0l0,21600,21600,21600,21600,0xe" coordsize="21600,21600" id="_x0000_t202"> <v:str

Word允许用户创建文本框并用颜色填充。我试图从中找出两个值:1字体的颜色2文本框填充的颜色

我已经在docx4j的webapp上尝试了这两个示例,下面是区别

文本框颜色=黑色。文本颜色=黑色

<w:pict>
    <v:shapetype o:spt="202.0" path="m0,0l0,21600,21600,21600,21600,0xe" coordsize="21600,21600" id="_x0000_t202">
        <v:stroke joinstyle="miter"/>
        <v:path gradientshapeok="t" o:connecttype="rect"/>
    </v:shapetype>

    <v:shape o:gfxdata="<bunch of text here>" type="#_x0000_t202" style="position:absolute;margin-left:18pt;margin-top:15.75pt;width:172.65pt;height:1in;z-index:251659264;visibility:visible;mso-wrap-style:none;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;v-text-anchor:top" id="Text Box 2" o:spid="_x0000_s1026" stroked="f" fillcolor="black [3213]">
        <v:textbox>
            <w:txbxContent>
                <w:p w14:paraId="77D94695" w14:textId="70E108CF">
                    <w:r>
                        <w:t xml:space="preserve">This is a simple test by </w:t>
                    </w:r>    

                    <w:proofErr w:type="spellStart"/>
                    <w:r>
                        <w:t>foobar</w:t>
                    </w:r>

                    <w:proofErr w:type="spellEnd"/>
                </w:p>
            </w:txbxContent>
        </v:textbox>

        <w10:wrap type="square"/>
    </v:shape>
</w:pict>

如果o instanceof org.docx4j.vml.CTShape位显示,则其他选项会显示什么?如果没有,您确定日志记录配置正确吗?
<w:pict>
    <v:shapetype o:spt="202.0" path="m0,0l0,21600,21600,21600,21600,0xe" coordsize="21600,21600" id="_x0000_t202">
        <v:stroke joinstyle="miter"/>
        <v:path gradientshapeok="t" o:connecttype="rect"/>
    </v:shapetype>
    <v:shape o:gfxdata="" type="#_x0000_t202" style="position:absolute;margin-left:18pt;margin-top:15.75pt;width:172.65pt;height:1in;z-index:251659264;visibility:visible;mso-wrap-style:none;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;v-text-anchor:top" id="Text Box 2" o:spid="_x0000_s1026" stroked="f" fillcolor="black [3213]">
        <v:textbox>
            <w:txbxContent>
                <w:p w14:paraId="77D94695" w14:textId="70E108CF">
                    <w:pPr>
                        <w:rPr>
                            <w:color w:val="FFFFFF" w:themeColor="background1"/>
                        </w:rPr>
                    </w:pPr>
                    <w:r>
                        <w:rPr>
                            <w:color w:val="FFFFFF" w:themeColor="background1"/>
                        </w:rPr>
                        <w:t xml:space="preserve">This is a simple test by </w:t>
                    </w:r>
                    <w:proofErr w:type="spellStart"/>
                    <w:r>
                        <w:rPr>
                            <w:color w:val="FFFFFF" w:themeColor="background1"/>
                        </w:rPr>
                        <w:t>b</w:t>
                    </w:r>
                    <w:bookmarkStart w:name="_GoBack" w:id="1"/>
                    <w:bookmarkEnd w:id="1"/>
                    <w:r>
                        <w:rPr>
                            <w:color w:val="FFFFFF" w:themeColor="background1"/>
                        </w:rPr>
                        <w:t>foobar</w:t>
                    </w:r>
                    <w:proofErr w:type="spellEnd"/>
                </w:p>
            </w:txbxContent>
        </v:textbox>
        <w10:wrap type="square"/>
    </v:shape>
</w:pict>
class DocumentTraverser  extends TraversalUtil.CallbackImpl {
    @Override
    public List<Object> apply(Object o) {
        println " class name"
        println o.getClass()
        if (o instanceof org.docx4j.wml.Text) {
            text.append(((org.docx4j.wml.Text) o).getValue()); //append to text
        }
        else if (o instanceof org.docx4j.vml.CTShape)   {
            org.docx4j.vml.CTShape s = ((org.docx4j.vml.CTShape)o);
            log.debug(s.getFillcolor())
            //how can I get color of the text inside the text box
        }

        return null;
    }
}