gpt4 book ai didi

org.apache.poi.xwpf.usermodel.XWPFStyle类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 08:55:05 32 4
gpt4 key购买 nike

本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFStyle类的一些代码示例,展示了XWPFStyle类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFStyle类的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFStyle
类名称:XWPFStyle

XWPFStyle介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * add a style to the document
 *
 * @param style
 * @throws IOException
 */
public void addStyle(XWPFStyle style) {
  listStyle.add(style);
  ctStyles.addNewStyle();
  int pos = ctStyles.sizeOfStyleArray() - 1;
  ctStyles.setStyleArray(pos, style.getCTStyle());
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
   * Get the style with the specified name, if any.
   *
   * @param styleName The name of the style to get, e.g., "Heading 1"
   * @return {@link XWPFStyle} with the specified name, or null if not found.
   */
  public XWPFStyle getStyleWithName(String styleName) {
    XWPFStyle style = null;
    for (XWPFStyle cand : listStyle) {
      if (styleName.equals(cand.getName())) {
        style = cand;
        break;
      }
    }
    return style;
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * checks whether style with styleID exist
 *
 * @param styleID styleID of the Style in the style-Document
 * @return true if style exist, false if style not exist
 */
public boolean styleExist(String styleID) {
  for (XWPFStyle style : listStyle) {
    if (style.getStyleId().equals(styleID))
      return true;
  }
  return false;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * get the styles which are related to parameter style
 *
 * @param style
 * @return all Styles of the parameterList
 */
private List<XWPFStyle> getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList) {
  String basisStyleID = style.getBasisStyleID();
  XWPFStyle basisStyle = getStyle(basisStyleID);
  if ((basisStyle != null) && (!usedStyleList.contains(basisStyle))) {
    usedStyleList.add(basisStyle);
    getUsedStyleList(basisStyle, usedStyleList);
  }
  String linkStyleID = style.getLinkStyleID();
  XWPFStyle linkStyle = getStyle(linkStyleID);
  if ((linkStyle != null) && (!usedStyleList.contains(linkStyle))) {
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }
  String nextStyleID = style.getNextStyleID();
  XWPFStyle nextStyle = getStyle(nextStyleID);
  if ((nextStyle != null) && (!usedStyleList.contains(nextStyle))) {
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }
  return usedStyleList;
}

代码示例来源:origin: Sayi/poi-tl

@SuppressWarnings("unchecked")
private Map<String, String> mergeStyles(NiceXWPFDocument docMerge){
  Map<String, String> styleIdsMap = new HashMap<String, String>();
  XWPFStyles styles = this.getStyles();
  if (null == styles) styles = createStyles();
  XWPFStyles stylesMerge = docMerge.getStyles();
  if (null == stylesMerge) return styleIdsMap;
  try {
    Field listStyleField = XWPFStyles.class.getDeclaredField("listStyle");
    listStyleField.setAccessible(true);
    List<XWPFStyle> lists = (List<XWPFStyle>)listStyleField.get(stylesMerge);
    for (XWPFStyle xwpfStyle : lists) {
      if (styles.styleExist(xwpfStyle.getStyleId())) {
        String id = xwpfStyle.getStyleId();
        xwpfStyle.setStyleId(UUID.randomUUID().toString());
        styleIdsMap.put(id, xwpfStyle.getStyleId());
      }
      styles.addStyle(xwpfStyle);
    }
  } catch (Exception e) {
    LOG.error("merge style error", e);
  }
  return styleIdsMap;
}

代码示例来源:origin: stackoverflow.com

System.out.println("=============================================================");
XWPFStyle xStyle = xdoc.getStyles().getStyle(styleID);
if (xStyle.getType() == STStyleType.CHARACTER) {
 System.out.println(xStyle.getCTStyle());

代码示例来源:origin: stackoverflow.com

color.setVal(hexToBytes(hexColor));
rpr.setColor(color);
style.getCTStyle().setRPr(rpr);
style.setType(STStyleType.PARAGRAPH);
styles.addStyle(style);

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * get the style with the same name
 * if this style is not existing, return null
 */
public XWPFStyle getStyleWithSameName(XWPFStyle style) {
  for (XWPFStyle ownStyle : listStyle) {
    if (ownStyle.hasSameName(style)) {
      return ownStyle;
    }
  }
  return null;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Sets the ctStyles
 *
 * @param styles
 */
public void setStyles(CTStyles styles) {
  ctStyles = styles;
  // Build up all the style objects
  for (CTStyle style : ctStyles.getStyleArray()) {
    listStyle.add(new XWPFStyle(style, this));
  }
  if (ctStyles.isSetDocDefaults()) {
    CTDocDefaults docDefaults = ctStyles.getDocDefaults();
    if (docDefaults.isSetRPrDefault() && docDefaults.getRPrDefault().isSetRPr()) {
      defaultRunStyle = new XWPFDefaultRunStyle(
          docDefaults.getRPrDefault().getRPr());
    }
    if (docDefaults.isSetPPrDefault() && docDefaults.getPPrDefault().isSetPPr()) {
      defaultParaStyle = new XWPFDefaultParagraphStyle(
          docDefaults.getPPrDefault().getPPr());
    }
  }
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/** 
 * get the styles which are related to parameter style
 * @param style
 * @return all Styles of the parameterList
 */
private List<XWPFStyle> getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList){
  String basisStyleID  = style.getBasisStyleID();
  XWPFStyle basisStyle = getStyle(basisStyleID);
  if((basisStyle!=null)&&(!usedStyleList.contains(basisStyle))){
    usedStyleList.add(basisStyle);
    getUsedStyleList(basisStyle, usedStyleList);
  }        
  String linkStyleID = style.getLinkStyleID();
  XWPFStyle linkStyle = getStyle(linkStyleID);
  if((linkStyle!=null)&&(!usedStyleList.contains(linkStyle))){
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }
  
  String nextStyleID = style.getNextStyleID();
  XWPFStyle nextStyle = getStyle(nextStyleID);
  if((nextStyle!=null)&&(!usedStyleList.contains(nextStyle))){
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }        
  return usedStyleList;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * get the style with the same name
 * if this style is not existing, return null
 */
public XWPFStyle getStyleWithSameName(XWPFStyle style) {
  for (XWPFStyle ownStyle : listStyle) {
    if (ownStyle.hasSameName(style)) {
      return ownStyle;
    }
  }
  return null;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
* Read document
*/
@Override
protected void onDocumentRead() throws IOException{
 StylesDocument stylesDoc;
 try {
   InputStream is = getPackagePart().getInputStream();
   stylesDoc = StylesDocument.Factory.parse(is);
   ctStyles = stylesDoc.getStyles();
   latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
 } catch (XmlException e) {
   throw new POIXMLException("Unable to read styles", e);
 }
 
 // Build up all the style objects
 for(CTStyle style : ctStyles.getStyleList()) {
   listStyle.add(new XWPFStyle(style, this));
 }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * compares the names of the Styles
 *
 * @param compStyle
 */
public boolean hasSameName(XWPFStyle compStyle) {
  CTStyle ctCompStyle = compStyle.getCTStyle();
  String name = ctCompStyle.getName().getVal();
  return name.equals(ctStyle.getName().getVal());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * get the styles which are related to parameter style
 *
 * @param style
 * @return all Styles of the parameterList
 */
private List<XWPFStyle> getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList) {
  String basisStyleID = style.getBasisStyleID();
  XWPFStyle basisStyle = getStyle(basisStyleID);
  if ((basisStyle != null) && (!usedStyleList.contains(basisStyle))) {
    usedStyleList.add(basisStyle);
    getUsedStyleList(basisStyle, usedStyleList);
  }
  String linkStyleID = style.getLinkStyleID();
  XWPFStyle linkStyle = getStyle(linkStyleID);
  if ((linkStyle != null) && (!usedStyleList.contains(linkStyle))) {
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }
  String nextStyleID = style.getNextStyleID();
  XWPFStyle nextStyle = getStyle(nextStyleID);
  if ((nextStyle != null) && (!usedStyleList.contains(nextStyle))) {
    usedStyleList.add(linkStyle);
    getUsedStyleList(linkStyle, usedStyleList);
  }
  return usedStyleList;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
   * Get the style with the specified name, if any.
   *
   * @param styleName The name of the style to get, e.g., "Heading 1"
   * @return {@link XWPFStyle} with the specified name, or null if not found.
   */
  public XWPFStyle getStyleWithName(String styleName) {
    XWPFStyle style = null;
    for (XWPFStyle cand : listStyle) {
      if (styleName.equals(cand.getName())) {
        style = cand;
        break;
      }
    }
    return style;
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Get style by a styleID
 *
 * @param styleID styleID of the searched style
 * @return style
 */
public XWPFStyle getStyle(String styleID) {
  for (XWPFStyle style : listStyle) {
    try {
      if (style.getStyleId().equals(styleID))
        return style;
    } catch (NullPointerException e) {
      // Ignore NPE
    }
  }
  return null;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
   * get the style with the same name
   * if this style is not existing, return null
   */
  public XWPFStyle getStyleWithSameName(XWPFStyle style){
    for (XWPFStyle ownStyle : listStyle) {
      if(ownStyle.hasSameName(style)){
        return ownStyle;
      }    
    }
    return null;
    
  }
}//end class

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Sets the ctStyles
 *
 * @param styles
 */
public void setStyles(CTStyles styles) {
  ctStyles = styles;
  // Build up all the style objects
  for (CTStyle style : ctStyles.getStyleArray()) {
    listStyle.add(new XWPFStyle(style, this));
  }
  if (ctStyles.isSetDocDefaults()) {
    CTDocDefaults docDefaults = ctStyles.getDocDefaults();
    if (docDefaults.isSetRPrDefault() && docDefaults.getRPrDefault().isSetRPr()) {
      defaultRunStyle = new XWPFDefaultRunStyle(
          docDefaults.getRPrDefault().getRPr());
    }
    if (docDefaults.isSetPPrDefault() && docDefaults.getPPrDefault().isSetPPr()) {
      defaultParaStyle = new XWPFDefaultParagraphStyle(
          docDefaults.getPPrDefault().getPPr());
    }
  }
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter

public static CTPPr getPPr( XWPFStyle style )
{
  if ( style == null )
  {
    return null;
  }
  CTStyle ctStyle = style.getCTStyle();
  if ( ctStyle == null )
  {
    return null;
  }
  return ctStyle.getPPr();
}

代码示例来源:origin: apache/tika

);
if (style != null && style.getName() != null) {
  TagAndStyle tas = WordExtractor.buildParagraphTagAndStyle(
      style.getName(), paragraph.getPartType() == BodyType.TABLECELL
  );
  tag = tas.getTag();

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com