Example #1
0
void CPDFXFA_App::Response(CFX_WideString& wsAnswer,
                           const CFX_WideStringC& wsQuestion,
                           const CFX_WideStringC& wsTitle,
                           const CFX_WideStringC& wsDefaultAnswer,
                           FX_BOOL bMark) {
  CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
  if (pEnv) {
    int nLength = 2048;
    char* pBuff = new char[nLength];
    nLength = pEnv->JS_appResponse(wsQuestion.GetPtr(), wsTitle.GetPtr(),
                                   wsDefaultAnswer.GetPtr(), NULL, bMark, pBuff,
                                   nLength);
    if (nLength > 0) {
      nLength = nLength > 2046 ? 2046 : nLength;
      pBuff[nLength] = 0;
      pBuff[nLength + 1] = 0;
      wsAnswer = CFX_WideString::FromUTF16LE(
          reinterpret_cast<const unsigned short*>(pBuff),
          nLength / sizeof(unsigned short));
    }
    delete[] pBuff;
  }
}