]> source.dussan.org Git - poi.git/commitdiff
Bug 58802: HWPF: Allow reading of footnote and endnote properties
authorDominik Stadler <centic@apache.org>
Sun, 17 Jul 2016 09:27:17 +0000 (09:27 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 17 Jul 2016 09:27:17 +0000 (09:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753039 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java

index 464608ada383fe94d7cb46436546f51bb04714aa..98027a44639e44cb0f90c7f80bba1ae01bc39164 100644 (file)
@@ -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;
     }
index 4488457f87be519afbb8a615e8aa343431333039..71ab5017e02c6f946d29cf0c8a8279f5c698287e 100644 (file)
@@ -160,6 +160,72 @@ public final class Section extends Range
         return _props.getFEvenlySpaced();
     }
 
+    /**
+     * Get the footnote restart qualifier
+     *
+     * <dl>
+     * <dt>{@code 0x00}</dt><dd>If the numbering is continuous throughout the entire document</dd>
+     * <dt>{@code 0x01}</dt><dd>If the numbering restarts at the beginning of this section</dd>
+     * <dt>{@code 0x02}</dt><dd>If the numbering restarts on every page</dd>
+     * </dl>
+     *
+     * @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
+     *
+     * <p>The full list of possible return values is given in [MS-OSHARED], v20140428, 2.2.1.3</p>
+     *
+     * @return an Nfc specifying the numbering format for footnotes
+     */
+    public int getFootnoteNumberingFormat() {
+        return _props.getNfcFtnRef();
+    }
+    
+    /**
+     * Get the endnote restart qualifier
+     *
+     * <dl>
+     * <dt>{@code 0x00}</dt><dd>If the numbering is continuous throughout the entire document</dd>
+     * <dt>{@code 0x01}</dt><dd>If the numbering restarts at the beginning of this section</dd>
+     * <dt>{@code 0x02}</dt><dd>If the numbering restarts on every page</dd>
+     * </dl>
+     *
+     * @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
+     *
+     * <p>The full list of possible return values is given in [MS-OSHARED], v20140428, 2.2.1.3</p>
+     *
+     * @return an Nfc specifying the numbering format for endnotes
+     */
+    public int getEndnoteNumberingFormat() {
+        return _props.getNfcEdnRef();
+    }
+
     @Override
     public String toString()
     {
index 2d1ed8eefa41e94e01acbeec7742cb42aeb5b200..55db1481cbf58ecdc6c0ec3bc3b2386b91ef3d7a 100644 (file)
@@ -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;
+    }
 }
index efc5c0a2073932f278d03d3954e7d67f802270d6..af6aa652f5afcf7cf992f9b35636fce1fd917ae7 100644 (file)
@@ -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() {