function run()
{
var objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");
var objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection");
var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
var objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection");
var args= new Array();
var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
var objText= objDocument.getText();
var objCursor= objText.createTextCursor();
objText.insertString( objCursor, "The first line in the newly created text document.\n", false);
objText.insertString( objCursor, "Now we're in the second line", false);
var objTable= objDocument.createInstance( "com.sun.star.text.TextTable");objTable.initialize( 4, 4);
objText.insertTextContent( objCursor, objTable, false);
var objRows= objTable.getRows();
var objRow= objRows.getByIndex( 0);
objTable.setPropertyValue( "BackTransparent", false);
objTable.setPropertyValue( "BackColor", 13421823);
objRow.setPropertyValue( "BackTransparent", false);
objRow.setPropertyValue( "BackColor", 6710932);
insertIntoCell( "A1","FirstColumn", objTable);
insertIntoCell( "B1","SecondColumn", objTable);
insertIntoCell( "C1","ThirdColumn", objTable);
insertIntoCell( "D1","SUM", objTable);
objTable.getCellByName("A2").setValue( 22.5);
objTable.getCellByName("B2").setValue( 5615.3);
objTable.getCellByName("C2").setValue( -2315.7);
objTable.getCellByName("D2").setFormula("sum <A2:C2>");objTable.getCellByName("A3").setValue( 21.5);
objTable.getCellByName("B3").setValue( 615.3);
objTable.getCellByName("C3").setValue( -315.7);
objTable.getCellByName("D3").setFormula( "sum <A3:C3>");objTable.getCellByName("A4").setValue( 121.5);
objTable.getCellByName("B4").setValue( -615.3);
objTable.getCellByName("C4").setValue( 415.7);
objTable.getCellByName("D4").setFormula( "sum <A4:C4>");
objCursor.setPropertyValue( "CharColor", 255);
objCursor.setPropertyValue( "CharShadowed", true);
objText.insertControlCharacter( objCursor, 0 , false);
objText.insertString( objCursor, " This is a colored Text - blue with shadow\n", false);objText.insertControlCharacter(objCursor, 0, false );
var objTextFrame= objDocument.createInstance("com.sun.star.text.TextFrame");
var objSize= createStruct("com.sun.star.awt.Size");
objSize.Width= 15000;
objSize.Height= 400;
objTextFrame.setSize( objSize);
objTextFrame.setPropertyValue( "AnchorType", 1);
objText.insertTextContent( objCursor, objTextFrame, false);
var objFrameText= objTextFrame.getText();
var objFrameTextCursor= objFrameText.createTextCursor();
objFrameText.insertString( objFrameTextCursor, "The first line in the newly created text frame.",false);
objFrameText.insertString(objFrameTextCursor, "With this second line the height of the frame raises.", false );
objFrameText.insertControlCharacter( objCursor, 0 , false);
objCursor.setPropertyValue( "CharColor", 65536);
objCursor.setPropertyValue( "CharShadowed", false);
objText.insertString( objCursor, " That's all for now !!", false );
function insertIntoCell( strCellName, strText, objTable)
{
var objCellText= objTable.getCellByName( strCellName);
var objCellCursor= objCellText.createTextCursor();
objCellCursor.setPropertyValue( "CharColor",16777215);
objCellText.insertString( objCellCursor, strText, false);
}
function createStruct( strTypeName)
{
var classSize= objCoreReflection.forName( strTypeName);
var aStruct= new Array();
classSize.createObject( aStruct);
return aStruct[0];
}
}
run();