1

Word では、テキスト ボックスを作成して、色で塗りつぶすことができます。これから 2 つの値を見つけようとしています: 1) フォントの色 2) テキスト ボックスが塗りつぶされた色

私はdocx4jのwebappで両方の例を試しましたが、以下は違いです

  1. テキスト ボックスの色 = 黒。文字色=黒

    <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>
    
  2. テキスト ボックスの色 = 黒。文字色=白

    <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>
    

質問

w:pictタグにアクセスするにv:shapeはどうすればよいですか?ドキュメントでこれら 2 つの値を見つけるための最善の方法は何でしょうか?

私が試したこと

私はこのように traversaleUtil を使用しています

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;
    }
}
4

0 に答える 0