Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
nsGtkIMEHelper Class Reference

#include <nsGtkIMEHelper.h>

Collaboration diagram for nsGtkIMEHelper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~nsGtkIMEHelper ()
nsresult ConvertToUnicode (const char *aSrc, PRInt32 *aSrcLen, PRUnichar *aDes, PRInt32 *aDesLen)
void ResetDecoder ()
PRInt32 MultiByteToUnicode (const char *, const PRInt32, PRUnichar **, PRInt32 *)

Static Public Member Functions

static nsGtkIMEHelperGetSingleton ()
static void Shutdown ()

Private Member Functions

 nsGtkIMEHelper ()
void SetupUnicodeDecoder ()

Private Attributes

nsIUnicodeDecodermDecoder

Static Private Attributes

static nsGtkIMEHelpergSingleton = nsnull

Detailed Description

Definition at line 47 of file nsGtkIMEHelper.h.


Constructor & Destructor Documentation

Definition at line 93 of file nsGtkIMEHelper.cpp.

{
  MOZ_COUNT_DTOR(nsGtkIMEHelper);
  NS_IF_RELEASE(mDecoder);

#if defined(USE_XIM) && defined(_AIX)
  if (mUnichars) {
    delete[] mUnichars;
    mUnichars = nsnull;
  }
#endif
}

Definition at line 83 of file nsGtkIMEHelper.cpp.

{
  MOZ_COUNT_CTOR(nsGtkIMEHelper);
  SetupUnicodeDecoder(); 

#if defined(USE_XIM) && defined (_AIX)
  mUnicharsSize = 2;
  mUnichars = new PRUnichar[mUnicharsSize];
#endif
}

Here is the caller graph for this function:


Member Function Documentation

nsresult nsGtkIMEHelper::ConvertToUnicode ( const char *  aSrc,
PRInt32 aSrcLen,
PRUnichar aDes,
PRInt32 aDesLen 
)

Definition at line 107 of file nsGtkIMEHelper.cpp.

{
  NS_ASSERTION(mDecoder, "do not have mDecoder");
  if(! mDecoder)
     return NS_ERROR_ABORT;
  return mDecoder->Convert(aSrc, aSrcLen, aDest, aDestLen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 65 of file nsGtkIMEHelper.cpp.

{
  if(! gSingleton)
    gSingleton = new nsGtkIMEHelper();
  NS_ASSERTION(gSingleton, "do not have singleton");
  return gSingleton;  
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsGtkIMEHelper::MultiByteToUnicode ( const char *  aMbSrc,
const PRInt32  aMbSrcLen,
PRUnichar **  aUniDes,
PRInt32 aUniDesLen 
)

Definition at line 150 of file nsGtkIMEHelper.cpp.

{
  nsresult res;
  PRInt32 srcLeft;
  PRUnichar *uniCharLeft;
  PRInt32 uniCharSize = 0;

  if (nsGtkIMEHelper::GetSingleton()) {
    if (!*aUniDes || *aUniDesLen == 0) {
      *aUniDesLen = 128;
      *aUniDes = new PRUnichar[*aUniDesLen];
    }
    for (;;) {
      if (*aUniDes == nsnull) {
        uniCharSize = 0;
        break;
      }
      uniCharLeft = *aUniDes;
      uniCharSize = *aUniDesLen - 1;
      srcLeft = aMbSrcLen;
      res = nsGtkIMEHelper::GetSingleton()->ConvertToUnicode(
                     (char *)aMbSrc, &srcLeft, uniCharLeft, &uniCharSize);
      if (NS_ERROR_ABORT == res) {
        uniCharSize = 0;
        break;
      }
      if (srcLeft == aMbSrcLen && uniCharSize < *aUniDesLen - 1) {
        break;
      }
      nsGtkIMEHelper::GetSingleton()->ResetDecoder();
      *aUniDesLen += 32;
      if (aUniDes) {
        delete[] *aUniDes;
      }
      *aUniDes = new PRUnichar[*aUniDesLen];
    }
  }
  return uniCharSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file nsGtkIMEHelper.cpp.

{
  NS_ASSERTION(mDecoder, "do not have mDecoder");
  if(mDecoder) {
    mDecoder->Reset();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 126 of file nsGtkIMEHelper.cpp.

{
  mDecoder = nsnull;
  nsresult result = NS_ERROR_FAILURE;
  nsCOMPtr<nsIPlatformCharset> platform = 
           do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &result);
  if (platform && NS_SUCCEEDED(result)) {
    nsCAutoString charset;
    charset.Truncate();
    result = platform->GetCharset(kPlatformCharsetSel_Menu, charset);
    if (NS_FAILED(result) || charset.IsEmpty()) {
      charset.AssignLiteral("ISO-8859-1");   // default
    }
    nsICharsetConverterManager* manager = nsnull;
    nsresult res = CallGetService(kCharsetConverterManagerCID, &manager);
    if (manager && NS_SUCCEEDED(res)) {
      manager->GetUnicodeDecoderRaw(charset.get(), &mDecoder);
      NS_RELEASE(manager);
    }
  }
  NS_ASSERTION(mDecoder, "cannot get decoder");
}

Here is the call graph for this function:

Definition at line 73 of file nsGtkIMEHelper.cpp.

{
  if (gSingleton) {
    delete gSingleton;
    gSingleton = nsnull;
  }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 72 of file nsGtkIMEHelper.h.

Definition at line 70 of file nsGtkIMEHelper.h.


The documentation for this class was generated from the following files: