incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1388771 - in /incubator/ooo/trunk/test/testuno/source: testcase/uno/sw/ testcase/uno/sw/page/ testlib/uno/
Date Sat, 22 Sep 2012 11:20:30 GMT
Author: liuzhe
Date: Sat Sep 22 11:20:30 2012
New Revision: 1388771

URL: http://svn.apache.org/viewvc?rev=1388771&view=rev
Log:
#120784 - [testuno] - test writer's paper width, height, margins, orientation, header/footer via uno api
Patch By: Xiao Xiao Ting <tingxiaox@gmail.com>
Review By: Liu Zhe <aliuzhe@gmail.com>

Added:
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java   (with props)
Modified:
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/DocumentTest.java
    incubator/ooo/trunk/test/testuno/source/testlib/uno/SWUtil.java

Modified: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/DocumentTest.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/DocumentTest.java?rev=1388771&r1=1388770&r2=1388771&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/DocumentTest.java (original)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/DocumentTest.java Sat Sep 22 11:20:30 2012
@@ -43,12 +43,8 @@ public class DocumentTest {
 		temp.mkdirs();
 		
 		//copy sample file to temp folder
-		String originalFilePath = prepareData("uno/sw/DocumentTest.odt");	
-		String originalTemplatePath = prepareData("uno/sw/DocumentTest.ott");	
-		workingFilePath = temp + "/DocumentTest.odt";
-		workingTemplatePath = temp + "/DocumentTest.ott";
-		FileUtil.copyFile(new File(originalFilePath), new File(workingFilePath));	
-		FileUtil.copyFile(new File(originalTemplatePath), new File(workingTemplatePath));
+		workingFilePath = prepareData("uno/sw/DocumentTest.odt");	
+		workingTemplatePath = prepareData("uno/sw/DocumentTest.ott");			
 	}
 
 	@After

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,145 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+
+/**
+ * test page's back color,
+ * test page footer/header's back color. 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckBackColor {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String onProperty = "";
+	private String backColorProperty = "";	
+	
+	private int backColor = 0;	
+	
+	
+	public CheckBackColor(String onProperty, String backColorProperty, 	int backColor){
+		this.onProperty = onProperty;
+		this.backColorProperty = backColorProperty;		
+		
+		this.backColor = backColor;		
+	}
+	
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{"FooterIsOn", "BackColor", 255},
+    			{"FooterIsOn", "BackColor", 65535},  
+    			{"FooterIsOn", "FooterBackColor", 255},
+    			{"FooterIsOn", "FooterBackColor", 0},    			
+    			{"HeaderIsOn", "HeaderBackColor", 65536},
+    			{"HeaderIsOn", "HeaderBackColor", 65535}    			
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test header/footer's back color and back graphic.
+     * @throws Exception
+     */
+    @Ignore("#120949 - header/footer's background lost when export to doc format ")    
+	@Test
+	public void testFooterHeaderBackground() throws Exception
+	{		
+		XComponent xComponent = unoApp.newDocument("swriter");
+		//turn on header/footer		
+		SWUtil.setDefaultPageStyleProperty(xComponent, onProperty, new Boolean(true));
+		SWUtil.setDefaultPageStyleProperty(xComponent, backColorProperty, Integer.valueOf(backColor));		
+		
+		//save as ODT and reopen, get back color
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+        
+		int color = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, backColorProperty)).intValue();		
+		
+		
+		this.compare("ODT", color);
+		
+		//save as DOC and reopen, only get back color        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    color = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, backColorProperty)).intValue();
+		
+		this.compare("DOC", color);
+		
+		unoApp.closeDocument(xComponent);        
+	}
+	
+	private void compare(String preDescription, int color){		
+		Assert.assertEquals(preDescription + ":" + backColorProperty,(double)backColor, color, 2);				
+	}
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackColor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,137 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+
+/**
+ * test page's back graphic,
+ * test page footer/header's back graphic. 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckBackGraphic {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String onProperty = "";	
+	private String backGraphicURLProperty = "";		
+	
+	private String backGraphicPath = "";
+	private String backGraphicURL = "";
+	
+	
+	public CheckBackGraphic(String onProperty, String backGraphicURLProperty, String backGraphicPath){
+		this.onProperty = onProperty;		
+		this.backGraphicURLProperty = backGraphicURLProperty;		
+		
+		this.backGraphicPath = backGraphicPath;
+	}
+	
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{"FooterIsOn", "BackGraphicURL", "uno/sw/page/BackGraphic1.jpg"},
+    			{"FooterIsOn", "BackGraphicURL", "uno/sw/page/BackGraphic2.jpg"},  
+    			{"FooterIsOn", "FooterBackGraphicURL", "uno/sw/page/BackGraphic1.jpg"},
+    			{"FooterIsOn", "FooterBackGraphicURL", "uno/sw/page/BackGraphic2.jpg"},    			
+    			{"HeaderIsOn", "HeaderBackGraphicURL", "uno/sw/page/BackGraphic1.jpg"},
+    			{"HeaderIsOn", "HeaderBackGraphicURL", "uno/sw/page/BackGraphic2.jpg"}    			
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test header/footer's back color and back graphic.
+     * @throws Exception
+     */     
+	@Test
+	public void testFooterHeaderBackground() throws Exception
+	{			
+		String graphicUrl = FileUtil.getUrl(prepareData(backGraphicPath));
+		backGraphicURL = graphicUrl;
+		XComponent xComponent = unoApp.newDocument("swriter");
+		//turn on header/footer		
+		SWUtil.setDefaultPageStyleProperty(xComponent, onProperty, new Boolean(true));		
+		SWUtil.setDefaultPageStyleProperty(xComponent, backGraphicURLProperty, backGraphicURL);		
+		
+		//save as ODT and reopen, get back color and back graphic
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+		
+		String graphic = (String)SWUtil.getDefaultPageStyleProperty(xComponent, backGraphicURLProperty);
+		
+		
+		Assert.assertEquals("ODT:" + backGraphicURLProperty, backGraphicURL, graphic);	
+		
+		unoApp.closeDocument(xComponent);        
+	}
+	
+	
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBackGraphic.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,169 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+
+/**
+ * test page's border
+ * test page's footer/header's border 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckBorder {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String onProperty = "";
+	private String borderProperty = "";
+	private String borderDistanceProperty = "";
+	private BorderLine borderLine = null;
+	private int borderDistance = 0;
+	
+	
+	public CheckBorder(String onProperty, String borderProperty, String borderDistanceProperty, 
+			int color, int lineDistance, int innerLineWidth, int outerLineWidth, int borderDistance){
+		this.borderLine = new BorderLine();
+		this.borderLine.Color = color;
+		this.borderLine.LineDistance = (short)lineDistance;
+		this.borderLine.InnerLineWidth = (short)innerLineWidth;
+		this.borderLine.OuterLineWidth = (short)outerLineWidth;
+		
+		this.onProperty = onProperty;
+		this.borderProperty = borderProperty;
+		this.borderDistanceProperty = borderDistanceProperty;	
+		
+		this.borderDistance = borderDistance;
+	}
+	
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			/*{"FooterIsOn", "LeftBorder", "LeftBorderDistance", 255, 100, 50,70,199},
+    			{"FooterIsOn", "RightBorder", "RightBorderDistance", 256, 0, 0,0,20},
+    			{"FooterIsOn", "BottomBorder", "BottomBorderDistance", 65536, 15, 10,30,300},
+    			{"FooterIsOn", "TopBorder", "TopBorderDistance", 65535, 6, 100,200,400},
+    			{"FooterIsOn", "FooterLeftBorder", "FooterLeftBorderDistance", 255, 100, 50,70,199},
+    			{"FooterIsOn", "FooterRightBorder", "FooterRightBorderDistance", 256, 0, 0,0,20},
+    			{"FooterIsOn", "FooterBottomBorder", "FooterBottomBorderDistance", 65536, 15, 10,30,300},
+    			{"FooterIsOn", "FooterTopBorder", "FooterTopBorderDistance", 65535, 6, 100,200,400},*/
+    			{"HeaderIsOn", "HeaderLeftBorder", "HeaderLeftBorderDistance", 255, 100, 50,70,0},
+    			{"HeaderIsOn", "HeaderRightBorder", "HeaderRightBorderDistance", 256, 0, 0,0,100},
+    			{"HeaderIsOn", "HeaderBottomBorder", "HeaderBottomBorderDistance", 65536, 15, 10,30,900},
+    			{"HeaderIsOn", "HeaderTopBorder", "HeaderTopBorderDistance", 65535, 6, 100,200,50}
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test page's border
+     * test page's footer/header's border
+     * @throws Exception
+     */
+    @Ignore("#120822 - header/footer's border styles are lost when export to DOC format")
+	@Test
+	public void testFooterHeaderBorder() throws Exception
+	{		
+		XComponent xComponent = unoApp.newDocument("swriter");
+		//turn on header/footer		
+		SWUtil.setDefaultPageStyleProperty(xComponent, onProperty, new Boolean(true));
+		SWUtil.setDefaultPageStyleProperty(xComponent, borderProperty, borderLine);
+		SWUtil.setDefaultPageStyleProperty(xComponent, borderDistanceProperty, Integer.valueOf(borderDistance));
+		
+		//save as ODT and reopen, get border
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);
+        
+        BorderLine actualBorderLine = (BorderLine)SWUtil.getDefaultPageStyleProperty(xComponent, borderProperty);
+		int actualBorderDistance = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, borderDistanceProperty)).intValue();
+		
+		this.compareBorder("ODT:", borderLine, borderDistance);
+		
+		//save as DOC and reopen, get border        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    actualBorderLine = (BorderLine)SWUtil.getDefaultPageStyleProperty(xComponent, borderProperty);
+	    actualBorderDistance = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, borderDistanceProperty)).intValue();
+		
+		this.compareBorder("DOC:", actualBorderLine, actualBorderDistance);
+		
+		unoApp.closeDocument(xComponent);
+        
+	}
+	
+	private void compareBorder(String preDes, BorderLine actualBorderLine, int actualBorderDistance){		
+		Assert.assertEquals(preDes + borderProperty + "-->color.",(double)borderLine.Color, (double)actualBorderLine.Color, 2);		
+		Assert.assertEquals(preDes + borderProperty + "-->LineDistance.", (double)borderLine.LineDistance, (double)actualBorderLine.LineDistance, 2);
+		Assert.assertEquals(preDes + borderProperty + "-->InnerLineWidth.", (double)borderLine.InnerLineWidth, (double)actualBorderLine.InnerLineWidth, 2);
+		Assert.assertEquals(preDes + borderProperty + "-->OuterLineWidth.", (double)borderLine.OuterLineWidth, (double)actualBorderLine.OuterLineWidth, 2);
+		
+		Assert.assertEquals(preDes + "-->" + borderDistanceProperty, (double)borderLine.OuterLineWidth, (double)actualBorderLine.OuterLineWidth, 2);
+	}
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckBorder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,174 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+
+/**
+ * test footer/header's margins, spacing and height. 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckFooterHeader {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String m_onProperty = "";
+	
+	private String m_LeftMarginProperty = "";
+	private String m_RightMarginProperty = "";
+	private String m_BodyDistanceProperty = "";
+	private String m_HeightProperty = "";
+	
+	private int m_LeftMargin = 0;
+	private int m_RightMargin = 0;
+	private int m_BodyDistance = 0;
+	private int m_Height = 0;
+	
+	
+	public CheckFooterHeader(String onProperty, String leftMarginProperty, String rightMarginProperty, String bodyDistanceProperty, String heightProperty,
+			int leftMargin, int rightMargin, int bodyDistance, int height){
+		m_onProperty = onProperty;
+		m_LeftMarginProperty = leftMarginProperty;
+		m_RightMarginProperty = rightMarginProperty;		
+		m_BodyDistanceProperty = bodyDistanceProperty;
+		m_HeightProperty = heightProperty;
+		
+		m_LeftMargin = leftMargin;
+		m_RightMargin = rightMargin;
+		m_BodyDistance = bodyDistance;
+		m_BodyDistance = bodyDistance;
+		m_Height = height;
+	}
+	
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{"FooterIsOn", "FooterLeftMargin", "FooterRightMargin", "FooterBodyDistance","FooterHeight", 1000, 2000, 500,500},
+    			{"FooterIsOn", "FooterLeftMargin", "FooterRightMargin", "FooterBodyDistance","FooterHeight", 3000, 1500, 300,400},
+    			{"FooterIsOn", "FooterLeftMargin", "FooterRightMargin", "FooterBodyDistance","FooterHeight", 0, 0, 500,500},
+    			{"FooterIsOn", "FooterLeftMargin", "FooterRightMargin", "FooterBodyDistance","FooterHeight", 600, 2000, 0,300},
+    			{"HeaderIsOn", "HeaderLeftMargin", "HeaderRightMargin", "HeaderBodyDistance","HeaderHeight", 1000, 2000, 500,500},
+    			{"HeaderIsOn", "HeaderLeftMargin", "HeaderRightMargin", "HeaderBodyDistance","HeaderHeight", 3000, 1500, 300,400},
+    			{"HeaderIsOn", "HeaderLeftMargin", "HeaderRightMargin", "HeaderBodyDistance","HeaderHeight", 0, 0, 500,500},
+    			{"HeaderIsOn", "HeaderLeftMargin", "HeaderRightMargin", "HeaderBodyDistance","HeaderHeight", 600, 2000, 0,300}
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test header/footer's left margin, right margin, spacing and height.
+     * @throws Exception
+     */
+    //@Ignore("#120796 - header/footer's margins are all set to 0 when export to DOC format")
+    @Ignore("#120798 - header/footer's spacing is increased when export to DOC file")
+	@Test
+	public void testFooterHeader() throws Exception
+	{		
+		XComponent xComponent = unoApp.newDocument("swriter");
+		//turn on header/footer		
+		SWUtil.setDefaultPageStyleProperty(xComponent, m_onProperty, new Boolean(true));
+		SWUtil.setDefaultPageStyleProperty(xComponent, m_LeftMarginProperty, Integer.valueOf(m_LeftMargin));
+		SWUtil.setDefaultPageStyleProperty(xComponent, m_RightMarginProperty, Integer.valueOf(m_RightMargin));
+		SWUtil.setDefaultPageStyleProperty(xComponent, m_BodyDistanceProperty, Integer.valueOf(m_BodyDistance));
+		SWUtil.setDefaultPageStyleProperty(xComponent, m_HeightProperty, Integer.valueOf(m_Height));
+		
+		//save as ODT and reopen, get border
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+        
+		int leftMargin = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_LeftMarginProperty)).intValue();
+		int rightMargin = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_RightMarginProperty)).intValue();
+		int bodyDistance = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_BodyDistanceProperty)).intValue();
+		int height = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_HeightProperty)).intValue();
+		
+		this.compare("ODT", leftMargin, rightMargin, bodyDistance, height);
+		
+		//save as DOC and reopen, get properties        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    leftMargin = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_LeftMarginProperty)).intValue();
+		rightMargin = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_RightMarginProperty)).intValue();
+		bodyDistance = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_BodyDistanceProperty)).intValue();
+		height = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, m_HeightProperty)).intValue();
+		
+		this.compare("DOC", leftMargin, rightMargin, bodyDistance, height);
+		
+		unoApp.closeDocument(xComponent);
+        
+	}
+	
+	private void compare(String preDescription, int leftMargin, int rightMargin, int bodyDistance, int height){		
+		Assert.assertEquals(preDescription + ":" + m_LeftMarginProperty,(double)m_LeftMargin, (double)leftMargin, 2);
+		Assert.assertEquals(preDescription + ":" + m_RightMarginProperty,(double)m_RightMargin, (double)rightMargin, 2);
+		Assert.assertEquals(preDescription + ":" + m_BodyDistanceProperty,(double)m_BodyDistance, (double)bodyDistance, 2);
+		Assert.assertEquals(preDescription + ":" + m_HeightProperty,(double)m_Height, (double)height, 2);			
+	}
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckFooterHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,181 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+
+/**
+ * test page's orientation, width, height, margins 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckPage {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String isLandscapeProperty = "IsLandscape";
+	private String widthProperty = "Width";
+	private String heightProperty = "Height";
+	private String topMarginProperty = "TopMargin";
+	private String bottomMarginProperty = "BottomMargin";
+	private String leftMarginProperty = "LeftMargin";
+	private String rightMarginProperty = "RightMargin";	
+	
+	private boolean isLandscape = false;
+	private int width = 0;
+	private int height = 0;
+	private int topMargin = 0;
+	private int bottomMargin = 0;
+	private int leftMargin = 0;
+	private int rightMargin = 0;	
+	
+	
+	public CheckPage(boolean isLandscape, int width, int height, int topMargin, int bottomMargin, int leftMargin, int rightMargin){
+		this.isLandscape = isLandscape;
+		this.width = width;
+		this.height = height;
+		this.topMargin = topMargin;
+		this.bottomMargin = bottomMargin;
+		this.leftMargin = leftMargin;
+		this.rightMargin = rightMargin;
+	}
+	
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{false,10000, 20000, 1000,2000, 0, 0},
+    			{false, 30000,40000, 0, 0, 100, 200},
+    			{true, 900, 10000, 0,0,0,0},
+    			{true, 20000, 30000, 300, 300, 300, 300}    			
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test page's orientation, width, height, margins 
+     * @throws Exception
+     */    
+	@Test
+	public void testPage() throws Exception
+	{		
+		XComponent xComponent = unoApp.newDocument("swriter");
+			
+		SWUtil.setDefaultPageStyleProperty(xComponent, isLandscapeProperty, new Boolean(this.isLandscape));
+		SWUtil.setDefaultPageStyleProperty(xComponent, widthProperty, Integer.valueOf(this.width));
+		SWUtil.setDefaultPageStyleProperty(xComponent, heightProperty, Integer.valueOf(this.height));
+		SWUtil.setDefaultPageStyleProperty(xComponent, topMarginProperty, Integer.valueOf(this.topMargin));
+		SWUtil.setDefaultPageStyleProperty(xComponent, bottomMarginProperty, Integer.valueOf(this.bottomMargin));
+		SWUtil.setDefaultPageStyleProperty(xComponent, leftMarginProperty, Integer.valueOf(this.leftMargin));
+		SWUtil.setDefaultPageStyleProperty(xComponent, rightMarginProperty, Integer.valueOf(this.rightMargin));
+		
+		//save as ODT and reopen, get border
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+        
+        boolean actualIsLandScape = ((Boolean)SWUtil.getDefaultPageStyleProperty(xComponent, isLandscapeProperty)).booleanValue();
+		int actualWidth = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, widthProperty)).intValue();
+		int actualHeight = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, heightProperty)).intValue();
+		int actualTop = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, topMarginProperty)).intValue();
+		int actualBottom = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, bottomMarginProperty)).intValue();
+		int actualLeft = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, leftMarginProperty)).intValue();
+		int actualRight = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, rightMarginProperty)).intValue();
+        
+		
+		
+		this.compare("ODT", actualIsLandScape,actualWidth,actualHeight,actualTop,actualBottom, actualLeft,actualRight);
+		
+		//save as DOC and reopen, get properties        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    
+	    actualIsLandScape = ((Boolean)SWUtil.getDefaultPageStyleProperty(xComponent, isLandscapeProperty)).booleanValue();
+	    actualWidth = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, widthProperty)).intValue();
+		actualHeight = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, heightProperty)).intValue();
+		actualTop = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, topMarginProperty)).intValue();
+		actualBottom = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, bottomMarginProperty)).intValue();
+		actualLeft = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, leftMarginProperty)).intValue();
+		actualRight = ((Integer)SWUtil.getDefaultPageStyleProperty(xComponent, rightMarginProperty)).intValue();
+		
+		this.compare("DOC", actualIsLandScape,actualWidth,actualHeight,actualTop,actualBottom, actualLeft,actualRight);
+		
+		unoApp.closeDocument(xComponent);
+        
+	}
+	
+	private void compare(String preDescription, boolean isLandScape, int width, int height, int top, int bottom, int left, int right){		
+		Assert.assertEquals(preDescription + ":" + this.isLandscapeProperty,this.isLandscape, isLandScape);
+		Assert.assertEquals(preDescription + ":" + this.widthProperty,(double)this.width, (double)width, 2);
+		Assert.assertEquals(preDescription + ":" + this.heightProperty,(double)this.height, (double)height, 2);
+		Assert.assertEquals(preDescription + ":" + this.topMarginProperty,(double)this.topMargin, (double)top, 2);	
+		Assert.assertEquals(preDescription + ":" + this.bottomMarginProperty,(double)this.bottomMargin, (double)bottom, 2);
+		Assert.assertEquals(preDescription + ":" + this.leftMarginProperty,(double)this.leftMargin, (double)left, 2);
+		Assert.assertEquals(preDescription + ":" + this.rightMarginProperty,(double)this.rightMargin, (double)right, 2);		
+	}
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,145 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.lang.Enum;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+import com.sun.star.style.PageStyleLayout;
+
+/**
+ * test page's layout settings 
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckPageLayout {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String pageStyleLayoutProperty = "PageStyleLayout";	
+	
+	private PageStyleLayout pageStyleLayout = PageStyleLayout.getDefault();	
+	
+	
+	public CheckPageLayout(int styleValue){
+		this.pageStyleLayout = PageStyleLayout.fromInt(styleValue);
+	}
+	/**
+	 * 0:ALL
+	 * 1:LEFT
+	 * 2:RIGHT
+	 * 3:MIRRORED
+	 * @return
+	 */
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{0},
+    			{1},
+    			{2},
+    			{3}    			
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test page's layout settings 
+     * @throws Exception
+     */   
+    @Ignore("#120964 - page layout 'only left' and 'only right' all changed to default value 'right and left' after export to doc format in AOO")
+	@Test
+	public void testPageStyleLayout() throws Exception
+	{		
+		XComponent xComponent = unoApp.newDocument("swriter");		
+		SWUtil.setDefaultPageStyleProperty(xComponent, this.pageStyleLayoutProperty, this.pageStyleLayout);
+		
+		//save as ODT and reopen, get border
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+        
+       	PageStyleLayout actualPageStyleLayout = (PageStyleLayout)SWUtil.getDefaultPageStyleProperty(xComponent, this.pageStyleLayoutProperty);
+				
+		this.compare("ODT", actualPageStyleLayout);
+		
+		//save as DOC and reopen, get properties        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    
+	    actualPageStyleLayout = (PageStyleLayout)SWUtil.getDefaultPageStyleProperty(xComponent, this.pageStyleLayoutProperty);
+		
+	    this.compare("DOC", actualPageStyleLayout);
+		
+		unoApp.closeDocument(xComponent);
+        
+	}
+	
+	private void compare(String preDescription, PageStyleLayout actual){		
+		Assert.assertEquals(preDescription + ":" + this.pageStyleLayoutProperty,this.pageStyleLayout.getValue(), actual.getValue());
+	}
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckPageLayout.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java?rev=1388771&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java Sat Sep 22 11:20:30 2012
@@ -0,0 +1,176 @@
+/**************************************************************
+ * 
+ * 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 testcase.uno.sw.page;
+
+import static org.openoffice.test.common.Testspace.*;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SWUtil;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.BorderLine;
+import com.sun.star.table.ShadowFormat;
+import com.sun.star.table.ShadowLocation;
+
+/**
+ * test footer/header's border's shadow format. 
+ * test page border's shadow format
+ *
+ */
+@RunWith(Parameterized.class)
+public class CheckShadowFormat {
+	UnoApp unoApp = new UnoApp();
+	XTextDocument textDocument = null;
+	File temp = null;
+	String tempFilePathODT = "";	
+	String tempFilePathDOC = "";	
+	
+	private String onProperty = "";
+	private String shadowFormatProperty = "";
+	
+	private ShadowFormat shadowFormat = null;		
+	
+	public CheckShadowFormat(String onProperty, String shadowFormatProperty, int locationValue, int width, 
+			boolean isTransparent, int color){
+		this.onProperty = onProperty;
+		this.shadowFormatProperty = shadowFormatProperty;
+		this.shadowFormat = new ShadowFormat();
+		this.shadowFormat.Location = ShadowLocation.fromInt(locationValue);
+		this.shadowFormat.ShadowWidth = (short)width;
+		this.shadowFormat.IsTransparent = isTransparent;
+		this.shadowFormat.Color = color;
+	}
+	
+	/**
+	 * ShadowLocation
+	 * 0:NONE
+	 * 1:TOP_LEFT
+	 * 2:TOP_RIGHT
+	 * 3:BOTTOM_LEFT
+	 * 4:BOTTOM_RIGHT
+	 * @return
+	 */
+	@Parameters
+    public static Collection<Object[]> data(){
+    	Object[][] params = new Object[][]{
+    			{"FooterIsOn", "ShadowFormat", 0, 200, false,255},
+    			{"FooterIsOn", "ShadowFormat", 1, 500, false,256},
+    			{"FooterIsOn", "ShadowFormat", 2, 50, false,65535},
+    			{"FooterIsOn", "ShadowFormat", 3, 30, false,65536},
+    			{"FooterIsOn", "ShadowFormat", 4, 1000, false,255},
+    			{"FooterIsOn", "FooterShadowFormat", 0, 200, false,256},
+    			{"FooterIsOn", "FooterShadowFormat", 1, 500, false,65535},
+    			{"FooterIsOn", "FooterShadowFormat", 2, 50, false,65536},
+    			{"FooterIsOn", "FooterShadowFormat", 3, 30, false,255},
+    			{"FooterIsOn", "FooterShadowFormat", 4, 1000, false,256},
+    			{"HeaderIsOn", "HeaderShadowFormat", 0, 200, false,65535},
+    			{"HeaderIsOn", "HeaderShadowFormat", 1, 500, false,65536},
+    			{"HeaderIsOn", "HeaderShadowFormat", 2, 50, false,255},
+    			{"HeaderIsOn", "HeaderShadowFormat", 3, 30, false,256},
+    			{"HeaderIsOn", "HeaderShadowFormat", 4, 1000, false,65536}
+    			};
+    	return Arrays.asList(params);
+    }	
+    
+    /**
+     * test footer/header's border's shadow format. 
+     * test page border's shadow format
+     * @throws Exception
+     */
+    @Ignore("#120969 - page and page's footer/header's shadow style lost after export to doc format in AOO")
+    @Test
+	public void testFooterHeader() throws Exception
+	{    	
+		XComponent xComponent = unoApp.newDocument("swriter");
+		//turn on header/footer		
+		SWUtil.setDefaultPageStyleProperty(xComponent, onProperty, new Boolean(true));
+		SWUtil.setDefaultPageStyleProperty(xComponent, shadowFormatProperty, this.shadowFormat);		
+		
+		//save as ODT and reopen, get border
+		unoApp.saveDocument(xComponent, tempFilePathODT);        
+        unoApp.closeDocument(xComponent);
+        xComponent = unoApp.loadDocument(tempFilePathODT);        
+        
+		ShadowFormat actualShadowFormat = (ShadowFormat)SWUtil.getDefaultPageStyleProperty(xComponent, shadowFormatProperty);		
+		
+		this.compare("ODT", actualShadowFormat);
+		
+		//save as DOC and reopen, get properties        
+	    SWUtil.saveAsDoc(xComponent, FileUtil.getUrl(tempFilePathDOC));
+	    unoApp.closeDocument(xComponent);
+	    xComponent = unoApp.loadDocument(tempFilePathDOC);	
+	    actualShadowFormat = (ShadowFormat)SWUtil.getDefaultPageStyleProperty(xComponent, shadowFormatProperty);
+		
+		this.compare("DOC", actualShadowFormat);
+		
+		unoApp.closeDocument(xComponent);
+        
+	}
+	
+	private void compare(String preDescription, ShadowFormat actual){		
+		Assert.assertEquals(preDescription + ":" + shadowFormatProperty + "-->Location",this.shadowFormat.Location.getValue(), actual.Location.getValue());
+		//check shadow width, isTransparent, color if shadow location is not NONE
+		if(!this.shadowFormat.Location.equals(ShadowLocation.NONE)){
+			Assert.assertEquals(preDescription + ":" + shadowFormatProperty + "-->Width",(double)this.shadowFormat.ShadowWidth, (double)actual.ShadowWidth, 2);
+			Assert.assertEquals(preDescription + ":" + shadowFormatProperty + "-->IsTransparent",this.shadowFormat.IsTransparent, actual.IsTransparent);
+			Assert.assertEquals(preDescription + ":" + shadowFormatProperty + "-->Color",this.shadowFormat.Color, actual.Color);
+		}		
+	}
+		
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		unoApp.start();
+		
+		FileUtil.deleteFile(getPath("temp"));
+		temp = new File(getPath("temp"));
+		temp.mkdirs();		
+		
+		tempFilePathODT = temp + "/tempFilePathODT.odt";
+		tempFilePathDOC = temp + "/tempFilePathDOC.doc";		
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.close();
+	}	
+	
+
+}

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sw/page/CheckShadowFormat.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/ooo/trunk/test/testuno/source/testlib/uno/SWUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testlib/uno/SWUtil.java?rev=1388771&r1=1388770&r2=1388771&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testlib/uno/SWUtil.java (original)
+++ incubator/ooo/trunk/test/testuno/source/testlib/uno/SWUtil.java Sat Sep 22 11:20:30 2012
@@ -25,15 +25,18 @@ import org.openoffice.test.uno.UnoApp;
 
 import com.sun.star.beans.PropertyValue;
 import com.sun.star.beans.XPropertySet;
-import com.sun.star.container.XEnumeration;
-import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
 import com.sun.star.container.XNamed;
 import com.sun.star.document.XDocumentInfo;
 import com.sun.star.document.XDocumentInfoSupplier;
 import com.sun.star.frame.XStorable;
 import com.sun.star.io.IOException;
+import com.sun.star.lang.XComponent;
 import com.sun.star.lang.XMultiServiceFactory;
 import com.sun.star.style.BreakType;
+import com.sun.star.style.XStyle;
+import com.sun.star.style.XStyleFamiliesSupplier;
 import com.sun.star.text.ControlCharacter;
 import com.sun.star.text.XText;
 import com.sun.star.text.XTextContent;
@@ -53,6 +56,10 @@ public class SWUtil {
  		
  	}
  
+	public static void saveAsDoc(XComponent component, String url) throws IOException{
+		XTextDocument document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
+		saveAs(document, "MS Word 97", url);		
+	}
 
 	public static void saveAsODT(XTextDocument document, String url) throws IOException {
  		saveAs(document, "writer8", url);
@@ -183,6 +190,43 @@ public class SWUtil {
 		XPropertySet xps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xcont);
 		Integer pageCount = (Integer) xps.getPropertyValue("PageCount"); 
 		return pageCount.intValue();
+	}	
+	
+	
+	/**
+	 * get specific property value of the default page style
+	 * @param xComponent
+	 * @param propertyName
+	 * @return
+	 * @throws Exception
+	 */
+	public static Object getDefaultPageStyleProperty(XComponent xComponent, String propertyName) throws Exception
+	{
+		XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+		XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, textDocument);	     
+        XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (XNameAccess.class, xSupplier.getStyleFamilies());        
+        XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xFamilies.getByName("PageStyles"));        
+        XStyle xStyle = (XStyle)UnoRuntime.queryInterface(XStyle.class, xFamily.getByName("Default"));     
+        XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);  
+        Object propertyValue = xStyleProps.getPropertyValue(propertyName.toString());
+        return propertyValue;       
 	}
 	
+	/**
+	 * set value for specific property of default page style.
+	 * @param xComponent
+	 * @param propertyName
+	 * @param propertyValue
+	 * @throws Exception
+	 */
+	public static void setDefaultPageStyleProperty(XComponent xComponent, String propertyName, Object propertyValue) throws Exception
+	{
+		XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);		
+        XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, textDocument);     
+        XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (XNameAccess.class, xSupplier.getStyleFamilies());        
+        XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xFamilies.getByName("PageStyles"));        
+        XStyle xStyle = (XStyle)UnoRuntime.queryInterface(XStyle.class, xFamily.getByName("Default"));     
+        XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);        
+        xStyleProps.setPropertyValue (propertyName.toString(), propertyValue);
+	}
 }



Mime
View raw message