diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2006-05-17 12:40:24 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2006-05-17 12:40:24 +0000 |
commit | 95f8d8e621e87e770fcaeb0e307ad2c7ee9282f8 (patch) | |
tree | f00b1a34d546346c4137902de7157fd0a832a33a /qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java | |
parent | INTEGRATION: CWS qadev26 (1.7.12); FILE MERGED (diff) | |
download | core-95f8d8e621e87e770fcaeb0e307ad2c7ee9282f8.tar.gz core-95f8d8e621e87e770fcaeb0e307ad2c7ee9282f8.zip |
INTEGRATION: CWS qadev26 (1.7.12); FILE MERGED
2006/04/27 09:21:23 cn 1.7.12.2: #i38199# adabt Test to the rules of inserting a new group
2006/04/11 12:33:45 cn 1.7.12.1: #i41735# bugfixing in creation of a new AutoTextGroup
Diffstat (limited to 'qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java')
-rw-r--r-- | qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java index 0694c4c9bc28..2b490d0516f3 100644 --- a/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java @@ -4,9 +4,9 @@ * * $RCSfile: SwXAutoTextGroup.java,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: rt $ $Date: 2005-09-09 03:43:42 $ + * last change: $Author: vg $ $Date: 2006-05-17 13:40:24 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -35,6 +35,8 @@ package mod._sw; +import com.sun.star.container.ElementExistException; +import com.sun.star.container.XNameAccess; import java.io.PrintWriter; import lib.StatusException; @@ -42,9 +44,6 @@ import lib.TestCase; import lib.TestEnvironment; import lib.TestParameters; import util.SOfficeFactory; - -import com.sun.star.container.XElementAccess; -import com.sun.star.container.XIndexAccess; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.text.XAutoTextContainer; import com.sun.star.text.XText; @@ -53,6 +52,7 @@ 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; /** @@ -84,8 +84,8 @@ public class SwXAutoTextGroup extends TestCase { XTextDocument xTextDoc; /** - * Creates text document. - */ + * Creates text document. + */ protected void initialize( TestParameters tParam, PrintWriter log ) { SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); try { @@ -98,24 +98,24 @@ public class SwXAutoTextGroup extends TestCase { } /** - * Disposes text document. - */ + * 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 selects - * non-empty group from the given container.<p> - * Object relations created : - * <ul> - * <li> <code>'TextRange'</code> for - * {@link ifc.text._XAutoTextGroup} range of text</li> - * </ul> - */ + * 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; @@ -124,44 +124,52 @@ public class SwXAutoTextGroup extends TestCase { 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); + 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); - XIndexAccess oContIndex = (XIndexAccess) - UnoRuntime.queryInterface(XIndexAccess.class, oContainer); + try { + log.println("removing element with name '" + myGroupName + "'"); + xATC.removeByName(myGroupName); + } catch (com.sun.star.container.NoSuchElementException e) { + } - //search for a non-empty AutoTextGroup try { - int n = 0; - int count = oContIndex.getCount(); - oObj = (XInterface) AnyConverter.toObject( - new Type(XInterface.class),oContIndex.getByIndex(n)); - XElementAccess oElement = (XElementAccess) - UnoRuntime.queryInterface(XElementAccess.class, oObj); - while ( ( !oElement.hasElements() ) && ( n < count ) ) { - n++; - oObj = (XInterface) AnyConverter.toObject( - new Type(XInterface.class),oContIndex.getByIndex(n)); - oElement = (XElementAccess) - UnoRuntime.queryInterface(XElementAccess.class, oObj); + 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]); } - } catch ( com.sun.star.lang.WrappedTargetException e ) { - e.printStackTrace(log); - throw new StatusException("Couldn't get AutoTextGroup", e); - } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { - e.printStackTrace(log); - throw new StatusException("Couldn't get AutoTextGroup", e); - } catch ( com.sun.star.lang.IllegalArgumentException e ) { + } + + 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", e); + 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 ); |