3 * Copyright (C) 1998,1999 A.J. van Os
6 * Build, read and destroy a list of Word style information
14 /* Variables needed to write the Style Information List */
15 static style_desc_type
*pAnchor
= NULL
;
16 static style_desc_type
*pStyleLast
= NULL
;
17 /* Variable needed to read the Style Information List */
18 static style_desc_type
*pStyleCurrent
= NULL
;
22 * vDestroyStyleInfoList - destroy the Style Information List
25 vDestroyStyleInfoList(void)
27 style_desc_type
*pCurr
, *pNext
;
29 DBG_MSG("vDestroyStyleInfoList");
31 /* Free the Style Information List */
33 while (pCurr
!= NULL
) {
39 /* Reset all control variables */
42 } /* end of vDestroyStyleInfoList */
45 * ucChooseListCharacter - choose our list character
48 ucChooseListCharacter(unsigned char ucListType
, unsigned char ucListChar
)
50 if (isprint(ucListChar
)) {
53 if (ucListType
== LIST_BULLETS
) {
71 } /* end of ucChooseListCharacter */
74 * vAdd2StyleInfoList - Add an element to the Style Information List
77 vAdd2StyleInfoList(const style_block_type
*pStyleBlock
)
79 static BOOL bMustStore
= FALSE
;
80 style_desc_type
*pListMember
;
82 fail(pStyleBlock
== NULL
);
83 fail(pStyleBlock
->iOffset
< -1);
85 NO_DBG_MSG("bAdd2StyleInfoList");
87 if (pStyleBlock
->iOffset
< 0) {
91 switch (pStyleBlock
->ucStyle
) {
92 case 1: case 2: case 3:
93 case 4: case 5: case 6:
94 case 7: case 8: case 9:
95 /* These styles are the nine header levels */
98 if (pStyleBlock
->sLeftIndent
> 0 ||
99 pStyleBlock
->ucAlignment
!= 0x00 ||
104 * When reached here, the information is not useful to
105 * the current implementation, so we save memory by
111 NO_DBG_HEX(pStyleBlock
->iOffset
);
112 NO_DBG_DEC_C(pStyleBlock
->sLeftIndent
!= 0,
113 pStyleBlock
->sLeftIndent
);
114 NO_DBG_DEC_C(pStyleBlock
->sRightIndent
!= 0,
115 pStyleBlock
->sRightIndent
);
116 NO_DBG_DEC_C(pStyleBlock
->bInList
, pStyleBlock
->bInList
);
117 NO_DBG_DEC_C(pStyleBlock
->bUnmarked
, pStyleBlock
->bUnmarked
);
118 NO_DBG_DEC_C(pStyleBlock
->ucStyle
!= 0, pStyleBlock
->ucStyle
);
119 NO_DBG_DEC_C(pStyleBlock
->ucAlignment
!= 0, pStyleBlock
->ucAlignment
);
120 NO_DBG_DEC_C(pStyleBlock
->bInList
, pStyleBlock
->ucListType
);
121 NO_DBG_HEX_C(pStyleBlock
->bInList
, pStyleBlock
->ucListCharacter
);
124 * Always store the information about the paragraph
125 * following a member of a list.
127 bMustStore
= pStyleBlock
->bInList
;
129 if (pStyleLast
!= NULL
&&
130 pStyleLast
->tInfo
.iOffset
== pStyleBlock
->iOffset
) {
132 * If two consecutive styles share the same
133 * offset, remember only the last style
135 fail(pStyleLast
->pNext
!= NULL
);
136 pStyleLast
->tInfo
= *pStyleBlock
;
140 /* Create list member */
141 pListMember
= xmalloc(sizeof(style_desc_type
));
142 /* Fill the list member */
143 pListMember
->tInfo
= *pStyleBlock
;
144 pListMember
->pNext
= NULL
;
145 /* Correct the values where needed */
146 if (pListMember
->tInfo
.sLeftIndent
< 0) {
147 pListMember
->tInfo
.sLeftIndent
= 0;
149 if (pListMember
->tInfo
.ucListLevel
> 8) {
150 pListMember
->tInfo
.ucListLevel
= 8;
152 pListMember
->tInfo
.ucListCharacter
=
153 ucChooseListCharacter(pListMember
->tInfo
.ucListType
,
154 pListMember
->tInfo
.ucListCharacter
);
155 /* Add the new member to the list */
156 if (pAnchor
== NULL
) {
157 pAnchor
= pListMember
;
158 pStyleCurrent
= pListMember
;
160 fail(pStyleLast
== NULL
);
161 pStyleLast
->pNext
= pListMember
;
163 pStyleLast
= pListMember
;
164 } /* end of vAdd2StyleInfoList */
167 * Get the next item in the Style Information List
169 const style_block_type
*
170 pGetNextStyleInfoListItem(void)
172 const style_block_type
*pItem
;
174 if (pStyleCurrent
== NULL
) {
177 pItem
= &pStyleCurrent
->tInfo
;
178 pStyleCurrent
= pStyleCurrent
->pNext
;
180 } /* end of pGetNextStyleInfoListItem */