Back out my last changes for the mach-o build problem.

This commit is contained in:
nhotta%netscape.com 2002-07-17 00:38:33 +00:00
Родитель 2991ec4e20
Коммит c100b503d1
2 изменённых файлов: 32 добавлений и 133 удалений

Просмотреть файл

@ -60,13 +60,9 @@
#include "nsPrimitiveHelpers.h"
#include "nsIImageMac.h"
#include "nsMemory.h"
#include "nsMacNativeUnicodeConverter.h"
#include "nsICharsetConverterManager.h"
#include "nsCRT.h"
#include <Scrap.h>
#include <Script.h>
#include <TextEdit.h>
@ -156,22 +152,8 @@ nsClipboard :: SetNativeClipboardData ( PRInt32 aWhichClipboard )
char* plainTextData = nsnull;
PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*, data);
PRInt32 plainTextLen = 0;
errCode = nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText ( castedUnicode, dataSize / 2, &plainTextData, &plainTextLen );
// if characters are not mapped from Unicode then try native API to convert to
// available script
if (errCode == NS_ERROR_UENC_NOMAPPING) {
if (plainTextData) {
nsMemory::Free(plainTextData);
plainTextData = nsnull;
}
errCode = nsMacNativeUnicodeConverter::ConvertUnicodetoScript(castedUnicode,
dataSize / 2,
&plainTextData,
&plainTextLen);
}
if ( NS_SUCCEEDED(errCode) && plainTextData ) {
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText ( castedUnicode, dataSize / 2, &plainTextData, &plainTextLen );
if ( plainTextData ) {
errCode = PutOnClipboard ( 'TEXT', plainTextData, plainTextLen );
nsMemory::Free ( plainTextData );
}
@ -307,55 +289,21 @@ nsClipboard :: GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32
// if we are looking for text/unicode and we fail to find it on the clipboard first,
// try again with text/plain. If that is present, convert it to unicode.
if ( strcmp(flavorStr, kUnicodeMime) == 0 ) {
// if 'styl' is available, we can get a script of the first run
// and use it for converting 'TEXT'
loadResult = GetDataOffClipboard ( 'styl', &clipboardData, &dataSize );
if (NS_SUCCEEDED(loadResult) &&
clipboardData &&
(dataSize >= (sizeof(ScrpSTElement) + 2))) {
StScrpRec *scrpRecP = (StScrpRec *) clipboardData;
ScrpSTElement *styl = scrpRecP->scrpStyleTab;
ScriptCode script = styl ? ::FontToScript(styl->scrpFont) : smCurrentScript;
// free 'styl' and get 'TEXT'
nsMemory::Free(clipboardData);
loadResult = GetDataOffClipboard ( 'TEXT', &clipboardData, &dataSize );
if ( NS_SUCCEEDED(loadResult) && clipboardData ) {
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
errCode = nsMacNativeUnicodeConverter::ConvertScripttoUnicode(
script,
(const char *) clipboardData,
dataSize,
&convertedText,
&convertedTextLen);
if (NS_SUCCEEDED(errCode) && convertedText) {
nsMemory::Free(clipboardData);
clipboardData = convertedText;
dataSize = convertedTextLen * sizeof(PRUnichar);
dataFound = PR_TRUE;
}
loadResult = GetDataOffClipboard ( 'TEXT', &clipboardData, &dataSize );
if ( NS_SUCCEEDED(loadResult) && clipboardData ) {
const char* castedText = NS_REINTERPRET_CAST(char*, clipboardData);
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode ( castedText, dataSize,
&convertedText, &convertedTextLen );
if ( convertedText ) {
// out with the old, in with the new
nsMemory::Free(clipboardData);
clipboardData = convertedText;
dataSize = convertedTextLen * 2;
dataFound = PR_TRUE;
}
}
if (!dataFound) {
loadResult = GetDataOffClipboard ( 'TEXT', &clipboardData, &dataSize );
if ( NS_SUCCEEDED(loadResult) && clipboardData ) {
const char* castedText = NS_REINTERPRET_CAST(char*, clipboardData);
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode ( castedText, dataSize,
&convertedText, &convertedTextLen );
if ( convertedText ) {
// out with the old, in with the new
nsMemory::Free(clipboardData);
clipboardData = convertedText;
dataSize = convertedTextLen * 2;
dataFound = PR_TRUE;
}
} // if plain text data on clipboard
}
} // if plain text data on clipboard
} // if looking for text/unicode
} // else we try one last ditch effort to find our data

Просмотреть файл

@ -80,8 +80,6 @@
#include "nsIDOMElement.h"
#include "nsIImageMac.h"
#include "nsIImage.h"
#include "nsMacNativeUnicodeConverter.h"
#include "nsICharsetConverterManager.h"
// we need our own stuff for MacOS because of nsIDragSessionMac.
@ -497,55 +495,22 @@ printf("looking for data in type %s, mac flavor %ld\n", NS_STATIC_CAST(const cha
// if we are looking for text/unicode and we fail to find it on the clipboard first,
// try again with text/plain. If that is present, convert it to unicode.
if ( strcmp(flavorStr, kUnicodeMime) == 0 ) {
if ( ::GetFlavorFlags(mDragRef, itemRef, 'TEXT', &unused) == noErr ) {
// if 'styl' is available, we can get a script of the first run
// and use it for converting 'TEXT'
nsresult loadResult = ExtractDataFromOS(mDragRef, itemRef, 'styl', &dataBuff, &dataSize);
if (NS_SUCCEEDED(loadResult) &&
dataBuff &&
(dataSize >= (sizeof(ScrpSTElement) + 2))) {
StScrpRec *scrpRecP = (StScrpRec *) dataBuff;
ScrpSTElement *styl = scrpRecP->scrpStyleTab;
ScriptCode script = styl ? ::FontToScript(styl->scrpFont) : smCurrentScript;
// free 'styl' and get 'TEXT'
nsMemory::Free(dataBuff);
loadResult = ExtractDataFromOS(mDragRef, itemRef, 'TEXT', &dataBuff, &dataSize);
if ( NS_SUCCEEDED(loadResult) && dataBuff ) {
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
errCode = nsMacNativeUnicodeConverter::ConvertScripttoUnicode(script,
(const char *) dataBuff,
dataSize,
&convertedText,
&convertedTextLen);
if (NS_SUCCEEDED(errCode) && convertedText) {
nsMemory::Free(dataBuff);
dataBuff = convertedText;
dataSize = convertedTextLen * sizeof(PRUnichar);
dataFound = PR_TRUE;
}
if ( ::GetFlavorFlags(mDragRef, itemRef, 'TEXT', &unused) == noErr ) {
nsresult loadResult = ExtractDataFromOS(mDragRef, itemRef, 'TEXT', &dataBuff, &dataSize);
if ( NS_SUCCEEDED(loadResult) && dataBuff ) {
const char* castedText = NS_REINTERPRET_CAST(char*, dataBuff);
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode ( castedText, dataSize,
&convertedText, &convertedTextLen );
if ( convertedText ) {
// out with the old, in with the new
nsMemory::Free(dataBuff);
dataBuff = convertedText;
dataSize = convertedTextLen * 2;
dataFound = PR_TRUE;
}
}
if (!dataFound) {
loadResult = ExtractDataFromOS(mDragRef, itemRef, 'TEXT', &dataBuff, &dataSize);
if ( NS_SUCCEEDED(loadResult) && dataBuff ) {
const char* castedText = NS_REINTERPRET_CAST(char*, dataBuff);
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode ( castedText, dataSize,
&convertedText, &convertedTextLen );
if ( convertedText ) {
// out with the old, in with the new
nsMemory::Free(dataBuff);
dataBuff = convertedText;
dataSize = convertedTextLen * 2;
dataFound = PR_TRUE;
}
} // if plain text data on clipboard
}
} // if plain text data on clipboard
} // if plain text flavor present
} // if looking for text/unicode
} // else we try one last ditch effort to find our data
@ -800,22 +765,8 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
char* plainTextData = nsnull;
PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*, *outData);
PRInt32 plainTextLen = 0;
nsresult rv =
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText ( castedUnicode, *outDataSize / 2, &plainTextData, &plainTextLen );
// if characters are not mapped from Unicode then try native API to convert to
// available script
if (rv == NS_ERROR_UENC_NOMAPPING) {
if (plainTextData) {
nsMemory::Free(plainTextData);
plainTextData = nsnull;
}
rv = nsMacNativeUnicodeConverter::ConvertUnicodetoScript(castedUnicode,
*outDataSize / sizeof(PRUnichar),
&plainTextData,
&plainTextLen);
}
if ( plainTextData && *outData ) {
if ( *outData ) {
nsMemory::Free(*outData);
*outData = plainTextData;
*outDataSize = plainTextLen;