diff --git a/src/main/java/writer2latex/office/PropertySet.java b/src/main/java/writer2latex/office/PropertySet.java index 062d15e..8ebebc6 100644 --- a/src/main/java/writer2latex/office/PropertySet.java +++ b/src/main/java/writer2latex/office/PropertySet.java @@ -26,6 +26,7 @@ package writer2latex.office; import org.w3c.dom.Node; +import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import java.util.Enumeration; import java.util.Hashtable; @@ -102,5 +103,17 @@ public class PropertySet implements Cloneable { } return s; } + public void loadNoteProperties(Node child) { + Element noteConfiguration = (Element) child; + String noteClass = noteConfiguration.getAttribute(XMLString.TEXT_NOTE_CLASS); + NamedNodeMap attrs = noteConfiguration.getAttributes(); + for (int i=0;i Class representing a style in OOo which contains a style:properties * element

@@ -100,6 +101,7 @@ public class StyleWithProperties extends OfficeStyle { } else if (XMLString.STYLE_SECTION_PROPERTIES.equals(sName)) { loadPropertiesFromDOM(SECTION,child); + } else if (XMLString.STYLE_TABLE_PROPERTIES.equals(sName)) { loadPropertiesFromDOM(TABLE,child); @@ -133,18 +135,20 @@ public class StyleWithProperties extends OfficeStyle { Node child = node.getFirstChild(); while (child!=null) { if (child.getNodeType()==Node.ELEMENT_NODE) { - String sName = child.getNodeName(); - if (XMLString.STYLE_BACKGROUND_IMAGE.equals(sName)) { + String childName = child.getNodeName(); + if (XMLString.STYLE_BACKGROUND_IMAGE.equals(childName)) { backgroundImageProperties.loadFromDOM(child); } - else if (XMLString.STYLE_COLUMNS.equals(sName)) { + else if (XMLString.STYLE_COLUMNS.equals(childName)) { nColCount = Misc.getPosInteger(Misc.getAttribute(child, XMLString.FO_COLUMN_COUNT),1); // TODO: read individual columns } - else if (XMLString.STYLE_FOOTNOTE_SEP.equals(sName)) { + else if (XMLString.STYLE_FOOTNOTE_SEP.equals(childName)) { bHasFootnoteSep = true; footnoteSep.loadFromDOM(child); + } else if (XMLString.TEXT_NOTES_CONFIGURATION.equals(childName)) { + properties[nIndex].loadNoteProperties(child); } } child = child.getNextSibling(); diff --git a/src/main/java/writer2latex/xhtml/TextConverter.java b/src/main/java/writer2latex/xhtml/TextConverter.java index a5b785d..c3f9715 100644 --- a/src/main/java/writer2latex/xhtml/TextConverter.java +++ b/src/main/java/writer2latex/xhtml/TextConverter.java @@ -117,7 +117,8 @@ public class TextConverter extends ConverterHelper { private boolean inEndnote = false; private boolean inHeader = false; private boolean inFooter = false; - private String currentSection = null; + private String endnotesContext = null; + private String footnotesContext = null; public TextConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) { super(ofr,config,converter); @@ -530,16 +531,18 @@ public class TextConverter extends ConverterHelper { /* Process a text:section tag (returns current html node) */ private Node handleSection(Node onode, Node hnode) { // Unlike headings, paragraphs and spans, text:display is not attached to the style: - String lastSection = currentSection; + String lastEndnotesContext = endnotesContext; + String lastFootnotesContext = footnotesContext; + String sectionName = Misc.getAttribute(onode,TEXT_NAME); String last = Misc.getAttribute(onode,"last"); boolean isLast = false; if (last != null && last.equals("true")) { isLast = true;} String savedStyle = docSep.getPageContainerStyle(); + if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; } hnode = docSep.closePage(hnode); - currentSection = sectionName; setSectionStyle(onode); hnode = docSep.openPage(hnode, pageNum); @@ -547,7 +550,9 @@ public class TextConverter extends ConverterHelper { if (isLast) { insertEndnotes((Element) hnode, sectionName); } - currentSection = lastSection; + endnotesContext = lastEndnotesContext; + footnotesContext = lastFootnotesContext; + docSep.setPageContainerStyle(savedStyle); return hnode; @@ -555,8 +560,10 @@ public class TextConverter extends ConverterHelper { private void setSectionStyle(Node onode) { StyleWithProperties sectionStyle; - String sStyleName = Misc.getAttribute(onode,TEXT_STYLE_NAME); - OfficeStyle ofStyle = getSectionSc().getStyles().getStyle(sStyleName); + String styleName = Misc.getAttribute(onode,TEXT_STYLE_NAME); + String sectionName = Misc.getAttribute(onode,TEXT_NAME); + + OfficeStyle ofStyle = getSectionSc().getStyles().getStyle(styleName); if (ofStyle != null) { sectionStyle = (StyleWithProperties) ofStyle; int colCount = sectionStyle.getColCount(); @@ -564,7 +571,16 @@ public class TextConverter extends ConverterHelper { String styleValue = "column-count: " + colCount + ";"; docSep.setPageContainerStyle(styleValue); } + String collectEndnotes = sectionStyle.getSectionProperty("endnote", false); + if (collectEndnotes != null && collectEndnotes.equals("true")) { + endnotesContext = sectionName; + } + String collectFootnotes = sectionStyle.getSectionProperty("footnote", false); + if (collectFootnotes != null && collectFootnotes.equals("true")) { + footnotesContext = sectionName; + } } + } private void handleHeading(Element onode, Element hnode, boolean bAfterSplit) { @@ -1258,17 +1274,17 @@ public class TextConverter extends ConverterHelper { handleAnchor(child,hnode); } else if (sName.equals(TEXT_FOOTNOTE)) { - footCv.handleNote(child,hnode,currentSection); + footCv.handleNote(child,hnode,footnotesContext); } else if (sName.equals(TEXT_ENDNOTE)) { - endCv.handleNote(child,hnode,currentSection); + endCv.handleNote(child,hnode,endnotesContext); } else if (sName.equals(TEXT_NOTE)) { // oasis if ("endnote".equals(Misc.getAttribute(child,TEXT_NOTE_CLASS))) { - endCv.handleNote(child,hnode,currentSection); + endCv.handleNote(child,hnode,endnotesContext); } else { - footCv.handleNote(child,hnode,currentSection); + footCv.handleNote(child,hnode,footnotesContext); } } else if (sName.equals(TEXT_SEQUENCE)) {