From c42c709c9a9104b7cf4e87d2bb08c93b6bfb6703 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 5 Feb 2015 23:31:59 +0000 Subject: [PATCH] XWPF implementation of some common Paragraph methods git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1657717 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/XWPFParagraph.java | 45 +++++++++++++++++-- .../apache/poi/wp/usermodel/Paragraph.java | 27 +++++------ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index e80fcda29f..7ed629c10a 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -379,6 +379,17 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para jc.setVal(en); } + /** + * @return The raw alignment value, {@link #getAlignment()} is suggested + */ + public int getFontAlignment() { + return getAlignment().getValue(); + } + public void setFontAlignment(int align) { + ParagraphAlignment pAlign = ParagraphAlignment.valueOf(align); + setAlignment(pAlign); + } + /** * Returns the text vertical alignment which shall be applied to text in * this paragraph. @@ -942,7 +953,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para return (indentation != null && indentation.isSetLeft()) ? indentation.getLeft().intValue() : -1; } - + /** * Specifies the indentation which shall be placed between the right text * margin for this paragraph and the right edge of that paragraph's content @@ -1061,6 +1072,27 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para : -1; } + public int getIndentFromLeft() { + return getIndentFromLeft(); + } + public void setIndentFromLeft(int dxaLeft) { + setIndentationLeft(dxaLeft); + } + + public int getIndentFromRight() { + return getIndentFromRight(); + } + public void setIndentFromRight(int dxaRight) { + setIndentationRight(dxaRight); + } + + public int getFirstLineIndent() { + return getIndentationFirstLine(); + } + public void setFirstLineIndent(int first) { + setIndentationFirstLine(first); + } + /** * This element specifies whether a consumer shall break Latin text which * exceeds the text extents of a line by breaking the word across two lines @@ -1069,7 +1101,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para * * @param wrap - boolean */ - public void setWordWrap(boolean wrap) { + public void setWordWrapped(boolean wrap) { CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr() .getWordWrap() : getCTPPr().addNewWordWrap(); if (wrap) @@ -1077,6 +1109,10 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para else wordWrap.unsetVal(); } + @Deprecated + public void setWordWrap(boolean wrap) { + setWordWrapped(wrap); + } /** * This element specifies whether a consumer shall break Latin text which @@ -1086,7 +1122,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para * * @return boolean */ - public boolean isWordWrap() { + public boolean isWordWrapped() { CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr() .getWordWrap() : null; if (wordWrap != null) { @@ -1096,6 +1132,9 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para } return false; } + public boolean isWordWrap() { + return isWordWrapped(); + } /** * This method provides a style to the paragraph diff --git a/src/scratchpad/src/org/apache/poi/wp/usermodel/Paragraph.java b/src/scratchpad/src/org/apache/poi/wp/usermodel/Paragraph.java index ba2bc9f8a7..be488a2ef8 100644 --- a/src/scratchpad/src/org/apache/poi/wp/usermodel/Paragraph.java +++ b/src/scratchpad/src/org/apache/poi/wp/usermodel/Paragraph.java @@ -47,6 +47,15 @@ public interface Paragraph { public void setSideBySide(boolean fSideBySide); */ + public int getIndentFromRight(); + public void setIndentFromRight(int dxaRight); + + public int getIndentFromLeft(); + public void setIndentFromLeft(int dxaLeft); + + public int getFirstLineIndent(); + public void setFirstLineIndent(int first); + /* public boolean isLineNotNumbered(); public void setLineNotNumbered(boolean fNoLnn); @@ -57,15 +66,6 @@ public interface Paragraph { public boolean isWidowControlled(); public void setWidowControl(boolean widowControl); - public int getIndentFromRight(); - public void setIndentFromRight(int dxaRight); - - public int getIndentFromLeft(); - public void setIndentFromLeft(int dxaLeft); - - public int getFirstLineIndent(); - public void setFirstLineIndent(int first); - public int getSpacingBefore(); public void setSpacingBefore(int before); @@ -76,13 +76,13 @@ public interface Paragraph { // public LineSpacingDescriptor getLineSpacing(); // public void setLineSpacing(LineSpacingDescriptor lspd); -/* - public boolean isWordWrapped(); - public void setWordWrapped(boolean wrap); - public int getFontAlignment(); public void setFontAlignment(int align); + public boolean isWordWrapped(); + public void setWordWrapped(boolean wrap); + +/* public boolean isVertical(); public void setVertical(boolean vertical); @@ -90,6 +90,7 @@ public interface Paragraph { public void setBackward(boolean bward); */ + // TODO Make the HWPF and XWPF interface wrappers compatible for these /* public BorderCode getTopBorder(); public void setTopBorder(BorderCode top); -- 2.39.5