bool CFX_WideString::Equal(const CFX_WideStringC& str) const { if (m_pData == NULL) { return str.IsEmpty(); } return str.GetLength() == m_pData->m_nDataLength && wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; }
bool CFX_WideString::Equal(const CFX_WideStringC& str) const { if (m_pData == NULL) { return str.IsEmpty(); } return str.GetLength() == m_pData->m_nDataLength && FXSYS_memcmp32(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength * sizeof(FX_WCHAR)) == 0; }
void CXML_Parser::InsertContentSegment(bool bCDATA, const CFX_WideStringC& content, CXML_Element* pElement) { if (content.IsEmpty()) { return; } CXML_Content* pContent = new CXML_Content; pContent->Set(bCDATA, content); pElement->m_Children.push_back({CXML_Element::Content, pContent}); }
void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, const CFX_WideStringC& content, CXML_Element* pElement) { if (content.IsEmpty()) { return; } CXML_Content* pContent = new CXML_Content; pContent->Set(bCDATA, content); pElement->m_Children.Add((void*)CXML_Element::Content); pElement->m_Children.Add(pContent); }
CFX_WideString::CFX_WideString(const CFX_WideStringC& str) { if (str.IsEmpty()) { m_pData = NULL; return; } m_pData = StringData::Create(str.GetLength()); if (m_pData) { FXSYS_memcpy(m_pData->m_String, str.GetPtr(), str.GetLength()*sizeof(FX_WCHAR)); } }
bool CBC_EAN8::Encode(const CFX_WideStringC& contents, bool isDevice, int32_t& e) { if (contents.IsEmpty()) { e = BCExceptionNoContents; return false; } BCFORMAT format = BCFORMAT_EAN_8; int32_t outWidth = 0; int32_t outHeight = 0; CFX_WideString encodeContents = Preprocess(contents); CFX_ByteString byteString = encodeContents.UTF8Encode(); m_renderContents = encodeContents; uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); BC_EXCEPTION_CHECK_ReturnValue(e, false); static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); BC_EXCEPTION_CHECK_ReturnValue(e, false); return true; }
int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, CFX_WideTextBuf& wsJavascript, CFX_WideString& wsError) { if (wsFormcalc.IsEmpty()) { wsJavascript.Clear(); wsError.Empty(); return 0; } int32_t status = 0; CXFA_FMProgram program; status = program.Init(wsFormcalc); if (status) { wsError = program.GetError().message; return status; } status = program.ParseProgram(); if (status) { wsError = program.GetError().message; return status; } program.TranslateProgram(wsJavascript); return 0; }
std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( const CFX_WideStringC& pdf_path, const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude, bool bSimpleFileSpec) const { std::unique_ptr<CFDF_Document> pDoc = CFDF_Document::CreateNewDoc(); if (!pDoc) return nullptr; CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictFor("FDF"); if (!pdf_path.IsEmpty()) { if (bSimpleFileSpec) { CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); pMainDict->SetNewFor<CPDF_String>( "F", CFX_ByteString::FromUnicode(wsFilePath), false); pMainDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsFilePath), false); } else { CPDF_FileSpec filespec(pDoc->GetByteStringPool()); filespec.SetFileName(pdf_path); pMainDict->SetFor("F", pdfium::WrapUnique(filespec.GetObj())); } } CPDF_Array* pFields = pMainDict->SetNewFor<CPDF_Array>("Fields"); size_t nCount = m_pFieldTree->m_Root.CountFields(); for (size_t i = 0; i < nCount; ++i) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i); if (!pField || pField->GetType() == CPDF_FormField::PushButton) continue; uint32_t dwFlags = pField->GetFieldFlags(); if (dwFlags & 0x04) continue; if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) { if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringFor("V").IsEmpty()) continue; CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict()); auto pFieldDict = pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); pFieldDict->SetNewFor<CPDF_String>("T", fullname); if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType() == CPDF_FormField::RadioButton) { CFX_WideString csExport = pField->GetCheckValue(false); CFX_ByteString csBExport = PDF_EncodeText(csExport); CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); if (pOpt) pFieldDict->SetNewFor<CPDF_String>("V", csBExport, false); else pFieldDict->SetNewFor<CPDF_Name>("V", csBExport); } else { CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); if (pV) pFieldDict->SetFor("V", pV->CloneDirectObject()); } pFields->Add(std::move(pFieldDict)); } } return pDoc; }
int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, const CFX_WideStringC& wsExpression, XFA_RESOLVENODE_RS& resolveNodeRS, uint32_t dwStyles, CXFA_Node* bindNode) { if (wsExpression.IsEmpty()) { return 0; } if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { m_upObjectArray.RemoveAll(); } if (refNode && refNode->IsNode() && (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { m_upObjectArray.Add(refNode->AsNode()); } FX_BOOL bNextCreate = FALSE; if (dwStyles & XFA_RESOLVENODE_CreateNode) { m_ResolveProcessor->GetNodeHelper()->SetCreateNodeType(bindNode); } m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr; m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1; CXFA_ResolveNodesData rndFind; int32_t nStart = 0; int32_t nLevel = 0; int32_t nRet = -1; rndFind.m_pSC = this; CXFA_ObjArray findNodes; findNodes.Add(refNode ? refNode : m_pDocument->GetRoot()); int32_t nNodes = 0; while (TRUE) { nNodes = findNodes.GetSize(); int32_t i = 0; rndFind.m_dwStyles = dwStyles; m_ResolveProcessor->SetCurStart(nStart); nStart = m_ResolveProcessor->GetFilter(wsExpression, nStart, rndFind); if (nStart < 1) { if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) { CXFA_Node* pDataNode = nullptr; nStart = m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart; if (nStart != -1) { pDataNode = m_pDocument->GetNotBindNode(findNodes); if (pDataNode) { findNodes.RemoveAll(); findNodes.Add(pDataNode); break; } } else { pDataNode = findNodes[0]->AsNode(); findNodes.RemoveAll(); findNodes.Add(pDataNode); break; } dwStyles |= XFA_RESOLVENODE_Bind; findNodes.RemoveAll(); findNodes.Add(m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent); continue; } else { break; } } if (bNextCreate) { FX_BOOL bCreate = m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode( rndFind.m_wsName, rndFind.m_wsCondition, nStart == wsExpression.GetLength(), this); if (bCreate) { continue; } else { break; } } CXFA_ObjArray retNodes; while (i < nNodes) { FX_BOOL bDataBind = FALSE; if (((dwStyles & XFA_RESOLVENODE_Bind) || (dwStyles & XFA_RESOLVENODE_CreateNode)) && nNodes > 1) { CXFA_ResolveNodesData rndBind; m_ResolveProcessor->GetFilter(wsExpression, nStart, rndBind); m_ResolveProcessor->SetIndexDataBind(rndBind.m_wsCondition, i, nNodes); bDataBind = TRUE; } rndFind.m_CurNode = findNodes[i++]; rndFind.m_nLevel = nLevel; rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes; nRet = m_ResolveProcessor->Resolve(rndFind); if (nRet < 1) { continue; } if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute && rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) { std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate)); (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))( pValue.get(), FALSE, (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute); rndFind.m_Nodes.SetAt(0, ToObject(pValue.get(), nullptr)); } int32_t iSize = m_upObjectArray.GetSize(); if (iSize) { m_upObjectArray.RemoveAt(iSize - 1); } retNodes.Append(rndFind.m_Nodes); rndFind.m_Nodes.RemoveAll(); if (bDataBind) { break; } } findNodes.RemoveAll(); nNodes = retNodes.GetSize(); if (nNodes < 1) { if (dwStyles & XFA_RESOLVENODE_CreateNode) { bNextCreate = TRUE; if (!m_ResolveProcessor->GetNodeHelper()->m_pCreateParent) { m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = ToNode(rndFind.m_CurNode); m_ResolveProcessor->GetNodeHelper()->m_iCreateCount = 1; } FX_BOOL bCreate = m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode( rndFind.m_wsName, rndFind.m_wsCondition, nStart == wsExpression.GetLength(), this); if (bCreate) { continue; } else { break; } } else { break; } } findNodes.Copy(retNodes); rndFind.m_Nodes.RemoveAll(); if (nLevel == 0) { dwStyles &= ~(XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); } nLevel++; } if (!bNextCreate) { resolveNodeRS.dwFlags = rndFind.m_dwFlag; if (nNodes > 0) { resolveNodeRS.nodes.Append(findNodes); } if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute) { resolveNodeRS.pScriptAttribute = rndFind.m_pScriptAttribute; return 1; } } if (dwStyles & (XFA_RESOLVENODE_CreateNode | XFA_RESOLVENODE_Bind | XFA_RESOLVENODE_BindNew)) { m_ResolveProcessor->SetResultCreateNode(resolveNodeRS, rndFind.m_wsCondition); if (!bNextCreate && (dwStyles & XFA_RESOLVENODE_CreateNode)) { resolveNodeRS.dwFlags = XFA_RESOVENODE_RSTYPE_ExistNodes; } return resolveNodeRS.nodes.GetSize(); } return nNodes; }