cvs commit: xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc RtfExternalGraphic.java

2003-07-02 Thread vmote
vmote   2003/07/02 12:26:36

  Modified:src/java/org/apache/fop/rtf/rtflib/rtfdoc
RtfExternalGraphic.java
  Log:
  style changes only, mostly javadoc comments
  
  Revision  ChangesPath
  1.9   +11 -7 
xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
  
  Index: RtfExternalGraphic.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RtfExternalGraphic.java   2 Jul 2003 19:20:45 -   1.8
  +++ RtfExternalGraphic.java   2 Jul 2003 19:26:35 -   1.9
  @@ -178,6 +178,7 @@
*
* @param container a RtfContainer value
* @param writer a Writer value
  + * @throws IOException for I/O problems
*/
   public RtfExternalGraphic(RtfContainer container, Writer writer) throws 
IOException {
   super (container, writer);
  @@ -189,6 +190,7 @@
* @param container a RtfContainer value
* @param writer a Writer value
* @param attributes a RtfAttributes value
  + * @throws IOException for I/O problems
*/
   public RtfExternalGraphic(RtfContainer container, Writer writer,
   RtfAttributes attributes) throws IOException {
  @@ -200,8 +202,10 @@
   // @@ RtfElement implementation
   //
   
  -/** RtfElement override - catches ExternalGraphicException and writes a 
warning
  - *  message to the document if image cannot be read
  +/**
  + * RtfElement override - catches ExternalGraphicException and writes a 
warning
  + * message to the document if image cannot be read
  + * @throws IOException for I/O problems
*/
   protected void writeRtfContent() throws IOException {
   try {
  @@ -494,9 +498,7 @@
* Sets the compression rate for the image in percent.
*
* @param percent Compression rate
  - * @return
  - *  true:   The compression rate is valid (0..100)\n
  - *  false:  The compression rate is invalid
  + * @return true if the compression rate is valid (0..100), false if invalid
*/
   public boolean setCompressionRate (int percent) {
   if (percent < 1 || percent > 100) {
  @@ -622,7 +624,9 @@
   return type;
   }
   
  -/** true if this element would generate no "useful" RTF content */
  +/**
  + * @return true if this element would generate no "useful" RTF content
  + */
   public boolean isEmpty() {
   return url == null;
   }
  
  
  

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



cvs commit: xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc RtfExternalGraphic.java

2003-07-02 Thread vmote
vmote   2003/07/02 12:20:45

  Modified:src/java/org/apache/fop/rtf/rtflib/rtfdoc
RtfExternalGraphic.java
  Log:
  Extract computeImageSize and writeSizeInfo methods (to reduce size of 
writeRtfContentWithException for checkstyle). Compiles but untested.
  
  Revision  ChangesPath
  1.8   +42 -31
xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
  
  Index: RtfExternalGraphic.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RtfExternalGraphic.java   2 Jul 2003 16:59:54 -   1.7
  +++ RtfExternalGraphic.java   2 Jul 2003 19:20:45 -   1.8
  @@ -161,6 +161,11 @@
*/
protected int graphicCompressionRate = 80;
   
  + /** The image data */
  + private byte[] data = null;
  +
  + /** The image type */
  + private int type;
   
   //
   // @@ Construction
  @@ -236,7 +241,7 @@
   //getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");
   
   
  -byte[] data = null;
  +data = null;
   try {
   // image reading patch provided by Michael Krause <[EMAIL PROTECTED]>
   final BufferedInputStream bin = new 
BufferedInputStream(url.openStream());
  @@ -262,7 +267,7 @@
   
   // Determine image file format
   String file = url.getFile ();
  -int type = determineImageType(data, file.substring(file.lastIndexOf(".") + 
1));
  +type = determineImageType(data, file.substring(file.lastIndexOf(".") + 1));
   
   if (type >= ImageConstants.I_TO_CONVERT_BASIS) {
   // convert
  @@ -311,6 +316,38 @@
   
   writeControlWord(rtfImageCode);
   
  +computeImageSize();
  +writeSizeInfo();
  +
  +for (int i = 0; i < data.length; i++) {
  +int iData = data [i];
  +
  +// Make positive byte
  +if (iData < 0) {
  +iData += 256;
  +}
  +
  +if (iData < 16) {
  +// Set leading zero and append
  +buf.append('0');
  +}
  +
  +buf.append(Integer.toHexString(iData));
  +}
  +
  +int len = buf.length();
  +char[] chars = new char[len];
  +
  +buf.getChars(0, len, chars, 0);
  +writer.write(chars);
  +
  +// Writes the end of RTF image
  +
  +writeGroupMark(false);
  +writeGroupMark(false);
  +}
  +
  +private void computeImageSize () {
   if (type == ImageConstants.I_PNG) {
   width = ImageUtil.getIntFromByteArray(data, 16, 4, true);
   height = ImageUtil.getIntFromByteArray(data, 20, 4, true);
  @@ -342,7 +379,9 @@
   width = ImageUtil.getIntFromByteArray(data, 151, 4, false);
   height = ImageUtil.getIntFromByteArray(data, 155, 4, false);
   }
  +}
   
  +private void writeSizeInfo () throws IOException {
   // Set image size
   if (width != -1) {
   writeControlWord("picw" + width);
  @@ -382,35 +421,7 @@
   writeControlWord("picscaley" + widthDesired * 100 / width);
   }
   }
  -
  -for (int i = 0; i < data.length; i++) {
  -int iData = data [i];
  -
  -// Make positive byte
  -if (iData < 0) {
  -iData += 256;
  -}
  -
  -if (iData < 16) {
  -// Set leading zero and append
  -buf.append('0');
  -}
  -
  -buf.append(Integer.toHexString(iData));
  -}
  -
  -int len = buf.length();
  -char[] chars = new char[len];
  -
  -buf.getChars(0, len, chars, 0);
  -writer.write(chars);
  -
  -// Writes the end of RTF image
  -
  -writeGroupMark(false);
  -writeGroupMark(false);
   }
  -
   
   //
   // @@ Member access
  
  
  

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