You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by li...@apache.org on 2012/08/23 05:02:42 UTC
svn commit: r1376353 [1/2] - in
/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph: ./
Desert.jpg ParagraphAlignment.java ParagraphBackColor.java
ParagraphBackGraphic.java ParagraphIndentAndSpacing.java
ParagraphLineSpacing.java
Author: liuzhe
Date: Thu Aug 23 03:02:42 2012
New Revision: 1376353
URL: http://svn.apache.org/viewvc?rev=1376353&view=rev
Log:
#120651# - [testuno]paragraph general function test script of word processor via UNO API
Patch by: Du Jing <bj...@gmail.com>
Review by: Liu Zhe <al...@gmail.com>
Added:
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/Desert.jpg (with props)
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphAlignment.java
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackColor.java
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackGraphic.java
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphIndentAndSpacing.java
incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphLineSpacing.java
Added: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/Desert.jpg
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/Desert.jpg?rev=1376353&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/Desert.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphAlignment.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphAlignment.java?rev=1376353&view=auto
==============================================================================
--- incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphAlignment.java (added)
+++ incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphAlignment.java Thu Aug 23 03:02:42 2012
@@ -0,0 +1,268 @@
+package testcase.uno.sw.paragraph;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.common.Testspace;
+import org.openoffice.test.uno.UnoApp;
+import com.sun.star.text.*;
+import com.sun.star.beans.*;
+import com.sun.star.frame.XStorable;
+import com.sun.star.uno.UnoRuntime;
+
+public class ParagraphAlignment {
+ private static final UnoApp app = new UnoApp();
+ XText xText = null;
+
+ @Before
+ public void setUp() throws Exception {
+ app.start();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ app.close();
+ }
+ /*
+ * test paragraph alignment is justified
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph alignment is justified,and last line align to left,check expand single word
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph alignment
+ */
+ @Test@Ignore //bug120636_the expand single word option disable when save to doc
+ public void testParagraphAlignmentJustified() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //apply paragraph alignment as justified and last line alignment
+ xTextCursor.gotoStart(false);
+ xTextCursor.goRight((short)180 , true);
+ xCursorProps.setPropertyValue("ParaAdjust",com.sun.star.style.ParagraphAdjust.BLOCK);
+ xCursorProps.setPropertyValue("ParaLastLineAdjust", com.sun.star.style.ParagraphAdjust.LEFT);
+ xCursorProps.setPropertyValue("ParaExpandSingleWord", true);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document and assert table margin to page setting
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XTextCursor xTextCursor_assert_odt = assertDocument_odt.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_odt);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is justified",(short)2,xCursorProps_assert_odt.getPropertyValue("ParaAdjust"));
+ assertEquals("assert first paragraph last line alignment is left",(short)0, xCursorProps_assert_odt.getPropertyValue("ParaLastLineAdjust"));
+ assertEquals("assert expand single word is true",true,xCursorProps_assert_odt.getPropertyValue("ParaExpandSingleWord"));
+
+ //reopen the document and assert table margin to page setting
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XTextCursor xTextCursor_assert_doc = assertDocument_doc.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_doc);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is justified",(short)2,xCursorProps_assert_doc.getPropertyValue("ParaAdjust"));
+ assertEquals("assert first paragraph last line alignment is left",(short)0, xCursorProps_assert_doc.getPropertyValue("ParaLastLineAdjust"));
+ assertEquals("assert expand single word is true",true,xCursorProps_assert_doc.getPropertyValue("ParaExpandSingleWord"));
+
+ }
+ /*
+ * test paragraph alignment is left
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph alignment is left
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph alignment
+ */
+ @Test
+ public void testParagraphAlignmentLeft() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ xTextCursor.gotoStart(false);
+ xTextCursor.goRight((short)180 , true);
+ xCursorProps.setPropertyValue("ParaAdjust",com.sun.star.style.ParagraphAdjust.LEFT);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+
+ app.closeDocument(xTextDocument);
+
+ //reopen the odt document and assert paragraph alignment
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XTextCursor xTextCursor_assert_odt = assertDocument_odt.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_odt);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is left",(short)0,xCursorProps_assert_odt.getPropertyValue("ParaAdjust"));
+ //reopen the doc document and assert paragraph alignment
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XTextCursor xTextCursor_assert_doc = assertDocument_doc.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_doc);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is left",(short)0,xCursorProps_assert_doc.getPropertyValue("ParaAdjust"));
+
+
+ }
+ /*
+ * test paragraph alignment is justified
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph alignment is right
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph alignment
+ */
+ @Test
+ public void testParagraphAlignmentRight() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //apply paragraph alignment as justified and last line alignment
+ xTextCursor.gotoStart(false);
+ xTextCursor.goRight((short)180 , true);
+ xCursorProps.setPropertyValue("ParaAdjust",com.sun.star.style.ParagraphAdjust.RIGHT);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document and assert paragraph alignment
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XTextCursor xTextCursor_assert_odt = assertDocument_odt.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_odt);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is right",(short)1,xCursorProps_assert_odt.getPropertyValue("ParaAdjust"));
+ //reopen the document and assert paragraph alignment
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XTextCursor xTextCursor_assert_doc = assertDocument_doc.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_doc);
+ //verify paragraph alignment property
+ assertEquals("assert first paragraph alignment is right",(short)1,xCursorProps_assert_doc.getPropertyValue("ParaAdjust"));
+ }
+ /*
+ * test paragraph alignment is justified
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph alignment is center
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph alignment
+ */
+ @Test
+ public void testParagraphAlignmentCenter() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //apply paragraph alignment as justified and last line alignment
+ xTextCursor.gotoStart(false);
+ xTextCursor.goRight((short)180 , true);
+ xCursorProps.setPropertyValue("ParaAdjust",com.sun.star.style.ParagraphAdjust.CENTER);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+
+ app.closeDocument(xTextDocument);
+
+ //reopen the document and assert paragraph alignment
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XTextCursor xTextCursor_assert_odt = assertDocument_odt.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_odt);
+ assertEquals("assert first paragraph alignment is center",(short)3,xCursorProps_assert_odt.getPropertyValue("ParaAdjust"));
+ //reopen the document and assert paragraph alignment
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XTextCursor xTextCursor_assert_doc = assertDocument_doc.getText().createTextCursor();
+ XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_doc);
+ assertEquals("assert first paragraph alignment is center",(short)3,xCursorProps_assert_doc.getPropertyValue("ParaAdjust"));
+ }
+}
Added: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackColor.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackColor.java?rev=1376353&view=auto
==============================================================================
--- incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackColor.java (added)
+++ incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackColor.java Thu Aug 23 03:02:42 2012
@@ -0,0 +1,84 @@
+package testcase.uno.sw.paragraph;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.common.Testspace;
+import org.openoffice.test.uno.UnoApp;
+import com.sun.star.text.*;
+import com.sun.star.beans.*;
+import com.sun.star.frame.XStorable;
+import com.sun.star.uno.UnoRuntime;
+
+public class ParagraphBackColor {
+ private static final UnoApp app = new UnoApp();
+ XText xText = null;
+
+ @Before
+ public void setUp() throws Exception {
+ app.start();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ app.close();
+ }
+ /*
+ * test paragraph background color
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with color
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background color
+ */
+ @Test
+ public void testParagraphBackColorSetting() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackColor",0x0000FF00);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background color
+ assertEquals("assert first paragraph line spacing is fix",0x0000FF00,xCursorProps_Assert_odt.getPropertyValue("ParaBackColor"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background color
+ assertEquals("assert first paragraph line spacing is fix",0x0000FF00,xCursorProps_Assert_doc.getPropertyValue("ParaBackColor"));
+ }
+}
Added: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackGraphic.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackGraphic.java?rev=1376353&view=auto
==============================================================================
--- incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackGraphic.java (added)
+++ incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphBackGraphic.java Thu Aug 23 03:02:42 2012
@@ -0,0 +1,747 @@
+package testcase.uno.sw.paragraph;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.common.Testspace;
+import org.openoffice.test.uno.UnoApp;
+import com.sun.star.text.*;
+import com.sun.star.beans.*;
+import com.sun.star.frame.XStorable;
+import com.sun.star.uno.UnoRuntime;
+
+public class ParagraphBackGraphic {
+ private static final UnoApp app = new UnoApp();
+ XText xText = null;
+
+ @Before
+ public void setUp() throws Exception {
+ app.start();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ app.close();
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is left bottom
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_LeftBottom() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_BOTTOM);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is left middle
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_LeftMiddle() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_MIDDLE);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is left top
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_LeftTop() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_TOP);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is middle bottom
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_MiddleBottom() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is middle middle
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_MiddleMiddle() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is middle top
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_MiddleTop() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_TOP);
+ //save and reload text document
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is right bottom
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_RightBottom() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is right middle
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_RightMiddle() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is right top
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_RightTop() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_TOP);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is area
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_Area() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.AREA);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.AREA,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.AREA,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is titled
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test@Ignore //bug120638_graphic background lost when save to doc
+ public void testParagraphBackGraphic_Titled() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")));
+ xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export");
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.TILED);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.TILED,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraphtable/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.TILED,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+ assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter"));
+ assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/paragraph/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL"));
+ }
+ /*
+ * test paragraph background graphic
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph background with graphic and graphic location is none
+ * 4.save and close the document
+ * 5.reload the saved document and check the paragraph background graphic
+ */
+ @Test
+ public void testParagraphBackGraphic_Nonne() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph background color
+ xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.NONE);
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.NONE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation"));
+
+ //reopen the document
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph background graphic
+ assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.NONE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation"));
+
+ }
+}
Added: incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphIndentAndSpacing.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphIndentAndSpacing.java?rev=1376353&view=auto
==============================================================================
--- incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphIndentAndSpacing.java (added)
+++ incubator/ooo/trunk/main/test/testuno/source/testcase/uno/sw/paragraph/ParagraphIndentAndSpacing.java Thu Aug 23 03:02:42 2012
@@ -0,0 +1,149 @@
+package testcase.uno.sw.paragraph;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.common.Testspace;
+import org.openoffice.test.uno.UnoApp;
+import com.sun.star.text.*;
+import com.sun.star.beans.*;
+import com.sun.star.frame.XStorable;
+import com.sun.star.uno.UnoRuntime;
+
+public class ParagraphIndentAndSpacing {
+ private static final UnoApp app = new UnoApp();
+ XText xText = null;
+
+ @Before
+ public void setUp() throws Exception {
+ app.start();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ app.close();
+ }
+ /*
+ * test paragraph spacing
+ * 1.new a text document
+ * 2.insert some text
+ * 3.set paragraph spacing:before text,after text,above paragraph,below paragraph
+ * 4.save to odt and close it
+ * 5.reopen the saved document and check the paragraph spacing
+ */
+ @Test
+ public void testParagraphSpacingSetting() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph margin with page border
+ xCursorProps.setPropertyValue("ParaLeftMargin",2000);
+ xCursorProps.setPropertyValue("ParaRightMargin",3000);
+ xCursorProps.setPropertyValue("ParaTopMargin",1000);
+ xCursorProps.setPropertyValue("ParaBottomMargin",4000);
+ xCursorProps.setPropertyValue("ParaFirstLineIndent",4000);
+
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+ //reopen the document and assert line spacing
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph indent and spacing
+ assertEquals("assert before text margin",2000,xCursorProps_Assert_odt.getPropertyValue("ParaLeftMargin"));
+ assertEquals("assert after text margin",3000,xCursorProps_Assert_odt.getPropertyValue("ParaRightMargin"));
+ assertEquals("assert above paragraph margin",1000,xCursorProps_Assert_odt.getPropertyValue("ParaTopMargin"));
+ assertEquals("assert below paragraph margin",4001,xCursorProps_Assert_odt.getPropertyValue("ParaBottomMargin"));
+ assertEquals("assert first line indent",4001,xCursorProps_Assert_odt.getPropertyValue("ParaFirstLineIndent"));
+ assertEquals("assert paragraph first line is no autoindent",false,xCursorProps_Assert_odt.getPropertyValue("ParaIsAutoFirstLineIndent"));
+
+ //reopen the document and assert line spacing
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph indent and spacing
+ assertEquals("assert before text margin",2000,xCursorProps_Assert_doc.getPropertyValue("ParaLeftMargin"));
+ assertEquals("assert after text margin",3000,xCursorProps_Assert_doc.getPropertyValue("ParaRightMargin"));
+ assertEquals("assert above paragraph margin",1000,xCursorProps_Assert_doc.getPropertyValue("ParaTopMargin"));
+ assertEquals("assert below paragraph margin",4001,xCursorProps_Assert_doc.getPropertyValue("ParaBottomMargin"));
+ assertEquals("assert first line indent",4001,xCursorProps_Assert_doc.getPropertyValue("ParaFirstLineIndent"));
+ assertEquals("assert paragraph first line is no autoindent",false,xCursorProps_Assert_doc.getPropertyValue("ParaIsAutoFirstLineIndent"));
+ }
+ @Test@Ignore //bug 120646_the auto indent effect of first line lost when save to doc
+ public void testParagraphIndent() throws Exception {
+
+ XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
+ xText = xTextDocument.getText();
+ xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" +
+ "Hello,world!Hello,world!");
+ // create text cursor for selecting and formatting text
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
+ //set paragraph margin with page border
+ xCursorProps.setPropertyValue("ParaIsAutoFirstLineIndent",true);
+
+ //save to odt
+ XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
+ aStoreProperties_odt[0] = new PropertyValue();
+ aStoreProperties_odt[1] = new PropertyValue();
+ aStoreProperties_odt[0].Name = "Override";
+ aStoreProperties_odt[0].Value = true;
+ aStoreProperties_odt[1].Name = "FilterName";
+ aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
+ xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
+ //save to doc
+ XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
+ aStoreProperties_doc[0] = new PropertyValue();
+ aStoreProperties_doc[1] = new PropertyValue();
+ aStoreProperties_doc[0].Name = "Override";
+ aStoreProperties_doc[0].Value = true;
+ aStoreProperties_doc[1].Name = "FilterName";
+ aStoreProperties_doc[1].Value = "MS Word 97";
+ xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
+ app.closeDocument(xTextDocument);
+
+
+ //reopen the document and assert paragraph indent
+ XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
+ XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
+ //verify paragraph auto indent
+ assertEquals("assert paragraph first line is autoindent",true,xCursorProps_Assert_doc.getPropertyValue("ParaIsAutoFirstLineIndent"));
+
+ //reopen the document and assert paragraph indent
+ XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
+ XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
+ //verify paragraph auto indent
+ assertEquals("assert paragraph first line is autoindent",true,xCursorProps_Assert_odt.getPropertyValue("ParaIsAutoFirstLineIndent"));
+ }
+
+}