Impress ooRexx Rony G. Flatscher How do I deal with Impress?

... demonstrate some common things

... some common things one can do with impress documents

(modelled after/transcribed from the CPP snippet)

/* Modelled (transcribed from) the CPP snippet at {%internal ./Impress.DealWithImpress.snip} for ooRexx ({%external http://www.ooRexx.org}). */ -- Retrieve the Desktop object, we need its XComponentLoader interface to load a new document oDesktop = UNO.createDesktop() -- get the UNO Desktop service object comploader = oDesktop~{%see com.sun.star.frame.XDesktop%XDesktop}~{%see com.sun.star.frame.XComponentLoader%XComponentLoader} -- get componentLoader -- interface -- create an empty Impress component component = comploader~loadComponentFromURL("private:factory/simpress", "_blank", 0, .UNO~noProps) /* get draw page by index */ oDoc = component~{%see com.sun.star.drawing.XDrawPagesSupplier%XDrawPagesSupplier} call changeTitle oDoc -- set the Title with XDocumentInfoSupplier drawpages=oDoc~getDrawPages -- get DrawPages Container pagecount=drawpages~{%see com.sun.star.container.XIndexAccess%XIndexAccess} -- for index access and counting usage newDrawPage=drawpages~insertNewByIndex(0) -- insert a new drawpage namecontainer=newDrawPage~{%see com.sun.star.container.XNamed%XNamed} -- count pages and print them out to stdout say "There are" pageCount~getCount "pages in the Impress document" say -- Loop through all pages and give Pagenumber+Pagename to each of them do icounter=0 to pageCount~getCount-1 pagename=pagecount~getByIndex(icounter)~{%see com.sun.star.drawing.XDrawPage%XDrawPage}~{%see com.sun.star.container.XNamed%XNamed}~getName say " Page Number" icounter "has the name" pagename end namecontainer~setName("My second Page") -- Playing around with the inserted page... Name=namecontainer~getName mValue=newDrawPage~{%see com.sun.star.beans.XPropertySet%XPropertySet}~getPropertyValue("Number") say say "The newly inserted page '"Name"' is in position" mValue -- set the focus on the newly inserted page oDoc~{%see com.sun.star.frame.XModel%XModel}~getCurrentController~{%see com.sun.star.drawing.XDrawView%XDrawView}~setCurrentPage(newDrawPage) /********************** **** DRAWING PART **** **********************/ -- get Document factory DocFactory=component~{%see com.sun.star.lang.XMultiServiceFactory%XMultiServiceFactory} Pos =.bsf~new("{%see com.sun.star.awt.Point}", 7000, 7000) Size=.bsf~new("{%see com.sun.star.awt.Size}", 16000, 3000) -- instantiate TextShape and assign properties txtShape=DocFactory~createInstance("{%see com.sun.star.drawing.TextShape}")~{%see com.sun.star.drawing.XShape%XShape} txtShape~~setPosition(Pos)~~setSize(Size) page1=pageCount~getByIndex(0)~{%see com.sun.star.drawing.XDrawPage%XDrawPage} call drawMe txtShape, page1, "My TextShape" -- use the much simpler method XTextRange setString() rather than insertTextContent() txtShape~{%see com.sun.star.text.XText%XText}~setString("Hello to all people around the world") /* ~~ ON SECOND PAGE ~~ */ pos~X=2000; pos~Y=6000 size~Width=7000; size~Height=2000 rectShape=DocFactory~createInstance("{%see com.sun.star.drawing.RectangleShape}")~{%see com.sun.star.drawing.XShape%XShape} rectShape~~setPosition(pos)~~setSize(size) call drawMe rectShape, newDrawPage, "My Rectangle" -- play a Presentation call Presentation component ::requires UNO.CLS -- get UNO support ::routine changeTitle use arg oDoc docinfo=oDoc~{%see com.sun.star.document.XDocumentInfoSupplier%XDocumentInfoSupplier}~getDocumentInfo DocInfoProps=docinfo~{%see com.sun.star.beans.XPropertySet%XPropertySet} -- get some infos about user via Java s=.bsf4rexx~system.class -- get "java.lang.System" and its information userInfo=s~getProperty("user.name") "on" s~getProperty("os.name")":" -- Original author meant "Title" which can be queried via "File->Properties->Description" DocInfoProps~setPropertyValue("Title", userInfo "My First attempt on" date("S") time() ) ::routine drawMe use arg Shape, page, shapename page~{%see com.sun.star.drawing.XShapes%XShapes}~add(Shape) Shape~{%see com.sun.star.beans.XPropertySet%XPropertySet}~setPropertyValue("Name", shapename) ::routine Presentation use arg component mPres_props=component~{%see com.sun.star.presentation.XPresentationSupplier%XPresentationSupplier}~getPresentation~{%see com.sun.star.beans.XPropertySet%XPropertySet} mPres_props~setPropertyValue("FirstPage", box("short", 0))
Initial version