~ubuntu-branches/debian/wheezy/cuneiform/wheezy

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/puma/c/common.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
#include <stdio.h>
 
58
#include <string.h>
 
59
 
 
60
#include "mpuma.h"
 
61
#include "ccom.h"
 
62
#include "cstr.h"
 
63
 
 
64
void ClearAll( void )
 
65
{
 
66
        PAGEINFO           PInfo = {0};
 
67
//
 
68
// �������� ���������� ��������� � ������� ���������
 
69
//
 
70
        if(ghEdPage)
 
71
        {
 
72
                CED_DeletePage(ghEdPage);
 
73
                ghEdPage = NULL;
 
74
        }
 
75
 
 
76
        if(hCPAGE)
 
77
                GetPageInfo(hCPAGE,&PInfo);
 
78
 
 
79
    CSTR_DeleteAll();
 
80
        CPAGE_DeleteAll(); hCPAGE = CreateEmptyPage();
 
81
 
 
82
        strcpy((char*)PInfo.szImageName, PUMA_IMAGE_USER);
 
83
        PInfo.Incline2048 = 0;
 
84
        PInfo.Angle = 0;
 
85
        PInfo.Images=IMAGE_USER;
 
86
        SetPageInfo(hCPAGE,PInfo);
 
87
 
 
88
        CCOM_DeleteAll();  hCCOM = NULL;
 
89
        CIMAGE_DeleteImage((PWord8)PUMA_IMAGE_BINARIZE );
 
90
        CIMAGE_DeleteImage((PWord8)PUMA_IMAGE_DELLINE   );
 
91
//  ���������� ����������� ( PUMA_IMAGE_ROTATE) ������� ������, ��� � ��������,
 
92
//  ��������� ��� ������������ � ����������. ��� ����� �������
 
93
//  ���� ��� ��������� ������ ����������� �����������, ���� ���
 
94
//  �������� �����
 
95
        CIMAGE_DeleteImage((PWord8)PUMA_IMAGE_TURN              );
 
96
        /*
 
97
        if(hCPAGE && CPAGE_GetCountBlock(hCPAGE))
 
98
        {
 
99
                CPAGE_BackUp(hCPAGE);
 
100
                Handle hBlock = CPAGE_GetBlockFirst(hCPAGE,0);
 
101
                while(hBlock)
 
102
                {
 
103
                        CPAGE_DeleteBlock(hCPAGE,hBlock);
 
104
                        hBlock = CPAGE_GetBlockNext(hCPAGE,hBlock,0);
 
105
                }
 
106
        }
 
107
        */
 
108
}
 
109
///////////////////////////////////////////////////////
 
110
// ������� �������� ����������
 
111
Bool32 rexcProgressStep  (Word32 step)
 
112
{
 
113
        return ProgressStep(2,NULL,step);
 
114
}
 
115
///////////////////////////////////////////////////////
 
116
Bool32  ExtractComponents( Bool32 bIsRotate, Handle * prev_ccom, PWord8 name)
 
117
{
 
118
        Bool32 rc = TRUE;
 
119
        ExcControl      exc = {0};
 
120
 
 
121
    if(prev_ccom)
 
122
    {
 
123
        *prev_ccom = hCCOM ? hCCOM: NULL;
 
124
        hCCOM=NULL;
 
125
    }
 
126
    else
 
127
    {
 
128
        CCOM_DeleteContainer((CCOM_handle)hCCOM);
 
129
        hCCOM=NULL;
 
130
    }
 
131
 
 
132
        if(!REXC_SetImportData(REXC_ProgressStep, (void*)rexcProgressStep))
 
133
        {
 
134
                SetReturnCode_puma(REXC_GetReturnCode());
 
135
                return FALSE;
 
136
        }
 
137
 
 
138
        // ����� ������������� ��������
 
139
        exc.Control  = Ex_ExtraComp|/*Ex_EvnRecog|*/Ex_Picture;
 
140
    //exc.Control |= Ex_NetRecog;
 
141
 
 
142
        //Andrey: orientation is obtained from new library RNORM
 
143
    //exc.Control |= ( bIsRotate ? Ex_Orient : 0 );
 
144
    if( gnPictures )
 
145
        exc.Control |= Ex_PictureLarge;
 
146
/*
 
147
        if(rc && !REXC_SetEVNProperties(exc, GetModulePath(),(Word8)gnLanguage) )
 
148
        { // ���������������� ������������� �� ������� � ������ �������
 
149
                SetReturnCode_puma(REXC_GetReturnCode());
 
150
                rc = FALSE;
 
151
        }
 
152
        else
 
153
*/
 
154
        {
 
155
                Word8 w8 = (Word8)gbDotMatrix;
 
156
                        REXC_SetImportData(REXC_Word8_Matrix,&w8);
 
157
 
 
158
                w8 = (Word8)gbFax100;
 
159
                        REXC_SetImportData(REXC_Word8_Fax1x2,&w8);
 
160
        }
 
161
/*
 
162
        if(rc && !REXCExtraDIB( exc, lpdata,0,0,0,0) ) // ����� ��������� � DIB-e
 
163
*/
 
164
    CIMAGEIMAGECALLBACK clbk;
 
165
    if(rc && !CIMAGE_GetCallbackImage(name, &clbk))
 
166
    {
 
167
                SetReturnCode_puma(CIMAGE_GetReturnCode());
 
168
        rc = FALSE;
 
169
    }
 
170
    if( rc && !REXCExtracomp3CB(exc, // ����� ��������� by 3CallBacks
 
171
        (TImageOpen)clbk.CIMAGE_ImageOpen,
 
172
        (TImageClose)clbk.CIMAGE_ImageClose,
 
173
        (TImageRead)clbk.CIMAGE_ImageRead)
 
174
        )
 
175
                {
 
176
                SetReturnCode_puma(REXC_GetReturnCode());
 
177
                rc = FALSE;
 
178
                }
 
179
 
 
180
        if(rc)
 
181
        {
 
182
                hCCOM = (Handle)REXCGetContainer();
 
183
                if(hCCOM==0)
 
184
                {
 
185
                        SetReturnCode_puma(REXC_GetReturnCode());
 
186
                        rc = FALSE;
 
187
                }
 
188
 
 
189
        }
 
190
        if(rc)
 
191
        {
 
192
                hCCOM = (Handle)REXCGetContainer();
 
193
                if(hCCOM==0)
 
194
                {
 
195
                        SetReturnCode_puma(REXC_GetReturnCode());
 
196
                        rc = FALSE;
 
197
                }
 
198
        }
 
199
        if(rc)
 
200
                SetUpdate(FLG_UPDATE_NO,FLG_UPDATE_CCOM);
 
201
        return rc ;
 
202
}
 
203
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
204
// ����� ���������� � RSource.dll
 
205
Bool32  comp_over(CCOM_comp *sour,CCOM_comp *cur)
 
206
{
 
207
        Int32   le,ri,up,dn,w,h;
 
208
 
 
209
        if( sour->left+sour->w<=cur->left || cur->left+cur->w<=sour->left )
 
210
                return FALSE;
 
211
        if( sour->upper+sour->h<=cur->upper || cur->upper+cur->h<=sour->upper )
 
212
                return FALSE;
 
213
 
 
214
        if( sour->left<cur->left )
 
215
                le = cur->left;
 
216
        else
 
217
                le = sour->left;
 
218
 
 
219
        if( sour->left+sour->w<cur->left+cur->w )
 
220
                ri = sour->left+sour->w;
 
221
        else
 
222
                ri = cur->left+cur->w;
 
223
        w=ri-le;
 
224
        if( sour->upper<cur->upper )
 
225
                up = cur->upper;
 
226
        else
 
227
                up = sour->upper;
 
228
 
 
229
        if( sour->upper+sour->h<cur->upper+cur->h )
 
230
                dn = cur->upper+cur->h;
 
231
        else
 
232
                dn = sour->upper+sour->h;
 
233
        h=dn-up;
 
234
 
 
235
        if( w>0 && h>0 && cur->w<2*sour->w && cur->h<2*sour->h &&
 
236
                w*2>cur->w && h*2>cur->h )
 
237
                return TRUE;
 
238
        return FALSE;
 
239
}
 
240
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
241
// ����� ���������� � RSource.dll
 
242
Bool32  remove_overlayed(CCOM_comp *sour,CCOM_handle haCCOM)
 
243
{
 
244
CCOM_comp   *cur=CCOM_GetFirst(haCCOM,NULL), *curn;
 
245
Int32       over=0;
 
246
 
 
247
do  {
 
248
    curn=CCOM_GetNext(cur,NULL);
 
249
    if( cur->upper<sour->upper && sour->upper-cur->upper>10*sour->h)
 
250
        { // upper zone
 
251
        cur=curn;
 
252
        continue;
 
253
        }
 
254
    if( comp_over(sour,cur) )
 
255
        {
 
256
        CCOM_Delete(haCCOM,cur);
 
257
        over++;
 
258
        }
 
259
    if( cur->upper-sour->upper>10*sour->h)
 
260
        break; // downer zone
 
261
    cur = curn;
 
262
    }while( cur!=NULL );
 
263
return (over>0);
 
264
}
 
265
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
266
// ����� ���������� � RSource.dll
 
267
// ��������� ����������� AlMi
 
268
Bool32 MyGetZher (void **vvZher, Int32 *nZher, Int32 MaxZher, Handle hCPage)
 
269
{
 
270
        Word32 err32, nTeor, nReal;
 
271
        Handle hBlockZher;
 
272
        Handle hBlockPrev;
 
273
        int i;
 
274
        nTeor = sizeof (void *);
 
275
        i=0;
 
276
        while (1)
 
277
        {
 
278
                if (i==0)
 
279
                        hBlockZher = CPAGE_GetBlockFirst (hCPage, RVERLINE_ZHERTVY_LINIY);
 
280
                else
 
281
                        hBlockZher = CPAGE_GetBlockNext (hCPage, hBlockPrev, RVERLINE_ZHERTVY_LINIY);
 
282
                err32 = CPAGE_GetReturnCode ();
 
283
                if (err32!=0)
 
284
                {
 
285
                        //if (i==0)
 
286
                        //      Error_CPage ("[GetBlockFirst]");
 
287
                        //else
 
288
                        //      Error_CPage ("[GetBlockNext]");
 
289
                        return FALSE;
 
290
                }
 
291
                if (!hBlockZher)
 
292
                        break;
 
293
                if (i>=MaxZher)
 
294
                        return FALSE;
 
295
                nReal = CPAGE_GetBlockData (hCPage, hBlockZher, RVERLINE_ZHERTVY_LINIY, (void *)&(vvZher[i]), nTeor);
 
296
                err32 = CPAGE_GetReturnCode ();
 
297
                if (!nReal||(err32!=0))
 
298
                {
 
299
                        //Error_CPage ("[SetBlockData]");
 
300
                        return FALSE;
 
301
                }
 
302
                hBlockPrev = hBlockZher;
 
303
                i++;
 
304
        }
 
305
        *nZher = i;
 
306
        return TRUE;
 
307
}
 
308
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
309
// ����� ���������� � RSource.dll
 
310
Bool32 RemoveLines(Handle hccom,Handle hcpage,PWord8 * lppDIB)
 
311
{
 
312
        PWord8 hDIB = NULL;
 
313
        Bool32 rc = TRUE;
 
314
    hLinesCCOM = NULL;
 
315
    CCOM_comp   *victim[100];
 
316
    Int32       nvict,i;
 
317
    Bool32      yes_victim = FALSE;
 
318
//
 
319
//       ������ �����
 
320
//
 
321
        if(rc && !RLINE_DeleteLines(hcpage,PUMA_IMAGE_DELLINE))
 
322
        {
 
323
                SetReturnCode_puma(RLINE_GetReturnCode());
 
324
                rc = FALSE;
 
325
        }
 
326
//
 
327
//       ������� ����������� � ���������� �������
 
328
//
 
329
        if(rc && !CIMAGE_ReadDIB((PWord8)PUMA_IMAGE_DELLINE,(Handle*)&hDIB,TRUE))
 
330
        {
 
331
                SetReturnCode_puma(CIMAGE_GetReturnCode());
 
332
                rc = FALSE;
 
333
        }
 
334
        if(hDIB)
 
335
        {
 
336
//
 
337
//               ������ ���������� � ������� �� ������.
 
338
//
 
339
                *lppDIB = (PWord8)hDIB;
 
340
                if(rc)
 
341
                {
 
342
        if( CCOM_GetContainerVolume((CCOM_handle)hCCOM)<60000 &&
 
343
            MyGetZher ((void**)victim, &nvict, 100, hcpage) && nvict )
 
344
            yes_victim = TRUE;
 
345
 
 
346
        if( !yes_victim )
 
347
            {
 
348
            CCOM_DeleteContainer((CCOM_handle)hCCOM);
 
349
            hCCOM=0;
 
350
            }
 
351
 
 
352
                if(!ExtractComponents(FALSE,&hLinesCCOM,(PWord8)PUMA_IMAGE_DELLINE))
 
353
                {
 
354
                                rc = FALSE;
 
355
                }
 
356
        else
 
357
        {
 
358
            PAGEINFO inf = {0};
 
359
            GetPageInfo(hCPAGE,&inf);
 
360
            strcpy((char*)inf.szImageName,PUMA_IMAGE_DELLINE);
 
361
            SetPageInfo(hCPAGE,inf);
 
362
        }
 
363
 
 
364
                if(rc)
 
365
                {
 
366
 
 
367
                        hCCOM = (Handle)REXCGetContainer();
 
368
                        if(hCCOM==0)
 
369
                        {
 
370
                                SetReturnCode_puma(REXC_GetReturnCode());
 
371
                                rc = FALSE;
 
372
                        }
 
373
                        hccom = hCCOM;
 
374
            if( hLinesCCOM )
 
375
                {
 
376
//
 
377
//                 Refersh CCOM
 
378
//
 
379
                CCOM_comp   *exa=CCOM_GetFirst((CCOM_handle)hLinesCCOM,NULL);
 
380
 
 
381
                if( yes_victim )
 
382
                {
 
383
                /*
 
384
                Rect16 rect1;
 
385
                    Word32 key = 111;
 
386
                for(i=0;i<nvict;i++)
 
387
                    {
 
388
                    exa = victim[i];
 
389
                    rect1.top = exa->upper;
 
390
                            rect1.left = exa->left;
 
391
                            rect1.bottom = exa->upper+exa->h;
 
392
                            rect1.right = exa->left+exa->w;
 
393
                            LDPUMA_DrawRect(NULL, &rect1, 0, 23635, 1, key);
 
394
                    }
 
395
 
 
396
                if(!LDPUMA_Skip(hShowCheckLetters))
 
397
                        {
 
398
                                LDPUMA_Console("Puma_������� �����  \n");
 
399
                                LDPUMA_WaitUserInput(NULL, NULL);
 
400
                                LDPUMA_DeleteRects(NULL, key);
 
401
                        }
 
402
                    */
 
403
                for(i=0;i<nvict;i++)
 
404
                    {
 
405
                    exa = victim[i];
 
406
                    if( remove_overlayed(exa,(CCOM_handle)hCCOM) )
 
407
                        {
 
408
                        CCOM_comp   *dup=CCOM_New((CCOM_handle)hCCOM,exa->upper,exa->left,exa->w,exa->h);
 
409
                        if( dup )
 
410
                            {
 
411
                            CCOM_Store(dup,0,
 
412
                                exa->size_linerep,
 
413
                                exa->linerep,  exa->nl,
 
414
                                exa->begs, exa->ends,
 
415
                                exa->vers,   NULL);
 
416
                            dup->scale= exa->scale;
 
417
                            dup->type = exa->type;
 
418
                            dup->cs   = exa->cs;
 
419
                            }
 
420
                        }
 
421
                    }
 
422
                }
 
423
                CCOM_DeleteContainer((CCOM_handle)hLinesCCOM);
 
424
                }
 
425
                        }
 
426
                        else
 
427
                                LDPUMA_Console("�������� ���� ��������� ��������� ����� �������� �����.\n");
 
428
                }
 
429
        }
 
430
return rc;
 
431
}
 
432
 
 
433
void SetOptionsToFRMT()
 
434
{
 
435
        RFRMT_SetImportData(RFRMT_Bool32_Bold,&gbBold);
 
436
        RFRMT_SetImportData(RFRMT_Bool32_Italic,&gbItalic);
 
437
        RFRMT_SetImportData(RFRMT_Bool32_Size,&gbSize);
 
438
        RFRMT_SetImportData(RFRMT_Word32_Format,&gnFormat);
 
439
        RFRMT_SetImportData(RFRMT_char_SerifName,gpSerifName);
 
440
        RFRMT_SetImportData(RFRMT_char_SansSerifName,gpSansSerifName);
 
441
        RFRMT_SetImportData(RFRMT_char_CourierName,gpCourierName);
 
442
        RFRMT_SetImportData(RFRMT_Word8_UnRecogSymbol,&gnUnrecogChar);
 
443
        RFRMT_SetImportData(RFRMT_Word32_Language,&gnLanguage);
 
444
}
 
445
 
 
446
Bool32    SaveToText(char * lpOutFileName,int code)
 
447
{
 
448
        Bool32 rc = TRUE;
 
449
int count = CSTR_GetMaxNumber();
 
450
 
 
451
if(code != PUMA_CODE_ANSI)
 
452
{
 
453
        SetReturnCode_puma(IDS_ERR_NOTIMPLEMENT);
 
454
        return FALSE;
 
455
}
 
456
 
 
457
FILE * f = fopen(lpOutFileName,"wt");
 
458
        if(f)
 
459
        {
 
460
                for(int i=1;i<=count;i++)
 
461
                {
 
462
                CSTR_line lin_out;
 
463
                char    txt[500];
 
464
 
 
465
                        lin_out = CSTR_GetLineHandle(i, 1); // OLEG
 
466
                        if(lin_out == (CSTR_line)NULL)
 
467
                        {
 
468
                                SetReturnCode_puma(CSTR_GetReturnCode());
 
469
                                rc = FALSE;
 
470
                                break;
 
471
                        }
 
472
 
 
473
                        if( CSTR_LineToTxt(lin_out,txt) )
 
474
                        {
 
475
                                char szString[sizeof(txt)];
 
476
                                sprintf(szString,"%s\n",txt);
 
477
                                unsigned len = strlen(szString);
 
478
                                if(fwrite(szString,sizeof(char),len,f) != len)
 
479
                                {
 
480
                                        SetReturnCode_puma(IDS_ERR_FILEWRITE);
 
481
                                        rc = FALSE;
 
482
                                        break;
 
483
                                }
 
484
                        }
 
485
                        else
 
486
                        {
 
487
                                SetReturnCode_puma(CSTR_GetReturnCode());
 
488
                                rc = FALSE;
 
489
                                break;
 
490
                        }
 
491
 
 
492
                }
 
493
                fclose(f);
 
494
        }
 
495
        else
 
496
        {
 
497
                SetReturnCode_puma(IDS_ERR_FILEOPEN);
 
498
                rc = FALSE;
 
499
        }
 
500
        return rc;
 
501
}
 
502
////////////////////////////////////////////////////////////
 
503
void ProgressStart()
 
504
{
 
505
        LDPUMA_ProgressStart();
 
506
        if(fnProgressStart)
 
507
                fnProgressStart();
 
508
}
 
509
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
510
//
 
511
void ProgressFinish()
 
512
{
 
513
        LDPUMA_ProgressFinish();
 
514
        if(fnProgressFinish)
 
515
                fnProgressFinish();
 
516
}
 
517
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
518
//
 
519
Bool32 ProgressStep(Word32 step,char*name,Word32 percent)
 
520
{
 
521
        Bool32 rc = TRUE;
 
522
        static Word32 old = 0;
 
523
 
 
524
        g_PrgTime.dwStep = step;
 
525
        g_PrgTime.name = name ? name : g_PrgTime.name;
 
526
 
 
527
        Word32 perc = g_PrgTime.dwBeg + percent*(g_PrgTime.dwEnd - g_PrgTime.dwBeg)/100;
 
528
        rc = LDPUMA_ProgressStep(step,g_PrgTime.name,perc);
 
529
//      _ASSERT(perc>=old);
 
530
        if(fnProgressStep)
 
531
                rc &= fnProgressStep(step,g_PrgTime.name,perc);
 
532
 
 
533
        old = perc;
 
534
        return rc;
 
535
}
 
536
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
537
//
 
538
Bool32 ProgressStepLayout(Word32 step,Word32 percent)
 
539
{
 
540
        return ProgressStep(step, GetResourceString(IDS_PRG_OPEN), percent);
 
541
}
 
542
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
543
//
 
544
Bool32 ProgressStepLines(Word32 step,Word32 percent)
 
545
{
 
546
        return ProgressStep(step, GetResourceString(IDS_REMOVELINE), percent);
 
547
}
 
548
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
549
//
 
550
Bool32 ProgressStepTables(Word32 step,Word32 percent)
 
551
{
 
552
        return ProgressStep(step, GetResourceString(IDS_REMOVELINE), percent);
 
553
}
 
554
//////////////////////////////////////////////////////
 
555
Bool32 ProgressStepSearchTables(Word32 step,Word32 percent)
 
556
{
 
557
        return ProgressStep(step, GetResourceString(IDS_SEARCHTABLE), percent);
 
558
}
 
559
//////////////////////////////////////////////////////
 
560
Bool32 ProgressStepAutoLayout(Word32 step,Word32 percent)
 
561
{
 
562
        return ProgressStep(step, GetResourceString(IDS_AUTOLAYOUT), percent);
 
563
}
 
564
 
 
565
static Word32 bInitPrgTime = 0;
 
566
void ResetPRGTIME()
 
567
{
 
568
        bInitPrgTime = 0;
 
569
}
 
570
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
571
//
 
572
Bool32  DonePRGTIME()
 
573
{
 
574
        Bool32 rc = FALSE;
 
575
        if(     bInitPrgTime )
 
576
                bInitPrgTime--;
 
577
        if(!bInitPrgTime)
 
578
                rc = TRUE;
 
579
return rc;
 
580
}
 
581
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
582
//
 
583
Bool32  InitPRGTIME()
 
584
{
 
585
        Bool32 rc = FALSE;
 
586
        if(!bInitPrgTime)
 
587
        {
 
588
                g_PrgTime.dwBeg  = 0;
 
589
                g_PrgTime.dwEnd  = 100;
 
590
                g_PrgTime.dwStep = 0;
 
591
                g_PrgTime.name   = "";
 
592
                rc = TRUE;
 
593
        }
 
594
        bInitPrgTime++;
 
595
        return rc;
 
596
}
 
597
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
598
//
 
599
PRGTIME  StorePRGTIME(Word32 beg, Word32 end)
 
600
{
 
601
        PRGTIME rc = g_PrgTime;
 
602
 
 
603
        Word32 newBeg = g_PrgTime.dwBeg + (g_PrgTime.dwEnd - g_PrgTime.dwBeg)*beg/100;
 
604
        Word32 newEnd = g_PrgTime.dwBeg + (g_PrgTime.dwEnd - g_PrgTime.dwBeg)*end/100;
 
605
 
 
606
        g_PrgTime.dwBeg = newBeg;
 
607
        g_PrgTime.dwEnd = newEnd;
 
608
 
 
609
return rc;
 
610
}
 
611
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
612
//
 
613
void RestorePRGTIME(PRGTIME     prev)
 
614
{
 
615
        g_PrgTime  = prev;
 
616
}
 
617
/////////////////////////////////////////////////////////////////////
 
618
Bool32 PrintResult(int num,CSTR_line lout,Handle hCPAGE)
 
619
{
 
620
        Bool32 rc = FALSE;
 
621
        CSTR_rast       start = CSTR_GetFirstRaster (lout),
 
622
                stop = CSTR_GetLastRaster (lout), c;
 
623
        UniVersions     vers;
 
624
        CSTR_rast_attr  attr;
 
625
        CSTR_attr               line_attr = {0};
 
626
 
 
627
        Bool32 bold = 0;
 
628
        Bool32 italic = 0;
 
629
        Bool32 strikeout = 0;
 
630
        Bool32 underline = 0;
 
631
        Int32 height = 0;
 
632
        Int32 offset = 0;
 
633
        Word32 textcolor = 0;
 
634
        int charset = RUSSIAN_CHARSET;
 
635
        const char * name = NULL;
 
636
        static Int32  nFragment = -1;
 
637
        static Word32 deftextcolor = 0;
 
638
        Bool32 bOutputKegl = TRUE;
 
639
 
 
640
        CSTR_GetLineAttr (lout,&line_attr);
 
641
 
 
642
        if(line_attr.fragment != nFragment)
 
643
        {
 
644
                nFragment = -1;
 
645
                deftextcolor = 0;
 
646
                Handle hBlock = CPAGE_GetBlockFirst(hCPAGE,0);
 
647
                while(hBlock)
 
648
                {
 
649
                        if(CPAGE_GetBlockInterNum(hCPAGE,hBlock) == (Word32)line_attr.fragment)
 
650
                        {
 
651
                                nFragment = line_attr.fragment;
 
652
                                goto lNext;
 
653
                        }
 
654
                        hBlock = CPAGE_GetBlockNext(hCPAGE,hBlock,0);
 
655
                }
 
656
        }
 
657
lNext:
 
658
        if(nFragment<0)
 
659
                deftextcolor = 254L + (127L<<8);
 
660
 
 
661
 
 
662
        LDPUMA_SetConsoleProperty(0,0,0,0,0,0,deftextcolor,RUSSIAN_CHARSET,"Courier New");
 
663
        LDPUMA_Console("��.%2i ���.%3i: <",line_attr.fragment,num);
 
664
 
 
665
        if( start && stop )
 
666
        {
 
667
                c=CSTR_GetNextRaster (start,CSTR_f_all);
 
668
                for(; c && c!=stop; c=CSTR_GetNextRaster (c,CSTR_f_all))
 
669
                {
 
670
                        CSTR_GetAttr(c, &attr);
 
671
                        if( !(attr.flg & (CSTR_f_let|CSTR_f_punct|CSTR_f_bad|CSTR_f_space|CSTR_f_solid)) )
 
672
                                continue;
 
673
                        if( CSTR_GetCollectionUni(c, &vers) )
 
674
                        {
 
675
 
 
676
                                if(LDPUMA_Skip(hDebugCancelPropertyConsole))
 
677
                                {
 
678
                                        if(attr.font&CSTR_fp_bold)
 
679
                                                bold = TRUE;
 
680
                                        else
 
681
                                                bold = FALSE;
 
682
 
 
683
                                        if(attr.font&CSTR_fp_it)
 
684
                                                italic = TRUE;
 
685
                                        else
 
686
                                                italic = FALSE;
 
687
 
 
688
                                        if(attr.font&CSTR_fp_undrln)
 
689
                                                underline = TRUE;
 
690
                                        else
 
691
                                                underline = FALSE;
 
692
 
 
693
                                        height = attr.keg*10*2;
 
694
                    switch( attr.font_spec )
 
695
                                        {
 
696
                                        case    CSTR_fs_none:
 
697
                                                if(attr.font & CSTR_fp_ser)
 
698
                                                        name = "Times New Roman";
 
699
                                                else if(attr.font & CSTR_fp_gelv)
 
700
                                                        name = "Arial";
 
701
                                                else
 
702
                                                        name = "Courier New";
 
703
                                                if( attr.font & CSTR_fp_narrow )
 
704
                                                        name = "Arial Narrow";
 
705
                                                break;
 
706
                                        case    CSTR_fs_courier:
 
707
                                                name = "Courier New";
 
708
                                                break;
 
709
                                        }
 
710
 
 
711
 
 
712
                                        textcolor = 0;
 
713
                                        if(attr.flg_spell & CSTR_fa_spell_reject)
 
714
                                                textcolor |= 200<<16;// RGB
 
715
                    if(attr.flg_spell & CSTR_fa_spell_nocarrying)
 
716
                                                textcolor |= 200<<8;
 
717
 
 
718
                                        if(!vers.lnAltCnt || vers.Alt[0].Prob<70)
 
719
                                                textcolor |= 200;
 
720
                                }
 
721
 
 
722
                                charset = vers.Alt[0].Charset;
 
723
                                LDPUMA_SetConsoleProperty(bold,italic,strikeout,
 
724
                                        underline,height,offset,textcolor,charset,name);
 
725
 
 
726
                                if( !vers.lnAltCnt )
 
727
                                        LDPUMA_Console("%c",'~');
 
728
                                else
 
729
                                {
 
730
                    if( vers.Alt[0].Code[0]=='%' )
 
731
                        LDPUMA_Console((char *)"%%");
 
732
                    else
 
733
                                                LDPUMA_Console((char *)vers.Alt[0].Code);
 
734
                                }
 
735
 
 
736
                                if(bOutputKegl && !LDPUMA_Skip(hDebugCancelConsoleKeglOutput))
 
737
                                {
 
738
                                        LDPUMA_SetConsoleProperty(0,0,0,0,0,0,150L<<8,RUSSIAN_CHARSET,NULL);
 
739
                                        LDPUMA_Console(">%i<",attr.keg);
 
740
                                        bOutputKegl = FALSE;
 
741
                                }
 
742
                        }
 
743
                }
 
744
                rc = TRUE;
 
745
        }
 
746
        LDPUMA_SetConsoleProperty(0,0,0,0,0,0,deftextcolor,RUSSIAN_CHARSET,NULL);
 
747
        LDPUMA_Console(">\n");
 
748
 
 
749
        if(deftextcolor)
 
750
                LDPUMA_SetConsoleProperty(0,0,0,0,0,0,0,RUSSIAN_CHARSET,NULL);
 
751
 
 
752
        return rc;
 
753
}
 
754
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
755
//
 
756
Bool32  HL_TableExtractEx( Handle hPAGE, Word32 perc, Rect32 rect )
 
757
{
 
758
        return RMARKER_SearchTableInZone(hPAGE,hCCOM,perc,rect);
 
759
}
 
760
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
761
//
 
762
Bool32 IsUpdate(Word32 flg)
 
763
{
 
764
        return (g_flgUpdate & flg) > 0;
 
765
}
 
766
 
 
767
void   SetUpdate(Word32 flgAdd,Word32 flgRemove)
 
768
{
 
769
        g_flgUpdate = (g_flgUpdate | flgAdd) & ~flgRemove;
 
770
}