Ejemplo n.º 1
0
FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                      CPDFSDK_Annot* pAnnot,
                                      FX_UINT nFlags,
                                      const CPDF_Point& point) {
    ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
    CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
    CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();

    switch (pWidget->GetFieldType()) {
    case FIELDTYPE_PUSHBUTTON:
    case FIELDTYPE_CHECKBOX:
    case FIELDTYPE_RADIOBUTTON:
        if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
            pDocument->SetFocusAnnot(pAnnot);
        break;
    default:
        pDocument->SetFocusAnnot(pAnnot);
        break;
    }

    FX_BOOL bRet = FALSE;

    if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
        bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
    }

    if (pDocument->GetFocusAnnot() == pAnnot) {
        FX_BOOL bExit = FALSE;
        FX_BOOL bReset = FALSE;
        OnButtonUp(pWidget, pPageView, bReset, bExit, nFlags);
        if (bExit)
            return TRUE;
    }
    return bRet;
}
Ejemplo n.º 2
0
void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
  if (pAnnot->GetSubType() == BFFT_SIGNATURE)
    return;

  CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
  if (!pWidget->IsAppearanceValid())
    pWidget->ResetAppearance(NULL, FALSE);

  int nFieldType = pWidget->GetFieldType();
  if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
    FX_BOOL bFormated = FALSE;
    CFX_WideString sValue = pWidget->OnFormat(bFormated);
    if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
      pWidget->ResetAppearance(sValue.c_str(), FALSE);
    }
  }

#ifdef PDF_ENABLE_XFA
  CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
  CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
  CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
  if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
    if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
      pWidget->ResetAppearance(FALSE);
  }
#endif  // PDF_ENABLE_XFA
  if (m_pFormFiller)
    m_pFormFiller->OnLoad(pAnnot);
}
Ejemplo n.º 3
0
void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
  if (pAnnot->IsSignatureWidget())
    return;

  CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
  if (!pWidget->IsAppearanceValid())
    pWidget->ResetAppearance(nullptr, FALSE);

  int nFieldType = pWidget->GetFieldType();
  if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
    FX_BOOL bFormatted = FALSE;
    CFX_WideString sValue = pWidget->OnFormat(bFormatted);
    if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX)
      pWidget->ResetAppearance(&sValue, FALSE);
  }

#ifdef PDF_ENABLE_XFA
  CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
  CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
  CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
  if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
    if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
      pWidget->ResetAppearance(FALSE);
  }
#endif  // PDF_ENABLE_XFA
  if (m_pFormFiller)
    m_pFormFiller->OnLoad(pAnnot);
}
Ejemplo n.º 4
0
FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag)
{
    if(m_pFocusAnnot)
    {
        CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
        if(pAnnotHandler)
        {
            CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
            m_pFocusAnnot = NULL;
            if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag))
            {

                if(pFocusAnnot->GetType() == FX_BSTRC("Widget"))
                {
                    CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
                    int nFieldType = pWidget->GetFieldType();
                    if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType)
                        m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE);
                }

                if(!m_pFocusAnnot)
                    return TRUE;
            }
            else
            {
                m_pFocusAnnot = pFocusAnnot;
            }
        }
    }
    return FALSE;
}
Ejemplo n.º 5
0
CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)
{
// 	ASSERT(pAnnot != NULL);
// 	ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");

	CFFL_FormFiller * pFormFiller = NULL;
	m_Maps.Lookup(pAnnot, pFormFiller);

	if (pFormFiller)
		return pFormFiller;

	if (bRegister)
	{
		CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;		

		int nFieldType = pWidget->GetFieldType();
		switch(nFieldType)
		{
 		case FIELDTYPE_PUSHBUTTON:
 			pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
 			break;
		case FIELDTYPE_CHECKBOX:
			pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
			break;
 		case FIELDTYPE_RADIOBUTTON:
 			pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
 			break;
 		case FIELDTYPE_TEXTFIELD:
			pFormFiller = new CFFL_TextField(m_pApp, pWidget);
			break;
		case FIELDTYPE_LISTBOX:
			pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
			break;
		case FIELDTYPE_COMBOBOX:
			pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
			break;
		case FIELDTYPE_UNKNOWN:
		default:
			pFormFiller = NULL;
			break;
		}

		if (pFormFiller)
		{
			m_Maps.SetAt(pAnnot, pFormFiller);
		}
	}

	return pFormFiller;
}
Ejemplo n.º 6
0
CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller(
    CPDFSDK_Annot* pAnnot,
    bool bRegister) {
  auto it = m_Maps.find(pAnnot);
  if (it != m_Maps.end())
    return it->second.get();

  if (!bRegister)
    return nullptr;

  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
  FormFieldType fieldType = pWidget->GetFieldType();
  std::unique_ptr<CFFL_FormFiller> pFormFiller;
  switch (fieldType) {
    case FormFieldType::kPushButton:
      pFormFiller =
          pdfium::MakeUnique<CFFL_PushButton>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kCheckBox:
      pFormFiller =
          pdfium::MakeUnique<CFFL_CheckBox>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kRadioButton:
      pFormFiller =
          pdfium::MakeUnique<CFFL_RadioButton>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kTextField:
      pFormFiller =
          pdfium::MakeUnique<CFFL_TextField>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kListBox:
      pFormFiller =
          pdfium::MakeUnique<CFFL_ListBox>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kComboBox:
      pFormFiller =
          pdfium::MakeUnique<CFFL_ComboBox>(m_pFormFillEnv.Get(), pWidget);
      break;
    case FormFieldType::kUnknown:
    default:
      break;
  }

  if (!pFormFiller)
    return nullptr;

  CFFL_FormFiller* result = pFormFiller.get();
  m_Maps[pAnnot] = std::move(pFormFiller);
  return result;
}
Ejemplo n.º 7
0
CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot,
        FX_BOOL bRegister) {
    auto it = m_Maps.find(pAnnot);
    if (it != m_Maps.end())
        return it->second;

    if (!bRegister)
        return nullptr;

    CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
    int nFieldType = pWidget->GetFieldType();
    CFFL_FormFiller* pFormFiller;
    switch (nFieldType) {
    case FIELDTYPE_PUSHBUTTON:
        pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
        break;
    case FIELDTYPE_CHECKBOX:
        pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
        break;
    case FIELDTYPE_RADIOBUTTON:
        pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
        break;
    case FIELDTYPE_TEXTFIELD:
        pFormFiller = new CFFL_TextField(m_pApp, pWidget);
        break;
    case FIELDTYPE_LISTBOX:
        pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
        break;
    case FIELDTYPE_COMBOBOX:
        pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
        break;
    case FIELDTYPE_UNKNOWN:
    default:
        pFormFiller = nullptr;
        break;
    }

    if (!pFormFiller)
        return nullptr;

    m_Maps[pAnnot] = pFormFiller;
    return pFormFiller;
}
Ejemplo n.º 8
0
FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
  ASSERT(pAnnot->GetType() == "Widget");
  if (pAnnot->GetSubType() == BFFT_SIGNATURE)
    return FALSE;

  CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
  if (!pWidget->IsVisible())
    return FALSE;

  int nFieldFlags = pWidget->GetFieldFlags();
  if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
    return FALSE;

  if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
    return TRUE;

  CPDF_Page* pPage = pWidget->GetPDFPage();
  CPDF_Document* pDocument = pPage->m_pDocument;
  FX_DWORD dwPermissions = pDocument->GetUserPermissions();
  return (dwPermissions & FPDFPERM_FILL_FORM) ||
         (dwPermissions & FPDFPERM_ANNOT_FORM);
}
Ejemplo n.º 9
0
FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
  ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET);
  if (pAnnot->IsSignatureWidget())
    return FALSE;

  CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
  if (!pWidget->IsVisible())
    return FALSE;

  int nFieldFlags = pWidget->GetFieldFlags();
  if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
    return FALSE;

  if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
    return TRUE;

  CPDF_Page* pPage = pWidget->GetPDFPage();
  CPDF_Document* pDocument = pPage->m_pDocument;
  uint32_t dwPermissions = pDocument->GetUserPermissions();
  return (dwPermissions & FPDFPERM_FILL_FORM) ||
         (dwPermissions & FPDFPERM_ANNOT_FORM);
}
Ejemplo n.º 10
0
bool CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                             CPDFSDK_Annot::ObservedPtr* pAnnot,
                                             uint32_t nFlags,
                                             const CFX_PointF& point) {
  ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot->Get());

  bool bSetFocus;
  switch (pWidget->GetFieldType()) {
    case FormFieldType::kPushButton:
    case FormFieldType::kCheckBox:
    case FormFieldType::kRadioButton: {
      FX_RECT bbox = GetViewBBox(pPageView, pAnnot->Get());
      bSetFocus =
          bbox.Contains(static_cast<int>(point.x), static_cast<int>(point.y));
      break;
    }
    default:
      bSetFocus = true;
      break;
  }
  if (bSetFocus)
    m_pFormFillEnv->SetFocusAnnot(pAnnot);

  CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false);
  bool bRet = pFormFiller &&
              pFormFiller->OnLButtonUp(pPageView, pAnnot->Get(), nFlags, point);
  if (m_pFormFillEnv->GetFocusAnnot() != pAnnot->Get())
    return bRet;
  if (OnButtonUp(pAnnot, pPageView, nFlags) || !pAnnot)
    return true;
#ifdef PDF_ENABLE_XFA
  if (OnClick(pAnnot, pPageView, nFlags) || !pAnnot)
    return true;
#endif  // PDF_ENABLE_XFA
  return bRet;
}