Kaydet (Commit) ca178867 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS qadev26 (1.7.12); FILE MERGED

2006/02/01 13:34:29 cn 1.7.12.1: #i41735# use 'mytexts' container as oObj
üst 7271bfdb
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: SwXAutoTextEntry.java,v $ * $RCSfile: SwXAutoTextEntry.java,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: rt $ $Date: 2005-09-09 03:43:29 $ * last change: $Author: vg $ $Date: 2006-05-17 13:40:03 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -44,10 +44,7 @@ import lib.TestParameters; ...@@ -44,10 +44,7 @@ import lib.TestParameters;
import util.DefaultDsc; import util.DefaultDsc;
import util.InstCreator; import util.InstCreator;
import util.SOfficeFactory; import util.SOfficeFactory;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNamed;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.text.XAutoTextContainer; import com.sun.star.text.XAutoTextContainer;
import com.sun.star.text.XAutoTextEntry; import com.sun.star.text.XAutoTextEntry;
...@@ -60,6 +57,7 @@ import com.sun.star.uno.Type; ...@@ -60,6 +57,7 @@ import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
/** /**
* Test for object which is represented by service * Test for object which is represented by service
* <code>com.sun.star.text.AutoTextEntry</code>.<p> * <code>com.sun.star.text.AutoTextEntry</code>.<p>
...@@ -91,7 +89,8 @@ public class SwXAutoTextEntry extends TestCase { ...@@ -91,7 +89,8 @@ public class SwXAutoTextEntry extends TestCase {
* Creates text document. * Creates text document.
*/ */
protected void initialize( TestParameters tParam, PrintWriter log ) { protected void initialize( TestParameters tParam, PrintWriter log ) {
SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); XMultiServiceFactory msf = (XMultiServiceFactory) tParam.getMSF();
SOfficeFactory SOF = SOfficeFactory.getFactory( msf );
try { try {
log.println( "creating a textdocument" ); log.println( "creating a textdocument" );
xTextDoc = SOF.createTextDoc( null ); xTextDoc = SOF.createTextDoc( null );
...@@ -122,8 +121,8 @@ public class SwXAutoTextEntry extends TestCase { ...@@ -122,8 +121,8 @@ public class SwXAutoTextEntry extends TestCase {
/** /**
* Creating a Testenvironment for the interfaces to be tested. * Creating a Testenvironment for the interfaces to be tested.
* Creates an instance of the service * Creates an instance of the service
* <code>com.sun.star.text.AutoTextContainer</code>, then selects a non-empty * <code>com.sun.star.text.AutoTextContainer</code>, then selects the 'mytexts'
* group from the given container using <code>XIndexAccess</code> interface, * group from the given container using <code>XNameAccess</code> interface,
* and inserts some text entry to this group. Then entry passed as test * and inserts some text entry to this group. Then entry passed as test
* component.<p> * component.<p>
* Object relations created : * Object relations created :
...@@ -155,20 +154,15 @@ public class SwXAutoTextEntry extends TestCase { ...@@ -155,20 +154,15 @@ public class SwXAutoTextEntry extends TestCase {
throw new StatusException("Couldn't create AutoTextContainer", e); throw new StatusException("Couldn't create AutoTextContainer", e);
} }
XIndexAccess oContIndex = (XIndexAccess) XNameAccess oContNames = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oContainer);
UnoRuntime.queryInterface(XIndexAccess.class, oContainer);
try { String contNames[] = oContNames.getElementNames();
oObj = (XInterface) AnyConverter.toObject( for (int i =0; i < contNames.length; i++){
new Type(XInterface.class),oContIndex.getByIndex(n)); log.println("ContainerNames[ "+ i + "]: " + contNames[i]);
XIndexAccess oObjCount = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, oObj);
nCount = oObjCount.getCount();
while (nCount < 1) {
oObj = (XInterface) oContIndex.getByIndex(n++);
oObjCount = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, oObj);
nCount = oObjCount.getCount();
} }
try{
oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName("mytexts"));
} catch (com.sun.star.uno.Exception e) { } catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get AutoTextGroup", e); throw new StatusException("Couldn't get AutoTextGroup", e);
...@@ -181,28 +175,6 @@ public class SwXAutoTextEntry extends TestCase { ...@@ -181,28 +175,6 @@ public class SwXAutoTextEntry extends TestCase {
log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]); log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]);
} }
// Some Debug info
XNameAccess dObj = null;
log.println("Some debugging info:");
for ( n=0; n < oContIndex.getCount(); n++ ) {
try {
dObj = (XNameAccess) AnyConverter.toObject(
new Type(XNameAccess.class),oContIndex.getByIndex(n));
} catch ( com.sun.star.uno.Exception e ) {
e.printStackTrace(log);
}
XNamed namedGroup = (XNamed) UnoRuntime.queryInterface
(XNamed.class, dObj);
log.println(" " + namedGroup.getName() + ":");
String[] eNames = dObj.getElementNames();
for (int i=0; i<eNames.length; i++) {
log.print(eNames[i] + ", ");
}
log.println();
}
log.println("=======================================");
XText oText = xTextDoc.getText(); XText oText = xTextDoc.getText();
oText.insertString(oText.getStart(), "New AutoText", true); oText.insertString(oText.getStart(), "New AutoText", true);
XTextRange oTextRange = (XTextRange) oText; XTextRange oTextRange = (XTextRange) oText;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment