Ask Your Question
1

Writer master document using reportbuilder output, need to remove pagebreaks [closed]

asked 2018-01-22 18:18:38 +0200

Spun69 gravatar image

updated 2018-01-22 19:41:48 +0200

Hello

I need to create a document consisting of some header text, then the output of two Base ReportBuilder (RB) files. I am currently using a Writer master document for this. I can load the two subdocuments successfully with silent update to refresh content. My problem is the tables generated in RB have 'break before' attribute, so there is a page break before each subdocument; cannot find anyway to change this in RB. I want to change the tables BreakType to NONE.

The code below tries to do this, but does not seem to be working as the saved document still has the page breaks. I have tried a couple approaches, neither works. I can manually change the output to remove the page break, but need this automated. Any suggestions?

Using LO Version: 5.3.7.2

    REM Variable declarations not shown for brevity
    Set oController = CurrentDb.Document.CurrentController

    'Create registration base file
    pvArgs(0).Name  = "Hidden"
    pvArgs(0).Value = True
    Set odReport = oController.loadComponentWithArguments(com.sun.star.sdb.application.DatabaseObject.REPORT, acCampRegRep, acViewNormal, pvArgs)
    pvArgs(0).Name  = "Overwrite"
    pvArgs(0).Value = True
    odReport.storeAsURL(acCampRegURL, pvArgs)
    odReport.dispose()

    'Create registration invoice file
    pvArgs(0).Name  = "Hidden"
    pvArgs(0).Value = True
    Set odReport = oController.loadComponentWithArguments(com.sun.star.sdb.application.DatabaseObject.REPORT, acCampInvRep, acViewNormal, pvArgs)
    pvArgs(0).Name  = "Overwrite"
    pvArgs(0).Value = True
    odReport.storeAsURL(acCampInvURL, pvArgs)
    odReport.dispose()

    'Open MASTER file and update links
    pvArgs(0).Name  = "UpdateDocMode"
    pvArgs(0).Value =  com.sun.star.document.UpdateDocMode.QUIET_UPDATE
    Set odReport = StarDesktop.loadComponentFromURL(acCampTplURL, "_blank", 0, pvArgs)

    'Set textflow on ingested subdocuments
    Set oTables = odReport.getTextTables()
    Set oTable = oTables.getByIndex(0)
    oTable.BreakType = com.sun.star.style.BreakType.NONE
'    odReport.getTextTables().getByIndex(0).BreakType = com.sun.star.style.BreakType.NONE
    odReport.getTextTables().getByIndex(1).BreakType = com.sun.star.style.BreakType.NONE

    odReport.Select(oTable)
    oCurs = odReport.getViewCursor() 
    oCurs.BreakType = com.sun.star.style.BreakType.NONE

    pvArgs(0).Name  = "Overwrite"
    pvArgs(0).Value = True
    odReport.storeAsURL(acCampOutURL, pvArgs)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Spun69
close date 2018-01-27 23:52:23.659099

1 Answer

Sort by » oldest newest most voted
0

answered 2018-01-27 23:51:54 +0200

Spun69 gravatar image

After reading "OpenOffice.org Macros Explained " by Andrew D. Pitonyak, I reworked my code to make use of TextFrames and Bookmarks. Now I generate the report, extract required table(s), then paste into the output document at a bookmark location within a frame. This does exactly what I need. Working code below.

'Routine to import block from generated report
Sub InsertReportBlock(odOutput As Object, sReportName As String, sTables As Object, sBkmrkName As String )
   Dim odReport, oController, oTable, oInCursor, oOutCursor, oBlock, oBookmark
   Dim pvArgs(2) As New com.sun.star.beans.PropertyValue
   Dim i

   Set odReport = createunoservice("com.sun.star.text.TextDocument")
   Set oTable   = createunoservice("com.sun.star.text.TextTable")
   Set oController = CurrentDb.Document.CurrentController

   'Generate reports for reservation details & invoice
   pvArgs(0).Name  = "Hidden" : pvArgs(0).Value = True
   Set odReport  = oController.loadComponentWithArguments(com.sun.star.sdb.application.DatabaseObject.REPORT, sReportName, acViewNormal, pvArgs)

   Set oInCursor  = odReport.CurrentController.getViewCursor()
   Set oOutCursor = odOutput.CurrentController.getViewCursor()
   Set oBookmark  = odOutput.getBookmarks().getByName(sBkmrkName)

   'Loop over list of table names
   For i = LBound(sTables) To UBound(sTables)
      'Copy report content
      Set oTable = odReport.getTextTables().getByName(sTables(i)) 
      odReport.CurrentController.select(oTable)  
       oInCursor.gotoEnd(True)  'Move to the end of the current cell.
        oInCursor.gotoEnd(True)  'Move to the end of the table.  
        Set oBlock = odReport.CurrentController.getTransferable()  

      'Paste at bookmark 
        oOutCursor.gotoRange(oBookmark.getAnchor(), False)  'Move the cursor to bookmark location
        odOutput.CurrentController.insertTransferable(oBlock)
     Next

Exit_Function:
   odReport.dispose()

End Sub
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-22 18:18:38 +0200

Seen: 109 times

Last updated: Jan 27 '18