4.1、获取文本信息
文本的样式信息,应该从P对象的Content集合,过滤出R对象,获取R对象的RPr属性。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("D:/xxx.docx")); List<Object> content = wordMLPackage.getMainDocumentPart().getContent();
StringBuilder str = new StringBuilder(); for (Object o : content) { str.append(TextUtils.getText(o)); }
for (Object o : content) { if (o instanceof P){ P p = (P) o; List<Object> pContent = p.getContent(); for (Object object : pContent) { if (object instanceof R){ R r = (R) object; RPr rPr = r.getRPr(); } } } }
|
4.2、文本样式信息
Rpr之大,一图放不下。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| BooleanDefaultTrue b = rPr.getB();
BooleanDefaultTrue bCs = rPr.getBCs();
BooleanDefaultTrue i = rPr.getI();
BooleanDefaultTrue iCs = rPr.getICs();
BooleanDefaultTrue caps = rPr.getCaps();
BooleanDefaultTrue smallCaps = rPr.getSmallCaps();
BooleanDefaultTrue strike = rPr.getStrike();
BooleanDefaultTrue dstrike = rPr.getDstrike();
BooleanDefaultTrue outline = rPr.getOutline();
BooleanDefaultTrue shadow = rPr.getShadow();
BooleanDefaultTrue emboss = rPr.getEmboss();
BooleanDefaultTrue imprint = rPr.getImprint();
BooleanDefaultTrue noProof = rPr.getNoProof();
BooleanDefaultTrue snapToGrid = rPr.getSnapToGrid();
BooleanDefaultTrue vanish = rPr.getVanish();
BooleanDefaultTrue webHidden = rPr.getWebHidden();
BooleanDefaultTrue rtl = rPr.getRtl();
BooleanDefaultTrue cs = rPr.getCs();
BooleanDefaultTrue specVanish = rPr.getSpecVanish();
BooleanDefaultTrue oMath = rPr.getOMath();
|
引用的字符样式
1 2 3 4
| RStyle rStyle = rPr.getRStyle();
String val = rStyle.getVal();
|
引用字符样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| RFonts rFonts = rPr.getRFonts();
STHint hint = rFonts.getHint();
String ascii = rFonts.getAscii();
String hAnsi = rFonts.getHAnsi();
String eastAsia = rFonts.getEastAsia();
String cs = rFonts.getCs();
STTheme asciiTheme = rFonts.getAsciiTheme();
STTheme hAnsiTheme = rFonts.getHAnsiTheme();
STTheme eastAsiaTheme = rFonts.getEastAsiaTheme();
STTheme cstheme = rFonts.getCstheme();
|
颜色
1 2 3 4 5 6 7 8 9 10
| Color color = rPr.getColor();
STThemeColor themeColor = color.getThemeColor();
String themeShade = color.getThemeShade();
String themeTint = color.getThemeTint();
String val1 = color.getVal();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| CTSignedTwipsMeasure spacing = rPr.getSpacing();
BigInteger val = spacing.getVal();
CTTextScale w = rPr.getW();
Integer val = w.getVal();
HpsMeasure kern = rPr.getKern();
BigInteger val = kern.getVal();
CTSignedHpsMeasure position = rPr.getPosition();
BigInteger val = position.getVal();
HpsMeasure sz = rPr.getSz();
BigInteger val = sz.getVal();
HpsMeasure szCs = rPr.getSzCs();
BigInteger val = szCs.getVal();
Highlight highlight = rPr.getHighlight();
String val = highlight.getVal();
String hexVal = highlight.getHexVal();
|
下划线
1 2 3 4 5 6 7 8 9 10 11 12
| U u = rPr.getU();
UnderlineEnumeration val = u.getVal();
STThemeColor themeColor = u.getThemeColor();
String themeShade = u.getThemeShade();
String themeTint = u.getThemeTint();
String color = u.getColor();
|
文本影响
1 2 3 4
| CTTextEffect effect = rPr.getEffect();
STTextEffect val = effect.getVal();
|
文本边框
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| CTBorder bdr = rPr.getBdr();
STBorder val = bdr.getVal();
String color = bdr.getColor();
STThemeColor themeColor = bdr.getThemeColor();
String themeTint = bdr.getThemeTint();
String themeShade = bdr.getThemeShade();
BigInteger sz = bdr.getSz();
|
段落底纹
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| CTShd shd = rPr.getShd();
STShd val = shd.getVal();
String color = shd.getColor();
STThemeColor themeColor = shd.getThemeColor();
String themeTint = shd.getThemeTint();
String themeShade = shd.getThemeShade();
String fill = shd.getFill();
STThemeColor themeFill = shd.getThemeFill();
String themeFillTint = shd.getThemeFillTint();
String themeFillShade = shd.getThemeFillShade();
|
手动运行宽度
1 2 3 4 5 6
| CTFitText fitText = rPr.getFitText();
BigInteger val = fitText.getVal();
BigInteger id = fitText.getId();
|
下标/上标文本
1 2 3 4
| CTVerticalAlignRun vertAlign = rPr.getVertAlign();
STVerticalAlignRun val = vertAlign.getVal();
|
强调标记
1 2 3 4
| CTEm em = rPr.getEm();
STEm val = em.getVal();
|
用于运行内容的语言
1 2 3 4 5 6 7 8
| CTLanguage lang = rPr.getLang();
String val = lang.getVal();
String eastAsia = lang.getEastAsia();
String bidi = lang.getBidi();
|
应用于运行内容的任何东亚版式设置
1 2 3 4 5 6
| CTEastAsianLayout eastAsianLayout = rPr.getEastAsianLayout();
BigInteger id = eastAsianLayout.getId();
STCombineBrackets combineBrackets = eastAsianLayout.getCombineBrackets();
|
辉光
1 2 3 4 5 6 7 8
| CTGlow glow = rPr.getGlow();
Long rad = glow.getRad();
CTSRgbColor srgbClr = glow.getSrgbClr();
CTSchemeColor schemeClr = glow.getSchemeClr();
|
阴影
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| CTShadow shadow14 = rPr.getShadow14();
CTSRgbColor srgbClr = shadow14.getSrgbClr();
CTSchemeColor schemeClr = shadow14.getSchemeClr();
Long blurRad = shadow14.getBlurRad();
Long dist = shadow14.getDist();
Integer dir = shadow14.getDir();
Integer sx = shadow14.getSx();
Integer sy = shadow14.getSy();
Integer kx = shadow14.getKx();
Integer ky = shadow14.getKy();
STRectAlignment algn = shadow14.getAlgn();
|
反射
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| CTReflection reflection = rPr.getReflection();
Long blurRad = reflection.getBlurRad();
Integer stA = reflection.getStA();
Integer stPos = reflection.getStPos();
Integer endA = reflection.getEndA();
Integer endPos = reflection.getEndPos();
Long dist = reflection.getDist();
Integer dir = reflection.getDir();
Integer fadeDir = reflection.getFadeDir();
Integer sx = reflection.getSx();
Integer sy = reflection.getSy();
Integer kx = reflection.getKx();
Integer ky = reflection.getKy();
STRectAlignment algn = reflection.getAlgn();
|
应用于文本的大纲样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| 应用于文本的大纲样式 CTTextOutlineEffect textOutline = rPr.getTextOutline();
CTEmpty noFill = textOutline.getNoFill();
CTSolidColorFillProperties solidFill = textOutline.getSolidFill();
CTGradientFillProperties gradFill = textOutline.getGradFill();
CTPresetLineDashProperties prstDash = textOutline.getPrstDash();
CTEmpty round = textOutline.getRound();
CTEmpty bevel = textOutline.getBevel();
Integer w = textOutline.getW();
STLineCap cap = textOutline.getCap();
STCompoundLine cmpd = textOutline.getCmpd();
STPenAlignment algn = textOutline.getAlgn();
|
文本填充
1 2 3 4 5 6 7 8
| CTFillTextEffect textFill = rPr.getTextFill();
CTGradientFillProperties gradFill = textFill.getGradFill();
CTEmpty noFill = textFill.getNoFill();
CTSolidColorFillProperties solidFill = textFill.getSolidFill();
|
场景3d
1 2 3 4 5 6
| CTScene3D scene3D = rPr.getScene3D();
CTCamera camera = scene3D.getCamera();
CTLightRig lightRig = scene3D.getLightRig();
|
3D属性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| CTProps3D props3D = rPr.getProps3D();
CTBevel bevelT = props3D.getBevelT();
CTBevel bevelB = props3D.getBevelB();
CTColor extrusionClr = props3D.getExtrusionClr();
CTColor contourClr = props3D.getContourClr();
Long extrusionH = props3D.getExtrusionH();
Long contourW = props3D.getContourW();
STPresetMaterialType prstMaterial = props3D.getPrstMaterial();
|
连字
1 2 3 4
| CTLigatures ligatures = rPr.getLigatures();
STLigatures val = ligatures.getVal();
|
编号格式
1 2 3 4
| CTNumForm numForm = rPr.getNumForm();
STNumForm val = numForm.getVal();
|
编号间距
1 2 3 4
| CTNumSpacing numSpacing = rPr.getNumSpacing();
STNumSpacing val = numSpacing.getVal();
|
样式集
1 2 3 4
| CTStylisticSets stylisticSets = rPr.getStylisticSets();
List<CTStyleSet> styleSet = stylisticSets.getStyleSet();
|
上下文替代方案
1 2 3 4
| CTOnOff cntxtAlts = rPr.getCntxtAlts();
String val = cntxtAlts.getVal();
|
(运行属性) 的修订信息
1 2 3 4 5 6 7 8 9 10
| CTRPrChange rPrChange = rPr.getRPrChange();
BigInteger id = rPrChange.getId();
String author = rPrChange.getAuthor();
XMLGregorianCalendar date = rPrChange.getDate();
CTRPrChange.RPr rPr = rPrChange.getRPr();
|