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.
60
/*#include <crtdbg.h>*/
87
#include "mpumatime.h"
90
#include "rcorrkegl.h"
91
/////////////////////////////////////////////////////////////////////////////////////////////////////
100
#define VAL2(a,b) = { a,b }
101
#define VAL4(a,b,c,d) = { a,b,c,d }
103
#define EXTERN extern
107
#define VAL4(a,b,c,d)
110
#define NOSAVEBACKUP //�� ��������� ����������� ������ ������������ - Paul 29-12-2000
114
// �������� ������, ������������ �������������
115
EXTERN Word32 gnLanguage VAL(7);
116
EXTERN Bool32 gbSpeller VAL(TRUE);
117
EXTERN Bool32 gbOneColumn VAL(FALSE);
118
EXTERN Bool32 gbFax100 VAL(FALSE);
119
EXTERN Bool32 gbDotMatrix VAL(FALSE);
120
EXTERN Bool32 gbBold VAL(TRUE);
121
EXTERN Bool32 gbItalic VAL(TRUE);
122
EXTERN Bool32 gbSize VAL(TRUE);
123
EXTERN Bool32 gbFormat VAL(TRUE); // �������� ��. gnFormat
124
EXTERN Word32 gnFormat VAL(1);
125
EXTERN Bool32 gnPreserveLineBreaks VAL(FALSE);
127
EXTERN Word8 gnUnrecogChar VAL('~');
129
EXTERN Word32 gnPictures VAL(1);
130
EXTERN Word32 gnTables VAL(1);
132
EXTERN const char * gpUserDictName VAL("");
133
EXTERN const char * gpSerifName VAL("Times New Roman");
134
EXTERN const char * gpSansSerifName VAL("Arial");
135
EXTERN const char * gpCourierName VAL("Courier New");
137
EXTERN char szInputFileName[260];
138
EXTERN PWord8 gpInputDIB VAL(NULL);
139
EXTERN PWord8 gpRecogDIB VAL(NULL);
140
EXTERN Bool32 gbAutoRotate VAL(FALSE);
141
EXTERN Point32 gPageSize VAL2(209,295); // ������ �4 � �����������
142
EXTERN Rect32 gRectTemplate VAL4(-1,-1,-1,-1);
144
// ������ ���������� � ���������� ������.
145
EXTERN char szFormatStorageName[] VAL("%sstorage.tmp");
146
EXTERN char szFormatTbl1[] VAL("%stbl1%s.dat");
148
EXTERN Int32 gnNumberTables VAL(0);
150
EXTERN Handle hCCOM VAL(NULL);
151
EXTERN Handle hCPAGE VAL(NULL);
152
EXTERN CLINE_handle hCLINE VAL(0);
153
EXTERN Handle hLinesCCOM VAL(NULL); // ���������� � �������
154
EXTERN Handle ghEdPage VAL(NULL);
156
// 1. ���������� ���������
157
EXTERN Handle hDebugRoot VAL(NULL);
158
EXTERN Handle hDebugCancelStrings VAL(NULL);
159
EXTERN Handle hDebugCancelRecognition VAL(NULL);
160
EXTERN Handle hDebugCancelRemoveLines VAL(NULL);
161
EXTERN Handle hDebugCancelSearchLines VAL(NULL);
162
EXTERN Handle hDebugCancelOrtoMove VAL(NULL);
163
EXTERN Handle hDebugCancelAutoTemplate VAL(NULL);
164
EXTERN Handle hDebugCancelSearchTables VAL(NULL);
165
EXTERN Handle hDebugCancelVerifyLines VAL(NULL);
166
EXTERN Handle hDebugCancelSearchDotLines VAL(NULL);
167
EXTERN Handle hDebugCancelFormatted VAL(NULL);
168
EXTERN Handle hDebugCancelBinarize VAL(NULL);
169
EXTERN Handle hDebugCancelComponent VAL(NULL);
170
EXTERN Handle hDebugCancelComponentSecond VAL(NULL);
171
EXTERN Handle hDebugCancelExtractBlocks VAL(NULL);
172
EXTERN Handle hDebugCancelStringsPass2 VAL(NULL);
173
EXTERN Handle hDebugCancelStringsColor VAL(NULL);
174
EXTERN Handle hDebugCancelPostRecognition VAL(NULL);
175
EXTERN Handle hDebugCancelPostSpeller VAL(NULL);
176
EXTERN Handle hDebugCancelSearchPictures VAL(NULL);
177
EXTERN Handle hDebugCancelLinePass3 VAL(NULL);
178
EXTERN Handle hDebugCancelSearchNegatives VAL(NULL);
179
EXTERN Handle hDebugEnableSearchSegment VAL(NULL);
180
EXTERN Handle hDebugCancelVertCells VAL(NULL);
181
EXTERN Handle hDebugEnableSaveJtl VAL(NULL);
182
EXTERN Handle hDebugEnableSaveCstr1 VAL(NULL);
183
EXTERN Handle hDebugEnableSaveCstr2 VAL(NULL);
184
EXTERN Handle hDebugEnableSaveCstr3 VAL(NULL);
185
EXTERN Handle hDebugEnableSaveCstr4 VAL(NULL);
186
EXTERN Handle hDebugCPAGEStorage VAL(NULL);
188
EXTERN Handle hDebugRootStuff VAL(NULL);
189
EXTERN Handle hDebugBinarize VAL(NULL);
190
EXTERN Handle hDebugAutoTemplate VAL(NULL);
191
EXTERN Handle hDebugLines VAL(NULL);
192
EXTERN Handle hDebugVerLines VAL(NULL);
193
EXTERN Handle hDebugRSL VAL(NULL);
196
EXTERN Handle hDebugRootLayout VAL(NULL);
197
EXTERN Handle hDebugLayout VAL(NULL);
198
EXTERN Handle hDebugPictures VAL(NULL);
199
EXTERN Handle hDebugSegment VAL(NULL);
200
EXTERN Handle hDebugNeg VAL(NULL);
201
EXTERN Handle hDebugFon VAL(NULL);
202
EXTERN Handle hDebugTables VAL(NULL);
203
EXTERN Handle hDebugStrings VAL(NULL);
204
EXTERN Handle hDebugPostLines VAL(NULL);
205
EXTERN Handle hDebugSVLines VAL(NULL);
206
EXTERN Handle hDebugSVLinesStep VAL(NULL);
207
EXTERN Handle hDebugSVLinesData VAL(NULL);
209
EXTERN Handle hDebugRootRecognition VAL(NULL);
210
EXTERN Handle hDebugRecognition VAL(NULL);
211
EXTERN Handle hDebugSpell VAL(NULL);
213
EXTERN Handle hDebugRootFormatting VAL(NULL);
214
EXTERN Handle hDebugConverters VAL(NULL);
215
EXTERN Handle hDebugCeglCorr VAL(NULL);
218
EXTERN Handle hDebugMainDebug VAL(NULL);
219
EXTERN Handle hDebugMainTimeControl VAL(NULL);
221
EXTERN Handle hDebugLayoutFromFile VAL(NULL);
222
EXTERN Handle hDebugLayoutToFile VAL(NULL);
223
EXTERN Handle hDebugHandLayout VAL(NULL);
225
EXTERN Handle hDebugCancelPropertyConsole VAL(NULL);
226
EXTERN Handle hDebugCancelConsoleOutputText VAL(NULL);
227
EXTERN Handle hDebugCancelConsoleKeglOutput VAL(NULL);
228
EXTERN Handle hDebugCancelRanalFrm VAL(NULL);
229
EXTERN Handle hDebugPrintBlocksCPAGE VAL(NULL);
230
EXTERN Handle hDebugCancelFictive VAL(NULL);
231
EXTERN Handle hDebugCancelTurn VAL(NULL);
232
EXTERN Handle hDebugEnablePrintFormatted VAL(NULL);
234
EXTERN char szLayoutFileName[256] VAL("Layout.bin");
235
EXTERN unsigned nDebugReturnCode VAL(0);
236
EXTERN unsigned nDebugAllocMemory VAL(0);
238
EXTERN FNPUMA_ProgressStart fnProgressStart VAL(NULL);
239
EXTERN FNPUMA_ProgressFinish fnProgressFinish VAL(NULL);
240
EXTERN FNPUMA_ProgressStep fnProgressStep VAL(NULL);
242
EXTERN Word32 g_prgStep VAL(0);
243
//Allex ��� ���������� ����������� � ��������� ����
244
//��� �������� 'lpRecogName' ������� ���������� ����������
245
EXTERN const char * glpRecogName VAL(NULL);
246
EXTERN Bool32 grc_line VAL(TRUE);
247
EXTERN Bool32 gneed_clean_line VAL(FALSE);
248
EXTERN Bool32 gKillVSLComponents VAL(TRUE);
249
EXTERN Word8 gnSpecialProject VAL(0);
256
EXTERN _CrtMemState g_dbgMemState;
260
// ����� ���������� �����������
261
// �������� � mpumatime.h
262
//#define FLG_UPDATE_NO 0
263
//#define FLG_UPDATE (Word32)-1
264
//#define FLG_UPDATE_CCOM 0x1
265
//#define FLG_UPDATE_CPAGE 0x2
267
EXTERN Word32 g_flgUpdate VAL(0);
269
Bool32 IsUpdate(Word32 flg);
270
void SetUpdate(Word32 flgAdd,Word32 flgRemove);
274
// Word32 dwBeg; // ������ �������� ���������
275
// Word32 dwEnd; // �����
277
// Word32 dwStep; // ������� ����� ����
278
// char * name; // ������� �������� ����
281
EXTERN PRGTIME g_PrgTime;
283
//////////////////////////////////////////////////////////////////
285
// ����� ����������� ������ �� PreProcessImage
286
//////////////////////////////////////////////////////////Allex
287
EXTERN CIMAGEBITMAPINFOHEADER info;
288
//EXTERN PUMALinesBuffer gSVLBuffer VALM(0);
289
//#define PUMA_SVL_FIRST_STEP 0x1
290
//#define PUMA_SVL_SECOND_STEP 0x2
291
//#define PUMA_SVL_THRID_STEP 0x3
292
//#define PUMAMaxNumLines 2000
293
/////////////////////////////////////////////////////////////////////////////////////////////////////
296
void SetReturnCode_puma(Word32 rc);
297
Word32 GetReturnCode_puma();
298
char * GetModulePath();
299
char * GetModuleTempPath();
300
char * GetResourceString(Word32 id);
302
Bool32 InitMem(void);
304
void GiveMainBuff (void **vvBuff, int *Size);
305
void GiveWorkBuff (void **vvBuff, int *Size);
311
void My_SJTL_Init(void);
312
int My_SJTL_save(const char* filename);
313
int My_SJTL_save_old(char *filename, CSTR_line lino,int nfield);
314
int My_SJTL_open(const char *frmname, const char *jtlname);
315
int My_SJTL_mkfrm(char *frmname);
316
void My_SJTL_close(void);
317
void My_SJTL_Done(void);
323
Bool32 ModulesInit(Handle ghStorage);
324
Bool32 ModulesDone(Handle ghStorage);
325
char * GetModulesString(Word32 dwError);
327
Bool32 Layout(PWord8 lpdata);
334
static char lang_suff[][4] ={
335
"","GRM","FRN","RUS","SWE","SPA","ITA","R&E","UKR","SER","CRO",
336
"POL","DAN","POR","DUT","DIG"
340
long _EnumFormats(long prev);
341
long _EnumCodes(long f,long prev);
342
long _EnumLanguage(long prev);
343
long _EnumFormatMode(long prev);
344
long _EnumTable(long prev);
345
long _EnumPicture(long prev);
348
void ClearAll( void );
349
Bool32 rexcProgressStep (Word32);
350
Bool32 ExtractComponents(Bool32 bIsRotate, Handle * prev_ccom , PWord8 name);
351
Bool32 RemoveLines(Handle hccom,Handle hcpage,PWord8 * pDIB);
352
void SetOptionsToFRMT( void );
353
Bool32 SaveToText(char * lpOutFileName,int code);
354
// Bool32 HL_TableExtract( Handle hPAGE, Word32 type, Rect32 rect );
355
// Bool32 HL_TableExtractEx( Handle hPAGE, Word32 perc, Rect32 rect );
356
// ������� �������� ����������.
357
// 1. ��� ������������� ����������� �������� ���� ������� InitPRGTIME. ���������� TRUE, ���� ����������� �������
358
// 2. ������ ����� ������� ��������� ���� ������ �� 0 �� 100 ���������
359
// 3. ����� ������� ������� ���� ���������� �������� ��������� ��� ���� ������� � �������� 0 - 100
360
// ��� ����� ���� ��������� StorePRGTIME(Word32 beg, Word32 end);
361
// 4. ����� �������� �� ���� ������� ���� ������������ ������� �������� RestorePRGTIME(PRGTIME prev)
362
// ���������� ���� ������� ������ ���� ������������ �������� ������� StorePRGTIME
363
// 5. � ����� ������� ������� DonePRGTIME
365
Bool32 InitPRGTIME();
366
Bool32 DonePRGTIME();
367
PRGTIME StorePRGTIME(Word32 beg, Word32 end);// ������������� ������� ���������, ������� ����������� � ProgressStep
368
void RestorePRGTIME(PRGTIME prev);// ������������� ������� ���������, ������� ����������� � ProgressStep
370
void ProgressStart();
371
void ProgressFinish();
372
Bool32 ProgressStep(Word32 step,char*name,Word32 percent);
373
Bool32 ProgressStepLayout(Word32 step,Word32 percent);
374
Bool32 ProgressStepLines(Word32 step,Word32 percent);
375
Bool32 ProgressStepTables(Word32 step,Word32 percent);
376
Bool32 ProgressStepSearchTables(Word32 step,Word32 percent);
377
Bool32 ProgressStepAutoLayout(Word32 step,Word32 percent);
378
/////////////////////////////////////////////////////////////////////////////////////////////////////
379
// Allex (���������� � pumadef.h
380
//#define NAME_IMAGE_INPUT "�������� �����������"
381
//#define NAME_IMAGE_BINARIZE "�������������� �����������"
382
//#define NAME_IMAGE_DELLINE "����������� �� ������� �������"
383
/////////////////////////////////////////////////////////////////////////////////////////////////////
385
Bool32 PreProcessImage();
386
Bool32 BinariseImage();
388
Bool32 PrintResult(int num,CSTR_line lout,Handle hCPAGE);
389
Bool32 ConverROUT(char * lpOutFileName, Int32 lnFormat, Int32 lnCode,Bool32 bAppend);
390
Word32 ConverROUTtoMemory(Handle hEd, Int32 lnFormat, Int32 lnCode, Byte * lpMem, Word32 size);
392
Bool32 ReadSVLFromPageContainer ( LinesTotalInfo * );
393
Bool32 ShortVerticalLinesProcess ( Word32 );
394
Bool32 SVLFilter(LinesTotalInfo *, LinesTotalInfo *);
395
Bool32 SVLComponentFilter(LineInfo *);
396
Bool32 IsRectIntersect(Rect16 *, Rect16 *);
397
Bool32 CompIsGood (CCOM_comp *, Int32 );
399
//////////////////////////////////////////////////////////////////////////////////