| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" | 7 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 : CXFA_FMSimpleExpression(line, TOKnull) {} | 130 : CXFA_FMSimpleExpression(line, TOKnull) {} |
| 131 | 131 |
| 132 void CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 132 void CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 133 javascript << FX_WSTRC(L"null"); | 133 javascript << FX_WSTRC(L"null"); |
| 134 } | 134 } |
| 135 | 135 |
| 136 CXFA_FMNumberExpression::CXFA_FMNumberExpression(uint32_t line, | 136 CXFA_FMNumberExpression::CXFA_FMNumberExpression(uint32_t line, |
| 137 CFX_WideStringC wsNumber) | 137 CFX_WideStringC wsNumber) |
| 138 : CXFA_FMSimpleExpression(line, TOKnumber), m_wsNumber(wsNumber) {} | 138 : CXFA_FMSimpleExpression(line, TOKnumber), m_wsNumber(wsNumber) {} |
| 139 | 139 |
| 140 CXFA_FMNumberExpression::~CXFA_FMNumberExpression() {} |
| 141 |
| 140 void CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 142 void CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 141 javascript << m_wsNumber; | 143 javascript << m_wsNumber; |
| 142 } | 144 } |
| 143 | 145 |
| 144 CXFA_FMStringExpression::CXFA_FMStringExpression(uint32_t line, | 146 CXFA_FMStringExpression::CXFA_FMStringExpression(uint32_t line, |
| 145 CFX_WideStringC wsString) | 147 CFX_WideStringC wsString) |
| 146 : CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {} | 148 : CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {} |
| 147 | 149 |
| 150 CXFA_FMStringExpression::~CXFA_FMStringExpression() {} |
| 151 |
| 148 void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 152 void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 149 CFX_WideString tempStr(m_wsString); | 153 CFX_WideString tempStr(m_wsString); |
| 150 if (tempStr.GetLength() > 2) { | 154 if (tempStr.GetLength() > 2) { |
| 151 javascript.AppendChar(L'\"'); | 155 javascript.AppendChar(L'\"'); |
| 152 FX_WCHAR oneChar; | 156 FX_WCHAR oneChar; |
| 153 for (int16_t i = 1; i < tempStr.GetLength() - 1; i++) { | 157 for (int16_t i = 1; i < tempStr.GetLength() - 1; i++) { |
| 154 oneChar = tempStr[i]; | 158 oneChar = tempStr[i]; |
| 155 switch (oneChar) { | 159 switch (oneChar) { |
| 156 case L'\"': { | 160 case L'\"': { |
| 157 i++; | 161 i++; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 170 javascript << tempStr; | 174 javascript << tempStr; |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 | 177 |
| 174 CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( | 178 CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( |
| 175 uint32_t line, | 179 uint32_t line, |
| 176 CFX_WideStringC wsIdentifier) | 180 CFX_WideStringC wsIdentifier) |
| 177 : CXFA_FMSimpleExpression(line, TOKidentifier), | 181 : CXFA_FMSimpleExpression(line, TOKidentifier), |
| 178 m_wsIdentifier(wsIdentifier) {} | 182 m_wsIdentifier(wsIdentifier) {} |
| 179 | 183 |
| 184 CXFA_FMIdentifierExpressionn::~CXFA_FMIdentifierExpressionn() {} |
| 185 |
| 180 void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { | 186 void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 181 CFX_WideString tempStr(m_wsIdentifier); | 187 CFX_WideString tempStr(m_wsIdentifier); |
| 182 if (tempStr == FX_WSTRC(L"$")) { | 188 if (tempStr == FX_WSTRC(L"$")) { |
| 183 tempStr = FX_WSTRC(L"this"); | 189 tempStr = FX_WSTRC(L"this"); |
| 184 } else if (tempStr == FX_WSTRC(L"!")) { | 190 } else if (tempStr == FX_WSTRC(L"!")) { |
| 185 tempStr = FX_WSTRC(L"xfa.datasets"); | 191 tempStr = FX_WSTRC(L"xfa.datasets"); |
| 186 } else if (tempStr == FX_WSTRC(L"$data")) { | 192 } else if (tempStr == FX_WSTRC(L"$data")) { |
| 187 tempStr = FX_WSTRC(L"xfa.datasets.data"); | 193 tempStr = FX_WSTRC(L"xfa.datasets.data"); |
| 188 } else if (tempStr == FX_WSTRC(L"$event")) { | 194 } else if (tempStr == FX_WSTRC(L"$event")) { |
| 189 tempStr = FX_WSTRC(L"xfa.event"); | 195 tempStr = FX_WSTRC(L"xfa.event"); |
| 190 } else if (tempStr == FX_WSTRC(L"$form")) { | 196 } else if (tempStr == FX_WSTRC(L"$form")) { |
| 191 tempStr = FX_WSTRC(L"xfa.form"); | 197 tempStr = FX_WSTRC(L"xfa.form"); |
| 192 } else if (tempStr == FX_WSTRC(L"$host")) { | 198 } else if (tempStr == FX_WSTRC(L"$host")) { |
| 193 tempStr = FX_WSTRC(L"xfa.host"); | 199 tempStr = FX_WSTRC(L"xfa.host"); |
| 194 } else if (tempStr == FX_WSTRC(L"$layout")) { | 200 } else if (tempStr == FX_WSTRC(L"$layout")) { |
| 195 tempStr = FX_WSTRC(L"xfa.layout"); | 201 tempStr = FX_WSTRC(L"xfa.layout"); |
| 196 } else if (tempStr == FX_WSTRC(L"$template")) { | 202 } else if (tempStr == FX_WSTRC(L"$template")) { |
| 197 tempStr = FX_WSTRC(L"xfa.template"); | 203 tempStr = FX_WSTRC(L"xfa.template"); |
| 198 } else if (tempStr[0] == L'!') { | 204 } else if (tempStr[0] == L'!') { |
| 199 tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1); | 205 tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1); |
| 200 } | 206 } |
| 201 javascript << tempStr; | 207 javascript << tempStr; |
| 202 } | 208 } |
| 203 | 209 |
| 204 CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(uint32_t line, | 210 CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(uint32_t line, |
| 205 XFA_FM_TOKEN op, | 211 XFA_FM_TOKEN op, |
| 206 CXFA_FMSimpleExpression* pExp) | 212 CXFA_FMSimpleExpression* pExp) |
| 207 : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {} | 213 : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {} |
| 208 | 214 |
| 215 CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() {} |
| 216 |
| 209 void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} | 217 void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} |
| 210 | 218 |
| 211 CXFA_FMBinExpression::CXFA_FMBinExpression(uint32_t line, | 219 CXFA_FMBinExpression::CXFA_FMBinExpression(uint32_t line, |
| 212 XFA_FM_TOKEN op, | 220 XFA_FM_TOKEN op, |
| 213 CXFA_FMSimpleExpression* pExp1, | 221 CXFA_FMSimpleExpression* pExp1, |
| 214 CXFA_FMSimpleExpression* pExp2) | 222 CXFA_FMSimpleExpression* pExp2) |
| 215 : CXFA_FMSimpleExpression(line, op), m_pExp1(pExp1), m_pExp2(pExp2) {} | 223 : CXFA_FMSimpleExpression(line, op), m_pExp1(pExp1), m_pExp2(pExp2) {} |
| 216 | 224 |
| 225 CXFA_FMBinExpression::~CXFA_FMBinExpression() {} |
| 226 |
| 217 void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} | 227 void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} |
| 218 | 228 |
| 219 CXFA_FMAssignExpression::CXFA_FMAssignExpression(uint32_t line, | 229 CXFA_FMAssignExpression::CXFA_FMAssignExpression(uint32_t line, |
| 220 XFA_FM_TOKEN op, | 230 XFA_FM_TOKEN op, |
| 221 CXFA_FMSimpleExpression* pExp1, | 231 CXFA_FMSimpleExpression* pExp1, |
| 222 CXFA_FMSimpleExpression* pExp2) | 232 CXFA_FMSimpleExpression* pExp2) |
| 223 : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} | 233 : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} |
| 224 | 234 |
| 225 void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 235 void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 226 javascript << FX_WSTRC(L"if ("); | 236 javascript << FX_WSTRC(L"if ("); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 619 |
| 610 CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( | 620 CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( |
| 611 uint32_t line, | 621 uint32_t line, |
| 612 CXFA_FMSimpleExpression* pAccessor, | 622 CXFA_FMSimpleExpression* pAccessor, |
| 613 XFA_FM_TOKEN op, | 623 XFA_FM_TOKEN op, |
| 614 CFX_WideStringC wsIdentifier, | 624 CFX_WideStringC wsIdentifier, |
| 615 CXFA_FMSimpleExpression* pIndexExp) | 625 CXFA_FMSimpleExpression* pIndexExp) |
| 616 : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), | 626 : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), |
| 617 m_wsIdentifier(wsIdentifier) {} | 627 m_wsIdentifier(wsIdentifier) {} |
| 618 | 628 |
| 629 CXFA_FMDotAccessorExpression::~CXFA_FMDotAccessorExpression() {} |
| 630 |
| 619 void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 631 void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 620 javascript << gs_lpStrExpFuncName[DOT]; | 632 javascript << gs_lpStrExpFuncName[DOT]; |
| 621 javascript << FX_WSTRC(L"("); | 633 javascript << FX_WSTRC(L"("); |
| 622 if (m_pExp1) { | 634 if (m_pExp1) { |
| 623 m_pExp1->ToJavaScript(javascript); | 635 m_pExp1->ToJavaScript(javascript); |
| 624 } else { | 636 } else { |
| 625 javascript << FX_WSTRC(L"null"); | 637 javascript << FX_WSTRC(L"null"); |
| 626 } | 638 } |
| 627 javascript << FX_WSTRC(L", "); | 639 javascript << FX_WSTRC(L", "); |
| 628 javascript << FX_WSTRC(L"\""); | 640 javascript << FX_WSTRC(L"\""); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 697 |
| 686 CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( | 698 CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( |
| 687 uint32_t line, | 699 uint32_t line, |
| 688 CXFA_FMSimpleExpression* pAccessor, | 700 CXFA_FMSimpleExpression* pAccessor, |
| 689 XFA_FM_TOKEN op, | 701 XFA_FM_TOKEN op, |
| 690 CFX_WideStringC wsIdentifier, | 702 CFX_WideStringC wsIdentifier, |
| 691 CXFA_FMSimpleExpression* pIndexExp) | 703 CXFA_FMSimpleExpression* pIndexExp) |
| 692 : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), | 704 : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), |
| 693 m_wsIdentifier(wsIdentifier) {} | 705 m_wsIdentifier(wsIdentifier) {} |
| 694 | 706 |
| 707 CXFA_FMDotDotAccessorExpression::~CXFA_FMDotDotAccessorExpression() {} |
| 708 |
| 695 void CXFA_FMDotDotAccessorExpression::ToJavaScript( | 709 void CXFA_FMDotDotAccessorExpression::ToJavaScript( |
| 696 CFX_WideTextBuf& javascript) { | 710 CFX_WideTextBuf& javascript) { |
| 697 javascript << gs_lpStrExpFuncName[DOTDOT]; | 711 javascript << gs_lpStrExpFuncName[DOTDOT]; |
| 698 javascript << FX_WSTRC(L"("); | 712 javascript << FX_WSTRC(L"("); |
| 699 m_pExp1->ToJavaScript(javascript); | 713 m_pExp1->ToJavaScript(javascript); |
| 700 javascript << FX_WSTRC(L", "); | 714 javascript << FX_WSTRC(L", "); |
| 701 javascript << FX_WSTRC(L"\""); | 715 javascript << FX_WSTRC(L"\""); |
| 702 if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { | 716 if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { |
| 703 m_pExp1->ToJavaScript(javascript); | 717 m_pExp1->ToJavaScript(javascript); |
| 704 } | 718 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 729 L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); | 743 L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); |
| 730 javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); | 744 javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); |
| 731 m_pExp2->ToJavaScript(javascript); | 745 m_pExp2->ToJavaScript(javascript); |
| 732 javascript << FX_WSTRC(L";\n}\n}\n"); | 746 javascript << FX_WSTRC(L";\n}\n}\n"); |
| 733 javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); | 747 javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); |
| 734 m_pExp2->ToJavaScript(javascript); | 748 m_pExp2->ToJavaScript(javascript); |
| 735 javascript << FX_WSTRC(L";\n}\n"); | 749 javascript << FX_WSTRC(L";\n}\n"); |
| 736 javascript << FX_WSTRC(L"return method_return_value;\n"); | 750 javascript << FX_WSTRC(L"return method_return_value;\n"); |
| 737 javascript << FX_WSTRC(L"}\n).call(this)"); | 751 javascript << FX_WSTRC(L"}\n).call(this)"); |
| 738 } | 752 } |
| OLD | NEW |