2017-05-20 2 views
0

Disons qu'un style particulier est appliqué à un paragraphe. Je veux savoir quelle est la famille de police du style. J'ai essayé d'ouvrir le fichier styles.xml à l'intérieur du docx. Je ne trouve pas l'attribut w:ascii pour un grand nombre de styles. Par exemple, considérons le style Heading1. Le OOXML correspondant à ce style estComment savoir quelle famille de polices est utilisée par un paragraphe dans OOXML?

<w:style w:type="paragraph" w:styleId="Heading1"> 
    <w:name w:val="heading 1"/> 
    <w:basedOn w:val="Normal"/> 
    <w:next w:val="Normal"/> 
    <w:link w:val="Heading1Char"/> 
    <w:uiPriority w:val="9"/> 
    <w:qFormat/> 
    <w:rsid w:val="00FB3E81"/> 
    <w:pPr> 
     <w:keepNext/> 
     <w:keepLines/> 
     <w:spacing w:before="240"/> 
     <w:outlineLvl w:val="0"/> 
    </w:pPr> 
    <w:rPr> 
     <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/> 
     <w:color w:val="2E74B5" w:themeColor="accent1" w:themeShade="BF"/> 
     <w:sz w:val="32"/> 
     <w:szCs w:val="32"/> 
    </w:rPr> 
</w:style> 

Dans la balise w:rFonts il n'y a pas w:ascii attribut pour extraire la famille de polices. Où sont stockés les détails de la famille de polices pour ce style et comment l'extraire pour l'utiliser dans une application Java? J'utilise Apache POI pour analyser le document.

+0

C'est ce que je fais en ce moment. Montez dans la hiérarchie jusqu'à ce qu'il n'y ait plus de 'w: basedOn' et si je n'ai toujours pas trouvé la police, je définis une police par défaut manuellement. –

Répondre

1

Examine w:rFonts. Dans l'exemple que vous citez w:asciiTheme="majorHAnsi" vous dit qu'il utilise la police qui a été défini dans le thème comme majorHAnsi, qui est la police du thème utilisé pour les titres. Donc, vous devez déterminer la famille de polices spécifié dans le fichier thème, qui est susceptible d'être theme1.xml

Edit: Dans le fichier thème que vous trouverez la fontScheme qui définit deux polices, majorFont et minorFont. Ceux-ci correspondent à majorHAnsi et minorHAnsi Si le thème utilisé est l'un des thèmes standards qui viennent avec Office il peut y avoir de nombreuses entrées dépendant du script de la langue utilisée.

 <a:fontScheme name="Office Theme"> 
     <a:majorFont> 
      <a:latin typeface="Calibri Light" panose="020F0302020204030204" /> 
      <a:ea typeface="" /> 
      <a:cs typeface="" /> 
      <a:font script="Jpan" typeface="游ゴシック Light" /> 
      <a:font script="Hang" typeface="맑은 고딕" /> 
      <a:font script="Hans" typeface="等线 Light" /> 
      <a:font script="Hant" typeface="新細明體" /> 
      <a:font script="Arab" typeface="Times New Roman" /> 
      <a:font script="Hebr" typeface="Times New Roman" /> 
      <a:font script="Thai" typeface="Angsana New" /> 
      <a:font script="Ethi" typeface="Nyala" /> 
      <a:font script="Beng" typeface="Vrinda" /> 
      <a:font script="Gujr" typeface="Shruti" /> 
      <a:font script="Khmr" typeface="MoolBoran" /> 
      <a:font script="Knda" typeface="Tunga" /> 
      <a:font script="Guru" typeface="Raavi" /> 
      <a:font script="Cans" typeface="Euphemia" /> 
      <a:font script="Cher" typeface="Plantagenet Cherokee" /> 
      <a:font script="Yiii" typeface="Microsoft Yi Baiti" /> 
      <a:font script="Tibt" typeface="Microsoft Himalaya" /> 
      <a:font script="Thaa" typeface="MV Boli" /> 
      <a:font script="Deva" typeface="Mangal" /> 
      <a:font script="Telu" typeface="Gautami" /> 
      <a:font script="Taml" typeface="Latha" /> 
      <a:font script="Syrc" typeface="Estrangelo Edessa" /> 
      <a:font script="Orya" typeface="Kalinga" /> 
      <a:font script="Mlym" typeface="Kartika" /> 
      <a:font script="Laoo" typeface="DokChampa" /> 
      <a:font script="Sinh" typeface="Iskoola Pota" /> 
      <a:font script="Mong" typeface="Mongolian Baiti" /> 
      <a:font script="Viet" typeface="Times New Roman" /> 
      <a:font script="Uigh" typeface="Microsoft Uighur" /> 
      <a:font script="Geor" typeface="Sylfaen" /> 
     </a:majorFont> 
     <a:minorFont> 
      <a:latin typeface="Calibri" panose="020F0502020204030204" /> 
      <a:ea typeface="" /> 
      <a:cs typeface="" /> 
      <a:font script="Jpan" typeface="游ゴシック" /> 
      <a:font script="Hang" typeface="맑은 고딕" /> 
      <a:font script="Hans" typeface="等线" /> 
      <a:font script="Hant" typeface="新細明體" /> 
      <a:font script="Arab" typeface="Arial" /> 
      <a:font script="Hebr" typeface="Arial" /> 
      <a:font script="Thai" typeface="Cordia New" /> 
      <a:font script="Ethi" typeface="Nyala" /> 
      <a:font script="Beng" typeface="Vrinda" /> 
      <a:font script="Gujr" typeface="Shruti" /> 
      <a:font script="Khmr" typeface="DaunPenh" /> 
      <a:font script="Knda" typeface="Tunga" /> 
      <a:font script="Guru" typeface="Raavi" /> 
      <a:font script="Cans" typeface="Euphemia" /> 
      <a:font script="Cher" typeface="Plantagenet Cherokee" /> 
      <a:font script="Yiii" typeface="Microsoft Yi Baiti" /> 
      <a:font script="Tibt" typeface="Microsoft Himalaya" /> 
      <a:font script="Thaa" typeface="MV Boli" /> 
      <a:font script="Deva" typeface="Mangal" /> 
      <a:font script="Telu" typeface="Gautami" /> 
      <a:font script="Taml" typeface="Latha" /> 
      <a:font script="Syrc" typeface="Estrangelo Edessa" /> 
      <a:font script="Orya" typeface="Kalinga" /> 
      <a:font script="Mlym" typeface="Kartika" /> 
      <a:font script="Laoo" typeface="DokChampa" /> 
      <a:font script="Sinh" typeface="Iskoola Pota" /> 
      <a:font script="Mong" typeface="Mongolian Baiti" /> 
      <a:font script="Viet" typeface="Arial" /> 
      <a:font script="Uigh" typeface="Microsoft Uighur" /> 
      <a:font script="Geor" typeface="Sylfaen" /> 
     </a:minorFont> 
    </a:fontScheme> 
+0

J'ai essayé de regarder dans le fichier theme1.xml. Je ne peux pas trouver la police. Il n'y a pas de propriété majeureHAnsi en elle. –

+0

Réponse mise à jour. –

+0

Cela fonctionne pour les thèmes qui viennent avec le bureau. Mais il n'y a aucun moyen d'obtenir des thèmes de tiers. –