OO-Snippets: Scenario

Commons

Keywords
LanguageooRexx
ApplicationCalc
AuthorsMichael Hinz (initial)
Supported Versions2.0.x  
Supported OSWin32  
QuestionHow can i add a scenario
Answer

Code-Snippet-Listing (snippet-source)

/* get the desktop  (an Xdesktop object) */
oDesktop = UNO.createDesktop()   
xComponentLoader = oDesktop~XDesktop~XComponentLoader      --get componentLoader interface
                                                      
/* open a blank calc file */
url = "private:factory/scalc"
xCalcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)


/* get first sheet in spreadsheet */
xDocument = xCalcComponent~XSpreadSheetDocument
xSheet = xDocument~getSheets~XIndexAccess~getByIndex(0)~XSpreadSheet

/*create cell range, get address and set into array*/
xCellRange = xSheet~xCellRange~getCellRangeByName("B3:F6")
xCellRangeAddress = xCellRange~XCellRangeAddressable~getRangeAddress
CALL UNO.loadClass "com.sun.star.table.CellRangeAddress"
oAddr = bsf.createArray(.UNO~CellRangeAddress, 1) 
oAddr[1] = xCellRangeAddress

aScenarioName = rexx
aScenarioComment = mein scenario

/* get  scenario and apply to cell range*/
xScenSupplier = xSheet~XScenariosSupplier
xScenarios = xScenSupplier~getScenarios
xScenarios~addNewByName(aScenarioName, oAddr, aScenarioComment)

::requires UNO.CLS       -- get UNO support

Changelog

DateUserModification

and