// Setup reading from a file and initial states.
  bool InitTestFromFile(const FX_CHAR* path) {
    IFX_FileRead* pFileAccess = FX_CreateFileRead(path);
    if (!pFileAccess)
      return false;

    // For the test file, the header is set at the beginning.
    m_pSyntax->InitParser(pFileAccess, 0);
    return true;
  }
Exemple #2
0
IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
                                   FX_WORD wDefaultLCID) {
  void* pPathHandle = FX_OpenFolder(pszLocalPath);
  if (!pPathHandle) {
    return NULL;
  }
  CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID);
  CFX_WideString wsFileName;
  FX_BOOL bFolder = FALSE;
  while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) {
    if (!bFolder) {
      if (wsFileName.GetLength() < 4) {
        continue;
      }
      CFX_WideString wsExt = wsFileName.Right(4);
      wsExt.MakeLower();
      if (wsExt != L".xml") {
        continue;
      }
      CFX_WideString wsFullPath(pszLocalPath);
      wsFullPath += L"\\" + wsFileName;
      IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath);
      if (!pRead) {
        continue;
      }
      CXML_Element* pXmlLocale = CXML_Element::Parse(pRead);
      pRead->Release();
      CFX_ByteString bssp = pXmlLocale->GetNamespace();
      if (bssp == "http://www.foxitsoftware.com/localization") {
        CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid");
        wchar_t* pEnd = NULL;
        FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16);
        if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) {
          delete pXmlLocale;
        } else {
          pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale);
        }
      } else {
        delete pXmlLocale;
      }
    }
  }
  FX_CloseFolder(pPathHandle);
  return pLocaleMgr;
}
FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
                                       FX_BOOL bSaveStream) {
  if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
    return FALSE;
  }
  if (bSaveStream) {
    m_pStream = pFontStream;
  }
  m_pFileRead = FX_CreateFileRead(pFontStream);
  m_pFont = new CFX_Font;
  FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead);
  if (bRet) {
    bRet = InitFont();
  } else {
    m_pFileRead->Release();
    m_pFileRead = nullptr;
  }
  return bRet;
}
Exemple #4
0
FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
  if (m_pFont || m_pStream || m_pFileRead) {
    return FALSE;
  }
  Lock();
  m_pStream = IFX_Stream::CreateStream(
      pszFileName, FX_STREAMACCESS_Binary | FX_STREAMACCESS_Read);
  m_pFileRead = FX_CreateFileRead(m_pStream);
  FX_BOOL bRet = FALSE;
  if (m_pStream && m_pFileRead) {
    m_pFont = new CFX_Font;
    bRet = m_pFont->LoadFile(m_pFileRead);
    if (bRet) {
      bRet = InitFont();
    } else {
      m_pFileRead->Release();
      m_pFileRead = nullptr;
    }
  }
  m_wCharSet = 0xFFFF;
  Unlock();
  return bRet;
}
CFDF_Document* CFDF_Document::ParseFile(FX_LPCWSTR file_path)
{
    return CFDF_Document::ParseFile(FX_CreateFileRead(file_path), TRUE);
}