CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfHeader.java,1.5,1.6 RtfTemplate.java,1.1,1.2

Bertrand Delacretaz <[email protected]> Wed, 05 Jun 2002 09:40:31 -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-serv10530/src/org/jfor/jfor/rtflib/rtfdoc

Modified Files:
	RtfHeader.java RtfTemplate.java 
Log Message:
RtfTemplate does not check for template existence

Index: RtfHeader.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc/RtfHeader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RtfHeader.java	5 Jun 2002 14:17:40 -0000	1.5
--- RtfHeader.java	5 Jun 2002 16:40:29 -0000	1.6
***************
*** 38,41 ****
--- 38,44 ----
  // $Id$
  // $Log$
+ // Revision 1.6  2002/06/05 16:40:29  bdelacretaz
+ // RtfTemplate does not check for template existence
+ //
  // Revision 1.5  2002/06/05 14:17:40  rmarra
  // write template
***************
*** 113,116 ****
--- 116,124 ----
      void write(String toWrite) throws IOException {
          m_writer.write(toWrite);
+     }
+     
+     /** write to our Writer using an RtfStringConverter */
+     void writeRtfString(String toWrite) throws IOException {
+ 	    RtfStringConverter.getInstance().writeRtfString(m_writer,toWrite);
      }
  }

Index: RtfTemplate.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc/RtfTemplate.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RtfTemplate.java	5 Jun 2002 14:16:05 -0000	1.1
--- RtfTemplate.java	5 Jun 2002 16:40:29 -0000	1.2
***************
*** 73,100 ****
  	 **/
  	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
--- 73,84 ----
  	 **/
  	public void setTemplateFilePath(String templateFilePath) throws IOException {
! 		// no validity checks here - leave this to the RTF client
! 		if(templateFilePath == null) {
! 			this.templateFilePath = null;
! 		} else {
! 			this.templateFilePath = templateFilePath.trim();
  		}
  	}
  
  	/**
  	 * Write the rtf template
***************
*** 104,112 ****
  	public void writeTemplate (RtfHeader header) throws IOException
  	{
! 		if (templateFilePath == null) return;
  		
  		header.writeGroupMark (true);
  		header.writeControlWord ("template");
! 		header.write(this.templateFilePath);
  		header.writeGroupMark (false);
  		
--- 88,96 ----
  	public void writeTemplate (RtfHeader header) throws IOException
  	{
! 		if (templateFilePath == null || templateFilePath.length() == 0) return;
  		
  		header.writeGroupMark (true);
  		header.writeControlWord ("template");
! 		header.writeRtfString(this.templateFilePath);
  		header.writeGroupMark (false);
  		
***************
*** 115,120 ****
  		header.writeGroupMark (false);
  	}
-  
- 
  }
  
--- 99,102 ----


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm