All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.docx4j.model.datastorage.BindingTraverserState Maven / Gradle / Ivy

Go to download

docx4j is a library which helps you to work with the Office Open XML file format as used in docx documents, pptx presentations, and xlsx spreadsheets.

There is a newer version: 6.1.2
Show newest version
package org.docx4j.model.datastorage;

import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import org.docx4j.jaxb.Context;
import org.docx4j.wml.Tc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeIterator;

public class BindingTraverserState {
	
	private static Logger log = LoggerFactory.getLogger(BindingTraverserState.class);
	
	
	Tc tc;
	
	public static void enteredTc(BindingTraverserState btState, NodeIterator nodeIterator) {
		
		Node n = nodeIterator.nextNode(); //It is never null
		if (n!=null) {
			try {
    			Unmarshaller u = Context.jc.createUnmarshaller();			
    			u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
    			Object jaxb = u.unmarshal(n);
    			btState.tc =  (Tc)jaxb;
			} catch (ClassCastException e) {
				log.error("Couldn't cast  to RPr!");
			} catch (JAXBException e) {
				log.error(e.getMessage(), e);
			}        	        			
		}		
		
	}

	public static void exitedTc(BindingTraverserState btState) {
		
		btState.tc = null;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy