Example #1
0
CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
    const CFX_WideStringC& wsName,
    CXFA_WidgetAcc* pRefWidgetAcc) {
  CFX_WideString wsExpression;
  FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
                     XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
  IXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext();
  if (!pScriptContext) {
    return NULL;
  }
  CXFA_Node* refNode = NULL;
  if (pRefWidgetAcc != NULL) {
    refNode = pRefWidgetAcc->GetNode();
    wsExpression = wsName;
  } else {
    wsExpression = L"$form." + wsName;
  }
  XFA_RESOLVENODE_RS resoveNodeRS;
  int32_t iRet = pScriptContext->ResolveObjects(refNode, wsExpression,
                                                resoveNodeRS, dwStyle);
  if (iRet < 1) {
    return NULL;
  }
  if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
    CXFA_Node* pNode = resoveNodeRS.nodes[0]->AsNode();
    if (pNode) {
      return (CXFA_WidgetAcc*)pNode->GetWidgetData();
    }
  }
  return NULL;
}
int32_t CXFA_FFField::CalculateOverride() {
  CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup();
  if (!pAcc) {
    return CalculateWidgetAcc(m_pDataAcc);
  }
  if (CalculateWidgetAcc(pAcc) == 0) {
    return 0;
  }
  CXFA_Node* pNode = pAcc->GetExclGroupFirstMember();
  if (!pNode) {
    return 1;
  }
  CXFA_WidgetAcc* pWidgetAcc = nullptr;
  while (pNode) {
    pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
    if (!pWidgetAcc) {
      return 1;
    }
    if (CalculateWidgetAcc(pWidgetAcc) == 0) {
      return 0;
    }
    pNode = pWidgetAcc->GetExclGroupNextMember(pNode);
  }
  return 1;
}
Example #3
0
CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
  CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
                                     : m_ContentIterator.GetCurrent();
  while (pItem) {
    if ((m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) != NULL) {
      return m_pCurWidgetAcc;
    }
    pItem = m_ContentIterator.MoveToNext();
  }
  return NULL;
}
Example #4
0
CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
  CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
                                     : m_ContentIterator.GetCurrent();
  while (pItem) {
    m_pCurWidgetAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
    if (m_pCurWidgetAcc)
      return m_pCurWidgetAcc;
    pItem = m_ContentIterator.MoveToNext();
  }
  return nullptr;
}
void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData(
    CFXJSE_Arguments* pArguments) {
    int32_t iLength = pArguments->GetLength();
    if (iLength < 0 || iLength > 1) {
        ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData");
        return;
    }
    IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify();
    if (!pNotify) {
        return;
    }
    CFX_WideString wsExpression;
    if (iLength >= 1) {
        CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
        wsExpression =
            CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
    }
    if (wsExpression.IsEmpty()) {
        pNotify->ResetData();
        return;
    }
    int32_t iStart = 0;
    CFX_WideString wsName;
    CXFA_Node* pNode = NULL;
    int32_t iExpLength = wsExpression.GetLength();
    while (iStart < iExpLength) {
        iStart = XFA_FilterName(wsExpression, iStart, wsName);
        IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
        if (!pScriptContext) {
            return;
        }
        CXFA_Object* pObject = pScriptContext->GetThisObject();
        if (!pObject) {
            return;
        }
        FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
                          XFA_RESOLVENODE_Siblings;
        XFA_RESOLVENODE_RS resoveNodeRS;
        int32_t iRet =
            pScriptContext->ResolveObjects(pObject, wsName, resoveNodeRS, dwFlag);
        if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
            continue;
        }
        pNode = resoveNodeRS.nodes[0]->AsNode();
        pNotify->ResetData(pNode->GetWidgetData());
    }
    if (!pNode) {
        pNotify->ResetData();
    }
}
Example #6
0
void CXFA_FFDocView::RunSubformIndexChange() {
  int32_t iSubforms = m_IndexChangedSubforms.GetSize();
  for (int32_t i = 0; i < iSubforms; i++) {
    CXFA_Node* pSubformNode = (CXFA_Node*)m_IndexChangedSubforms[i];
    CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData();
    if (!pWidgetAcc) {
      continue;
    }
    CXFA_EventParam eParam;
    eParam.m_eType = XFA_EVENT_IndexChange;
    eParam.m_pTarget = pWidgetAcc;
    pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam);
  }
  m_IndexChangedSubforms.RemoveAll();
}
Example #7
0
IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToNext() {
  CXFA_Node* pItem = m_pCurWidget ? m_ContentIterator.MoveToNext()
                                  : m_ContentIterator.GetCurrent();
  while (pItem) {
    if (CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) {
      while ((m_pCurWidget = pAcc->GetNextWidget(NULL)) != NULL) {
        if (!m_pCurWidget->IsLoaded() &&
            (m_pCurWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
          m_pCurWidget->LoadWidget();
        }
        return m_pCurWidget;
      }
    }
    pItem = m_ContentIterator.MoveToNext();
  }
  return NULL;
}
Example #8
0
void CXFA_FFDocView::RunBindItems() {
  int32_t iCount = m_bindItems.GetSize();
  for (int32_t i = 0; i < iCount; i++) {
    if (reinterpret_cast<CXFA_Node*>(m_bindItems[i])
            ->HasFlag(XFA_NODEFLAG_HasRemoved)) {
      continue;
    }
    CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i])
                                 ->GetNodeItem(XFA_NODEITEM_Parent);
    CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData();
    if (!pAcc) {
      continue;
    }
    CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i]));
    IXFA_ScriptContext* pScriptContext =
        pWidgetNode->GetDocument()->GetScriptContext();
    CFX_WideStringC wsRef;
    binditems.GetRef(wsRef);
    FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
                       XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent |
                       XFA_RESOLVENODE_ALL;
    XFA_RESOLVENODE_RS rs;
    pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
    int32_t iCount = rs.nodes.GetSize();
    pAcc->DeleteItem(-1);
    if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) {
      continue;
    }
    CFX_WideStringC wsValueRef, wsLabelRef;
    binditems.GetValueRef(wsValueRef);
    binditems.GetLabelRef(wsLabelRef);
    FX_BOOL bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef;
    FX_BOOL bLabelUseContent =
        wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$");
    FX_BOOL bValueUseContent =
        wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$");
    CFX_WideString wsValue, wsLabel;
    FX_DWORD uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef),
                                                  wsValueRef.GetLength());
    for (int32_t i = 0; i < iCount; i++) {
      CXFA_Object* refObj = rs.nodes[i];
      if (!refObj->IsNode()) {
        continue;
      }
      CXFA_Node* refNode = refObj->AsNode();
      if (bValueUseContent) {
        wsValue = refNode->GetContent();
      } else {
        CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash);
        if (nodeValue == NULL) {
          wsValue = refNode->GetContent();
        } else {
          wsValue = nodeValue->GetContent();
        }
      }
      if (!bUseValue) {
        if (bLabelUseContent) {
          wsLabel = refNode->GetContent();
        } else {
          CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef);
          if (nodeLabel != NULL) {
            wsLabel = nodeLabel->GetContent();
          }
        }
      } else {
        wsLabel = wsValue;
      }
      pAcc->InsertItem(wsLabel, wsValue);
    }
  }
  m_bindItems.RemoveAll();
}
Example #9
0
void CXFA_FFDocView::RunBindItems() {
  for (int32_t i = 0; i < m_BindItems.GetSize(); i++) {
    if (m_BindItems[i]->HasRemovedChildren())
      continue;

    CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent);
    CXFA_WidgetAcc* pAcc =
        static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
    if (!pAcc)
      continue;

    CXFA_BindItems binditems(m_BindItems[i]);
    CXFA_ScriptContext* pScriptContext =
        pWidgetNode->GetDocument()->GetScriptContext();
    CFX_WideStringC wsRef;
    binditems.GetRef(wsRef);
    uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
                       XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent |
                       XFA_RESOLVENODE_ALL;
    XFA_RESOLVENODE_RS rs;
    pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
    int32_t iCount = rs.nodes.GetSize();
    pAcc->DeleteItem(-1);
    if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1)
      continue;

    CFX_WideStringC wsValueRef, wsLabelRef;
    binditems.GetValueRef(wsValueRef);
    binditems.GetLabelRef(wsLabelRef);
    const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef;
    const bool bLabelUseContent =
        wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$");
    const bool bValueUseContent =
        wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$");
    CFX_WideString wsValue;
    CFX_WideString wsLabel;
    uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false);
    for (int32_t j = 0; j < iCount; j++) {
      CXFA_Object* refObj = rs.nodes[j];
      if (!refObj->IsNode()) {
        continue;
      }
      CXFA_Node* refNode = refObj->AsNode();
      if (bValueUseContent) {
        wsValue = refNode->GetContent();
      } else {
        CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash);
        wsValue = nodeValue ? nodeValue->GetContent() : refNode->GetContent();
      }
      if (!bUseValue) {
        if (bLabelUseContent) {
          wsLabel = refNode->GetContent();
        } else {
          CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef);
          if (nodeLabel)
            wsLabel = nodeLabel->GetContent();
        }
      } else {
        wsLabel = wsValue;
      }
      pAcc->InsertItem(wsLabel, wsValue);
    }
  }
  m_BindItems.RemoveAll();
}