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

word.w2004.Footer2004 Maven / Gradle / Ivy

The newest version!
package word.w2004;

import word.api.interfaces.IElement;
import word.api.interfaces.IFooter;

public class Footer2004 implements IFooter{
	
	StringBuilder txt = new StringBuilder("");
	private boolean hasBeenCalledBefore = false; // if getContent has already been called, I cached the result for future invocations
	private boolean showPageNumber = true;
	
	public void addEle(IElement e) {
		this.txt.append("\n" + e.getContent());
	}

	public void addEle(String str) {
		this.txt.append("\n" + str);		
	}

	public String getContent() {
		if("".equals(txt.toString())){
			return "";
		}
		if(hasBeenCalledBefore ){
			return txt.toString();	
		}else{
			hasBeenCalledBefore = true;
		}
		
		txt.insert(0, HEADER_TOP);
		if(showPageNumber){
			txt.append(PAGE_NUMBER);
		}	
		txt.append(HEADER_BOTTON);
		
		return txt.toString();
	}
	
	public void showPageNumber(boolean value){
		this.showPageNumber  = value;
	}
	
	private static String HEADER_TOP = "\n	";
	private static String HEADER_BOTTON = "\n	";
	private static String PAGE_NUMBER = 
		"\n                 "
		+"\n                     "
		+"\n                         "
		+"\n                     "
		+"\n                     "
		+"\n                         "
		+"\n                             "
		+"\n                             "
		+"\n                             "
		+"\n                                 "
		+"\n                             "
		+"\n                         "
		+"\n                         "
		+"\n                             "
		+"\n                                 "
		+"\n                             "
		+"\n                             "
		+"\n                         "
		+"\n                         "
		+"\n                             "
		+"\n                                 "
		+"\n                             "
		+"\n                            PAGE   "
		+"\n                         "
		+"\n                         "
		+"\n                             "
		+"\n                                 "
		+"\n                             "
		+"\n                             "
		+"\n                         "
		+"\n                         "
		+"\n                             "
		+"\n                                 "
		+"\n                                 "
		+"\n                             "
		+"\n                            2 "
		+"\n                         "
		+"\n                         "
		+"\n                             "
		+"\n                                 "
		+"\n                             "
		+"\n                             "
		+"\n                         "
		+"\n                     "
		+"\n                 \n"		
		;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy