diff options
author | Liu Zhe <liuzhe@apache.org> | 2012-08-27 01:24:28 +0000 |
---|---|---|
committer | Liu Zhe <liuzhe@apache.org> | 2012-08-27 01:24:28 +0000 |
commit | 9b31e8a316bb9ab87c2a9fc7f613a0e9b48f2419 (patch) | |
tree | f822c2b198e40f5583d448e844e865dec59b6e9d | |
parent | 7da4aa5d517aab4147e51c215cea7b50a48676e2 (diff) |
#120690 - [testuno]puretext general function test script of word processor via UNO API
Patch by: Du Jing <bjdujing@gmail.com>
Review by: Liu Zhe <aliuzhe@gmail.com>
Notes
Notes:
ignore: vclauto
22 files changed, 2888 insertions, 1 deletions
diff --git a/test/testuno/source/org/openoffice/test/uno/UnoApp.java b/test/testuno/source/org/openoffice/test/uno/UnoApp.java index 53a7112ad105..052c55c38d2c 100644 --- a/test/testuno/source/org/openoffice/test/uno/UnoApp.java +++ b/test/testuno/source/org/openoffice/test/uno/UnoApp.java @@ -60,7 +60,7 @@ public class UnoApp { private double reconnectInterval = 2; - private int reconnectCount = 5; + private int reconnectCount = 10; public UnoApp() { this.openOffice = OpenOffice.getDefault(); diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterBackColor.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterBackColor.java new file mode 100644 index 000000000000..49486b427c67 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterBackColor.java @@ -0,0 +1,77 @@ +package testcase.uno.sw.puretext; + +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 CharacterBackColor { + 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 + public void testCharacterBackColorSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharBackColor", 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 and assert row height setting + 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 set property + assertEquals("assert character color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharBackColor")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharBackColor")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterBlink.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterBlink.java new file mode 100644 index 000000000000..fb6bad118159 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterBlink.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterBlink { + 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 character color + * 1.new a text document and insert some character + * 2.set character hidden + * 3.save and reopen the document + * 4.check the character color + */ + @Test + public void testCharacterBlinkSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharFlash", 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 row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_odt.getPropertyValue("CharFlash")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_doc.getPropertyValue("CharFlash")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterChangeCase.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterChangeCase.java new file mode 100644 index 000000000000..8eeafad895f3 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterChangeCase.java @@ -0,0 +1,268 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterChangeCase { + 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 + public void testCharacterLowerCaseSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("We are Chinese they are American We are all living in one earth " + + "And we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharCaseMap",new Short(com.sun.star.style.CaseMap.LOWERCASE)); + //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); + //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); + + app.closeDocument(xTextDocument); + + //reopen the document and assert case map + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.LOWERCASE,xCursorProps_assert_odt.getPropertyValue("CharCaseMap")); + + //when save to doc,lower case setting by UNO API lost,change to default. + //reopen the document and assert case map + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.NONE,xCursorProps_assert_doc.getPropertyValue("CharCaseMap")); + } + @Test + public void testCharacterUpperCaseSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharCaseMap",com.sun.star.style.CaseMap.UPPERCASE); + //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 row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.UPPERCASE,xCursorProps_assert_odt.getPropertyValue("CharCaseMap")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.UPPERCASE,xCursorProps_assert_doc.getPropertyValue("CharCaseMap")); + } + @Test + public void testCharacterSmallCapsSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharCaseMap",com.sun.star.style.CaseMap.SMALLCAPS); + //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 row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.SMALLCAPS,xCursorProps_assert_odt.getPropertyValue("CharCaseMap")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.SMALLCAPS,xCursorProps_assert_doc.getPropertyValue("CharCaseMap")); + } + @Test + public void testCharacterCapitalEveryWordSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("we are Chinese they are American we are all living in one earth " + + "and we all love our home very much!!!"); + // 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) 110, true); + xCursorProps.setPropertyValue("CharCaseMap",new Short(com.sun.star.style.CaseMap.TITLE)); + //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 row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.TITLE,xCursorProps_assert_odt.getPropertyValue("CharCaseMap")); + + //reopen the document and assert row height setting + 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 set property,when save to doc and reopen,the proeprty value change to default,but display is normally + assertEquals("assert character casemap",com.sun.star.style.CaseMap.NONE,xCursorProps_assert_doc.getPropertyValue("CharCaseMap")); + } + @Test + public void testCharacterNoCaseSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("we are Chinese they are American we are all living in one earth " + + "and we all love our home very much!!!"); + // 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) 110, true); + xCursorProps.setPropertyValue("CharCaseMap",new Short(com.sun.star.style.CaseMap.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 and assert row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.NONE,xCursorProps_assert_odt.getPropertyValue("CharCaseMap")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character casemap",com.sun.star.style.CaseMap.NONE,xCursorProps_assert_doc.getPropertyValue("CharCaseMap")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterColor.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterColor.java new file mode 100644 index 000000000000..557edb40707c --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterColor.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterColor { + 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 character color + * 1.new a text document and insert some character + * 2.set character color as green(0x0000FF00) + * 3.save and reopen the document + * 4.check the character color + */ + @Test + public void testCharacterColorSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharColor", 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 and assert row height setting + 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 set property + assertEquals("assert character color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharColor")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharColor")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterEmphasis.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterEmphasis.java new file mode 100644 index 000000000000..34a65123fddf --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterEmphasis.java @@ -0,0 +1,207 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterEmphasis { + 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@Ignore //bug120657_charmode change to disable from enable when save to doc. + public void testCharacterEmphasisSetting() 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!" + + "and we all love our home very much!!!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American." + + " We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!"); + // 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) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.ACCENT_ABOVE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.ACCENT_BELOW)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.CIRCLE_ABOVE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.CIRCLE_BELOW)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.DISK_ABOVE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.DISK_BELOW)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.DOT_ABOVE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.DOT_BELOW)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharEmphasis", new Short(com.sun.star.text.FontEmphasis.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 and assert character emphasis + 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); + + xTextCursor_assert_odt.gotoStart(false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.ACCENT_ABOVE,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.ACCENT_BELOW,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.CIRCLE_ABOVE,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.CIRCLE_BELOW,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DISK_ABOVE,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DISK_BELOW,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DOT_ABOVE,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DOT_BELOW,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.NONE,xCursorProps_assert_odt.getPropertyValue("CharEmphasis")); + + //reopen the document and assert character emphasis + 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); + + xTextCursor_assert_doc.gotoStart(false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.ACCENT_ABOVE,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.ACCENT_BELOW,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.CIRCLE_ABOVE,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.CIRCLE_BELOW,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DISK_ABOVE,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DISK_BELOW,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DOT_ABOVE,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.DOT_BELOW,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert overline",com.sun.star.text.FontEmphasis.NONE,xCursorProps_assert_doc.getPropertyValue("CharEmphasis")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterFontname.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterFontname.java new file mode 100644 index 000000000000..e1183a417f56 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterFontname.java @@ -0,0 +1,268 @@ +package testcase.uno.sw.puretext; + +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 CharacterFontname { + 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 + public void testCharacterFontSetting() 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!" + + "and we all love our home very much!!!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American." + + " We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!"); + // 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) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Times New Roman"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Arial Black"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Aharoni"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Agency FB"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Algerian"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Andalus"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Bodoni MT Black"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "BatangChe"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Britannic Bold"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Cooper Black"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "DaunPenh"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Estrangelo Edessa"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Wingdings"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Rage Italic"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Symbol"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Tw Cen MT Condensed Extra Bold"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Vivaldi"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "SimSun"); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharFontName", "Lucida Bright"); + //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 font style + XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); + XTextCursor xTextCursor_assert = assertDocument.getText().createTextCursor(); + XPropertySet xCursorProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert); + + xTextCursor_assert.gotoStart(false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Times New Roman",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Arial Black",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Aharoni",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Agency FB",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Algerian",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Andalus",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Bodoni MT Black",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("BatangChe",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Britannic Bold",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Cooper Black",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("DaunPenh",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Estrangelo Edessa",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Wingdings",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Rage Italic",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Symbol",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Tw Cen MT Condensed Extra Bold",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Vivaldi",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("SimSun",xCursorProps_assert.getPropertyValue("CharFontName")); + xTextCursor_assert.gotoRange(xTextCursor_assert, false); + xTextCursor_assert.goRight((short) 100, true); + assertEquals("Lucida Bright",xCursorProps_assert.getPropertyValue("CharFontName")); + + //reopen the document and assert font style + XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); + XTextCursor xTextCursor_assert_doc = assertDocument_doc.getText().createTextCursor(); + XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor_assert_doc); + + xTextCursor_assert_doc.gotoStart(false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Times New Roman",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Arial Black",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Aharoni",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Agency FB",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Algerian",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Andalus",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Bodoni MT Black",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("BatangChe",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Britannic Bold",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Cooper Black",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("DaunPenh",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Estrangelo Edessa",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Wingdings",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Rage Italic",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Symbol",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Tw Cen MT Condensed Extra Bold",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Vivaldi",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("SimSun",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("Lucida Bright",xCursorProps_assert_doc.getPropertyValue("CharFontName")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterHidden.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterHidden.java new file mode 100644 index 000000000000..38f58094ec67 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterHidden.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterHidden { + 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 character color + * 1.new a text document and insert some character + * 2.set character hidden + * 3.save and reopen the document + * 4.check the character color + */ + @Test + public void testCharacterHiddenSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharHidden", 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 row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_odt.getPropertyValue("CharHidden")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_doc.getPropertyValue("CharHidden")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterHyperlink.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterHyperlink.java new file mode 100644 index 000000000000..30b0a2dfc54b --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterHyperlink.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 CharacterHyperlink { + 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@Ignore //bug120676_the hyperlink name lost and hyperlinktarget change to "_blank" when save to doc + public void testCharacterBackHyperlinkSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("HyperLinkURL", FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/puretext/Desert.jpg"))); + xCursorProps.setPropertyValue("HyperLinkTarget","picture"); + xCursorProps.setPropertyValue("HyperLinkName","testCharacterHyperlink"); + + //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 row height setting + 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 set property + assertEquals("assert character hyperlink URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/puretext/Desert.jpg")),xCursorProps_assert_odt.getPropertyValue("HyperLinkURL")); + assertEquals("assert character hyperlink target name","picture",xCursorProps_assert_odt.getPropertyValue("HyperLinkTarget")); + assertEquals("assert character hyperlink name","testCharacterHyperlink",xCursorProps_assert_odt.getPropertyValue("HyperLinkName")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character hyperlink URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/puretext/Desert.jpg")),xCursorProps_assert_doc.getPropertyValue("HyperLinkURL")); + assertEquals("assert character hyperlink target name","picture",xCursorProps_assert_doc.getPropertyValue("HyperLinkTarget")); + assertEquals("assert character hyperlink name","testCharacterHyperlink",xCursorProps_assert_doc.getPropertyValue("HyperLinkName")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterLocale.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterLocale.java new file mode 100644 index 000000000000..281450cb90a6 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterLocale.java @@ -0,0 +1,76 @@ +package testcase.uno.sw.puretext; + +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 CharacterLocale { + 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 + public void testCharacterLocaleSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a 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 and assert row height setting + 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 set property + Object charLocale_obj_odt=xCursorProps_assert_odt.getPropertyValue("CharLocale"); + com.sun.star.lang.Locale charLocale_odt=(com.sun.star.lang.Locale)UnoRuntime.queryInterface(com.sun.star.lang.Locale.class,charLocale_obj_odt); + + assertEquals("assert character language","en",charLocale_odt.Language); + assertEquals("assert character language","US",charLocale_odt.Country); + + //reopen the document and assert row height setting + 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 set property + Object charLocale_obj_doc=xCursorProps_assert_doc.getPropertyValue("CharLocale"); + com.sun.star.lang.Locale charLocale_doc=(com.sun.star.lang.Locale)UnoRuntime.queryInterface(com.sun.star.lang.Locale.class,charLocale_obj_doc); + + assertEquals("assert character language","en",charLocale_doc.Language); + assertEquals("assert character language","US",charLocale_doc.Country); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterOutline.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterOutline.java new file mode 100644 index 000000000000..f175a5055096 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterOutline.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterOutline { + 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 character color + * 1.new a text document and insert some character + * 2.set character outline + * 3.save and reopen the document + * 4.check the character outline effect + */ + @Test + public void testCharacterOutlineSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharContoured", 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 row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_odt.getPropertyValue("CharContoured")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_doc.getPropertyValue("CharContoured")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterPosition.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterPosition.java new file mode 100644 index 000000000000..0fe7c708a114 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterPosition.java @@ -0,0 +1,179 @@ +package testcase.uno.sw.puretext; + +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 CharacterPosition { + 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 + public void testCharacterSuperscriptSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharEscapement", (short)29); + xCursorProps.setPropertyValue("CharEscapementHeight", (byte)50); + //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 character position setting + 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 set property + assertEquals("assert character position",(short)29,xCursorProps_assert_odt.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)50,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + + //reopen the document and assert character position setting + 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 set property + assertEquals("assert character position",(short)29,xCursorProps_assert_doc.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)50,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + } + @Test@Ignore //bug120674_the lower and relative font size value of subscript change when save to doc. + public void testCharacterSubscriptSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharEscapement", (short)-29); + xCursorProps.setPropertyValue("CharEscapementHeight", (byte)50); + //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 character position setting + 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 set property + assertEquals("assert character position",(short)-29,xCursorProps_assert_odt.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)50,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + + //reopen the document and assert character position setting + 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 set property + assertEquals("assert character position",(short)-29,xCursorProps_assert_doc.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)50,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + } + @Test + public void testCharacterDefaultPositionSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharEscapement", (short)0); + xCursorProps.setPropertyValue("CharEscapementHeight", (byte)100); + //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 character position setting + 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 set property + assertEquals("assert character position",(short)0,xCursorProps_assert_odt.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)100,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + + //reopen the document and assert character position setting + 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 set property + assertEquals("assert character position",(short)0,xCursorProps_assert_doc.getPropertyValue("CharEscapement")); + assertEquals("assert character position",(byte)100,xCursorProps_assert_odt.getPropertyValue("CharEscapementHeight")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterRelief.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterRelief.java new file mode 100644 index 000000000000..4199fe7033a9 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterRelief.java @@ -0,0 +1,104 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterRelief { + 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 + public void testCharacterReliefSetting() 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!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharRelief", new Short(com.sun.star.text.FontRelief.EMBOSSED)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 102, true); + xCursorProps.setPropertyValue("CharRelief", new Short(com.sun.star.text.FontRelief.ENGRAVED)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 102, true); + xCursorProps.setPropertyValue("CharRelief", new Short(com.sun.star.text.FontRelief.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 and assert row height 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 set property + xTextCursor_assert_odt.gotoStart(false); + xTextCursor_assert_odt.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.EMBOSSED,xCursorProps_assert_odt.getPropertyValue("CharRelief")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.ENGRAVED,xCursorProps_assert_odt.getPropertyValue("CharRelief")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.NONE,xCursorProps_assert_odt.getPropertyValue("CharRelief")); + + //reopen the document and assert row height 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 set property + xTextCursor_assert_doc.gotoStart(false); + xTextCursor_assert_doc.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.EMBOSSED,xCursorProps_assert_doc.getPropertyValue("CharRelief")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.ENGRAVED,xCursorProps_assert_doc.getPropertyValue("CharRelief")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 102, true); + assertEquals("assert character relief",com.sun.star.text.FontRelief.NONE,xCursorProps_assert_doc.getPropertyValue("CharRelief")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterRotationAndScaleWidth.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterRotationAndScaleWidth.java new file mode 100644 index 000000000000..00df3474eba2 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterRotationAndScaleWidth.java @@ -0,0 +1,184 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterRotationAndScaleWidth { + 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 + public void testCharacterRotationZeroSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharRotation", (short)0); + xCursorProps.setPropertyValue("CharScaleWidth", (short)150); + //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 character rotation and scale width + 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 set property + assertEquals("assert character rotation ",(short)0,xCursorProps_assert_odt.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)150,xCursorProps_assert_odt.getPropertyValue("CharScaleWidth")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character rotation ",(short)0,xCursorProps_assert_doc.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)150,xCursorProps_assert_doc.getPropertyValue("CharScaleWidth")); + } + @Test + public void testCharacterRotationNinetySetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharRotation", (short)900); + xCursorProps.setPropertyValue("CharScaleWidth", (short)200); + xCursorProps.setPropertyValue("CharRotationIsFitToLine", 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 character rotation and scale width + 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 set property + assertEquals("assert character rotation ",(short)900,xCursorProps_assert_odt.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)200,xCursorProps_assert_odt.getPropertyValue("CharScaleWidth")); + assertEquals("assert character rotation ",true,xCursorProps_assert_odt.getPropertyValue("CharRotationIsFitToLine")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character rotation ",(short)900,xCursorProps_assert_doc.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)200,xCursorProps_assert_doc.getPropertyValue("CharScaleWidth")); + assertEquals("assert character rotation ",true,xCursorProps_assert_odt.getPropertyValue("CharRotationIsFitToLine")); + } + //test character rotation 270 degree + @Test@Ignore //bug 120673_character rotation degree change to 90 from 270 when save to doc + public void testCharacterRotationDefineSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharRotation", (short)2700); + xCursorProps.setPropertyValue("CharScaleWidth", (short)300); + //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 character rotation and scale width + 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 set property + assertEquals("assert character rotation ",(short)2700,xCursorProps_assert_odt.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)300,xCursorProps_assert_odt.getPropertyValue("CharScaleWidth")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character rotation ",(short)2700,xCursorProps_assert_doc.getPropertyValue("CharRotation")); + assertEquals("assert character rotation ",(short)300,xCursorProps_assert_doc.getPropertyValue("CharScaleWidth")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterShadow.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterShadow.java new file mode 100644 index 000000000000..0cfab364b6c1 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterShadow.java @@ -0,0 +1,85 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterShadow { + 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 character color + * 1.new a text document and insert some character + * 2.set character shadow + * 3.save and reopen the document + * 4.check the character color + */ + @Test + public void testCharacterShadowSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharShadowed", 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 row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_odt.getPropertyValue("CharShadowed")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character shadow",true,xCursorProps_assert_doc.getPropertyValue("CharShadowed")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterSize.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterSize.java new file mode 100644 index 000000000000..62f570526418 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterSize.java @@ -0,0 +1,77 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterSize { + 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 + public void testCharacterSizeSetting() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharHeight", 20); + //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 row height setting + 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 set property + assertEquals("assert character size",(float)20.0,xCursorProps_assert_odt.getPropertyValue("CharHeight")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character size",(float)20.0,xCursorProps_assert_doc.getPropertyValue("CharHeight")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterSpacing.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterSpacing.java new file mode 100644 index 000000000000..ff5feda3e826 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterSpacing.java @@ -0,0 +1,169 @@ +package testcase.uno.sw.puretext; + +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 CharacterSpacing { + 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 + public void testCharacterSpacing_Default() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharAutoKerning", 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 row height setting + 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 set property + assertEquals("assert character color",true,xCursorProps_assert_odt.getPropertyValue("CharAutoKerning")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character color",true,xCursorProps_assert_doc.getPropertyValue("CharAutoKerning")); + } + @Test + public void testCharacterSpacing_Expand() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharKerning", (short)101); + //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 row height setting + 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 set property + assertEquals("assert character color",(short)101,xCursorProps_assert_odt.getPropertyValue("CharKerning")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character color",(short)101,xCursorProps_assert_doc.getPropertyValue("CharKerning")); + } + @Test + public void testCharacterSpacing_Condens() 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!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharKerning", (short)-101); + //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 row height setting + 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 set property + assertEquals("assert character color",(short)-101,xCursorProps_assert_odt.getPropertyValue("CharKerning")); + + //reopen the document and assert row height setting + 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 set property + assertEquals("assert character color",(short)-101,xCursorProps_assert_doc.getPropertyValue("CharKerning")); +} +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterStrikeThrough.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterStrikeThrough.java new file mode 100644 index 000000000000..d4bf5012cbbc --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterStrikeThrough.java @@ -0,0 +1,145 @@ +package testcase.uno.sw.puretext; + +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 CharacterStrikeThrough { + 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@Ignore //bug 120656_bold,"/","X" strike through change to single when save to doc + public void testCharacterStrikeThroughSetting() 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!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!"); + // 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) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.BOLD)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.DONTKNOW)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.DOUBLE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.NONE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.SINGLE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.SLASH)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharStrikeout", new Short(com.sun.star.awt.FontStrikeout.X)); + //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 row height 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 set property + xTextCursor_assert_odt.gotoStart(false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is bold",com.sun.star.awt.FontStrikeout.BOLD,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is don'tknow",com.sun.star.awt.FontStrikeout.NONE,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is double",com.sun.star.awt.FontStrikeout.DOUBLE,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is without",com.sun.star.awt.FontStrikeout.NONE,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is single",com.sun.star.awt.FontStrikeout.SINGLE,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is with /",com.sun.star.awt.FontStrikeout.SLASH,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert strikethrough is with X",com.sun.star.awt.FontStrikeout.X,xCursorProps_assert_odt.getPropertyValue("CharStrikeout")); + + //reopen the document and assert row height 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 set property + xTextCursor_assert_doc.gotoStart(false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is bold",com.sun.star.awt.FontStrikeout.BOLD,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is don'tknow",com.sun.star.awt.FontStrikeout.NONE,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is double",com.sun.star.awt.FontStrikeout.DOUBLE,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is without",com.sun.star.awt.FontStrikeout.NONE,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is single",com.sun.star.awt.FontStrikeout.SINGLE,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is with /",com.sun.star.awt.FontStrikeout.SLASH,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert strikethrough is with X",com.sun.star.awt.FontStrikeout.X,xCursorProps_assert_doc.getPropertyValue("CharStrikeout")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterStyle.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterStyle.java new file mode 100644 index 000000000000..63aaf789b16a --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterStyle.java @@ -0,0 +1,81 @@ +package testcase.uno.sw.puretext; + +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 org.openoffice.test.vcl.Tester.*; +import com.sun.star.text.*; +import com.sun.star.beans.*; +import com.sun.star.frame.XStorable; +import com.sun.star.uno.UnoRuntime; + +public class CharacterStyle { + 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 + public void testCharacterStyleSetting() throws Exception { + XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document + xText = xTextDocument.getText(); + // simply set whole text as one string + xText.setString("we are Chinese,they are American.We are all living in one earth!" + + "and we all love our home very much!!!"); + // 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) 102, true); + xCursorProps.setPropertyValue("CharPosture",com.sun.star.awt.FontSlant.ITALIC); + xCursorProps.setPropertyValue("CharWeight", new Float(com.sun.star.awt.FontWeight.BOLD)); + //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 row height setting + 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 set property + assertEquals(com.sun.star.awt.FontSlant.ITALIC,xCursorProps_assert_odt.getPropertyValue("CharPosture")); + assertEquals(com.sun.star.awt.FontWeight.BOLD,xCursorProps_assert_odt.getPropertyValue("CharWeight")); + + //reopen the document and assert row height setting + 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 set property + assertEquals(com.sun.star.awt.FontSlant.ITALIC,xCursorProps_assert_doc.getPropertyValue("CharPosture")); + assertEquals(com.sun.star.awt.FontWeight.BOLD,xCursorProps_assert_doc.getPropertyValue("CharWeight")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/CharacterUnderline.java b/test/testuno/source/testcase/uno/sw/puretext/CharacterUnderline.java new file mode 100644 index 000000000000..4a29374cfcb1 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/CharacterUnderline.java @@ -0,0 +1,431 @@ +package testcase.uno.sw.puretext; + +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 CharacterUnderline { + 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@Ignore //bug120657_underline color lost and individual words option disable when save to doc + public void testCharacterUnderlineSetting() 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!" + + "and we all love our home very much!!!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American." + + " We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!We are all living in one earth!We are Chinese,they are American. " + + "We are all living in one earth!"); + // 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) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DOUBLE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x00FF00FF); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.WAVE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x00FF00FF); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.SMALLWAVE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x00FF00FF); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.SINGLE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", true); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.NONE)); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.LONGDASH)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DOUBLEWAVE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DONTKNOW)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DOTTED)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DASHDOTDOT)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DASHDOT)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.DASH)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDWAVE)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDLONGDASH)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDDOTTED)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDDASHDOT)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLDDASH)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 0x0000FF00); + xTextCursor.gotoRange(xTextCursor, false); + xTextCursor.goRight((short) 100, true); + xCursorProps.setPropertyValue("CharWordMode", false); + xCursorProps.setPropertyValue("CharUnderline", new Short(com.sun.star.awt.FontUnderline.BOLD)); + xCursorProps.setPropertyValue("CharUnderlineHasColor", true); + xCursorProps.setPropertyValue("CharUnderlineColor", 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 and assert row height 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); + + xTextCursor_assert_odt.gotoStart(false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is double",com.sun.star.awt.FontUnderline.DOUBLE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is wave",com.sun.star.awt.FontUnderline.WAVE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is smallwave",com.sun.star.awt.FontUnderline.SMALLWAVE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is single",com.sun.star.awt.FontUnderline.SINGLE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is without",com.sun.star.awt.FontUnderline.NONE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is LONGDASH",com.sun.star.awt.FontUnderline.LONGDASH,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DOUBLEWAVE",com.sun.star.awt.FontUnderline.DOUBLEWAVE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DONTKNOW",com.sun.star.awt.FontUnderline.NONE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DOTTED",com.sun.star.awt.FontUnderline.DOTTED,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASHDOTDOT",com.sun.star.awt.FontUnderline.DASHDOTDOT,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASHDOT",com.sun.star.awt.FontUnderline.DASHDOT,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASH",com.sun.star.awt.FontUnderline.DASH,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDWAVE",com.sun.star.awt.FontUnderline.BOLDWAVE,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDLONGDASH",com.sun.star.awt.FontUnderline.BOLDLONGDASH,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDOTTED",com.sun.star.awt.FontUnderline.BOLDDOTTED,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASHDOTDOT",com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASHDOT",com.sun.star.awt.FontUnderline.BOLDDASHDOT,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASH",com.sun.star.awt.FontUnderline.BOLDDASH,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_odt.gotoRange(xTextCursor_assert_odt, false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_odt.getPropertyValue("CharWordMode")); + assertEquals("assert underline is bold",com.sun.star.awt.FontUnderline.BOLD,xCursorProps_assert_odt.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_odt.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_odt.getPropertyValue("CharUnderlineColor")); + + //reopen the document and assert row height 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); + + xTextCursor_assert_odt.gotoStart(false); + xTextCursor_assert_odt.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is double",com.sun.star.awt.FontUnderline.DOUBLE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is wave",com.sun.star.awt.FontUnderline.WAVE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is smallwave",com.sun.star.awt.FontUnderline.SMALLWAVE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x00FF00FF,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is single",com.sun.star.awt.FontUnderline.SINGLE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",true,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is without",com.sun.star.awt.FontUnderline.NONE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is LONGDASH",com.sun.star.awt.FontUnderline.LONGDASH,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color is true",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individual word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DOUBLEWAVE",com.sun.star.awt.FontUnderline.DOUBLEWAVE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DONTKNOW",com.sun.star.awt.FontUnderline.NONE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DOTTED",com.sun.star.awt.FontUnderline.DOTTED,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASHDOTDOT",com.sun.star.awt.FontUnderline.DASHDOTDOT,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASHDOT",com.sun.star.awt.FontUnderline.DASHDOT,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is DASH",com.sun.star.awt.FontUnderline.DASH,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDWAVE",com.sun.star.awt.FontUnderline.BOLDWAVE,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDLONGDASH",com.sun.star.awt.FontUnderline.BOLDLONGDASH,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDOTTED",com.sun.star.awt.FontUnderline.BOLDDOTTED,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASHDOTDOT",com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASHDOT",com.sun.star.awt.FontUnderline.BOLDDASHDOT,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is BOLDDASH",com.sun.star.awt.FontUnderline.BOLDDASH,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + xTextCursor_assert_doc.gotoRange(xTextCursor_assert_doc, false); + xTextCursor_assert_doc.goRight((short) 100, true); + assertEquals("assert individula word setting",false,xCursorProps_assert_doc.getPropertyValue("CharWordMode")); + assertEquals("assert underline is bold",com.sun.star.awt.FontUnderline.BOLD,xCursorProps_assert_doc.getPropertyValue("CharUnderline")); + assertEquals("assert has underline color",true,xCursorProps_assert_doc.getPropertyValue("CharUnderlineHasColor")); + assertEquals("assert underline color",0x0000FF00,xCursorProps_assert_doc.getPropertyValue("CharUnderlineColor")); + } +} diff --git a/test/testuno/source/testcase/uno/sw/puretext/Desert.jpg b/test/testuno/source/testcase/uno/sw/puretext/Desert.jpg Binary files differnew file mode 100644 index 000000000000..0be7c09b6171 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/Desert.jpg diff --git a/test/testuno/source/testcase/uno/sw/puretext/InsertCharacterToTable.java b/test/testuno/source/testcase/uno/sw/puretext/InsertCharacterToTable.java new file mode 100644 index 000000000000..6ac5483deea6 --- /dev/null +++ b/test/testuno/source/testcase/uno/sw/puretext/InsertCharacterToTable.java @@ -0,0 +1,111 @@ +package testcase.uno.sw.puretext; + +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.uno.UnoRuntime; +import com.sun.star.text.*; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XStorable; + +public class InsertCharacterToTable { + + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument = null; + private XMultiServiceFactory xWriterFactory = null; + private XText xText = null; + + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testCreateTable() throws Exception { + xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText = xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextTable xTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class,xWriterFactory.createInstance("com.sun.star.text.TextTable")); + xTable.initialize(4, 4); + xText.insertTextContent(xTextCursor, xTable, false); + //insert text in to table cell + insertIntoCell( "A1","test", xTable ); + insertIntoCell( "C4","123", xTable ); + insertIntoCell( "D2","fsdf132134", xTable ); + insertIntoCell( "B3","*^$%^$^$", xTable ); + + //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 create table successfully + XTextDocument assertDocument_odt = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,app.loadDocument(Testspace.getPath("output/test.odt"))); + XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt); + XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables()); + Object xTable_obj_odt = xIndexedTables_odt.getByIndex(0); + XTextTable xTable_Assert_odt = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt); + assertEquals("assert table cell text","test",getFromCell("A1", xTable_Assert_odt)); + assertEquals("assert table cell text","*^$%^$^$",getFromCell("B3", xTable_Assert_odt)); + assertEquals("assert table cell text","123",getFromCell("C4", xTable_Assert_odt)); + assertEquals("assert table cell text","fsdf132134",getFromCell("D2", xTable_Assert_odt)); + + // reopen the document and assert create table successfully + XTextDocument assertDocument_doc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,app.loadDocument(Testspace.getPath("output/test.doc"))); + XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc); + XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables()); + Object xTable_obj_doc = xIndexedTables_doc.getByIndex(0); + XTextTable xTable_Assert_doc = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc); + assertEquals("assert table cell text","test",getFromCell("A1", xTable_Assert_doc)); + assertEquals("assert table cell text","*^$%^$^$",getFromCell("B3", xTable_Assert_doc)); + assertEquals("assert table cell text","123",getFromCell("C4", xTable_Assert_doc)); + assertEquals("assert table cell text","fsdf132134",getFromCell("D2", xTable_Assert_doc)); + } + // This method is inserts string sText in table cell by sCellName. + public static void insertIntoCell(String sCellName, String sText, XTextTable xTable) { + // Access the XText interface of the cell referred to by sCellName + XText xCellText = (XText) UnoRuntime.queryInterface(XText.class, xTable.getCellByName(sCellName)); + // Set the text in the cell to sText + xCellText.setString(sText); + } + // This method is get string sText in table cell by sCellName. + public static String getFromCell(String sCellName, XTextTable xTable) { + // Access the XText interface of the cell referred to by sCellName + XText xCellText = (XText) UnoRuntime.queryInterface(XText.class, xTable.getCellByName(sCellName)); + // Set the text in the cell to sText + return xCellText.getString(); + } +}
\ No newline at end of file |