diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java index 464608ada3..98027a4463 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java @@ -208,6 +208,30 @@ public final class SectionSprmUncompressor extends SprmUncompressor case 0x33: newSEP.setWTextFlow ((short) sprm.getOperand()); break; + case 0x3C: + // [MS-DOC], v20140721, 2.6.4, sprmSRncFtn + newSEP.setRncFtn((short) sprm.getOperand()); + break; + case 0x3E: + // [MS-DOC], v20140721, 2.6.4, sprmSRncEdn + newSEP.setRncEdn((short) sprm.getOperand()); + break; + case 0x3F: + // [MS-DOC], v20140721, 2.6.4, sprmSNFtn + newSEP.setNFtn((int) sprm.getOperand()); + break; + case 0x40: + // [MS-DOC], v20140721, 2.6.4, sprmSNFtnRef + newSEP.setNfcFtnRef((int) sprm.getOperand()); + break; + case 0x41: + // [MS-DOC], v20140721, 2.6.4, sprmSNEdn + newSEP.setNEdn((int) sprm.getOperand()); + break; + case 0x42: + // [MS-DOC], v20140721, 2.6.4, sprmSNEdnRef + newSEP.setNfcEdnRef((int) sprm.getOperand()); + break; default: break; } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java index 4488457f87..71ab5017e0 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java @@ -160,6 +160,72 @@ public final class Section extends Range return _props.getFEvenlySpaced(); } + /** + * Get the footnote restart qualifier + * + *
+ *
{@code 0x00}
If the numbering is continuous throughout the entire document
+ *
{@code 0x01}
If the numbering restarts at the beginning of this section
+ *
{@code 0x02}
If the numbering restarts on every page
+ *
+ * + * @return an Rnc, as decribed above, specifying when and where footnote numbering restarts + */ + public short getFootnoteRestartQualifier() { + return _props.getRncFtn(); + } + + /** + * @return an offset to be added to footnote numbers + */ + public int getFootnoteNumberingOffset() { + return _props.getNFtn(); + } + + /** + * Get the numbering format of embedded footnotes + * + *

The full list of possible return values is given in [MS-OSHARED], v20140428, 2.2.1.3

+ * + * @return an Nfc specifying the numbering format for footnotes + */ + public int getFootnoteNumberingFormat() { + return _props.getNfcFtnRef(); + } + + /** + * Get the endnote restart qualifier + * + *
+ *
{@code 0x00}
If the numbering is continuous throughout the entire document
+ *
{@code 0x01}
If the numbering restarts at the beginning of this section
+ *
{@code 0x02}
If the numbering restarts on every page
+ *
+ * + * @return an Rnc, as decribed above, specifying when and where endnote numbering restarts + */ + public short getEndnoteRestartQualifier() { + return _props.getRncEdn(); + } + + /** + * @return an offset to be added to endnote numbers + */ + public int getEndnoteNumberingOffset() { + return _props.getNEdn(); + } + + /** + * Get the numbering format of embedded endnotes + * + *

The full list of possible return values is given in [MS-OSHARED], v20140428, 2.2.1.3

+ * + * @return an Nfc specifying the numbering format for endnotes + */ + public int getEndnoteNumberingFormat() { + return _props.getNfcEdnRef(); + } + @Override public String toString() { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java index 2d1ed8eefa..55db1481cb 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java @@ -21,6 +21,13 @@ import org.apache.poi.hwpf.model.types.SEPAbstractType; public final class SectionProperties extends SEPAbstractType { + private short field_60_rncftn; + private short field_61_rncedn; + private int field_62_nftn; + private int field_63_nfcftnref = 0x00; // initialize with default value; msonfcArabic + private int field_64_nedn; + private int field_65_nfcednref = 0x02; // initialize with default value; msonfcLCRoman + public SectionProperties() { field_20_brcTop = new BorderCode(); @@ -42,5 +49,108 @@ public final class SectionProperties extends SEPAbstractType return copy; } - + + /** + * sprmSRncFtn, [MS-DOC], 20140721, 2.6.4 + * + * @param field_60_rncftn unsigned 8-bit integer specifying the footnote numbering restart condition + */ + public void setRncFtn(final short field_60_rncftn) { + this.field_60_rncftn = field_60_rncftn; + } + + /** + * @see #setRncFtn(int) + * @return an Rnc value specifying when and where footnote numbering restarts + */ + public short getRncFtn() { + return this.field_60_rncftn; + } + + /** + * sprmSRncEdn, [MS-DOC], 20140721, 2.6.4 + * + * @param field_61_rncedn unsigned 8-bit integer specifying the endnote numbering restart condition + */ + public void setRncEdn(final short field_61_rncedn) { + this.field_61_rncedn = field_61_rncedn; + } + + /** + * @see #setRncEdn(int) + * @return an Rnc value specifying when and where endnote numbering restarts + */ + public short getRncEdn() { + return this.field_61_rncedn; + } + + /** + * sprmSNftn, [MS-DOC], v20140721, 2.6.4 + * + * @param field_62_nftn a number specifying the offset to add to footnote numbers + */ + public void setNFtn(final int field_62_nftn) { + this.field_62_nftn = field_62_nftn; + } + + /** + * @see #setNFtn(int) + * @return a 16-bit integer specifying the offset to add to footnote numbering + */ + public int getNFtn() { + return this.field_62_nftn; + } + + /** + * sprmSNfcFtnRef, [MS-DOC], v20140721 + * + * @param field_63_nfcftnref an Nfc specifying the numbering format for footnotes + */ + public void setNfcFtnRef(final int field_63_nfcftnref) { + this.field_63_nfcftnref = field_63_nfcftnref; + } + + /** + * + * @see #setNfcFtnRef(int) + * @return a 16-bit integer with an Nfc specifying the numbering format for footnotes + */ + public int getNfcFtnRef() { + return this.field_63_nfcftnref; + } + + /** + * sprmSNEdn, [MS-DOC], v20140721, 2.6.4 + * + * @param field_64_nedn a number specifying the offset to add to footnote numbers + */ + public void setNEdn(final int field_64_nedn) { + this.field_64_nedn = field_64_nedn; + } + + /** + * @see #setNEdn(int) + * @return a 16-bit integer specifying the offset to add to endnote numbering + */ + public int getNEdn() { + return this.field_64_nedn; + } + + /** + * sprmSNfcEdnRef, [MS-DOC], v20140721 + * + * @param field_65_nfcednref an Nfc specifying the numbering format for endnotes + */ + public void setNfcEdnRef(final int field_65_nfcednref) { + this.field_65_nfcednref = field_65_nfcednref; + } + + /** + * + * @see #setNfcEdnRef(int) + * @return a 16-bit integer with an Nfc specifying the numbering format for endnotes + */ + public int getNfcEdnRef() { + return this.field_65_nfcednref; + } } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java index efc5c0a207..af6aa652f5 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java @@ -233,6 +233,10 @@ public final class TestWordExtractor extends TestCase { } assertTrue(b.toString().contains("TestFootnote")); + assertEquals(0x00, doc.getRange().getSection(0).getFootnoteNumberingFormat()); // msonfcArabic + assertEquals(0x00, doc.getRange().getSection(0).getFootnoteRestartQualifier()); // rncCont + assertEquals(0, doc.getRange().getSection(0).getFootnoteNumberingOffset()); + assertEquals(1, doc.getFootnotes().getNotesCount()); } public void testEndnote() { @@ -246,6 +250,10 @@ public final class TestWordExtractor extends TestCase { } assertTrue(b.toString().contains("TestEndnote")); + assertEquals(0x02, doc.getRange().getSection(0).getEndnoteNumberingFormat()); // msonfcLCRoman + assertEquals(0x00, doc.getRange().getSection(0).getEndnoteRestartQualifier()); // rncCont + assertEquals(0, doc.getRange().getSection(0).getEndnoteNumberingOffset()); + assertEquals(1, doc.getEndnotes().getNotesCount()); } public void testComments() {