ORB direct print?

Getting your data onto paper - or the web - Discussing the reports features of Base
Post Reply
zeke99
Posts: 24
Joined: Fri Jun 29, 2012 4:05 pm

ORB direct print?

Post by zeke99 »

I have a macro that opens a OracleReportBuilder report. The report opens nicely but then I have to push the print button to actually send it to the printer. Is there a way to get rid of that extra click on the printerbutton? Can you send a ORB report directly to the printer without the preview? Or maybe open the report, send a printcommand from the macro and then close the ORB-report.

Code: Select all

sub PrintReport(    aConnection as variant, _
                   aQueryName as string, _
                   aFilter as String, _
                   aReportName )
                   
   dim composer as variant
   dim oReport as variant
   dim aryProp(1) as new com.sun.star.beans.PropertyValue
       
   composer = aConnection.createQueryComposer
   composer.setQuery( aConnection.Queries.getByName( aQueryName ).Command )
   composer.setFilter( aFilter )
       
   aryProp(0).Name = "ActiveConnection"
   aryProp(0).Value = aConnection
   aryProp(1).Name = "OpenMode"
   aryProp(1).Value = "open" 
   
   aConnection.Parent.DatabaseDocument.ReportDocuments.loadComponentFromURL( aReportName, "_blank", 0, aryProp() )
   
   aConnection.Queries.getByName( aQueryName ).Command = composer.getQuery

end sub
OpenOffice 4.1 LinuxMint 17
RPG
Volunteer
Posts: 2261
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: ORB direct print?

Post by RPG »

LibreOffice 24.8.5.2 on openSUSE Leap 15.6
zeke99
Posts: 24
Joined: Fri Jun 29, 2012 4:05 pm

Re: ORB direct print?

Post by zeke99 »

Thank's RPG

Here is the final code

Code: Select all

REM *******************************************************
REM *****                                             *****
REM ***** CustomerAdressLabel                         *****
REM *****										      *****
REM ***** Filter and prints adresslabels.             *****
REM ***** Open the query QueryCustomerAdressLabel,    *****
REM ***** changing the underlying SQL-statement       *****
REM ***** so it only filters the current post         *****
REM ***** and then print the report ReportCustomer    *****
REM ***** AdressLabel which is based on the query     *****
REM ***** QueryCustomerAdressLabel. Uses the macro    *****
REM ***** ExecuteReport to open and print the report. *****
REM *****                                             *****
REM *******************************************************


Sub CustomerAdressLabel (Event as object)

Dim tblcustomer as object
Dim Controller as object
Dim RepQuery as variant
Dim SQLtext as string
Dim custID as integer

    REM oEvent is an EventObject
    REM Source is the control that called the event - the button
    REM Model is what we use when we want to get to properties avialable at design time
    REM Parent is the name of the contol that the button belongs to

tblcustomer=Event.Source.Model.Parent

custID = tblcustomer.getInt(tblcustomer.FindColumn( "customer_id" ))
'xray tblcustomer

ExecuteReport(    tblcustomer.ActiveConnection,"QueryCustomerAdressLabel",_
				"customer_id = " & custID,"ReportCustomerAdressLabel" )
     
end sub


REM *************************************************
REM *****                                       *****
REM ***** ExecuteReport                         *****
REM *****										*****
REM ***** Macro for printing filtered reports   *****
REM *****										*****
REM *************************************************


sub ExecuteReport(    aConnection as variant, _
                   aQueryName as string, _
                   aFilter as String, _
                   aReportName )
                   
   dim composer as variant
   dim oReport as variant
   dim aryProp(1) as new com.sun.star.beans.PropertyValue
   dim oreport as object
   dim printOpts()
       
   REM ---- Creates a SQLQueryComposer object
   composer = aConnection.createQueryComposer
   REM ---- Creates a new query in the composerobject based on the old query from aConnection.Queries ...
   composer.setQuery( aConnection.Queries.getByName( aQueryName ).Command )
   REM ---- Sets a filter to the query in the composerobject
   composer.setFilter( aFilter )
       
   aryProp(0).Name = "ActiveConnection"
   aryProp(0).Value = aConnection
   aryProp(1).Name = "OpenMode"
   aryProp(1).Value = "open" 
   
   REM ---- Open the report
   oreport=aConnection.Parent.DatabaseDocument.ReportDocuments.loadComponentFromURL( aReportName, "_blank", 0, aryProp() )
   REM ---- Prints the report
   oreport.Print(printOpts)
   
   wait 800
   
   REM ---- Close the report-document
   odocument.close(true)
   
   REM ---- Put back the old SQL-statement to the query
   aConnection.Queries.getByName( aQueryName ).Command = composer.getQuery

end sub
I noticed in the API wiki that DatabaseDocument was deprecated. The devguide suggested using:

XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc);

Tried to convert that to starbasic but get a couple of errors (probably due to me being tired). Anyone less tired than me knowing the starbasic syntax?

Zeke
OpenOffice 4.1 LinuxMint 17
Post Reply