CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfTemplate.java,NONE,1.1 IrtfTemplateContainer.java,NONE,1.1
Marra Roberto <[email protected]> Wed, 05 Jun 2002 07:16:08 -0700
| Newsgroups | gmane.text.xml.jfor.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc In directory usw-pr-cvs1:/tmp/cvs-serv23548 Added Files: RtfTemplate.java IrtfTemplateContainer.java Log Message: initial checkin --- NEW FILE: RtfTemplate.java --- package org.jfor.jfor.rtflib.rtfdoc; import java.util.*; import java.io.Writer; import java.io.IOException; import java.io.File; /*----------------------------------------------------------------------------- * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the contents of this java source file, as distributed * on www.sourceforge.net/projects/jfor and/or www.jfor.org. * * The Initial Developer of the Original Code is Andreas Putz, skynamics AG, * München, Germany, [email protected]. * Portions created by Andreas Putz are Copyright (C) 2001 skynamics AG, München, * Andreas Putz. All Rights Reserved. * * Contributor(s): -----------------------------------------------------------------------------*/ /** * Singelton of the RTF style template * This class belongs to the <jfor:style-template> tag processing. */ public class RtfTemplate { /** Singelton instance */ private static RtfTemplate instance = null; private String templateFilePath = null; /** * Constructor. */ private RtfTemplate () { } /** * Singelton. * * @return The instance of RtfTemplate */ public static RtfTemplate getInstance () { if (instance == null) { instance = new RtfTemplate(); } return instance; } /** *Set the template file and adjust tha path separator * *@param templateFilePath The full path of the template **/ public void setTemplateFilePath(String templateFilePath) throws IOException { if(templateFilePath==null) throw new IOException("Error template file is null"); File f = new File(templateFilePath); if(!f.exists()) throw new IOException("Error template file not found: "+templateFilePath); StringTokenizer st = new StringTokenizer(templateFilePath,File.separator,false); StringBuffer sb = new StringBuffer(); while(st.hasMoreTokens()) { sb.append(st.nextToken()); if (st.hasMoreTokens()) { sb.append(File.separator); sb.append(File.separator); } } this.templateFilePath = sb.toString(); } /** * Write the rtf template * @param header Rtf header is the parent * @throws IOException On write error */ public void writeTemplate (RtfHeader header) throws IOException { if (templateFilePath == null) return; header.writeGroupMark (true); header.writeControlWord ("template"); header.write(this.templateFilePath); header.writeGroupMark (false); header.writeGroupMark (true); header.writeControlWord ("linkstyles"); header.writeGroupMark (false); } } --- NEW FILE: IrtfTemplateContainer.java --- package org.jfor.jfor.rtflib.rtfdoc; import java.io.IOException; /*----------------------------------------------------------------------------- * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the contents of this java source file, as distributed * on www.sourceforge.net/projects/jfor and/or www.jfor.org. * * The Initial Developer of the Original Code is Andreas Putz, skynamics AG, * München, Germany, [email protected]. * Portions created by Andreas Putz are Copyright (C) 2001 skynamics AG, München, * Andreas Putz. All Rights Reserved. * * Contributor(s): -----------------------------------------------------------------------------*/ public interface IrtfTemplateContainer { /** * Creates a new Template. * * @exception IOException on error */ public RtfTemplate newTemplate (String str, RtfAttributes attr) throws IOException; } _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm