Attachment #218770: Patch the right place this time for bug #334205

View | Details | Raw Unified | Return to bug 334205
Collapse All | Expand All

(-)widget/src/xpwidgets/nsPrimitiveHelpers.cpp (-2 / +2 lines)
Line     Link Here 
 Lines 152-170   nsPrimitiveHelpers :: CreateDataFromPrim Link Here 
152
nsresult
152
nsresult
153
nsPrimitiveHelpers :: ConvertUnicodeToPlatformPlainText ( PRUnichar* inUnicode, PRInt32 inUnicodeLen, 
153
nsPrimitiveHelpers :: ConvertUnicodeToPlatformPlainText ( PRUnichar* inUnicode, PRInt32 inUnicodeLen, 
154
                                                            char** outPlainTextData, PRInt32* outPlainTextLen )
154
                                                            char** outPlainTextData, PRInt32* outPlainTextLen )
155
{
155
{
156
  if ( !outPlainTextData || !outPlainTextLen )
156
  if ( !outPlainTextData || !outPlainTextLen )
157
    return NS_ERROR_INVALID_ARG;
157
    return NS_ERROR_INVALID_ARG;
158
158
159
  // Get the appropriate unicode encoder. We're guaranteed that this won't change
159
  // Get the appropriate unicode encoder. We're guaranteed that this won't change
160
  // through the life of the app so we can cache it.
160
  // through the life of the app so we can cache it.
161
  nsresult rv;
161
  nsresult rv = NS_OK;
162
  nsCOMPtr<nsIUnicodeEncoder> encoder;
162
  nsCOMPtr<nsIUnicodeEncoder> encoder;
163
163
164
  // get the charset
164
  // get the charset
165
  nsCAutoString platformCharset;
165
  nsCAutoString platformCharset;
166
  nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
166
  nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
167
  if (NS_SUCCEEDED(rv))
167
  if (NS_SUCCEEDED(rv))
168
    rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset);
168
    rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset);
169
  if (NS_FAILED(rv))
169
  if (NS_FAILED(rv))
170
    platformCharset.AssignLiteral("ISO-8859-1");
170
    platformCharset.AssignLiteral("ISO-8859-1");
 Lines 201-219   nsPrimitiveHelpers :: ConvertUnicodeToPl Link Here 
201
nsresult
201
nsresult
202
nsPrimitiveHelpers :: ConvertPlatformPlainTextToUnicode ( const char* inText, PRInt32 inTextLen, 
202
nsPrimitiveHelpers :: ConvertPlatformPlainTextToUnicode ( const char* inText, PRInt32 inTextLen, 
203
                                                            PRUnichar** outUnicode, PRInt32* outUnicodeLen )
203
                                                            PRUnichar** outUnicode, PRInt32* outUnicodeLen )
204
{
204
{
205
  if ( !outUnicode || !outUnicodeLen )
205
  if ( !outUnicode || !outUnicodeLen )
206
    return NS_ERROR_INVALID_ARG;
206
    return NS_ERROR_INVALID_ARG;
207
207
208
  // Get the appropriate unicode decoder. We're guaranteed that this won't change
208
  // Get the appropriate unicode decoder. We're guaranteed that this won't change
209
  // through the life of the app so we can cache it.
209
  // through the life of the app so we can cache it.
210
  nsresult rv;
210
  nsresult rv = NS_OK;
211
  static nsCOMPtr<nsIUnicodeDecoder> decoder;
211
  static nsCOMPtr<nsIUnicodeDecoder> decoder;
212
  static PRBool hasConverter = PR_FALSE;
212
  static PRBool hasConverter = PR_FALSE;
213
  if ( !hasConverter ) {
213
  if ( !hasConverter ) {
214
    // get the charset
214
    // get the charset
215
    nsCAutoString platformCharset;
215
    nsCAutoString platformCharset;
216
    nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
216
    nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
217
    if (NS_SUCCEEDED(rv))
217
    if (NS_SUCCEEDED(rv))
218
      rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset);
218
      rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset);
219
    if (NS_FAILED(rv))
219
    if (NS_FAILED(rv))

Return to bug 334205