File: annotations.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (205 lines) | stat: -rw-r--r-- 5,489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "wv.h"

extern FILE *erroroutput;
extern FILE *outputfile;
extern long int cp;
extern long int realcp;
extern int insuper;

ATRD *key_atrd;

void decode_annotation(textportions *portions)
	{
	U32 i,j,val;
	/*
	search in the first thing for the cp of this
	reference.
	*/
	i=0;
	while(i<portions->andref_no)
		{
		if (portions->andRef[i] == (U32)cp)
			{
			error(erroroutput,"found correct anno ref pos at %x, index was %d\n",portions->andRef[i],i);
			if (!insuper)
				fprintf(outputfile,"<sup>");
			fprintf(outputfile,"<a href=\"#");
			j = portions->the_atrd[i].xstUsrInitl[0];
			val = portions->the_atrd[i].xstUsrInitl[0]+1;
			for (j=1;j<val;j++)
                    {
                    /*warning despite the possibility of being 16 bit nos ive done this*/
                    fprintf(outputfile,"%c",portions->the_atrd[i].xstUsrInitl[j]);
                    }
			fprintf(outputfile,"%d\">[",i);
			j = portions->the_atrd[i].xstUsrInitl[0];
			val = portions->the_atrd[i].xstUsrInitl[0]+1;
			key_atrd[portions->the_atrd[i].ibst].xstUsrInitl[0] = j;
			key_atrd[portions->the_atrd[i].ibst].ibst = portions->the_atrd[i].ibst;
			for (j=1;j<val;j++)
                    {
                    /*warning despite the possibility of being 16 bit nos ive done this*/
                    fprintf(outputfile,"%c",portions->the_atrd[i].xstUsrInitl[j]);
					key_atrd[portions->the_atrd[i].ibst].xstUsrInitl[j] = portions->the_atrd[i].xstUsrInitl[j];
                    }
			fprintf(outputfile,"%d]</a>",i+1);

			if (!insuper)
				fprintf(outputfile,"</sup>");
			break;
			}
		i++;
		}

	/*part deux*/
	/*
	now to hold off to the very end any spray them all out, or at the end of every page.
	ill do the latter for the moment
	*/
	if ( (i < portions->andref_no ) && (i < 256) )
		portions->list_annotations[portions->list_anno_no++] = i;
	else if (i >= 256)
		fprintf(erroroutput,"oops silly programmer :-) lost an annotation\n");
	}

#if 0
Xst *extract_authors(FILE *tablefd,U32 fcGrpXstAtnOwners,U32 lcbGrpXstAtnOwners)
	{
	U16 len,i;
	U32 count=0;
	Xst *authorlist=NULL;
	Xst *current=NULL;


	if (lcbGrpXstAtnOwners > 0)
		{
		fprintf(stderr,"offset is %x\n",fcGrpXstAtnOwners);
		fseek(tablefd,fcGrpXstAtnOwners,SEEK_SET);
		authorlist = (Xst*) malloc(sizeof(Xst));

		if (authorlist == NULL)
			{
			fprintf(erroroutput,"not enough mem for annotation group\n");
			return(NULL);
			}

		authorlist->next = NULL;
		authorlist->u16string = NULL;
		authorlist->noofstrings=0;
		current = authorlist;

		while (count < lcbGrpXstAtnOwners)
			{
			len = read_16ubit(tablefd);
			fprintf(stderr,"len is %d\n",len);
			count+=2;
			current->u16string = malloc((len+1) * sizeof(U16));
			authorlist->noofstrings++;
			if (current->u16string == NULL)
				{
				fprintf(erroroutput,"not enough mem for author string of len %d\n",len);
				break;
				}
			for (i=0;i<len;i++)
				{
				current->u16string[i] = read_16ubit(tablefd);
				fprintf(stderr,"char is %c\n",current->u16string[i]);
				count+=2;
				}
			current->u16string[i] = '\0';

			if (count < lcbGrpXstAtnOwners)
				{
				current->next= (Xst*) malloc(sizeof(Xst));
				if (current->next == NULL)
					{
					fprintf(erroroutput,"not enough mem for annotation group\n");
					break;
					}
				current = current->next;
				current->next = NULL;
				current->u16string = NULL;
				}
			}
		}
	return(authorlist);
	}
#endif


/*this finds the beginning of a annotation given a particular cp, adds
the beginning tag and returns the next annotation cp*/
U32 decode_b_annotation(bookmark_limits *l_bookmarks)
	{
	U32 i=0;
	while (i<l_bookmarks->bookmark_b_no)
		{
		if (l_bookmarks->bookmark_b_cps[i] == (U32)realcp)
			{
			l_bookmarks->bookmark_b_cps[i] = 0xffff;		/*mark it off the list*/
			fprintf(outputfile,"<a name=\"#an");
			/*
			fprintf(outputfile,"%x",sread_32ubit(bookmarks->extradata[i]+2));
			*/
			fprintf(outputfile,"%x",0x99);		/*i cant remember what i was at here, it was well wrong anyway, 
			i have to get this one right on my next pass through this part of the source*/
			fprintf(outputfile,"\">");
			fprintf(outputfile,"<img src=\"%s/doccommentb.jpg\">",patterndir());
			if (i == l_bookmarks->bookmark_b_no-1)
				return(0xffffffffL);
			else
				return(l_bookmarks->bookmark_b_cps[i+1]);
			}
		i++;
		}

	i=0;
	while (i<l_bookmarks->bookmark_b_no)
		{
		if ( (l_bookmarks->bookmark_b_cps[i] != 0xffff) && (l_bookmarks->bookmark_b_cps[i] > (U32)realcp))
			return(l_bookmarks->bookmark_b_cps[i]);
		i++;
		}

	if ((l_bookmarks->bookmark_b_no) > 0)
		return(l_bookmarks->bookmark_b_cps[0]);
		
	return(0xffffffffL);
	}

U32 decode_e_annotation(bookmark_limits *l_bookmarks)
	{
	U32 i=0;
	
	while (i<l_bookmarks->bookmark_e_no)
		{
		if (l_bookmarks->bookmark_e_cps[i] == (U32)realcp)
			{
			l_bookmarks->bookmark_e_cps[i] = 0xffff;		/*mark it off the list*/
			fprintf(outputfile,"</A>");
			fprintf(outputfile,"<img src=\"%s/doccommente.jpg\">",patterndir());
			if (i == l_bookmarks->bookmark_e_no-1)
				return(0xffffffffL);
			else
				return(l_bookmarks->bookmark_e_cps[i+1]);
			}
		i++;
		}

	i=0;
	while (i<l_bookmarks->bookmark_e_no)
		{
		if ((l_bookmarks->bookmark_e_cps[i] != 0xffff) && (l_bookmarks->bookmark_e_cps[i] > (U32)realcp))
			return(l_bookmarks->bookmark_e_cps[i]);
		i++;
		}
		
	if ((l_bookmarks->bookmark_e_no) > 0)
		return(l_bookmarks->bookmark_e_cps[0]);
		
	return(0xffffffffL);
	}