예제 #1
0
FX_BOOL CPDFSDK_Document::ProcOpenAction() {
  if (!m_pDoc)
    return FALSE;

  CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
  if (!pRoot)
    return FALSE;

  CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
  if (!pOpenAction)
    pOpenAction = pRoot->GetArray("OpenAction");

  if (!pOpenAction)
    return FALSE;

  if (pOpenAction->IsArray())
    return TRUE;

  if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {
    CPDF_Action action(pDict);
    if (m_pEnv->GetActionHander())
      m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
    return TRUE;
  }
  return FALSE;
}
예제 #2
0
FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) {
  if (!pFormDict) {
    return 0;
  }
  CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
  if (!pDR) {
    return 0;
  }
  CPDF_Dictionary* pFonts = pDR->GetDict("Font");
  if (!pFonts) {
    return 0;
  }
  FX_DWORD dwCount = 0;
  for (const auto& it : *pFonts) {
    CPDF_Object* pObj = it.second;
    if (!pObj) {
      continue;
    }
    if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
      if (pDirect->GetString("Type") == "Font") {
        dwCount++;
      }
    }
  }
  return dwCount;
}
예제 #3
0
static int InsertNewPage(CPDF_Document* pDoc, int iPage, CPDF_Dictionary* pPageDict, CFX_DWordArray &pageList)
{
    CPDF_Dictionary* pRoot = pDoc->GetRoot();
    if (!pRoot) {
        return -1;
    }
    CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages"));
    if (!pPages) {
        return -1;
    }
    int nPages = pDoc->GetPageCount();
    if (iPage < 0 || iPage > nPages) {
        return -1;
    }
    if (iPage == nPages) {
        CPDF_Array* pPagesList = pPages->GetArray(FX_BSTRC("Kids"));
        if (!pPagesList) {
            pPagesList = FX_NEW CPDF_Array;
            pPages->SetAt(FX_BSTRC("Kids"), pPagesList);
        }
        pPagesList->Add(pPageDict, pDoc);
        pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1);
        pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum());
    } else {
        CFX_PtrArray stack;
        stack.Add(pPages);
        if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) {
            return -1;
        }
    }
    pageList.InsertAt(iPage, pPageDict->GetObjNum());
    return iPage;
}
예제 #4
0
CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP)
    : CFX_PrivateData(),
      m_pDocument(pDocument),
      m_bGenerateAP(bGenerateAP),
      m_pFormDict(nullptr),
      m_pFieldTree(new CFieldTree),
      m_pFormNotify(nullptr),
      m_bUpdated(FALSE) {
  CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
  if (!pRoot)
    return;

  m_pFormDict = pRoot->GetDict("AcroForm");
  if (!m_pFormDict)
    return;

  CPDF_Array* pFields = m_pFormDict->GetArray("Fields");
  if (!pFields)
    return;

  int count = pFields->GetCount();
  for (int i = 0; i < count; i++) {
    LoadField(pFields->GetDict(i));
  }
}
FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict)
{
    if (pFormDict == NULL) {
        return 0;
    }
    CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
    if (pDR == NULL) {
        return 0;
    }
    CPDF_Dictionary* pFonts = pDR->GetDict("Font");
    if (pFonts == NULL) {
        return 0;
    }
    FX_DWORD dwCount = 0;
    FX_POSITION pos = pFonts->GetStartPos();
    while (pos) {
        CPDF_Object* pObj = NULL;
        CFX_ByteString csKey;
        pObj = pFonts->GetNextElement(pos, csKey);
        if (pObj == NULL) {
            continue;
        }
        CPDF_Object* pDirect = pObj->GetDirect();
        if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) {
            if (((CPDF_Dictionary*)pDirect)->GetString("Type") == "Font") {
                dwCount ++;
            }
        }
    }
    return dwCount;
}
예제 #6
0
static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document *pDoc, const CPDF_Dictionary *pOCGDict, FX_BSTR 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;
        FX_INT32 iCount = pConfigs->GetCount();
        for (FX_INT32 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;
}
int CPDF_Document::GetPageIndex(FX_DWORD objnum) {
    FX_DWORD nPages = m_PageList.GetSize();
    FX_DWORD skip_count = 0;
    FX_BOOL bSkipped = FALSE;
    for (FX_DWORD i = 0; i < nPages; i++) {
        FX_DWORD objnum1 = m_PageList.GetAt(i);
        if (objnum1 == objnum) {
            return i;
        }
        if (!bSkipped && objnum1 == 0) {
            skip_count = i;
            bSkipped = TRUE;
        }
    }
    CPDF_Dictionary* pRoot = GetRoot();
    if (!pRoot) {
        return -1;
    }
    CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
    if (!pPages) {
        return -1;
    }
    int index = 0;
    return _FindPageIndex(pPages, skip_count, objnum, index);
}
CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
    if (iPage < 0 || iPage >= m_PageList.GetSize())
        return nullptr;

    if (m_bLinearized && (iPage == (int)m_dwFirstPageNo)) {
        if (CPDF_Dictionary* pDict =
                    ToDictionary(GetIndirectObject(m_dwFirstPageObjNum, nullptr)))
            return pDict;
    }

    int objnum = m_PageList.GetAt(iPage);
    if (objnum) {
        if (CPDF_Dictionary* pDict =
                    ToDictionary(GetIndirectObject(objnum, nullptr))) {
            return pDict;
        }
    }

    CPDF_Dictionary* pRoot = GetRoot();
    if (!pRoot)
        return nullptr;

    CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
    if (!pPages)
        return nullptr;

    CPDF_Dictionary* pPage = _FindPDFPage(pPages, iPage, iPage, 0);
    if (!pPage)
        return nullptr;

    m_PageList.SetAt(iPage, pPage->GetObjNum());
    return pPage;
}
예제 #9
0
FX_BOOL CPDFSDK_Document::ProcOpenAction()
{
    if(!m_pDoc)
        return FALSE;

    CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
    if (!pRoot)
        return FALSE;

    CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
    if(!pOpenAction)
        pOpenAction = pRoot->GetArray("OpenAction");

    if(!pOpenAction)
        return FALSE;

    if(pOpenAction->GetType()==PDFOBJ_ARRAY)
        return TRUE;

    if(pOpenAction->GetType()==PDFOBJ_DICTIONARY)
    {
        CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction;
        CPDF_Action action(pDict);
        if(m_pEnv->GetActionHander())
            m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
        return TRUE;
    }
    return FALSE;
}
예제 #10
0
CFX_ByteString CPDF_ViewerPreferences::Duplex() const {
  CPDF_Dictionary* pDict = m_pDoc->GetRoot();
  pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences"));
  if (!pDict) {
    return FX_BSTRC("None");
  }
  return pDict->GetString(FX_BSTRC("Duplex"));
}
예제 #11
0
int32_t CPDF_ViewerPreferences::NumCopies() const {
  CPDF_Dictionary* pDict = m_pDoc->GetRoot();
  pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences"));
  if (!pDict) {
    return 1;
  }
  return pDict->GetInteger(FX_BSTRC("NumCopies"));
}
예제 #12
0
FX_BOOL CPDF_ViewerPreferences::PrintScaling() const {
  CPDF_Dictionary* pDict = m_pDoc->GetRoot();
  pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences"));
  if (!pDict) {
    return TRUE;
  }
  return FX_BSTRC("None") != pDict->GetString(FX_BSTRC("PrintScaling"));
}
예제 #13
0
FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const {
  CPDF_Dictionary* pDict = m_pDoc->GetRoot();
  pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences"));
  if (!pDict) {
    return FALSE;
  }
  return FX_BSTRC("R2L") == pDict->GetString(FX_BSTRC("Direction"));
}
예제 #14
0
CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
  ASSERT(m_pAnnotDict != NULL);
  ASSERT(m_pDocument != NULL);

  CPDF_Dictionary* pAcroFormDict = NULL;

  FX_BOOL bWidget = (m_pAnnotDict->GetString("Subtype") == "Widget");

  if (bWidget) {
    if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
      pAcroFormDict = pRootDict->GetDict("AcroForm");
  }

  CFX_ByteString sDA;
  CPDF_Object* pObj;
  if ((pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA")))
    sDA = pObj->GetString();

  if (bWidget) {
    if (sDA.IsEmpty()) {
      pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA");
      sDA = pObj ? pObj->GetString() : CFX_ByteString();
    }
  }

  CPDF_Dictionary* pFontDict = NULL;

  if (!sDA.IsEmpty()) {
    CPDF_SimpleParser syntax(sDA);
    syntax.FindTagParam("Tf", 2);
    CFX_ByteString sFontName = syntax.GetWord();
    sAlias = PDF_NameDecode(sFontName).Mid(1);

    if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDict("DR"))
      if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDict("Font"))
        pFontDict = pDRFontDict->GetDict(sAlias);

    if (!pFontDict)
      if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"))
        if (CPDF_Dictionary* pNormalDict = pAPDict->GetDict("N"))
          if (CPDF_Dictionary* pNormalResDict =
                  pNormalDict->GetDict("Resources"))
            if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDict("Font"))
              pFontDict = pResFontDict->GetDict(sAlias);

    if (bWidget) {
      if (!pFontDict) {
        if (pAcroFormDict) {
          if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDict("DR"))
            if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDict("Font"))
              pFontDict = pDRFontDict->GetDict(sAlias);
        }
      }
    }
  }

  return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr;
}
예제 #15
0
CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc)
{
    CPDF_Dictionary* pCatalog = pDoc->GetRoot();
    m_pTreeRoot = pCatalog->GetDict(FX_BSTRC("StructTreeRoot"));
    if (m_pTreeRoot == NULL) {
        return;
    }
    m_pRoleMap = m_pTreeRoot->GetDict(FX_BSTRC("RoleMap"));
}
예제 #16
0
CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
  CPDF_Dictionary* pDict = m_pDoc->GetRoot();
  CPDF_Array* pRange = NULL;
  pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences"));
  if (!pDict) {
    return pRange;
  }
  pRange = pDict->GetArray(FX_BSTRC("PrintPageRange"));
  return pRange;
}
예제 #17
0
void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
                                      const CPDF_Rect& rcBBox,
                                      const CFX_Matrix& matrix,
                                      const CFX_ByteString& sContents,
                                      const CFX_ByteString& sAPState) {
  CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");

  if (!pAPDict) {
    pAPDict = new CPDF_Dictionary;
    m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
  }

  CPDF_Stream* pStream = nullptr;
  CPDF_Dictionary* pParentDict = nullptr;

  if (sAPState.IsEmpty()) {
    pParentDict = pAPDict;
    pStream = pAPDict->GetStream(sAPType);
  } else {
    CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
    if (!pAPTypeDict) {
      pAPTypeDict = new CPDF_Dictionary;
      pAPDict->SetAt(sAPType, pAPTypeDict);
    }

    pParentDict = pAPTypeDict;
    pStream = pAPTypeDict->GetStream(sAPState);
  }

  if (!pStream) {
    pStream = new CPDF_Stream(nullptr, 0, nullptr);

    CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
    int32_t objnum = pDoc->AddIndirectObject(pStream);
    pParentDict->SetAtReference(sAPType, pDoc, objnum);
  }

  CPDF_Dictionary* pStreamDict = pStream->GetDict();
  if (!pStreamDict) {
    pStreamDict = new CPDF_Dictionary;
    pStreamDict->SetAtName("Type", "XObject");
    pStreamDict->SetAtName("Subtype", "Form");
    pStreamDict->SetAtInteger("FormType", 1);
    pStream->InitStream(nullptr, 0, pStreamDict);
  }

  if (pStreamDict) {
    pStreamDict->SetAtMatrix("Matrix", matrix);
    pStreamDict->SetAtRect("BBox", rcBBox);
  }

  pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE,
                   FALSE);
}
CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(CPDF_Bookmark Parent)
{
    if (Parent.m_pDict == NULL) {
        CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines");
        if (pRoot == NULL) {
            return NULL;
        }
        return pRoot->GetDict("First");
    }
    return Parent.m_pDict->GetDict("First");
}
예제 #19
0
CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(
    const CPDF_Bookmark& parent) const {
  if (!parent.m_pDict) {
    CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines");
    if (!pRoot) {
      return CPDF_Bookmark();
    }
    return CPDF_Bookmark(pRoot->GetDict("First"));
  }
  return CPDF_Bookmark(parent.m_pDict->GetDict("First"));
}
예제 #20
0
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
  if (!pFormDict || !pFont) {
    return;
  }
  CFX_ByteString csTag;
  if (!FindInterFormFont(pFormDict, pFont, csTag)) {
    return;
  }
  CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
  CPDF_Dictionary* pFonts = pDR->GetDict("Font");
  pFonts->RemoveAt(csTag);
}
예제 #21
0
CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
  CPDF_DefaultAppearance cDA = GetDefaultAppearance();
  CFX_ByteString csFontNameTag;
  FX_FLOAT fFontSize;
  cDA.GetFont(csFontNameTag, fFontSize);
  if (csFontNameTag.IsEmpty())
    return nullptr;

  CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR");
  if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) {
    CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font");
    if (pFonts) {
      CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag);
      if (pElement) {
        CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
        if (pFont) {
          return pFont;
        }
      }
    }
  }
  if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag))
    return pFormFont;

  CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDict("P");
  pObj = FPDF_GetFieldAttr(pPageDict, "Resources");
  if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) {
    CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font");
    if (pFonts) {
      CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag);
      if (pElement) {
        CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
        if (pFont) {
          return pFont;
        }
      }
    }
  }
  return nullptr;
}
예제 #22
0
FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
                                               const CPDF_Dictionary* pOCGDict,
                                               FX_BOOL& bValidConfig) const {
  CPDF_Dictionary* pConfig =
      FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict, csConfig);
  if (!pConfig) {
    return TRUE;
  }
  bValidConfig = TRUE;
  FX_BOOL bState = pConfig->GetString(FX_BSTRC("BaseState"), FX_BSTRC("ON")) !=
                   FX_BSTRC("OFF");
  CPDF_Array* pArray = pConfig->GetArray(FX_BSTRC("ON"));
  if (pArray) {
    if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) {
      bState = TRUE;
    }
  }
  pArray = pConfig->GetArray(FX_BSTRC("OFF"));
  if (pArray) {
    if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) {
      bState = FALSE;
    }
  }
  pArray = pConfig->GetArray(FX_BSTRC("AS"));
  if (pArray) {
    CFX_ByteString csFind = csConfig + FX_BSTRC("State");
    int32_t iCount = pArray->GetCount();
    for (int32_t i = 0; i < iCount; i++) {
      CPDF_Dictionary* pUsage = pArray->GetDict(i);
      if (!pUsage) {
        continue;
      }
      if (pUsage->GetString(FX_BSTRC("Event"), FX_BSTRC("View")) != csConfig) {
        continue;
      }
      CPDF_Array* pOCGs = pUsage->GetArray(FX_BSTRC("OCGs"));
      if (!pOCGs) {
        continue;
      }
      if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) {
        continue;
      }
      CPDF_Dictionary* pState = pUsage->GetDict(csConfig);
      if (!pState) {
        continue;
      }
      bState = pState->GetString(csFind) != FX_BSTRC("OFF");
    }
  }
  return bState;
}
예제 #23
0
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
  if (!pFormDict || csNameTag.IsEmpty()) {
    return;
  }
  CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
  if (!pDR) {
    return;
  }
  CPDF_Dictionary* pFonts = pDR->GetDict("Font");
  if (!pFonts) {
    return;
  }
  pFonts->RemoveAt(csNameTag);
}
예제 #24
0
int CPDF_Document::_GetPageCount() const {
    CPDF_Dictionary* pRoot = GetRoot();
    if (!pRoot) {
        return 0;
    }
    CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
    if (!pPages) {
        return 0;
    }
    if (!pPages->KeyExist("Kids")) {
        return 1;
    }
    return _CountPages(pPages, 0);
}
예제 #25
0
CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32 nCharset)
{
	ASSERT(m_pAnnotDict != NULL);

	if (m_pAnnotDict->GetString("Subtype") == "Widget")
	{
		CPDF_Document* pDocument = GetDocument();
		ASSERT(pDocument != NULL);

		CPDF_Dictionary * pRootDict = pDocument->GetRoot();
		if (!pRootDict) return NULL;

		CPDF_Dictionary* pAcroFormDict = pRootDict->GetDict("AcroForm");
		if (!pAcroFormDict) return NULL;

		CPDF_Dictionary * pDRDict = pAcroFormDict->GetDict("DR");
		if (!pDRDict) return NULL;

		return FindResFontSameCharset(pDRDict, sFontAlias, nCharset);
	}

	return NULL;
}
예제 #26
0
CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csNameTag)
{
    CFX_ByteString csAlias = PDF_NameDecode(csNameTag);
    if (pFormDict == NULL || csAlias.IsEmpty()) {
        return NULL;
    }
    CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
    if (pDR == NULL) {
        return NULL;
    }
    CPDF_Dictionary* pFonts = pDR->GetDict("Font");
    if (pFonts == NULL) {
        return NULL;
    }
    CPDF_Dictionary* pElement = pFonts->GetDict(csAlias);
    if (pElement == NULL) {
        return NULL;
    }
    if (pElement->GetString("Type") == "Font") {
        return pDocument->LoadFont(pElement);
    }
    return NULL;
}
예제 #27
0
DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen)
{
    if (!buffer)
        *buflen = 0;
    if (!document || index < 0) return NULL;
    CPDF_Document* pDoc = (CPDF_Document*)document;

    CPDF_Dictionary* pRoot = pDoc->GetRoot();
    if (!pRoot) return NULL;

    CPDF_Object* pDestObj = NULL;
    CFX_ByteString bsName;
    CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests"));
    int count = nameTree.GetCount();
    if (index >= count) {
        CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests"));
        if (!pDest) return NULL;
        if (index >= count + pDest->GetCount()) return NULL;
        index -= count;
        FX_POSITION pos = pDest->GetStartPos();
        int i = 0;
        while (pos) {
            pDestObj = pDest->GetNextElement(pos, bsName);
            if (!pDestObj) continue;
            if (i == index) break;
            i++;
        }
    } else {
        pDestObj = nameTree.LookupValue(index, bsName);
    }
    if (!pDestObj) return NULL;
    if (pDestObj->GetType() == PDFOBJ_DICTIONARY) {
        pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D"));
        if (!pDestObj) return NULL;
    }
    if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL;
    CFX_WideString wsName = PDF_DecodeText(bsName);
    CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
    unsigned int len = utf16Name.GetLength();
    if (!buffer) {
        *buflen = len;
    } else if (*buflen >= len) {
        memcpy(buffer, utf16Name.c_str(), len);
        *buflen = len;
    } else {
        *buflen = -1;
    }
    return (FPDF_DEST)pDestObj;
}
예제 #28
0
FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
  if (!FPDFDOC_OCG_HasIntent(pOCGDict, FX_BSTRC("View"), FX_BSTRC("View"))) {
    return TRUE;
  }
  CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType);
  CPDF_Dictionary* pUsage = pOCGDict->GetDict(FX_BSTRC("Usage"));
  if (pUsage) {
    CPDF_Dictionary* pState = pUsage->GetDict(csState);
    if (pState) {
      CFX_ByteString csFind = csState + FX_BSTRC("State");
      if (pState->KeyExist(csFind)) {
        return pState->GetString(csFind) != FX_BSTRC("OFF");
      }
    }
    if (csState != FX_BSTRC("View")) {
      pState = pUsage->GetDict(FX_BSTRC("View"));
      if (pState && pState->KeyExist(FX_BSTRC("ViewState"))) {
        return pState->GetString(FX_BSTRC("ViewState")) != FX_BSTRC("OFF");
      }
    }
  }
  FX_BOOL bDefValid = FALSE;
  return LoadOCGStateFromConfig(csState, pOCGDict, bDefValid);
}
예제 #29
0
DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document)
{
    if (!document) return 0;
    CPDF_Document* pDoc = (CPDF_Document*)document;

    CPDF_Dictionary* pRoot = pDoc->GetRoot();
    if (!pRoot) return 0;

    CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests"));
    int count = nameTree.GetCount();
    CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests"));
    if (pDest)
        count += pDest->GetCount();
    return count;
}
예제 #30
0
CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) {
  CFX_WideString full_name;
  CPDF_Dictionary* pLevel = pFieldDict;
  while (pLevel) {
    CFX_WideString short_name = pLevel->GetUnicodeText("T");
    if (short_name != L"") {
      if (full_name == L"") {
        full_name = short_name;
      } else {
        full_name = short_name + L"." + full_name;
      }
    }
    pLevel = pLevel->GetDict("Parent");
  }
  return full_name;
}