VKRep
Class TWordReport

java.lang.Object
  |
  +--VKRep.TReportAbstract
        |
        +--VKRep.TReportVertical
              |
              +--VKRep.TWordReport
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class TWordReport
extends TReportVertical

Title: Reporter to RTF, HTML, TXT.

Description: Main class for all vertical text based reports (TXT, RTF, HTML).

Build report processing.

First of all you should make blank for you report with format what you want. Class TWordReport allowed to do reports in text based formats such as TXT, RTF, HTML. So if you want to get TXT file with you data you should make TXT format blank, if you want to get RTF file you should make RTF blank, and HTML blank if you want HTML.

The blank in any formats may consists of report sections. There are 11 standard sections and 2 special sections. In addition you can define your own report sections.

11 standard sections:

2 special sections:

All sections have a name and a number. All standard sections have a predefined name and numbers from 0 to 12. When you define your own section you give name this section and when you register this section in reporter ( method int prepareSection(String SectionName) ) you supplied number of section (returned from prepareSection). You can invoke prepareSection only in doSectionPrepare or in prepareSection event.

The section definition looks differ in differ formats. For example in RTF format REPORT_HEADER section definition looks like:

 #BEGIN SECTION 'REPORT HEADER'
    ...
 #END SECTION 'REPORT HEADER'
 

The same in HTML format:

 <!-- { #BEGIN SECTION \lquote REPORT HEADER\rquote } -->
    ...
 <!-- { #END SECTION \lquote REPORT HEADER\rquote } -->
 

And for TXT format:

 { #BEGIN SECTION \lquote REPORT HEADER\rquote }
    ...
 { #END SECTION \lquote REPORT HEADER\rquote }
 

Two special sections (FILE_HEADER and FILE_FOOTER) is needed for define work area in blank where dispose all other sections.

The FILE_HEADER section is part of blank from begining of the blank file to the definition:

 #BEGIN VKREPORT
 

And the FILE_FOOTER section is part of blank from

 #END VKREPORT
 
to the end of blank file.

In that way, if we are view (for example) RTF blank in low level, in text editor as a text file we can see the follow:


 begin of blank file
       |       | {\rtf1\ ...
       |file   | ...
       |header | {... #BEGIN VKREPORT ...}
       |
       |         ...
       |
       |       | {... #BEGIN SECTION \lquote REPORT HEADER\rquote ... }
       |report |   ...
       |header | {... #END SECTION \lquote REPORT HEADER\rquote ... }
       |
       |       | {... #BEGIN SECTION \lquote BODY\rquote ... }
 blank |body   |   ...
 file  |       | {... #END SECTION \lquote BODY\rquote ... }
       |
       |       | {... #BEGIN SECTION \lquote REPORT FOOTER\rquote ... }
       |report |   ...
       |footer | {... #END SECTION \lquote REPORT FOOTER\rquote ... }
       |
       |         ...
       |
       |file   | {... #END VKREPORT ... }
       |footer | }
 end of blank file

 

Properly speaking, all reporter to do is only copy sections from input blank to the output report according the following schema:


   copy FILE_HEADER (always)
   copy REPORT_HEADER (try always)
     doMoveTop  //move your data source to the top
     loop ( not end of your data source )
       copy GROUP_HEADER
       copy SUBGROUP_HEADER
       copy SUBSUBGROUP_HEADER
       copy SUPERSUBGROUP_HEADER
       copy BODY (try always)
       copy SUPERSUBGROUP_FOOTER
       copy SUBSUBGROUP_FOOTER
       copy SUBGROUP_FOOTER
       copy GROUP_FOOTER
       doMoveNext //move your data source to the next row
     end loop
   copy REPORT_FOOTER (try always)
   copy FILE_FOOTER (always)

 

Process of copy any section is accompany following events:


   doSectionBegin            //notify event
   doSectionCheck            //qury event to ask copy section or not
   if SectionCheck == true then
     copy content of section with query data from your data source
     doSectionComplete       //notify event
   end if
   doSectionEnd              //notify event

 

As you see, you can define in program youself when to copy section exactly (group sections should copy only for definite condition).

The data for report is supplied by mark. There are two types of marks: mark by name and mark by number.

Mark by name looks like:

   ...
   ~field_name1~    ~field_name2~  ....
   ...
 

Mark by number looks like:

   ...
   @0001    @0002  ....
   ...
 

When reporter copy section and determinate data request mark (by name or by numbar) it fire event for delivery data. Your programm should handle this event and return data corresponding to mark.

The navigation within data source realize throw two events: onMoveTop and onMoveNext.

Create blank for you report.

Create blank process include 2 steps in general. First - edit blank in high level tools, such as WordPard, WinWord, FronPage and so on.

The second step is needed for correct defects in blank after high level tools and it happens in low level tools like a simple text editor.

Blank for RTF format.

High level.

Open WinWord. Define work area to type #BEGIN VKREPORT at begin and #END VKREPORT at end.

I usually to set of blue color for #BEGIN VKREPORT and #END VKREPORT.

Between #BEGIN VKREPORT and #END VKREPORT define any report sections with data request mark within section. Any section start with #BEGIN SECTION 'SECTION NAME' and end of #END SECTION 'SECTION NAME'. Tag #BEGIN SECTION I usually set to green color and tag #END SECTION set to gray color. The color set is needed for correct compound VK Report tag within a RTF tag.

You can apply any formating text, paragraph. Use tables, lists and any ather features RTF format - these all available for you reports.

Low level.

This step is needed because WinWord may mix VK Report control tags within RTF control tags and VK Reports can not find these. Perceive this step like instraction:

Blank for HTML format.

High level.

In any high level tools (Macromedia Dreamweaver MX, MS FronPage, and so on ...) design your report blank. You should segregate report sections from each other and keep it mind when you design report blank. You can use any HTML features in your blank without limitations.

Low level.

In this step you should insert VK Reports tags in your HTML blank by hands in any simple text editor. The VK Reports tags for HTML is the same for RTF and looks like:

 < begin of your HTML report blank >
     ...
 < !-- { #BEGIN VKREPORT } -- >
 < !-- { #BEGIN SECTION \lquote REPORT HEADER\rquote } -- >
     ... @0001  ... @0002 ...
 < !-- { #END SECTION \lquote REPORT HEADER\rquote } -- >
     ...
 < other sections >
     ...
 < !-- { #BEGIN SECTION \lquote BODY\rquote } -- >
     ... @0001  ... @0002 ...
 < !-- { #END SECTION \lquote BODY\rquote } -- >
     ...
 < other sections >
     ...
 < !-- { #BEGIN SECTION \lquote REPORT FOOTER\rquote }  -- >
     ... @0001  ... @0002 ...
 < !-- { #END SECTION \lquote REPORT FOOTER\rquote }  -- >
 < !-- { #END VKREPORT } -- >
     ...
 < end of your HTML report blank >

 
As you see VK Reports tags design as HTML remarks with RTF tags inside for compatibility between these formats.

Blank for TXT format.

To make TXT report blank you should do the same that you do for HTML. (It clear - HTML is the text...). But VK Reports tags is not be HTML remarks. It looks like:

 < begin of your TXT report blank >
     ...
 { #BEGIN VKREPORT }
 { #BEGIN SECTION \lquote REPORT HEADER\rquote }
     ... @0001  ... @0002 ...
 { #END SECTION \lquote REPORT HEADER\rquote }
     ...
 < other sections >
     ...
 { #BEGIN SECTION \lquote BODY\rquote }
     ... @0001  ... @0002 ...
 { #END SECTION \lquote BODY\rquote }
     ...
 < other sections >
     ...
 { #BEGIN SECTION \lquote REPORT FOOTER\rquote }
     ... @0001  ... @0002 ...
 { #END SECTION \lquote REPORT FOOTER\rquote }
 { #END VKREPORT }
     ...
 < end of your HTML report blank >

 

Copyright: Copyright (c) 2003

Company:

Version:
1.0
Author:
Vlad Karpov
See Also:
TReportAbstract, Serialized Form

Nested Class Summary
 
Nested classes inherited from class VKRep.TReportAbstract
TReportAbstract.BOutStream, TReportAbstract.TBiffRec, TReportAbstract.TBiffRecHeader, TReportAbstract.TSection
 
Field Summary
 
Fields inherited from class VKRep.TReportAbstract
blankInputStream, BODY, BOutStreamA, BOutStreamB, charByName, charByNum, FILE_FOOTER, FILE_HEADER, GROUP_FOOTER, GROUP_HEADER, inputBlank, inputBuffer, LAST_DYN_SECTION, lastDynSection, listener, MAX_LABEL_NAME_LEGTH, MAX_SECTION_NUM, offsetXLSInput, outCase, outputBuffer, outputBufferCount, outputReport, realInputBlankLength, REPORT_FOOTER, REPORT_HEADER, reportOutStream, REQUEST_DATA_BY_NAME_SYMBOL, REQUEST_DATA_BY_NUM_SYMBOL, rptEvent, RTF_SECTION_BEGIN_BREAKED, RTF_SECTION_END_BREAKED, sections, STREAM_BUFFER_SIZE, streamBufferSize, SUBGROUP_FOOTER, SUBGROUP_HEADER, SUBSUBGROUP_FOOTER, SUBSUBGROUP_HEADER, SUPERSUBGROUP_FOOTER, SUPERSUBGROUP_HEADER, XLSBlank, XLSBool, XLSCOL, XLSDimension, XLSLabel, XLSNumber, XLSRK, XLSRow
 
Constructor Summary
TWordReport()
           
 
Method Summary
private  int findTag(java.lang.String tag)
           
protected  void outSectionInternal(int SectionNum, boolean defaultOut)
          Abstract method for override in inheritance classes for output report section.
protected  boolean prepareFileFooter()
          Abstract method for override in inheritance classes for parse file footer section.
protected  boolean prepareFileHeader()
          Abstract method for override in inheritance classes for parse file header section.
protected  int prepareSectionInternal(java.lang.String SectionName, int SectionNum)
          Abstract method for override in inheritance classes for parse report section.
 
Methods inherited from class VKRep.TReportAbstract
addVKRepListener, ass2Number, byteAsShort, clearSections, clearVars, closeInputStream, closeOutBuffer, closeOutputStream, doDataRequest, doEndReport, doMoveNext, doMoveTop, doReportError, doRequestByName, doRequestByNum, doSectionBegin, doSectionCheck, doSectionComplete, doSectionEnd, doSectionPrepare, doStartReport, execute, exp2, fireDataRequest, fireEndReport, fireMoveNext, fireMoveTop, fireReportError, fireRequestByName, fireRequestByNum, fireSectionBegin, fireSectionCheck, fireSectionComplete, fireSectionEnd, fireSectionPrepare, fireStartReport, flushOutBuffer, getBlankInputStream, getBytes, getCharByName, getCharByNum, getInputBlank, getInt, getListener, getLong, getOutputReport, getReportOutStream, getShort, getShort, getStreamBufferSize, isInt, openInputStream, openOutputStream, outByte, outBytes, outBytes, outDouble, outInteger, outSection, outSection, outShort, outShorts, outSpecial, outVariant, outXLSDouble, prepareSection, removeAllBlanks, removeVKRepListener, run, setBlankInputStream, setCharByName, setCharByNum, setInputBlank, setListener, setOutputReport, setReportOutStream, setShort, setStreamBufferSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TWordReport

public TWordReport()
Method Detail

outSectionInternal

protected void outSectionInternal(int SectionNum,
                                  boolean defaultOut)
Description copied from class: TReportAbstract
Abstract method for override in inheritance classes for output report section. For different formats (RTF, HTML, XLS4) this methos should do different work.

Specified by:
outSectionInternal in class TReportAbstract
Parameters:
SectionNum - section number for out.
defaultOut - default logic value means outed it by default or not.

prepareFileHeader

protected boolean prepareFileHeader()
Description copied from class: TReportAbstract
Abstract method for override in inheritance classes for parse file header section. For different formats (RTF, HTML, XLS4) this methos should do different work.

Specified by:
prepareFileHeader in class TReportAbstract
Returns:
success of operation.

prepareFileFooter

protected boolean prepareFileFooter()
Description copied from class: TReportAbstract
Abstract method for override in inheritance classes for parse file footer section. For different formats (RTF, HTML, XLS4) this methos should do different work.

Specified by:
prepareFileFooter in class TReportAbstract
Returns:
success of operation.

prepareSectionInternal

protected int prepareSectionInternal(java.lang.String SectionName,
                                     int SectionNum)
Description copied from class: TReportAbstract
Abstract method for override in inheritance classes for parse report section. For different formats (RTF, HTML, XLS4) this methos should do different work.

Specified by:
prepareSectionInternal in class TReportAbstract
Parameters:
SectionName - section name for prepare.
SectionNum - section number for prepare.
Returns:
section number.

findTag

private int findTag(java.lang.String tag)