Ejemplo n.º 1
0
FX_BOOL CheckSharedForm(CXML_Element * pElement, CFX_ByteString cbName)
{
    int count = pElement->CountAttrs();
    int i=0;
    for (i = 0; i < count; i++)
    {
        CFX_ByteString space, name;
        CFX_WideString value;
        pElement->GetAttrByIndex(i, space, name, value);
        if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") && value ==  L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/")
        {
            CXML_Element *pVersion = pElement->GetElement("adhocwf",cbName);
            if (!pVersion)
                continue;
            CFX_WideString wsContent = pVersion->GetContent(0); // == 1.1
            int nType = wsContent.GetInteger();
            switch(nType)
            {
            case 1:
                FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT);
                break;
            case 2:
                FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM);
                break;
            case 0:
                FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL);
                break;
            }
        }
    }

    FX_DWORD nCount = pElement->CountChildren();
    for(i=0; i<(int)nCount; i++)
    {
        CXML_Element::ChildType childType = pElement->GetChildType(i);
        if(childType == CXML_Element::Element)
        {
            CXML_Element * pChild = pElement->GetElement(i);
            if(CheckSharedForm(pChild, cbName))
                return TRUE;
        }
    }
    return FALSE;
}
Ejemplo n.º 2
0
void CPWL_Edit::SetText(const CFX_WideString& csText) {
  CFX_WideString swText = csText;
  if (!HasFlag(PES_RICH)) {
    m_pEdit->SetText(swText);
    return;
  }

  CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
  std::unique_ptr<CXML_Element> pXML(
      CXML_Element::Parse(sValue.c_str(), sValue.GetLength()));
  if (!pXML) {
    m_pEdit->SetText(swText);
    return;
  }

  int32_t nCount = pXML->CountChildren();
  bool bFirst = true;

  swText.clear();

  for (int32_t i = 0; i < nCount; i++) {
    CXML_Element* pSubElement = pXML->GetElement(i);
    if (!pSubElement)
      continue;

    CFX_ByteString tag = pSubElement->GetTagName();
    if (tag.EqualNoCase("p")) {
      int nChild = pSubElement->CountChildren();
      CFX_WideString swSection;
      for (int32_t j = 0; j < nChild; j++)
        swSection += pSubElement->GetContent(j);

      if (bFirst)
        bFirst = false;
      else
        swText += FWL_VKEY_Return;
      swText += swSection;
    }
  }

  m_pEdit->SetText(swText);
}
Ejemplo n.º 3
0
FX_INT32 CPDF_Metadata::GetString(FX_BSTR bsItem, CFX_WideString &wsStr)
{
    if (!((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt) {
        return -1;
    }
    if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap) {
        return -1;
    }
    void *szTag;
    if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap->Lookup(bsItem, szTag)) {
        return -1;
    }
    CFX_ByteString bsTag = (FX_LPCSTR)szTag;
    wsStr = L"";
    CXML_Element *pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf;
    if (!pElmntRdf) {
        return -1;
    }
    int nChild = pElmntRdf->CountChildren();
    for (int i = 0; i < nChild; i++) {
        CXML_Element *pTag = pElmntRdf->GetElement(NULL, FX_BSTRC("Description"), i);
        if (!pTag) {
            continue;
        }
        if (bsItem == FX_BSTRC("Title") || bsItem == FX_BSTRC("Subject")) {
            CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
            if (!pElmnt) {
                continue;
            }
            pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("Alt"));
            if (!pElmnt) {
                continue;
            }
            pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("li"));
            if (!pElmnt) {
                continue;
            }
            wsStr = pElmnt->GetContent(0);
            return wsStr.GetLength();
        } else if (bsItem == FX_BSTRC("Author")) {
            CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
            if (!pElmnt) {
                continue;
            }
            pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("Seq"));
            if (!pElmnt) {
                continue;
            }
            pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("li"));
            if (!pElmnt) {
                continue;
            }
            wsStr = pElmnt->GetContent(0);
            return wsStr.GetLength();
        } else {
            CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
            if (!pElmnt) {
                continue;
            }
            wsStr = pElmnt->GetContent(0);
            return wsStr.GetLength();
        }
    }
    return -1;
}