3 * Copyright (C) 1998,1999 A.J. van Os
6 * Build, read and destroy a list of Word table-row information
14 * Privat structures to hide the way the information
15 * is stored from the rest of the program
17 typedef struct row_unique_tag
{
21 typedef struct row_common_tag
{
22 int iColumnWidthSum
; /* In twips */
23 short asColumnWidth
[TABLE_COLUMN_MAX
+1]; /* In twips */
24 unsigned char ucNumberOfColumns
;
26 typedef struct row_desc_tag
{
27 row_unique_type tUnique
;
28 row_common_type
*pCommon
;
29 struct row_desc_tag
*pNext
;
32 /* Variables needed to write the Row Information List */
33 static row_desc_type
*pAnchor
= NULL
;
34 static row_desc_type
*pRowLast
= NULL
;
35 /* Variable needed to read the Row Information List */
36 static row_desc_type
*pRowCurrent
= NULL
;
40 * vDestroyRowInfoList - destroy the Row Information List
43 vDestroyRowInfoList(void)
45 row_desc_type
*pCurr
, *pNext
;
47 DBG_MSG("vDestroyRowInfoList");
49 /* Free the Row Information List */
51 while (pCurr
!= NULL
) {
53 pCurr
->pCommon
= xfree(pCurr
->pCommon
);
58 /* Reset all control variables */
61 } /* end of vDestroyRowInfoList */
64 * vAdd2RowInfoList - Add an element to the Row Information List
67 vAdd2RowInfoList(const row_block_type
*pRowBlock
)
73 fail(pRowBlock
== NULL
);
75 NO_DBG_HEX(pRowBlock
->iOffset
);
76 NO_DBG_DEC(pRowBlock
->iLength
);
77 NO_DBG_DEC(pRowBlock
->ucNumberOfColumns
);
78 NO_DBG_DEC(pRowBlock
->iColumnWidthSum
);
80 /* Create the new list member */
81 pNew
= xmalloc(sizeof(row_desc_type
));
82 pNew
->pCommon
= xmalloc(sizeof(row_common_type
));
83 /* Fill the new list member */
84 pNew
->tUnique
.iOffsetStart
= pRowBlock
->iOffsetStart
;
85 pNew
->tUnique
.iOffsetEnd
= pRowBlock
->iOffsetEnd
;
86 pNew
->pCommon
->iColumnWidthSum
= pRowBlock
->iColumnWidthSum
;
87 (void)memcpy(pNew
->pCommon
->asColumnWidth
,
88 pRowBlock
->asColumnWidth
,
89 sizeof(pNew
->pCommon
->asColumnWidth
));
90 pNew
->pCommon
->ucNumberOfColumns
= pRowBlock
->ucNumberOfColumns
;
92 /* Correct the values where needed */
93 for (iIndex
= 0, psTmp
= pNew
->pCommon
->asColumnWidth
;
94 iIndex
< (int)pNew
->pCommon
->ucNumberOfColumns
;
98 DBG_MSG("The column width was negative");
101 /* Add the new member to the list */
102 if (pAnchor
== NULL
) {
106 fail(pRowLast
== NULL
);
107 pRowLast
->pNext
= pNew
;
110 } /* end of vAdd2RowInfoList */
113 * Get the next item in the Row Information List
116 bGetNextRowInfoListItem(row_block_type
*pItem
)
120 if (pItem
== NULL
|| pRowCurrent
== NULL
) {
123 /* Get the information */
124 pItem
->iOffsetStart
= pRowCurrent
->tUnique
.iOffsetStart
;
125 pItem
->iOffsetEnd
= pRowCurrent
->tUnique
.iOffsetEnd
;
126 pItem
->iColumnWidthSum
= pRowCurrent
->pCommon
->iColumnWidthSum
;
127 (void)memcpy(pItem
->asColumnWidth
,
128 pRowCurrent
->pCommon
->asColumnWidth
,
129 sizeof(pItem
->asColumnWidth
));
130 pItem
->ucNumberOfColumns
= pRowCurrent
->pCommon
->ucNumberOfColumns
;
131 /* Stand by for the next item in the list */
132 pRowCurrent
= pRowCurrent
->pNext
;
134 } /* end of bGetNextRowInfoListItem */