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/app/xfa_ffwidgetacc.h" | 7 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); | 274 pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); |
275 } else { | 275 } else { |
276 CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); | 276 CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); |
277 ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); | 277 ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); |
278 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"href", wsHref); | 278 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"href", wsHref); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { | 282 CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { |
283 CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); | 283 CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); |
284 if (!pExcl || pExcl->GetClassID() != XFA_Element::ExclGroup) { | 284 if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) { |
285 return NULL; | 285 return NULL; |
286 } | 286 } |
287 return static_cast<CXFA_WidgetAcc*>(pExcl->GetWidgetData()); | 287 return static_cast<CXFA_WidgetAcc*>(pExcl->GetWidgetData()); |
288 } | 288 } |
289 CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { | 289 CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { |
290 return m_pDocView; | 290 return m_pDocView; |
291 } | 291 } |
292 CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { | 292 CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { |
293 return m_pDocView->GetDoc(); | 293 return m_pDocView->GetDoc(); |
294 } | 294 } |
295 CXFA_FFApp* CXFA_WidgetAcc::GetApp() { | 295 CXFA_FFApp* CXFA_WidgetAcc::GetApp() { |
296 return GetDoc()->GetApp(); | 296 return GetDoc()->GetApp(); |
297 } | 297 } |
298 IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { | 298 IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { |
299 return GetApp()->GetAppProvider(); | 299 return GetApp()->GetAppProvider(); |
300 } | 300 } |
301 int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, | 301 int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, |
302 CXFA_EventParam* pEventParam) { | 302 CXFA_EventParam* pEventParam) { |
303 if (GetClassID() == XFA_Element::Draw) { | 303 if (GetElementType() == XFA_Element::Draw) { |
304 return XFA_EVENTERROR_NotExist; | 304 return XFA_EVENTERROR_NotExist; |
305 } | 305 } |
306 int32_t iRet = XFA_EVENTERROR_NotExist; | 306 int32_t iRet = XFA_EVENTERROR_NotExist; |
307 CXFA_NodeArray eventArray; | 307 CXFA_NodeArray eventArray; |
308 int32_t iCounts = | 308 int32_t iCounts = |
309 GetEventByActivity(iActivity, eventArray, pEventParam->m_bIsFormReady); | 309 GetEventByActivity(iActivity, eventArray, pEventParam->m_bIsFormReady); |
310 for (int32_t i = 0; i < iCounts; i++) { | 310 for (int32_t i = 0; i < iCounts; i++) { |
311 CXFA_Event event(eventArray[i]); | 311 CXFA_Event event(eventArray[i]); |
312 int32_t result = ProcessEvent(event, pEventParam); | 312 int32_t result = ProcessEvent(event, pEventParam); |
313 if (i == 0) { | 313 if (i == 0) { |
(...skipping 22 matching lines...) Expand all Loading... |
336 CXFA_Submit submit = event.GetSubmit(); | 336 CXFA_Submit submit = event.GetSubmit(); |
337 return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); | 337 return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); |
338 } | 338 } |
339 default: | 339 default: |
340 break; | 340 break; |
341 } | 341 } |
342 return XFA_EVENTERROR_NotExist; | 342 return XFA_EVENTERROR_NotExist; |
343 } | 343 } |
344 | 344 |
345 int32_t CXFA_WidgetAcc::ProcessCalculate() { | 345 int32_t CXFA_WidgetAcc::ProcessCalculate() { |
346 if (GetClassID() == XFA_Element::Draw) | 346 if (GetElementType() == XFA_Element::Draw) |
347 return XFA_EVENTERROR_NotExist; | 347 return XFA_EVENTERROR_NotExist; |
348 | 348 |
349 CXFA_Calculate calc = GetCalculate(); | 349 CXFA_Calculate calc = GetCalculate(); |
350 if (!calc) | 350 if (!calc) |
351 return XFA_EVENTERROR_NotExist; | 351 return XFA_EVENTERROR_NotExist; |
352 if (GetNode()->IsUserInteractive()) | 352 if (GetNode()->IsUserInteractive()) |
353 return XFA_EVENTERROR_Disabled; | 353 return XFA_EVENTERROR_Disabled; |
354 | 354 |
355 CXFA_EventParam EventParam; | 355 CXFA_EventParam EventParam; |
356 EventParam.m_eType = XFA_EVENT_Calculate; | 356 EventParam.m_eType = XFA_EVENT_Calculate; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 pAppProvider->LoadString(XFA_IDS_ValidateError, wsError); | 562 pAppProvider->LoadString(XFA_IDS_ValidateError, wsError); |
563 wsMessage.Format(wsError.c_str(), wsCaptionName.c_str()); | 563 wsMessage.Format(wsError.c_str(), wsCaptionName.c_str()); |
564 return; | 564 return; |
565 } | 565 } |
566 CFX_WideString wsWarning; | 566 CFX_WideString wsWarning; |
567 pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning); | 567 pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning); |
568 wsMessage.Format(wsWarning.c_str(), wsCaptionName.c_str(), | 568 wsMessage.Format(wsWarning.c_str(), wsCaptionName.c_str(), |
569 wsCaptionName.c_str()); | 569 wsCaptionName.c_str()); |
570 } | 570 } |
571 int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { | 571 int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { |
572 if (GetClassID() == XFA_Element::Draw) { | 572 if (GetElementType() == XFA_Element::Draw) { |
573 return XFA_EVENTERROR_NotExist; | 573 return XFA_EVENTERROR_NotExist; |
574 } | 574 } |
575 CXFA_Validate validate = GetValidate(); | 575 CXFA_Validate validate = GetValidate(); |
576 if (!validate) { | 576 if (!validate) { |
577 return XFA_EVENTERROR_NotExist; | 577 return XFA_EVENTERROR_NotExist; |
578 } | 578 } |
579 FX_BOOL bInitDoc = validate.GetNode()->NeedsInitApp(); | 579 FX_BOOL bInitDoc = validate.GetNode()->NeedsInitApp(); |
580 FX_BOOL bStatus = | 580 FX_BOOL bStatus = |
581 m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; | 581 m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; |
582 int32_t iFormat = 0; | 582 int32_t iFormat = 0; |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 return; | 1400 return; |
1401 case XFA_Element::Image: | 1401 case XFA_Element::Image: |
1402 m_pLayoutData.reset(new CXFA_ImageLayoutData); | 1402 m_pLayoutData.reset(new CXFA_ImageLayoutData); |
1403 return; | 1403 return; |
1404 case XFA_Element::ImageEdit: | 1404 case XFA_Element::ImageEdit: |
1405 m_pLayoutData.reset(new CXFA_ImageEditData); | 1405 m_pLayoutData.reset(new CXFA_ImageEditData); |
1406 return; | 1406 return; |
1407 default: | 1407 default: |
1408 break; | 1408 break; |
1409 } | 1409 } |
1410 if (GetClassID() == XFA_Element::Field) { | 1410 if (GetElementType() == XFA_Element::Field) { |
1411 m_pLayoutData.reset(new CXFA_FieldLayoutData); | 1411 m_pLayoutData.reset(new CXFA_FieldLayoutData); |
1412 return; | 1412 return; |
1413 } | 1413 } |
1414 m_pLayoutData.reset(new CXFA_WidgetLayoutData); | 1414 m_pLayoutData.reset(new CXFA_WidgetLayoutData); |
1415 } | 1415 } |
1416 | 1416 |
1417 void CXFA_WidgetAcc::StartTextLayout(FX_FLOAT& fCalcWidth, | 1417 void CXFA_WidgetAcc::StartTextLayout(FX_FLOAT& fCalcWidth, |
1418 FX_FLOAT& fCalcHeight) { | 1418 FX_FLOAT& fCalcHeight) { |
1419 LoadText(); | 1419 LoadText(); |
1420 CXFA_TextLayout* pTextLayout = | 1420 CXFA_TextLayout* pTextLayout = |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 } | 1549 } |
1550 FX_ARGB CXFA_WidgetAcc::GetTextColor() { | 1550 FX_ARGB CXFA_WidgetAcc::GetTextColor() { |
1551 if (CXFA_Font font = GetFont()) { | 1551 if (CXFA_Font font = GetFont()) { |
1552 return font.GetColor(); | 1552 return font.GetColor(); |
1553 } | 1553 } |
1554 return 0xFF000000; | 1554 return 0xFF000000; |
1555 } | 1555 } |
1556 CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { | 1556 CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { |
1557 bRichText = FALSE; | 1557 bRichText = FALSE; |
1558 if (m_pTextNode) { | 1558 if (m_pTextNode) { |
1559 if (m_pTextNode->GetClassID() == XFA_Element::ExData) { | 1559 if (m_pTextNode->GetElementType() == XFA_Element::ExData) { |
1560 CFX_WideString wsContentType; | 1560 CFX_WideString wsContentType; |
1561 m_pTextNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, | 1561 m_pTextNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, |
1562 FALSE); | 1562 FALSE); |
1563 if (wsContentType == FX_WSTRC(L"text/html")) { | 1563 if (wsContentType == FX_WSTRC(L"text/html")) { |
1564 bRichText = TRUE; | 1564 bRichText = TRUE; |
1565 } | 1565 } |
1566 } | 1566 } |
1567 return m_pTextNode; | 1567 return m_pTextNode; |
1568 } | 1568 } |
1569 if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { | 1569 if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { |
1570 CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); | 1570 CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); |
1571 CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_Element::Value); | 1571 CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_Element::Value); |
1572 if (!pValueNode) { | 1572 if (!pValueNode) { |
1573 return NULL; | 1573 return NULL; |
1574 } | 1574 } |
1575 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1575 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
1576 if (pChildNode && pChildNode->GetClassID() == XFA_Element::ExData) { | 1576 if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { |
1577 CFX_WideString wsContentType; | 1577 CFX_WideString wsContentType; |
1578 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); | 1578 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); |
1579 if (wsContentType == FX_WSTRC(L"text/html")) { | 1579 if (wsContentType == FX_WSTRC(L"text/html")) { |
1580 bRichText = TRUE; | 1580 bRichText = TRUE; |
1581 } | 1581 } |
1582 } | 1582 } |
1583 return pChildNode; | 1583 return pChildNode; |
1584 } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { | 1584 } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { |
1585 CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); | 1585 CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); |
1586 CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); | 1586 CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); |
(...skipping 14 matching lines...) Expand all Loading... |
1601 CXFA_Node* pCaptionNode = | 1601 CXFA_Node* pCaptionNode = |
1602 m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); | 1602 m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); |
1603 if (pCaptionNode == NULL) { | 1603 if (pCaptionNode == NULL) { |
1604 return NULL; | 1604 return NULL; |
1605 } | 1605 } |
1606 CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_Element::Value); | 1606 CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_Element::Value); |
1607 if (pValueNode == NULL) { | 1607 if (pValueNode == NULL) { |
1608 return NULL; | 1608 return NULL; |
1609 } | 1609 } |
1610 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1610 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
1611 if (pChildNode && pChildNode->GetClassID() == XFA_Element::ExData) { | 1611 if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { |
1612 CFX_WideString wsContentType; | 1612 CFX_WideString wsContentType; |
1613 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); | 1613 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); |
1614 if (wsContentType == FX_WSTRC(L"text/html")) { | 1614 if (wsContentType == FX_WSTRC(L"text/html")) { |
1615 bRichText = TRUE; | 1615 bRichText = TRUE; |
1616 } | 1616 } |
1617 } | 1617 } |
1618 return pChildNode; | 1618 return pChildNode; |
1619 } | 1619 } |
1620 CXFA_Node* pItemNode = | 1620 CXFA_Node* pItemNode = |
1621 m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items); | 1621 m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 if (pIDNode) { | 1687 if (pIDNode) { |
1688 pEmbAcc = static_cast<CXFA_WidgetAcc*>(pIDNode->GetWidgetData()); | 1688 pEmbAcc = static_cast<CXFA_WidgetAcc*>(pIDNode->GetWidgetData()); |
1689 } | 1689 } |
1690 if (pEmbAcc) { | 1690 if (pEmbAcc) { |
1691 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 1691 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
1692 return TRUE; | 1692 return TRUE; |
1693 } | 1693 } |
1694 } | 1694 } |
1695 return FALSE; | 1695 return FALSE; |
1696 } | 1696 } |
OLD | NEW |