2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65
extern MN * main_number_ptr;
66
extern BOX * boxchain, *dl_last_in_chain;
68
extern WORD lpool_lth;
69
extern BYTE work_raster[];
70
//extern version * start_rec, * rec_ptr;
71
extern BYTE records_change;
73
static void boxes_to_line();
75
BOOL component_account()
77
if (boxes_account()) { boxes_to_line(); wcomp.type = 0; return TRUE; }
86
memset (&wcomp,0,sizeof(wcomp));
87
mn = main_number_ptr; bp = mn->mnfirstbox;
88
left = bp->boxleft; right = bp->boxright; boxchain = bp;
89
while ((bp = (dl_last_in_chain = bp)->boxnext) != NULL)
91
if (bp->boxleft < left) left = bp->boxleft;
92
if (bp->boxright > right) right = bp->boxright;
95
wcomp.upper = mn->mnupper; wcomp.left = left;
96
wcomp.h = mn->mnlower - mn->mnupper;
97
wcomp.rw = ((wcomp.w = right - left) + 7)/8;
98
wcomp.nl = mn->mnlines; wcomp.begs = mn->mnbegs; wcomp.ends = mn->mnends;
100
if (mn->mnflag & mnpicture) return FALSE;
101
if ((wcomp.w > RASTER_MAX_WIDTH) || (wcomp.h > RASTER_MAX_HEIGHT))
103
if (mn->mnboxcnt > great_box_count) return FALSE;
104
if (wcomp.nl < usual_box_count) return TRUE;
106
for (bp = boxchain, n=0; bp; bp = bp->boxnext)
108
if ((bp->boxflag & BOXBEG) == 0) continue;
109
if (bp->boxptr > sizeof(BOX) + sizeof(LNSTRT) + 2) {n++; continue;}
110
if ((bp->boxflag & (BOXFREEBEG + BOXFREEEND - BOXBEG - BOXEND)) == 0) n++;
112
if (n >= usual_box_count) return FALSE; else return TRUE;
115
static void boxes_to_line()
124
bp = boxchain; lnp = (lnhead *)lpool; goto enter_loop;
128
lsp = (LNSTRT *)(bp+1); lnp->row = lsp->y - wcomp.upper;
129
lnp->flg = bp->boxflag; ip = (interval *) (lnp+1);
130
ip->l = (BYTE)lsp->l; x = lsp->x - wcomp.left;
132
bip = (BOXINT *)(lsp+1);
133
n = (bp->boxptr - sizeof(BOX) - sizeof(LNSTRT))/sizeof(BOXINT);
137
ip->l = (BYTE)bip->l;
139
(ip++)->e = (BYTE)x ;
141
if ((bp->boxflag & BOXEND) == 0)
143
bp = bp->boxnext; bip = (BOXINT *)(bp+1);
144
n = (bp->boxptr - sizeof(BOX))/ sizeof(BOXINT); goto cont_box;
147
lnp->lth = (PBYTE)ip - (PBYTE)lnp;
148
lnp->h = (lnp->lth - sizeof(*lnp) - sizeof(*ip))/sizeof(*ip);
149
lnp->flg |= bp->boxflag; lnp = (lnhead *)ip;
150
if (bp != dl_last_in_chain) goto next_line;
152
lpool_lth = (PBYTE)lnp - lpool + sizeof (lnp->lth);
155
static BYTE make_fill[] = {0, 1, 3, 7, 15, 31, 63, 127, 255};
165
memset (work_raster,0,wcomp.rw*wcomp.h);
166
lp = (lnhead *)lpool;
169
pp = work_raster + lp->row * wcomp.rw; ip = (interval *) (lp+1);
170
while (x = ip->e, (l = (ip++)->l) != 0)
172
p = pp + (x>>3); sh = x & 7;
173
while (l > 8) { w = 0xff00 >> sh; *p |= w & 0xff; *(--p) |= w>>8; l-=8; }
174
w = make_fill[l]; w = w << (8-sh); *p |= w & 0xff; *(p-1) |= w >> 8;
183
PBYTE make_extended_raster(c_comp *cp)
191
memset (work_raster,0,cp->rw * cp->h); wd = cp->rw;
192
lp = (lnhead *)((PBYTE)cp + cp->lines + sizeof(DWORD));
195
pp = work_raster + lp->row * wd; ip = (large_interval *) (lp+1);
196
while (x = ip->e, (l = (ip++)->l) != 0)
198
p = pp + (x>>3); sh = x & 7;
199
while (l > 8) { w = 0xff00 >> sh; *p |= w & 0xff; *(--p) |= w>>8; l-=8; }
200
w = make_fill[l]; w = w << (8-sh); *p |= w & 0xff; *(p-1) |= w >> 8;
203
lp = (lnhead *)((PBYTE)ip - sizeof(WORD));
208
lnhead *c_boxln(MN *mn)
210
main_number_ptr = mn;
213
return (lnhead *)lpool;
216
INT MN_to_line(MN * mn)
218
main_number_ptr = mn;
225
WORD length_table[] = {0x100, 0x300, 0x700,0xf00,0x1f00,0x3f00,0x7f00,0xff00};
227
BYTE byte_seg_size[256] = {
228
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
229
0x00,0x18,0x17,0x28,0x16,0x00,0x27,0x38,0x15,0x00,0x00,0x00,0x26,0x00,0x37,0x48, // 0
230
0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x36,0x00,0x47,0x58, // 1
231
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 2
232
0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x00,0x00,0x00,0x46,0x00,0x57,0x68, // 3
233
0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 4
234
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 5
235
0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 6
236
0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x56,0x00,0x67,0x78, // 7
237
0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 8
238
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 9
239
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // a
240
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // b
241
0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // c
242
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // d
243
0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // e
244
0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x00,0x00,0x00,0x66,0x00,0x77,0x88 // f