You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2003/04/17 18:00:00 UTC

cvs commit: xml-fop/src/org/apache/fop/render/ps PSRenderer.java

jeremias    2003/04/17 08:59:59

  Modified:    src/org/apache/fop/render/ps Tag: fop-0_20_2-maintain
                        PSRenderer.java
  Log:
  Ported the auto-rotate-landscape functionality from HEAD.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.16 +44 -14    xml-fop/src/org/apache/fop/render/ps/Attic/PSRenderer.java
  
  Index: PSRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/Attic/PSRenderer.java,v
  retrieving revision 1.15.2.15
  retrieving revision 1.15.2.16
  diff -u -r1.15.2.15 -r1.15.2.16
  --- PSRenderer.java	2 Mar 2003 16:55:18 -0000	1.15.2.15
  +++ PSRenderer.java	17 Apr 2003 15:59:58 -0000	1.15.2.16
  @@ -3,34 +3,34 @@
    * ============================================================================
    *                    The Apache Software License, Version 1.1
    * ============================================================================
  - * 
  + *
    * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without modifica-
    * tion, are permitted provided that the following conditions are met:
  - * 
  + *
    * 1. Redistributions of source code must retain the above copyright notice,
    *    this list of conditions and the following disclaimer.
  - * 
  + *
    * 2. Redistributions in binary form must reproduce the above copyright notice,
    *    this list of conditions and the following disclaimer in the documentation
    *    and/or other materials provided with the distribution.
  - * 
  + *
    * 3. The end-user documentation included with the redistribution, if any, must
    *    include the following acknowledgment: "This product includes software
    *    developed by the Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself, if
    *    and wherever such third-party acknowledgments normally appear.
  - * 
  + *
    * 4. The names "FOP" and "Apache Software Foundation" must not be used to
    *    endorse or promote products derived from this software without prior
    *    written permission. For written permission, please contact
    *    apache@apache.org.
  - * 
  + *
    * 5. Products derived from this software may not be called "Apache", nor may
    *    "Apache" appear in their name, without prior written permission of the
    *    Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  @@ -42,12 +42,12 @@
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ============================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many individuals
    * on behalf of the Apache Software Foundation and was originally created by
    * James Tauber <jt...@jtauber.com>. For more information on the Apache
    * Software Foundation, please see <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.fop.render.ps;
   
   // FOP
  @@ -130,6 +130,7 @@
       int pagecount = 0;
   
       private boolean enableComments = true;
  +    private boolean autoRotateLandscape = false;
   
       /**
        * the stream used to output the PostScript
  @@ -191,6 +192,13 @@
           return this.psLevel;
       }
   
  +    public void setAutoRotateLandscape(boolean value) {
  +        this.autoRotateLandscape = value;
  +    }
  +
  +    public boolean isAutoRotateLandscape() {
  +        return this.autoRotateLandscape;
  +    }
   
       /**
        * write out a command
  @@ -845,12 +853,34 @@
           this.idReferences = page.getIDReferences();
   
           write("%%Page: " + page.getNumber() + " " + page.getNumber());
  -        write("%%PageBoundingBox: 0 0 " +
  -                Math.round(page.getWidth() / 1000f) + " " +
  -                Math.round(page.getHeight() / 1000f));
  +
  +        final long pagewidth = page.getWidth();
  +        final long pageheight = page.getHeight();
  +        final double pspagewidth = pagewidth / 1000f;
  +        final double pspageheight = pageheight / 1000f;
  +        boolean rotate = false;
  +        if (isAutoRotateLandscape() && (pageheight < pagewidth)) {
  +            rotate = true;
  +            write("%%PageBoundingBox: 0 0 " +
  +                    Math.round(pspageheight) + " " +
  +                    Math.round(pspagewidth));
  +            write("%%PageOrientation: Landscape");
  +        } else {
  +            write("%%PageBoundingBox: 0 0 " +
  +                    Math.round(pspagewidth) + " " +
  +                    Math.round(pspageheight));
  +            if (isAutoRotateLandscape()) {
  +                write("%%PageOrientation: Portrait");
  +            }
  +        }
  +
           write("%%BeginPageSetup");
           write("FOPprocs begin");
           write("FOPFonts begin");
  +        if (rotate) {
  +            write(Math.round(pspageheight) + " 0 translate");
  +            write("90 rotate");
  +        }
           write("0.001 0.001 scale");
           write("%%EndPageSetup");
           renderRegions(page);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org