Beispiel #1
0
CFGAS_GEFont* CFGAS_FontMgr::GetFontByUnicode(FX_WCHAR wUnicode,
                                              uint32_t dwFontStyles,
                                              const FX_WCHAR* pszFontFamily) {
  CFGAS_GEFont* pFont = nullptr;
  if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont))
    return nullptr;
  const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode);
  uint16_t wCodePage = x ? x->wCodePage : 0xFFFF;
  uint16_t wBitField = x ? x->wBitField : 0x03E7;
  CFX_ByteString bsHash;
  if (wCodePage == 0xFFFF)
    bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles);
  else
    bsHash.Format("%d, %d", wCodePage, dwFontStyles);
  bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
  uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
  CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr;
  if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
    if (!pFonts)
      return nullptr;

    for (int32_t i = 0; i < pFonts->GetSize(); ++i) {
      if (VerifyUnicode(pFonts->GetAt(i), wUnicode))
        return pFonts->GetAt(i)->Retain();
    }
  }
  if (!pFonts)
    pFonts = new CFX_ArrayTemplate<CFGAS_GEFont*>;
  m_Hash2Fonts.SetAt(dwHash, pFonts);
  CFX_FontDescriptorInfos* sortedFonts = nullptr;
  if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) {
    sortedFonts = new CFX_FontDescriptorInfos;
    MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
               CFX_WideString(pszFontFamily), wUnicode);
    m_Hash2CandidateList.SetAt(dwHash, sortedFonts);
  }
  for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) {
    CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont;
    if (!VerifyUnicode(pDesc, wUnicode))
      continue;
    pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
    if (!pFont)
      continue;
    pFont->SetLogicalFontStyle(dwFontStyles);
    pFonts->Add(pFont);
    return pFont;
  }
  if (!pszFontFamily)
    m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr);
  return nullptr;
}
Beispiel #2
0
CFGAS_FontMgr::~CFGAS_FontMgr() {
  for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++)
    delete m_InstalledFonts[i];
  FX_POSITION pos = m_Hash2CandidateList.GetStartPosition();
  while (pos) {
    uint32_t dwHash;
    CFX_FontDescriptorInfos* pDescs;
    m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs);
    delete pDescs;
  }
  pos = m_Hash2Fonts.GetStartPosition();
  while (pos) {
    uint32_t dwHash;
    CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts;
    m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
    for (int32_t i = 0; i < pFonts->GetSize(); i++)
      delete pFonts->GetAt(i);
    delete pFonts;
  }
  m_Hash2Fonts.RemoveAll();
  pos = m_IFXFont2FileRead.GetStartPosition();
  while (pos) {
    CFGAS_GEFont* pFont;
    IFX_SeekableReadStream* pFileRead;
    m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead);
    pFileRead->Release();
  }
}
Beispiel #3
0
void IFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) {
  if (!m_pProperties)
    return;
  if (!bGlobal) {
    matrix.SetIdentity();
    return;
  }

  IFWL_Widget* parent = GetParent();
  CFX_ArrayTemplate<IFWL_Widget*> parents;
  while (parent) {
    parents.Add(parent);
    parent = parent->GetParent();
  }
  matrix.SetIdentity();
  CFX_Matrix ctmOnParent;
  CFX_RectF rect;
  int32_t count = parents.GetSize();
  for (int32_t i = count - 2; i >= 0; i--) {
    parent = parents.GetAt(i);
    parent->GetMatrix(ctmOnParent, false);
    parent->GetWidgetRect(rect);
    matrix.Concat(ctmOnParent, true);
    matrix.Translate(rect.left, rect.top, true);
  }
  CFX_Matrix m;
  m.SetIdentity();
  matrix.Concat(m, true);
  parents.RemoveAll();
}
Beispiel #4
0
void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pEFont) {
  if (!pEFont)
    return;

  IFX_SeekableReadStream* pFileRead;
  if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) {
    pFileRead->Release();
    m_IFXFont2FileRead.RemoveKey(pEFont);
  }
  FX_POSITION pos;
  pos = m_Hash2Fonts.GetStartPosition();
  while (pos) {
    uint32_t dwHash;
    CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts;
    m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
    if (pFonts) {
      for (int32_t i = 0; i < pFonts->GetSize(); i++) {
        if (pFonts->GetAt(i) == pEFont)
          pFonts->SetAt(i, nullptr);
      }
    } else {
      m_Hash2Fonts.RemoveKey(dwHash);
    }
  }
}
Beispiel #5
0
void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex)
{
	CFX_DWordArray DelArray;
	CFX_ArrayTemplate<CJS_DelayData*> DelayDataForFieldAndControlIndex;

	for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
	{
		if (CJS_DelayData* pData = m_DelayData.GetAt(i))
		{
			if (pData->sFieldName == sFieldName && pData->nControlIndex == nControlIndex)
			{
				DelayDataForFieldAndControlIndex.Add(pData);
				m_DelayData.SetAt(i, NULL);
				DelArray.Add(i);
			}
		}
	}

	for (int j=DelArray.GetSize()-1; j>=0; j--)
	{
		m_DelayData.RemoveAt(DelArray[j]);
	}

	for (int i=0,sz=DelayDataForFieldAndControlIndex.GetSize(); i < sz; i++)
	{
		CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i);
		Field::DoDelay(m_pDocument, pData);
		DelayDataForFieldAndControlIndex.SetAt(i,NULL);
		delete pData;
	}
}
Beispiel #6
0
    int CountFields(int nLevel = 0) {
      if (nLevel > nMaxRecursion)
        return 0;
      if (field_ptr)
        return 1;

      int count = 0;
      for (int i = 0; i < children.GetSize(); i++)
        count += children.GetAt(i)->CountFields(nLevel + 1);
      return count;
    }
void CFDE_CSSStyleRule::SetSelector(
    IFX_MemoryAllocator* pStaticStore,
    const CFX_ArrayTemplate<CFDE_CSSSelector*>& list) {
  ASSERT(!m_ppSelector);
  m_iSelectors = list.GetSize();
  m_ppSelector = static_cast<CFDE_CSSSelector**>(
      pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*)));
  for (int32_t i = 0; i < m_iSelectors; ++i) {
    m_ppSelector[i] = list.GetAt(i);
  }
}
Beispiel #8
0
FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
	if (vp.IsGetting())
	{
		vp << m_bDelay;
		return TRUE;
	}
	else
	{
		ASSERT(m_pDocument != NULL);

		if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;

		bool b;
		vp >> b;

		m_bDelay = b;

		if (m_bDelay)
		{
			for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
				delete m_DelayData.GetAt(i);

			m_DelayData.RemoveAll();
		}
		else
		{
			CFX_ArrayTemplate<CJS_DelayData*> DelayDataToProcess;

			for (int i=0,sz=m_DelayData.GetSize(); i < sz; i++)
			{
				if (CJS_DelayData* pData = m_DelayData.GetAt(i))
				{
					DelayDataToProcess.Add(pData);
					m_DelayData.SetAt(i, NULL);
				}
			}
			m_DelayData.RemoveAll();

			for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i++)
			{
				CJS_DelayData* pData = DelayDataToProcess.GetAt(i);
				Field::DoDelay(m_pDocument, pData);
				DelayDataToProcess.SetAt(i,NULL);
				delete pData;
			}
		}

		return TRUE;
	}
}
Beispiel #9
0
    CPDF_FormField* GetField(int* fields_to_go) {
      if (field_ptr) {
        if (*fields_to_go == 0)
          return field_ptr;

        --*fields_to_go;
        return nullptr;
      }
      for (int i = 0; i < children.GetSize(); i++) {
        if (CPDF_FormField* pField = children.GetAt(i)->GetField(fields_to_go))
          return pField;
      }
      return nullptr;
    }
Beispiel #10
0
void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg,
                                      int32_t errorCorrectionLevel,
                                      int32_t& e) {
  int32_t errorCorrectionCodeWords =
      CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount(
          errorCorrectionLevel, e);
  if (e != BCExceptionNO)
    return;
  CFX_WideString highLevel =
      CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e);
  if (e != BCExceptionNO)
    return;
  int32_t sourceCodeWords = highLevel.GetLength();
  CFX_ArrayTemplate<int32_t>* dimension =
      determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e);
  if (e != BCExceptionNO)
    return;
  int32_t cols = dimension->GetAt(0);
  int32_t rows = dimension->GetAt(1);
  delete dimension;
  int32_t pad = getNumberOfPadCodewords(sourceCodeWords,
                                        errorCorrectionCodeWords, cols, rows);
  if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) {
    e = BCExceptionEncodedMessageContainsTooManyCodeWords;
    return;
  }
  int32_t n = sourceCodeWords + pad + 1;
  CFX_WideString sb;
  sb += (FX_WCHAR)n;
  sb += highLevel;
  for (int32_t i = 0; i < pad; i++) {
    sb += (FX_WCHAR)900;
  }
  CFX_WideString dataCodewords(sb);
  CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection(
      dataCodewords, errorCorrectionLevel, e);
  if (e != BCExceptionNO)
    return;
  CFX_WideString fullCodewords = dataCodewords + ec;
  m_barcodeMatrix = pdfium::MakeUnique<CBC_BarcodeMatrix>(rows, cols);
  encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel,
                 m_barcodeMatrix.get());
}
CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCodePage(
    uint16_t wCodePage,
    uint32_t dwFontStyles,
    const FX_WCHAR* pszFontFamily) {
  CFX_ByteString bsHash;
  bsHash.Format("%d, %d", wCodePage, dwFontStyles);
  bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
  uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
  CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr;
  if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
    if (!pFonts)
      return nullptr;

    if (pFonts->GetSize() != 0)
      return pFonts->GetAt(0)->Retain();
  }

  if (!pFonts)
    pFonts = new CFX_ArrayTemplate<CFGAS_GEFont*>;

  m_Hash2Fonts.SetAt(dwHash, pFonts);
  CFX_FontDescriptorInfos* sortedFonts = nullptr;
  if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) {
    sortedFonts = new CFX_FontDescriptorInfos;
    MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
               CFX_WideString(pszFontFamily), 0);
    m_Hash2CandidateList.SetAt(dwHash, sortedFonts);
  }
  if (sortedFonts->GetSize() == 0)
    return nullptr;

  CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont;
  CFGAS_GEFont* pFont =
      LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
  if (pFont)
    pFont->SetLogicalFontStyle(dwFontStyles);

  pFonts->Add(pFont);
  return pFont;
}