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.setFormula("ScAccessiblePageHeader");
} catch(com.sun.star.lang.WrappedTargetException e) {
log.println("Exception ceating relation :");
e.printStackTrace(log);
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Exception ceating relation :");
e.printStackTrace(log);
}
XModel aModel = (XModel)
UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc);
XController xController = aModel.getCurrentController();
// switching to 'Page Preview' mode
try {
XDispatchProvider xDispProv = (XDispatchProvider)
UnoRuntime.queryInterface(XDispatchProvider.class, xController);
XURLTransformer xParser = (com.sun.star.util.XURLTransformer)
UnoRuntime.queryInterface(XURLTransformer.class,
( (XMultiServiceFactory) Param.getMSF()).createInstance("com.sun.star.util.URLTransformer"));
// Because it's an in/out parameter we must use an array of URL objects.
URL[] aParseURL = new URL[1];
aParseURL[0] = new URL();
aParseURL[0].Complete = ".uno:PrintPreview";
xParser.parseStrict(aParseURL);
URL aURL = aParseURL[0];
XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0);
if(xDispatcher != null)
xDispatcher.dispatch( aURL, null );
} catch (com.sun.star.uno.Exception e) {
log.println("Couldn't change mode");
throw new StatusException(Status.failed("Couldn't change mode"));
}
try {
Thread.sleep(500);
} catch (InterruptedException ex) {}
AccessibilityTools at = new AccessibilityTools();
XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel);
XAccessible xRoot = at.getAccessibleObject(xWindow);
oObj = at.getAccessibleObjectForRole
(xRoot, AccessibleRole.HEADER, "");
log.println("ImplementationName " + utils.getImplName(oObj));
at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
TestEnvironment tEnv = new TestEnvironment(oObj);
XStyleFamiliesSupplier StyleFam = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class,
xSpreadsheetDoc );
XNameAccess StyleFamNames = StyleFam.getStyleFamilies();
XStyle StdStyle = null;
try{
XNameAccess PageStyles = (XNameAccess) AnyConverter.toObject(
new Type(XNameAccess.class),
StyleFamNames.getByName("PageStyles"));
StdStyle = (XStyle) AnyConverter.toObject(
new Type(XStyle.class), PageStyles.getByName("Default"));
} catch(com.sun.star.lang.WrappedTargetException e){
e.printStackTrace(log);
throw new StatusException("Couldn't get by name", e);
} catch(com.sun.star.container.NoSuchElementException e){
e.printStackTrace(log);
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
final XPropertySet PropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, StdStyle);
XHeaderFooterContent RPHC = null;
// creation of testobject here
// first we write what we are intend to do to log file
log.println( "creating a test environment" );
try {
RPHC = (XHeaderFooterContent) AnyConverter.toObject(
new Type(XHeaderFooterContent.class),
PropSet.getPropertyValue("RightPageHeaderContent"));
} catch(com.sun.star.lang.WrappedTargetException e){
e.printStackTrace(log);
throw new StatusException("Couldn't get HeaderContent", e);
} catch(com.sun.star.beans.UnknownPropertyException e){
e.printStackTrace(log);
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 XText center = RPHC2.getCenterText();