示例#1
0
/////////////////////////////////////////////////////////////////////////////
//                    CheckLineForFilling
Bool CheckLineForFilling( CSTR_line* Comingline )
{
 CSTR_line	     line;
 CSTR_rast       rast;
 RecVersions     vers;
 CSTR_rast_attr	 rast_attr;

 line = *Comingline;
 rast =  CSTR_GetFirstRaster( line );                              // I фикт. растр
 rast =  CSTR_GetNextRaster( rast , CSTR_f_all );

 while( rast )
 {
	 CSTR_GetCollection( rast,&vers );
     CSTR_GetAttr( rast,&rast_attr );

     if((rast_attr.flg&CSTR_f_dust) ||  (rast_attr.flg&CSTR_f_fict ) ||//Дусты и
	    ((rast_attr.flg&CSTR_f_space) &&
	    (!vers.Alt[0].Code || vers.Alt[0].Code == 0x1e ||
		vers.Alt[0].Code == 0x1f)))                                 //полупробелы  выкидываем.
     goto next_raster;
     return TRUE;

     next_raster:
	  rast = CSTR_GetNextRaster( rast , CSTR_f_all );
 }

 return FALSE;
}
示例#2
0
/////////////////////////////////////////////////////////////////////////////
//                   CheckComingLine
Bool CheckComingLine( CSTR_line* Comingline )
{
 CSTR_rast       rast;
 CSTR_line	     line;

  line     = *Comingline;
  rast =  CSTR_GetFirstRaster( line );
  assert( rast );
  rast = CSTR_GetNextRaster( rast , CSTR_f_all );
  if(rast)
    return TRUE;

  return FALSE;
}
示例#3
0
Bool32 ed_cstr_string(CSTR_line ln)
{
CSTR_rast       eng, enge;
uchar           elen,ewrd[MAX_LEN_WORD+40];

eng = CSTR_GetFirstRaster(ln);
while(1)
    {
    eng = ed_next_word(eng);
    if( !eng )
        break;
    enge = ed_end_word(eng,ewrd,&elen);
    ed_init();
    ed_make_word(eng,enge);
    ed_save();
    // ed spell
    // ed conv ed back to CSTR
    break; // debug
    }
return  TRUE;
}
示例#4
0
static void show_spell(CSTR_rast c)
{
uchar   wrd[80],buf[160],*w=wrd, lang;
Bool32  nonrec=FALSE;
CSTR_rast_attr  attr;
UniVersions     uni;
CSTR_rast       co=c;
*w=0;
do{
    CSTR_GetAttr(c, &attr);
    c=CSTR_GetPrev(c);
    }
    while( c && attr.flg&(CSTR_f_let|CSTR_f_bad) );
if( !c )
    c=CSTR_GetNext(CSTR_GetFirstRaster(CSTR_GetRasterLine(co)));
else
    c=CSTR_GetNext(CSTR_GetNext(c));
CSTR_GetAttr(c,&attr);
for(lang=attr.language;c;c=CSTR_GetNext(c))
    {
    CSTR_GetAttr(c,&attr);
    if(!(attr.flg&(CSTR_f_let|CSTR_f_bad)) )
        break;
    if( attr.flg&CSTR_f_bad )
        nonrec=TRUE;
    CSTR_GetCollectionUni(c,&uni);
    strcat(w,uni.Alt[0].Code);
    }

strcpy(buf,"<");
strcat(buf,wrd);
strcat(buf,"> static : ");
if( rpstr_txt_spell(wrd,lang)        )
    strcat(buf,"y");
else
    strcat(buf," n");
Snap_Console(buf);
return;
}
示例#5
0
/////////////////////////////////////////////////////////////////////////////////////////
//	DESC:	Востановление контейнера CSTR
//	ARGS:	filename	- имя файла
//	RETS:	TRUE	- успешно
//			FALSE	- ошибка
/////////////////////////////////////////////////////////////////////////////////////////
CSTR_FUNC(Bool32) CSTR_RestoreCont(char *filename)
{
	CSTR_line	linx;
	CSTR_rast	rst;
	FILE		*in;
	uchar		IDt[IDTEXT_LEN];
	int32_t		i, j, count;
	Bool32		lineFlg;
	CGRAPH_FileData	fData;


	if(!(in = fopen(filename, "rb")))
	{
		wLowRC = CGRAPH_ERR_OPEN;
		return FALSE;
	}

	fread(IDt, sizeof(IDt), 1, in);
	fread(&fData, sizeof(fData), 1, in);
	fread(&count, sizeof(count), 1, in);

	if(strcmp((char *)IDt, (char *)IDtext) != 0)
	{
		fclose(in);
		wLowRC = CGRAPH_ERR_FILE;
		return FALSE;
	}

	for(i = 1; i <= count; i++)
	{
		for(j = 0; j < fData.MaxLineVer; j++)
		{
			fread(&i, sizeof(i), 1, in);
			fread(&j, sizeof(j), 1, in);

			if(!(linx = CSTR_NewLine(i, j, -1)))
			{
				fclose(in);
				wLowRC = CGRAPH_ERR_PARAM;
				return FALSE;
			}

			fread(&lineFlg, sizeof(lineFlg), 1, in);

			if(!lineFlg)
				continue;

			if(!(CGRAPH_RestoreCSTR(&linx, in)))
			{
				fclose(in);
				return FALSE;
			}

			if(!(rst = CSTR_GetFirstRaster(linx)))
			{
				fclose(in);
				wLowRC = CGRAPH_ERR_PARAM;
				return FALSE;
			}

			if(!CGRAPH_RestoreLoop(rst->next, in))
			{
				fclose(in);
				return FALSE;
			}

			if(!CSTR_PackLine(linx))
			{
				fclose(in);
				wLowRC = CGRAPH_ERR_PARAM;
				return FALSE;
			}
		}
	}

	return TRUE;
}
示例#6
0
/////////////////////////////////////////////////////////////////////////////////////////
//	DESC:	Запись контейнера CSTR на диск
//	ARGS:	filename	- имя файла
//	RETS:	TRUE	- успешно
//			FALSE	- ошибка
/////////////////////////////////////////////////////////////////////////////////////////
CSTR_FUNC(Bool32) CSTR_SaveCont(char *filename)
{
	int32_t		i, j, count;
	Bool32		lineFlg;
	FILE		*out;

	CSTR_rast	rst;
	CSTR_attr	attr;
	CSTR_line	linx;
	CGRAPH_FileData	fData;

	if(!(out = fopen(filename, "wb")))
	{
		wLowRC = CGRAPH_ERR_OPEN;
		return FALSE;
	}

	fData.FileVer	 = FILE_VER;
	fData.MaxLineVer = LINE_VER;

	count = CSTR_GetMaxNumber();

	fwrite(IDtext, sizeof(IDtext), 1, out);
	fwrite(&fData, sizeof(fData), 1, out);
	fwrite(&count, sizeof(count), 1, out);

	for(i = 1; i <= count; i++)
	{
		for(j = 0; j < fData.MaxLineVer; j++)
		{
			fwrite(&i, sizeof(i), 1, out);			//Номер строки
			fwrite(&j, sizeof(i), 1, out);			//Версия

			if(!(linx = CSTR_GetLineHandle(i, j)))
			{
				lineFlg = FALSE;
				fwrite(&lineFlg, sizeof(lineFlg), 1, out);
				continue;
			}
			else
			{
				lineFlg = TRUE;
				fwrite(&lineFlg, sizeof(lineFlg), 1, out);
			}

			if(!(rst = CSTR_GetFirstRaster(linx)))
			{
				wLowRC = CGRAPH_ERR_PARAM;
				fclose(out);
				return FALSE;
			}

			if(!(CSTR_GetLineAttr(linx, &attr)))
			{
				wLowRC = CGRAPH_ERR_PARAM;
				fclose(out);
				return FALSE;
			}

			if(!CGRAPH_SaveCSTR(rst->next, &attr, out))
			{
				fclose(out);
				return FALSE;
			}

			if(!CGRAPH_SaveLoop(rst->next, &attr, out))
			{
				fclose(out);
				return FALSE;
			}
		}
	}

	fclose(out);
	return TRUE;
}
示例#7
0
/////////////////////////////////////////////////////////////////////////////
//                   CFString::ExtractWordsFromString
void CFString::ExtractWordsFromString( CSTR_line* Comingline , PageElementCount* Count)
{
 CSTR_rast_attr	 rast_attr;
 CSTR_rast       rast;
 RecVersions     vers;
 CSTR_line	      line;
 CSTR_attr       line_attr;
 CWord*          CurrentWord;
 const char*     SeparatorsWord=" ";
 const char*     result=NULL;
 int16_t             FlagWord;
 Bool            FlagString,FlagCapDrop;

 line        = *Comingline;
 FlagWord    = 0;
 FlagString  = FALSE;
 FlagCapDrop = FALSE;

 CSTR_GetLineAttr( line , &line_attr );
 if(line_attr.Flags & CSTR_STR_CapDrop) //буквица - см. первая буква в сказках
    FlagCapDrop = TRUE;

 SetRect(&m_rectBaseLine, line_attr.bs1, line_attr.bs2,
                        line_attr.bs3, line_attr.bs4); //don't used now
 SetRect(&m_rectString, line_attr.col - TemplateOffset.x,
                      line_attr.row - TemplateOffset.y,
	                  line_attr.col - TemplateOffset.x + line_attr.wid,
                      line_attr.row - TemplateOffset.y + line_attr.hei);

 #ifdef alDebug //obsolete option
 {
  RECT rect;
  SetRect(&rect,line_attr.col, line_attr.row,
                         line_attr.col + line_attr.wid,
					     line_attr.row + line_attr.hei);
  pInputArray->push_back(rect);
 }
 #endif

 rast =  CSTR_GetFirstRaster( line );            // I фикт. растр
 rast =  CSTR_GetNextRaster( rast , CSTR_f_all );

 while( rast )
 {
	 CSTR_GetCollection( rast,&vers );
     CSTR_GetAttr( rast,&rast_attr );
     //#define NEG_HALF_SPACE  0x1e
     //#define POS_HALF_SPACE  0x1f
     //#define REGULAR_SPACE   0x20

     if((rast_attr.flg&CSTR_f_dust) ||  (rast_attr.flg&CSTR_f_fict ) ||//Дусты и
	    ((rast_attr.flg&CSTR_f_space) &&
	    (!vers.Alt[0].Code || vers.Alt[0].Code == 0x1e ||
	    vers.Alt[0].Code == 0x1f)))//полупробелы  выкидываем.
      goto next_raster;

      FlagString = TRUE;
	  result = strchr( SeparatorsWord, vers.Alt[0].Code );
	  if( FlagWord ){   // word openly
	    if(result)      // word is broken
	       FlagWord =0;
	    else{           // word lasts
    	   assert( CurrentWord );
           CurrentWord->AddLetter2Word( &rast , Count ,&FlagCapDrop );
        }
      }
	  else{             // expect new word
        if(!result){  // beginning word
          ++m_wWordsCount;
          ++Count->Words;
	      FlagWord = 1;
          m_arWords.push_back( new CWord() );
          CurrentWord = m_arWords[m_wWordsCount-1];
          assert( CurrentWord );

   	      if(rast_attr.font_spec == CSTR_fs_courier)
             CurrentWord->m_wFontNumber     = rast_attr.font & 0xFC;
          else
             CurrentWord->m_wFontNumber     = rast_attr.font;

		  CurrentWord->m_wFontPointSize  = rast_attr.keg;
          CurrentWord->AddLetter2Word( &rast , Count ,&FlagCapDrop );
          if(FlagCapDrop){
            CurrentWord->m_wFontPointSize = 14;
		    FlagCapDrop = FALSE;
		    FlagWord    = 0;
          }
        }
      }
      next_raster:
	   rast = CSTR_GetNextRaster( rast , CSTR_f_all );
 }

 if(FlagString == FALSE)
   Count->Strings--;
}
示例#8
0
void save_alphabet_information(str_info *str,int16_t column,CSTR_line ln)
{
uchar            buf[256]={0};
cell *          c;
RecObject       ro={0};
CSTR_rast       rst;
RecRaster       rrst;
RecVersions     ver;
LeoFieldSetup   fs={0};
CSTR_attr       lattr;
CSTR_rast_attr  attr;
UniVersions     uvs;

if( db_status && snap_activity('n') )
 {
 snap_show_text("DIG : start selection");
 snap_monitor();
 }
str[column].all++;
fs.nStyle = LS_PRINT;
buf['0']=buf['1']=buf['2']=buf['3']=buf['4']=
buf['5']=buf['6']=buf['7']=buf['8']=buf['9']=1;
memcpy(fs.AlphaTable,buf,256);
#ifdef _USE_LEO_
LEOSetupField(&fs);
for(c=cell_f()->nextl;c!=cell_l();c=c->nextl)
    {
    if( c->nvers==0 && c->w*2>c->h && c->h*2>c->w )
        {
        puchar           wr;
        // to work_rst
        wr=save_raster_align8(c);
        // rst -->> rrst
        rrst.lnPixHeight = c->h;
        rrst.lnPixWidth  = c->w;
        rrst.lnRasterBufSize = REC_MAX_RASTER_SIZE;
        memcpy(rrst.Raster,wr,((c->w+63)/64)*8*c->h);
        memcpy(&ro.recData.recRaster,&rrst,REC_MAX_RASTER_SIZE);
        LEORecogPrnMethod( &ro , REC_METHOD_3X5, 1);
        memcpy(&ver,&ro.recResults,sizeof(ver));
        if( ver.lnAltCnt && ver.Alt[0].Prob>220 )
            {
            c->nvers=1;
            c->vers[0].let=ver.Alt[0].Code;
            c->vers[0].prob=ver.Alt[0].Prob;
            c->vers[1].let=0;
            c->flg=c_f_let;
            }
        }
    }
#endif
setup_digital_mode(&str[column], 1);
for(c=cell_f()->next;c!=cell_l();c=c->next)
  if( c->nvers>0 && c->vers[0].let=='$' && c->vers[0].prob>220 )
    {
    str[column].dollars++;
    break;
    }
if( digital_mode==2 )
  {
  str[column].dig++;
  if( db_status && snap_activity('n') )
    {
    sprintf(buf,"DIG : digital str, col %d, all %d, dig %d, plus_minus %d" ,
                                    column, str[column].all,str[column].dig,str[column].pm);
    snap_show_text(buf);
    snap_monitor();
    }

  }
else if( digital_mode==1 )
  {
  str[column].fuzzy_dig++;
  if( db_status && snap_activity('n') )
    {
    sprintf(buf,"DIG : fuzzy digital str, col %d, all %d, dig %d, plus_minus %d" ,
                                    column, str[column].all,str[column].dig,str[column].pm);
    snap_show_text(buf);
    snap_monitor();
    }

  }
else
    {
    plusminus_mode=0;
    if( cell_f()->next && cell_f()->next==cell_l()->prev )
        {
        c=cell_f()->next;
        rst=CSTR_GetNextRaster(CSTR_GetFirstRaster(ln),CSTR_f_bad|CSTR_f_let);

        if( rst && CSTR_GetImage(rst,(uchar *)&rrst,CSTR_TYPE_IMAGE_RS))
            {
            if( c->w>c->h*5
				|| c->w>c->h*3 && c->env && c->env->nl == 1 // Nick 18.01.2002
			  )
                {
                c->nvers=1;
                c->vers[0].let='-';
                c->vers[0].prob=254;
                ver.Alt[0].Code='-';
                ver.Alt[0].Prob=255;
                ver.lnAltCnt =1;
                CSTR_StoreCollection(rst,&ver);
                CSTR_GetAttr(rst,&attr);
                //attr.keg=Ps<<line_scale;
                CSTR_SetAttr(rst,&attr);
                CSTR_GetLineAttr(ln,&lattr);
                lattr.Flags |= CSTR_STR_ReadyResults ;
                CSTR_SetLineAttr(ln,&lattr);
                plusminus_mode=1;
                }
            else if( abs(c->w-c->h)<5  )
                {
                #ifdef _USE_LEO_
                fs.nStyle = LS_PRINT;
                buf['+']=1;
                memcpy(fs.AlphaTable,buf,256);
                LEOSetupField(&fs);
                memcpy(&ro.recData.recRaster,&rrst,REC_MAX_RASTER_SIZE);
                LEORecogPrnMethod( &ro , REC_METHOD_3X5, 1);
                memcpy(&ver,&ro.recResults,sizeof(ver));
                if( ver.lnAltCnt && ver.Alt[0].Code=='+' && ver.Alt[0].Prob>220 )
                    {
                    c->nvers=1;
                    c->vers[0].let='+';
                    c->vers[0].prob=254;
                    ver.lnAltCnt =1;

                    CSTR_StoreCollection(rst,&ver);
                    CSTR_GetAttr(rst,&attr);
                    //attr.keg=Ps<<line_scale;
                    CSTR_SetAttr(rst,&attr);
                    CSTR_GetLineAttr(ln,&lattr);
                    lattr.Flags |= CSTR_STR_ReadyResults ;
                    CSTR_SetLineAttr(ln,&lattr);
                    plusminus_mode=1;
                    }
                #endif
                }
            }
        }
    if( plusminus_mode )
      {
      str[column].pm++;
      rst=CSTR_GetNextRaster(CSTR_GetFirstRaster(ln),CSTR_f_bad|CSTR_f_let);
      CSTR_GetCollectionUni(rst,&uvs);
      if( uvs.lnAltCnt )
          {
          uvs.Alt[0].Charset=CodePages[language];
          CSTR_StoreCollectionUni(rst,&uvs);
          }
      if( db_status && snap_activity('n') )
        {
        sprintf(buf,"DIG : plus_minus str , col %d, all %d, dig %d, plus_min %d" ,
                                        column, str[column].all,str[column].dig,str[column].pm);
        snap_show_text(buf);
        snap_monitor();
        }

      }
    else
        {
        if( db_status && snap_activity('n') )
            {
            sprintf(buf,"DIG : unknown alphabet , col %d, all %d, dig %d, plus_min %d" ,
                                            column, str[column].all,str[column].dig,str[column].pm);
            snap_show_text(buf);
            snap_monitor();
            }
        }
    }

return;
}