47 lines
1.3 KiB
Java
47 lines
1.3 KiB
Java
package w2phtml.pageSplitters;
|
|
|
|
import static w2phtml.office.XMLString.TEXT_P;
|
|
import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK;
|
|
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import w2phtml.office.OfficeReader;
|
|
|
|
public class IndexBodySplitter extends BasicSplitter implements ISplitter {
|
|
|
|
public IndexBodySplitter(OfficeReader officeReader, SplitFactory factory) {
|
|
super(officeReader, factory);
|
|
}
|
|
|
|
@Override
|
|
public SplitResults Split(Node indexBody) {
|
|
Node indexBodyFirstPart = indexBody.cloneNode(false);
|
|
NodeList childs = indexBody.getChildNodes();
|
|
SplitResults results = new SplitResults(false);
|
|
int i = 0;
|
|
while (childs.getLength() > i) {
|
|
Node child = childs.item(i);
|
|
if (!containsSPB(child)) {
|
|
indexBodyFirstPart.appendChild(child);
|
|
} else {
|
|
String childName = child.getNodeName();
|
|
if (childName.equals(TEXT_P)) {
|
|
if (factory.split(child).isDataMoved()) {
|
|
indexBodyFirstPart.appendChild(child.getPreviousSibling());
|
|
results.setDataMoved(true);
|
|
}
|
|
return results;
|
|
} else
|
|
if (childName.equals(TEXT_SOFT_PAGE_BREAK)) {
|
|
//indexBody.removeChild(child);
|
|
//return dataMoved;
|
|
System.out.println("Error. Soft page break inside " + childName);
|
|
System.exit(1);
|
|
}
|
|
}
|
|
}
|
|
return results;
|
|
}
|
|
|
|
}
|