diff --git a/src/main/java/w2phtml/xhtml/content/TextParser.java b/src/main/java/w2phtml/xhtml/content/TextParser.java index 7af062b..8863bf1 100644 --- a/src/main/java/w2phtml/xhtml/content/TextParser.java +++ b/src/main/java/w2phtml/xhtml/content/TextParser.java @@ -264,7 +264,7 @@ public class TextParser extends Parser { if (child.getNodeType() == Node.ELEMENT_NODE) { String nodeName = child.getNodeName(); // Block splitting - + //System.out.println(nodeName); if (OfficeReader.isDrawElement(child)) { getDrawParser().handleDrawElement((Element)child,(Element)hnode,null,nFloatMode); } @@ -323,40 +323,7 @@ public class TextParser extends Parser { nodeName.equals(TEXT_UNORDERED_LIST) || // old nodeName.equals(TEXT_ORDERED_LIST)) // old { - StyleWithProperties style = null; - String newPageNumberProperty = null; - Element para = null; - Element head = null; - Element item = Misc.getChildByTagName(child, TEXT_LIST_ITEM); - if (item != null){ - NodeList paras = item.getElementsByTagName(TEXT_P); - if (paras != null && paras.getLength() > 0){ - para = (Element) paras.item(0); - } - NodeList heads = item.getElementsByTagName(TEXT_H); - if (heads != null && heads.getLength() > 0){ - head = (Element) heads.item(0); - } - if (para != null ){ - StyleWithProperties paraStyle = ofr.getParStyle(Misc.getAttribute(para,TEXT_STYLE_NAME)); - if (paraStyle != null) { - newPageNumberProperty = paraStyle.getParProperty(STYLE_PAGE_NUMBER, true); - } - newPageNumberProperty = paraStyle.getParProperty(STYLE_PAGE_NUMBER, true); - if (hasMasterPage(paraStyle) || newPageNumberProperty != null){ - style = paraStyle; - } - } - if (head != null && style == null){ - StyleWithProperties headStyle = ofr.getParStyle(Misc.getAttribute(head,TEXT_STYLE_NAME)); - if (headStyle != null) { - newPageNumberProperty = headStyle.getParProperty(STYLE_PAGE_NUMBER, true); - } - if (hasMasterPage(headStyle) || newPageNumberProperty != null){ - style = headStyle; - } - } - } + StyleWithProperties style = getListFirstParaStyle(child); hnode = processPageBreaks(child, hnode,style); inList = true; if (getListParser().listIsOnlyHeadings(child)) { @@ -420,6 +387,24 @@ public class TextParser extends Parser { } return hnode; } + + private StyleWithProperties getListFirstParaStyle(Node list) { + StyleWithProperties style = null; + Element listItem = Misc.getChildByTagName(list, TEXT_LIST_ITEM); + if (listItem == null){ + return style; + } + Element itemChild = Misc.getFirstChildElement(listItem); + if (itemChild == null) { + return style; + } + String itemChildName = itemChild.getNodeName(); + if (!itemChildName.equals(TEXT_H) && !itemChildName.equals(TEXT_P)) { + return style; + } + style = ofr.getParStyle(Misc.getAttribute(itemChild,TEXT_STYLE_NAME)); + return style; + } /* Process a text:section tag (returns current html node) */ private Node handleSection(Node onode, Node hnode) { @@ -1393,6 +1378,7 @@ public class TextParser extends Parser { } } else { System.out.println("ERROR MP is null"); + Debug.printStackTrace(); } inHeader = false; return node; @@ -1427,6 +1413,7 @@ public class TextParser extends Parser { } } else { System.out.println("ERROR MP is null"); + Debug.printStackTrace(); } inFooter = false; return node;