diff options
Diffstat (limited to 'qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java')
-rw-r--r-- | qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java | 88 |
1 files changed, 21 insertions, 67 deletions
diff --git a/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java index ee7f2f4e4d27..6c98dfd16f8c 100644 --- a/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java +++ b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java @@ -30,7 +30,9 @@ 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; @@ -82,7 +84,7 @@ public class ConditionalParagraphStyle extends TestCase { * @param log The log writer. */ @Override - protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { TestEnvironment tEnv = null; XNameAccess oSFNA = null; XStyle oStyle = null; @@ -90,41 +92,21 @@ public class ConditionalParagraphStyle extends TestCase { log.println("creating a test environment"); - try { - log.println("getting style"); - XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, - xTextDoc); - XNameAccess oSF = oSFS.getStyleFamilies(); - oSFNA = UnoRuntime.queryInterface( - XNameAccess.class,oSF.getByName("ParagraphStyles")); - XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); - oStyle = 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 ); - } + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("ParagraphStyles")); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(1)); - try { - log.print("Creating a user-defined style... "); - XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); - XInterface oInt = (XInterface) - oMSF.createInstance("com.sun.star.style.ConditionalParagraphStyle"); - oMyStyle = 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 ); - } + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.ConditionalParagraphStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); if (oMyStyle == null) { @@ -137,42 +119,14 @@ public class ConditionalParagraphStyle extends TestCase { XNameContainer oSFNC = 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 ); - } + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); XText oText = xTextDoc.getText(); XTextCursor oCursor = oText.createTextCursor(); XPropertySet xProp = 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 ); - } + xProp.setPropertyValue("ParaStyleName", oMyStyle.getName()); log.println("creating a new environment for object"); tEnv = new TestEnvironment(oMyStyle); |