FX_BOOL CXFA_FFConfigAcc::GetFontInfo(int32_t index, CFX_WideString& wsFontFamily, CFX_WideString& wsPsName, FX_BOOL bBold, FX_BOOL bItalic) { if (index < 0 || index >= CountChildren()) { return FALSE; } CXFA_Node* pFontNode = m_pPsMapNode->GetChild(index, XFA_ELEMENT_Font); if (pFontNode == NULL) { return FALSE; } wsFontFamily.Empty(); wsPsName.Empty(); bBold = FALSE; bItalic = FALSE; pFontNode->GetAttribute(XFA_ATTRIBUTE_Typeface, wsFontFamily); pFontNode->GetAttribute(XFA_ATTRIBUTE_PsName, wsPsName); CFX_WideString wsValue; pFontNode->GetAttribute(XFA_ATTRIBUTE_Weight, wsValue); wsValue.MakeLower(); if (wsValue == FX_WSTRC(L"bold")) { bBold = TRUE; } pFontNode->GetAttribute(XFA_ATTRIBUTE_Posture, wsValue); wsValue.MakeLower(); if (wsValue == FX_WSTRC(L"italic")) { bItalic = TRUE; } return wsFontFamily.GetLength() > 0; }
void CPWL_Edit::SetText(const FX_WCHAR* csText) { CFX_WideString swText = csText; if (HasFlag(PES_RICH)) { CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); if (CXML_Element* pXML = CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) { int32_t nCount = pXML->CountChildren(); FX_BOOL bFirst = TRUE; swText.Empty(); for (int32_t i = 0; i < nCount; i++) { if (CXML_Element* pSubElement = pXML->GetElement(i)) { 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; } } } delete pXML; } } m_pEdit->SetText(swText.c_str()); }
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; }
void CXFA_NodeHelper::XFA_GetNameExpression(CXFA_Node* refNode, CFX_WideString& wsName, FX_BOOL bIsAllPath, XFA_LOGIC_TYPE eLogicType) { wsName.Empty(); if (bIsAllPath) { XFA_GetNameExpression(refNode, wsName, FALSE, eLogicType); CFX_WideString wsParent; CXFA_Node* parent = XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); while (parent != NULL) { XFA_GetNameExpression(parent, wsParent, FALSE, eLogicType); wsParent += L"."; wsParent += wsName; wsName = wsParent; parent = XFA_ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent); } return; } else { CFX_WideStringC wsTagName; CFX_WideString ws; FX_BOOL bIsProperty = XFA_NodeIsProperty(refNode); if (refNode->IsUnnamed() || (bIsProperty && refNode->GetClassID() != XFA_ELEMENT_PageSet)) { refNode->GetClassName(wsTagName); ws = wsTagName; wsName.Format(L"#%s[%d]", (const FX_WCHAR*)ws, XFA_GetIndex(refNode, eLogicType, bIsProperty, TRUE)); return; } ws = refNode->GetCData(XFA_ATTRIBUTE_Name); ws.Replace(L".", L"\\."); wsName.Format(L"%s[%d]", (const FX_WCHAR*)ws, XFA_GetIndex(refNode, eLogicType, bIsProperty, FALSE)); } }
void NormalizeString(CFX_WideString& str) { if (str.GetLength() <= 0) { return; } CFX_WideString sBuffer; IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); if (NULL == BidiChar) { return; } CFX_WordArray order; FX_BOOL bR2L = FALSE; FX_INT32 start = 0, count = 0, i = 0; int nR2L = 0, nL2R = 0; for (i = 0; i < str.GetLength(); i++) { if(BidiChar->AppendChar(str.GetAt(i))) { FX_INT32 ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); if(!bR2L) { if(ret == 2) { nR2L++; } else if (ret == 1) { nL2R++; } } } } if(BidiChar->EndChar()) { FX_INT32 ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); if(!bR2L) { if(ret == 2) { nR2L++; } else if(ret == 1) { nL2R++; } } } if(nR2L > 0 && nR2L >= nL2R) { bR2L = TRUE; } if(bR2L) { int count = order.GetSize(); for(int j = count - 1; j > 0; j -= 3) { int ret = order.GetAt(j); int start = order.GetAt(j - 2); int count1 = order.GetAt(j - 1); if(ret == 2 || ret == 0) { for(int i = start + count1 - 1; i >= start; i--) { NormalizeCompositeChar(str[i], sBuffer); } } else { i = j; FX_BOOL bSymbol = FALSE; while(i > 0 && order.GetAt(i) != 2) { bSymbol = !order.GetAt(i); i -= 3; } int end = start + count1 ; int n = 0; if(bSymbol) { n = i + 6; } else { n = i + 3; } if(n >= j) { for(int m = start; m < end; m++) { sBuffer += str[m]; } } else { i = j; j = n; for(; n <= i; n += 3) { int start = order.GetAt(n - 2); int count1 = order.GetAt(n - 1); int end = start + count1 ; for(int m = start; m < end; m++) { sBuffer += str[m]; } } } } } } else { int count = order.GetSize(); FX_BOOL bL2R = FALSE; for(int j = 0; j < count; j += 3) { int ret = order.GetAt(j + 2); int start = order.GetAt(j); int count1 = order.GetAt(j + 1); if(ret == 2 || (j == 0 && ret == 0 && !bL2R)) { int i = j + 3; while(bR2L && i < count) { if(order.GetAt(i + 2) == 1) { break; } else { i += 3; } } if(i == 3) { j = -3; bL2R = TRUE; continue; } int end = str.GetLength() - 1; if(i < count) { end = order.GetAt(i) - 1; } j = i - 3; for(int n = end; n >= start; n--) { NormalizeCompositeChar(str[i], sBuffer); } } else { int end = start + count1 ; for(int i = start; i < end; i++) { sBuffer += str[i]; } } } } str.Empty(); str += sBuffer; BidiChar->Release(); }