cvs commit: xml-fop/src/java/org/apache/fop/pdf PDFObject.java

2004-08-23 Thread jeremias
jeremias2004/08/23 12:23:30

  Modified:src/java/org/apache/fop/pdf PDFObject.java
  Log:
  Rewrite formatDateTime() to be compatible with JDK 1.3 again.
  
  Revision  ChangesPath
  1.7   +43 -4 xml-fop/src/java/org/apache/fop/pdf/PDFObject.java
  
  Index: PDFObject.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFObject.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PDFObject.java23 Apr 2004 03:05:11 -  1.6
  +++ PDFObject.java23 Aug 2004 19:23:30 -  1.7
  @@ -22,7 +22,9 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.text.SimpleDateFormat;
  +import java.util.Calendar;
   import java.util.Date;
  +import java.util.TimeZone;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -219,7 +221,7 @@
   
   /** Formatting pattern for PDF date */
   protected static final SimpleDateFormat DATE_FORMAT 
  -= new SimpleDateFormat('D:'MMddHHmmssZ);
  += new SimpleDateFormat('D:'MMddHHmmss);
   
   /**
* Formats a date/time according to the PDF specification 
  @@ -228,9 +230,46 @@
* @return the requested String representation
*/
   protected String formatDateTime(Date time) {
  -String s = DATE_FORMAT.format(time);
  -int i = s.length() - 2;
  -return s.substring(0, i) + ' + s.substring(i) + ';
  +StringBuffer sb = new StringBuffer();
  +sb.append(DATE_FORMAT.format(time));
  +TimeZone tz = TimeZone.getDefault();
  +Calendar cal = Calendar.getInstance();
  +cal.setTime(time);
  +
  +int era = cal.get(Calendar.ERA);
  +int year = cal.get(Calendar.YEAR);
  +int month = cal.get(Calendar.MONTH);
  +int day = cal.get(Calendar.DAY_OF_MONTH);
  +int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
  +int milliseconds = cal.get(Calendar.HOUR_OF_DAY) * 1000 * 60 * 60;
  +milliseconds += cal.get(Calendar.MINUTE) * 1000 * 60;
  +milliseconds += cal.get(Calendar.SECOND) * 1000;
  +milliseconds += cal.get(Calendar.MILLISECOND);
  +
  +int offset = tz.getOffset(era, year, month, day, dayOfWeek, milliseconds);
  +if (offset == 0) {
  +sb.append('Z');
  +} else {
  +if (offset  0) {
  +sb.append('+');
  +} else {
  +sb.append('-');
  +}
  +final int HOUR = (1000 * 60 * 60);
  +int offsetHour = Math.abs(offset / HOUR);
  +int offsetMinutes = (offset - (offsetHour * HOUR)) / (1000 * 60);
  +if (offsetHour  10) {
  +sb.append('0');
  +}
  +sb.append(Integer.toString(offsetHour));
  +sb.append('\'');
  +if (offsetMinutes  10) {
  +sb.append('0');
  +}
  +sb.append(Integer.toString(offsetMinutes));
  +sb.append('\'');
  +}
  +return sb.toString();
   }
   
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/fo/flow MultiCase.java MultiProperties.java MultiPropertySet.java MultiSwitch.java MultiToggle.java TableAndCaption.java TableCaption.java

2004-08-23 Thread gmazza
gmazza  2004/08/23 15:09:20

  Modified:src/java/org/apache/fop/fo/flow MultiCase.java
MultiProperties.java MultiPropertySet.java
MultiSwitch.java MultiToggle.java
TableAndCaption.java TableCaption.java
  Removed: src/java/org/apache/fop/fo ToBeImplementedElement.java
  Log:
  ToBeImplementedElement removed in favor of one-time static warning messages
  in the unimplemented FO's.
  
  Revision  ChangesPath
  1.14  +10 -4 xml-fop/src/java/org/apache/fop/fo/flow/MultiCase.java
  
  Index: MultiCase.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiCase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MultiCase.java21 Aug 2004 19:48:00 -  1.13
  +++ MultiCase.java23 Aug 2004 22:09:20 -  1.14
  @@ -20,19 +20,25 @@
   
   // FOP
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.ToBeImplementedElement;
  +import org.apache.fop.fo.FObj;
   
   /**
  - * Class modelling the fo:multi-case object. See Sec. 6.9.4 of the XSL-FO
  - * Standard.
  + * Class modelling the fo:multi-case object.
*/
  -public class MultiCase extends ToBeImplementedElement {
  +public class MultiCase extends FObj {
  +
  +static boolean notImplementedWarningGiven = false;
   
   /**
* @param parent FONode that is the parent of this object
*/
   public MultiCase(FONode parent) {
   super(parent);
  +
  +if (!notImplementedWarningGiven) {
  +getLogger().warn(fo:multi-case is not yet implemented.);
  +notImplementedWarningGiven = true;
  +}
   }
   
   /**
  
  
  
  1.13  +1 -2  xml-fop/src/java/org/apache/fop/fo/flow/MultiProperties.java
  
  Index: MultiProperties.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiProperties.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MultiProperties.java  21 Aug 2004 19:48:00 -  1.12
  +++ MultiProperties.java  23 Aug 2004 22:09:20 -  1.13
  @@ -28,8 +28,7 @@
   import org.apache.fop.fo.FObj;
   
   /**
  - * Class modelling the fo:multi-properties object. See Sec. 6.9.6 of the XSL-FO
  - * Standard.
  + * Class modelling the fo:multi-properties object.
*/
   public class MultiProperties extends FObj {
   
  
  
  
  1.13  +10 -4 xml-fop/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
  
  Index: MultiPropertySet.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiPropertySet.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MultiPropertySet.java 11 Aug 2004 04:15:26 -  1.12
  +++ MultiPropertySet.java 23 Aug 2004 22:09:20 -  1.13
  @@ -25,19 +25,25 @@
   
   // FOP
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.ToBeImplementedElement;
  +import org.apache.fop.fo.FObj;
   
   /**
  - * Class modelling the fo:multi-property-set object. See Sec. 6.9.7 of the
  - * XSL-FO Standard.
  + * Class modelling the fo:multi-property-set object.
*/
  -public class MultiPropertySet extends ToBeImplementedElement {
  +public class MultiPropertySet extends FObj {
  +
  +static boolean notImplementedWarningGiven = false;
   
   /**
* @param parent FONode that is the parent of this object
*/
   public MultiPropertySet(FONode parent) {
   super(parent);
  +
  +if (!notImplementedWarningGiven) {
  +getLogger().warn(fo:multi-property-set is not yet implemented.);
  +notImplementedWarningGiven = true;
  +}
   }
   
   /**
  
  
  
  1.13  +13 -4 xml-fop/src/java/org/apache/fop/fo/flow/MultiSwitch.java
  
  Index: MultiSwitch.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiSwitch.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MultiSwitch.java  11 Aug 2004 04:15:26 -  1.12
  +++ MultiSwitch.java  23 Aug 2004 22:09:20 -  1.13
  @@ -20,21 +20,30 @@
   
   // FOP
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.ToBeImplementedElement;
  +import org.apache.fop.fo.FObj;
   
   /**
  - * Class modelling the fo:multi-switch object. See Sec. 6.9.3 of the XSL-FO
  - * Standard.
  + * Class modelling the fo:multi-switch object.
*/
  -public class MultiSwitch extends ToBeImplementedElement {
  +public class MultiSwitch extends FObj {
  +
  +static boolean notImplementedWarningGiven = false;
   
   /**
* @param parent FONode that is the parent of this object