CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
    CXFA_Document* pDocument,
    CXFA_Node* pDataParent,
    XFA_Element eNodeType,
    const CFX_WideString& wsName) {
  if (!pDataParent) {
    return nullptr;
  }
  CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode();
  if (!pParentDDNode) {
    CXFA_Node* pDataNode =
        pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
    ASSERT(pDataNode);
    pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
    pDataNode->CreateXMLMappingNode();
    pDataParent->InsertChild(pDataNode);
    pDataNode->SetFlag(XFA_NodeFlag_Initialized, false);
    return pDataNode;
  } else {
    CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
        sIterator(pParentDDNode);
    for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode;
         pDDGroupNode = sIterator.MoveToNext()) {
      if (pDDGroupNode != pParentDDNode) {
        if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) {
          continue;
        }
        CFX_WideString wsNamespace;
        if (!pDDGroupNode->TryNamespace(wsNamespace) ||
            wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
          continue;
        }
      }
      CXFA_Node* pDDNode =
          pDDGroupNode->GetFirstChildByName(wsName.AsStringC());
      if (!pDDNode) {
        continue;
      }
      if (pDDNode->GetElementType() != eNodeType) {
        break;
      }
      CXFA_Node* pDataNode =
          pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
      ASSERT(pDataNode);
      pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
      pDataNode->CreateXMLMappingNode();
      if (eNodeType == XFA_Element::DataValue &&
          pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) ==
              XFA_ATTRIBUTEENUM_MetaData) {
        pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData);
      }
      pDataParent->InsertChild(pDataNode);
      pDataNode->SetDataDescriptionNode(pDDNode);
      pDataNode->SetFlag(XFA_NodeFlag_Initialized, false);
      return pDataNode;
    }
    return nullptr;
  }
}
Пример #2
0
int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) {
    CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Pattern);
    if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) {
        CFX_WideStringC wsColor;
        pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
        foreColor = CXFA_Data::ToColor(wsColor);
    } else {
        foreColor = 0xFF000000;
    }
    return pNode->GetEnum(XFA_ATTRIBUTE_Type);
}
Пример #3
0
void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) {
  size.clear();
  CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium);
  if (!pMedium)
    return;

  size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
                   pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
  if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
      XFA_ATTRIBUTEENUM_Landscape) {
    size = CFX_SizeF(size.y, size.x);
  }
}
CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
  CFX_SizeF size;
  CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_Element::Medium);
  if (!pMedium)
    return size;

  size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
                   pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
  if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
      XFA_ATTRIBUTEENUM_Landscape) {
    size = CFX_SizeF(size.height, size.width);
  }
  return size;
}
Пример #5
0
XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(IXFA_Doc* hDoc) {
  CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc();
  if (!pXFADoc) {
    return XFA_ATTRIBUTEENUM_Unknown;
  }
  CXFA_Node* pForm = (CXFA_Node*)pXFADoc->GetXFANode(XFA_HASHCODE_Form);
  if (!pForm) {
    return XFA_ATTRIBUTEENUM_Unknown;
  }
  CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform);
  if (!pSubForm) {
    return XFA_ATTRIBUTEENUM_Unknown;
  }
  return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState);
}
Пример #6
0
FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) {
  FX_BOOL bRet = FALSE;
  if (!pFieldNode) {
    return bRet;
  }
  CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui);
  if (pUIChild) {
    CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
    if (pFirstChild && pFirstChild->GetClassID() == XFA_ELEMENT_ChoiceList) {
      bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) ==
             XFA_ATTRIBUTEENUM_MultiSelect;
    }
  }
  return bRet;
}
Пример #7
0
CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_ELEMENT& eWidgetType) {
  XFA_ELEMENT eType = pNode->GetClassID();
  eWidgetType = eType;
  if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_Draw) {
    return NULL;
  }
  eWidgetType = XFA_ELEMENT_UNKNOWN;
  XFA_ELEMENT eUIType = XFA_ELEMENT_UNKNOWN;
  CXFA_Value defValue(pNode->GetProperty(0, XFA_ELEMENT_Value, TRUE));
  XFA_ELEMENT eValueType = (XFA_ELEMENT)defValue.GetChildValueClassID();
  switch (eValueType) {
    case XFA_ELEMENT_Boolean:
      eUIType = XFA_ELEMENT_CheckButton;
      break;
    case XFA_ELEMENT_Integer:
    case XFA_ELEMENT_Decimal:
    case XFA_ELEMENT_Float:
      eUIType = XFA_ELEMENT_NumericEdit;
      break;
    case XFA_ELEMENT_ExData:
    case XFA_ELEMENT_Text:
      eUIType = XFA_ELEMENT_TextEdit;
      eWidgetType = XFA_ELEMENT_Text;
      break;
    case XFA_ELEMENT_Date:
    case XFA_ELEMENT_Time:
    case XFA_ELEMENT_DateTime:
      eUIType = XFA_ELEMENT_DateTimeEdit;
      break;
    case XFA_ELEMENT_Image:
      eUIType = XFA_ELEMENT_ImageEdit;
      eWidgetType = XFA_ELEMENT_Image;
      break;
      ;
    case XFA_ELEMENT_Arc:
    case XFA_ELEMENT_Line:
    case XFA_ELEMENT_Rectangle:
      eUIType = XFA_ELEMENT_DefaultUi;
      eWidgetType = eValueType;
      break;
    default:
      break;
  }
  CXFA_Node* pUIChild = NULL;
  CXFA_Node* pUI = pNode->GetProperty(0, XFA_ELEMENT_Ui, TRUE);
  CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
  for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
    XFA_ELEMENT eChild = pChild->GetClassID();
    if (eChild == XFA_ELEMENT_Extras || eChild == XFA_ELEMENT_Picture) {
      continue;
    }
    XFA_LPCPROPERTY pProterty =
        XFA_GetPropertyOfElement(XFA_ELEMENT_Ui, eChild, XFA_XDPPACKET_Form);
    if (pProterty && (pProterty->uFlags & XFA_PROPERTYFLAG_OneOf)) {
      pUIChild = pChild;
      break;
    }
  }
  if (eType == XFA_ELEMENT_Draw) {
    XFA_ELEMENT eDraw = pUIChild ? pUIChild->GetClassID() : XFA_ELEMENT_UNKNOWN;
    switch (eDraw) {
      case XFA_ELEMENT_TextEdit:
        eWidgetType = XFA_ELEMENT_Text;
        break;
      case XFA_ELEMENT_ImageEdit:
        eWidgetType = XFA_ELEMENT_Image;
        break;
      default:
        eWidgetType =
            eWidgetType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_Text : eWidgetType;
        break;
    }
  } else {
    if (pUIChild && pUIChild->GetClassID() == XFA_ELEMENT_DefaultUi) {
      eWidgetType = XFA_ELEMENT_TextEdit;
    } else {
      eWidgetType = pUIChild
                        ? pUIChild->GetClassID()
                        : (eUIType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_TextEdit
                                                          : eUIType);
    }
  }
  if (!pUIChild) {
    if (eUIType == XFA_ELEMENT_UNKNOWN) {
      eUIType = XFA_ELEMENT_TextEdit;
      defValue.GetNode()->GetProperty(0, XFA_ELEMENT_Text, TRUE);
    }
    pUIChild = pUI->GetProperty(0, eUIType, TRUE);
  } else if (eUIType == XFA_ELEMENT_UNKNOWN) {
    switch (pUIChild->GetClassID()) {
      case XFA_ELEMENT_CheckButton: {
        eValueType = XFA_ELEMENT_Text;
        if (CXFA_Node* pItems = pNode->GetChild(0, XFA_ELEMENT_Items)) {
          if (CXFA_Node* pItem = pItems->GetChild(0, XFA_ELEMENT_UNKNOWN)) {
            eValueType = pItem->GetClassID();
          }
        }
      } break;
      case XFA_ELEMENT_DateTimeEdit:
        eValueType = XFA_ELEMENT_DateTime;
        break;
      case XFA_ELEMENT_ImageEdit:
        eValueType = XFA_ELEMENT_Image;
        break;
      case XFA_ELEMENT_NumericEdit:
        eValueType = XFA_ELEMENT_Float;
        break;
      case XFA_ELEMENT_ChoiceList: {
        eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) ==
                      XFA_ATTRIBUTEENUM_MultiSelect)
                         ? XFA_ELEMENT_ExData
                         : XFA_ELEMENT_Text;
      } break;
      case XFA_ELEMENT_Barcode:
      case XFA_ELEMENT_Button:
      case XFA_ELEMENT_PasswordEdit:
      case XFA_ELEMENT_Signature:
      case XFA_ELEMENT_TextEdit:
      default:
        eValueType = XFA_ELEMENT_Text;
        break;
    }
    defValue.GetNode()->GetProperty(0, eValueType, TRUE);
  }
  return pUIChild;
}