diff options
Diffstat (limited to 'qadevOOo/tests/java/mod/_sw')
96 files changed, 16081 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_sw/CharacterStyle.java b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java new file mode 100644 index 000000000000..d5dc53dcf180 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java @@ -0,0 +1,207 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.CharacterStyle</code>. <p> + * @see com.sun.star.style.CharacterStyle + */ +public class CharacterStyle extends TestCase { + private XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * At first style families are gotten from a text document using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from this style family using <code>XIndexAccess</code> interface. + * Next, method creates an instance of the service + * <code>com.sun.star.style.CharacterStyle</code> and inserts it to a + * previously obtained style family using <code>XNameContainer</code> + * interface. Finally, method creates a cursor of a major text of text + * document and sets it's property 'CharStyleName' value to the name of + * previously created style's name. + * Object relations created : + * <ul> + * <li> <code>'PoolStyle'</code> for + * {@link ifc.style._XStyle} : style indexed '10' obtained from + * StyleFamily indexed '0' from text document using + * <code>XIndexAccess</code> interface.</li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + try { + log.println("getting style"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFsIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSF); + oSFNA = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class,oSFsIA.getByIndex(0)); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = (XStyle) UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(0)); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + try { + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.CharacterStyle"); + oMyStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, oInt); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + try { + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + try { + xProp.setPropertyValue("CharStyleName", oMyStyle.getName()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + + short exclude = PropertyAttribute.MAYBEVOID + PropertyAttribute.READONLY; + tEnv.addObjRelation("PropertyNames",utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude)); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java new file mode 100644 index 000000000000..072071bb04eb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java @@ -0,0 +1,201 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.ConditionalParagraphStyle</code>. <p> + * @see com.sun.star.style.ConditionalParagraphStyle + */ +public class ConditionalParagraphStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Create a new instance of the conditional + * paragraph style, and insert it into the document. + * @see com.sun.star.style.ConditionalParagraphStyle + * @param tParam The test paramters + * @param log The log writer. + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + try { + log.println("getting style"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("ParagraphStyles")); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = (XStyle) UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(1)); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + try { + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.ConditionalParagraphStyle"); + oMyStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, oInt); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + + if (oMyStyle == null) { + log.println("FAILED"); + throw new StatusException(Status.failed("Couldn't create an own style ")); + } + else { + log.println("OK"); + } + + XNameContainer oSFNC = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + try { + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oCursor); + try { + xProp.setPropertyValue("ParaStyleName", oMyStyle.getName()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + short exclude = PropertyAttribute.MAYBEVOID + PropertyAttribute.READONLY; + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude); + tEnv.addObjRelation("PropertyNames", names); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/DocumentSettings.java b/qadevOOo/tests/java/mod/_sw/DocumentSettings.java new file mode 100644 index 000000000000..5ece58f1a29c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/DocumentSettings.java @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; +import util.WriterTools; + +import java.io.PrintWriter; + + +public class DocumentSettings extends TestCase +{ + XTextDocument xTextDoc = null; + + /** + * Creates text document. + */ + protected void initialize(TestParameters tParam, PrintWriter log) + { + log.println(" opening xTextDoc "); + xTextDoc = + WriterTools.createTextDoc((XMultiServiceFactory) tParam.getMSF()); + } + + /** + * Disposes text document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) + { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log + ) + { + SOfficeFactory SOF = + SOfficeFactory.getFactory((XMultiServiceFactory) tParam.getMSF()); + XInterface oObj = null; + + log.println("creating a test environment"); + + oObj = + (XInterface) SOF.createInstance( + xTextDoc, "com.sun.star.text.DocumentSettings" + ); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sw/PageStyle.java b/qadevOOo/tests/java/mod/_sw/PageStyle.java new file mode 100644 index 000000000000..4c7b369d37a9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/PageStyle.java @@ -0,0 +1,201 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.PageStyle</code>. <p> + * @see com.sun.star.style.PageStyle + */ +public class PageStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + try { + log.println("getting style"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("PageStyles")); // get the page style + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = (XStyle) UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(0)); + log.println("Chosen pool style: "+oStyle.getName()); + + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + try { + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.PageStyle"); +// oMSF.createInstanceWithArguments("com.sun.star.style.PageStyle",new Object[]{oStyle}); + oMyStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, oInt); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + + XNameContainer oSFNC = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + + try { + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oCursor); + Property[] props = xProp.getPropertySetInfo().getProperties(); + for (int i=0; i<props.length; i++) + System.out.println("# Property: " + props[i].Name + " val: " + props[i].Type.toString() + " attr: " + props[i].Attributes); + try { + xProp.setPropertyValue("PageDescName", oMyStyle.getName()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } + +// oMyStyle = oStyle; + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + tEnv.addObjRelation("FollowStyle", "Envelope"); + XPropertySet xStyleProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + + short exclude = PropertyAttribute.MAYBEVOID + PropertyAttribute.READONLY; + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude); + tEnv.addObjRelation("PropertyNames", names); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/ParagraphStyle.java b/qadevOOo/tests/java/mod/_sw/ParagraphStyle.java new file mode 100644 index 000000000000..b8822c4a3025 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/ParagraphStyle.java @@ -0,0 +1,192 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.ParagraphStyle</code>. <p> + * @see com.sun.star.style.ParagraphStyle + */ +public class ParagraphStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + try { + log.println("getting style"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("ParagraphStyles")); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + String[] els = oSFNA.getElementNames(); + oStyle = (XStyle) UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(1)); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + try { + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.ParagraphStyle"); + oMyStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, oInt); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + try { + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + try { + xProp.setPropertyValue("ParaStyleName", oMyStyle.getName()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + short exclude = PropertyAttribute.MAYBEVOID + PropertyAttribute.READONLY; + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude); + tEnv.addObjRelation("PropertyNames", names); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.java new file mode 100644 index 000000000000..3eb0aa20d8b5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.java @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +public class SwAccessibleDocumentPageView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switchs the document to Print Preview mode. + * Obtains accissible object for the document page view. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + try { + for (int i=0; i<25; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwAccessibleDocumentPageView", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwAccessibleDocumentPageView", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace(log); + throw new StatusException( "Couldn't insert lines", e ); + } + + XController xController = xTextDoc.getCurrentController(); + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + //switch to 'Print Preview' mode + try { + XDispatchProvider xDispProv = (XDispatchProvider) + UnoRuntime.queryInterface(XDispatchProvider.class, xController); + XURLTransformer xParser = (com.sun.star.util.XURLTransformer) + UnoRuntime.queryInterface(XURLTransformer.class, + ( (XMultiServiceFactory) Param.getMSF()).createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + throw new StatusException(Status.failed("Couldn't change mode")); + } + + shortWait(); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT ); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XText the_text = oText; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + String oldText = the_text.getString(); + the_text.setString("EVENT FIRED"); + shortWait(); + the_text.setString(oldText); + } + }); + + return tEnv; + + } + + + /** + * Sleeps for 1 sec. to allow StarOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(2000) ; + } catch (InterruptedException e) { + log.println("While waiting :" + e) ; + } + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) Param.getMSF()); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java new file mode 100644 index 000000000000..45d0e9a226d8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleValue; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test of accessible object for the text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleDocumentView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. The method is called from + * <code>getTestEnvironment()</code>. Obtains accissible object for + * text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + try { + for (int i=0; i<5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace(log); + throw new StatusException( "Couldn't insert lines", e ); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR); + final XAccessibleValue xAccVal = (XAccessibleValue) UnoRuntime.queryInterface + (XAccessibleValue.class, SearchedContext) ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + xAccVal.setCurrentValue(xAccVal.getMinimumValue()); + xAccVal.setCurrentValue(xAccVal.getMaximumValue()); + } + }); + + return tEnv; + + } + + public static boolean first = false; + public static XAccessibleContext SearchedContext = null; + + public static void getAccessibleObjectForRole(XAccessible xacc,short role) { + XAccessibleContext ac = xacc.getAccessibleContext(); + if (ac.getAccessibleRole()==role) { + if (first) SearchedContext = ac; + else first=true; + } else { + int k = ac.getAccessibleChildCount(); + for (int i=0;i<k;i++) { + try { + getAccessibleObjectForRole(ac.getAccessibleChild(i),role); + if (SearchedContext != null) return ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't get Child"); + } + } + } + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java new file mode 100644 index 000000000000..51c28e2e68aa --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +public class SwAccessibleEndnoteView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Inserts the created endnote to the document. + * Changes zoom value to 10%(endnote must be in vissible area of the document). + * Obtains accessible object for the inserted endnote. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XInterface oEndnote = null; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a endnote"); + try { + oEndnote = (XInterface) UnoRuntime.queryInterface(XInterface.class, + msf.createInstance("com.sun.star.text.Endnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create endnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + XTextContent xTC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oEndnote); + try { + oText.insertTextContent(oCursor, xTC, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the endnote", e); + } + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + + try { + //change zoom value to 10% + //footer should be in the vissible area of the document + xPropSet.setPropertyValue("ZoomValue", new Short("10")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.END_NOTE); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 130% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 10% + PropSet.setPropertyValue("ZoomValue", new Short("10")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java new file mode 100644 index 000000000000..33cdc1e2fff8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for a footer of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleFooterView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains style + * <code>Standard</code> from style family <code>PageStyles</code>. + * Changes values of property <code>FooterIsOn</code> by <code>true</code>. + * Changes zoom value to 10%(footer must be in vissible area of the document). + * Obtains accessible component for the footer. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standard' from style family 'PageStyles' + try { + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException("Error, no such style name! ", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } + + final XPropertySet PropSet = (XPropertySet) + UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + try { + log.println( "Switching on footer" ); + PropSet.setPropertyValue("FooterIsOn", new Boolean(true)); + + //change zoom value to 10% + //footer should be in the vissible area of the document + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + xPropSet.setPropertyValue("ZoomValue", new Short("20")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.FOOTER); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + PropSet.setPropertyValue("FooterLeftMargin", + new Integer(1000)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + throw new StatusException("Cann't change footer.", e); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java new file mode 100644 index 000000000000..3b9604124211 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +public class SwAccessibleFootnoteView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Inserts the created footnote to the document. + * Changes zoom value to 10%(endnote must be in vissible area of the document). + * Obtains accessible object for the inserted footnote. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XFootnote oFootnote = null; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + try { + oFootnote = (XFootnote) UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create footnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + try { + oText.insertTextContent(oCursor, oFootnote, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the footnote", e); + } + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + + try { + //change zoom value to 10% + //footer should be in the vissible area of the document + xPropSet.setPropertyValue("ZoomValue", new Short("10")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.FOOTNOTE); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 130% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 10% + PropSet.setPropertyValue("ZoomValue", new Short("10")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java new file mode 100644 index 000000000000..9fc37c112980 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java @@ -0,0 +1,188 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test of accessible object for a header of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleHeaderView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains style + * <code>Standard</code> from style family <code>PageStyles</code>. + * Changes values of properties <code>HeaderIsOn</code> and + * <code>FooterIsOn</code> by <code>true</code>. Obtains accessible component + * for header. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standatd' from style family 'PageStyles' + try { + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException("Error, no such style name! ", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } + + final XPropertySet PropSet = (XPropertySet) + UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + try { + log.println( "Switching on header" ); + PropSet.setPropertyValue("HeaderIsOn", new Boolean(true)); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set propertyValue...", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.HEADER); + + oObj = AccessibilityTools.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + PropSet.setPropertyValue("HeaderLeftMargin", + new Integer(1000)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + throw new StatusException("Cann't change footer.", e); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java new file mode 100644 index 000000000000..5d4ddb903f62 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java @@ -0,0 +1,286 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleValue; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +public class SwAccessiblePageView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switchs the document to Print Preview mode. + * Obtains accissible object for the page view. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XInterface port = null; + XInterface para = null; + XPropertySet paraP = null; + XPropertySet portP = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + try { + for (int i=0; i<2; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace(log); + throw new StatusException( "Couldn't insert lines", e ); + } + + // Enumeration + XEnumerationAccess oEnumA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + try { + para = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + XEnumerationAccess oEnumB = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, para ); + XEnumeration oEnum2 = oEnumB.createEnumeration(); + port = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum2.nextElement()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } + + try { + portP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, port); + paraP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, para); + paraP.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_AFTER); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } + + shortWait(); + + XController xController = xTextDoc.getCurrentController(); + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + //switch to 'Print Preview' mode + try { + XDispatchProvider xDispProv = (XDispatchProvider) + UnoRuntime.queryInterface(XDispatchProvider.class, xController); + XURLTransformer xParser = (com.sun.star.util.XURLTransformer) + UnoRuntime.queryInterface(XURLTransformer.class, + ((XMultiServiceFactory)Param.getMSF()).createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + throw new StatusException(Status.failed("Couldn't change mode")); + } + + shortWait(); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + System.out.println("Panel: "+AccessibleRole.PANEL); + System.out.println("ScrollPane: "+AccessibleRole.SCROLL_PANE); + oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL,"Page"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + + TestEnvironment tEnv = new TestEnvironment(oObj); + + getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR); + final XAccessibleValue xAccVal = (XAccessibleValue) UnoRuntime.queryInterface + (XAccessibleValue.class, SearchedContext) ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Integer old = (Integer) xAccVal.getCurrentValue(); + Integer newValue = new Integer(old.intValue()+10); + xAccVal.setCurrentValue(newValue); + xAccVal.setCurrentValue(old); + } + }); + + return tEnv; + + } + + public static boolean first = false; + public static XAccessibleContext SearchedContext = null; + + public static void getAccessibleObjectForRole(XAccessible xacc,short role) { + XAccessibleContext ac = xacc.getAccessibleContext(); + if (ac.getAccessibleRole()==role) { + if (first) SearchedContext = ac; + else first=true; + } else { + int k = ac.getAccessibleChildCount(); + for (int i=0;i<k;i++) { + try { + getAccessibleObjectForRole(ac.getAccessibleChild(i),role); + if (SearchedContext != null) return ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't get Child"); + } + } + } + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } + + /** + * Sleeps for 0.5 sec. to allow StarOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(500) ; + } catch (InterruptedException e) { + log.println("While waiting :" + e) ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java new file mode 100644 index 000000000000..23e7014e46eb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java @@ -0,0 +1,139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test of accessible object for paragraph of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleParagraphView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains accessible object + * for one of document paragraph. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XText oText = xTextDoc.getText(); + oText.setString("XAccessibleText"); + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XText paraText = xTextDoc.getText(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + String old = paraText.getString(); + paraText.setString("Just a line"); + paraText.setString(old); + } + }); + + final String text = "XAccessibleText"; + + tEnv.addObjRelation("XAccessibleText.Text", text); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java new file mode 100644 index 000000000000..b067b9a6293d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** +* Test of accessible object for the table cell of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTableCellView extends TestCase { + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a text table and inserts it to document. Then obtains accessible + * object for one of table cell. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XTextTable oTable = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) Param.getMSF()); + + try { + oTable = SOF.createTextTable(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create TextTable : " + + e.getMessage(), e); + } + + try { + SOF.insertTextContent(xTextDoc, oTable); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert text content :" + + e.getMessage(), e); + } + + XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleSelection accSel = (XAccessibleSelection) UnoRuntime.queryInterface( + XAccessibleSelection.class, + at.SearchedContext.getAccessibleParent()); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + accSel.selectAllAccessibleChildren(); + } + }); + + return tEnv; + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println("creating a text document"); + xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) Param.getMSF()); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java new file mode 100644 index 000000000000..d08e2cef7d50 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the table of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTableView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a text table and inserts it into the document. + * Then obtains accessible object for the table. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XTextTable oTable = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)Param.getMSF()); + try { + oTable = SOF.createTextTable( xTextDoc ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + + e.getMessage(), e); + } + + try { + SOF.insertTextContent(xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't insert text content :" + + e.getMessage(), e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", new Short("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java new file mode 100644 index 000000000000..a55f458de64b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the text embedded object of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextEmbeddedObject extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Obtains accessible object for the embedded object. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.EMBEDDED_OBJECT); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", new Short("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Loads the text document <code>SwXTextEmbeddedObject.sxw</code> + * with a text embedded object. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "open a text document" ); + String testdoc = utils.getFullTestURL("SwXTextEmbeddedObject.sxw"); + log.println(testdoc); + xTextDoc = WriterTools.loadTextDoc((XMultiServiceFactory)Param.getMSF(),testdoc); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java new file mode 100644 index 000000000000..676a475b099b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the text frame of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextFrameView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a frame and inserts it into document. + * Obtains accessible object for the inserted text frame. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XTextFrame oFrame1 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = null; + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); + // creating Frames + log.println( "creating Frames" ); + try { + oFrame1 = SOF.createTextFrame(xTextDoc, 500, 500); + oPropSet = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet.class, oFrame1 ); + oPropSet.setPropertyValue("AnchorType", + TextContentAnchorType.AS_CHARACTER); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println( "inserting Frame1" ); + XTextContent the_content = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oFrame1); + oText.insertTextContent(oCursor, the_content, true); + } catch (Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert TextFrame", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", new Short("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java new file mode 100644 index 000000000000..2f18e8eefc44 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the graphic object of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextGraphicObject extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a graphic object and inserts it into the document. + * Obtains accessible object for graphic object. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment() + */ + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)Param.getMSF()); + Object oGraphObj = SOF.createInstance( + xTextDoc, "com.sun.star.text.GraphicObject"); + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oGraphObj); + + log.println( "inserting graphic" ); + try { + the_text.insertTextContent(the_cursor, the_content, true); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new StatusException("Couldn't insert Content", e); + } + + XModel aModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xTextDoc); + + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.GRAPHIC); + + oObj = at.SearchedContext; + + log.println("ImplementationName " + utils.getImplName(oObj)); + at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", new Short("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", new Short("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param tParam test parameters + * @param tEnv the environment to cleanup + * @param log writer to log information while testing + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase() + */ + protected void initialize(TestParameters Param, PrintWriter log) { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java new file mode 100644 index 000000000000..00bad4ad1f62 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.text.AutoTextContainer</code>.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::text::XAutoTextContainer</code></li> +* </ul> +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.text.XAutoTextContainer +* @see com.sun.star.text.AutoTextContainer +* @see ifc.container._XNameAccess +* @see ifc.container._XElementAccess +* @see ifc.text._XAutoTextContainer +*/ +public class SwXAutoTextContainer extends TestCase { + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>.<p> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XAutoTextContainer oContainer = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a AutoTextContainer"); + try { + XMultiServiceFactory myMSF = (XMultiServiceFactory)Param.getMSF(); + Object oInst = myMSF.createInstance + ("com.sun.star.text.AutoTextContainer"); + oContainer = (XAutoTextContainer)UnoRuntime.queryInterface + (XAutoTextContainer.class,oInst); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create AutoTextContainer", e); + } + + TestEnvironment tEnv = new TestEnvironment(oContainer); + + return tEnv; + } + +} // finish class SwXAutoTextcontainer + diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java new file mode 100644 index 000000000000..9953196cfcbe --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java @@ -0,0 +1,217 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.InstCreator; +import util.SOfficeFactory; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.text.XAutoTextEntry; +import com.sun.star.text.XAutoTextGroup; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.AutoTextEntry</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XAutoTextEntry</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.AutoTextEntry + * @see com.sun.star.text.AutoTextContainer + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XAutoTextEntry + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XText + * @see ifc.text._XSimpleText + * @see ifc.text._XAutoTextEntry + * @see ifc.text._XTextRange + * @see ifc.text._XText + */ +public class SwXAutoTextEntry extends TestCase { + XTextDocument xTextDoc; + XAutoTextGroup oGroup; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + XMultiServiceFactory msf = (XMultiServiceFactory) tParam.getMSF(); + SOfficeFactory SOF = SOfficeFactory.getFactory( msf ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Removes added element from AutoTextGroup + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + try { + if ( oGroup.hasByName("NewEntryName") ) { + log.println("Removing 'NewEntryName' element"); + oGroup.removeByName("NewEntryName"); + } + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Cannot remove TextEntry from group..."); + e.printStackTrace(log); + } + log.println( "disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>, then selects the 'mytexts' + * group from the given container using <code>XNameAccess</code> interface, + * and inserts some text entry to this group. Then entry passed as test + * component.<p> + * Object relations created : + * <ul> + * <li><code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : creates tables 6x4</li> + * <li><code>'TEXTDOC'</code> for + * {@link ifc.text._XAutoTextEntry} : text document</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) { + + XAutoTextEntry oEntry = null; + XAutoTextContainer oContainer; + XInterface oObj = null; + int n = 0; + int nCount = 0; + + log.println( "creating a test environment" ); + try { + XMultiServiceFactory myMSF = (XMultiServiceFactory)Param.getMSF(); + Object oInst = myMSF.createInstance + ("com.sun.star.text.AutoTextContainer"); + oContainer = (XAutoTextContainer) + UnoRuntime.queryInterface(XAutoTextContainer.class,oInst); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create AutoTextContainer", e); + } + + XNameAccess oContNames = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oContainer); + + String contNames[] = oContNames.getElementNames(); + for (int i =0; i < contNames.length; i++){ + log.println("ContainerNames[ "+ i + "]: " + contNames[i]); + } + + try{ + oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName("mytexts")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't get AutoTextGroup", e); + } + + oGroup = (XAutoTextGroup) UnoRuntime.queryInterface + (XAutoTextGroup.class, oObj); + String[] oENames = oGroup.getElementNames(); + for (int i=0; i<oENames.length; i++) { + log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]); + } + + XText oText = xTextDoc.getText(); + oText.insertString(oText.getStart(), "New AutoText", true); + XTextRange oTextRange = (XTextRange) oText; + try { + if ( oGroup.hasByName("NewEntryName") ) { + oGroup.removeByName("NewEntryName"); + log.println("Element 'NewEntryName' exists, removing..."); + } + log.println("Adding new element 'NewEntryName' to group..."); + oGroup.insertNewByName("NewEntryName", "NewEntryTitle", oTextRange); + oEntry = (XAutoTextEntry) AnyConverter.toObject( + new Type(XAutoTextEntry.class),oGroup.getByName("NewEntryName")); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + } + + oObj = oEntry; + + log.println("Trying to use XText as TextRange in the method applyTo"); + oEntry.applyTo(oTextRange); + + oTextRange = oText.createTextCursor(); + log.println("Trying to use XTextCursor as TextRange in the method applyTo"); + oEntry.applyTo(oTextRange); + + log.println( "creating a new environment for AutoTextEntry object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.DateTime"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXAutoTextEntry diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java new file mode 100644 index 000000000000..3e021d7267c9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.container.ElementExistException; +import com.sun.star.container.XNameAccess; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import util.utils; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.AutoTextGroup</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::text::XAutoTextGroup</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.XAutoTextGroup + * @see com.sun.star.text.AutoTextContainer + * @see ifc.container._XNamed + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._XAutoTextGroup + */ +public class SwXAutoTextGroup extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>, then creates a new + * group into the container.<p> + * Object relations created : + * <ul> + * <li> <code>'TextRange'</code> for + * {@link ifc.text._XAutoTextGroup} range of text</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XAutoTextContainer oContainer; + + log.println( "creating a test environment" ); + try { + XMultiServiceFactory myMSF = (XMultiServiceFactory)Param.getMSF(); + Object oInst = myMSF.createInstance("com.sun.star.text.AutoTextContainer"); + oContainer = (XAutoTextContainer) UnoRuntime.queryInterface(XAutoTextContainer.class,oInst); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create AutoTextContainer", e); + } + String myGroupName="myNewGroup2*1"; + + XAutoTextContainer xATC = (XAutoTextContainer) UnoRuntime.queryInterface(XAutoTextContainer.class, oContainer); + + try { + log.println("removing element with name '" + myGroupName + "'"); + xATC.removeByName(myGroupName); + } catch (com.sun.star.container.NoSuchElementException e) { + } + + try { + log.println("adding element with name '" + myGroupName + "'"); + xATC.insertNewByName(myGroupName); + } catch (ElementExistException ex) { + ex.printStackTrace(log); + throw new StatusException("could not insert '"+myGroupName+"' into container",ex); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + ex.printStackTrace(log); + throw new StatusException("could not insert '"+myGroupName+"' into container",ex); + } + + + XNameAccess oContNames = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oContainer); + + if (Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)){ + String contNames[] = oContNames.getElementNames(); + for (int i =0; i < contNames.length; i++){ + log.println("ContainerNames[ "+ i + "]: " + contNames[i]); + } + } + + try{ + oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName(myGroupName)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't get AutoTextGroup '"+myGroupName + "'", e); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + log.println( "creating a new environment for AutoTextGroup object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XText oText = xTextDoc.getText(); + oText.insertString(oText.getStart(), "New AutoText", true); + + log.println( "adding TextRange as mod relation to environment" ); + tEnv.addObjRelation("TextRange", oText); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXAutoTextGroup diff --git a/qadevOOo/tests/java/mod/_sw/SwXBodyText.java b/qadevOOo/tests/java/mod/_sw/SwXBodyText.java new file mode 100644 index 000000000000..91c14dd2b0b6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBodyText.java @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Text</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXBodyText extends TestCase { + XTextDocument xTextDoc = null;; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Obtains body text from text document. + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : text</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates 6x4 tables</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + + // get the bodytext of textdocument here + log.println( " getting the bodytext of textdocument with getText()" ); + oObj = xTextDoc.getText(); + + log.println( " creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println(" adding Text as ObjRelation"); + tEnv.addObjRelation("TEXT", oObj ); + + log.println( " adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXBodyText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXBookmark.java b/qadevOOo/tests/java/mod/_sw/SwXBookmark.java new file mode 100644 index 000000000000..12e7fa2403ff --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBookmark.java @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Bookmark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + */ +public class SwXBookmark extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After creating + * a bookmark, it is inserted to the text document. + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); + XInterface oObj = null; + Object instance = null; + log.println( "creating a test environment" ); + try { + oObj = SOF.createBookmark( xTextDoc ); + SOF.insertTextContent( xTextDoc, (XTextContent) oObj ); + instance = SOF.createInstance(xTextDoc,"com.sun.star.text.Bookmark"); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create Bookmark", e ); + } + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + util.dbg.printInterfaces((XInterface) instance); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXBookmark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java b/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java new file mode 100644 index 000000000000..a28896ef7844 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XBookmarksSupplier; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Bookmarks</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + */ +public class SwXBookmarks extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. Method + * creates two bookmarks and inserts them to the text document. Then bookmarks + * are gotten from text document using <code>XBookmarksSupplier</code> + * interface. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + try { + oObj = SOF.createBookmark( xTextDoc ); + SOF.insertTextContent( xTextDoc, (XTextContent) oObj ); + oObj = SOF.createBookmark( xTextDoc ); + SOF.insertTextContent( xTextDoc, (XTextContent) oObj ); + } catch( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create Bookmark", e ); + } + + XBookmarksSupplier oBSupp = (XBookmarksSupplier) + UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc); + XNameAccess oBookNA = oBSupp.getBookmarks(); + oObj = oBookNA; + log.println( "creating a new environment for Bookmarks object" ); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXBookmarks + diff --git a/qadevOOo/tests/java/mod/_sw/SwXCell.java b/qadevOOo/tests/java/mod/_sw/SwXCell.java new file mode 100644 index 000000000000..367b59e02979 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXCell.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is a cell of the table in a text document, and + * represented by service <code>com.sun.star.table.Cell</code><p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::CellProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.table.Cell + * @see com.sun.star.text.CellProperties + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._CellProperties + * @see ifc.beans._XPropertySet + */ +public class SwXCell extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After creating + * a text table, it is inserted to the text document. Finally, first cell of + * this table is gotten. + * Object relations created : + * <ul> + * <li> <code>'CellProperties.TextSection'</code> for + * {@link ifc.text._CellProperties} : range of complete paragraphs + * within a text</li> + * </ul> + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextContent oTable = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + log.println( "creating a test environment" ); + try { + oTable = SOF.createTextTable(xTextDoc, 3, 4); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Unable to create TextTable..."); + e.printStackTrace(log); + } + try { + SOF.insertTextContent( xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Unable to insert TextContent..."); + e.printStackTrace(log); + } + oObj = SOF.getFirstTableCell( oTable ); + + log.println( " creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + try { + XInterface oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + log.println(" adding TextSection object"); + tEnv.addObjRelation("CellProperties.TextSection", oTS); + } catch (com.sun.star.uno.Exception e) { + log.println("Could not get instance of TextSection"); + e.printStackTrace(log); + } + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXCell + diff --git a/qadevOOo/tests/java/mod/_sw/SwXCellRange.java b/qadevOOo/tests/java/mod/_sw/SwXCellRange.java new file mode 100644 index 000000000000..a9a5dfff9bd4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXCellRange.java @@ -0,0 +1,169 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.CellRange</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::CellProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.table.CellRange + * @see com.sun.star.text.CellProperties + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._CellProperties + * @see ifc.beans._XPropertySet + */ +public class SwXCellRange extends TestCase { + SOfficeFactory SOF; + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. At first + * method creates and initializes the table, then if text document has no + * tables, previously created table is inserted to text document. Finally, + * custom cell range is gotten from the table created. + * Object relations created : + * <ul> + * <li> <code>'CellProperties.TextSection'</code> for + * {@link ifc.text._CellProperties} : range of complete paragraphs + * within a text</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XTextTable the_table = null; + XInterface oObj = null; + try { + the_table = SOF.createTextTable( xTextDoc ); + the_table.initialize(5, 5); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create testobj: " + +e.getMessage(),e); + } + + if( SOF.getTableCollection( xTextDoc ).getCount() == 0 ) { + try { + SOF.insertTextContent(xTextDoc, the_table ); + } catch( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + + e.getMessage(), e); + } + } + try { + XCellRange the_Range = (XCellRange) + UnoRuntime.queryInterface(XCellRange.class, the_table); + oObj = the_Range.getCellRangeByPosition(0, 0, 3, 4); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace( log ); + throw new StatusException("Couldn't get CellRange : " + + e.getMessage(), e); + } + + log.println("Creating instance..."); + TestEnvironment tEnv = new TestEnvironment( oObj ); + log.println("ImplName: " + util.utils.getImplName(oObj)); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + try { + XInterface oTS = (XInterface) + oDocMSF.createInstance("com.sun.star.text.TextSection"); + log.println(" adding TextSection object"); + tEnv.addObjRelation("CellProperties.TextSection", oTS); + } catch (com.sun.star.uno.Exception e) { + log.println("Could not get instance of TextSection"); + e.printStackTrace(log); + } + + Object[][] NewData = new Object[5][]; + NewData[0] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[1] = new Double[] + {new Double(4),new Double(9),new Double(2.5),new Double(5)}; + NewData[2] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[3] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[4] = new Double[] + {new Double(4),new Double(9),new Double(2.5),new Double(5)}; + tEnv.addObjRelation("NewData",NewData); + + // com::sun::star::chart::XChartDataArray + tEnv.addObjRelation("CRDESC", + "Column and RowDescriptions can't be changed for this Object"); + + + return tEnv; + } +} // finish class SwXCellRange + diff --git a/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java b/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java new file mode 100644 index 000000000000..582d2fbbfc23 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XChapterNumberingSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object, which is a collection of chapter numbering rules of document. + * Object implements the following interfaces: + * <ul> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::text::NumberingRules</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.NumberingRules + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._NumberingRules + */ +public class SwXChapterNumbering extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. Chapter + * numbering rules are gotten from text document using interface + * <code>XChapterNumberingSupplier</code>. + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + XChapterNumberingSupplier oCNSupp = (XChapterNumberingSupplier) + UnoRuntime.queryInterface(XChapterNumberingSupplier.class,xTextDoc); + oObj = oCNSupp.getChapterNumberingRules(); + + PropertyValue[] instance1 = null; + try { + instance1 = (PropertyValue[]) oCNSupp.getChapterNumberingRules().getByIndex(1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + } + + //instance1[0].Value = new Short((short)5); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("INSTANCE1", instance1); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXChapterNumbering + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java new file mode 100644 index 000000000000..ab776da4c6e1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java @@ -0,0 +1,144 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.DocumentIndex</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XDocumentIndex</code></li> + * <li> <code>com::sun::star::text::BaseIndex</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::DocumentIndex</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XDocumentIndex + * @see com.sun.star.text.BaseIndex + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.DocumentIndex + * @see ifc.lang._XComponent + * @see ifc.text._XDocumentIndex + * @see ifc.text._BaseIndex + * @see ifc.text._XTextContent + * @see ifc.text._DocumentIndex + */ +public class SwXDocumentIndex extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.DocumentIndex</code>, then created document index + * is inserted to the text of the document as content. + * + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + XTextContent xTC = null; + Object instance = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()); + log.println( "creating a test environment" ); + try { + xTC = SOF.createIndex(xTextDoc, "com.sun.star.text.DocumentIndex"); + instance = SOF.createIndex(xTextDoc, "com.sun.star.text.DocumentIndex"); + } + catch ( com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create the Index", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the Index into text document"); + try { + oText.insertTextContent(oCursor, xTC, false); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the Index", e); + } + + TestEnvironment tEnv = new TestEnvironment(xTC); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + oCursor.gotoEnd(false); + tEnv.addObjRelation("RANGE", (XTextRange) + UnoRuntime.queryInterface(XTextRange.class, oCursor)); + + // relation for XDocumentIndex + tEnv.addObjRelation("TextDoc", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXDocumentIndex + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java new file mode 100644 index 000000000000..b8e0448d2d12 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDocumentIndexMark; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.DocumentIndexMark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::BaseIndexMark</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * <li> <code>com::sun::star::text::DocumentIndexMark</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.BaseIndexMark + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.DocumentIndexMark + * @see ifc.lang._XComponent + * @see ifc.text._BaseIndexMark + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + * @see ifc.text._DocumentIndexMark + */ +public class SwXDocumentIndexMark extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.DocumentIndexMark</code>, attaches text to + * created DocumentIndexMark, and inserts DocumentIndexMark to the + * text document. + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + Object oDIM = null; + Object instance = null; + try { + oDIM = oDocMSF.createInstance + ("com.sun.star.text.DocumentIndexMark"); + instance = oDocMSF.createInstance + ("com.sun.star.text.DocumentIndexMark"); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error:" + e); + } + + XDocumentIndexMark xDIM = (XDocumentIndexMark) + UnoRuntime.queryInterface(XDocumentIndexMark.class, oDIM); + + try { + oText.insertTextContent(oCursor, xDIM, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException + ("Couldn't insert the DocumentIndexMark", e); + } + + TestEnvironment tEnv = new TestEnvironment(xDIM); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + + } // finish method getTestEnvironment + + } // finish class SwXDocumentIndexMark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java new file mode 100644 index 000000000000..3fd780373e08 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDocumentIndexesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for the object, which is represented by collection of document indexes. + * Object implements the following interfaces: + * <ul> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXDocumentIndexes extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.ContentIndex</code>, then created content index is + * inserted to the text document, and finally all document indexes are gotten + * from a text document using <code>XDocumentIndexesSupplier</code> interface. + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + log.println( "creating a test environment" ); + XTextContent xTC = null; + + try { + xTC = SOF.createIndex(xTextDoc,"com.sun.star.text.ContentIndex"); + } + catch ( com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create the Index", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the Index into text document"); + try { + oText.insertTextContent(oCursor, xTC, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the Index", e); + } + + XDocumentIndexesSupplier xDocInd = (XDocumentIndexesSupplier) + UnoRuntime.queryInterface(XDocumentIndexesSupplier.class,xTextDoc); + + oObj = xDocInd.getDocumentIndexes(); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXDocumentIndexes + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDrawPage.java b/qadevOOo/tests/java/mod/_sw/SwXDrawPage.java new file mode 100644 index 000000000000..6a6d7f6480c0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDrawPage.java @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.drawing.DrawPage</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li> + * <li> <code>com::sun::star::drawing::XShapeBinder</code></li> + * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li> + * <li> <code>com::sun::star::drawing::XShapes</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.drawing.GenericDrawPage + * @see com.sun.star.drawing.XShapeBinder + * @see com.sun.star.drawing.XShapeGrouper + * @see com.sun.star.drawing.XShapes + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.drawing.XMasterPageTarget + * @see com.sun.star.container.XNamed + * @see com.sun.star.drawing.XShapeCombiner + * @see ifc.drawing._GenericDrawPage + * @see ifc.drawing._XShapeBinder + * @see ifc.drawing._XShapeGrouper + * @see ifc.drawing._XShapes + * @see ifc.lang._XServiceInfo + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.drawing._XMasterPageTarget + * @see ifc.container._XNamed + * @see ifc.drawing._XShapeCombiner + */ +public class SwXDrawPage extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After + * obtaining DrawPage object several shapes are inserted to it. + * Object relations created : + * <ul> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes} : shape creator. </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeBinder}, + * {@link ifc.drawing._XShapeCombiner}, + * {@link ifc.drawing._XShapeGrouper} : DrawPage component we are + * testing.</li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XDrawPageSupplier XDPSupp; + XDrawPage xDP = null; + XShapes oShapes = null; + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); + XDPSupp = (XDrawPageSupplier) UnoRuntime.queryInterface + (XDrawPageSupplier.class, xTextDoc); + xDP = XDPSupp.getDrawPage(); + oObj = xDP; + + //dbg.printInterfaces(oObj); + //System.exit(0); + + log.println( "inserting some Shapes" ); + oShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, oObj); + oShapes.add(SOF.createShape(xTextDoc,2000,1500,1000,1000,"Line")); + oShapes.add(SOF.createShape(xTextDoc,3000,4500,15000,1000,"Ellipse")); + oShapes.add(SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle")); + + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + ShapeDsc sDsc = new ShapeDsc(15000,13500,7500,10000,"Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator( xTextDoc, sDsc)); + tEnv.addObjRelation("DrawPage", oObj); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXDrawPage + diff --git a/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.java b/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.java new file mode 100644 index 000000000000..7518b94309fc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.java @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.dbg; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XEndnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.FootnoteSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::FootnoteSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.FootnoteSettings + * @see ifc.text._FootnoteSettings + */ +public class SwXEndnoteProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Endnote</code>. Then created endnote is inserted + * to the text document, and finally endnote settings are gotten from text + * document using <code>XEndnotesSupplier</code> interface. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XEndnotesSupplier oInterface = null; + XInterface oObj = null; + XInterface oEndnote; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a endnote"); + try { + oEndnote = (XInterface) UnoRuntime.queryInterface(XInterface.class, + msf.createInstance("com.sun.star.text.Endnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create endnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + XTextContent xTC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oEndnote); + try { + oText.insertTextContent(oCursor, xTC, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the endnote", e); + } + + oInterface = (XEndnotesSupplier) + UnoRuntime.queryInterface(XEndnotesSupplier.class, xTextDoc); + oObj = oInterface.getEndnoteSettings(); + dbg.printPropertiesNames((XPropertySet) oObj); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java new file mode 100644 index 000000000000..81a7e4b70447 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java @@ -0,0 +1,176 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XEnumeration</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XEnumeration + * @see ifc.container._XEnumeration + */ +public class SwXFieldEnumeration extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. FieldMaster + * object is created and attached to Bibliography database. After setting + * properties of created FieldMaster object, it is attached to the TextField + * object. Then TextField is inserted as TextContent to the text document. + * At the end, TextFields of text document are obtained and + * enumeration of these fields is created.<br> + * Creates instances of the services: + * <code>com.sun.star.text.FieldMaster.Database</code>, + * <code>com.sun.star.text.TextField.Database</code>.<br> + * Object relations created : + * <ul> + * <li> <code>'ENUM'</code> for + * {@link ifc.container._XEnumeration} : text fields</li> + * </ul> + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + Object FieldMaster = null; + XPropertySet PFieldMaster = null; + XDependentTextField xTF = null; + XEnumerationAccess xFEA = null; + XText the_Text; + XTextCursor the_Cursor; + XTextContent the_Field; + + log.println( "creating a test environment" ); + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDoc ); + + try { + FieldMaster = oDocMSF.createInstance + ( "com.sun.star.text.FieldMaster.Database" ); + PFieldMaster = (XPropertySet) UnoRuntime.queryInterface + (XPropertySet.class,(XInterface) FieldMaster); + oObj = (XInterface) + oDocMSF.createInstance("com.sun.star.text.TextField.Database"); + xTF = (XDependentTextField) + UnoRuntime.queryInterface(XDependentTextField.class,oObj); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace(log); + } + + try { + PFieldMaster.setPropertyValue("DataBaseName","Bibliography"); + PFieldMaster.setPropertyValue("DataTableName","biblio"); + PFieldMaster.setPropertyValue("DataColumnName","Address"); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } + + the_Text = xTextDoc.getText(); + the_Cursor = the_Text.createTextCursor(); + the_Field = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oObj); + + try { + xTF.attachTextFieldMaster(PFieldMaster); + the_Text.insertTextContent(the_Cursor,the_Field,false); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create TextField", e ); + } + + // create testobject here + XTextFieldsSupplier oTFS = (XTextFieldsSupplier) + UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + xFEA = oTFS.getTextFields(); + oObj = oTFS.getTextFields().createEnumeration(); + + log.println( "creating a new environment for FieldEnumeration object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("ENUM", xFEA); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFieldEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java b/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java new file mode 100644 index 000000000000..e2e7bac89b6c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.FieldMaster.Database</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::TextFieldMaster</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.TextFieldMaster + * @see com.sun.star.text.FieldMaster.Database + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._TextFieldMaster + * @see ifc.beans._XPropertySet + */ +public class SwXFieldMaster extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.FieldMaster.Database</code>. + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + try { + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDoc ); + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.FieldMaster.Database" ); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMaster object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFieldMaster + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnote.java b/qadevOOo/tests/java/mod/_sw/SwXFootnote.java new file mode 100644 index 000000000000..39ab7c74a009 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnote.java @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FrameDsc; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Footnote</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XFootnote</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::Footnote</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XFootnote + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.Footnote + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XText + * @see ifc.text._XFootnote + * @see ifc.lang._XComponent + * @see ifc.text._XSimpleText + * @see ifc.text._Footnote + * @see ifc.text._XTextContent + * @see ifc.text._XTextRange + * @see ifc.text._XText + */ +public class SwXFootnote extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created footnote + * to a text of document as content. + * Object relations created : + * <ul> + * <li><code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} </li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XFootnote oFootnote; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + Object instance = null; + try { + oFootnote = (XFootnote) UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + instance = msf.createInstance("com.sun.star.text.Footnote"); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create footnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + try { + oText.insertTextContent(oCursor, oFootnote, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the footnote", e); + } + + TestEnvironment tEnv = new TestEnvironment(oFootnote); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + log.println( "adding InstDescriptor object" ); + FrameDsc tDsc = new FrameDsc( 3000, 6000 ); + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + return tEnv; + } + +} // finish class SwXFootnote + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java b/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java new file mode 100644 index 000000000000..df6e541fd553 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for the object, which is represented as set of footnote properties + * (instance of <code>com.sun.star.text.FootnoteSettings</code> service). + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::FootnoteSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.FootnoteSettings + * @see ifc.text._FootnoteSettings + */ +public class SwXFootnoteProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text document, and finally gets footnote settings from text + * document through <code>XFootnotesSupplier</code> interface.<br> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XFootnotesSupplier oInterface = null; + XInterface oObj = null; + XFootnote oFootnote; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + try { + oFootnote = (XFootnote) UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create footnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + try { + oText.insertTextContent(oCursor, oFootnote, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the footnote", e); + } + + oInterface = (XFootnotesSupplier) + UnoRuntime.queryInterface(XFootnotesSupplier.class, xTextDoc); + oObj = oInterface.getFootnoteSettings(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java b/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java new file mode 100644 index 000000000000..661f3c9c055a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java @@ -0,0 +1,176 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TextSectionDsc; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXFootnoteText extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text, and finally sets a string to the footnote. Then the text + * gotten from the footnote is returned as tested component.<br> + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : footnote text</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : text section creator</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XFootnote oFootnote; + + log.println( "creating a test environment" ); + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + try { + oFootnote = (XFootnote)UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create footnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + try { + oText.insertTextContent(oCursor, oFootnote, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the footnote", e); + } + + XSimpleText oFootText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, oFootnote); + oFootText.setString("SwXFootnoteText"); + + oObj = oFootText.getText(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXT", (XText) oObj); + + TextSectionDsc tDsc = new TextSectionDsc(); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFootnoteText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java b/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java new file mode 100644 index 000000000000..0c50c4c28014 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Footnotes</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXFootnotes extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text, and finally gets all footnotes of text document + * through <code>XFootnotesSupplier</code> interface. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XFootnotesSupplier oInterface = null; + XInterface oObj = null; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + XFootnote oFootnote; + + try { + oFootnote = (XFootnote) UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create footnote", e); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + try { + oText.insertTextContent(oCursor, oFootnote, false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert the footnote", e); + } + oInterface = (XFootnotesSupplier) + UnoRuntime.queryInterface(XFootnotesSupplier.class, xTextDoc); + oObj = oInterface.getFootnotes(); + + log.println( "creating a new environment for Foontnotes object" ); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} // finish class SwXFootnote + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFrames.java b/qadevOOo/tests/java/mod/_sw/SwXFrames.java new file mode 100644 index 000000000000..ad4dd2eaa1c0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFrames.java @@ -0,0 +1,143 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XContainer</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XContainer + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXFrames extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.TextFrame</code>. Then inserts created text frame + * to the text, and finally gets all frames of text document using + * <code>XTextFramesSupplier</code> interface.<br> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextFrame oFrame1 = null; + XText oText = null; + XTextCursor oCursor = null; + XMultiServiceFactory oDocMSF = null; + XTextFramesSupplier oInterface = null; + + log.println( "creating a test environment" ); + try { + oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object oInt = oDocMSF.createInstance("com.sun.star.text.TextFrame"); + oFrame1 = (XTextFrame) + UnoRuntime.queryInterface( XTextFrame.class, oInt ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace(log); + throw new StatusException + ("Couldn't create instance of TextFrame", e); + } + + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + try { + oText.insertTextContent(oCursor, oFrame1, false); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException + ("Error: can't insert text content to text document", e); + } + + oInterface = (XTextFramesSupplier) + UnoRuntime.queryInterface( XTextFramesSupplier.class, xTextDoc ); + + oObj = oInterface.getTextFrames(); + + log.println( "creating a new environment for Frame object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFrames + diff --git a/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java b/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java new file mode 100644 index 000000000000..dcf62875f97d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java @@ -0,0 +1,198 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXHeadFootText extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. At first + * style families are obtained from text document, then style 'Standard' has + * gotten from style family 'PageStyles'. At the end, document header and + * footer are switched on and document text is obtained. + * Object relations created : + * <ul> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates tables 6x4</li> + * <li> <code>'TEXTDOC'</code> for + * {@link ifc.text._XTextRangeCompare} : text document</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + XPropertySet PropSet; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + log.println( "creating a test environment" ); + XStyleFamiliesSupplier StyleFam = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standatd' from style family 'PageStyles' + try { + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException("Error, no such style name! ", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Error getting style by name!", e); + } + + PropSet = (XPropertySet) + UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + try { + log.println( "Switching on header" ); + PropSet.setPropertyValue("HeaderIsOn", new Boolean(true)); + log.println( "Switching on footer" ); + PropSet.setPropertyValue("FooterIsOn", new Boolean(true)); + log.println( "Get header text" ); + oObj = (XText) UnoRuntime.queryInterface( + XText.class, PropSet.getPropertyValue("HeaderText")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set/get propertyValue...", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set/get propertyValue...", e); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set/get propertyValue...", e); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace(log); + throw new StatusException("Couldn't set/get propertyValue...", e); + } + + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + log.println( "adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + tEnv.addObjRelation( "TEXT", oObj); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXHeadFootText diff --git a/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java b/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java new file mode 100644 index 000000000000..433b40ea9b68 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.dbg; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XLineNumberingProperties; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.LineNumberingProperties</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::LineNumberingProperties</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.LineNumberingProperties + * @see ifc.text._LineNumberingProperties + */ +public class SwXLineNumberingProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. After inserting + * string and control character to the text document, line numbering + * properties are gotten using <code>XLineNumberingProperties</code> interface. + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + + // insert some Text + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + try { + for (int i=0; i<5; i++) { + oText.insertString(oCursor, "The quick brown fox jumps "+ + "over the lazy Dog", false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + log.println("Exception occurred: " + e); + } + + XLineNumberingProperties oLNP = (XLineNumberingProperties) + UnoRuntime.queryInterface(XLineNumberingProperties.class,xTextDoc); + XPropertySet lineNumProps = oLNP.getLineNumberingProperties(); + dbg.printPropertiesNames(lineNumProps); + TestEnvironment tEnv = new TestEnvironment(lineNumProps); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXLineNumberingProperties + diff --git a/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java b/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java new file mode 100644 index 000000000000..64327817ec02 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java @@ -0,0 +1,439 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.beans.NamedValue; + +import util.DBTools; +import util.utils; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.*; +import com.sun.star.sdbcx.XRowLocate; +import com.sun.star.task.XJob; +import com.sun.star.text.MailMergeType; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Here <code>com.sun.star.text.MailMerge</code> service is tested.<p> +* @see com.sun.star.text.MailMerge +* @see com.sun.star.task.XJob +* @see com.sun.star.text.XMailMergeBroadcaster +*/ +public class SwXMailMerge extends TestCase { + + public void initialize( TestParameters Param, PrintWriter log ) { + if (! Param.containsKey("uniqueSuffix")){ + Param.put("uniqueSuffix", new Integer(0)); + } + } + + /** + * Creating a Testenvironment for the interfaces to be tested. <p> + * Creates <code>MailMerge</code> service * Object relations created : + * <ul> + * <li> <code>'executeArgs'</code> for + * {@link ifc.text._XMailMergeBroadcaster} : NamedValue[]</li> + * <li> <code>'Job'</code> for + * {@link ifc.text._XMailMergeBroadcaster} : XJob</li> + * <li> <code>'XJobArgs'</code> for + * {@link ifc.task._XJob} : Object[]</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XInterface oRowSet = null; + Object oConnection = null; + XJob Job = null; + + log.println(" instantiate MailMerge service"); + try { + oObj = (XInterface) ( (XMultiServiceFactory) Param.getMSF()).createInstance + ("com.sun.star.text.MailMerge"); + } catch (Exception e) { + throw new StatusException("Can't create object environment", e) ; + } + + // <set some variables> + String cTestDoc = utils.getFullTestURL("MailMerge.sxw"); + //cMailMerge_DocumentURL = cTestDoc + String cOutputURL = utils.getOfficeTemp( (XMultiServiceFactory) Param.getMSF()); + String cDataSourceName = "Bibliography"; + String cDataCommand = "biblio"; + Object[] sel = new Object[2]; + sel[0] = new int[2]; + sel[1] = new int[5]; + Object[] myBookMarks = new Object[2]; + // </set some variables> + + // <create XResultSet> + log.println("create a XResultSet"); + try { + oRowSet = (XInterface) ( (XMultiServiceFactory) Param.getMSF()).createInstance + ("com.sun.star.sdb.RowSet"); + } catch (Exception e) { + throw new StatusException("Can't create com.sun.star.sdb.RowSet", e); + } + XPropertySet oRowSetProps = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oRowSet); + XRowSet xRowSet = (XRowSet) + UnoRuntime.queryInterface(XRowSet.class, oRowSet); + try { + oRowSetProps.setPropertyValue("DataSourceName",cDataSourceName); + oRowSetProps.setPropertyValue("Command",cDataCommand); + oRowSetProps.setPropertyValue("CommandType", new Integer(CommandType.TABLE)); + } catch (UnknownPropertyException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (PropertyVetoException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (IllegalArgumentException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (WrappedTargetException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } + try { + xRowSet.execute(); + } catch (SQLException e) { + throw new StatusException("Can't execute oRowSet", e); + } + + XResultSet oResultSet = (XResultSet) + UnoRuntime.queryInterface(XResultSet.class, oRowSet); + + + + + // <create Bookmarks> + log.println("create bookmarks"); + try { + XRowLocate oRowLocate = (XRowLocate) UnoRuntime.queryInterface( + XRowLocate.class, oResultSet); + oResultSet.first(); + myBookMarks[0] = oRowLocate.getBookmark(); + oResultSet.next(); + myBookMarks[1] = oRowLocate.getBookmark(); + } catch (SQLException e) { + throw new StatusException("Cant get Bookmarks", e); + } + // </create Bookmarks> + + // <fill object with values> + + log.println("fill MailMerge with default connection"); + + XPropertySet oObjProps = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oObj); + try { + oObjProps.setPropertyValue("ActiveConnection", getLocalXConnection(Param)); + oObjProps.setPropertyValue("DataSourceName", cDataSourceName); + oObjProps.setPropertyValue("Command", cDataCommand); + oObjProps.setPropertyValue("CommandType", new Integer(CommandType.TABLE)); + oObjProps.setPropertyValue("OutputType", new Short(MailMergeType.FILE)); + oObjProps.setPropertyValue("DocumentURL", cTestDoc); + oObjProps.setPropertyValue("OutputURL", cOutputURL); + oObjProps.setPropertyValue("FileNamePrefix", "Author"); + oObjProps.setPropertyValue("FileNameFromColumn", new Boolean(false)); + oObjProps.setPropertyValue("Selection", new Object[0]); + + } catch (UnknownPropertyException e) { + throw new StatusException("Can't set properties on oObj", e); + } catch (PropertyVetoException e) { + throw new StatusException("Can't set properties on oObj", e); + } catch (IllegalArgumentException e) { + throw new StatusException("Can't set properties on oObj", e); + } catch (WrappedTargetException e) { + throw new StatusException("Can't set properties on oObj", e); + } + // </fill object with values> + + + // <create object relations> + Object[] vXJobArgs = new Object[4]; + NamedValue[] vXJobArg0 = new NamedValue[8]; + NamedValue[] vXJobArg1 = new NamedValue[7]; + NamedValue[] vXJobArg2 = new NamedValue[10]; + NamedValue[] vXJobArg3 = new NamedValue[0]; + + // first Arguments + vXJobArg0[0] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg0[1] = new NamedValue("Command", cDataCommand); + vXJobArg0[2] = new NamedValue("CommandType",new Integer(CommandType.TABLE)); + vXJobArg0[3] = new NamedValue("OutputType",new Short(MailMergeType.FILE)); + vXJobArg0[4] = new NamedValue("DocumentURL", cTestDoc); + vXJobArg0[5] = new NamedValue("OutputURL", cOutputURL); + vXJobArg0[6] = new NamedValue("FileNamePrefix", "Identifier"); + vXJobArg0[7] = new NamedValue("FileNameFromColumn", new Boolean(true)); + + //second Arguments + vXJobArg1[0] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg1[1] = new NamedValue("Command", cDataCommand); + vXJobArg1[2] = new NamedValue("CommandType",new Integer(CommandType.TABLE)); + vXJobArg1[3] = new NamedValue("OutputType", + new Short(MailMergeType.PRINTER)); + vXJobArg1[4] = new NamedValue("DocumentURL", cTestDoc); + vXJobArg1[5] = new NamedValue("FileNamePrefix", "Author"); + vXJobArg1[6] = new NamedValue("FileNameFromColumn", new Boolean(true)); + + // third Arguments + vXJobArg2[0] = new NamedValue("ActiveConnection", getLocalXConnection(Param)); + vXJobArg2[1] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg2[2] = new NamedValue("Command", cDataCommand); + vXJobArg2[3] = new NamedValue("CommandType",new Integer(CommandType.TABLE)); + vXJobArg2[4] = new NamedValue("OutputType", + new Short(MailMergeType.FILE)); + vXJobArg2[5] = new NamedValue("ResultSet", oResultSet); + vXJobArg2[6] = new NamedValue("OutputURL", cOutputURL); + vXJobArg2[7] = new NamedValue("FileNamePrefix", "Identifier"); + vXJobArg2[8] = new NamedValue("FileNameFromColumn", new Boolean(true)); + vXJobArg2[9] = new NamedValue("Selection", myBookMarks); + + vXJobArgs[0] = vXJobArg0; + vXJobArgs[1] = vXJobArg1; + vXJobArgs[2] = vXJobArg2; + vXJobArgs[3] = vXJobArg3; + + + Job = (XJob) UnoRuntime.queryInterface(XJob.class, oObj); + try{ + Job.execute(vXJobArg2); + } catch ( IllegalArgumentException e){ + System.out.println(e.toString()); + } catch ( Exception e){ + System.out.println(e.toString()); + } + + + // <create XResultSet> + log.println("create XResultSet"); + + try { + oRowSet = (XInterface) ( (XMultiServiceFactory) Param.getMSF()).createInstance + ("com.sun.star.sdb.RowSet"); + } catch (Exception e) { + throw new StatusException("Can't create com.sun.star.sdb.RowSet", e); + } + oRowSetProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRowSet); + + xRowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class, oRowSet); + + try { + oRowSetProps.setPropertyValue("DataSourceName",cDataSourceName); + oRowSetProps.setPropertyValue("Command",cDataCommand); + oRowSetProps.setPropertyValue("CommandType", new Integer(CommandType.TABLE)); + } catch (UnknownPropertyException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (PropertyVetoException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (IllegalArgumentException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } catch (WrappedTargetException e) { + throw new StatusException("Can't set properties on oRowSet", e); + } + try { + xRowSet.execute(); + } catch (SQLException e) { + throw new StatusException("Can't execute oRowSet", e); + } + + oResultSet = (XResultSet) + UnoRuntime.queryInterface(XResultSet.class, oRowSet); + + XResultSet oMMXResultSet = null; + try { + oMMXResultSet = (XResultSet) + UnoRuntime.queryInterface(XResultSet.class, + ( (XInterface) + ( (XMultiServiceFactory) + Param.getMSF()).createInstance("com.sun.star.sdb.RowSet"))); + + } catch (Exception e) { + throw new StatusException("Can't create com.sun.star.sdb.RowSet", e); + } + // </create object relations> + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + // <adding object relations> + + // com.sun.star.sdb.DataAccessDescriptor + tEnv.addObjRelation("DataAccessDescriptor.XResultSet", oResultSet); + tEnv.addObjRelation("DataAccessDescriptor.XConnection", getRemoteXConnection(Param)); + + // com.sun.star.text.MailMaerge + tEnv.addObjRelation("MailMerge.XConnection", getRemoteXConnection(Param)); + tEnv.addObjRelation("MailMerge.XResultSet", oMMXResultSet); + + // com.sun.star.text.XMailMergeBroadcaster + tEnv.addObjRelation( "executeArgs", vXJobArg0); + tEnv.addObjRelation( "Job", Job); + + // com.sun.star.task.XJob + tEnv.addObjRelation("XJobArgs", vXJobArgs); + + // </adding object relations> + + return tEnv ; + } + + private XConnection getRemoteXConnection(TestParameters Param){ + + log.println("create remote connection"); + + String databaseName = null ; + XDataSource oXDataSource = null; + Object oInterface = null; + XMultiServiceFactory xMSF = null ; + int uniqueSuffix = Param.getInt("uniqueSuffix"); + + try { + xMSF = (XMultiServiceFactory)Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + // retrieving temp directory for database + String tmpDatabaseUrl = utils.getOfficeTempDir((XMultiServiceFactory)Param.getMSF()); + + databaseName = "NewDatabaseSource" + uniqueSuffix ; + + String tmpDatabaseFile = tmpDatabaseUrl + databaseName + ".odb"; + System.out.println("try to delete '"+tmpDatabaseFile+"'"); + utils.deleteFile(((XMultiServiceFactory) Param.getMSF()), tmpDatabaseFile); + + + tmpDatabaseUrl = "sdbc:dbase:file:///" + tmpDatabaseUrl ; + + // Creating new DBase data source in the TEMP directory + XInterface newSource = (XInterface) xMSF.createInstance + ("com.sun.star.sdb.DataSource") ; + + XPropertySet xSrcProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, newSource); + + xSrcProp.setPropertyValue("URL", tmpDatabaseUrl) ; + + DBTools dbt = new DBTools( (XMultiServiceFactory)Param.getMSF(), log ); + // registering source in DatabaseContext + log.println("register database '"+tmpDatabaseUrl+"' as '"+databaseName+"'" ); + dbt.reRegisterDB(databaseName, newSource) ; + + uniqueSuffix++; + Param.put("uniqueSuffix", new Integer(uniqueSuffix)); + + return dbt.connectToSource(newSource); + } + catch( Exception e ) { + uniqueSuffix++; + Param.put("uniqueSuffix", new Integer(uniqueSuffix)); + log.println("could not register new database" ); + e.printStackTrace(); + throw new StatusException("could not register new database", e) ; + } + } + + private XConnection getLocalXConnection(TestParameters Param){ + + log.println("create local connection"); + + XInterface oDataCont = null; + try { + oDataCont = (XInterface)( (XMultiServiceFactory) Param.getMSF()).createInstance + ("com.sun.star.sdb.DatabaseContext"); + } catch(Exception e) { + throw new StatusException("Couldn't create instance of 'com.sun.star.sdb.DatabaseContext'", e); + } + XNameAccess xNADataCont = (XNameAccess) + UnoRuntime.queryInterface(XNameAccess.class, oDataCont); + + String[] dataNames = xNADataCont.getElementNames(); + + String dataName=""; + for (int i = 0; i < dataNames.length; i++){ + if (dataNames[i].startsWith("Biblio")) dataName=dataNames[i]; + } + + try{ + + Object oDataBase = xNADataCont.getByName(dataName); + XDataSource xDataSource = (XDataSource) + UnoRuntime.queryInterface(XDataSource.class, oDataBase); + + return xDataSource.getConnection("",""); + + } catch ( NoSuchElementException e){ + throw new StatusException("Couldn't get registered data base", e); + } catch ( WrappedTargetException e){ + throw new StatusException("Couldn't get registered data base", e); + } catch ( SQLException e){ + throw new StatusException("Couldn't get XConnection from registered data base", e); + } + + } + + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("closing connections..."); + XMultiServiceFactory xMsf = (XMultiServiceFactory) Param.getMSF(); + DBTools dbt = new DBTools( xMsf, log ); + + if (Param.containsKey("uniqueSuffix")){ + int uniqueSuffix = Param.getInt("uniqueSuffix"); + uniqueSuffix--; + String databaseName = ""; + while (uniqueSuffix >= 0){ + + databaseName = "NewDatabaseSource" + uniqueSuffix ; + + log.println("revoke '"+databaseName+"'"); + + try{ + dbt.revokeDB(databaseName); + } catch (com.sun.star.uno.Exception e){ + } + + uniqueSuffix--; + } + } + + } + +} + + diff --git a/qadevOOo/tests/java/mod/_sw/SwXModule.java b/qadevOOo/tests/java/mod/_sw/SwXModule.java new file mode 100644 index 000000000000..dea1cc05998f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXModule.java @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.GlobalSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::view::XPrintSettingsSupplier</code></li> + * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.view.XPrintSettingsSupplier + * @see com.sun.star.view.XViewSettingsSupplier + * @see ifc.view._XPrintSettingsSupplier + * @see ifc.view._XViewSettingsSupplier + */ +public class SwXModule extends TestCase { + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.GlobalSettings</code>. + */ + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + Object oInterface = null; + + try { + oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance( + "com.sun.star.text.GlobalSettings" ); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + throw new StatusException("Service not available", e) ; + } + + if (oInterface == null) { + log.println("Service wasn't created") ; + throw new StatusException("Service wasn't created", + new NullPointerException()) ; + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXModule + diff --git a/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java b/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java new file mode 100644 index 000000000000..c292150dc9a2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.NumberingRules</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::text::NumberingRules</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.NumberingRules + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._NumberingRules + */ +public class SwXNumberingRules extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * At first some strings are inserted to a text document, then style families + * are gotten from text document using <code>XStyleFamiliesSupplier</code>. + * Then style family 'NuberingRules' is retrieved, then style indexed '0' + * is obtained. At the end property value 'NumberingRules' is obtained from + * given style. + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + XInterface oObj = null; + XIndexAccess NumStyleI = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + try { + for (int i=0; i<5; i++) { + oText.insertString(oCursor, "The quick brown fox jumps "+ + "over the lazy Dog", false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + XStyleFamiliesSupplier oStyleFamiliesSupplier = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + + try { + XNameAccess oStyleFamilies = oStyleFamiliesSupplier.getStyleFamilies(); + XNameContainer NumStyles = (XNameContainer) AnyConverter.toObject( + new Type(XNameContainer.class), + oStyleFamilies.getByName("NumberingStyles")); + NumStyleI = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class,NumStyles); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error, no such style family..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + Object instance1 = null; + + try { + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),NumStyleI.getByIndex(0)); + XPropertySet props = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oObj); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),props.getPropertyValue("NumberingRules")); + XIndexAccess nRules = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, props.getPropertyValue("NumberingRules")); + instance1 = nRules.getByIndex(0); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("INSTANCE1", instance1); + return tEnv; + } + +} // finish class SwXNumberingRules diff --git a/qadevOOo/tests/java/mod/_sw/SwXParagraph.java b/qadevOOo/tests/java/mod/_sw/SwXParagraph.java new file mode 100644 index 000000000000..35ff7f739f9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXParagraph.java @@ -0,0 +1,279 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Paragraph</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.lang.XComponent + * @see com.sun.star.style.CharacterPropertiesAsian + * @see com.sun.star.text.Paragraph + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.beans._XPropertySet + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.beans._XPropertyState + * @see ifc.style._CharacterProperties + * @see ifc.style._ParagraphProperties + * @see ifc.lang._XComponent + * @see ifc.style._CharacterPropertiesAsian + */ +public class SwXParagraph extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + + } + + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + + /** + * Creating a Testenvironment for the interfaces to be tested. To obtain + * test component, at first several paragraphs are inserted to a major text + * of text document. Then enumeration of text paragraphs is created, and + * some paragraph is gotten using <code>XEnumeration</code> interface.<p> + * Object relations created : + * <ul> + * <li> <code>'PARA'</code> for + * {@link ifc.style._CharacterProperties} : paragraph </li> + * <li> <code>'PORTION'</code> for + * {@link ifc.style._CharacterProperties} : some text portion of + * paragraph. To obtain text portion, enumeration of paragraph text portions is + * created, and some text portion is gotten using <code>XEnumeration</code> + * interface. </li> + * <li> <code>'NRULES'</code> for + * {@link ifc.style._ParagraphProperties} : value of property + * 'NumberingRules' of paragraph. Method changes property + * 'NumberingStyleName' of previously obtained paragraph, and gets value of + * a property 'NumberingRules'. </li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + + XInterface oObj = null; + XPropertySet paraP = null; + XPropertySet portP = null; + Object nRules = null; + XInterface port = null; + XInterface para = null; + + log.println( "creating a test environment" ); + + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + try { + for (int i=0; i<5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace(log); + throw new StatusException( "Couldn't insert lines", e ); + } + + // Enumeration + XEnumerationAccess oEnumA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + try { + para = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + XEnumerationAccess oEnumB = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, para ); + XEnumeration oEnum2 = oEnumB.createEnumeration(); + port = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum2.nextElement()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } + + try { + portP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, port); + paraP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, para); + paraP.setPropertyValue("NumberingStyleName","Numbering 4"); + nRules = paraP.getPropertyValue("NumberingRules"); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } + + + try { + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + } catch ( Exception e) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } + + + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println("adding ObjectRelation 'PARA' for CharacterProperties"); + tEnv.addObjRelation("PARA", paraP); + + log.println("adding ObjectRelation 'PORTION' for CharacterProperties"); + tEnv.addObjRelation("PORTION", portP); + + log.println("adding ObjectRelation 'NRULES' for ParagraphProperties"); + tEnv.addObjRelation("NRULES", nRules); + + tEnv.addObjRelation("NoAttach","SwXParagraph"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXParagraph + diff --git a/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java new file mode 100644 index 000000000000..9be419637935 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ParagraphEnumeration</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XEnumeration</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XEnumeration + * @see ifc.container._XEnumeration + */ +public class SwXParagraphEnumeration extends TestCase { + XTextDocument xTextDoc = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After major + * text is gotten from a text document, three paragraphs (each of them + * filled by 5 strings) are inserted to major text. Finally, paragraph + * enumeration is created using <code>XEnumeration</code> interface. + * Object relations created : + * <ul> + * <li> <code>'ENUM'</code> for + * {@link ifc.container._XEnumeration} : major text of text document + * with several paragraphs inserted, queried to + * <code>XEnumerationAccess</code> interface.</li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int i=0; i<3; i++) { + try { + oText.insertString( oCursor, "Paragraph Number: " + i, false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + + for (int j=0; j<5; j++){ + try { + oText.insertString( oCursor,"The quick brown fox jumps"+ + " over the lazy Dog: SwXParagraph", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, "THE QUICK BROWN FOX JUMPS"+ + " OVER THE LAZY DOG: SwXParagraph", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + } + + try { + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + } + + // Enumeration + XEnumerationAccess oEnumA = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + oObj = oEnum; + + log.println("creating a new environment for ParagraphEnumeration object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("ENUM", oEnumA); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXParagraphEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java b/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java new file mode 100644 index 000000000000..0a9345ccc401 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java @@ -0,0 +1,110 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XPrintSettingsSupplier; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.PrintSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::PrintSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.PrintSettings + * @see ifc.text._PrintSettings + */ +public class SwXPrintSettings extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.GlobalSettings</code>, then print settings are + * gotten using <code>XPrintSettingsSupplier</code> interface. + */ + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + Object oInst = null; + + log.println( "creating a test environment" ); + try { + XMultiServiceFactory myMSF = (XMultiServiceFactory)tParam.getMSF(); + oInst = myMSF.createInstance("com.sun.star.text.GlobalSettings"); + } catch ( com.sun.star.uno.Exception e ){ + log.println("Couldn't create instance!" + e); + e.printStackTrace( log ); + throw new StatusException( "Couldn't create instance!", e ); + } + XPrintSettingsSupplier xPSS = (XPrintSettingsSupplier) + UnoRuntime.queryInterface(XPrintSettingsSupplier.class, oInst); + oObj = xPSS.getPrintSettings(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPrintSettings + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java b/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java new file mode 100644 index 000000000000..56d2cca07516 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; + +/** + * Test for object which is represented by text document.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.beans.XPropertySet + * @see ifc.beans._XPropertySet + */ +public class SwXPropertySet extends TestCase { + XTextDocument xTextDoc; + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Method creates text document as a test component. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); + try { + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create text document", e ); + } + + TestEnvironment tEnv = new TestEnvironment( xTextDoc ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPropertySet + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java b/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java new file mode 100644 index 000000000000..1ab4f7b370ce --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by PropertySetInfo of + * text document.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XPropertySetInfo</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.beans.XPropertySetInfo + * @see ifc.beans._XPropertySetInfo + */ +public class SwXPropertySetInfo extends TestCase { + XTextDocument xTextDoc; + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. Method + * creates text document, then obtains PropertySetInfo of created text + * document using <code>XPropertySet</code> interface. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + + log.println( " getting the XPropertySetInfo" ); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xTextDoc); + oObj = xProp.getPropertySetInfo(); + log.println( " creating a new environment for PropertySetInfo object" ); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPropertySetInfo + diff --git a/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java b/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java new file mode 100644 index 000000000000..f3761738fd7b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ReferenceMark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.ReferenceMark + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.text._XTextContent + */ +public class SwXReferenceMark extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.ReferenceMark</code>, then sets new + * name of created ReferenceMark using <code>XNamed</code> interface. + * Finally, renamed ReferenceMark is inserted to a major text of text + * document as a text content. + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + XText oText = null; + String Name = "SwXReferenceMark"; + + log.println( "creating a test environment" ); + oText = xTextDoc.getText(); + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object instance = null; + try { + oObj = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.ReferenceMark"); + instance = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.ReferenceMark"); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't get ReferenceMark", e); + } + + XNamed oObjN = (XNamed) UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN.setName(Name); + XTextContent oObjTC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oObj); + + XTextCursor oCursor = oText.createTextCursor(); + try { + oText.insertTextContent(oCursor, oObjTC, false); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace( log ); + throw new StatusException(" Couldn't insert ReferenceMark", e); + } + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXReferenceMark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java b/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java new file mode 100644 index 000000000000..bf53b234bd97 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XReferenceMarksSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ReferenceMarks</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.ReferenceMarks + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXReferenceMarks extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instances of the service + * <code>com.sun.star.text.ReferenceMark</code>, then sets new names to + * created ReferenceMark's using <code>XNamed</code> interface. Then renamed + * ReferenceMark's are inserted to a major text of text document. Finally, + * ReferenceMarks are gotten from text document using + * <code>XReferenceMarksSupplier</code> interface. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XText oText = null; + String Name = "SwXReferenceMark01"; + String Name2 = "SwXReferenceMark02"; + + log.println( "creating a test environment" ); + oText = xTextDoc.getText(); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + // Creation and insertion of ReferenceMark01 + try { + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't get ReferenceMark", e); + } + XNamed oObjN = (XNamed) UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN.setName(Name); + XTextContent oObjTC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oObj); + XTextCursor oCursor = oText.createTextCursor(); + try { + oText.insertTextContent(oCursor, oObjTC, false); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace( log ); + throw new StatusException(" Couldn't insert ReferenceMark01", e); + } + + // Creation and insertion of ReferenceMark02 + try { + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't get ReferenceMark", e); + } + XNamed oObjN2 = (XNamed) UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN2.setName(Name2); + + XTextContent oObjTC2 = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oObj); + try { + oText.insertTextContent(oCursor, oObjTC2, false); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + e.printStackTrace( log ); + throw new StatusException(" Couldn't insert ReferenceMark02", e); + } + + // getting ReferenceMarks from text document + XReferenceMarksSupplier oRefSupp = (XReferenceMarksSupplier) + UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xTextDoc); + oObj = oRefSupp.getReferenceMarks(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXReferenceMarks + diff --git a/qadevOOo/tests/java/mod/_sw/SwXShape.java b/qadevOOo/tests/java/mod/_sw/SwXShape.java new file mode 100644 index 000000000000..bd516d22f46f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXShape.java @@ -0,0 +1,133 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.drawing.Shape</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.drawing.XShape + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.drawing.Shape + * @see ifc.lang._XComponent + * @see ifc.drawing._XShape + * @see ifc.drawing._XShapeDescriptor + * @see ifc.beans._XPropertySet + * @see ifc.drawing._Shape + */ +public class SwXShape extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. At first, + * DrawPage is gotten from text document using <code>XDrawPageSupplier</code> + * interface. Then shape (rectangle) is created and added to DrawPage + * obtained before, then returned as a test component. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XDrawPage oDP = null; + XShapes oShapes = null; + + log.println( "creating a test environment" ); + log.println( "getting Drawpage" ); + XDrawPageSupplier oDPS = (XDrawPageSupplier) + UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDoc); + oDP = oDPS.getDrawPage(); + + log.println( "getting Shape" ); + oShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, oDP); + oObj = SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle"); + oShapes.add((XShape) oObj); + + for ( int i = 0; i < 9; i++){ + XInterface oShape = SOF.createShape(xTextDoc, + 5000 + 100*i,3500,7500,5000,"Rectangle"); + oShapes.add((XShape) oShape); + } + + log.println( "creating a new environment for XShape object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXShape + diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyle.java b/qadevOOo/tests/java/mod/_sw/SwXStyle.java new file mode 100644 index 000000000000..ab6e9a92b137 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyle.java @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.Style</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::style::Style</code></li> + * <li> <code>com::sun::star::style::XStyle</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.style.Style + * @see com.sun.star.style.XStyle + * @see ifc.container._XNamed + * @see ifc.style._Style + * @see ifc.style._XStyle + */ +public class SwXStyle extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * At first style families are gotten from a text document using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from this style family using <code>XIndexAccess</code> interface. + * Next, method creates an instance of the service + * <code>com.sun.star.style.CharacterStyle</code> and inserts it to a + * previously obtained style family using <code>XNameContainer</code> + * interface. Finally, method creates a cursor of a major text of text + * document and sets it's property 'CharStyleName' value to the name of + * previously created style's name. + * Object relations created : + * <ul> + * <li> <code>'PoolStyle'</code> for + * {@link ifc.style._XStyle} : slyle indexed '10' obtained from + * StyleFamily indexed '0' from text document using + * <code>XIndexAccess</code> interface.</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) { + + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + try { + log.println("getting style"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFsIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSF); + oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFsIA.getByIndex(0)); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oSFIA.getByIndex(10)); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + try { + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.CharacterStyle"); + oMyStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, oInt); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error: exception occurred."); + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + try { + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + throw new StatusException( "Couldn't create environment ", e ); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + try { + xProp.setPropertyValue("CharStyleName", oMyStyle.getName()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create environment ", e ); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + tEnv.addObjRelation("PropertyNames",getPropertyNames(xStyleProp)); + + return tEnv; + } + + public String[] getPropertyNames(XPropertySet props) { + Property[] the_props = props.getPropertySetInfo().getProperties(); + String[] names = new String[the_props.length]; + String placebo = ""; + for (int i=0;i<the_props.length;i++) { + boolean isWritable = + ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable) placebo=the_props[i].Name; + } + for (int i=0;i<the_props.length;i++) { + boolean isWritable = + ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable) { + names[i]=the_props[i].Name; + } else { + names[i] = placebo; + } + } + return names; + } + +} // finish class SwXStyle diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java b/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java new file mode 100644 index 000000000000..d8a5b840ecb3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.StyleFamilies</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.style.StyleFamilies + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XIndexAccess + */ +public class SwXStyleFamilies extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. Style families + * are gotten from text document using <code>XStyleFamiliesSupplier</code> + * interface and returned as a test component. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + + + log.println( "Creating a test environment" ); + XTextDocument xArea = (XTextDocument) + UnoRuntime.queryInterface(XTextDocument.class, xTextDoc); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xArea); + XNameAccess oSF = oSFS.getStyleFamilies(); + + TestEnvironment tEnv = new TestEnvironment(oSF); + return tEnv; + } + + +} // finish class SwXStyle + diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.java b/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.java new file mode 100644 index 000000000000..75180338e316 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.java @@ -0,0 +1,197 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.StyleFamily</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNameContainer</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XNameReplace</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XNameReplace + * @see ifc.container._XNameContainer + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XNameReplace + */ +public class SwXStyleFamily extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. At first, + * style families of text document are gotten using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from previously obtained style families collection using + * <code>XIndexAccess</code> interface. Finally, method creates an instance + * of the service <code>com.sun.star.style.CharacterStyle</code> and inserts + * it to a gotten style family as 'SwXStyleFamily' using + * <code>XNameContainer</code> interface. + * Object relations created : + * <ul> + * <li> <code>'XNameReplaceINDEX'</code> for + * {@link ifc.container._XNameReplace} : number of last taken instance + * of <code>com.sun.star.style.CharacterStyle</code>, when multithread + * testing is going.</li> + * <li> <code>'NAMEREPLACE'</code> for + * {@link ifc.container._XNameReplace} : name of style family, inserted + * to style families of a text document.</li> + * <li> <code>'INSTANCEn'</code> for + * {@link ifc.container._XIndexContainer}, + * {@link ifc.container._XIndexReplace}, + * {@link ifc.container._XNameContainer}, + * {@link ifc.container._XNameReplace} : several relations, which are + * represented by instances of service + * <code>com.sun.star.style.CharacterStyle</code>.</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XNameAccess oSFNA = null; + + log.println( "Creating Test Environment..." ); + + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); + XComponent xComp = (XComponent) + UnoRuntime.queryInterface(XComponent.class, xTextDoc); + XInterface oInstance = (XInterface) + SOF.createInstance(xComp, "com.sun.star.style.CharacterStyle"); + XStyleFamiliesSupplier oSFsS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess oSF = oSFsS.getStyleFamilies(); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSF); + + try { + oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFIA.getByIndex(0)); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + e.printStackTrace(log); + throw new StatusException("Unexpected exception. ", e); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + throw new StatusException("Unexpected exception. ", e); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + throw new StatusException("Unexpected exception. ", e); + } + + XNameContainer oContainer = (XNameContainer) + UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + // insert a Style which can be replaced by name + try { + oContainer.insertByName("SwXStyleFamily",oInstance); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } catch ( com.sun.star.container.ElementExistException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } + + TestEnvironment tEnv = new TestEnvironment(oSFNA); + + int THRCNT = 1; + if ((String)Param.get("THRCNT") != null) { + THRCNT = Integer.parseInt((String)Param.get("THRCNT")); + } + String nr = new Integer(THRCNT+1).toString(); + + log.println( "adding NameReplaceIndex as mod relation to environment" ); + tEnv.addObjRelation("XNameReplaceINDEX", nr); + + for (int n=1; n<(THRCNT+3); n++ ) { + log.println( "adding INSTANCE"+n+" as mod relation to environment"); + tEnv.addObjRelation("INSTANCE"+n, + SOF.createInstance(xComp,"com.sun.star.style.CharacterStyle")); + } + + log.println("adding NAMEREPLACE as mod relation to environment"); + tEnv.addObjRelation("NAMEREPLACE", "SwXStyleFamily"); + + return tEnv; + } + +} // finish class SwXStyleFamily diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java b/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java new file mode 100644 index 000000000000..2ceaf704254b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java @@ -0,0 +1,172 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TextSectionDsc; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCell; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by cell text of the text table.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXTableCellText extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After creation + * of text table, it is inserted to a text document. Then cell named 'A1' is + * obtained from table, string 'SwXTableCellText' is set to this cell, then + * cell text is gotten from cell obtained before and returned as a test + * component. + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : table cell text</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates text sections</li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "Creating a test environment" ); + try { + oTable = SOF.createTextTable( xTextDoc ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + +e.getMessage(),e); + } + + try { + SOF.insertTextContent(xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't insert text content : " + +e.getMessage(),e); + } + + XCell oCell = oTable.getCellByName("A1"); + XSimpleText oCellText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, oCell); + oCellText.setString("SwXTableCellText"); + oObj = oCellText.getText(); + + log.println( "creating a new environment for Cell object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXT", (XText) oObj); + + log.println( " adding InstCreator object" ); + TextSectionDsc tDsc = new TextSectionDsc(); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTableCellText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java b/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java new file mode 100644 index 000000000000..ace59c91cc02 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.TableColumns</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::table::XTableColumns</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.table.XTableColumns + * @see com.sun.star.table.TableColumns + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.table._XTableColumns + */ +public class SwXTableColumns extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After creation + * of text table, it is inserted to text document, then columns are gotten + * from table. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "creating a test environment" ); + + try { + oTable = SOF.createTextTable( xTextDoc ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable: " + +e.getMessage(),e); + } + + try { + SOF.insertTextContent(xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't insert text content: " + +e.getMessage(),e); + } + + oObj = oTable.getColumns(); + + log.println( "creating a new environment for TableColumns object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XTableColumns + tEnv.addObjRelation("XTableColumns.XCellRange", + UnoRuntime.queryInterface(XCellRange.class, oTable)); + + tEnv.addObjRelation("XIndexAccess.getByIndex.mustBeNull", new Boolean(true)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTableColumns + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableRows.java b/qadevOOo/tests/java/mod/_sw/SwXTableRows.java new file mode 100644 index 000000000000..8d11e3607f44 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableRows.java @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.TableRows</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::table::XTableRows</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.table.XTableRows + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.table._XTableRows + */ +public class SwXTableRows extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After creation + * of text table, it is inserted to text document, then rows are gotten + * from table. + */ + public synchronized TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + oTable = SOF.createTextTable( xTextDoc ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable: " + +e.getMessage(),e); + } + + try { + SOF.insertTextContent(xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace( log ); + throw new StatusException("Couldn't insert text content: " + +e.getMessage(),e); + } + oObj = oTable.getRows(); + + log.println( "creating a new environment for TableColumns object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XTableColumns + tEnv.addObjRelation("XTableRows.XCellRange", + UnoRuntime.queryInterface(XCellRange.class, oTable)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTableRows + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java b/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java new file mode 100644 index 000000000000..99a61a82bbdb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java @@ -0,0 +1,184 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextColumns; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.TextColumns</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextColumns</code></li> + * <li> <code>com::sun::star::text::TextColumns</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextColumns + * @see com.sun.star.text.TextColumns + * @see ifc.text._XTextColumns + * @see ifc.text._TextColumns + */ +public class SwXTextColumns extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After style + * families are gotten from text document using + * <code>XStyleFamiliesSupplier</code> interface, style family indexed '2' + * is obtained using <code>XIndexAccess</code> interface. Then style + * named 'Standard' is gotten from previously obtained style family using + * <code>XNameAccess</code> interface, and 'TextColumns' property value + * of this style is returned as a test component. Finally, several + * paragraphs within the text are inserted to a text document. + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + XInterface oObj = null; + TestEnvironment tEnv = null; + XStyle oStyle = null; + + log.println( "creating a test environment" ); + log.println("getting PageStyle"); + XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) + UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFIA = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oSF); + + try { + XNameAccess oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFIA.getByIndex(2)); + oStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oSFNA.getByName("Standard")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } + + try { + log.println("Getting property ('TextColumns') value of style " + + oStyle.getName()); + XPropertySet xProps = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class,oStyle); + oObj = (XTextColumns) AnyConverter.toObject( + new Type(XTextColumns.class),xProps.getPropertyValue("TextColumns")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some text to text document..." ); + try { + for (int i =0; i < 5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println("Exception occurred while inserting Text"); + e.printStackTrace(log); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oObj); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextColumns diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java new file mode 100644 index 000000000000..a7313943ce50 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java @@ -0,0 +1,316 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; +import java.util.Vector; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XParagraphCursor; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.TextCursor</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextCursor</code></li> + * <li> <code>com::sun::star::text::XWordCursor</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::text::XSentenceCursor</code></li> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::text::XParagraphCursor</code></li> + * <li> <code>com::sun::star::document::XDocumentInsertable</code></li> + * <li> <code>com::sun::star::util::XSortable</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.text.XTextCursor + * @see com.sun.star.text.XWordCursor + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.text.XTextRange + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XContentEnumerationAccess + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.text.XSentenceCursor + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XParagraphCursor + * @see com.sun.star.document.XDocumentInsertable + * @see com.sun.star.util.XSortable + * @see com.sun.star.style.CharacterPropertiesAsian + * @see ifc.text._XTextCursor + * @see ifc.text._XWordCursor + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.text._XTextRange + * @see ifc.beans._XPropertySet + * @see ifc.container._XContentEnumerationAccess + * @see ifc.beans._XPropertyState + * @see ifc.style._CharacterProperties + * @see ifc.text._XSentenceCursor + * @see ifc.style._ParagraphProperties + * @see ifc.text._XParagraphCursor + * @see ifc.document._XDocumentInsertable + * @see ifc.util._XSortable + * @see ifc.style._CharacterPropertiesAsian + */ +public class SwXTextCursor extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes text document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. After major + * text of text document is obtained, text cursor is created and several + * paragraphs within the text are inserted to a text document. Finally, + * text cursor is returned as a test component. + * Object relations created : + * <ul> + * <li> <code>'XTEXT'</code> for + * {@link ifc.text._XTextRange} : major text of text document</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + log.println("creating a test environment"); + + + // get the bodytext of textdocument here + log.println("getting the TextCursor"); + + final XSimpleText aText = xTextDoc.getText(); + final XTextCursor textCursor = aText.createTextCursor(); + oObj = textCursor; + + log.println("inserting some text"); + + try { + for (int i = 0; i < 3; i++) { + aText.insertString(textCursor, "" + (3 - i), false); + + for (int j = 0; j < 5; j++) { + aText.insertString(textCursor, "XTextCursor,XTextCursor", + false); + aText.insertString(textCursor, "The quick brown fox ", + false); + aText.insertString(textCursor, "jumps over the lazy dog ", + false); + } + + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertControlCharacter(textCursor, + ControlCharacter.LINE_BREAK, + false); + } + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Error, insert text to text document."); + e.printStackTrace(log); + } + + log.println("creating a new environment for SwXTextCursor object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XTEXT", xTextDoc.getText()); + + XPropertySet xCursorProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oObj); + tEnv.addObjRelation("PropertyNames", getPropertyNames(xCursorProp)); + + //Adding relation for util.XSortable + final XParagraphCursor paragrCursor = (XParagraphCursor) UnoRuntime.queryInterface( + XParagraphCursor.class, + oObj); + final PrintWriter finalLog = log; + + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + textCursor.gotoEnd(false); + + try { + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "4", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "b", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "3", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "a", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "23", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "ab", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + out.println("Unexpected exception:" + e); + } + + out.println( + "Preparing cursor to sorting. Text before sorting:"); + paragrCursor.gotoEnd(true); + + for (int i = 0; i < 6; i++) { + paragrCursor.gotoPreviousParagraph(true); + } + + out.println(textCursor.getString()); + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + String ls = System.getProperty("line.separator"); + + String text = paragrCursor.getString(); + out.println("Text after sorting:\n" + text); + + boolean res = false; + + if (isSortNumbering) { + if (isSortAscending) { + res = text.endsWith(ls+"3"+ls+"4"+ls+"23"); + + if (!res) { + out.println("Text must ends by:\n" + "\r\n3\r\n4\r\n23\r\n"); + } + } else { + res = text.startsWith("23"+ls+"4"+ls+"3"+ls); + + if (!res) { + out.println("Text must starts with:\n" + "23\r\n4\r\n3\r\n"); + } + } + } else { + if (isSortAscending) { + res = text.equals(ls+"23"+ls+"3"+ls+"4"+ls+"a"+ls+"ab"+ls+"b"); + + if (!res) { + out.println("Text must be equal to:\n" + "\r\n23\r\n3\r\n4\r\na\r\nab\r\nb\r\n"); + } + } else { + res = text.endsWith("b"+ls+"ab"+ls+"a"+ls+"4"+ls+"3"+ls+"23"+ls); + + if (!res) { + out.println("Text must be equal to:\n" + "b\r\nab\r\na\r\n4\r\n3\r\n23\r\n"); + } + } + } + + if (res) { + out.println("Sorted correctly"); + } + + return res; + } + }); + + return tEnv; + } // finish method getTestEnvironment + + public String[] getPropertyNames(XPropertySet props) { + Property[] the_props = props.getPropertySetInfo().getProperties(); + Vector names = new Vector(); + + for (int i = 0; i < the_props.length; i++) { + boolean isWritable = ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + + if (isWritable) { + names.add(the_props[i].Name); + } + } + + return (String[]) names.toArray(new String[names.size()]); + } +} // finish class SwXTextCursor diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java b/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java new file mode 100644 index 000000000000..db5c223f4f29 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +//API Interfaces +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Defaults</code> created by a writer + * document's <code>XMultiServiceFactory</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * <li> <code>com::sun::star::text::Defaults</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::style::ParagraphPropertiesComplex</code></li> + * </ul> <p> + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.style.CharacterPropertiesAsian + * @see com.sun.star.text.Defaults + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.style.ParagraphPropertiesComplex + * @see ifc.style._ParagraphProperties + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.style._CharacterPropertiesAsian + * @see ifc.text._Defaults + * @see ifc.style._CharacterProperties + * @see ifc.beans._XPropertySet + * @see ifc.style._ParagraphPropertiesComplex + */ +public class SwXTextDefaults extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates the service <code>com.sun.star.text.Defaults</code> + */ + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + + XMultiServiceFactory docMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class,xTextDoc); + + try { + oObj = (XInterface) + docMSF.createInstance("com.sun.star.text.Defaults"); + } catch (com.sun.star.uno.Exception e) { + throw new StatusException("Couldn't create Object",e); + } + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + /** + * Creates text document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes text document. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java b/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java new file mode 100644 index 000000000000..da2f53168863 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java @@ -0,0 +1,268 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextSection; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XWordCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; + +import util.SOfficeFactory; +import util.WriterTools; + + +public class SwXTextDocument extends TestCase { + XTextDocument xTextDoc; + XTextDocument xSecondTextDoc; + + protected void initialize(TestParameters tParam, PrintWriter log) { + } + + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + DesktopTools.closeDoc(xSecondTextDoc); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + */ + public synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws StatusException { + TestEnvironment tEnv = null; + XTextTable the_table = null; + + try { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + (XMultiServiceFactory) Param.getMSF()); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting some lines"); + + try { + for (int i = 0; i < 5; i++) { + oText.insertString(oCursor, "Paragraph Number: " + i, + false); + oText.insertString(oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + oText.insertString(oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.LINE_BREAK, + false); + } + for (int i = 0; i < 11; i++) { + oText.insertString(oCursor, "xTextDoc ", false); + + } + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't insert lines", e); + } + + //insert two sections parent and child + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xTextDoc); + + XInterface oTS; + XTextSection xTS; + + XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier) UnoRuntime.queryInterface( + XTextSectionsSupplier.class, + xTextDoc); + XNameAccess oTSSuppName = oTSSupp.getTextSections(); + + oTS = (XInterface) oDocMSF.createInstance( + "com.sun.star.text.TextSection"); + + XTextContent oTSC = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + + XWordCursor oWordC = (XWordCursor) UnoRuntime.queryInterface( + XWordCursor.class, oCursor); + oCursor.setString("End of TextSection"); + oCursor.gotoStart(false); + oCursor.setString("Start of TextSection "); + oWordC.gotoEndOfWord(false); + + XInterface oTS2 = (XInterface) oDocMSF.createInstance( + "com.sun.star.text.TextSection"); + oTSC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, + oTS2); + oText.insertTextContent(oCursor, oTSC, false); + + XIndexAccess oTSSuppIndex = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, + oTSSuppName); + log.println( + "getting a TextSection with the XTextSectionSupplier()"); + xTS = (XTextSection) UnoRuntime.queryInterface(XTextSection.class, + oTSSuppIndex.getByIndex(0)); + + XNamed xTSName = (XNamed) UnoRuntime.queryInterface(XNamed.class, + xTS); + xTSName.setName("SwXTextSection"); + + log.println(" adding TextTable"); + the_table = SOfficeFactory.createTextTable(xTextDoc, 6, 4); + + XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class, + the_table); + the_name.setName("SwXTextDocument"); + SOfficeFactory.insertTextContent(xTextDoc, + (XTextContent) the_table); + + log.println(" adding ReferenceMark"); + + XInterface aMark = (XInterface) oDocMSF.createInstance( + "com.sun.star.text.ReferenceMark"); + the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class, aMark); + the_name.setName("SwXTextDocument"); + + XTextContent oTC = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, aMark); + SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC); + + log.println(" adding TextGraphic"); + WriterTools.insertTextGraphic(xTextDoc, oDocMSF, 5200, 4200, 4400, + 4000, "space-metal.jpg", + "SwXTextDocument"); + + log.println(" adding EndNote"); + + XInterface aEndNote = (XInterface) oDocMSF.createInstance( + "com.sun.star.text.Endnote"); + oTC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, + aEndNote); + SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC); + + log.println(" adding Bookmark"); + SOfficeFactory.insertTextContent(xTextDoc, + (XTextContent) SOfficeFactory.createBookmark( + xTextDoc)); + + log.println(" adding DocumentIndex"); + oTC = SOfficeFactory.createIndex(xTextDoc, + "com.sun.star.text.DocumentIndex"); + SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC); + + log.println(" adding TextFrame"); + + XTextFrame frame = SOfficeFactory.createTextFrame(xTextDoc, 500, + 500); + oTC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, + frame); + SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC); + + log.println("creating a second textdocument"); + xSecondTextDoc = WriterTools.createTextDoc( + (XMultiServiceFactory) Param.getMSF()); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + + if (xTextDoc != null) { + log.println("Creating instance..."); + + XText oText = xTextDoc.getText(); + XTextCursor oTextCursor = oText.createTextCursor(); + + for (int i = 0; i < 11; i++) { + oText.insertString(oTextCursor, "xTextDoc ", false); + } + + tEnv = new TestEnvironment(xTextDoc); + } else { + log.println("Failed to create instance."); + + return tEnv; + } + + XModel model1 = (XModel) UnoRuntime.queryInterface(XModel.class, + xTextDoc); + XModel model2 = (XModel) UnoRuntime.queryInterface(XModel.class, + xSecondTextDoc); + + XController cont1 = model1.getCurrentController(); + XController cont2 = model2.getCurrentController(); + + cont1.getFrame().setName("cont1"); + cont2.getFrame().setName("cont2"); + + XSelectionSupplier sel = (XSelectionSupplier) UnoRuntime.queryInterface( + XSelectionSupplier.class, cont1); + + log.println("Adding SelectionSupplier and Shape to select for XModel"); + tEnv.addObjRelation("SELSUPP", sel); + tEnv.addObjRelation("TOSELECT", the_table); + + log.println("adding Controller as ObjRelation for XModel"); + tEnv.addObjRelation("CONT1", cont1); + tEnv.addObjRelation("CONT2", cont2); + + return tEnv; + } +} // finish class SwXTextDocument diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java new file mode 100644 index 000000000000..50e218b0d319 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java @@ -0,0 +1,173 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import com.sun.star.beans.XPropertySet; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextEmbeddedObjectsSupplier; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** + * + * initial description + * @see com.sun.star.container.XNamed + * @see com.sun.star.document.XEmbeddedObjectSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextEmbeddedObject + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextEmbeddedObject + * + */ +public class SwXTextEmbeddedObject extends TestCase { + XTextDocument xTextDoc; + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) { + XInterface oObj = null; + + // create testobject here + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF()); + try { + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't open document", e); + } + + XTextCursor xCursor = xTextDoc.getText().createTextCursor(); + try { + XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object o = xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" ); + XTextContent xTextContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, o); + String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e"; + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xTextContent); + xPropertySet.setPropertyValue( "CLSID", sChartClassID ); + + xTextDoc.getText().insertTextContent( xCursor, xTextContent, false ); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace((java.io.PrintWriter)log); + } + + XTextEmbeddedObjectsSupplier oTEOS = (XTextEmbeddedObjectsSupplier) UnoRuntime.queryInterface( + XTextEmbeddedObjectsSupplier.class, + xTextDoc); + + XNameAccess oEmObj = oTEOS.getEmbeddedObjects(); + XIndexAccess oEmIn = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, oEmObj); + + try { + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), oEmIn.getByIndex(0)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Couldn't get Object", e); + } + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("NoAttach", "SwXTextEmbeddedObject"); + + XTextFrame aFrame = SOF.createTextFrame(xTextDoc, 500, 500); + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XTextContent the_content = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, aFrame); + + try { + oText.insertTextContent(oCursor, the_content, true); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Couldn't insert frame " + e.getMessage()); + } + + tEnv.addObjRelation("TextFrame", aFrame); + + tEnv.addObjRelation("NoSetSize", "SwXTextEmbeddedObject"); + tEnv.addObjRelation("NoPos", "SwXTextEmbeddedObject"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextEmbeddedObject diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java new file mode 100644 index 000000000000..51a3e8a45a12 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.beans.XPropertySet; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextEmbeddedObjectsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +public class SwXTextEmbeddedObjects extends TestCase { + + XTextDocument oDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + oDoc = SOF.createTextDoc(null); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn?t create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(oDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) throws StatusException { + + XInterface oObj = null; + + // create testobject here + XTextCursor xCursor = oDoc.getText().createTextCursor(); + try { + XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + Object o = xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" ); + XTextContent xTextContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, o); + String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e"; + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xTextContent); + xPropertySet.setPropertyValue( "CLSID", sChartClassID ); + + oDoc.getText().insertTextContent( xCursor, xTextContent, false ); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace((java.io.PrintWriter)log); + } + + XTextEmbeddedObjectsSupplier oTEOS = (XTextEmbeddedObjectsSupplier) + UnoRuntime.queryInterface(XTextEmbeddedObjectsSupplier.class, oDoc); + + oObj = oTEOS.getEmbeddedObjects(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextEmbeddedObjects + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextField.java b/qadevOOo/tests/java/mod/_sw/SwXTextField.java new file mode 100644 index 000000000000..aabab6efe480 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextField.java @@ -0,0 +1,168 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextField + * + */ +public class SwXTextField extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + Object instance = null; + + // create testobject here + try { + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + Object FieldMaster = oDocMSF.createInstance + ( "com.sun.star.text.FieldMaster.Database" ); + XPropertySet PFieldMaster = (XPropertySet) UnoRuntime.queryInterface + (XPropertySet.class,(XInterface) FieldMaster); + oObj = (XInterface) oDocMSF.createInstance + ( "com.sun.star.text.TextField.Database" ); + + instance = (XInterface) oDocMSF.createInstance + ( "com.sun.star.text.TextField.DateTime" ); + + XDependentTextField xTF = (XDependentTextField) + UnoRuntime.queryInterface(XDependentTextField.class,oObj); + + PFieldMaster.setPropertyValue("DataBaseName","Address Book File"); + PFieldMaster.setPropertyValue("DataTableName","address"); + PFieldMaster.setPropertyValue("DataColumnName","FIRSTNAME"); + XText the_Text = xTextDoc.getText(); + XTextCursor the_Cursor = the_Text.createTextCursor(); + XTextContent the_Field = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,oObj); + + xTF.attachTextFieldMaster(PFieldMaster); + the_Text.insertTextContent(the_Cursor,the_Field,false); + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMaster object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextField + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java b/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java new file mode 100644 index 000000000000..d0ba5c70af3c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.container.XNameReplace + * + */ +public class SwXTextFieldMasters extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + + // create testobject here + try { + XTextFieldsSupplier oTFS = (XTextFieldsSupplier) + UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + + oObj = oTFS.getTextFieldMasters(); + + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMasters object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFieldMasters + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java b/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java new file mode 100644 index 000000000000..1b730500f37c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * + */ +public class SwXTextFieldTypes extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + + // create testobject here + try { + XTextFieldsSupplier oTFS = (XTextFieldsSupplier) + UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + + oObj = oTFS.getTextFields(); + + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldTypes object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFieldTypes + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java b/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java new file mode 100644 index 000000000000..64874119ca14 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ +public class SwXTextFrame extends TestCase { + XTextDocument xTextDoc; + + protected void initialize(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + */ + public synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XTextFrame oFrame1 = null; + XTextFrame oFrame2 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) Param.getMSF()); + + + // creating Frames + log.println("creating Frames"); + + + Object instance = null; + + try { + oFrame1 = SOF.createTextFrame(xTextDoc, 500, 500); + oFrame2 = SOF.createTextFrame(xTextDoc, 1500, 1500); + oPropSet = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oFrame1); + + + // AnchorTypes: 0 = paragraph, 1 = as char, 2 = page, + // 3 = frame/paragraph 4= at char + oPropSet.setPropertyValue("AnchorType", + TextContentAnchorType.AS_CHARACTER); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println("inserting Frame1"); + + XTextContent the_content = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, oFrame1); + oText.insertTextContent(oCursor, the_content, true); + + log.println("inserting Frame2"); + the_content = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, oFrame2); + oText.insertTextContent(oCursor, the_content, true); + + XText oFrameText = oFrame1.getText(); + oFrameText.insertString(oFrameText.getStart(), "The FrameText", + true); + + instance = SOF.createInstance(xTextDoc, + "com.sun.star.text.TextFrame"); + } catch (Exception Ex) { + Ex.printStackTrace(log); + throw new StatusException("Couldn't insert TextFrame ", Ex); + } + + oObj = oFrame1; + + log.println("creating a new environment for TextFrame object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("CONTENT", + (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + log.println("adding ObjRelation for XShape " + + "(get/setPosition won't work there)"); + tEnv.addObjRelation("NoPos", "SwXTextFrame"); + tEnv.addObjRelation("NoSetSize", "SwXTextFrame"); + + tEnv.addObjRelation("TextFrame", oFrame2); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFrame diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java b/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java new file mode 100644 index 000000000000..ef304a631f9f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XTextRangeMover + * + */ +public class SwXTextFrameText extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) { + + XInterface oObj = null; + XTextFrame oFrame1 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + // create testobject here + //////////////////////////////////// + + try { + oFrame1 = SOF.createTextFrame(xTextDoc, 500, 500); + oPropSet = (XPropertySet)UnoRuntime.queryInterface + (XPropertySet.class, oFrame1 ); + //AnchorTypes: 0 = paragraph, 1 = as char, 2 = page, + // 3 = frame/paragraph 4= at char + oPropSet.setPropertyValue("AnchorType", new Integer(2)); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println( "inserting Frame1" ); + oText.insertTextContent(oCursor,oFrame1, false); + + } catch (Exception Ex ) { + Ex.printStackTrace(log); + throw new StatusException("Couldn't insert TextFrame ", Ex); + } + + XText oFText = (XText)UnoRuntime.queryInterface(XText.class, oFrame1); + XTextCursor oFCursor = oFText.createTextCursor(); + oFText.insertString(oFCursor, "SwXTextFrameText", false); + + oObj = oFText.getText(); + + log.println( "creating a new environment for TextFrameText object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXT", (XText) oObj); + + log.println( "adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextFrameText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java new file mode 100644 index 000000000000..9e45193586e2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java @@ -0,0 +1,207 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class SwXTextGraphicObject extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdoc" ); + xTextDoc = SOF.createTextDoc( null );; + } catch ( Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + Object oGObject = null; + Object xTextFrame = null; + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + Object instance = null; + + try { + oGObject = SOF.createInstance + (xTextDoc,"com.sun.star.text.GraphicObject"); + instance = SOF.createInstance + (xTextDoc,"com.sun.star.text.GraphicObject"); + xTextFrame = SOF.createTextFrame(xTextDoc, 500, 500); + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + throw new StatusException("Couldn't create instance", ex ); + } + + oObj = (XInterface) oGObject; + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,oObj); + + log.println("inserting Frame"); + try{ + XTextContent Framecontent = (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, xTextFrame); + the_text.insertTextContent(the_cursor, Framecontent, true); + } catch (Exception e) { + System.out.println("Couldn't insert text frame"); + e.printStackTrace(); + throw new StatusException("Couldn't insert text frame", e ); + } + + + log.println( "inserting graphic" ); + try { + the_text.insertTextContent(the_cursor,the_content,true); + } catch (Exception e) { + System.out.println("Couldn't insert Content"); + e.printStackTrace(); + throw new StatusException("Couldn't insert Content", e ); + } + + log.println( "adding graphic" ); + XPropertySet oProps = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class,oObj); + try { + String wat = util.utils.getFullTestURL("space-metal.jpg"); + oProps.setPropertyValue("AnchorType", + TextContentAnchorType.AT_PARAGRAPH); + oProps.setPropertyValue("GraphicURL",wat); + oProps.setPropertyValue("HoriOrientPosition",new Integer(5500)); + oProps.setPropertyValue("VertOrientPosition",new Integer(4200)); + oProps.setPropertyValue("Width",new Integer(4400)); + oProps.setPropertyValue("Height",new Integer(4000)); + } catch (Exception e) { + System.out.println("Couldn't set property 'GraphicURL'"); + e.printStackTrace(); + throw new StatusException + ("Couldn't set property 'GraphicURL'", e ); + } + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding ObjRelation for XShape " + +"(get/setPosition won't work there)" ); + tEnv.addObjRelation("NoPos", "SwXTextGraphicObject"); + tEnv.addObjRelation("NoSetSize","SwXTextGraphicObject"); + Object ImgMap = null; + //creating ObjectRelation for the property + // 'ImageMap' of 'TextGraphicObject' + try { + XMultiServiceFactory xDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface + (XMultiServiceFactory.class,xTextDoc); + ImgMap = xDocMSF.createInstance + ("com.sun.star.image.ImageMapRectangleObject"); + } + catch (Exception ex) { + ex.printStackTrace(); + } + + tEnv.addObjRelation("IMGMAP",ImgMap); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + //object relation for text.BaseFrameProperties + tEnv.addObjRelation("TextFrame", xTextFrame); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextGraphicObject + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.java b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.java new file mode 100644 index 000000000000..8b233ea5ceb5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.java @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextGraphicObjectsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class SwXTextGraphicObjects extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdoc" ); + xTextDoc = SOF.createTextDoc( null );; + } catch ( Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + Object oGObject = null; + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + oGObject = SOF.createInstance + (xTextDoc,"com.sun.star.text.GraphicObject"); + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + throw new StatusException("Couldn't create instance", ex ); + } + + oObj = (XInterface) oGObject; + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,oObj); + + log.println( "inserting graphic" ); + try { + the_text.insertTextContent(the_cursor,the_content,true); + } catch (Exception e) { + System.out.println("Couldn't insert Content"); + e.printStackTrace(); + throw new StatusException("Couldn't insert Content", e ); + } + + log.println( "adding graphic" ); + XPropertySet oProps = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class,oObj); + try { + String wat = util.utils.getFullTestURL("space-metal.jpg"); + oProps.setPropertyValue("GraphicURL",wat); + oProps.setPropertyValue("HoriOrientPosition",new Integer(5500)); + oProps.setPropertyValue("VertOrientPosition",new Integer(4200)); + oProps.setPropertyValue("Width",new Integer(4400)); + oProps.setPropertyValue("Height",new Integer(4000)); + } catch (Exception e) { + System.out.println("Couldn't set property 'GraphicURL'"); + e.printStackTrace(); + throw new StatusException("Couldn't set property 'GraphicURL'", e ); + } + + XTextGraphicObjectsSupplier xTGS = (XTextGraphicObjectsSupplier) + UnoRuntime.queryInterface(XTextGraphicObjectsSupplier.class, + xTextDoc); + oObj = xTGS.getGraphicObjects(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextGraphicObjects + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java b/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java new file mode 100644 index 000000000000..3b581644cbe3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.TextPortion + * + */ +public class SwXTextPortion extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + protected synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XInterface param = null; + XPropertySet paraP = null; + XPropertySet portP = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting Strings" ); + log.println( "inserting ControlCharacter" ); + + try{ + for (int i =0; i < 5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph\n", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + } + }catch(Exception e){ + log.println("Couldn't insert Text"); + e.printStackTrace(log); + throw new StatusException( "Couldn't insert Text", e ); + } + + // Enumeration + XEnumerationAccess oEnumA = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + int n = 0; + while ( (oEnum.hasMoreElements()) ) { + try { + param = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + log.println("Element Nr.: " + n ); + } catch ( Exception e) { + log.println("Couldn't get Paragraph"); + e.printStackTrace(log); + throw new StatusException( "Couldn't get Paragraph", e ); + } + n++; + } + + XEnumerationAccess oEnumP = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, param ); + XEnumeration oEnum2 = oEnumP.createEnumeration(); + try { + oObj = (XInterface)AnyConverter.toObject( + new Type(XInterface.class),oEnum2.nextElement()); + } catch ( Exception e) { + log.println("Couldn't get TextPortion"); + e.printStackTrace(log); + throw new StatusException( "Couldn't get TextPortion", e ); + } + + portP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, oObj); + paraP = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, param); + + + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println("adding ObjRelation TRO for TextContent"); + tEnv.addObjRelation("TRO", new Boolean(true)); + + log.println("adding ObjectRelation 'PARA' for CharacterProperties"); + tEnv.addObjRelation("PARA", paraP); + + log.println("adding ObjectRelation 'PORTION' for CharacterProperties"); + tEnv.addObjRelation("PORTION", portP); + + tEnv.addObjRelation("XTEXT", oText); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTextPortion + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java new file mode 100644 index 000000000000..b591a6b45be8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java @@ -0,0 +1,161 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.TextPortion + * + */ +public class SwXTextPortionEnumeration extends TestCase { + + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface param = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting Strings" ); + log.println( "inserting ControlCharacter" ); + + + try{ + for (int i =0; i < 5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph\n", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + } + }catch(Exception e){ + log.println("Couldn't insert Text"); + e.printStackTrace(); + throw new StatusException( "Couldn't insert Text", e ); + } + + // Enumeration + XEnumerationAccess oEnumA = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + int n = 0; + while ( (oEnum.hasMoreElements()) ) { + try { + param = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + } catch ( Exception e) { + log.println("Couldn't get Paragraph"); + e.printStackTrace(); + throw new StatusException( "Couldn't get Paragraph", e ); + } + n++; + } + + XEnumerationAccess oEnumP = (XEnumerationAccess) + UnoRuntime.queryInterface( XEnumerationAccess.class, param ); + XEnumeration oEnum2 = oEnumP.createEnumeration(); + + log.println( "creating a new environment for TextPortionEnumeration object" ); + TestEnvironment tEnv = new TestEnvironment( oEnum2 ); + + log.println("adding ObjRelation ENUM for XEnumeration"); + tEnv.addObjRelation("ENUM", oEnumP); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTextPortionEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextRange.java b/qadevOOo/tests/java/mod/_sw/SwXTextRange.java new file mode 100644 index 000000000000..8b09a01dac9d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextRange.java @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +public class SwXTextRange extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + */ + public synchronized TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + + XText aText = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + + // get the bodytext of textdocument here + log.println( "getting the TextRange of the text document" ); + aText = xTextDoc.getText(); + XTextCursor oCursor = aText.createTextCursor(); + + XInterface oObj = oCursor.getStart(); + + log.println( "creating a new environment for textrange object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + System.out.println("Implementation Name: "+utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextRange + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java b/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java new file mode 100644 index 000000000000..5310ab00546a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; + +/** + * + * initial description + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * + */ +public class SwXTextRanges extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int j =0; j < 5; j++){ + try{ + oText.insertString( oCursor, + "SwXTextRanges...SwXTextRanges...SwXTextRanges", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + catch( Exception e ){ + log.println( "EXCEPTION: " + e); + } + } + + XSearchable oSearch = (XSearchable)UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextRanges"); + + oObj = oSearch.findAll(xSDesc); + + log.println( "creating a new environment for textrange object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextRanges + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java b/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java new file mode 100644 index 000000000000..d637bb23a252 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.util.SearchDescriptor + * @see com.sun.star.util.XSearchDescriptor + * + */ +public class SwXTextSearch extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int j =0; j < 5; j++){ + try{ + oText.insertString( oCursor, + "SwXTextSearch...SwXTextSearch...SwXTextSearch", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + catch( Exception e ){ + log.println( "EXCEPTION: " + e); + } + } + + XSearchable oSearch = (XSearchable)UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextSearch"); + + oObj = xSDesc; + + log.println( "creating a new environment for TextSearch object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextSearch + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSection.java b/qadevOOo/tests/java/mod/_sw/SwXTextSection.java new file mode 100644 index 000000000000..c74f3a527323 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSection.java @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextColumns; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextSection; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.text.XWordCursor; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ + +public class SwXTextSection extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XInterface oTS = null; + XTextSection xTS = null; + XText oText = null; + XTextColumns TC = null; + Object instance = null; + + log.println( "creating a test environment" ); + + oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + try { + XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier) + UnoRuntime.queryInterface + ( XTextSectionsSupplier.class, xTextDoc ); + XNameAccess oTSSuppName = oTSSupp.getTextSections(); + + //cleanup if necessary + if (oTSSuppName.hasByName("SwXTextSection")) { + XTextSection old = (XTextSection) AnyConverter.toObject( + new Type(XTextSection.class), + oTSSuppName.getByName("SwXTextSection")); + XComponent oldC = (XComponent) + UnoRuntime.queryInterface(XComponent.class,old); + oldC.dispose(); + oText.setString(""); + } + + //insert two sections parent and child + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + instance = oDocMSF.createInstance("com.sun.star.text.TextSection"); + XTextContent oTSC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + XWordCursor oWordC = (XWordCursor) + UnoRuntime.queryInterface(XWordCursor.class, oCursor); + oCursor.setString("End of TextSection"); + oCursor.gotoStart(false); + oCursor.setString("Start of TextSection "); + oWordC.gotoEndOfWord(false); + XInterface oTS2 = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + oTSC = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, oTS2); + oText.insertTextContent(oCursor, oTSC, false); + + XIndexAccess oTSSuppIndex = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, oTSSuppName); + + log.println( "getting a TextSection with the XTextSectionSupplier()" ); + xTS = (XTextSection) AnyConverter.toObject( + new Type(XTextSection.class),oTSSuppIndex.getByIndex(0)); + XNamed xTSName = (XNamed) + UnoRuntime.queryInterface( XNamed.class, xTS); + xTSName.setName("SwXTextSection"); + } + catch(Exception e){ + System.out.println("Couldn't get Textsection " + e); + } + + oObj = xTS; + + log.println( "creating a new environment for TextSection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + tEnv.addObjRelation("TRO",new Boolean(true)); + + try { + TC = (XTextColumns) UnoRuntime.queryInterface(XTextColumns.class, + oDocMSF.createInstance("com.sun.star.text.TextColumns")); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace(log); + throw new StatusException + ("Couldn't create instance of service TextColumns", e ); + } + tEnv.addObjRelation("TC",TC); + + tEnv.addObjRelation("CONTENT", (XTextContent) + UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment + +}// finish class SwXTextSection + + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSections.java b/qadevOOo/tests/java/mod/_sw/SwXTextSections.java new file mode 100644 index 000000000000..0a672de3bdc8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSections.java @@ -0,0 +1,152 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ +public class SwXTextSections extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a Testenvironment for the interfaces to be tested + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log ) throws StatusException { + + XInterface oObj = null; + XInterface oTS = null; + XNameAccess oTSSuppName = null; + + XText oText = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + + oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + + log.println( "inserting TextSections" ); + + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + // First TextSection + try { + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + XTextContent oTSC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + } + catch(Exception e){ + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + + // Second TextSection + try { + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + XTextContent oTSC = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + } + catch(Exception e){ + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + + + log.println( "try to get a TextSection with the XTextSectionSupplier()" ); + + try{ + XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier) + UnoRuntime.queryInterface( XTextSectionsSupplier.class, + xTextDoc ); + oTSSuppName = oTSSupp.getTextSections(); + } + catch(Exception e){ + System.out.println("Couldn't get Textsection " + e); + } + + + oObj = oTSSuppName; + + log.println( "creating a new environment for TextSections object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextSection diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTable.java b/qadevOOo/tests/java/mod/_sw/SwXTextTable.java new file mode 100644 index 000000000000..c3bc78208b27 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTable.java @@ -0,0 +1,261 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.ValueComparer; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCell; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; + + +/** + * this class tests the implementation of listed interfaces + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextTable + */ +public class SwXTextTable extends TestCase { + SOfficeFactory SOF; + XTextDocument xTextDoc; + + protected void initialize(TestParameters tParam, PrintWriter log) { + SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + this method creates the testenvironment + @param tParam TestParameters class which contains additional + test parameters + @param log PrintWriter class to log the test state and result + + @return TestEnvironment class + + @see TestParameters + @see PrintWriter + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) { + // creation of testobject here + XTextTable oObj = null; + TestEnvironment tEnv = null; + Object instance = null; + + try { + oObj = SOF.createTextTable(xTextDoc); + instance = SOF.createTextTable(xTextDoc); + } catch (com.sun.star.uno.Exception uE) { + uE.printStackTrace(log); + throw new StatusException("Couldn't create testobj : " + + uE.getMessage(), uE); + } + + int nRow = 6; + int nCol = 2; + oObj.initialize(nRow, nCol); + + log.println("Creating instance..."); + tEnv = new TestEnvironment(oObj); + + if (SOF.getTableCollection(xTextDoc).getCount() == 0) { + try { + SOF.insertTextContent(xTextDoc, oObj); + } catch (com.sun.star.uno.Exception uE) { + uE.printStackTrace(log); + throw new StatusException("Couldn't create TextTable : " + + uE.getMessage(), uE); + } + } + + XPropertySet props = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + try { + props.setPropertyValue("ChartRowAsLabel", new Boolean(true)); + props.setPropertyValue("ChartColumnAsLabel", new Boolean(true)); + } catch (Exception e) { + e.printStackTrace(log); + } + + + //Adding relation for util.XTextTable + tEnv.addObjRelation("NROW", new Integer(nRow)); + tEnv.addObjRelation("NCOL", new Integer(nCol)); + + //Adding ObjRelation for XCellRangeData + Object[][] newData = new Object[6][]; + Object[] line = new Object[2]; + line[0] = new Double(1.5); + line[1] = new Double(2.5); + newData[0] = line; + newData[1] = line; + newData[2] = line; + newData[3] = line; + newData[4] = line; + newData[5] = line; + tEnv.addObjRelation("NewData", newData); + + //Adding relation for util.XSortable + final PrintWriter finalLog = log; + final XTextTable oTable = oObj; + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + oTable.getCellByName("A1").setValue(4); + + XTextRange textRange = (XTextRange) UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A2")); + textRange.setString("b"); + oTable.getCellByName("A3").setValue(3); + textRange = (XTextRange) UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A4")); + textRange.setString("a"); + oTable.getCellByName("A5").setValue(23); + textRange = (XTextRange) UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A6")); + textRange.setString("ab"); + + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + boolean res = false; + String[] value = new String[6]; + + for (int i = 0; i < 6; i++) { + XCell cell = oTable.getCellByName("A" + (i + 1)); + XTextRange textRange = (XTextRange) UnoRuntime.queryInterface( + XTextRange.class, cell); + value[i] = textRange.getString(); + } + + if (isSortNumbering) { + if (isSortAscending) { + String[] rightVal = { "3", "4", "23" }; + String[] vals = { value[3], value[4], value[5] }; + res = ValueComparer.equalValue(vals, rightVal); + + if (!res) { + out.println("Expected: 3, 4, 23"); + out.println("Getting: " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } else { + String[] rightVal = { "23", "4", "3" }; + String[] vals = { value[0], value[1], value[2] }; + res = ValueComparer.equalValue(vals, rightVal); + + if (!res) { + out.println("Expected: 23, 4, 3"); + out.println("Getting: " + value[1] + ", " + + value[2] + ", " + value[3]); + } + } + } else { + if (isSortAscending) { + String[] rightVal = { "23", "3", "4", "a", "ab", "b" }; + res = ValueComparer.equalValue(value, rightVal); + + if (!res) { + out.println("Expected: 23, 3, 4, a, ab, b"); + out.println("Getting: " + value[0] + ", " + + value[1] + ", " + value[2] + + ", " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } else { + String[] rightVal = { "b", "ab", "a", "4", "3", "23" }; + res = ValueComparer.equalValue(value, rightVal); + + if (!res) { + out.println("Expected: b, ab, a, 4, 3, 23"); + out.println("Getting: " + value[0] + ", " + + value[1] + ", " + value[2] + + ", " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } + } + + if (res) { + out.println("Sorted correctly"); + } else { + out.println("Sorted uncorrectly"); + } + + return res; + } + }); + + tEnv.addObjRelation("CONTENT", + (XTextContent) UnoRuntime.queryInterface( + XTextContent.class, instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } +} // finish class SwXTextTable diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java new file mode 100644 index 000000000000..765dd4d6cea3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XTextTableCursor + * + */ +public class SwXTextTableCursor extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + // create testobject here + + XTextTable oTable = null; + try { + oTable = SOF.createTextTable( xTextDoc ); + SOF.insertTextContent(xTextDoc, oTable ); + } + catch( com.sun.star.uno.Exception uE ) { + uE.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + + uE.getMessage(), uE); + } + + oObj = oTable.createCursorByCellName("A1"); + + log.println( "creating a new environment for TextTableCursor object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + tEnv.addObjRelation("STYLENAME1", "Table"); + tEnv.addObjRelation("STYLENAME2", "Text"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTableCursor + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java b/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java new file mode 100644 index 000000000000..11df9282c49f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XTableRows; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +public class SwXTextTableRow extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XTextTable oTable = null; + + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "Creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); + + try { + log.println("creating a texttable"); + oTable = (XTextTable) SOF.createTextTable(xTextDoc,5,5); + } catch( Exception e ) { + e.printStackTrace(log); + } + + XText oText = xTextDoc.getText(); + + XTextCursor oCursor = oText.createTextCursor(); + + try { + log.println("inserting texttable"); + oText.insertTextContent(oCursor, oTable, false); + } catch (Exception e) { + log.println("Exception!"); + } + + try { + log.println("getting table row"); + XTableRows oTRn = oTable.getRows(); + XIndexAccess oIA = (XIndexAccess) UnoRuntime.queryInterface + (XIndexAccess.class,oTRn); + oObj = (XPropertySet) AnyConverter.toObject( + new Type(XPropertySet.class),oIA.getByIndex(1)); + } catch( Exception e ) { + e.printStackTrace(log); + } + + log.println( "creating a new environment for TextTableRow object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTableRow + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTables.java b/qadevOOo/tests/java/mod/_sw/SwXTextTables.java new file mode 100644 index 000000000000..daa8768d83c5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTables.java @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XTextTablesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XNameAccess + * + */ +public class SwXTextTables extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + int nRow = 4; + int nCol = 5; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + // create testobject here + TestEnvironment tEnv = null; + XTextTable oTable = null; + try { + oTable = SOF.createTextTable( xTextDoc ); + SOF.insertTextContent(xTextDoc, oTable ); + } + catch( Exception uE ) { + uE.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + + uE.getMessage(), uE); + } + + // Number two + XTextTable oTable2 = null; + try { + oTable2 = SOF.createTextTable( xTextDoc ); + SOF.insertTextContent(xTextDoc, oTable2 ); + } + catch( Exception uE ) { + uE.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable two: " + + uE.getMessage(), uE); + } + + XMultiServiceFactory msf = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XTextTablesSupplier oTTSupp = (XTextTablesSupplier) + UnoRuntime.queryInterface(XTextTablesSupplier.class, msf); + oObj = oTTSupp.getTextTables(); + + if ( oTable != null ) { + log.println("Creating instance..."); + tEnv = new TestEnvironment(oObj); + } + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation( "TEXTDOC", xTextDoc ); + tEnv.addObjRelation( "ROW", new Integer( nRow ) ); + tEnv.addObjRelation( "COL", new Integer( nCol ) ); + try { + tEnv.addObjRelation( "INST", SOF.createTextTable( xTextDoc )); + } + catch( Exception uE ) { + uE.printStackTrace( log ); + throw new StatusException("Couldn't create TextTable : " + + uE.getMessage(), uE); + } + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTables + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextView.java b/qadevOOo/tests/java/mod/_sw/SwXTextView.java new file mode 100644 index 000000000000..891a953cb72e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextView.java @@ -0,0 +1,297 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.WrappedTargetException; +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.form.XForm; +import com.sun.star.frame.XController; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; +import com.sun.star.view.XSelectionSupplier; +import util.FormTools; +import util.WriterTools; + +/** + * + * initial description + * @see com.sun.star.text.XTextViewCursorSupplier + * @see com.sun.star.view.XControlAccess + * @see com.sun.star.view.XSelectionSupplier + * @see com.sun.star.view.XViewSettingsSupplier + * + */ +public class SwXTextView extends TestCase { + + XTextDocument xTextDoc; + + boolean debug = false; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + debug = tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE); + + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log )throws StatusException { + + + // creation of testobject here + log.println( "creating a test environment" ); + + XController xContr = xTextDoc.getCurrentController(); + + TestEnvironment tEnv = new TestEnvironment(xContr); + + util.dbg.getSuppServices(xContr); + + SOfficeFactory SOF=SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + XTextFrame first =null; + XTextFrame second =null; + + Object oFrame1 = null; + Object oFrame2 = null; + try { + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + oFrame1 = SOF.createInstance + (xTextDoc, "com.sun.star.text.TextFrame" ); + first = (XTextFrame)UnoRuntime.queryInterface + ( XTextFrame.class, oFrame1); + oText.insertTextContent(oCursor,first, false); + first.getText().setString("Frame 1"); + oFrame2 = SOF.createInstance(xTextDoc, "com.sun.star.text.TextFrame" ); + second = (XTextFrame)UnoRuntime.queryInterface + ( XTextFrame.class, oFrame2); + oText.insertTextContent(oCursor,second, false); + second.getText().setString("Frame 2"); + oText.insertString( oCursor, + "SwXTextRanges...SwXTextRanges...SwXTextRanges", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + oText.insertString( oCursor, + "bla...bla...", false); + } catch (Exception Ex ) { + Ex.printStackTrace(log); + throw new StatusException("Couldn't insert text table ", Ex); + } + + XSearchable oSearch = (XSearchable)UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextRanges"); + XIndexAccess textRanges1 = oSearch.findAll(xSDesc); + + xSDesc.setSearchString("bla"); + XIndexAccess textRanges2 = oSearch.findAll(xSDesc); + + tEnv.addObjRelation("Selections", new Object[] { + oFrame1, oFrame2, textRanges1, textRanges2}); + tEnv.addObjRelation("Comparer", new Comparator() { + public int compare(Object o1, Object o2) { + XServiceInfo serv1 = (XServiceInfo) + UnoRuntime.queryInterface(XServiceInfo.class, o1); + XServiceInfo serv2 = (XServiceInfo) + UnoRuntime.queryInterface(XServiceInfo.class, o2); + + String implName1 = serv1.getImplementationName(); + String implName2 = serv2.getImplementationName(); + if (!implName1.equals(implName2)) { + return -1; + } + + XIndexAccess indAc1 = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = (XIndexAccess) + UnoRuntime.queryInterface(XIndexAccess.class, o2); + + if (indAc1 != null && indAc2 != null) { + int c1 = indAc1.getCount(); + int c2 = indAc2.getCount(); + return c1 == c2 ? 0 : 1; + } + + XText text1 = (XText) + UnoRuntime.queryInterface(XText.class, o1); + XText text2 = (XText) + UnoRuntime.queryInterface(XText.class, o2); + + if (text1 != null && text2 != null) { + return text1.getString().equals(text2.getString()) ? 0 : 1; + } + + return -1; + } + public boolean equals(Object obj) { + return compare(this, obj) == 0; + } }); + + XSelectionSupplier xsel = (XSelectionSupplier) + UnoRuntime.queryInterface(XSelectionSupplier.class,xContr); + try { + xsel.select(second); + } catch (Exception e) { + log.println("Couldn't select"); + throw new StatusException( "Couldn't select", e ); + } + + tEnv.addObjRelation("DOCUMENT",xTextDoc); + XForm myForm = null; + String kindOfControl="CommandButton"; + XShape aShape = null; + try{ + log.println("adding contol shape '" + kindOfControl + "'"); + aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + kindOfControl); + } catch (Exception e){ + e.printStackTrace(log); + throw new StatusException("Couldn't create following control shape : '" + + kindOfControl + "': ", e); + + } + + + log.println("adding relation for com.sun.star.view.XFormLayerAccess: XForm"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + try { + + XDrawPage xDP = WriterTools.getDrawPage(xTextDoc); + if (xDP == null) + log.println("ERROR: could not get DrawPage"); + + XNameContainer xForms = FormTools.getForms(xDP); + if (xForms == null) + log.println("ERROR: could not get Forms"); + + log.println("the draw page contains folowing elemtens:"); + String[] elements = FormTools.getForms(WriterTools.getDrawPage(xTextDoc)).getElementNames(); + for (int i = 0; i< elements.length; i++){ + log.println("Element[" + i + "] :" + elements[i]); + } + + myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), xForms.getByName("Standard")); + if (myForm == null){ + log.println("ERROR: could not get 'Standard' from drawpage!"); + if (debug){ + log.println("the draw page contains folowing elemtens:"); +// String[] elements = FormTools.getForms(WriterTools.getDrawPage(xTextDoc)).getElementNames(); +// for (int i = 0; i< elements.length; i++){ +// log.println("Element[" + i + "] :" + elements[i]); +// } + } + } + else + tEnv.addObjRelation("XFormLayerAccess.XForm", myForm); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (NoSuchElementException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } + + + return tEnv; + + } // finish method getTestEnvironment +} // finish class SwXTextView diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.java new file mode 100644 index 000000000000..a95e06573ea0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.java @@ -0,0 +1,122 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextViewCursorSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.document.XDocumentInsertable + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XPageCursor + * @see com.sun.star.text.XParagraphCursor + * @see com.sun.star.text.XSentenceCursor + * @see com.sun.star.text.XTextCursor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XWordCursor + * @see com.sun.star.util.XSortable + * @see com.sun.star.view.XScreenCursor + * + */ +public class SwXTextViewCursor extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + oObj = xTextDoc.getCurrentController(); + + XTextViewCursorSupplier oTVCSupp = (XTextViewCursorSupplier) + UnoRuntime.queryInterface(XTextViewCursorSupplier.class, oObj); + + oObj = oTVCSupp.getViewCursor(); + + log.println( "creating a new environment for TextViewCursor object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + tEnv.addObjRelation("XTEXT", xTextDoc.getText()); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTextViewCursor diff --git a/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java b/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java new file mode 100644 index 000000000000..85cb5c3e642a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.ViewSettings + * + */ +public class SwXViewSettings extends TestCase { + XTextDocument xTextDoc; + + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a Testenvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + + oObj = xTextDoc.getCurrentController(); + XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, oObj); + + oObj = oVSSupp.getViewSettings(); + + log.println( "creating a new environment for ViewSettings object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXViewSettings + diff --git a/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java b/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java new file mode 100644 index 000000000000..d06018a3c620 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java @@ -0,0 +1,196 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XTextDocument xTextDoc; + ContentFilterChecker Filter; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Document disposed here. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. A string inserted into document. This made + * for checking if this string is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) throws StatusException { + + final String CONTENT = "XMLContentExporter"; + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + + Filter = new ContentFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLContentExporter", + new Object[] {arg}); + XExporter xEx = (XExporter) UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + // text added to the document + XSimpleText aText = xTextDoc.getText(); + XTextCursor curs = (XTextCursor) aText.createTextCursor(); + aText.insertString(curs, CONTENT, false); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // adding tags which must be contained in XML output + Filter.addTag("office:document-content") ; + Filter.addTagEnclosed("office:body", "office:document-content") ; + Filter.addTagEnclosed("office:script", "office:document-content") ; + Filter.addTagEnclosed("office:body", "office:document-content") ; + Filter.addCharactersEnclosed(CONTENT, "text:p") ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + protected class ContentFilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + public ContentFilterChecker(PrintWriter log) { + super(log) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java b/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java new file mode 100644 index 000000000000..565ecce877fe --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Text document destroyed. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLContentImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only content tags including test text. + * After import text getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + Object oInt = null ; + final String impText = "XMLContentImporter test." ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + + try { + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLContentImporter") ; + //XImporter imp = (XImporter) UnoRuntime.queryInterface + // (XImporter.class, oInt) ; + //imp.setTargetDocument(xTextDoc) ; + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-content", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text" + }, + {"start", "office:body"}, + {"start", "text:p"}, + {"chars", impText}, + {"end", "text:p"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final XTextDocument textDoc = (XTextDocument) UnoRuntime.queryInterface + (XTextDocument.class, xTextDoc) ; + final PrintWriter fLog = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String docText = textDoc.getText().getString() ; + fLog.println("Document text returned = '" + docText + "'") ; + return impText.equals(docText) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLExporter.java b/qadevOOo/tests/java/mod/_sw/XMLExporter.java new file mode 100644 index 000000000000..a42c394bc3d2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLExporter.java @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XTextDocument xTextDoc; + FilterChecker Filter; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Document disposed here. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. A string inserted into document. This made + * for checking if this string is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + final String TEST_STR = "XMLExporter"; + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + + Filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),Filter); + + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLExporter", new Object[] {arg}); + XExporter xEx = (XExporter) UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + XSimpleText aText = xTextDoc.getText(); + XTextCursor curs = (XTextCursor) aText.createTextCursor(); + aText.insertString(curs, TEST_STR, false); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // adding tags which must be contained in XML output + Filter.addTag("office:document") ; + Filter.addTagEnclosed("office:meta", "office:document") ; + Filter.addTagEnclosed("office:settings", "office:document") ; + Filter.addTagEnclosed("office:script", "office:document") ; + Filter.addTagEnclosed("office:styles", "office:document") ; + Filter.addTagEnclosed("office:body", "office:document") ; + Filter.addCharactersEnclosed(TEST_STR, "text:p") ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + return tEnv; + + } // finish method getTestEnvironment + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + protected class FilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + public FilterChecker(PrintWriter log) { + super(log) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags() ; + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLImporter.java b/qadevOOo/tests/java/mod/_sw/XMLImporter.java new file mode 100644 index 000000000000..7fee85b07844 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLImporter.java @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XImporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Text document destroyed. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported tags contain tag including tag with test text. + * After import text getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log) { + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + + try { + oObj = (XInterface) xMSF.createInstance + ("com.sun.star.comp.Writer.XMLImporter"); + XImporter xIm = (XImporter) UnoRuntime.queryInterface + (XImporter.class,oObj); + xIm.setTargetDocument(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + final String impText = "XMLImporter test." ; + String[][] xml = new String[][] { + {"start", "office:document" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "office:class", "CDATA", "text", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text"}, + {"start", "office:body" }, + {"start", "text:p" }, + {"chars", impText}, + {"end", "text:p"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + tEnv.addObjRelation("TargetDocument",xTextDoc); + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + final XTextDocument textDoc = (XTextDocument) UnoRuntime.queryInterface + (XTextDocument.class, xTextDoc) ; + final PrintWriter fLog = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String docText = textDoc.getText().getString() ; + fLog.println("Document text returned = '" + docText + "'") ; + return impText.equals(docText) ; + } + }) ; + + return tEnv; + + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java new file mode 100644 index 000000000000..4299aafd8044 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + + XTextDocument xTextDoc; + MetaFilterChecker Filter; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Document disposed here. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. The 'Title' metadata property is set to a value. This made + * for checking if this property is successfully exported within + * the document metadata. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) throws StatusException { + final String TITLE = "Title for testing of XMLMetaExporter"; + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + + Filter = new MetaFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLMetaExporter", + new Object[] {arg}); + XExporter xEx = (XExporter) UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + //set some meta data + XDocumentInfoSupplier infoSup = (XDocumentInfoSupplier) + UnoRuntime.queryInterface + (XDocumentInfoSupplier.class, xTextDoc) ; + XPropertySet docInfo = (XPropertySet) UnoRuntime.queryInterface + (XPropertySet.class, infoSup.getDocumentInfo()) ; + docInfo.setPropertyValue("Title", TITLE); + + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // adding tags which must be contained in XML output + Filter.addTag("office:document-meta"); + Filter.addTagEnclosed("office:meta", "office:document-meta"); + Filter.addCharactersEnclosed(TITLE, "dc:title"); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument", xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + protected class MetaFilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + public MetaFilterChecker(PrintWriter log) { + super(log) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java new file mode 100644 index 000000000000..97ca747338a0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java @@ -0,0 +1,189 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Text document destroyed. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLMetaImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only meta tags including + * title tag with test name. + * After import title name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + Object oInt = null ; + final String impTitle = "XMLMetaImporter test." ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + + try { + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLMetaImporter") ; + //XImporter imp = (XImporter) UnoRuntime.queryInterface + // (XImporter.class, oInt) ; + //imp.setTargetDocument(xTextDoc) ; + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"}, + {"start", "office:meta"} , + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XDocumentInfoSupplier infoSup = (XDocumentInfoSupplier) UnoRuntime.queryInterface + (XDocumentInfoSupplier.class, xTextDoc) ; + final XPropertySet docInfo = (XPropertySet) UnoRuntime.queryInterface + (XPropertySet.class, infoSup.getDocumentInfo()) ; + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String title = (String) docInfo.getPropertyValue("Title") ; + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java new file mode 100644 index 000000000000..cc734526248d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java @@ -0,0 +1,209 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + + XTextDocument xTextDoc; + SettingsFilterChecker Filter; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + + } + + /** + * Document disposed here. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. New document zoom is set as one of the 'View' settings. This made + * for checking if this setting is successfully exported within + * the document settings. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + final short ZOOM = 50; + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + + Filter = new SettingsFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLSettingsExporter", + new Object[] {arg}); + XExporter xEx = (XExporter) UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + //set some settings + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + xPropSet.setPropertyValue("ZoomValue", new Short(ZOOM)); + + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // adding tags which must be contained in XML output + Filter.addTag( new XMLTools.Tag("office:document-settings") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document-settings") ); + Filter.addCharactersEnclosed( + String.valueOf(ZOOM), + new XMLTools.Tag("config:config-item", + "config:name", "ZoomFactor") ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter); + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + protected class SettingsFilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + public SettingsFilterChecker(PrintWriter log) { + super(log, false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java new file mode 100644 index 000000000000..4e9b47aaffd8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java @@ -0,0 +1,208 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Text document destroyed. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLSettingsImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only settings tags including + * title tag with test zoom factor. + * After import zoom factor getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws StatusException { + + XInterface oObj = null; + Object oInt = null ; + final short impZoom = 50 ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + + try { + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLSettingsImporter") ; + + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + }, + {"start", "office:settings"}, + {"start", "config:config-item-set", + "config:name", "CDATA", "view-settings" + }, + {"start", "config:config-item-map-indexed", + "config:name", "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomFactor", + "config:type", "CDATA", "short" + }, + {"chars", String.valueOf(impZoom)}, + {"end", "config:config-item"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomType", + "config:type", "CDATA", "short" + }, + {"chars", "0"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "config:config-item-set"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = (XViewSettingsSupplier) + UnoRuntime.queryInterface(XViewSettingsSupplier.class, xController); + final XPropertySet xPropSet = xViewSetSup.getViewSettings(); + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Short gValue = (Short) + xPropSet.getPropertyValue("ZoomValue"); + logF.println("ZoomValue property value = " + gValue) ; + return impZoom == gValue.shortValue() ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception while checking import :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java new file mode 100644 index 000000000000..35e88a6a8a27 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java @@ -0,0 +1,203 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Document disposed here. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. Footnote property 'Prefix' is set to a new value. This made + * for checking if this property value is successfully exported within + * the document styles. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) { + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log) ; + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLStylesExporter", + new Object[] {arg}); + XExporter xEx = (XExporter) UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // Cheching Head Tag existance and that property has changed + filter.addTag(new XMLTools.Tag ("office:document-styles")); + filter.addTag(new XMLTools.Tag ("text:footnotes-configuration", + "style:num-prefix","New Property")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Obtain Footnotes properties + XFootnotesSupplier supp = (XFootnotesSupplier) UnoRuntime.queryInterface + (XFootnotesSupplier.class, xTextDoc); + XPropertySet set = supp.getFootnoteSettings(); + + // Change property "Prefix" + try { + set.setPropertyValue("Prefix","New Property"); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace( log ); + throw new StatusException( "Couldn't change property value", e ); + } + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + protected class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + public FilterChecker(PrintWriter log) { + super(log,false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.java new file mode 100644 index 000000000000..a22e638a9e6d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.java @@ -0,0 +1,188 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Text document destroyed. + */ + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLStylesImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only style tags including + * title tag with test prefix. + * After import prefixes getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + public synchronized TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + Object oInt = null ; + final String impPrefix = "Prefix" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ; + + try { + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLStylesImporter") ; + + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text" + }, + {"start", "office:styles"}, + {"start", "text:footnotes-configuration", + "style:num-prefix", "CDATA", impPrefix}, + {"end", "text:footnotes-configuration"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XFootnotesSupplier supp = (XFootnotesSupplier) UnoRuntime.queryInterface + (XFootnotesSupplier.class, xTextDoc); + final XPropertySet set = supp.getFootnoteSettings(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String prefix = (String) set.getPropertyValue("Prefix"); + logF.println("Prefix returned = '" + prefix + "'") ; + return impPrefix.equals(prefix) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/package.html b/qadevOOo/tests/java/mod/_sw/package.html new file mode 100644 index 000000000000..e8be03da8143 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/package.html @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<BODY> +<P>Containes all test cases for the module 'sw'.</P> +</BODY> +</HTML>
\ No newline at end of file |