示例#1
0
FX_BOOL CXFA_FFListBox::LoadWidget() {
  CFWL_ListBox* pListBox = CFWL_ListBox::Create();
  pListBox->Initialize();
  pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground,
                         0xFFFFFFFF);
  m_pNormalWidget = (CFWL_Widget*)pListBox;
  IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
  m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
  pNoteDriver->RegisterEventTarget(pWidget, pWidget);
  m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
  m_pNormalWidget->LockUpdate();
  CFX_WideStringArray wsLabelArray;
  m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
  int32_t iItems = wsLabelArray.GetSize();
  for (int32_t i = 0; i < iItems; i++) {
    pListBox->AddString(wsLabelArray[i]);
  }
  FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus;
  if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
    dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection;
  }
  dwExtendedStyle |= GetAlignment();
  m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  for (int32_t j = 0; j < iSelCount; j++) {
    FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]);
    pListBox->SetSelItem(item, TRUE);
  }
  m_pNormalWidget->UnlockUpdate();
  return CXFA_FFField::LoadWidget();
}
示例#2
0
void CFGAS_FontMgr::GetNames(const uint8_t* name_table,
                             CFX_WideStringArray& Names) {
  if (!name_table)
    return;

  uint8_t* lpTable = (uint8_t*)name_table;
  CFX_WideString wsFamily;
  uint8_t* sp = lpTable + 2;
  uint8_t* lpNameRecord = lpTable + 6;
  uint16_t nNameCount = GetUInt16(sp);
  uint8_t* lpStr = lpTable + GetUInt16(sp + 2);
  for (uint16_t j = 0; j < nNameCount; j++) {
    uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6);
    if (nNameID != 1)
      continue;

    uint16_t nPlatformID = GetUInt16(lpNameRecord + j * 12 + 0);
    uint16_t nNameLength = GetUInt16(lpNameRecord + j * 12 + 8);
    uint16_t nNameOffset = GetUInt16(lpNameRecord + j * 12 + 10);
    wsFamily.clear();
    if (nPlatformID != 1) {
      for (uint16_t k = 0; k < nNameLength / 2; k++) {
        FX_WCHAR wcTemp = GetUInt16(lpStr + nNameOffset + k * 2);
        wsFamily += wcTemp;
      }
      Names.Add(wsFamily);
      continue;
    }
    for (uint16_t k = 0; k < nNameLength; k++) {
      FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k);
      wsFamily += wcTemp;
    }
    Names.Add(wsFamily);
  }
}
示例#3
0
bool CXFA_FFComboBox::LoadWidget() {
  CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp());
  pComboBox->Initialize();
  m_pNormalWidget = (CFWL_Widget*)pComboBox;
  m_pNormalWidget->SetLayoutItem(this);

  IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
  CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
  pNoteDriver->RegisterEventTarget(pWidget, pWidget);

  m_pOldDelegate = m_pNormalWidget->GetDelegate();
  m_pNormalWidget->SetDelegate(this);
  m_pNormalWidget->LockUpdate();

  CFX_WideStringArray wsLabelArray;
  m_pDataAcc->GetChoiceListItems(wsLabelArray, false);
  int32_t iItems = wsLabelArray.GetSize();
  for (int32_t i = 0; i < iItems; i++) {
    pComboBox->AddString(wsLabelArray[i].AsStringC());
  }
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  if (iSelCount > 0) {
    pComboBox->SetCurSel(iSelArray[0]);
  } else {
    CFX_WideString wsText;
    m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
    pComboBox->SetEditText(wsText);
  }
  UpdateWidgetProperty();
  m_pNormalWidget->UnlockUpdate();
  return CXFA_FFField::LoadWidget();
}
示例#4
0
void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) {
  allFieldNames.RemoveAll();
  int nCount = m_pFieldTree->m_Root.CountFields();
  for (int i = 0; i < nCount; i++) {
    CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
    if (pField) {
      CFX_WideString full_name = GetFullName(pField->GetFieldDict());
      allFieldNames.Add(full_name);
    }
  }
}
示例#5
0
void PDF_GetPageText(CFX_ByteStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
                     int iMinWidth, FX_DWORD flags)
{
    lines.RemoveAll();
    CFX_WideStringArray wlines;
    PDF_GetPageText_Unicode(wlines, pDoc, pPage, iMinWidth, flags);
    for (int i = 0; i < wlines.GetSize(); i ++) {
        CFX_WideString wstr = wlines[i];
        CFX_ByteString str;
        for (int c = 0; c < wstr.GetLength(); c ++) {
            str += CharFromUnicodeAlt(wstr[c], FXSYS_GetACP(), "?");
        }
        lines.Add(str);
    }
}
示例#6
0
void PDF_GetPageText_Unicode(CFX_WideStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
                             int iMinWidth, FX_DWORD flags)
{
    lines.RemoveAll();
    if (pPage == NULL) {
        return;
    }
    CPDF_Page page;
    page.Load(pDoc, pPage);
    CPDF_ParseOptions options;
    options.m_bTextOnly = TRUE;
    options.m_bSeparateForm = FALSE;
    page.ParseContent(&options);
    CFX_FloatRect page_bbox = page.GetPageBBox();
    if (flags & PDF2TXT_AUTO_ROTATE) {
        CheckRotate(page, page_bbox);
    }
    CTextPage texts;
    texts.m_bAutoWidth = flags & PDF2TXT_AUTO_WIDTH;
    texts.m_bKeepColumn = flags & PDF2TXT_KEEP_COLUMN;
    texts.m_bBreakSpace = TRUE;
    FX_POSITION pos = page.GetFirstObjectPosition();
    while (pos) {
        CPDF_PageObject* pObject = page.GetNextObject(pos);
        if (!(flags & PDF2TXT_INCLUDE_INVISIBLE)) {
            CFX_FloatRect rect(pObject->m_Left, pObject->m_Bottom, pObject->m_Right, pObject->m_Top);
            if (!page_bbox.Contains(rect)) {
                continue;
            }
        }
        texts.ProcessObject(pObject);
    }
    texts.WriteOutput(lines, iMinWidth);
}
示例#7
0
void CJS_Runtime::GetObjectMethods(const CFX_WideString& sObjName, CFX_WideStringArray& array)
{
	JSMethodSpec* pMethods = NULL;
	int nSize = 0;

 	 if (sObjName == CJS_App::m_pClassName)
		CJS_App::GetMethods(pMethods, nSize);
	else if (sObjName == CJS_Color::m_pClassName)
		CJS_Color::GetMethods(pMethods, nSize);	
	else if (sObjName == L"this") 
	{
		if (GetReaderDocument())
			CJS_Document::GetMethods(pMethods, nSize);
		else	
			CJS_App::GetMethods(pMethods, nSize);
	}
	else if (sObjName == CJS_Event::m_pClassName)
		CJS_Event::GetMethods(pMethods, nSize);	
	else if (sObjName == CJS_Field::m_pClassName)
		CJS_Field::GetMethods(pMethods, nSize);	
	else if (sObjName == CJS_Global::m_pClassName)
		CJS_Global::GetMethods(pMethods, nSize);	
	else if (sObjName == CJS_Util::m_pClassName)
		CJS_Util::GetMethods(pMethods, nSize);

	for (int i=0; i<nSize; i++)
		array.Add(pMethods[i].pName);
}
示例#8
0
bool CXFA_FFListBox::LoadWidget() {
  CFWL_ListBox* pListBox = new CFWL_ListBox(GetFWLApp());
  pListBox->Initialize();
  pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground,
                         0xFFFFFFFF);
  m_pNormalWidget = (CFWL_Widget*)pListBox;
  m_pNormalWidget->SetLayoutItem(this);

  IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
  CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
  pNoteDriver->RegisterEventTarget(pWidget, pWidget);

  m_pOldDelegate = m_pNormalWidget->GetDelegate();
  m_pNormalWidget->SetDelegate(this);
  m_pNormalWidget->LockUpdate();

  CFX_WideStringArray wsLabelArray;
  m_pDataAcc->GetChoiceListItems(wsLabelArray, false);
  int32_t iItems = wsLabelArray.GetSize();
  for (int32_t i = 0; i < iItems; i++) {
    pListBox->AddString(wsLabelArray[i].AsStringC());
  }
  uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus;
  if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
    dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection;
  }
  dwExtendedStyle |= GetAlignment();
  m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  for (int32_t j = 0; j < iSelCount; j++) {
    CFWL_ListItem* item = pListBox->GetItem(iSelArray[j]);
    pListBox->SetSelItem(item, true);
  }
  m_pNormalWidget->UnlockUpdate();
  return CXFA_FFField::LoadWidget();
}
FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult,
                                         const CFX_WideString& wsFormat,
                                         IFX_Locale* pLocale,
                                         XFA_VALUEPICTURE eValueType) const {
  wsResult.clear();
  FX_BOOL bRet = FALSE;

  CFX_FormatString* pFormat = nullptr;
  if (m_pLocaleMgr)
    pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);

  CFX_WideStringArray wsPatterns;
  pFormat->SplitFormatString(wsFormat, wsPatterns);
  int32_t iCount = wsPatterns.GetSize();
  for (int32_t i = 0; i < iCount; i++) {
    bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType);
    if (bRet) {
      break;
    }
  }
  pFormat->Release();
  return bRet;
}
示例#10
0
void CJS_Runtime::GetObjectConsts(const CFX_WideString& sObjName, CFX_WideStringArray& array)
{
	JSConstSpec* pConsts = NULL;
	int nSize = 0;

	if (sObjName == CJS_Border::m_pClassName)
		CJS_Border::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Display::m_pClassName)
		CJS_Display::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Font::m_pClassName)
		CJS_Font::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Highlight::m_pClassName)
		CJS_Highlight::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Position::m_pClassName)
		CJS_Position::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_ScaleHow::m_pClassName)
		CJS_ScaleHow::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_ScaleWhen::m_pClassName)
		CJS_ScaleWhen::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Style::m_pClassName)
		CJS_Style::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Zoomtype::m_pClassName)
		CJS_Zoomtype::GetConsts(pConsts, nSize);

	else if (sObjName == CJS_App::m_pClassName)
		CJS_App::GetConsts(pConsts, nSize);
	else if (sObjName == CJS_Color::m_pClassName)
		CJS_Color::GetConsts(pConsts, nSize);	

	else if (sObjName == L"this") 
	{
		if (GetReaderDocument())
			CJS_Document::GetConsts(pConsts, nSize);
		else 
			CJS_App::GetConsts(pConsts, nSize);
	}

	if (sObjName == CJS_Event::m_pClassName)
		CJS_Event::GetConsts(pConsts, nSize);	
	else if (sObjName == CJS_Field::m_pClassName)
		CJS_Field::GetConsts(pConsts, nSize);	
	else if (sObjName == CJS_Global::m_pClassName)
		CJS_Global::GetConsts(pConsts, nSize);	
	else if (sObjName == CJS_Util::m_pClassName)
		CJS_Util::GetConsts(pConsts, nSize);

	for (int i=0; i<nSize; i++)
		array.Add(pConsts[i].pName);
}
示例#11
0
void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth)
{
    FX_FLOAT lastheight = -1;
    FX_FLOAT lastbaseline = -1;
    FX_FLOAT MinLeftX = 1000000;
    FX_FLOAT MaxRightX = 0;
    int i;
    for (i = 0; i < m_BaseLines.GetSize(); i ++) {
        CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
        FX_FLOAT leftx, rightx;
        if (pBaseLine->GetWidth(leftx, rightx)) {
            if (leftx < MinLeftX) {
                MinLeftX = leftx;
            }
            if (rightx > MaxRightX) {
                MaxRightX = rightx;
            }
        }
    }
    for (i = 0; i < m_BaseLines.GetSize(); i ++) {
        CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
        pBaseLine->MergeBoxes();
    }
    for (i = 1; i < m_BaseLines.GetSize(); i ++) {
        CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
        CTextBaseLine* pPrevLine = (CTextBaseLine*)m_BaseLines.GetAt(i - 1);
        if (pBaseLine->CanMerge(pPrevLine)) {
            pPrevLine->Merge(pBaseLine);
            delete pBaseLine;
            m_BaseLines.RemoveAt(i);
            i --;
        }
    }
    if (m_bAutoWidth) {
        int* widths = FX_Alloc(int, m_BaseLines.GetSize());
        if (widths) {
            for (i = 0; i < m_BaseLines.GetSize(); i ++) {
                widths[i] = 0;
                CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
                int TotalChars = 0;
                FX_FLOAT TotalWidth = 0;
                int minchars;
                pBaseLine->CountChars(TotalChars, TotalWidth, minchars);
                if (TotalChars) {
                    FX_FLOAT charwidth = TotalWidth / TotalChars;
                    widths[i] = (int)((MaxRightX - MinLeftX) / charwidth);
                }
                if (widths[i] > 1000) {
                    widths[i] = 1000;
                }
                if (widths[i] < minchars) {
                    widths[i] = minchars;
                }
            }
            int AvgWidth = 0, widthcount = 0;
            for (i = 0; i < m_BaseLines.GetSize(); i ++)
                if (widths[i]) {
                    AvgWidth += widths[i];
                    widthcount ++;
                }
            AvgWidth = int((FX_FLOAT)AvgWidth / widthcount + 0.5);
            int MaxWidth = 0;
            for (i = 0; i < m_BaseLines.GetSize(); i ++)
                if (MaxWidth < widths[i]) {
                    MaxWidth = widths[i];
                }
            if (MaxWidth > AvgWidth * 6 / 5) {
                MaxWidth = AvgWidth * 6 / 5;
            }
            FX_Free(widths);
            if (iMinWidth < MaxWidth) {
                iMinWidth = MaxWidth;
            }
        }
    }
    for (i = 0; i < m_BaseLines.GetSize(); i ++) {
        CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
        pBaseLine->MergeBoxes();
    }
    if (m_bKeepColumn) {
        FindColumns();
    }
    for (i = 0; i < m_BaseLines.GetSize(); i ++) {
        CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
        if (lastheight >= 0) {
            FX_FLOAT dy = lastbaseline - pBaseLine->m_BaseLine;
            if (dy >= (pBaseLine->m_MaxFontSizeV) * 1.5 || dy >= lastheight * 1.5) {
                lines.Add(L"");
            }
        }
        lastheight = pBaseLine->m_MaxFontSizeV;
        lastbaseline = pBaseLine->m_BaseLine;
        CFX_WideString str;
        pBaseLine->WriteOutput(str, MinLeftX, MaxRightX - MinLeftX, iMinWidth);
        lines.Add(str);
    }
}
示例#12
0
void CJS_Runtime::GetObjectNames(CFX_WideStringArray& array)
{
	array.RemoveAll();

	array.Add(CJS_Border::m_pClassName);
	array.Add(CJS_Display::m_pClassName);
	array.Add(CJS_Font::m_pClassName);
	array.Add(CJS_Highlight::m_pClassName);
	array.Add(CJS_Position::m_pClassName);
	array.Add(CJS_ScaleHow::m_pClassName);
	array.Add(CJS_ScaleWhen::m_pClassName);
	array.Add(CJS_Style::m_pClassName);
	array.Add(CJS_Zoomtype::m_pClassName);

	array.Add(CJS_App::m_pClassName);
	array.Add((FX_LPCWSTR)"this"); 
	array.Add(CJS_Event::m_pClassName);	

	array.Add(CJS_Global::m_pClassName);	
	array.Add(CJS_Util::m_pClassName);
}
FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue,
                                        const CFX_WideString& wsPattern,
                                        IFX_Locale* pLocale,
                                        CFX_WideString* pMatchFormat) {
  CFX_WideString wsOutput;
  IFX_Locale* locale = m_pLocaleMgr->GetDefLocale();
  if (pLocale) {
    m_pLocaleMgr->SetDefLocale(pLocale);
  }
  CFX_FormatString* pFormat = nullptr;
  if (m_pLocaleMgr)
    pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);

  CFX_WideStringArray wsPatterns;
  pFormat->SplitFormatString(wsPattern, wsPatterns);
  FX_BOOL bRet = FALSE;
  int32_t iCount = wsPatterns.GetSize();
  int32_t i = 0;
  for (; i < iCount && !bRet; i++) {
    CFX_WideString wsFormat = wsPatterns[i];
    FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat);
    eCategory = XFA_ValugeCategory(eCategory, m_dwType);
    switch (eCategory) {
      case FX_LOCALECATEGORY_Null:
        bRet = pFormat->ParseNull(wsValue, wsFormat);
        if (!bRet) {
          bRet = wsValue.IsEmpty();
        }
        break;
      case FX_LOCALECATEGORY_Zero:
        bRet = pFormat->ParseZero(wsValue, wsFormat);
        if (!bRet) {
          bRet = wsValue == FX_WSTRC(L"0");
        }
        break;
      case FX_LOCALECATEGORY_Num: {
        CFX_WideString fNum;
        bRet = pFormat->ParseNum(wsValue, wsFormat, fNum);
        if (!bRet) {
          bRet = pFormat->FormatNum(wsValue, wsFormat, wsOutput);
        }
        break;
      }
      case FX_LOCALECATEGORY_Text:
        bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput);
        wsOutput.clear();
        if (!bRet) {
          bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput);
        }
        break;
      case FX_LOCALECATEGORY_Date: {
        CFX_Unitime dt;
        bRet = ValidateCanonicalDate(wsValue, dt);
        if (!bRet) {
          bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date,
                                        dt);
          if (!bRet) {
            bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput,
                                           FX_DATETIMETYPE_Date);
          }
        }
        break;
      }
      case FX_LOCALECATEGORY_Time: {
        CFX_Unitime dt;
        bRet =
            pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, dt);
        if (!bRet) {
          bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput,
                                         FX_DATETIMETYPE_Time);
        }
        break;
      }
      case FX_LOCALECATEGORY_DateTime: {
        CFX_Unitime dt;
        bRet = pFormat->ParseDateTime(wsValue, wsFormat,
                                      FX_DATETIMETYPE_DateTime, dt);
        if (!bRet) {
          bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput,
                                         FX_DATETIMETYPE_DateTime);
        }
        break;
      }
      default:
        bRet = FALSE;
        break;
    }
  }
  if (bRet && pMatchFormat) {
    *pMatchFormat = wsPatterns[i - 1];
  }
  pFormat->Release();
  if (pLocale) {
    m_pLocaleMgr->SetDefLocale(locale);
  }
  return bRet;
}