summaryrefslogtreecommitdiff
path: root/qadevOOo/tests/java/mod/_sw/CharacterStyle.java
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/tests/java/mod/_sw/CharacterStyle.java')
-rw-r--r--qadevOOo/tests/java/mod/_sw/CharacterStyle.java86
1 files changed, 22 insertions, 64 deletions
diff --git a/qadevOOo/tests/java/mod/_sw/CharacterStyle.java b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java
index d74b2d0e62e8..34271e7b2b1c 100644
--- a/qadevOOo/tests/java/mod/_sw/CharacterStyle.java
+++ b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java
@@ -31,7 +31,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.StatusException;
import lib.TestCase;
import lib.TestEnvironment;
@@ -92,7 +94,7 @@ public class CharacterStyle extends TestCase {
* </ul>
*/
@Override
- protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
+ protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
TestEnvironment tEnv = null;
XNameAccess oSFNA = null;
@@ -101,38 +103,22 @@ public class CharacterStyle extends TestCase {
log.println("creating a test environment");
- try {
- log.println("getting style");
- XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
- xTextDoc);
- XNameAccess oSF = oSFS.getStyleFamilies();
- XIndexAccess oSFsIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF);
- oSFNA = UnoRuntime.queryInterface(
- XNameAccess.class,oSFsIA.getByIndex(0));
- XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA);
- oStyle = 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 );
- }
+ log.println("getting style");
+ XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
+ xTextDoc);
+ XNameAccess oSF = oSFS.getStyleFamilies();
+ XIndexAccess oSFsIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF);
+ oSFNA = UnoRuntime.queryInterface(
+ XNameAccess.class,oSFsIA.getByIndex(0));
+ XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA);
+ oStyle = UnoRuntime.queryInterface(
+ XStyle.class,oSFIA.getByIndex(0));
- try {
- log.print("Creating a user-defined style... ");
- XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc);
- XInterface oInt = (XInterface)
- oMSF.createInstance("com.sun.star.style.CharacterStyle");
- 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.CharacterStyle");
+ oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt);
if (oMyStyle == null)
@@ -141,43 +127,15 @@ public class CharacterStyle extends TestCase {
log.println("OK");
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("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 );
- }
+ xProp.setPropertyValue("CharStyleName", oMyStyle.getName());
log.println("creating a new environment for object");
tEnv = new TestEnvironment(oMyStyle);