// Formatted Output Generator
//
// By Sergey V. Natarov (senatc@postman.ru)
// Date: 12/10-2003
//
// This package is a part of cWindowsEx Framework for Visual Dataflex
//
//
Class cOutputColorTbl Is an Array
Procedure Add_Color Integer iRed Integer iGreen Integer iBlue
Set Value Item (Item_Count(Self)+1) To ("\red"+String(iRed)+"\green"+String(iGreen)+"\blue"+String(iBlue)+";")
End_Procedure
Procedure Generate
Integer iItem iCount
Get Item_Count To iCount
Write "{\colortbl;"
For iItem From 1 To iCount
Write (Value(Self,iItem))
Loop
Writeln "}"
End_Procedure
End_Class // oColorTbl (Array)
Class cOutputFontTbl Is an Array
Procedure Add_Font String sFont
Set Value Item (Item_Count(Self)) To (Trim(sFont))
End_Procedure
Procedure Generate
Integer iItem iCount
Get Item_Count To iCount
Write "{\fonttbl"
For iItem From 0 To (iCount-1)
Write "{\f" iItem " " (Value(Self,iItem)) ";}"
Loop
Writeln "}"
End_Procedure
End_Class // oColorTbl (Array)
Class cFormattedOuptut Is an message
Procedure Construct_Object
Forward Send Construct_Object
Property String psGenerator Public "cWindowsEx Formatted Output"
Property String psAuthor Public "cWindowsEx Formatted Output"
Property String psProduct Public "cWindowsEx(TM)"
Property String psVersion Public "1.0.1"
Property String psCompany Public "Sergey V. Natarov (senatc@postman.ru)"
Property String psDocumentName Public "System Information"
// General
//DOC//PUBLIC//
// If this property set to True, then output into the RTF format,
// otherwise HTML format (default).
Property Boolean pbOutput Public 0
Property String psNoteString Public "Note."
Property String psTipString Public "Tip."
//
// Special Characters conversion
Property String psCopyRightChar Public "(C)"
Property String psRegisteredChar Public "(R)"
Property String psTradeMarkChar Public "(TM)"
Property Integer pbCopyRightChar Public True
Property Integer pbRegisteredChar Public True
Property Integer pbTradeMarkChar Public True
//
// Html Related
Property String psHtmlIndexFile Public "SysInfo.htm"
Property String psDefaultHtmlFile Public "noname.htm"
Property String psCharSet Public "iso-8859-1"
Property String psStyleSheet Public "SysInfo.css"
Property String psCSSNoteClass Public "Note"
Property String psCSSTipClass Public "Tip"
// Rtf related
Property String psRtfDocumentName Public "SysInfo.rtf"
Property String psRtfPaperWidth Public "11906"
Property String psRtfPaperHeight Public "16838"
Property String psRtfMarginLeft Public "1300"
Property String psRtfMarginRight Public "700"
Property String psRtfMarginTop Public "800"
Property String psRtfMarginBottom Public "850"
Property Integer pbPageNumbers Public True
//
// Index
Property Integer piIndex Public True
// Formats Index to N columns
Property Integer piIndexCol Public 3
// Index section title
Property String psIndex Public "Index"
// Index Header output mask
Property String psIndexHdr Public "\line - A -"
//
// TOC
Property Integer piToc Public True
Property String psToc Public "Table of contents"
//
// RTF formatting
Property Number pnFontSize Public 11
//
Object oColorTbl Is a cOutputColorTbl
Send Add_Color 0 0 0 // 1
Send Add_Color 0 0 255 // 2
Send Add_Color 0 255 255 // 3
Send Add_Color 0 255 0 // 4
Send Add_Color 255 0 255 // 5
Send Add_Color 255 0 0 // 6
Send Add_Color 255 255 0 // 7
Send Add_Color 255 255 255 // 8
Send Add_Color 0 0 128 // 9
Send Add_Color 0 128 128 // 10
Send Add_Color 0 128 0 // 11
Send Add_Color 128 0 128 // 12
Send Add_Color 128 0 0 // 13
Send Add_Color 128 128 0 // 14
Send Add_Color 128 128 128 // 15
Send Add_Color 192 192 192 // 16
Send Add_Color 51 51 153 // 17
Send Add_Color 220 220 220 // 18
Send Add_Color 255 102 0 // 19
Send Add_Color 176 7 32 // 20
Send Add_Color 85 85 85 // 21
End_Object
//
Object oFontTbl Is a cOutputFontTbl
Send Add_Font "Verdana" // Default
Send Add_Font "Times New Roman"
Send Add_Font "Tahoma"
Send Add_Font "Verdana"
Send Add_Font "\froman\fcharset2\fprq2 Symbol"
Send Add_Font "Courier New"
End_Object
//
End_Procedure // Construct_Object
Function mHelpPath For BaseClass Returns String
Local String sPath
get_Profile_string ("WorkSpaces\" + CURRENT$WORKSPACE) "HelpPath" To sPath
Move (Uppercase(Trim(sPath))) To sPath
Function_Return sPath
End_Function
Function FormatOutput String sType String sText Returns String
String sChar sTmp sKW sStr
If (pbCopyRightChar(Self)) Begin
Get psCopyRightChar To sChar
If (sType="RTF") Move (Replaces(sChar, sText, "{\'a9}")) To sText
Else Move (Replaces(sChar, sText, "©")) To sText
End
If (pbRegisteredChar(Self)) Begin
Get psRegisteredChar To sChar
If (sType="RTF") Move (Replaces(sChar, sText, "{\super \'ae}")) To sText
Else Move (Replaces(sChar, sText, "®")) To sText
End
If (pbTradeMarkChar(Self)) Begin
Get psTradeMarkChar To sChar
If (sType="RTF") Move (Replaces(sChar, sText, "{\super \'99}")) To sText
Else Move (Replaces(sChar, sText, "™")) To sText
End
If ((sText Contains "
" In sText Move (Replaces("
", sText, "\line ")) To sText
If ((sText Contains "")And(sText Contains "")) Begin
Move (Replaces("", sText, "{\b ")) To sText
Move (Replaces("", sText, "}")) To sText
End
If ((sText Contains "")And(sText Contains "")) Begin
Move (Replaces("", sText, "{\i ")) To sText
Move (Replaces("", sText, "}")) To sText
End
If ((sText Contains "")And(sText Contains "")) Begin
Move (Replaces("", sText, "{\ul ")) To sText
Move (Replaces("", sText, "}")) To sText
End
Function_Return sText
End_Function
//
// ****************************************************************
// ****************************************************************
// RTF Output
// ****************************************************************
// ****************************************************************
//
Procedure mRTFOutputHeader String sFile
Direct_Output sFile
// Header
Writeln "{\rtf1\ansi\deff0"
// Font Table
Send Generate To (oFontTbl(Self))
// Color Table
Send Generate To (oColorTbl(Self))
// Styles
Write "{\stylesheet"
Write "{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\fs" (String(pnFontSize(Self)*2)) "\cgrid \snext0 Normal;}"
Write "{\s1\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel0\adjustright\rin0\lin0\itap0 \b\f0\fs40\cf17\kerning32\cgrid \sbasedon0 \snext0 heading 1;}"
Write "{\s2\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel1\adjustright\rin0\lin0\itap0 \b\i\f0\fs32\cgrid \sbasedon0 \snext0 heading 2;}"
Write "{\s3\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel2\adjustright\rin0\lin0\itap0 \b\f0\fs28\cgrid \sbasedon0 \snext0 heading 3;}"
Write "{\s4\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel3\adjustright\rin0\lin0\itap0 \b\f0\fs26\kerning32\cgrid \sbasedon0 \snext0 heading 4;}"
Write "{\s5\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel4\adjustright\rin0\lin0\itap0 \b\i\f0\fs24\cgrid \sbasedon0 \snext0 heading 5;}"
Write "{\s6\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel5\adjustright\rin0\lin0\itap0 \b\f0\fs22\cgrid \sbasedon0 \snext0 heading 6;}"
Write "{\*\cs10 \additive \ssemihidden Default Paragraph Font;}"
Write "{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv "
Write "\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0}"
Write "{\*\cs12 \additive \ul\cf2 \sbasedon10 Hyperlink;}"
Write "{\s13\ql \li0\ri0\widctlpar\tqc\tx4677\tqr\tx9355\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\cgrid \sbasedon0 \snext13 footer;}"
Write "{\*\cs14 \additive \sbasedon10 Page Number;}"
Write "{\s15\ql \li0\ri0\widctlpar\tqc\tx4677\tqr\tx9355\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\cgrid \sbasedon0 \snext15 header;}"
Write "{\s16\ql \fi-220\li220\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin220\itap0 \f0\fs16 \sbasedon0 \snext0 \sautoupd \ssemihidden Index 1;}"
Writeln "}"
// Info
Writeln "{\*\generator " (psGenerator(Self)) ";}{\info"
Write "{\title " (psProduct(Self)) " v. " (psVersion(Self)) "}"
Write "{\author " (psAuthor(Self)) "}"
Write "{\operator " (psAuthor(Self)) "}"
Write "{\version1}"
Write "{\*\company " (psCompany(Self)) "}"
Writeln "}"
// Page properties
Write "\paperw" (psRtfPaperWidth(Self))
Write "\paperh" (psRtfPaperHeight(Self))
Write "\margl" (psRtfMarginLeft(Self))
Write "\margr" (psRtfMarginRight(Self))
Write "\margt" (psRtfMarginTop(Self))
Writeln "\margb" (psRtfMarginBottom(Self)) " "
Write "\widowctrl\noxlattoyen\expshrtn\dntblnsbdb\formshade\horzdoc\jexpand\viewkind1 "
Writeln "\htmautsp\nolnhtadjtbl\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\headery708\footery708\colsx708\sectlinegrid360\sectdefaultcl"
// Footer
If (pbPageNumbers(Self)) Begin
Write "{\footer \pard\plain \s13\ql \li0\ri-5\widctlpar\brdrt\brdrs\brdrw10\brsp20 \tqc\tx4677\tqr\tx9355\aspalpha\aspnum\faauto\adjustright\rin-5\lin0\itap0 "
Write "\fs20\cgrid "
Write "{\fs20 " (FormatOutput(Self,"RTF",psProduct(Self)*psVersion(Self)*psDocumentName(Self))) ", Page }"
Write "{\field{\*\fldinst {\cs14 PAGE }}"
Write "{\fldrslt {\cs14\noproof 1}}}"
Write "{\cs13 of }"
Write "{\field{\*\fldinst {\cs14 NUMPAGES }}"
Write "{\fldrslt {\cs14\noproof 1}}}"
Writeln "{\par}}"
End
Writeln
End_Procedure
Procedure mRTFOutputFooter
If (piIndex(Self)) Begin
Send mRtfOutputTag "RtfTag" "" "" "{\page}"
Send mRtfOutputTag "Title" "Header 1" (psIndex(Self)) ""
Writeln '{\pard\plain \par}{\pard\plain {\field{\*\fldinst { INDEX \\c "' (piIndexCol(Self)) '" \\z "1033" \\h "' (psIndexHdr(Self)) '"}}{\fldrslt ' (psIndex(Self)) ' field}}\par}'
End
If (piTOC(Self)) Begin
Send mRtfOutputTag "RtfTag" "" "" "{\page}"
Send mRtfOutputTag "Title" "Header 1" (psToc(Self)) ""
Writeln '{\pard\plain \par}{\pard\plain {\field{\*\fldinst { TOC \\o "1-6" \\h \\z \\u }}{\fldrslt ' (psToc(Self)) ' field}}\par}'
End
Writeln '}'
Close_Output
End_Procedure
Procedure mRtfTableOutput String sText
String sRow
Integer iRow
If (sText="") Procedure_Return
Move (Replace("
'+(psNoteString(Self))+' ') To sStartTag Move '
' To sEndTag End If (sStyle="PARAGRAPH") Begin Move '' To sStartTag Move '
' To sEndTag End If (sStyle="TIP") Begin Move (''+(psTipString(Self))+' ') To sStartTag Move '
' To sEndTag End // // Type If ((sType="FILE")And(sTag<>"")And(sTag Contains "\")And(sTag Contains ":")And(sTag Contains ".")) Begin If (Right(Uppercase(sTag),4)<>".RTF") Begin Direct_Input Channel 9 sTag If (Right(Uppercase(sTag),4)=".TXT") Writeln "" While (Not(seqeof)) Readln sLine Writeln sLine Loop If (Right(Uppercase(sTag),4)=".TXT") Writeln "" Close_Input Channel 9 End End If (sType="IMAGE") Begin If (sTag="") Move sText To sTag Write sStartTag Write sTag Writeln sEndTag End If (sType="HTMLTAG") Begin If ((sTag="")Or(Not(sTag Contains '<'))) Move sText To sTag If ((sTag<>"")And(sText<>"")) Move (sTag+sText) To sTag Writeln sTag End If (sType="TEXT") Begin If (sText="") Move sTag To sText Move (Replaces(Character(13)+Character(10)+Character(13)+Character(10), sText, ""+Character(13)+Character(10)+"
")) To sText Write sStartTag Write sText Writeln sEndTag End If (sType="TITLE") Begin If (sTag="") Move sText To sTag Write sStartTag Write sTag Writeln sEndTag End If (sType="LINK") Begin Write sStartTag Write '' sTag '' Writeln sEndTag End If (sType="LIST") Begin Writeln "