OO-Snippets: pageSize

Commons

Keywords
LanguageooRexx
ApplicationCalc
AuthorsMichael Hinz (initial)
Supported Versions2.0.x  
Supported OSWin32  
QuestionHow can i change the page size
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

CALL UNO.setCell xSheet, 0, 0, "Please change the view" 

xServiceManager = xDocument~XMultiServiceFactory
/*create an instance of page style*/
xPageStyle = xServiceManager~createInstance("com.sun.star.style.PageStyle")
xFamiliesSupplier = xDocument~XStyleFamiliesSupplier
xStyle = xFamiliesSupplier~getStyleFamilies~getByName("PageStyles")~XNameContainer
xPage = xStyle~getByName( "Default" )

xPageSize = xPage~XPropertySet~getPropertyValue("Size")

CALL syssleep 5

/*set size*/
height = xPageSize~Height
xPageSize~Height = xPageSize~Width
xPageSize~Width = height

/*apply size to page size*/
xPage~xPropertySet~setPropertyValue("Size",xPageSize)
xPage~xPropertySet~setPropertyValue("IsLandscape", box("new Boolean", (true)))

CALL syssleep 5


/*set new size*/
width = 5000
height = 10000

xPageSize~Height = height
xPageSize~Width=height = width

/*apply size to page size*/
xPage~xPropertySet~setPropertyValue("Size",xPageSize)
xPage~xPropertySet~setPropertyValue("IsLandscape", box("new Boolean", (true)))

::requires UNO.cls       -- get UNO support

Changelog

DateUserModification

and