Read and apply notes' properties in section configuration
This commit is contained in:
parent
2c7fb816e6
commit
274f1089c8
3 changed files with 47 additions and 14 deletions
|
@ -26,6 +26,7 @@
|
||||||
package writer2latex.office;
|
package writer2latex.office;
|
||||||
|
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
@ -102,5 +103,17 @@ public class PropertySet implements Cloneable {
|
||||||
}
|
}
|
||||||
return s;
|
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<attrs.getLength();i++) {
|
||||||
|
Node attr = attrs.item(i);
|
||||||
|
if (attr.getNodeName().equals(XMLString.TEXT_NOTE_CLASS)) {
|
||||||
|
properties.put(noteClass, "true");
|
||||||
|
}
|
||||||
|
properties.put(attr.getNodeName()+":"+noteClass, attr.getNodeValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -30,6 +30,7 @@ import writer2latex.util.Calc;
|
||||||
//import org.w3c.dom.NamedNodeMap;
|
//import org.w3c.dom.NamedNodeMap;
|
||||||
//import java.util.Hashtable;
|
//import java.util.Hashtable;
|
||||||
import writer2latex.util.Misc;
|
import writer2latex.util.Misc;
|
||||||
|
import writer2latex.xhtml.Debug;
|
||||||
|
|
||||||
/** <p> Class representing a style in OOo which contains a style:properties
|
/** <p> Class representing a style in OOo which contains a style:properties
|
||||||
* element </p>
|
* element </p>
|
||||||
|
@ -100,6 +101,7 @@ public class StyleWithProperties extends OfficeStyle {
|
||||||
}
|
}
|
||||||
else if (XMLString.STYLE_SECTION_PROPERTIES.equals(sName)) {
|
else if (XMLString.STYLE_SECTION_PROPERTIES.equals(sName)) {
|
||||||
loadPropertiesFromDOM(SECTION,child);
|
loadPropertiesFromDOM(SECTION,child);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (XMLString.STYLE_TABLE_PROPERTIES.equals(sName)) {
|
else if (XMLString.STYLE_TABLE_PROPERTIES.equals(sName)) {
|
||||||
loadPropertiesFromDOM(TABLE,child);
|
loadPropertiesFromDOM(TABLE,child);
|
||||||
|
@ -133,18 +135,20 @@ public class StyleWithProperties extends OfficeStyle {
|
||||||
Node child = node.getFirstChild();
|
Node child = node.getFirstChild();
|
||||||
while (child!=null) {
|
while (child!=null) {
|
||||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||||
String sName = child.getNodeName();
|
String childName = child.getNodeName();
|
||||||
if (XMLString.STYLE_BACKGROUND_IMAGE.equals(sName)) {
|
if (XMLString.STYLE_BACKGROUND_IMAGE.equals(childName)) {
|
||||||
backgroundImageProperties.loadFromDOM(child);
|
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);
|
nColCount = Misc.getPosInteger(Misc.getAttribute(child, XMLString.FO_COLUMN_COUNT),1);
|
||||||
|
|
||||||
// TODO: read individual columns
|
// TODO: read individual columns
|
||||||
}
|
}
|
||||||
else if (XMLString.STYLE_FOOTNOTE_SEP.equals(sName)) {
|
else if (XMLString.STYLE_FOOTNOTE_SEP.equals(childName)) {
|
||||||
bHasFootnoteSep = true;
|
bHasFootnoteSep = true;
|
||||||
footnoteSep.loadFromDOM(child);
|
footnoteSep.loadFromDOM(child);
|
||||||
|
} else if (XMLString.TEXT_NOTES_CONFIGURATION.equals(childName)) {
|
||||||
|
properties[nIndex].loadNoteProperties(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child = child.getNextSibling();
|
child = child.getNextSibling();
|
||||||
|
|
|
@ -117,7 +117,8 @@ public class TextConverter extends ConverterHelper {
|
||||||
private boolean inEndnote = false;
|
private boolean inEndnote = false;
|
||||||
private boolean inHeader = false;
|
private boolean inHeader = false;
|
||||||
private boolean inFooter = 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) {
|
public TextConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
||||||
super(ofr,config,converter);
|
super(ofr,config,converter);
|
||||||
|
@ -530,16 +531,18 @@ public class TextConverter extends ConverterHelper {
|
||||||
/* Process a text:section tag (returns current html node) */
|
/* Process a text:section tag (returns current html node) */
|
||||||
private Node handleSection(Node onode, Node hnode) {
|
private Node handleSection(Node onode, Node hnode) {
|
||||||
// Unlike headings, paragraphs and spans, text:display is not attached to the style:
|
// 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 sectionName = Misc.getAttribute(onode,TEXT_NAME);
|
||||||
String last = Misc.getAttribute(onode,"last");
|
String last = Misc.getAttribute(onode,"last");
|
||||||
boolean isLast = false;
|
boolean isLast = false;
|
||||||
if (last != null && last.equals("true")) { isLast = true;}
|
if (last != null && last.equals("true")) { isLast = true;}
|
||||||
|
|
||||||
String savedStyle = docSep.getPageContainerStyle();
|
String savedStyle = docSep.getPageContainerStyle();
|
||||||
|
|
||||||
if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; }
|
if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; }
|
||||||
hnode = docSep.closePage(hnode);
|
hnode = docSep.closePage(hnode);
|
||||||
currentSection = sectionName;
|
|
||||||
setSectionStyle(onode);
|
setSectionStyle(onode);
|
||||||
|
|
||||||
hnode = docSep.openPage(hnode, pageNum);
|
hnode = docSep.openPage(hnode, pageNum);
|
||||||
|
@ -547,7 +550,9 @@ public class TextConverter extends ConverterHelper {
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
insertEndnotes((Element) hnode, sectionName);
|
insertEndnotes((Element) hnode, sectionName);
|
||||||
}
|
}
|
||||||
currentSection = lastSection;
|
endnotesContext = lastEndnotesContext;
|
||||||
|
footnotesContext = lastFootnotesContext;
|
||||||
|
|
||||||
docSep.setPageContainerStyle(savedStyle);
|
docSep.setPageContainerStyle(savedStyle);
|
||||||
|
|
||||||
return hnode;
|
return hnode;
|
||||||
|
@ -555,8 +560,10 @@ public class TextConverter extends ConverterHelper {
|
||||||
|
|
||||||
private void setSectionStyle(Node onode) {
|
private void setSectionStyle(Node onode) {
|
||||||
StyleWithProperties sectionStyle;
|
StyleWithProperties sectionStyle;
|
||||||
String sStyleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
String styleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
||||||
OfficeStyle ofStyle = getSectionSc().getStyles().getStyle(sStyleName);
|
String sectionName = Misc.getAttribute(onode,TEXT_NAME);
|
||||||
|
|
||||||
|
OfficeStyle ofStyle = getSectionSc().getStyles().getStyle(styleName);
|
||||||
if (ofStyle != null) {
|
if (ofStyle != null) {
|
||||||
sectionStyle = (StyleWithProperties) ofStyle;
|
sectionStyle = (StyleWithProperties) ofStyle;
|
||||||
int colCount = sectionStyle.getColCount();
|
int colCount = sectionStyle.getColCount();
|
||||||
|
@ -564,7 +571,16 @@ public class TextConverter extends ConverterHelper {
|
||||||
String styleValue = "column-count: " + colCount + ";";
|
String styleValue = "column-count: " + colCount + ";";
|
||||||
docSep.setPageContainerStyle(styleValue);
|
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) {
|
private void handleHeading(Element onode, Element hnode, boolean bAfterSplit) {
|
||||||
|
@ -1258,17 +1274,17 @@ public class TextConverter extends ConverterHelper {
|
||||||
handleAnchor(child,hnode);
|
handleAnchor(child,hnode);
|
||||||
}
|
}
|
||||||
else if (sName.equals(TEXT_FOOTNOTE)) {
|
else if (sName.equals(TEXT_FOOTNOTE)) {
|
||||||
footCv.handleNote(child,hnode,currentSection);
|
footCv.handleNote(child,hnode,footnotesContext);
|
||||||
}
|
}
|
||||||
else if (sName.equals(TEXT_ENDNOTE)) {
|
else if (sName.equals(TEXT_ENDNOTE)) {
|
||||||
endCv.handleNote(child,hnode,currentSection);
|
endCv.handleNote(child,hnode,endnotesContext);
|
||||||
}
|
}
|
||||||
else if (sName.equals(TEXT_NOTE)) { // oasis
|
else if (sName.equals(TEXT_NOTE)) { // oasis
|
||||||
if ("endnote".equals(Misc.getAttribute(child,TEXT_NOTE_CLASS))) {
|
if ("endnote".equals(Misc.getAttribute(child,TEXT_NOTE_CLASS))) {
|
||||||
endCv.handleNote(child,hnode,currentSection);
|
endCv.handleNote(child,hnode,endnotesContext);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
footCv.handleNote(child,hnode,currentSection);
|
footCv.handleNote(child,hnode,footnotesContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sName.equals(TEXT_SEQUENCE)) {
|
else if (sName.equals(TEXT_SEQUENCE)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue