//get the property-set
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);
}
XText center = RPHC.getCenterText();
XTextRange text_to_move = null;
log.println( "inserting some lines" );
try {
XTextCursor oCursor = center.createTextCursor();
center.insertControlCharacter(
oCursor, ControlCharacter.PARAGRAPH_BREAK, false );
center.insertControlCharacter(
oCursor, ControlCharacter.LINE_BREAK, false );
center.insertString(oCursor,"Paragraph 1", false);
center.insertString(oCursor,": ScHeaderFooterTextObj", false);
center.insertControlCharacter(
oCursor, ControlCharacter.PARAGRAPH_BREAK, false );
center.insertString(oCursor, "THE QUICK BROWN FOX JUMPS OVER THE" +
" LAZY DOG: ScHeaderFooterTextObj", false );
center.insertControlCharacter(
oCursor, ControlCharacter.PARAGRAPH_BREAK, false );
center.insertControlCharacter(
oCursor, ControlCharacter.LINE_BREAK, false );
oCursor.setString("TextForMove");
text_to_move = oCursor;
XTextCursor oCursor1 = center.createTextCursorByRange(center.getEnd());
center.insertString(oCursor1,"Paragraph 2", false);
center.insertString(oCursor1,": ScHeaderFooterTextObj", false);
center.insertControlCharacter(
oCursor1, ControlCharacter.PARAGRAPH_BREAK, false );
center.insertString( oCursor1, "THE QUICK BROWN FOX JUMPS OVER THE" +
" LAZY DOG: ScHeaderFooterTextObj", false);
center.insertControlCharacter(
oCursor1, ControlCharacter.PARAGRAPH_BREAK, false );
center.insertControlCharacter(
oCursor1, ControlCharacter.LINE_BREAK, false );
} catch(com.sun.star.lang.IllegalArgumentException e){
e.printStackTrace(log);
throw new StatusException("Couldn't insert Text ", e);
}
try {
PropSet.setPropertyValue("RightPageHeaderContent", RPHC);
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set HeaderContent", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set HeaderContent", e);
} catch (com.sun.star.beans.PropertyVetoException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set HeaderContent", e);
} catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set HeaderContent", e);
}
// create testobject here
oObj = center;
TestEnvironment tEnv = new TestEnvironment(oObj);
DefaultDsc tDsc = new DefaultDsc(
"com.sun.star.text.XTextContent","com.sun.star.text.TextField.Time");
log.println( "adding InstCreator object" );
tEnv.addObjRelation(
"XTEXTINFO", new InstCreator( xSpreadsheetDoc, tDsc ) );
ParagraphDsc pDsc = new ParagraphDsc();
tEnv.addObjRelation( "PARA", new InstCreator(xSpreadsheetDoc, pDsc) );
log.println("adding TextRange for XTextRangeMover" );
tEnv.addObjRelation("RangeForMove", text_to_move);
tEnv.addObjRelation("XTextRange", RPHC.getCenterText());
return tEnv;
} // finish method getTestEnvironment