diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 22 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_textlayout.cpp | 57 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 104 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fmparse.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_serialize.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_itemlayout.cpp | 38 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp | 35 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_object_imp.cpp | 26 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_imp.cpp | 14 |
11 files changed, 148 insertions, 178 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index beb7dec1a3..d8b65c4c5b 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -721,8 +721,7 @@ FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { return TRUE; } void CXFA_FFDocView::RunBindItems() { - int32_t iCount = m_BindItems.GetSize(); - for (int32_t i = 0; i < iCount; i++) { + for (int32_t i = 0; i < m_BindItems.GetSize(); i++) { if (m_BindItems[i]->HasFlag(XFA_NODEFLAG_HasRemoved)) continue; @@ -757,8 +756,8 @@ void CXFA_FFDocView::RunBindItems() { CFX_WideString wsValue; CFX_WideString wsLabel; uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false); - for (int32_t i = 0; i < iCount; i++) { - CXFA_Object* refObj = rs.nodes[i]; + for (int32_t j = 0; j < iCount; j++) { + CXFA_Object* refObj = rs.nodes[j]; if (!refObj->IsNode()) { continue; } diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 2a9638e817..8e10189f8c 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -1345,9 +1345,8 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, return; } FX_BOOL bSameStyles = TRUE; - int32_t i; CXFA_Stroke stroke1 = strokes[0]; - for (i = 1; i < 8; i++) { + for (int32_t i = 1; i < 8; i++) { CXFA_Stroke stroke2 = strokes[i]; if (!stroke1.SameStyles(stroke2)) { bSameStyles = FALSE; @@ -1357,7 +1356,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, } if (bSameStyles) { stroke1 = strokes[0]; - for (i = 2; i < 8; i += 2) { + for (int32_t i = 2; i < 8; i += 2) { CXFA_Stroke stroke2 = strokes[i]; if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) { @@ -1839,9 +1838,8 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box, } FX_BOOL bClose = FALSE; FX_BOOL bSameStyles = TRUE; - int32_t i; CXFA_Stroke stroke1 = strokes[0]; - for (i = 1; i < 8; i++) { + for (int32_t i = 1; i < 8; i++) { CXFA_Stroke stroke2 = strokes[i]; if (!stroke1.SameStyles(stroke2)) { bSameStyles = FALSE; @@ -1852,7 +1850,7 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box, if (bSameStyles) { stroke1 = strokes[0]; bClose = TRUE; - for (i = 2; i < 8; i += 2) { + for (int32_t i = 2; i < 8; i += 2) { CXFA_Stroke stroke2 = strokes[i]; if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) { @@ -1874,12 +1872,12 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box, FX_BOOL bStart = TRUE; CFX_Path path; path.Create(); - for (i = 0; i < 8; i++) { - CXFA_Stroke stroke1 = strokes[i]; - if ((i % 1) == 0 && stroke1.GetRadius() < 0) { + for (int32_t i = 0; i < 8; i++) { + CXFA_Stroke stroke = strokes[i]; + if ((i % 1) == 0 && stroke.GetRadius() < 0) { FX_BOOL bEmpty = path.IsEmpty(); if (!bEmpty) { - XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); + XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); path.Clear(); } bStart = TRUE; @@ -1887,9 +1885,9 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box, } XFA_BOX_GetPath(box, strokes, rtWidget, path, i, bStart, !bSameStyles); CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; - bStart = !stroke1.SameStyles(stroke2); + bStart = !stroke.SameStyles(stroke2); if (bStart) { - XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); + XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); path.Clear(); } } diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index fe72e29c05..fa300f1721 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -1042,12 +1042,11 @@ FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { } FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { - if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { + if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) return FALSE; - } - if (m_pLoader->m_fWidth < 1) { + if (m_pLoader->m_fWidth < 1) return FALSE; - } + m_pLoader->m_iTotalLines = -1; m_iLines = 0; FX_FLOAT fLinePos = 0; @@ -1056,9 +1055,8 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { int32_t iCount = m_Blocks.GetSize(); int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); iBlocksHeightCount /= 2; - if (iBlock < iBlocksHeightCount) { + if (iBlock < iBlocksHeightCount) return TRUE; - } if (iBlock == iBlocksHeightCount) { Unload(); m_pBreak.reset(CreateBreak(TRUE)); @@ -1067,18 +1065,15 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); } m_pLoader->m_iChar = 0; - if (iCount > 1) { + if (iCount > 1) m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); - } Loader(szText, fLinePos, TRUE); - if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) { + if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) UpdateAlign(szText.y, fLinePos); - } } else if (m_pTextDataNode) { iBlock *= 2; - if (iBlock < iCount - 2) { + if (iBlock < iCount - 2) m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); - } m_pBreak->Reset(); if (m_bRichText) { CFDE_XMLNode* pContainerNode = GetXMLContainerNode(); @@ -1086,48 +1081,40 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { return TRUE; } CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; - if (pXMLNode == NULL) { + if (!pXMLNode) return TRUE; - } CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; for (; pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, - m_pLoader->m_pParentStyle, TRUE); - if (!bFlag) { + if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, + TRUE)) { break; } } - while (pXMLNode == NULL) { + while (!pXMLNode) { pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); - if (pXMLNode == pContainerNode) { + if (pXMLNode == pContainerNode) break; - } - FX_BOOL bFlag = - LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, - TRUE, NULL, FALSE); - if (!bFlag) { + if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, + TRUE, NULL, FALSE)) { break; } pSaveXMLNode = pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); - if (!pXMLNode) { + if (!pXMLNode) continue; - } for (; pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, - m_pLoader->m_pParentStyle, TRUE); - if (!bFlag) { + if (!LoadRichText(pXMLNode, szText, fLinePos, + m_pLoader->m_pParentStyle, TRUE)) { break; } } } } else { pNode = m_pLoader->m_pNode; - if (pNode == NULL) { + if (!pNode) return TRUE; - } LoadText(pNode, szText, fLinePos, TRUE); } } @@ -1839,7 +1826,6 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, if (iChars > 0) { CFX_PointF pt1, pt2; FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; - int32_t i = 0; if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { for (int32_t i = 0; i < pPiece->iUnderline; i++) { for (int32_t j = 0; j < iChars; j++) { @@ -1866,7 +1852,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, pt1.x = pCharPos[0].m_OriginX; pt2.x = pCharPos[iChars - 1].m_OriginX + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; - for (i = 0; i < pPiece->iLineThrough; i++) { + for (int32_t i = 0; i < pPiece->iLineThrough; i++) { pt1.y = pt2.y = fEndY; pPath->AddLine(pt1, pt2); fEndY += 2.0f; @@ -1917,14 +1903,13 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, CFX_PointF pt1, pt2; pt1.x = fOrgX, pt2.x = fEndX; FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; - int32_t i = 0; - for (i = 0; i < pPiece->iUnderline; i++) { + for (int32_t i = 0; i < pPiece->iUnderline; i++) { pt1.y = pt2.y = fEndY; pPath->AddLine(pt1, pt2); fEndY += 2.0f; } fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; - for (i = 0; i < pPiece->iLineThrough; i++) { + for (int32_t i = 0; i < pPiece->iLineThrough; i++) { pt1.y = pt2.y = fEndY; pPath->AddLine(pt1, pt2); fEndY += 2.0f; diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index a31a5a189a..a9b296eb3f 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -647,8 +647,8 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); if (FXJSE_Value_IsNull(propertyValue.get())) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); if (!FXJSE_Value_IsNull(newPropertyValue.get())) @@ -657,8 +657,8 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, } else { CFX_ByteString propertyStr; FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), @@ -730,8 +730,8 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); if (FXJSE_Value_IsNull(propertyValue.get())) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); if (FXJSE_Value_IsNull(newPropertyValue.get())) @@ -744,8 +744,8 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, } else { CFX_ByteString propertyStr; FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), @@ -812,8 +812,8 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); if (FXJSE_Value_IsNull(propertyValue.get())) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); if (FXJSE_Value_IsNull(newPropertyValue.get())) @@ -826,8 +826,8 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, } else { CFX_ByteString propertyStr; FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, jsObjectValue.get()); FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), @@ -1943,21 +1943,21 @@ FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, } if (*(pData + iIndex) == '.') { ++iIndex; - FX_CHAR strTemp[4]; - strTemp[3] = '\0'; + FX_CHAR strSec[4]; + strSec[3] = '\0'; if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { return iRet; } - strTemp[0] = *(pData + iIndex); + strSec[0] = *(pData + iIndex); if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { return iRet; } - strTemp[1] = *(pData + iIndex + 1); + strSec[1] = *(pData + iIndex + 1); if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { return iRet; } - strTemp[2] = *(pData + iIndex + 2); - iMilliSecond = FXSYS_atoi(strTemp); + strSec[2] = *(pData + iIndex + 2); + iMilliSecond = FXSYS_atoi(strSec); if (iMilliSecond > 100) { iMilliSecond = 0; return iRet; @@ -3033,9 +3033,9 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, CFXJSE_Arguments& args) { CXFA_FM2JSContext* pContext = static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); int32_t argc = args.GetLength(); if (argc > 1) { + v8::Isolate* pIsolate = pContext->GetScriptRuntime(); std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); FX_BOOL argOneIsNull = FALSE; int32_t iIndex = 0; @@ -3245,8 +3245,8 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, CFXJSE_Arguments& args) { CXFA_FM2JSContext* pContext = static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); if (args.GetLength() == 1) { + v8::Isolate* pIsolate = pContext->GetScriptRuntime(); std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); CFX_ByteString utf8ScriptString; ValueToUTF8String(scriptValue.get(), utf8ScriptString); @@ -3259,16 +3259,16 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, CXFA_FM2JSContext::Translate( CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), wsJavaScriptBuf, wsError); - CFXJSE_Context* pContext = + CFXJSE_Context* pNewContext = FXJSE_Context_Create(pIsolate, nullptr, nullptr); std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); javaScript = wsJavaScriptBuf.AsStringC(); FXJSE_ExecuteScript( - pContext, + pNewContext, FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), returnValue.get()); FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); - FXJSE_Context_Release(pContext); + FXJSE_Context_Release(pNewContext); } } else { pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); @@ -3517,32 +3517,32 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, GetSimpleValue(pThis, args, 1); CFX_ByteString unitTempString; ValueToUTF8String(unitValue.get(), unitTempString); - const FX_CHAR* pData = unitTempString.c_str(); - int32_t u = 0; - while (*(pData + u) == ' ' || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; + const FX_CHAR* pChar = unitTempString.c_str(); + int32_t uVal = 0; + while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 || + *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C || + *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) { + ++uVal; } - while (u < unitTempString.GetLength()) { - if ((*(pData + u) > '9' || *(pData + u) < '0') && - *(pData + u) != '.') { + while (uVal < unitTempString.GetLength()) { + if ((*(pChar + uVal) > '9' || *(pChar + uVal) < '0') && + *(pChar + uVal) != '.') { break; } - ++u; + ++uVal; } - while (*(pData + u) == ' ' || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; + while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 || + *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C || + *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) { + ++uVal; } - int32_t uLen = unitTempString.GetLength(); - while (u < uLen) { - if (*(pData + u) == ' ') { + int32_t uValLen = unitTempString.GetLength(); + while (uVal < uValLen) { + if (*(pChar + uVal) == ' ') { break; } - strUnit += (*(pData + u)); - ++u; + strUnit += (*(pChar + uVal)); + ++uVal; } strUnit.MakeLower(); } else { @@ -4614,10 +4614,10 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, } else { wsTestPattern = FX_WSTRC(L"text{") + wsPattern; wsTestPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue2.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue2.GetValue()); FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue.AsStringC()); } else { @@ -5296,14 +5296,12 @@ void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, if (iInteger < iLength) { strBuf << " And "; iIndex = iInteger + 1; - int32_t iCount = 0; while (iIndex < iLength) { - iCount = (iLength - iIndex) % 12; - if (!iCount && iLength - iIndex > 0) { - iCount = 12; - } - TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); - iIndex += iCount; + int32_t iSize = (iLength - iIndex) % 12; + if (!iSize && iLength - iIndex > 0) + iSize = 12; + TrillionUS(CFX_ByteStringC(pData + iIndex, iSize), strBuf); + iIndex += iSize; if (iIndex < iLength) { strBuf << " Trillion "; } diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp index efbf224a40..5fd6c06613 100644 --- a/xfa/fxfa/fm2js/xfa_fmparse.cpp +++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp @@ -555,10 +555,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression( if (m_pToken->m_type != TOKrparen) { pArray.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>()); while (m_pToken->m_type != TOKrparen) { - CXFA_FMSimpleExpression* e = ParseSimpleExpression(); - if (e) { - pArray->Add(e); - } + if (CXFA_FMSimpleExpression* expr = ParseSimpleExpression()) + pArray->Add(expr); if (m_pToken->m_type == TOKcomma) { NextToken(); } else if (m_pToken->m_type == TOKeof || diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 03643cd988..7d7b50fb3f 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -811,7 +811,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( sNodeIterator.MoveToNext(); } else { CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; - CXFA_NodeArray subformArray; + CXFA_NodeArray nodeArray; for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { FX_BOOL bSelfMatch = FALSE; XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; @@ -830,11 +830,11 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( XFA_DataMerge_CreateDataBinding(pSubformNode, pDataNode); ASSERT(pSubformNode); subformMapArray.SetAt(pSubformNode, pDataNode); - subformArray.Add(pSubformNode); + nodeArray.Add(pSubformNode); } subformMapArray.GetStartPosition(); - for (int32_t iIndex = 0; iIndex < subformArray.GetSize(); iIndex++) { - CXFA_Node* pSubform = subformArray[iIndex]; + for (int32_t iIndex = 0; iIndex < nodeArray.GetSize(); iIndex++) { + CXFA_Node* pSubform = nodeArray[iIndex]; CXFA_Node* pDataNode = reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform)); for (CXFA_Node* pTemplateChild = diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index 497c8216dd..d7b8bf04d9 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -336,13 +336,12 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( pNode->GetClassID() == XFA_ELEMENT_Items) { wsChildren.clear(); bSaveXML = TRUE; - CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, - bSaveXML); + CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChild) { + XFA_DataExporter_RegenerateFormFile_Changed(pChild, newBuf, bSaveXML); wsChildren += newBuf.AsStringC(); newBuf.Clear(); - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); } } break; diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp index 7b7ecf4ba7..509bf630e9 100644 --- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp @@ -154,11 +154,11 @@ FX_BOOL CXFA_ItemLayoutProcessor::FindLayoutItemSplitPos( (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { FX_FLOAT fChildOffset = fCurVerticalOffset + fCurTopMargin + pChildItem->m_sPos.y; - FX_BOOL bAppChange = FALSE; + FX_BOOL bChange = FALSE; if (FindLayoutItemSplitPos(pChildItem, fChildOffset, fRelSplitPos, - bAppChange, bCalculateMargin)) { + bChange, bCalculateMargin)) { if (fRelSplitPos - fChildOffset < XFA_LAYOUT_FLOAT_PERCISION && - bAppChange) { + bChange) { fProposedSplitPos = fRelSplitPos - fCurTopMargin; } else { fProposedSplitPos = fRelSplitPos + fCurBottomMargin; @@ -1922,13 +1922,13 @@ void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( } static XFA_ItemLayoutProcessorResult XFA_ItemLayoutProcessor_InsertFlowedItem( CXFA_ItemLayoutProcessor* pThis, - CXFA_ItemLayoutProcessor*& pProcessor, + CXFA_ItemLayoutProcessor* pProcessor, FX_BOOL bContainerWidthAutoSize, FX_BOOL bContainerHeightAutoSize, FX_FLOAT fContainerHeight, XFA_ATTRIBUTEENUM eFlowStrategy, uint8_t& uCurHAlignState, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> (&rgCurLineLayoutItems)[3], FX_BOOL bUseBreakControl, FX_FLOAT fAvailHeight, FX_FLOAT fRealHeight, @@ -2266,6 +2266,7 @@ static XFA_ItemLayoutProcessorResult XFA_ItemLayoutProcessor_InsertFlowedItem( } return XFA_ItemLayoutProcessorResult_Done; } + XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( FX_BOOL bUseBreakControl, XFA_ATTRIBUTEENUM eFlowStrategy, @@ -2445,7 +2446,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( pLayoutChild = NULL; } while (m_pCurChildNode) { - CXFA_ItemLayoutProcessor* pProcessor = NULL; + CXFA_ItemLayoutProcessor* pProcessor = nullptr; FX_BOOL bAddedItemInRow = FALSE; fContentCurRowY += XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); @@ -2477,18 +2478,16 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( XFA_ItemLayoutProcessor_AddPendingNode(this, pTrailerNode, TRUE); } else { - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); + std::unique_ptr<CXFA_ItemLayoutProcessor> pTempProcessor( + new CXFA_ItemLayoutProcessor(pTrailerNode, nullptr)); XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, + this, pTempProcessor.get(), bContainerWidthAutoSize, bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, uCurHAlignState, rgCurLineLayoutItems, FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, fContentWidthLimit, fContentCurRowAvailWidth, fContentCurRowHeight, bAddedItemInRow, bForceEndPage, pContext); - delete pProcessor; - pProcessor = NULL; } } XFA_ItemLayoutProcessor_GotoNextContainerNode( @@ -2507,18 +2506,16 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( bCreatePage) && m_pFormNode->GetClassID() != XFA_ELEMENT_Form) { if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); + std::unique_ptr<CXFA_ItemLayoutProcessor> pTempProcessor( + new CXFA_ItemLayoutProcessor(pTrailerNode, nullptr)); XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, + this, pTempProcessor.get(), bContainerWidthAutoSize, bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, uCurHAlignState, rgCurLineLayoutItems, FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, fContentWidthLimit, fContentCurRowAvailWidth, fContentCurRowHeight, bAddedItemInRow, bForceEndPage, pContext); - delete pProcessor; - pProcessor = NULL; } if (!bCreatePage) { if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { @@ -2528,18 +2525,16 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( fContentCalculatedWidth, fContentCalculatedHeight, fContentCurRowY, fContentCurRowHeight, fContentWidthLimit); rgCurLineLayoutItems->RemoveAll(); - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pLeaderNode, NULL); + std::unique_ptr<CXFA_ItemLayoutProcessor> pTempProcessor( + new CXFA_ItemLayoutProcessor(pLeaderNode, nullptr)); XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, + this, pTempProcessor.get(), bContainerWidthAutoSize, bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, uCurHAlignState, rgCurLineLayoutItems, FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, fContentWidthLimit, fContentCurRowAvailWidth, fContentCurRowHeight, bAddedItemInRow, bForceEndPage, pContext); - delete pProcessor; - pProcessor = NULL; } } else { if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { @@ -2715,6 +2710,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( : (bIsManualBreak ? XFA_ItemLayoutProcessorResult_ManualBreak : XFA_ItemLayoutProcessorResult_PageFullBreak); } + FX_BOOL CXFA_ItemLayoutProcessor::CalculateRowChildPosition( CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], XFA_ATTRIBUTEENUM eFlowStrategy, diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp index 02bc0a8469..4b36bc8e4c 100644 --- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -140,30 +140,29 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, int32_t iSpliteIndex = 0; FX_BOOL bTargetAllFind = TRUE; while (iSpliteIndex != -1) { - CFX_WideString wsTargetExpr; + CFX_WideString wsExpr; int32_t iSpliteNextIndex = 0; if (!bTargetAllFind) { iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); - wsTargetExpr = - wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); + wsExpr = wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); } else { - wsTargetExpr = wsTargetAll; + wsExpr = wsTargetAll; } - if (wsTargetExpr.IsEmpty()) + if (wsExpr.IsEmpty()) return nullptr; bTargetAllFind = FALSE; - if (wsTargetExpr.GetAt(0) == '#') { + if (wsExpr.GetAt(0) == '#') { CXFA_Node* pNode = pDocument->GetNodeByID( ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), - wsTargetExpr.Mid(1).AsStringC()); + wsExpr.Mid(1).AsStringC()); if (pNode) return pNode; } else if (bNewExprStyle) { - CFX_WideString wsProcessedTarget = wsTargetExpr; - if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && - wsTargetExpr.Right(1) == FX_WSTRC(L")")) { - wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); + CFX_WideString wsProcessedTarget = wsExpr; + if (wsExpr.Left(4) == FX_WSTRC(L"som(") && + wsExpr.Right(1) == FX_WSTRC(L")")) { + wsProcessedTarget = wsExpr.Mid(4, wsExpr.GetLength() - 5); } XFA_RESOLVENODE_RS rs; int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( @@ -893,7 +892,6 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, CXFA_Node*& pLeaderTemplate, CXFA_Node*& pTrailerTemplate, FX_BOOL bCreatePage) { - CFX_WideStringC wsOverflowLeader, wsOverflowTrailer; CXFA_Node* pContainer = pOverflowNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode) @@ -937,6 +935,8 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, } return NULL; } else if (pOverflowNode->GetClassID() == XFA_ELEMENT_Overflow) { + CFX_WideStringC wsOverflowLeader; + CFX_WideStringC wsOverflowTrailer; CFX_WideStringC wsOverflowTarget; pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); @@ -967,8 +967,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, } return pOverflowNode; } - return NULL; + return nullptr; } + FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, CXFA_Node*& pLeaderNode, CXFA_Node*& pTrailerNode, @@ -1718,11 +1719,11 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { pDocument, pContainerItem->m_pFormNode->GetClassID(), pContainerItem->m_pFormNode->GetNameHash(), pParentNode); CXFA_ContainerIterator sIterator(pExistingNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { + for (CXFA_Node* pIter = sIterator.GetCurrent(); pIter; + pIter = sIterator.MoveToNext()) { + if (pIter->GetClassID() != XFA_ELEMENT_ContentArea) { CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pNode->GetUserData(XFA_LAYOUTITEMKEY)); + pIter->GetUserData(XFA_LAYOUTITEMKEY)); if (pLayoutItem) { pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); delete pLayoutItem; diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index f3bb4fefb2..cfe65ed864 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -1393,8 +1393,8 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( if (!pValueNode) { return; } - XFA_ELEMENT eType = pValueNode->GetClassID(); - if (eType == XFA_ELEMENT_Value) { + XFA_ELEMENT eNodeType = pValueNode->GetClassID(); + if (eNodeType == XFA_ELEMENT_Value) { bNeedFindContainer = true; CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); if (pNode && pNode->IsContainerNode()) { @@ -1407,7 +1407,7 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( pNode->GetNodeItem(XFA_NODEITEM_Parent)); } } else { - if (eType == XFA_ELEMENT_Items) { + if (eNodeType == XFA_ELEMENT_Items) { CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); if (pNode && pNode->IsContainerNode()) { pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); @@ -4190,12 +4190,10 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, CXFA_NodeArray nodeArray; pBind->GetBindItems(nodeArray); for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - if (pNode == this) { - continue; + if (nodeArray[i] != this) { + nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, + bScriptModify, FALSE); } - pNode->SetScriptContent(wsContent, wsContent, bNotify, - bScriptModify, FALSE); } } break; @@ -4215,11 +4213,10 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, CXFA_NodeArray nodeArray; pBindNode->GetBindItems(nodeArray); for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - if (pNode == this) { - continue; + if (nodeArray[i] != this) { + nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, true, + FALSE); } - pNode->SetScriptContent(wsContent, wsContent, bNotify, true, FALSE); } } pBindNode = nullptr; @@ -4280,9 +4277,8 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, CXFA_NodeArray nodeArray; pBindNode->GetBindItems(nodeArray); for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - pNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, - FALSE); + nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, + bScriptModify, FALSE); } } return TRUE; diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index 357566ed9c..528758f6f8 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -219,10 +219,10 @@ void CXFA_ScriptContext::GlobalPropertyGetter(CFXJSE_Value* pObject, XFA_HashCode uHashCode = static_cast<XFA_HashCode>( FX_HashCode_GetW(wsPropName.AsStringC(), false)); if (uHashCode != XFA_HASHCODE_Layout) { - CXFA_Object* pObject = + CXFA_Object* pObj = lpScriptContext->GetDocument()->GetXFAObject(uHashCode); - if (pObject) { - FXJSE_Value_Set(pValue, lpScriptContext->GetJSValueFromMap(pObject)); + if (pObj) { + FXJSE_Value_Set(pValue, lpScriptContext->GetJSValueFromMap(pObj)); return; } } @@ -335,12 +335,12 @@ void CXFA_ScriptContext::NormalPropertySetter(CFXJSE_Value* pOriginalValue, } if (pPropOrChild) { CFX_WideString wsDefaultName(L"{default}"); - const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = + const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo = XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), wsDefaultName.AsStringC()); - if (lpAttributeInfo) { - (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( - pReturnValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); + if (lpAttrInfo) { + (pPropOrChild->*(lpAttrInfo->lpfnCallback))( + pReturnValue, TRUE, (XFA_ATTRIBUTE)lpAttrInfo->eAttribute); return; } } |