Kaydet (Commit) 0a1a09be authored tarafından Stephan Wunderlich's avatar Stephan Wunderlich

CHG: using AnyConverter instead of simple cast

üst 441cb7b7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* $RCSfile: ScAccessiblePageHeader.java,v $ * $RCSfile: ScAccessiblePageHeader.java,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: sw $ * last change: $Author: sw $
* *
...@@ -98,6 +98,9 @@ import com.sun.star.style.XStyle; ...@@ -98,6 +98,9 @@ import com.sun.star.style.XStyle;
import com.sun.star.style.XStyleFamiliesSupplier; import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.text.XText; import com.sun.star.text.XText;
import com.sun.star.uno.Type;
import com.sun.star.uno.AnyConverter;
/** /**
* Test for object which is represented by accessible component of * Test for object which is represented by accessible component of
* a printed header in 'Page Preview' mode. * a printed header in 'Page Preview' mode.
...@@ -140,7 +143,13 @@ public class ScAccessiblePageHeader extends TestCase { ...@@ -140,7 +143,13 @@ public class ScAccessiblePageHeader extends TestCase {
XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ;
XIndexAccess oIndexSheets = (XIndexAccess) XIndexAccess oIndexSheets = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, oSheets); UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
XSpreadsheet oSheet = (XSpreadsheet) oIndexSheets.getByIndex(0); XSpreadsheet oSheet = null;
try {
oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("couldn't get sheet",iae);
}
xCell = oSheet.getCellByPosition(0, 0) ; xCell = oSheet.getCellByPosition(0, 0) ;
xCell.setFormula("ScAccessiblePageHeader"); xCell.setFormula("ScAccessiblePageHeader");
} catch(com.sun.star.lang.WrappedTargetException e) { } catch(com.sun.star.lang.WrappedTargetException e) {
...@@ -202,15 +211,19 @@ public class ScAccessiblePageHeader extends TestCase { ...@@ -202,15 +211,19 @@ public class ScAccessiblePageHeader extends TestCase {
XStyle StdStyle = null; XStyle StdStyle = null;
try{ try{
XNameAccess PageStyles = (XNameAccess) XNameAccess PageStyles = (XNameAccess) AnyConverter.toObject(
StyleFamNames.getByName("PageStyles"); new Type(XNameAccess.class),
StdStyle = (XStyle)PageStyles.getByName("Default"); StyleFamNames.getByName("PageStyles"));
StdStyle = (XStyle) AnyConverter.toObject(
new Type(XStyle.class), PageStyles.getByName("Default"));
} catch(com.sun.star.lang.WrappedTargetException e){ } catch(com.sun.star.lang.WrappedTargetException e){
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get by name", e); throw new StatusException("Couldn't get by name", e);
} catch(com.sun.star.container.NoSuchElementException e){ } catch(com.sun.star.container.NoSuchElementException e){
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get by name", e); throw new StatusException("Couldn't get by name", e);
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("Couldn't convert any", iae);
} }
//get the property-set //get the property-set
...@@ -222,14 +235,18 @@ public class ScAccessiblePageHeader extends TestCase { ...@@ -222,14 +235,18 @@ public class ScAccessiblePageHeader extends TestCase {
// first we write what we are intend to do to log file // first we write what we are intend to do to log file
log.println( "creating a test environment" ); log.println( "creating a test environment" );
try { try {
RPHC = (XHeaderFooterContent) RPHC = (XHeaderFooterContent) AnyConverter.toObject(
PropSet.getPropertyValue("RightPageHeaderContent"); new Type(XHeaderFooterContent.class),
PropSet.getPropertyValue("RightPageHeaderContent"));
} catch(com.sun.star.lang.WrappedTargetException e){ } catch(com.sun.star.lang.WrappedTargetException e){
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get HeaderContent", e); throw new StatusException("Couldn't get HeaderContent", e);
} catch(com.sun.star.beans.UnknownPropertyException e){ } catch(com.sun.star.beans.UnknownPropertyException e){
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get HeaderContent", e); throw new StatusException("Couldn't get HeaderContent", e);
} catch(com.sun.star.lang.IllegalArgumentException e){
e.printStackTrace(log);
throw new StatusException("Couldn't get HeaderContent", e);
} }
final XHeaderFooterContent RPHC2 = RPHC; final XHeaderFooterContent RPHC2 = RPHC;
......
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