Esempio n. 1
0
FX_BOOL CFX_GEFont::GetCharBBox(FX_WCHAR wUnicode,
                                CFX_Rect& bbox,
                                FX_BOOL bRecursive,
                                FX_BOOL bCharCode) {
  FXSYS_assert(m_pRectArray != NULL);
  FXSYS_assert(m_pBBoxMap != NULL);
  void* pRect = NULL;
  if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) {
    IFX_Font* pFont = NULL;
    int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode);
    if (iGlyph != 0xFFFF && pFont != NULL) {
      if (pFont == (IFX_Font*)this) {
        FX_RECT rtBBox;
        if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
          Lock();
          CFX_Rect rt;
          rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
          int32_t index = m_pRectArray->Add(rt);
          pRect = m_pRectArray->GetPtrAt(index);
          m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect);
          Unlock();
        }
      } else if (((CFX_GEFont*)pFont)
                     ->GetCharBBox(wUnicode, bbox, FALSE, bCharCode)) {
        return TRUE;
      }
    }
  }
  if (pRect == NULL) {
    return FALSE;
  }
  bbox = *(FX_LPCRECT)pRect;
  return TRUE;
}
Esempio n. 2
0
uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) {
  FXSYS_assert(iYear != 0);
  FXSYS_assert(iMonth >= 1 && iMonth <= 12);
  const uint8_t* p =
      FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth;
  return p[iMonth - 1];
}
Esempio n. 3
0
void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) {
  if (used_bytes == 0) {
    return;
  }
  if (m_Operator < 128) {
    FXSYS_assert((FX_DWORD)m_Operator + 1 >= used_bytes);
    if (used_bytes == m_Operator + 1) {
      m_SrcOffset += used_bytes;
      GetNextOperator();
      return;
    }
    m_Operator -= used_bytes;
    m_SrcOffset += used_bytes;
    if (m_SrcOffset >= m_SrcSize) {
      m_Operator = 128;
    }
    return;
  }
  uint8_t count = 257 - m_Operator;
  FXSYS_assert((FX_DWORD)count >= used_bytes);
  if (used_bytes == count) {
    m_SrcOffset++;
    GetNextOperator();
    return;
  }
  count -= used_bytes;
  m_Operator = 257 - count;
}
Esempio n. 4
0
void CFDE_RenderContext::RenderPath(IFDE_PathSet* pPathSet,
                                    FDE_HVISUALOBJ hPath) {
  FXSYS_assert(m_pRenderDevice != NULL);
  FXSYS_assert(pPathSet != NULL && hPath != NULL);
  IFDE_Path* pPath = pPathSet->GetPath(hPath);
  if (pPath == NULL) {
    return;
  }
  FDE_HDEVICESTATE hState;
  FX_BOOL bClip = ApplyClip(pPathSet, hPath, hState);
  int32_t iRenderMode = pPathSet->GetRenderMode(hPath);
  if (iRenderMode & FDE_PATHRENDER_Stroke) {
    IFDE_Pen* pPen = pPathSet->GetPen(hPath);
    FX_FLOAT fWidth = pPathSet->GetPenWidth(hPath);
    if (pPen != NULL && fWidth > 0) {
      m_pRenderDevice->DrawPath(pPen, fWidth, pPath, &m_Transform);
    }
  }
  if (iRenderMode & FDE_PATHRENDER_Fill) {
    IFDE_Brush* pBrush = pPathSet->GetBrush(hPath);
    if (pBrush != NULL) {
      m_pRenderDevice->FillPath(pBrush, pPath, &m_Transform);
    }
  }
  if (bClip) {
    RestoreClip(hState);
  }
}
Esempio n. 5
0
FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) {
  FXSYS_assert(pStr != NULL);
  if (iLength < 0) {
    iLength = FXSYS_strlen(pStr);
  }
  if (iLength == 0) {
    return 0xFFFF;
  }
  uint32_t uHash = FX_HashCode_String_GetA(pStr, iLength, TRUE);
  int32_t iStart = 0, iMid;
  int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1;
  FXSYS_assert(iEnd >= 0);
  do {
    iMid = (iStart + iEnd) / 2;
    const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid];
    if (uHash == cp.uHash) {
      return (FX_WORD)cp.uCodePage;
    } else if (uHash < cp.uHash) {
      iEnd = iMid - 1;
    } else {
      iStart = iMid + 1;
    }
  } while (iStart <= iEnd);
  return 0xFFFF;
}
Esempio n. 6
0
static int32_t FX_DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) {
  FXSYS_assert(iYear != 0);
  FXSYS_assert(iMonth >= 1 && iMonth <= 12);
  const int32_t* p =
      FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth;
  return p[iMonth - 1];
}
Esempio n. 7
0
void CFDE_TxtEdtBuf::Insert(int32_t nPos,
                            const FX_WCHAR* lpText,
                            int32_t nLength) {
  FXSYS_assert(nPos >= 0 && nPos <= m_nTotal);
  FDE_CHUNKPLACE cp;
  Index2CP(nPos, cp);
  int32_t nLengthTemp = nLength;
  if (cp.nCharIndex != 0) {
    FDE_LPCHUNKHEADER lpNewChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
        sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
    FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex];
    int32_t nCopy = lpChunk->nUsed - cp.nCharIndex;
    FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex,
                 nCopy * sizeof(FX_WCHAR));
    lpChunk->nUsed -= nCopy;
    cp.nChunkIndex++;
    m_Chunks.InsertAt(cp.nChunkIndex, lpNewChunk);
    lpNewChunk->nUsed = nCopy;
    cp.nCharIndex = 0;
  }
  if (cp.nChunkIndex != 0) {
    FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex - 1];
    if (lpChunk->nUsed != m_nChunkSize) {
      cp.nChunkIndex--;
      int32_t nFree = m_nChunkSize - lpChunk->nUsed;
      int32_t nCopy = std::min(nLengthTemp, nFree);
      FXSYS_memcpy(lpChunk->wChars + lpChunk->nUsed, lpText,
                   nCopy * sizeof(FX_WCHAR));
      lpText += nCopy;
      nLengthTemp -= nCopy;
      lpChunk->nUsed += nCopy;
      cp.nChunkIndex++;
    }
  }
  while (nLengthTemp > 0) {
    FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
        sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
    FXSYS_assert(lpChunk);
    int32_t nCopy = std::min(nLengthTemp, m_nChunkSize);
    FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR));
    lpText += nCopy;
    nLengthTemp -= nCopy;
    lpChunk->nUsed = nCopy;
    m_Chunks.InsertAt(cp.nChunkIndex, lpChunk);
    cp.nChunkIndex++;
  }
  m_nTotal += nLength;
  m_bChanged = TRUE;
}
Esempio n. 8
0
FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) {
  if (bPrev) {
    if (m_nIndex == 0) {
      return FALSE;
    }
    FXSYS_assert(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
    CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk = NULL;
    if (m_nCurIndex > 0) {
      m_nCurIndex--;
    } else {
      while (m_nCurChunk > 0) {
        --m_nCurChunk;
        lpChunk =
            (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
        if (lpChunk->nUsed > 0) {
          m_nCurIndex = lpChunk->nUsed - 1;
          break;
        }
      }
    }
    FXSYS_assert(m_nCurChunk >= 0);
    m_nIndex--;
    return TRUE;
  } else {
    if (m_nIndex >= (m_pBuf->m_nTotal - 1)) {
      return FALSE;
    }
    FXSYS_assert(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
    CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk =
        (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
    if (lpChunk->nUsed != (m_nCurIndex + 1)) {
      m_nCurIndex++;
    } else {
      int32_t nEnd = m_pBuf->m_Chunks.GetSize() - 1;
      while (m_nCurChunk < nEnd) {
        m_nCurChunk++;
        CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunkTemp =
            (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
        if (lpChunkTemp->nUsed > 0) {
          m_nCurIndex = 0;
          break;
        }
      }
    }
    m_nIndex++;
    return TRUE;
  }
}
Esempio n. 9
0
FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode,
                                 int32_t& iWidth,
                                 FX_BOOL bRecursive,
                                 FX_BOOL bCharCode) {
  FXSYS_assert(m_pCharWidthMap != NULL);
  iWidth = m_pCharWidthMap->GetAt(wUnicode, 0);
  if (iWidth < 1) {
    if (!m_pProvider ||
        !m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) {
      IFX_Font* pFont = NULL;
      int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode);
      if (iGlyph != 0xFFFF && pFont != NULL) {
        if (pFont == (IFX_Font*)this) {
          iWidth = m_pFont->GetGlyphWidth(iGlyph);
          if (iWidth < 0) {
            iWidth = -1;
          }
        } else if (((CFX_GEFont*)pFont)
                       ->GetCharWidth(wUnicode, iWidth, FALSE, bCharCode)) {
          return TRUE;
        }
      } else {
        iWidth = -1;
      }
    }
    Lock();
    m_pCharWidthMap->SetAtGrow(wUnicode, (int16_t)iWidth);
    Unlock();
  } else if (iWidth == 65535) {
    iWidth = -1;
  }
  return iWidth > 0;
}
Esempio n. 10
0
FX_DWORD CFX_GEFont::GetFontStyles() const {
  FXSYS_assert(m_pFont != NULL);
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
  if (m_bUseLogFontStyle) {
    return m_dwLogFontStyle;
  }
#endif
  FX_DWORD dwStyles = 0;
  if (!m_pFont->GetSubstFont()) {
    if (m_pFont->IsBold()) {
      dwStyles |= FX_FONTSTYLE_Bold;
    }
    if (m_pFont->IsItalic()) {
      dwStyles |= FX_FONTSTYLE_Italic;
    }
  } else {
    if (m_pFont->GetSubstFont()->m_Weight == FXFONT_FW_BOLD) {
      dwStyles |= FX_FONTSTYLE_Bold;
    }
    if (m_pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_ITALIC) {
      dwStyles |= FX_FONTSTYLE_Italic;
    }
  }
  return dwStyles;
}
Esempio n. 11
0
void CFDE_CSSStyleSheet::Reset() {
  for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) {
    IFDE_CSSRule* pRule = m_RuleArray.GetAt(i);
    switch (pRule->GetType()) {
      case FDE_CSSRULETYPE_Style:
        ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule();
        break;
      case FDE_CSSRULETYPE_Media:
        ((CFDE_CSSMediaRule*)pRule)->~CFDE_CSSMediaRule();
        break;
      case FDE_CSSRULETYPE_FontFace:
        ((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule();
        break;
      default:
        FXSYS_assert(FALSE);
        break;
    }
  }
  m_RuleArray.RemoveAll();
  m_Selectors.RemoveAll();
  m_StringCache.RemoveAll();
  if (m_pAllocator) {
    m_pAllocator->Release();
    m_pAllocator = NULL;
  }
}
Esempio n. 12
0
void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) {
  FXSYS_assert(nLength > 0 && nIndex >= 0 && nIndex + nLength <= m_nTotal);
  FDE_CHUNKPLACE cpEnd;
  Index2CP(nIndex + nLength - 1, cpEnd);
  m_nTotal -= nLength;
  FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex];
  int32_t nFirstPart = cpEnd.nCharIndex + 1;
  int32_t nMovePart = lpChunk->nUsed - nFirstPart;
  if (nMovePart != 0) {
    int32_t nDelete = std::min(nFirstPart, nLength);
    FXSYS_memmove(lpChunk->wChars + nFirstPart - nDelete,
                  lpChunk->wChars + nFirstPart, nMovePart * sizeof(FX_WCHAR));
    lpChunk->nUsed -= nDelete;
    nLength -= nDelete;
    cpEnd.nChunkIndex--;
  }
  while (nLength > 0) {
    lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex];
    int32_t nDeleted = std::min(lpChunk->nUsed, nLength);
    lpChunk->nUsed -= nDeleted;
    if (lpChunk->nUsed == 0) {
      m_pAllocator->Free(lpChunk);
      m_Chunks.RemoveAt(cpEnd.nChunkIndex);
      lpChunk = NULL;
    }
    nLength -= nDeleted;
    cpEnd.nChunkIndex--;
  }
  m_bChanged = TRUE;
}
Esempio n. 13
0
FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
  FXSYS_assert(nIndex >= 0 && nIndex < GetTextLength());
  FDE_LPCHUNKHEADER pChunkHeader = NULL;
  int32_t nTotal = 0;
  int32_t nCount = m_Chunks.GetSize();
  int32_t i = 0;
  for (i = 0; i < nCount; i++) {
    pChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[i];
    nTotal += pChunkHeader->nUsed;
    if (nTotal > nIndex) {
      break;
    }
  }
  FXSYS_assert(pChunkHeader);
  return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)];
}
Esempio n. 14
0
void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
  FXSYS_assert(!wsText.IsEmpty());
  Clear(FALSE);
  int32_t nTextLength = wsText.GetLength();
  int32_t nNeedCount =
      ((nTextLength - 1) / m_nChunkSize + 1) - m_Chunks.GetSize();
  int32_t i = 0;
  for (i = 0; i < nNeedCount; i++) {
    FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
        sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
    lpChunk->nUsed = 0;
    m_Chunks.Add(lpChunk);
  }
  int32_t nTotalCount = m_Chunks.GetSize();
  const FX_WCHAR* lpSrcBuf = wsText.c_str();
  int32_t nLeave = nTextLength;
  int32_t nCopyedLength = m_nChunkSize;
  for (i = 0; i < nTotalCount && nLeave > 0; i++) {
    if (nLeave < nCopyedLength) {
      nCopyedLength = nLeave;
    }
    FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i];
    FXSYS_memcpy(lpChunk->wChars, lpSrcBuf, nCopyedLength * sizeof(FX_WCHAR));
    nLeave -= nCopyedLength;
    lpSrcBuf += nCopyedLength;
    lpChunk->nUsed = nCopyedLength;
  }
  m_nTotal = nTextLength;
  m_bChanged = TRUE;
}
Esempio n. 15
0
CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) {
  if (!pObj) {
    return NULL;
  }
  FXSYS_assert(pObj->GetObjNum());
  return GetValidatePageData()->GetImage(pObj);
}
Esempio n. 16
0
CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList)
    : m_wCodePage(FX_CODEPAGE_UTF8),
      m_wRefCount(1),
      m_dwMediaList(dwMediaList),
      m_pAllocator(NULL) {
  FXSYS_assert(m_dwMediaList > 0);
}
FX_BOOL CCodec_JpegDecoder::v_Rewind()
{
    if (m_pExtProvider) {
        return m_pExtProvider->Rewind(m_pExtContext);
    }
    if (m_bStarted) {
        jpeg_destroy_decompress(&cinfo);
        if (!InitDecode()) {
            return FALSE;
        }
    }
    if (setjmp(m_JmpBuf) == -1) {
        return FALSE;
    }
    cinfo.scale_denom = m_nDefaultScaleDenom * m_DownScale;
    m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale;
    m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale;
    if (!jpeg_start_decompress(&cinfo)) {
        jpeg_destroy_decompress(&cinfo);
        return FALSE;
    }
    if ((int)cinfo.output_width > m_OrigWidth) {
        FXSYS_assert(FALSE);
        return FALSE;
    }
    m_bStarted = TRUE;
    return TRUE;
}
Esempio n. 18
0
FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile,
                               FX_DWORD dwStart,
                               FX_DWORD dwLen) {
  FXSYS_assert(m_pFile == NULL && pFile != NULL);
  FX_DWORD dwSize = pFile->GetSize();
  if (dwStart >= dwSize) {
    return FALSE;
  }
  if (dwLen == -1 || dwStart + dwLen > dwSize) {
    dwLen = dwSize - dwStart;
  }
  if (dwLen == 0) {
    return FALSE;
  }
  m_dwBufSize = std::min(dwLen, kSaxFileBufSize);
  m_pBuf = FX_Alloc(uint8_t, m_dwBufSize);
  if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) {
    return FALSE;
  }
  m_dwStart = dwStart;
  m_dwEnd = dwStart + dwLen;
  m_dwCur = dwStart;
  m_pFile = pFile;
  m_dwBufIndex = 0;
  return TRUE;
}
// static
CFX_WideString::StringData* CFX_WideString::StringData::Create(int nLen)
{
    // TODO(palmer): |nLen| should really be declared as |size_t|, or
    // at least unsigned.
    if (nLen == 0 || nLen < 0) {
        return NULL;
    }

    // Fixed portion of header plus a NUL wide char not in m_nAllocLength.
    int overhead = offsetof(StringData, m_String) + sizeof(FX_WCHAR);
    pdfium::base::CheckedNumeric<int> iSize = nLen;
    iSize *= sizeof(FX_WCHAR);
    iSize += overhead;

    // Now round to an 8-byte boundary. We'd expect that this is the minimum
    // granularity of any of the underlying allocators, so there may be cases
    // where we can save a re-alloc when adding a few characters to a string
    // by using this otherwise wasted space.
    iSize += 7;
    int totalSize = iSize.ValueOrDie() & ~7;
    int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR);
    FXSYS_assert(usableLen >= nLen);

    void* pData = FX_Alloc(uint8_t, iSize.ValueOrDie());
    return new (pData) StringData(nLen, usableLen);
}
Esempio n. 20
0
void CFX_SAXReader::NotifyClose() {
  FXSYS_assert(m_pHandler != NULL);
  if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
      m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
    m_pHandler->OnTagClose(m_pCurItem->m_pNode, m_dwNodePos);
  }
}
Esempio n. 21
0
static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary* pFieldDict,
                                      CFX_WideString& csValue,
                                      CFX_ByteString& bsEncoding) {
  ASSERT(pFieldDict != NULL);
  CFX_ByteString csBValue = pFieldDict->GetString("V");
  int32_t iCount = sizeof(g_fieldEncoding) / sizeof(g_fieldEncoding[0]);
  int32_t i = 0;
  for (; i < iCount; ++i)
    if (bsEncoding == g_fieldEncoding[i].m_name) {
      break;
    }
  if (i < iCount) {
    CFX_CharMap* pCharMap =
        CFX_CharMap::GetDefaultMapper(g_fieldEncoding[i].m_codePage);
    FXSYS_assert(pCharMap != NULL);
    csValue.ConvertFrom(csBValue, pCharMap);
    return;
  }
  CFX_ByteString csTemp = csBValue.Left(2);
  if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") {
    csValue = PDF_DecodeText(csBValue);
  } else {
    csValue = CFX_WideString::FromLocal(csBValue);
  }
}
void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter(
    int32_t iCurIndex,
    CFX_WideString wsCondition,
    int32_t iFoundCount,
    CXFA_ResolveNodesData& rnd) {
  CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
  FXSYS_assert(iFoundCount == findNodes.GetSize());
  CFX_WideString wsExpression;
  IXFA_ScriptContext* pContext = NULL;
  XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown;
  if (wsCondition.Left(2) == FX_WSTRC(L".[") &&
      wsCondition.Right(1) == FX_WSTRC(L"]")) {
    eLangType = XFA_SCRIPTLANGTYPE_Formcalc;
  } else if (wsCondition.Left(2) == FX_WSTRC(L".(") &&
             wsCondition.Right(1) == FX_WSTRC(L")")) {
    eLangType = XFA_SCRIPTLANGTYPE_Javascript;
  } else {
    return;
  }
  pContext = rnd.m_pSC;
  wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3);
  for (int32_t i = iFoundCount - 1; i >= 0; i--) {
    CXFA_Object* node = findNodes[i];
    FX_BOOL bRet = FALSE;
    FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime());
    bRet = pContext->RunScript(eLangType, wsExpression, pRetValue, node);
    if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) {
      findNodes.RemoveAt(i);
    }
    FXJSE_Value_Release(pRetValue);
  }
}
Esempio n. 23
0
void CPDF_Metadata::LoadDoc(CPDF_Document *pDoc)
{
    FXSYS_assert(pDoc != NULL);
    ((PDFDOC_LPMETADATA)m_pData)->m_pDoc = pDoc;
    CPDF_Dictionary *pRoot = pDoc->GetRoot();
    CPDF_Stream *pStream = pRoot->GetStream(FX_BSTRC("Metadata"));
    if (!pStream) {
        return;
    }
    CPDF_StreamAcc acc;
    acc.LoadAllData(pStream, FALSE);
    int size = acc.GetSize();
    FX_LPCBYTE pBuf = acc.GetData();
    CXML_Element *&pXmlElmnt = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt;
    pXmlElmnt = CXML_Element::Parse(pBuf, size);
    if (!pXmlElmnt) {
        return;
    }
    CXML_Element *&pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf;
    if (pXmlElmnt->GetTagName() == FX_BSTRC("RDF")) {
        pElmntRdf = pXmlElmnt;
    } else {
        pElmntRdf = pXmlElmnt->GetElement(NULL, FX_BSTRC("RDF"));
    }
}
Esempio n. 24
0
int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst) {
  FXSYS_assert(pSrc != NULL);
  if (iSrcLen < 1) {
    return 0;
  }
  if (pDst == NULL) {
    int32_t iDstLen = iSrcLen / 3 * 4;
    if ((iSrcLen % 3) != 0) {
      iDstLen += 4;
    }
    return iDstLen;
  }
  FX_BASE64DATA srcData;
  int32_t iBytes = 3;
  FX_CHAR* pDstEnd = pDst;
  while (iSrcLen > 0) {
    if (iSrcLen > 2) {
      ((uint8_t*)&srcData)[0] = *pSrc++;
      ((uint8_t*)&srcData)[1] = *pSrc++;
      ((uint8_t*)&srcData)[2] = *pSrc++;
      iSrcLen -= 3;
    } else {
      *((FX_DWORD*)&srcData) = 0;
      ((uint8_t*)&srcData)[0] = *pSrc++;
      if (iSrcLen > 1) {
        ((uint8_t*)&srcData)[1] = *pSrc++;
      }
      iBytes = iSrcLen;
      iSrcLen = 0;
    }
    FX_Base64EncodePiece(srcData, iBytes, pDstEnd);
    pDstEnd += 4;
  }
  return pDstEnd - pDst;
}
Esempio n. 25
0
static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc,
                                              const CPDF_Dictionary* pOCGDict,
                                              const CFX_ByteStringC& bsState) {
  FXSYS_assert(pDoc && pOCGDict);
  CPDF_Dictionary* pOCProperties =
      pDoc->GetRoot()->GetDict(FX_BSTRC("OCProperties"));
  if (!pOCProperties) {
    return NULL;
  }
  CPDF_Array* pOCGs = pOCProperties->GetArray(FX_BSTRC("OCGs"));
  if (!pOCGs) {
    return NULL;
  }
  if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) {
    return NULL;
  }
  CPDF_Dictionary* pConfig = pOCProperties->GetDict(FX_BSTRC("D"));
  CPDF_Array* pConfigs = pOCProperties->GetArray(FX_BSTRC("Configs"));
  if (pConfigs) {
    CPDF_Dictionary* pFind;
    int32_t iCount = pConfigs->GetCount();
    for (int32_t i = 0; i < iCount; i++) {
      pFind = pConfigs->GetDict(i);
      if (!pFind) {
        continue;
      }
      if (!FPDFDOC_OCG_HasIntent(pFind, FX_BSTRC("View"), FX_BSTRC("View"))) {
        continue;
      }
      pConfig = pFind;
      break;
    }
  }
  return pConfig;
}
Esempio n. 26
0
FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice,
                                        IFDE_CanvasSet* pCanvasSet,
                                        const CFX_Matrix& tmDoc2Device) {
  if (m_pRenderDevice != NULL) {
    return FALSE;
  }
  if (pRenderDevice == NULL) {
    return FALSE;
  }
  if (pCanvasSet == NULL) {
    return FALSE;
  }
  Lock();
  m_eStatus = FDE_RENDERSTATUS_Paused;
  m_pRenderDevice = pRenderDevice;
  m_Transform = tmDoc2Device;
  if (m_pIterator == NULL) {
    m_pIterator = IFDE_VisualSetIterator::Create();
    FXSYS_assert(m_pIterator != NULL);
  }
  FX_BOOL bAttach =
      m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
  Unlock();
  return bAttach;
}
Esempio n. 27
0
FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
  if (m_pRenderDevice == NULL) {
    return FDE_RENDERSTATUS_Failed;
  }
  if (m_pIterator == NULL) {
    return FDE_RENDERSTATUS_Failed;
  }
  Lock();
  FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused;
  CFX_Matrix rm;
  rm.SetReverse(m_Transform);
  CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect();
  if (rtDocClip.IsEmpty()) {
    rtDocClip.left = rtDocClip.top = 0;
    rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth();
    rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight();
  }
  rm.TransformRect(rtDocClip);
  IFDE_VisualSet* pVisualSet;
  FDE_HVISUALOBJ hVisualObj;
  CFX_RectF rtObj;
  int32_t iCount = 0;
  while (TRUE) {
    hVisualObj = m_pIterator->GetNext(pVisualSet);
    if (hVisualObj == NULL || pVisualSet == NULL) {
      eStatus = FDE_RENDERSTATUS_Done;
      break;
    }
    rtObj.Empty();
    pVisualSet->GetRect(hVisualObj, rtObj);
    if (!rtDocClip.IntersectWith(rtObj)) {
      continue;
    }
    switch (pVisualSet->GetType()) {
      case FDE_VISUALOBJ_Text:
        RenderText((IFDE_TextSet*)pVisualSet, hVisualObj);
        iCount += 5;
        break;
      case FDE_VISUALOBJ_Path:
        RenderPath((IFDE_PathSet*)pVisualSet, hVisualObj);
        iCount += 20;
        break;
      case FDE_VISUALOBJ_Widget:
        iCount += 10;
        break;
      case FDE_VISUALOBJ_Canvas:
        FXSYS_assert(FALSE);
        break;
      default:
        break;
    }
    if (iCount >= 100 && pPause != NULL && pPause->NeedToPauseNow()) {
      eStatus = FDE_RENDERSTATUS_Paused;
      break;
    }
  }
  Unlock();
  return m_eStatus = eStatus;
}
Esempio n. 28
0
void CFX_SAXReader::NotifyData() {
  FXSYS_assert(m_pHandler != NULL);
  if (m_pCurItem->m_eNode == FX_SAXNODE_Tag)
    m_pHandler->OnTagData(m_pCurItem->m_pNode,
                          m_bCharData ? FX_SAXNODE_CharData : FX_SAXNODE_Text,
                          CFX_ByteStringC(m_pszData, m_iDataLength),
                          m_File.m_dwCur + m_dwDataOffset);
}
Esempio n. 29
0
void CPDF_StreamContentParser::AddContainer(CPDF_Object* pObject)
{
    if (m_ObjectSize) {
        m_pObjectState[m_ObjectSize] = SetToCurObj(pObject);
    }
    FXSYS_assert(m_ObjectSize < _FPDF_MAX_OBJECT_STACK_SIZE_);
    m_pObjectStack[m_ObjectSize++] = pObject;
}
Esempio n. 30
0
void CFX_SAXReader::NotifyEnd() {
  FXSYS_assert(m_pHandler != NULL);
  if (m_pCurItem->m_eNode == FX_SAXNODE_Tag) {
    m_pHandler->OnTagEnd(m_pCurItem->m_pNode,
                         CFX_ByteStringC(m_pszData, m_iDataLength),
                         m_dwNodePos);
  }
}