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

org.docx4j.convert.out.common.ConversionSectionWrappers 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: 11.4.11
Show newest version
/*
   Licensed to Plutext Pty Ltd under one or more contributor license agreements.  
   
 *  This file is part of docx4j.

    docx4j is licensed under the Apache License, Version 2.0 (the "License"); 
    you may not use this file except in compliance with the License. 

    You may obtain a copy of the License at 

        http://www.apache.org/licenses/LICENSE-2.0 

    Unless required by applicable law or agreed to in writing, software 
    distributed under the License is distributed on an "AS IS" BASIS, 
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    See the License for the specific language governing permissions and 
    limitations under the License.

 */
package org.docx4j.convert.out.common;

import java.util.List;

import org.docx4j.XmlUtils;
import org.docx4j.model.structure.jaxb.ObjectFactory;
import org.docx4j.model.structure.jaxb.Sections;
import org.docx4j.model.structure.jaxb.Sections.Section;
import org.w3c.dom.Element;

public class ConversionSectionWrappers {
	
	protected List conversionSections = null;
	protected int currentSectionIndex = -1;
	protected ConversionSectionWrapper currentSection = null;
	
	public ConversionSectionWrappers(List conversionSections) {
		this.conversionSections = conversionSections;
	}

	public Sections createSections() {
		
		ObjectFactory factory = new ObjectFactory();
		
		Sections ret = factory.createSections();
		for (int i=0; i
						
							
						
				 *
				 * Note also that marshaltoString uses 
				 * just the normal non-rels part NamespacePrefixMapper,
				 * so if/when this is marshalled again, that could
				 * have been causing problems as well?? 
				 */
	        return w3cDoc.getDocumentElement();		        
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 		        
		return null;
		
	}

	public List getList() {
		return conversionSections;
	}
	
	public void start() {
		currentSectionIndex = -1;
	}
	
	public void next() {
		
		currentSectionIndex++;
		currentSection = null;
		if ((currentSectionIndex >= 0) && (currentSectionIndex < conversionSections.size())) {
			currentSection = conversionSections.get(currentSectionIndex);
		}
		
	}
	
	public ConversionSectionWrapper getCurrentSection() {
		
		if (currentSection != null) 
			return currentSection;
		if (currentSectionIndex < 0) {
			throw new IllegalArgumentException("Trying to access a section, but moveNext wasn't called");
		}
		else if (currentSectionIndex >= conversionSections.size()) {
			throw new IllegalArgumentException("Trying to access more sections than avaiable");
		}
		else {
			throw new IllegalArgumentException("There is no current section"); //?????
		}
	}
	
	public ConversionSectionWrapper peekNextSection() {
		
		int nextSectionIndex=currentSectionIndex+1; 
		if ((nextSectionIndex >= 0) && (nextSectionIndex < conversionSections.size())) {
			return conversionSections.get(nextSectionIndex);
		} else {
			return null;
		}
		
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy