home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / fmlistcong.tcl < prev    next >
Text File  |  1997-04-10  |  5KB  |  186 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Westmount Technology    1994
  4. #
  5. #      File:           @(#)fmlistcong.tcl    /main/hindenburg/2
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)fmlistcong.tcl    /main/hindenburg/2   10 Apr 1997 Copyright 1994 Westmount Technology
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require "fmcongen.tcl"
  15.  
  16. Class FmListConGen : {FmConGen} {
  17.     constructor
  18.     method destructor
  19.     method generate
  20.     method genTextLine
  21.     method genTitle
  22.     method makeReport
  23.     attribute frames
  24.     attribute pgfs
  25.     attribute chapter
  26. }
  27.  
  28. constructor FmListConGen {class this name section} {
  29.     set this [FmConGen::constructor $class $this $name $section]
  30.     # Start constructor user section
  31.  
  32.     # this is not a type-tied generator, so adjust the type
  33.     # part of the tempate name
  34.     set version [[[[$this section] document] editor] version]
  35.     $this templatePath [m4_path_name etc fm${version}doc.mif]
  36.  
  37.     # End constructor user section
  38.     return $this
  39. }
  40.  
  41. method FmListConGen::destructor {this} {
  42.     # Start destructor user section
  43.     # End destructor user section
  44.     $this FmConGen::destructor
  45. }
  46.  
  47. method FmListConGen::generate {this} {
  48.  
  49.     # First the contents is generated in a section. This sections
  50.     # is put in a MIF-file by expanding the template MIF-file
  51.     # '<name><version>.mif'. This file contains expandable TCL-
  52.     # macro's to include the contents of the section.
  53.     # Furthermore the template MIF-file contains a macro to include the
  54.     # title of the document using 'FmListConGen::genTitle'.
  55.  
  56.     set mifFid [$this openMif]
  57.  
  58.     # check first if output file can be opened
  59.     if {$mifFid == ""} {
  60.         return
  61.     }
  62.  
  63.     # get the parent (chapter) if the current section
  64.     $this chapter [[$this section] parentSection]
  65.     if { [$this chapter] == "" } {
  66.         return
  67.     }
  68.  
  69.     # Create the sections to be filled in into the MIF-template
  70.     $this frames [TextSection new]
  71.     $this pgfs [TextSection new]
  72.  
  73.     $this makeReport
  74.  
  75.     # make the Framemaker file
  76.     set contents [TextSection new]
  77.  
  78.     # need to do this, otherwise pgfs is removed ???????
  79.     set pgfs [$this pgfs]
  80.     expand_file $contents [$this templatePath]
  81.  
  82.     # Write the contents into the MIF-file
  83.     $contents write $mifFid
  84.     close $mifFid
  85.  
  86.     $this mif2Bin
  87. }
  88.  
  89. method FmListConGen::genTextLine {this line} {
  90.  
  91.     # Generate a paragraph-line, within the global paragraphs-section
  92.  
  93.     [$this pgfs] append "    <ParaLine\n"
  94.     [$this pgfs] append "      <String `[[$this section] escapeText $line]'>\n"
  95.     [$this pgfs] append "      <Char HardReturn>\n"
  96.     [$this pgfs] append "    >\n"
  97. }
  98.  
  99. method FmListConGen::genTitle {this textRectID} {
  100.  
  101.     # Get the level of the section. 
  102.     # This determines the kind of title
  103.     set level [[$this section] indentation]
  104.  
  105.     # Determine the kind of title, i.e. the paragraph-tag
  106.     case $level {
  107.         {0 1}    {set tag Chapter}
  108.         {2}    {set tag Section}
  109.         {3}    {set tag SubSection}
  110.         {4}    {set tag SubSubSection}
  111.         default    {return ""}
  112.     }
  113.  
  114.     # Check if the section is the first one of this level 
  115.     # within the upper level. If so then use the paragraph-tag 
  116.     # extended with '1', to make the number starting at the beginning.
  117.     set extension 1
  118.  
  119.     set parent [[$this section] parentSection]
  120.     if { $parent == "" } {
  121.         return ""
  122.     }
  123.  
  124.     set brothers [$parent childSectionSet]
  125.     
  126.     # only if it's the first the extension is 1
  127.     if {[$this section] == [$brothers index]} {
  128.         set extension 1
  129.     } else {
  130.         set extension ""
  131.     }
  132.  
  133.     # Make a section for the title
  134.     set title [TextSection new]
  135.  
  136.     # Fill the section with the paragraph that defined the complete title
  137.     $title append "  <Para\n"
  138.     $title append "    <PgfTag `$tag$extension'>\n"
  139.     $title append "    <ParaLine\n"
  140.     $title append "      <TextRectID $textRectID>\n"
  141.     $title append "      <String `[[$this section] escapeText [[$this section] docTitle]]'>\n"
  142.     $title append "    >\n"
  143.     $title append "  >\n"
  144.  
  145.     # Return the contents of the title-section to be filled in into 
  146.     # the template
  147.     return [$title contents]
  148. }
  149.  
  150. method FmListConGen::makeReport {this} {
  151.  
  152.     # Start the paragraph
  153.     [$this pgfs] append "  <Para\n"
  154.     [$this pgfs] append "    <PgfTag `Reports'>\n"
  155.  
  156.     # get all the cad_classes and cad_containers from the 
  157.     # documented system
  158.     foreach file [[[[$this section] document] documentedSystem] localFileVersions] {
  159.         if {[[$file file] type] != "cad"} {
  160.             continue
  161.         }
  162.         set fileName [[$file file] name]
  163.         $this genTextLine $fileName
  164.         foreach comp [$file components] {
  165.             if { [$comp type] == "cad_class" || \
  166.                  [$comp type] == "cad_container"} {
  167.                 set name ""
  168.                 foreach label [$comp labels] {
  169.                     if {[$label type] == "name"} {
  170.                         set name [$label value]
  171.                     }
  172.                 }
  173.                 if {$name != ""} {
  174.                     $this genTextLine "   -$name"
  175.                 }
  176.             }
  177.         }
  178.     }
  179.  
  180.     # Finish the paragraph
  181.     [$this pgfs] append "  >\n"
  182. }
  183.  
  184. # Do not delete this line -- regeneration end marker
  185.  
  186.