/* * Help Access Library * A Library to access the contents of Windows Help files. * * Copyright (C) 1995-2000 Bernd Herd, http://www.herdsoft.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* PTABLE.C ----------------------------------------- * @doc * * @module PTABLE.C | * topic Table enumeration * * Help Access Library Project. *-----------------------------------------------------*/ #include #include #include #include #include "hlpacces.h" #include "top.h" // ---------- Declare TL_TABLE Record Header(s) ---------- #pragma pack(1) typedef struct { BYTE CellCount; // count of Cells in this Row BYTE CellFormat; // 0x01: Fixed Table, 0x00: Zoomable Table } PACKED TOPICTABLEHEADER, FAR *LPTOPICTABLEHEADER; // ---------- One Tab Cell Position ---------------------- typedef struct { LEWORD CellWidth; LEWORD CellLeftOffset; } PACKED TOPICCELLHEADER, FAR *LPTOPICCELLHEADER; // ------------------------------------------------------- typedef struct { BYTE CellNo; // 00 in First Cell, 01 in Second ... BYTE Zero; BYTE One; BYTE DoubleLength; BYTE EightZero; } PACKED TOPICCELLFORMAT, FAR *LPTOPICCELLFORMAT; #pragma pack() /* RtfTopicTable -----------------------------------------------* * Convert a TL_TABLE - Type Record. * *--------------------------------------------------------------*/ void iTopicTable( HTOPIC topic, TOPICENUMPROC fnenum, LPARAM lParam, LPCSTR String, UINT Length, BYTE *FormatData, UINT FormatLength, DWORD TopicOffset, BOOL InNonScrollingRegion) { LPTOPICTABLEHEADER Table = ( (LPTOPICTABLEHEADER) FormatData) ++; LPTOPICCELLHEADER CellHeaders = (LPTOPICCELLHEADER) FormatData; BOOL AutoSize = FALSE; UINT MinSize; LPTOPICCELLFORMAT CellFormat; LEWORD FAR * lpleWord; int CellCount = Table->CellCount, CellNo, GapH=0, CurrentCell, CurrentX; LPSTR ptemp; HLPTRACE(("CellCount:%d\n", CellCount)); # if DEBUG if (Table->CellFormat != 0x01) HLPTRACE(("Warning: Table->CellFormat: 0x%02X\n", Table->CellFormat)); # endif // ------- Create RTF Table-Header ----------------------- iFormatString(topic, fnenum, lParam, "{\\pard\\trowd\\intbl"); switch (Table->CellFormat) { case 0x03: case 0x01: // ------------- Fixed Cells ----------------------------- FormatData += CellCount * sizeof(TOPICCELLHEADER); FormatLength -= sizeof(TOPICTABLEHEADER) + CellCount * sizeof(TOPICCELLHEADER); if (CellCount>1) { GapH = leword(CellHeaders[1].CellLeftOffset); iFormatString(topic, fnenum, lParam, "\\trgaph%d0", GapH); } CurrentX=leword(CellHeaders[0].CellLeftOffset) - GapH/2; iFormatString(topic, fnenum, lParam, "\\trleft%d0", CurrentX - GapH/2); // ------- Set Cell Width... ----------------------------- for (CurrentCell=0; CurrentCellCellFormat==0x1 ? CurrentX*10 : CurrentX); } break; case 0x02: /* Occured in trtf msdncd16.mvb 8a330cf4 */ iFormatString(topic, fnenum, lParam, "\\trqc"); MinSize = leword(*((LEWORD FAR *) CellHeaders)); ((LPWORD)CellHeaders)++; FormatData += 2; FormatLength -= 2; for (CurrentCell=0, lpleWord = ((LEWORD FAR *) CellHeaders); CurrentCellb1 = wNewVal & 0xff; lpleWord->b2 = wNewVal >>8; } // ------------- Fixed Cells ----------------------------- FormatData += CellCount * sizeof(TOPICCELLHEADER); FormatLength -= sizeof(TOPICTABLEHEADER) + CellCount * sizeof(TOPICCELLHEADER); if (CellCount>1) { GapH = leword(CellHeaders[1].CellLeftOffset); iFormatString(topic, fnenum, lParam, "\\trgaph%d0", GapH/10); } CurrentX=leword(CellHeaders[0].CellLeftOffset) - GapH/2; iFormatString(topic, fnenum, lParam, "\\trleft%d0", (CurrentX - GapH/2)/10); // ------- Set Cell Width... ----------------------------- for (CurrentCell=0; CurrentCellb1 = wNewVal & 0xff; lpleWord->b2 = wNewVal >>8; } // ------------- Fixed Cells ----------------------------- FormatData += CellCount * sizeof(TOPICCELLHEADER); FormatLength -= sizeof(TOPICTABLEHEADER) + CellCount * sizeof(TOPICCELLHEADER); if (CellCount>1) { GapH = leword(CellHeaders[1].CellLeftOffset); iFormatString(topic, fnenum, lParam, "\\trgaph%d0", GapH); } CurrentX=leword(CellHeaders[0].CellLeftOffset) - GapH/2; iFormatString(topic, fnenum, lParam, "\\trleft%d0", CurrentX - GapH/2); // ------- Set Cell Width... ----------------------------- for (CurrentCell=0; CurrentCellCellNosizeof(TOPICCELLFORMAT)+sizeof(FORMAT)+1 && *FormatData!=0xff) { // --- Mark Cell End ------------------------------------- if (CurrentCell != (CellNo=CellFormat->CellNo)) { CurrentCell = CellNo; iFormatString(topic, fnenum, lParam, "\\cell "); ptemp="\t"; iTopicString (topic, fnenum, lParam, &ptemp, NULL, TOPIC_TEXT_CONTROL); } // --- Get Cell Format ------------------------------- // CellFormat = ((LPTOPICCELLFORMAT) FormatData)++; FormatLength -= sizeof(TOPICCELLFORMAT); // --- Trace Infos --------------------------------------- HLPTRACE(("CurrentCell:%d CellNo:%d\n", CurrentCell, CellFormat->CellNo)); // --- Transfer Paragraph Data ----------------------- iTopicParagraph(topic, fnenum, lParam, &String, &Length, &FormatData, &FormatLength, TopicOffset, InNonScrollingRegion, TRUE); } // -------- Normal Text Follows. ------------------------- iFormatString(topic, fnenum, lParam, "\\cell\\row\\pard}"); ptemp="\n"; iTopicString (topic, fnenum, lParam, &ptemp, NULL, TOPIC_TEXT_CONTROL); }