This ooRexx program creates a simpress presentation and then runs/starts it.

   /**********************************************************************
     AOO_simpress_present.rex using OLE (object linking and embedding) with 
ooRexx

     Links: <https://OpenOffice.org>
   
<https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge>
   <https://www.pitonyak.org/oo.php>
   <https://www.openoffice.org/udk/common/man/spec/ole_bridge.html>

     Using OLE create a new simpress presentation about REXX and ooRexx and then
     display it as a presentation. Demonstrates how to use enumeration to
     enumerate paragraphs of a text and query their 'NumberingLevel' property.
   ***********************************************************************/

   /* create a presentation, then start it */
   serviceManager = .OLEObject~new('com.sun.star.ServiceManager')
   desktop  = serviceManager~createInstance('com.sun.star.frame.Desktop')
   noProps  = .array~new   /* empty array (no properties)   */
   document = desktop~loadComponentFromURL('private:factory/simpress', 
'_blank', 0, noProps)

   drawPages = document~getDrawPages      -- get DrawPages
       -- first page
   drawPage=drawPages~getByIndex(0)       -- get first (empty) page
   drawPage~setPropertyValue("Layout", 0) -- "Title Slide"

   title = "ooRexx"
   shape = drawPage~getByIndex(0)         -- get first shape (title)
   shape~setString(title)

   shape = drawPage~getByIndex(1)         -- get second shape (subtitle)
   cursor = shape~createTextCursor        -- get XTextCursor
   cr="0d"x
   shape~insertString(cursor,"Open Object Rexx (ooRexx)"cr, .false)

   textRange=shape~getEnd                 -- get a XTextRange
   textRange~setPropertyValue("CharHeight", 15)    -- use 15 pixel height
   info="(Presentation created:" .dateTime~new")"
   textRange~setString(info)              -- set it to this string

       -- add a second page
   drawPage=drawPages~~insertNewByIndex(1)~getByIndex(1) -- insert at end, get 
access
   drawPage~setPropertyValue("Layout", 1) -- "Title Content"
   drawPage~getByIndex(0)~setString("Open Object Rexx (ooRexx)") -- first shape

   text=drawPage~getByIndex(1)            -- get second shape (listing)
   -- add string, supply level
   call addItem text, "REXX (IBM)",                                   0
   call addItem text, "First released in 1979 for IBM mainframes",    1
   call addItem text, "Object REXX (IBM)",                            0
   call addItem text, "Object-oriented successor to REXX",            1
   call addItem text, "First released in 1994 with IBM's OS/2 Warp",  1
   call addItem text, "Negotiations about open-sourcing with RexxLA", 1
   call addItem text, "Rexx Language Association (www.RexxLA.org)",   2
   call addItem text, "Source code handed over to RexxLA in 2003",    2
   call addItem text, "Open Object Rexx (ooRexx by RexxLA)",          0
   call addItem text, "First released in 2004 by RexxLA",             1, .false

   document~setModified(.false)                 -- inhibit save-as popup
   /* OOo OLE interface does not answer hasOleMethod('start') with .true
       therefore forcing "start" to be dispatched to Windows */
   document~getPresentation~dispatch("start")   -- start presentation

   say "double-check: dump NumberingLevel of each text paragraph:"
   call dumpItems text                    -- demonstrates enumerating listing 
text


   ::routine addItem                -- adds string at the given (0-based 
outline) level
      use arg xText, string, level, bNewParagraph=.true

      xTR=xText~getEnd               -- get XTextRange
      xTR~setPropertyValue("NumberingLevel",level) -- set XTextRange level
      xTR~setString(string)          -- set string

      if bNewParagraph=.true then    -- add new paragraph
         xTR~getEnd~setString("0a"x) -- add linefeed character -> new paragraph

   ::routine dumpItems              -- show level and string from XText
      use arg xText

      enum=xText~createEnumeration   -- enumerate paragraphs
      do i=1 while enum~hasMoreElements
        xtr=enum~nextElement         -- we need XTextRange's string & properties
        nl=xtr~getPropertyValue("NumberingLevel")
        say "     item #" i": NumberingLevel="pp(nl) pp(xtr~getString)
      end
      return
   pp: -- "pretty print", internal routine: return argument enclosed in square 
brackets
      return "["arg(1)"]"

HTH

---rony

P.S.: The short paper at <https://epub.wu.ac.at/8118/> introduces ooRexx briefly in ten pages, home of Rexx based technologies is the non-profit SIG "Rexx Language Association" at <https://www.RexxLA.org>.

Reply via email to