示例#1
0
DLLEXPORT FPDF_BOOL STDCALL
FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
                                  int index,
                                  FPDF_BYTESTRING bsText,
                                  FPDF_DWORD* size) {
  if (!sHandle || !size)
    return FALSE;

  int count = FPDF_StringHandleCounts(sHandle);
  if (index < 0 || index >= count)
    return FALSE;

  std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
  int len = (*sSuggestWords)[index].GetLength();
  if (!bsText) {
    *size = len;
    return TRUE;
  }

  int real_size = len < *size ? len : *size;
  if (real_size > 0)
    FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index],
                 real_size);
  *size = real_size;
  return TRUE;
}
示例#2
0
DLLEXPORT FPDF_BOOL STDCALL
FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle,
                                  int index,
                                  FPDF_BYTESTRING bsText,
                                  FPDF_DWORD* size) {
  if (stringHandle == NULL || size == NULL)
    return FALSE;
  int count = FPDF_StringHandleCounts(stringHandle);
  if (index < 0 || index >= count)
    return FALSE;

  CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle;
  int len = sSuggestWords[index].GetLength();

  if (bsText == NULL) {
    *size = len;
    return TRUE;
  }

  int real_size = len < *size ? len : *size;
  if (real_size > 0)
    FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index]),
                 real_size);
  *size = real_size;

  return TRUE;
}