Exemplo n.º 1
0
// **************************************************************************
// Function:   LoadDictionary
// Purpose:    This function loads a dictionary file
// Parameters: dictionaryfile - filename of the dictionary file
//             eraseold - true  ... deletes all existing words in the dictionary
//                        false ... does not delete existing words in the dictionary
// Returns:    0 ... error
//             1 ... OK
// **************************************************************************
int DICTIONARY::LoadDictionary(const char *dictionaryfile, bool eraseold)
{
char    line[MAX_WORDLENGTH];
FILE    *fp;
int     i;

 if (eraseold) DeleteWords();

 fp=fopen(dictionaryfile, "rb");
 if (!fp) return(0);

 
 while (!feof(fp))
  {
  fgets(line, MAX_WORDLENGTH, fp);
  line[MAX_WORDLENGTH-1]=0;
  for (i=0; i<(int)strlen(line); i++)
   if ((line[i] == ' ') || (line[i] == '\r') || (line[i] == '\n'))
      line[i]=0;
  AddWord(line);
  }
 fclose(fp);

 return(1);
}
void CPDF_VariableText::SetText(const FX_WCHAR* text,
                                int32_t charset,
                                const CPVT_SecProps* pSecProps,
                                const CPVT_WordProps* pWordProps) {
  DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
  CFX_WideString swText = text;
  CPVT_WordPlace wp(0, 0, -1);
  CPVT_SectionInfo secinfo;
  if (m_bRichText) {
    if (pSecProps)
      secinfo.pSecProps = new CPVT_SecProps(*pSecProps);
    if (pWordProps)
      secinfo.pWordProps = new CPVT_WordProps(*pWordProps);
  }
  if (CSection* pSection = m_SectionArray.GetAt(0))
    pSection->m_SecInfo = secinfo;

  int32_t nCharCount = 0;
  for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
    if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar)
      break;
    if (m_nCharArray > 0 && nCharCount >= m_nCharArray)
      break;

    uint16_t word = swText.GetAt(i);
    switch (word) {
      case 0x0D:
        if (m_bMultiLine) {
          if (swText.GetAt(i + 1) == 0x0A)
            i += 1;

          wp.nSecIndex++;
          wp.nLineIndex = 0;
          wp.nWordIndex = -1;
          AddSection(wp, secinfo);
        }
        break;
      case 0x0A:
        if (m_bMultiLine) {
          if (swText.GetAt(i + 1) == 0x0D)
            i += 1;

          wp.nSecIndex++;
          wp.nLineIndex = 0;
          wp.nWordIndex = -1;
          AddSection(wp, secinfo);
        }
        break;
      case 0x09:
        word = 0x20;
      default:
        wp = InsertWord(wp, word, charset, pWordProps);
        break;
    }
    nCharCount++;
  }
}
Exemplo n.º 3
0
// **************************************************************************
// Function:   DICTIONARY
// Purpose:    This is the constructor of the DICTIONARY class
// Parameters: N/A
// Returns:    N/A
// **************************************************************************
DICTIONARY::~DICTIONARY()
{
 DeleteWords();
}