FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString &csFileName) const { if (m_pObj == NULL) { return FALSE; } if (m_pObj->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_pObj; csFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); if (csFileName.IsEmpty()) { csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F"))); } if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) { return TRUE; } if (csFileName.IsEmpty()) { if (pDict->KeyExist(FX_BSTRC("DOS"))) { csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DOS"))); } else if (pDict->KeyExist(FX_BSTRC("Mac"))) { csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("Mac"))); } else if (pDict->KeyExist(FX_BSTRC("Unix"))) { csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("Unix"))); } else { return FALSE; } } } else { csFileName = CFX_WideString::FromLocal(m_pObj->GetString()); } csFileName = FILESPEC_DecodeFileName(csFileName); return TRUE; }
CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) { CFX_WideString wsFileName; if (pFileSpec->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pDict = (CPDF_Dictionary*)pFileSpec; wsFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); if (wsFileName.IsEmpty()) { wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F"))); } if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) { return wsFileName; } if (wsFileName.IsEmpty() && pDict->KeyExist(FX_BSTRC("DOS"))) { wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DOS"))); } } else { wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString()); } if (wsFileName[0] != '/') { return ChangeSlash(wsFileName); } if (wsFileName[2] == '/') { CFX_WideString result; result += wsFileName[1]; result += ':'; result += ChangeSlash(((FX_LPCWSTR)wsFileName) + 2); return result; } else { CFX_WideString result; result += '\\'; result += ChangeSlash(wsFileName); return result; } }
FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString& csFileName) const { if (!m_pObj) { return FALSE; } if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { csFileName = pDict->GetUnicodeTextBy("UF"); if (csFileName.IsEmpty()) { csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("F")); } if (pDict->GetStringBy("FS") == "URL") { return TRUE; } if (csFileName.IsEmpty()) { if (pDict->KeyExist("DOS")) { csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("DOS")); } else if (pDict->KeyExist("Mac")) { csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Mac")); } else if (pDict->KeyExist("Unix")) { csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Unix")); } else { return FALSE; } } } else { csFileName = CFX_WideString::FromLocal(m_pObj->GetString()); } csFileName = FILESPEC_DecodeFileName(csFileName); return TRUE; }
bool CPDF_InterForm::ValidateFieldName( CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl) const { if (csNewFieldName.IsEmpty()) return false; int iPos = 0; int iLength = csNewFieldName.GetLength(); CFX_WideString csSub; while (true) { while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) { iPos++; } if (iPos < iLength && !csSub.IsEmpty()) csSub += L'.'; while (iPos < iLength && csNewFieldName[iPos] != L'.') csSub += csNewFieldName[iPos++]; for (int i = csSub.GetLength() - 1; i > -1; i--) { if (csSub[i] != L' ' && csSub[i] != L'.') break; csSub.SetAt(i, L'\0'); } size_t dwCount = m_pFieldTree->m_Root.CountFields(); for (size_t m = 0; m < dwCount; ++m) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(m); if (!pField) continue; if (pField == pExcludedField) { if (!pExcludedControl || pField->CountControls() < 2) continue; } CFX_WideString csFullName = pField->GetFullName(); int iRet = CompareFieldName(csSub, csFullName); if (iRet == 1) { if (pField->GetFieldType() != iType) return false; } else if (iRet == 2 && csSub == csNewFieldName) { if (csFullName[iPos] == L'.') return false; } else if (iRet == 3 && csSub == csNewFieldName) { if (csNewFieldName[csFullName.GetLength()] == L'.') return false; } } if (iPos >= iLength) break; } if (csSub.IsEmpty()) return false; csNewFieldName = csSub; return true; }
bool CFX_WideString::Equal(const CFX_WideString& other) const { if (IsEmpty()) { return other.IsEmpty(); } if (other.IsEmpty()) { return false; } return other.m_pData->m_nDataLength == m_pData->m_nDataLength && wmemcmp(other.m_pData->m_String, m_pData->m_String, m_pData->m_nDataLength) == 0; }
CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const { CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode); if (!str.IsEmpty()) return str; FX_WCHAR ret = GetUnicodeFromCharCode(charcode); return ret ? ret : CFX_WideString(); }
CFX_WideString CRF_TextPage::GetPageText(int start, int nCount ) const { if(nCount == -1) { nCount = CountChars(); start = 0; } else if(nCount < 1) { return L""; } else if(start >= CountChars()) { return L""; } int i, index = start + nCount; FPDF_CHAR_INFO info; CFX_WideString str; CFX_FloatRect recttmp; FX_BOOL bstart = TRUE; for(i = start; i < index; i++) { GetCharInfo(i, info); if(bstart) { recttmp = info.m_CharBox; str += info.m_Unicode; bstart = FALSE; } else if (_IsInsameline(recttmp, info.m_CharBox)) { str += info.m_Unicode; } else { str += L"\r\n"; recttmp = info.m_CharBox; str += info.m_Unicode; } } if(str.IsEmpty()) { return L""; } return str; }
void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) { 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_CHUNKHEADER* lpChunk = static_cast<FDE_CHUNKHEADER*>(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_CHUNKHEADER* lpChunk = 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; }
void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { if (sContents.IsEmpty()) m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); else m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText(sContents)); }
bool CPDFSDK_ActionHandler::ExecuteDocumentPageAction( const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, std::set<CPDF_Dictionary*>* visited) { CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; visited->insert(pDict); ASSERT(pFormFillEnv); if (action.GetType() == CPDF_Action::JavaScript) { if (pFormFillEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunDocumentPageJavaScript(pFormFillEnv, type, swJS); } } } else { DoAction_NoJs(action, pFormFillEnv); } if (!IsValidDocView(pFormFillEnv)) return false; for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteDocumentPageAction(subaction, type, pFormFillEnv, visited)) return false; } return true; }
size_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) const { if (csFieldName.IsEmpty()) return m_pFieldTree->m_Root.CountFields(); CFieldTree::Node* pNode = m_pFieldTree->FindNode(csFieldName); return pNode ? pNode->CountFields() : 0; }
FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( const CPDF_Action& action, CPDFSDK_Document* pDocument, CFX_PtrList& list) { CPDF_Dictionary* pDict = action.GetDict(); if (list.Find(pDict)) return FALSE; list.AddTail(pDict); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if (pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunDocumentOpenJavaScript(pDocument, L"", swJS); } } } else { DoAction_NoJs(action, pDocument); } for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) return FALSE; } return TRUE; }
void CXFA_FFDocView::ShowNullTestMsg() { int32_t iCount = m_arrNullTestMsg.GetSize(); CXFA_FFApp* pApp = m_pDoc->GetApp(); IXFA_AppProvider* pAppProvider = pApp->GetAppProvider(); if (pAppProvider && iCount) { int32_t iRemain = iCount > 7 ? iCount - 7 : 0; iCount -= iRemain; CFX_WideString wsMsg; for (int32_t i = 0; i < iCount; i++) { wsMsg += m_arrNullTestMsg[i] + FX_WSTRC(L"\n"); } if (iRemain > 0) { CFX_WideString wsLimit; pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit); if (!wsLimit.IsEmpty()) { CFX_WideString wsTemp; wsTemp.Format((const FX_WCHAR*)wsLimit, iRemain); wsMsg += FX_WSTRC(L"\n") + wsTemp; } } CFX_WideString wsTitle; pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); } m_arrNullTestMsg.RemoveAll(); }
int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, int index, FX_BOOL bNotify) { if (csOptLabel.IsEmpty()) return -1; if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel)) return -1; CFX_ByteString csStr = PDF_EncodeText(csOptLabel.c_str(), csOptLabel.GetLength()); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt"); CPDF_Array* pOpt = ToArray(pValue); if (!pOpt) { pOpt = new CPDF_Array; m_pDict->SetAt("Opt", pOpt); } int iCount = (int)pOpt->GetCount(); if (index < 0 || index >= iCount) { pOpt->AddString(csStr); index = iCount; } else { CPDF_String* pString = new CPDF_String(csStr, FALSE); pOpt->InsertAt(index, pString); } if (bNotify) NotifyListOrComboBoxAfterChange(); return index; }
FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded) { if (sDestination.IsEmpty()) return FALSE; if (!m_pDocument || !m_pInterForm) return FALSE; CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); if (!pFDFDoc) return FALSE; CFX_ByteTextBuf FdfBuffer; FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); delete pFDFDoc; if (!bRet) return FALSE; uint8_t* pBuffer = FdfBuffer.GetBuffer(); FX_STRSIZE nBufSize = FdfBuffer.GetLength(); if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) return FALSE; pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); if (bUrlEncoded) FX_Free(pBuffer); return TRUE; }
int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild( CXFA_ResolveNodesData& rnd) { CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); CFX_WideString wsCondition = rnd.m_wsCondition; CXFA_Node* findNode = NULL; CXFA_NodeArray siblings; FX_BOOL bClassName = FALSE; if (wsName.GetAt(0) == '#') { bClassName = TRUE; wsName = wsName.Right(wsName.GetLength() - 1); } findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(ToNode(rnd.m_CurNode), wsName, bClassName); if (findNode == NULL) { return 0; } if (wsCondition.IsEmpty()) { rnd.m_Nodes.Add(findNode); return rnd.m_Nodes.GetSize(); } m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); XFA_ResolveNode_FilterCondition(rnd, wsCondition); return rnd.m_Nodes.GetSize(); }
CFX_WideString CRF_TextPage::GetTextByRect(CFX_FloatRect rect) const { int count; FPDF_CHAR_INFO info; CFX_WideString str; CFX_FloatRect Recttmp; FX_BOOL bstart = TRUE; count = CountChars(); if(rect.IsEmpty()) { return L""; } for(int i = 0; i < count; i++) { GetCharInfo(i, info); if(_IsIntersect(rect, info.m_CharBox)) { if(bstart) { Recttmp = info.m_CharBox; str += info.m_Unicode; bstart = FALSE; } else if(_IsInsameline(Recttmp, info.m_CharBox)) { str += info.m_Unicode; } else { str += L"\r\n"; Recttmp = info.m_CharBox; str += info.m_Unicode; } } } if(str.IsEmpty()) { return L""; } else { return str; } }
bool CXFA_FFDateTimeEdit::LoadWidget() { CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); pWidget->Initialize(); m_pNormalWidget = pWidget; m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); m_pOldDelegate = m_pNormalWidget->GetDelegate(); m_pNormalWidget->SetDelegate(this); m_pNormalWidget->LockUpdate(); CFX_WideString wsText; m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); pWidget->SetEditText(wsText); if (CXFA_Value value = m_pDataAcc->GetFormValue()) { switch (value.GetChildValueClassID()) { case XFA_Element::Date: { if (!wsText.IsEmpty()) { CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); CFX_Unitime date = lcValue.GetDate(); if ((FX_UNITIME)date != 0) { pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); } } } break; default: break; } } UpdateWidgetProperty(); m_pNormalWidget->UnlockUpdate(); return CXFA_FFField::LoadWidget(); }
FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( const CPDF_Action& action, CPDFSDK_Document* pDocument, std::set<CPDF_Dictionary*>* visited) { CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return FALSE; visited->insert(pDict); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if (pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunDocumentOpenJavaScript(pDocument, L"", swJS); } } } else { DoAction_NoJs(action, pDocument); } for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteDocumentOpenAction(subaction, pDocument, visited)) return FALSE; } return TRUE; }
int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, int index, bool bNotify) { if (csOptLabel.IsEmpty()) return -1; if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel)) return -1; CFX_ByteString csStr = PDF_EncodeText(csOptLabel.c_str(), csOptLabel.GetLength()); CPDF_Array* pOpt = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); if (!pOpt) pOpt = m_pDict->SetNewFor<CPDF_Array>("Opt"); int iCount = pdfium::base::checked_cast<int>(pOpt->GetCount()); if (index >= iCount) { pOpt->AddNew<CPDF_String>(csStr, false); index = iCount; } else { pOpt->InsertNewAt<CPDF_String>(index, csStr, false); } if (bNotify) NotifyListOrComboBoxAfterChange(); return index; }
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName) { if (pField == NULL || csNewFieldName.IsEmpty()) { return FALSE; } return ValidateFieldName( csNewFieldName, ((CPDF_FormField*)pField)->GetFieldType(), pField, NULL); }
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName) { if (!pControl || csNewFieldName.IsEmpty()) return FALSE; CPDF_FormField* pField = pControl->GetField(); return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pControl); }
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName) { if (pControl == NULL || csNewFieldName.IsEmpty()) { return FALSE; } CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pControl); }
void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, const CFX_WideString& parent_name, FX_BOOL bNotify, int nLevel) { CFX_WideString name; if (!parent_name.IsEmpty()) name = parent_name + L"."; name += pFieldDict->GetUnicodeTextBy("T"); CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); if (pKids) { for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); if (!pKid) continue; if (nLevel <= nMaxRecursion) FDF_ImportField(pKid, name, bNotify, nLevel + 1); } return; } if (!pFieldDict->KeyExist("V")) return; CPDF_FormField* pField = m_pFieldTree->GetField(name); if (!pField) return; CFX_WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding); int iType = pField->GetFieldType(); if (bNotify && m_pFormNotify) { int iRet = 0; if (iType == FIELDTYPE_LISTBOX) iRet = m_pFormNotify->BeforeSelectionChange(pField, csWValue); else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) iRet = m_pFormNotify->BeforeValueChange(pField, csWValue); if (iRet < 0) return; } pField->SetValue(csWValue); CPDF_FormField::Type eType = pField->GetType(); if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && pFieldDict->KeyExist("Opt")) { pField->m_pDict->SetAt( "Opt", pFieldDict->GetDirectObjectBy("Opt")->CloneDirectObject()); } if (bNotify && m_pFormNotify) { if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) m_pFormNotify->AfterCheckedStatusChange(pField); else if (iType == FIELDTYPE_LISTBOX) m_pFormNotify->AfterSelectionChange(pField); else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) m_pFormNotify->AfterValueChange(pField); } }
FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt, IFWL_Widget* pOwner) { if (HasToolTip(pEvt->m_pDstTarget)) { if (NULL == m_pToolTipImp) { CFWL_WidgetImpProperties prop; prop.m_pDataProvider = m_ToolTipDp; prop.m_pOwner = pOwner; CFX_RectF rtTooltip; rtTooltip.Set(150, 150, 100, 50); prop.m_rtWidget = rtTooltip; IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr); pToolTip->Initialize(); m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl()); m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0); m_pToolTipImp->SetStates(FWL_WGTSTATE_Invisible, TRUE); } if (pCurTarget->IsShowed()) { CFX_WideString wsCaption; pCurTarget->GetCaption(wsCaption); if (!wsCaption.IsEmpty()) { m_ToolTipDp->m_wsCaption = wsCaption; } CFX_RectF rt; rt.Reset(); CFX_SizeF sz; sz.Reset(); pCurTarget->GetToolTipSize(sz); if (sz.x > 0 && sz.y > 0) { rt.width = sz.x; rt.height = sz.y; } else { CFX_RectF r; m_pToolTipImp->GetWidgetRect(r, TRUE); rt.width = r.width; rt.height = r.height; } CFX_PointF pt; pt.Set(pEvt->m_fx, pEvt->m_fy); if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) { rt.left = pt.x; rt.top = pt.y; m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0); } else { CFX_RectF rtAnchor; pCurTarget->GetWidget()->GetClientRect(rtAnchor); pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top); m_pToolTipImp->SetAnchor(rtAnchor); m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor); } m_pToolTipImp->SetWidgetRect(rt); m_pToolTipImp->Update(); m_pToolTipImp->Show(); } return TRUE; } return FALSE; }
void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); ASSERT(pEnv); if (!pEnv->IsJSInitiated()) return; if (m_bBusy) return; m_bBusy = TRUE; if (!IsCalculateEnabled()) { m_bBusy = FALSE; return; } IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); pRuntime->SetReaderDocument(m_pDocument); int nSize = m_pInterForm->CountFieldsInCalculationOrder(); for (int i = 0; i < nSize; i++) { CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); if (!pField) continue; int nType = pField->GetFieldType(); if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) continue; CPDF_AAction aAction = pField->GetAdditionalAction(); if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Calculate)) continue; CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); if (!action.GetDict()) continue; CFX_WideString csJS = action.GetJavaScript(); if (csJS.IsEmpty()) continue; IJS_Context* pContext = pRuntime->NewContext(); CFX_WideString sOldValue = pField->GetValue(); CFX_WideString sValue = sOldValue; FX_BOOL bRC = TRUE; pContext->OnField_Calculate(pFormField, pField, sValue, bRC); CFX_WideString sInfo; FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); pRuntime->ReleaseContext(pContext); if (bRet && bRC && sValue.Compare(sOldValue) != 0) pField->SetValue(sValue, TRUE); } m_bBusy = FALSE; }
void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, CFX_WideString& wsPlainText) { if (pXMLNode == NULL) { return; } switch (pXMLNode->GetType()) { case FDE_XMLNODE_Element: { IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; CFX_WideString wsTag; pXMLElement->GetLocalTagName(wsTag); uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); if (uTag == 0x0001f714) { wsPlainText += L"\n"; } else if (uTag == 0x00000070) { if (!wsPlainText.IsEmpty()) { wsPlainText += L"\n"; } } else if (uTag == 0xa48ac63) { if (!wsPlainText.IsEmpty() && wsPlainText[wsPlainText.GetLength() - 1] != '\n') { wsPlainText += L"\n"; } } } break; case FDE_XMLNODE_Text: { CFX_WideString wsContent; ((IFDE_XMLText*)pXMLNode)->GetText(wsContent); wsPlainText += wsContent; } break; case FDE_XMLNODE_CharData: { CFX_WideString wsCharData; ((IFDE_XMLCharData*)pXMLNode)->GetCharData(wsCharData); wsPlainText += wsCharData; } break; default: break; } for (IFDE_XMLNode* pChildXML = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); pChildXML; pChildXML = pChildXML->GetNodeItem(IFDE_XMLNode::NextSibling)) { XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); } }
void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) { if (findwhat.IsEmpty()) return; int index = 0; while (1) { CFX_WideString csWord = TEXT_EMPTY; int ret = ExtractSubString(csWord, findwhat.c_str(), index, TEXT_SPACE_CHAR); if (csWord.IsEmpty()) { if (ret) { m_csFindWhatArray.push_back(L""); index++; continue; } else { break; } } int pos = 0; while (pos < csWord.GetLength()) { CFX_WideString curStr = csWord.Mid(pos, 1); FX_WCHAR curChar = csWord.GetAt(pos); if (IsIgnoreSpaceCharacter(curChar)) { if (pos > 0 && curChar == 0x2019) { pos++; continue; } if (pos > 0) m_csFindWhatArray.push_back(csWord.Mid(0, pos)); m_csFindWhatArray.push_back(curStr); if (pos == csWord.GetLength() - 1) { csWord.clear(); break; } csWord = csWord.Right(csWord.GetLength() - pos - 1); pos = 0; continue; } pos++; } if (!csWord.IsEmpty()) m_csFindWhatArray.push_back(csWord); index++; } }
FX_BOOL CPWL_Edit::CanPaste() const { if (IsReadOnly()) return FALSE; CFX_WideString swClipboard; if (IFX_SystemHandler* pSH = GetSystemHandler()) swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); return !swClipboard.IsEmpty(); }
void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName) { ASSERT(m_pAnnot != NULL); ASSERT(m_pAnnot->m_pAnnotDict != NULL); if (sName.IsEmpty()) m_pAnnot->m_pAnnotDict->RemoveAt("NM"); else m_pAnnot->m_pAnnotDict->SetAtString("NM", PDF_EncodeText(sName)); }