diff --git a/src/main/java/writer2latex/xhtml/EndnoteConverter.java b/src/main/java/writer2latex/xhtml/EndnoteConverter.java
index c8ed507..8509046 100644
--- a/src/main/java/writer2latex/xhtml/EndnoteConverter.java
+++ b/src/main/java/writer2latex/xhtml/EndnoteConverter.java
@@ -39,12 +39,12 @@ class EndnoteConverter extends NoteConverter {
*
* @param hnode a block HTML element to contain the endnotes
*/
- void insertEndnotes(Node hnode) {
+ void insertEndnotes(Node hnode, String section) {
if (hasNotes()) {
if (config.getXhtmlSplitLevel()>0) { hnode = converter.nextOutFile(); }
- Element section = createNoteSection(hnode, "rearnotes");
- insertNoteHeading(section, config.getEndnotesHeading(), "endnotes");
- flushNotes(section,"rearnote");
+ Element sectionElement = createNoteSection(hnode, "rearnotes");
+ insertNoteHeading(sectionElement, config.getEndnotesHeading(), "endnotes");
+ flushNotes(sectionElement,"rearnote",section);
}
}
}
diff --git a/src/main/java/writer2latex/xhtml/FootnoteConverter.java b/src/main/java/writer2latex/xhtml/FootnoteConverter.java
index d594825..e981e4a 100644
--- a/src/main/java/writer2latex/xhtml/FootnoteConverter.java
+++ b/src/main/java/writer2latex/xhtml/FootnoteConverter.java
@@ -53,23 +53,23 @@ class FootnoteConverter extends NoteConverter {
void insertFootnotes(Node hnode, boolean bFinal) {
if (hasNotes()) {
if (bFootnotesAtPage) {
- Element section = createNoteSection(hnode, "footnotes");
+ Element sectionElement = createNoteSection(hnode, "footnotes");
// Add footnote rule
Element rule = converter.createElement("hr");
StyleInfo info = new StyleInfo();
getPageSc().applyFootnoteRuleStyle(info);
getPageSc().applyStyle(info, rule);
- section.appendChild(rule);
+ sectionElement.appendChild(rule);
- flushNotes(section,"footnote");
+ flushAllNotes(sectionElement,"footnote");
}
else if (bFinal) {
// New page if required for footnotes as endnotes
if (config.getXhtmlSplitLevel()>0) { hnode = converter.nextOutFile(); }
- Element section = createNoteSection(hnode, "footnotes");
- insertNoteHeading(section, config.getFootnotesHeading(), "footnotes");
- flushNotes(section,"footnote");
+ Element sectionElement = createNoteSection(hnode, "footnotes");
+ insertNoteHeading(sectionElement, config.getFootnotesHeading(), "footnotes");
+ flushAllNotes(sectionElement,"footnote");
}
}
}
diff --git a/src/main/java/writer2latex/xhtml/NoteConverter.java b/src/main/java/writer2latex/xhtml/NoteConverter.java
index bb0857b..efaf448 100644
--- a/src/main/java/writer2latex/xhtml/NoteConverter.java
+++ b/src/main/java/writer2latex/xhtml/NoteConverter.java
@@ -25,7 +25,10 @@
package writer2latex.xhtml;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map.Entry;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -43,8 +46,8 @@ class NoteConverter extends ConverterHelper {
private PropertySet noteConfig;
// The collection of notes
- private List notes = new ArrayList();
-
+ //private List notes = new ArrayList();
+ private HashMap> notes = new HashMap>();
/** Construct a new note converter
*
* @param ofr the office reader used to read the source document
@@ -62,7 +65,7 @@ class NoteConverter extends ConverterHelper {
* @param onode a text:note element
* @param hnode the inline HTML element to contain the citation
*/
- void handleNote(Node onode, Node hnode) {
+ void handleNote(Node onode, Node hnode, String section) {
// Create a style span for the citation
String sCitBodyStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_BODY_STYLE_NAME);
Element span = getTextCv().createInline((Element) hnode,sCitBodyStyle);
@@ -85,7 +88,12 @@ class NoteConverter extends ConverterHelper {
getTextCv().traversePCDATA(citation,link);
}
// Remember the actual note
- notes.add(onode);
+ List noteList = notes.get(section);
+ if (noteList == null) {
+ noteList = new ArrayList();
+ notes.put(section, noteList);
+ }
+ noteList.add(onode);
}
boolean hasNotes() {
@@ -117,11 +125,17 @@ class NoteConverter extends ConverterHelper {
}
}
}
+ public void flushAllNotes(Node hnode, String sEpubType) {
+ for (Entry> entry : notes.entrySet()) {
+ flushNotes(hnode, sEpubType, entry.getKey());
+ }
+ }
- void flushNotes(Node hnode, String sEpubType) {
- int nSize = notes.size();
+ public void flushNotes(Node hnode, String sEpubType, String section) {
+ List noteList = notes.get(section);
+ int nSize = noteList.size();
for (int i=0; i