本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFStyles
类的一些代码示例,展示了XWPFStyles
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFStyles
类的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFStyles
类名称:XWPFStyles
暂无
代码示例来源: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: org.apache.poi/poi-ooxml
/**
* Read document
*/
@Override
protected void onDocumentRead() throws IOException {
StylesDocument stylesDoc;
InputStream is = getPackagePart().getInputStream();
try {
stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
setStyles(stylesDoc.getStyles());
latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
} catch (XmlException e) {
throw new POIXMLException("Unable to read styles", e);
} finally {
is.close();
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Get the default paragraph style which applies to the document
*/
public XWPFDefaultParagraphStyle getDefaultParagraphStyle() {
ensureDocDefaults();
return defaultParaStyle;
}
代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae
protected XWPFStyle getXWPFStyle( String styleID )
{
if ( styleID == null )
return null;
else
return document.getStyles().getStyle( styleID );
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates an empty styles for the document if one does not already exist
*
* @return styles
*/
public XWPFStyles createStyles() {
if (styles == null) {
StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.STYLES;
int i = getRelationIndex(relation);
XWPFStyles wrapper = (XWPFStyles) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setStyles(stylesDoc.addNewStyles());
styles = wrapper;
}
return styles;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
protected void commit() throws IOException {
if (ctStyles == null) {
throw new IllegalStateException("Unable to write out styles that were never read in!");
}
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles"));
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
ctStyles.save(out, xmlOptions);
out.close();
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* get the styles which are related to the parameter style and their relatives
* this method can be used to copy all styles from one document to another document
*
* @param style
* @return a list of all styles which were used by this method
*/
public List<XWPFStyle> getUsedStyleList(XWPFStyle style) {
List<XWPFStyle> usedStyleList = new ArrayList<>();
usedStyleList.add(style);
return getUsedStyleList(style, usedStyleList);
}
代码示例来源:origin: org.apache.poi/poi-ooxml
if (relation.equals(XWPFRelation.STYLES.getRelation())) {
this.styles = (XWPFStyles) p;
this.styles.onDocumentRead();
} else if (relation.equals(XWPFRelation.NUMBERING.getRelation())) {
this.numbering = (XWPFNumbering) p;
代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter
protected XWPFStyle getXWPFStyle( String styleID )
{
if ( styleID == null )
return null;
else
return document.getStyles().getStyle( styleID );
}
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument();
XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));
XWPFStyles newStyles = document.createStyles();
newStyles.setStyles(template.getStyle());
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
@Override
protected void commit() throws IOException {
if (ctStyles == null) {
throw new IllegalStateException("Unable to write out styles that were never read in!");
}
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles"));
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
ctStyles.save(out, xmlOptions);
out.close();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* get the styles which are related to the parameter style and their relatives
* this method can be used to copy all styles from one document to another document
*
* @param style
* @return a list of all styles which were used by this method
*/
public List<XWPFStyle> getUsedStyleList(XWPFStyle style) {
List<XWPFStyle> usedStyleList = new ArrayList<>();
usedStyleList.add(style);
return getUsedStyleList(style, usedStyleList);
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
if (relation.equals(XWPFRelation.STYLES.getRelation())) {
this.styles = (XWPFStyles) p;
this.styles.onDocumentRead();
} else if (relation.equals(XWPFRelation.NUMBERING.getRelation())) {
this.numbering = (XWPFNumbering) p;
代码示例来源:origin: com.github.livesense/org.liveSense.framework.xdocreport
protected XWPFStyle getXWPFStyle( String styleID )
{
if ( styleID == null )
return null;
else
return document.getStyles().getStyle( styleID );
}
代码示例来源: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
/**
* Read document
*/
@Override
protected void onDocumentRead() throws IOException {
StylesDocument stylesDoc;
InputStream is = getPackagePart().getInputStream();
try {
stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
setStyles(stylesDoc.getStyles());
latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
} catch (XmlException e) {
throw new POIXMLException("Unable to read styles", e);
} finally {
is.close();
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));
XWPFDocument doc = new XWPFDocument();
// let's copy styles from template to new doc
XWPFStyles newStyles = doc.createStyles();
newStyles.setStyles(template.getStyle());
XWPFParagraph para = doc.createParagraph();
para.setStyle("Heading1");
XWPFRun run = para.createRun();
run.setText("Heading 1");
return doc;
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
@Override
protected void commit() throws IOException {
if (ctStyles == null) {
throw new IllegalStateException("Unable to write out styles that were never read in!");
}
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles"));
Map<String,String> map = new HashMap<String,String>();
map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
xmlOptions.setSaveSuggestedPrefixes(map);
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
ctStyles.save(out, xmlOptions);
out.close();
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Get the default style which applies text runs in the document
*/
public XWPFDefaultRunStyle getDefaultRunStyle() {
ensureDocDefaults();
return defaultRunStyle;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* get the styles which are related to the parameter style and their relatives
* this method can be used to copy all styles from one document to another document
* @param style
* @return a list of all styles which were used by this method
*/
public List<XWPFStyle> getUsedStyleList(XWPFStyle style){
List<XWPFStyle> usedStyleList = new ArrayList<XWPFStyle>();
usedStyleList.add(style);
return getUsedStyleList(style, usedStyleList);
}
内容来源于网络,如有侵权,请联系作者删除!