Kaydet (Commit) 531a052b authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Java5 update - convert to use generics

Change-Id: Ie9d9b278341132d08477d015245fedf2b66f62fd
üst 8aa97e36
...@@ -61,7 +61,7 @@ public class AccessibleRelationSet { ...@@ -61,7 +61,7 @@ public class AccessibleRelationSet {
try { try {
firstrelation = set.getRelation(0).RelationType; firstrelation = set.getRelation(0).RelationType;
Object oTmp = set.getRelation(0).TargetSet[0]; Object oTmp = set.getRelation(0).TargetSet[0];
atarget = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); atarget = UnoRuntime.queryInterface(XAccessibleText.class, oTmp);
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
fail("Exception when getting relations "+e); fail("Exception when getting relations "+e);
} }
...@@ -72,7 +72,7 @@ public class AccessibleRelationSet { ...@@ -72,7 +72,7 @@ public class AccessibleRelationSet {
types[firstrelation]); types[firstrelation]);
XAccessibleText paraTxt2 = XAccessibleText paraTxt2 =
(XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para2); UnoRuntime.queryInterface(XAccessibleText.class, para2);
assertEquals( assertEquals(
"didn't gain correct target paragraph", atarget.getText(), "didn't gain correct target paragraph", atarget.getText(),
paraTxt2.getText()); paraTxt2.getText());
...@@ -92,13 +92,13 @@ public class AccessibleRelationSet { ...@@ -92,13 +92,13 @@ public class AccessibleRelationSet {
if ( tmprelation == 1 ) if ( tmprelation == 1 )
{ {
Object oTmp = set.getRelation(0).TargetSet[0]; Object oTmp = set.getRelation(0).TargetSet[0];
atargets[0] = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); atargets[0] = UnoRuntime.queryInterface(XAccessibleText.class, oTmp);
relationtypes[0] = tmprelation; relationtypes[0] = tmprelation;
} }
else if ( tmprelation == 2 ) else if ( tmprelation == 2 )
{ {
Object oTmp = set.getRelation(0).TargetSet[0]; Object oTmp = set.getRelation(0).TargetSet[0];
atargets[1] = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); atargets[1] = UnoRuntime.queryInterface(XAccessibleText.class, oTmp);
relationtypes[1] = tmprelation; relationtypes[1] = tmprelation;
} }
else else
...@@ -109,13 +109,13 @@ public class AccessibleRelationSet { ...@@ -109,13 +109,13 @@ public class AccessibleRelationSet {
if ( tmprelation == 1 ) if ( tmprelation == 1 )
{ {
Object oTmp = set.getRelation(1).TargetSet[0]; Object oTmp = set.getRelation(1).TargetSet[0];
atargets[0] = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); atargets[0] = UnoRuntime.queryInterface(XAccessibleText.class, oTmp);
relationtypes[0] = tmprelation; relationtypes[0] = tmprelation;
} }
else if ( tmprelation == 2 ) else if ( tmprelation == 2 )
{ {
Object oTmp = set.getRelation(1).TargetSet[0]; Object oTmp = set.getRelation(1).TargetSet[0];
atargets[1] = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); atargets[1] = UnoRuntime.queryInterface(XAccessibleText.class, oTmp);
relationtypes[1] = tmprelation; relationtypes[1] = tmprelation;
} }
else else
...@@ -132,7 +132,7 @@ public class AccessibleRelationSet { ...@@ -132,7 +132,7 @@ public class AccessibleRelationSet {
types[relationtypes[0]]); types[relationtypes[0]]);
XAccessibleText paraTxt1 = XAccessibleText paraTxt1 =
(XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para1); UnoRuntime.queryInterface(XAccessibleText.class, para1);
assertEquals( assertEquals(
"didn't gain correct target paragraph", atargets[0].getText(), "didn't gain correct target paragraph", atargets[0].getText(),
paraTxt1.getText()); paraTxt1.getText());
...@@ -142,7 +142,7 @@ public class AccessibleRelationSet { ...@@ -142,7 +142,7 @@ public class AccessibleRelationSet {
types[relationtypes[1]]); types[relationtypes[1]]);
XAccessibleText paraTxt3 = XAccessibleText paraTxt3 =
(XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para3); UnoRuntime.queryInterface(XAccessibleText.class, para3);
assertEquals( assertEquals(
"didn't gain correct target paragraph", atargets[1].getText(), "didn't gain correct target paragraph", atargets[1].getText(),
paraTxt3.getText()); paraTxt3.getText());
...@@ -167,8 +167,7 @@ public class AccessibleRelationSet { ...@@ -167,8 +167,7 @@ public class AccessibleRelationSet {
oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); oCursor, ControlCharacter.PARAGRAPH_BREAK, false );
} }
XModel aModel = (XModel) XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
UnoRuntime.queryInterface(XModel.class, xTextDoc);
AccessibilityTools at = new AccessibilityTools(); AccessibilityTools at = new AccessibilityTools();
...@@ -187,8 +186,7 @@ public class AccessibleRelationSet { ...@@ -187,8 +186,7 @@ public class AccessibleRelationSet {
} }
public XAccessibleRelationSet getAccessibleRelation(XAccessible xAcc) { public XAccessibleRelationSet getAccessibleRelation(XAccessible xAcc) {
XAccessibleContext oObj = (XAccessibleContext) XAccessibleContext oObj = UnoRuntime.queryInterface(XAccessibleContext.class, xAcc);
UnoRuntime.queryInterface(XAccessibleContext.class, xAcc);
XAccessibleRelationSet set = oObj.getAccessibleRelationSet(); XAccessibleRelationSet set = oObj.getAccessibleRelationSet();
return set; return set;
......
...@@ -49,15 +49,15 @@ public class CheckChangeColor { ...@@ -49,15 +49,15 @@ public class CheckChangeColor {
*/ */
@Test public void checkChangeColor() throws Exception { @Test public void checkChangeColor() throws Exception {
// create a supplier to get the Style family collection // create a supplier to get the Style family collection
XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, document); XStyleFamiliesSupplier xSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, document);
// get the NameAccess interface from the Style family collection // get the NameAccess interface from the Style family collection
XNameAccess xNameAccess = xSupplier.getStyleFamilies(); XNameAccess xNameAccess = xSupplier.getStyleFamilies();
XNameContainer xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" )); XNameContainer xPageStyleCollection = UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" ));
// create a PropertySet to set the properties for the new Pagestyle // create a PropertySet to set the properties for the new Pagestyle
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") ); XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") );
assertEquals( assertEquals(
"BackColor", new Any(Type.LONG, 0xFFFFFFFF), "BackColor", new Any(Type.LONG, 0xFFFFFFFF),
......
...@@ -54,8 +54,7 @@ public class CheckIndeterminateState { ...@@ -54,8 +54,7 @@ public class CheckIndeterminateState {
* The used tools are in project qadevOOo/runner * The used tools are in project qadevOOo/runner
*/ */
@Test public void checkToolBoxItem() throws Exception { @Test public void checkToolBoxItem() throws Exception {
XModel aModel = (XModel) XModel aModel = UnoRuntime.queryInterface(XModel.class, document);
UnoRuntime.queryInterface(XModel.class, document);
XController xController = aModel.getCurrentController(); XController xController = aModel.getCurrentController();
...@@ -78,8 +77,7 @@ public class CheckIndeterminateState { ...@@ -78,8 +77,7 @@ public class CheckIndeterminateState {
AccessibleRole.TOGGLE_BUTTON, "Bold"); AccessibleRole.TOGGLE_BUTTON, "Bold");
assertNotNull("Found a TOGGLE_BUTTON", oObj); assertNotNull("Found a TOGGLE_BUTTON", oObj);
XAccessibleContext oContext = (XAccessibleContext) XAccessibleContext oContext = UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
XAccessibleStateSet oSet = oContext.getAccessibleStateSet(); XAccessibleStateSet oSet = oContext.getAccessibleStateSet();
......
...@@ -63,13 +63,13 @@ class BookmarkHashes { ...@@ -63,13 +63,13 @@ class BookmarkHashes {
throws com.sun.star.uno.Exception, java.security.NoSuchAlgorithmException throws com.sun.star.uno.Exception, java.security.NoSuchAlgorithmException
{ {
StringBuffer buffer = new StringBuffer(""); StringBuffer buffer = new StringBuffer("");
XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)UnoRuntime.queryInterface( XBookmarksSupplier xBookmarksSupplier = UnoRuntime.queryInterface(
XBookmarksSupplier.class, XBookmarksSupplier.class,
xDoc); xDoc);
XNameAccess xBookmarks = xBookmarksSupplier.getBookmarks(); XNameAccess xBookmarks = xBookmarksSupplier.getBookmarks();
for(String sBookmarkname : xBookmarks.getElementNames()) { for(String sBookmarkname : xBookmarks.getElementNames()) {
Object xBookmark = xBookmarks.getByName(sBookmarkname); Object xBookmark = xBookmarks.getByName(sBookmarkname);
XTextContent xBookmarkAsContent = (XTextContent)UnoRuntime.queryInterface( XTextContent xBookmarkAsContent = UnoRuntime.queryInterface(
XTextContent.class, XTextContent.class,
xBookmark); xBookmark);
buffer.append(sBookmarkname); buffer.append(sBookmarkname);
...@@ -152,7 +152,7 @@ public class CheckBookmarks { ...@@ -152,7 +152,7 @@ public class CheckBookmarks {
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
XText xText = m_xDoc.getText(); XText xText = m_xDoc.getText();
XSimpleText xSimpleText = (XSimpleText)UnoRuntime.queryInterface( XSimpleText xSimpleText = UnoRuntime.queryInterface(
XSimpleText.class, XSimpleText.class,
xText); xText);
for(int nPara=0; nPara<10; ++nPara) { for(int nPara=0; nPara<10; ++nPara) {
...@@ -165,7 +165,7 @@ public class CheckBookmarks { ...@@ -165,7 +165,7 @@ public class CheckBookmarks {
xWordCrsr.setString(" "); xWordCrsr.setString(" ");
} }
XTextCursor xParaCrsr = xText.createTextCursor(); XTextCursor xParaCrsr = xText.createTextCursor();
XTextRange xParaCrsrAsRange = (XTextRange)UnoRuntime.queryInterface( XTextRange xParaCrsrAsRange = UnoRuntime.queryInterface(
XTextRange.class, XTextRange.class,
xParaCrsr); xParaCrsr);
xText.insertControlCharacter(xParaCrsrAsRange, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false); xText.insertControlCharacter(xParaCrsrAsRange, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
...@@ -203,7 +203,7 @@ public class CheckBookmarks { ...@@ -203,7 +203,7 @@ public class CheckBookmarks {
XTextCursor xCrsr = m_xDoc.getText().createTextCursor(); XTextCursor xCrsr = m_xDoc.getText().createTextCursor();
for(int i=0; i<30; i++) { for(int i=0; i<30; i++) {
xCrsr.goRight((short)rnd.nextInt(300), false); xCrsr.goRight((short)rnd.nextInt(300), false);
XTextRange xCrsrAsRange = (XTextRange)UnoRuntime.queryInterface( XTextRange xCrsrAsRange = UnoRuntime.queryInterface(
XTextRange.class, XTextRange.class,
xCrsr); xCrsr);
xText.insertControlCharacter(xCrsrAsRange, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false); xText.insertControlCharacter(xCrsrAsRange, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
...@@ -213,16 +213,16 @@ public class CheckBookmarks { ...@@ -213,16 +213,16 @@ public class CheckBookmarks {
private void insertBookmark(XTextCursor crsr, String name, String content) private void insertBookmark(XTextCursor crsr, String name, String content)
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
XMultiServiceFactory xDocFactory = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory xDocFactory = UnoRuntime.queryInterface(
XMultiServiceFactory.class, XMultiServiceFactory.class,
m_xDoc); m_xDoc);
Object xBookmark = xDocFactory.createInstance("com.sun.star.text.Bookmark"); Object xBookmark = xDocFactory.createInstance("com.sun.star.text.Bookmark");
XTextContent xBookmarkAsTextContent = (XTextContent)UnoRuntime.queryInterface( XTextContent xBookmarkAsTextContent = UnoRuntime.queryInterface(
XTextContent.class, XTextContent.class,
xBookmark); xBookmark);
crsr.setString(content); crsr.setString(content);
XNamed xBookmarkAsNamed = (XNamed)UnoRuntime.queryInterface( XNamed xBookmarkAsNamed = UnoRuntime.queryInterface(
XNamed.class, XNamed.class,
xBookmark); xBookmark);
xBookmarkAsNamed.setName(name); xBookmarkAsNamed.setName(name);
...@@ -241,7 +241,7 @@ public class CheckBookmarks { ...@@ -241,7 +241,7 @@ public class CheckBookmarks {
aStoreProperties[0].Value = true; aStoreProperties[0].Value = true;
aStoreProperties[1].Name = "FilterName"; aStoreProperties[1].Name = "FilterName";
aStoreProperties[1].Value = sFilter; aStoreProperties[1].Value = sFilter;
XStorable xStorable = (XStorable)UnoRuntime.queryInterface( XStorable xStorable = UnoRuntime.queryInterface(
XStorable.class, XStorable.class,
m_xDoc); m_xDoc);
xStorable.storeToURL(sFileUrl, aStoreProperties); xStorable.storeToURL(sFileUrl, aStoreProperties);
......
...@@ -45,12 +45,12 @@ public class CheckCrossReferences { ...@@ -45,12 +45,12 @@ public class CheckCrossReferences {
if ( xPortionEnum != null ) { if ( xPortionEnum != null ) {
while ( xPortionEnum.hasMoreElements() ) { while ( xPortionEnum.hasMoreElements() ) {
com.sun.star.beans.XPropertySet xPortionProps = com.sun.star.beans.XPropertySet xPortionProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement());
final String sPortionType = final String sPortionType =
xPortionProps.getPropertyValue( "TextPortionType" ).toString(); xPortionProps.getPropertyValue( "TextPortionType" ).toString();
if ( sPortionType.equals( "TextField") ) { if ( sPortionType.equals( "TextField") ) {
com.sun.star.text.XTextField xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( com.sun.star.text.XTextField xField = UnoRuntime.queryInterface(
com.sun.star.text.XTextField.class, com.sun.star.text.XTextField.class,
xPortionProps.getPropertyValue( "TextField" ) ); xPortionProps.getPropertyValue( "TextField" ) );
assertNotNull("Cannot retrieve next field.", xField); assertNotNull("Cannot retrieve next field.", xField);
...@@ -61,17 +61,17 @@ public class CheckCrossReferences { ...@@ -61,17 +61,17 @@ public class CheckCrossReferences {
while ( xParaEnum.hasMoreElements() ) { while ( xParaEnum.hasMoreElements() ) {
com.sun.star.container.XEnumerationAccess aPara = com.sun.star.container.XEnumerationAccess aPara =
(com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement()); com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement());
xPortionEnum = aPara.createEnumeration(); xPortionEnum = aPara.createEnumeration();
while ( xPortionEnum.hasMoreElements() ) { while ( xPortionEnum.hasMoreElements() ) {
com.sun.star.beans.XPropertySet xPortionProps = com.sun.star.beans.XPropertySet xPortionProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement());
final String sPortionType = final String sPortionType =
xPortionProps.getPropertyValue( "TextPortionType" ).toString(); xPortionProps.getPropertyValue( "TextPortionType" ).toString();
if ( sPortionType.equals( "TextField") ) { if ( sPortionType.equals( "TextField") ) {
com.sun.star.text.XTextField xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( com.sun.star.text.XTextField xField = UnoRuntime.queryInterface(
com.sun.star.text.XTextField.class, com.sun.star.text.XTextField.class,
xPortionProps.getPropertyValue( "TextField" ) ); xPortionProps.getPropertyValue( "TextField" ) );
assertNotNull("Cannot retrieve next field.", xField); assertNotNull("Cannot retrieve next field.", xField);
...@@ -87,8 +87,8 @@ public class CheckCrossReferences { ...@@ -87,8 +87,8 @@ public class CheckCrossReferences {
public com.sun.star.beans.XPropertySet getFieldProps( public com.sun.star.beans.XPropertySet getFieldProps(
com.sun.star.text.XTextField xField ) { com.sun.star.text.XTextField xField ) {
com.sun.star.beans.XPropertySet xProps = com.sun.star.beans.XPropertySet xProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xField ); com.sun.star.beans.XPropertySet.class, xField );
assertNotNull("Cannot retrieve field properties.", xProps); assertNotNull("Cannot retrieve field properties.", xProps);
...@@ -116,17 +116,17 @@ public class CheckCrossReferences { ...@@ -116,17 +116,17 @@ public class CheckCrossReferences {
// setup paragraph enumeration // setup paragraph enumeration
{ {
com.sun.star.container.XEnumerationAccess xParaEnumAccess = com.sun.star.container.XEnumerationAccess xParaEnumAccess =
(com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.container.XEnumerationAccess.class, document.getText()); com.sun.star.container.XEnumerationAccess.class, document.getText());
xParaEnum = xParaEnumAccess.createEnumeration(); xParaEnum = xParaEnumAccess.createEnumeration();
} }
// get field refresher // get field refresher
{ {
com.sun.star.text.XTextFieldsSupplier xFieldSupp = com.sun.star.text.XTextFieldsSupplier xFieldSupp =
(com.sun.star.text.XTextFieldsSupplier)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.text.XTextFieldsSupplier.class, document); com.sun.star.text.XTextFieldsSupplier.class, document);
xFldsRefresh = (com.sun.star.util.XRefreshable)UnoRuntime.queryInterface( xFldsRefresh = UnoRuntime.queryInterface(
com.sun.star.util.XRefreshable.class, xFieldSupp.getTextFields()); com.sun.star.util.XRefreshable.class, xFieldSupp.getTextFields());
} }
...@@ -195,14 +195,14 @@ public class CheckCrossReferences { ...@@ -195,14 +195,14 @@ public class CheckCrossReferences {
{ {
// restart paragraph enumeration // restart paragraph enumeration
com.sun.star.container.XEnumerationAccess xParaEnumAccess = com.sun.star.container.XEnumerationAccess xParaEnumAccess =
(com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.container.XEnumerationAccess.class, document.getText()); com.sun.star.container.XEnumerationAccess.class, document.getText());
xParaEnum = xParaEnumAccess.createEnumeration(); xParaEnum = xParaEnumAccess.createEnumeration();
// iterate on the paragraphs to find certain paragraph to insert the bookmark // iterate on the paragraphs to find certain paragraph to insert the bookmark
com.sun.star.text.XTextRange xParaTextRange = null; com.sun.star.text.XTextRange xParaTextRange = null;
while ( xParaEnum.hasMoreElements() ) { while ( xParaEnum.hasMoreElements() ) {
xParaTextRange = (com.sun.star.text.XTextRange)UnoRuntime.queryInterface( xParaTextRange = UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class, xParaEnum.nextElement()); com.sun.star.text.XTextRange.class, xParaEnum.nextElement());
if ( xParaTextRange.getString().equals( "J" ) ) { if ( xParaTextRange.getString().equals( "J" ) ) {
break; break;
...@@ -216,44 +216,44 @@ public class CheckCrossReferences { ...@@ -216,44 +216,44 @@ public class CheckCrossReferences {
xParaTextRange); xParaTextRange);
// insert bookmark // insert bookmark
XMultiServiceFactory xFac = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory xFac = UnoRuntime.queryInterface(
XMultiServiceFactory.class, document); XMultiServiceFactory.class, document);
final String cBookmarkName = "__RefNumPara__47114711"; final String cBookmarkName = "__RefNumPara__47114711";
com.sun.star.text.XTextContent xBookmark = com.sun.star.text.XTextContent xBookmark =
(com.sun.star.text.XTextContent)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.text.XTextContent.class, com.sun.star.text.XTextContent.class,
xFac.createInstance( "com.sun.star.text.Bookmark" ) ); xFac.createInstance( "com.sun.star.text.Bookmark" ) );
if ( xBookmark != null ) { if ( xBookmark != null ) {
com.sun.star.container.XNamed xName = com.sun.star.container.XNamed xName =
(com.sun.star.container.XNamed)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.container.XNamed.class, xBookmark ); com.sun.star.container.XNamed.class, xBookmark );
xName.setName( cBookmarkName ); xName.setName( cBookmarkName );
xBookmark.attach(xParaTextRange.getStart()); xBookmark.attach(xParaTextRange.getStart());
} }
// insert reference field, which references the inserted bookmark // insert reference field, which references the inserted bookmark
com.sun.star.text.XTextContent xNewField = com.sun.star.text.XTextContent xNewField =
(com.sun.star.text.XTextContent)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.text.XTextContent.class, com.sun.star.text.XTextContent.class,
xFac.createInstance( "com.sun.star.text.TextField.GetReference" ) ); xFac.createInstance( "com.sun.star.text.TextField.GetReference" ) );
if ( xNewField != null ) { if ( xNewField != null ) {
com.sun.star.beans.XPropertySet xFieldProps = com.sun.star.beans.XPropertySet xFieldProps =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xNewField ); com.sun.star.beans.XPropertySet.class, xNewField );
xFieldProps.setPropertyValue( "ReferenceFieldPart", new Short(com.sun.star.text.ReferenceFieldPart.TEXT) ); xFieldProps.setPropertyValue( "ReferenceFieldPart", new Short(com.sun.star.text.ReferenceFieldPart.TEXT) );
xFieldProps.setPropertyValue( "ReferenceFieldSource", new Short(com.sun.star.text.ReferenceFieldSource.BOOKMARK) ); xFieldProps.setPropertyValue( "ReferenceFieldSource", new Short(com.sun.star.text.ReferenceFieldSource.BOOKMARK) );
xFieldProps.setPropertyValue( "SourceName", cBookmarkName ); xFieldProps.setPropertyValue( "SourceName", cBookmarkName );
com.sun.star.text.XTextRange xFieldTextRange = com.sun.star.text.XTextRange xFieldTextRange =
(com.sun.star.text.XTextRange)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class, xParaEnum.nextElement()); com.sun.star.text.XTextRange.class, xParaEnum.nextElement());
xNewField.attach(xFieldTextRange.getEnd()); xNewField.attach(xFieldTextRange.getEnd());
xFldsRefresh.refresh(); xFldsRefresh.refresh();
} }
// check inserted reference field // check inserted reference field
com.sun.star.text.XTextField xField = com.sun.star.text.XTextField xField =
(com.sun.star.text.XTextField)UnoRuntime.queryInterface( UnoRuntime.queryInterface(
com.sun.star.text.XTextField.class, xNewField ); com.sun.star.text.XTextField.class, xNewField );
assertEquals( "inserted reference field doesn't has correct field result", assertEquals( "inserted reference field doesn't has correct field result",
"J", xField.getPresentation( false ) ); "J", xField.getPresentation( false ) );
......
...@@ -105,11 +105,9 @@ public class CheckFields ...@@ -105,11 +105,9 @@ public class CheckFields
String file = TestDocument.getUrl("fdo39694.ott"); String file = TestDocument.getUrl("fdo39694.ott");
XComponent xComp = util.DesktopTools.loadDoc(m_xMSF, file, loadProps); XComponent xComp = util.DesktopTools.loadDoc(m_xMSF, file, loadProps);
XTextDocument xTextDoc = (XTextDocument) XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp);
UnoRuntime.queryInterface(XTextDocument.class, xComp);
XTextFieldsSupplier xTFS = (XTextFieldsSupplier) XTextFieldsSupplier xTFS = UnoRuntime.queryInterface(XTextFieldsSupplier.class, xComp);
UnoRuntime.queryInterface(XTextFieldsSupplier.class, xComp);
XEnumeration xEnum = xTFS.getTextFields().createEnumeration(); XEnumeration xEnum = xTFS.getTextFields().createEnumeration();
Set<String> placeholders = new HashSet<String>(); Set<String> placeholders = new HashSet<String>();
placeholders.add("<Kadr1>"); placeholders.add("<Kadr1>");
...@@ -123,12 +121,10 @@ public class CheckFields ...@@ -123,12 +121,10 @@ public class CheckFields
while (xEnum.hasMoreElements()) while (xEnum.hasMoreElements())
{ {
Object xField = xEnum.nextElement(); Object xField = xEnum.nextElement();
XServiceInfo xSI = (XServiceInfo) XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class, xField);
UnoRuntime.queryInterface(XServiceInfo.class, xField);
if (xSI.supportsService("com.sun.star.text.TextField.JumpEdit")) if (xSI.supportsService("com.sun.star.text.TextField.JumpEdit"))
{ {
XTextContent xContent = (XTextContent) XTextContent xContent = UnoRuntime.queryInterface(XTextContent.class, xField);
UnoRuntime.queryInterface(XTextContent.class, xField);
XTextRange xAnchor = xContent.getAnchor(); XTextRange xAnchor = xContent.getAnchor();
String readContent = xAnchor.getString(); String readContent = xAnchor.getString();
if (!placeholders.remove(readContent)) if (!placeholders.remove(readContent))
...@@ -139,7 +135,7 @@ public class CheckFields ...@@ -139,7 +135,7 @@ public class CheckFields
} }
} }
assertTrue(placeholders.isEmpty()); assertTrue(placeholders.isEmpty());
XCloseable xClos = (XCloseable) UnoRuntime.queryInterface( XCloseable xClos = UnoRuntime.queryInterface(
XCloseable.class, xComp); XCloseable.class, xComp);
if (xClos != null) { if (xClos != null) {
xClos.close(true); xClos.close(true);
...@@ -149,19 +145,16 @@ public class CheckFields ...@@ -149,19 +145,16 @@ public class CheckFields
@Test @Test
public void test_fdo42073() throws Exception public void test_fdo42073() throws Exception
{ {
XMultiServiceFactory xDocFactory = (XMultiServiceFactory) XMultiServiceFactory xDocFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, m_xDoc);
UnoRuntime.queryInterface(XMultiServiceFactory.class, m_xDoc);
Object xField = Object xField =
xDocFactory.createInstance("com.sun.star.text.TextField.Input"); xDocFactory.createInstance("com.sun.star.text.TextField.Input");
XText xBodyText = m_xDoc.getText(); XText xBodyText = m_xDoc.getText();
XTextCursor xCursor = xBodyText.createTextCursor(); XTextCursor xCursor = xBodyText.createTextCursor();
XTextField xTextField = (XTextField) XTextField xTextField = UnoRuntime.queryInterface(XTextField.class, xField);
UnoRuntime.queryInterface(XTextField.class, xField);
xBodyText.insertTextContent(xCursor, xTextField, true); xBodyText.insertTextContent(xCursor, xTextField, true);
XPropertySet xPropSet = (XPropertySet) XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xField);
UnoRuntime.queryInterface(XPropertySet.class, xField);
{ {
Object readContent = xPropSet.getPropertyValue("Content"); Object readContent = xPropSet.getPropertyValue("Content");
assertEquals("", readContent); assertEquals("", readContent);
......
...@@ -41,15 +41,15 @@ public class CheckFlies { ...@@ -41,15 +41,15 @@ public class CheckFlies {
@Test public void checkFlies() @Test public void checkFlies()
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
com.sun.star.text.XTextFramesSupplier xTFS = (com.sun.star.text.XTextFramesSupplier)UnoRuntime.queryInterface( com.sun.star.text.XTextFramesSupplier xTFS = UnoRuntime.queryInterface(
com.sun.star.text.XTextFramesSupplier.class, com.sun.star.text.XTextFramesSupplier.class,
document); document);
checkTextFrames(xTFS); checkTextFrames(xTFS);
com.sun.star.text.XTextGraphicObjectsSupplier xTGOS = (com.sun.star.text.XTextGraphicObjectsSupplier)UnoRuntime.queryInterface( com.sun.star.text.XTextGraphicObjectsSupplier xTGOS = UnoRuntime.queryInterface(
com.sun.star.text.XTextGraphicObjectsSupplier.class, com.sun.star.text.XTextGraphicObjectsSupplier.class,
document); document);
checkGraphicFrames(xTGOS); checkGraphicFrames(xTGOS);
com.sun.star.text.XTextEmbeddedObjectsSupplier xTEOS = (com.sun.star.text.XTextEmbeddedObjectsSupplier)UnoRuntime.queryInterface( com.sun.star.text.XTextEmbeddedObjectsSupplier xTEOS = UnoRuntime.queryInterface(
com.sun.star.text.XTextEmbeddedObjectsSupplier.class, com.sun.star.text.XTextEmbeddedObjectsSupplier.class,
document); document);
checkEmbeddedFrames(xTEOS); checkEmbeddedFrames(xTEOS);
...@@ -86,7 +86,7 @@ public class CheckFlies { ...@@ -86,7 +86,7 @@ public class CheckFlies {
"Has nonexisting embedded frame", "Has nonexisting embedded frame",
xEmbeddedFrames.hasByName("Nonexisting embedded frame")); xEmbeddedFrames.hasByName("Nonexisting embedded frame"));
com.sun.star.container.XIndexAccess xEmbeddedFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess xEmbeddedFramesIdx = UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, com.sun.star.container.XIndexAccess.class,
xEmbeddedFrames); xEmbeddedFrames);
assertEquals( assertEquals(
...@@ -129,7 +129,7 @@ public class CheckFlies { ...@@ -129,7 +129,7 @@ public class CheckFlies {
"Has nonexisting graphics frame", "Has nonexisting graphics frame",
xGraphicFrames.hasByName("Nonexisting graphics frame")); xGraphicFrames.hasByName("Nonexisting graphics frame"));
com.sun.star.container.XIndexAccess xGraphicFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess xGraphicFramesIdx = UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, com.sun.star.container.XIndexAccess.class,
xGraphicFrames); xGraphicFrames);
assertEquals( assertEquals(
...@@ -173,7 +173,7 @@ public class CheckFlies { ...@@ -173,7 +173,7 @@ public class CheckFlies {
"Has nonexisting text frame.", "Has nonexisting text frame.",
xTextFrames.hasByName("Nonexisting text frame")); xTextFrames.hasByName("Nonexisting text frame"));
com.sun.star.container.XIndexAccess xTextFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess xTextFramesIdx = UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, com.sun.star.container.XIndexAccess.class,
xTextFrames); xTextFrames);
assertEquals( assertEquals(
......
...@@ -86,8 +86,7 @@ public class LoadSaveTest ...@@ -86,8 +86,7 @@ public class LoadSaveTest
XMultiServiceFactory.class, m_xContext.getServiceManager()); XMultiServiceFactory.class, m_xContext.getServiceManager());
Object oGEB = m_xMSF.createInstance( Object oGEB = m_xMSF.createInstance(
"com.sun.star.frame.GlobalEventBroadcaster"); "com.sun.star.frame.GlobalEventBroadcaster");
m_xGEB = (XDocumentEventBroadcaster) m_xGEB = UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, oGEB);
UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, oGEB);
assertNotNull("could not get global event broadcaster.", m_xGEB); assertNotNull("could not get global event broadcaster.", m_xGEB);
m_TmpDir = util.utils.getOfficeTemp/*Dir*/(m_xMSF); m_TmpDir = util.utils.getOfficeTemp/*Dir*/(m_xMSF);
System.out.println("tempdir: " + m_TmpDir); System.out.println("tempdir: " + m_TmpDir);
...@@ -145,7 +144,7 @@ public class LoadSaveTest ...@@ -145,7 +144,7 @@ public class LoadSaveTest
System.out.println("Storing document: " + fileName + " ..."); System.out.println("Storing document: " + fileName + " ...");
XStorable xStor = (XStorable) UnoRuntime.queryInterface( XStorable xStor = UnoRuntime.queryInterface(
XStorable.class, xDoc); XStorable.class, xDoc);
String targetFile = m_fileURL + m_TargetDir + fileName; String targetFile = m_fileURL + m_TargetDir + fileName;
......
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