Bug 58802: HWPF: Allow reading of footnote and endnote properties

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-07-17 09:27:17 +00:00
parent 16b0c380c9
commit 146839d0ce
4 changed files with 209 additions and 1 deletions

View 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;
}

View 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()
{

View 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;
}
}

View 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() {