poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: r619316 - in /poi/branches/ooxml/src/ooxml: java/org/apache/poi/xssf/usermodel/ java/org/apache/poi/xssf/usermodel/extensions/ java/org/apache/poi/xssf/usermodel/helpers/ testcases/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/xss...
Date Thu, 07 Feb 2008 09:24:50 GMT
Author: ugo
Date: Thu Feb  7 01:24:49 2008
New Revision: 619316

URL: http://svn.apache.org/viewvc?rev=619316&view=rev
Log:
XSSF implementation of header and footer. Contributed by Paolo Mottadelli <p.mottadelli@sourcesense.com> as bugzilla issue #44330.

Added:
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java   (with props)
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java   (with props)
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java   (with props)
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java   (with props)
Modified:
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Footer;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFEvenFooter extends XSSFHeaderFooter implements Footer{
+
+    public XSSFEvenFooter(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getEvenFooter();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setEvenFooter(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Header;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFEvenHeader extends XSSFHeaderFooter implements Header{
+
+    public XSSFEvenHeader(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getEvenHeader();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setEvenHeader(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Footer;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFFirstFooter extends XSSFHeaderFooter implements Footer{
+
+    public XSSFFirstFooter(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getFirstFooter();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setFirstFooter(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Header;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFFirstHeader extends XSSFHeaderFooter implements Header{
+
+    public XSSFFirstHeader(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getFirstHeader();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setFirstHeader(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Footer;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFOddFooter extends XSSFHeaderFooter implements Footer{
+
+    public XSSFOddFooter(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getOddFooter();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setOddFooter(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,38 @@
+/* ====================================================================
+   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.Header;
+import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public class XSSFOddHeader extends XSSFHeaderFooter implements Header{
+
+    public XSSFOddHeader(CTHeaderFooter headerFooter) {
+        super(headerFooter);
+    }
+    
+    public String getText() {
+        return getHeaderFooter().getOddHeader();
+    }
+    
+    public void setText(String text) {
+        getHeaderFooter().setOddHeader(text);
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=619316&r1=619315&r2=619316&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 Thu Feb  7 01:24:49 2008
@@ -96,8 +96,6 @@
             col.setCustomWidth(true);
         }
         CTHeaderFooter hf = this.worksheet.addNewHeaderFooter();
-        hf.setOddHeader("&amp;C&amp;A");
-        hf.setOddFooter("&amp;C&amp;\"Arial\"&amp;10Page &amp;P");
         CTPageBreak rowBreaks = worksheet.addNewRowBreaks();
         CTPageBreak columnBreak = worksheet.addNewColBreaks();
         CTSheetPr sheetPr = worksheet.addNewSheetPr();
@@ -251,13 +249,36 @@
     }
 
     public Footer getFooter() {
-        // TODO Auto-generated method stub
-        return null;
+        return getOddFooter();
+    }
+    
+    public Footer getOddFooter() {
+        return new XSSFOddFooter(worksheet.getHeaderFooter());
+    }
+    
+    public Footer getEvenFooter() {
+        return new XSSFEvenFooter(worksheet.getHeaderFooter());
+    }
+    
+    public Footer getFirstFooter() {
+        return new XSSFFirstFooter(worksheet.getHeaderFooter());
     }
 
     public Header getHeader() {
-        // TODO Auto-generated method stub
-        return null;
+        return getOddHeader();
+    }
+    
+    public Header getOddHeader() {
+        return new XSSFOddHeader(worksheet.getHeaderFooter());
+    }
+    
+    public Header getEvenHeader() {
+        return new XSSFEvenHeader(worksheet.getHeaderFooter()
+);
+    }
+    
+    public Header getFirstHeader() {
+        return new XSSFFirstHeader(worksheet.getHeaderFooter());
     }
 
     public boolean getHorizontallyCenter() {
@@ -282,23 +303,23 @@
     }
 
     public double getMargin(short margin) {
-    	CTPageMargins pageMargins = worksheet.getPageMargins();
-    	switch (margin) {
-    	case LeftMargin:
-    		return pageMargins.getLeft();
-    	case RightMargin:
-    		return pageMargins.getRight();
-    	case TopMargin:
-    		return pageMargins.getTop();
-    	case BottomMargin:
-    		return pageMargins.getBottom();
-    	case HeaderMargin:
-    		return pageMargins.getHeader();
-    	case FooterMargin:
-    		return pageMargins.getFooter();
-    	default :
-    		throw new RuntimeException( "Unknown margin constant:  " + margin );
-    	}
+        CTPageMargins pageMargins = worksheet.getPageMargins();
+        switch (margin) {
+        case LeftMargin:
+            return pageMargins.getLeft();
+        case RightMargin:
+            return pageMargins.getRight();
+        case TopMargin:
+            return pageMargins.getTop();
+        case BottomMargin:
+            return pageMargins.getBottom();
+        case HeaderMargin:
+            return pageMargins.getHeader();
+        case FooterMargin:
+            return pageMargins.getFooter();
+        default :
+            throw new RuntimeException( "Unknown margin constant:  " + margin );
+        }
     }
 
     public Region getMergedRegionAt(int index) {
@@ -537,19 +558,11 @@
     }
 
     public void setColumnHidden(short column, boolean hidden) {
-        CTCol col = columnHelper.getColumn(column);
-        if (col == null) {
-            col = columnHelper.createColumn(column);
-        }
-        col.setHidden(hidden);
+        columnHelper.getColumn(column).setHidden(hidden);
     }
 
     public void setColumnWidth(short column, short width) {
-        CTCol col = columnHelper.getColumn(column);
-        if (col == null) {
-            col = columnHelper.createColumn(column);
-        }
-        col.setWidth(width);
+        columnHelper.getColumn(column).setWidth(width);
     }
 
     public void setDefaultColumnStyle(short column, CellStyle style) {
@@ -611,21 +624,21 @@
     }
 
     public void setMargin(short margin, double size) {
-	    CTPageMargins pageMargins = worksheet.getPageMargins();
-	    switch (margin) {
-	    case LeftMargin:
-	    	pageMargins.setLeft(size);
-	    case RightMargin:
-	    	pageMargins.setRight(size);
-	    case TopMargin:
-	    	pageMargins.setTop(size);
-	    case BottomMargin:
-	    	pageMargins.setBottom(size);
-	    case HeaderMargin:
-	    	pageMargins.setHeader(size);
-	    case FooterMargin:
-	    	pageMargins.setFooter(size);
-	    }
+        CTPageMargins pageMargins = worksheet.getPageMargins();
+        switch (margin) {
+        case LeftMargin:
+            pageMargins.setLeft(size);
+        case RightMargin:
+            pageMargins.setRight(size);
+        case TopMargin:
+            pageMargins.setTop(size);
+        case BottomMargin:
+            pageMargins.setBottom(size);
+        case HeaderMargin:
+            pageMargins.setHeader(size);
+        case FooterMargin:
+            pageMargins.setFooter(size);
+        }
     }
 
     public void setPrintGridlines(boolean newPrintGridlines) {

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java Thu Feb  7 01:24:49 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.extensions;
+
+import org.apache.poi.ss.usermodel.Footer;
+import org.apache.poi.xssf.usermodel.helpers.HeaderFooterHelper;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+public abstract class XSSFHeaderFooter implements Footer{
+    
+    private HeaderFooterHelper helper;
+    private CTHeaderFooter headerFooter;
+    private String value;
+
+    public XSSFHeaderFooter(CTHeaderFooter headerFooter) {
+       this.headerFooter = headerFooter;
+       this.value = getText();
+       this.value = this.value != null ? this.value : "";
+       this.helper = new HeaderFooterHelper();
+    }
+    
+    public CTHeaderFooter getHeaderFooter() {
+        return this.headerFooter;
+    }
+    
+    public String getValue() {
+        return this.value;
+    }
+    
+    public abstract String getText();
+    
+    protected abstract void setText(String text);
+
+    public String getCenter() {
+        return helper.getCenterSection(getText());
+    }
+
+    public String getLeft() {
+        return helper.getLeftSection(getText());
+    }
+
+    public String getRight() {
+        return helper.getRightSection(getText());
+    }
+
+    public void setCenter(String newCenter) {
+        setText(helper.setCenterSection(getText(), newCenter));
+    }
+
+    public void setLeft(String newLeft) {
+        setText(helper.setLeftSection(getText(), newLeft));
+    }
+
+    public void setRight(String newRight) {
+        setText(helper.setRightSection(getText(), newRight));
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=619316&r1=619315&r2=619316&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Thu Feb  7 01:24:49 2008
@@ -1,99 +1,90 @@
+/* ====================================================================
+   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.helpers;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
 
+
 public class ColumnHelper {
-	
-	private List<CTCol> columns;
-	
-    public ColumnHelper(CTWorksheet worksheet) {
-		super();
-		setColumns(worksheet);
-	}
+    
+    private CTWorksheet worksheet;
+    
 
-	public List<CTCol> getColumns() {
-    	return columns;
+    public ColumnHelper(CTWorksheet worksheet) {
+        super();
+        this.worksheet = worksheet;
+        cleanColumns();
     }
-	
-	public void setColumns(CTWorksheet worksheet) {
-    	columns = new ArrayList<CTCol>();
-    	CTCols[] colsArray = worksheet.getColsArray();
-    	for (int i = 0 ; i < colsArray.length ; i++) {
-    		CTCols cols = colsArray[i];
-    		CTCol[] colArray = cols.getColArray();
-    		for (int y = 0 ; y < colArray.length ; y++) {
-    		 	CTCol col = colArray[y];
-    		 	for (long k = col.getMin() ; k <= col.getMax() ; k++) {
-    		 		setColumn(columns, col, k);
-    		 	}
-    		}
-    	}
-	}
-
-	private void setColumn(List<CTCol> columns, CTCol col, long k) {
-		CTCol column = getColumn(columns, k);
-		if (column == null) {
-			column = CTCol.Factory.newInstance();
-			column.setMin(k);
-			column.setMax(k);
-			setColumnAttributes(col, column);
-			columns.add(column);
-		}
-		else {
-			setColumnAttributes(col, column);
-		}
-	}
-
-	private void setColumnAttributes(CTCol col, CTCol column) {
-		if (col.getWidth() > 0) {
-			column.setWidth(col.getWidth());
-		}
-		// TODO set all col attributes
-	}
-    
-    public CTCol getColumn(List<CTCol> columns, long k) {
-    	for (Iterator<CTCol> it = columns.iterator() ; it.hasNext() ; ) {
-    		CTCol column = it.next();
-    		if (column.getMin() == k) {
-    			return column;
-    		}
-    	}
-    	return null;
+
+    public void cleanColumns() {
+        CTCols newCols = CTCols.Factory.newInstance();
+        CTCols[] colsArray = worksheet.getColsArray();
+        int i = 0;
+        for (i = 0 ; i < colsArray.length ; i++) {
+            CTCols cols = colsArray[i];
+            CTCol[] colArray = cols.getColArray();
+            for (int y = 0 ; y < colArray.length ; y++) {
+                 CTCol col = colArray[y];
+                 for (long k = col.getMin() ; k <= col.getMax() ; k++) {
+                     if (!columnExists(newCols, k)) {
+                         CTCol newCol = newCols.addNewCol();
+                         newCol.setMin(k);
+                         newCol.setMax(k);
+                         setColumnAttributes(col, newCol);
+                     }
+                 }
+            }
+        }
+        for (int y = i-1 ; y >= 0 ; y--) {
+            worksheet.removeCols(y);
+        }
+        worksheet.addNewCols();
+        worksheet.setColsArray(0, newCols);
     }
     
     public CTCol getColumn(long index) {
-    	for (Iterator<CTCol> it = columns.iterator() ; it.hasNext() ; ) {
-    		CTCol column = it.next();
-    		if (getColumnIndex(column) == index) {
-    			return column;
-    		}
-    	}
-    	return null;
+        for (int i = 0 ; i < worksheet.getColsArray(0).sizeOfColArray() ; i++) {
+            if (worksheet.getColsArray(0).getColArray(i).getMin() == index) {
+                return worksheet.getColsArray(0).getColArray(i);
+            }
+        }
+        return  null;
     }
     
-    public long getColumnIndex(CTCol column) {
-    	if (column.getMin() == column.getMax()) {
-    		return column.getMin();
-    	}
-    	return -1;
+    public boolean columnExists(CTCols cols, long index) {
+        for (int i = 0 ; i < cols.sizeOfColArray() ; i++) {
+            if (cols.getColArray(i).getMin() == index) {
+                return true;
+            }
+        }
+        return false;
     }
     
-    public CTCol createColumn(long index) {
-    	CTCol column = CTCol.Factory.newInstance();
-    	setIndex(column, index);
-    	columns.add(column);
-    	return column;
+    public void setColumnAttributes(CTCol col, CTCol newCol) {
+        if (col.getWidth() != 0) {
+            newCol.setWidth(col.getWidth());
+        }
+        if (col.getHidden()) {
+            newCol.setHidden(true);
+        }
     }
-
-	private void setIndex(CTCol column, long index) {
-		column.setMin(index);
-		column.setMax(index);
-	}
-
+    
 }

Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java (added)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java Thu Feb  7 01:24:49 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.helpers;
+
+
+public class HeaderFooterHelper {
+    
+    private static final String HeaderFooterEntity = "&amp;";
+    private static final String HeaderFooterEntity_R = "&amp;R";
+    private static final String HeaderFooterEntity_L = "&amp;L";
+    private static final String HeaderFooterEntity_C = "&amp;C";
+
+    public String getCenterSection(String string) {
+        return getSection(string, HeaderFooterEntity_C);
+    }
+    public String getLeftSection(String string) {
+        return getSection(string, HeaderFooterEntity_L);
+    }
+    public String getRightSection(String string) {
+        return getSection(string, HeaderFooterEntity_R);
+    }
+    
+    public String setCenterSection(String string, String newCenter) {
+        return setSection(string, newCenter, HeaderFooterEntity_C);
+    }
+    public String setLeftSection(String string, String newLeft) {
+        return setSection(string, newLeft, HeaderFooterEntity_L);
+    }
+    public String setRightSection(String string, String newRight) {
+        return setSection(string, newRight, HeaderFooterEntity_R);
+    }
+    
+    public String setSection(String string, String newSection, String entity) {
+        string = string != null ? string : "";
+        String oldSection = getSection(string, entity);
+        if (oldSection.equals("")) {
+            return string.concat(entity + newSection);
+        }
+        return string.replaceAll(entity + oldSection, entity + newSection);
+    }
+
+    private String getSection(String string, String entity) {
+        if (string == null) {
+            return "";
+        }
+        String stringAfterEntity = "";
+        if (string.indexOf(entity) >= 0) {
+            stringAfterEntity = string.substring(string.indexOf(entity) + entity.length());
+        }
+        String nextEntity = "";
+        if (stringAfterEntity.indexOf(HeaderFooterEntity) > 0) {
+            nextEntity = stringAfterEntity.substring(stringAfterEntity.indexOf(HeaderFooterEntity), stringAfterEntity.indexOf(HeaderFooterEntity) + (HeaderFooterEntity.length()));
+            stringAfterEntity = stringAfterEntity.substring(0, stringAfterEntity.indexOf(nextEntity));
+        }
+        return stringAfterEntity;
+    }
+
+}

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/HeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java (added)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,50 @@
+/* ====================================================================
+   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.CTHeaderFooter;
+
+import junit.framework.TestCase;
+
+
+public class TestXSSFHeaderFooter extends TestCase {
+    
+    public void testGetSetCenterLeftRight() {
+        
+        XSSFOddFooter footer = new XSSFOddFooter(CTHeaderFooter.Factory.newInstance());
+        assertEquals("", footer.getCenter());
+        footer.setCenter("My first center section");
+        assertEquals("My first center section", footer.getCenter());
+        footer.setCenter("No, let's update the center section");
+        assertEquals("No, let's update the center section", footer.getCenter());
+        footer.setLeft("And add a left one");
+        footer.setRight("Finally the right section is added");
+        assertEquals("And add a left one", footer.getLeft());
+        assertEquals("Finally the right section is added", footer.getRight());
+        
+        // Test changing the three sections value
+        footer.setCenter("Second center version");
+        footer.setLeft("Second left version");
+        footer.setRight("Second right version");
+        assertEquals("Second center version", footer.getCenter());
+        assertEquals("Second left version", footer.getLeft());
+        assertEquals("Second right version", footer.getRight());
+        
+    }
+    
+}

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHeaderFooter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=619316&r1=619315&r2=619316&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Thu Feb  7 01:24:49 2008
@@ -20,6 +20,7 @@
 import java.util.Iterator;
 
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Footer;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 
@@ -125,14 +126,6 @@
         assertEquals((short) 14, sheet.getDefaultColumnWidth());
     }
     
-    public void testGetSetColumnWidth() {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        Sheet sheet = workbook.createSheet("Sheet 1");
-        // Test setting a column width and getting that value
-        sheet.setColumnWidth((short) 0, (short) 16);
-        assertEquals(16, sheet.getColumnWidth((short) 0));
-    }
-    
     public void testGetFirstLastRowNum() {
         XSSFWorkbook workbook = new XSSFWorkbook();
         Sheet sheet = workbook.createSheet("Sheet 1");
@@ -220,17 +213,6 @@
         assertFalse(sheet.getAutobreaks());
     }
     
-    public void testIsSetColumnHidden() {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        Sheet sheet = workbook.createSheet("Sheet 1");
-        sheet.setColumnWidth((short) 0, (short) 13);
-        sheet.setColumnHidden((short) 1, false);
-        sheet.setColumnHidden((short) 2, true);
-        assertFalse(sheet.isColumnHidden((short) 0));
-        assertFalse(sheet.isColumnHidden((short) 1));
-        assertTrue(sheet.isColumnHidden((short) 2));
-    }
-    
     public void testIsSetFitToPage() {
         XSSFWorkbook workbook = new XSSFWorkbook();
         Sheet sheet = workbook.createSheet("Sheet 1");
@@ -246,16 +228,31 @@
         Sheet sheet = workbook.createSheet("Sheet 1");
         assertEquals((double) 0, sheet.getMargin((short) 0));
         sheet.setMargin((short) 0, 10);
-        sheet.setMargin((short) 1, 11);
-        sheet.setMargin((short) 2, 12);
-        sheet.setMargin((short) 3, 13);
-        sheet.setMargin((short) 4, 14);
-        sheet.setMargin((short) 5, 15);
         assertEquals((double) 10, sheet.getMargin((short) 0));
+        assertEquals((double) 10, sheet.getMargin((short) 1));
+        assertEquals((double) 10, sheet.getMargin((short) 2));
+        assertEquals((double) 10, sheet.getMargin((short) 3));
+        assertEquals((double) 10, sheet.getMargin((short) 4));
+        assertEquals((double) 10, sheet.getMargin((short) 5));
+        sheet.setMargin((short) 1, 11);
         assertEquals((double) 11, sheet.getMargin((short) 1));
+        assertEquals((double) 11, sheet.getMargin((short) 2));
+        assertEquals((double) 11, sheet.getMargin((short) 3));
+        assertEquals((double) 11, sheet.getMargin((short) 4));
+        assertEquals((double) 11, sheet.getMargin((short) 5));
+        sheet.setMargin((short) 2, 12);
         assertEquals((double) 12, sheet.getMargin((short) 2));
+        assertEquals((double) 12, sheet.getMargin((short) 3));
+        assertEquals((double) 12, sheet.getMargin((short) 4));
+        assertEquals((double) 12, sheet.getMargin((short) 5));
+        sheet.setMargin((short) 3, 13);
         assertEquals((double) 13, sheet.getMargin((short) 3));
+        assertEquals((double) 13, sheet.getMargin((short) 4));
+        assertEquals((double) 13, sheet.getMargin((short) 5));
+        sheet.setMargin((short) 4, 14);
         assertEquals((double) 14, sheet.getMargin((short) 4));
+        assertEquals((double) 14, sheet.getMargin((short) 5));
+        sheet.setMargin((short) 5, 15);
         assertEquals((double) 15, sheet.getMargin((short) 5));
         
         // Test that nothing happens if another margin constant is given (E.G. 65)
@@ -266,5 +263,63 @@
         assertEquals((double) 13, sheet.getMargin((short) 3));
         assertEquals((double) 14, sheet.getMargin((short) 4));
         assertEquals((double) 15, sheet.getMargin((short) 5));
+    }
+    
+    public void testGetFooter() {
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        assertNotNull(sheet.getFooter());
+        sheet.getFooter().setCenter("test center footer");
+        assertEquals("test center footer", sheet.getFooter().getCenter());
+    }
+    
+    public void testGetAllHeadersFooters() {
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        assertNotNull(sheet.getOddFooter());
+        assertNotNull(sheet.getEvenFooter());
+        assertNotNull(sheet.getFirstFooter());
+        assertNotNull(sheet.getOddHeader());
+        assertNotNull(sheet.getEvenHeader());
+        assertNotNull(sheet.getFirstHeader());
+        
+        assertEquals("", sheet.getOddFooter().getLeft());
+        sheet.getOddFooter().setLeft("odd footer left");
+        assertEquals("odd footer left", sheet.getOddFooter().getLeft());
+        
+        assertEquals("", sheet.getEvenFooter().getLeft());
+        sheet.getEvenFooter().setLeft("even footer left");
+        assertEquals("even footer left", sheet.getEvenFooter().getLeft());
+        
+        assertEquals("", sheet.getFirstFooter().getLeft());
+        sheet.getFirstFooter().setLeft("first footer left");
+        assertEquals("first footer left", sheet.getFirstFooter().getLeft());
+        
+        assertEquals("", sheet.getOddHeader().getLeft());
+        sheet.getOddHeader().setLeft("odd header left");
+        assertEquals("odd header left", sheet.getOddHeader().getLeft());
+        
+        assertEquals("", sheet.getOddHeader().getRight());
+        sheet.getOddHeader().setRight("odd header right");
+        assertEquals("odd header right", sheet.getOddHeader().getRight());
+        
+        assertEquals("", sheet.getOddHeader().getCenter());
+        sheet.getOddHeader().setCenter("odd header center");
+        assertEquals("odd header center", sheet.getOddHeader().getCenter());
+
+    }
+    
+    public void testGetSetColumnWidth() {
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        sheet.setColumnWidth((short) 1,(short)  22);
+        assertEquals(22, sheet.getColumnWidth((short) 1));
+    }
+    
+    public void testGetSetColumnHidden() {
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        sheet.setColumnHidden((short) 2, true);
+        assertTrue(sheet.isColumnHidden((short) 2));
     }
 }

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java?rev=619316&r1=619315&r2=619316&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java Thu Feb  7 01:24:49 2008
@@ -17,55 +17,95 @@
 
 package org.apache.poi.xssf.usermodel.helpers;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
 import junit.framework.TestCase;
 
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.SharedStringSource;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
 
 
 public class TestColumnHelper extends TestCase {
-	
-	public void testGetColumnList() {
-		CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
-		ColumnHelper columnHelper = new ColumnHelper(worksheet);
-		
-		CTCols cols1 = worksheet.addNewCols();
-		CTCols cols2 = worksheet.addNewCols();
-		
-		CTCol col1_1 = cols1.addNewCol();
-		col1_1.setMin(1);
-		col1_1.setMax(10);
-		col1_1.setWidth(13);
-		CTCol col1_2 = cols1.addNewCol();
-		col1_2.setMin(15);
-		col1_2.setMax(15);
-		col1_2.setWidth(14);
+    
+    public void testCleanColumns() {
+        CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
+        
+        CTCols cols1 = worksheet.addNewCols();
+        CTCol col1 = cols1.addNewCol();
+        col1.setMin(1);
+        col1.setMax(1);
+        col1.setWidth(88);
+        col1.setHidden(true);
+        CTCol col2 = cols1.addNewCol();
+        col2.setMin(2);
+        col2.setMax(3);
+        CTCols cols2 = worksheet.addNewCols();
+        CTCol col4 = cols2.addNewCol();
+        col4.setMin(3);
+        col4.setMax(6);
+        
+        // Test cleaning cols
+        assertEquals(2, worksheet.sizeOfColsArray());
+        int count = countColumns(worksheet);
+        assertEquals(7, count);
+        // Clean columns and test a clean worksheet
+        ColumnHelper helper = new ColumnHelper(worksheet);
+        assertEquals(1, worksheet.sizeOfColsArray());
+        count = countColumns(worksheet);
+        assertEquals(6, count);
+        assertEquals((double) 88, helper.getColumn(1).getWidth());
+        assertTrue(helper.getColumn(1).getHidden());
+        
+    }
+    
+    public void testGetColumn() {
+        CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
+        
+        CTCols cols1 = worksheet.addNewCols();
+        CTCol col1 = cols1.addNewCol();
+        col1.setMin(1);
+        col1.setMax(1);
+        col1.setWidth(88);
+        col1.setHidden(true);
+        CTCol col2 = cols1.addNewCol();
+        col2.setMin(2);
+        col2.setMax(3);
+        CTCols cols2 = worksheet.addNewCols();
+        CTCol col4 = cols2.addNewCol();
+        col4.setMin(3);
+        col4.setMax(6);
+        
+        ColumnHelper helper = new ColumnHelper(worksheet);
+        assertNotNull(helper.getColumn(1));
+        assertEquals((double) 88, helper.getColumn(1).getWidth());
+        assertTrue(helper.getColumn(1).getHidden());
+        assertFalse(helper.getColumn(2).getHidden());
+        assertNull(helper.getColumn(99));
+    }
+    
+    public void testSetColumnAttributes() {
+        CTCol col = CTCol.Factory.newInstance();
+        col.setWidth(12);
+        col.setHidden(true);
+        CTCol newCol = CTCol.Factory.newInstance();
+        assertEquals((double) 0, newCol.getWidth());
+        assertFalse(newCol.getHidden());
+        ColumnHelper helper = new ColumnHelper(CTWorksheet.Factory.newInstance());
+        helper.setColumnAttributes(col, newCol);
+        assertEquals((double) 12, newCol.getWidth());
+        assertTrue(newCol.getHidden());
+    }
 
-		CTCol col2_1 = cols2.addNewCol();
-		col2_1.setMin(6);
-		col2_1.setMax(10);
-		CTCol col2_2 = cols2.addNewCol();
-		col2_2.setMin(20);
-		col2_2.setMax(20);
-		
-		columnHelper.setColumns(worksheet);
-		List<CTCol> columns = columnHelper.getColumns();
-		
-		assertEquals(12, columns.size());
-		assertEquals((double) 14, columnHelper.getColumn(15).getWidth());
-	}
-	
+    private int countColumns(CTWorksheet worksheet) {
+        int count;
+        count = 0;
+        for (int i = 0 ; i < worksheet.sizeOfColsArray() ; i++) {
+            for (int y = 0 ; y < worksheet.getColsArray(i).sizeOfColArray() ; y++) {
+                for (long k = worksheet.getColsArray(i).getColArray(y).getMin() ; k <= worksheet.getColsArray(i).getColArray(y).getMax() ; k++) {
+                    count++;
+                }
+            }
+        }
+        return count;
+    }
+    
 }

Added: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java?rev=619316&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java (added)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java Thu Feb  7 01:24:49 2008
@@ -0,0 +1,59 @@
+/* ====================================================================
+   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.helpers;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.xssf.usermodel.helpers.HeaderFooterHelper;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
+
+
+public class TestHeaderFooterHelper extends TestCase {
+    
+    public void testGetCenterLeftRightSection() {
+        HeaderFooterHelper helper = new HeaderFooterHelper();
+        String headerFooter = "&amp;CTest the center section";
+        assertEquals("Test the center section", helper.getCenterSection(headerFooter));
+        headerFooter = "&amp;CTest the center section&amp;LThe left one&amp;RAnd the right one";
+        assertEquals("Test the center section", helper.getCenterSection(headerFooter));
+        assertEquals("The left one", helper.getLeftSection(headerFooter));
+        assertEquals("And the right one", helper.getRightSection(headerFooter));
+    }
+    
+    public void testSetCenterLeftRightSection() {
+        HeaderFooterHelper helper = new HeaderFooterHelper();
+        String headerFooter = "";
+        headerFooter = helper.setCenterSection(headerFooter, "First added center section");
+        assertEquals("First added center section", helper.getCenterSection(headerFooter));
+        headerFooter = helper.setLeftSection(headerFooter, "First left");
+        assertEquals("First left", helper.getLeftSection(headerFooter));
+
+        headerFooter = helper.setRightSection(headerFooter, "First right");
+        assertEquals("First right", helper.getRightSection(headerFooter));
+        assertEquals("&amp;CFirst added center section&amp;LFirst left&amp;RFirst right", headerFooter);
+
+        headerFooter = helper.setRightSection(headerFooter, "First right&amp");
+        assertEquals("First right&amp", helper.getRightSection(headerFooter));
+        assertEquals("&amp;CFirst added center section&amp;LFirst left&amp;RFirst right&amp", headerFooter);
+        
+        headerFooter = helper.setRightSection(headerFooter, "First right&amp;");
+        assertEquals("First right", helper.getRightSection(headerFooter));
+        assertEquals("&amp;CFirst added center section&amp;LFirst left&amp;RFirst right&amp;", headerFooter);
+    }
+    
+}

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestHeaderFooterHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



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


Mime
View raw message