~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/usage/line_vp_util.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
Import upstream version 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1993-2008, Cognitive Technologies
 
3
All rights reserved.
 
4
 
 
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
 
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
 
7
 
 
8
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
 
9
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
 
10
        ����� �� ��������.
 
11
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
 
12
        ������ ����������, ������������ ��� ���������������, ������ �����������
 
13
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
 
14
        ����������� ����� �� ��������.
 
15
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
 
16
        ���� ������������ � �������� �������� ��������� �/��� �����������
 
17
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
 
18
        ����������.
 
19
 
 
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
 
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
 
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
 
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
 
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
 
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
 
26
������������� ������, ��������� � �������������� ��� ���������� ����������
 
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
 
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
 
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
 
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
 
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
32
 
 
33
Redistribution and use in source and binary forms, with or without modification,
 
34
are permitted provided that the following conditions are met:
 
35
 
 
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.
 
44
 
 
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.
 
55
*/
 
56
 
 
57
/**********  ���������  **********/
 
58
/*  �����      :  ��������� ��������                                          */
 
59
/*  ��������   :  12.03.01                                                    */
 
60
/*  ����       :  'Util_Line_VP.CPP'                                          */
 
61
/*  ���������� :  ����� ������ � ������� ������� LNS.                         */
 
62
/*  ���������� :  ������������ �����/������ (� ��������������� ������� � ���).*/
 
63
/*----------------------------------------------------------------------------*/
 
64
#include <stdio.h>
 
65
#include <math.h>
 
66
#include <stdlib.h>
 
67
/*#include <windows.h>*/
 
68
/*  interface our-other  */
 
69
#include "cpage.h"
 
70
#include "cline.h"
 
71
#include "lnsdefs.h"
 
72
#include "rline.h"
 
73
/*  interface my        */
 
74
#include "un_err.h"
 
75
#include "am_comm.h"
 
76
 
 
77
#ifdef Almi
 
78
#include "FT_Rule.H"
 
79
#endif
 
80
 
 
81
#include "markdatadefs.h"
 
82
/*  interface my-my      */
 
83
#include "un_buff.h"
 
84
#include "line_vp_util.h" //own functions
 
85
#include "puma_err.h"
 
86
/*----------------------------------------------------------------------------*/
 
87
/* JussiP: this function is never called and the signature clashes with
 
88
 * the next one with the same name.
 
89
 */
 
90
#if 0
 
91
Bool LoadLinesVP_rv (Handle hC, int Type, void *vB, char *pStr, Word16 *pCode)
 
92
{
 
93
        Bool ret;
 
94
        Word32 KeyHor, KeyVer; //// � ����� ���� �� ���������!
 
95
        int CntHor, CntVer;
 
96
        UN_BUFF *pB;
 
97
        pB = (UN_BUFF *)vB;
 
98
        switch ((UN_LOADDATA)Type)
 
99
        {
 
100
                case UN_LD_LinesVP :
 
101
                        /***  ����� ���������� � ������  ***/
 
102
                        ret = LoadLinesTotalInfo_rv (hC, vB, pStr); //f-t-e-d
 
103
                        if (ret!=RV_TRUE)
 
104
                        {
 
105
                                if (ret==RV_FALSE)
 
106
                                        Error_CPage_Code (pCode);
 
107
                                if (ret==RV_DOUBT)
 
108
                                        Error_MyNoMem_Code (pCode);
 
109
                                return ret;
 
110
                        }
 
111
                        ret = GetSomeKeys_rv (vB, &KeyHor, &KeyVer, &CntHor, &CntVer, pStr); //t-e-d
 
112
                        if (ret==RV_DOUBT)
 
113
                        {
 
114
                                Error_MyNoMem_Code (pCode);
 
115
                        }
 
116
                        if (ret!=RV_TRUE)
 
117
                        {
 
118
                                CleanLastDataPart (vB);
 
119
                                return ret;
 
120
                        }
 
121
                        /***  �������������� �����  ***/
 
122
                        if (CntHor>0)
 
123
                        {
 
124
                                ret = LoadLinesSpecInfo (hC, vB, KeyHor, CntHor);
 
125
                                pB->AimPart[pB->nPart-1] = UN_DA_Hori;
 
126
                                if (!ret)
 
127
                                {
 
128
                                        Error_CPage_Code (pCode);
 
129
                                        return ret;
 
130
                                }
 
131
                        }
 
132
                        /***  ������������ �����  ***/
 
133
                        if (CntVer>0)
 
134
                        {
 
135
                                ret = LoadLinesSpecInfo (hC, vB, KeyVer, CntVer);
 
136
                                pB->AimPart[pB->nPart-1] = UN_DA_Vert;
 
137
                                if (!ret)
 
138
                                {
 
139
                                        Error_CPage_Code (pCode);
 
140
                                }
 
141
                                return ret;
 
142
                        }
 
143
                        return RV_TRUE;
 
144
                default :
 
145
                        return RV_FALSE;
 
146
        }
 
147
}
 
148
#endif
 
149
/*---------------------------------------------------------------------------*/
 
150
Bool LoadLinesVP_rv (CLINE_handle hC, int Type, void *vB, char *pStr, Word16 *pCode)
 
151
{
 
152
        Bool ret;
 
153
        UN_BUFF *pB;
 
154
        pB = (UN_BUFF *)vB;
 
155
        switch ((UN_LOADDATA)Type)
 
156
        {
 
157
                case UN_LD_LinesVP2 :
 
158
                        //Hori lines
 
159
                        ret = LoadLinesInfo_rv (hC, vB, pStr,TRUE); //f-t-e-d
 
160
                        pB->AimPart[pB->nPart-1] = UN_DA_Hori;
 
161
                        if (ret!=RV_TRUE)
 
162
                        {
 
163
                                if (ret==RV_FALSE)
 
164
                                        Error_CPage_Code (pCode);
 
165
                                if (ret==RV_DOUBT)
 
166
                                        Error_MyNoMem_Code (pCode);
 
167
                                return ret;
 
168
                        }
 
169
                        //Vert lines
 
170
                        ret = LoadLinesInfo_rv (hC, vB, pStr,FALSE); //f-t-e-d
 
171
                        pB->AimPart[pB->nPart-1] = UN_DA_Vert;
 
172
                        if (ret!=RV_TRUE)
 
173
                        {
 
174
                                if (ret==RV_FALSE)
 
175
                                        Error_CPage_Code (pCode);
 
176
                                if (ret==RV_DOUBT)
 
177
                                        Error_MyNoMem_Code (pCode);
 
178
                                return ret;
 
179
                        }
 
180
                        return RV_TRUE;
 
181
                default :
 
182
                        return RV_FALSE;
 
183
        }
 
184
}
 
185
/*---------------------------------------------------------------------------*/
 
186
void GetKeysPumaVP (void *vLti, Handle *pKeyHor, Handle *pKeyVer)
 
187
{
 
188
        LinesTotalInfo *pLti;
 
189
        pLti = (LinesTotalInfo *)vLti;
 
190
        *pKeyHor = pLti->Hor.Lns;
 
191
        *pKeyVer = pLti->Ver.Lns;
 
192
}
 
193
/*---------------------------------------------------------------------------*/
 
194
Bool GetSomeKeys_rv (void *vB, Handle *pKeyHor, Handle *pKeyVer
 
195
                                         , int *pCntHor, int *pCntVer, char *pStr)
 
196
{
 
197
        UN_BUFF *pB;
 
198
        LinesTotalInfo *pLti;
 
199
        int SizeNeed;
 
200
        pB = (UN_BUFF *)vB;
 
201
        pLti = (LinesTotalInfo *)(pB->vPart[pB->nPart-1]);
 
202
        SizeNeed = (pLti->Hor.Cnt + pLti->Ver.Cnt) * sizeof (LinesTotalInfo);
 
203
        if (SizeNeed > pB->SizeCurr)
 
204
        {
 
205
                sprintf (pStr, "�� ������� ������ ��� %d �����!", pLti->Hor.Cnt + pLti->Ver.Cnt);
 
206
                return RV_DOUBT;
 
207
        }
 
208
        if (SizeNeed==0)
 
209
        {
 
210
                sprintf (pStr, "����� ����������, �� �� ����� �� ��������.");
 
211
                return RV_EMPTY;
 
212
        }
 
213
        *pKeyHor = pLti->Hor.Lns;
 
214
        *pKeyVer = pLti->Ver.Lns;
 
215
        *pCntHor = pLti->Hor.Cnt;
 
216
        *pCntVer = pLti->Ver.Cnt;
 
217
        return RV_TRUE;
 
218
}
 
219
/*---------------------------------------------------------------------------*/
 
220
Bool LoadLinesTotalInfo_rv (Handle hC, void *vB, char *pStr)
 
221
{
 
222
        Word32 err32, nTeor, nReal;
 
223
        Handle hBlockLine;
 
224
        UN_BUFF *pB;
 
225
        pB = (UN_BUFF *)vB;
 
226
        /*  ���� � ������  */
 
227
        hBlockLine = CPAGE_GetBlockFirst (hC, RLINE_BLOCK_TYPE);
 
228
        if (!hBlockLine)
 
229
        {
 
230
                sprintf (pStr, "����� �� ����������.");
 
231
                return RV_EMPTY;
 
232
        }
 
233
        err32 = CPAGE_GetReturnCode ();
 
234
        if (err32!=0)
 
235
        {
 
236
       #ifdef Almi
 
237
                AM_Console ("RLTABLE : ������ ����� ���������� - [CPAGE]%s", "[GetBlockFirst]");
 
238
       #endif
 
239
                return RV_FALSE;
 
240
        }
 
241
        /*  ���������� ������  */
 
242
        nTeor = sizeof (LinesTotalInfo);
 
243
        if ((int)nTeor>pB->SizeCurr)
 
244
        {
 
245
                sprintf (pStr, "�� ������� ������ ��� 1, ����-�����!");
 
246
                return RV_DOUBT;
 
247
        }
 
248
        nReal = CPAGE_GetBlockData (hC, hBlockLine, RLINE_BLOCK_TYPE, pB->vCurr, nTeor);
 
249
        err32 = CPAGE_GetReturnCode ();
 
250
        if ((nReal!=nTeor)||(err32!=0))
 
251
        {
 
252
      #ifdef Almi
 
253
                AM_Console ("RLTABLE : ������ ����� ���������� - [CPAGE]%s", "[GetBlockData]");
 
254
      #endif
 
255
                return RV_FALSE;
 
256
        }
 
257
        EndLastDataPart (vB, UN_DA_Unknown, UN_DT_LinesTotalInfo, nTeor, 1);
 
258
        return RV_TRUE;
 
259
}
 
260
/*---------------------------------------------------------------------------*/
 
261
Bool LoadLinesInfo_rv (CLINE_handle hC, void *vB, char *pStr,Bool Hori)
 
262
{
 
263
        int Cnt;
 
264
        Word32 err32, nTeor;
 
265
        UN_BUFF *pB;
 
266
        char *vCurr;
 
267
        pB = (UN_BUFF *)vB;
 
268
        vCurr = (char *)pB->vCurr;
 
269
        nTeor = sizeof (DLine);
 
270
        Cnt=CLINE_GetLineCount(hC);
 
271
        if(Cnt*((int)nTeor)>pB->SizeCurr)
 
272
        {
 
273
                sprintf (pStr, "�� ������� ������ ��� 1, ����-�����!");
 
274
                return RV_DOUBT;
 
275
        }
 
276
        Cnt=0;
 
277
        for(CLINE_handle hline=CLINE_GetFirstLine(hC);hline;hline=CLINE_GetNextLine(hline))
 
278
        {
 
279
                CPDLine cpdata=CLINE_GetLineData(hline);
 
280
                err32 = CLINE_GetReturnCode ();
 
281
                if(!cpdata)
 
282
                {
 
283
         #ifdef Almi
 
284
                        AM_Console ("RLTABLE : ������ ����� ���������� - [CLINE]%s", "[GetLineData]");
 
285
         #endif
 
286
                        return FALSE;
 
287
                }
 
288
                if(Hori&&cpdata->Dir==LD_Horiz||(!Hori&&cpdata->Dir!=LD_Horiz))
 
289
                {
 
290
                 CLINE_CopyData(vCurr,cpdata,nTeor);
 
291
                 vCurr += nTeor;
 
292
                 Cnt++;
 
293
                }
 
294
        }
 
295
        EndLastDataPart (vB,UN_DA_Unknown,UN_DT_ClineLine,nTeor,Cnt);
 
296
        return TRUE;
 
297
}
 
298
/*---------------------------------------------------------------------------*/
 
299
Bool LoadLinesSpecInfo (Handle hC, void *vB, Handle Key, int Cnt)
 
300
{
 
301
        int i;
 
302
        Word32 err32, nTeor, nReal;
 
303
        Handle hBlockLineSpec;
 
304
        Handle hBlockLinePrev;
 
305
        UN_BUFF *pB;
 
306
        char *vCurr;
 
307
        pB = (UN_BUFF *)vB;
 
308
        vCurr = (char *)pB->vCurr;
 
309
        nTeor = sizeof (LineInfo);
 
310
        for (i=0; i<Cnt; i++)
 
311
        {
 
312
                /*  ���� � ������  */
 
313
                if (i==0)
 
314
                        hBlockLineSpec = CPAGE_GetBlockFirst (hC, Key);
 
315
                else
 
316
                        hBlockLineSpec = CPAGE_GetBlockNext (hC, hBlockLinePrev, Key);
 
317
                err32 = CPAGE_GetReturnCode ();
 
318
                if ((err32!=0)||(hBlockLineSpec==NULL))
 
319
                {
 
320
         #ifdef Almi
 
321
                        if (i==0)
 
322
                                AM_Console ("RLTABLE : ������ ����� ���������� - [CPAGE]%s", "[GetBlockFirst]");
 
323
                        else
 
324
                                AM_Console ("RLTABLE : ������ ����� ���������� - [CPAGE]%s", "[GetBlockNext]");
 
325
         #endif
 
326
                        return FALSE;
 
327
                }
 
328
                /*  ���������� ������  */
 
329
                nReal = CPAGE_GetBlockData (hC, hBlockLineSpec, Key, (void *)vCurr, nTeor);
 
330
                err32 = CPAGE_GetReturnCode ();
 
331
                if ((nReal!=nTeor)||(err32!=0))
 
332
                {
 
333
         #ifdef Almi
 
334
                        AM_Console ("RLTABLE : ������ ����� ���������� - [CPAGE]%s", "[GetBlockData]");
 
335
         #endif
 
336
                        return FALSE;
 
337
                }
 
338
                hBlockLinePrev = hBlockLineSpec;
 
339
                vCurr += nTeor;
 
340
        }
 
341
        EndLastDataPart (vB, UN_DA_Unknown, UN_DT_LineInfo, nTeor, Cnt);
 
342
        return TRUE;
 
343
}
 
344
/*---------------------------------------------------------------------------*/
 
345
Bool MyReSetLines (void *vLti, int MaxNumLin, Handle hCPage, Handle HoriType
 
346
                                   , Handle VertType, char *pStr)
 
347
{
 
348
        int i;
 
349
        Word32 err32, nTeor;//, nReal;
 
350
        Bool32 nReal;//differ
 
351
        Handle hBlockLine;
 
352
        Handle hBlockLineHor;
 
353
        Handle hBlockLineVer;
 
354
        Handle hBlockLinePrev;
 
355
        void *Hor, *Ver;
 
356
        LinesTotalInfo *pLti;
 
357
        pLti = (LinesTotalInfo *)vLti;
 
358
        /***  ����� ���������� � ������  ***/
 
359
        Hor = pLti->Hor.Lns;
 
360
        Ver = pLti->Ver.Lns;
 
361
        pLti->Hor.Lns = (LineInfo *)HoriType;
 
362
        pLti->Ver.Lns = (LineInfo *)VertType;
 
363
        hBlockLine = CPAGE_GetBlockFirst (hCPage, RLINE_BLOCK_TYPE);
 
364
        err32 = CPAGE_GetReturnCode ();
 
365
        if (err32!=0)
 
366
        {
 
367
                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][GetBlockFirst]");
 
368
                return FALSE;
 
369
        }
 
370
        nTeor = sizeof (LinesTotalInfo);
 
371
        nReal = CPAGE_SetBlockData (hCPage, hBlockLine, RLINE_BLOCK_TYPE, (void *)pLti, nTeor);
 
372
        err32 = CPAGE_GetReturnCode ();
 
373
//      if ((nReal!=nTeor)||(err32!=0))
 
374
        if (!nReal||(err32!=0))
 
375
        {
 
376
                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][SetBlockData]");
 
377
                return FALSE;
 
378
        }
 
379
        pLti->Hor.Lns = (LineInfo *)Hor;
 
380
        pLti->Ver.Lns = (LineInfo *)Ver;
 
381
        /***  �������������� �����  ***/
 
382
        for (i=0; i<pLti->Hor.Cnt; i++)
 
383
        {
 
384
                if (i==0)
 
385
                        hBlockLineHor = CPAGE_GetBlockFirst (hCPage, HoriType);
 
386
                else
 
387
                        hBlockLineHor = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, HoriType);
 
388
                err32 = CPAGE_GetReturnCode ();
 
389
                if (err32!=0)
 
390
                {
 
391
                        if (i==0)
 
392
                                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][GetBlockFirst]");
 
393
                        else
 
394
                                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][GetBlockNext]");
 
395
                        return FALSE;
 
396
                }
 
397
                nTeor = sizeof (LineInfo);
 
398
                nReal = CPAGE_SetBlockData (hCPage, hBlockLineHor, HoriType, (void *)&(pLti->Hor.Lns[i]), nTeor);
 
399
                err32 = CPAGE_GetReturnCode ();
 
400
//              if ((nReal!=nTeor)||(err32!=0))
 
401
                if (!nReal||(err32!=0))
 
402
                {
 
403
                        sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][SetBlockData]");
 
404
                        return FALSE;
 
405
                }
 
406
                hBlockLinePrev = hBlockLineHor;
 
407
        }
 
408
        /***  ������������ �����  ***/
 
409
        for (i=0; i<pLti->Ver.Cnt; i++)
 
410
        {
 
411
                if (i==0)
 
412
                        hBlockLineVer = CPAGE_GetBlockFirst (hCPage, VertType);
 
413
                else
 
414
                        hBlockLineVer = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, VertType);
 
415
                err32 = CPAGE_GetReturnCode ();
 
416
                if (err32!=0)
 
417
                {
 
418
                        if (i==0)
 
419
                                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][GetBlockFirst]");
 
420
                        else
 
421
                                sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][GetBlockNext]");
 
422
                        return FALSE;
 
423
                }
 
424
                nTeor = sizeof (LineInfo);
 
425
                nReal = CPAGE_SetBlockData (hCPage, hBlockLineVer, VertType, (void *)&(pLti->Ver.Lns[i]), nTeor);
 
426
                err32 = CPAGE_GetReturnCode ();
 
427
//              if ((nReal!=nTeor)||(err32!=0))
 
428
                if (!nReal||(err32!=0))
 
429
                {
 
430
                        sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CPAGE][SetBlockData]");
 
431
                        return FALSE;
 
432
                }
 
433
                hBlockLinePrev = hBlockLineVer;
 
434
        }
 
435
        return TRUE;
 
436
}
 
437
/*----------------------------------------------------------------------------*/
 
438
Bool MyReSetLines(void* vLines,int count,CLINE_handle hCLINE,char *pStr)
 
439
{
 
440
        Word32 nTeor;
 
441
        nTeor=sizeof(DLine);
 
442
        DLine* pbeg=(DLine*)vLines;
 
443
        DLine* pend=&(pbeg[count]);
 
444
        DLine* p;
 
445
        CPDLine cpdata;
 
446
        int Beg_X;
 
447
        int End_X;
 
448
        int Beg_Y;
 
449
        int End_Y;
 
450
        for(CLINE_handle hline=CLINE_GetFirstLine(hCLINE);hline&&count;hline=CLINE_GetNextLine(hline))
 
451
        {
 
452
         cpdata=CLINE_GetLineData(hline);
 
453
         if(!cpdata)
 
454
         {
 
455
                        sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CLINE][SetLineData]");
 
456
                        return FALSE;
 
457
         }
 
458
         Beg_X=cpdata->Line.Beg_X;
 
459
         End_X=cpdata->Line.End_X;
 
460
         Beg_Y=cpdata->Line.Beg_Y;
 
461
         End_Y=cpdata->Line.End_Y;
 
462
         for(p=pbeg;p<pend;p++)
 
463
         {
 
464
          if(p->Line.Beg_X==Beg_X&&p->Line.Beg_Y==Beg_Y&&p->Line.End_X==End_X&&p->Line.End_Y==End_Y)
 
465
          {
 
466
                if(!CLINE_SetLineData(hline,p))
 
467
                {
 
468
                        sprintf (pStr, "RLTABLE : ������ ����� ���������� - [CLINE][SetLineData]");
 
469
                        return FALSE;
 
470
                }
 
471
                count--;
 
472
          }
 
473
         }
 
474
        }
 
475
        return TRUE;
 
476
}
 
477
/*----------------------------------------------------------------------------*/
 
478
Bool ReferForLinesVP (void *vLti, void *vB)
 
479
{
 
480
        int Ind;
 
481
        Bool IsData;
 
482
        UN_BUFF *pB;
 
483
        LinesTotalInfo *pLti;
 
484
        pLti = (LinesTotalInfo *)vLti;
 
485
        pB = (UN_BUFF *)vB;
 
486
        IsData = FALSE;
 
487
        Ind = FindSuchAimedData (vB, UN_DT_LineInfo, UN_DA_Hori);
 
488
        if (Ind >= 0)
 
489
        {
 
490
                IsData = TRUE;
 
491
                pLti->Hor.Lns = (LineInfo *)pB->vPart[Ind];
 
492
        }
 
493
        Ind = FindSuchAimedData (vB, UN_DT_LineInfo, UN_DA_Vert);
 
494
        if (Ind >= 0)
 
495
        {
 
496
                IsData = TRUE;
 
497
                pLti->Ver.Lns = (LineInfo *)pB->vPart[Ind];
 
498
        }
 
499
        if (!IsData)
 
500
                return FALSE;
 
501
        return TRUE;
 
502
}
 
503
/*----------------------------------------------------------------------------*/
 
504
Bool PrepareLinesVP_rv (void *vB, void **vvData)
 
505
{
 
506
        int Ind;
 
507
        Bool ret;
 
508
        UN_BUFF *pB;
 
509
        pB = (UN_BUFF *)vB;
 
510
        *vvData = NULL;
 
511
        Ind = FindSuchData (vB, UN_DT_LinesTotalInfo);
 
512
        if (Ind < 0)
 
513
                return RV_EMPTY;
 
514
        *vvData = pB->vPart[Ind];
 
515
        ret = ReferForLinesVP (*vvData, vB);
 
516
        return ret;
 
517
}
 
518
/*----------------------------------------------------------------------------*/
 
519
Bool ReferForAndCountLinesVP (void *vB, void **vvData,int* pcount,Bool Hori)
 
520
{
 
521
        int Ind;
 
522
        UN_BUFF *pB;
 
523
        pB = (UN_BUFF *)vB;
 
524
        *vvData = NULL;
 
525
        if(Hori)
 
526
            Ind = FindSuchAimedData(vB, UN_DT_ClineLine,UN_DA_Hori);
 
527
        else
 
528
                Ind=FindSuchAimedData(vB, UN_DT_ClineLine,UN_DA_Vert);
 
529
        if (Ind < 0)
 
530
                return RV_EMPTY;
 
531
        *vvData = pB->vPart[Ind];
 
532
        *pcount = pB->nPartUnits[Ind];
 
533
        return TRUE;
 
534
}
 
535
/*----------------------------------------------------------------------------*/
 
536
Bool IsWarnAtLine (void *vLns, Bool Hori)
 
537
{
 
538
        LineInfo *pLns = (LineInfo *)vLns;
 
539
        if (Hori)
 
540
        {
 
541
                if (abs(pLns->A.y - pLns->B.y) > abs(pLns->A.x - pLns->B.x))
 
542
                {
 
543
                   #ifdef Almi
 
544
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContErr)))
 
545
                                AM_Console ("Rlt-Error-Ignore : ���������� ����� �� �������� ��������������! ��� ������������.");
 
546
           #endif
 
547
                        return TRUE;
 
548
                }
 
549
                if (pLns->A.x > pLns->B.x)
 
550
                {
 
551
                   #ifdef Almi
 
552
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContWarn)))
 
553
                                AM_Console ("Rlt-Warning-Continue : ����� ������� �������������� �����!");
 
554
           #endif
 
555
                        return TRUE;
 
556
                }
 
557
        }
 
558
        else
 
559
        {
 
560
                if (abs(pLns->A.y - pLns->B.y) < abs(pLns->A.x - pLns->B.x))
 
561
                {
 
562
          #ifdef Almi
 
563
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContErr)))
 
564
                                AM_Console ("Rlt-Error-Ignore : ���������� ����� �� �������� ������������! ��� ������������.");
 
565
          #endif
 
566
                        return TRUE;
 
567
                }
 
568
                if (pLns->A.y > pLns->B.y)
 
569
                {
 
570
          #ifdef Almi
 
571
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContWarn)))
 
572
                                AM_Console ("Rlt-Warning-Continue : ����� ������� ������������ �����!");
 
573
          #endif
 
574
                        return TRUE;
 
575
                }
 
576
        }
 
577
        return FALSE;
 
578
}
 
579
/*----------------------------------------------------------------------------*/
 
580
Bool IsWarnAtLine (void *vLine,Bool Hori,Bool zero)
 
581
{
 
582
        NR_SimpLine* pLine = (NR_SimpLine*)vLine;
 
583
        if (Hori)
 
584
        {
 
585
                if (abs(pLine->Beg_Y-pLine->End_Y)>abs(pLine->Beg_X-pLine->End_X))
 
586
                {
 
587
          #ifdef Almi
 
588
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContErr)))
 
589
                                AM_Console ("Rlt-Error-Ignore : ���������� ����� �� �������� ��������������! ��� ������������.");
 
590
          #endif
 
591
                        return TRUE;
 
592
                }
 
593
                if (pLine->Beg_X>pLine->End_X)
 
594
                {
 
595
          #ifdef Almi
 
596
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContWarn)))
 
597
                                AM_Console ("Rlt-Warning-Continue : ����� ������� �������������� �����!");
 
598
          #endif
 
599
                        return TRUE;
 
600
                }
 
601
        }
 
602
        else
 
603
        {
 
604
                if (abs(pLine->Beg_Y-pLine->End_Y)<abs(pLine->Beg_X-pLine->End_X))
 
605
                {
 
606
          #ifdef Almi
 
607
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContErr)))
 
608
                                AM_Console ("Rlt-Error-Ignore : ���������� ����� �� �������� ������������! ��� ������������.");
 
609
          #endif
 
610
                        return TRUE;
 
611
                }
 
612
                if (pLine->Beg_Y>pLine->End_Y)
 
613
                {
 
614
          #ifdef Almi
 
615
                        if (!AM_Skip (FT_GetKeyOfRule (RU_FT_C_ContWarn)))
 
616
                                AM_Console ("Rlt-Warning-Continue : ����� ������� ������������ �����!");
 
617
          #endif
 
618
                        return TRUE;
 
619
                }
 
620
        }
 
621
        return FALSE;
 
622
}
 
623
/*----------------------------------------------------------------------------*/
 
624
void MarkTableLines (void *vLti, int *pForw, int MyMaxL)
 
625
{
 
626
        int i, n, Lent;
 
627
        LineInfo *pLns;
 
628
        LinesTotalInfo *pLti;
 
629
        Word32 AntiFalse, AntiTrue, AntiIsAtTable, AntiIsNotAtTable;
 
630
        AntiFalse         = 0xFFFFFFFF;
 
631
        AntiFalse        ^= LI_IsFalse;
 
632
        AntiTrue          = 0xFFFFFFFF;
 
633
        AntiTrue         ^= LI_IsTrue;
 
634
        AntiIsAtTable     = 0xFFFFFFFF;
 
635
        AntiIsAtTable    ^= LI_IsAtTable;
 
636
        AntiIsNotAtTable  = 0xFFFFFFFF;
 
637
        AntiIsNotAtTable ^= LI_IsNotAtTable;
 
638
        pLti = (LinesTotalInfo *)vLti;
 
639
        n = pLti->Hor.Cnt;
 
640
        pLns = pLti->Hor.Lns;
 
641
        for (i=0; i<n; i++)
 
642
        {
 
643
                if (LineBringToTable (i, pForw, MyMaxL))
 
644
                {
 
645
                        pLns->Flags |= LI_IsAtTable;
 
646
                        pLns->Flags &= AntiIsNotAtTable;
 
647
                }
 
648
                else
 
649
                {
 
650
                        if (!(pLns->Flags & LI_IsAtTable))
 
651
                                pLns->Flags |= LI_IsNotAtTable;
 
652
                }
 
653
                pLns++;
 
654
        }
 
655
        n = pLti->Ver.Cnt;
 
656
        pLns = pLti->Ver.Lns;
 
657
        for (i=0; i<n; i++)
 
658
        {
 
659
                if (LineBringToTable (i + MyMaxL, pForw, MyMaxL))
 
660
                {
 
661
                        pLns->Flags |= LI_IsAtTable;
 
662
                        pLns->Flags &= AntiIsNotAtTable;
 
663
                        Lent  = (pLns->A.x - pLns->B.x) * (pLns->A.x - pLns->B.x);
 
664
                        Lent += (pLns->A.y - pLns->B.y) * (pLns->A.y - pLns->B.y);
 
665
                        Lent  = (int) sqrt ((double)Lent);
 
666
                        /*  �������� ��������� ������������ - ���������!  */
 
667
                        if (Lent<70)
 
668
                        {
 
669
                                pLns->Flags &= AntiFalse;
 
670
                                pLns->Flags |= LI_IsTrue;
 
671
                        }
 
672
                }
 
673
                else
 
674
                {
 
675
                        if (!(pLns->Flags & LI_IsAtTable))
 
676
                                pLns->Flags |= LI_IsNotAtTable;
 
677
                }
 
678
                pLns++;
 
679
        }
 
680
}
 
681
/*----------------------------------------------------------------------------*/
 
682
void MarkTableLines (void *vHorLines,int hor_count,void *vVerLines,int ver_count, int *pForw, int MyMaxL)
 
683
{
 
684
        int Lent;
 
685
        int i;
 
686
        DLine* pline;
 
687
        int line_size=sizeof(DLine);
 
688
        Word32 AntiFalse, AntiTrue, AntiIsAtTable, AntiIsNotAtTable;
 
689
        AntiFalse         = 0xFFFFFFFF;
 
690
        AntiFalse        ^= LI_IsFalse;
 
691
        AntiTrue          = 0xFFFFFFFF;
 
692
        AntiTrue         ^= LI_IsTrue;
 
693
        AntiIsAtTable     = 0xFFFFFFFF;
 
694
        AntiIsAtTable    ^= LI_IsAtTable;
 
695
        AntiIsNotAtTable  = 0xFFFFFFFF;
 
696
        AntiIsNotAtTable ^= LI_IsNotAtTable;
 
697
        //Hor lines
 
698
        pline=(DLine*)vHorLines;
 
699
        for(i=0;i<hor_count;i++,pline++)
 
700
        {
 
701
                if (LineBringToTable (i, pForw, MyMaxL))
 
702
                {
 
703
                        pline->Flags |= LI_IsAtTable;
 
704
                        pline->Flags &= AntiIsNotAtTable;
 
705
                }
 
706
                else
 
707
                {
 
708
                        if (!(pline->Flags & LI_IsAtTable))
 
709
                                pline->Flags |= LI_IsNotAtTable;
 
710
                }
 
711
        }
 
712
 
 
713
        //Ver lines
 
714
        pline=(DLine*)vVerLines;
 
715
        ver_count+=MyMaxL;
 
716
        for(i=MyMaxL;i<ver_count;i++,pline++)
 
717
        {
 
718
                if (LineBringToTable (i, pForw, MyMaxL))
 
719
                {
 
720
                        pline->Flags |= LI_IsAtTable;
 
721
                        pline->Flags &= AntiIsNotAtTable;
 
722
                        Lent  = (pline->Line.Beg_X - pline->Line.End_X) * (pline->Line.Beg_X - pline->Line.End_X);
 
723
                        Lent += (pline->Line.Beg_Y - pline->Line.End_Y) * (pline->Line.Beg_Y - pline->Line.End_Y);
 
724
                        Lent  = (int) sqrt ((double)Lent);
 
725
                        /*  �������� ��������� ������������ - ���������!  */
 
726
                        if (Lent<70)
 
727
                        {
 
728
                                pline->Flags &= AntiFalse;
 
729
                                pline->Flags |= LI_IsTrue;
 
730
                        }
 
731
                }
 
732
                else
 
733
                {
 
734
                        if (!(pline->Flags & LI_IsAtTable))
 
735
                                pline->Flags |= LI_IsNotAtTable;
 
736
                }
 
737
        }
 
738
}
 
739
/*----------------------------------------------------------------------------*/
 
740
Bool LineBringToTable (int i, int *pForw, int MyMaxL)
 
741
{
 
742
        int k, l;
 
743
        l = pForw[i];
 
744
        for (k=0; k<=3; k++)
 
745
        {
 
746
                if (l<0)
 
747
                        return FALSE;
 
748
                l = pForw[2*(k+1)*MyMaxL + l];
 
749
        }
 
750
        return TRUE;
 
751
}
 
752
/*---------------------------------------------------------------------------*/