You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2008/10/12 12:25:59 UTC

svn commit: r703778 - in /poi/branches/ooxml/src: examples/src/org/apache/poi/xssf/usermodel/examples/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/

Author: yegor
Date: Sun Oct 12 03:25:58 2008
New Revision: 703778

URL: http://svn.apache.org/viewvc?rev=703778&view=rev
Log:
applied patch #45967 by Gisella Bronzetti: support for XSSFPrintSetup object

Added:
    poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java   (with props)
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java   (with props)
Removed:
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorksheet.java
Modified:
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintSetup.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java

Added: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java (added)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,31 @@
+package org.apache.poi.xssf.usermodel.examples;
+
+import java.io.FileOutputStream;
+
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+public class FitSheetToOnePage {
+
+
+    public static void main(String[]args) throws Exception{
+	Workbook wb = new XSSFWorkbook();
+	Sheet sheet = wb.createSheet("format sheet");
+	PrintSetup ps = sheet.getPrintSetup();
+
+	sheet.setAutobreaks(true);
+
+	ps.setFitHeight((short)1);
+	ps.setFitWidth((short)1);
+
+
+	// Create various cells and rows for spreadsheet.
+
+	FileOutputStream fileOut = new FileOutputStream("fitSheetToOnePage.xlsx");
+	wb.write(fileOut);
+	fileOut.close();
+
+    }
+}

Propchange: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintSetup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintSetup.java?rev=703778&r1=703777&r2=703778&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintSetup.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintSetup.java Sun Oct 12 03:25:58 2008
@@ -67,13 +67,7 @@
      */
     void setFitHeight(short height);
 
-    /**    
-     * Sets the options flags.  Not advisable to do it directly.    
-     * @param options The bit flags for the options    
-     */
-    void setOptions(short options);
-
-    /**    
+    /**
      * Set whether to go left to right or top down in ordering    
      * @param ltor left to right    
      */
@@ -182,12 +176,6 @@
     short getFitHeight();
 
     /**    
-     * Returns the bit flags for the options.    
-     * @return bit flags for the options    
-     */
-    short getOptions();
-
-    /**    
      * Returns the left to right print order.    
      * @return left to right print order    
      */

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,65 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPageOrder;
+
+/**
+ * Specifies printed page order.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum PageOrder {
+
+    /**
+     * Order pages vertically first, then move horizontally.
+     */
+    DOWN_THEN_OVER(STPageOrder.DOWN_THEN_OVER),
+    /**
+     * Order pages horizontally first, then move vertically
+     */
+    OVER_THEN_DOWN(STPageOrder.OVER_THEN_DOWN);
+
+
+    private STPageOrder.Enum order;
+
+
+    PageOrder(STPageOrder.Enum order) {
+        this.order = order;
+    }
+
+    /**
+     * Returns value of pages order
+     *
+     * @return String value of pages order
+     */
+    public STPageOrder.Enum getValue() {
+        return order;
+    }
+
+
+    public static PageOrder valueOf(STPageOrder.Enum pageOrder) {
+        switch (pageOrder.intValue()) {
+            case STPageOrder.INT_DOWN_THEN_OVER:
+                return DOWN_THEN_OVER;
+            case STPageOrder.INT_OVER_THEN_DOWN:
+                return OVER_THEN_DOWN;
+        }
+        throw new RuntimeException("PageOrder value [" + pageOrder + "] not supported");
+    }
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,44 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+/**
+ *  The enumeration value indicating the possible paper size for a sheet
+ *
+ * @author Daniele Montagni
+ */
+public enum PaperSize {
+    LETTER_PAPER,
+    LETTER_SMALL_PAPER,
+    TABLOID_PAPER,
+    LEDGER_PAPER,
+    LEGAL_PAPER,
+    STATEMENT_PAPER,
+    EXECUTIVE_PAPER,
+    A3_PAPER,
+    A4_PAPER,
+    A4_SMALL_PAPER,
+    A5_PAPER,
+    B4_PAPER,
+    B5_PAPER,
+    FOLIO_PAPER,
+    QUARTO_PAPER,
+    STANDARD_PAPER_10_14,
+    STANDARD_PAPER_11_17;
+    
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,73 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellComments;
+
+/**
+ * These enumerations specify how cell comments shall be displayed for paper printing purposes.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum PrintCellComments {
+
+    /**
+     * Do not print cell comments.
+     */
+    NONE(STCellComments.NONE),
+    /**
+     * Print cell comments as displayed.
+     */
+    AS_DISPLAYED(STCellComments.AS_DISPLAYED),
+    /**
+     * Print cell comments at end of document.
+     */
+    AT_END(STCellComments.AT_END);
+
+
+    private STCellComments.Enum comments;
+
+
+    PrintCellComments(STCellComments.Enum comments) {
+        this.comments = comments;
+    }
+
+
+    /**
+     * Returns comments of cell
+     *
+     * @return String comments of cell
+     */
+    public STCellComments.Enum getValue() {
+        return comments;
+    }
+
+
+    public static PrintCellComments valueOf(STCellComments.Enum cellComment) {
+        switch (cellComment.intValue()) {
+            case STCellComments.INT_AS_DISPLAYED:
+                return AS_DISPLAYED;
+            case STCellComments.INT_AT_END:
+                return AT_END;
+            case STCellComments.INT_NONE:
+                return NONE;
+        }
+        throw new RuntimeException("PrintCellComments: value [" + cellComment + "] not supported");
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,77 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STOrientation;
+
+/**
+ * The enumeration value indicating the print orientation for a sheet.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum PrintOrientation {
+
+    /**
+     * orientation not specified
+     */
+    DEFAULT(STOrientation.DEFAULT),
+    /**
+     * portrait orientation
+     */
+    PORTRAIT(STOrientation.PORTRAIT),
+    /**
+     * landscape orientations
+     */
+    LANDSCAPE(STOrientation.LANDSCAPE);
+
+
+    private STOrientation.Enum orientation;
+
+
+    PrintOrientation(STOrientation.Enum orientation) {
+        this.orientation = orientation;
+    }
+
+
+    /**
+     * Returns value of the orientation
+     *
+     * @return String value of the orientation
+     */
+    public STOrientation.Enum getValue() {
+        return orientation;
+    }
+
+
+    public static PrintOrientation valueOf(STOrientation.Enum orient) {
+        switch (orient.intValue()) {
+            case STOrientation.INT_DEFAULT:
+                return DEFAULT;
+            case STOrientation.INT_LANDSCAPE:
+                return LANDSCAPE;
+            case STOrientation.INT_PORTRAIT:
+                return PORTRAIT;
+                /*
+        default:
+            return DEFAULT;
+            */
+        }
+        throw new RuntimeException("Orientation value [" + orient + "] not supported");
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java?rev=703778&r1=703777&r2=703778&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java Sun Oct 12 03:25:58 2008
@@ -17,7 +17,7 @@
 package org.apache.poi.xssf.usermodel;
 
 /**
- * All know type of automatic shapes in DrawingML
+ * All known types of automatic shapes in DrawingML
  *
  * @author Yegor Kozlov
  */

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java?rev=703778&r1=703777&r2=703778&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java Sun Oct 12 03:25:58 2008
@@ -45,7 +45,7 @@
     /**
      * Create a new SpreadsheetML drawing
      *
-     * @see org.apache.poi.xssf.usermodel.XSSFWorksheet#createDrawingPatriarch()
+     * @see org.apache.poi.xssf.usermodel.XSSFSheet#createDrawingPatriarch()
      */
     public XSSFDrawing() {
         super(null, null);

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,455 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+
+
+/**
+ * Page setup and page margins settings for the worksheet.
+ */
+public class XSSFPrintSetup implements PrintSetup {
+
+    private CTWorksheet ctWorksheet;
+    private CTPageSetup pageSetup;
+    private CTPageMargins pageMargins;
+
+
+    public XSSFPrintSetup(CTWorksheet worksheet) {
+        if (worksheet == null) throw new NullPointerException("");
+        this.ctWorksheet = worksheet;
+        this.pageSetup = ctWorksheet.getPageSetup() == null ? ctWorksheet.addNewPageSetup() : ctWorksheet.getPageSetup();
+        this.pageMargins = ctWorksheet.getPageMargins() == null ? ctWorksheet.addNewPageMargins() : ctWorksheet.getPageMargins();
+    }
+
+    public XSSFPrintSetup(XSSFSheet sheet) {
+        this(sheet.getWorksheet());
+    }
+
+    public XSSFPrintSetup(CTPageSetup pageSetup, CTPageMargins pageMargins) {
+        this.pageMargins = pageMargins;
+        this.pageSetup = pageSetup;
+    }
+
+
+    /**
+     * Set the paper size.
+     *
+     * @param size the paper size.
+     */
+    public void setPaperSize(short size) {
+        pageSetup.setPaperSize(size);
+    }
+
+    /**
+     * Set the paper size as enum value.
+     *
+     * @param size value for the paper size.
+     */
+    public void setPaperSize(PaperSize size) {
+        setPaperSize((short) (size.ordinal() + 1));
+    }
+
+    /**
+     * Set the scale.
+     * Valid values range from 10 to 400.
+     * This setting is overridden when fitToWidth and/or fitToHeight are in use
+     *
+     * @param scale the scale to use
+     */
+    public void setScale(short scale) {
+        if (scale < 10 || scale > 400) throw new RuntimeException("Scale value not accepted: you must choose a value between 10 and 400.");
+        pageSetup.setScale(scale);
+    }
+
+    /**
+     * Set the page numbering start.
+     * Page number for first printed page. If no value is specified, then 'automatic' is assumed.
+     *
+     * @param start the page numbering start
+     */
+    public void setPageStart(short start) {
+        pageSetup.setFirstPageNumber(start);
+    }
+
+    /**
+     * Set the number of pages wide to fit the sheet in
+     *
+     * @param width the number of pages
+     */
+    public void setFitWidth(short width) {
+        pageSetup.setFitToWidth(width);
+    }
+
+    /**
+     * Set the number of pages high to fit the sheet in
+     *
+     * @param height the number of pages
+     */
+    public void setFitHeight(short height) {
+        pageSetup.setFitToHeight(height);
+    }
+
+    /**
+     * Set whether to go left to right or top down in ordering
+     *
+     * @param ltor left to right
+     */
+    public void setLeftToRight(boolean ltor) {
+        if (ltor)
+            setPageOrder(PageOrder.OVER_THEN_DOWN);
+    }
+
+    /**
+     * Set whether to print in landscape
+     *
+     * @param ls landscape
+     */
+    public void setLandscape(boolean ls) {
+        if (ls)
+            setOrientation(PrintOrientation.LANDSCAPE);
+    }
+
+    /**
+     * Use the printer's defaults settings for page setup values and don't use the default values
+     * specified in the schema. For example, if dpi is not present or specified in the XML, the
+     * a plication shall not assume 600dpi as specified in the schema as a default and instead
+     * shall let the printer specify the default dpi.
+     *
+     * @param valid Valid
+     */
+    public void setValidSettings(boolean valid) {
+        pageSetup.setUsePrinterDefaults(valid);
+    }
+
+    /**
+     * Set whether it is black and white
+     *
+     * @param mono Black and white
+     */
+    public void setNoColor(boolean mono) {
+        pageSetup.setBlackAndWhite(mono);
+    }
+
+    /**
+     * Set whether it is in draft mode
+     *
+     * @param d draft
+     */
+    public void setDraft(boolean d) {
+        pageSetup.setDraft(d);
+    }
+
+    /**
+     * Print the include notes
+     *
+     * @param printnotes print the notes
+     */
+    public void setNotes(boolean printnotes) {
+        if (printnotes)
+            pageSetup.setCellComments(PrintCellComments.AS_DISPLAYED.getValue());
+    }
+
+    /**
+     * Set no orientation.
+     *
+     * @param orientation Orientation.
+     */
+    public void setNoOrientation(boolean orientation) {
+        if (orientation) {
+            setOrientation(PrintOrientation.DEFAULT);
+        }
+    }
+
+    /**
+     * Set whether to use page start
+     *
+     * @param page Use page start
+     */
+    public void setUsePage(boolean page) {
+        pageSetup.setUseFirstPageNumber(page);
+    }
+
+    /**
+     * Sets the horizontal resolution.
+     *
+     * @param resolution horizontal resolution
+     */
+    public void setHResolution(short resolution) {
+        pageSetup.setHorizontalDpi(resolution);
+    }
+
+    /**
+     * Sets the vertical resolution.
+     *
+     * @param resolution vertical resolution
+     */
+    public void setVResolution(short resolution) {
+        pageSetup.setVerticalDpi(resolution);
+    }
+
+    /**
+     * Sets the header margin.
+     *
+     * @param headermargin header margin
+     */
+    public void setHeaderMargin(double headermargin) {
+        pageMargins.setHeader(headermargin);
+    }
+
+    /**
+     * Sets the footer margin.
+     *
+     * @param footermargin footer margin
+     */
+    public void setFooterMargin(double footermargin) {
+        pageMargins.setFooter(footermargin);
+    }
+
+    /**
+     * Sets the number of copies.
+     *
+     * @param copies number of copies
+     */
+    public void setCopies(short copies) {
+        pageSetup.setCopies(copies);
+    }
+
+    /**
+     * Orientation of the page: landscape - portrait.
+     *
+     * @param orientation - Orientation of the page
+     * @see PrintOrientation
+     */
+    public void setOrientation(PrintOrientation orientation) {
+        pageSetup.setOrientation(orientation.getValue());
+    }
+
+    /**
+     * Orientation of the page: landscape - portrait.
+     *
+     * @return Orientation of the page
+     * @see PrintOrientation
+     */
+    public PrintOrientation getOrientation() {
+        return (pageSetup.getOrientation() == null) ? null : PrintOrientation.valueOf(pageSetup.getOrientation());
+    }
+
+
+    public PrintCellComments getCellComment() {
+        return (pageSetup.getCellComments() == null) ? null : PrintCellComments.valueOf(pageSetup.getCellComments());
+    }
+
+    /**
+     * Set print page order.
+     *
+     * @param pageOrder
+     */
+    public void setPageOrder(PageOrder pageOrder) {
+        pageSetup.setPageOrder(pageOrder.getValue());
+    }
+
+    /**
+     * get print page order.
+     *
+     * @return PageOrder
+     */
+    public PageOrder getPageOrder() {
+        return (pageSetup.getPageOrder() == null) ? null : PageOrder.valueOf(pageSetup.getPageOrder());
+    }
+
+    /**
+     * Returns the paper size.
+     *
+     * @return short - paper size
+     */
+    public short getPaperSize() {
+        return (short) pageSetup.getPaperSize();
+    }
+
+    /**
+     * Returns the paper size as enum.
+     *
+     * @return PaperSize paper size
+     * @see PaperSize
+     */
+    public PaperSize getPaperSizeEnum() {
+        return PaperSize.values()[((int) getPaperSize() - 1)];
+    }
+
+    /**
+     * Returns the scale.
+     *
+     * @return short - scale
+     */
+    public short getScale() {
+        return (short) pageSetup.getScale();
+    }
+
+    /**
+     * Set the page numbering start.
+     * Page number for first printed page. If no value is specified, then 'automatic' is assumed.
+     *
+     * @return page number for first printed page
+     */
+    public short getPageStart() {
+        return (short) pageSetup.getFirstPageNumber();
+    }
+
+    /**
+     * Returns the number of pages wide to fit sheet in.
+     *
+     * @return number of pages wide to fit sheet in
+     */
+    public short getFitWidth() {
+        return (short) pageSetup.getFitToWidth();
+    }
+
+    /**
+     * Returns the number of pages high to fit the sheet in.
+     *
+     * @return number of pages high to fit the sheet in
+     */
+    public short getFitHeight() {
+        return (short) pageSetup.getFitToHeight();
+    }
+
+    /**
+     * Returns the left to right print order.
+     *
+     * @return left to right print order
+     */
+    public boolean getLeftToRight() {
+        return getPageOrder() == PageOrder.OVER_THEN_DOWN;
+    }
+
+    /**
+     * Returns the landscape mode.
+     *
+     * @return landscape mode
+     */
+    public boolean getLandscape() {
+        return getOrientation() == PrintOrientation.LANDSCAPE;
+    }
+
+    /**
+     * Use the printerÕs defaults settings for page setup values and don't use the default values
+     * specified in the schema. For example, if dpi is not present or specified in the XML, the
+     * application shall not assume 600dpi as specified in the schema as a default and instead
+     * shall let the printer specify the default dpi.
+     *
+     * @return valid settings
+     */
+    public boolean getValidSettings() {
+        return pageSetup.getUsePrinterDefaults();
+    }
+
+    /**
+     * Returns the black and white setting.
+     *
+     * @return black and white setting
+     */
+    public boolean getNoColor() {
+        return pageSetup.getBlackAndWhite();
+    }
+
+    /**
+     * Returns the draft mode.
+     *
+     * @return draft mode
+     */
+    public boolean getDraft() {
+        return pageSetup.getDraft();
+    }
+
+    /**
+     * Returns the print notes.
+     *
+     * @return print notes
+     */
+    public boolean getNotes() {
+        return getCellComment() == PrintCellComments.AS_DISPLAYED;
+    }
+
+    /**
+     * Returns the no orientation.
+     *
+     * @return no orientation
+     */
+    public boolean getNoOrientation() {
+        return getOrientation() == PrintOrientation.DEFAULT;
+    }
+
+    /**
+     * Returns the use page numbers.
+     *
+     * @return use page numbers
+     */
+    public boolean getUsePage() {
+        return pageSetup.getUseFirstPageNumber();
+    }
+
+    /**
+     * Returns the horizontal resolution.
+     *
+     * @return horizontal resolution
+     */
+    public short getHResolution() {
+        return (short) pageSetup.getHorizontalDpi();
+    }
+
+    /**
+     * Returns the vertical resolution.
+     *
+     * @return vertical resolution
+     */
+    public short getVResolution() {
+        return (short) pageSetup.getVerticalDpi();
+    }
+
+    /**
+     * Returns the header margin.
+     *
+     * @return header margin
+     */
+    public double getHeaderMargin() {
+        return pageMargins.getHeader();
+    }
+
+    /**
+     * Returns the footer margin.
+     *
+     * @return footer margin
+     */
+    public double getFooterMargin() {
+        return pageMargins.getFooter();
+    }
+
+    /**
+     * Returns the number of copies.
+     *
+     * @return number of copies
+     */
+    public short getCopies() {
+        return (short) pageSetup.getCopies();
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=703778&r1=703777&r2=703778&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Oct 12 03:25:58 2008
@@ -22,6 +22,7 @@
 import java.util.*;
 import javax.xml.namespace.QName;
 
+import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.hssf.util.PaneInformation;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.CommentsSource;
@@ -699,9 +700,8 @@
         return counter;
     }
 
-    public PrintSetup getPrintSetup() {
-        // TODO Auto-generated method stub
-        return null;
+    public XSSFPrintSetup getPrintSetup() {
+        return new XSSFPrintSetup(getWorksheet());
     }
 
     public boolean getProtect() {

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java?rev=703778&r1=703777&r2=703778&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java Sun Oct 12 03:25:58 2008
@@ -54,6 +54,7 @@
 		result.addTestSuite(TestXSSFWorkbook.class);
 				
 		result.addTestSuite(TestXSSFFont.class);
+		result.addTestSuite(TestXSSFPrintSetup.class);
 
 		return result;
 	}

Added: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java?rev=703778&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java (added)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java Sun Oct 12 03:25:58 2008
@@ -0,0 +1,209 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (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.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import junit.framework.TestCase;
+
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STOrientation;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPageOrder;
+
+/**
+ * Tests for {@link XSSFPrintSetup}
+ *
+ */
+public class TestXSSFPrintSetup extends TestCase {
+
+
+    public void testConstructor(){
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	CTPageMargins pMargins=CTPageMargins.Factory.newInstance();
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, pMargins);
+	assertNotNull(printSetup);
+
+	XSSFWorkbook wb=new XSSFWorkbook();
+	printSetup=new XSSFPrintSetup(wb.createSheet());
+	assertNotNull(printSetup);
+    }
+
+    public void testSetGetPaperSize() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setPaperSize(9);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(PaperSize.A4_PAPER,printSetup.getPaperSizeEnum());
+	assertEquals(9,printSetup.getPaperSize());
+
+	printSetup.setPaperSize(PaperSize.A3_PAPER);
+	assertEquals(8,pSetup.getPaperSize());
+    }
+
+
+    public void testSetGetScale() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setScale(9);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(9,printSetup.getScale());
+
+	printSetup.setScale((short)100);
+	assertEquals(100,pSetup.getScale());
+    }
+
+    public void testSetGetPageStart() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setFirstPageNumber(9);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(9,printSetup.getPageStart());
+
+	printSetup.setPageStart((short)1);
+	assertEquals(1,pSetup.getFirstPageNumber());
+    }
+
+
+    public void testSetGetFitWidthHeight() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setFitToWidth(50);
+	pSetup.setFitToHeight(99);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(50,printSetup.getFitWidth());
+	assertEquals(99,printSetup.getFitHeight());
+
+	printSetup.setFitWidth((short)66);
+	printSetup.setFitHeight((short)80);
+	assertEquals(66,pSetup.getFitToWidth());
+	assertEquals(80,pSetup.getFitToHeight());
+
+    }
+
+    public void testSetGetLeftToRight() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setPageOrder(STPageOrder.DOWN_THEN_OVER);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getLeftToRight());
+	
+	printSetup.setLeftToRight(true);
+	assertEquals(PageOrder.OVER_THEN_DOWN.getValue(),pSetup.getPageOrder());
+    }
+
+    public void testSetGetOrientation() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setOrientation(STOrientation.PORTRAIT);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(PrintOrientation.PORTRAIT,printSetup.getOrientation());
+	assertEquals(false,printSetup.getLandscape());
+	assertEquals(false,printSetup.getNoOrientation());
+
+	printSetup.setOrientation(PrintOrientation.LANDSCAPE);
+	assertEquals(pSetup.getOrientation(),printSetup.getOrientation().getValue());
+	assertEquals(true,printSetup.getLandscape());
+	assertEquals(false,printSetup.getNoOrientation());
+    }
+
+
+    public void testSetGetValidSettings() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setUsePrinterDefaults(false);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getValidSettings());
+
+	printSetup.setValidSettings(true);
+	assertEquals(true,pSetup.getUsePrinterDefaults());
+    }
+
+    public void testSetGetNoColor() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setBlackAndWhite(false);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getNoColor());
+
+	printSetup.setNoColor(true);
+	assertEquals(true,pSetup.getBlackAndWhite());
+    }
+
+    public void testSetGetDraft() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setDraft(false);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getDraft());
+
+	printSetup.setDraft(true);
+	assertEquals(true,pSetup.getDraft());
+    }
+
+    public void testSetGetNotes() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setCellComments(STCellComments.NONE);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getNotes());
+
+	printSetup.setNotes(true);
+	assertEquals(PrintCellComments.AS_DISPLAYED.getValue(),pSetup.getCellComments());
+    }
+
+
+    public void testSetGetUsePage() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setUseFirstPageNumber(false);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(false,printSetup.getUsePage());
+
+	printSetup.setUsePage(true);
+	assertEquals(true,pSetup.getUseFirstPageNumber());
+    }
+
+    public void testSetGetHVResolution() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setHorizontalDpi(120);
+	pSetup.setVerticalDpi(100);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(120,printSetup.getHResolution());
+	assertEquals(100,printSetup.getVResolution());
+
+	printSetup.setHResolution((short)150);
+	printSetup.setVResolution((short)130);
+	assertEquals(150,pSetup.getHorizontalDpi());
+	assertEquals(130,pSetup.getVerticalDpi());
+    }
+
+    public void testSetGetHeaderFooterMargin() {
+	CTPageMargins pMargins=CTPageMargins.Factory.newInstance();
+	pMargins.setHeader(1.5);
+	pMargins.setFooter(2);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup( null, pMargins);
+	assertEquals(1.5,printSetup.getHeaderMargin());
+	assertEquals(2.0,printSetup.getFooterMargin());
+
+	printSetup.setHeaderMargin(5);
+	printSetup.setFooterMargin(3.5);
+	assertEquals(5.0,pMargins.getHeader());
+	assertEquals(3.5,pMargins.getFooter());
+    }
+
+    public void testSetGetCopies() {
+	CTPageSetup pSetup=CTPageSetup.Factory.newInstance();
+	pSetup.setCopies(9);
+	XSSFPrintSetup printSetup=new XSSFPrintSetup(pSetup, null);
+	assertEquals(9,printSetup.getCopies());
+
+	printSetup.setCopies((short)15);
+	assertEquals(15,pSetup.getCopies());
+    }
+
+
+}

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org