From 25cb9d03a9ce87e102f53d01e461cedaa39cacef Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Wed, 21 Sep 2016 23:43:21 +0300 Subject: [PATCH] Fixed one more bug --- .../java/writer2latex/xhtml/GreenstoneTags.java | 8 ++------ source/java/writer2latex/xhtml/TextConverter.java | 15 ++++++++------- source/java/writer2latex/xhtml/XhtmlConfig.java | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/source/java/writer2latex/xhtml/GreenstoneTags.java b/source/java/writer2latex/xhtml/GreenstoneTags.java index f0706f4..c3a5eae 100644 --- a/source/java/writer2latex/xhtml/GreenstoneTags.java +++ b/source/java/writer2latex/xhtml/GreenstoneTags.java @@ -63,28 +63,24 @@ public class GreenstoneTags { } } - } + } return hnode; } protected static Node processPageBreak(Node currentNode, Node hnode, Integer pageNum){ - if (pageTags.equals(NONE)){ return hnode; } if ( !( currentNode.getNodeType() == Node.ELEMENT_NODE - && currentNode.getNodeName().equals(XMLString.TEXT_H) && Misc.getAttribute(currentNode, XMLString.TEXT_OUTLINE_LEVEL) != null && !Misc.getAttribute(currentNode, XMLString.TEXT_OUTLINE_LEVEL).isEmpty() ) - && !headerStack.isEmpty() - || pageTags.equals("sections") ) { if (pageOpened) { hnode = closePage(hnode); } hnode = openPage(hnode, pageNum); - } + } return hnode; } //Method to open main document tag diff --git a/source/java/writer2latex/xhtml/TextConverter.java b/source/java/writer2latex/xhtml/TextConverter.java index 008c348..b05792b 100644 --- a/source/java/writer2latex/xhtml/TextConverter.java +++ b/source/java/writer2latex/xhtml/TextConverter.java @@ -105,6 +105,7 @@ public class TextConverter extends ConverterHelper { private String headingTags = config.getHeadingTags(); private String pageTags = config.getPageTags(); + private boolean breakBeforeNextNode = false; public TextConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) { super(ofr,config,converter); @@ -200,7 +201,7 @@ public class TextConverter extends ConverterHelper { int nLen = nList.getLength(); int i = 0; //hard Break after marker - boolean breakBeforeNextNode = false; + breakBeforeNextNode = false; while (i < nLen) { Node child = nList.item(i); @@ -214,7 +215,7 @@ public class TextConverter extends ConverterHelper { } else if (nodeName.equals(XMLString.TEXT_P)) { StyleWithProperties style = ofr.getParStyle(Misc.getAttribute(child,XMLString.TEXT_STYLE_NAME)); - hnode = processPageBreaks(child, hnode,style, breakBeforeNextNode); + hnode = processPageBreaks(child, hnode,style); hnode = maybeSplit(hnode, style); nCharacterCount+=OfficeReader.getCharacterCount(child); // is there a block element, we should use? @@ -263,7 +264,7 @@ public class TextConverter extends ConverterHelper { StyleWithProperties style = ofr.getParStyle(Misc.getAttribute(child,XMLString.TEXT_STYLE_NAME)); int nOutlineLevel = getOutlineLevel((Element)child); Node rememberNode = hnode; - hnode = processPageBreaks(child, hnode, style, breakBeforeNextNode); + hnode = processPageBreaks(child, hnode, style); hnode = GreenstoneTags.processHeading(child, hnode, pageNum); hnode = maybeSplit(hnode,style,nOutlineLevel); nCharacterCount+=OfficeReader.getCharacterCount(child); @@ -273,7 +274,7 @@ public class TextConverter extends ConverterHelper { nodeName.equals(XMLString.TEXT_UNORDERED_LIST) || // old nodeName.equals(XMLString.TEXT_ORDERED_LIST)) // old { - hnode = processPageBreaks(child, hnode,null, breakBeforeNextNode); + hnode = processPageBreaks(child, hnode,null); hnode = maybeSplit(hnode,null); if (listIsOnlyHeadings(child)) { nDontSplitLevel--; @@ -286,7 +287,7 @@ public class TextConverter extends ConverterHelper { } else if (nodeName.equals(XMLString.TABLE_TABLE)) { StyleWithProperties style = ofr.getTableStyle(Misc.getAttribute(child, XMLString.TABLE_STYLE_NAME)); - hnode = processPageBreaks(child, hnode,style, breakBeforeNextNode); + hnode = processPageBreaks(child, hnode,style); hnode = maybeSplit(hnode,style); getTableCv().handleTable(child,hnode); } @@ -294,7 +295,7 @@ public class TextConverter extends ConverterHelper { getTableCv().handleTable(child,hnode); } else if (nodeName.equals(XMLString.TEXT_SECTION)) { - hnode = processPageBreaks(child, hnode,null, breakBeforeNextNode); + hnode = processPageBreaks(child, hnode,null); hnode = maybeSplit(hnode,null); nDontSplitLevel--; hnode = handleSection(child,hnode); @@ -1549,7 +1550,7 @@ public class TextConverter extends ConverterHelper { Misc.getPosInteger(node.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1): Misc.getPosInteger(node.getAttribute(XMLString.TEXT_LEVEL),1); } - private Node processPageBreaks(Node currentNode, Node hnode,StyleWithProperties style, boolean breakBeforeNextNode){ + private Node processPageBreaks(Node currentNode, Node hnode,StyleWithProperties style){ Integer newPageNumber = null; if (style != null) { // If style:paragraph-properties extists and contain diff --git a/source/java/writer2latex/xhtml/XhtmlConfig.java b/source/java/writer2latex/xhtml/XhtmlConfig.java index d85b8b8..e91855f 100644 --- a/source/java/writer2latex/xhtml/XhtmlConfig.java +++ b/source/java/writer2latex/xhtml/XhtmlConfig.java @@ -293,8 +293,8 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase { options[UPLINK] = new Option("uplink",""); options[DIRECTORY_ICON] = new Option("directory_icon",""); options[DOCUMENT_ICON] = new Option("document_icon",""); - options[HEADING_TAGS] = new Option("heading_tags","none"); - options[PAGE_TAGS] = new Option("page_tags","none"); + options[HEADING_TAGS] = new Option("heading_tags","sections"); + options[PAGE_TAGS] = new Option("page_tags","div"); } protected void readInner(Element elm) {